peachsim 0.1.780 → 0.1.781
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/commands/detox.ts +6 -2
- 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/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +591 -257
- 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 +593 -259
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- 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 +583 -257
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/swift-host.ts +55 -28
- package/src/swift-standin-emit.ts +471 -242
- package/src/swift-standins.ts +285 -40
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.781 | (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;
|
|
@@ -1241,6 +1241,13 @@ function rotateHardwareButtons(buttons, portraitFrameHeight, side) {
|
|
|
1241
1241
|
volumeDown: rotate(buttons.volumeDown)
|
|
1242
1242
|
};
|
|
1243
1243
|
}
|
|
1244
|
+
function landscapeKeyboardPanelHeights(device) {
|
|
1245
|
+
if (device.model === "iphone-duo") return { qwerty: 230, pad: 182, emoji: 230 };
|
|
1246
|
+
return usesLandscapePhoneKeyboard(device) ? { qwerty: 224, pad: 171, emoji: 224 } : device.keyboardPanelHeights;
|
|
1247
|
+
}
|
|
1248
|
+
function usesLandscapePhoneKeyboard(device) {
|
|
1249
|
+
return device.platform === "ios" && device.model !== "iphone-duo" && !isPadIdiom(device) && device.homeIndicatorHeight > 0;
|
|
1250
|
+
}
|
|
1244
1251
|
function rotateDevice(device, side) {
|
|
1245
1252
|
const frameHeight = resolveDeviceFrameGeometry(device).frameHeight;
|
|
1246
1253
|
const insets = rotateFrameInsets(device.frameInsets, side);
|
|
@@ -1283,6 +1290,7 @@ function rotateDevice(device, side) {
|
|
|
1283
1290
|
// to whichever side the cutout turned to.
|
|
1284
1291
|
safeAreaInsets: side === "left" ? safeArea : { ...safeArea, left: safeArea.right, right: safeArea.left },
|
|
1285
1292
|
statusBarHeight: device.landscapeStatusBarHeight,
|
|
1293
|
+
keyboardPanelHeights: landscapeKeyboardPanelHeights(device),
|
|
1286
1294
|
// the indicator's band is the landscape bottom inset
|
|
1287
1295
|
homeIndicatorHeight: device.platform === "ios" && device.homeIndicatorHeight > 0 ? safeArea.bottom : device.homeIndicatorHeight
|
|
1288
1296
|
};
|
|
@@ -9752,6 +9760,7 @@ var import_node_os7 = __toESM(require("node:os"), 1);
|
|
|
9752
9760
|
var import_node_path16 = __toESM(require("node:path"), 1);
|
|
9753
9761
|
|
|
9754
9762
|
// src/swift-standin-emit.ts
|
|
9763
|
+
var STANDIN_EMIT_VERSION = "1";
|
|
9755
9764
|
var TYPE_KINDS = /* @__PURE__ */ new Set([
|
|
9756
9765
|
"swift.class",
|
|
9757
9766
|
"swift.struct",
|
|
@@ -9785,7 +9794,7 @@ var KEEP_EXTERNAL = /* @__PURE__ */ new Map([
|
|
|
9785
9794
|
]);
|
|
9786
9795
|
var LEADING_ATTRS = /^((?:@\w+(?:\([^)]*\))?\s*|nonisolated\s+)*)(.*)$/s;
|
|
9787
9796
|
var OBJC_ONLY = /@(?:objcMembers|objc|IBOutlet|IBInspectable|IBAction|IBSegueAction|GKInspectable|nonobjc|NSCopying|NSManaged)(?:\([^)]*\))?\s*|\bdynamic\s+/g;
|
|
9788
|
-
var text = (symbol) => (symbol.declarationFragments ?? []).map((fragment) => fragment.spelling).join("").replace(OBJC_ONLY, "").replace(/(^|\s)optional (?=func|var|init|subscript|static|class)/, "$1");
|
|
9797
|
+
var text = (symbol) => (symbol.declarationFragments ?? []).map((fragment) => fragment.spelling).join("").replace(OBJC_ONLY, "").replace(/(^|\s)optional (?=func|var|init|subscript|static|class)/, "$1").replace(/\bAutoreleasingUnsafeMutablePointer</g, "UnsafeMutablePointer<");
|
|
9789
9798
|
var leaf = (symbol) => symbol.pathComponents[symbol.pathComponents.length - 1];
|
|
9790
9799
|
var pathOf = (symbol) => symbol.pathComponents.join(".");
|
|
9791
9800
|
var unavailable = (symbol) => (symbol.availability ?? []).some(
|
|
@@ -9826,7 +9835,11 @@ function emitSwiftStandin(graphs, options) {
|
|
|
9826
9835
|
if (local) return { name: pathOf(local), local: true };
|
|
9827
9836
|
if (!fallback) return null;
|
|
9828
9837
|
const parts = fallback.split(".");
|
|
9829
|
-
return {
|
|
9838
|
+
return {
|
|
9839
|
+
name: family.has(parts[0]) ? parts.join(".") : parts.slice(1).join(".") || parts[0],
|
|
9840
|
+
module: parts[0],
|
|
9841
|
+
local: false
|
|
9842
|
+
};
|
|
9830
9843
|
};
|
|
9831
9844
|
for (const graph of graphs)
|
|
9832
9845
|
for (const edge of graph.relationships) {
|
|
@@ -9837,7 +9850,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
9837
9850
|
const parent = byId.get(edge.target);
|
|
9838
9851
|
if (parent) {
|
|
9839
9852
|
owner.set(edge.source, edge.target);
|
|
9840
|
-
children.set(edge.target, [
|
|
9853
|
+
children.set(edge.target, [
|
|
9854
|
+
...children.get(edge.target) ?? [],
|
|
9855
|
+
...all(edge.source)
|
|
9856
|
+
]);
|
|
9841
9857
|
} else if (edge.targetFallback) {
|
|
9842
9858
|
const name2 = nameOf(edge.target, edge.targetFallback).name;
|
|
9843
9859
|
external.set(name2, [...external.get(name2) ?? [], ...all(edge.source)]);
|
|
@@ -9855,7 +9871,8 @@ function emitSwiftStandin(graphs, options) {
|
|
|
9855
9871
|
const target = nameOf(edge.target, edge.targetFallback);
|
|
9856
9872
|
const kept = KEEP_EXTERNAL.get(edge.target);
|
|
9857
9873
|
const name2 = kept ?? (target && (target.local || family.has(target.module ?? "")) ? target.name : null);
|
|
9858
|
-
if (name2)
|
|
9874
|
+
if (name2)
|
|
9875
|
+
conforms.set(edge.source, [...conforms.get(edge.source) ?? [], name2]);
|
|
9859
9876
|
if (byId.has(edge.target)) {
|
|
9860
9877
|
const map = source.kind.identifier === "swift.protocol" ? protocolParents : conformIds;
|
|
9861
9878
|
map.set(edge.source, [...map.get(edge.source) ?? [], edge.target]);
|
|
@@ -9868,7 +9885,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
9868
9885
|
if (edge.kind === "optionalRequirementOf") optional.add(edge.source);
|
|
9869
9886
|
if (byId.has(edge.target) && !owner.has(edge.source)) {
|
|
9870
9887
|
owner.set(edge.source, edge.target);
|
|
9871
|
-
children.set(edge.target, [
|
|
9888
|
+
children.set(edge.target, [
|
|
9889
|
+
...children.get(edge.target) ?? [],
|
|
9890
|
+
...all(edge.source)
|
|
9891
|
+
]);
|
|
9872
9892
|
}
|
|
9873
9893
|
break;
|
|
9874
9894
|
case "overrides":
|
|
@@ -9907,59 +9927,77 @@ function emitSwiftStandin(graphs, options) {
|
|
|
9907
9927
|
});
|
|
9908
9928
|
};
|
|
9909
9929
|
const access = (symbol, openOwner) => symbol.accessLevel === "open" && openOwner ? "open" : "public";
|
|
9910
|
-
const emitMember = scoped(
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
9914
|
-
|
|
9915
|
-
|
|
9916
|
-
|
|
9917
|
-
|
|
9918
|
-
|
|
9919
|
-
|
|
9920
|
-
|
|
9921
|
-
|
|
9922
|
-
|
|
9923
|
-
|
|
9924
|
-
|
|
9925
|
-
|
|
9926
|
-
|
|
9927
|
-
|
|
9928
|
-
|
|
9929
|
-
|
|
9930
|
-
|
|
9931
|
-
|
|
9932
|
-
|
|
9933
|
-
|
|
9934
|
-
|
|
9935
|
-
|
|
9936
|
-
|
|
9937
|
-
|
|
9938
|
-
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
const
|
|
9946
|
-
const
|
|
9947
|
-
const
|
|
9948
|
-
|
|
9930
|
+
const emitMember = scoped(
|
|
9931
|
+
(member, indent, context) => {
|
|
9932
|
+
const path24 = pathOf(member);
|
|
9933
|
+
if (TYPE_KINDS.has(member.kind.identifier)) {
|
|
9934
|
+
emitType(member, indent);
|
|
9935
|
+
return;
|
|
9936
|
+
}
|
|
9937
|
+
if (member.kind.identifier === "swift.enum.case") return;
|
|
9938
|
+
if (!MEMBER_KINDS.has(member.kind.identifier)) {
|
|
9939
|
+
skipped.push({ path: path24, reason: `unhandled ${member.kind.identifier}` });
|
|
9940
|
+
return;
|
|
9941
|
+
}
|
|
9942
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
9943
|
+
const modifiers = /^((?:(?:required|final|override|convenience|unowned(?:\(\w+\))?|weak|lazy|nonisolated|mutating|nonmutating) )*)(.*)$/s.exec(
|
|
9944
|
+
rest
|
|
9945
|
+
);
|
|
9946
|
+
const flags = new Set(
|
|
9947
|
+
modifiers[1].trim().split(/\s+/).filter(Boolean).map((flag) => flag.replace(/\(.*/, ""))
|
|
9948
|
+
);
|
|
9949
|
+
const required = context.inClass && flags.has("required");
|
|
9950
|
+
const final = context.inClass && flags.has("final") ? "final " : "";
|
|
9951
|
+
const mutating = flags.has("mutating") ? "mutating " : flags.has("nonmutating") ? "nonmutating " : "";
|
|
9952
|
+
let core = `${context.inClass && flags.has("convenience") ? "convenience " : ""}${modifiers[2]}`;
|
|
9953
|
+
const override = context.inClass && !options.plain?.has(path24) && (flags.has("override") || overrides.has(member.identifier.precise) || isObjC(member) && path24.endsWith(".init()")) ? "override " : "";
|
|
9954
|
+
const head = `${indent}${attrs}${access(member, context.openOwner)} ${required ? "required " : ""}${final}${override}${mutating}`;
|
|
9955
|
+
const measured = behavior.get(path24);
|
|
9956
|
+
if (measured) used.add(path24);
|
|
9957
|
+
const overloadBody = /\basync\b/.test(core) ? measured?.asyncBody : /\bResult</.test(core) ? measured?.resultBody : void 0;
|
|
9958
|
+
const body = overloadBody ?? measured?.body ?? trap(path24);
|
|
9959
|
+
switch (member.kind.identifier) {
|
|
9960
|
+
case "swift.property":
|
|
9961
|
+
case "swift.type.property":
|
|
9962
|
+
case "swift.subscript":
|
|
9963
|
+
case "swift.type.subscript": {
|
|
9964
|
+
const accessors = ACCESSORS.exec(core);
|
|
9965
|
+
const decl = core.replace(ACCESSORS, "").trimEnd();
|
|
9966
|
+
const effects = `${accessors?.[1] ?? ""}${accessors?.[2] ?? ""}`;
|
|
9967
|
+
const settable = accessors ? Boolean(accessors[3]) : /^(?:static |class )?var /.test(core);
|
|
9968
|
+
const computed = decl.replace(/^((?:static |class )*)let /, "$1var ");
|
|
9969
|
+
if (measured?.stored !== void 0) {
|
|
9970
|
+
const ownership = flags.has("weak") ? "weak " : flags.has("unowned") ? "unowned " : "";
|
|
9971
|
+
const setter = settable ? "" : "internal(set) ";
|
|
9972
|
+
const value = measured.stored ? ` = ${measured.stored}` : "";
|
|
9973
|
+
emit(
|
|
9974
|
+
`${indent}${attrs}${access(member, context.openOwner)} ${setter}${final}${override}${ownership}${computed}${value}`
|
|
9975
|
+
);
|
|
9976
|
+
return;
|
|
9977
|
+
}
|
|
9978
|
+
emit(
|
|
9979
|
+
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` set { ${measured?.set ?? trap(path24)} }` : ""} }`
|
|
9980
|
+
);
|
|
9949
9981
|
return;
|
|
9950
9982
|
}
|
|
9951
|
-
|
|
9952
|
-
|
|
9983
|
+
default:
|
|
9984
|
+
emit(`${head}${core} { ${body} }`);
|
|
9953
9985
|
}
|
|
9954
|
-
default:
|
|
9955
|
-
emit(`${head}${core} { ${body} }`);
|
|
9956
9986
|
}
|
|
9957
|
-
|
|
9987
|
+
);
|
|
9958
9988
|
const header = (symbol, keyword, indent) => {
|
|
9959
9989
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
9960
|
-
const shape = new RegExp(
|
|
9990
|
+
const shape = new RegExp(
|
|
9991
|
+
`^(?:final )?${keyword}\\s+\`?(\\w+)\`?(<[^>]*>)?\\s*(?::\\s*([^{]*?))?(\\s+where\\s+.*)?$`
|
|
9992
|
+
).exec(rest);
|
|
9961
9993
|
if (!shape) return null;
|
|
9962
|
-
return {
|
|
9994
|
+
return {
|
|
9995
|
+
attrs,
|
|
9996
|
+
name: shape[1],
|
|
9997
|
+
generics: shape[2] ?? "",
|
|
9998
|
+
where: shape[4] ?? "",
|
|
9999
|
+
indent
|
|
10000
|
+
};
|
|
9963
10001
|
};
|
|
9964
10002
|
const externalRoot = (id) => {
|
|
9965
10003
|
for (let at = id; at; at = superId.get(at)) {
|
|
@@ -9974,7 +10012,8 @@ function emitSwiftStandin(graphs, options) {
|
|
|
9974
10012
|
if (!parentSymbol) return null;
|
|
9975
10013
|
if (/^(?:final )?class\s+\w+</.test(LEADING_ATTRS.exec(text(parentSymbol))[2]) && !options.superclasses?.has(pathOf(byId.get(id))))
|
|
9976
10014
|
return `superclass ${pathOf(parentSymbol)} is generic and the graph omits its arguments`;
|
|
9977
|
-
if (unavailable(parentSymbol))
|
|
10015
|
+
if (unavailable(parentSymbol))
|
|
10016
|
+
return `superclass ${pathOf(parentSymbol)} is unavailable`;
|
|
9978
10017
|
return classBlocked(parent) && `superclass ${pathOf(parentSymbol)} is left out`;
|
|
9979
10018
|
};
|
|
9980
10019
|
const objcProtocols = new Set(
|
|
@@ -9988,153 +10027,203 @@ function emitSwiftStandin(graphs, options) {
|
|
|
9988
10027
|
const list2 = [...first ? [first] : [], ...conforms.get(id) ?? []];
|
|
9989
10028
|
return [...new Set(list2)];
|
|
9990
10029
|
};
|
|
9991
|
-
const emitType = scoped(
|
|
9992
|
-
|
|
9993
|
-
|
|
9994
|
-
|
|
9995
|
-
|
|
9996
|
-
|
|
9997
|
-
|
|
9998
|
-
|
|
9999
|
-
|
|
10000
|
-
|
|
10001
|
-
case "swift.class": {
|
|
10002
|
-
const shape = header(symbol, "class", indent);
|
|
10003
|
-
if (!shape) return void skipped.push({ path: path24, reason: `unparsed class ${text(symbol)}` });
|
|
10004
|
-
const parent = options.superclasses?.get(path24) ?? superclass.get(id);
|
|
10005
|
-
const blocked = classBlocked(id);
|
|
10006
|
-
if (blocked) return void skipped.push({ path: path24, reason: blocked });
|
|
10007
|
-
const ancestors = /* @__PURE__ */ new Set();
|
|
10008
|
-
for (let at = superId.get(id); at; at = superId.get(at))
|
|
10009
|
-
for (const name2 of conforms.get(at) ?? []) ancestors.add(name2);
|
|
10010
|
-
const list2 = [
|
|
10011
|
-
...parent ? [parent] : [],
|
|
10012
|
-
...(conforms.get(id) ?? []).filter(
|
|
10013
|
-
(name2) => !ancestors.has(name2) && !(parent && [...KEEP_EXTERNAL.values()].includes(name2))
|
|
10014
|
-
)
|
|
10015
|
-
].filter((name2, at, all2) => all2.indexOf(name2) === at);
|
|
10016
|
-
const parentSymbol = superId.has(id) ? byId.get(superId.get(id)) : void 0;
|
|
10017
|
-
const open = symbol.accessLevel === "open" && (!parentSymbol || parentSymbol.accessLevel === "open");
|
|
10018
|
-
emit(`${indent}${shape.attrs}${open ? "open" : "public"} class ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${selfConforming(shape.where)} {`);
|
|
10019
|
-
const members = membersOf(id);
|
|
10020
|
-
for (const member of members)
|
|
10021
|
-
emitMember(member, inner, { openOwner: open, inClass: true, ownerName: shape.name });
|
|
10022
|
-
const designated = members.some(
|
|
10023
|
-
(member) => member.kind.identifier === "swift.init" && !text(member).startsWith("convenience")
|
|
10024
|
-
);
|
|
10025
|
-
const have = /* @__PURE__ */ new Set();
|
|
10026
|
-
for (let at = id; at; at = superId.get(at))
|
|
10027
|
-
for (const member of children.get(at) ?? []) have.add(witnessKey(member));
|
|
10028
|
-
const protocols = [];
|
|
10029
|
-
const visit = (protocolId) => {
|
|
10030
|
-
if (protocols.includes(protocolId)) return;
|
|
10031
|
-
protocols.push(protocolId);
|
|
10032
|
-
for (const edge of protocolParents.get(protocolId) ?? []) visit(edge);
|
|
10033
|
-
};
|
|
10034
|
-
for (const protocolId of conformIds.get(id) ?? []) visit(protocolId);
|
|
10035
|
-
for (const protocolId of protocols)
|
|
10036
|
-
for (const member of children.get(protocolId) ?? []) {
|
|
10037
|
-
if (!requirement.has(member.identifier.precise) || optional.has(member.identifier.precise)) continue;
|
|
10038
|
-
if (isObjC(member) && / async\b/.test(text(member))) continue;
|
|
10039
|
-
if (have.has(witnessKey(member)) || member.kind.identifier === "swift.associatedtype") continue;
|
|
10040
|
-
have.add(witnessKey(member));
|
|
10041
|
-
emitWitness(member, inner, path24);
|
|
10042
|
-
}
|
|
10043
|
-
const coder = members.some((member) => leaf(member) === "init(coder:)");
|
|
10044
|
-
if (designated && !coder && externalRoot(id) !== "NSObject" && externalRoot(id) !== null)
|
|
10045
|
-
emit(`${inner}public required init?(coder: NSCoder) { ${trap(`${path24}.init(coder:)`)} }`);
|
|
10046
|
-
emit(`${indent}}`);
|
|
10047
|
-
return;
|
|
10048
|
-
}
|
|
10049
|
-
case "swift.struct": {
|
|
10050
|
-
const shape = header(symbol, "struct", indent);
|
|
10051
|
-
if (!shape) return void skipped.push({ path: path24, reason: `unparsed struct ${text(symbol)}` });
|
|
10052
|
-
const members = membersOf(id);
|
|
10053
|
-
const raw2 = rawType(members);
|
|
10054
|
-
const list2 = inheritance(id);
|
|
10055
|
-
emit(`${indent}${shape.attrs}public struct ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`);
|
|
10056
|
-
if (raw2) {
|
|
10057
|
-
emit(`${inner}public let rawValue: ${raw2}`);
|
|
10058
|
-
emit(`${inner}public init(rawValue: ${raw2}) { self.rawValue = rawValue }`);
|
|
10030
|
+
const emitType = scoped(
|
|
10031
|
+
(symbol, indent) => {
|
|
10032
|
+
const path24 = pathOf(symbol);
|
|
10033
|
+
const id = symbol.identifier.precise;
|
|
10034
|
+
const inner = `${indent} `;
|
|
10035
|
+
switch (symbol.kind.identifier) {
|
|
10036
|
+
case "swift.typealias": {
|
|
10037
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
10038
|
+
emit(`${indent}${attrs}public ${rest}`);
|
|
10039
|
+
return;
|
|
10059
10040
|
}
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10041
|
+
case "swift.class": {
|
|
10042
|
+
const shape = header(symbol, "class", indent);
|
|
10043
|
+
if (!shape)
|
|
10044
|
+
return void skipped.push({ path: path24, reason: `unparsed class ${text(symbol)}` });
|
|
10045
|
+
const parent = options.superclasses?.get(path24) ?? superclass.get(id);
|
|
10046
|
+
const blocked = classBlocked(id);
|
|
10047
|
+
if (blocked) return void skipped.push({ path: path24, reason: blocked });
|
|
10048
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
10049
|
+
for (let at = superId.get(id); at; at = superId.get(at))
|
|
10050
|
+
for (const name2 of conforms.get(at) ?? []) ancestors.add(name2);
|
|
10051
|
+
const list2 = [
|
|
10052
|
+
...parent ? [parent] : [],
|
|
10053
|
+
...(conforms.get(id) ?? []).filter(
|
|
10054
|
+
(name2) => !ancestors.has(name2) && !(parent && [...KEEP_EXTERNAL.values()].includes(name2))
|
|
10055
|
+
)
|
|
10056
|
+
].filter((name2, at, all2) => all2.indexOf(name2) === at);
|
|
10057
|
+
const parentSymbol = superId.has(id) ? byId.get(superId.get(id)) : void 0;
|
|
10058
|
+
const open = symbol.accessLevel === "open" && (!parentSymbol || parentSymbol.accessLevel === "open");
|
|
10059
|
+
emit(
|
|
10060
|
+
`${indent}${shape.attrs}${open ? "open" : "public"} class ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${selfConforming(shape.where)} {`
|
|
10061
|
+
);
|
|
10062
|
+
const members = membersOf(id);
|
|
10063
|
+
for (const member of members)
|
|
10064
|
+
emitMember(member, inner, {
|
|
10065
|
+
openOwner: open,
|
|
10066
|
+
inClass: true,
|
|
10067
|
+
ownerName: shape.name
|
|
10068
|
+
});
|
|
10069
|
+
const designated = members.some(
|
|
10070
|
+
(member) => member.kind.identifier === "swift.init" && !text(member).startsWith("convenience")
|
|
10071
|
+
);
|
|
10072
|
+
const have = /* @__PURE__ */ new Set();
|
|
10073
|
+
for (let at = id; at; at = superId.get(at))
|
|
10074
|
+
for (const member of children.get(at) ?? []) have.add(witnessKey(member));
|
|
10075
|
+
const protocols = [];
|
|
10076
|
+
const visit = (protocolId) => {
|
|
10077
|
+
if (protocols.includes(protocolId)) return;
|
|
10078
|
+
protocols.push(protocolId);
|
|
10079
|
+
for (const edge of protocolParents.get(protocolId) ?? []) visit(edge);
|
|
10080
|
+
};
|
|
10081
|
+
for (const protocolId of conformIds.get(id) ?? []) visit(protocolId);
|
|
10082
|
+
for (const protocolId of protocols)
|
|
10083
|
+
for (const member of children.get(protocolId) ?? []) {
|
|
10084
|
+
if (!requirement.has(member.identifier.precise) || optional.has(member.identifier.precise))
|
|
10085
|
+
continue;
|
|
10086
|
+
if (isObjC(member) && / async\b/.test(text(member))) continue;
|
|
10087
|
+
if (have.has(witnessKey(member)) || member.kind.identifier === "swift.associatedtype")
|
|
10088
|
+
continue;
|
|
10089
|
+
have.add(witnessKey(member));
|
|
10090
|
+
emitWitness(member, inner, path24);
|
|
10091
|
+
}
|
|
10092
|
+
const coder = members.some((member) => leaf(member) === "init(coder:)");
|
|
10093
|
+
if (designated && !coder && externalRoot(id) !== "NSObject" && externalRoot(id) !== null)
|
|
10094
|
+
emit(
|
|
10095
|
+
`${inner}public required init?(coder: NSCoder) { ${trap(`${path24}.init(coder:)`)} }`
|
|
10096
|
+
);
|
|
10097
|
+
emit(`${indent}}`);
|
|
10098
|
+
return;
|
|
10069
10099
|
}
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
emit(`${indent}${shape.attrs}public enum ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`);
|
|
10084
|
-
const seenValues = /* @__PURE__ */ new Map();
|
|
10085
|
-
for (const member of cases) {
|
|
10086
|
-
const value = values.get(member.identifier.precise);
|
|
10087
|
-
if (value !== void 0 && seenValues.has(value)) {
|
|
10088
|
-
emit(`${inner}public static var ${tick(leaf(member))}: ${shape.name} { .${seenValues.get(value)} }`);
|
|
10089
|
-
continue;
|
|
10100
|
+
case "swift.struct": {
|
|
10101
|
+
const shape = header(symbol, "struct", indent);
|
|
10102
|
+
if (!shape)
|
|
10103
|
+
return void skipped.push({ path: path24, reason: `unparsed struct ${text(symbol)}` });
|
|
10104
|
+
const members = membersOf(id);
|
|
10105
|
+
const raw2 = rawType(members);
|
|
10106
|
+
const list2 = inheritance(id);
|
|
10107
|
+
emit(
|
|
10108
|
+
`${indent}${shape.attrs}public struct ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`
|
|
10109
|
+
);
|
|
10110
|
+
if (raw2) {
|
|
10111
|
+
emit(`${inner}public let rawValue: ${raw2}`);
|
|
10112
|
+
emit(`${inner}public init(rawValue: ${raw2}) { self.rawValue = rawValue }`);
|
|
10090
10113
|
}
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
|
|
10098
|
-
|
|
10114
|
+
for (const member of members) {
|
|
10115
|
+
if (raw2 && (leaf(member) === "rawValue" || leaf(member) === "init(rawValue:)" || leaf(member) === "init(_:)"))
|
|
10116
|
+
continue;
|
|
10117
|
+
const value = values.get(member.identifier.precise);
|
|
10118
|
+
if (value !== void 0 && member.kind.identifier === "swift.type.property") {
|
|
10119
|
+
emit(
|
|
10120
|
+
`${inner}public static let ${tick(leaf(member))} = ${shape.name}(rawValue: ${value})`
|
|
10121
|
+
);
|
|
10122
|
+
continue;
|
|
10123
|
+
}
|
|
10124
|
+
emitMember(member, inner, {
|
|
10125
|
+
openOwner: false,
|
|
10126
|
+
inClass: false,
|
|
10127
|
+
ownerName: shape.name
|
|
10128
|
+
});
|
|
10129
|
+
}
|
|
10130
|
+
emit(`${indent}}`);
|
|
10131
|
+
return;
|
|
10099
10132
|
}
|
|
10100
|
-
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
|
|
10110
|
-
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
|
|
10133
|
+
case "swift.enum": {
|
|
10134
|
+
const shape = header(symbol, "enum", indent);
|
|
10135
|
+
if (!shape)
|
|
10136
|
+
return void skipped.push({ path: path24, reason: `unparsed enum ${text(symbol)}` });
|
|
10137
|
+
const members = membersOf(id);
|
|
10138
|
+
const raw2 = rawType(members);
|
|
10139
|
+
const cases = (children.get(id) ?? []).filter(
|
|
10140
|
+
(member) => member.kind.identifier === "swift.enum.case"
|
|
10141
|
+
);
|
|
10142
|
+
const missing = raw2 ? cases.filter((member) => !values.has(member.identifier.precise)) : [];
|
|
10143
|
+
if (raw2 && isObjC(symbol) && missing.length > 0)
|
|
10144
|
+
return void skipped.push({
|
|
10145
|
+
path: path24,
|
|
10146
|
+
reason: `no header value for ${missing.map(leaf).join(", ")}`
|
|
10147
|
+
});
|
|
10148
|
+
const list2 = inheritance(id, raw2 ?? void 0).filter(
|
|
10149
|
+
(name2) => name2 !== "RawRepresentable"
|
|
10150
|
+
);
|
|
10151
|
+
emit(
|
|
10152
|
+
`${indent}${shape.attrs}public enum ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`
|
|
10153
|
+
);
|
|
10154
|
+
const seenValues = /* @__PURE__ */ new Map();
|
|
10155
|
+
for (const member of cases) {
|
|
10156
|
+
const value = values.get(member.identifier.precise);
|
|
10157
|
+
if (value !== void 0 && seenValues.has(value)) {
|
|
10158
|
+
emit(
|
|
10159
|
+
`${inner}public static var ${tick(leaf(member))}: ${shape.name} { .${seenValues.get(value)} }`
|
|
10160
|
+
);
|
|
10161
|
+
continue;
|
|
10162
|
+
}
|
|
10163
|
+
if (value !== void 0) seenValues.set(value, tick(leaf(member)));
|
|
10164
|
+
const caseText = text(member).replace(/^case\s+/, "");
|
|
10165
|
+
emit(`${inner}case ${caseText}${value !== void 0 ? ` = ${value}` : ""}`);
|
|
10114
10166
|
}
|
|
10115
|
-
const
|
|
10116
|
-
|
|
10117
|
-
|
|
10118
|
-
|
|
10167
|
+
for (const member of members) {
|
|
10168
|
+
if (member.kind.identifier === "swift.enum.case") continue;
|
|
10169
|
+
if (raw2 && (leaf(member) === "rawValue" || leaf(member) === "init(rawValue:)"))
|
|
10170
|
+
continue;
|
|
10171
|
+
emitMember(member, inner, {
|
|
10172
|
+
openOwner: false,
|
|
10173
|
+
inClass: false,
|
|
10174
|
+
ownerName: shape.name
|
|
10175
|
+
});
|
|
10119
10176
|
}
|
|
10120
|
-
|
|
10121
|
-
|
|
10177
|
+
emit(`${indent}}`);
|
|
10178
|
+
return;
|
|
10122
10179
|
}
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
|
|
10180
|
+
case "swift.protocol": {
|
|
10181
|
+
const shape = header(symbol, "protocol", indent);
|
|
10182
|
+
if (!shape)
|
|
10183
|
+
return void skipped.push({
|
|
10184
|
+
path: path24,
|
|
10185
|
+
reason: `unparsed protocol ${text(symbol)}`
|
|
10186
|
+
});
|
|
10187
|
+
const list2 = [...isObjC(symbol) ? ["AnyObject"] : [], ...inheritance(id)];
|
|
10188
|
+
emit(
|
|
10189
|
+
`${indent}${shape.attrs}public protocol ${shape.name}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`
|
|
10190
|
+
);
|
|
10191
|
+
const members = membersOf(id);
|
|
10192
|
+
const defaults = [];
|
|
10193
|
+
for (const member of members) {
|
|
10194
|
+
if (member.kind.identifier === "swift.associatedtype") {
|
|
10195
|
+
emit(`${inner}${text(member)}`);
|
|
10196
|
+
continue;
|
|
10197
|
+
}
|
|
10198
|
+
const asyncTwin = isObjC(member) && / async\b/.test(text(member));
|
|
10199
|
+
if (!requirement.has(member.identifier.precise) || asyncTwin) {
|
|
10200
|
+
defaults.push(member);
|
|
10201
|
+
continue;
|
|
10202
|
+
}
|
|
10203
|
+
emitRequirement(member, inner);
|
|
10204
|
+
if (optional.has(member.identifier.precise)) defaults.push(member);
|
|
10131
10205
|
}
|
|
10132
10206
|
emit(`${indent}}`);
|
|
10207
|
+
if (defaults.length > 0) {
|
|
10208
|
+
emit(`${indent}extension ${path24} {`);
|
|
10209
|
+
for (const member of defaults) {
|
|
10210
|
+
const decl = text(member);
|
|
10211
|
+
if (optional.has(member.identifier.precise) && member.kind.identifier === "swift.method" && !decl.replace(/\([^)]*\)/g, "").includes("->") && !/ async\b/.test(decl))
|
|
10212
|
+
emitNoop(member, inner);
|
|
10213
|
+
else
|
|
10214
|
+
emitMember(member, inner, {
|
|
10215
|
+
openOwner: false,
|
|
10216
|
+
inClass: false,
|
|
10217
|
+
ownerName: shape.name
|
|
10218
|
+
});
|
|
10219
|
+
}
|
|
10220
|
+
emit(`${indent}}`);
|
|
10221
|
+
}
|
|
10222
|
+
return;
|
|
10133
10223
|
}
|
|
10134
|
-
return;
|
|
10135
10224
|
}
|
|
10136
10225
|
}
|
|
10137
|
-
|
|
10226
|
+
);
|
|
10138
10227
|
const emitWitness = (member, indent, owner2) => {
|
|
10139
10228
|
const { 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
10140
10229
|
const decl = rest.replace(/^(?:weak |unowned )/, "").replace(/^((?:static )?)let /, "$1var ");
|
|
@@ -10143,15 +10232,22 @@ function emitSwiftStandin(graphs, options) {
|
|
|
10143
10232
|
if (member.kind.identifier === "swift.property" || member.kind.identifier === "swift.type.property") {
|
|
10144
10233
|
const accessors = ACCESSORS.exec(decl);
|
|
10145
10234
|
const bare = decl.replace(ACCESSORS, "").trimEnd();
|
|
10146
|
-
emit(
|
|
10147
|
-
|
|
10235
|
+
emit(
|
|
10236
|
+
`${indent}public ${bare} { get { ${body} }${accessors?.[3] ? ` set { ${body} }` : ""} }`
|
|
10237
|
+
);
|
|
10238
|
+
} else
|
|
10239
|
+
emit(
|
|
10240
|
+
`${indent}public ${member.kind.identifier === "swift.init" ? "required " : ""}${stripDefaults(decl)} { ${body} }`
|
|
10241
|
+
);
|
|
10148
10242
|
};
|
|
10149
10243
|
const emitNoop = scoped((member, indent) => {
|
|
10150
10244
|
emit(`${indent}public ${stripDefaults(text(member))} {}`);
|
|
10151
10245
|
});
|
|
10152
10246
|
const emitRequirement = scoped((member, indent) => {
|
|
10153
10247
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
10154
|
-
emit(
|
|
10248
|
+
emit(
|
|
10249
|
+
`${indent}${attrs}${stripDefaults(rest.replace(/^(?:weak |unowned )/, "").replace(/^((?:static )?)let /, "$1var "))}`
|
|
10250
|
+
);
|
|
10155
10251
|
});
|
|
10156
10252
|
const rawType = (members) => {
|
|
10157
10253
|
const init = members.find((member) => leaf(member) === "init(rawValue:)");
|
|
@@ -10164,7 +10260,9 @@ function emitSwiftStandin(graphs, options) {
|
|
|
10164
10260
|
emit(`${attrs}public ${rest} { ${trap(path24)} }`);
|
|
10165
10261
|
} else if (symbol.kind.identifier === "swift.var") {
|
|
10166
10262
|
const decl = text(symbol).replace(/^let /, "var ").replace(ACCESSORS, "").trimEnd();
|
|
10167
|
-
|
|
10263
|
+
const measured = behavior.get(path24);
|
|
10264
|
+
if (measured) used.add(path24);
|
|
10265
|
+
emit(`public ${decl} { ${measured?.body ?? trap(path24)} }`);
|
|
10168
10266
|
} else skipped.push({ path: path24, reason: `unhandled top-level ${symbol.kind.identifier}` });
|
|
10169
10267
|
});
|
|
10170
10268
|
const roots = [...byId.values()].filter((symbol) => !owner.has(symbol.identifier.precise) && !unavailable(symbol)).sort((a, b) => pathOf(a).localeCompare(pathOf(b)));
|
|
@@ -10185,11 +10283,20 @@ function emitSwiftStandin(graphs, options) {
|
|
|
10185
10283
|
emit(`extension ${name2} {`);
|
|
10186
10284
|
for (const member of kept)
|
|
10187
10285
|
if (member.kind.identifier === "swift.init" && !text(member).startsWith("convenience"))
|
|
10188
|
-
emitMember(
|
|
10189
|
-
|
|
10190
|
-
|
|
10191
|
-
|
|
10192
|
-
|
|
10286
|
+
emitMember(
|
|
10287
|
+
{
|
|
10288
|
+
...member,
|
|
10289
|
+
declarationFragments: [
|
|
10290
|
+
{ kind: "text", spelling: `convenience ${text(member)}` }
|
|
10291
|
+
]
|
|
10292
|
+
},
|
|
10293
|
+
" ",
|
|
10294
|
+
{
|
|
10295
|
+
openOwner: false,
|
|
10296
|
+
inClass: true,
|
|
10297
|
+
ownerName: name2
|
|
10298
|
+
}
|
|
10299
|
+
);
|
|
10193
10300
|
else emitMember(member, " ", { openOwner: false, inClass: false, ownerName: name2 });
|
|
10194
10301
|
emit(`}`);
|
|
10195
10302
|
}
|
|
@@ -10203,7 +10310,8 @@ function emitSwiftStandin(graphs, options) {
|
|
|
10203
10310
|
""
|
|
10204
10311
|
];
|
|
10205
10312
|
for (const path24 of behavior.keys())
|
|
10206
|
-
if (!used.has(path24))
|
|
10313
|
+
if (!used.has(path24))
|
|
10314
|
+
skipped.push({ path: path24, reason: "behavior names no emitted declaration" });
|
|
10207
10315
|
return {
|
|
10208
10316
|
source: `${[...banner, ...lines].join("\n")}
|
|
10209
10317
|
`,
|
|
@@ -10211,7 +10319,41 @@ function emitSwiftStandin(graphs, options) {
|
|
|
10211
10319
|
owners: [...banner.map(() => ""), ...owners]
|
|
10212
10320
|
};
|
|
10213
10321
|
}
|
|
10214
|
-
var KEYWORDS = /* @__PURE__ */ new Set([
|
|
10322
|
+
var KEYWORDS = /* @__PURE__ */ new Set([
|
|
10323
|
+
"Type",
|
|
10324
|
+
"Protocol",
|
|
10325
|
+
"Self",
|
|
10326
|
+
"default",
|
|
10327
|
+
"init",
|
|
10328
|
+
"self",
|
|
10329
|
+
"class",
|
|
10330
|
+
"func",
|
|
10331
|
+
"var",
|
|
10332
|
+
"let",
|
|
10333
|
+
"in",
|
|
10334
|
+
"is",
|
|
10335
|
+
"as",
|
|
10336
|
+
"repeat",
|
|
10337
|
+
"internal",
|
|
10338
|
+
"public",
|
|
10339
|
+
"private",
|
|
10340
|
+
"operator",
|
|
10341
|
+
"extension",
|
|
10342
|
+
"subscript",
|
|
10343
|
+
"static",
|
|
10344
|
+
"struct",
|
|
10345
|
+
"protocol",
|
|
10346
|
+
"enum",
|
|
10347
|
+
"case",
|
|
10348
|
+
"where",
|
|
10349
|
+
"return",
|
|
10350
|
+
"throw",
|
|
10351
|
+
"throws",
|
|
10352
|
+
"import",
|
|
10353
|
+
"true",
|
|
10354
|
+
"false",
|
|
10355
|
+
"nil"
|
|
10356
|
+
]);
|
|
10215
10357
|
var tick = (name2) => KEYWORDS.has(name2) ? `\`${name2}\`` : name2;
|
|
10216
10358
|
function stripDefaults(decl) {
|
|
10217
10359
|
let out = "";
|
|
@@ -10260,19 +10402,34 @@ ${"stdout" in error ? String(error.stdout) : ""}` : String(error);
|
|
|
10260
10402
|
return [...new Set(errors)].slice(0, 3).join("; ") || output.trim().slice(0, 400);
|
|
10261
10403
|
}
|
|
10262
10404
|
var key = (...parts) => (0, import_node_crypto7.createHash)("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
10263
|
-
|
|
10264
|
-
|
|
10265
|
-
const
|
|
10266
|
-
|
|
10267
|
-
import_node_fs16.default.
|
|
10268
|
-
|
|
10269
|
-
|
|
10270
|
-
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
|
|
10274
|
-
|
|
10275
|
-
|
|
10405
|
+
var digests = /* @__PURE__ */ new Map();
|
|
10406
|
+
function treeDigest(root) {
|
|
10407
|
+
const names = [];
|
|
10408
|
+
const walk2 = (dir) => {
|
|
10409
|
+
for (const entry of import_node_fs16.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name < right.name ? -1 : 1)) {
|
|
10410
|
+
const full = import_node_path16.default.join(dir, entry.name);
|
|
10411
|
+
if (entry.isDirectory()) walk2(full);
|
|
10412
|
+
else if (entry.isFile()) names.push(import_node_path16.default.relative(root, full));
|
|
10413
|
+
}
|
|
10414
|
+
};
|
|
10415
|
+
walk2(root);
|
|
10416
|
+
const stamp = names.map((name2) => {
|
|
10417
|
+
const stat2 = import_node_fs16.default.statSync(import_node_path16.default.join(root, name2));
|
|
10418
|
+
return `${name2}\0${stat2.size}:${stat2.mtimeMs}`;
|
|
10419
|
+
}).join("\n");
|
|
10420
|
+
const memo2 = digests.get(`tree\0${root}`);
|
|
10421
|
+
if (memo2?.stamp === stamp) return memo2.digest;
|
|
10422
|
+
const hash = (0, import_node_crypto7.createHash)("sha256");
|
|
10423
|
+
for (const name2 of names) {
|
|
10424
|
+
hash.update(`${name2}\0`);
|
|
10425
|
+
hash.update(import_node_fs16.default.readFileSync(import_node_path16.default.join(root, name2)));
|
|
10426
|
+
hash.update("\0");
|
|
10427
|
+
}
|
|
10428
|
+
const digest = hash.digest("hex");
|
|
10429
|
+
digests.set(`tree\0${root}`, { stamp, digest });
|
|
10430
|
+
return digest;
|
|
10431
|
+
}
|
|
10432
|
+
function locateXcframework(tree) {
|
|
10276
10433
|
const find = (root, depth) => {
|
|
10277
10434
|
for (const entry of import_node_fs16.default.readdirSync(root, { withFileTypes: true })) {
|
|
10278
10435
|
if (!entry.isDirectory() || entry.name === "__MACOSX") continue;
|
|
@@ -10283,9 +10440,53 @@ function xcframework(binary) {
|
|
|
10283
10440
|
}
|
|
10284
10441
|
return null;
|
|
10285
10442
|
};
|
|
10286
|
-
|
|
10443
|
+
return find(tree, 2);
|
|
10444
|
+
}
|
|
10445
|
+
function xcframework(binary) {
|
|
10446
|
+
if (!binary.url && !binary.dir.endsWith(".zip"))
|
|
10447
|
+
return { dir: binary.dir, digest: treeDigest(binary.dir) };
|
|
10448
|
+
const dir = import_node_path16.default.join(cacheDir4, "archives", key(binary.url ?? binary.dir));
|
|
10449
|
+
const archive = import_node_path16.default.join(dir, "archive.zip");
|
|
10450
|
+
const fingerprint = import_node_path16.default.join(dir, ".fingerprint");
|
|
10451
|
+
const stored = (() => {
|
|
10452
|
+
try {
|
|
10453
|
+
const parsed = JSON.parse(import_node_fs16.default.readFileSync(fingerprint, "utf8"));
|
|
10454
|
+
return parsed && typeof parsed === "object" && "sha" in parsed ? parsed : null;
|
|
10455
|
+
} catch {
|
|
10456
|
+
return null;
|
|
10457
|
+
}
|
|
10458
|
+
})();
|
|
10459
|
+
if (!binary.url) {
|
|
10460
|
+
const stat2 = import_node_fs16.default.statSync(binary.dir);
|
|
10461
|
+
const stamp = `${stat2.size}:${stat2.mtimeMs}`;
|
|
10462
|
+
if (stored?.stamp === stamp) {
|
|
10463
|
+
const found3 = locateXcframework(import_node_path16.default.join(dir, "tree"));
|
|
10464
|
+
if (found3) return { dir: found3, digest: stored.sha };
|
|
10465
|
+
}
|
|
10466
|
+
const sha2 = (0, import_node_crypto7.createHash)("sha256").update(import_node_fs16.default.readFileSync(binary.dir)).digest("hex");
|
|
10467
|
+
if (sha2 !== stored?.sha || !locateXcframework(import_node_path16.default.join(dir, "tree"))) {
|
|
10468
|
+
import_node_fs16.default.rmSync(dir, { recursive: true, force: true });
|
|
10469
|
+
import_node_fs16.default.mkdirSync(import_node_path16.default.join(dir, "tree"), { recursive: true });
|
|
10470
|
+
exec("unzip", ["-q", binary.dir, "-d", import_node_path16.default.join(dir, "tree")]);
|
|
10471
|
+
}
|
|
10472
|
+
import_node_fs16.default.writeFileSync(fingerprint, JSON.stringify({ stamp, sha: sha2 }));
|
|
10473
|
+
const found2 = locateXcframework(import_node_path16.default.join(dir, "tree"));
|
|
10474
|
+
if (!found2) throw new Error("its archive holds no .xcframework");
|
|
10475
|
+
return { dir: found2, digest: sha2 };
|
|
10476
|
+
}
|
|
10477
|
+
if (stored && import_node_fs16.default.existsSync(archive)) {
|
|
10478
|
+
const found2 = locateXcframework(import_node_path16.default.join(dir, "tree"));
|
|
10479
|
+
if (found2) return { dir: found2, digest: stored.sha };
|
|
10480
|
+
}
|
|
10481
|
+
import_node_fs16.default.rmSync(dir, { recursive: true, force: true });
|
|
10482
|
+
import_node_fs16.default.mkdirSync(import_node_path16.default.join(dir, "tree"), { recursive: true });
|
|
10483
|
+
exec("curl", ["-fsSL", "--retry", "2", "-o", archive, binary.url]);
|
|
10484
|
+
const sha = (0, import_node_crypto7.createHash)("sha256").update(import_node_fs16.default.readFileSync(archive)).digest("hex");
|
|
10485
|
+
exec("unzip", ["-q", archive, "-d", import_node_path16.default.join(dir, "tree")]);
|
|
10486
|
+
import_node_fs16.default.writeFileSync(fingerprint, JSON.stringify({ sha }));
|
|
10487
|
+
const found = locateXcframework(import_node_path16.default.join(dir, "tree"));
|
|
10287
10488
|
if (!found) throw new Error("its archive holds no .xcframework");
|
|
10288
|
-
return found;
|
|
10489
|
+
return { dir: found, digest: sha };
|
|
10289
10490
|
}
|
|
10290
10491
|
var files = (dir, test) => import_node_fs16.default.existsSync(dir) ? import_node_fs16.default.readdirSync(dir, { recursive: true, encoding: "utf8" }).filter((file) => test(import_node_path16.default.basename(file))).sort() : [];
|
|
10291
10492
|
function surfaces(xcframeworkDir) {
|
|
@@ -10504,6 +10705,62 @@ function functionDeclarations(ast, headers) {
|
|
|
10504
10705
|
}
|
|
10505
10706
|
return found;
|
|
10506
10707
|
}
|
|
10708
|
+
function matchOpen(text3, close) {
|
|
10709
|
+
const open = text3[close] === ")" ? "(" : "[";
|
|
10710
|
+
let depth = 0;
|
|
10711
|
+
for (let index = close; index >= 0; index--) {
|
|
10712
|
+
if (text3[index] === text3[close]) depth++;
|
|
10713
|
+
else if (text3[index] === open && --depth === 0) return index;
|
|
10714
|
+
}
|
|
10715
|
+
return -1;
|
|
10716
|
+
}
|
|
10717
|
+
var identChar = (char) => char !== void 0 && /[\w$]/.test(char);
|
|
10718
|
+
function splitDeclarators(statement, names) {
|
|
10719
|
+
const chunks = [];
|
|
10720
|
+
let depth = 0;
|
|
10721
|
+
let quote = null;
|
|
10722
|
+
let start = 0;
|
|
10723
|
+
for (let index = 0; index < statement.length; index++) {
|
|
10724
|
+
const char = statement[index];
|
|
10725
|
+
if (quote) {
|
|
10726
|
+
if (char === "\\") index++;
|
|
10727
|
+
else if (char === quote) quote = null;
|
|
10728
|
+
} else if (char === '"' || char === "'") quote = char;
|
|
10729
|
+
else if (char === "(" || char === "[" || char === "{") depth++;
|
|
10730
|
+
else if (char === ")" || char === "]" || char === "}") depth--;
|
|
10731
|
+
else if (char === "," && depth === 0) {
|
|
10732
|
+
chunks.push(statement.slice(start, index));
|
|
10733
|
+
start = index + 1;
|
|
10734
|
+
}
|
|
10735
|
+
}
|
|
10736
|
+
chunks.push(statement.slice(start));
|
|
10737
|
+
if (chunks.length !== names.length)
|
|
10738
|
+
throw new Error(
|
|
10739
|
+
`${names[0]} has an unexpected grouped declaration in ${JSON.stringify(statement.trim().slice(0, 80))}`
|
|
10740
|
+
);
|
|
10741
|
+
let end = chunks[0].indexOf(names[0]);
|
|
10742
|
+
if (end < 0) throw new Error(`${names[0]} names no declarator in its own declaration`);
|
|
10743
|
+
for (; ; ) {
|
|
10744
|
+
while (end > 0 && /[\s*]/.test(chunks[0][end - 1])) end--;
|
|
10745
|
+
if (end > 0 && (chunks[0][end - 1] === ")" || chunks[0][end - 1] === "]")) {
|
|
10746
|
+
end = matchOpen(chunks[0], end - 1);
|
|
10747
|
+
if (end < 0) throw new Error(`${names[0]} has unbalanced groups in its declaration`);
|
|
10748
|
+
while (end > 0 && identChar(chunks[0][end - 1])) end--;
|
|
10749
|
+
continue;
|
|
10750
|
+
}
|
|
10751
|
+
if (end > 1 && chunks[0][end - 1] === "(" && identChar(chunks[0][end - 2])) {
|
|
10752
|
+
end--;
|
|
10753
|
+
while (end > 0 && identChar(chunks[0][end - 1])) end--;
|
|
10754
|
+
continue;
|
|
10755
|
+
}
|
|
10756
|
+
break;
|
|
10757
|
+
}
|
|
10758
|
+
if (end > 0 && chunks[0][end - 1] === "(") end--;
|
|
10759
|
+
const specifiers = chunks[0].slice(0, end);
|
|
10760
|
+
return chunks.map(
|
|
10761
|
+
(chunk, index) => index === 0 ? chunk : `${specifiers} ${chunk.trim()}`
|
|
10762
|
+
);
|
|
10763
|
+
}
|
|
10507
10764
|
function cStandin(surface, binary, toolchain, work) {
|
|
10508
10765
|
const named = [
|
|
10509
10766
|
...import_node_fs16.default.readFileSync(surface.modulemap, "utf8").matchAll(/(?:umbrella\s+)?header\s+"([^"]+)"/g)
|
|
@@ -10548,26 +10805,40 @@ ${roots.map((file) => ` header "${file}"
|
|
|
10548
10805
|
);
|
|
10549
10806
|
const byPath = new Map(headers.map((file) => [import_node_path16.default.join(include, file), file]));
|
|
10550
10807
|
const declarations = functionDeclarations(ast, new Set(byPath.keys()));
|
|
10808
|
+
const groups = /* @__PURE__ */ new Map();
|
|
10809
|
+
for (const declaration of declarations) {
|
|
10810
|
+
const group = groups.get(`${declaration.file}\0${declaration.begin}`) ?? [];
|
|
10811
|
+
group.push(declaration);
|
|
10812
|
+
groups.set(`${declaration.file}\0${declaration.begin}`, group);
|
|
10813
|
+
}
|
|
10551
10814
|
const seen = /* @__PURE__ */ new Set();
|
|
10552
10815
|
const definitions = [];
|
|
10553
|
-
for (const
|
|
10554
|
-
|
|
10555
|
-
|
|
10556
|
-
const
|
|
10557
|
-
const close = text3.indexOf(";", end);
|
|
10816
|
+
for (const group of groups.values()) {
|
|
10817
|
+
const first = group[0];
|
|
10818
|
+
const text3 = texts.get(byPath.get(first.file));
|
|
10819
|
+
const close = text3.indexOf(";", first.end);
|
|
10558
10820
|
if (close < 0)
|
|
10559
|
-
throw new Error(`${
|
|
10560
|
-
|
|
10561
|
-
|
|
10562
|
-
|
|
10821
|
+
throw new Error(`${first.name} has no declaration end in ${byPath.get(first.file)}`);
|
|
10822
|
+
const statement = text3.slice(first.begin, close);
|
|
10823
|
+
const declarators = group.length === 1 ? [statement] : splitDeclarators(
|
|
10824
|
+
statement,
|
|
10825
|
+
group.map((declaration) => declaration.name)
|
|
10826
|
+
);
|
|
10827
|
+
group.forEach((declaration, index) => {
|
|
10828
|
+
if (seen.has(declaration.name)) return;
|
|
10829
|
+
seen.add(declaration.name);
|
|
10830
|
+
definitions.push(
|
|
10831
|
+
`${declarators[index].trim()} {
|
|
10832
|
+
peach_standin_trap("${declaration.name}");
|
|
10563
10833
|
}
|
|
10564
10834
|
`
|
|
10565
|
-
|
|
10835
|
+
);
|
|
10836
|
+
});
|
|
10566
10837
|
}
|
|
10567
10838
|
const sdk = JSON.stringify(`${binary.target} (${binary.source})`);
|
|
10568
10839
|
const source = [
|
|
10569
10840
|
`// generated by peach from ${surface.module}'s headers: ${binary.target} ships`,
|
|
10570
|
-
"// iOS machine code only, so every function traps naming itself.",
|
|
10841
|
+
"// iOS machine code only, so every extern function traps naming itself.",
|
|
10571
10842
|
...roots.map((file) => `#include "${file}"`),
|
|
10572
10843
|
"#include <stdio.h>",
|
|
10573
10844
|
"#include <stdlib.h>",
|
|
@@ -10579,6 +10850,22 @@ ${roots.map((file) => ` header "${file}"
|
|
|
10579
10850
|
"",
|
|
10580
10851
|
...definitions
|
|
10581
10852
|
].join("\n");
|
|
10853
|
+
const out = import_node_path16.default.join(work, `${surface.module}.c`);
|
|
10854
|
+
import_node_fs16.default.writeFileSync(out, source);
|
|
10855
|
+
try {
|
|
10856
|
+
exec(import_node_path16.default.join(toolchain.toolchainBin, "clang"), [
|
|
10857
|
+
"-target",
|
|
10858
|
+
TRIPLE,
|
|
10859
|
+
"--sysroot",
|
|
10860
|
+
sysroot,
|
|
10861
|
+
"-fsyntax-only",
|
|
10862
|
+
"-I",
|
|
10863
|
+
include,
|
|
10864
|
+
out
|
|
10865
|
+
]);
|
|
10866
|
+
} catch (error) {
|
|
10867
|
+
throw new Error(`its generated source does not compile: ${failure(error)}`);
|
|
10868
|
+
}
|
|
10582
10869
|
return {
|
|
10583
10870
|
module: surface.module,
|
|
10584
10871
|
target: binary.target,
|
|
@@ -10592,18 +10879,48 @@ ${roots.map((file) => ` header "${file}"
|
|
|
10592
10879
|
};
|
|
10593
10880
|
}
|
|
10594
10881
|
var built = /* @__PURE__ */ new Map();
|
|
10595
|
-
function
|
|
10596
|
-
|
|
10882
|
+
function standinGenerationInputs(binaries, toolchain) {
|
|
10883
|
+
const { moduleRoot, toolchainBin, release } = toolchain;
|
|
10884
|
+
const parts = [
|
|
10885
|
+
"standin/v2",
|
|
10886
|
+
toolchainBin,
|
|
10887
|
+
release,
|
|
10888
|
+
swiftModuleSdk(moduleRoot).wasmSdkId,
|
|
10889
|
+
swiftModuleDigest(moduleRoot).toString("hex"),
|
|
10890
|
+
`emit/${STANDIN_EMIT_VERSION}`
|
|
10891
|
+
];
|
|
10892
|
+
for (const binary of binaries) {
|
|
10893
|
+
try {
|
|
10894
|
+
parts.push(
|
|
10895
|
+
binary.target,
|
|
10896
|
+
binary.source,
|
|
10897
|
+
binary.url ?? "",
|
|
10898
|
+
xcframework(binary).digest
|
|
10899
|
+
);
|
|
10900
|
+
} catch {
|
|
10901
|
+
parts.push(binary.target, binary.source, binary.url ?? "", "unreadable");
|
|
10902
|
+
}
|
|
10903
|
+
}
|
|
10904
|
+
return (0, import_node_crypto7.createHash)("sha256").update(parts.join("\0")).digest("hex");
|
|
10905
|
+
}
|
|
10906
|
+
function binaryStandins(binary, toolchain, provided) {
|
|
10907
|
+
if (provided.has(binary.target)) return [];
|
|
10908
|
+
let all;
|
|
10909
|
+
let digest;
|
|
10597
10910
|
try {
|
|
10598
|
-
|
|
10911
|
+
const artifact = xcframework(binary);
|
|
10912
|
+
all = surfaces(artifact.dir);
|
|
10913
|
+
digest = artifact.digest;
|
|
10599
10914
|
} catch (error) {
|
|
10600
10915
|
return error instanceof Error ? error.message : String(error);
|
|
10601
10916
|
}
|
|
10602
|
-
|
|
10917
|
+
const found = all.filter((surface) => !provided.has(surface.module));
|
|
10918
|
+
if (found.length === 0) {
|
|
10919
|
+
if (all.length > 0) return [];
|
|
10603
10920
|
return "its iOS simulator slice has no Swift interface or C modulemap";
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
);
|
|
10921
|
+
}
|
|
10922
|
+
const hash = (0, import_node_crypto7.createHash)("sha256").update(standinGenerationInputs([binary], toolchain));
|
|
10923
|
+
hash.update(digest);
|
|
10607
10924
|
for (const surface of found) {
|
|
10608
10925
|
hash.update(`${surface.kind}\0${surface.module}\0`);
|
|
10609
10926
|
for (const file of surface.kind === "swift" ? [surface.interface] : [
|
|
@@ -10646,11 +10963,11 @@ function binaryStandins(binary, toolchain) {
|
|
|
10646
10963
|
}
|
|
10647
10964
|
return result;
|
|
10648
10965
|
}
|
|
10649
|
-
function swiftStandins(binaries, toolchain) {
|
|
10966
|
+
function swiftStandins(binaries, toolchain, provided = /* @__PURE__ */ new Set()) {
|
|
10650
10967
|
const standins = [];
|
|
10651
10968
|
const gaps = /* @__PURE__ */ new Map();
|
|
10652
10969
|
for (const binary of binaries) {
|
|
10653
|
-
const result = binaryStandins(binary, toolchain);
|
|
10970
|
+
const result = binaryStandins(binary, toolchain, provided);
|
|
10654
10971
|
if (typeof result === "string") gaps.set(binary.target, result);
|
|
10655
10972
|
else standins.push(...result);
|
|
10656
10973
|
}
|
|
@@ -11875,32 +12192,49 @@ function swiftPackages(entry, app) {
|
|
|
11875
12192
|
({ source }) => source.kind === "local" ? stamp(import_node_path19.default.join(source.dir, "Package.swift")) : 0
|
|
11876
12193
|
)
|
|
11877
12194
|
]);
|
|
11878
|
-
|
|
11879
|
-
|
|
11880
|
-
|
|
11881
|
-
|
|
11882
|
-
|
|
11883
|
-
|
|
11884
|
-
|
|
11885
|
-
|
|
11886
|
-
|
|
11887
|
-
|
|
11888
|
-
|
|
11889
|
-
|
|
11890
|
-
|
|
11891
|
-
|
|
11892
|
-
|
|
11893
|
-
|
|
12195
|
+
let cached3 = entry.packages;
|
|
12196
|
+
if (cached3?.key !== key2) {
|
|
12197
|
+
cached3 = {
|
|
12198
|
+
key: key2,
|
|
12199
|
+
standinKey: "",
|
|
12200
|
+
packages: resolveSwiftPackages({
|
|
12201
|
+
rootDir: app.rootDir,
|
|
12202
|
+
resolved: app.packageResolved,
|
|
12203
|
+
products: app.linkedProducts,
|
|
12204
|
+
localDirs: app.localPackageDirs,
|
|
12205
|
+
provided: entry.provided
|
|
12206
|
+
}),
|
|
12207
|
+
standins: []
|
|
12208
|
+
};
|
|
12209
|
+
entry.packages = cached3;
|
|
12210
|
+
}
|
|
12211
|
+
const reached = cached3.packages.binaries.filter((binary) => binary.reached);
|
|
12212
|
+
if (entry.moduleRoot && entry.provided && reached.length > 0) {
|
|
12213
|
+
const resolved = swiftModuleToolchain(entry.moduleRoot);
|
|
12214
|
+
const toolchain = {
|
|
12215
|
+
moduleRoot: entry.moduleRoot,
|
|
12216
|
+
toolchainBin: resolved.toolchainBin,
|
|
12217
|
+
release: resolved.release
|
|
12218
|
+
};
|
|
12219
|
+
const generation = standinGenerationInputs(reached, toolchain);
|
|
12220
|
+
if (cached3.standinKey !== generation) {
|
|
12221
|
+
const built2 = swiftStandins(reached, toolchain, entry.provided);
|
|
12222
|
+
cached3.packages = resolveSwiftPackages({
|
|
12223
|
+
rootDir: app.rootDir,
|
|
12224
|
+
resolved: app.packageResolved,
|
|
12225
|
+
products: app.linkedProducts,
|
|
12226
|
+
localDirs: app.localPackageDirs,
|
|
12227
|
+
provided: /* @__PURE__ */ new Set([
|
|
12228
|
+
...entry.provided,
|
|
12229
|
+
...built2.standins.map((standin) => standin.target)
|
|
12230
|
+
]),
|
|
12231
|
+
binaryGaps: built2.gaps
|
|
11894
12232
|
});
|
|
11895
|
-
standins = built2.standins;
|
|
11896
|
-
|
|
11897
|
-
/* @__PURE__ */ new Set([...entry.provided, ...standins.map((standin) => standin.target)]),
|
|
11898
|
-
built2.gaps
|
|
11899
|
-
);
|
|
12233
|
+
cached3.standins = built2.standins;
|
|
12234
|
+
cached3.standinKey = generation;
|
|
11900
12235
|
}
|
|
11901
|
-
entry.packages = { key: key2, packages, standins };
|
|
11902
12236
|
}
|
|
11903
|
-
return
|
|
12237
|
+
return cached3;
|
|
11904
12238
|
}
|
|
11905
12239
|
var XCODE_APP_DIR = "__app__";
|
|
11906
12240
|
var XCODE_FRAMEWORKS_DIR = "__frameworks__";
|