peachsim 0.1.686 → 0.1.688
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-client.ts +3 -3
- package/cli/command-registry.ts +2 -0
- package/cli/commands/control.ts +1 -0
- package/cli/commands/debug.ts +10 -33
- package/cli/commands/do-chain.ts +56 -6
- package/cli/commands/inspect/core.ts +2 -0
- package/cli/commands/inspect/list.ts +2 -1
- package/cli/commands/inspect/settling.ts +17 -3
- package/cli/commands/inspect/shared.ts +2 -0
- package/cli/commands/inspect/wait-idle.ts +2 -2
- package/cli/commands/inspect/wait-ready.ts +3 -3
- package/cli/commands/inspect.ts +33 -7
- package/cli/commands/location.ts +164 -0
- package/cli/commands/platform.ts +1 -1
- package/cli/drivers/playwright-sim-host.ts +46 -25
- package/cli/main.ts +6 -0
- package/detox/index.ts +13 -8
- 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 +4 -3
- package/dist-lib/bridge-contract-input.cjs +12 -1
- package/dist-lib/bridge-contract-input.mjs +12 -1
- package/dist-lib/bridge-contract.cjs +4 -3
- package/dist-lib/bridge-contract.mjs +4 -3
- 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 +2 -1
- package/dist-lib/cloud-contract.mjs +2 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +2 -1
- package/dist-lib/cloud.mjs +2 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1197 -65
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +402 -113
- package/dist-lib/host/fetch-proxy-handler.cjs +50 -40
- package/dist-lib/host/fetch-proxy-overrides.cjs +50 -6
- package/dist-lib/host/fetch-proxy-overrides.mjs +48 -5
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +29 -11
- 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 +89 -13
- 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 +5 -3
- package/dist-lib/native-app-identity.cjs +8 -3
- package/dist-lib/native-app-identity.mjs +8 -3
- 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 +2 -2
- package/dist-lib/sdk.cjs +21 -6
- package/dist-lib/sdk.mjs +21 -6
- package/dist-lib/skills.cjs +441 -135
- package/dist-lib/swift-compile.cjs +317 -27
- package/dist-lib/swift-compile.mjs +315 -27
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +10 -10
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +320 -49
- package/dist-lib/vite.cjs +1 -1
- package/kotlin/AppSources/android/content/res/Configuration.kt +2 -0
- package/kotlin/AppSources/android/content/res/Resources.kt +6 -3
- package/kotlin/AppSources/android/util/DisplayMetrics.kt +12 -0
- package/kotlin/AppSources/androidx/compose/ui/res/PainterResources.kt +70 -0
- package/kotlin/AppSources/dev/peach/app/PeachApp.kt +12 -10
- package/kotlin/AppSources/dev/peach/app/PeachDrawable.kt +95 -0
- package/kotlin/fixtures/kotlin-app-variants/Bitmaps.kt +50 -0
- package/kotlin/fixtures/kotlin-app-variants/Drawables.kt +53 -0
- package/package.json +2 -2
- package/scripts/dev-server-scanner.ts +3 -1
- package/skills/contrast/SKILL.md +1 -0
- package/src/android-drawables.ts +315 -0
- package/src/android-theme.ts +9 -0
- package/src/bridge-constants.ts +3 -2
- package/src/bridge-contract-input.ts +11 -0
- package/src/bridge-contract.ts +45 -3
- package/src/cloud-contract.ts +1 -0
- package/src/host/fetch-proxy-handler.ts +13 -49
- package/src/host/fetch-proxy-overrides.ts +69 -12
- package/src/kotlin-app.ts +6 -0
- package/src/kotlin-host.ts +103 -15
- package/src/native-app-identity.ts +16 -3
- package/src/swift-compile.ts +426 -29
- package/src/swift-distribution-contract.ts +11 -4
- package/src/swift-distribution.lock.json +11 -9
- package/src/swift-distribution.ts +4 -4
- package/src/swift-icu.ts +8 -11
- package/src/swift-submit.ts +13 -1
- package/src/swift-toolchain.ts +17 -9
- package/src/vite-plugin.ts +86 -34
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.688 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
|
|
3
3
|
// src/swift-compile.ts
|
|
4
4
|
import { execFile as execFile2 } from "node:child_process";
|
|
5
5
|
import { createHash as createHash2 } from "node:crypto";
|
|
6
6
|
import {
|
|
7
|
+
cpSync,
|
|
7
8
|
existsSync,
|
|
8
9
|
mkdirSync,
|
|
9
10
|
readFileSync as readFileSync2,
|
|
@@ -31,7 +32,7 @@ var SWIFT_DISTRIBUTION_HOSTS = [
|
|
|
31
32
|
];
|
|
32
33
|
var isStrings = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
33
34
|
function parseSwiftDistributionManifest(value) {
|
|
34
|
-
if (!isRecord(value) || typeof value.id !== "string" || typeof value.release !== "string" || typeof value.wasmSdkChecksum !== "string" || !isStrings(value.modules) || !isStrings(value.objects) || !isStrings(value.link) || !isRecord(value.files) || !Object.values(value.files).every((sha) => typeof sha === "string") || typeof value.host !== "string" || !isStrings(value.plugins)) {
|
|
35
|
+
if (!isRecord(value) || typeof value.id !== "string" || typeof value.release !== "string" || typeof value.wasmSdkId !== "string" || typeof value.wasmSdkUrl !== "string" || typeof value.wasmSdkChecksum !== "string" || !isStrings(value.modules) || !isStrings(value.objects) || !isStrings(value.link) || !isRecord(value.files) || !Object.values(value.files).every((sha) => typeof sha === "string") || typeof value.host !== "string" || !isStrings(value.plugins)) {
|
|
35
36
|
throw new Error(`invalid Swift distribution ${SWIFT_DISTRIBUTION_MANIFEST}`);
|
|
36
37
|
}
|
|
37
38
|
const host2 = SWIFT_DISTRIBUTION_HOSTS.find((candidate) => candidate === value.host);
|
|
@@ -39,6 +40,8 @@ function parseSwiftDistributionManifest(value) {
|
|
|
39
40
|
return {
|
|
40
41
|
id: value.id,
|
|
41
42
|
release: value.release,
|
|
43
|
+
wasmSdkId: value.wasmSdkId,
|
|
44
|
+
wasmSdkUrl: value.wasmSdkUrl,
|
|
42
45
|
wasmSdkChecksum: value.wasmSdkChecksum,
|
|
43
46
|
modules: value.modules,
|
|
44
47
|
objects: value.objects,
|
|
@@ -73,25 +76,25 @@ function memo(cache, key, load2) {
|
|
|
73
76
|
}
|
|
74
77
|
return pending;
|
|
75
78
|
}
|
|
76
|
-
function swiftIcuData(toolchainBin,
|
|
77
|
-
return memo(raw, `${toolchainBin}\0${
|
|
79
|
+
function swiftIcuData(toolchainBin, sdk) {
|
|
80
|
+
return memo(raw, `${toolchainBin}\0${sdk}`, () => load(toolchainBin, sdk));
|
|
78
81
|
}
|
|
79
|
-
function swiftIcuAsset(toolchainBin,
|
|
80
|
-
return memo(assets, `${toolchainBin}\0${
|
|
81
|
-
const zipped = await deflate(await swiftIcuData(toolchainBin,
|
|
82
|
+
function swiftIcuAsset(toolchainBin, sdk) {
|
|
83
|
+
return memo(assets, `${toolchainBin}\0${sdk}`, async () => {
|
|
84
|
+
const zipped = await deflate(await swiftIcuData(toolchainBin, sdk));
|
|
82
85
|
return { sha256: createHash("sha256").update(zipped).digest("hex"), gzip: zipped };
|
|
83
86
|
});
|
|
84
87
|
}
|
|
85
|
-
async function load(toolchainBin,
|
|
88
|
+
async function load(toolchainBin, sdk) {
|
|
86
89
|
const { stdout } = await run(path.join(toolchainBin, "swift"), [
|
|
87
90
|
"sdk",
|
|
88
91
|
"configure",
|
|
89
92
|
"--show-configuration",
|
|
90
|
-
|
|
93
|
+
sdk,
|
|
91
94
|
"wasm32-unknown-wasip1"
|
|
92
95
|
]);
|
|
93
96
|
const resources = /^swiftStaticResourcesPath: (.+)$/m.exec(stdout)?.[1]?.trim();
|
|
94
|
-
if (!resources) throw new Error(`swift-icu: ${
|
|
97
|
+
if (!resources) throw new Error(`swift-icu: ${sdk} names no static resources`);
|
|
95
98
|
return Buffer.from(
|
|
96
99
|
icuSegment(archiveMember(readFileSync(path.join(resources, ARCHIVE)), MEMBER))
|
|
97
100
|
);
|
|
@@ -220,6 +223,16 @@ function swiftDistributionAt(root) {
|
|
|
220
223
|
if (!existsSync(file)) return null;
|
|
221
224
|
return parseSwiftDistributionManifest(JSON.parse(readFileSync2(file, "utf8")));
|
|
222
225
|
}
|
|
226
|
+
function swiftModuleSdk(root) {
|
|
227
|
+
const pin = swiftDistributionAt(root) ?? JSON.parse(readFileSync2(path2.join(root, "toolchain.json"), "utf8"));
|
|
228
|
+
if (!pin || typeof pin !== "object" || typeof Reflect.get(pin, "wasmSdkId") !== "string" || typeof Reflect.get(pin, "wasmSdkUrl") !== "string" || typeof Reflect.get(pin, "wasmSdkChecksum") !== "string")
|
|
229
|
+
throw new Error(`${root} pins no wasm SDK id, url and checksum`);
|
|
230
|
+
return {
|
|
231
|
+
wasmSdkId: String(Reflect.get(pin, "wasmSdkId")),
|
|
232
|
+
wasmSdkUrl: String(Reflect.get(pin, "wasmSdkUrl")),
|
|
233
|
+
wasmSdkChecksum: String(Reflect.get(pin, "wasmSdkChecksum"))
|
|
234
|
+
};
|
|
235
|
+
}
|
|
223
236
|
function swiftModuleInputFiles(root) {
|
|
224
237
|
if (swiftDistributionAt(root)) return [SWIFT_DISTRIBUTION_MANIFEST];
|
|
225
238
|
const files = [
|
|
@@ -231,7 +244,7 @@ function swiftModuleInputFiles(root) {
|
|
|
231
244
|
for (const entry of readdirSync(path2.join(root, dir), { withFileTypes: true })) {
|
|
232
245
|
const relative = `${dir}/${entry.name}`;
|
|
233
246
|
if (entry.isDirectory()) walk(relative);
|
|
234
|
-
else if (/\.(swift|c|h)$/.test(entry.name)) files.push(relative);
|
|
247
|
+
else if (/\.(swift|c|cpp|h)$/.test(entry.name)) files.push(relative);
|
|
235
248
|
}
|
|
236
249
|
};
|
|
237
250
|
walk("Sources");
|
|
@@ -314,14 +327,29 @@ function withNativeSourceGlue(input, glue) {
|
|
|
314
327
|
oneModule: true
|
|
315
328
|
};
|
|
316
329
|
}
|
|
317
|
-
|
|
318
|
-
|
|
330
|
+
var OPTIONAL_FRAMEWORK_DEPENDENCIES = {
|
|
331
|
+
Accelerate: [],
|
|
332
|
+
CryptoKit: [],
|
|
333
|
+
Security: [],
|
|
334
|
+
Statsig: [],
|
|
335
|
+
DatadogCore: [],
|
|
336
|
+
DatadogLogs: ["DatadogCore"],
|
|
337
|
+
DatadogRUM: ["DatadogCore"],
|
|
338
|
+
DatadogTrace: ["DatadogCore"]
|
|
339
|
+
};
|
|
340
|
+
var OPTIONAL_FRAMEWORKS = new Set(Object.keys(OPTIONAL_FRAMEWORK_DEPENDENCIES));
|
|
341
|
+
function swiftTargetDependencies(files, targets) {
|
|
342
|
+
const names = /* @__PURE__ */ new Set([...OPTIONAL_FRAMEWORKS, ...targets.map((target) => target.name)]);
|
|
319
343
|
const siblings = /* @__PURE__ */ new Map();
|
|
320
344
|
for (const target of targets) {
|
|
321
|
-
const prefix = `${target.path}/`;
|
|
345
|
+
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
322
346
|
const deps = /* @__PURE__ */ new Set();
|
|
323
347
|
for (const [file, contents] of Object.entries(files)) {
|
|
324
348
|
if (file === "Package.swift" || !file.startsWith(prefix)) continue;
|
|
349
|
+
if (targets.some(
|
|
350
|
+
(candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
|
|
351
|
+
))
|
|
352
|
+
continue;
|
|
325
353
|
for (const match of contents.matchAll(
|
|
326
354
|
/^\s*(?:@\w+(?:\([^)]*\))?\s+)*import\s+(?:(?:typealias|struct|class|enum|protocol|let|var|func)\s+)?([A-Za-z_][A-Za-z0-9_]*)/gm
|
|
327
355
|
)) {
|
|
@@ -339,12 +367,12 @@ var importsSpriteKit = (files) => Object.entries(files).some(
|
|
|
339
367
|
contents
|
|
340
368
|
)
|
|
341
369
|
);
|
|
342
|
-
var
|
|
370
|
+
var FOUNDATION_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "PeachObjC", "-Xfrontend", "-import-module", "-Xfrontend", "Dispatch", "-Xfrontend", "-import-module", "-Xfrontend", "FoundationNetworking"';
|
|
343
371
|
var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
|
|
344
|
-
var MULTI_MANIFEST_VERSION =
|
|
372
|
+
var MULTI_MANIFEST_VERSION = 10;
|
|
345
373
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
346
374
|
const hash = createHash2("sha256");
|
|
347
|
-
hash.update(`swift-compile/
|
|
375
|
+
hash.update(`swift-compile/v12
|
|
348
376
|
${release}
|
|
349
377
|
`);
|
|
350
378
|
if (input.oneModule) hash.update("one-module\n");
|
|
@@ -373,7 +401,7 @@ ${release}
|
|
|
373
401
|
hash.update(
|
|
374
402
|
JSON.stringify({
|
|
375
403
|
targets,
|
|
376
|
-
siblings: [...
|
|
404
|
+
siblings: [...swiftTargetDependencies(input.files, targets)].sort(
|
|
377
405
|
(a, b) => String(a) < String(b) ? -1 : String(a) > String(b) ? 1 : 0
|
|
378
406
|
)
|
|
379
407
|
})
|
|
@@ -383,22 +411,34 @@ ${release}
|
|
|
383
411
|
}
|
|
384
412
|
function emitSwiftPackageManifest(args) {
|
|
385
413
|
const { targets, siblings, moduleRoot, oneModule, spriteKit, distribution } = args;
|
|
414
|
+
const reachedFrameworks = new Set(
|
|
415
|
+
[...siblings.values()].flat().filter(
|
|
416
|
+
(name) => OPTIONAL_FRAMEWORKS.has(name) && !targets.some((target) => target.name === name)
|
|
417
|
+
).flatMap((name) => [name, ...OPTIONAL_FRAMEWORK_DEPENDENCIES[name] ?? []])
|
|
418
|
+
);
|
|
419
|
+
const distributionObjects = distribution?.objects.filter(
|
|
420
|
+
(object) => [...OPTIONAL_FRAMEWORKS].every(
|
|
421
|
+
(name) => !object.startsWith(`lib/${name}-`) || reachedFrameworks.has(name)
|
|
422
|
+
)
|
|
423
|
+
);
|
|
386
424
|
const executable = targets.find((target) => target.executable);
|
|
387
425
|
if (!executable) throw new Error("swift-compile: no executable target to emit");
|
|
388
426
|
const stanza = (target) => {
|
|
389
427
|
const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
|
|
390
428
|
const imports = distribution ? `, "-I", ${JSON.stringify(path2.join(moduleRoot, "modules"))}` : "";
|
|
391
|
-
const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation} .unsafeFlags(["-Osize"${
|
|
429
|
+
const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation} .unsafeFlags(["-Osize"${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}])]`;
|
|
392
430
|
const deps = [
|
|
393
431
|
...distribution ? [] : [
|
|
394
432
|
'.product(name: "SwiftUI", package: "sootsim-swift")',
|
|
395
433
|
...oneModule ? [ONE_PRODUCT] : [],
|
|
396
434
|
...spriteKit ? [SPRITEKIT_PRODUCT] : []
|
|
397
435
|
],
|
|
398
|
-
...(siblings.get(target.name) ?? []).
|
|
436
|
+
...(siblings.get(target.name) ?? []).flatMap(
|
|
437
|
+
(dependency) => OPTIONAL_FRAMEWORKS.has(dependency) && !targets.some((candidate) => candidate.name === dependency) ? distribution ? [] : [`.product(name: "${dependency}", package: "sootsim-swift")`] : [`"${dependency}"`]
|
|
438
|
+
)
|
|
399
439
|
].join(", ");
|
|
400
440
|
const library = distribution ? [
|
|
401
|
-
...
|
|
441
|
+
...(distributionObjects ?? []).map((object) => path2.join(moduleRoot, object)),
|
|
402
442
|
...distribution.link
|
|
403
443
|
].map((flag) => `, ${JSON.stringify(flag)}`).join("") : "";
|
|
404
444
|
const kind = target.executable ? ".executableTarget" : ".target";
|
|
@@ -456,8 +496,185 @@ var DIRECTIVE = /^[ \t]*#(?:if|elseif)\b/;
|
|
|
456
496
|
var OS_IOS = /\bos\(\s*iOS\s*\)/g;
|
|
457
497
|
var OBJC_ATTRIBUTE = /^@(?:objcMembers\b|objc\b(?:(\s*)\(([^()]*)\))?|IBAction\b)/;
|
|
458
498
|
var SELECTOR = /^#selector\b/;
|
|
499
|
+
var TYPE_AFTER_ATTRIBUTE = /^(?:\s+|\/\/[^\n]*|\/\*[\s\S]*?\*\/|@\w+(?:\([^()]*\))?|\b(?:public|open|final|internal|fileprivate|private|package|nonisolated|indirect)\b)*\b(?:class(?!\s+(?:func|var|let|subscript)\b)|struct|enum|protocol|extension|actor)\b/;
|
|
459
500
|
var DELEGATE_CLASS = /^class\s+[A-Za-z_]\w*\s*(?:<[^>{]*>)?\s*:[^{]*\b(?:UIApplicationDelegate|UISceneDelegate|UIWindowSceneDelegate)\b[^{]*\{/;
|
|
460
|
-
|
|
501
|
+
var REUSABLE_INIT = /^override(?=\s+init\s*\(\s*(?:style\s*:[^,)]*,\s*reuseIdentifier|reuseIdentifier)\s*:)/;
|
|
502
|
+
var REUSABLE_VIEW_BASES = [
|
|
503
|
+
"UICollectionReusableView",
|
|
504
|
+
"UICollectionViewCell",
|
|
505
|
+
"UICollectionViewListCell"
|
|
506
|
+
];
|
|
507
|
+
var CLASS_BASE = /^class\s+([A-Za-z_]\w*)\s*(?:<[^>{]*>)?\s*:\s*([A-Za-z_][\w.]*)[^{]*\{/;
|
|
508
|
+
var FRAME_INIT = /^override(?=\s+(?:(?:public|open|internal)\s+)?init\s*\(\s*frame\s*:)/;
|
|
509
|
+
var APPLE_CLASS = /^(?:UI|NS|CA|SK|WK|MK|AV|PK|CL|GK|PH|SF|AS|QL)[A-Z]/;
|
|
510
|
+
var EXTENSION_DECL = /^extension\s+([A-Za-z_][\w.]*)/;
|
|
511
|
+
var CLASS_DECL = /^class\s+(?!(?:func|var|let|subscript)\b)([A-Za-z_]\w*)/;
|
|
512
|
+
var MODIFIERS = /(?:^|\s)(public|open|internal|fileprivate|private|final|nonisolated|@MainActor)(?=\s)/g;
|
|
513
|
+
var OVERRIDE_FUNC = /^override((?:\s+(?:public|open|internal|fileprivate|private|final|nonisolated|dynamic|@\w+))*)\s+func\s+([A-Za-z_]\w*)\s*(<[^>{}]*>)?\s*\(/;
|
|
514
|
+
var OVERRIDE_VAR = /^override((?:\s+(?:public|open|internal|fileprivate|private|final|nonisolated|dynamic|@\w+))*)\s+var\s+([A-Za-z_]\w*)\s*:\s*([^{=]+?)\s*\{/;
|
|
515
|
+
function splitTopLevel(text) {
|
|
516
|
+
const parts = [];
|
|
517
|
+
let depth = 0;
|
|
518
|
+
let start = 0;
|
|
519
|
+
for (let i = 0; i < text.length; i++) {
|
|
520
|
+
const char = text[i];
|
|
521
|
+
if (char === "(" || char === "[" || char === "<") depth++;
|
|
522
|
+
else if (char === ")" || char === "]" || char === ">" && text[i - 1] !== "-")
|
|
523
|
+
depth--;
|
|
524
|
+
else if (char === "," && depth === 0) {
|
|
525
|
+
parts.push(text.slice(start, i));
|
|
526
|
+
start = i + 1;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
parts.push(text.slice(start));
|
|
530
|
+
return parts.map((part) => part.trim()).filter((part) => part !== "");
|
|
531
|
+
}
|
|
532
|
+
function forwardedArguments(parameters) {
|
|
533
|
+
const args = [];
|
|
534
|
+
for (const parameter of splitTopLevel(parameters)) {
|
|
535
|
+
const match = /^(?:([A-Za-z_]\w*)\s+)?([A-Za-z_]\w*)\s*:\s*([\s\S]*)$/.exec(parameter);
|
|
536
|
+
if (!match || match[3].includes("...")) return null;
|
|
537
|
+
const label = match[1] ?? match[2];
|
|
538
|
+
const value = (/^(?:@\w+\s+)*inout\b/.test(match[3]) ? "&" : "") + match[2];
|
|
539
|
+
args.push(label === "_" ? value : `${label}: ${value}`);
|
|
540
|
+
}
|
|
541
|
+
return args.join(", ");
|
|
542
|
+
}
|
|
543
|
+
function liftExtensionOverrides(source) {
|
|
544
|
+
const { tokens } = swiftCodeScan(source);
|
|
545
|
+
const stack = [];
|
|
546
|
+
let pending = null;
|
|
547
|
+
const classes = /* @__PURE__ */ new Map();
|
|
548
|
+
let declaredBase = null;
|
|
549
|
+
let declaredObjCMembers = false;
|
|
550
|
+
const lifted = [];
|
|
551
|
+
const closing = (open) => {
|
|
552
|
+
let depth = 0;
|
|
553
|
+
for (const at of tokens) {
|
|
554
|
+
if (at < open) continue;
|
|
555
|
+
if (source[at] === "{") depth++;
|
|
556
|
+
else if (source[at] === "}" && --depth === 0) return at + 1;
|
|
557
|
+
}
|
|
558
|
+
return source.length;
|
|
559
|
+
};
|
|
560
|
+
for (const at of tokens) {
|
|
561
|
+
const rest = source.slice(at, at + 600);
|
|
562
|
+
if (rest.startsWith("{")) {
|
|
563
|
+
const frame = pending ?? { kind: "other", name: "" };
|
|
564
|
+
if (frame.kind === "class" && !classes.has(frame.name))
|
|
565
|
+
classes.set(frame.name, {
|
|
566
|
+
brace: at,
|
|
567
|
+
base: declaredBase,
|
|
568
|
+
objcMembers: declaredObjCMembers
|
|
569
|
+
});
|
|
570
|
+
stack.push(frame);
|
|
571
|
+
pending = null;
|
|
572
|
+
continue;
|
|
573
|
+
}
|
|
574
|
+
if (rest.startsWith("}")) {
|
|
575
|
+
stack.pop();
|
|
576
|
+
continue;
|
|
577
|
+
}
|
|
578
|
+
const declared = CLASS_DECL.exec(rest);
|
|
579
|
+
if (declared) {
|
|
580
|
+
pending = { kind: "class", name: declared[1] };
|
|
581
|
+
declaredBase = CLASS_BASE.exec(rest)?.[2]?.split(".").pop() ?? null;
|
|
582
|
+
const lines = source.lastIndexOf("\n", source.lastIndexOf("\n", at - 1) - 1) + 1;
|
|
583
|
+
declaredObjCMembers = /@objcMembers\b/.test(source.slice(lines, at));
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
const extended = EXTENSION_DECL.exec(rest);
|
|
587
|
+
if (extended) {
|
|
588
|
+
pending = { kind: "extension", name: extended[1].split(".").pop() };
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
591
|
+
const top = stack.at(-1);
|
|
592
|
+
if (!rest.startsWith("override") || top?.kind !== "extension" || pending) continue;
|
|
593
|
+
const line = source.slice(source.lastIndexOf("\n", at - 1) + 1, at);
|
|
594
|
+
const modifiers = (` ${line} `.match(MODIFIERS) ?? []).map((word) => word.trim());
|
|
595
|
+
const func = OVERRIDE_FUNC.exec(rest);
|
|
596
|
+
if (func) {
|
|
597
|
+
const name = func[2];
|
|
598
|
+
const open = at + func[0].length - 1;
|
|
599
|
+
let depth = 0;
|
|
600
|
+
let close = open;
|
|
601
|
+
for (; close < source.length; close++) {
|
|
602
|
+
if (source[close] === "(") depth++;
|
|
603
|
+
else if (source[close] === ")" && --depth === 0) break;
|
|
604
|
+
}
|
|
605
|
+
const body = tokens.find((token) => token > close && source[token] === "{");
|
|
606
|
+
if (body === void 0) continue;
|
|
607
|
+
const clause = source.slice(close + 1, body).trim();
|
|
608
|
+
const args = forwardedArguments(source.slice(open + 1, close));
|
|
609
|
+
if (args === null) continue;
|
|
610
|
+
const call = (clause.includes("->") ? "return " : "") + (/\b(?:throws|rethrows)\b/.test(clause) ? "try " : "") + (/\basync\b/.test(clause) ? "await " : "") + `__peach_ext_${name}(${args})`;
|
|
611
|
+
const signature = `func ${name}${func[3] ?? ""}${source.slice(open, close + 1)}${clause ? ` ${clause}` : ""}`;
|
|
612
|
+
lifted.push({
|
|
613
|
+
type: top.name,
|
|
614
|
+
member: name,
|
|
615
|
+
stub: `${[...modifiers, "override"].join(" ")} ${signature} { ${call} };`,
|
|
616
|
+
edits: [
|
|
617
|
+
[at, "override".length, " ".repeat("override".length)],
|
|
618
|
+
[
|
|
619
|
+
at + rest.indexOf(
|
|
620
|
+
name,
|
|
621
|
+
rest.indexOf("func", "override".length + func[1].length) + 4
|
|
622
|
+
),
|
|
623
|
+
0,
|
|
624
|
+
"__peach_ext_"
|
|
625
|
+
]
|
|
626
|
+
]
|
|
627
|
+
});
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
const property = OVERRIDE_VAR.exec(rest);
|
|
631
|
+
if (property) {
|
|
632
|
+
const open = at + property[0].length - 1;
|
|
633
|
+
if (/\b(?:set|willSet|didSet)\b/.test(source.slice(open, closing(open)))) continue;
|
|
634
|
+
const name = property[2];
|
|
635
|
+
lifted.push({
|
|
636
|
+
type: top.name,
|
|
637
|
+
member: name,
|
|
638
|
+
stub: `${[...modifiers, "override"].join(" ")} var ${name}: ${property[3].trim()} { __peach_ext_${name} };`,
|
|
639
|
+
edits: [
|
|
640
|
+
[at, "override".length, " ".repeat("override".length)],
|
|
641
|
+
[at + rest.indexOf(name, rest.indexOf("var")), 0, "__peach_ext_"]
|
|
642
|
+
]
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
const overridesObjC = (type, member) => {
|
|
647
|
+
let base = classes.get(type)?.base ?? null;
|
|
648
|
+
while (base !== null) {
|
|
649
|
+
if (APPLE_CLASS.test(base)) return true;
|
|
650
|
+
const declaredClass = classes.get(base);
|
|
651
|
+
if (!declaredClass) return false;
|
|
652
|
+
const body = source.slice(declaredClass.brace, closing(declaredClass.brace));
|
|
653
|
+
const found = new RegExp(`\\b(?:func|var)\\s+${member}\\b`).exec(body);
|
|
654
|
+
if (found) {
|
|
655
|
+
const line = body.slice(body.lastIndexOf("\n", found.index) + 1, found.index);
|
|
656
|
+
return declaredClass.objcMembers || /@objc\b/.test(line);
|
|
657
|
+
}
|
|
658
|
+
base = declaredClass.base;
|
|
659
|
+
}
|
|
660
|
+
return false;
|
|
661
|
+
};
|
|
662
|
+
const edits = [];
|
|
663
|
+
const stubs = /* @__PURE__ */ new Map();
|
|
664
|
+
for (const entry of lifted) {
|
|
665
|
+
const brace = classes.get(entry.type)?.brace;
|
|
666
|
+
if (brace === void 0 || !overridesObjC(entry.type, entry.member)) continue;
|
|
667
|
+
edits.push(...entry.edits);
|
|
668
|
+
stubs.set(brace, [...stubs.get(brace) ?? [], entry.stub]);
|
|
669
|
+
}
|
|
670
|
+
for (const [brace, list] of stubs) edits.push([brace + 1, 0, ` ${list.join(" ")}`]);
|
|
671
|
+
let out = source;
|
|
672
|
+
for (const [at, remove, insert] of edits.sort((a, b) => b[0] - a[0]))
|
|
673
|
+
out = out.slice(0, at) + insert + out.slice(at + remove);
|
|
674
|
+
return out;
|
|
675
|
+
}
|
|
676
|
+
function swiftSourceAsIOS(original) {
|
|
677
|
+
const source = liftExtensionOverrides(original);
|
|
461
678
|
const { lineStarts, tokens } = swiftCodeScan(source);
|
|
462
679
|
let offset = 0;
|
|
463
680
|
const conditioned = source.split("\n").map((line) => {
|
|
@@ -468,8 +685,30 @@ function swiftSourceAsIOS(source) {
|
|
|
468
685
|
}).join("\n");
|
|
469
686
|
let out = "";
|
|
470
687
|
let copied = 0;
|
|
688
|
+
const reusableViews = new Set(REUSABLE_VIEW_BASES);
|
|
689
|
+
const reusableBodies = [];
|
|
690
|
+
let depth = 0;
|
|
691
|
+
let opensReusableBody = false;
|
|
471
692
|
for (const at of tokens) {
|
|
472
693
|
const rest = conditioned.slice(at, at + 400);
|
|
694
|
+
if (rest.startsWith("{")) {
|
|
695
|
+
depth++;
|
|
696
|
+
if (opensReusableBody) reusableBodies.push(depth);
|
|
697
|
+
opensReusableBody = false;
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
if (rest.startsWith("}")) {
|
|
701
|
+
if (reusableBodies.at(-1) === depth) reusableBodies.pop();
|
|
702
|
+
depth--;
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
if (rest.startsWith("override")) {
|
|
706
|
+
if (REUSABLE_INIT.test(rest) || reusableBodies.at(-1) === depth && FRAME_INIT.test(rest)) {
|
|
707
|
+
out += `${conditioned.slice(copied, at)}required`;
|
|
708
|
+
copied = at + "override".length;
|
|
709
|
+
}
|
|
710
|
+
continue;
|
|
711
|
+
}
|
|
473
712
|
const imported = /^import\s+CoreImage\.CIFilterBuiltins\b/.exec(rest);
|
|
474
713
|
if (imported) {
|
|
475
714
|
out += conditioned.slice(copied, at) + "import CoreImage".padEnd(imported[0].length);
|
|
@@ -482,6 +721,11 @@ function swiftSourceAsIOS(source) {
|
|
|
482
721
|
continue;
|
|
483
722
|
}
|
|
484
723
|
if (rest.startsWith("class")) {
|
|
724
|
+
const declared = CLASS_BASE.exec(rest);
|
|
725
|
+
if (declared && reusableViews.has(declared[2].split(".").pop())) {
|
|
726
|
+
reusableViews.add(declared[1]);
|
|
727
|
+
opensReusableBody = true;
|
|
728
|
+
}
|
|
485
729
|
const modifiers = conditioned.slice(conditioned.lastIndexOf("\n", at - 1) + 1, at);
|
|
486
730
|
if (DELEGATE_CLASS.test(rest) && !/\b(?:final|open)\b/.test(modifiers)) {
|
|
487
731
|
out += `${conditioned.slice(copied, at)}final `;
|
|
@@ -496,6 +740,8 @@ function swiftSourceAsIOS(source) {
|
|
|
496
740
|
if (selector) replacement = "#Selector";
|
|
497
741
|
else if (match[0] === "@objcMembers") replacement = "@ObjCMembers";
|
|
498
742
|
else if (match[0] === "@IBAction") replacement = "@ObjC".padEnd(match[0].length);
|
|
743
|
+
else if (TYPE_AFTER_ATTRIBUTE.test(rest.slice(match[0].length)))
|
|
744
|
+
replacement = " ".repeat(match[0].length);
|
|
499
745
|
else if (match[2] !== void 0)
|
|
500
746
|
replacement = `@ObjC${match[1]}("${match[2].trim()}")`;
|
|
501
747
|
out += conditioned.slice(copied, at) + replacement;
|
|
@@ -574,6 +820,9 @@ function swiftCodeScan(source) {
|
|
|
574
820
|
if (hashes > 0) tokens.push(at - 1);
|
|
575
821
|
i = Math.max(at, i + 1);
|
|
576
822
|
}
|
|
823
|
+
} else if (char === "{" || char === "}") {
|
|
824
|
+
tokens.push(i);
|
|
825
|
+
i++;
|
|
577
826
|
} else if (char === "(") {
|
|
578
827
|
top.parens++;
|
|
579
828
|
i++;
|
|
@@ -582,7 +831,7 @@ function swiftCodeScan(source) {
|
|
|
582
831
|
else top.parens--;
|
|
583
832
|
i++;
|
|
584
833
|
} else {
|
|
585
|
-
const keyword = source.startsWith("class", i) ? "class" : source.startsWith("import", i) ? "import" : source.startsWith("NSClassFromString", i) ? "NSClassFromString" : null;
|
|
834
|
+
const keyword = source.startsWith("class", i) ? "class" : source.startsWith("extension", i) ? "extension" : source.startsWith("override", i) ? "override" : source.startsWith("import", i) ? "import" : source.startsWith("NSClassFromString", i) ? "NSClassFromString" : null;
|
|
586
835
|
if (keyword && !/[\w$]/.test(source[i - 1] ?? "") && !/[\w$]/.test(source[i + keyword.length] ?? "")) {
|
|
587
836
|
tokens.push(i);
|
|
588
837
|
i += keyword.length;
|
|
@@ -595,6 +844,23 @@ function swiftCodeScan(source) {
|
|
|
595
844
|
return { lineStarts: starts, tokens };
|
|
596
845
|
}
|
|
597
846
|
var compiledSource = (file, contents) => file.endsWith(".swift") ? swiftSourceAsIOS(contents) : contents;
|
|
847
|
+
function prepareSwiftDependency(source, destination) {
|
|
848
|
+
rmSync(destination, { recursive: true, force: true });
|
|
849
|
+
const copy = (from, to, root) => {
|
|
850
|
+
mkdirSync(to, { recursive: true });
|
|
851
|
+
for (const entry of readdirSync(from, { withFileTypes: true })) {
|
|
852
|
+
if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
|
|
853
|
+
continue;
|
|
854
|
+
const file = path2.join(from, entry.name);
|
|
855
|
+
const target = path2.join(to, entry.name);
|
|
856
|
+
if (entry.isDirectory()) copy(file, target, false);
|
|
857
|
+
else if (entry.isFile() && entry.name.endsWith(".swift") && !(root && /^Package(@swift-[\d.]+)?\.swift$/.test(entry.name)))
|
|
858
|
+
writeFileSync(target, compiledSource(file, readFileSync2(file, "utf8")));
|
|
859
|
+
else cpSync(file, target, { verbatimSymlinks: true });
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
copy(source, destination, true);
|
|
863
|
+
}
|
|
598
864
|
function writeSwiftProject(layout, input, moduleRoot) {
|
|
599
865
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
600
866
|
const targets = distribution && compileTargets(input).length === 0 ? [
|
|
@@ -620,9 +886,24 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
620
886
|
path2.join(moduleRoot, "scripts/contrast-app-Package.swift"),
|
|
621
887
|
"utf8"
|
|
622
888
|
).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
|
|
889
|
+
const optionalProducts = swiftTargetDependencies(input.files, [{ name: "App", path: "." }]).get("App") ?? [];
|
|
890
|
+
if (optionalProducts.length > 0) {
|
|
891
|
+
const product = '.product(name: "SwiftUI", package: "sootsim-swift"),';
|
|
892
|
+
if (!manifest.includes(product))
|
|
893
|
+
throw new Error("Swift app template lost its framework dependency anchor");
|
|
894
|
+
manifest = manifest.replace(
|
|
895
|
+
product,
|
|
896
|
+
[
|
|
897
|
+
product,
|
|
898
|
+
...optionalProducts.map(
|
|
899
|
+
(name) => `.product(name: "${name}", package: "sootsim-swift"),`
|
|
900
|
+
)
|
|
901
|
+
].join("\n ")
|
|
902
|
+
);
|
|
903
|
+
}
|
|
623
904
|
if (input.oneModule) {
|
|
624
905
|
const product = '.product(name: "CoreLocation", package: "sootsim-swift"),';
|
|
625
|
-
const flags = `"-Osize"${
|
|
906
|
+
const flags = `"-Osize"${FOUNDATION_IMPLICIT_FLAGS}`;
|
|
626
907
|
if (!manifest.includes(product) || !manifest.includes(flags)) {
|
|
627
908
|
throw new Error(
|
|
628
909
|
"scripts/contrast-app-Package.swift lost the lines the One module links at"
|
|
@@ -665,7 +946,10 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
665
946
|
path2.join(layout.root, "Package.swift"),
|
|
666
947
|
emitSwiftPackageManifest({
|
|
667
948
|
targets,
|
|
668
|
-
siblings:
|
|
949
|
+
siblings: swiftTargetDependencies(
|
|
950
|
+
input.files,
|
|
951
|
+
layout.multi ? targets : targets.map((target) => ({ ...target, path: "." }))
|
|
952
|
+
),
|
|
669
953
|
moduleRoot,
|
|
670
954
|
oneModule: input.oneModule,
|
|
671
955
|
spriteKit: importsSpriteKit(input.files),
|
|
@@ -743,7 +1027,8 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
743
1027
|
);
|
|
744
1028
|
}
|
|
745
1029
|
const macroPlugins = await ensureMacroPlugins(moduleRoot, options.toolchainBin);
|
|
746
|
-
const
|
|
1030
|
+
const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
|
|
1031
|
+
const icu = swiftIcuAsset(options.toolchainBin, sdk);
|
|
747
1032
|
try {
|
|
748
1033
|
await run2(
|
|
749
1034
|
swift,
|
|
@@ -754,7 +1039,7 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
754
1039
|
"--package-path",
|
|
755
1040
|
root,
|
|
756
1041
|
"--swift-sdk",
|
|
757
|
-
|
|
1042
|
+
sdk,
|
|
758
1043
|
"-c",
|
|
759
1044
|
"release",
|
|
760
1045
|
"-Xswiftc",
|
|
@@ -784,12 +1069,15 @@ export {
|
|
|
784
1069
|
compileSwiftProjectUnit,
|
|
785
1070
|
compileTargets,
|
|
786
1071
|
emitSwiftPackageManifest,
|
|
1072
|
+
prepareSwiftDependency,
|
|
787
1073
|
swiftArtifactHash,
|
|
788
1074
|
swiftDistributionAt,
|
|
789
1075
|
swiftIcuAsset,
|
|
790
1076
|
swiftModuleDigest,
|
|
791
1077
|
swiftModuleInputFiles,
|
|
1078
|
+
swiftModuleSdk,
|
|
792
1079
|
swiftSourceAsIOS,
|
|
1080
|
+
swiftTargetDependencies,
|
|
793
1081
|
withNativeSourceGlue,
|
|
794
1082
|
writeSwiftProject
|
|
795
1083
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.688 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.688 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -51,7 +51,7 @@ var MAX_SWIFT_COMPILE_RESOURCE_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
|
51
51
|
var MAX_SWIFT_COMPILE_IMAGES = 128;
|
|
52
52
|
var MAX_SWIFT_COMPILE_IMAGE_BYTES = 4 * 1024 * 1024;
|
|
53
53
|
var MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024;
|
|
54
|
-
var SWIFT_HOST_ABI =
|
|
54
|
+
var SWIFT_HOST_ABI = 15;
|
|
55
55
|
var POLL_INTERVAL_MS = 1500;
|
|
56
56
|
function swiftNativeEntry(native, file) {
|
|
57
57
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.688 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
|
|
3
3
|
// src/swift-submit.ts
|
|
4
4
|
var SWIFT_COMPILE_PATH = "/api/swift-compile";
|
|
@@ -12,7 +12,7 @@ var MAX_SWIFT_COMPILE_RESOURCE_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
|
12
12
|
var MAX_SWIFT_COMPILE_IMAGES = 128;
|
|
13
13
|
var MAX_SWIFT_COMPILE_IMAGE_BYTES = 4 * 1024 * 1024;
|
|
14
14
|
var MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024;
|
|
15
|
-
var SWIFT_HOST_ABI =
|
|
15
|
+
var SWIFT_HOST_ABI = 15;
|
|
16
16
|
var POLL_INTERVAL_MS = 1500;
|
|
17
17
|
function swiftNativeEntry(native, file) {
|
|
18
18
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.688 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -56,8 +56,8 @@ function swiftToolchainBin(release) {
|
|
|
56
56
|
return (process.env.PATH ?? "").split(import_node_path.default.delimiter).find((dir) => dir && import_node_fs.default.existsSync(import_node_path.default.join(dir, "swift"))) ?? image;
|
|
57
57
|
}
|
|
58
58
|
var verified = /* @__PURE__ */ new Map();
|
|
59
|
-
function swiftToolchain(release,
|
|
60
|
-
const cached = verified.get(release);
|
|
59
|
+
function swiftToolchain(release, sdk) {
|
|
60
|
+
const cached = verified.get(`${release}\0${sdk.wasmSdkId}`);
|
|
61
61
|
if (cached) return cached;
|
|
62
62
|
const bin = swiftToolchainBin(release);
|
|
63
63
|
const swift = import_node_path.default.join(bin, "swift");
|
|
@@ -69,26 +69,26 @@ function swiftToolchain(release, wasmSdkChecksum) {
|
|
|
69
69
|
const found = version ? `found ${version.split("\n")[0]?.trim()} at ${swift}` : process.platform === "darwin" ? `found no ${release}.xctoolchain in ~/Library/Developer/Toolchains or /Library/Developer/Toolchains` : "found no swift on PATH";
|
|
70
70
|
throw new Error(
|
|
71
71
|
`peach compiles Swift with the swift.org toolchain ${release} and its wasm SDK; ${found}.
|
|
72
|
-
${swiftInstallSteps(release,
|
|
72
|
+
${swiftInstallSteps(release, sdk)}`
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
75
|
const sdks = (0, import_node_child_process.execFileSync)(swift, ["sdk", "list"], {
|
|
76
76
|
encoding: "utf8",
|
|
77
77
|
stdio: ["ignore", "pipe", "pipe"]
|
|
78
78
|
});
|
|
79
|
-
if (!sdks.split("\n").some((line) => line.trim() ===
|
|
79
|
+
if (!sdks.split("\n").some((line) => line.trim() === sdk.wasmSdkId)) {
|
|
80
80
|
throw new Error(
|
|
81
|
-
`peach compiles Swift with the ${
|
|
82
|
-
${swiftInstallSteps(release,
|
|
81
|
+
`peach compiles Swift with the ${sdk.wasmSdkId} SDK, which ${swift} does not have.
|
|
82
|
+
${swiftInstallSteps(release, sdk)}`
|
|
83
83
|
);
|
|
84
84
|
}
|
|
85
|
-
verified.set(release
|
|
85
|
+
verified.set(`${release}\0${sdk.wasmSdkId}`, bin);
|
|
86
86
|
return bin;
|
|
87
87
|
}
|
|
88
|
-
function swiftInstallSteps(release,
|
|
88
|
+
function swiftInstallSteps(release, wasmSdk) {
|
|
89
89
|
const version = release.replace(/^swift-/, "").toLowerCase();
|
|
90
90
|
const downloads = `https://download.swift.org/swift-${version}`;
|
|
91
|
-
const sdk = `swift sdk install ${
|
|
91
|
+
const sdk = `swift sdk install ${wasmSdk.wasmSdkUrl} --checksum ${wasmSdk.wasmSdkChecksum}`;
|
|
92
92
|
if (process.platform === "darwin") {
|
|
93
93
|
const swift = `~/Library/Developer/Toolchains/${release}.xctoolchain/usr/bin/swift`;
|
|
94
94
|
return [
|
package/dist-lib/swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.688 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|