peachsim 0.1.782 → 0.1.783
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 -0
- package/cli/main.ts +1 -0
- 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 +2 -2
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +109 -32
- 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 +111 -34
- 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 +109 -32
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/swift-standin-emit.ts +149 -39
package/dist-lib/vite-swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.783 | (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;
|
|
@@ -4721,7 +4721,7 @@ function getCliVersion() {
|
|
|
4721
4721
|
}
|
|
4722
4722
|
|
|
4723
4723
|
// src/swift-standin-emit.ts
|
|
4724
|
-
var STANDIN_EMIT_VERSION = "
|
|
4724
|
+
var STANDIN_EMIT_VERSION = "2";
|
|
4725
4725
|
var TYPE_KINDS = /* @__PURE__ */ new Set([
|
|
4726
4726
|
"swift.class",
|
|
4727
4727
|
"swift.struct",
|
|
@@ -4739,7 +4739,18 @@ var MEMBER_KINDS = /* @__PURE__ */ new Set([
|
|
|
4739
4739
|
"swift.subscript",
|
|
4740
4740
|
"swift.type.subscript"
|
|
4741
4741
|
]);
|
|
4742
|
-
var
|
|
4742
|
+
var ACCESSOR_WORD = /^(?:get|set|nonmutating|mutating|async|throws|rethrows|_read|_modify)$/;
|
|
4743
|
+
function splitAccessors(core) {
|
|
4744
|
+
const match = /\{\s*([^}]*)\}\s*$/.exec(core);
|
|
4745
|
+
const words = match ? match[1].trim().split(/\s+/).filter(Boolean) : [];
|
|
4746
|
+
const accessors = words.length > 0 && words.every((word) => ACCESSOR_WORD.test(word));
|
|
4747
|
+
return {
|
|
4748
|
+
decl: accessors ? core.slice(0, match.index).trimEnd() : core,
|
|
4749
|
+
effects: `${words.includes("async") ? " async" : ""}${words.includes("throws") ? " throws" : words.includes("rethrows") ? " rethrows" : ""}`,
|
|
4750
|
+
settable: accessors ? words.includes("set") : /^(?:static |class )?var /.test(core),
|
|
4751
|
+
nonmutating: words.includes("nonmutating")
|
|
4752
|
+
};
|
|
4753
|
+
}
|
|
4743
4754
|
var KEEP_EXTERNAL = /* @__PURE__ */ new Map([
|
|
4744
4755
|
["s:SH", "Hashable"],
|
|
4745
4756
|
["s:SQ", "Equatable"],
|
|
@@ -4761,7 +4772,10 @@ var pathOf = (symbol) => symbol.pathComponents.join(".");
|
|
|
4761
4772
|
var unavailable = (symbol) => (symbol.availability ?? []).some(
|
|
4762
4773
|
(entry) => entry.isUnconditionallyUnavailable || entry.obsoleted !== void 0
|
|
4763
4774
|
);
|
|
4764
|
-
var witnessKey = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.") ? "type" : "instance"}|${
|
|
4775
|
+
var witnessKey = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.") ? "type" : "instance"}|${stripDefaults(
|
|
4776
|
+
splitAccessors(text(symbol)).decl
|
|
4777
|
+
).replace(/\s+/g, " ").trim()}`;
|
|
4778
|
+
var sideLeaf = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.") ? "type" : "instance"}|leaf|${leaf(symbol)}`;
|
|
4765
4779
|
var isObjC = (symbol) => symbol.identifier.precise.startsWith("c:");
|
|
4766
4780
|
var trap = (path16) => `fatalError("${path16} is a binary framework peach cannot run")`;
|
|
4767
4781
|
function emitSwiftStandin(graphs, options) {
|
|
@@ -4796,11 +4810,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4796
4810
|
if (local) return { name: pathOf(local), local: true };
|
|
4797
4811
|
if (!fallback) return null;
|
|
4798
4812
|
const parts = fallback.split(".");
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
};
|
|
4813
|
+
const module2 = parts[0] === "SwiftUICore" ? "SwiftUI" : parts[0];
|
|
4814
|
+
const unqualified = parts.slice(1).join(".") || parts[0];
|
|
4815
|
+
const name2 = family.has(parts[0]) && parts[0] !== "SwiftUICore" ? parts.join(".") : unqualified;
|
|
4816
|
+
return { name: name2, module: module2, local: false };
|
|
4804
4817
|
};
|
|
4805
4818
|
for (const graph of graphs)
|
|
4806
4819
|
for (const edge of graph.relationships) {
|
|
@@ -4855,8 +4868,42 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4855
4868
|
case "overrides":
|
|
4856
4869
|
overrides.add(edge.source);
|
|
4857
4870
|
break;
|
|
4871
|
+
case "defaultImplementationOf":
|
|
4872
|
+
break;
|
|
4858
4873
|
}
|
|
4859
4874
|
}
|
|
4875
|
+
const requirementProtocol = /* @__PURE__ */ new Map();
|
|
4876
|
+
const hasDefault = /* @__PURE__ */ new Set();
|
|
4877
|
+
for (const graph of graphs)
|
|
4878
|
+
for (const edge of graph.relationships) {
|
|
4879
|
+
if ((edge.kind === "requirementOf" || edge.kind === "optionalRequirementOf") && byId.has(edge.target))
|
|
4880
|
+
requirementProtocol.set(edge.source, edge.target);
|
|
4881
|
+
if (edge.kind === "defaultImplementationOf") hasDefault.add(edge.target);
|
|
4882
|
+
}
|
|
4883
|
+
for (const graph of graphs)
|
|
4884
|
+
for (const edge of graph.relationships) {
|
|
4885
|
+
if (edge.kind !== "defaultImplementationOf" || !byId.has(edge.source) || owner.has(edge.source))
|
|
4886
|
+
continue;
|
|
4887
|
+
const protocolId = requirementProtocol.get(edge.target);
|
|
4888
|
+
if (!protocolId) continue;
|
|
4889
|
+
owner.set(edge.source, protocolId);
|
|
4890
|
+
children.set(protocolId, [...children.get(protocolId) ?? [], ...all(edge.source)]);
|
|
4891
|
+
}
|
|
4892
|
+
const typeByPath = /* @__PURE__ */ new Map();
|
|
4893
|
+
for (const symbol of byId.values())
|
|
4894
|
+
if (TYPE_KINDS.has(symbol.kind.identifier))
|
|
4895
|
+
typeByPath.set(pathOf(symbol), symbol.identifier.precise);
|
|
4896
|
+
for (const symbol of byId.values()) {
|
|
4897
|
+
if (owner.has(symbol.identifier.precise) || symbol.pathComponents.length < 2) continue;
|
|
4898
|
+
if (TYPE_KINDS.has(symbol.kind.identifier)) continue;
|
|
4899
|
+
const parent = typeByPath.get(symbol.pathComponents.slice(0, -1).join("."));
|
|
4900
|
+
if (!parent) continue;
|
|
4901
|
+
owner.set(symbol.identifier.precise, parent);
|
|
4902
|
+
children.set(parent, [
|
|
4903
|
+
...children.get(parent) ?? [],
|
|
4904
|
+
...all(symbol.identifier.precise)
|
|
4905
|
+
]);
|
|
4906
|
+
}
|
|
4860
4907
|
const lines = [];
|
|
4861
4908
|
const owners = [];
|
|
4862
4909
|
const omit = options.omit ?? /* @__PURE__ */ new Map();
|
|
@@ -4881,7 +4928,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4881
4928
|
const seen = /* @__PURE__ */ new Set();
|
|
4882
4929
|
return (children.get(id) ?? []).filter((member) => {
|
|
4883
4930
|
if (unavailable(member)) return false;
|
|
4884
|
-
const key2 = `${member.kind.identifier}|${text(member)}`;
|
|
4931
|
+
const key2 = `${member.kind.identifier}|${requirement.has(member.identifier.precise) ? "req" : "ext"}|${text(member)}`;
|
|
4885
4932
|
if (seen.has(key2)) return false;
|
|
4886
4933
|
seen.add(key2);
|
|
4887
4934
|
return true;
|
|
@@ -4910,8 +4957,8 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4910
4957
|
const required = context.inClass && flags.has("required");
|
|
4911
4958
|
const final = context.inClass && flags.has("final") ? "final " : "";
|
|
4912
4959
|
const mutating = flags.has("mutating") ? "mutating " : flags.has("nonmutating") ? "nonmutating " : "";
|
|
4913
|
-
let core = `${
|
|
4914
|
-
const override = context.inClass && !options.plain?.has(path16) && (flags.has("override") || overrides.has(member.identifier.precise) || isObjC(member) && path16.endsWith(".init()")) ? "override " : "";
|
|
4960
|
+
let core = `${flags.has("convenience") ? "convenience " : ""}${modifiers[2]}`;
|
|
4961
|
+
const override = context.inClass && !options.plain?.has(path16) && (flags.has("override") || overrides.has(member.identifier.precise) || options.forcedOverride?.has(path16) || isObjC(member) && path16.endsWith(".init()")) ? "override " : "";
|
|
4915
4962
|
const head = `${indent}${attrs}${access(member, context.openOwner)} ${required ? "required " : ""}${final}${override}${mutating}`;
|
|
4916
4963
|
const measured = behavior.get(path16);
|
|
4917
4964
|
if (measured) used.add(path16);
|
|
@@ -4922,10 +4969,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4922
4969
|
case "swift.type.property":
|
|
4923
4970
|
case "swift.subscript":
|
|
4924
4971
|
case "swift.type.subscript": {
|
|
4925
|
-
const
|
|
4926
|
-
const decl =
|
|
4927
|
-
const effects =
|
|
4928
|
-
const settable =
|
|
4972
|
+
const parsed = splitAccessors(core);
|
|
4973
|
+
const decl = parsed.decl;
|
|
4974
|
+
const effects = parsed.effects;
|
|
4975
|
+
const settable = parsed.settable;
|
|
4929
4976
|
const computed = decl.replace(/^((?:static |class )*)let /, "$1var ");
|
|
4930
4977
|
if (measured?.stored !== void 0) {
|
|
4931
4978
|
const ownership = flags.has("weak") ? "weak " : flags.has("unowned") ? "unowned " : "";
|
|
@@ -4937,7 +4984,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4937
4984
|
return;
|
|
4938
4985
|
}
|
|
4939
4986
|
emit(
|
|
4940
|
-
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` set { ${measured?.set ?? trap(path16)} }` : ""} }`
|
|
4987
|
+
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` ${parsed.nonmutating ? "nonmutating " : ""}set { ${measured?.set ?? trap(path16)} }` : ""} }`
|
|
4941
4988
|
);
|
|
4942
4989
|
return;
|
|
4943
4990
|
}
|
|
@@ -5032,7 +5079,18 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5032
5079
|
);
|
|
5033
5080
|
const have = /* @__PURE__ */ new Set();
|
|
5034
5081
|
for (let at = id; at; at = superId.get(at))
|
|
5035
|
-
for (const member of children.get(at) ?? [])
|
|
5082
|
+
for (const member of children.get(at) ?? []) {
|
|
5083
|
+
have.add(witnessKey(member));
|
|
5084
|
+
have.add(sideLeaf(member));
|
|
5085
|
+
}
|
|
5086
|
+
const covered = /* @__PURE__ */ new Set();
|
|
5087
|
+
const cover = (protocolId) => {
|
|
5088
|
+
if (covered.has(protocolId)) return;
|
|
5089
|
+
covered.add(protocolId);
|
|
5090
|
+
for (const edge of protocolParents.get(protocolId) ?? []) cover(edge);
|
|
5091
|
+
};
|
|
5092
|
+
for (let at = superId.get(id); at; at = superId.get(at))
|
|
5093
|
+
for (const protocolId of conformIds.get(at) ?? []) cover(protocolId);
|
|
5036
5094
|
const protocols = [];
|
|
5037
5095
|
const visit = (protocolId) => {
|
|
5038
5096
|
if (protocols.includes(protocolId)) return;
|
|
@@ -5040,16 +5098,28 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5040
5098
|
for (const edge of protocolParents.get(protocolId) ?? []) visit(edge);
|
|
5041
5099
|
};
|
|
5042
5100
|
for (const protocolId of conformIds.get(id) ?? []) visit(protocolId);
|
|
5101
|
+
const overloaded = /* @__PURE__ */ new Set();
|
|
5102
|
+
const named = /* @__PURE__ */ new Set();
|
|
5043
5103
|
for (const protocolId of protocols)
|
|
5104
|
+
for (const member of children.get(protocolId) ?? []) {
|
|
5105
|
+
if (!requirement.has(member.identifier.precise)) continue;
|
|
5106
|
+
if (named.has(sideLeaf(member))) overloaded.add(sideLeaf(member));
|
|
5107
|
+
named.add(sideLeaf(member));
|
|
5108
|
+
}
|
|
5109
|
+
const met = (member) => have.has(witnessKey(member)) || !overloaded.has(sideLeaf(member)) && have.has(sideLeaf(member));
|
|
5110
|
+
for (const protocolId of protocols) {
|
|
5111
|
+
if (covered.has(protocolId)) continue;
|
|
5044
5112
|
for (const member of children.get(protocolId) ?? []) {
|
|
5045
5113
|
if (!requirement.has(member.identifier.precise) || optional.has(member.identifier.precise))
|
|
5046
5114
|
continue;
|
|
5115
|
+
if (hasDefault.has(member.identifier.precise)) continue;
|
|
5047
5116
|
if (isObjC(member) && / async\b/.test(text(member))) continue;
|
|
5048
|
-
if (
|
|
5049
|
-
continue;
|
|
5117
|
+
if (met(member) || member.kind.identifier === "swift.associatedtype") continue;
|
|
5050
5118
|
have.add(witnessKey(member));
|
|
5119
|
+
have.add(sideLeaf(member));
|
|
5051
5120
|
emitWitness(member, inner, path16);
|
|
5052
5121
|
}
|
|
5122
|
+
}
|
|
5053
5123
|
const coder = members.some((member) => leaf(member) === "init(coder:)");
|
|
5054
5124
|
if (designated && !coder && externalRoot(id) !== "NSObject" && externalRoot(id) !== null)
|
|
5055
5125
|
emit(
|
|
@@ -5162,7 +5232,8 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5162
5232
|
continue;
|
|
5163
5233
|
}
|
|
5164
5234
|
emitRequirement(member, inner);
|
|
5165
|
-
if (optional.has(member.identifier.precise)
|
|
5235
|
+
if (optional.has(member.identifier.precise) && !hasDefault.has(member.identifier.precise))
|
|
5236
|
+
defaults.push(member);
|
|
5166
5237
|
}
|
|
5167
5238
|
emit(`${indent}}`);
|
|
5168
5239
|
if (defaults.length > 0) {
|
|
@@ -5191,11 +5262,9 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5191
5262
|
const witness = `${owner2}.${leaf(member)}`;
|
|
5192
5263
|
const body = trap(witness);
|
|
5193
5264
|
if (member.kind.identifier === "swift.property" || member.kind.identifier === "swift.type.property") {
|
|
5194
|
-
const
|
|
5195
|
-
const
|
|
5196
|
-
emit(
|
|
5197
|
-
`${indent}public ${bare} { get { ${body} }${accessors?.[3] ? ` set { ${body} }` : ""} }`
|
|
5198
|
-
);
|
|
5265
|
+
const parsed = splitAccessors(decl);
|
|
5266
|
+
const setter = parsed.settable ? ` ${parsed.nonmutating ? "nonmutating " : ""}set { ${body} }` : "";
|
|
5267
|
+
emit(`${indent}public ${parsed.decl} { get${parsed.effects} { ${body} }${setter} }`);
|
|
5199
5268
|
} else
|
|
5200
5269
|
emit(
|
|
5201
5270
|
`${indent}public ${member.kind.identifier === "swift.init" ? "required " : ""}${stripDefaults(decl)} { ${body} }`
|
|
@@ -5216,15 +5285,23 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5216
5285
|
};
|
|
5217
5286
|
const emitGlobal = scoped((symbol) => {
|
|
5218
5287
|
const path16 = pathOf(symbol);
|
|
5219
|
-
|
|
5288
|
+
const kind = symbol.kind.identifier;
|
|
5289
|
+
if (kind === "swift.func" || kind === "swift.func.op" || kind === "swift.method" || kind === "swift.type.method") {
|
|
5220
5290
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5291
|
+
let spelled = rest;
|
|
5292
|
+
if (kind === "swift.func.op") {
|
|
5293
|
+
const token = /func\s+(\S+)/.exec(spelled)?.[1];
|
|
5294
|
+
const fix = token ? options.operators?.get(token) : void 0;
|
|
5295
|
+
if (fix && !/^(?:prefix|infix|postfix)\b/.test(spelled))
|
|
5296
|
+
spelled = `${fix} ${spelled}`;
|
|
5297
|
+
}
|
|
5298
|
+
emit(`${attrs}public ${spelled} { ${trap(path16)} }`);
|
|
5299
|
+
} else if (kind === "swift.var") {
|
|
5300
|
+
const parsed = splitAccessors(text(symbol).replace(/^let /, "var "));
|
|
5224
5301
|
const measured = behavior.get(path16);
|
|
5225
5302
|
if (measured) used.add(path16);
|
|
5226
|
-
emit(`public ${decl} { ${measured?.body ?? trap(path16)} }`);
|
|
5227
|
-
} else skipped.push({ path: path16, reason: `unhandled top-level ${
|
|
5303
|
+
emit(`public ${parsed.decl} { ${measured?.body ?? trap(path16)} }`);
|
|
5304
|
+
} else skipped.push({ path: path16, reason: `unhandled top-level ${kind}` });
|
|
5228
5305
|
});
|
|
5229
5306
|
const roots = [...byId.values()].filter((symbol) => !owner.has(symbol.identifier.precise) && !unavailable(symbol)).sort((a, b) => pathOf(a).localeCompare(pathOf(b)));
|
|
5230
5307
|
for (const symbol of roots) {
|
package/dist-lib/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.783 | (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;
|
package/package.json
CHANGED
|
@@ -55,6 +55,10 @@ export type StandinOptions = {
|
|
|
55
55
|
omit?: ReadonlyMap<string, string>
|
|
56
56
|
/** paths the graph says override but the compiler finds nothing to override */
|
|
57
57
|
plain?: ReadonlySet<string>
|
|
58
|
+
/** paths the compiler says must be marked override */
|
|
59
|
+
forcedOverride?: ReadonlySet<string>
|
|
60
|
+
/** operator token → prefix, infix, or postfix, from the swiftinterface */
|
|
61
|
+
operators?: ReadonlyMap<string, string>
|
|
58
62
|
/** class path → its generic superclass with arguments, from the swiftinterface */
|
|
59
63
|
superclasses?: ReadonlyMap<string, string>
|
|
60
64
|
}
|
|
@@ -79,7 +83,7 @@ export type StandinResult = {
|
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
/** bump when emitted source changes: the stand-in cache keys on it. */
|
|
82
|
-
export const STANDIN_EMIT_VERSION = '
|
|
86
|
+
export const STANDIN_EMIT_VERSION = '2'
|
|
83
87
|
|
|
84
88
|
const TYPE_KINDS = new Set([
|
|
85
89
|
'swift.class',
|
|
@@ -98,7 +102,20 @@ const MEMBER_KINDS = new Set([
|
|
|
98
102
|
'swift.subscript',
|
|
99
103
|
'swift.type.subscript',
|
|
100
104
|
])
|
|
101
|
-
const
|
|
105
|
+
const ACCESSOR_WORD =
|
|
106
|
+
/^(?:get|set|nonmutating|mutating|async|throws|rethrows|_read|_modify)$/
|
|
107
|
+
// `{ get }`, `{ get set }`, `{ get nonmutating set }`, `{ get async throws }`
|
|
108
|
+
function splitAccessors(core: string) {
|
|
109
|
+
const match = /\{\s*([^}]*)\}\s*$/.exec(core)
|
|
110
|
+
const words = match ? match[1]!.trim().split(/\s+/).filter(Boolean) : []
|
|
111
|
+
const accessors = words.length > 0 && words.every((word) => ACCESSOR_WORD.test(word))
|
|
112
|
+
return {
|
|
113
|
+
decl: accessors ? core.slice(0, match!.index).trimEnd() : core,
|
|
114
|
+
effects: `${words.includes('async') ? ' async' : ''}${words.includes('throws') ? ' throws' : words.includes('rethrows') ? ' rethrows' : ''}`,
|
|
115
|
+
settable: accessors ? words.includes('set') : /^(?:static |class )?var /.test(core),
|
|
116
|
+
nonmutating: words.includes('nonmutating'),
|
|
117
|
+
}
|
|
118
|
+
}
|
|
102
119
|
// standard protocols a declaration keeps when the graph names them directly;
|
|
103
120
|
// anything else from outside the family drops with a reason (a missing
|
|
104
121
|
// capability, never a trap).
|
|
@@ -136,9 +153,15 @@ const unavailable = (symbol: GraphSymbol) =>
|
|
|
136
153
|
(symbol.availability ?? []).some(
|
|
137
154
|
(entry) => entry.isUnconditionallyUnavailable || entry.obsoleted !== undefined,
|
|
138
155
|
)
|
|
139
|
-
// a witness matches by
|
|
156
|
+
// a witness matches by side and signature. overloads share a leaf (`pow(_:)`).
|
|
140
157
|
const witnessKey = (symbol: GraphSymbol) =>
|
|
141
|
-
`${symbol.kind.identifier.startsWith('swift.type.') ? 'type' : 'instance'}|${
|
|
158
|
+
`${symbol.kind.identifier.startsWith('swift.type.') ? 'type' : 'instance'}|${stripDefaults(
|
|
159
|
+
splitAccessors(text(symbol)).decl,
|
|
160
|
+
)
|
|
161
|
+
.replace(/\s+/g, ' ')
|
|
162
|
+
.trim()}`
|
|
163
|
+
const sideLeaf = (symbol: GraphSymbol) =>
|
|
164
|
+
`${symbol.kind.identifier.startsWith('swift.type.') ? 'type' : 'instance'}|leaf|${leaf(symbol)}`
|
|
142
165
|
const isObjC = (symbol: GraphSymbol) => symbol.identifier.precise.startsWith('c:')
|
|
143
166
|
const trap = (path: string) =>
|
|
144
167
|
`fatalError("${path} is a binary framework peach cannot run")`
|
|
@@ -181,13 +204,12 @@ export function emitSwiftStandin(
|
|
|
181
204
|
if (local) return { name: pathOf(local), local: true }
|
|
182
205
|
if (!fallback) return null
|
|
183
206
|
const parts = fallback.split('.')
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
207
|
+
// swiftinterfaces spell SwiftUI types as SwiftUICore; the import is SwiftUI
|
|
208
|
+
const module = parts[0] === 'SwiftUICore' ? 'SwiftUI' : parts[0]!
|
|
209
|
+
const unqualified = parts.slice(1).join('.') || parts[0]!
|
|
210
|
+
const name =
|
|
211
|
+
family.has(parts[0]!) && parts[0] !== 'SwiftUICore' ? parts.join('.') : unqualified
|
|
212
|
+
return { name, module, local: false }
|
|
191
213
|
}
|
|
192
214
|
for (const graph of graphs)
|
|
193
215
|
for (const edge of graph.relationships) {
|
|
@@ -247,8 +269,52 @@ export function emitSwiftStandin(
|
|
|
247
269
|
case 'overrides':
|
|
248
270
|
overrides.add(edge.source)
|
|
249
271
|
break
|
|
272
|
+
case 'defaultImplementationOf':
|
|
273
|
+
// recorded below, once requirementOf has named each protocol
|
|
274
|
+
break
|
|
250
275
|
}
|
|
251
276
|
}
|
|
277
|
+
// a protocol extension method's edge points at the requirement, not the protocol
|
|
278
|
+
const requirementProtocol = new Map<string, string>()
|
|
279
|
+
const hasDefault = new Set<string>()
|
|
280
|
+
for (const graph of graphs)
|
|
281
|
+
for (const edge of graph.relationships) {
|
|
282
|
+
if (
|
|
283
|
+
(edge.kind === 'requirementOf' || edge.kind === 'optionalRequirementOf') &&
|
|
284
|
+
byId.has(edge.target)
|
|
285
|
+
)
|
|
286
|
+
requirementProtocol.set(edge.source, edge.target)
|
|
287
|
+
if (edge.kind === 'defaultImplementationOf') hasDefault.add(edge.target)
|
|
288
|
+
}
|
|
289
|
+
for (const graph of graphs)
|
|
290
|
+
for (const edge of graph.relationships) {
|
|
291
|
+
if (
|
|
292
|
+
edge.kind !== 'defaultImplementationOf' ||
|
|
293
|
+
!byId.has(edge.source) ||
|
|
294
|
+
owner.has(edge.source)
|
|
295
|
+
)
|
|
296
|
+
continue
|
|
297
|
+
const protocolId = requirementProtocol.get(edge.target)
|
|
298
|
+
if (!protocolId) continue
|
|
299
|
+
owner.set(edge.source, protocolId)
|
|
300
|
+
children.set(protocolId, [...(children.get(protocolId) ?? []), ...all(edge.source)])
|
|
301
|
+
}
|
|
302
|
+
// a member whose extension block the extractor omitted still names its type
|
|
303
|
+
const typeByPath = new Map<string, string>()
|
|
304
|
+
for (const symbol of byId.values())
|
|
305
|
+
if (TYPE_KINDS.has(symbol.kind.identifier))
|
|
306
|
+
typeByPath.set(pathOf(symbol), symbol.identifier.precise)
|
|
307
|
+
for (const symbol of byId.values()) {
|
|
308
|
+
if (owner.has(symbol.identifier.precise) || symbol.pathComponents.length < 2) continue
|
|
309
|
+
if (TYPE_KINDS.has(symbol.kind.identifier)) continue
|
|
310
|
+
const parent = typeByPath.get(symbol.pathComponents.slice(0, -1).join('.'))
|
|
311
|
+
if (!parent) continue
|
|
312
|
+
owner.set(symbol.identifier.precise, parent)
|
|
313
|
+
children.set(parent, [
|
|
314
|
+
...(children.get(parent) ?? []),
|
|
315
|
+
...all(symbol.identifier.precise),
|
|
316
|
+
])
|
|
317
|
+
}
|
|
252
318
|
|
|
253
319
|
const lines: string[] = []
|
|
254
320
|
const owners: string[] = []
|
|
@@ -279,7 +345,8 @@ export function emitSwiftStandin(
|
|
|
279
345
|
const seen = new Set<string>()
|
|
280
346
|
return (children.get(id) ?? []).filter((member) => {
|
|
281
347
|
if (unavailable(member)) return false
|
|
282
|
-
|
|
348
|
+
// a requirement and its protocol-extension default share a spelling and both stay
|
|
349
|
+
const key = `${member.kind.identifier}|${requirement.has(member.identifier.precise) ? 'req' : 'ext'}|${text(member)}`
|
|
283
350
|
if (seen.has(key)) return false
|
|
284
351
|
seen.add(key)
|
|
285
352
|
return true
|
|
@@ -324,13 +391,15 @@ export function emitSwiftStandin(
|
|
|
324
391
|
: flags.has('nonmutating')
|
|
325
392
|
? 'nonmutating '
|
|
326
393
|
: ''
|
|
327
|
-
|
|
394
|
+
// the graph already spelled convenience; an external class extension is not inClass
|
|
395
|
+
let core = `${flags.has('convenience') ? 'convenience ' : ''}${modifiers[2]!}`
|
|
328
396
|
// a class's init() always overrides NSObject's in an objective-c class
|
|
329
397
|
const override =
|
|
330
398
|
context.inClass &&
|
|
331
399
|
!options.plain?.has(path) &&
|
|
332
400
|
(flags.has('override') ||
|
|
333
401
|
overrides.has(member.identifier.precise) ||
|
|
402
|
+
options.forcedOverride?.has(path) ||
|
|
334
403
|
(isObjC(member) && path.endsWith('.init()')))
|
|
335
404
|
? 'override '
|
|
336
405
|
: ''
|
|
@@ -348,12 +417,10 @@ export function emitSwiftStandin(
|
|
|
348
417
|
case 'swift.type.property':
|
|
349
418
|
case 'swift.subscript':
|
|
350
419
|
case 'swift.type.subscript': {
|
|
351
|
-
const
|
|
352
|
-
const decl =
|
|
353
|
-
const effects =
|
|
354
|
-
const settable =
|
|
355
|
-
? Boolean(accessors[3])
|
|
356
|
-
: /^(?:static |class )?var /.test(core)
|
|
420
|
+
const parsed = splitAccessors(core)
|
|
421
|
+
const decl = parsed.decl
|
|
422
|
+
const effects = parsed.effects
|
|
423
|
+
const settable = parsed.settable
|
|
357
424
|
const computed = decl.replace(/^((?:static |class )*)let /, '$1var ')
|
|
358
425
|
if (measured?.stored !== undefined) {
|
|
359
426
|
// a read-only sdk property stays read-only outside the module
|
|
@@ -370,7 +437,7 @@ export function emitSwiftStandin(
|
|
|
370
437
|
return
|
|
371
438
|
}
|
|
372
439
|
emit(
|
|
373
|
-
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` set { ${measured?.set ?? trap(path)} }` : ''} }`,
|
|
440
|
+
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` ${parsed.nonmutating ? 'nonmutating ' : ''}set { ${measured?.set ?? trap(path)} }` : ''} }`,
|
|
374
441
|
)
|
|
375
442
|
return
|
|
376
443
|
}
|
|
@@ -498,9 +565,25 @@ export function emitSwiftStandin(
|
|
|
498
565
|
// an objective-c class implements its protocols' requirements in the
|
|
499
566
|
// binary without restating them in its header; swift needs a
|
|
500
567
|
// witness, which traps like every other member.
|
|
568
|
+
// a class restates a requirement with its own modifiers, parameter
|
|
569
|
+
// names and Self, so a name on the same side meets it; only overloads
|
|
570
|
+
// sharing that name (`pow(_:)`) need the whole signature to match.
|
|
501
571
|
const have = new Set<string>()
|
|
502
572
|
for (let at: string | undefined = id; at; at = superId.get(at))
|
|
503
|
-
for (const member of children.get(at) ?? [])
|
|
573
|
+
for (const member of children.get(at) ?? []) {
|
|
574
|
+
have.add(witnessKey(member))
|
|
575
|
+
have.add(sideLeaf(member))
|
|
576
|
+
}
|
|
577
|
+
// a superclass that already conforms supplies the requirements, including
|
|
578
|
+
// ones a protocol extension implements, so a subclass does not restate them
|
|
579
|
+
const covered = new Set<string>()
|
|
580
|
+
const cover = (protocolId: string) => {
|
|
581
|
+
if (covered.has(protocolId)) return
|
|
582
|
+
covered.add(protocolId)
|
|
583
|
+
for (const edge of protocolParents.get(protocolId) ?? []) cover(edge)
|
|
584
|
+
}
|
|
585
|
+
for (let at = superId.get(id); at; at = superId.get(at))
|
|
586
|
+
for (const protocolId of conformIds.get(at) ?? []) cover(protocolId)
|
|
504
587
|
const protocols: string[] = []
|
|
505
588
|
const visit = (protocolId: string) => {
|
|
506
589
|
if (protocols.includes(protocolId)) return
|
|
@@ -508,22 +591,33 @@ export function emitSwiftStandin(
|
|
|
508
591
|
for (const edge of protocolParents.get(protocolId) ?? []) visit(edge)
|
|
509
592
|
}
|
|
510
593
|
for (const protocolId of conformIds.get(id) ?? []) visit(protocolId)
|
|
594
|
+
const overloaded = new Set<string>()
|
|
595
|
+
const named = new Set<string>()
|
|
511
596
|
for (const protocolId of protocols)
|
|
597
|
+
for (const member of children.get(protocolId) ?? []) {
|
|
598
|
+
if (!requirement.has(member.identifier.precise)) continue
|
|
599
|
+
if (named.has(sideLeaf(member))) overloaded.add(sideLeaf(member))
|
|
600
|
+
named.add(sideLeaf(member))
|
|
601
|
+
}
|
|
602
|
+
const met = (member: GraphSymbol) =>
|
|
603
|
+
have.has(witnessKey(member)) ||
|
|
604
|
+
(!overloaded.has(sideLeaf(member)) && have.has(sideLeaf(member)))
|
|
605
|
+
for (const protocolId of protocols) {
|
|
606
|
+
if (covered.has(protocolId)) continue
|
|
512
607
|
for (const member of children.get(protocolId) ?? []) {
|
|
513
608
|
if (
|
|
514
609
|
!requirement.has(member.identifier.precise) ||
|
|
515
610
|
optional.has(member.identifier.precise)
|
|
516
611
|
)
|
|
517
612
|
continue
|
|
613
|
+
if (hasDefault.has(member.identifier.precise)) continue
|
|
518
614
|
if (isObjC(member) && / async\b/.test(text(member))) continue
|
|
519
|
-
if (
|
|
520
|
-
have.has(witnessKey(member)) ||
|
|
521
|
-
member.kind.identifier === 'swift.associatedtype'
|
|
522
|
-
)
|
|
523
|
-
continue
|
|
615
|
+
if (met(member) || member.kind.identifier === 'swift.associatedtype') continue
|
|
524
616
|
have.add(witnessKey(member))
|
|
617
|
+
have.add(sideLeaf(member))
|
|
525
618
|
emitWitness(member, inner, path)
|
|
526
619
|
}
|
|
620
|
+
}
|
|
527
621
|
const coder = members.some((member) => leaf(member) === 'init(coder:)')
|
|
528
622
|
if (
|
|
529
623
|
designated &&
|
|
@@ -659,7 +753,11 @@ export function emitSwiftStandin(
|
|
|
659
753
|
continue
|
|
660
754
|
}
|
|
661
755
|
emitRequirement(member, inner)
|
|
662
|
-
if (
|
|
756
|
+
if (
|
|
757
|
+
optional.has(member.identifier.precise) &&
|
|
758
|
+
!hasDefault.has(member.identifier.precise)
|
|
759
|
+
)
|
|
760
|
+
defaults.push(member)
|
|
663
761
|
}
|
|
664
762
|
emit(`${indent}}`)
|
|
665
763
|
if (defaults.length > 0) {
|
|
@@ -701,11 +799,11 @@ export function emitSwiftStandin(
|
|
|
701
799
|
member.kind.identifier === 'swift.property' ||
|
|
702
800
|
member.kind.identifier === 'swift.type.property'
|
|
703
801
|
) {
|
|
704
|
-
const
|
|
705
|
-
const
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
)
|
|
802
|
+
const parsed = splitAccessors(decl)
|
|
803
|
+
const setter = parsed.settable
|
|
804
|
+
? ` ${parsed.nonmutating ? 'nonmutating ' : ''}set { ${body} }`
|
|
805
|
+
: ''
|
|
806
|
+
emit(`${indent}public ${parsed.decl} { get${parsed.effects} { ${body} }${setter} }`)
|
|
709
807
|
} else
|
|
710
808
|
emit(
|
|
711
809
|
`${indent}public ${member.kind.identifier === 'swift.init' ? 'required ' : ''}${stripDefaults(decl)} { ${body} }`,
|
|
@@ -731,20 +829,32 @@ export function emitSwiftStandin(
|
|
|
731
829
|
|
|
732
830
|
const emitGlobal = scoped((symbol: GraphSymbol) => {
|
|
733
831
|
const path = pathOf(symbol)
|
|
832
|
+
const kind = symbol.kind.identifier
|
|
734
833
|
if (
|
|
735
|
-
|
|
736
|
-
|
|
834
|
+
kind === 'swift.func' ||
|
|
835
|
+
kind === 'swift.func.op' ||
|
|
836
|
+
kind === 'swift.method' ||
|
|
837
|
+
kind === 'swift.type.method'
|
|
737
838
|
) {
|
|
738
839
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol))!
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
840
|
+
let spelled = rest!
|
|
841
|
+
if (kind === 'swift.func.op') {
|
|
842
|
+
const token = /func\s+(\S+)/.exec(spelled)?.[1]
|
|
843
|
+
const fix = token ? options.operators?.get(token) : undefined
|
|
844
|
+
if (fix && !/^(?:prefix|infix|postfix)\b/.test(spelled))
|
|
845
|
+
spelled = `${fix} ${spelled}`
|
|
846
|
+
}
|
|
847
|
+
emit(`${attrs}public ${spelled} { ${trap(path)} }`)
|
|
848
|
+
} else if (kind === 'swift.var') {
|
|
849
|
+
const parsed = splitAccessors(text(symbol).replace(/^let /, 'var '))
|
|
742
850
|
// a measured global keeps the sdk's declaration with a working getter,
|
|
743
851
|
// the same way a member keeps its declaration with a working body.
|
|
852
|
+
// a top-level var stays get-only: the graph often spells a constant
|
|
853
|
+
// as `var` with no setter.
|
|
744
854
|
const measured = behavior.get(path)
|
|
745
855
|
if (measured) used.add(path)
|
|
746
|
-
emit(`public ${decl} { ${measured?.body ?? trap(path)} }`)
|
|
747
|
-
} else skipped.push({ path, reason: `unhandled top-level ${
|
|
856
|
+
emit(`public ${parsed.decl} { ${measured?.body ?? trap(path)} }`)
|
|
857
|
+
} else skipped.push({ path, reason: `unhandled top-level ${kind}` })
|
|
748
858
|
})
|
|
749
859
|
|
|
750
860
|
const roots = [...byId.values()]
|