peachsim 0.1.796 → 0.1.798
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/cloud-test-tunnel.ts +1 -1
- package/cli/outbound-endpoints.ts +6 -1
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +383 -346
- 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 +356 -326
- 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 +679 -565
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +401 -178
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +1 -1
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +85 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +976 -842
- package/dist-lib/swift-compile.cjs +30 -5
- package/dist-lib/swift-compile.mjs +29 -5
- 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 +415 -358
- 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 +31 -5
- 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.798 | (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) {
|
|
@@ -2028,9 +2028,18 @@ var SPRITEKIT_PRODUCT = '.product(name: "SpriteKit", package: "sootsim-swift")';
|
|
|
2028
2028
|
var importsSpriteKit = (files2) => Object.entries(files2).some(
|
|
2029
2029
|
([file, contents]) => file.endsWith(".swift") && swiftImportNames(contents).includes("SpriteKit")
|
|
2030
2030
|
);
|
|
2031
|
-
var
|
|
2031
|
+
var FOUNDATION_IMPLICIT_MODULES = [
|
|
2032
|
+
"PeachObjC",
|
|
2033
|
+
"Dispatch",
|
|
2034
|
+
"FoundationNetworking",
|
|
2035
|
+
"WASILibc",
|
|
2036
|
+
"wasi_pthread"
|
|
2037
|
+
];
|
|
2038
|
+
var FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
|
|
2039
|
+
(module2) => `, "-Xfrontend", "-import-module", "-Xfrontend", "${module2}"`
|
|
2040
|
+
).join("");
|
|
2032
2041
|
var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
|
|
2033
|
-
var MULTI_MANIFEST_VERSION =
|
|
2042
|
+
var MULTI_MANIFEST_VERSION = 12;
|
|
2034
2043
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
2035
2044
|
const hash = (0, import_node_crypto2.createHash)("sha256");
|
|
2036
2045
|
hash.update(`swift-compile/v18
|
|
@@ -2081,8 +2090,12 @@ function emitSwiftPackageManifest(args) {
|
|
|
2081
2090
|
(name2) => OPTIONAL_FRAMEWORKS.has(name2) && !targets.some((target) => target.name === name2)
|
|
2082
2091
|
).flatMap((name2) => [name2, ...OPTIONAL_FRAMEWORK_DEPENDENCIES[name2] ?? []])
|
|
2083
2092
|
);
|
|
2093
|
+
if (spriteKit) {
|
|
2094
|
+
reachedFrameworks.add("SpriteKit");
|
|
2095
|
+
reachedFrameworks.add("PeachBox2D");
|
|
2096
|
+
}
|
|
2084
2097
|
const distributionObjects = distribution?.objects.filter(
|
|
2085
|
-
(object) => [...OPTIONAL_FRAMEWORKS].every(
|
|
2098
|
+
(object) => [...OPTIONAL_FRAMEWORKS, "SpriteKit", "PeachBox2D"].every(
|
|
2086
2099
|
(name2) => !object.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
|
|
2087
2100
|
)
|
|
2088
2101
|
);
|
|
@@ -3209,7 +3222,17 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
3209
3222
|
])
|
|
3210
3223
|
],
|
|
3211
3224
|
{
|
|
3212
|
-
env:
|
|
3225
|
+
env: {
|
|
3226
|
+
...BUILD_ENV,
|
|
3227
|
+
// shipped host plugins resolve against the selected compiler's runtime.
|
|
3228
|
+
...process.platform === "linux" ? {
|
|
3229
|
+
LD_LIBRARY_PATH: [
|
|
3230
|
+
import_node_path2.default.resolve(options.toolchainBin, "../lib/swift/linux"),
|
|
3231
|
+
import_node_path2.default.resolve(options.toolchainBin, "../lib/swift/host"),
|
|
3232
|
+
process.env.LD_LIBRARY_PATH
|
|
3233
|
+
].filter(Boolean).join(":")
|
|
3234
|
+
} : {}
|
|
3235
|
+
},
|
|
3213
3236
|
maxBuffer: 64 * 1024 * 1024,
|
|
3214
3237
|
timeout: options.timeoutMs
|
|
3215
3238
|
}
|
|
@@ -3229,9 +3252,9 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
3229
3252
|
|
|
3230
3253
|
// src/swift-host.ts
|
|
3231
3254
|
var import_node_crypto7 = require("node:crypto");
|
|
3232
|
-
var
|
|
3255
|
+
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
3233
3256
|
var import_node_os8 = __toESM(require("node:os"), 1);
|
|
3234
|
-
var
|
|
3257
|
+
var import_node_path15 = __toESM(require("node:path"), 1);
|
|
3235
3258
|
|
|
3236
3259
|
// ../sootsim-swift/src/bundleAssets.ts
|
|
3237
3260
|
var import_svgpath = __toESM(require("svgpath"), 1);
|
|
@@ -3265,8 +3288,8 @@ function pickImagesetFile(images) {
|
|
|
3265
3288
|
scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
|
|
3266
3289
|
};
|
|
3267
3290
|
}
|
|
3268
|
-
function flatScale(
|
|
3269
|
-
const match = /@([23])x\.[^./]+$/.exec(
|
|
3291
|
+
function flatScale(path18) {
|
|
3292
|
+
const match = /@([23])x\.[^./]+$/.exec(path18);
|
|
3270
3293
|
return match ? Number(match[1]) : 1;
|
|
3271
3294
|
}
|
|
3272
3295
|
function providesNamespace(text3) {
|
|
@@ -3293,13 +3316,13 @@ function catalogEntryName(contentsPath, kind, readText) {
|
|
|
3293
3316
|
}
|
|
3294
3317
|
return segments.join("/");
|
|
3295
3318
|
}
|
|
3296
|
-
function isFlatResourceImage(
|
|
3297
|
-
return
|
|
3319
|
+
function isFlatResourceImage(path18) {
|
|
3320
|
+
return path18.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path18));
|
|
3298
3321
|
}
|
|
3299
3322
|
function enumerateBundleImages(paths, readText) {
|
|
3300
3323
|
const table = [];
|
|
3301
3324
|
const seen = /* @__PURE__ */ new Set();
|
|
3302
|
-
const catalogs = paths.filter((
|
|
3325
|
+
const catalogs = paths.filter((path18) => baseOf(path18) === "Contents.json");
|
|
3303
3326
|
for (const contentsPath of catalogs) {
|
|
3304
3327
|
const name2 = catalogEntryName(contentsPath, ".imageset", readText);
|
|
3305
3328
|
if (name2 === null || seen.has(name2)) continue;
|
|
@@ -3320,12 +3343,12 @@ function enumerateBundleImages(paths, readText) {
|
|
|
3320
3343
|
seen.add(name2);
|
|
3321
3344
|
table.push({ name: name2, file: `${dir}/${pick.filename}`, scale: pick.scale });
|
|
3322
3345
|
}
|
|
3323
|
-
for (const
|
|
3324
|
-
if (!isFlatResourceImage(
|
|
3325
|
-
const name2 = baseOf(
|
|
3346
|
+
for (const path18 of paths) {
|
|
3347
|
+
if (!isFlatResourceImage(path18)) continue;
|
|
3348
|
+
const name2 = baseOf(path18).slice(0, -extOf(path18).length);
|
|
3326
3349
|
if (name2 === "" || seen.has(name2)) continue;
|
|
3327
3350
|
seen.add(name2);
|
|
3328
|
-
table.push({ name: name2, file:
|
|
3351
|
+
table.push({ name: name2, file: path18, scale: flatScale(path18) });
|
|
3329
3352
|
}
|
|
3330
3353
|
return table;
|
|
3331
3354
|
}
|
|
@@ -3354,7 +3377,7 @@ function colorsetValue(color) {
|
|
|
3354
3377
|
}
|
|
3355
3378
|
function enumerateBundleColors(paths, readText) {
|
|
3356
3379
|
const table = {};
|
|
3357
|
-
for (const contentsPath of paths.filter((
|
|
3380
|
+
for (const contentsPath of paths.filter((path18) => baseOf(path18) === "Contents.json")) {
|
|
3358
3381
|
const name2 = catalogEntryName(contentsPath, ".colorset", readText);
|
|
3359
3382
|
if (name2 === null || name2 in table) continue;
|
|
3360
3383
|
let colors;
|
|
@@ -3419,8 +3442,8 @@ function axisExtremes(points) {
|
|
|
3419
3442
|
function pathBounds(d) {
|
|
3420
3443
|
const xs = [];
|
|
3421
3444
|
const ys = [];
|
|
3422
|
-
for (const
|
|
3423
|
-
(0, import_svgpath.default)(
|
|
3445
|
+
for (const path18 of d)
|
|
3446
|
+
(0, import_svgpath.default)(path18).abs().unshort().unarc().iterate((segment, _index, x, y) => {
|
|
3424
3447
|
const [command, ...args] = segment;
|
|
3425
3448
|
if (command === "M" || command === "L") {
|
|
3426
3449
|
xs.push(Number(args[0]));
|
|
@@ -3447,7 +3470,7 @@ function guide(svg, id, axis) {
|
|
|
3447
3470
|
}
|
|
3448
3471
|
function enumerateBundleSymbols(paths, readText) {
|
|
3449
3472
|
const table = {};
|
|
3450
|
-
for (const contentsPath of paths.filter((
|
|
3473
|
+
for (const contentsPath of paths.filter((path18) => baseOf(path18) === "Contents.json")) {
|
|
3451
3474
|
const name2 = catalogEntryName(contentsPath, ".symbolset", readText);
|
|
3452
3475
|
if (name2 === null || name2 in table) continue;
|
|
3453
3476
|
let symbols;
|
|
@@ -3480,8 +3503,8 @@ function enumerateBundleSymbols(paths, readText) {
|
|
|
3480
3503
|
viewBox: "0 0 24 24",
|
|
3481
3504
|
advance,
|
|
3482
3505
|
box: [12 - advance / 2, 12 - tall / 2, advance, tall],
|
|
3483
|
-
layers: d.map((
|
|
3484
|
-
d: (0, import_svgpath.default)(
|
|
3506
|
+
layers: d.map((path18) => ({
|
|
3507
|
+
d: (0, import_svgpath.default)(path18).abs().scale(scale).translate(translateX, translateY).round(3).toString()
|
|
3485
3508
|
}))
|
|
3486
3509
|
};
|
|
3487
3510
|
}
|
|
@@ -3491,7 +3514,7 @@ function enumerateBundleJson(paths) {
|
|
|
3491
3514
|
const found = [];
|
|
3492
3515
|
const seen = /* @__PURE__ */ new Set();
|
|
3493
3516
|
const ordered = [...paths].filter(
|
|
3494
|
-
(
|
|
3517
|
+
(path18) => path18.split("/").includes("Resources") && path18.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path18) === ".json" || extOf(path18) === ".xcstrings")
|
|
3495
3518
|
).sort((a, b) => {
|
|
3496
3519
|
const aDepth = a.split("/").length;
|
|
3497
3520
|
const bDepth = b.split("/").length;
|
|
@@ -4777,15 +4800,60 @@ function resolveSwiftPackages(options) {
|
|
|
4777
4800
|
return result;
|
|
4778
4801
|
}
|
|
4779
4802
|
|
|
4803
|
+
// src/swift-source-file.ts
|
|
4804
|
+
var import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
4805
|
+
var import_node_path11 = __toESM(require("node:path"), 1);
|
|
4806
|
+
function readPackageFile(root, file, maxBytes) {
|
|
4807
|
+
const canonicalRoot = import_node_fs10.default.realpathSync(root);
|
|
4808
|
+
const relative = import_node_path11.default.relative(canonicalRoot, import_node_fs10.default.realpathSync(file));
|
|
4809
|
+
if (relative === ".." || relative.startsWith(`..${import_node_path11.default.sep}`) || import_node_path11.default.isAbsolute(relative)) {
|
|
4810
|
+
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
4811
|
+
}
|
|
4812
|
+
let ancestor = import_node_path11.default.resolve(file);
|
|
4813
|
+
while (ancestor !== canonicalRoot) {
|
|
4814
|
+
if (import_node_fs10.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
4815
|
+
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
4816
|
+
}
|
|
4817
|
+
const parent = import_node_path11.default.dirname(ancestor);
|
|
4818
|
+
if (parent === ancestor)
|
|
4819
|
+
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
4820
|
+
ancestor = parent;
|
|
4821
|
+
}
|
|
4822
|
+
const expected = import_node_fs10.default.statSync(file);
|
|
4823
|
+
const fd = import_node_fs10.default.openSync(file, import_node_fs10.default.constants.O_RDONLY | import_node_fs10.default.constants.O_NOFOLLOW);
|
|
4824
|
+
try {
|
|
4825
|
+
const stat = import_node_fs10.default.fstatSync(fd);
|
|
4826
|
+
if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
|
|
4827
|
+
throw new Error(`swift input changed while opening: ${file}`);
|
|
4828
|
+
}
|
|
4829
|
+
if (!stat.isFile() || stat.size > maxBytes) {
|
|
4830
|
+
throw new Error(`swift input exceeds ${maxBytes} bytes: ${file}`);
|
|
4831
|
+
}
|
|
4832
|
+
const bytes = Buffer.alloc(stat.size + 1);
|
|
4833
|
+
let offset = 0;
|
|
4834
|
+
while (offset < bytes.length) {
|
|
4835
|
+
const count = import_node_fs10.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
4836
|
+
if (count === 0) break;
|
|
4837
|
+
offset += count;
|
|
4838
|
+
}
|
|
4839
|
+
if (offset !== stat.size || import_node_fs10.default.fstatSync(fd).size !== stat.size) {
|
|
4840
|
+
throw new Error(`swift input changed while reading: ${file}`);
|
|
4841
|
+
}
|
|
4842
|
+
return bytes.subarray(0, offset);
|
|
4843
|
+
} finally {
|
|
4844
|
+
import_node_fs10.default.closeSync(fd);
|
|
4845
|
+
}
|
|
4846
|
+
}
|
|
4847
|
+
|
|
4780
4848
|
// src/swift-standins.ts
|
|
4781
4849
|
var import_node_child_process7 = require("node:child_process");
|
|
4782
4850
|
var import_node_crypto6 = require("node:crypto");
|
|
4783
|
-
var
|
|
4851
|
+
var import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
4784
4852
|
var import_node_os7 = __toESM(require("node:os"), 1);
|
|
4785
|
-
var
|
|
4853
|
+
var import_node_path12 = __toESM(require("node:path"), 1);
|
|
4786
4854
|
|
|
4787
4855
|
// src/cli-version.ts
|
|
4788
|
-
var
|
|
4856
|
+
var import_node_fs11 = require("node:fs");
|
|
4789
4857
|
var import_node_url = require("node:url");
|
|
4790
4858
|
|
|
4791
4859
|
// src/public-brand.ts
|
|
@@ -4814,7 +4882,7 @@ function getCliVersion() {
|
|
|
4814
4882
|
];
|
|
4815
4883
|
for (const resolve2 of candidates) {
|
|
4816
4884
|
try {
|
|
4817
|
-
const version = JSON.parse((0,
|
|
4885
|
+
const version = JSON.parse((0, import_node_fs11.readFileSync)(resolve2(), "utf8")).version;
|
|
4818
4886
|
if (typeof version === "string" && version) {
|
|
4819
4887
|
cached = version;
|
|
4820
4888
|
return cached;
|
|
@@ -4884,7 +4952,7 @@ var witnessKey = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.")
|
|
|
4884
4952
|
var sideLeaf = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.") ? "type" : "instance"}|leaf|${leaf(symbol)}`;
|
|
4885
4953
|
var isObjC = (symbol) => symbol.identifier.precise.startsWith("c:");
|
|
4886
4954
|
var synthesizedEquality = (symbol, conforms) => conforms.includes("Hashable") ? ["==(_:_:)", "hash(into:)", "hashValue"].includes(leaf(symbol)) : conforms.includes("Equatable") && leaf(symbol) === "==(_:_:)";
|
|
4887
|
-
var trap = (
|
|
4955
|
+
var trap = (path18) => `fatalError("${path18} is a binary framework peach cannot run")`;
|
|
4888
4956
|
function emitSwiftStandin(graphs, options) {
|
|
4889
4957
|
const skipped = [];
|
|
4890
4958
|
const behavior = options.behavior ?? /* @__PURE__ */ new Map();
|
|
@@ -5021,10 +5089,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5021
5089
|
owners.push(...physical.map(() => current));
|
|
5022
5090
|
};
|
|
5023
5091
|
const scoped = (body) => (symbol, ...rest) => {
|
|
5024
|
-
const
|
|
5025
|
-
if (omit.has(
|
|
5092
|
+
const path18 = pathOf(symbol);
|
|
5093
|
+
if (omit.has(path18)) return void skipped.push({ path: path18, reason: omit.get(path18) });
|
|
5026
5094
|
const previous = current;
|
|
5027
|
-
current =
|
|
5095
|
+
current = path18;
|
|
5028
5096
|
try {
|
|
5029
5097
|
body(symbol, ...rest);
|
|
5030
5098
|
} finally {
|
|
@@ -5044,14 +5112,14 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5044
5112
|
const access = (symbol, openOwner) => symbol.accessLevel === "open" && openOwner ? "open" : "public";
|
|
5045
5113
|
const emitMember = scoped(
|
|
5046
5114
|
(member, indent, context) => {
|
|
5047
|
-
const
|
|
5115
|
+
const path18 = pathOf(member);
|
|
5048
5116
|
if (TYPE_KINDS.has(member.kind.identifier)) {
|
|
5049
5117
|
emitType(member, indent);
|
|
5050
5118
|
return;
|
|
5051
5119
|
}
|
|
5052
5120
|
if (member.kind.identifier === "swift.enum.case") return;
|
|
5053
5121
|
if (!MEMBER_KINDS.has(member.kind.identifier)) {
|
|
5054
|
-
skipped.push({ path:
|
|
5122
|
+
skipped.push({ path: path18, reason: `unhandled ${member.kind.identifier}` });
|
|
5055
5123
|
return;
|
|
5056
5124
|
}
|
|
5057
5125
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
@@ -5065,12 +5133,12 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5065
5133
|
const final = context.inClass && flags.has("final") ? "final " : "";
|
|
5066
5134
|
const mutating = flags.has("mutating") ? "mutating " : flags.has("nonmutating") ? "nonmutating " : "";
|
|
5067
5135
|
let core = `${flags.has("convenience") ? "convenience " : ""}${modifiers[2]}`;
|
|
5068
|
-
const override = context.inClass && !options.plain?.has(
|
|
5136
|
+
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
5137
|
const head = `${indent}${attrs}${access(member, context.openOwner)} ${required ? "required " : ""}${final}${override}${mutating}`;
|
|
5070
|
-
const measured = behavior.get(
|
|
5071
|
-
if (measured) used.add(
|
|
5138
|
+
const measured = behavior.get(path18);
|
|
5139
|
+
if (measured) used.add(path18);
|
|
5072
5140
|
const overloadBody = /\basync\b/.test(core) ? measured?.asyncBody : /\bResult</.test(core) ? measured?.resultBody : void 0;
|
|
5073
|
-
const body = overloadBody ?? measured?.body ?? trap(
|
|
5141
|
+
const body = overloadBody ?? measured?.body ?? trap(path18);
|
|
5074
5142
|
switch (member.kind.identifier) {
|
|
5075
5143
|
case "swift.property":
|
|
5076
5144
|
case "swift.type.property":
|
|
@@ -5091,7 +5159,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5091
5159
|
return;
|
|
5092
5160
|
}
|
|
5093
5161
|
emit(
|
|
5094
|
-
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` ${parsed.nonmutating ? "nonmutating " : ""}set { ${measured?.set ?? trap(
|
|
5162
|
+
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` ${parsed.nonmutating ? "nonmutating " : ""}set { ${measured?.set ?? trap(path18)} }` : ""} }`
|
|
5095
5163
|
);
|
|
5096
5164
|
return;
|
|
5097
5165
|
}
|
|
@@ -5144,7 +5212,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5144
5212
|
};
|
|
5145
5213
|
const emitType = scoped(
|
|
5146
5214
|
(symbol, indent) => {
|
|
5147
|
-
const
|
|
5215
|
+
const path18 = pathOf(symbol);
|
|
5148
5216
|
const id = symbol.identifier.precise;
|
|
5149
5217
|
const inner = `${indent} `;
|
|
5150
5218
|
switch (symbol.kind.identifier) {
|
|
@@ -5156,10 +5224,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5156
5224
|
case "swift.class": {
|
|
5157
5225
|
const shape = header(symbol, "class", indent);
|
|
5158
5226
|
if (!shape)
|
|
5159
|
-
return void skipped.push({ path:
|
|
5160
|
-
const parent = options.superclasses?.get(
|
|
5227
|
+
return void skipped.push({ path: path18, reason: `unparsed class ${text(symbol)}` });
|
|
5228
|
+
const parent = options.superclasses?.get(path18) ?? superclass.get(id);
|
|
5161
5229
|
const blocked = classBlocked(id);
|
|
5162
|
-
if (blocked) return void skipped.push({ path:
|
|
5230
|
+
if (blocked) return void skipped.push({ path: path18, reason: blocked });
|
|
5163
5231
|
const ancestors = /* @__PURE__ */ new Set();
|
|
5164
5232
|
for (let at = superId.get(id); at; at = superId.get(at))
|
|
5165
5233
|
for (const name2 of conforms.get(at) ?? []) ancestors.add(name2);
|
|
@@ -5175,9 +5243,9 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5175
5243
|
`${indent}${shape.attrs}${open ? "open" : "public"} class ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${selfConforming(shape.where)} {`
|
|
5176
5244
|
);
|
|
5177
5245
|
const members = membersOf(id);
|
|
5178
|
-
const extra = options.behavior?.get(
|
|
5246
|
+
const extra = options.behavior?.get(path18)?.members;
|
|
5179
5247
|
if (extra) {
|
|
5180
|
-
used.add(
|
|
5248
|
+
used.add(path18);
|
|
5181
5249
|
emit(`${inner}${extra}`);
|
|
5182
5250
|
}
|
|
5183
5251
|
for (const member of members)
|
|
@@ -5230,13 +5298,13 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5230
5298
|
continue;
|
|
5231
5299
|
have.add(witnessKey(member));
|
|
5232
5300
|
have.add(sideLeaf(member));
|
|
5233
|
-
emitWitness(member, inner,
|
|
5301
|
+
emitWitness(member, inner, path18);
|
|
5234
5302
|
}
|
|
5235
5303
|
}
|
|
5236
5304
|
const coder = members.some((member) => leaf(member) === "init(coder:)");
|
|
5237
5305
|
if (designated && !coder && externalRoot(id) !== "NSObject" && externalRoot(id) !== null)
|
|
5238
5306
|
emit(
|
|
5239
|
-
`${inner}public required init?(coder: NSCoder) { ${trap(`${
|
|
5307
|
+
`${inner}public required init?(coder: NSCoder) { ${trap(`${path18}.init(coder:)`)} }`
|
|
5240
5308
|
);
|
|
5241
5309
|
emit(`${indent}}`);
|
|
5242
5310
|
return;
|
|
@@ -5244,7 +5312,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5244
5312
|
case "swift.struct": {
|
|
5245
5313
|
const shape = header(symbol, "struct", indent);
|
|
5246
5314
|
if (!shape)
|
|
5247
|
-
return void skipped.push({ path:
|
|
5315
|
+
return void skipped.push({ path: path18, reason: `unparsed struct ${text(symbol)}` });
|
|
5248
5316
|
const members = membersOf(id);
|
|
5249
5317
|
const raw2 = rawType(members);
|
|
5250
5318
|
const list2 = inheritance(id);
|
|
@@ -5295,7 +5363,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5295
5363
|
case "swift.enum": {
|
|
5296
5364
|
const shape = header(symbol, "enum", indent);
|
|
5297
5365
|
if (!shape)
|
|
5298
|
-
return void skipped.push({ path:
|
|
5366
|
+
return void skipped.push({ path: path18, reason: `unparsed enum ${text(symbol)}` });
|
|
5299
5367
|
const members = membersOf(id);
|
|
5300
5368
|
const raw2 = rawType(members);
|
|
5301
5369
|
const cases = (children.get(id) ?? []).filter(
|
|
@@ -5304,7 +5372,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5304
5372
|
const missing = raw2 ? cases.filter((member) => !values.has(member.identifier.precise)) : [];
|
|
5305
5373
|
if (raw2 && isObjC(symbol) && missing.length > 0)
|
|
5306
5374
|
return void skipped.push({
|
|
5307
|
-
path:
|
|
5375
|
+
path: path18,
|
|
5308
5376
|
reason: `no header value for ${missing.map(leaf).join(", ")}`
|
|
5309
5377
|
});
|
|
5310
5378
|
const list2 = inheritance(id, raw2 ?? void 0).filter(
|
|
@@ -5345,7 +5413,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5345
5413
|
const shape = header(symbol, "protocol", indent);
|
|
5346
5414
|
if (!shape)
|
|
5347
5415
|
return void skipped.push({
|
|
5348
|
-
path:
|
|
5416
|
+
path: path18,
|
|
5349
5417
|
reason: `unparsed protocol ${text(symbol)}`
|
|
5350
5418
|
});
|
|
5351
5419
|
const list2 = [...isObjC(symbol) ? ["AnyObject"] : [], ...inheritance(id)];
|
|
@@ -5370,7 +5438,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5370
5438
|
}
|
|
5371
5439
|
emit(`${indent}}`);
|
|
5372
5440
|
if (defaults.length > 0) {
|
|
5373
|
-
emit(`${indent}extension ${
|
|
5441
|
+
emit(`${indent}extension ${path18} {`);
|
|
5374
5442
|
for (const member of defaults) {
|
|
5375
5443
|
const decl = text(member);
|
|
5376
5444
|
if (optional.has(member.identifier.precise) && member.kind.identifier === "swift.method" && !decl.replace(/\([^)]*\)/g, "").includes("->") && !/ async\b/.test(decl))
|
|
@@ -5417,7 +5485,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5417
5485
|
return init ? /rawValue:\s*([^)]+)\)/.exec(text(init))?.[1]?.trim() ?? null : null;
|
|
5418
5486
|
};
|
|
5419
5487
|
const emitGlobal = scoped((symbol) => {
|
|
5420
|
-
const
|
|
5488
|
+
const path18 = pathOf(symbol);
|
|
5421
5489
|
const kind = symbol.kind.identifier;
|
|
5422
5490
|
if (kind === "swift.func" || kind === "swift.func.op" || kind === "swift.method" || kind === "swift.type.method") {
|
|
5423
5491
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
@@ -5428,17 +5496,17 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5428
5496
|
if (fix && !/^(?:prefix|infix|postfix)\b/.test(spelled))
|
|
5429
5497
|
spelled = `${fix} ${spelled}`;
|
|
5430
5498
|
}
|
|
5431
|
-
emit(`${attrs}public ${spelled} { ${trap(
|
|
5499
|
+
emit(`${attrs}public ${spelled} { ${trap(path18)} }`);
|
|
5432
5500
|
} else if (kind === "swift.var") {
|
|
5433
5501
|
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:
|
|
5502
|
+
const measured = behavior.get(path18);
|
|
5503
|
+
if (measured) used.add(path18);
|
|
5504
|
+
emit(`public ${parsed.decl} { ${measured?.body ?? trap(path18)} }`);
|
|
5505
|
+
} else skipped.push({ path: path18, reason: `unhandled top-level ${kind}` });
|
|
5438
5506
|
});
|
|
5439
5507
|
const roots = [...byId.values()].filter((symbol) => !owner.has(symbol.identifier.precise) && !unavailable(symbol)).sort((a, b) => pathOf(a).localeCompare(pathOf(b)));
|
|
5440
5508
|
for (const symbol of roots) {
|
|
5441
|
-
const
|
|
5509
|
+
const path18 = pathOf(symbol);
|
|
5442
5510
|
if (TYPE_KINDS.has(symbol.kind.identifier)) emitType(symbol, "");
|
|
5443
5511
|
else emitGlobal(symbol);
|
|
5444
5512
|
}
|
|
@@ -5480,9 +5548,9 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5480
5548
|
...imports.map((name2) => `import ${name2}`),
|
|
5481
5549
|
""
|
|
5482
5550
|
];
|
|
5483
|
-
for (const
|
|
5484
|
-
if (!used.has(
|
|
5485
|
-
skipped.push({ path:
|
|
5551
|
+
for (const path18 of behavior.keys())
|
|
5552
|
+
if (!used.has(path18))
|
|
5553
|
+
skipped.push({ path: path18, reason: "behavior names no emitted declaration" });
|
|
5486
5554
|
return {
|
|
5487
5555
|
source: `${[...banner, ...lines].join("\n")}
|
|
5488
5556
|
`,
|
|
@@ -5557,7 +5625,7 @@ function stripDefaults(decl) {
|
|
|
5557
5625
|
|
|
5558
5626
|
// src/swift-standins.ts
|
|
5559
5627
|
var TRIPLE = "wasm32-unknown-wasip1";
|
|
5560
|
-
var cacheDir3 =
|
|
5628
|
+
var cacheDir3 = import_node_path12.default.join(import_node_os7.default.tmpdir(), "peach-swift-standins");
|
|
5561
5629
|
function exec(file, args, cwd) {
|
|
5562
5630
|
return (0, import_node_child_process7.execFileSync)(file, args, {
|
|
5563
5631
|
cwd,
|
|
@@ -5577,15 +5645,15 @@ var digests = /* @__PURE__ */ new Map();
|
|
|
5577
5645
|
function treeDigest(root) {
|
|
5578
5646
|
const names = [];
|
|
5579
5647
|
const walk2 = (dir) => {
|
|
5580
|
-
for (const entry of
|
|
5581
|
-
const full =
|
|
5648
|
+
for (const entry of import_node_fs12.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name < right.name ? -1 : 1)) {
|
|
5649
|
+
const full = import_node_path12.default.join(dir, entry.name);
|
|
5582
5650
|
if (entry.isDirectory()) walk2(full);
|
|
5583
|
-
else if (entry.isFile()) names.push(
|
|
5651
|
+
else if (entry.isFile()) names.push(import_node_path12.default.relative(root, full));
|
|
5584
5652
|
}
|
|
5585
5653
|
};
|
|
5586
5654
|
walk2(root);
|
|
5587
5655
|
const stamp = names.map((name2) => {
|
|
5588
|
-
const stat =
|
|
5656
|
+
const stat = import_node_fs12.default.statSync(import_node_path12.default.join(root, name2));
|
|
5589
5657
|
return `${name2}\0${stat.size}:${stat.mtimeMs}`;
|
|
5590
5658
|
}).join("\n");
|
|
5591
5659
|
const memo2 = digests.get(`tree\0${root}`);
|
|
@@ -5593,7 +5661,7 @@ function treeDigest(root) {
|
|
|
5593
5661
|
const hash = (0, import_node_crypto6.createHash)("sha256");
|
|
5594
5662
|
for (const name2 of names) {
|
|
5595
5663
|
hash.update(`${name2}\0`);
|
|
5596
|
-
hash.update(
|
|
5664
|
+
hash.update(import_node_fs12.default.readFileSync(import_node_path12.default.join(root, name2)));
|
|
5597
5665
|
hash.update("\0");
|
|
5598
5666
|
}
|
|
5599
5667
|
const digest = hash.digest("hex");
|
|
@@ -5602,9 +5670,9 @@ function treeDigest(root) {
|
|
|
5602
5670
|
}
|
|
5603
5671
|
function locateXcframework(tree) {
|
|
5604
5672
|
const find = (root, depth) => {
|
|
5605
|
-
for (const entry of
|
|
5673
|
+
for (const entry of import_node_fs12.default.readdirSync(root, { withFileTypes: true })) {
|
|
5606
5674
|
if (!entry.isDirectory() || entry.name === "__MACOSX") continue;
|
|
5607
|
-
const full =
|
|
5675
|
+
const full = import_node_path12.default.join(root, entry.name);
|
|
5608
5676
|
if (entry.name.endsWith(".xcframework")) return full;
|
|
5609
5677
|
const nested = depth > 0 ? find(full, depth - 1) : null;
|
|
5610
5678
|
if (nested) return nested;
|
|
@@ -5619,67 +5687,67 @@ function xcframework(binary) {
|
|
|
5619
5687
|
if (binary.url && (!binary.checksum || !/^[a-f0-9]{64}$/i.test(binary.checksum)))
|
|
5620
5688
|
throw new Error("remote binary archive requires its Package.swift SHA-256 checksum");
|
|
5621
5689
|
const expected = binary.checksum?.toLowerCase();
|
|
5622
|
-
const dir =
|
|
5623
|
-
const archive =
|
|
5624
|
-
const fingerprint =
|
|
5690
|
+
const dir = import_node_path12.default.join(cacheDir3, "archives", key(binary.url ? expected : binary.dir));
|
|
5691
|
+
const archive = import_node_path12.default.join(dir, "archive.zip");
|
|
5692
|
+
const fingerprint = import_node_path12.default.join(dir, ".fingerprint");
|
|
5625
5693
|
const stored = (() => {
|
|
5626
5694
|
try {
|
|
5627
|
-
const parsed = JSON.parse(
|
|
5695
|
+
const parsed = JSON.parse(import_node_fs12.default.readFileSync(fingerprint, "utf8"));
|
|
5628
5696
|
return parsed && typeof parsed === "object" && "sha" in parsed ? parsed : null;
|
|
5629
5697
|
} catch {
|
|
5630
5698
|
return null;
|
|
5631
5699
|
}
|
|
5632
5700
|
})();
|
|
5633
5701
|
if (!binary.url) {
|
|
5634
|
-
const stat =
|
|
5702
|
+
const stat = import_node_fs12.default.statSync(binary.dir);
|
|
5635
5703
|
const stamp = `${stat.size}:${stat.mtimeMs}`;
|
|
5636
5704
|
if (stored?.stamp === stamp) {
|
|
5637
|
-
const found3 = locateXcframework(
|
|
5705
|
+
const found3 = locateXcframework(import_node_path12.default.join(dir, "tree"));
|
|
5638
5706
|
if (found3) return { dir: found3, digest: stored.sha };
|
|
5639
5707
|
}
|
|
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",
|
|
5708
|
+
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs12.default.readFileSync(binary.dir)).digest("hex");
|
|
5709
|
+
if (sha2 !== stored?.sha || !locateXcframework(import_node_path12.default.join(dir, "tree"))) {
|
|
5710
|
+
import_node_fs12.default.rmSync(dir, { recursive: true, force: true });
|
|
5711
|
+
import_node_fs12.default.mkdirSync(import_node_path12.default.join(dir, "tree"), { recursive: true });
|
|
5712
|
+
exec("unzip", ["-q", binary.dir, "-d", import_node_path12.default.join(dir, "tree")]);
|
|
5645
5713
|
}
|
|
5646
|
-
|
|
5647
|
-
const found2 = locateXcframework(
|
|
5714
|
+
import_node_fs12.default.writeFileSync(fingerprint, JSON.stringify({ stamp, sha: sha2 }));
|
|
5715
|
+
const found2 = locateXcframework(import_node_path12.default.join(dir, "tree"));
|
|
5648
5716
|
if (!found2) throw new Error("its archive holds no .xcframework");
|
|
5649
5717
|
return { dir: found2, digest: sha2 };
|
|
5650
5718
|
}
|
|
5651
|
-
if (stored &&
|
|
5652
|
-
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(
|
|
5719
|
+
if (stored && import_node_fs12.default.existsSync(archive)) {
|
|
5720
|
+
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs12.default.readFileSync(archive)).digest("hex");
|
|
5653
5721
|
if (sha2 !== expected)
|
|
5654
5722
|
throw new Error(`archive checksum ${sha2} is not the declared checksum ${expected}`);
|
|
5655
|
-
const found2 = locateXcframework(
|
|
5723
|
+
const found2 = locateXcframework(import_node_path12.default.join(dir, "tree"));
|
|
5656
5724
|
if (found2) return { dir: found2, digest: sha2 };
|
|
5657
5725
|
}
|
|
5658
|
-
|
|
5659
|
-
|
|
5726
|
+
import_node_fs12.default.rmSync(dir, { recursive: true, force: true });
|
|
5727
|
+
import_node_fs12.default.mkdirSync(import_node_path12.default.join(dir, "tree"), { recursive: true });
|
|
5660
5728
|
exec("curl", ["-fsSL", "--retry", "2", "-o", archive, binary.url]);
|
|
5661
|
-
const sha = (0, import_node_crypto6.createHash)("sha256").update(
|
|
5729
|
+
const sha = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs12.default.readFileSync(archive)).digest("hex");
|
|
5662
5730
|
if (sha !== expected) {
|
|
5663
|
-
|
|
5731
|
+
import_node_fs12.default.rmSync(dir, { recursive: true, force: true });
|
|
5664
5732
|
throw new Error(`archive checksum ${sha} is not the declared checksum ${expected}`);
|
|
5665
5733
|
}
|
|
5666
|
-
exec("unzip", ["-q", archive, "-d",
|
|
5667
|
-
|
|
5668
|
-
const found = locateXcframework(
|
|
5734
|
+
exec("unzip", ["-q", archive, "-d", import_node_path12.default.join(dir, "tree")]);
|
|
5735
|
+
import_node_fs12.default.writeFileSync(fingerprint, JSON.stringify({ sha }));
|
|
5736
|
+
const found = locateXcframework(import_node_path12.default.join(dir, "tree"));
|
|
5669
5737
|
if (!found) throw new Error("its archive holds no .xcframework");
|
|
5670
5738
|
return { dir: found, digest: sha };
|
|
5671
5739
|
}
|
|
5672
|
-
var files = (dir, test) =>
|
|
5740
|
+
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
5741
|
function surfaces(xcframeworkDir) {
|
|
5674
|
-
const slice =
|
|
5742
|
+
const slice = import_node_fs12.default.readdirSync(xcframeworkDir).filter((name2) => /^ios-.+-simulator$/.test(name2)).sort()[0];
|
|
5675
5743
|
if (!slice) throw new Error("it has no iOS simulator slice");
|
|
5676
|
-
const root =
|
|
5744
|
+
const root = import_node_path12.default.join(xcframeworkDir, slice);
|
|
5677
5745
|
const found = [];
|
|
5678
|
-
for (const entry of
|
|
5746
|
+
for (const entry of import_node_fs12.default.readdirSync(root).sort()) {
|
|
5679
5747
|
if (!entry.endsWith(".framework")) continue;
|
|
5680
5748
|
const module2 = entry.slice(0, -".framework".length);
|
|
5681
|
-
const framework =
|
|
5682
|
-
const swiftmodule =
|
|
5749
|
+
const framework = import_node_path12.default.join(root, entry);
|
|
5750
|
+
const swiftmodule = import_node_path12.default.join(framework, "Modules", `${module2}.swiftmodule`);
|
|
5683
5751
|
const interfaces = files(
|
|
5684
5752
|
swiftmodule,
|
|
5685
5753
|
(name2) => name2.endsWith(".swiftinterface") && !name2.endsWith(".private.swiftinterface") && !name2.endsWith(".package.swiftinterface")
|
|
@@ -5689,41 +5757,41 @@ function surfaces(xcframeworkDir) {
|
|
|
5689
5757
|
found.push({
|
|
5690
5758
|
kind: "swift",
|
|
5691
5759
|
module: module2,
|
|
5692
|
-
interface:
|
|
5760
|
+
interface: import_node_path12.default.join(swiftmodule, chosen)
|
|
5693
5761
|
});
|
|
5694
5762
|
continue;
|
|
5695
5763
|
}
|
|
5696
|
-
const modulemap =
|
|
5697
|
-
if (
|
|
5764
|
+
const modulemap = import_node_path12.default.join(framework, "Modules", "module.modulemap");
|
|
5765
|
+
if (import_node_fs12.default.existsSync(modulemap))
|
|
5698
5766
|
found.push({
|
|
5699
5767
|
kind: "c",
|
|
5700
5768
|
module: module2,
|
|
5701
5769
|
modulemap,
|
|
5702
|
-
headers:
|
|
5770
|
+
headers: import_node_path12.default.join(framework, "Headers")
|
|
5703
5771
|
});
|
|
5704
5772
|
}
|
|
5705
|
-
const headers =
|
|
5773
|
+
const headers = import_node_path12.default.join(root, "Headers");
|
|
5706
5774
|
for (const map of files(headers, (name2) => name2 === "module.modulemap")) {
|
|
5707
|
-
const modulemap =
|
|
5708
|
-
const module2 = /(?:^|\s)module\s+(\w+)/.exec(
|
|
5775
|
+
const modulemap = import_node_path12.default.join(headers, map);
|
|
5776
|
+
const module2 = /(?:^|\s)module\s+(\w+)/.exec(import_node_fs12.default.readFileSync(modulemap, "utf8"))?.[1];
|
|
5709
5777
|
if (module2) found.push({ kind: "c", module: module2, modulemap, headers });
|
|
5710
5778
|
}
|
|
5711
5779
|
return found;
|
|
5712
5780
|
}
|
|
5713
5781
|
function peachModuleDirs(toolchain, imports) {
|
|
5714
5782
|
const { moduleRoot, toolchainBin } = toolchain;
|
|
5715
|
-
if (swiftDistributionAt(moduleRoot)) return [
|
|
5783
|
+
if (swiftDistributionAt(moduleRoot)) return [import_node_path12.default.join(moduleRoot, "modules")];
|
|
5716
5784
|
const peach = new Set(swiftPeachModules(moduleRoot));
|
|
5717
5785
|
const plugins = swiftMacroPlugins(moduleRoot);
|
|
5718
5786
|
if (plugins.stale)
|
|
5719
5787
|
exec("sh", [
|
|
5720
|
-
|
|
5788
|
+
import_node_path12.default.join(moduleRoot, "scripts/build-preview-plugin.sh"),
|
|
5721
5789
|
toolchainBin,
|
|
5722
5790
|
plugins.libraries[0]
|
|
5723
5791
|
]);
|
|
5724
5792
|
for (const target of imports.filter((name2) => peach.has(name2)))
|
|
5725
5793
|
exec(
|
|
5726
|
-
|
|
5794
|
+
import_node_path12.default.join(toolchainBin, "swift"),
|
|
5727
5795
|
[
|
|
5728
5796
|
"build",
|
|
5729
5797
|
"--swift-sdk",
|
|
@@ -5743,7 +5811,7 @@ function peachModuleDirs(toolchain, imports) {
|
|
|
5743
5811
|
],
|
|
5744
5812
|
moduleRoot
|
|
5745
5813
|
);
|
|
5746
|
-
return [
|
|
5814
|
+
return [import_node_path12.default.join(moduleRoot, ".build", TRIPLE, "release", "Modules")];
|
|
5747
5815
|
}
|
|
5748
5816
|
function swiftInterfaceForWasm(text3) {
|
|
5749
5817
|
return text3.replace(
|
|
@@ -5755,11 +5823,11 @@ function swiftInterfaceForWasm(text3) {
|
|
|
5755
5823
|
);
|
|
5756
5824
|
}
|
|
5757
5825
|
function swiftStandin(surface, binary, toolchain, work) {
|
|
5758
|
-
const text3 = swiftInterfaceForWasm(
|
|
5759
|
-
const search =
|
|
5760
|
-
const moduleDir =
|
|
5761
|
-
|
|
5762
|
-
|
|
5826
|
+
const text3 = swiftInterfaceForWasm(import_node_fs12.default.readFileSync(surface.interface, "utf8"));
|
|
5827
|
+
const search = import_node_path12.default.join(work, "interfaces");
|
|
5828
|
+
const moduleDir = import_node_path12.default.join(search, `${surface.module}.swiftmodule`);
|
|
5829
|
+
import_node_fs12.default.mkdirSync(moduleDir, { recursive: true });
|
|
5830
|
+
import_node_fs12.default.writeFileSync(import_node_path12.default.join(moduleDir, `${TRIPLE}.swiftinterface`), text3);
|
|
5763
5831
|
const imports = [
|
|
5764
5832
|
...text3.matchAll(
|
|
5765
5833
|
/^(?:@_exported[ \t]+)?import[ \t]+(?:(?:struct|class|enum|protocol|typealias|func|var|let)[ \t]+)?(\w+)/gm
|
|
@@ -5771,9 +5839,9 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
5771
5839
|
);
|
|
5772
5840
|
const target = ["-target", TRIPLE, "-sdk", sysroot, "-resource-dir", resources];
|
|
5773
5841
|
const peach = peachModuleDirs(toolchain, imports).flatMap((dir) => ["-I", dir]);
|
|
5774
|
-
const out =
|
|
5775
|
-
|
|
5776
|
-
exec(
|
|
5842
|
+
const out = import_node_path12.default.join(work, "graphs");
|
|
5843
|
+
import_node_fs12.default.mkdirSync(out, { recursive: true });
|
|
5844
|
+
exec(import_node_path12.default.join(toolchain.toolchainBin, "swift-symbolgraph-extract"), [
|
|
5777
5845
|
"-module-name",
|
|
5778
5846
|
surface.module,
|
|
5779
5847
|
...target,
|
|
@@ -5787,10 +5855,10 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
5787
5855
|
"-output-dir",
|
|
5788
5856
|
out
|
|
5789
5857
|
]);
|
|
5790
|
-
const graphs =
|
|
5858
|
+
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
5859
|
const omit = /* @__PURE__ */ new Map();
|
|
5792
5860
|
const plain = /* @__PURE__ */ new Set();
|
|
5793
|
-
const file =
|
|
5861
|
+
const file = import_node_path12.default.join(work, `${surface.module}.swift`);
|
|
5794
5862
|
for (; ; ) {
|
|
5795
5863
|
const { source, owners } = emitSwiftStandin(graphs, {
|
|
5796
5864
|
module: surface.module,
|
|
@@ -5798,9 +5866,9 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
5798
5866
|
omit,
|
|
5799
5867
|
plain
|
|
5800
5868
|
});
|
|
5801
|
-
|
|
5869
|
+
import_node_fs12.default.writeFileSync(file, source);
|
|
5802
5870
|
const check = (0, import_node_child_process7.spawnSync)(
|
|
5803
|
-
|
|
5871
|
+
import_node_path12.default.join(toolchain.toolchainBin, "swiftc"),
|
|
5804
5872
|
[
|
|
5805
5873
|
"-typecheck",
|
|
5806
5874
|
"-parse-as-library",
|
|
@@ -5950,21 +6018,21 @@ function splitDeclarators(statement, names) {
|
|
|
5950
6018
|
}
|
|
5951
6019
|
function cStandin(surface, binary, toolchain, work) {
|
|
5952
6020
|
const named = [
|
|
5953
|
-
...
|
|
6021
|
+
...import_node_fs12.default.readFileSync(surface.modulemap, "utf8").matchAll(/(?:umbrella\s+)?header\s+"([^"]+)"/g)
|
|
5954
6022
|
].map((match) => match[1]);
|
|
5955
6023
|
const headers = files(surface.headers, (name2) => name2.endsWith(".h"));
|
|
5956
6024
|
const texts = new Map(
|
|
5957
6025
|
headers.map((file) => [
|
|
5958
6026
|
file,
|
|
5959
|
-
|
|
6027
|
+
import_node_fs12.default.readFileSync(import_node_path12.default.join(surface.headers, file), "utf8")
|
|
5960
6028
|
])
|
|
5961
6029
|
);
|
|
5962
6030
|
const objc = headers.find((file) => OBJC.test(texts.get(file)));
|
|
5963
6031
|
if (objc) throw new Error(`its header ${objc} is Objective-C`);
|
|
5964
|
-
const include =
|
|
6032
|
+
const include = import_node_path12.default.join(work, "include");
|
|
5965
6033
|
for (const [file, text3] of texts) {
|
|
5966
|
-
|
|
5967
|
-
|
|
6034
|
+
import_node_fs12.default.mkdirSync(import_node_path12.default.dirname(import_node_path12.default.join(include, file)), { recursive: true });
|
|
6035
|
+
import_node_fs12.default.writeFileSync(import_node_path12.default.join(include, file), text3);
|
|
5968
6036
|
}
|
|
5969
6037
|
const roots = named.length > 0 ? named : headers;
|
|
5970
6038
|
const modulemap = `module ${surface.module} {
|
|
@@ -5972,12 +6040,12 @@ ${roots.map((file) => ` header "${file}"
|
|
|
5972
6040
|
`).join("")} export *
|
|
5973
6041
|
}
|
|
5974
6042
|
`;
|
|
5975
|
-
const probe =
|
|
5976
|
-
|
|
6043
|
+
const probe = import_node_path12.default.join(work, "declarations.c");
|
|
6044
|
+
import_node_fs12.default.writeFileSync(probe, roots.map((file) => `#include "${file}"
|
|
5977
6045
|
`).join(""));
|
|
5978
6046
|
const { sysroot } = swiftSdkPaths(toolchain.moduleRoot, toolchain.toolchainBin);
|
|
5979
6047
|
const ast = JSON.parse(
|
|
5980
|
-
exec(
|
|
6048
|
+
exec(import_node_path12.default.join(toolchain.toolchainBin, "clang"), [
|
|
5981
6049
|
"-target",
|
|
5982
6050
|
TRIPLE,
|
|
5983
6051
|
"--sysroot",
|
|
@@ -5990,7 +6058,7 @@ ${roots.map((file) => ` header "${file}"
|
|
|
5990
6058
|
probe
|
|
5991
6059
|
])
|
|
5992
6060
|
);
|
|
5993
|
-
const byPath = new Map(headers.map((file) => [
|
|
6061
|
+
const byPath = new Map(headers.map((file) => [import_node_path12.default.join(include, file), file]));
|
|
5994
6062
|
const declarations = functionDeclarations(ast, new Set(byPath.keys()));
|
|
5995
6063
|
const groups = /* @__PURE__ */ new Map();
|
|
5996
6064
|
for (const declaration of declarations) {
|
|
@@ -6037,10 +6105,10 @@ ${roots.map((file) => ` header "${file}"
|
|
|
6037
6105
|
"",
|
|
6038
6106
|
...definitions
|
|
6039
6107
|
].join("\n");
|
|
6040
|
-
const out =
|
|
6041
|
-
|
|
6108
|
+
const out = import_node_path12.default.join(work, `${surface.module}.c`);
|
|
6109
|
+
import_node_fs12.default.writeFileSync(out, source);
|
|
6042
6110
|
try {
|
|
6043
|
-
exec(
|
|
6111
|
+
exec(import_node_path12.default.join(toolchain.toolchainBin, "clang"), [
|
|
6044
6112
|
"-target",
|
|
6045
6113
|
TRIPLE,
|
|
6046
6114
|
"--sysroot",
|
|
@@ -6122,25 +6190,25 @@ function binaryStandins(binary, toolchain, provided) {
|
|
|
6122
6190
|
for (const file of surface.kind === "swift" ? [surface.interface] : [
|
|
6123
6191
|
surface.modulemap,
|
|
6124
6192
|
...files(surface.headers, (name2) => name2.endsWith(".h")).map(
|
|
6125
|
-
(file2) =>
|
|
6193
|
+
(file2) => import_node_path12.default.join(surface.headers, file2)
|
|
6126
6194
|
)
|
|
6127
6195
|
])
|
|
6128
|
-
hash.update(
|
|
6196
|
+
hash.update(import_node_fs12.default.readFileSync(file));
|
|
6129
6197
|
}
|
|
6130
6198
|
const id = hash.digest("hex").slice(0, 32);
|
|
6131
6199
|
const memo2 = built.get(id);
|
|
6132
6200
|
if (memo2) return memo2;
|
|
6133
|
-
const cached2 =
|
|
6134
|
-
if (
|
|
6135
|
-
const value = JSON.parse(
|
|
6201
|
+
const cached2 = import_node_path12.default.join(cacheDir3, "standins", `${id}.json`);
|
|
6202
|
+
if (import_node_fs12.default.existsSync(cached2)) {
|
|
6203
|
+
const value = JSON.parse(import_node_fs12.default.readFileSync(cached2, "utf8"));
|
|
6136
6204
|
built.set(id, value);
|
|
6137
6205
|
return value;
|
|
6138
6206
|
}
|
|
6139
|
-
const work =
|
|
6207
|
+
const work = import_node_fs12.default.mkdtempSync(import_node_path12.default.join(import_node_os7.default.tmpdir(), "peach-standin-"));
|
|
6140
6208
|
let result;
|
|
6141
6209
|
try {
|
|
6142
6210
|
result = found.map((surface) => {
|
|
6143
|
-
const dir =
|
|
6211
|
+
const dir = import_node_path12.default.join(work, surface.module);
|
|
6144
6212
|
try {
|
|
6145
6213
|
return surface.kind === "swift" ? swiftStandin(surface, binary, toolchain, dir) : cStandin(surface, binary, toolchain, dir);
|
|
6146
6214
|
} catch (error) {
|
|
@@ -6149,13 +6217,13 @@ function binaryStandins(binary, toolchain, provided) {
|
|
|
6149
6217
|
);
|
|
6150
6218
|
}
|
|
6151
6219
|
});
|
|
6152
|
-
|
|
6153
|
-
|
|
6220
|
+
import_node_fs12.default.mkdirSync(import_node_path12.default.dirname(cached2), { recursive: true });
|
|
6221
|
+
import_node_fs12.default.writeFileSync(cached2, JSON.stringify(result));
|
|
6154
6222
|
built.set(id, result);
|
|
6155
6223
|
} catch (error) {
|
|
6156
6224
|
result = error instanceof Error ? error.message : String(error);
|
|
6157
6225
|
} finally {
|
|
6158
|
-
|
|
6226
|
+
import_node_fs12.default.rmSync(work, { recursive: true, force: true });
|
|
6159
6227
|
}
|
|
6160
6228
|
return result;
|
|
6161
6229
|
}
|
|
@@ -6307,12 +6375,12 @@ async function compileSwiftProject(submit, work, origin, signal) {
|
|
|
6307
6375
|
}
|
|
6308
6376
|
|
|
6309
6377
|
// src/xcode-project.ts
|
|
6310
|
-
var
|
|
6311
|
-
var
|
|
6378
|
+
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
6379
|
+
var import_node_path14 = __toESM(require("node:path"), 1);
|
|
6312
6380
|
var import_plist = __toESM(require_plist(), 1);
|
|
6313
6381
|
|
|
6314
6382
|
// src/xcode-json-project.ts
|
|
6315
|
-
var
|
|
6383
|
+
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
6316
6384
|
var import_json5 = __toESM(require_lib(), 1);
|
|
6317
6385
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6318
6386
|
var text2 = (value) => typeof value === "string" ? value : void 0;
|
|
@@ -6328,7 +6396,7 @@ var PHASE_ISA = {
|
|
|
6328
6396
|
function readXcodeJsonProject(xcodeproj, source) {
|
|
6329
6397
|
const json = import_json5.default.parse(source);
|
|
6330
6398
|
if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
|
|
6331
|
-
const projectDir =
|
|
6399
|
+
const projectDir = import_node_path13.default.dirname(xcodeproj);
|
|
6332
6400
|
const objects = {};
|
|
6333
6401
|
let next = 0;
|
|
6334
6402
|
const add = (entry, id) => {
|
|
@@ -6341,7 +6409,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
6341
6409
|
const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
|
|
6342
6410
|
if (base) {
|
|
6343
6411
|
if (base[1] === "PROJECT")
|
|
6344
|
-
return { sourceTree: "<absolute>", path:
|
|
6412
|
+
return { sourceTree: "<absolute>", path: import_node_path13.default.join(projectDir, base[2]) };
|
|
6345
6413
|
if (base[1] === "PRODUCTS")
|
|
6346
6414
|
return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
|
|
6347
6415
|
return null;
|
|
@@ -6349,7 +6417,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
6349
6417
|
const unescaped = raw2.replaceAll("\\<", "<");
|
|
6350
6418
|
if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
|
|
6351
6419
|
if (unescaped.startsWith("~")) return null;
|
|
6352
|
-
return groupDir === null ? null : { sourceTree: "<absolute>", path:
|
|
6420
|
+
return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path13.default.join(groupDir, unescaped) };
|
|
6353
6421
|
};
|
|
6354
6422
|
const memberships = [];
|
|
6355
6423
|
const folders = [];
|
|
@@ -6360,7 +6428,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
6360
6428
|
const kind = text2(entry.kind) ?? "file-reference";
|
|
6361
6429
|
const raw2 = text2(entry.path) ?? "";
|
|
6362
6430
|
const located = raw2 === "" ? null : locate(raw2, parent.dir);
|
|
6363
|
-
const name2 = text2(entry.name) ??
|
|
6431
|
+
const name2 = text2(entry.name) ?? import_node_path13.default.basename(raw2);
|
|
6364
6432
|
const node = { id: "", name: name2, dir: null, parent, children: [] };
|
|
6365
6433
|
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
6366
6434
|
node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
@@ -6475,7 +6543,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
6475
6543
|
if (!isObject(entry)) continue;
|
|
6476
6544
|
const repository = text2(entry.repository);
|
|
6477
6545
|
const local = text2(entry.path);
|
|
6478
|
-
const name2 = local !== void 0 ?
|
|
6546
|
+
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
6547
|
const id = text2(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
6480
6548
|
packageIds.set(name2.toLowerCase(), id);
|
|
6481
6549
|
}
|
|
@@ -6752,28 +6820,28 @@ var CONDITIONS = {
|
|
|
6752
6820
|
variant: "normal"
|
|
6753
6821
|
};
|
|
6754
6822
|
function walkFiles(dir) {
|
|
6755
|
-
if (!
|
|
6823
|
+
if (!import_node_fs13.default.existsSync(dir)) return [];
|
|
6756
6824
|
const out = [];
|
|
6757
|
-
for (const entry of
|
|
6825
|
+
for (const entry of import_node_fs13.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
6758
6826
|
if (entry.name.startsWith(".")) continue;
|
|
6759
|
-
const full =
|
|
6827
|
+
const full = import_node_path14.default.join(dir, entry.name);
|
|
6760
6828
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
6761
6829
|
else if (entry.isFile()) out.push(full);
|
|
6762
6830
|
}
|
|
6763
6831
|
return out;
|
|
6764
6832
|
}
|
|
6765
|
-
var isDirectory = (dir) =>
|
|
6833
|
+
var isDirectory = (dir) => import_node_fs13.default.existsSync(dir) && import_node_fs13.default.statSync(dir).isDirectory();
|
|
6766
6834
|
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
6767
|
-
if (seen.has(file) || !
|
|
6835
|
+
if (seen.has(file) || !import_node_fs13.default.existsSync(file)) return {};
|
|
6768
6836
|
seen.add(file);
|
|
6769
6837
|
const settings = {};
|
|
6770
|
-
for (const raw2 of
|
|
6838
|
+
for (const raw2 of import_node_fs13.default.readFileSync(file, "utf8").split("\n")) {
|
|
6771
6839
|
const line = raw2.replace(/\/\/.*$/, "").trim();
|
|
6772
6840
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
6773
6841
|
if (include) {
|
|
6774
6842
|
Object.assign(
|
|
6775
6843
|
settings,
|
|
6776
|
-
readXcconfig(
|
|
6844
|
+
readXcconfig(import_node_path14.default.resolve(import_node_path14.default.dirname(file), include[1]), seen)
|
|
6777
6845
|
);
|
|
6778
6846
|
continue;
|
|
6779
6847
|
}
|
|
@@ -6823,22 +6891,22 @@ function decodeXml(text3) {
|
|
|
6823
6891
|
return text3.replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
6824
6892
|
}
|
|
6825
6893
|
function workspaceReferences(workspace) {
|
|
6826
|
-
const data =
|
|
6827
|
-
if (!
|
|
6894
|
+
const data = import_node_path14.default.join(workspace, "contents.xcworkspacedata");
|
|
6895
|
+
if (!import_node_fs13.default.existsSync(data))
|
|
6828
6896
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
6829
|
-
const container =
|
|
6897
|
+
const container = import_node_path14.default.dirname(workspace);
|
|
6830
6898
|
const locate = (location, base) => {
|
|
6831
6899
|
const colon = location.indexOf(":");
|
|
6832
6900
|
const kind = location.slice(0, colon);
|
|
6833
6901
|
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(`${
|
|
6902
|
+
if (kind === "group") return import_node_path14.default.resolve(base, rest);
|
|
6903
|
+
if (kind === "container" || kind === "self") return import_node_path14.default.resolve(container, rest);
|
|
6904
|
+
if (kind === "absolute") return import_node_path14.default.resolve(rest);
|
|
6905
|
+
throw new Error(`${import_node_path14.default.basename(workspace)} has an unsupported location ${location}`);
|
|
6838
6906
|
};
|
|
6839
6907
|
const groups = [container];
|
|
6840
6908
|
const references = [];
|
|
6841
|
-
for (const [, closing, tag, attributes, selfClosing] of
|
|
6909
|
+
for (const [, closing, tag, attributes, selfClosing] of import_node_fs13.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
|
|
6842
6910
|
if (closing) {
|
|
6843
6911
|
if (tag === "Group") groups.pop();
|
|
6844
6912
|
continue;
|
|
@@ -6854,8 +6922,8 @@ function workspaceReferences(workspace) {
|
|
|
6854
6922
|
var loaded = /* @__PURE__ */ new Map();
|
|
6855
6923
|
function xcodeProjectFile(xcodeproj) {
|
|
6856
6924
|
for (const name2 of ["project.pbxproj", "project.xcproj"]) {
|
|
6857
|
-
const file =
|
|
6858
|
-
if (
|
|
6925
|
+
const file = import_node_path14.default.join(xcodeproj, name2);
|
|
6926
|
+
if (import_node_fs13.default.existsSync(file)) return file;
|
|
6859
6927
|
}
|
|
6860
6928
|
return null;
|
|
6861
6929
|
}
|
|
@@ -6863,10 +6931,10 @@ function loadProject(xcodeproj) {
|
|
|
6863
6931
|
const projectFile = xcodeProjectFile(xcodeproj);
|
|
6864
6932
|
if (!projectFile)
|
|
6865
6933
|
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
6866
|
-
const mtimeMs =
|
|
6934
|
+
const mtimeMs = import_node_fs13.default.statSync(projectFile).mtimeMs;
|
|
6867
6935
|
const cached2 = loaded.get(projectFile);
|
|
6868
6936
|
if (cached2?.mtimeMs === mtimeMs) return cached2.project;
|
|
6869
|
-
const source =
|
|
6937
|
+
const source = import_node_fs13.default.readFileSync(projectFile, "utf8");
|
|
6870
6938
|
const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
|
|
6871
6939
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
6872
6940
|
throw new Error(`${projectFile} has no objects table`);
|
|
@@ -6880,8 +6948,8 @@ function loadProject(xcodeproj) {
|
|
|
6880
6948
|
if (!project || project.isa !== "PBXProject") {
|
|
6881
6949
|
throw new Error(`${projectFile} has no PBXProject root`);
|
|
6882
6950
|
}
|
|
6883
|
-
const projectDir =
|
|
6884
|
-
|
|
6951
|
+
const projectDir = import_node_fs13.default.realpathSync(
|
|
6952
|
+
import_node_path14.default.resolve(import_node_path14.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
6885
6953
|
);
|
|
6886
6954
|
const parent = /* @__PURE__ */ new Map();
|
|
6887
6955
|
for (const [id, entry] of Object.entries(objects)) {
|
|
@@ -6899,11 +6967,11 @@ function loadProject(xcodeproj) {
|
|
|
6899
6967
|
const own = str(entry.path) ?? "";
|
|
6900
6968
|
const tree = str(entry.sourceTree) ?? "<group>";
|
|
6901
6969
|
if (tree === "<absolute>") result2 = own;
|
|
6902
|
-
else if (tree === "SOURCE_ROOT") result2 =
|
|
6970
|
+
else if (tree === "SOURCE_ROOT") result2 = import_node_path14.default.join(projectDir, own);
|
|
6903
6971
|
else if (tree === "<group>") {
|
|
6904
6972
|
const up = parent.get(id);
|
|
6905
6973
|
const base = up ? resolvePath(up) : projectDir;
|
|
6906
|
-
result2 = base === null ? null :
|
|
6974
|
+
result2 = base === null ? null : import_node_path14.default.join(base, own);
|
|
6907
6975
|
}
|
|
6908
6976
|
}
|
|
6909
6977
|
resolvedPaths.set(id, result2);
|
|
@@ -7003,7 +7071,7 @@ function targetMembers(ref) {
|
|
|
7003
7071
|
const addResource = (file) => {
|
|
7004
7072
|
if (isDirectory(file)) {
|
|
7005
7073
|
for (const inner of walkFiles(file)) resources.add(inner);
|
|
7006
|
-
} else if (
|
|
7074
|
+
} else if (import_node_fs13.default.existsSync(file)) resources.add(file);
|
|
7007
7075
|
};
|
|
7008
7076
|
const fileRefPaths = (refId) => {
|
|
7009
7077
|
const entry = project.object(refId);
|
|
@@ -7024,7 +7092,7 @@ function targetMembers(ref) {
|
|
|
7024
7092
|
for (const buildFileId of list(phase.files)) {
|
|
7025
7093
|
for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
|
|
7026
7094
|
if (phase.isa === "PBXSourcesBuildPhase") {
|
|
7027
|
-
if (!
|
|
7095
|
+
if (!import_node_fs13.default.existsSync(file)) continue;
|
|
7028
7096
|
allSources.add(file);
|
|
7029
7097
|
if (file.endsWith(".swift")) sources.add(file);
|
|
7030
7098
|
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
@@ -7032,7 +7100,7 @@ function targetMembers(ref) {
|
|
|
7032
7100
|
}
|
|
7033
7101
|
}
|
|
7034
7102
|
const addSynchronized = (folder, relative) => {
|
|
7035
|
-
const file =
|
|
7103
|
+
const file = import_node_path14.default.join(folder, relative);
|
|
7036
7104
|
if (NEVER_MEMBER.test(relative)) return;
|
|
7037
7105
|
if (file.endsWith(".swift")) {
|
|
7038
7106
|
if (!relative.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
|
|
@@ -7057,7 +7125,7 @@ function targetMembers(ref) {
|
|
|
7057
7125
|
}
|
|
7058
7126
|
if (owned.has(groupId)) {
|
|
7059
7127
|
for (const file of walkFiles(folder)) {
|
|
7060
|
-
const relative =
|
|
7128
|
+
const relative = import_node_path14.default.relative(folder, file).split(import_node_path14.default.sep).join("/");
|
|
7061
7129
|
if ([...exceptions].some(
|
|
7062
7130
|
(exception) => relative === exception || relative.startsWith(`${exception}/`)
|
|
7063
7131
|
))
|
|
@@ -7066,14 +7134,14 @@ function targetMembers(ref) {
|
|
|
7066
7134
|
}
|
|
7067
7135
|
} else {
|
|
7068
7136
|
for (const relative of exceptions) {
|
|
7069
|
-
const file =
|
|
7137
|
+
const file = import_node_path14.default.join(folder, relative);
|
|
7070
7138
|
if (isDirectory(file)) {
|
|
7071
7139
|
for (const inner of walkFiles(file))
|
|
7072
7140
|
addSynchronized(
|
|
7073
7141
|
folder,
|
|
7074
|
-
|
|
7142
|
+
import_node_path14.default.relative(folder, inner).split(import_node_path14.default.sep).join("/")
|
|
7075
7143
|
);
|
|
7076
|
-
} else if (
|
|
7144
|
+
} else if (import_node_fs13.default.existsSync(file)) addSynchronized(folder, relative);
|
|
7077
7145
|
}
|
|
7078
7146
|
}
|
|
7079
7147
|
}
|
|
@@ -7086,8 +7154,8 @@ function targetMembers(ref) {
|
|
|
7086
7154
|
function commonAncestor(dirs) {
|
|
7087
7155
|
let common = dirs[0];
|
|
7088
7156
|
for (const dir of dirs) {
|
|
7089
|
-
while (common !==
|
|
7090
|
-
common =
|
|
7157
|
+
while (common !== import_node_path14.default.dirname(common) && import_node_path14.default.relative(common, dir).startsWith(".."))
|
|
7158
|
+
common = import_node_path14.default.dirname(common);
|
|
7091
7159
|
}
|
|
7092
7160
|
return common;
|
|
7093
7161
|
}
|
|
@@ -7096,8 +7164,8 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
7096
7164
|
const projects2 = [];
|
|
7097
7165
|
const projectAt = /* @__PURE__ */ new Map();
|
|
7098
7166
|
const addProject = (xcodeproj) => {
|
|
7099
|
-
const key2 =
|
|
7100
|
-
if (projectAt.has(key2) || key2.split(
|
|
7167
|
+
const key2 = import_node_path14.default.resolve(xcodeproj);
|
|
7168
|
+
if (projectAt.has(key2) || key2.split(import_node_path14.default.sep).includes("Pods")) return;
|
|
7101
7169
|
if (!xcodeProjectFile(key2)) return;
|
|
7102
7170
|
const project = loadProject(key2);
|
|
7103
7171
|
projectAt.set(key2, project);
|
|
@@ -7114,7 +7182,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
7114
7182
|
for (const reference of listed)
|
|
7115
7183
|
if (reference.endsWith(".xcodeproj")) addProject(reference);
|
|
7116
7184
|
if (projects2.length === 0) {
|
|
7117
|
-
throw new Error(`${
|
|
7185
|
+
throw new Error(`${import_node_path14.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
|
|
7118
7186
|
}
|
|
7119
7187
|
return { listed, projects: projects2, projectAt };
|
|
7120
7188
|
}
|
|
@@ -7136,7 +7204,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7136
7204
|
const allTargets = projects2.flatMap(nativeTargets);
|
|
7137
7205
|
const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
|
|
7138
7206
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
|
|
7139
|
-
const container =
|
|
7207
|
+
const container = import_node_path14.default.basename(xcodeprojOrWorkspace);
|
|
7140
7208
|
const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
|
|
7141
7209
|
if (named.length !== 1) {
|
|
7142
7210
|
throw new Error(
|
|
@@ -7148,14 +7216,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7148
7216
|
for (const ref of allTargets) {
|
|
7149
7217
|
const product = ref.project.object(str(ref.target.productReference));
|
|
7150
7218
|
const file = str(product?.path);
|
|
7151
|
-
if (file && !byProduct.has(
|
|
7152
|
-
byProduct.set(
|
|
7219
|
+
if (file && !byProduct.has(import_node_path14.default.basename(file)))
|
|
7220
|
+
byProduct.set(import_node_path14.default.basename(file), ref);
|
|
7153
7221
|
}
|
|
7154
7222
|
const proxied = (project, proxyId) => {
|
|
7155
7223
|
const proxy = project.object(proxyId);
|
|
7156
7224
|
if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
|
|
7157
7225
|
const portal = str(proxy.containerPortal);
|
|
7158
|
-
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(
|
|
7226
|
+
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path14.default.resolve(project.resolvePath(portal ?? "") ?? ""));
|
|
7159
7227
|
const remote = str(proxy.remoteGlobalIDString);
|
|
7160
7228
|
if (!owner || !remote) return void 0;
|
|
7161
7229
|
return nativeTargets(owner).find(
|
|
@@ -7176,7 +7244,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7176
7244
|
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
7177
7245
|
for (const buildFileId of list(phase.files)) {
|
|
7178
7246
|
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(
|
|
7247
|
+
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
7248
|
if (resolved) found.push(resolved);
|
|
7181
7249
|
}
|
|
7182
7250
|
}
|
|
@@ -7197,7 +7265,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7197
7265
|
const name2 = str(ref.target.name) ?? ref.id;
|
|
7198
7266
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
7199
7267
|
TARGET_NAME: name2,
|
|
7200
|
-
PROJECT_NAME:
|
|
7268
|
+
PROJECT_NAME: import_node_path14.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
7201
7269
|
SRCROOT: ref.project.projectDir,
|
|
7202
7270
|
SOURCE_ROOT: ref.project.projectDir,
|
|
7203
7271
|
PROJECT_DIR: ref.project.projectDir,
|
|
@@ -7228,8 +7296,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7228
7296
|
}
|
|
7229
7297
|
return value;
|
|
7230
7298
|
};
|
|
7231
|
-
const infoPlistFile = settings("INFOPLIST_FILE") ?
|
|
7232
|
-
const sourceInfo = infoPlistFile ? import_plist.default.parse(
|
|
7299
|
+
const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path14.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
|
|
7300
|
+
const sourceInfo = infoPlistFile ? import_plist.default.parse(import_node_fs13.default.readFileSync(infoPlistFile, "utf8")) : {};
|
|
7233
7301
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
7234
7302
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
7235
7303
|
}
|
|
@@ -7247,12 +7315,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7247
7315
|
};
|
|
7248
7316
|
}
|
|
7249
7317
|
const localPackageDirs = [
|
|
7250
|
-
...listed.filter((reference) =>
|
|
7318
|
+
...listed.filter((reference) => import_node_fs13.default.existsSync(import_node_path14.default.join(reference, "Package.swift"))),
|
|
7251
7319
|
...projects2.flatMap(
|
|
7252
7320
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
7253
7321
|
if (!isDict(entry)) return [];
|
|
7254
|
-
const candidate = entry.isa === "XCLocalSwiftPackageReference" ?
|
|
7255
|
-
return candidate &&
|
|
7322
|
+
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path14.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
|
|
7323
|
+
return candidate && import_node_fs13.default.existsSync(import_node_path14.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
7256
7324
|
})
|
|
7257
7325
|
)
|
|
7258
7326
|
];
|
|
@@ -7276,7 +7344,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7276
7344
|
product,
|
|
7277
7345
|
source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
|
|
7278
7346
|
kind: "local",
|
|
7279
|
-
dir:
|
|
7347
|
+
dir: import_node_path14.default.resolve(
|
|
7280
7348
|
project.projectDir,
|
|
7281
7349
|
str(reference.relativePath) ?? ""
|
|
7282
7350
|
)
|
|
@@ -7298,8 +7366,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7298
7366
|
}
|
|
7299
7367
|
}
|
|
7300
7368
|
}
|
|
7301
|
-
const resolvedFile =
|
|
7302
|
-
workspace ??
|
|
7369
|
+
const resolvedFile = import_node_path14.default.join(
|
|
7370
|
+
workspace ?? import_node_path14.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
|
|
7303
7371
|
"xcshareddata",
|
|
7304
7372
|
"swiftpm",
|
|
7305
7373
|
"Package.resolved"
|
|
@@ -7309,13 +7377,13 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7309
7377
|
...module2,
|
|
7310
7378
|
rootDir: commonAncestor(
|
|
7311
7379
|
[
|
|
7312
|
-
workspace ?
|
|
7380
|
+
workspace ? import_node_path14.default.dirname(workspace) : app.project.projectDir,
|
|
7313
7381
|
...used.map((project) => project.projectDir),
|
|
7314
7382
|
...localPackageDirs,
|
|
7315
7383
|
...linkedProducts.flatMap(
|
|
7316
|
-
({ source }) => source.kind === "local" &&
|
|
7384
|
+
({ source }) => source.kind === "local" && import_node_fs13.default.existsSync(source.dir) ? [source.dir] : []
|
|
7317
7385
|
)
|
|
7318
|
-
].map((dir) =>
|
|
7386
|
+
].map((dir) => import_node_fs13.default.realpathSync(dir))
|
|
7319
7387
|
),
|
|
7320
7388
|
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
7321
7389
|
infoPlist: import_plist.default.build(info),
|
|
@@ -7323,10 +7391,10 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7323
7391
|
frameworks,
|
|
7324
7392
|
linkedProducts,
|
|
7325
7393
|
localPackageDirs: [
|
|
7326
|
-
...new Set(localPackageDirs.map((dir) =>
|
|
7394
|
+
...new Set(localPackageDirs.map((dir) => import_node_fs13.default.realpathSync(dir)))
|
|
7327
7395
|
].sort(),
|
|
7328
7396
|
binaryFrameworks: [...binaryFrameworks].sort(),
|
|
7329
|
-
packageResolved:
|
|
7397
|
+
packageResolved: import_node_fs13.default.existsSync(resolvedFile) ? resolvedFile : null,
|
|
7330
7398
|
appTargets: appTargetNames
|
|
7331
7399
|
};
|
|
7332
7400
|
}
|
|
@@ -7346,17 +7414,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
|
|
|
7346
7414
|
var NATIVE_DESCRIPTOR = ".one-native-source.json";
|
|
7347
7415
|
var NATIVE_GLUE = ".one-native-source.swift.txt";
|
|
7348
7416
|
function swiftPackageId(packagePath) {
|
|
7349
|
-
return
|
|
7417
|
+
return import_node_path15.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
7350
7418
|
}
|
|
7351
7419
|
function nativeSourceDescriptor(packagePath) {
|
|
7352
|
-
packagePath =
|
|
7353
|
-
const file =
|
|
7354
|
-
if (!
|
|
7420
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7421
|
+
const file = import_node_path15.default.join(packagePath, NATIVE_DESCRIPTOR);
|
|
7422
|
+
if (!import_node_fs14.default.existsSync(file)) return null;
|
|
7355
7423
|
const value = JSON.parse(
|
|
7356
7424
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
7357
7425
|
);
|
|
7358
7426
|
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" || !
|
|
7427
|
+
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
7428
|
throw invalid();
|
|
7361
7429
|
}
|
|
7362
7430
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -7365,14 +7433,14 @@ function nativeSourceDescriptor(packagePath) {
|
|
|
7365
7433
|
return value;
|
|
7366
7434
|
}
|
|
7367
7435
|
function nativeSourceFiles(packagePath) {
|
|
7368
|
-
packagePath =
|
|
7369
|
-
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name2) =>
|
|
7436
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7437
|
+
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name2) => import_node_path15.default.join(packagePath, name2)).filter((file) => import_node_fs14.default.existsSync(file));
|
|
7370
7438
|
}
|
|
7371
7439
|
var SwiftMissingModulesError = class extends Error {
|
|
7372
7440
|
};
|
|
7373
7441
|
var projects = /* @__PURE__ */ new Map();
|
|
7374
7442
|
function projectFor(packagePath, hosted) {
|
|
7375
|
-
packagePath =
|
|
7443
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7376
7444
|
const existing = projects.get(packagePath);
|
|
7377
7445
|
if (existing) {
|
|
7378
7446
|
if (hosted && !existing.hosted) {
|
|
@@ -7394,14 +7462,14 @@ function projectFor(packagePath, hosted) {
|
|
|
7394
7462
|
}
|
|
7395
7463
|
var xcodeProjects = /* @__PURE__ */ new Map();
|
|
7396
7464
|
function swiftPackages(entry, app) {
|
|
7397
|
-
const stamp = (file) => file &&
|
|
7465
|
+
const stamp = (file) => file && import_node_fs14.default.existsSync(file) ? import_node_fs14.default.statSync(file).mtimeMs : 0;
|
|
7398
7466
|
const key2 = JSON.stringify([
|
|
7399
7467
|
app.linkedProducts,
|
|
7400
7468
|
app.packageResolved,
|
|
7401
7469
|
stamp(app.packageResolved),
|
|
7402
|
-
app.localPackageDirs.map((dir) => stamp(
|
|
7470
|
+
app.localPackageDirs.map((dir) => stamp(import_node_path15.default.join(dir, "Package.swift"))),
|
|
7403
7471
|
app.linkedProducts.map(
|
|
7404
|
-
({ source }) => source.kind === "local" ? stamp(
|
|
7472
|
+
({ source }) => source.kind === "local" ? stamp(import_node_path15.default.join(source.dir, "Package.swift")) : 0
|
|
7405
7473
|
)
|
|
7406
7474
|
]);
|
|
7407
7475
|
let cached2 = entry.packages;
|
|
@@ -7452,11 +7520,11 @@ var XCODE_APP_DIR = "__app__";
|
|
|
7452
7520
|
var XCODE_FRAMEWORKS_DIR = "__frameworks__";
|
|
7453
7521
|
var XCODE_PACKAGES_DIR = "__packages__";
|
|
7454
7522
|
var XCODE_STANDINS_DIR = "__standins__";
|
|
7455
|
-
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(
|
|
7523
|
+
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)}/`;
|
|
7456
7524
|
function xcodeInputKey(layout, file, relative) {
|
|
7457
7525
|
const owner = layout.targetDirs.get(file);
|
|
7458
|
-
if (owner) return
|
|
7459
|
-
return relative.startsWith(CHECKOUTS_PREFIX) ?
|
|
7526
|
+
if (owner) return import_node_path15.default.posix.join(owner, relative);
|
|
7527
|
+
return relative.startsWith(CHECKOUTS_PREFIX) ? import_node_path15.default.posix.join(XCODE_PACKAGES_DIR, relative.slice(CHECKOUTS_PREFIX.length)) : relative;
|
|
7460
7528
|
}
|
|
7461
7529
|
function xcodeLayout(root) {
|
|
7462
7530
|
const registered = xcodeProjects.get(root);
|
|
@@ -7467,7 +7535,7 @@ function xcodeLayout(root) {
|
|
|
7467
7535
|
const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
|
|
7468
7536
|
const targets = [];
|
|
7469
7537
|
for (const framework of app.frameworks) {
|
|
7470
|
-
const dir =
|
|
7538
|
+
const dir = import_node_path15.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
|
|
7471
7539
|
for (const file of framework.sources) {
|
|
7472
7540
|
if (targetDirs.has(file)) continue;
|
|
7473
7541
|
targetDirs.set(file, dir);
|
|
@@ -7487,7 +7555,7 @@ function xcodeLayout(root) {
|
|
|
7487
7555
|
for (const standin of standins)
|
|
7488
7556
|
targets.push({
|
|
7489
7557
|
name: standin.module,
|
|
7490
|
-
path:
|
|
7558
|
+
path: import_node_path15.default.posix.join(XCODE_STANDINS_DIR, standin.module),
|
|
7491
7559
|
executable: false,
|
|
7492
7560
|
resources: false,
|
|
7493
7561
|
exclude: [],
|
|
@@ -7495,19 +7563,19 @@ function xcodeLayout(root) {
|
|
|
7495
7563
|
mainActorIsolation: false
|
|
7496
7564
|
});
|
|
7497
7565
|
for (const target of packages.targets) {
|
|
7498
|
-
const relative =
|
|
7499
|
-
target.remote ?
|
|
7566
|
+
const relative = import_node_path15.default.relative(
|
|
7567
|
+
target.remote ? import_node_path15.default.join(root, REMOTE_CHECKOUTS) : root,
|
|
7500
7568
|
target.dir
|
|
7501
7569
|
);
|
|
7502
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
7570
|
+
if (relative === ".." || relative.startsWith(`..${import_node_path15.default.sep}`) || import_node_path15.default.isAbsolute(relative))
|
|
7503
7571
|
throw new Error(`swift input escapes the selected package: ${target.dir}`);
|
|
7504
|
-
const posix = relative.split(
|
|
7572
|
+
const posix = relative.split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep);
|
|
7505
7573
|
targets.push({
|
|
7506
7574
|
...target,
|
|
7507
|
-
path: target.remote ?
|
|
7575
|
+
path: target.remote ? import_node_path15.default.posix.join(XCODE_PACKAGES_DIR, posix) : posix,
|
|
7508
7576
|
exclude: []
|
|
7509
7577
|
});
|
|
7510
|
-
if (!target.remote) files2.add(
|
|
7578
|
+
if (!target.remote) files2.add(import_node_path15.default.join(target.packageDir, "Package.swift"));
|
|
7511
7579
|
for (const file of target.files) files2.add(file);
|
|
7512
7580
|
}
|
|
7513
7581
|
for (const target of targets) {
|
|
@@ -7537,25 +7605,25 @@ function xcodeManifest(layout) {
|
|
|
7537
7605
|
].join("\n");
|
|
7538
7606
|
}
|
|
7539
7607
|
function packageFiles(root) {
|
|
7540
|
-
const canonicalRoot =
|
|
7608
|
+
const canonicalRoot = import_node_fs14.default.realpathSync(root);
|
|
7541
7609
|
const xcode = xcodeLayout(canonicalRoot);
|
|
7542
7610
|
return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
|
|
7543
7611
|
}
|
|
7544
7612
|
function sourceTreeFiles(dir, canonicalRoot) {
|
|
7545
7613
|
const found = [];
|
|
7546
7614
|
const walk2 = (dir2) => {
|
|
7547
|
-
for (const entry of
|
|
7615
|
+
for (const entry of import_node_fs14.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
7548
7616
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
7549
7617
|
continue;
|
|
7550
|
-
const full =
|
|
7618
|
+
const full = import_node_path15.default.join(dir2, entry.name);
|
|
7551
7619
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
7552
|
-
const real =
|
|
7553
|
-
const relative =
|
|
7554
|
-
if (relative.startsWith(`..${
|
|
7620
|
+
const real = import_node_fs14.default.realpathSync(full);
|
|
7621
|
+
const relative = import_node_path15.default.relative(canonicalRoot, real);
|
|
7622
|
+
if (relative.startsWith(`..${import_node_path15.default.sep}`) || relative === ".." || import_node_path15.default.isAbsolute(relative)) {
|
|
7555
7623
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
7556
7624
|
}
|
|
7557
7625
|
if (entry.isDirectory()) {
|
|
7558
|
-
if (
|
|
7626
|
+
if (import_node_fs14.default.existsSync(import_node_path15.default.join(full, "Package.swift"))) continue;
|
|
7559
7627
|
walk2(full);
|
|
7560
7628
|
} else if (entry.isFile()) {
|
|
7561
7629
|
found.push(full);
|
|
@@ -7563,56 +7631,15 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
7563
7631
|
}
|
|
7564
7632
|
}
|
|
7565
7633
|
};
|
|
7566
|
-
if (
|
|
7634
|
+
if (import_node_fs14.default.existsSync(dir)) walk2(import_node_fs14.default.realpathSync(dir));
|
|
7567
7635
|
return found;
|
|
7568
7636
|
}
|
|
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
7637
|
function sourceFiles(root) {
|
|
7611
7638
|
return packageFiles(root).filter((file) => file.endsWith(".swift"));
|
|
7612
7639
|
}
|
|
7613
7640
|
function resourceCandidateFiles(root) {
|
|
7614
7641
|
return packageFiles(root).filter(
|
|
7615
|
-
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(
|
|
7642
|
+
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path15.default.basename(file))
|
|
7616
7643
|
);
|
|
7617
7644
|
}
|
|
7618
7645
|
var HOSTED_LIMITS = {
|
|
@@ -7646,7 +7673,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
7646
7673
|
const limits = inputLimits(Boolean(project.hosted));
|
|
7647
7674
|
const absolute = resourceCandidateFiles(project.packagePath);
|
|
7648
7675
|
const relative = absolute.map(
|
|
7649
|
-
(file) =>
|
|
7676
|
+
(file) => import_node_path15.default.relative(project.packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
7650
7677
|
);
|
|
7651
7678
|
const byRelative = new Map(absolute.map((file, index) => [relative[index], file]));
|
|
7652
7679
|
const readContents = (candidate) => {
|
|
@@ -7668,16 +7695,16 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
7668
7695
|
for (const { name: name2, file, scale } of found) {
|
|
7669
7696
|
const disk = byRelative.get(file);
|
|
7670
7697
|
if (!disk) continue;
|
|
7671
|
-
if (Object.keys(images).length >= limits.images || imageBytes +
|
|
7698
|
+
if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs14.default.statSync(disk).size > limits.imageTotalBytes) {
|
|
7672
7699
|
throw new Error("swift image pack exceeds the compile service caps");
|
|
7673
7700
|
}
|
|
7674
7701
|
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
7675
7702
|
imageBytes += bytes.length;
|
|
7676
7703
|
const hash = (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
|
|
7677
|
-
const ext =
|
|
7704
|
+
const ext = import_node_path15.default.posix.extname(file).toLowerCase();
|
|
7678
7705
|
table[name2] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
7679
7706
|
images[name2] = {
|
|
7680
|
-
file:
|
|
7707
|
+
file: import_node_path15.default.posix.basename(file),
|
|
7681
7708
|
data: bytes.toString("base64")
|
|
7682
7709
|
};
|
|
7683
7710
|
watched.push(file);
|
|
@@ -7701,10 +7728,10 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
7701
7728
|
return { table, images, colors, symbols, watched };
|
|
7702
7729
|
}
|
|
7703
7730
|
function buildSwiftBundleFiles(packagePath, hosted) {
|
|
7704
|
-
packagePath =
|
|
7731
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7705
7732
|
const limits = inputLimits(hosted);
|
|
7706
7733
|
const relative = resourceCandidateFiles(packagePath).map(
|
|
7707
|
-
(file) =>
|
|
7734
|
+
(file) => import_node_path15.default.relative(packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
7708
7735
|
);
|
|
7709
7736
|
const files2 = {};
|
|
7710
7737
|
const watched = [];
|
|
@@ -7718,13 +7745,13 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
7718
7745
|
total += bytes.length;
|
|
7719
7746
|
if (xcode.app.infoPlistFile)
|
|
7720
7747
|
watched.push(
|
|
7721
|
-
|
|
7748
|
+
import_node_path15.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path15.default.sep).join("/")
|
|
7722
7749
|
);
|
|
7723
7750
|
}
|
|
7724
7751
|
for (const { base, file } of enumerateBundleJson(relative)) {
|
|
7725
7752
|
watched.push(file);
|
|
7726
|
-
const disk =
|
|
7727
|
-
if (Object.keys(files2).length >= limits.resources || total +
|
|
7753
|
+
const disk = import_node_path15.default.join(packagePath, ...file.split("/"));
|
|
7754
|
+
if (Object.keys(files2).length >= limits.resources || total + import_node_fs14.default.statSync(disk).size > limits.resourceTotalBytes) {
|
|
7728
7755
|
throw new Error(
|
|
7729
7756
|
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
7730
7757
|
);
|
|
@@ -7739,12 +7766,12 @@ function serveSwiftResource(project, key2) {
|
|
|
7739
7766
|
return project.resourceFiles.get(key2) ?? project.resourcesPrevious.get(key2) ?? null;
|
|
7740
7767
|
}
|
|
7741
7768
|
function linkedModuleRoots(packagePath) {
|
|
7742
|
-
packagePath =
|
|
7769
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7743
7770
|
let manifest;
|
|
7744
7771
|
try {
|
|
7745
7772
|
manifest = readPackageFile(
|
|
7746
7773
|
packagePath,
|
|
7747
|
-
|
|
7774
|
+
import_node_path15.default.join(packagePath, "Package.swift"),
|
|
7748
7775
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
7749
7776
|
).toString("utf8");
|
|
7750
7777
|
} catch {
|
|
@@ -7753,8 +7780,8 @@ function linkedModuleRoots(packagePath) {
|
|
|
7753
7780
|
const roots = /* @__PURE__ */ new Set();
|
|
7754
7781
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
7755
7782
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
7756
|
-
const root =
|
|
7757
|
-
if (
|
|
7783
|
+
const root = import_node_path15.default.resolve(packagePath, match[1]);
|
|
7784
|
+
if (import_node_fs14.default.existsSync(import_node_path15.default.join(root, "Package.swift"))) roots.add(root);
|
|
7758
7785
|
}
|
|
7759
7786
|
return [...roots].sort();
|
|
7760
7787
|
}
|
|
@@ -7763,25 +7790,25 @@ function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
|
7763
7790
|
hash.update(packagePath);
|
|
7764
7791
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
7765
7792
|
for (const file of [...projectInputs].sort()) {
|
|
7766
|
-
hash.update(
|
|
7767
|
-
const stat =
|
|
7793
|
+
hash.update(import_node_path15.default.relative(packagePath, file));
|
|
7794
|
+
const stat = import_node_fs14.default.statSync(file);
|
|
7768
7795
|
hash.update(`${stat.mtimeMs}/${stat.ctimeMs}/${stat.size}`);
|
|
7769
7796
|
}
|
|
7770
7797
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
7771
|
-
(root) =>
|
|
7798
|
+
(root) => import_node_fs14.default.existsSync(import_node_path15.default.join(root, "toolchain.json"))
|
|
7772
7799
|
);
|
|
7773
7800
|
if (moduleRoot) {
|
|
7774
7801
|
hash.update(moduleRoot);
|
|
7775
7802
|
for (const relative of swiftModuleInputFiles(moduleRoot)) {
|
|
7776
7803
|
hash.update(relative);
|
|
7777
|
-
hash.update(String(
|
|
7804
|
+
hash.update(String(import_node_fs14.default.statSync(import_node_path15.default.join(moduleRoot, relative)).mtimeMs));
|
|
7778
7805
|
}
|
|
7779
7806
|
}
|
|
7780
7807
|
return hash.digest("hex").slice(0, 16);
|
|
7781
7808
|
}
|
|
7782
7809
|
function entryRootId(packagePath, file) {
|
|
7783
|
-
const relative =
|
|
7784
|
-
return `${
|
|
7810
|
+
const relative = import_node_path15.default.relative(packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep);
|
|
7811
|
+
return `${import_node_path15.default.basename(packagePath)}${import_node_path15.default.posix.sep}${relative}`;
|
|
7785
7812
|
}
|
|
7786
7813
|
function icuUrl(origin, artifact) {
|
|
7787
7814
|
return "url" in artifact.icu ? artifact.icu.url : `${origin}${ICU_PATH}${artifact.icu.sha256}`;
|
|
@@ -7790,8 +7817,8 @@ function packageSources(packagePath) {
|
|
|
7790
7817
|
const xcode = xcodeLayout(packagePath);
|
|
7791
7818
|
const files2 = {};
|
|
7792
7819
|
for (const file of sourceFiles(packagePath)) {
|
|
7793
|
-
const relative =
|
|
7794
|
-
if (xcode &&
|
|
7820
|
+
const relative = import_node_path15.default.relative(packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep);
|
|
7821
|
+
if (xcode && import_node_path15.default.basename(file) === "Package.swift") continue;
|
|
7795
7822
|
files2[xcode ? xcodeInputKey(xcode, file, relative) : relative] = readPackageFile(
|
|
7796
7823
|
packagePath,
|
|
7797
7824
|
file,
|
|
@@ -7802,7 +7829,7 @@ function packageSources(packagePath) {
|
|
|
7802
7829
|
files2["Package.swift"] = xcodeManifest(xcode);
|
|
7803
7830
|
for (const standin of xcode.standins)
|
|
7804
7831
|
for (const [file, text3] of Object.entries(standin.files))
|
|
7805
|
-
files2[
|
|
7832
|
+
files2[import_node_path15.default.posix.join(XCODE_STANDINS_DIR, standin.module, file)] = text3;
|
|
7806
7833
|
}
|
|
7807
7834
|
return files2;
|
|
7808
7835
|
}
|
|
@@ -7813,7 +7840,7 @@ function packageSnapshot(project) {
|
|
|
7813
7840
|
files: files2,
|
|
7814
7841
|
resourcePaths: swiftImplicitResourcePaths(
|
|
7815
7842
|
resourceCandidateFiles(project.packagePath).map(
|
|
7816
|
-
(file) =>
|
|
7843
|
+
(file) => import_node_path15.default.relative(project.packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
7817
7844
|
)
|
|
7818
7845
|
),
|
|
7819
7846
|
resources: buildSwiftResourceTable(project, ""),
|
|
@@ -7822,7 +7849,7 @@ function packageSnapshot(project) {
|
|
|
7822
7849
|
...native ? {
|
|
7823
7850
|
glue: readPackageFile(
|
|
7824
7851
|
project.packagePath,
|
|
7825
|
-
|
|
7852
|
+
import_node_path15.default.join(project.packagePath, NATIVE_GLUE),
|
|
7826
7853
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
7827
7854
|
).toString("utf8")
|
|
7828
7855
|
} : {}
|
|
@@ -7861,7 +7888,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
7861
7888
|
package: content
|
|
7862
7889
|
};
|
|
7863
7890
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
7864
|
-
(root) =>
|
|
7891
|
+
(root) => import_node_fs14.default.existsSync(import_node_path15.default.join(root, "toolchain.json"))
|
|
7865
7892
|
) ?? await swiftDistributionRoot();
|
|
7866
7893
|
if (!moduleRoot)
|
|
7867
7894
|
return {
|
|
@@ -7888,10 +7915,10 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
7888
7915
|
// server and a capture, or two checkouts) build each other's sources. so
|
|
7889
7916
|
// each app and module checkout gets its own root, which keeps the same
|
|
7890
7917
|
// app's incremental build across restarts.
|
|
7891
|
-
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ??
|
|
7918
|
+
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path15.default.join(
|
|
7892
7919
|
import_node_os8.default.tmpdir(),
|
|
7893
7920
|
"contrast-swift-build",
|
|
7894
|
-
(0, import_node_crypto7.createHash)("sha256").update(`${moduleRoot}\0${
|
|
7921
|
+
(0, import_node_crypto7.createHash)("sha256").update(`${moduleRoot}\0${import_node_path15.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
|
|
7895
7922
|
),
|
|
7896
7923
|
moduleRoot,
|
|
7897
7924
|
...toolchain
|
|
@@ -8003,7 +8030,7 @@ async function missingModulesMessage(packagePath, missing) {
|
|
|
8003
8030
|
`Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
|
|
8004
8031
|
...[...missing].map(([name2, files2]) => {
|
|
8005
8032
|
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 ${
|
|
8033
|
+
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
8034
|
})
|
|
8008
8035
|
].join("\n");
|
|
8009
8036
|
}
|
|
@@ -8011,7 +8038,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
8011
8038
|
const auth = hosted ? null : resolveCliAuth();
|
|
8012
8039
|
if (!hosted && (!auth || auth.kind === "github")) {
|
|
8013
8040
|
throw new Error(
|
|
8014
|
-
`compiling ${
|
|
8041
|
+
`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
8042
|
);
|
|
8016
8043
|
}
|
|
8017
8044
|
const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
|
|
@@ -8030,7 +8057,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
8030
8057
|
const bytes = sources.reduce((total2, text3) => total2 + Buffer.byteLength(text3), 0);
|
|
8031
8058
|
if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
|
|
8032
8059
|
throw new Error(
|
|
8033
|
-
`${
|
|
8060
|
+
`${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
8061
|
);
|
|
8035
8062
|
}
|
|
8036
8063
|
const descriptor = snapshot.native;
|
|
@@ -8049,7 +8076,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
8049
8076
|
);
|
|
8050
8077
|
if (descriptor && address.native?.hash !== descriptor.hash) {
|
|
8051
8078
|
throw new Error(
|
|
8052
|
-
`${
|
|
8079
|
+
`${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
8080
|
);
|
|
8054
8081
|
}
|
|
8055
8082
|
const response = await fetch(address.url, { signal });
|
|
@@ -8122,17 +8149,17 @@ function artifactFor(project, entry, moduleRoot) {
|
|
|
8122
8149
|
return fresh;
|
|
8123
8150
|
}
|
|
8124
8151
|
function swiftPackageWatchFiles(packagePath, moduleRoot) {
|
|
8125
|
-
packagePath =
|
|
8152
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
8126
8153
|
return [
|
|
8127
|
-
...xcodeProjects.has(packagePath) ? [] : [
|
|
8154
|
+
...xcodeProjects.has(packagePath) ? [] : [import_node_path15.default.join(packagePath, "Package.swift")],
|
|
8128
8155
|
...sourceFiles(packagePath),
|
|
8129
8156
|
...nativeSourceFiles(packagePath),
|
|
8130
8157
|
...resourceCandidateFiles(packagePath),
|
|
8131
|
-
...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) =>
|
|
8158
|
+
...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) => import_node_path15.default.join(moduleRoot, file)) : []
|
|
8132
8159
|
];
|
|
8133
8160
|
}
|
|
8134
8161
|
async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin, hosted) {
|
|
8135
|
-
packagePath =
|
|
8162
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
8136
8163
|
const mains = sourceFiles(packagePath).filter(
|
|
8137
8164
|
(file) => swiftApplicationEntry(
|
|
8138
8165
|
file,
|
|
@@ -8146,7 +8173,7 @@ async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin
|
|
|
8146
8173
|
);
|
|
8147
8174
|
}
|
|
8148
8175
|
const project = projectFor(packagePath, hosted);
|
|
8149
|
-
const entry = mains.length === 1 ?
|
|
8176
|
+
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
8177
|
([_file, names]) => names.length > 0
|
|
8151
8178
|
)?.[0];
|
|
8152
8179
|
if (!entry) throw new Error(`swift package ${packageName} has no native module source`);
|
|
@@ -8222,18 +8249,23 @@ function serveSwiftPackageAsset(pathname, res) {
|
|
|
8222
8249
|
}
|
|
8223
8250
|
|
|
8224
8251
|
// src/one-widget-package.ts
|
|
8252
|
+
var import_node_crypto9 = require("node:crypto");
|
|
8253
|
+
var import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
8254
|
+
var import_node_os9 = __toESM(require("node:os"), 1);
|
|
8255
|
+
var import_node_path17 = __toESM(require("node:path"), 1);
|
|
8256
|
+
|
|
8257
|
+
// src/one-widget-metadata.ts
|
|
8225
8258
|
var import_node_child_process8 = require("node:child_process");
|
|
8226
8259
|
var import_node_crypto8 = require("node:crypto");
|
|
8227
|
-
var
|
|
8260
|
+
var import_node_fs15 = __toESM(require("node:fs"), 1);
|
|
8228
8261
|
var import_node_module = require("node:module");
|
|
8229
|
-
var
|
|
8230
|
-
var import_node_path15 = __toESM(require("node:path"), 1);
|
|
8262
|
+
var import_node_path16 = __toESM(require("node:path"), 1);
|
|
8231
8263
|
var import_node_util3 = require("node:util");
|
|
8232
8264
|
|
|
8233
8265
|
// cli/internal-child.ts
|
|
8234
8266
|
var RNX_FORKED_SCRIPT_ENV = "PEACH_RUNS_FORKED_SCRIPTS";
|
|
8235
8267
|
|
|
8236
|
-
// src/one-widget-
|
|
8268
|
+
// src/one-widget-metadata.ts
|
|
8237
8269
|
var run3 = (0, import_node_util3.promisify)(import_node_child_process8.execFile);
|
|
8238
8270
|
var ONE_WIDGET_PACKAGE = "OneWidgets";
|
|
8239
8271
|
var configs = /* @__PURE__ */ new Map();
|
|
@@ -8248,14 +8280,15 @@ fs.writeFileSync(process.argv[2], JSON.stringify({
|
|
|
8248
8280
|
widget: widgets ? { appName: app.name, bundleId: app.ios.bundleId,
|
|
8249
8281
|
suite: widgets.appGroup, kind: widgets.kind, displayName: widgets.displayName,
|
|
8250
8282
|
description: widgets.description } : null,
|
|
8283
|
+
urlSchemes: app?.scheme === undefined ? [] : Array.isArray(app.scheme) ? app.scheme : [app.scheme],
|
|
8251
8284
|
watched: [config.path, ...config.dependencies]
|
|
8252
8285
|
}));
|
|
8253
8286
|
`;
|
|
8254
8287
|
function configStamp(files2) {
|
|
8255
8288
|
return JSON.stringify(
|
|
8256
8289
|
files2.map((file) => {
|
|
8257
|
-
if (!
|
|
8258
|
-
const stat =
|
|
8290
|
+
if (!import_node_fs15.default.existsSync(file)) return [file, null];
|
|
8291
|
+
const stat = import_node_fs15.default.statSync(file);
|
|
8259
8292
|
return [file, stat.mtimeMs, stat.ctimeMs, stat.size];
|
|
8260
8293
|
})
|
|
8261
8294
|
);
|
|
@@ -8266,13 +8299,13 @@ async function readConfig(root) {
|
|
|
8266
8299
|
const reading = reads.get(root);
|
|
8267
8300
|
if (reading) return reading;
|
|
8268
8301
|
const promise = (async () => {
|
|
8269
|
-
(0, import_node_module.createRequire)(
|
|
8270
|
-
const cache =
|
|
8271
|
-
|
|
8272
|
-
const directory =
|
|
8273
|
-
const script =
|
|
8274
|
-
const result =
|
|
8275
|
-
|
|
8302
|
+
(0, import_node_module.createRequire)(import_node_path16.default.join(root, "package.json")).resolve("one/vite");
|
|
8303
|
+
const cache = import_node_path16.default.join(root, "node_modules/.cache/peach-widget-config");
|
|
8304
|
+
import_node_fs15.default.mkdirSync(cache, { recursive: true });
|
|
8305
|
+
const directory = import_node_fs15.default.mkdtempSync(import_node_path16.default.join(cache, "read-"));
|
|
8306
|
+
const script = import_node_path16.default.join(directory, "read.mjs");
|
|
8307
|
+
const result = import_node_path16.default.join(directory, "result.json");
|
|
8308
|
+
import_node_fs15.default.writeFileSync(script, CONFIG_CHILD);
|
|
8276
8309
|
try {
|
|
8277
8310
|
await run3(process.execPath, [script, result], {
|
|
8278
8311
|
cwd: root,
|
|
@@ -8280,9 +8313,13 @@ async function readConfig(root) {
|
|
|
8280
8313
|
timeout: 3e4,
|
|
8281
8314
|
maxBuffer: 1024 * 1024
|
|
8282
8315
|
});
|
|
8283
|
-
const value = JSON.parse(
|
|
8316
|
+
const value = JSON.parse(import_node_fs15.default.readFileSync(result, "utf8"));
|
|
8284
8317
|
if (!isRecord(value) || !Array.isArray(value.watched) || !value.watched.every((file) => typeof file === "string"))
|
|
8285
8318
|
throw new Error("One config loader returned invalid dependencies");
|
|
8319
|
+
if (!Array.isArray(value.urlSchemes) || !value.urlSchemes.every(
|
|
8320
|
+
(scheme) => typeof scheme === "string" && /^[A-Za-z][A-Za-z0-9+.-]*$/.test(scheme)
|
|
8321
|
+
))
|
|
8322
|
+
throw new Error("One config loader returned invalid native.app.scheme");
|
|
8286
8323
|
let widget = null;
|
|
8287
8324
|
if (value.widget !== null) {
|
|
8288
8325
|
const entry = value.widget;
|
|
@@ -8299,15 +8336,20 @@ async function readConfig(root) {
|
|
|
8299
8336
|
}
|
|
8300
8337
|
const watched = [
|
|
8301
8338
|
.../* @__PURE__ */ new Set([
|
|
8302
|
-
|
|
8303
|
-
...value.watched.map((file) =>
|
|
8339
|
+
import_node_path16.default.join(root, "package.json"),
|
|
8340
|
+
...value.watched.map((file) => import_node_path16.default.resolve(root, file))
|
|
8304
8341
|
])
|
|
8305
8342
|
];
|
|
8306
|
-
const loaded2 = {
|
|
8343
|
+
const loaded2 = {
|
|
8344
|
+
widget,
|
|
8345
|
+
urlSchemes: value.urlSchemes,
|
|
8346
|
+
watched,
|
|
8347
|
+
stamp: configStamp(watched)
|
|
8348
|
+
};
|
|
8307
8349
|
configs.set(root, loaded2);
|
|
8308
8350
|
return loaded2;
|
|
8309
8351
|
} finally {
|
|
8310
|
-
|
|
8352
|
+
import_node_fs15.default.rmSync(directory, { recursive: true, force: true });
|
|
8311
8353
|
}
|
|
8312
8354
|
})();
|
|
8313
8355
|
reads.set(root, promise);
|
|
@@ -8317,14 +8359,14 @@ async function readConfig(root) {
|
|
|
8317
8359
|
reads.delete(root);
|
|
8318
8360
|
}
|
|
8319
8361
|
}
|
|
8320
|
-
async function
|
|
8321
|
-
const root =
|
|
8362
|
+
async function readOneWidgetSources(appRoot) {
|
|
8363
|
+
const root = import_node_fs15.default.realpathSync(appRoot);
|
|
8322
8364
|
const config = await readConfig(root);
|
|
8323
8365
|
if (!config.widget) return null;
|
|
8324
8366
|
const widget = config.widget;
|
|
8325
8367
|
const sourceFiles2 = {
|
|
8326
|
-
"OneWidget.swift":
|
|
8327
|
-
"OneWidgetContract.swift":
|
|
8368
|
+
"OneWidget.swift": import_node_path16.default.join(root, "ios/OneWidgets/OneWidget.swift"),
|
|
8369
|
+
"OneWidgetContract.swift": import_node_path16.default.join(
|
|
8328
8370
|
root,
|
|
8329
8371
|
"ios",
|
|
8330
8372
|
widget.appName,
|
|
@@ -8334,14 +8376,14 @@ async function oneWidgetPackage(appRoot) {
|
|
|
8334
8376
|
const files2 = /* @__PURE__ */ new Map();
|
|
8335
8377
|
const sources = {};
|
|
8336
8378
|
for (const [name2, file] of Object.entries(sourceFiles2)) {
|
|
8337
|
-
if (!
|
|
8379
|
+
if (!import_node_fs15.default.existsSync(file))
|
|
8338
8380
|
throw new Error(`missing One widget prebuild source ${file}; run one prebuild`);
|
|
8339
8381
|
const bytes = readPackageFile(root, file, MAX_SWIFT_COMPILE_SOURCE_BYTES);
|
|
8340
8382
|
const text3 = bytes.toString("utf8");
|
|
8341
8383
|
if (!Buffer.from(text3).equals(bytes))
|
|
8342
8384
|
throw new Error(`One widget prebuild source is not UTF-8: ${file}`);
|
|
8343
8385
|
files2.set(name2, text3);
|
|
8344
|
-
sources[
|
|
8386
|
+
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
8387
|
}
|
|
8346
8388
|
const contract = files2.get("OneWidgetContract.swift") ?? "";
|
|
8347
8389
|
const source = files2.get("OneWidget.swift") ?? "";
|
|
@@ -8351,11 +8393,26 @@ async function oneWidgetPackage(appRoot) {
|
|
|
8351
8393
|
throw new Error(
|
|
8352
8394
|
"One widget prebuild sources disagree with native.app.ios.widgets; run one prebuild"
|
|
8353
8395
|
);
|
|
8396
|
+
return {
|
|
8397
|
+
root,
|
|
8398
|
+
files: files2,
|
|
8399
|
+
watched: [...config.watched, ...Object.values(sourceFiles2)],
|
|
8400
|
+
widget: { ...widget, sources },
|
|
8401
|
+
urlSchemes: config.urlSchemes
|
|
8402
|
+
};
|
|
8403
|
+
}
|
|
8404
|
+
|
|
8405
|
+
// src/one-widget-package.ts
|
|
8406
|
+
async function oneWidgetPackage(appRoot) {
|
|
8407
|
+
const source = await readOneWidgetSources(appRoot);
|
|
8408
|
+
if (!source) return null;
|
|
8409
|
+
const { root, files: files2, watched, widget } = source;
|
|
8410
|
+
const { sources: _sources, ...config } = widget;
|
|
8354
8411
|
files2.set(
|
|
8355
8412
|
"Package.swift",
|
|
8356
8413
|
[
|
|
8357
8414
|
"// swift-tools-version: 6.2",
|
|
8358
|
-
`// One widget config ${JSON.stringify(
|
|
8415
|
+
`// One widget config ${JSON.stringify(config)}`,
|
|
8359
8416
|
"import PackageDescription",
|
|
8360
8417
|
'let package = Package(name: "OneWidgets", targets: [',
|
|
8361
8418
|
' .executableTarget(name: "OneWidgets", path: ".", swiftSettings: [.swiftLanguageMode(.v5)]),',
|
|
@@ -8363,21 +8420,21 @@ async function oneWidgetPackage(appRoot) {
|
|
|
8363
8420
|
""
|
|
8364
8421
|
].join("\n")
|
|
8365
8422
|
);
|
|
8366
|
-
const packagePath =
|
|
8423
|
+
const packagePath = import_node_path17.default.join(
|
|
8367
8424
|
import_node_os9.default.tmpdir(),
|
|
8368
8425
|
"peach-one-widgets",
|
|
8369
|
-
(0,
|
|
8426
|
+
(0, import_node_crypto9.createHash)("sha256").update(root).digest("hex"),
|
|
8370
8427
|
ONE_WIDGET_PACKAGE
|
|
8371
8428
|
);
|
|
8372
|
-
|
|
8429
|
+
import_node_fs16.default.mkdirSync(packagePath, { recursive: true });
|
|
8373
8430
|
syncSwiftTree(
|
|
8374
8431
|
packagePath,
|
|
8375
|
-
new Map([...files2].map(([file, text3]) => [
|
|
8432
|
+
new Map([...files2].map(([file, text3]) => [import_node_path17.default.join(packagePath, file), text3]))
|
|
8376
8433
|
);
|
|
8377
8434
|
return {
|
|
8378
8435
|
packagePath,
|
|
8379
|
-
watched
|
|
8380
|
-
widget
|
|
8436
|
+
watched,
|
|
8437
|
+
widget
|
|
8381
8438
|
};
|
|
8382
8439
|
}
|
|
8383
8440
|
|
|
@@ -8395,12 +8452,12 @@ function artifactUrl(project, artifact) {
|
|
|
8395
8452
|
return `${serverOrigin()}${ARTIFACT_PATH2}${artifact.hash}.wasm`;
|
|
8396
8453
|
}
|
|
8397
8454
|
function packageFor(file) {
|
|
8398
|
-
let dir =
|
|
8455
|
+
let dir = import_node_path18.default.dirname(file);
|
|
8399
8456
|
const stop = devServer?.config.root;
|
|
8400
8457
|
for (; ; ) {
|
|
8401
|
-
if (
|
|
8402
|
-
if (stop !== void 0 && dir === stop ||
|
|
8403
|
-
dir =
|
|
8458
|
+
if (import_node_fs17.default.existsSync(import_node_path18.default.join(dir, "Package.swift"))) return dir;
|
|
8459
|
+
if (stop !== void 0 && dir === stop || import_node_path18.default.dirname(dir) === dir) break;
|
|
8460
|
+
dir = import_node_path18.default.dirname(dir);
|
|
8404
8461
|
}
|
|
8405
8462
|
throw new Error(
|
|
8406
8463
|
`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 +8478,9 @@ function swiftPlugin(options = {}) {
|
|
|
8421
8478
|
if (!resolved) throw new Error(`cannot resolve swift source ${source}`);
|
|
8422
8479
|
let id = resolved.id;
|
|
8423
8480
|
if (importer && (source.startsWith("./") || source.startsWith("../"))) {
|
|
8424
|
-
const raw2 =
|
|
8481
|
+
const raw2 = import_node_path18.default.resolve(import_node_path18.default.dirname(importer.split("?")[0] ?? importer), source);
|
|
8425
8482
|
try {
|
|
8426
|
-
if (
|
|
8483
|
+
if (import_node_fs17.default.realpathSync(raw2) === import_node_fs17.default.realpathSync(resolved.id)) id = raw2;
|
|
8427
8484
|
} catch {
|
|
8428
8485
|
}
|
|
8429
8486
|
}
|
|
@@ -8432,22 +8489,22 @@ function swiftPlugin(options = {}) {
|
|
|
8432
8489
|
async load(id) {
|
|
8433
8490
|
if (!id.startsWith(VIRTUAL_PREFIX)) return null;
|
|
8434
8491
|
const file = id.slice(VIRTUAL_PREFIX.length);
|
|
8435
|
-
if (!
|
|
8492
|
+
if (!import_node_fs17.default.existsSync(file)) throw new Error(`swift source ${file} no longer exists`);
|
|
8436
8493
|
const packagePath = options.packagePath ?? packageFor(file);
|
|
8437
8494
|
const project = projectFor(packagePath);
|
|
8438
|
-
const entry =
|
|
8495
|
+
const entry = import_node_path18.default.relative(packagePath, file).split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep);
|
|
8439
8496
|
for (const source of [
|
|
8440
8497
|
...sourceFiles(packagePath),
|
|
8441
8498
|
...nativeSourceFiles(packagePath)
|
|
8442
8499
|
])
|
|
8443
8500
|
this.addWatchFile(source);
|
|
8444
|
-
this.addWatchFile(
|
|
8501
|
+
this.addWatchFile(import_node_path18.default.join(packagePath, "Package.swift"));
|
|
8445
8502
|
const moduleRoot = linkedModuleRoots(packagePath).find(
|
|
8446
|
-
(root) =>
|
|
8503
|
+
(root) => import_node_fs17.default.existsSync(import_node_path18.default.join(root, "toolchain.json"))
|
|
8447
8504
|
);
|
|
8448
8505
|
if (moduleRoot)
|
|
8449
8506
|
for (const relative of swiftModuleInputFiles(moduleRoot))
|
|
8450
|
-
this.addWatchFile(
|
|
8507
|
+
this.addWatchFile(import_node_path18.default.join(moduleRoot, relative));
|
|
8451
8508
|
let artifact;
|
|
8452
8509
|
try {
|
|
8453
8510
|
artifact = await artifactFor(project, entry);
|
|
@@ -8466,7 +8523,7 @@ function swiftPlugin(options = {}) {
|
|
|
8466
8523
|
...artifact.package.resources.watched,
|
|
8467
8524
|
...artifact.package.bundleFiles.watched
|
|
8468
8525
|
])
|
|
8469
|
-
this.addWatchFile(
|
|
8526
|
+
this.addWatchFile(import_node_path18.default.join(packagePath, ...watched.split(import_node_path18.default.posix.sep)));
|
|
8470
8527
|
const colors = artifact.package.resources.colors;
|
|
8471
8528
|
const symbols = artifact.package.resources.symbols;
|
|
8472
8529
|
const bundleFiles = artifact.package.bundleFiles.files;
|