peachsim 0.1.687 → 0.1.689
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 +362 -108
- 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 +401 -130
- package/dist-lib/swift-compile.cjs +277 -22
- package/dist-lib/swift-compile.mjs +275 -22
- 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 +280 -44
- 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 +366 -24
- 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.689 | (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,7 +327,17 @@ function withNativeSourceGlue(input, glue) {
|
|
|
314
327
|
oneModule: true
|
|
315
328
|
};
|
|
316
329
|
}
|
|
317
|
-
var
|
|
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));
|
|
318
341
|
function swiftTargetDependencies(files, targets) {
|
|
319
342
|
const names = /* @__PURE__ */ new Set([...OPTIONAL_FRAMEWORKS, ...targets.map((target) => target.name)]);
|
|
320
343
|
const siblings = /* @__PURE__ */ new Map();
|
|
@@ -344,12 +367,12 @@ var importsSpriteKit = (files) => Object.entries(files).some(
|
|
|
344
367
|
contents
|
|
345
368
|
)
|
|
346
369
|
);
|
|
347
|
-
var
|
|
370
|
+
var FOUNDATION_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "PeachObjC", "-Xfrontend", "-import-module", "-Xfrontend", "Dispatch", "-Xfrontend", "-import-module", "-Xfrontend", "FoundationNetworking"';
|
|
348
371
|
var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
|
|
349
|
-
var MULTI_MANIFEST_VERSION =
|
|
372
|
+
var MULTI_MANIFEST_VERSION = 10;
|
|
350
373
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
351
374
|
const hash = createHash2("sha256");
|
|
352
|
-
hash.update(`swift-compile/
|
|
375
|
+
hash.update(`swift-compile/v12
|
|
353
376
|
${release}
|
|
354
377
|
`);
|
|
355
378
|
if (input.oneModule) hash.update("one-module\n");
|
|
@@ -391,7 +414,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
391
414
|
const reachedFrameworks = new Set(
|
|
392
415
|
[...siblings.values()].flat().filter(
|
|
393
416
|
(name) => OPTIONAL_FRAMEWORKS.has(name) && !targets.some((target) => target.name === name)
|
|
394
|
-
)
|
|
417
|
+
).flatMap((name) => [name, ...OPTIONAL_FRAMEWORK_DEPENDENCIES[name] ?? []])
|
|
395
418
|
);
|
|
396
419
|
const distributionObjects = distribution?.objects.filter(
|
|
397
420
|
(object) => [...OPTIONAL_FRAMEWORKS].every(
|
|
@@ -403,7 +426,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
403
426
|
const stanza = (target) => {
|
|
404
427
|
const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
|
|
405
428
|
const imports = distribution ? `, "-I", ${JSON.stringify(path2.join(moduleRoot, "modules"))}` : "";
|
|
406
|
-
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}])]`;
|
|
407
430
|
const deps = [
|
|
408
431
|
...distribution ? [] : [
|
|
409
432
|
'.product(name: "SwiftUI", package: "sootsim-swift")',
|
|
@@ -473,8 +496,185 @@ var DIRECTIVE = /^[ \t]*#(?:if|elseif)\b/;
|
|
|
473
496
|
var OS_IOS = /\bos\(\s*iOS\s*\)/g;
|
|
474
497
|
var OBJC_ATTRIBUTE = /^@(?:objcMembers\b|objc\b(?:(\s*)\(([^()]*)\))?|IBAction\b)/;
|
|
475
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/;
|
|
476
500
|
var DELEGATE_CLASS = /^class\s+[A-Za-z_]\w*\s*(?:<[^>{]*>)?\s*:[^{]*\b(?:UIApplicationDelegate|UISceneDelegate|UIWindowSceneDelegate)\b[^{]*\{/;
|
|
477
|
-
|
|
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);
|
|
478
678
|
const { lineStarts, tokens } = swiftCodeScan(source);
|
|
479
679
|
let offset = 0;
|
|
480
680
|
const conditioned = source.split("\n").map((line) => {
|
|
@@ -485,8 +685,30 @@ function swiftSourceAsIOS(source) {
|
|
|
485
685
|
}).join("\n");
|
|
486
686
|
let out = "";
|
|
487
687
|
let copied = 0;
|
|
688
|
+
const reusableViews = new Set(REUSABLE_VIEW_BASES);
|
|
689
|
+
const reusableBodies = [];
|
|
690
|
+
let depth = 0;
|
|
691
|
+
let opensReusableBody = false;
|
|
488
692
|
for (const at of tokens) {
|
|
489
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
|
+
}
|
|
490
712
|
const imported = /^import\s+CoreImage\.CIFilterBuiltins\b/.exec(rest);
|
|
491
713
|
if (imported) {
|
|
492
714
|
out += conditioned.slice(copied, at) + "import CoreImage".padEnd(imported[0].length);
|
|
@@ -499,6 +721,11 @@ function swiftSourceAsIOS(source) {
|
|
|
499
721
|
continue;
|
|
500
722
|
}
|
|
501
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
|
+
}
|
|
502
729
|
const modifiers = conditioned.slice(conditioned.lastIndexOf("\n", at - 1) + 1, at);
|
|
503
730
|
if (DELEGATE_CLASS.test(rest) && !/\b(?:final|open)\b/.test(modifiers)) {
|
|
504
731
|
out += `${conditioned.slice(copied, at)}final `;
|
|
@@ -513,6 +740,8 @@ function swiftSourceAsIOS(source) {
|
|
|
513
740
|
if (selector) replacement = "#Selector";
|
|
514
741
|
else if (match[0] === "@objcMembers") replacement = "@ObjCMembers";
|
|
515
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);
|
|
516
745
|
else if (match[2] !== void 0)
|
|
517
746
|
replacement = `@ObjC${match[1]}("${match[2].trim()}")`;
|
|
518
747
|
out += conditioned.slice(copied, at) + replacement;
|
|
@@ -591,6 +820,9 @@ function swiftCodeScan(source) {
|
|
|
591
820
|
if (hashes > 0) tokens.push(at - 1);
|
|
592
821
|
i = Math.max(at, i + 1);
|
|
593
822
|
}
|
|
823
|
+
} else if (char === "{" || char === "}") {
|
|
824
|
+
tokens.push(i);
|
|
825
|
+
i++;
|
|
594
826
|
} else if (char === "(") {
|
|
595
827
|
top.parens++;
|
|
596
828
|
i++;
|
|
@@ -599,7 +831,7 @@ function swiftCodeScan(source) {
|
|
|
599
831
|
else top.parens--;
|
|
600
832
|
i++;
|
|
601
833
|
} else {
|
|
602
|
-
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;
|
|
603
835
|
if (keyword && !/[\w$]/.test(source[i - 1] ?? "") && !/[\w$]/.test(source[i + keyword.length] ?? "")) {
|
|
604
836
|
tokens.push(i);
|
|
605
837
|
i += keyword.length;
|
|
@@ -612,6 +844,23 @@ function swiftCodeScan(source) {
|
|
|
612
844
|
return { lineStarts: starts, tokens };
|
|
613
845
|
}
|
|
614
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
|
+
}
|
|
615
864
|
function writeSwiftProject(layout, input, moduleRoot) {
|
|
616
865
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
617
866
|
const targets = distribution && compileTargets(input).length === 0 ? [
|
|
@@ -654,7 +903,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
654
903
|
}
|
|
655
904
|
if (input.oneModule) {
|
|
656
905
|
const product = '.product(name: "CoreLocation", package: "sootsim-swift"),';
|
|
657
|
-
const flags = `"-Osize"${
|
|
906
|
+
const flags = `"-Osize"${FOUNDATION_IMPLICIT_FLAGS}`;
|
|
658
907
|
if (!manifest.includes(product) || !manifest.includes(flags)) {
|
|
659
908
|
throw new Error(
|
|
660
909
|
"scripts/contrast-app-Package.swift lost the lines the One module links at"
|
|
@@ -778,7 +1027,8 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
778
1027
|
);
|
|
779
1028
|
}
|
|
780
1029
|
const macroPlugins = await ensureMacroPlugins(moduleRoot, options.toolchainBin);
|
|
781
|
-
const
|
|
1030
|
+
const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
|
|
1031
|
+
const icu = swiftIcuAsset(options.toolchainBin, sdk);
|
|
782
1032
|
try {
|
|
783
1033
|
await run2(
|
|
784
1034
|
swift,
|
|
@@ -789,7 +1039,7 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
789
1039
|
"--package-path",
|
|
790
1040
|
root,
|
|
791
1041
|
"--swift-sdk",
|
|
792
|
-
|
|
1042
|
+
sdk,
|
|
793
1043
|
"-c",
|
|
794
1044
|
"release",
|
|
795
1045
|
"-Xswiftc",
|
|
@@ -819,12 +1069,15 @@ export {
|
|
|
819
1069
|
compileSwiftProjectUnit,
|
|
820
1070
|
compileTargets,
|
|
821
1071
|
emitSwiftPackageManifest,
|
|
1072
|
+
prepareSwiftDependency,
|
|
822
1073
|
swiftArtifactHash,
|
|
823
1074
|
swiftDistributionAt,
|
|
824
1075
|
swiftIcuAsset,
|
|
825
1076
|
swiftModuleDigest,
|
|
826
1077
|
swiftModuleInputFiles,
|
|
1078
|
+
swiftModuleSdk,
|
|
827
1079
|
swiftSourceAsIOS,
|
|
1080
|
+
swiftTargetDependencies,
|
|
828
1081
|
withNativeSourceGlue,
|
|
829
1082
|
writeSwiftProject
|
|
830
1083
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.689 | (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.689 | (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.689 | (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.689 | (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.689 | (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;
|