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
package/dist-lib/skills.cjs
CHANGED
|
@@ -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;
|
|
@@ -25221,7 +25221,11 @@ function emitSwiftStandin(graphs, options) {
|
|
|
25221
25221
|
if (local) return { name: pathOf(local), local: true };
|
|
25222
25222
|
if (!fallback) return null;
|
|
25223
25223
|
const parts = fallback.split(".");
|
|
25224
|
-
return {
|
|
25224
|
+
return {
|
|
25225
|
+
name: family.has(parts[0]) ? parts.join(".") : parts.slice(1).join(".") || parts[0],
|
|
25226
|
+
module: parts[0],
|
|
25227
|
+
local: false
|
|
25228
|
+
};
|
|
25225
25229
|
};
|
|
25226
25230
|
for (const graph of graphs)
|
|
25227
25231
|
for (const edge of graph.relationships) {
|
|
@@ -25232,7 +25236,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
25232
25236
|
const parent = byId.get(edge.target);
|
|
25233
25237
|
if (parent) {
|
|
25234
25238
|
owner.set(edge.source, edge.target);
|
|
25235
|
-
children.set(edge.target, [
|
|
25239
|
+
children.set(edge.target, [
|
|
25240
|
+
...children.get(edge.target) ?? [],
|
|
25241
|
+
...all(edge.source)
|
|
25242
|
+
]);
|
|
25236
25243
|
} else if (edge.targetFallback) {
|
|
25237
25244
|
const name2 = nameOf(edge.target, edge.targetFallback).name;
|
|
25238
25245
|
external.set(name2, [...external.get(name2) ?? [], ...all(edge.source)]);
|
|
@@ -25250,7 +25257,8 @@ function emitSwiftStandin(graphs, options) {
|
|
|
25250
25257
|
const target = nameOf(edge.target, edge.targetFallback);
|
|
25251
25258
|
const kept = KEEP_EXTERNAL.get(edge.target);
|
|
25252
25259
|
const name2 = kept ?? (target && (target.local || family.has(target.module ?? "")) ? target.name : null);
|
|
25253
|
-
if (name2)
|
|
25260
|
+
if (name2)
|
|
25261
|
+
conforms.set(edge.source, [...conforms.get(edge.source) ?? [], name2]);
|
|
25254
25262
|
if (byId.has(edge.target)) {
|
|
25255
25263
|
const map = source.kind.identifier === "swift.protocol" ? protocolParents : conformIds;
|
|
25256
25264
|
map.set(edge.source, [...map.get(edge.source) ?? [], edge.target]);
|
|
@@ -25263,7 +25271,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
25263
25271
|
if (edge.kind === "optionalRequirementOf") optional.add(edge.source);
|
|
25264
25272
|
if (byId.has(edge.target) && !owner.has(edge.source)) {
|
|
25265
25273
|
owner.set(edge.source, edge.target);
|
|
25266
|
-
children.set(edge.target, [
|
|
25274
|
+
children.set(edge.target, [
|
|
25275
|
+
...children.get(edge.target) ?? [],
|
|
25276
|
+
...all(edge.source)
|
|
25277
|
+
]);
|
|
25267
25278
|
}
|
|
25268
25279
|
break;
|
|
25269
25280
|
case "overrides":
|
|
@@ -25302,59 +25313,77 @@ function emitSwiftStandin(graphs, options) {
|
|
|
25302
25313
|
});
|
|
25303
25314
|
};
|
|
25304
25315
|
const access = (symbol, openOwner) => symbol.accessLevel === "open" && openOwner ? "open" : "public";
|
|
25305
|
-
const emitMember = scoped(
|
|
25306
|
-
|
|
25307
|
-
|
|
25308
|
-
|
|
25309
|
-
|
|
25310
|
-
|
|
25311
|
-
|
|
25312
|
-
|
|
25313
|
-
|
|
25314
|
-
|
|
25315
|
-
|
|
25316
|
-
|
|
25317
|
-
|
|
25318
|
-
|
|
25319
|
-
|
|
25320
|
-
|
|
25321
|
-
|
|
25322
|
-
|
|
25323
|
-
|
|
25324
|
-
|
|
25325
|
-
|
|
25326
|
-
|
|
25327
|
-
|
|
25328
|
-
|
|
25329
|
-
|
|
25330
|
-
|
|
25331
|
-
|
|
25332
|
-
|
|
25333
|
-
|
|
25334
|
-
|
|
25335
|
-
|
|
25336
|
-
|
|
25337
|
-
|
|
25338
|
-
|
|
25339
|
-
|
|
25340
|
-
const
|
|
25341
|
-
const
|
|
25342
|
-
const
|
|
25343
|
-
|
|
25316
|
+
const emitMember = scoped(
|
|
25317
|
+
(member, indent, context) => {
|
|
25318
|
+
const path37 = pathOf(member);
|
|
25319
|
+
if (TYPE_KINDS.has(member.kind.identifier)) {
|
|
25320
|
+
emitType(member, indent);
|
|
25321
|
+
return;
|
|
25322
|
+
}
|
|
25323
|
+
if (member.kind.identifier === "swift.enum.case") return;
|
|
25324
|
+
if (!MEMBER_KINDS.has(member.kind.identifier)) {
|
|
25325
|
+
skipped.push({ path: path37, reason: `unhandled ${member.kind.identifier}` });
|
|
25326
|
+
return;
|
|
25327
|
+
}
|
|
25328
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
25329
|
+
const modifiers = /^((?:(?:required|final|override|convenience|unowned(?:\(\w+\))?|weak|lazy|nonisolated|mutating|nonmutating) )*)(.*)$/s.exec(
|
|
25330
|
+
rest
|
|
25331
|
+
);
|
|
25332
|
+
const flags = new Set(
|
|
25333
|
+
modifiers[1].trim().split(/\s+/).filter(Boolean).map((flag) => flag.replace(/\(.*/, ""))
|
|
25334
|
+
);
|
|
25335
|
+
const required = context.inClass && flags.has("required");
|
|
25336
|
+
const final = context.inClass && flags.has("final") ? "final " : "";
|
|
25337
|
+
const mutating = flags.has("mutating") ? "mutating " : flags.has("nonmutating") ? "nonmutating " : "";
|
|
25338
|
+
let core = `${context.inClass && flags.has("convenience") ? "convenience " : ""}${modifiers[2]}`;
|
|
25339
|
+
const override = context.inClass && !options.plain?.has(path37) && (flags.has("override") || overrides.has(member.identifier.precise) || isObjC(member) && path37.endsWith(".init()")) ? "override " : "";
|
|
25340
|
+
const head = `${indent}${attrs}${access(member, context.openOwner)} ${required ? "required " : ""}${final}${override}${mutating}`;
|
|
25341
|
+
const measured = behavior.get(path37);
|
|
25342
|
+
if (measured) used.add(path37);
|
|
25343
|
+
const overloadBody = /\basync\b/.test(core) ? measured?.asyncBody : /\bResult</.test(core) ? measured?.resultBody : void 0;
|
|
25344
|
+
const body = overloadBody ?? measured?.body ?? trap(path37);
|
|
25345
|
+
switch (member.kind.identifier) {
|
|
25346
|
+
case "swift.property":
|
|
25347
|
+
case "swift.type.property":
|
|
25348
|
+
case "swift.subscript":
|
|
25349
|
+
case "swift.type.subscript": {
|
|
25350
|
+
const accessors = ACCESSORS.exec(core);
|
|
25351
|
+
const decl = core.replace(ACCESSORS, "").trimEnd();
|
|
25352
|
+
const effects = `${accessors?.[1] ?? ""}${accessors?.[2] ?? ""}`;
|
|
25353
|
+
const settable = accessors ? Boolean(accessors[3]) : /^(?:static |class )?var /.test(core);
|
|
25354
|
+
const computed = decl.replace(/^((?:static |class )*)let /, "$1var ");
|
|
25355
|
+
if (measured?.stored !== void 0) {
|
|
25356
|
+
const ownership = flags.has("weak") ? "weak " : flags.has("unowned") ? "unowned " : "";
|
|
25357
|
+
const setter = settable ? "" : "internal(set) ";
|
|
25358
|
+
const value = measured.stored ? ` = ${measured.stored}` : "";
|
|
25359
|
+
emit(
|
|
25360
|
+
`${indent}${attrs}${access(member, context.openOwner)} ${setter}${final}${override}${ownership}${computed}${value}`
|
|
25361
|
+
);
|
|
25362
|
+
return;
|
|
25363
|
+
}
|
|
25364
|
+
emit(
|
|
25365
|
+
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` set { ${measured?.set ?? trap(path37)} }` : ""} }`
|
|
25366
|
+
);
|
|
25344
25367
|
return;
|
|
25345
25368
|
}
|
|
25346
|
-
|
|
25347
|
-
|
|
25369
|
+
default:
|
|
25370
|
+
emit(`${head}${core} { ${body} }`);
|
|
25348
25371
|
}
|
|
25349
|
-
default:
|
|
25350
|
-
emit(`${head}${core} { ${body} }`);
|
|
25351
25372
|
}
|
|
25352
|
-
|
|
25373
|
+
);
|
|
25353
25374
|
const header = (symbol, keyword, indent) => {
|
|
25354
25375
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
25355
|
-
const shape = new RegExp(
|
|
25376
|
+
const shape = new RegExp(
|
|
25377
|
+
`^(?:final )?${keyword}\\s+\`?(\\w+)\`?(<[^>]*>)?\\s*(?::\\s*([^{]*?))?(\\s+where\\s+.*)?$`
|
|
25378
|
+
).exec(rest);
|
|
25356
25379
|
if (!shape) return null;
|
|
25357
|
-
return {
|
|
25380
|
+
return {
|
|
25381
|
+
attrs,
|
|
25382
|
+
name: shape[1],
|
|
25383
|
+
generics: shape[2] ?? "",
|
|
25384
|
+
where: shape[4] ?? "",
|
|
25385
|
+
indent
|
|
25386
|
+
};
|
|
25358
25387
|
};
|
|
25359
25388
|
const externalRoot = (id) => {
|
|
25360
25389
|
for (let at = id; at; at = superId.get(at)) {
|
|
@@ -25369,7 +25398,8 @@ function emitSwiftStandin(graphs, options) {
|
|
|
25369
25398
|
if (!parentSymbol) return null;
|
|
25370
25399
|
if (/^(?:final )?class\s+\w+</.test(LEADING_ATTRS.exec(text(parentSymbol))[2]) && !options.superclasses?.has(pathOf(byId.get(id))))
|
|
25371
25400
|
return `superclass ${pathOf(parentSymbol)} is generic and the graph omits its arguments`;
|
|
25372
|
-
if (unavailable(parentSymbol))
|
|
25401
|
+
if (unavailable(parentSymbol))
|
|
25402
|
+
return `superclass ${pathOf(parentSymbol)} is unavailable`;
|
|
25373
25403
|
return classBlocked(parent) && `superclass ${pathOf(parentSymbol)} is left out`;
|
|
25374
25404
|
};
|
|
25375
25405
|
const objcProtocols = new Set(
|
|
@@ -25383,153 +25413,203 @@ function emitSwiftStandin(graphs, options) {
|
|
|
25383
25413
|
const list2 = [...first ? [first] : [], ...conforms.get(id) ?? []];
|
|
25384
25414
|
return [...new Set(list2)];
|
|
25385
25415
|
};
|
|
25386
|
-
const emitType = scoped(
|
|
25387
|
-
|
|
25388
|
-
|
|
25389
|
-
|
|
25390
|
-
|
|
25391
|
-
|
|
25392
|
-
|
|
25393
|
-
|
|
25394
|
-
|
|
25395
|
-
|
|
25396
|
-
case "swift.class": {
|
|
25397
|
-
const shape = header(symbol, "class", indent);
|
|
25398
|
-
if (!shape) return void skipped.push({ path: path37, reason: `unparsed class ${text(symbol)}` });
|
|
25399
|
-
const parent = options.superclasses?.get(path37) ?? superclass.get(id);
|
|
25400
|
-
const blocked = classBlocked(id);
|
|
25401
|
-
if (blocked) return void skipped.push({ path: path37, reason: blocked });
|
|
25402
|
-
const ancestors = /* @__PURE__ */ new Set();
|
|
25403
|
-
for (let at = superId.get(id); at; at = superId.get(at))
|
|
25404
|
-
for (const name2 of conforms.get(at) ?? []) ancestors.add(name2);
|
|
25405
|
-
const list2 = [
|
|
25406
|
-
...parent ? [parent] : [],
|
|
25407
|
-
...(conforms.get(id) ?? []).filter(
|
|
25408
|
-
(name2) => !ancestors.has(name2) && !(parent && [...KEEP_EXTERNAL.values()].includes(name2))
|
|
25409
|
-
)
|
|
25410
|
-
].filter((name2, at, all2) => all2.indexOf(name2) === at);
|
|
25411
|
-
const parentSymbol = superId.has(id) ? byId.get(superId.get(id)) : void 0;
|
|
25412
|
-
const open = symbol.accessLevel === "open" && (!parentSymbol || parentSymbol.accessLevel === "open");
|
|
25413
|
-
emit(`${indent}${shape.attrs}${open ? "open" : "public"} class ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${selfConforming(shape.where)} {`);
|
|
25414
|
-
const members = membersOf(id);
|
|
25415
|
-
for (const member of members)
|
|
25416
|
-
emitMember(member, inner, { openOwner: open, inClass: true, ownerName: shape.name });
|
|
25417
|
-
const designated = members.some(
|
|
25418
|
-
(member) => member.kind.identifier === "swift.init" && !text(member).startsWith("convenience")
|
|
25419
|
-
);
|
|
25420
|
-
const have = /* @__PURE__ */ new Set();
|
|
25421
|
-
for (let at = id; at; at = superId.get(at))
|
|
25422
|
-
for (const member of children.get(at) ?? []) have.add(witnessKey(member));
|
|
25423
|
-
const protocols = [];
|
|
25424
|
-
const visit = (protocolId) => {
|
|
25425
|
-
if (protocols.includes(protocolId)) return;
|
|
25426
|
-
protocols.push(protocolId);
|
|
25427
|
-
for (const edge of protocolParents.get(protocolId) ?? []) visit(edge);
|
|
25428
|
-
};
|
|
25429
|
-
for (const protocolId of conformIds.get(id) ?? []) visit(protocolId);
|
|
25430
|
-
for (const protocolId of protocols)
|
|
25431
|
-
for (const member of children.get(protocolId) ?? []) {
|
|
25432
|
-
if (!requirement.has(member.identifier.precise) || optional.has(member.identifier.precise)) continue;
|
|
25433
|
-
if (isObjC(member) && / async\b/.test(text(member))) continue;
|
|
25434
|
-
if (have.has(witnessKey(member)) || member.kind.identifier === "swift.associatedtype") continue;
|
|
25435
|
-
have.add(witnessKey(member));
|
|
25436
|
-
emitWitness(member, inner, path37);
|
|
25437
|
-
}
|
|
25438
|
-
const coder = members.some((member) => leaf(member) === "init(coder:)");
|
|
25439
|
-
if (designated && !coder && externalRoot(id) !== "NSObject" && externalRoot(id) !== null)
|
|
25440
|
-
emit(`${inner}public required init?(coder: NSCoder) { ${trap(`${path37}.init(coder:)`)} }`);
|
|
25441
|
-
emit(`${indent}}`);
|
|
25442
|
-
return;
|
|
25443
|
-
}
|
|
25444
|
-
case "swift.struct": {
|
|
25445
|
-
const shape = header(symbol, "struct", indent);
|
|
25446
|
-
if (!shape) return void skipped.push({ path: path37, reason: `unparsed struct ${text(symbol)}` });
|
|
25447
|
-
const members = membersOf(id);
|
|
25448
|
-
const raw2 = rawType(members);
|
|
25449
|
-
const list2 = inheritance(id);
|
|
25450
|
-
emit(`${indent}${shape.attrs}public struct ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`);
|
|
25451
|
-
if (raw2) {
|
|
25452
|
-
emit(`${inner}public let rawValue: ${raw2}`);
|
|
25453
|
-
emit(`${inner}public init(rawValue: ${raw2}) { self.rawValue = rawValue }`);
|
|
25454
|
-
}
|
|
25455
|
-
for (const member of members) {
|
|
25456
|
-
if (raw2 && (leaf(member) === "rawValue" || leaf(member) === "init(rawValue:)" || leaf(member) === "init(_:)"))
|
|
25457
|
-
continue;
|
|
25458
|
-
const value = values.get(member.identifier.precise);
|
|
25459
|
-
if (value !== void 0 && member.kind.identifier === "swift.type.property") {
|
|
25460
|
-
emit(`${inner}public static let ${tick(leaf(member))} = ${shape.name}(rawValue: ${value})`);
|
|
25461
|
-
continue;
|
|
25462
|
-
}
|
|
25463
|
-
emitMember(member, inner, { openOwner: false, inClass: false, ownerName: shape.name });
|
|
25416
|
+
const emitType = scoped(
|
|
25417
|
+
(symbol, indent) => {
|
|
25418
|
+
const path37 = pathOf(symbol);
|
|
25419
|
+
const id = symbol.identifier.precise;
|
|
25420
|
+
const inner = `${indent} `;
|
|
25421
|
+
switch (symbol.kind.identifier) {
|
|
25422
|
+
case "swift.typealias": {
|
|
25423
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
25424
|
+
emit(`${indent}${attrs}public ${rest}`);
|
|
25425
|
+
return;
|
|
25464
25426
|
}
|
|
25465
|
-
|
|
25466
|
-
|
|
25467
|
-
|
|
25468
|
-
|
|
25469
|
-
|
|
25470
|
-
|
|
25471
|
-
|
|
25472
|
-
|
|
25473
|
-
|
|
25474
|
-
|
|
25475
|
-
|
|
25476
|
-
|
|
25477
|
-
|
|
25478
|
-
|
|
25479
|
-
|
|
25480
|
-
|
|
25481
|
-
const
|
|
25482
|
-
|
|
25483
|
-
|
|
25484
|
-
|
|
25485
|
-
|
|
25486
|
-
|
|
25487
|
-
const
|
|
25488
|
-
|
|
25427
|
+
case "swift.class": {
|
|
25428
|
+
const shape = header(symbol, "class", indent);
|
|
25429
|
+
if (!shape)
|
|
25430
|
+
return void skipped.push({ path: path37, reason: `unparsed class ${text(symbol)}` });
|
|
25431
|
+
const parent = options.superclasses?.get(path37) ?? superclass.get(id);
|
|
25432
|
+
const blocked = classBlocked(id);
|
|
25433
|
+
if (blocked) return void skipped.push({ path: path37, reason: blocked });
|
|
25434
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
25435
|
+
for (let at = superId.get(id); at; at = superId.get(at))
|
|
25436
|
+
for (const name2 of conforms.get(at) ?? []) ancestors.add(name2);
|
|
25437
|
+
const list2 = [
|
|
25438
|
+
...parent ? [parent] : [],
|
|
25439
|
+
...(conforms.get(id) ?? []).filter(
|
|
25440
|
+
(name2) => !ancestors.has(name2) && !(parent && [...KEEP_EXTERNAL.values()].includes(name2))
|
|
25441
|
+
)
|
|
25442
|
+
].filter((name2, at, all2) => all2.indexOf(name2) === at);
|
|
25443
|
+
const parentSymbol = superId.has(id) ? byId.get(superId.get(id)) : void 0;
|
|
25444
|
+
const open = symbol.accessLevel === "open" && (!parentSymbol || parentSymbol.accessLevel === "open");
|
|
25445
|
+
emit(
|
|
25446
|
+
`${indent}${shape.attrs}${open ? "open" : "public"} class ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${selfConforming(shape.where)} {`
|
|
25447
|
+
);
|
|
25448
|
+
const members = membersOf(id);
|
|
25449
|
+
for (const member of members)
|
|
25450
|
+
emitMember(member, inner, {
|
|
25451
|
+
openOwner: open,
|
|
25452
|
+
inClass: true,
|
|
25453
|
+
ownerName: shape.name
|
|
25454
|
+
});
|
|
25455
|
+
const designated = members.some(
|
|
25456
|
+
(member) => member.kind.identifier === "swift.init" && !text(member).startsWith("convenience")
|
|
25457
|
+
);
|
|
25458
|
+
const have = /* @__PURE__ */ new Set();
|
|
25459
|
+
for (let at = id; at; at = superId.get(at))
|
|
25460
|
+
for (const member of children.get(at) ?? []) have.add(witnessKey(member));
|
|
25461
|
+
const protocols = [];
|
|
25462
|
+
const visit = (protocolId) => {
|
|
25463
|
+
if (protocols.includes(protocolId)) return;
|
|
25464
|
+
protocols.push(protocolId);
|
|
25465
|
+
for (const edge of protocolParents.get(protocolId) ?? []) visit(edge);
|
|
25466
|
+
};
|
|
25467
|
+
for (const protocolId of conformIds.get(id) ?? []) visit(protocolId);
|
|
25468
|
+
for (const protocolId of protocols)
|
|
25469
|
+
for (const member of children.get(protocolId) ?? []) {
|
|
25470
|
+
if (!requirement.has(member.identifier.precise) || optional.has(member.identifier.precise))
|
|
25471
|
+
continue;
|
|
25472
|
+
if (isObjC(member) && / async\b/.test(text(member))) continue;
|
|
25473
|
+
if (have.has(witnessKey(member)) || member.kind.identifier === "swift.associatedtype")
|
|
25474
|
+
continue;
|
|
25475
|
+
have.add(witnessKey(member));
|
|
25476
|
+
emitWitness(member, inner, path37);
|
|
25477
|
+
}
|
|
25478
|
+
const coder = members.some((member) => leaf(member) === "init(coder:)");
|
|
25479
|
+
if (designated && !coder && externalRoot(id) !== "NSObject" && externalRoot(id) !== null)
|
|
25480
|
+
emit(
|
|
25481
|
+
`${inner}public required init?(coder: NSCoder) { ${trap(`${path37}.init(coder:)`)} }`
|
|
25482
|
+
);
|
|
25483
|
+
emit(`${indent}}`);
|
|
25484
|
+
return;
|
|
25489
25485
|
}
|
|
25490
|
-
|
|
25491
|
-
|
|
25492
|
-
if (
|
|
25493
|
-
|
|
25486
|
+
case "swift.struct": {
|
|
25487
|
+
const shape = header(symbol, "struct", indent);
|
|
25488
|
+
if (!shape)
|
|
25489
|
+
return void skipped.push({ path: path37, reason: `unparsed struct ${text(symbol)}` });
|
|
25490
|
+
const members = membersOf(id);
|
|
25491
|
+
const raw2 = rawType(members);
|
|
25492
|
+
const list2 = inheritance(id);
|
|
25493
|
+
emit(
|
|
25494
|
+
`${indent}${shape.attrs}public struct ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`
|
|
25495
|
+
);
|
|
25496
|
+
if (raw2) {
|
|
25497
|
+
emit(`${inner}public let rawValue: ${raw2}`);
|
|
25498
|
+
emit(`${inner}public init(rawValue: ${raw2}) { self.rawValue = rawValue }`);
|
|
25499
|
+
}
|
|
25500
|
+
for (const member of members) {
|
|
25501
|
+
if (raw2 && (leaf(member) === "rawValue" || leaf(member) === "init(rawValue:)" || leaf(member) === "init(_:)"))
|
|
25502
|
+
continue;
|
|
25503
|
+
const value = values.get(member.identifier.precise);
|
|
25504
|
+
if (value !== void 0 && member.kind.identifier === "swift.type.property") {
|
|
25505
|
+
emit(
|
|
25506
|
+
`${inner}public static let ${tick(leaf(member))} = ${shape.name}(rawValue: ${value})`
|
|
25507
|
+
);
|
|
25508
|
+
continue;
|
|
25509
|
+
}
|
|
25510
|
+
emitMember(member, inner, {
|
|
25511
|
+
openOwner: false,
|
|
25512
|
+
inClass: false,
|
|
25513
|
+
ownerName: shape.name
|
|
25514
|
+
});
|
|
25515
|
+
}
|
|
25516
|
+
emit(`${indent}}`);
|
|
25517
|
+
return;
|
|
25494
25518
|
}
|
|
25495
|
-
|
|
25496
|
-
|
|
25497
|
-
|
|
25498
|
-
|
|
25499
|
-
|
|
25500
|
-
|
|
25501
|
-
|
|
25502
|
-
|
|
25503
|
-
|
|
25504
|
-
|
|
25505
|
-
|
|
25506
|
-
|
|
25507
|
-
|
|
25508
|
-
|
|
25519
|
+
case "swift.enum": {
|
|
25520
|
+
const shape = header(symbol, "enum", indent);
|
|
25521
|
+
if (!shape)
|
|
25522
|
+
return void skipped.push({ path: path37, reason: `unparsed enum ${text(symbol)}` });
|
|
25523
|
+
const members = membersOf(id);
|
|
25524
|
+
const raw2 = rawType(members);
|
|
25525
|
+
const cases = (children.get(id) ?? []).filter(
|
|
25526
|
+
(member) => member.kind.identifier === "swift.enum.case"
|
|
25527
|
+
);
|
|
25528
|
+
const missing = raw2 ? cases.filter((member) => !values.has(member.identifier.precise)) : [];
|
|
25529
|
+
if (raw2 && isObjC(symbol) && missing.length > 0)
|
|
25530
|
+
return void skipped.push({
|
|
25531
|
+
path: path37,
|
|
25532
|
+
reason: `no header value for ${missing.map(leaf).join(", ")}`
|
|
25533
|
+
});
|
|
25534
|
+
const list2 = inheritance(id, raw2 ?? void 0).filter(
|
|
25535
|
+
(name2) => name2 !== "RawRepresentable"
|
|
25536
|
+
);
|
|
25537
|
+
emit(
|
|
25538
|
+
`${indent}${shape.attrs}public enum ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`
|
|
25539
|
+
);
|
|
25540
|
+
const seenValues = /* @__PURE__ */ new Map();
|
|
25541
|
+
for (const member of cases) {
|
|
25542
|
+
const value = values.get(member.identifier.precise);
|
|
25543
|
+
if (value !== void 0 && seenValues.has(value)) {
|
|
25544
|
+
emit(
|
|
25545
|
+
`${inner}public static var ${tick(leaf(member))}: ${shape.name} { .${seenValues.get(value)} }`
|
|
25546
|
+
);
|
|
25547
|
+
continue;
|
|
25548
|
+
}
|
|
25549
|
+
if (value !== void 0) seenValues.set(value, tick(leaf(member)));
|
|
25550
|
+
const caseText = text(member).replace(/^case\s+/, "");
|
|
25551
|
+
emit(`${inner}case ${caseText}${value !== void 0 ? ` = ${value}` : ""}`);
|
|
25509
25552
|
}
|
|
25510
|
-
const
|
|
25511
|
-
|
|
25512
|
-
|
|
25513
|
-
|
|
25553
|
+
for (const member of members) {
|
|
25554
|
+
if (member.kind.identifier === "swift.enum.case") continue;
|
|
25555
|
+
if (raw2 && (leaf(member) === "rawValue" || leaf(member) === "init(rawValue:)"))
|
|
25556
|
+
continue;
|
|
25557
|
+
emitMember(member, inner, {
|
|
25558
|
+
openOwner: false,
|
|
25559
|
+
inClass: false,
|
|
25560
|
+
ownerName: shape.name
|
|
25561
|
+
});
|
|
25514
25562
|
}
|
|
25515
|
-
|
|
25516
|
-
|
|
25563
|
+
emit(`${indent}}`);
|
|
25564
|
+
return;
|
|
25517
25565
|
}
|
|
25518
|
-
|
|
25519
|
-
|
|
25520
|
-
|
|
25521
|
-
|
|
25522
|
-
|
|
25523
|
-
|
|
25524
|
-
|
|
25525
|
-
|
|
25566
|
+
case "swift.protocol": {
|
|
25567
|
+
const shape = header(symbol, "protocol", indent);
|
|
25568
|
+
if (!shape)
|
|
25569
|
+
return void skipped.push({
|
|
25570
|
+
path: path37,
|
|
25571
|
+
reason: `unparsed protocol ${text(symbol)}`
|
|
25572
|
+
});
|
|
25573
|
+
const list2 = [...isObjC(symbol) ? ["AnyObject"] : [], ...inheritance(id)];
|
|
25574
|
+
emit(
|
|
25575
|
+
`${indent}${shape.attrs}public protocol ${shape.name}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`
|
|
25576
|
+
);
|
|
25577
|
+
const members = membersOf(id);
|
|
25578
|
+
const defaults = [];
|
|
25579
|
+
for (const member of members) {
|
|
25580
|
+
if (member.kind.identifier === "swift.associatedtype") {
|
|
25581
|
+
emit(`${inner}${text(member)}`);
|
|
25582
|
+
continue;
|
|
25583
|
+
}
|
|
25584
|
+
const asyncTwin = isObjC(member) && / async\b/.test(text(member));
|
|
25585
|
+
if (!requirement.has(member.identifier.precise) || asyncTwin) {
|
|
25586
|
+
defaults.push(member);
|
|
25587
|
+
continue;
|
|
25588
|
+
}
|
|
25589
|
+
emitRequirement(member, inner);
|
|
25590
|
+
if (optional.has(member.identifier.precise)) defaults.push(member);
|
|
25526
25591
|
}
|
|
25527
25592
|
emit(`${indent}}`);
|
|
25593
|
+
if (defaults.length > 0) {
|
|
25594
|
+
emit(`${indent}extension ${path37} {`);
|
|
25595
|
+
for (const member of defaults) {
|
|
25596
|
+
const decl = text(member);
|
|
25597
|
+
if (optional.has(member.identifier.precise) && member.kind.identifier === "swift.method" && !decl.replace(/\([^)]*\)/g, "").includes("->") && !/ async\b/.test(decl))
|
|
25598
|
+
emitNoop(member, inner);
|
|
25599
|
+
else
|
|
25600
|
+
emitMember(member, inner, {
|
|
25601
|
+
openOwner: false,
|
|
25602
|
+
inClass: false,
|
|
25603
|
+
ownerName: shape.name
|
|
25604
|
+
});
|
|
25605
|
+
}
|
|
25606
|
+
emit(`${indent}}`);
|
|
25607
|
+
}
|
|
25608
|
+
return;
|
|
25528
25609
|
}
|
|
25529
|
-
return;
|
|
25530
25610
|
}
|
|
25531
25611
|
}
|
|
25532
|
-
|
|
25612
|
+
);
|
|
25533
25613
|
const emitWitness = (member, indent, owner2) => {
|
|
25534
25614
|
const { 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
25535
25615
|
const decl = rest.replace(/^(?:weak |unowned )/, "").replace(/^((?:static )?)let /, "$1var ");
|
|
@@ -25538,15 +25618,22 @@ function emitSwiftStandin(graphs, options) {
|
|
|
25538
25618
|
if (member.kind.identifier === "swift.property" || member.kind.identifier === "swift.type.property") {
|
|
25539
25619
|
const accessors = ACCESSORS.exec(decl);
|
|
25540
25620
|
const bare = decl.replace(ACCESSORS, "").trimEnd();
|
|
25541
|
-
emit(
|
|
25542
|
-
|
|
25621
|
+
emit(
|
|
25622
|
+
`${indent}public ${bare} { get { ${body} }${accessors?.[3] ? ` set { ${body} }` : ""} }`
|
|
25623
|
+
);
|
|
25624
|
+
} else
|
|
25625
|
+
emit(
|
|
25626
|
+
`${indent}public ${member.kind.identifier === "swift.init" ? "required " : ""}${stripDefaults(decl)} { ${body} }`
|
|
25627
|
+
);
|
|
25543
25628
|
};
|
|
25544
25629
|
const emitNoop = scoped((member, indent) => {
|
|
25545
25630
|
emit(`${indent}public ${stripDefaults(text(member))} {}`);
|
|
25546
25631
|
});
|
|
25547
25632
|
const emitRequirement = scoped((member, indent) => {
|
|
25548
25633
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
25549
|
-
emit(
|
|
25634
|
+
emit(
|
|
25635
|
+
`${indent}${attrs}${stripDefaults(rest.replace(/^(?:weak |unowned )/, "").replace(/^((?:static )?)let /, "$1var "))}`
|
|
25636
|
+
);
|
|
25550
25637
|
});
|
|
25551
25638
|
const rawType = (members) => {
|
|
25552
25639
|
const init = members.find((member) => leaf(member) === "init(rawValue:)");
|
|
@@ -25559,7 +25646,9 @@ function emitSwiftStandin(graphs, options) {
|
|
|
25559
25646
|
emit(`${attrs}public ${rest} { ${trap(path37)} }`);
|
|
25560
25647
|
} else if (symbol.kind.identifier === "swift.var") {
|
|
25561
25648
|
const decl = text(symbol).replace(/^let /, "var ").replace(ACCESSORS, "").trimEnd();
|
|
25562
|
-
|
|
25649
|
+
const measured = behavior.get(path37);
|
|
25650
|
+
if (measured) used.add(path37);
|
|
25651
|
+
emit(`public ${decl} { ${measured?.body ?? trap(path37)} }`);
|
|
25563
25652
|
} else skipped.push({ path: path37, reason: `unhandled top-level ${symbol.kind.identifier}` });
|
|
25564
25653
|
});
|
|
25565
25654
|
const roots = [...byId.values()].filter((symbol) => !owner.has(symbol.identifier.precise) && !unavailable(symbol)).sort((a, b) => pathOf(a).localeCompare(pathOf(b)));
|
|
@@ -25580,11 +25669,20 @@ function emitSwiftStandin(graphs, options) {
|
|
|
25580
25669
|
emit(`extension ${name2} {`);
|
|
25581
25670
|
for (const member of kept)
|
|
25582
25671
|
if (member.kind.identifier === "swift.init" && !text(member).startsWith("convenience"))
|
|
25583
|
-
emitMember(
|
|
25584
|
-
|
|
25585
|
-
|
|
25586
|
-
|
|
25587
|
-
|
|
25672
|
+
emitMember(
|
|
25673
|
+
{
|
|
25674
|
+
...member,
|
|
25675
|
+
declarationFragments: [
|
|
25676
|
+
{ kind: "text", spelling: `convenience ${text(member)}` }
|
|
25677
|
+
]
|
|
25678
|
+
},
|
|
25679
|
+
" ",
|
|
25680
|
+
{
|
|
25681
|
+
openOwner: false,
|
|
25682
|
+
inClass: true,
|
|
25683
|
+
ownerName: name2
|
|
25684
|
+
}
|
|
25685
|
+
);
|
|
25588
25686
|
else emitMember(member, " ", { openOwner: false, inClass: false, ownerName: name2 });
|
|
25589
25687
|
emit(`}`);
|
|
25590
25688
|
}
|
|
@@ -25598,7 +25696,8 @@ function emitSwiftStandin(graphs, options) {
|
|
|
25598
25696
|
""
|
|
25599
25697
|
];
|
|
25600
25698
|
for (const path37 of behavior.keys())
|
|
25601
|
-
if (!used.has(path37))
|
|
25699
|
+
if (!used.has(path37))
|
|
25700
|
+
skipped.push({ path: path37, reason: "behavior names no emitted declaration" });
|
|
25602
25701
|
return {
|
|
25603
25702
|
source: `${[...banner, ...lines].join("\n")}
|
|
25604
25703
|
`,
|
|
@@ -25634,10 +25733,11 @@ function stripDefaults(decl) {
|
|
|
25634
25733
|
}
|
|
25635
25734
|
return out;
|
|
25636
25735
|
}
|
|
25637
|
-
var TYPE_KINDS, MEMBER_KINDS, ACCESSORS, KEEP_EXTERNAL, LEADING_ATTRS, OBJC_ONLY, text, leaf, pathOf, unavailable, witnessKey, isObjC, trap, KEYWORDS, tick;
|
|
25736
|
+
var STANDIN_EMIT_VERSION, TYPE_KINDS, MEMBER_KINDS, ACCESSORS, KEEP_EXTERNAL, LEADING_ATTRS, OBJC_ONLY, text, leaf, pathOf, unavailable, witnessKey, isObjC, trap, KEYWORDS, tick;
|
|
25638
25737
|
var init_swift_standin_emit = __esm({
|
|
25639
25738
|
"src/swift-standin-emit.ts"() {
|
|
25640
25739
|
"use strict";
|
|
25740
|
+
STANDIN_EMIT_VERSION = "1";
|
|
25641
25741
|
TYPE_KINDS = /* @__PURE__ */ new Set([
|
|
25642
25742
|
"swift.class",
|
|
25643
25743
|
"swift.struct",
|
|
@@ -25671,7 +25771,7 @@ var init_swift_standin_emit = __esm({
|
|
|
25671
25771
|
]);
|
|
25672
25772
|
LEADING_ATTRS = /^((?:@\w+(?:\([^)]*\))?\s*|nonisolated\s+)*)(.*)$/s;
|
|
25673
25773
|
OBJC_ONLY = /@(?:objcMembers|objc|IBOutlet|IBInspectable|IBAction|IBSegueAction|GKInspectable|nonobjc|NSCopying|NSManaged)(?:\([^)]*\))?\s*|\bdynamic\s+/g;
|
|
25674
|
-
text = (symbol) => (symbol.declarationFragments ?? []).map((fragment) => fragment.spelling).join("").replace(OBJC_ONLY, "").replace(/(^|\s)optional (?=func|var|init|subscript|static|class)/, "$1");
|
|
25774
|
+
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<");
|
|
25675
25775
|
leaf = (symbol) => symbol.pathComponents[symbol.pathComponents.length - 1];
|
|
25676
25776
|
pathOf = (symbol) => symbol.pathComponents.join(".");
|
|
25677
25777
|
unavailable = (symbol) => (symbol.availability ?? []).some(
|
|
@@ -25680,7 +25780,41 @@ var init_swift_standin_emit = __esm({
|
|
|
25680
25780
|
witnessKey = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.") ? "type" : "instance"}|${leaf(symbol)}`;
|
|
25681
25781
|
isObjC = (symbol) => symbol.identifier.precise.startsWith("c:");
|
|
25682
25782
|
trap = (path37) => `fatalError("${path37} is a binary framework peach cannot run")`;
|
|
25683
|
-
KEYWORDS = /* @__PURE__ */ new Set([
|
|
25783
|
+
KEYWORDS = /* @__PURE__ */ new Set([
|
|
25784
|
+
"Type",
|
|
25785
|
+
"Protocol",
|
|
25786
|
+
"Self",
|
|
25787
|
+
"default",
|
|
25788
|
+
"init",
|
|
25789
|
+
"self",
|
|
25790
|
+
"class",
|
|
25791
|
+
"func",
|
|
25792
|
+
"var",
|
|
25793
|
+
"let",
|
|
25794
|
+
"in",
|
|
25795
|
+
"is",
|
|
25796
|
+
"as",
|
|
25797
|
+
"repeat",
|
|
25798
|
+
"internal",
|
|
25799
|
+
"public",
|
|
25800
|
+
"private",
|
|
25801
|
+
"operator",
|
|
25802
|
+
"extension",
|
|
25803
|
+
"subscript",
|
|
25804
|
+
"static",
|
|
25805
|
+
"struct",
|
|
25806
|
+
"protocol",
|
|
25807
|
+
"enum",
|
|
25808
|
+
"case",
|
|
25809
|
+
"where",
|
|
25810
|
+
"return",
|
|
25811
|
+
"throw",
|
|
25812
|
+
"throws",
|
|
25813
|
+
"import",
|
|
25814
|
+
"true",
|
|
25815
|
+
"false",
|
|
25816
|
+
"nil"
|
|
25817
|
+
]);
|
|
25684
25818
|
tick = (name2) => KEYWORDS.has(name2) ? `\`${name2}\`` : name2;
|
|
25685
25819
|
}
|
|
25686
25820
|
});
|
|
@@ -25700,19 +25834,33 @@ ${"stdout" in error ? String(error.stdout) : ""}` : String(error);
|
|
|
25700
25834
|
const errors = output.split("\n").filter((line) => /\berror:/.test(line)).map((line) => line.replace(/^.*?error:\s*/, "").trim());
|
|
25701
25835
|
return [...new Set(errors)].slice(0, 3).join("; ") || output.trim().slice(0, 400);
|
|
25702
25836
|
}
|
|
25703
|
-
function
|
|
25704
|
-
|
|
25705
|
-
const
|
|
25706
|
-
|
|
25707
|
-
|
|
25708
|
-
|
|
25709
|
-
|
|
25710
|
-
|
|
25711
|
-
|
|
25712
|
-
|
|
25713
|
-
|
|
25714
|
-
import_node_fs16.default.
|
|
25837
|
+
function treeDigest(root) {
|
|
25838
|
+
const names = [];
|
|
25839
|
+
const walk2 = (dir) => {
|
|
25840
|
+
for (const entry of import_node_fs16.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name < right.name ? -1 : 1)) {
|
|
25841
|
+
const full = import_node_path16.default.join(dir, entry.name);
|
|
25842
|
+
if (entry.isDirectory()) walk2(full);
|
|
25843
|
+
else if (entry.isFile()) names.push(import_node_path16.default.relative(root, full));
|
|
25844
|
+
}
|
|
25845
|
+
};
|
|
25846
|
+
walk2(root);
|
|
25847
|
+
const stamp = names.map((name2) => {
|
|
25848
|
+
const stat2 = import_node_fs16.default.statSync(import_node_path16.default.join(root, name2));
|
|
25849
|
+
return `${name2}\0${stat2.size}:${stat2.mtimeMs}`;
|
|
25850
|
+
}).join("\n");
|
|
25851
|
+
const memo2 = digests.get(`tree\0${root}`);
|
|
25852
|
+
if (memo2?.stamp === stamp) return memo2.digest;
|
|
25853
|
+
const hash = (0, import_node_crypto7.createHash)("sha256");
|
|
25854
|
+
for (const name2 of names) {
|
|
25855
|
+
hash.update(`${name2}\0`);
|
|
25856
|
+
hash.update(import_node_fs16.default.readFileSync(import_node_path16.default.join(root, name2)));
|
|
25857
|
+
hash.update("\0");
|
|
25715
25858
|
}
|
|
25859
|
+
const digest = hash.digest("hex");
|
|
25860
|
+
digests.set(`tree\0${root}`, { stamp, digest });
|
|
25861
|
+
return digest;
|
|
25862
|
+
}
|
|
25863
|
+
function locateXcframework(tree) {
|
|
25716
25864
|
const find = (root, depth) => {
|
|
25717
25865
|
for (const entry of import_node_fs16.default.readdirSync(root, { withFileTypes: true })) {
|
|
25718
25866
|
if (!entry.isDirectory() || entry.name === "__MACOSX") continue;
|
|
@@ -25723,9 +25871,53 @@ function xcframework(binary) {
|
|
|
25723
25871
|
}
|
|
25724
25872
|
return null;
|
|
25725
25873
|
};
|
|
25726
|
-
|
|
25874
|
+
return find(tree, 2);
|
|
25875
|
+
}
|
|
25876
|
+
function xcframework(binary) {
|
|
25877
|
+
if (!binary.url && !binary.dir.endsWith(".zip"))
|
|
25878
|
+
return { dir: binary.dir, digest: treeDigest(binary.dir) };
|
|
25879
|
+
const dir = import_node_path16.default.join(cacheDir4, "archives", key(binary.url ?? binary.dir));
|
|
25880
|
+
const archive = import_node_path16.default.join(dir, "archive.zip");
|
|
25881
|
+
const fingerprint = import_node_path16.default.join(dir, ".fingerprint");
|
|
25882
|
+
const stored = (() => {
|
|
25883
|
+
try {
|
|
25884
|
+
const parsed = JSON.parse(import_node_fs16.default.readFileSync(fingerprint, "utf8"));
|
|
25885
|
+
return parsed && typeof parsed === "object" && "sha" in parsed ? parsed : null;
|
|
25886
|
+
} catch {
|
|
25887
|
+
return null;
|
|
25888
|
+
}
|
|
25889
|
+
})();
|
|
25890
|
+
if (!binary.url) {
|
|
25891
|
+
const stat2 = import_node_fs16.default.statSync(binary.dir);
|
|
25892
|
+
const stamp = `${stat2.size}:${stat2.mtimeMs}`;
|
|
25893
|
+
if (stored?.stamp === stamp) {
|
|
25894
|
+
const found3 = locateXcframework(import_node_path16.default.join(dir, "tree"));
|
|
25895
|
+
if (found3) return { dir: found3, digest: stored.sha };
|
|
25896
|
+
}
|
|
25897
|
+
const sha2 = (0, import_node_crypto7.createHash)("sha256").update(import_node_fs16.default.readFileSync(binary.dir)).digest("hex");
|
|
25898
|
+
if (sha2 !== stored?.sha || !locateXcframework(import_node_path16.default.join(dir, "tree"))) {
|
|
25899
|
+
import_node_fs16.default.rmSync(dir, { recursive: true, force: true });
|
|
25900
|
+
import_node_fs16.default.mkdirSync(import_node_path16.default.join(dir, "tree"), { recursive: true });
|
|
25901
|
+
exec("unzip", ["-q", binary.dir, "-d", import_node_path16.default.join(dir, "tree")]);
|
|
25902
|
+
}
|
|
25903
|
+
import_node_fs16.default.writeFileSync(fingerprint, JSON.stringify({ stamp, sha: sha2 }));
|
|
25904
|
+
const found2 = locateXcframework(import_node_path16.default.join(dir, "tree"));
|
|
25905
|
+
if (!found2) throw new Error("its archive holds no .xcframework");
|
|
25906
|
+
return { dir: found2, digest: sha2 };
|
|
25907
|
+
}
|
|
25908
|
+
if (stored && import_node_fs16.default.existsSync(archive)) {
|
|
25909
|
+
const found2 = locateXcframework(import_node_path16.default.join(dir, "tree"));
|
|
25910
|
+
if (found2) return { dir: found2, digest: stored.sha };
|
|
25911
|
+
}
|
|
25912
|
+
import_node_fs16.default.rmSync(dir, { recursive: true, force: true });
|
|
25913
|
+
import_node_fs16.default.mkdirSync(import_node_path16.default.join(dir, "tree"), { recursive: true });
|
|
25914
|
+
exec("curl", ["-fsSL", "--retry", "2", "-o", archive, binary.url]);
|
|
25915
|
+
const sha = (0, import_node_crypto7.createHash)("sha256").update(import_node_fs16.default.readFileSync(archive)).digest("hex");
|
|
25916
|
+
exec("unzip", ["-q", archive, "-d", import_node_path16.default.join(dir, "tree")]);
|
|
25917
|
+
import_node_fs16.default.writeFileSync(fingerprint, JSON.stringify({ sha }));
|
|
25918
|
+
const found = locateXcframework(import_node_path16.default.join(dir, "tree"));
|
|
25727
25919
|
if (!found) throw new Error("its archive holds no .xcframework");
|
|
25728
|
-
return found;
|
|
25920
|
+
return { dir: found, digest: sha };
|
|
25729
25921
|
}
|
|
25730
25922
|
function surfaces(xcframeworkDir) {
|
|
25731
25923
|
const slice = import_node_fs16.default.readdirSync(xcframeworkDir).filter((name2) => /^ios-.+-simulator$/.test(name2)).sort()[0];
|
|
@@ -25942,6 +26134,61 @@ function functionDeclarations(ast, headers) {
|
|
|
25942
26134
|
}
|
|
25943
26135
|
return found;
|
|
25944
26136
|
}
|
|
26137
|
+
function matchOpen(text3, close) {
|
|
26138
|
+
const open = text3[close] === ")" ? "(" : "[";
|
|
26139
|
+
let depth = 0;
|
|
26140
|
+
for (let index = close; index >= 0; index--) {
|
|
26141
|
+
if (text3[index] === text3[close]) depth++;
|
|
26142
|
+
else if (text3[index] === open && --depth === 0) return index;
|
|
26143
|
+
}
|
|
26144
|
+
return -1;
|
|
26145
|
+
}
|
|
26146
|
+
function splitDeclarators(statement, names) {
|
|
26147
|
+
const chunks = [];
|
|
26148
|
+
let depth = 0;
|
|
26149
|
+
let quote = null;
|
|
26150
|
+
let start = 0;
|
|
26151
|
+
for (let index = 0; index < statement.length; index++) {
|
|
26152
|
+
const char = statement[index];
|
|
26153
|
+
if (quote) {
|
|
26154
|
+
if (char === "\\") index++;
|
|
26155
|
+
else if (char === quote) quote = null;
|
|
26156
|
+
} else if (char === '"' || char === "'") quote = char;
|
|
26157
|
+
else if (char === "(" || char === "[" || char === "{") depth++;
|
|
26158
|
+
else if (char === ")" || char === "]" || char === "}") depth--;
|
|
26159
|
+
else if (char === "," && depth === 0) {
|
|
26160
|
+
chunks.push(statement.slice(start, index));
|
|
26161
|
+
start = index + 1;
|
|
26162
|
+
}
|
|
26163
|
+
}
|
|
26164
|
+
chunks.push(statement.slice(start));
|
|
26165
|
+
if (chunks.length !== names.length)
|
|
26166
|
+
throw new Error(
|
|
26167
|
+
`${names[0]} has an unexpected grouped declaration in ${JSON.stringify(statement.trim().slice(0, 80))}`
|
|
26168
|
+
);
|
|
26169
|
+
let end = chunks[0].indexOf(names[0]);
|
|
26170
|
+
if (end < 0) throw new Error(`${names[0]} names no declarator in its own declaration`);
|
|
26171
|
+
for (; ; ) {
|
|
26172
|
+
while (end > 0 && /[\s*]/.test(chunks[0][end - 1])) end--;
|
|
26173
|
+
if (end > 0 && (chunks[0][end - 1] === ")" || chunks[0][end - 1] === "]")) {
|
|
26174
|
+
end = matchOpen(chunks[0], end - 1);
|
|
26175
|
+
if (end < 0) throw new Error(`${names[0]} has unbalanced groups in its declaration`);
|
|
26176
|
+
while (end > 0 && identChar(chunks[0][end - 1])) end--;
|
|
26177
|
+
continue;
|
|
26178
|
+
}
|
|
26179
|
+
if (end > 1 && chunks[0][end - 1] === "(" && identChar(chunks[0][end - 2])) {
|
|
26180
|
+
end--;
|
|
26181
|
+
while (end > 0 && identChar(chunks[0][end - 1])) end--;
|
|
26182
|
+
continue;
|
|
26183
|
+
}
|
|
26184
|
+
break;
|
|
26185
|
+
}
|
|
26186
|
+
if (end > 0 && chunks[0][end - 1] === "(") end--;
|
|
26187
|
+
const specifiers = chunks[0].slice(0, end);
|
|
26188
|
+
return chunks.map(
|
|
26189
|
+
(chunk, index) => index === 0 ? chunk : `${specifiers} ${chunk.trim()}`
|
|
26190
|
+
);
|
|
26191
|
+
}
|
|
25945
26192
|
function cStandin(surface, binary, toolchain, work) {
|
|
25946
26193
|
const named = [
|
|
25947
26194
|
...import_node_fs16.default.readFileSync(surface.modulemap, "utf8").matchAll(/(?:umbrella\s+)?header\s+"([^"]+)"/g)
|
|
@@ -25986,26 +26233,40 @@ ${roots.map((file) => ` header "${file}"
|
|
|
25986
26233
|
);
|
|
25987
26234
|
const byPath = new Map(headers.map((file) => [import_node_path16.default.join(include, file), file]));
|
|
25988
26235
|
const declarations = functionDeclarations(ast, new Set(byPath.keys()));
|
|
26236
|
+
const groups = /* @__PURE__ */ new Map();
|
|
26237
|
+
for (const declaration of declarations) {
|
|
26238
|
+
const group = groups.get(`${declaration.file}\0${declaration.begin}`) ?? [];
|
|
26239
|
+
group.push(declaration);
|
|
26240
|
+
groups.set(`${declaration.file}\0${declaration.begin}`, group);
|
|
26241
|
+
}
|
|
25989
26242
|
const seen = /* @__PURE__ */ new Set();
|
|
25990
26243
|
const definitions = [];
|
|
25991
|
-
for (const
|
|
25992
|
-
|
|
25993
|
-
|
|
25994
|
-
const
|
|
25995
|
-
const close = text3.indexOf(";", end);
|
|
26244
|
+
for (const group of groups.values()) {
|
|
26245
|
+
const first = group[0];
|
|
26246
|
+
const text3 = texts.get(byPath.get(first.file));
|
|
26247
|
+
const close = text3.indexOf(";", first.end);
|
|
25996
26248
|
if (close < 0)
|
|
25997
|
-
throw new Error(`${
|
|
25998
|
-
|
|
25999
|
-
|
|
26000
|
-
|
|
26249
|
+
throw new Error(`${first.name} has no declaration end in ${byPath.get(first.file)}`);
|
|
26250
|
+
const statement = text3.slice(first.begin, close);
|
|
26251
|
+
const declarators = group.length === 1 ? [statement] : splitDeclarators(
|
|
26252
|
+
statement,
|
|
26253
|
+
group.map((declaration) => declaration.name)
|
|
26254
|
+
);
|
|
26255
|
+
group.forEach((declaration, index) => {
|
|
26256
|
+
if (seen.has(declaration.name)) return;
|
|
26257
|
+
seen.add(declaration.name);
|
|
26258
|
+
definitions.push(
|
|
26259
|
+
`${declarators[index].trim()} {
|
|
26260
|
+
peach_standin_trap("${declaration.name}");
|
|
26001
26261
|
}
|
|
26002
26262
|
`
|
|
26003
|
-
|
|
26263
|
+
);
|
|
26264
|
+
});
|
|
26004
26265
|
}
|
|
26005
26266
|
const sdk = JSON.stringify(`${binary.target} (${binary.source})`);
|
|
26006
26267
|
const source = [
|
|
26007
26268
|
`// generated by peach from ${surface.module}'s headers: ${binary.target} ships`,
|
|
26008
|
-
"// iOS machine code only, so every function traps naming itself.",
|
|
26269
|
+
"// iOS machine code only, so every extern function traps naming itself.",
|
|
26009
26270
|
...roots.map((file) => `#include "${file}"`),
|
|
26010
26271
|
"#include <stdio.h>",
|
|
26011
26272
|
"#include <stdlib.h>",
|
|
@@ -26017,6 +26278,22 @@ ${roots.map((file) => ` header "${file}"
|
|
|
26017
26278
|
"",
|
|
26018
26279
|
...definitions
|
|
26019
26280
|
].join("\n");
|
|
26281
|
+
const out = import_node_path16.default.join(work, `${surface.module}.c`);
|
|
26282
|
+
import_node_fs16.default.writeFileSync(out, source);
|
|
26283
|
+
try {
|
|
26284
|
+
exec(import_node_path16.default.join(toolchain.toolchainBin, "clang"), [
|
|
26285
|
+
"-target",
|
|
26286
|
+
TRIPLE,
|
|
26287
|
+
"--sysroot",
|
|
26288
|
+
sysroot,
|
|
26289
|
+
"-fsyntax-only",
|
|
26290
|
+
"-I",
|
|
26291
|
+
include,
|
|
26292
|
+
out
|
|
26293
|
+
]);
|
|
26294
|
+
} catch (error) {
|
|
26295
|
+
throw new Error(`its generated source does not compile: ${failure(error)}`);
|
|
26296
|
+
}
|
|
26020
26297
|
return {
|
|
26021
26298
|
module: surface.module,
|
|
26022
26299
|
target: binary.target,
|
|
@@ -26029,18 +26306,48 @@ ${roots.map((file) => ` header "${file}"
|
|
|
26029
26306
|
}
|
|
26030
26307
|
};
|
|
26031
26308
|
}
|
|
26032
|
-
function
|
|
26033
|
-
|
|
26309
|
+
function standinGenerationInputs(binaries, toolchain) {
|
|
26310
|
+
const { moduleRoot, toolchainBin, release } = toolchain;
|
|
26311
|
+
const parts = [
|
|
26312
|
+
"standin/v2",
|
|
26313
|
+
toolchainBin,
|
|
26314
|
+
release,
|
|
26315
|
+
swiftModuleSdk(moduleRoot).wasmSdkId,
|
|
26316
|
+
swiftModuleDigest(moduleRoot).toString("hex"),
|
|
26317
|
+
`emit/${STANDIN_EMIT_VERSION}`
|
|
26318
|
+
];
|
|
26319
|
+
for (const binary of binaries) {
|
|
26320
|
+
try {
|
|
26321
|
+
parts.push(
|
|
26322
|
+
binary.target,
|
|
26323
|
+
binary.source,
|
|
26324
|
+
binary.url ?? "",
|
|
26325
|
+
xcframework(binary).digest
|
|
26326
|
+
);
|
|
26327
|
+
} catch {
|
|
26328
|
+
parts.push(binary.target, binary.source, binary.url ?? "", "unreadable");
|
|
26329
|
+
}
|
|
26330
|
+
}
|
|
26331
|
+
return (0, import_node_crypto7.createHash)("sha256").update(parts.join("\0")).digest("hex");
|
|
26332
|
+
}
|
|
26333
|
+
function binaryStandins(binary, toolchain, provided) {
|
|
26334
|
+
if (provided.has(binary.target)) return [];
|
|
26335
|
+
let all;
|
|
26336
|
+
let digest;
|
|
26034
26337
|
try {
|
|
26035
|
-
|
|
26338
|
+
const artifact = xcframework(binary);
|
|
26339
|
+
all = surfaces(artifact.dir);
|
|
26340
|
+
digest = artifact.digest;
|
|
26036
26341
|
} catch (error) {
|
|
26037
26342
|
return error instanceof Error ? error.message : String(error);
|
|
26038
26343
|
}
|
|
26039
|
-
|
|
26344
|
+
const found = all.filter((surface) => !provided.has(surface.module));
|
|
26345
|
+
if (found.length === 0) {
|
|
26346
|
+
if (all.length > 0) return [];
|
|
26040
26347
|
return "its iOS simulator slice has no Swift interface or C modulemap";
|
|
26041
|
-
|
|
26042
|
-
|
|
26043
|
-
);
|
|
26348
|
+
}
|
|
26349
|
+
const hash = (0, import_node_crypto7.createHash)("sha256").update(standinGenerationInputs([binary], toolchain));
|
|
26350
|
+
hash.update(digest);
|
|
26044
26351
|
for (const surface of found) {
|
|
26045
26352
|
hash.update(`${surface.kind}\0${surface.module}\0`);
|
|
26046
26353
|
for (const file of surface.kind === "swift" ? [surface.interface] : [
|
|
@@ -26083,17 +26390,17 @@ function binaryStandins(binary, toolchain) {
|
|
|
26083
26390
|
}
|
|
26084
26391
|
return result;
|
|
26085
26392
|
}
|
|
26086
|
-
function swiftStandins(binaries, toolchain) {
|
|
26393
|
+
function swiftStandins(binaries, toolchain, provided = /* @__PURE__ */ new Set()) {
|
|
26087
26394
|
const standins = [];
|
|
26088
26395
|
const gaps = /* @__PURE__ */ new Map();
|
|
26089
26396
|
for (const binary of binaries) {
|
|
26090
|
-
const result = binaryStandins(binary, toolchain);
|
|
26397
|
+
const result = binaryStandins(binary, toolchain, provided);
|
|
26091
26398
|
if (typeof result === "string") gaps.set(binary.target, result);
|
|
26092
26399
|
else standins.push(...result);
|
|
26093
26400
|
}
|
|
26094
26401
|
return { standins, gaps };
|
|
26095
26402
|
}
|
|
26096
|
-
var import_node_child_process9, import_node_crypto7, import_node_fs16, import_node_os7, import_node_path16, TRIPLE, cacheDir4, key, files, OBJC, built;
|
|
26403
|
+
var import_node_child_process9, import_node_crypto7, import_node_fs16, import_node_os7, import_node_path16, TRIPLE, cacheDir4, key, digests, files, OBJC, identChar, built;
|
|
26097
26404
|
var init_swift_standins = __esm({
|
|
26098
26405
|
"src/swift-standins.ts"() {
|
|
26099
26406
|
"use strict";
|
|
@@ -26107,8 +26414,10 @@ var init_swift_standins = __esm({
|
|
|
26107
26414
|
TRIPLE = "wasm32-unknown-wasip1";
|
|
26108
26415
|
cacheDir4 = import_node_path16.default.join(import_node_os7.default.tmpdir(), "peach-swift-standins");
|
|
26109
26416
|
key = (...parts) => (0, import_node_crypto7.createHash)("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
26417
|
+
digests = /* @__PURE__ */ new Map();
|
|
26110
26418
|
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() : [];
|
|
26111
26419
|
OBJC = /^\s*(?:@interface|@protocol|@class|@import|#import)\b/m;
|
|
26420
|
+
identChar = (char) => char !== void 0 && /[\w$]/.test(char);
|
|
26112
26421
|
built = /* @__PURE__ */ new Map();
|
|
26113
26422
|
}
|
|
26114
26423
|
});
|
|
@@ -27336,32 +27645,49 @@ function swiftPackages(entry, app) {
|
|
|
27336
27645
|
({ source }) => source.kind === "local" ? stamp(import_node_path19.default.join(source.dir, "Package.swift")) : 0
|
|
27337
27646
|
)
|
|
27338
27647
|
]);
|
|
27339
|
-
|
|
27340
|
-
|
|
27341
|
-
|
|
27342
|
-
|
|
27343
|
-
|
|
27344
|
-
|
|
27345
|
-
|
|
27346
|
-
|
|
27347
|
-
|
|
27348
|
-
|
|
27349
|
-
|
|
27350
|
-
|
|
27351
|
-
|
|
27352
|
-
|
|
27353
|
-
|
|
27354
|
-
|
|
27648
|
+
let cached4 = entry.packages;
|
|
27649
|
+
if (cached4?.key !== key2) {
|
|
27650
|
+
cached4 = {
|
|
27651
|
+
key: key2,
|
|
27652
|
+
standinKey: "",
|
|
27653
|
+
packages: resolveSwiftPackages({
|
|
27654
|
+
rootDir: app.rootDir,
|
|
27655
|
+
resolved: app.packageResolved,
|
|
27656
|
+
products: app.linkedProducts,
|
|
27657
|
+
localDirs: app.localPackageDirs,
|
|
27658
|
+
provided: entry.provided
|
|
27659
|
+
}),
|
|
27660
|
+
standins: []
|
|
27661
|
+
};
|
|
27662
|
+
entry.packages = cached4;
|
|
27663
|
+
}
|
|
27664
|
+
const reached = cached4.packages.binaries.filter((binary) => binary.reached);
|
|
27665
|
+
if (entry.moduleRoot && entry.provided && reached.length > 0) {
|
|
27666
|
+
const resolved = swiftModuleToolchain(entry.moduleRoot);
|
|
27667
|
+
const toolchain = {
|
|
27668
|
+
moduleRoot: entry.moduleRoot,
|
|
27669
|
+
toolchainBin: resolved.toolchainBin,
|
|
27670
|
+
release: resolved.release
|
|
27671
|
+
};
|
|
27672
|
+
const generation = standinGenerationInputs(reached, toolchain);
|
|
27673
|
+
if (cached4.standinKey !== generation) {
|
|
27674
|
+
const built2 = swiftStandins(reached, toolchain, entry.provided);
|
|
27675
|
+
cached4.packages = resolveSwiftPackages({
|
|
27676
|
+
rootDir: app.rootDir,
|
|
27677
|
+
resolved: app.packageResolved,
|
|
27678
|
+
products: app.linkedProducts,
|
|
27679
|
+
localDirs: app.localPackageDirs,
|
|
27680
|
+
provided: /* @__PURE__ */ new Set([
|
|
27681
|
+
...entry.provided,
|
|
27682
|
+
...built2.standins.map((standin) => standin.target)
|
|
27683
|
+
]),
|
|
27684
|
+
binaryGaps: built2.gaps
|
|
27355
27685
|
});
|
|
27356
|
-
standins = built2.standins;
|
|
27357
|
-
|
|
27358
|
-
/* @__PURE__ */ new Set([...entry.provided, ...standins.map((standin) => standin.target)]),
|
|
27359
|
-
built2.gaps
|
|
27360
|
-
);
|
|
27686
|
+
cached4.standins = built2.standins;
|
|
27687
|
+
cached4.standinKey = generation;
|
|
27361
27688
|
}
|
|
27362
|
-
entry.packages = { key: key2, packages, standins };
|
|
27363
27689
|
}
|
|
27364
|
-
return
|
|
27690
|
+
return cached4;
|
|
27365
27691
|
}
|
|
27366
27692
|
function xcodeInputKey(layout, file, relative3) {
|
|
27367
27693
|
const owner = layout.targetDirs.get(file);
|
|
@@ -32006,6 +32332,13 @@ function rotateHardwareButtons(buttons, portraitFrameHeight, side) {
|
|
|
32006
32332
|
volumeDown: rotate(buttons.volumeDown)
|
|
32007
32333
|
};
|
|
32008
32334
|
}
|
|
32335
|
+
function landscapeKeyboardPanelHeights(device) {
|
|
32336
|
+
if (device.model === "iphone-duo") return { qwerty: 230, pad: 182, emoji: 230 };
|
|
32337
|
+
return usesLandscapePhoneKeyboard(device) ? { qwerty: 224, pad: 171, emoji: 224 } : device.keyboardPanelHeights;
|
|
32338
|
+
}
|
|
32339
|
+
function usesLandscapePhoneKeyboard(device) {
|
|
32340
|
+
return device.platform === "ios" && device.model !== "iphone-duo" && !isPadIdiom(device) && device.homeIndicatorHeight > 0;
|
|
32341
|
+
}
|
|
32009
32342
|
function rotateDevice(device, side) {
|
|
32010
32343
|
const frameHeight = resolveDeviceFrameGeometry(device).frameHeight;
|
|
32011
32344
|
const insets = rotateFrameInsets(device.frameInsets, side);
|
|
@@ -32048,6 +32381,7 @@ function rotateDevice(device, side) {
|
|
|
32048
32381
|
// to whichever side the cutout turned to.
|
|
32049
32382
|
safeAreaInsets: side === "left" ? safeArea : { ...safeArea, left: safeArea.right, right: safeArea.left },
|
|
32050
32383
|
statusBarHeight: device.landscapeStatusBarHeight,
|
|
32384
|
+
keyboardPanelHeights: landscapeKeyboardPanelHeights(device),
|
|
32051
32385
|
// the indicator's band is the landscape bottom inset
|
|
32052
32386
|
homeIndicatorHeight: device.platform === "ios" && device.homeIndicatorHeight > 0 ? safeArea.bottom : device.homeIndicatorHeight
|
|
32053
32387
|
};
|