peachsim 0.1.1667 → 0.1.1673
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/README.md +1 -1
- package/cli/bridge-flow-runner.ts +4 -1
- package/cli/commands/coverage-swift.ts +291 -0
- package/cli/commands/coverage.ts +168 -24
- package/cli/commands/diagnose.ts +1 -19
- package/cli/commands/react.ts +3 -18
- package/cli/commands/screenshot.ts +1 -1
- package/cli/commands/screenshots-capture.ts +1 -1
- package/cli/drivers/playwright-provisioning.ts +1 -4
- package/cli/drivers/playwright.ts +15 -1
- package/cli/scene-video.ts +1 -1
- package/cli/ui.ts +20 -0
- package/cli/ws-bridge.ts +7 -36
- package/detox/frame-identity.cjs +21 -0
- package/detox/frame-identity.d.cts +6 -0
- package/detox/index.ts +39 -33
- package/detox/jest-environment.cjs +4 -1
- package/detox/jest-setup-after-env.cjs +0 -4
- package/detox/navigation-lifecycle.ts +2 -2
- package/detox/proof-observer.ts +126 -0
- package/dist-lib/agent-daemon-client.cjs +29 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +10 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +530 -154
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +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/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +5074 -7353
- package/dist-lib/detox/jest-environment.cjs +4 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +578 -151
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +660 -192
- package/dist-lib/host/fetch-proxy-handler.cjs +2 -2
- 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 +206 -6
- 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 +10 -1
- package/dist-lib/metro-production-bundle.mjs +12 -1
- package/dist-lib/metro.cjs +155 -5
- package/dist-lib/native-app-identity-project.cjs +43 -5
- package/dist-lib/native-app-identity-project.mjs +43 -5
- 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 +21 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +73 -27
- package/dist-lib/public-origins-lib-static.json +1 -1
- package/dist-lib/public-origins-lib.json +563 -183
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +964 -0
- 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 +963 -521
- package/dist-lib/swift-compile.cjs +276 -86
- package/dist-lib/swift-compile.mjs +276 -86
- package/dist-lib/swift-package.cjs +34 -4
- package/dist-lib/swift-package.mjs +33 -4
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +25 -44
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +579 -113
- package/dist-lib/vite.cjs +61 -2
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/clipboardContract.d.ts +7 -0
- package/dist-types/packages/peach-engine/src/engine/glass-material.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/engine/inspect-outline.d.ts +2 -1
- package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/paint-boundary.d.ts +3 -1
- package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +7 -0
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime-kind.d.ts +24 -0
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +4 -2
- package/dist-types/packages/peach-engine/src/settings/devices.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/clipboardBridgeContract.d.ts +18 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
- package/dist-types/packages/peach-globals/src/nodeContract.d.ts +1 -0
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h +2 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +36 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCDynamicStore.h +439 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCDynamicStoreCopySpecific.h +216 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCDynamicStoreKey.h +267 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCNetwork.h +204 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCNetworkConfiguration.h +1393 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCNetworkConnection.h +568 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCNetworkReachability.h +369 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCPreferences.h +473 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCPreferencesPath.h +179 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCPreferencesSetSpecific.h +95 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCSchemaDefinitions.h +2395 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SystemConfiguration.h +184 -0
- package/sdk/ios/usr/include/libkern/OSByteOrder.h +315 -0
- package/sdk/ios/usr/include/libkern/machine/OSByteOrder.h +147 -0
- package/src/bridge-contract.ts +42 -0
- package/src/chromium-admission.ts +196 -0
- package/src/host/bridge-host.ts +6 -43
- package/src/launch-deadline.ts +74 -0
- package/src/nitro-adapter.lock.json +3 -3
- package/src/profiles.ts +21 -0
- package/src/react-native-coverage/capability-reference-resolution.ts +402 -0
- package/src/react-native-coverage/capability-source-references.ts +1296 -0
- package/src/react-native-coverage/native-typescript-parser.ts +74 -0
- package/src/react-native-coverage/project-aliases.ts +207 -0
- package/src/react-native-coverage/verified-reach.ts +47 -0
- package/src/reap-browser.ts +1019 -0
- package/src/skills/builtin/a11y-review.ts +1 -1
- package/src/skills/builtin/perf-profile.ts +1 -1
- package/src/skills/builtin/screenshot-all.ts +1 -1
- package/src/skills/builtin/visual-diff.ts +1 -1
- package/src/swift-compile.ts +107 -56
- package/src/swift-coverage/indexdump.ts +80 -0
- package/src/swift-coverage/indexing.ts +147 -0
- package/src/swift-coverage/package.ts +230 -0
- package/src/swift-coverage/provenance.ts +47 -0
- package/src/swift-coverage/reader.ts +81 -0
- package/src/swift-coverage/source.ts +252 -0
- package/src/swift-coverage/types.ts +58 -0
- package/src/swift-coverage/xcode-assets.ts +175 -0
- package/src/swift-coverage/xcode-bridging.ts +160 -0
- package/src/swift-coverage/xcode-packages.ts +251 -0
- package/src/swift-coverage/xcode-strings.ts +78 -0
- package/src/swift-coverage/xcode.ts +656 -0
- package/src/swift-distribution.lock.json +8 -8
- package/src/swift-host.ts +21 -1
- package/src/swift-objc-import.ts +191 -27
- package/src/swift-objc-standin.ts +4 -2
- package/src/swift-package-manifest.ts +134 -13
- package/src/swift-package.ts +46 -4
- package/src/swift-submit.ts +2 -1
- package/src/swift-toolchain.ts +36 -61
- package/src/worker-system-chunks.ts +3 -10
- package/src/xcode-project.ts +5 -5
- package/detox/attempt-events.cjs +0 -914
- package/detox/attempt-events.d.cts +0 -113
- package/detox/motion-change.cjs +0 -524
- package/detox/motion-change.d.cts +0 -140
- package/detox/motion-leg-starts.cjs +0 -20
- package/detox/motion-leg-starts.d.cts +0 -8
- package/detox/proof-frame.cjs +0 -190
- package/detox/record-block-execution.cjs +0 -78
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.1673 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -7511,7 +7511,17 @@ function sourceSwiftCheckout() {
|
|
|
7511
7511
|
}
|
|
7512
7512
|
function swiftSdkOptions() {
|
|
7513
7513
|
const directory = process.env.PEACH_SWIFT_SDKS_PATH;
|
|
7514
|
-
|
|
7514
|
+
if (directory) return ["--swift-sdks-path", import_node_path4.default.resolve(directory)];
|
|
7515
|
+
if (scratch && process.platform === "linux") {
|
|
7516
|
+
const config = process.env.XDG_CONFIG_HOME;
|
|
7517
|
+
if (config !== void 0 && !import_node_path4.default.isAbsolute(config))
|
|
7518
|
+
throw new Error("XDG_CONFIG_HOME must be an absolute path");
|
|
7519
|
+
return [
|
|
7520
|
+
"--swift-sdks-path",
|
|
7521
|
+
config === void 0 ? import_node_path4.default.join(import_node_os3.default.userInfo().homedir, ".swiftpm", "swift-sdks") : import_node_path4.default.join(config, "swiftpm", "swift-sdks")
|
|
7522
|
+
];
|
|
7523
|
+
}
|
|
7524
|
+
return [];
|
|
7515
7525
|
}
|
|
7516
7526
|
var SWIFT_HOST_COMPILER_RELEASE = "swift-6.4.0-RELEASE-custom-0d775d32d7c74eae";
|
|
7517
7527
|
var SWIFT_HOST_COMPILER_ID = "0d775d32d7c74eae";
|
|
@@ -7570,10 +7580,16 @@ function peachHome() {
|
|
|
7570
7580
|
return override ? import_node_path4.default.resolve(override) : import_node_path4.default.join(import_node_os3.default.homedir(), ".peach");
|
|
7571
7581
|
}
|
|
7572
7582
|
var scratch;
|
|
7573
|
-
var swiftHome;
|
|
7574
7583
|
function swiftEnvironment(base = process.env) {
|
|
7575
7584
|
if (!scratch) return base;
|
|
7576
|
-
return
|
|
7585
|
+
return {
|
|
7586
|
+
...base,
|
|
7587
|
+
TMPDIR: scratch.directory,
|
|
7588
|
+
XDG_CONFIG_HOME: import_node_path4.default.join(scratch.home, ".config"),
|
|
7589
|
+
XDG_CACHE_HOME: import_node_path4.default.join(scratch.home, ".cache"),
|
|
7590
|
+
XDG_DATA_HOME: import_node_path4.default.join(scratch.home, ".local", "share"),
|
|
7591
|
+
...process.platform === "linux" ? { HOME: scratch.home } : {}
|
|
7592
|
+
};
|
|
7577
7593
|
}
|
|
7578
7594
|
function swiftSourceSdk(root) {
|
|
7579
7595
|
const pin = JSON.parse(
|
|
@@ -8483,6 +8499,7 @@ function swiftObjCImports(graphs, options) {
|
|
|
8483
8499
|
const categories = /* @__PURE__ */ new Map();
|
|
8484
8500
|
const functions = /* @__PURE__ */ new Map();
|
|
8485
8501
|
const typedefs = /* @__PURE__ */ new Map();
|
|
8502
|
+
const wrappedTypedefs = /* @__PURE__ */ new Map();
|
|
8486
8503
|
const visit3 = (node) => {
|
|
8487
8504
|
if (!record(node)) return;
|
|
8488
8505
|
if (node.kind === "ObjCInterfaceDecl" && typeof node.name === "string" && selected.has(node.name)) {
|
|
@@ -8504,6 +8521,9 @@ function swiftObjCImports(graphs, options) {
|
|
|
8504
8521
|
if (node.kind === "TypedefDecl" && typeof node.name === "string" && record(node.type)) {
|
|
8505
8522
|
const canonical2 = node.type.desugaredQualType ?? node.type.qualType;
|
|
8506
8523
|
if (typeof canonical2 === "string") typedefs.set(node.name, canonical2);
|
|
8524
|
+
if (nodes(node.inner).some((attribute) => attribute.kind === "SwiftNewTypeAttr")) {
|
|
8525
|
+
wrappedTypedefs.set(node.name, [...wrappedTypedefs.get(node.name) ?? [], node]);
|
|
8526
|
+
}
|
|
8507
8527
|
}
|
|
8508
8528
|
for (const child of nodes(node.inner)) visit3(child);
|
|
8509
8529
|
};
|
|
@@ -8511,14 +8531,29 @@ function swiftObjCImports(graphs, options) {
|
|
|
8511
8531
|
fail("declarations", "expected a complete Clang translation unit AST");
|
|
8512
8532
|
visit3(options.clangAST);
|
|
8513
8533
|
const symbols = /* @__PURE__ */ new Map();
|
|
8534
|
+
const seenSymbols = /* @__PURE__ */ new Set();
|
|
8514
8535
|
for (const graph of graphs) {
|
|
8515
8536
|
if (graph.module.name !== options.module)
|
|
8516
8537
|
fail("declarations", `symbol graph belongs to ${graph.module.name}`);
|
|
8517
8538
|
for (const symbol of graph.symbols) {
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8539
|
+
if (symbol.availability?.some(
|
|
8540
|
+
(entry) => entry.isUnconditionallyUnavailable && (!entry.domain || entry.domain === "Swift" || entry.domain === "iOS")
|
|
8541
|
+
))
|
|
8542
|
+
continue;
|
|
8543
|
+
const key = JSON.stringify([
|
|
8544
|
+
symbol.identifier.precise,
|
|
8545
|
+
symbol.kind.identifier,
|
|
8546
|
+
symbol.pathComponents,
|
|
8547
|
+
symbol.declarationFragments,
|
|
8548
|
+
symbol.functionSignature,
|
|
8549
|
+
symbol.accessLevel,
|
|
8550
|
+
symbol.availability
|
|
8551
|
+
]);
|
|
8552
|
+
if (seenSymbols.has(key)) continue;
|
|
8553
|
+
seenSymbols.add(key);
|
|
8554
|
+
const overloads = symbols.get(symbol.identifier.precise) ?? [];
|
|
8555
|
+
overloads.push(symbol);
|
|
8556
|
+
symbols.set(symbol.identifier.precise, overloads);
|
|
8522
8557
|
}
|
|
8523
8558
|
}
|
|
8524
8559
|
const classes = [];
|
|
@@ -8533,7 +8568,10 @@ function swiftObjCImports(graphs, options) {
|
|
|
8533
8568
|
types.set(name2, nativeName);
|
|
8534
8569
|
}
|
|
8535
8570
|
for (const nativeName of [...selected].sort()) {
|
|
8536
|
-
const
|
|
8571
|
+
const candidates = symbols.get(`c:objc(cs)${nativeName}`);
|
|
8572
|
+
if (candidates && candidates.length !== 1)
|
|
8573
|
+
fail(nativeName, "ambiguous imported class declaration");
|
|
8574
|
+
const symbol = candidates?.[0];
|
|
8537
8575
|
const name2 = symbol?.pathComponents[0];
|
|
8538
8576
|
if (!symbol || symbol.kind.identifier !== "swift.class" || !name2 || !identifier(name2))
|
|
8539
8577
|
fail(nativeName, "missing Swift-imported class declaration");
|
|
@@ -8548,6 +8586,70 @@ function swiftObjCImports(graphs, options) {
|
|
|
8548
8586
|
types.set(name2, nativeName);
|
|
8549
8587
|
classes.push({ name: name2, nativeName });
|
|
8550
8588
|
}
|
|
8589
|
+
const wrapperMembers = /* @__PURE__ */ new Map();
|
|
8590
|
+
const wrapperConformances = /* @__PURE__ */ new Map();
|
|
8591
|
+
for (const graph of graphs)
|
|
8592
|
+
for (const edge of graph.relationships)
|
|
8593
|
+
if (edge.kind === "conformsTo" && edge.source.includes("@T@")) {
|
|
8594
|
+
const protocols = wrapperConformances.get(edge.source) ?? /* @__PURE__ */ new Set();
|
|
8595
|
+
protocols.add(edge.target);
|
|
8596
|
+
wrapperConformances.set(edge.source, protocols);
|
|
8597
|
+
}
|
|
8598
|
+
for (const candidates of symbols.values())
|
|
8599
|
+
for (const member of candidates)
|
|
8600
|
+
if (member.pathComponents.length === 2 && ["init(rawValue:)", "init(_:)"].includes(member.pathComponents[1])) {
|
|
8601
|
+
const owner = member.pathComponents[0];
|
|
8602
|
+
wrapperMembers.set(owner, [...wrapperMembers.get(owner) ?? [], member]);
|
|
8603
|
+
}
|
|
8604
|
+
const stringWrappers = /* @__PURE__ */ new Map();
|
|
8605
|
+
const wrapperSymbols = [...symbols].filter(
|
|
8606
|
+
([usr, candidates]) => usr.includes("@T@") && candidates[0]?.kind.identifier === "swift.struct"
|
|
8607
|
+
).sort(([left], [right]) => left.localeCompare(right));
|
|
8608
|
+
for (const [usr, candidates] of wrapperSymbols) {
|
|
8609
|
+
const nativeName = /^c:.*@T@([A-Za-z_]\w*)$/.exec(usr)?.[1];
|
|
8610
|
+
if (!nativeName) continue;
|
|
8611
|
+
const originals = wrappedTypedefs.get(nativeName);
|
|
8612
|
+
const declaration = originals?.[0];
|
|
8613
|
+
if (!declaration || !record(declaration.type)) continue;
|
|
8614
|
+
const original = declaration.type.desugaredQualType ?? declaration.type.qualType;
|
|
8615
|
+
if (typeof original !== "string" || original.replace(/\s/g, "") !== "NSString*")
|
|
8616
|
+
continue;
|
|
8617
|
+
const symbol = candidates[0];
|
|
8618
|
+
const name2 = symbol.pathComponents[0];
|
|
8619
|
+
if (candidates.length !== 1 || originals?.length !== 1 || symbol.pathComponents.length !== 1 || !name2 || !identifier(name2) || types.has(name2) || stringWrappers.has(name2) || symbol.accessLevel !== "public" || text2(symbol.declarationFragments ?? []).trim() !== `struct ${name2}` || symbol.availability?.length)
|
|
8620
|
+
fail(usr, "typed string wrapper identity is unqualified");
|
|
8621
|
+
if (!["s:SY", "s:SH", "s:SQ", "s:s8SendableP"].every(
|
|
8622
|
+
(protocol) => wrapperConformances.get(usr)?.has(protocol)
|
|
8623
|
+
))
|
|
8624
|
+
fail(usr, "typed string wrapper conformances are unqualified");
|
|
8625
|
+
const members = wrapperMembers.get(name2) ?? [];
|
|
8626
|
+
const initializers = members.filter(
|
|
8627
|
+
(member) => member.pathComponents[1] === "init(rawValue:)"
|
|
8628
|
+
);
|
|
8629
|
+
if (initializers.length !== 1 || initializers[0].kind.identifier !== "swift.init" || initializers[0].accessLevel !== "public" || text2(initializers[0].declarationFragments ?? []).trim() !== "init(rawValue: String)" || !initializers[0].declarationFragments?.some(
|
|
8630
|
+
(part) => part.kind === "typeIdentifier" && part.preciseIdentifier === "s:SS"
|
|
8631
|
+
))
|
|
8632
|
+
fail(usr, "typed string wrapper raw initializer is unqualified");
|
|
8633
|
+
const unlabelled = members.filter((member) => member.pathComponents[1] === "init(_:)");
|
|
8634
|
+
if (unlabelled.length > 1 || unlabelled.length === 1 && (unlabelled[0].kind.identifier !== "swift.init" || unlabelled[0].accessLevel !== "public" || text2(unlabelled[0].declarationFragments ?? []).trim() !== "init(_ rawValue: String)" || !unlabelled[0].declarationFragments?.some(
|
|
8635
|
+
(part) => part.kind === "typeIdentifier" && part.preciseIdentifier === "s:SS"
|
|
8636
|
+
)))
|
|
8637
|
+
fail(usr, "typed string wrapper unlabeled initializer is unqualified");
|
|
8638
|
+
stringWrappers.set(
|
|
8639
|
+
name2,
|
|
8640
|
+
[
|
|
8641
|
+
`public struct ${swiftName(name2)}: Swift.RawRepresentable, Swift.Hashable, Swift.Equatable, Swift._SwiftNewtypeWrapper, Swift._ObjectiveCBridgeable, Swift.Sendable {`,
|
|
8642
|
+
" public typealias RawValue = Swift.String",
|
|
8643
|
+
" public typealias _ObjectiveCType = Foundation.NSString",
|
|
8644
|
+
" private let _rawValue: Swift.String",
|
|
8645
|
+
" public var rawValue: Swift.String { _rawValue }",
|
|
8646
|
+
" public init(rawValue: Swift.String) { _rawValue = rawValue }",
|
|
8647
|
+
...unlabelled.length ? [" public init(_ rawValue: Swift.String) { _rawValue = rawValue }"] : [],
|
|
8648
|
+
"}",
|
|
8649
|
+
""
|
|
8650
|
+
].join("\n")
|
|
8651
|
+
);
|
|
8652
|
+
}
|
|
8551
8653
|
const type = (parts, where) => {
|
|
8552
8654
|
const written = text2(parts).trim();
|
|
8553
8655
|
const optional = /[?!]$/.test(written);
|
|
@@ -8570,7 +8672,7 @@ function swiftObjCImports(graphs, options) {
|
|
|
8570
8672
|
Double: "double"
|
|
8571
8673
|
};
|
|
8572
8674
|
if (!optional && primitive[written] && !parts.some(
|
|
8573
|
-
(part) => part.preciseIdentifier?.startsWith("c:") || part.preciseIdentifier && symbols.get(part.preciseIdentifier)?.kind.identifier === "swift.class"
|
|
8675
|
+
(part) => part.preciseIdentifier?.startsWith("c:") || part.preciseIdentifier && symbols.get(part.preciseIdentifier)?.[0]?.kind.identifier === "swift.class"
|
|
8574
8676
|
))
|
|
8575
8677
|
return {
|
|
8576
8678
|
swift: `Swift.${written === "()" ? "Void" : written}`,
|
|
@@ -8582,7 +8684,7 @@ function swiftObjCImports(graphs, options) {
|
|
|
8582
8684
|
const identifiers = parts.filter((part) => part.kind === "typeIdentifier");
|
|
8583
8685
|
const id = identifiers.length === 1 ? identifiers[0]?.preciseIdentifier : void 0;
|
|
8584
8686
|
const native = id && nativeClass(id);
|
|
8585
|
-
const swiftClass = id ? symbols.get(id) : void 0;
|
|
8687
|
+
const swiftClass = id ? symbols.get(id)?.[0] : void 0;
|
|
8586
8688
|
const resolved = native ? names.get(native) : swiftClass?.kind.identifier === "swift.class" && swiftClass.pathComponents.length === 1 && swiftClass.pathComponents[0] === spelling && types.has(spelling) ? spelling : void 0;
|
|
8587
8689
|
if (!resolved || identifiers[0]?.spelling !== spelling || spelling !== resolved && spelling !== native)
|
|
8588
8690
|
return fail(
|
|
@@ -8643,7 +8745,8 @@ function swiftObjCImports(graphs, options) {
|
|
|
8643
8745
|
);
|
|
8644
8746
|
};
|
|
8645
8747
|
const membersByClass = /* @__PURE__ */ new Map();
|
|
8646
|
-
|
|
8748
|
+
const importedSymbols = [...symbols.values()].flat();
|
|
8749
|
+
for (const symbol of importedSymbols) {
|
|
8647
8750
|
const owner = /^c:objc\(cs\)([A-Za-z_]\w*)\(/.exec(symbol.identifier.precise)?.[1];
|
|
8648
8751
|
if (owner && selected.has(owner)) {
|
|
8649
8752
|
const members = membersByClass.get(owner);
|
|
@@ -8770,27 +8873,40 @@ function swiftObjCImports(graphs, options) {
|
|
|
8770
8873
|
(n) => nodes(n.inner)
|
|
8771
8874
|
);
|
|
8772
8875
|
for (const member of members) {
|
|
8773
|
-
if (member.kind === "ObjCMethodDecl" && typeof member.name === "string" && (/^init(?:$|[^a-z])/.test(member.name.replace(/^_+/, "")) || nodes(member.inner).some(
|
|
8876
|
+
if (member.kind === "ObjCMethodDecl" && typeof member.name === "string" && member.name !== "init" && (/^init(?:$|[^a-z])/.test(member.name.replace(/^_+/, "")) || nodes(member.inner).some(
|
|
8774
8877
|
(attribute) => attribute.kind === "NSConsumesSelfAttr" || attribute.kind === "ObjCDesignatedInitializerAttr"
|
|
8775
|
-
)))
|
|
8878
|
+
)) && !nodes(member.inner).some((attribute) => attribute.kind === "UnavailableAttr"))
|
|
8776
8879
|
fail(
|
|
8777
8880
|
`${nativeName}.${member.name}`,
|
|
8778
8881
|
"explicit or designated initialization is unqualified"
|
|
8779
8882
|
);
|
|
8780
|
-
|
|
8781
|
-
fail(`${nativeName}.${member.name}`, "variadic methods are unqualified");
|
|
8782
|
-
}
|
|
8783
|
-
const constructor = thunk(
|
|
8784
|
-
`${nativeName}:new`,
|
|
8785
|
-
raw2,
|
|
8786
|
-
[],
|
|
8787
|
-
null,
|
|
8788
|
-
`[[${nativeName} alloc] init]`
|
|
8789
|
-
);
|
|
8883
|
+
}
|
|
8790
8884
|
const body = [
|
|
8791
|
-
`public required init(_objcRetained: Swift.UnsafeMutableRawPointer) { precondition(Self.self == ${swiftName(name2)}.self, "Swift subclass construction is unqualified"); super.init(_objcRetained: _objcRetained) }
|
|
8792
|
-
`public init() { precondition(Self.self == ${swiftName(name2)}.self, "Swift subclass construction is unqualified"); super.init(_objcRetained: ${constructor}()!) }`
|
|
8885
|
+
`public required init(_objcRetained: Swift.UnsafeMutableRawPointer) { precondition(Self.self == ${swiftName(name2)}.self, "Swift subclass construction is unqualified"); super.init(_objcRetained: _objcRetained) }`
|
|
8793
8886
|
];
|
|
8887
|
+
const defaultInitializer = members.find(
|
|
8888
|
+
(member) => member.kind === "ObjCMethodDecl" && member.instance === true && member.name === "init"
|
|
8889
|
+
);
|
|
8890
|
+
const importedInitializer = symbols.get(`c:objc(cs)${nativeName}(im)init`);
|
|
8891
|
+
const initializerSpelling = importedInitializer?.[0] ? text2(importedInitializer[0].declarationFragments ?? []).trim() : "init()";
|
|
8892
|
+
if (!/^init[?!]?\(\)$/.test(initializerSpelling))
|
|
8893
|
+
fail(`${nativeName}.init`, "default initializer signature is unqualified");
|
|
8894
|
+
if (!defaultInitializer || !nodes(defaultInitializer.inner).some(
|
|
8895
|
+
(attribute) => attribute.kind === "UnavailableAttr"
|
|
8896
|
+
)) {
|
|
8897
|
+
if (defaultInitializer && (importedInitializer?.length !== 1 || importedInitializer[0]?.kind.identifier !== "swift.init"))
|
|
8898
|
+
fail(`${nativeName}.init`, "missing Swift-imported default initializer");
|
|
8899
|
+
const constructor = thunk(
|
|
8900
|
+
`${nativeName}:new`,
|
|
8901
|
+
raw2,
|
|
8902
|
+
[],
|
|
8903
|
+
null,
|
|
8904
|
+
`[[${nativeName} alloc] init]`
|
|
8905
|
+
);
|
|
8906
|
+
body.push(
|
|
8907
|
+
`public ${initializerSpelling} { precondition(Self.self == ${swiftName(name2)}.self, "Swift subclass construction is unqualified"); ${/^init[?!]/.test(initializerSpelling) ? `guard let _peer = ${constructor}() else { return nil }; super.init(_objcRetained: _peer)` : `super.init(_objcRetained: ${constructor}()!)`} }`
|
|
8908
|
+
);
|
|
8909
|
+
}
|
|
8794
8910
|
bodies.set(name2, body);
|
|
8795
8911
|
const prefix = `c:objc(cs)${nativeName}`;
|
|
8796
8912
|
for (const symbol of membersByClass.get(nativeName) ?? []) {
|
|
@@ -8808,16 +8924,19 @@ function swiftObjCImports(graphs, options) {
|
|
|
8808
8924
|
(m) => m.kind === (property ? "ObjCPropertyDecl" : "ObjCMethodDecl") && m.name === selector && (property ? m.class !== true === instance : m.instance === instance)
|
|
8809
8925
|
);
|
|
8810
8926
|
if (!decl) fail(usr, "member absent from original Clang interface");
|
|
8927
|
+
if (decl.variadic === true)
|
|
8928
|
+
fail(`${nativeName}.${selector}`, "variadic methods are unqualified");
|
|
8811
8929
|
const parts = symbol.declarationFragments ?? [];
|
|
8812
8930
|
const written = text2(parts);
|
|
8813
8931
|
if (symbol.availability?.length || /@|\b(?:optional|nonisolated|isolated|async|throws|rethrows)\b/.test(written))
|
|
8814
8932
|
fail(usr, "availability and asynchronous or throwing imports are unqualified");
|
|
8815
8933
|
if (nodes(decl.inner).some(
|
|
8816
|
-
(a) => /^(?:Unavailable|SwiftPrivate|SwiftAsync|SwiftError|ObjCRequiresSuper
|
|
8934
|
+
(a) => /^(?:Unavailable|SwiftPrivate|SwiftAsync|SwiftError|ObjCRequiresSuper)Attr$/.test(
|
|
8817
8935
|
String(a.kind)
|
|
8818
|
-
)
|
|
8936
|
+
) || a.kind === "NSConsumesSelfAttr" && selector !== "init"
|
|
8819
8937
|
))
|
|
8820
8938
|
fail(usr, "member attributes require a qualified importer path");
|
|
8939
|
+
if (selector === "init" && symbol.kind.identifier === "swift.init") continue;
|
|
8821
8940
|
const receiver = instance ? "_object" : nativeName;
|
|
8822
8941
|
const access = symbol.accessLevel === "open" ? "open" : "public";
|
|
8823
8942
|
const memberName = parts.find((part) => part.kind === "identifier")?.spelling;
|
|
@@ -8896,7 +9015,7 @@ function swiftObjCImports(graphs, options) {
|
|
|
8896
9015
|
}
|
|
8897
9016
|
}
|
|
8898
9017
|
const importedFunctions = [];
|
|
8899
|
-
for (const symbol of
|
|
9018
|
+
for (const symbol of importedSymbols) {
|
|
8900
9019
|
if (symbol.kind.identifier !== "swift.func") continue;
|
|
8901
9020
|
const usr = symbol.identifier.precise;
|
|
8902
9021
|
const native = /^c:@F@([A-Za-z_]\w*)$/.exec(usr)?.[1];
|
|
@@ -8937,7 +9056,7 @@ function swiftObjCImports(graphs, options) {
|
|
|
8937
9056
|
`public func ${swiftName(name2)}(${argumentsSwift}) -> ${result.swift} { ${result.c === "void" ? "" : "return "}${local}(${parameters.map((p) => swiftName(p.name)).join(", ")}) }`
|
|
8938
9057
|
);
|
|
8939
9058
|
}
|
|
8940
|
-
if (!classes.length && !importedFunctions.length)
|
|
9059
|
+
if (!classes.length && !importedFunctions.length && !stringWrappers.size)
|
|
8941
9060
|
fail("declarations", "no represented original Objective-C classes or C functions");
|
|
8942
9061
|
const registerFunction = `_peachRegisterObjCImports_${hash(options.module)}`;
|
|
8943
9062
|
const registration = [
|
|
@@ -8950,12 +9069,14 @@ function swiftObjCImports(graphs, options) {
|
|
|
8950
9069
|
""
|
|
8951
9070
|
].join("\n");
|
|
8952
9071
|
const swift = [
|
|
8953
|
-
...classes.length ? ["import Foundation"
|
|
9072
|
+
...classes.length || stringWrappers.size ? ["import Foundation"] : [],
|
|
9073
|
+
...classes.length ? ["import PeachObjC"] : [],
|
|
8954
9074
|
"",
|
|
8955
9075
|
...external,
|
|
8956
9076
|
"",
|
|
8957
9077
|
...importedFunctions,
|
|
8958
9078
|
"",
|
|
9079
|
+
...stringWrappers.values(),
|
|
8959
9080
|
...classes.flatMap((c) => [
|
|
8960
9081
|
`open class ${swiftName(c.name)}: PeachObjC._ObjCForeignObject {`,
|
|
8961
9082
|
...bodies.get(c.name).map((line) => ` ${line}`),
|
|
@@ -9216,7 +9337,9 @@ function objcView(surface, toolchainBin, stdlib, cacheDir2, work, original) {
|
|
|
9216
9337
|
"-module-cache-path",
|
|
9217
9338
|
import_node_path7.default.join(cacheDir2, "ios-module-cache"),
|
|
9218
9339
|
"-minimum-access-level",
|
|
9219
|
-
|
|
9340
|
+
// symbol graphs hide public underscored names at the public threshold.
|
|
9341
|
+
// original clang headers remain the declaration boundary.
|
|
9342
|
+
original ? "internal" : "public",
|
|
9220
9343
|
"-skip-synthesized-members",
|
|
9221
9344
|
"-omit-extension-block-symbols",
|
|
9222
9345
|
"-output-dir",
|
|
@@ -9702,6 +9825,32 @@ function splitManifestArguments(source) {
|
|
|
9702
9825
|
function swiftTargetModuleName(name2) {
|
|
9703
9826
|
return name2.replace(/[^A-Za-z0-9_]/g, "_").replace(/^[0-9]/, "_");
|
|
9704
9827
|
}
|
|
9828
|
+
function clangMacroSetting(macro) {
|
|
9829
|
+
const [name2, ...value] = macro.split("=");
|
|
9830
|
+
return value.length === 0 ? `.define(${JSON.stringify(name2)})` : `.define(${JSON.stringify(name2)}, to: ${JSON.stringify(value.join("="))})`;
|
|
9831
|
+
}
|
|
9832
|
+
function settingDefines(call, tool) {
|
|
9833
|
+
const defines = [];
|
|
9834
|
+
for (const open of call.matchAll(new RegExp(`\\b${tool}Settings\\s*:\\s*\\[`, "g"))) {
|
|
9835
|
+
let depth = 1;
|
|
9836
|
+
let index = open.index + open[0].length;
|
|
9837
|
+
const start = index;
|
|
9838
|
+
for (; index < call.length && depth > 0; index++) {
|
|
9839
|
+
const char = call[index];
|
|
9840
|
+
if (char === '"') {
|
|
9841
|
+
for (index++; index < call.length && call[index] !== '"'; index++)
|
|
9842
|
+
if (call[index] === "\\") index++;
|
|
9843
|
+
} else if (char === "[") depth++;
|
|
9844
|
+
else if (char === "]") depth--;
|
|
9845
|
+
}
|
|
9846
|
+
const body = call.slice(start, index - 1);
|
|
9847
|
+
for (const match of body.matchAll(
|
|
9848
|
+
/\.define\(\s*"([A-Za-z_][A-Za-z0-9_]*)"\s*(?:,\s*to:\s*"([^"]*)"\s*)?\)/g
|
|
9849
|
+
))
|
|
9850
|
+
defines.push(match[2] === void 0 ? match[1] : `${match[1]}=${match[2]}`);
|
|
9851
|
+
}
|
|
9852
|
+
return defines;
|
|
9853
|
+
}
|
|
9705
9854
|
function swiftManifestTargets(manifest, resourcePaths = []) {
|
|
9706
9855
|
const implicitResources = swiftImplicitResourcePaths(resourcePaths);
|
|
9707
9856
|
const targets = [];
|
|
@@ -9729,9 +9878,9 @@ function swiftManifestTargets(manifest, resourcePaths = []) {
|
|
|
9729
9878
|
const cxxInterop = /\.interoperabilityMode\(\s*\.Cxx\s*\)/.test(
|
|
9730
9879
|
call.replace(/"(?:\\.|[^"\\])*"/g, "")
|
|
9731
9880
|
);
|
|
9732
|
-
const defines = [
|
|
9733
|
-
|
|
9734
|
-
|
|
9881
|
+
const defines = settingDefines(call, "swift").map((define) => define.split("=")[0]);
|
|
9882
|
+
const cDefines = settingDefines(call, "c");
|
|
9883
|
+
const cxxDefines = settingDefines(call, "cxx");
|
|
9735
9884
|
const linkedLibraries = [...call.matchAll(/\.linkedLibrary\(\s*"([^"]+)"\s*\)/g)].map(
|
|
9736
9885
|
(match) => match[1]
|
|
9737
9886
|
);
|
|
@@ -9774,6 +9923,8 @@ function swiftManifestTargets(manifest, resourcePaths = []) {
|
|
|
9774
9923
|
mainActorIsolation,
|
|
9775
9924
|
...cxxInterop ? { cxxInterop: true } : {},
|
|
9776
9925
|
...defines.length === 0 ? {} : { defines },
|
|
9926
|
+
...cDefines.length === 0 ? {} : { cDefines },
|
|
9927
|
+
...cxxDefines.length === 0 ? {} : { cxxDefines },
|
|
9777
9928
|
...linkedLibraries.length === 0 ? {} : { linkedLibraries },
|
|
9778
9929
|
resources,
|
|
9779
9930
|
...dependencies.length === 0 ? {} : { dependencies },
|
|
@@ -10682,7 +10833,7 @@ var EXECUTABLE_LINK_FLAGS = ` "-Xclang-linker", "-O0",
|
|
|
10682
10833
|
`;
|
|
10683
10834
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
10684
10835
|
var MULTI_MANIFEST_VERSION = 40;
|
|
10685
|
-
var compilerSourceDigest = true ? "
|
|
10836
|
+
var compilerSourceDigest = true ? "6ea8d8a06ae707693b5fbb43a21e9d705ee8a19779051d47b05c4bbaeb39fb6c" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
|
|
10686
10837
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
10687
10838
|
const hash2 = (0, import_node_crypto7.createHash)("sha256");
|
|
10688
10839
|
hash2.update(`swift-compile
|
|
@@ -10799,6 +10950,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
10799
10950
|
const linkedNativeModules = [...args.native?.entries() ?? []].flatMap(
|
|
10800
10951
|
([name2, value]) => value.clang ? [name2] : []
|
|
10801
10952
|
);
|
|
10953
|
+
const macroSettings = (values) => (values ?? []).map((value) => ` ${clangMacroSetting(value)},`).join("");
|
|
10802
10954
|
const stanza = (target) => {
|
|
10803
10955
|
if (target.systemLibrary)
|
|
10804
10956
|
return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(target.path)}),`;
|
|
@@ -10875,10 +11027,15 @@ function emitSwiftPackageManifest(args) {
|
|
|
10875
11027
|
.unsafeFlags(["-Xlinker", "--strip-all"], .when(configuration: .release)),
|
|
10876
11028
|
]` : librarySettings.length > 0 ? `,
|
|
10877
11029
|
linkerSettings: [${librarySettings.join(", ")}]` : "";
|
|
11030
|
+
const cDefines = macroSettings(target.cDefines);
|
|
11031
|
+
const cxxDefines = macroSettings(target.cxxDefines);
|
|
10878
11032
|
const nativeSettings = native?.clang ? [
|
|
10879
|
-
`cSettings: [.unsafeFlags(${JSON.stringify([...args.objcExports?.flags ?? args.nativeFlags ?? [], ...native.clang.flags])})]`,
|
|
10880
|
-
`cxxSettings: [${
|
|
10881
|
-
].join(", ") :
|
|
11033
|
+
`cSettings: [${cDefines} .unsafeFlags(${JSON.stringify([...args.objcExports?.flags ?? args.nativeFlags ?? [], ...native.clang.flags])})]`,
|
|
11034
|
+
`cxxSettings: [${cxxDefines} .unsafeFlags(${JSON.stringify(["-fno-cxx-modules", ...args.objcExports?.flags ?? args.nativeFlags ?? [], ...native.clang.cxxFlags])})]`
|
|
11035
|
+
].join(", ") : [
|
|
11036
|
+
`cSettings: [${cDefines} .unsafeFlags(${JSON.stringify([...args.objcExports?.flags ?? args.nativeFlags ?? [], ...native?.flags ?? []])})]`,
|
|
11037
|
+
`cxxSettings: [${cxxDefines} .unsafeFlags(${JSON.stringify(["-fno-cxx-modules", ...args.objcExports?.flags ?? args.nativeFlags ?? [], ...native?.cxxFlags ?? []])})]`
|
|
11038
|
+
].join(", ");
|
|
10882
11039
|
return [
|
|
10883
11040
|
` ${kind}(`,
|
|
10884
11041
|
` name: "${target.name}",`,
|
|
@@ -10888,7 +11045,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
10888
11045
|
...native?.clang ? [
|
|
10889
11046
|
` sources: ${JSON.stringify(native.clang.sources.map((source) => import_node_path10.default.posix.join(native.path, source)))},`,
|
|
10890
11047
|
` publicHeadersPath: ${JSON.stringify(import_node_path10.default.posix.dirname(native.clang.modulemap))},`
|
|
10891
|
-
] : [],
|
|
11048
|
+
] : native?.flags ? [` sources: ${JSON.stringify(native.sources)},`] : [],
|
|
10892
11049
|
// the native backend supplies dependency module maps without their
|
|
10893
11050
|
// compiled modules. textual c++ includes keep those dependencies usable.
|
|
10894
11051
|
` ${clang ? nativeSettings : swiftSettings}${link}`,
|
|
@@ -10914,24 +11071,26 @@ function emitSwiftPackageManifest(args) {
|
|
|
10914
11071
|
' publicHeadersPath: "include",',
|
|
10915
11072
|
` cSettings: [.unsafeFlags(${JSON.stringify([...args.objcExports.flags.filter((flag) => flag !== "-fobjc-arc"), "-fno-objc-arc", "-Xclang", "-disable-objc-default-synthesize-properties"])})]),`
|
|
10916
11073
|
] : [],
|
|
10917
|
-
...[...args.native?.entries() ?? []].flatMap(
|
|
10918
|
-
|
|
11074
|
+
...[...args.native?.entries() ?? []].flatMap(([name2, native]) => {
|
|
11075
|
+
const late = native.late;
|
|
11076
|
+
const owner = targets.find((target) => target.name === name2);
|
|
11077
|
+
return late ? (native.groups ?? [
|
|
10919
11078
|
{
|
|
10920
|
-
name:
|
|
11079
|
+
name: late.name,
|
|
10921
11080
|
sources: native.lateSources,
|
|
10922
11081
|
flags: [],
|
|
10923
11082
|
cxxFlags: []
|
|
10924
11083
|
}
|
|
10925
11084
|
]).flatMap((group) => [
|
|
10926
11085
|
` .target(name: ${JSON.stringify(group.name)},`,
|
|
10927
|
-
` dependencies: ${JSON.stringify(
|
|
11086
|
+
` dependencies: ${JSON.stringify(native.mixed ? [] : [name2, ...late.producers])},`,
|
|
10928
11087
|
` path: ${JSON.stringify(native.clang ? "." : native.path)},`,
|
|
10929
11088
|
` sources: ${JSON.stringify(native.clang ? group.sources.map((source) => import_node_path10.default.posix.join(native.path, source)) : group.sources)},`,
|
|
10930
11089
|
` publicHeadersPath: ${JSON.stringify(native.clang ? import_node_path10.default.posix.dirname(native.clang.modulemap) : "include")},`,
|
|
10931
|
-
` cSettings: [.unsafeFlags(${JSON.stringify([...args.objcExports?.flags ?? args.nativeFlags ?? [], ...group.flags])})],`,
|
|
10932
|
-
` cxxSettings: [.unsafeFlags(${JSON.stringify(["-fno-cxx-modules", "-I", native.includeDirectory, "-I", args.headerDirectory, ...group.cxxFlags])})]),`
|
|
10933
|
-
]) : []
|
|
10934
|
-
),
|
|
11090
|
+
` cSettings: [${macroSettings(owner?.cDefines)} .unsafeFlags(${JSON.stringify([...args.objcExports?.flags ?? args.nativeFlags ?? [], ...group.flags])})],`,
|
|
11091
|
+
` cxxSettings: [${macroSettings(owner?.cxxDefines)} .unsafeFlags(${JSON.stringify(["-fno-cxx-modules", ...args.objcExports?.flags ?? args.nativeFlags ?? [], "-I", native.includeDirectory, "-I", args.headerDirectory, ...group.cxxFlags])})]),`
|
|
11092
|
+
]) : [];
|
|
11093
|
+
}),
|
|
10935
11094
|
args.cxxLanguageStandard ? ` ],
|
|
10936
11095
|
cxxLanguageStandard: .${args.cxxLanguageStandard}` : " ]",
|
|
10937
11096
|
")",
|
|
@@ -14998,7 +15157,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
14998
15157
|
else files.set(file, prior);
|
|
14999
15158
|
}
|
|
15000
15159
|
targetStagedFiles.delete(target.name);
|
|
15001
|
-
if (entries.some(([file]) => /\.(?:c|cc|cpp|cxx|m|mm)$/.test(file)) && (swift || input.nativeTargets?.some((value) => value.name === target.name)
|
|
15160
|
+
if (entries.some(([file]) => /\.(?:c|cc|cpp|cxx|m|mm)$/.test(file)) && (swift || input.nativeTargets?.some((value) => value.name === target.name))) {
|
|
15002
15161
|
if (!swift) {
|
|
15003
15162
|
const unprepared = import_node_path10.default.join(
|
|
15004
15163
|
layout.root,
|
|
@@ -15071,8 +15230,42 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
15071
15230
|
const entries = targetEntries(target);
|
|
15072
15231
|
const units = entries.filter(([file]) => /\.(?:c|cc|cpp|cxx|m|mm)$/.test(file));
|
|
15073
15232
|
if (units.length === 0) continue;
|
|
15233
|
+
const includes = `${prefix}include/`;
|
|
15234
|
+
const consumers = /* @__PURE__ */ new Map();
|
|
15235
|
+
const reverse = /* @__PURE__ */ new Map();
|
|
15236
|
+
for (const [file, contents] of entries) {
|
|
15237
|
+
const producers2 = /* @__PURE__ */ new Set();
|
|
15238
|
+
const source = contents.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
15239
|
+
for (const match of source.matchAll(
|
|
15240
|
+
/^\s*#\s*(?:include|import)\s*[<"]([^>"]+)[>"]/gm
|
|
15241
|
+
)) {
|
|
15242
|
+
const include2 = match[1];
|
|
15243
|
+
const producer = /(?:^|\/)([^/]+)-Swift\.h$/.exec(include2)?.[1];
|
|
15244
|
+
if (producer && targets.some((value) => value.name === producer))
|
|
15245
|
+
producers2.add(producer);
|
|
15246
|
+
const local = [
|
|
15247
|
+
import_node_path10.default.posix.join(import_node_path10.default.posix.dirname(file), include2),
|
|
15248
|
+
`${includes}${include2}`
|
|
15249
|
+
].find((candidate) => input.files[candidate] !== void 0);
|
|
15250
|
+
if (local) {
|
|
15251
|
+
reverse.set(local, [...reverse.get(local) ?? [], file]);
|
|
15252
|
+
}
|
|
15253
|
+
}
|
|
15254
|
+
consumers.set(file, producers2);
|
|
15255
|
+
}
|
|
15256
|
+
const queue = [...consumers.keys()].filter((file) => consumers.get(file).size > 0);
|
|
15257
|
+
for (let index = 0; index < queue.length; index++) {
|
|
15258
|
+
const file = queue[index];
|
|
15259
|
+
for (const parent of reverse.get(file) ?? []) {
|
|
15260
|
+
const inherited = consumers.get(parent);
|
|
15261
|
+
const before = inherited.size;
|
|
15262
|
+
for (const producer of consumers.get(file)) inherited.add(producer);
|
|
15263
|
+
if (before !== inherited.size) queue.push(parent);
|
|
15264
|
+
}
|
|
15265
|
+
}
|
|
15266
|
+
const late = units.filter(([file]) => consumers.get(file).size > 0);
|
|
15074
15267
|
const settings = input.nativeTargets?.find((value) => value.name === target.name);
|
|
15075
|
-
if (entries.some(([file]) => file.endsWith(".swift"))
|
|
15268
|
+
if (settings || entries.some(([file]) => file.endsWith(".swift"))) {
|
|
15076
15269
|
try {
|
|
15077
15270
|
if (!settings)
|
|
15078
15271
|
throw new Error(
|
|
@@ -15140,7 +15333,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
15140
15333
|
return relative.split("/").some((part) => part.startsWith(".")) ? import_node_path10.default.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
|
|
15141
15334
|
};
|
|
15142
15335
|
const accessorFlags = accessor ? ["-include", accessorHeader] : [];
|
|
15143
|
-
let nativeC =
|
|
15336
|
+
let nativeC = !roots2.length && !entries.some(([file]) => file.endsWith(".swift")) && !units.some(([file]) => /\.mm?$/.test(file));
|
|
15144
15337
|
if (roots2.length) {
|
|
15145
15338
|
const sourceHeaders = import_node_path10.default.join(
|
|
15146
15339
|
layout.root,
|
|
@@ -15239,7 +15432,13 @@ export *
|
|
|
15239
15432
|
)
|
|
15240
15433
|
];
|
|
15241
15434
|
const cxx = /\.(?:cc|cpp|cxx|mm)$/.test(file);
|
|
15242
|
-
const identity = (0, import_node_crypto7.createHash)("sha256").update(
|
|
15435
|
+
const identity = (0, import_node_crypto7.createHash)("sha256").update(
|
|
15436
|
+
JSON.stringify([
|
|
15437
|
+
cxx,
|
|
15438
|
+
perFile,
|
|
15439
|
+
...nativeC && !roots2.length ? [(consumers.get(file)?.size ?? 0) > 0] : []
|
|
15440
|
+
])
|
|
15441
|
+
).digest("hex").slice(0, 12);
|
|
15243
15442
|
const group = groups.get(identity) ?? {
|
|
15244
15443
|
name: `${target.name}${nativeC ? "Native" : "Swift"}Implementation_${identity}`,
|
|
15245
15444
|
sources: [],
|
|
@@ -15274,6 +15473,31 @@ export *
|
|
|
15274
15473
|
accessor.body
|
|
15275
15474
|
);
|
|
15276
15475
|
}
|
|
15476
|
+
if (nativeC && !roots2.length) {
|
|
15477
|
+
const lateSources = new Set(late.map(([file]) => unitSource(file)));
|
|
15478
|
+
const owner = [...groups.values()].find(
|
|
15479
|
+
(group) => group.sources.every((source) => !lateSources.has(source))
|
|
15480
|
+
);
|
|
15481
|
+
const implementations = [...groups.values()].filter((group) => group !== owner);
|
|
15482
|
+
native.set(target.name, {
|
|
15483
|
+
path: target.path,
|
|
15484
|
+
includeDirectory: include2,
|
|
15485
|
+
sources: owner?.sources ?? [],
|
|
15486
|
+
lateSources: implementations.flatMap((group) => group.sources),
|
|
15487
|
+
flags: owner?.flags ?? flags,
|
|
15488
|
+
cxxFlags: owner?.cxxFlags ?? flags,
|
|
15489
|
+
...implementations.length ? {
|
|
15490
|
+
groups: implementations,
|
|
15491
|
+
late: {
|
|
15492
|
+
name: `${target.name}NativeImplementation`,
|
|
15493
|
+
producers: [
|
|
15494
|
+
...new Set(late.flatMap(([file]) => [...consumers.get(file)]))
|
|
15495
|
+
].sort()
|
|
15496
|
+
}
|
|
15497
|
+
} : {}
|
|
15498
|
+
});
|
|
15499
|
+
continue;
|
|
15500
|
+
}
|
|
15277
15501
|
if (nativeC) {
|
|
15278
15502
|
const modulemaps = Object.entries(settings.productHeaders).filter(
|
|
15279
15503
|
([product2]) => product2.endsWith("/Modules/module.modulemap")
|
|
@@ -15344,40 +15568,6 @@ export *
|
|
|
15344
15568
|
}
|
|
15345
15569
|
continue;
|
|
15346
15570
|
}
|
|
15347
|
-
const includes = `${prefix}include/`;
|
|
15348
|
-
const consumers = /* @__PURE__ */ new Map();
|
|
15349
|
-
const reverse = /* @__PURE__ */ new Map();
|
|
15350
|
-
for (const [file, contents] of entries) {
|
|
15351
|
-
const producers2 = /* @__PURE__ */ new Set();
|
|
15352
|
-
const source = contents.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
15353
|
-
for (const match of source.matchAll(
|
|
15354
|
-
/^\s*#\s*(?:include|import)\s*[<"]([^>"]+)[>"]/gm
|
|
15355
|
-
)) {
|
|
15356
|
-
const include2 = match[1];
|
|
15357
|
-
const producer = /(?:^|\/)([^/]+)-Swift\.h$/.exec(include2)?.[1];
|
|
15358
|
-
if (producer && targets.some((value) => value.name === producer))
|
|
15359
|
-
producers2.add(producer);
|
|
15360
|
-
const local = [
|
|
15361
|
-
import_node_path10.default.posix.join(import_node_path10.default.posix.dirname(file), include2),
|
|
15362
|
-
`${includes}${include2}`
|
|
15363
|
-
].find((candidate) => input.files[candidate] !== void 0);
|
|
15364
|
-
if (local) {
|
|
15365
|
-
reverse.set(local, [...reverse.get(local) ?? [], file]);
|
|
15366
|
-
}
|
|
15367
|
-
}
|
|
15368
|
-
consumers.set(file, producers2);
|
|
15369
|
-
}
|
|
15370
|
-
const queue = [...consumers.keys()].filter((file) => consumers.get(file).size > 0);
|
|
15371
|
-
for (let index = 0; index < queue.length; index++) {
|
|
15372
|
-
const file = queue[index];
|
|
15373
|
-
for (const parent of reverse.get(file) ?? []) {
|
|
15374
|
-
const inherited = consumers.get(parent);
|
|
15375
|
-
const before = inherited.size;
|
|
15376
|
-
for (const producer of consumers.get(file)) inherited.add(producer);
|
|
15377
|
-
if (before !== inherited.size) queue.push(parent);
|
|
15378
|
-
}
|
|
15379
|
-
}
|
|
15380
|
-
const late = units.filter(([file]) => consumers.get(file).size > 0);
|
|
15381
15571
|
native.set(target.name, {
|
|
15382
15572
|
path: target.path,
|
|
15383
15573
|
includeDirectory: import_node_path10.default.join(layout.root, includes),
|