peachsim 0.1.799 → 0.1.801
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/drivers/playwright-sim-host.ts +2 -0
- package/cli/outbound-endpoints.ts +0 -4
- 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 +125 -10
- 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 +48 -7
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +125 -10
- 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 +125 -10
- 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 +1 -1
- 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 +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +125 -10
- package/dist-lib/swift-compile.cjs +134 -11
- package/dist-lib/swift-compile.mjs +133 -11
- 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 +125 -10
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/swift-compile.ts +151 -11
package/dist-lib/vite-swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.801 | (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;
|
|
@@ -2042,7 +2042,7 @@ var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"'
|
|
|
2042
2042
|
var MULTI_MANIFEST_VERSION = 12;
|
|
2043
2043
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
2044
2044
|
const hash = (0, import_node_crypto2.createHash)("sha256");
|
|
2045
|
-
hash.update(`swift-compile/
|
|
2045
|
+
hash.update(`swift-compile/v19
|
|
2046
2046
|
${release}
|
|
2047
2047
|
`);
|
|
2048
2048
|
if (input.oneModule) hash.update("one-module\n");
|
|
@@ -2640,6 +2640,118 @@ function lowerNotificationDelegate(source) {
|
|
|
2640
2640
|
result = result.slice(0, at) + text3 + result.slice(at + count);
|
|
2641
2641
|
return result;
|
|
2642
2642
|
}
|
|
2643
|
+
function tableProtocolConformances(sources) {
|
|
2644
|
+
const parents = /* @__PURE__ */ new Map();
|
|
2645
|
+
for (const source of sources) {
|
|
2646
|
+
const code = swiftCodeMask(source);
|
|
2647
|
+
for (const owner of code.matchAll(
|
|
2648
|
+
/\b(?:class|extension)\s+([A-Za-z_]\w*)\s*:\s*([^{}]+)\{/g
|
|
2649
|
+
)) {
|
|
2650
|
+
const inherited = parents.get(owner[1]) ?? /* @__PURE__ */ new Set();
|
|
2651
|
+
for (const type of owner[2].matchAll(/\b[A-Za-z_]\w*\b/g)) inherited.add(type[0]);
|
|
2652
|
+
parents.set(owner[1], inherited);
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
const result = /* @__PURE__ */ new Map();
|
|
2656
|
+
const protocols = ["UITableViewDataSource", "UITableViewDelegate"];
|
|
2657
|
+
for (const type of parents.keys()) {
|
|
2658
|
+
const pending = [type];
|
|
2659
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2660
|
+
const conformances = /* @__PURE__ */ new Set();
|
|
2661
|
+
while (pending.length) {
|
|
2662
|
+
const next = pending.pop();
|
|
2663
|
+
if (seen.has(next)) continue;
|
|
2664
|
+
seen.add(next);
|
|
2665
|
+
if (protocols.includes(next)) conformances.add(next);
|
|
2666
|
+
for (const parent of parents.get(next) ?? []) pending.push(parent);
|
|
2667
|
+
}
|
|
2668
|
+
if (conformances.size) result.set(type, conformances);
|
|
2669
|
+
}
|
|
2670
|
+
return result;
|
|
2671
|
+
}
|
|
2672
|
+
function lowerTableProtocolMethods(source, conformances) {
|
|
2673
|
+
const code = swiftCodeMask(source);
|
|
2674
|
+
const dataSource = {
|
|
2675
|
+
numberOfRowsInSection: "tableView:numberOfRowsInSection:",
|
|
2676
|
+
cellForRowAt: "tableView:cellForRowAtIndexPath:",
|
|
2677
|
+
titleForHeaderInSection: "tableView:titleForHeaderInSection:",
|
|
2678
|
+
titleForFooterInSection: "tableView:titleForFooterInSection:"
|
|
2679
|
+
};
|
|
2680
|
+
const delegate = {
|
|
2681
|
+
willDisplay: "tableView:willDisplayCell:forRowAtIndexPath:",
|
|
2682
|
+
didEndDisplaying: "tableView:didEndDisplayingCell:forRowAtIndexPath:",
|
|
2683
|
+
heightForRowAt: "tableView:heightForRowAtIndexPath:",
|
|
2684
|
+
estimatedHeightForRowAt: "tableView:estimatedHeightForRowAtIndexPath:",
|
|
2685
|
+
heightForHeaderInSection: "tableView:heightForHeaderInSection:",
|
|
2686
|
+
heightForFooterInSection: "tableView:heightForFooterInSection:",
|
|
2687
|
+
estimatedHeightForHeaderInSection: "tableView:estimatedHeightForHeaderInSection:",
|
|
2688
|
+
estimatedHeightForFooterInSection: "tableView:estimatedHeightForFooterInSection:",
|
|
2689
|
+
viewForHeaderInSection: "tableView:viewForHeaderInSection:",
|
|
2690
|
+
viewForFooterInSection: "tableView:viewForFooterInSection:",
|
|
2691
|
+
willDisplayHeaderView: "tableView:willDisplayHeaderView:forSection:",
|
|
2692
|
+
willDisplayFooterView: "tableView:willDisplayFooterView:forSection:",
|
|
2693
|
+
didEndDisplayingHeaderView: "tableView:didEndDisplayingHeaderView:forSection:",
|
|
2694
|
+
didEndDisplayingFooterView: "tableView:didEndDisplayingFooterView:forSection:",
|
|
2695
|
+
shouldHighlightRowAt: "tableView:shouldHighlightRowAtIndexPath:",
|
|
2696
|
+
didHighlightRowAt: "tableView:didHighlightRowAtIndexPath:",
|
|
2697
|
+
didUnhighlightRowAt: "tableView:didUnhighlightRowAtIndexPath:",
|
|
2698
|
+
willSelectRowAt: "tableView:willSelectRowAtIndexPath:",
|
|
2699
|
+
willDeselectRowAt: "tableView:willDeselectRowAtIndexPath:",
|
|
2700
|
+
didSelectRowAt: "tableView:didSelectRowAtIndexPath:",
|
|
2701
|
+
didDeselectRowAt: "tableView:didDeselectRowAtIndexPath:",
|
|
2702
|
+
accessoryButtonTappedForRowWith: "tableView:accessoryButtonTappedForRowWithIndexPath:"
|
|
2703
|
+
};
|
|
2704
|
+
const braces = [...code.matchAll(/[{}]/g)].map((match) => match.index);
|
|
2705
|
+
const edits = [];
|
|
2706
|
+
for (const owner of code.matchAll(/\b(?:class|extension)\s+([A-Za-z_]\w*)[^{}]*\{/g)) {
|
|
2707
|
+
const conforms = conformances.get(owner[1]);
|
|
2708
|
+
if (!conforms) continue;
|
|
2709
|
+
const selectors = {
|
|
2710
|
+
...conforms.has("UITableViewDataSource") ? dataSource : {},
|
|
2711
|
+
...conforms.has("UITableViewDelegate") ? delegate : {}
|
|
2712
|
+
};
|
|
2713
|
+
const open = owner.index + owner[0].length - 1;
|
|
2714
|
+
const close = closingBrace(code, braces, open);
|
|
2715
|
+
let depth = 1;
|
|
2716
|
+
let previous = open + 1;
|
|
2717
|
+
for (const token of swiftCodeScan(code.slice(open + 1, close - 1)).tokens) {
|
|
2718
|
+
const at = open + 1 + token;
|
|
2719
|
+
if (code[at] === "{") depth++;
|
|
2720
|
+
else if (code[at] === "}") {
|
|
2721
|
+
depth--;
|
|
2722
|
+
if (depth === 1) previous = at + 1;
|
|
2723
|
+
} else if (depth === 1 && /^func\b/.test(code.slice(at))) {
|
|
2724
|
+
const signature2 = code.slice(at, code.indexOf("{", at));
|
|
2725
|
+
const prefix = code.slice(previous, at);
|
|
2726
|
+
const attributes = /(?:@\w+(?:\([^{}]*\))?\s*|(?:public|open|private|fileprivate|internal|final|override|static|class|nonisolated|dynamic)\s+)*$/.exec(
|
|
2727
|
+
prefix
|
|
2728
|
+
)?.[0] ?? "";
|
|
2729
|
+
if (/\b(?:override|static|class)\b|@(?:objc|ObjC|IBAction)\b/.test(attributes))
|
|
2730
|
+
continue;
|
|
2731
|
+
let selector;
|
|
2732
|
+
if (conforms.has("UITableViewDataSource") && /^func\s+numberOfSections\s*\(\s*in\s+\w+\s*:\s*(?:UIKit\.)?UITableView\s*\)/.test(
|
|
2733
|
+
signature2
|
|
2734
|
+
))
|
|
2735
|
+
selector = "numberOfSectionsInTableView:";
|
|
2736
|
+
else {
|
|
2737
|
+
const match = /^func\s+tableView\s*\(\s*_\s+\w+\s*:\s*(?:UIKit\.)?UITableView\s*,\s*(\w+)\b/.exec(
|
|
2738
|
+
signature2
|
|
2739
|
+
);
|
|
2740
|
+
if (match) selector = selectors[match[1]];
|
|
2741
|
+
}
|
|
2742
|
+
if (selector)
|
|
2743
|
+
edits.push([
|
|
2744
|
+
at,
|
|
2745
|
+
`${/\bnonisolated\b/.test(attributes) ? "" : "@MainActor "}@ObjC(${JSON.stringify(selector)}) `
|
|
2746
|
+
]);
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
let result = source;
|
|
2751
|
+
for (const [at, text3] of edits.sort((a, b) => b[0] - a[0]))
|
|
2752
|
+
result = result.slice(0, at) + text3 + result.slice(at);
|
|
2753
|
+
return result;
|
|
2754
|
+
}
|
|
2643
2755
|
function swiftCodeMask(source) {
|
|
2644
2756
|
const chars = source.split("");
|
|
2645
2757
|
const blank = (from, to) => {
|
|
@@ -2743,9 +2855,9 @@ function swiftCodeMask(source) {
|
|
|
2743
2855
|
scanCode(0, false);
|
|
2744
2856
|
return chars.join("");
|
|
2745
2857
|
}
|
|
2746
|
-
function swiftSourceAsIOS(original, extraObjCExtensions) {
|
|
2858
|
+
function swiftSourceAsIOS(original, extraObjCExtensions, tableConformances = tableProtocolConformances([original])) {
|
|
2747
2859
|
const source = liftExtensionOverrides(
|
|
2748
|
-
lowerNotificationDelegate(original),
|
|
2860
|
+
lowerTableProtocolMethods(lowerNotificationDelegate(original), tableConformances),
|
|
2749
2861
|
extraObjCExtensions
|
|
2750
2862
|
);
|
|
2751
2863
|
const { lineStarts, tokens } = swiftCodeScan(source);
|
|
@@ -2957,7 +3069,7 @@ function swiftCodeScan(source) {
|
|
|
2957
3069
|
}
|
|
2958
3070
|
return { lineStarts: starts, tokens };
|
|
2959
3071
|
}
|
|
2960
|
-
var compiledSource = (file, contents, extraObjCExtensions) => file.endsWith(".swift") ? swiftSourceAsIOS(contents, extraObjCExtensions) : contents;
|
|
3072
|
+
var compiledSource = (file, contents, extraObjCExtensions, tableConformances) => file.endsWith(".swift") ? swiftSourceAsIOS(contents, extraObjCExtensions, tableConformances) : contents;
|
|
2961
3073
|
function writeSwiftProject(layout, input, moduleRoot) {
|
|
2962
3074
|
const resourceTargets = swiftManifestTargets(
|
|
2963
3075
|
input.files["Package.swift"] ?? "",
|
|
@@ -2990,15 +3102,15 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
2990
3102
|
// sootsim-swift files ${modulePlan.digest("hex").slice(0, 16)}
|
|
2991
3103
|
// resource accessors ${resourcePlan}
|
|
2992
3104
|
`;
|
|
2993
|
-
const
|
|
2994
|
-
|
|
2995
|
-
);
|
|
3105
|
+
const swiftSources = Object.entries(input.files).filter(([file]) => file.endsWith(".swift")).map(([, contents]) => contents);
|
|
3106
|
+
const objcExtensions = objcExtensionMemberIndex(swiftSources);
|
|
3107
|
+
const tableConformances = tableProtocolConformances(swiftSources);
|
|
2996
3108
|
if (targets.length === 0) {
|
|
2997
3109
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
2998
3110
|
if (file === "Package.swift") continue;
|
|
2999
3111
|
files2.set(
|
|
3000
3112
|
import_node_path2.default.join(layout.sources, file),
|
|
3001
|
-
compiledSource(file, contents, objcExtensions)
|
|
3113
|
+
compiledSource(file, contents, objcExtensions, tableConformances)
|
|
3002
3114
|
);
|
|
3003
3115
|
}
|
|
3004
3116
|
let manifest = (0, import_node_fs2.readFileSync)(
|
|
@@ -3045,7 +3157,10 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
3045
3157
|
const base = layout.multi ? layout.root : layout.sources;
|
|
3046
3158
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
3047
3159
|
if (file === "Package.swift") continue;
|
|
3048
|
-
files2.set(
|
|
3160
|
+
files2.set(
|
|
3161
|
+
import_node_path2.default.join(base, file),
|
|
3162
|
+
compiledSource(file, contents, objcExtensions, tableConformances)
|
|
3163
|
+
);
|
|
3049
3164
|
}
|
|
3050
3165
|
files2.set(
|
|
3051
3166
|
import_node_path2.default.join(layout.root, "Package.swift"),
|
package/dist-lib/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.801 | (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;
|
package/package.json
CHANGED
package/src/swift-compile.ts
CHANGED
|
@@ -582,6 +582,7 @@ export function swiftArtifactHash(
|
|
|
582
582
|
moduleRoot: string,
|
|
583
583
|
): string {
|
|
584
584
|
const hash = createHash('sha256')
|
|
585
|
+
// v19: supplied table protocol methods preserve Objective-C selectors
|
|
585
586
|
// v18: NSValue(time:) constructs NSStructBox through NSValue.boxedTime
|
|
586
587
|
// v17: AVAsset(url:) constructs AVURLAsset for the class cluster
|
|
587
588
|
// v16: overrides of @objc extension members rename to __peach_ovr_
|
|
@@ -597,7 +598,7 @@ export function swiftArtifactHash(
|
|
|
597
598
|
// v6: app and scene delegate classes compile final
|
|
598
599
|
// (v5: a target declaring resources gets SwiftPM's Bundle.module accessor;
|
|
599
600
|
// v4: sources compile through swiftSourceAsIOS)
|
|
600
|
-
hash.update(`swift-compile/
|
|
601
|
+
hash.update(`swift-compile/v19\n${release}\n`)
|
|
601
602
|
if (input.oneModule) hash.update('one-module\n')
|
|
602
603
|
hash.update(swiftModuleDigest(moduleRoot))
|
|
603
604
|
for (const file of Object.keys(input.files).sort()) {
|
|
@@ -1419,6 +1420,132 @@ export function lowerNotificationDelegate(source: string): string {
|
|
|
1419
1420
|
return result
|
|
1420
1421
|
}
|
|
1421
1422
|
|
|
1423
|
+
// uikit's Objective-C table requirements expose only supplied methods. index
|
|
1424
|
+
// the module first: a conformance, subclass or extension may live in another file.
|
|
1425
|
+
export function tableProtocolConformances(sources: string[]): Map<string, Set<string>> {
|
|
1426
|
+
const parents = new Map<string, Set<string>>()
|
|
1427
|
+
for (const source of sources) {
|
|
1428
|
+
const code = swiftCodeMask(source)
|
|
1429
|
+
for (const owner of code.matchAll(
|
|
1430
|
+
/\b(?:class|extension)\s+([A-Za-z_]\w*)\s*:\s*([^{}]+)\{/g,
|
|
1431
|
+
)) {
|
|
1432
|
+
const inherited = parents.get(owner[1]!) ?? new Set<string>()
|
|
1433
|
+
for (const type of owner[2]!.matchAll(/\b[A-Za-z_]\w*\b/g)) inherited.add(type[0])
|
|
1434
|
+
parents.set(owner[1]!, inherited)
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
const result = new Map<string, Set<string>>()
|
|
1438
|
+
const protocols = ['UITableViewDataSource', 'UITableViewDelegate']
|
|
1439
|
+
for (const type of parents.keys()) {
|
|
1440
|
+
const pending = [type]
|
|
1441
|
+
const seen = new Set<string>()
|
|
1442
|
+
const conformances = new Set<string>()
|
|
1443
|
+
while (pending.length) {
|
|
1444
|
+
const next = pending.pop()!
|
|
1445
|
+
if (seen.has(next)) continue
|
|
1446
|
+
seen.add(next)
|
|
1447
|
+
if (protocols.includes(next)) conformances.add(next)
|
|
1448
|
+
for (const parent of parents.get(next) ?? []) pending.push(parent)
|
|
1449
|
+
}
|
|
1450
|
+
if (conformances.size) result.set(type, conformances)
|
|
1451
|
+
}
|
|
1452
|
+
return result
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
function lowerTableProtocolMethods(
|
|
1456
|
+
source: string,
|
|
1457
|
+
conformances: Map<string, Set<string>>,
|
|
1458
|
+
): string {
|
|
1459
|
+
const code = swiftCodeMask(source)
|
|
1460
|
+
const dataSource: Record<string, string> = {
|
|
1461
|
+
numberOfRowsInSection: 'tableView:numberOfRowsInSection:',
|
|
1462
|
+
cellForRowAt: 'tableView:cellForRowAtIndexPath:',
|
|
1463
|
+
titleForHeaderInSection: 'tableView:titleForHeaderInSection:',
|
|
1464
|
+
titleForFooterInSection: 'tableView:titleForFooterInSection:',
|
|
1465
|
+
}
|
|
1466
|
+
const delegate: Record<string, string> = {
|
|
1467
|
+
willDisplay: 'tableView:willDisplayCell:forRowAtIndexPath:',
|
|
1468
|
+
didEndDisplaying: 'tableView:didEndDisplayingCell:forRowAtIndexPath:',
|
|
1469
|
+
heightForRowAt: 'tableView:heightForRowAtIndexPath:',
|
|
1470
|
+
estimatedHeightForRowAt: 'tableView:estimatedHeightForRowAtIndexPath:',
|
|
1471
|
+
heightForHeaderInSection: 'tableView:heightForHeaderInSection:',
|
|
1472
|
+
heightForFooterInSection: 'tableView:heightForFooterInSection:',
|
|
1473
|
+
estimatedHeightForHeaderInSection: 'tableView:estimatedHeightForHeaderInSection:',
|
|
1474
|
+
estimatedHeightForFooterInSection: 'tableView:estimatedHeightForFooterInSection:',
|
|
1475
|
+
viewForHeaderInSection: 'tableView:viewForHeaderInSection:',
|
|
1476
|
+
viewForFooterInSection: 'tableView:viewForFooterInSection:',
|
|
1477
|
+
willDisplayHeaderView: 'tableView:willDisplayHeaderView:forSection:',
|
|
1478
|
+
willDisplayFooterView: 'tableView:willDisplayFooterView:forSection:',
|
|
1479
|
+
didEndDisplayingHeaderView: 'tableView:didEndDisplayingHeaderView:forSection:',
|
|
1480
|
+
didEndDisplayingFooterView: 'tableView:didEndDisplayingFooterView:forSection:',
|
|
1481
|
+
shouldHighlightRowAt: 'tableView:shouldHighlightRowAtIndexPath:',
|
|
1482
|
+
didHighlightRowAt: 'tableView:didHighlightRowAtIndexPath:',
|
|
1483
|
+
didUnhighlightRowAt: 'tableView:didUnhighlightRowAtIndexPath:',
|
|
1484
|
+
willSelectRowAt: 'tableView:willSelectRowAtIndexPath:',
|
|
1485
|
+
willDeselectRowAt: 'tableView:willDeselectRowAtIndexPath:',
|
|
1486
|
+
didSelectRowAt: 'tableView:didSelectRowAtIndexPath:',
|
|
1487
|
+
didDeselectRowAt: 'tableView:didDeselectRowAtIndexPath:',
|
|
1488
|
+
accessoryButtonTappedForRowWith:
|
|
1489
|
+
'tableView:accessoryButtonTappedForRowWithIndexPath:',
|
|
1490
|
+
}
|
|
1491
|
+
const braces = [...code.matchAll(/[{}]/g)].map((match) => match.index)
|
|
1492
|
+
const edits: [number, string][] = []
|
|
1493
|
+
for (const owner of code.matchAll(/\b(?:class|extension)\s+([A-Za-z_]\w*)[^{}]*\{/g)) {
|
|
1494
|
+
const conforms = conformances.get(owner[1]!)
|
|
1495
|
+
if (!conforms) continue
|
|
1496
|
+
const selectors = {
|
|
1497
|
+
...(conforms.has('UITableViewDataSource') ? dataSource : {}),
|
|
1498
|
+
...(conforms.has('UITableViewDelegate') ? delegate : {}),
|
|
1499
|
+
}
|
|
1500
|
+
const open = owner.index + owner[0].length - 1
|
|
1501
|
+
const close = closingBrace(code, braces, open)
|
|
1502
|
+
let depth = 1
|
|
1503
|
+
let previous = open + 1
|
|
1504
|
+
for (const token of swiftCodeScan(code.slice(open + 1, close - 1)).tokens) {
|
|
1505
|
+
const at = open + 1 + token
|
|
1506
|
+
if (code[at] === '{') depth++
|
|
1507
|
+
else if (code[at] === '}') {
|
|
1508
|
+
depth--
|
|
1509
|
+
if (depth === 1) previous = at + 1
|
|
1510
|
+
} else if (depth === 1 && /^func\b/.test(code.slice(at))) {
|
|
1511
|
+
const signature = code.slice(at, code.indexOf('{', at))
|
|
1512
|
+
const prefix = code.slice(previous, at)
|
|
1513
|
+
const attributes =
|
|
1514
|
+
/(?:@\w+(?:\([^{}]*\))?\s*|(?:public|open|private|fileprivate|internal|final|override|static|class|nonisolated|dynamic)\s+)*$/.exec(
|
|
1515
|
+
prefix,
|
|
1516
|
+
)?.[0] ?? ''
|
|
1517
|
+
// an override dispatches through its superclass's method record.
|
|
1518
|
+
if (/\b(?:override|static|class)\b|@(?:objc|ObjC|IBAction)\b/.test(attributes))
|
|
1519
|
+
continue
|
|
1520
|
+
let selector: string | undefined
|
|
1521
|
+
if (
|
|
1522
|
+
conforms.has('UITableViewDataSource') &&
|
|
1523
|
+
/^func\s+numberOfSections\s*\(\s*in\s+\w+\s*:\s*(?:UIKit\.)?UITableView\s*\)/.test(
|
|
1524
|
+
signature,
|
|
1525
|
+
)
|
|
1526
|
+
)
|
|
1527
|
+
selector = 'numberOfSectionsInTableView:'
|
|
1528
|
+
else {
|
|
1529
|
+
const match =
|
|
1530
|
+
/^func\s+tableView\s*\(\s*_\s+\w+\s*:\s*(?:UIKit\.)?UITableView\s*,\s*(\w+)\b/.exec(
|
|
1531
|
+
signature,
|
|
1532
|
+
)
|
|
1533
|
+
if (match) selector = selectors[match[1]!]
|
|
1534
|
+
}
|
|
1535
|
+
if (selector)
|
|
1536
|
+
edits.push([
|
|
1537
|
+
at,
|
|
1538
|
+
`${/\bnonisolated\b/.test(attributes) ? '' : '@MainActor '}@ObjC(${JSON.stringify(selector)}) `,
|
|
1539
|
+
])
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
let result = source
|
|
1544
|
+
for (const [at, text] of edits.sort((a, b) => b[0] - a[0]))
|
|
1545
|
+
result = result.slice(0, at) + text + result.slice(at)
|
|
1546
|
+
return result
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1422
1549
|
// the index-preserving view lowerAnyObjectDoubleValue matches on: every
|
|
1423
1550
|
// char outside code (comments, strings, regex literals) reads as a space,
|
|
1424
1551
|
// so an identifier that survives is code. newlines stay, keeping every
|
|
@@ -1541,9 +1668,10 @@ function swiftCodeMask(source: string): string {
|
|
|
1541
1668
|
export function swiftSourceAsIOS(
|
|
1542
1669
|
original: string,
|
|
1543
1670
|
extraObjCExtensions?: Map<string, Set<string>>,
|
|
1671
|
+
tableConformances = tableProtocolConformances([original]),
|
|
1544
1672
|
): string {
|
|
1545
1673
|
const source = liftExtensionOverrides(
|
|
1546
|
-
lowerNotificationDelegate(original),
|
|
1674
|
+
lowerTableProtocolMethods(lowerNotificationDelegate(original), tableConformances),
|
|
1547
1675
|
extraObjCExtensions,
|
|
1548
1676
|
)
|
|
1549
1677
|
const { lineStarts, tokens } = swiftCodeScan(source)
|
|
@@ -1862,8 +1990,11 @@ const compiledSource = (
|
|
|
1862
1990
|
file: string,
|
|
1863
1991
|
contents: string,
|
|
1864
1992
|
extraObjCExtensions?: Map<string, Set<string>>,
|
|
1993
|
+
tableConformances?: Map<string, Set<string>>,
|
|
1865
1994
|
) =>
|
|
1866
|
-
file.endsWith('.swift')
|
|
1995
|
+
file.endsWith('.swift')
|
|
1996
|
+
? swiftSourceAsIOS(contents, extraObjCExtensions, tableConformances)
|
|
1997
|
+
: contents
|
|
1867
1998
|
|
|
1868
1999
|
/** a dependency package's build copy: the published tree with every Swift
|
|
1869
2000
|
* source rewritten as app sources are, so an unchanged upstream package that
|
|
@@ -1890,6 +2021,7 @@ export function prepareSwiftDependency(source: string, destination: string): voi
|
|
|
1890
2021
|
}
|
|
1891
2022
|
gather(source, true)
|
|
1892
2023
|
const objcExtensions = objcExtensionMemberIndex(origins)
|
|
2024
|
+
const tableConformances = tableProtocolConformances(origins)
|
|
1893
2025
|
const copy = (from: string, to: string, root: boolean) => {
|
|
1894
2026
|
mkdirSync(to, { recursive: true })
|
|
1895
2027
|
for (const entry of readdirSync(from, { withFileTypes: true })) {
|
|
@@ -1905,7 +2037,12 @@ export function prepareSwiftDependency(source: string, destination: string): voi
|
|
|
1905
2037
|
)
|
|
1906
2038
|
writeFileSync(
|
|
1907
2039
|
target,
|
|
1908
|
-
compiledSource(
|
|
2040
|
+
compiledSource(
|
|
2041
|
+
file,
|
|
2042
|
+
readFileSync(file, 'utf8'),
|
|
2043
|
+
objcExtensions,
|
|
2044
|
+
tableConformances,
|
|
2045
|
+
),
|
|
1909
2046
|
)
|
|
1910
2047
|
else cpSync(file, target, { verbatimSymlinks: true })
|
|
1911
2048
|
}
|
|
@@ -1962,17 +2099,17 @@ export function writeSwiftProject(
|
|
|
1962
2099
|
const moduleFiles = `\n// sootsim-swift files ${modulePlan.digest('hex').slice(0, 16)}\n// resource accessors ${resourcePlan}\n`
|
|
1963
2100
|
// an override in one file may answer an @objc member an extension
|
|
1964
2101
|
// declares in another, so the module-wide member index precedes the copy.
|
|
1965
|
-
const
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
)
|
|
2102
|
+
const swiftSources = Object.entries(input.files)
|
|
2103
|
+
.filter(([file]) => file.endsWith('.swift'))
|
|
2104
|
+
.map(([, contents]) => contents)
|
|
2105
|
+
const objcExtensions = objcExtensionMemberIndex(swiftSources)
|
|
2106
|
+
const tableConformances = tableProtocolConformances(swiftSources)
|
|
1970
2107
|
if (targets.length === 0) {
|
|
1971
2108
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
1972
2109
|
if (file === 'Package.swift') continue
|
|
1973
2110
|
files.set(
|
|
1974
2111
|
path.join(layout.sources, file),
|
|
1975
|
-
compiledSource(file, contents, objcExtensions),
|
|
2112
|
+
compiledSource(file, contents, objcExtensions, tableConformances),
|
|
1976
2113
|
)
|
|
1977
2114
|
}
|
|
1978
2115
|
let manifest = readFileSync(
|
|
@@ -2022,7 +2159,10 @@ export function writeSwiftProject(
|
|
|
2022
2159
|
const base = layout.multi ? layout.root : layout.sources
|
|
2023
2160
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
2024
2161
|
if (file === 'Package.swift') continue
|
|
2025
|
-
files.set(
|
|
2162
|
+
files.set(
|
|
2163
|
+
path.join(base, file),
|
|
2164
|
+
compiledSource(file, contents, objcExtensions, tableConformances),
|
|
2165
|
+
)
|
|
2026
2166
|
}
|
|
2027
2167
|
files.set(
|
|
2028
2168
|
path.join(layout.root, 'Package.swift'),
|