peachsim 0.1.774 → 0.1.776
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/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 +1790 -810
- 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 +2158 -1165
- package/dist-lib/swift-compile.cjs +54 -15
- package/dist-lib/swift-compile.mjs +52 -15
- 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 +1404 -424
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/swift-compile.ts +65 -18
- package/src/swift-distribution.lock.json +11 -11
- package/src/swift-host.ts +60 -11
- package/src/swift-packages.ts +18 -3
- package/src/swift-standin-emit.ts +12 -5
- package/src/swift-standins.ts +546 -0
package/dist-lib/vite-swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.776 | (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;
|
|
@@ -16,9 +16,9 @@ var __export = (target, all) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __copyProps = (to, from, except, desc) => {
|
|
18
18
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
-
for (let
|
|
20
|
-
if (!__hasOwnProp.call(to,
|
|
21
|
-
__defProp(to,
|
|
19
|
+
for (let key2 of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key2) && key2 !== except)
|
|
21
|
+
__defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
|
|
22
22
|
}
|
|
23
23
|
return to;
|
|
24
24
|
};
|
|
@@ -66,7 +66,7 @@ var require_parse = __commonJS({
|
|
|
66
66
|
return plist2;
|
|
67
67
|
}
|
|
68
68
|
function parsePlistXML(node) {
|
|
69
|
-
var i, new_obj,
|
|
69
|
+
var i, new_obj, key2, val, new_arr, res, counter, type;
|
|
70
70
|
if (!node) return null;
|
|
71
71
|
if (node.nodeName === "plist") {
|
|
72
72
|
new_arr = [];
|
|
@@ -81,7 +81,7 @@ var require_parse = __commonJS({
|
|
|
81
81
|
return new_arr;
|
|
82
82
|
} else if (node.nodeName === "dict") {
|
|
83
83
|
new_obj = {};
|
|
84
|
-
|
|
84
|
+
key2 = null;
|
|
85
85
|
counter = 0;
|
|
86
86
|
if (isEmptyNode(node)) {
|
|
87
87
|
return new_obj;
|
|
@@ -93,18 +93,18 @@ var require_parse = __commonJS({
|
|
|
93
93
|
node.childNodes[i].nodeName === "key",
|
|
94
94
|
"Missing key while parsing <dict/>."
|
|
95
95
|
);
|
|
96
|
-
|
|
96
|
+
key2 = parsePlistXML(node.childNodes[i]);
|
|
97
97
|
} else {
|
|
98
98
|
invariant(
|
|
99
99
|
node.childNodes[i].nodeName !== "key",
|
|
100
100
|
'Unexpected key "' + parsePlistXML(node.childNodes[i]) + '" while parsing <dict/>.'
|
|
101
101
|
);
|
|
102
|
-
new_obj[
|
|
102
|
+
new_obj[key2] = parsePlistXML(node.childNodes[i]);
|
|
103
103
|
}
|
|
104
104
|
counter += 1;
|
|
105
105
|
}
|
|
106
106
|
if (counter % 2 === 1) {
|
|
107
|
-
new_obj[
|
|
107
|
+
new_obj[key2] = "";
|
|
108
108
|
}
|
|
109
109
|
return new_obj;
|
|
110
110
|
} else if (node.nodeName === "array") {
|
|
@@ -287,8 +287,8 @@ __export(vite_plugin_swift_exports, {
|
|
|
287
287
|
swiftPlugin: () => swiftPlugin
|
|
288
288
|
});
|
|
289
289
|
module.exports = __toCommonJS(vite_plugin_swift_exports);
|
|
290
|
-
var
|
|
291
|
-
var
|
|
290
|
+
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
291
|
+
var import_node_path15 = __toESM(require("node:path"), 1);
|
|
292
292
|
|
|
293
293
|
// ../sootsim-swift/src/entryModule.ts
|
|
294
294
|
function nativeExportLines(args, commonjs) {
|
|
@@ -401,12 +401,12 @@ var ARCHIVE = "wasi/lib_FoundationICU.a";
|
|
|
401
401
|
var MEMBER = "icu_packaged_data.cpp.obj";
|
|
402
402
|
var raw = /* @__PURE__ */ new Map();
|
|
403
403
|
var assets = /* @__PURE__ */ new Map();
|
|
404
|
-
function memo(cache,
|
|
405
|
-
let pending = cache.get(
|
|
404
|
+
function memo(cache, key2, load2) {
|
|
405
|
+
let pending = cache.get(key2);
|
|
406
406
|
if (!pending) {
|
|
407
407
|
pending = load2();
|
|
408
|
-
pending.catch(() => cache.delete(
|
|
409
|
-
cache.set(
|
|
408
|
+
pending.catch(() => cache.delete(key2));
|
|
409
|
+
cache.set(key2, pending);
|
|
410
410
|
}
|
|
411
411
|
return pending;
|
|
412
412
|
}
|
|
@@ -618,7 +618,7 @@ function swiftModuleSdk(root) {
|
|
|
618
618
|
}
|
|
619
619
|
function swiftModuleInputFiles(root) {
|
|
620
620
|
if (swiftDistributionAt(root)) return [SWIFT_DISTRIBUTION_MANIFEST];
|
|
621
|
-
const
|
|
621
|
+
const files2 = [
|
|
622
622
|
"Package.swift",
|
|
623
623
|
"scripts/contrast-app-Package.swift",
|
|
624
624
|
"toolchain.json"
|
|
@@ -629,16 +629,19 @@ function swiftModuleInputFiles(root) {
|
|
|
629
629
|
})) {
|
|
630
630
|
const relative = `${dir}/${entry.name}`;
|
|
631
631
|
if (entry.isDirectory()) walk2(relative);
|
|
632
|
-
else if (/\.(swift|c|cpp|h)$/.test(entry.name))
|
|
632
|
+
else if (/\.(swift|c|cpp|h)$/.test(entry.name)) files2.push(relative);
|
|
633
633
|
}
|
|
634
634
|
};
|
|
635
635
|
walk2("Sources");
|
|
636
|
-
return
|
|
636
|
+
return files2.sort();
|
|
637
637
|
}
|
|
638
|
-
|
|
638
|
+
function swiftMacroPlugins(moduleRoot) {
|
|
639
639
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
640
640
|
if (distribution)
|
|
641
|
-
return
|
|
641
|
+
return {
|
|
642
|
+
libraries: distribution.plugins.map((plugin) => import_node_path2.default.join(moduleRoot, plugin)),
|
|
643
|
+
stale: false
|
|
644
|
+
};
|
|
642
645
|
const dir = import_node_path2.default.join(moduleRoot, ".build/host/RnxPreviewMacros");
|
|
643
646
|
const ext = process.platform === "darwin" ? "dylib" : "so";
|
|
644
647
|
const plugins = [
|
|
@@ -651,23 +654,29 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin) {
|
|
|
651
654
|
source: import_node_path2.default.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift")
|
|
652
655
|
}
|
|
653
656
|
];
|
|
654
|
-
|
|
655
|
-
({ library
|
|
656
|
-
|
|
657
|
+
return {
|
|
658
|
+
libraries: plugins.map(({ library }) => library),
|
|
659
|
+
stale: plugins.some(
|
|
660
|
+
({ library, source }) => !(0, import_node_fs2.existsSync)(library) || (0, import_node_fs2.statSync)(source).mtimeMs > (0, import_node_fs2.statSync)(library).mtimeMs
|
|
661
|
+
)
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
async function ensureMacroPlugins(moduleRoot, toolchainBin) {
|
|
665
|
+
const { libraries, stale } = swiftMacroPlugins(moduleRoot);
|
|
657
666
|
if (stale) {
|
|
658
667
|
await run2("sh", [
|
|
659
668
|
import_node_path2.default.join(moduleRoot, "scripts/build-preview-plugin.sh"),
|
|
660
669
|
toolchainBin,
|
|
661
|
-
|
|
670
|
+
libraries[0]
|
|
662
671
|
]);
|
|
663
672
|
}
|
|
664
|
-
return
|
|
673
|
+
return libraries;
|
|
665
674
|
}
|
|
666
675
|
var linkedModuleDigests = /* @__PURE__ */ new Map();
|
|
667
676
|
function swiftModuleDigest(root) {
|
|
668
|
-
const
|
|
677
|
+
const files2 = swiftModuleInputFiles(root);
|
|
669
678
|
const stampHash = (0, import_node_crypto2.createHash)("sha256");
|
|
670
|
-
for (const file of
|
|
679
|
+
for (const file of files2) {
|
|
671
680
|
const stat = (0, import_node_fs2.statSync)(import_node_path2.default.join(root, file), { bigint: true });
|
|
672
681
|
stampHash.update(file);
|
|
673
682
|
stampHash.update(
|
|
@@ -679,7 +688,7 @@ function swiftModuleDigest(root) {
|
|
|
679
688
|
const cached = linkedModuleDigests.get(root);
|
|
680
689
|
if (cached?.stamp === stamp) return cached.digest;
|
|
681
690
|
const hash = (0, import_node_crypto2.createHash)("sha256");
|
|
682
|
-
for (const file of
|
|
691
|
+
for (const file of files2) {
|
|
683
692
|
hash.update((0, import_node_crypto2.createHash)("sha256").update(file).digest());
|
|
684
693
|
hash.update(
|
|
685
694
|
(0, import_node_crypto2.createHash)("sha256").update((0, import_node_fs2.readFileSync)(import_node_path2.default.join(root, file))).digest()
|
|
@@ -733,12 +742,21 @@ var OPTIONAL_FRAMEWORK_DEPENDENCIES = {
|
|
|
733
742
|
FBAEMKit: ["FBSDKCoreKit_Basics"],
|
|
734
743
|
FBSDKCoreKit_Basics: [],
|
|
735
744
|
Intercom: [],
|
|
745
|
+
FirebaseCore: [],
|
|
746
|
+
FirebaseSharedSwift: ["FirebaseCore"],
|
|
747
|
+
FirebaseFirestoreInternal: ["FirebaseCore"],
|
|
748
|
+
FirebaseAnalytics: ["FirebaseCore"],
|
|
749
|
+
FirebaseAppCheck: ["FirebaseCore"],
|
|
750
|
+
FirebaseAuth: ["FirebaseCore"],
|
|
751
|
+
FirebaseCrashlytics: ["FirebaseCore"],
|
|
752
|
+
FirebaseFirestore: ["FirebaseCore", "FirebaseSharedSwift", "FirebaseFirestoreInternal"],
|
|
753
|
+
FirebaseStorage: ["FirebaseCore"],
|
|
736
754
|
FBAudienceNetwork: []
|
|
737
755
|
};
|
|
738
756
|
var OPTIONAL_FRAMEWORKS = new Set(Object.keys(OPTIONAL_FRAMEWORK_DEPENDENCIES));
|
|
739
757
|
var SWIFT_IMPORT = /^\s*(?:@\w+(?:\([^)]*\))?\s+)*import\s+(?:(?:typealias|struct|class|enum|protocol|let|var|func)\s+)?([A-Za-z_][A-Za-z0-9_]*)/;
|
|
740
|
-
function swiftCondition(
|
|
741
|
-
const tokens =
|
|
758
|
+
function swiftCondition(text3, available) {
|
|
759
|
+
const tokens = text3.match(/\w+\s*\([^()]*\)|&&|\|\||!|\(|\)|\w+/g) ?? [];
|
|
742
760
|
let index = 0;
|
|
743
761
|
const atom = () => {
|
|
744
762
|
const token = tokens[index++];
|
|
@@ -816,20 +834,37 @@ function swiftPeachModules(moduleRoot) {
|
|
|
816
834
|
)
|
|
817
835
|
].map((match) => match[1]);
|
|
818
836
|
}
|
|
819
|
-
var
|
|
820
|
-
function
|
|
837
|
+
var sdkPaths = /* @__PURE__ */ new Map();
|
|
838
|
+
function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
821
839
|
const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
|
|
822
|
-
const
|
|
823
|
-
const cached =
|
|
840
|
+
const key2 = `${toolchainBin}\0${sdk}`;
|
|
841
|
+
const cached = sdkPaths.get(key2);
|
|
824
842
|
if (cached) return cached;
|
|
825
|
-
const modules = new Set(swiftPeachModules(moduleRoot));
|
|
826
843
|
const configuration = (0, import_node_child_process2.execFileSync)(
|
|
827
844
|
import_node_path2.default.join(toolchainBin, "swift"),
|
|
828
845
|
["sdk", "configure", "--show-configuration", sdk, "wasm32-unknown-wasip1"],
|
|
829
846
|
{ encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }
|
|
830
847
|
);
|
|
831
|
-
const
|
|
832
|
-
|
|
848
|
+
const field = (name) => {
|
|
849
|
+
const value = new RegExp(`^${name}:\\s*(.+)$`, "m").exec(configuration)?.[1]?.trim();
|
|
850
|
+
if (!value) throw new Error(`swift sdk ${sdk} reports no ${name}`);
|
|
851
|
+
return value;
|
|
852
|
+
};
|
|
853
|
+
const paths = {
|
|
854
|
+
sysroot: field("sdkRootPath"),
|
|
855
|
+
resources: field("swiftResourcesPath")
|
|
856
|
+
};
|
|
857
|
+
sdkPaths.set(key2, paths);
|
|
858
|
+
return paths;
|
|
859
|
+
}
|
|
860
|
+
var availableModules = /* @__PURE__ */ new Map();
|
|
861
|
+
function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
862
|
+
const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
|
|
863
|
+
const key2 = `${moduleRoot}\0${sdk}`;
|
|
864
|
+
const cached = availableModules.get(key2);
|
|
865
|
+
if (cached) return cached;
|
|
866
|
+
const modules = new Set(swiftPeachModules(moduleRoot));
|
|
867
|
+
const { resources } = swiftSdkPaths(moduleRoot, toolchainBin);
|
|
833
868
|
for (const entry of (0, import_node_fs2.readdirSync)(import_node_path2.default.join(resources, "wasi"))) {
|
|
834
869
|
if (entry.endsWith(".swiftmodule"))
|
|
835
870
|
modules.add(entry.slice(0, -".swiftmodule".length));
|
|
@@ -840,12 +875,12 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
840
875
|
for (const match of (0, import_node_fs2.readFileSync)(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
|
|
841
876
|
modules.add(match[1]);
|
|
842
877
|
}
|
|
843
|
-
availableModules.set(
|
|
878
|
+
availableModules.set(key2, modules);
|
|
844
879
|
return modules;
|
|
845
880
|
}
|
|
846
|
-
function missingSwiftModules(
|
|
881
|
+
function missingSwiftModules(files2, available) {
|
|
847
882
|
const missing = /* @__PURE__ */ new Map();
|
|
848
|
-
for (const [file, contents] of Object.entries(
|
|
883
|
+
for (const [file, contents] of Object.entries(files2)) {
|
|
849
884
|
if (!file.endsWith(".swift") || file === "Package.swift") continue;
|
|
850
885
|
for (const name of new Set(swiftImportNames(contents, available))) {
|
|
851
886
|
if (available.has(name)) continue;
|
|
@@ -854,13 +889,13 @@ function missingSwiftModules(files, available) {
|
|
|
854
889
|
}
|
|
855
890
|
return new Map([...missing].sort(([left], [right]) => left.localeCompare(right)));
|
|
856
891
|
}
|
|
857
|
-
function swiftTargetDependencies(
|
|
892
|
+
function swiftTargetDependencies(files2, targets) {
|
|
858
893
|
const names = /* @__PURE__ */ new Set([...OPTIONAL_FRAMEWORKS, ...targets.map((target) => target.name)]);
|
|
859
894
|
const siblings = /* @__PURE__ */ new Map();
|
|
860
895
|
for (const target of targets) {
|
|
861
896
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
862
897
|
const deps = /* @__PURE__ */ new Set();
|
|
863
|
-
for (const [file, contents] of Object.entries(
|
|
898
|
+
for (const [file, contents] of Object.entries(files2)) {
|
|
864
899
|
if (file === "Package.swift" || !file.startsWith(prefix)) continue;
|
|
865
900
|
if (targets.some(
|
|
866
901
|
(candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
|
|
@@ -876,7 +911,7 @@ function swiftTargetDependencies(files, targets) {
|
|
|
876
911
|
}
|
|
877
912
|
var ONE_PRODUCT = '.product(name: "One", package: "sootsim-swift")';
|
|
878
913
|
var SPRITEKIT_PRODUCT = '.product(name: "SpriteKit", package: "sootsim-swift")';
|
|
879
|
-
var importsSpriteKit = (
|
|
914
|
+
var importsSpriteKit = (files2) => Object.entries(files2).some(
|
|
880
915
|
([file, contents]) => file.endsWith(".swift") && swiftImportNames(contents).includes("SpriteKit")
|
|
881
916
|
);
|
|
882
917
|
var FOUNDATION_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "PeachObjC", "-Xfrontend", "-import-module", "-Xfrontend", "Dispatch", "-Xfrontend", "-import-module", "-Xfrontend", "FoundationNetworking", "-Xfrontend", "-import-module", "-Xfrontend", "WASILibc", "-Xfrontend", "-import-module", "-Xfrontend", "wasi_pthread"';
|
|
@@ -991,18 +1026,18 @@ function emitSwiftPackageManifest(args) {
|
|
|
991
1026
|
""
|
|
992
1027
|
].join("\n");
|
|
993
1028
|
}
|
|
994
|
-
function syncSwiftTree(base,
|
|
1029
|
+
function syncSwiftTree(base, files2) {
|
|
995
1030
|
(0, import_node_fs2.mkdirSync)(base, { recursive: true });
|
|
996
1031
|
const walk2 = (dir) => {
|
|
997
1032
|
for (const entry of (0, import_node_fs2.readdirSync)(dir, { withFileTypes: true })) {
|
|
998
1033
|
const full = import_node_path2.default.join(dir, entry.name);
|
|
999
1034
|
if (dir === base && entry.name === ".build") continue;
|
|
1000
1035
|
if (entry.isDirectory()) walk2(full);
|
|
1001
|
-
else if (!
|
|
1036
|
+
else if (!files2.has(full)) (0, import_node_fs2.rmSync)(full, { force: true });
|
|
1002
1037
|
}
|
|
1003
1038
|
};
|
|
1004
1039
|
walk2(base);
|
|
1005
|
-
for (const [full, contents] of
|
|
1040
|
+
for (const [full, contents] of files2) {
|
|
1006
1041
|
if ((0, import_node_fs2.existsSync)(full) && (0, import_node_fs2.readFileSync)(full, "utf8") === contents) continue;
|
|
1007
1042
|
(0, import_node_fs2.mkdirSync)(import_node_path2.default.dirname(full), { recursive: true });
|
|
1008
1043
|
(0, import_node_fs2.writeFileSync)(full, contents, "utf8");
|
|
@@ -1028,21 +1063,21 @@ var CLASS_DECL = /^class\s+(?!(?:func|var|let|subscript)\b)([A-Za-z_]\w*)/;
|
|
|
1028
1063
|
var MODIFIERS = /(?:^|\s)(public|open|internal|fileprivate|private|final|nonisolated|@MainActor)(?=\s)/g;
|
|
1029
1064
|
var OVERRIDE_FUNC = /^override((?:\s+(?:public|open|internal|fileprivate|private|final|nonisolated|dynamic|@\w+))*)\s+func\s+([A-Za-z_]\w*)\s*(<[^>{}]*>)?\s*\(/;
|
|
1030
1065
|
var OVERRIDE_VAR = /^override((?:\s+(?:public|open|internal|fileprivate|private|final|nonisolated|dynamic|@\w+))*)\s+var\s+([A-Za-z_]\w*)\s*:\s*([^{=]+?)\s*\{/;
|
|
1031
|
-
function splitTopLevel(
|
|
1066
|
+
function splitTopLevel(text3) {
|
|
1032
1067
|
const parts = [];
|
|
1033
1068
|
let depth = 0;
|
|
1034
1069
|
let start = 0;
|
|
1035
|
-
for (let i = 0; i <
|
|
1036
|
-
const char =
|
|
1070
|
+
for (let i = 0; i < text3.length; i++) {
|
|
1071
|
+
const char = text3[i];
|
|
1037
1072
|
if (char === "(" || char === "[" || char === "<") depth++;
|
|
1038
|
-
else if (char === ")" || char === "]" || char === ">" &&
|
|
1073
|
+
else if (char === ")" || char === "]" || char === ">" && text3[i - 1] !== "-")
|
|
1039
1074
|
depth--;
|
|
1040
1075
|
else if (char === "," && depth === 0) {
|
|
1041
|
-
parts.push(
|
|
1076
|
+
parts.push(text3.slice(start, i));
|
|
1042
1077
|
start = i + 1;
|
|
1043
1078
|
}
|
|
1044
1079
|
}
|
|
1045
|
-
parts.push(
|
|
1080
|
+
parts.push(text3.slice(start));
|
|
1046
1081
|
return parts.map((part) => part.trim()).filter((part) => part !== "");
|
|
1047
1082
|
}
|
|
1048
1083
|
function forwardedArguments(parameters) {
|
|
@@ -1758,7 +1793,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
1758
1793
|
resources: false
|
|
1759
1794
|
}
|
|
1760
1795
|
] : compileTargets(input);
|
|
1761
|
-
const
|
|
1796
|
+
const files2 = /* @__PURE__ */ new Map();
|
|
1762
1797
|
const modulePlan = (0, import_node_crypto2.createHash)("sha256").update(
|
|
1763
1798
|
swiftModuleInputFiles(moduleRoot).join("\n")
|
|
1764
1799
|
);
|
|
@@ -1780,7 +1815,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
1780
1815
|
if (targets.length === 0) {
|
|
1781
1816
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
1782
1817
|
if (file === "Package.swift") continue;
|
|
1783
|
-
|
|
1818
|
+
files2.set(
|
|
1784
1819
|
import_node_path2.default.join(layout.sources, file),
|
|
1785
1820
|
compiledSource(file, contents, objcExtensions)
|
|
1786
1821
|
);
|
|
@@ -1824,14 +1859,14 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
1824
1859
|
manifest = manifest.replace(anchor, `${anchor}
|
|
1825
1860
|
${SPRITEKIT_PRODUCT},`);
|
|
1826
1861
|
}
|
|
1827
|
-
|
|
1862
|
+
files2.set(import_node_path2.default.join(layout.root, "Package.swift"), manifest + moduleFiles);
|
|
1828
1863
|
} else {
|
|
1829
1864
|
const base = layout.multi ? layout.root : layout.sources;
|
|
1830
1865
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
1831
1866
|
if (file === "Package.swift") continue;
|
|
1832
|
-
|
|
1867
|
+
files2.set(import_node_path2.default.join(base, file), compiledSource(file, contents, objcExtensions));
|
|
1833
1868
|
}
|
|
1834
|
-
|
|
1869
|
+
files2.set(
|
|
1835
1870
|
import_node_path2.default.join(layout.root, "Package.swift"),
|
|
1836
1871
|
emitSwiftPackageManifest({
|
|
1837
1872
|
targets,
|
|
@@ -1849,7 +1884,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
1849
1884
|
for (const target of resourceTargets) {
|
|
1850
1885
|
if (!target.resources) continue;
|
|
1851
1886
|
const directory = layout.multi ? import_node_path2.default.join(layout.root, target.path) : layout.sources;
|
|
1852
|
-
|
|
1887
|
+
files2.set(
|
|
1853
1888
|
import_node_path2.default.join(directory, "ResourceBundleAccessor.generated.swift"),
|
|
1854
1889
|
[
|
|
1855
1890
|
"import Foundation",
|
|
@@ -1861,7 +1896,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
1861
1896
|
].join("\n")
|
|
1862
1897
|
);
|
|
1863
1898
|
}
|
|
1864
|
-
syncSwiftTree(layout.root,
|
|
1899
|
+
syncSwiftTree(layout.root, files2);
|
|
1865
1900
|
}
|
|
1866
1901
|
function streamText(value) {
|
|
1867
1902
|
if (typeof value === "string") return value.trim();
|
|
@@ -1975,10 +2010,10 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
1975
2010
|
}
|
|
1976
2011
|
|
|
1977
2012
|
// src/swift-host.ts
|
|
1978
|
-
var
|
|
1979
|
-
var
|
|
1980
|
-
var
|
|
1981
|
-
var
|
|
2013
|
+
var import_node_crypto7 = require("node:crypto");
|
|
2014
|
+
var import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
2015
|
+
var import_node_os8 = __toESM(require("node:os"), 1);
|
|
2016
|
+
var import_node_path14 = __toESM(require("node:path"), 1);
|
|
1982
2017
|
|
|
1983
2018
|
// ../sootsim-swift/src/bundleAssets.ts
|
|
1984
2019
|
var import_svgpath = __toESM(require("svgpath"), 1);
|
|
@@ -2012,14 +2047,14 @@ function pickImagesetFile(images) {
|
|
|
2012
2047
|
scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
|
|
2013
2048
|
};
|
|
2014
2049
|
}
|
|
2015
|
-
function flatScale(
|
|
2016
|
-
const match = /@([23])x\.[^./]+$/.exec(
|
|
2050
|
+
function flatScale(path15) {
|
|
2051
|
+
const match = /@([23])x\.[^./]+$/.exec(path15);
|
|
2017
2052
|
return match ? Number(match[1]) : 1;
|
|
2018
2053
|
}
|
|
2019
|
-
function providesNamespace(
|
|
2020
|
-
if (
|
|
2054
|
+
function providesNamespace(text3) {
|
|
2055
|
+
if (text3 === null) return false;
|
|
2021
2056
|
try {
|
|
2022
|
-
const parsed = JSON.parse(
|
|
2057
|
+
const parsed = JSON.parse(text3);
|
|
2023
2058
|
return parsed?.properties?.["provides-namespace"] === true;
|
|
2024
2059
|
} catch {
|
|
2025
2060
|
return false;
|
|
@@ -2027,9 +2062,9 @@ function providesNamespace(text2) {
|
|
|
2027
2062
|
}
|
|
2028
2063
|
function catalogEntryName(contentsPath, kind, readText) {
|
|
2029
2064
|
const parts = contentsPath.split("/");
|
|
2030
|
-
const
|
|
2031
|
-
if (!
|
|
2032
|
-
const short =
|
|
2065
|
+
const leaf2 = parts[parts.length - 2] ?? "";
|
|
2066
|
+
if (!leaf2.endsWith(kind)) return null;
|
|
2067
|
+
const short = leaf2.slice(0, -kind.length) || null;
|
|
2033
2068
|
if (short === null) return null;
|
|
2034
2069
|
const segments = [short];
|
|
2035
2070
|
for (let depth = parts.length - 3; depth >= 0; depth -= 1) {
|
|
@@ -2040,21 +2075,21 @@ function catalogEntryName(contentsPath, kind, readText) {
|
|
|
2040
2075
|
}
|
|
2041
2076
|
return segments.join("/");
|
|
2042
2077
|
}
|
|
2043
|
-
function isFlatResourceImage(
|
|
2044
|
-
return
|
|
2078
|
+
function isFlatResourceImage(path15) {
|
|
2079
|
+
return path15.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path15));
|
|
2045
2080
|
}
|
|
2046
2081
|
function enumerateBundleImages(paths, readText) {
|
|
2047
2082
|
const table = [];
|
|
2048
2083
|
const seen = /* @__PURE__ */ new Set();
|
|
2049
|
-
const catalogs = paths.filter((
|
|
2084
|
+
const catalogs = paths.filter((path15) => baseOf(path15) === "Contents.json");
|
|
2050
2085
|
for (const contentsPath of catalogs) {
|
|
2051
2086
|
const name = catalogEntryName(contentsPath, ".imageset", readText);
|
|
2052
2087
|
if (name === null || seen.has(name)) continue;
|
|
2053
2088
|
let parsed;
|
|
2054
2089
|
try {
|
|
2055
|
-
const
|
|
2056
|
-
if (
|
|
2057
|
-
parsed = JSON.parse(
|
|
2090
|
+
const text3 = readText(contentsPath);
|
|
2091
|
+
if (text3 === null) continue;
|
|
2092
|
+
parsed = JSON.parse(text3);
|
|
2058
2093
|
} catch {
|
|
2059
2094
|
continue;
|
|
2060
2095
|
}
|
|
@@ -2067,12 +2102,12 @@ function enumerateBundleImages(paths, readText) {
|
|
|
2067
2102
|
seen.add(name);
|
|
2068
2103
|
table.push({ name, file: `${dir}/${pick.filename}`, scale: pick.scale });
|
|
2069
2104
|
}
|
|
2070
|
-
for (const
|
|
2071
|
-
if (!isFlatResourceImage(
|
|
2072
|
-
const name = baseOf(
|
|
2105
|
+
for (const path15 of paths) {
|
|
2106
|
+
if (!isFlatResourceImage(path15)) continue;
|
|
2107
|
+
const name = baseOf(path15).slice(0, -extOf(path15).length);
|
|
2073
2108
|
if (name === "" || seen.has(name)) continue;
|
|
2074
2109
|
seen.add(name);
|
|
2075
|
-
table.push({ name, file:
|
|
2110
|
+
table.push({ name, file: path15, scale: flatScale(path15) });
|
|
2076
2111
|
}
|
|
2077
2112
|
return table;
|
|
2078
2113
|
}
|
|
@@ -2092,7 +2127,7 @@ function colorsetValue(color) {
|
|
|
2092
2127
|
const components = Reflect.get(color, "components");
|
|
2093
2128
|
if (typeof components !== "object" || components === null) return null;
|
|
2094
2129
|
const [red, green, blue, alpha] = ["red", "green", "blue", "alpha"].map(
|
|
2095
|
-
(
|
|
2130
|
+
(key2) => colorComponent(Reflect.get(components, key2))
|
|
2096
2131
|
);
|
|
2097
2132
|
if (red === null || green === null || blue === null || alpha === null) return null;
|
|
2098
2133
|
if (![red, green, blue].every((value) => value >= 0 && value <= 1)) return null;
|
|
@@ -2101,14 +2136,14 @@ function colorsetValue(color) {
|
|
|
2101
2136
|
}
|
|
2102
2137
|
function enumerateBundleColors(paths, readText) {
|
|
2103
2138
|
const table = {};
|
|
2104
|
-
for (const contentsPath of paths.filter((
|
|
2139
|
+
for (const contentsPath of paths.filter((path15) => baseOf(path15) === "Contents.json")) {
|
|
2105
2140
|
const name = catalogEntryName(contentsPath, ".colorset", readText);
|
|
2106
2141
|
if (name === null || name in table) continue;
|
|
2107
2142
|
let colors;
|
|
2108
2143
|
try {
|
|
2109
|
-
const
|
|
2110
|
-
if (
|
|
2111
|
-
colors = Reflect.get(JSON.parse(
|
|
2144
|
+
const text3 = readText(contentsPath);
|
|
2145
|
+
if (text3 === null) continue;
|
|
2146
|
+
colors = Reflect.get(JSON.parse(text3), "colors");
|
|
2112
2147
|
} catch {
|
|
2113
2148
|
continue;
|
|
2114
2149
|
}
|
|
@@ -2166,8 +2201,8 @@ function axisExtremes(points) {
|
|
|
2166
2201
|
function pathBounds(d) {
|
|
2167
2202
|
const xs = [];
|
|
2168
2203
|
const ys = [];
|
|
2169
|
-
for (const
|
|
2170
|
-
(0, import_svgpath.default)(
|
|
2204
|
+
for (const path15 of d)
|
|
2205
|
+
(0, import_svgpath.default)(path15).abs().unshort().unarc().iterate((segment, _index, x, y) => {
|
|
2171
2206
|
const [command, ...args] = segment;
|
|
2172
2207
|
if (command === "M" || command === "L") {
|
|
2173
2208
|
xs.push(Number(args[0]));
|
|
@@ -2194,7 +2229,7 @@ function guide(svg, id, axis) {
|
|
|
2194
2229
|
}
|
|
2195
2230
|
function enumerateBundleSymbols(paths, readText) {
|
|
2196
2231
|
const table = {};
|
|
2197
|
-
for (const contentsPath of paths.filter((
|
|
2232
|
+
for (const contentsPath of paths.filter((path15) => baseOf(path15) === "Contents.json")) {
|
|
2198
2233
|
const name = catalogEntryName(contentsPath, ".symbolset", readText);
|
|
2199
2234
|
if (name === null || name in table) continue;
|
|
2200
2235
|
let symbols;
|
|
@@ -2227,8 +2262,8 @@ function enumerateBundleSymbols(paths, readText) {
|
|
|
2227
2262
|
viewBox: "0 0 24 24",
|
|
2228
2263
|
advance,
|
|
2229
2264
|
box: [12 - advance / 2, 12 - tall / 2, advance, tall],
|
|
2230
|
-
layers: d.map((
|
|
2231
|
-
d: (0, import_svgpath.default)(
|
|
2265
|
+
layers: d.map((path15) => ({
|
|
2266
|
+
d: (0, import_svgpath.default)(path15).abs().scale(scale).translate(translateX, translateY).round(3).toString()
|
|
2232
2267
|
}))
|
|
2233
2268
|
};
|
|
2234
2269
|
}
|
|
@@ -2238,7 +2273,7 @@ function enumerateBundleJson(paths) {
|
|
|
2238
2273
|
const found = [];
|
|
2239
2274
|
const seen = /* @__PURE__ */ new Set();
|
|
2240
2275
|
const ordered = [...paths].filter(
|
|
2241
|
-
(
|
|
2276
|
+
(path15) => path15.split("/").includes("Resources") && path15.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path15) === ".json" || extOf(path15) === ".xcstrings")
|
|
2242
2277
|
).sort((a, b) => {
|
|
2243
2278
|
const aDepth = a.split("/").length;
|
|
2244
2279
|
const bDepth = b.split("/").length;
|
|
@@ -2943,24 +2978,24 @@ function runExtractor(command, args) {
|
|
|
2943
2978
|
|
|
2944
2979
|
// src/swift-distribution.lock.json
|
|
2945
2980
|
var swift_distribution_lock_default = {
|
|
2946
|
-
id: "
|
|
2981
|
+
id: "487239d0e061dfaa",
|
|
2947
2982
|
release: "swift-6.3-RELEASE",
|
|
2948
|
-
wasmSdkId: "swift-6.3-RELEASE_wasm-peach-41921598-peach-
|
|
2949
|
-
wasmSdkUrl: "https://r2.sootsim.com/swift-wasm-sdk/swift-6.3-RELEASE_wasm-peach-41921598-peach-
|
|
2950
|
-
wasmSdkChecksum: "
|
|
2951
|
-
source: "
|
|
2983
|
+
wasmSdkId: "swift-6.3-RELEASE_wasm-peach-41921598-peach-209157d6",
|
|
2984
|
+
wasmSdkUrl: "https://r2.sootsim.com/swift-wasm-sdk/swift-6.3-RELEASE_wasm-peach-41921598-peach-209157d6.artifactbundle.tar.gz",
|
|
2985
|
+
wasmSdkChecksum: "2b291ff21683ba1063c7362fd5a244fe22af704315f20563abd68c8b4a19b089",
|
|
2986
|
+
source: "a3d70fe1a5bcc462e1362c11285327d180e54e28",
|
|
2952
2987
|
hosts: {
|
|
2953
2988
|
"darwin-arm64": {
|
|
2954
|
-
sha256: "
|
|
2955
|
-
size:
|
|
2989
|
+
sha256: "361390f1d2f9fee9577fc2253ce67ad40b09bb7946e8e6f3e034f3dc6670fd5b",
|
|
2990
|
+
size: 31682452
|
|
2956
2991
|
},
|
|
2957
2992
|
"linux-x64": {
|
|
2958
|
-
sha256: "
|
|
2959
|
-
size:
|
|
2993
|
+
sha256: "d36ab74f444591458f72dc1d0c3c4032ee1620585a12ce3635fbd6adb8c9a0c8",
|
|
2994
|
+
size: 31688001
|
|
2960
2995
|
},
|
|
2961
2996
|
"linux-arm64": {
|
|
2962
|
-
sha256: "
|
|
2963
|
-
size:
|
|
2997
|
+
sha256: "b3f167eb3cbfcf06f1ccf43e3b2cdd94c1a949a0d5ffea03a065a724d306caea",
|
|
2998
|
+
size: 31686984
|
|
2964
2999
|
}
|
|
2965
3000
|
}
|
|
2966
3001
|
};
|
|
@@ -3123,12 +3158,12 @@ var evaluated = /* @__PURE__ */ new Map();
|
|
|
3123
3158
|
function dump(dir) {
|
|
3124
3159
|
const manifests = import_node_fs8.default.readdirSync(dir).filter((name) => /^Package(@swift-[\d.]+)?\.swift$/.test(name)).sort();
|
|
3125
3160
|
const command = swiftCommand();
|
|
3126
|
-
const
|
|
3161
|
+
const key2 = (0, import_node_crypto5.createHash)("sha256").update(JSON.stringify([command, import_node_path9.default.resolve(dir)])).update(
|
|
3127
3162
|
manifests.map((name) => `${name}\0${import_node_fs8.default.readFileSync(import_node_path9.default.join(dir, name), "utf8")}`).join("\0")
|
|
3128
3163
|
).digest("hex").slice(0, 32);
|
|
3129
|
-
const cached = import_node_path9.default.join(cacheDir2, `${
|
|
3164
|
+
const cached = import_node_path9.default.join(cacheDir2, `${key2}.json`);
|
|
3130
3165
|
if (import_node_fs8.default.existsSync(cached))
|
|
3131
|
-
return { key, raw: record(JSON.parse(import_node_fs8.default.readFileSync(cached, "utf8"))) };
|
|
3166
|
+
return { key: key2, raw: record(JSON.parse(import_node_fs8.default.readFileSync(cached, "utf8"))) };
|
|
3132
3167
|
let output;
|
|
3133
3168
|
try {
|
|
3134
3169
|
output = (0, import_node_child_process5.execFileSync)(
|
|
@@ -3140,7 +3175,7 @@ function dump(dir) {
|
|
|
3140
3175
|
dir,
|
|
3141
3176
|
// swiftpm's scratch files never land in the app's own package
|
|
3142
3177
|
"--scratch-path",
|
|
3143
|
-
import_node_path9.default.join(cacheDir2, `${
|
|
3178
|
+
import_node_path9.default.join(cacheDir2, `${key2}.build`),
|
|
3144
3179
|
"dump-package"
|
|
3145
3180
|
],
|
|
3146
3181
|
{
|
|
@@ -3157,7 +3192,7 @@ function dump(dir) {
|
|
|
3157
3192
|
}
|
|
3158
3193
|
import_node_fs8.default.mkdirSync(cacheDir2, { recursive: true });
|
|
3159
3194
|
import_node_fs8.default.writeFileSync(cached, output);
|
|
3160
|
-
return { key, raw: record(JSON.parse(output)) };
|
|
3195
|
+
return { key: key2, raw: record(JSON.parse(output)) };
|
|
3161
3196
|
}
|
|
3162
3197
|
function defaultTraits(manifest) {
|
|
3163
3198
|
const traits = new Map(
|
|
@@ -3185,8 +3220,8 @@ function linksOnIOS(condition, traits) {
|
|
|
3185
3220
|
}
|
|
3186
3221
|
function swiftPackageManifest(dir) {
|
|
3187
3222
|
dir = import_node_fs8.default.realpathSync(dir);
|
|
3188
|
-
const { key, raw: raw2 } = dump(dir);
|
|
3189
|
-
const known = evaluated.get(
|
|
3223
|
+
const { key: key2, raw: raw2 } = dump(dir);
|
|
3224
|
+
const known = evaluated.get(key2);
|
|
3190
3225
|
if (known) return known;
|
|
3191
3226
|
const traits = defaultTraits(raw2);
|
|
3192
3227
|
const tools = Number(
|
|
@@ -3279,7 +3314,7 @@ function swiftPackageManifest(dir) {
|
|
|
3279
3314
|
});
|
|
3280
3315
|
}
|
|
3281
3316
|
const manifest = { dir, products, targets, packages };
|
|
3282
|
-
evaluated.set(
|
|
3317
|
+
evaluated.set(key2, manifest);
|
|
3283
3318
|
return manifest;
|
|
3284
3319
|
}
|
|
3285
3320
|
var within = (file, roots) => roots.some((root) => file === root || file.startsWith(`${root}${import_node_path9.default.sep}`));
|
|
@@ -3329,8 +3364,8 @@ function readPins(resolved) {
|
|
|
3329
3364
|
var verified2 = /* @__PURE__ */ new Set();
|
|
3330
3365
|
function checkout(checkouts, identity, pin) {
|
|
3331
3366
|
const dir = import_node_path10.default.join(checkouts, identity);
|
|
3332
|
-
const
|
|
3333
|
-
if (verified2.has(
|
|
3367
|
+
const key2 = `${dir}\0${pin.revision}`;
|
|
3368
|
+
if (verified2.has(key2)) return dir;
|
|
3334
3369
|
const git = (...args) => (0, import_node_child_process6.execFileSync)("git", ["-C", dir, ...args], {
|
|
3335
3370
|
encoding: "utf8",
|
|
3336
3371
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -3351,7 +3386,7 @@ function checkout(checkouts, identity, pin) {
|
|
|
3351
3386
|
);
|
|
3352
3387
|
}
|
|
3353
3388
|
}
|
|
3354
|
-
verified2.add(
|
|
3389
|
+
verified2.add(key2);
|
|
3355
3390
|
return dir;
|
|
3356
3391
|
}
|
|
3357
3392
|
function resolveSwiftPackages(options) {
|
|
@@ -3367,12 +3402,12 @@ function resolveSwiftPackages(options) {
|
|
|
3367
3402
|
const checkouts = import_node_path10.default.join(rootDir, REMOTE_CHECKOUTS);
|
|
3368
3403
|
const packages = /* @__PURE__ */ new Map();
|
|
3369
3404
|
const load2 = (source) => {
|
|
3370
|
-
const
|
|
3371
|
-
const cached = packages.get(
|
|
3405
|
+
const key2 = source.kind === "local" ? import_node_path10.default.resolve(source.dir) : source.url;
|
|
3406
|
+
const cached = packages.get(key2);
|
|
3372
3407
|
if (cached !== void 0) return cached;
|
|
3373
3408
|
let loaded2;
|
|
3374
3409
|
if (source.kind === "local") {
|
|
3375
|
-
loaded2 = { source:
|
|
3410
|
+
loaded2 = { source: key2, remote: false, manifest: swiftPackageManifest(key2) };
|
|
3376
3411
|
} else {
|
|
3377
3412
|
const identity = swiftPackageIdentity(source.url);
|
|
3378
3413
|
const pin = pins?.get(identity);
|
|
@@ -3388,24 +3423,27 @@ function resolveSwiftPackages(options) {
|
|
|
3388
3423
|
};
|
|
3389
3424
|
}
|
|
3390
3425
|
}
|
|
3391
|
-
packages.set(
|
|
3426
|
+
packages.set(key2, loaded2);
|
|
3392
3427
|
return loaded2;
|
|
3393
3428
|
};
|
|
3394
3429
|
const targets = /* @__PURE__ */ new Map();
|
|
3395
3430
|
const targetOutcomes = /* @__PURE__ */ new Map();
|
|
3396
3431
|
const resolveTarget = (pkg, name) => {
|
|
3397
|
-
const
|
|
3398
|
-
if (targetOutcomes.has(
|
|
3399
|
-
targetOutcomes.set(
|
|
3432
|
+
const key2 = `${pkg.manifest.dir}\0${name}`;
|
|
3433
|
+
if (targetOutcomes.has(key2)) return targetOutcomes.get(key2);
|
|
3434
|
+
targetOutcomes.set(key2, null);
|
|
3400
3435
|
const outcome = (() => {
|
|
3401
3436
|
if (provided.has(name)) return null;
|
|
3402
3437
|
const target = pkg.manifest.targets.get(name);
|
|
3403
3438
|
if (!target) return `${import_node_path10.default.basename(pkg.manifest.dir)} declares no target ${name}`;
|
|
3404
|
-
if (target.type === "binary")
|
|
3439
|
+
if (target.type === "binary") {
|
|
3440
|
+
const gap = options.binaryGaps?.get(name);
|
|
3441
|
+
return `${name} ${BINARY}${gap ? `; ${gap}` : ""}`;
|
|
3442
|
+
}
|
|
3405
3443
|
if (target.type === "system") return `${name} is a system C library`;
|
|
3406
3444
|
if (target.type !== "regular") return `${name} is a ${target.type} target`;
|
|
3407
|
-
const
|
|
3408
|
-
if (
|
|
3445
|
+
const files2 = swiftTargetFiles(pkg.manifest, target);
|
|
3446
|
+
if (files2.some((file) => C_FAMILY.test(file)))
|
|
3409
3447
|
return `${name} is a C or Objective-C target`;
|
|
3410
3448
|
const reasons = target.dependencies.map((dependency) => {
|
|
3411
3449
|
if (dependency.kind === "target") return resolveTarget(pkg, dependency.name);
|
|
@@ -3414,12 +3452,12 @@ function resolveSwiftPackages(options) {
|
|
|
3414
3452
|
});
|
|
3415
3453
|
const blocked = blocker(reasons);
|
|
3416
3454
|
if (blocked) return blocked;
|
|
3417
|
-
const relative =
|
|
3455
|
+
const relative = files2.map((file) => import_node_path10.default.relative(target.dir, file));
|
|
3418
3456
|
targets.set(`${pkg.manifest.dir}\0${name}`, {
|
|
3419
3457
|
name,
|
|
3420
3458
|
path: "",
|
|
3421
3459
|
dir: target.dir,
|
|
3422
|
-
files,
|
|
3460
|
+
files: files2,
|
|
3423
3461
|
packageDir: pkg.manifest.dir,
|
|
3424
3462
|
remote: pkg.remote,
|
|
3425
3463
|
executable: false,
|
|
@@ -3429,7 +3467,7 @@ function resolveSwiftPackages(options) {
|
|
|
3429
3467
|
});
|
|
3430
3468
|
return null;
|
|
3431
3469
|
})();
|
|
3432
|
-
targetOutcomes.set(
|
|
3470
|
+
targetOutcomes.set(key2, outcome);
|
|
3433
3471
|
return outcome;
|
|
3434
3472
|
};
|
|
3435
3473
|
const productOutcomes = /* @__PURE__ */ new Map();
|
|
@@ -3476,23 +3514,24 @@ function resolveSwiftPackages(options) {
|
|
|
3476
3514
|
target: name,
|
|
3477
3515
|
source: pkg.source,
|
|
3478
3516
|
url: target.url,
|
|
3479
|
-
dir: target.dir
|
|
3517
|
+
dir: target.dir,
|
|
3518
|
+
reached: false
|
|
3480
3519
|
});
|
|
3481
3520
|
const reason = resolveTarget(pkg, name);
|
|
3482
3521
|
if (reason && !result.modules.has(name))
|
|
3483
3522
|
result.modules.set(name, { source: pkg.source, reason });
|
|
3484
3523
|
}
|
|
3485
3524
|
}
|
|
3486
|
-
for (const [
|
|
3487
|
-
const product =
|
|
3525
|
+
for (const [key2, { pkg, reason }] of productOutcomes) {
|
|
3526
|
+
const product = key2.slice(key2.indexOf("\0") + 1);
|
|
3488
3527
|
if (reason && !result.modules.has(product))
|
|
3489
3528
|
result.modules.set(product, { source: pkg.source, reason });
|
|
3490
3529
|
}
|
|
3491
3530
|
const reached = /* @__PURE__ */ new Set();
|
|
3492
3531
|
const reach = (pkg, name) => {
|
|
3493
|
-
const
|
|
3494
|
-
if (reached.has(
|
|
3495
|
-
reached.add(
|
|
3532
|
+
const key2 = `${pkg.manifest.dir}\0${name}`;
|
|
3533
|
+
if (reached.has(key2)) return;
|
|
3534
|
+
reached.add(key2);
|
|
3496
3535
|
for (const dependency of pkg.manifest.targets.get(name)?.dependencies ?? []) {
|
|
3497
3536
|
if (dependency.kind === "target") reach(pkg, dependency.name);
|
|
3498
3537
|
else {
|
|
@@ -3509,9 +3548,920 @@ function resolveSwiftPackages(options) {
|
|
|
3509
3548
|
if (!pkg || typeof pkg === "string") continue;
|
|
3510
3549
|
for (const root of pkg.manifest.products.get(product) ?? []) reach(pkg, root);
|
|
3511
3550
|
}
|
|
3512
|
-
|
|
3551
|
+
for (const binary of result.binaries) {
|
|
3552
|
+
const pkg = packages.get(binary.source);
|
|
3553
|
+
if (pkg && typeof pkg !== "string")
|
|
3554
|
+
binary.reached = reached.has(`${pkg.manifest.dir}\0${binary.target}`);
|
|
3555
|
+
}
|
|
3556
|
+
result.targets = [...targets.entries()].filter(([key2]) => reached.has(key2)).map(([, target]) => target);
|
|
3557
|
+
return result;
|
|
3558
|
+
}
|
|
3559
|
+
|
|
3560
|
+
// src/swift-standins.ts
|
|
3561
|
+
var import_node_child_process7 = require("node:child_process");
|
|
3562
|
+
var import_node_crypto6 = require("node:crypto");
|
|
3563
|
+
var import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
3564
|
+
var import_node_os7 = __toESM(require("node:os"), 1);
|
|
3565
|
+
var import_node_path11 = __toESM(require("node:path"), 1);
|
|
3566
|
+
|
|
3567
|
+
// src/swift-standin-emit.ts
|
|
3568
|
+
var TYPE_KINDS = /* @__PURE__ */ new Set([
|
|
3569
|
+
"swift.class",
|
|
3570
|
+
"swift.struct",
|
|
3571
|
+
"swift.enum",
|
|
3572
|
+
"swift.protocol",
|
|
3573
|
+
"swift.typealias"
|
|
3574
|
+
]);
|
|
3575
|
+
var MEMBER_KINDS = /* @__PURE__ */ new Set([
|
|
3576
|
+
"swift.method",
|
|
3577
|
+
"swift.type.method",
|
|
3578
|
+
"swift.func.op",
|
|
3579
|
+
"swift.init",
|
|
3580
|
+
"swift.property",
|
|
3581
|
+
"swift.type.property",
|
|
3582
|
+
"swift.subscript",
|
|
3583
|
+
"swift.type.subscript"
|
|
3584
|
+
]);
|
|
3585
|
+
var ACCESSORS = /\{\s*get(\s+async)?(\s+throws)?(\s+set)?\s*\}\s*$/;
|
|
3586
|
+
var KEEP_EXTERNAL = /* @__PURE__ */ new Map([
|
|
3587
|
+
["s:SH", "Hashable"],
|
|
3588
|
+
["s:SQ", "Equatable"],
|
|
3589
|
+
["s:s5ErrorP", "Error"],
|
|
3590
|
+
["s:s8SendableP", "Sendable"],
|
|
3591
|
+
["s:s12IdentifiableP", "Identifiable"],
|
|
3592
|
+
["s:SY", "RawRepresentable"],
|
|
3593
|
+
["s:s9OptionSetP", "OptionSet"],
|
|
3594
|
+
["s:s12CaseIterableP", "CaseIterable"],
|
|
3595
|
+
["s:SE", "Encodable"],
|
|
3596
|
+
["s:Se", "Decodable"],
|
|
3597
|
+
["s:s23CustomStringConvertibleP", "CustomStringConvertible"]
|
|
3598
|
+
]);
|
|
3599
|
+
var LEADING_ATTRS = /^((?:@\w+(?:\([^)]*\))?\s*|nonisolated\s+)*)(.*)$/s;
|
|
3600
|
+
var OBJC_ONLY = /@(?:objcMembers|objc|IBOutlet|IBInspectable|IBAction|IBSegueAction|GKInspectable|nonobjc|NSCopying|NSManaged)(?:\([^)]*\))?\s*|\bdynamic\s+/g;
|
|
3601
|
+
var text = (symbol) => (symbol.declarationFragments ?? []).map((fragment) => fragment.spelling).join("").replace(OBJC_ONLY, "").replace(/(^|\s)optional (?=func|var|init|subscript|static|class)/, "$1");
|
|
3602
|
+
var leaf = (symbol) => symbol.pathComponents[symbol.pathComponents.length - 1];
|
|
3603
|
+
var pathOf = (symbol) => symbol.pathComponents.join(".");
|
|
3604
|
+
var unavailable = (symbol) => (symbol.availability ?? []).some(
|
|
3605
|
+
(entry) => entry.isUnconditionallyUnavailable || entry.obsoleted !== void 0
|
|
3606
|
+
);
|
|
3607
|
+
var witnessKey = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.") ? "type" : "instance"}|${leaf(symbol)}`;
|
|
3608
|
+
var isObjC = (symbol) => symbol.identifier.precise.startsWith("c:");
|
|
3609
|
+
var trap = (path15) => `fatalError("${path15} is a binary framework peach cannot run")`;
|
|
3610
|
+
function emitSwiftStandin(graphs, options) {
|
|
3611
|
+
const skipped = [];
|
|
3612
|
+
const behavior = options.behavior ?? /* @__PURE__ */ new Map();
|
|
3613
|
+
const used = /* @__PURE__ */ new Set();
|
|
3614
|
+
const values = options.values ?? /* @__PURE__ */ new Map();
|
|
3615
|
+
const family = /* @__PURE__ */ new Set([options.module, ...options.family ?? []]);
|
|
3616
|
+
const byId = /* @__PURE__ */ new Map();
|
|
3617
|
+
const twins = /* @__PURE__ */ new Map();
|
|
3618
|
+
const owner = /* @__PURE__ */ new Map();
|
|
3619
|
+
for (const graph of graphs)
|
|
3620
|
+
for (const symbol of graph.symbols) {
|
|
3621
|
+
if (symbol.accessLevel !== "public" && symbol.accessLevel !== "open") continue;
|
|
3622
|
+
const id = symbol.identifier.precise;
|
|
3623
|
+
if (!byId.has(id)) byId.set(id, symbol);
|
|
3624
|
+
twins.set(id, [...twins.get(id) ?? [], symbol]);
|
|
3625
|
+
}
|
|
3626
|
+
const all = (id) => twins.get(id) ?? [];
|
|
3627
|
+
const children = /* @__PURE__ */ new Map();
|
|
3628
|
+
const superclass = /* @__PURE__ */ new Map();
|
|
3629
|
+
const superId = /* @__PURE__ */ new Map();
|
|
3630
|
+
const conforms = /* @__PURE__ */ new Map();
|
|
3631
|
+
const conformIds = /* @__PURE__ */ new Map();
|
|
3632
|
+
const protocolParents = /* @__PURE__ */ new Map();
|
|
3633
|
+
const requirement = /* @__PURE__ */ new Set();
|
|
3634
|
+
const optional = /* @__PURE__ */ new Set();
|
|
3635
|
+
const overrides = /* @__PURE__ */ new Set();
|
|
3636
|
+
const external = /* @__PURE__ */ new Map();
|
|
3637
|
+
const nameOf = (id, fallback) => {
|
|
3638
|
+
const local = byId.get(id);
|
|
3639
|
+
if (local) return { name: pathOf(local), local: true };
|
|
3640
|
+
if (!fallback) return null;
|
|
3641
|
+
const parts = fallback.split(".");
|
|
3642
|
+
return { name: family.has(parts[0]) ? parts.join(".") : parts.slice(1).join(".") || parts[0], module: parts[0], local: false };
|
|
3643
|
+
};
|
|
3644
|
+
for (const graph of graphs)
|
|
3645
|
+
for (const edge of graph.relationships) {
|
|
3646
|
+
const source = byId.get(edge.source);
|
|
3647
|
+
if (!source) continue;
|
|
3648
|
+
switch (edge.kind) {
|
|
3649
|
+
case "memberOf": {
|
|
3650
|
+
const parent = byId.get(edge.target);
|
|
3651
|
+
if (parent) {
|
|
3652
|
+
owner.set(edge.source, edge.target);
|
|
3653
|
+
children.set(edge.target, [...children.get(edge.target) ?? [], ...all(edge.source)]);
|
|
3654
|
+
} else if (edge.targetFallback) {
|
|
3655
|
+
const name = nameOf(edge.target, edge.targetFallback).name;
|
|
3656
|
+
external.set(name, [...external.get(name) ?? [], ...all(edge.source)]);
|
|
3657
|
+
owner.set(edge.source, edge.target);
|
|
3658
|
+
}
|
|
3659
|
+
break;
|
|
3660
|
+
}
|
|
3661
|
+
case "inheritsFrom": {
|
|
3662
|
+
const target = nameOf(edge.target, edge.targetFallback);
|
|
3663
|
+
if (target) superclass.set(edge.source, target.name);
|
|
3664
|
+
superId.set(edge.source, edge.target);
|
|
3665
|
+
break;
|
|
3666
|
+
}
|
|
3667
|
+
case "conformsTo": {
|
|
3668
|
+
const target = nameOf(edge.target, edge.targetFallback);
|
|
3669
|
+
const kept = KEEP_EXTERNAL.get(edge.target);
|
|
3670
|
+
const name = kept ?? (target && (target.local || family.has(target.module ?? "")) ? target.name : null);
|
|
3671
|
+
if (name) conforms.set(edge.source, [...conforms.get(edge.source) ?? [], name]);
|
|
3672
|
+
if (byId.has(edge.target)) {
|
|
3673
|
+
const map = source.kind.identifier === "swift.protocol" ? protocolParents : conformIds;
|
|
3674
|
+
map.set(edge.source, [...map.get(edge.source) ?? [], edge.target]);
|
|
3675
|
+
}
|
|
3676
|
+
break;
|
|
3677
|
+
}
|
|
3678
|
+
case "requirementOf":
|
|
3679
|
+
case "optionalRequirementOf":
|
|
3680
|
+
requirement.add(edge.source);
|
|
3681
|
+
if (edge.kind === "optionalRequirementOf") optional.add(edge.source);
|
|
3682
|
+
if (byId.has(edge.target) && !owner.has(edge.source)) {
|
|
3683
|
+
owner.set(edge.source, edge.target);
|
|
3684
|
+
children.set(edge.target, [...children.get(edge.target) ?? [], ...all(edge.source)]);
|
|
3685
|
+
}
|
|
3686
|
+
break;
|
|
3687
|
+
case "overrides":
|
|
3688
|
+
overrides.add(edge.source);
|
|
3689
|
+
break;
|
|
3690
|
+
}
|
|
3691
|
+
}
|
|
3692
|
+
const lines = [];
|
|
3693
|
+
const owners = [];
|
|
3694
|
+
const omit = options.omit ?? /* @__PURE__ */ new Map();
|
|
3695
|
+
let current = "";
|
|
3696
|
+
const emit = (line) => {
|
|
3697
|
+
const physical = line.split("\n");
|
|
3698
|
+
lines.push(...physical);
|
|
3699
|
+
owners.push(...physical.map(() => current));
|
|
3700
|
+
};
|
|
3701
|
+
const scoped = (body) => (symbol, ...rest) => {
|
|
3702
|
+
const path15 = pathOf(symbol);
|
|
3703
|
+
if (omit.has(path15)) return void skipped.push({ path: path15, reason: omit.get(path15) });
|
|
3704
|
+
const previous = current;
|
|
3705
|
+
current = path15;
|
|
3706
|
+
try {
|
|
3707
|
+
body(symbol, ...rest);
|
|
3708
|
+
} finally {
|
|
3709
|
+
current = previous;
|
|
3710
|
+
}
|
|
3711
|
+
};
|
|
3712
|
+
const membersOf = (id) => {
|
|
3713
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3714
|
+
return (children.get(id) ?? []).filter((member) => {
|
|
3715
|
+
if (unavailable(member)) return false;
|
|
3716
|
+
const key2 = `${member.kind.identifier}|${text(member)}`;
|
|
3717
|
+
if (seen.has(key2)) return false;
|
|
3718
|
+
seen.add(key2);
|
|
3719
|
+
return true;
|
|
3720
|
+
});
|
|
3721
|
+
};
|
|
3722
|
+
const access = (symbol, openOwner) => symbol.accessLevel === "open" && openOwner ? "open" : "public";
|
|
3723
|
+
const emitMember = scoped((member, indent, context) => {
|
|
3724
|
+
const path15 = pathOf(member);
|
|
3725
|
+
if (TYPE_KINDS.has(member.kind.identifier)) {
|
|
3726
|
+
emitType(member, indent);
|
|
3727
|
+
return;
|
|
3728
|
+
}
|
|
3729
|
+
if (member.kind.identifier === "swift.enum.case") return;
|
|
3730
|
+
if (!MEMBER_KINDS.has(member.kind.identifier)) {
|
|
3731
|
+
skipped.push({ path: path15, reason: `unhandled ${member.kind.identifier}` });
|
|
3732
|
+
return;
|
|
3733
|
+
}
|
|
3734
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
3735
|
+
const modifiers = /^((?:(?:required|final|override|convenience|unowned(?:\(\w+\))?|weak|lazy|nonisolated|mutating|nonmutating) )*)(.*)$/s.exec(rest);
|
|
3736
|
+
const flags = new Set(modifiers[1].trim().split(/\s+/).filter(Boolean).map((flag) => flag.replace(/\(.*/, "")));
|
|
3737
|
+
const required = context.inClass && flags.has("required");
|
|
3738
|
+
const final = context.inClass && flags.has("final") ? "final " : "";
|
|
3739
|
+
const mutating = flags.has("mutating") ? "mutating " : flags.has("nonmutating") ? "nonmutating " : "";
|
|
3740
|
+
let core = `${context.inClass && flags.has("convenience") ? "convenience " : ""}${modifiers[2]}`;
|
|
3741
|
+
const override = context.inClass && !options.plain?.has(path15) && (flags.has("override") || overrides.has(member.identifier.precise) || isObjC(member) && path15.endsWith(".init()")) ? "override " : "";
|
|
3742
|
+
const head = `${indent}${attrs}${access(member, context.openOwner)} ${required ? "required " : ""}${final}${override}${mutating}`;
|
|
3743
|
+
const measured = behavior.get(path15);
|
|
3744
|
+
if (measured) used.add(path15);
|
|
3745
|
+
const overloadBody = /\basync\b/.test(core) ? measured?.asyncBody : /\bResult</.test(core) ? measured?.resultBody : void 0;
|
|
3746
|
+
const body = overloadBody ?? measured?.body ?? trap(path15);
|
|
3747
|
+
switch (member.kind.identifier) {
|
|
3748
|
+
case "swift.property":
|
|
3749
|
+
case "swift.type.property":
|
|
3750
|
+
case "swift.subscript":
|
|
3751
|
+
case "swift.type.subscript": {
|
|
3752
|
+
const accessors = ACCESSORS.exec(core);
|
|
3753
|
+
const decl = core.replace(ACCESSORS, "").trimEnd();
|
|
3754
|
+
const effects = `${accessors?.[1] ?? ""}${accessors?.[2] ?? ""}`;
|
|
3755
|
+
const settable = accessors ? Boolean(accessors[3]) : /^(?:static |class )?var /.test(core);
|
|
3756
|
+
const computed = decl.replace(/^((?:static |class )*)let /, "$1var ");
|
|
3757
|
+
if (measured?.stored !== void 0) {
|
|
3758
|
+
const ownership = flags.has("weak") ? "weak " : flags.has("unowned") ? "unowned " : "";
|
|
3759
|
+
const setter = settable ? "" : "internal(set) ";
|
|
3760
|
+
const value = measured.stored ? ` = ${measured.stored}` : "";
|
|
3761
|
+
emit(`${indent}${attrs}${access(member, context.openOwner)} ${setter}${final}${override}${ownership}${computed}${value}`);
|
|
3762
|
+
return;
|
|
3763
|
+
}
|
|
3764
|
+
emit(`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` set { ${measured?.set ?? trap(path15)} }` : ""} }`);
|
|
3765
|
+
return;
|
|
3766
|
+
}
|
|
3767
|
+
default:
|
|
3768
|
+
emit(`${head}${core} { ${body} }`);
|
|
3769
|
+
}
|
|
3770
|
+
});
|
|
3771
|
+
const header = (symbol, keyword, indent) => {
|
|
3772
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
3773
|
+
const shape = new RegExp(`^(?:final )?${keyword}\\s+\`?(\\w+)\`?(<[^>]*>)?\\s*(?::\\s*([^{]*?))?(\\s+where\\s+.*)?$`).exec(rest);
|
|
3774
|
+
if (!shape) return null;
|
|
3775
|
+
return { attrs, name: shape[1], generics: shape[2] ?? "", where: shape[4] ?? "", indent };
|
|
3776
|
+
};
|
|
3777
|
+
const externalRoot = (id) => {
|
|
3778
|
+
for (let at = id; at; at = superId.get(at)) {
|
|
3779
|
+
const next = superId.get(at);
|
|
3780
|
+
if (next && !byId.has(next)) return superclass.get(at) ?? null;
|
|
3781
|
+
}
|
|
3782
|
+
return null;
|
|
3783
|
+
};
|
|
3784
|
+
const classBlocked = (id) => {
|
|
3785
|
+
const parent = superId.get(id);
|
|
3786
|
+
const parentSymbol = parent ? byId.get(parent) : void 0;
|
|
3787
|
+
if (!parentSymbol) return null;
|
|
3788
|
+
if (/^(?:final )?class\s+\w+</.test(LEADING_ATTRS.exec(text(parentSymbol))[2]))
|
|
3789
|
+
return `superclass ${pathOf(parentSymbol)} is generic and the graph omits its arguments`;
|
|
3790
|
+
if (unavailable(parentSymbol)) return `superclass ${pathOf(parentSymbol)} is unavailable`;
|
|
3791
|
+
return classBlocked(parent) && `superclass ${pathOf(parentSymbol)} is left out`;
|
|
3792
|
+
};
|
|
3793
|
+
const inheritance = (id, first) => {
|
|
3794
|
+
const list2 = [...first ? [first] : [], ...conforms.get(id) ?? []];
|
|
3795
|
+
return [...new Set(list2)];
|
|
3796
|
+
};
|
|
3797
|
+
const emitType = scoped((symbol, indent) => {
|
|
3798
|
+
const path15 = pathOf(symbol);
|
|
3799
|
+
const id = symbol.identifier.precise;
|
|
3800
|
+
const inner = `${indent} `;
|
|
3801
|
+
switch (symbol.kind.identifier) {
|
|
3802
|
+
case "swift.typealias": {
|
|
3803
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
3804
|
+
emit(`${indent}${attrs}public ${rest}`);
|
|
3805
|
+
return;
|
|
3806
|
+
}
|
|
3807
|
+
case "swift.class": {
|
|
3808
|
+
const shape = header(symbol, "class", indent);
|
|
3809
|
+
if (!shape) return void skipped.push({ path: path15, reason: `unparsed class ${text(symbol)}` });
|
|
3810
|
+
const parent = superclass.get(id);
|
|
3811
|
+
const blocked = classBlocked(id);
|
|
3812
|
+
if (blocked) return void skipped.push({ path: path15, reason: blocked });
|
|
3813
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
3814
|
+
for (let at = superId.get(id); at; at = superId.get(at))
|
|
3815
|
+
for (const name of conforms.get(at) ?? []) ancestors.add(name);
|
|
3816
|
+
const list2 = [
|
|
3817
|
+
...parent ? [parent] : [],
|
|
3818
|
+
...(conforms.get(id) ?? []).filter(
|
|
3819
|
+
(name) => !ancestors.has(name) && !(parent && [...KEEP_EXTERNAL.values()].includes(name))
|
|
3820
|
+
)
|
|
3821
|
+
].filter((name, at, all2) => all2.indexOf(name) === at);
|
|
3822
|
+
const parentSymbol = superId.has(id) ? byId.get(superId.get(id)) : void 0;
|
|
3823
|
+
const open = symbol.accessLevel === "open" && (!parentSymbol || parentSymbol.accessLevel === "open");
|
|
3824
|
+
emit(`${indent}${shape.attrs}${open ? "open" : "public"} class ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`);
|
|
3825
|
+
const members = membersOf(id);
|
|
3826
|
+
for (const member of members)
|
|
3827
|
+
emitMember(member, inner, { openOwner: open, inClass: true, ownerName: shape.name });
|
|
3828
|
+
const designated = members.some(
|
|
3829
|
+
(member) => member.kind.identifier === "swift.init" && !text(member).startsWith("convenience")
|
|
3830
|
+
);
|
|
3831
|
+
const have = /* @__PURE__ */ new Set();
|
|
3832
|
+
for (let at = id; at; at = superId.get(at))
|
|
3833
|
+
for (const member of children.get(at) ?? []) have.add(witnessKey(member));
|
|
3834
|
+
const protocols = [];
|
|
3835
|
+
const visit = (protocolId) => {
|
|
3836
|
+
if (protocols.includes(protocolId)) return;
|
|
3837
|
+
protocols.push(protocolId);
|
|
3838
|
+
for (const edge of protocolParents.get(protocolId) ?? []) visit(edge);
|
|
3839
|
+
};
|
|
3840
|
+
for (const protocolId of conformIds.get(id) ?? []) visit(protocolId);
|
|
3841
|
+
for (const protocolId of protocols)
|
|
3842
|
+
for (const member of children.get(protocolId) ?? []) {
|
|
3843
|
+
if (!requirement.has(member.identifier.precise) || optional.has(member.identifier.precise)) continue;
|
|
3844
|
+
if (isObjC(member) && / async\b/.test(text(member))) continue;
|
|
3845
|
+
if (have.has(witnessKey(member)) || member.kind.identifier === "swift.associatedtype") continue;
|
|
3846
|
+
have.add(witnessKey(member));
|
|
3847
|
+
emitWitness(member, inner, path15);
|
|
3848
|
+
}
|
|
3849
|
+
const coder = members.some((member) => leaf(member) === "init(coder:)");
|
|
3850
|
+
if (designated && !coder && externalRoot(id) !== "NSObject" && externalRoot(id) !== null)
|
|
3851
|
+
emit(`${inner}public required init?(coder: NSCoder) { ${trap(`${path15}.init(coder:)`)} }`);
|
|
3852
|
+
emit(`${indent}}`);
|
|
3853
|
+
return;
|
|
3854
|
+
}
|
|
3855
|
+
case "swift.struct": {
|
|
3856
|
+
const shape = header(symbol, "struct", indent);
|
|
3857
|
+
if (!shape) return void skipped.push({ path: path15, reason: `unparsed struct ${text(symbol)}` });
|
|
3858
|
+
const members = membersOf(id);
|
|
3859
|
+
const raw2 = rawType(members);
|
|
3860
|
+
const list2 = inheritance(id);
|
|
3861
|
+
emit(`${indent}${shape.attrs}public struct ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`);
|
|
3862
|
+
if (raw2) {
|
|
3863
|
+
emit(`${inner}public let rawValue: ${raw2}`);
|
|
3864
|
+
emit(`${inner}public init(rawValue: ${raw2}) { self.rawValue = rawValue }`);
|
|
3865
|
+
}
|
|
3866
|
+
for (const member of members) {
|
|
3867
|
+
if (raw2 && (leaf(member) === "rawValue" || leaf(member) === "init(rawValue:)" || leaf(member) === "init(_:)"))
|
|
3868
|
+
continue;
|
|
3869
|
+
const value = values.get(member.identifier.precise);
|
|
3870
|
+
if (value !== void 0 && member.kind.identifier === "swift.type.property") {
|
|
3871
|
+
emit(`${inner}public static let ${tick(leaf(member))} = ${shape.name}(rawValue: ${value})`);
|
|
3872
|
+
continue;
|
|
3873
|
+
}
|
|
3874
|
+
emitMember(member, inner, { openOwner: false, inClass: false, ownerName: shape.name });
|
|
3875
|
+
}
|
|
3876
|
+
emit(`${indent}}`);
|
|
3877
|
+
return;
|
|
3878
|
+
}
|
|
3879
|
+
case "swift.enum": {
|
|
3880
|
+
const shape = header(symbol, "enum", indent);
|
|
3881
|
+
if (!shape) return void skipped.push({ path: path15, reason: `unparsed enum ${text(symbol)}` });
|
|
3882
|
+
const members = membersOf(id);
|
|
3883
|
+
const raw2 = rawType(members);
|
|
3884
|
+
const cases = (children.get(id) ?? []).filter((member) => member.kind.identifier === "swift.enum.case");
|
|
3885
|
+
const missing = raw2 ? cases.filter((member) => !values.has(member.identifier.precise)) : [];
|
|
3886
|
+
if (raw2 && isObjC(symbol) && missing.length > 0)
|
|
3887
|
+
return void skipped.push({ path: path15, reason: `no header value for ${missing.map(leaf).join(", ")}` });
|
|
3888
|
+
const list2 = inheritance(id, raw2 ?? void 0).filter((name) => name !== "RawRepresentable");
|
|
3889
|
+
emit(`${indent}${shape.attrs}public enum ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`);
|
|
3890
|
+
const seenValues = /* @__PURE__ */ new Map();
|
|
3891
|
+
for (const member of cases) {
|
|
3892
|
+
const value = values.get(member.identifier.precise);
|
|
3893
|
+
if (value !== void 0 && seenValues.has(value)) {
|
|
3894
|
+
emit(`${inner}public static var ${tick(leaf(member))}: ${shape.name} { .${seenValues.get(value)} }`);
|
|
3895
|
+
continue;
|
|
3896
|
+
}
|
|
3897
|
+
if (value !== void 0) seenValues.set(value, tick(leaf(member)));
|
|
3898
|
+
const caseText = text(member).replace(/^case\s+/, "");
|
|
3899
|
+
emit(`${inner}case ${caseText}${value !== void 0 ? ` = ${value}` : ""}`);
|
|
3900
|
+
}
|
|
3901
|
+
for (const member of members) {
|
|
3902
|
+
if (member.kind.identifier === "swift.enum.case") continue;
|
|
3903
|
+
if (raw2 && (leaf(member) === "rawValue" || leaf(member) === "init(rawValue:)")) continue;
|
|
3904
|
+
emitMember(member, inner, { openOwner: false, inClass: false, ownerName: shape.name });
|
|
3905
|
+
}
|
|
3906
|
+
emit(`${indent}}`);
|
|
3907
|
+
return;
|
|
3908
|
+
}
|
|
3909
|
+
case "swift.protocol": {
|
|
3910
|
+
const shape = header(symbol, "protocol", indent);
|
|
3911
|
+
if (!shape) return void skipped.push({ path: path15, reason: `unparsed protocol ${text(symbol)}` });
|
|
3912
|
+
const list2 = [...isObjC(symbol) ? ["AnyObject"] : [], ...inheritance(id)];
|
|
3913
|
+
emit(`${indent}${shape.attrs}public protocol ${shape.name}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`);
|
|
3914
|
+
const members = membersOf(id);
|
|
3915
|
+
const defaults = [];
|
|
3916
|
+
for (const member of members) {
|
|
3917
|
+
if (member.kind.identifier === "swift.associatedtype") {
|
|
3918
|
+
emit(`${inner}${text(member)}`);
|
|
3919
|
+
continue;
|
|
3920
|
+
}
|
|
3921
|
+
const asyncTwin = isObjC(member) && / async\b/.test(text(member));
|
|
3922
|
+
if (!requirement.has(member.identifier.precise) || asyncTwin) {
|
|
3923
|
+
defaults.push(member);
|
|
3924
|
+
continue;
|
|
3925
|
+
}
|
|
3926
|
+
emitRequirement(member, inner);
|
|
3927
|
+
if (optional.has(member.identifier.precise)) defaults.push(member);
|
|
3928
|
+
}
|
|
3929
|
+
emit(`${indent}}`);
|
|
3930
|
+
if (defaults.length > 0) {
|
|
3931
|
+
emit(`${indent}extension ${path15} {`);
|
|
3932
|
+
for (const member of defaults) {
|
|
3933
|
+
const decl = text(member);
|
|
3934
|
+
if (optional.has(member.identifier.precise) && member.kind.identifier === "swift.method" && !/->/.test(decl.replace(/\([^)]*\)/g, "")) && !/ async\b/.test(decl))
|
|
3935
|
+
emitNoop(member, inner);
|
|
3936
|
+
else emitMember(member, inner, { openOwner: false, inClass: false, ownerName: shape.name });
|
|
3937
|
+
}
|
|
3938
|
+
emit(`${indent}}`);
|
|
3939
|
+
}
|
|
3940
|
+
return;
|
|
3941
|
+
}
|
|
3942
|
+
}
|
|
3943
|
+
});
|
|
3944
|
+
const emitWitness = (member, indent, owner2) => {
|
|
3945
|
+
const { 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
3946
|
+
const decl = rest.replace(/^(?:weak |unowned )/, "").replace(/^((?:static )?)let /, "$1var ");
|
|
3947
|
+
const witness = `${owner2}.${leaf(member)}`;
|
|
3948
|
+
const body = trap(witness);
|
|
3949
|
+
if (member.kind.identifier === "swift.property" || member.kind.identifier === "swift.type.property") {
|
|
3950
|
+
const accessors = ACCESSORS.exec(decl);
|
|
3951
|
+
const bare = decl.replace(ACCESSORS, "").trimEnd();
|
|
3952
|
+
emit(`${indent}public ${bare} { get { ${body} }${accessors?.[3] ? ` set { ${body} }` : ""} }`);
|
|
3953
|
+
} else emit(`${indent}public ${member.kind.identifier === "swift.init" ? "required " : ""}${stripDefaults(decl)} { ${body} }`);
|
|
3954
|
+
};
|
|
3955
|
+
const emitNoop = scoped((member, indent) => {
|
|
3956
|
+
emit(`${indent}public ${stripDefaults(text(member))} {}`);
|
|
3957
|
+
});
|
|
3958
|
+
const emitRequirement = scoped((member, indent) => {
|
|
3959
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
3960
|
+
emit(`${indent}${attrs}${stripDefaults(rest.replace(/^(?:weak |unowned )/, "").replace(/^((?:static )?)let /, "$1var "))}`);
|
|
3961
|
+
});
|
|
3962
|
+
const rawType = (members) => {
|
|
3963
|
+
const init = members.find((member) => leaf(member) === "init(rawValue:)");
|
|
3964
|
+
return init ? /rawValue:\s*([^)]+)\)/.exec(text(init))?.[1]?.trim() ?? null : null;
|
|
3965
|
+
};
|
|
3966
|
+
const emitGlobal = scoped((symbol) => {
|
|
3967
|
+
const path15 = pathOf(symbol);
|
|
3968
|
+
if (symbol.kind.identifier === "swift.func" || symbol.kind.identifier === "swift.func.op") {
|
|
3969
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
3970
|
+
emit(`${attrs}public ${rest} { ${trap(path15)} }`);
|
|
3971
|
+
} else if (symbol.kind.identifier === "swift.var") {
|
|
3972
|
+
const decl = text(symbol).replace(/^let /, "var ").replace(ACCESSORS, "").trimEnd();
|
|
3973
|
+
emit(`public ${decl} { ${trap(path15)} }`);
|
|
3974
|
+
} else skipped.push({ path: path15, reason: `unhandled top-level ${symbol.kind.identifier}` });
|
|
3975
|
+
});
|
|
3976
|
+
const roots = [...byId.values()].filter((symbol) => !owner.has(symbol.identifier.precise) && !unavailable(symbol)).sort((a, b) => pathOf(a).localeCompare(pathOf(b)));
|
|
3977
|
+
for (const symbol of roots) {
|
|
3978
|
+
const path15 = pathOf(symbol);
|
|
3979
|
+
if (TYPE_KINDS.has(symbol.kind.identifier)) emitType(symbol, "");
|
|
3980
|
+
else emitGlobal(symbol);
|
|
3981
|
+
}
|
|
3982
|
+
for (const [name, members] of [...external].sort(([a], [b]) => a.localeCompare(b))) {
|
|
3983
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3984
|
+
const kept = members.filter((member) => {
|
|
3985
|
+
const key2 = `${member.kind.identifier}|${text(member)}`;
|
|
3986
|
+
if (unavailable(member) || seen.has(key2)) return false;
|
|
3987
|
+
seen.add(key2);
|
|
3988
|
+
return true;
|
|
3989
|
+
});
|
|
3990
|
+
if (kept.length === 0) continue;
|
|
3991
|
+
emit(`extension ${name} {`);
|
|
3992
|
+
for (const member of kept)
|
|
3993
|
+
if (member.kind.identifier === "swift.init" && !text(member).startsWith("convenience"))
|
|
3994
|
+
emitMember({ ...member, declarationFragments: [{ kind: "text", spelling: `convenience ${text(member)}` }] }, " ", {
|
|
3995
|
+
openOwner: false,
|
|
3996
|
+
inClass: true,
|
|
3997
|
+
ownerName: name
|
|
3998
|
+
});
|
|
3999
|
+
else emitMember(member, " ", { openOwner: false, inClass: false, ownerName: name });
|
|
4000
|
+
emit(`}`);
|
|
4001
|
+
}
|
|
4002
|
+
const imports = ["Foundation", "UIKit", ...options.imports ?? []];
|
|
4003
|
+
const banner = [
|
|
4004
|
+
`// stand-in for the binary ${options.module} module, generated from ${options.source}.`,
|
|
4005
|
+
`// do not hand-edit: every body traps because the vendor binary cannot run`,
|
|
4006
|
+
`// in peach; behavior a hand file measures lives beside this file.`,
|
|
4007
|
+
"",
|
|
4008
|
+
...imports.map((name) => `import ${name}`),
|
|
4009
|
+
""
|
|
4010
|
+
];
|
|
4011
|
+
for (const path15 of behavior.keys())
|
|
4012
|
+
if (!used.has(path15)) skipped.push({ path: path15, reason: "behavior names no emitted declaration" });
|
|
4013
|
+
return {
|
|
4014
|
+
source: `${[...banner, ...lines].join("\n")}
|
|
4015
|
+
`,
|
|
4016
|
+
skipped,
|
|
4017
|
+
owners: [...banner.map(() => ""), ...owners]
|
|
4018
|
+
};
|
|
4019
|
+
}
|
|
4020
|
+
var KEYWORDS = /* @__PURE__ */ new Set(["Type", "Protocol", "Self", "default", "init", "self", "class", "func", "var", "let", "in", "is", "as", "repeat", "internal", "public", "private", "operator", "extension", "subscript", "static", "struct", "protocol", "enum", "case", "where", "return", "throw", "throws", "import", "true", "false", "nil"]);
|
|
4021
|
+
var tick = (name) => KEYWORDS.has(name) ? `\`${name}\`` : name;
|
|
4022
|
+
function stripDefaults(decl) {
|
|
4023
|
+
let out = "";
|
|
4024
|
+
let depth = 0;
|
|
4025
|
+
for (let at = 0; at < decl.length; at++) {
|
|
4026
|
+
const char = decl[at];
|
|
4027
|
+
if (char === "(" || char === "[" || char === "<") depth++;
|
|
4028
|
+
if (char === ")" || char === "]" || char === ">" && decl[at - 1] !== "-") depth--;
|
|
4029
|
+
if (char === "=" && depth === 1 && decl[at - 1] === " ") {
|
|
4030
|
+
let skip = at + 1;
|
|
4031
|
+
let inner = 0;
|
|
4032
|
+
while (skip < decl.length) {
|
|
4033
|
+
const next = decl[skip];
|
|
4034
|
+
if (next === "(" || next === "[") inner++;
|
|
4035
|
+
if (next === ")" || next === "]") {
|
|
4036
|
+
if (inner === 0) break;
|
|
4037
|
+
inner--;
|
|
4038
|
+
}
|
|
4039
|
+
if (next === "," && inner === 0) break;
|
|
4040
|
+
skip++;
|
|
4041
|
+
}
|
|
4042
|
+
out = out.trimEnd();
|
|
4043
|
+
at = skip - 1;
|
|
4044
|
+
continue;
|
|
4045
|
+
}
|
|
4046
|
+
out += char;
|
|
4047
|
+
}
|
|
4048
|
+
return out;
|
|
4049
|
+
}
|
|
4050
|
+
|
|
4051
|
+
// src/swift-standins.ts
|
|
4052
|
+
var TRIPLE = "wasm32-unknown-wasip1";
|
|
4053
|
+
var cacheDir3 = import_node_path11.default.join(import_node_os7.default.tmpdir(), "peach-swift-standins");
|
|
4054
|
+
function exec(file, args, cwd) {
|
|
4055
|
+
return (0, import_node_child_process7.execFileSync)(file, args, {
|
|
4056
|
+
cwd,
|
|
4057
|
+
encoding: "utf8",
|
|
4058
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
4059
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
4060
|
+
});
|
|
4061
|
+
}
|
|
4062
|
+
function failure(error) {
|
|
4063
|
+
const output = error && typeof error === "object" && "stderr" in error ? `${String(error.stderr)}
|
|
4064
|
+
${"stdout" in error ? String(error.stdout) : ""}` : String(error);
|
|
4065
|
+
const errors = output.split("\n").filter((line) => /\berror:/.test(line)).map((line) => line.replace(/^.*?error:\s*/, "").trim());
|
|
4066
|
+
return [...new Set(errors)].slice(0, 3).join("; ") || output.trim().slice(0, 400);
|
|
4067
|
+
}
|
|
4068
|
+
var key = (...parts) => (0, import_node_crypto6.createHash)("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
4069
|
+
function xcframework(binary) {
|
|
4070
|
+
if (!binary.url && !binary.dir.endsWith(".zip")) return binary.dir;
|
|
4071
|
+
const dir = import_node_path11.default.join(cacheDir3, "archives", key(binary.url ?? binary.dir));
|
|
4072
|
+
if (!import_node_fs10.default.existsSync(import_node_path11.default.join(dir, ".complete"))) {
|
|
4073
|
+
import_node_fs10.default.rmSync(dir, { recursive: true, force: true });
|
|
4074
|
+
import_node_fs10.default.mkdirSync(dir, { recursive: true });
|
|
4075
|
+
const archive = import_node_path11.default.join(dir, "archive.zip");
|
|
4076
|
+
if (binary.url) exec("curl", ["-fsSL", "--retry", "2", "-o", archive, binary.url]);
|
|
4077
|
+
else import_node_fs10.default.copyFileSync(binary.dir, archive);
|
|
4078
|
+
exec("unzip", ["-q", archive, "-d", import_node_path11.default.join(dir, "tree")]);
|
|
4079
|
+
import_node_fs10.default.rmSync(archive);
|
|
4080
|
+
import_node_fs10.default.writeFileSync(import_node_path11.default.join(dir, ".complete"), "");
|
|
4081
|
+
}
|
|
4082
|
+
const find = (root, depth) => {
|
|
4083
|
+
for (const entry of import_node_fs10.default.readdirSync(root, { withFileTypes: true })) {
|
|
4084
|
+
if (!entry.isDirectory() || entry.name === "__MACOSX") continue;
|
|
4085
|
+
const full = import_node_path11.default.join(root, entry.name);
|
|
4086
|
+
if (entry.name.endsWith(".xcframework")) return full;
|
|
4087
|
+
const nested = depth > 0 ? find(full, depth - 1) : null;
|
|
4088
|
+
if (nested) return nested;
|
|
4089
|
+
}
|
|
4090
|
+
return null;
|
|
4091
|
+
};
|
|
4092
|
+
const found = find(import_node_path11.default.join(dir, "tree"), 2);
|
|
4093
|
+
if (!found) throw new Error("its archive holds no .xcframework");
|
|
4094
|
+
return found;
|
|
4095
|
+
}
|
|
4096
|
+
var files = (dir, test) => import_node_fs10.default.existsSync(dir) ? import_node_fs10.default.readdirSync(dir, { recursive: true, encoding: "utf8" }).filter((file) => test(import_node_path11.default.basename(file))).sort() : [];
|
|
4097
|
+
function surfaces(xcframeworkDir) {
|
|
4098
|
+
const slice = import_node_fs10.default.readdirSync(xcframeworkDir).filter((name) => /^ios-.+-simulator$/.test(name)).sort()[0];
|
|
4099
|
+
if (!slice) throw new Error("it has no iOS simulator slice");
|
|
4100
|
+
const root = import_node_path11.default.join(xcframeworkDir, slice);
|
|
4101
|
+
const found = [];
|
|
4102
|
+
for (const entry of import_node_fs10.default.readdirSync(root).sort()) {
|
|
4103
|
+
if (!entry.endsWith(".framework")) continue;
|
|
4104
|
+
const module2 = entry.slice(0, -".framework".length);
|
|
4105
|
+
const framework = import_node_path11.default.join(root, entry);
|
|
4106
|
+
const swiftmodule = import_node_path11.default.join(framework, "Modules", `${module2}.swiftmodule`);
|
|
4107
|
+
const interfaces = files(
|
|
4108
|
+
swiftmodule,
|
|
4109
|
+
(name) => name.endsWith(".swiftinterface") && !name.endsWith(".private.swiftinterface") && !name.endsWith(".package.swiftinterface")
|
|
4110
|
+
);
|
|
4111
|
+
const chosen = interfaces.find((name) => name.startsWith("arm64-")) ?? interfaces[0] ?? null;
|
|
4112
|
+
if (chosen) {
|
|
4113
|
+
found.push({
|
|
4114
|
+
kind: "swift",
|
|
4115
|
+
module: module2,
|
|
4116
|
+
interface: import_node_path11.default.join(swiftmodule, chosen)
|
|
4117
|
+
});
|
|
4118
|
+
continue;
|
|
4119
|
+
}
|
|
4120
|
+
const modulemap = import_node_path11.default.join(framework, "Modules", "module.modulemap");
|
|
4121
|
+
if (import_node_fs10.default.existsSync(modulemap))
|
|
4122
|
+
found.push({
|
|
4123
|
+
kind: "c",
|
|
4124
|
+
module: module2,
|
|
4125
|
+
modulemap,
|
|
4126
|
+
headers: import_node_path11.default.join(framework, "Headers")
|
|
4127
|
+
});
|
|
4128
|
+
}
|
|
4129
|
+
const headers = import_node_path11.default.join(root, "Headers");
|
|
4130
|
+
for (const map of files(headers, (name) => name === "module.modulemap")) {
|
|
4131
|
+
const modulemap = import_node_path11.default.join(headers, map);
|
|
4132
|
+
const module2 = /(?:^|\s)module\s+(\w+)/.exec(import_node_fs10.default.readFileSync(modulemap, "utf8"))?.[1];
|
|
4133
|
+
if (module2) found.push({ kind: "c", module: module2, modulemap, headers });
|
|
4134
|
+
}
|
|
4135
|
+
return found;
|
|
4136
|
+
}
|
|
4137
|
+
function peachModuleDirs(toolchain, imports) {
|
|
4138
|
+
const { moduleRoot, toolchainBin } = toolchain;
|
|
4139
|
+
if (swiftDistributionAt(moduleRoot)) return [import_node_path11.default.join(moduleRoot, "modules")];
|
|
4140
|
+
const peach = new Set(swiftPeachModules(moduleRoot));
|
|
4141
|
+
const plugins = swiftMacroPlugins(moduleRoot);
|
|
4142
|
+
if (plugins.stale)
|
|
4143
|
+
exec("sh", [
|
|
4144
|
+
import_node_path11.default.join(moduleRoot, "scripts/build-preview-plugin.sh"),
|
|
4145
|
+
toolchainBin,
|
|
4146
|
+
plugins.libraries[0]
|
|
4147
|
+
]);
|
|
4148
|
+
for (const target of imports.filter((name) => peach.has(name)))
|
|
4149
|
+
exec(
|
|
4150
|
+
import_node_path11.default.join(toolchainBin, "swift"),
|
|
4151
|
+
[
|
|
4152
|
+
"build",
|
|
4153
|
+
"--swift-sdk",
|
|
4154
|
+
swiftModuleSdk(moduleRoot).wasmSdkId,
|
|
4155
|
+
"-c",
|
|
4156
|
+
"release",
|
|
4157
|
+
"--target",
|
|
4158
|
+
target,
|
|
4159
|
+
"-Xswiftc",
|
|
4160
|
+
"-Osize",
|
|
4161
|
+
...plugins.libraries.flatMap((library) => [
|
|
4162
|
+
"-Xswiftc",
|
|
4163
|
+
"-load-plugin-library",
|
|
4164
|
+
"-Xswiftc",
|
|
4165
|
+
library
|
|
4166
|
+
])
|
|
4167
|
+
],
|
|
4168
|
+
moduleRoot
|
|
4169
|
+
);
|
|
4170
|
+
return [import_node_path11.default.join(moduleRoot, ".build", TRIPLE, "release", "Modules")];
|
|
4171
|
+
}
|
|
4172
|
+
function swiftInterfaceForWasm(text3) {
|
|
4173
|
+
return text3.replace(
|
|
4174
|
+
/^(\/\/ swift-module-flags:.*)$/m,
|
|
4175
|
+
(flags) => flags.replace(/-target \S+/, `-target ${TRIPLE}`).replace(/\s-enable-objc-interop\b/, "").replace(/\s-target-variant \S+/, "")
|
|
4176
|
+
).replace(
|
|
4177
|
+
/@(?:objc(?:\s*\([^()]*\))?|objcMembers|nonobjc|IBOutlet|IBAction|IBInspectable|IBDesignable|_objcRuntimeName\([^()]*\))(?![\w(])/g,
|
|
4178
|
+
""
|
|
4179
|
+
);
|
|
4180
|
+
}
|
|
4181
|
+
function swiftStandin(surface, binary, toolchain, work) {
|
|
4182
|
+
const text3 = swiftInterfaceForWasm(import_node_fs10.default.readFileSync(surface.interface, "utf8"));
|
|
4183
|
+
const search = import_node_path11.default.join(work, "interfaces");
|
|
4184
|
+
const moduleDir = import_node_path11.default.join(search, `${surface.module}.swiftmodule`);
|
|
4185
|
+
import_node_fs10.default.mkdirSync(moduleDir, { recursive: true });
|
|
4186
|
+
import_node_fs10.default.writeFileSync(import_node_path11.default.join(moduleDir, `${TRIPLE}.swiftinterface`), text3);
|
|
4187
|
+
const imports = [
|
|
4188
|
+
...text3.matchAll(
|
|
4189
|
+
/^(?:@_exported[ \t]+)?import[ \t]+(?:(?:struct|class|enum|protocol|typealias|func|var|let)[ \t]+)?(\w+)/gm
|
|
4190
|
+
)
|
|
4191
|
+
].map((match) => match[1]);
|
|
4192
|
+
const { sysroot, resources } = swiftSdkPaths(
|
|
4193
|
+
toolchain.moduleRoot,
|
|
4194
|
+
toolchain.toolchainBin
|
|
4195
|
+
);
|
|
4196
|
+
const target = ["-target", TRIPLE, "-sdk", sysroot, "-resource-dir", resources];
|
|
4197
|
+
const peach = peachModuleDirs(toolchain, imports).flatMap((dir) => ["-I", dir]);
|
|
4198
|
+
const out = import_node_path11.default.join(work, "graphs");
|
|
4199
|
+
import_node_fs10.default.mkdirSync(out, { recursive: true });
|
|
4200
|
+
exec(import_node_path11.default.join(toolchain.toolchainBin, "swift-symbolgraph-extract"), [
|
|
4201
|
+
"-module-name",
|
|
4202
|
+
surface.module,
|
|
4203
|
+
...target,
|
|
4204
|
+
"-I",
|
|
4205
|
+
search,
|
|
4206
|
+
...peach,
|
|
4207
|
+
"-minimum-access-level",
|
|
4208
|
+
"public",
|
|
4209
|
+
"-skip-synthesized-members",
|
|
4210
|
+
"-omit-extension-block-symbols",
|
|
4211
|
+
"-output-dir",
|
|
4212
|
+
out
|
|
4213
|
+
]);
|
|
4214
|
+
const graphs = import_node_fs10.default.readdirSync(out).filter((name) => name.endsWith(".symbols.json")).sort().map((name) => JSON.parse(import_node_fs10.default.readFileSync(import_node_path11.default.join(out, name), "utf8")));
|
|
4215
|
+
const omit = /* @__PURE__ */ new Map();
|
|
4216
|
+
const plain = /* @__PURE__ */ new Set();
|
|
4217
|
+
const file = import_node_path11.default.join(work, `${surface.module}.swift`);
|
|
4218
|
+
for (; ; ) {
|
|
4219
|
+
const { source, owners } = emitSwiftStandin(graphs, {
|
|
4220
|
+
module: surface.module,
|
|
4221
|
+
source: `${binary.target} (${binary.source})`,
|
|
4222
|
+
omit,
|
|
4223
|
+
plain
|
|
4224
|
+
});
|
|
4225
|
+
import_node_fs10.default.writeFileSync(file, source);
|
|
4226
|
+
const check = (0, import_node_child_process7.spawnSync)(
|
|
4227
|
+
import_node_path11.default.join(toolchain.toolchainBin, "swiftc"),
|
|
4228
|
+
[
|
|
4229
|
+
"-typecheck",
|
|
4230
|
+
"-parse-as-library",
|
|
4231
|
+
"-swift-version",
|
|
4232
|
+
"5",
|
|
4233
|
+
"-module-name",
|
|
4234
|
+
surface.module,
|
|
4235
|
+
...target,
|
|
4236
|
+
...peach,
|
|
4237
|
+
file
|
|
4238
|
+
],
|
|
4239
|
+
{ encoding: "utf8", maxBuffer: 256 * 1024 * 1024 }
|
|
4240
|
+
);
|
|
4241
|
+
if (check.status === 0)
|
|
4242
|
+
return {
|
|
4243
|
+
module: surface.module,
|
|
4244
|
+
target: binary.target,
|
|
4245
|
+
files: { [`${surface.module}.swift`]: source }
|
|
4246
|
+
};
|
|
4247
|
+
const before = omit.size + plain.size;
|
|
4248
|
+
const elsewhere = [];
|
|
4249
|
+
for (const match of check.stderr.matchAll(/^(\S+?):(\d+):\d+: error: (.*)$/gm)) {
|
|
4250
|
+
const owner = match[1] === file ? owners[Number(match[2]) - 1] : void 0;
|
|
4251
|
+
if (owner && /does not override any|overrides nothing/.test(match[3]))
|
|
4252
|
+
plain.add(owner);
|
|
4253
|
+
else if (owner) omit.set(owner, `rejected by swiftc: ${match[3]}`);
|
|
4254
|
+
else elsewhere.push(match[3]);
|
|
4255
|
+
}
|
|
4256
|
+
if (omit.size + plain.size === before)
|
|
4257
|
+
throw new Error(
|
|
4258
|
+
`its generated source does not typecheck: ${elsewhere.slice(0, 3).join("; ") || check.stderr.trim().slice(0, 400)}`
|
|
4259
|
+
);
|
|
4260
|
+
}
|
|
4261
|
+
}
|
|
4262
|
+
var OBJC = /^\s*(?:@interface|@protocol|@class|@import|#import)\b/m;
|
|
4263
|
+
function functionDeclarations(ast, headers) {
|
|
4264
|
+
const found = [];
|
|
4265
|
+
let file = "";
|
|
4266
|
+
const note = (location) => {
|
|
4267
|
+
if (!location || typeof location !== "object") return;
|
|
4268
|
+
const expansion = Reflect.get(location, "expansionLoc");
|
|
4269
|
+
const at = expansion && typeof expansion === "object" ? expansion : location;
|
|
4270
|
+
const named = Reflect.get(at, "file");
|
|
4271
|
+
if (typeof named === "string") file = named;
|
|
4272
|
+
};
|
|
4273
|
+
const walk2 = (node) => {
|
|
4274
|
+
if (Array.isArray(node)) {
|
|
4275
|
+
for (const item of node) walk2(item);
|
|
4276
|
+
return;
|
|
4277
|
+
}
|
|
4278
|
+
if (!node || typeof node !== "object") return;
|
|
4279
|
+
for (const [field, value] of Object.entries(node)) {
|
|
4280
|
+
if (field === "loc") note(value);
|
|
4281
|
+
else if (field === "range" && value && typeof value === "object") {
|
|
4282
|
+
note(Reflect.get(value, "begin"));
|
|
4283
|
+
note(Reflect.get(value, "end"));
|
|
4284
|
+
} else if (value && typeof value === "object") walk2(value);
|
|
4285
|
+
}
|
|
4286
|
+
};
|
|
4287
|
+
const top = ast && typeof ast === "object" ? Reflect.get(ast, "inner") : null;
|
|
4288
|
+
for (const decl of Array.isArray(top) ? top : []) {
|
|
4289
|
+
note(Reflect.get(decl, "loc"));
|
|
4290
|
+
const declFile = file;
|
|
4291
|
+
walk2(decl);
|
|
4292
|
+
if (Reflect.get(decl, "kind") !== "FunctionDecl" || !headers.has(declFile)) continue;
|
|
4293
|
+
if (Reflect.get(decl, "isImplicit") || Reflect.get(decl, "storageClass") === "static")
|
|
4294
|
+
continue;
|
|
4295
|
+
const inner = Reflect.get(decl, "inner");
|
|
4296
|
+
if (Array.isArray(inner) && inner.some((child) => Reflect.get(child, "kind") === "CompoundStmt"))
|
|
4297
|
+
continue;
|
|
4298
|
+
const range2 = Reflect.get(decl, "range");
|
|
4299
|
+
const offset = (end) => {
|
|
4300
|
+
const at = Reflect.get(range2, end);
|
|
4301
|
+
const expansion = Reflect.get(at, "expansionLoc");
|
|
4302
|
+
return Number(Reflect.get(expansion ?? at, "offset"));
|
|
4303
|
+
};
|
|
4304
|
+
found.push({
|
|
4305
|
+
name: String(Reflect.get(decl, "name")),
|
|
4306
|
+
file: declFile,
|
|
4307
|
+
begin: offset("begin"),
|
|
4308
|
+
end: offset("end")
|
|
4309
|
+
});
|
|
4310
|
+
}
|
|
4311
|
+
return found;
|
|
4312
|
+
}
|
|
4313
|
+
function cStandin(surface, binary, toolchain, work) {
|
|
4314
|
+
const named = [
|
|
4315
|
+
...import_node_fs10.default.readFileSync(surface.modulemap, "utf8").matchAll(/(?:umbrella\s+)?header\s+"([^"]+)"/g)
|
|
4316
|
+
].map((match) => match[1]);
|
|
4317
|
+
const headers = files(surface.headers, (name) => name.endsWith(".h"));
|
|
4318
|
+
const texts = new Map(
|
|
4319
|
+
headers.map((file) => [
|
|
4320
|
+
file,
|
|
4321
|
+
import_node_fs10.default.readFileSync(import_node_path11.default.join(surface.headers, file), "utf8")
|
|
4322
|
+
])
|
|
4323
|
+
);
|
|
4324
|
+
const objc = headers.find((file) => OBJC.test(texts.get(file)));
|
|
4325
|
+
if (objc) throw new Error(`its header ${objc} is Objective-C`);
|
|
4326
|
+
const include = import_node_path11.default.join(work, "include");
|
|
4327
|
+
for (const [file, text3] of texts) {
|
|
4328
|
+
import_node_fs10.default.mkdirSync(import_node_path11.default.dirname(import_node_path11.default.join(include, file)), { recursive: true });
|
|
4329
|
+
import_node_fs10.default.writeFileSync(import_node_path11.default.join(include, file), text3);
|
|
4330
|
+
}
|
|
4331
|
+
const roots = named.length > 0 ? named : headers;
|
|
4332
|
+
const modulemap = `module ${surface.module} {
|
|
4333
|
+
${roots.map((file) => ` header "${file}"
|
|
4334
|
+
`).join("")} export *
|
|
4335
|
+
}
|
|
4336
|
+
`;
|
|
4337
|
+
const probe = import_node_path11.default.join(work, "declarations.c");
|
|
4338
|
+
import_node_fs10.default.writeFileSync(probe, roots.map((file) => `#include "${file}"
|
|
4339
|
+
`).join(""));
|
|
4340
|
+
const { sysroot } = swiftSdkPaths(toolchain.moduleRoot, toolchain.toolchainBin);
|
|
4341
|
+
const ast = JSON.parse(
|
|
4342
|
+
exec(import_node_path11.default.join(toolchain.toolchainBin, "clang"), [
|
|
4343
|
+
"-target",
|
|
4344
|
+
TRIPLE,
|
|
4345
|
+
"--sysroot",
|
|
4346
|
+
sysroot,
|
|
4347
|
+
"-fsyntax-only",
|
|
4348
|
+
"-I",
|
|
4349
|
+
include,
|
|
4350
|
+
"-Xclang",
|
|
4351
|
+
"-ast-dump=json",
|
|
4352
|
+
probe
|
|
4353
|
+
])
|
|
4354
|
+
);
|
|
4355
|
+
const byPath = new Map(headers.map((file) => [import_node_path11.default.join(include, file), file]));
|
|
4356
|
+
const declarations = functionDeclarations(ast, new Set(byPath.keys()));
|
|
4357
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4358
|
+
const definitions = [];
|
|
4359
|
+
for (const { name, file, begin, end } of declarations) {
|
|
4360
|
+
if (seen.has(name)) continue;
|
|
4361
|
+
seen.add(name);
|
|
4362
|
+
const text3 = texts.get(byPath.get(file));
|
|
4363
|
+
const close = text3.indexOf(";", end);
|
|
4364
|
+
if (close < 0)
|
|
4365
|
+
throw new Error(`${name} has no declaration end in ${byPath.get(file)}`);
|
|
4366
|
+
definitions.push(
|
|
4367
|
+
`${text3.slice(begin, close).trim()} {
|
|
4368
|
+
peach_standin_trap("${name}");
|
|
4369
|
+
}
|
|
4370
|
+
`
|
|
4371
|
+
);
|
|
4372
|
+
}
|
|
4373
|
+
const sdk = JSON.stringify(`${binary.target} (${binary.source})`);
|
|
4374
|
+
const source = [
|
|
4375
|
+
`// generated by peach from ${surface.module}'s headers: ${binary.target} ships`,
|
|
4376
|
+
"// iOS machine code only, so every function traps naming itself.",
|
|
4377
|
+
...roots.map((file) => `#include "${file}"`),
|
|
4378
|
+
"#include <stdio.h>",
|
|
4379
|
+
"#include <stdlib.h>",
|
|
4380
|
+
"",
|
|
4381
|
+
"static _Noreturn void peach_standin_trap(const char *symbol) {",
|
|
4382
|
+
` fprintf(stderr, "Peach: %s is a vendored binary framework with no WebAssembly build; ${surface.module}.%s cannot run\\n", ${sdk}, symbol);`,
|
|
4383
|
+
" abort();",
|
|
4384
|
+
"}",
|
|
4385
|
+
"",
|
|
4386
|
+
...definitions
|
|
4387
|
+
].join("\n");
|
|
4388
|
+
return {
|
|
4389
|
+
module: surface.module,
|
|
4390
|
+
target: binary.target,
|
|
4391
|
+
files: {
|
|
4392
|
+
...Object.fromEntries(
|
|
4393
|
+
[...texts].map(([file, text3]) => [`include/${file}`, text3])
|
|
4394
|
+
),
|
|
4395
|
+
"include/module.modulemap": modulemap,
|
|
4396
|
+
[`${surface.module}.c`]: source
|
|
4397
|
+
}
|
|
4398
|
+
};
|
|
4399
|
+
}
|
|
4400
|
+
var built = /* @__PURE__ */ new Map();
|
|
4401
|
+
function binaryStandins(binary, toolchain) {
|
|
4402
|
+
let found;
|
|
4403
|
+
try {
|
|
4404
|
+
found = surfaces(xcframework(binary));
|
|
4405
|
+
} catch (error) {
|
|
4406
|
+
return error instanceof Error ? error.message : String(error);
|
|
4407
|
+
}
|
|
4408
|
+
if (found.length === 0)
|
|
4409
|
+
return "its iOS simulator slice has no Swift interface or C modulemap";
|
|
4410
|
+
const hash = (0, import_node_crypto6.createHash)("sha256").update(
|
|
4411
|
+
`standin/v1\0${toolchain.toolchainBin}\0${swiftModuleSdk(toolchain.moduleRoot).wasmSdkId}\0${toolchain.moduleRoot}\0${binary.target}\0${binary.source}\0`
|
|
4412
|
+
);
|
|
4413
|
+
for (const surface of found) {
|
|
4414
|
+
hash.update(`${surface.kind}\0${surface.module}\0`);
|
|
4415
|
+
for (const file of surface.kind === "swift" ? [surface.interface] : [
|
|
4416
|
+
surface.modulemap,
|
|
4417
|
+
...files(surface.headers, (name) => name.endsWith(".h")).map(
|
|
4418
|
+
(file2) => import_node_path11.default.join(surface.headers, file2)
|
|
4419
|
+
)
|
|
4420
|
+
])
|
|
4421
|
+
hash.update(import_node_fs10.default.readFileSync(file));
|
|
4422
|
+
}
|
|
4423
|
+
const id = hash.digest("hex").slice(0, 32);
|
|
4424
|
+
const memo2 = built.get(id);
|
|
4425
|
+
if (memo2) return memo2;
|
|
4426
|
+
const cached = import_node_path11.default.join(cacheDir3, "standins", `${id}.json`);
|
|
4427
|
+
if (import_node_fs10.default.existsSync(cached)) {
|
|
4428
|
+
const value = JSON.parse(import_node_fs10.default.readFileSync(cached, "utf8"));
|
|
4429
|
+
built.set(id, value);
|
|
4430
|
+
return value;
|
|
4431
|
+
}
|
|
4432
|
+
const work = import_node_fs10.default.mkdtempSync(import_node_path11.default.join(import_node_os7.default.tmpdir(), "peach-standin-"));
|
|
4433
|
+
let result;
|
|
4434
|
+
try {
|
|
4435
|
+
result = found.map((surface) => {
|
|
4436
|
+
const dir = import_node_path11.default.join(work, surface.module);
|
|
4437
|
+
try {
|
|
4438
|
+
return surface.kind === "swift" ? swiftStandin(surface, binary, toolchain, dir) : cStandin(surface, binary, toolchain, dir);
|
|
4439
|
+
} catch (error) {
|
|
4440
|
+
throw new Error(
|
|
4441
|
+
`no stand-in for ${surface.module}: ${error instanceof Error && !("stderr" in error) ? error.message : failure(error)}`
|
|
4442
|
+
);
|
|
4443
|
+
}
|
|
4444
|
+
});
|
|
4445
|
+
import_node_fs10.default.mkdirSync(import_node_path11.default.dirname(cached), { recursive: true });
|
|
4446
|
+
import_node_fs10.default.writeFileSync(cached, JSON.stringify(result));
|
|
4447
|
+
built.set(id, result);
|
|
4448
|
+
} catch (error) {
|
|
4449
|
+
result = error instanceof Error ? error.message : String(error);
|
|
4450
|
+
} finally {
|
|
4451
|
+
import_node_fs10.default.rmSync(work, { recursive: true, force: true });
|
|
4452
|
+
}
|
|
3513
4453
|
return result;
|
|
3514
4454
|
}
|
|
4455
|
+
function swiftStandins(binaries, toolchain) {
|
|
4456
|
+
const standins = [];
|
|
4457
|
+
const gaps = /* @__PURE__ */ new Map();
|
|
4458
|
+
for (const binary of binaries) {
|
|
4459
|
+
const result = binaryStandins(binary, toolchain);
|
|
4460
|
+
if (typeof result === "string") gaps.set(binary.target, result);
|
|
4461
|
+
else standins.push(...result);
|
|
4462
|
+
}
|
|
4463
|
+
return { standins, gaps };
|
|
4464
|
+
}
|
|
3515
4465
|
|
|
3516
4466
|
// src/swift-submit.ts
|
|
3517
4467
|
var SWIFT_COMPILE_PATH = "/api/swift-compile";
|
|
@@ -3650,15 +4600,15 @@ async function compileSwiftProject(submit, work, origin, signal) {
|
|
|
3650
4600
|
}
|
|
3651
4601
|
|
|
3652
4602
|
// src/xcode-project.ts
|
|
3653
|
-
var
|
|
3654
|
-
var
|
|
4603
|
+
var import_node_fs11 = __toESM(require("node:fs"), 1);
|
|
4604
|
+
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
3655
4605
|
var import_plist = __toESM(require_plist(), 1);
|
|
3656
4606
|
|
|
3657
4607
|
// src/xcode-json-project.ts
|
|
3658
|
-
var
|
|
4608
|
+
var import_node_path12 = __toESM(require("node:path"), 1);
|
|
3659
4609
|
var import_json5 = __toESM(require("json5"), 1);
|
|
3660
4610
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3661
|
-
var
|
|
4611
|
+
var text2 = (value) => typeof value === "string" ? value : void 0;
|
|
3662
4612
|
var items = (value) => Array.isArray(value) ? value : [];
|
|
3663
4613
|
var PHASE_ISA = {
|
|
3664
4614
|
"compile-sources": "PBXSourcesBuildPhase",
|
|
@@ -3671,20 +4621,20 @@ var PHASE_ISA = {
|
|
|
3671
4621
|
function readXcodeJsonProject(xcodeproj, source) {
|
|
3672
4622
|
const json = import_json5.default.parse(source);
|
|
3673
4623
|
if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
|
|
3674
|
-
const projectDir =
|
|
4624
|
+
const projectDir = import_node_path12.default.dirname(xcodeproj);
|
|
3675
4625
|
const objects = {};
|
|
3676
4626
|
let next = 0;
|
|
3677
4627
|
const add = (entry, id) => {
|
|
3678
|
-
const
|
|
3679
|
-
objects[
|
|
3680
|
-
return
|
|
4628
|
+
const key2 = id ?? `XCPROJ${(next++).toString(16).toUpperCase().padStart(18, "0")}`;
|
|
4629
|
+
objects[key2] = entry;
|
|
4630
|
+
return key2;
|
|
3681
4631
|
};
|
|
3682
4632
|
const locate = (raw2, groupDir) => {
|
|
3683
4633
|
if (raw2.startsWith("<USER:")) return null;
|
|
3684
4634
|
const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
|
|
3685
4635
|
if (base) {
|
|
3686
4636
|
if (base[1] === "PROJECT")
|
|
3687
|
-
return { sourceTree: "<absolute>", path:
|
|
4637
|
+
return { sourceTree: "<absolute>", path: import_node_path12.default.join(projectDir, base[2]) };
|
|
3688
4638
|
if (base[1] === "PRODUCTS")
|
|
3689
4639
|
return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
|
|
3690
4640
|
return null;
|
|
@@ -3692,7 +4642,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3692
4642
|
const unescaped = raw2.replaceAll("\\<", "<");
|
|
3693
4643
|
if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
|
|
3694
4644
|
if (unescaped.startsWith("~")) return null;
|
|
3695
|
-
return groupDir === null ? null : { sourceTree: "<absolute>", path:
|
|
4645
|
+
return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path12.default.join(groupDir, unescaped) };
|
|
3696
4646
|
};
|
|
3697
4647
|
const memberships = [];
|
|
3698
4648
|
const folders = [];
|
|
@@ -3700,10 +4650,10 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3700
4650
|
const root = { id: "", name: "", dir: projectDir, parent: null, children: [] };
|
|
3701
4651
|
const walk2 = (entries, parent) => entries.flatMap((entry) => {
|
|
3702
4652
|
if (!isObject(entry)) return [];
|
|
3703
|
-
const kind =
|
|
3704
|
-
const raw2 =
|
|
4653
|
+
const kind = text2(entry.kind) ?? "file-reference";
|
|
4654
|
+
const raw2 = text2(entry.path) ?? "";
|
|
3705
4655
|
const located = raw2 === "" ? null : locate(raw2, parent.dir);
|
|
3706
|
-
const name =
|
|
4656
|
+
const name = text2(entry.name) ?? import_node_path12.default.basename(raw2);
|
|
3707
4657
|
const node = { id: "", name, dir: null, parent, children: [] };
|
|
3708
4658
|
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
3709
4659
|
node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
@@ -3719,7 +4669,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3719
4669
|
...kind === "variant-group" ? {} : { sourceTree: "<absolute>", path: node.dir ?? "" },
|
|
3720
4670
|
name
|
|
3721
4671
|
},
|
|
3722
|
-
|
|
4672
|
+
text2(entry.id)
|
|
3723
4673
|
);
|
|
3724
4674
|
} else if (kind === "folder") {
|
|
3725
4675
|
node.id = add(
|
|
@@ -3727,7 +4677,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3727
4677
|
isa: "PBXFileSystemSynchronizedRootGroup",
|
|
3728
4678
|
...located ?? { sourceTree: "SDKROOT", path: raw2 }
|
|
3729
4679
|
},
|
|
3730
|
-
|
|
4680
|
+
text2(entry.id)
|
|
3731
4681
|
);
|
|
3732
4682
|
folders.push({ id: node.id, folder: entry });
|
|
3733
4683
|
} else {
|
|
@@ -3737,7 +4687,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3737
4687
|
...located ?? { sourceTree: "SDKROOT", path: raw2 },
|
|
3738
4688
|
name
|
|
3739
4689
|
},
|
|
3740
|
-
|
|
4690
|
+
text2(entry.id)
|
|
3741
4691
|
);
|
|
3742
4692
|
if (located?.sourceTree === "<absolute>" && located.path.endsWith(".xcodeproj"))
|
|
3743
4693
|
projectFiles.push(node.id);
|
|
@@ -3764,7 +4714,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3764
4714
|
if (Array.isArray(reference)) {
|
|
3765
4715
|
return lookupNode(
|
|
3766
4716
|
reference.map(
|
|
3767
|
-
(component) => isObject(component) ?
|
|
4717
|
+
(component) => isObject(component) ? text2(component.name) ?? "" : text2(component) ?? ""
|
|
3768
4718
|
).join("/"),
|
|
3769
4719
|
from
|
|
3770
4720
|
)?.id;
|
|
@@ -3772,7 +4722,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3772
4722
|
return lookupNode(reference, from)?.id;
|
|
3773
4723
|
};
|
|
3774
4724
|
const lookupNode = (reference, from) => {
|
|
3775
|
-
const value =
|
|
4725
|
+
const value = text2(reference);
|
|
3776
4726
|
if (value === void 0) return void 0;
|
|
3777
4727
|
if (value.startsWith("id:")) {
|
|
3778
4728
|
const id = value.slice(3);
|
|
@@ -3787,14 +4737,14 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3787
4737
|
return node;
|
|
3788
4738
|
};
|
|
3789
4739
|
const configurations = items(json.configurations).flatMap((entry) => {
|
|
3790
|
-
const name = isObject(entry) ?
|
|
4740
|
+
const name = isObject(entry) ? text2(entry.name) : text2(entry);
|
|
3791
4741
|
return name ? [{ name, file: isObject(entry) ? entry.file : void 0 }] : [];
|
|
3792
4742
|
});
|
|
3793
4743
|
const settingsOf = (value) => Object.fromEntries(
|
|
3794
4744
|
Object.entries(isObject(value) ? value : {}).flatMap(
|
|
3795
|
-
([
|
|
4745
|
+
([key2, setting]) => typeof setting === "string" ? [[key2, setting]] : Array.isArray(setting) ? [
|
|
3796
4746
|
[
|
|
3797
|
-
|
|
4747
|
+
key2,
|
|
3798
4748
|
setting.filter((item) => typeof item === "string")
|
|
3799
4749
|
]
|
|
3800
4750
|
] : []
|
|
@@ -3802,7 +4752,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3802
4752
|
);
|
|
3803
4753
|
const configurationList = (settings, specialized) => add({
|
|
3804
4754
|
isa: "XCConfigurationList",
|
|
3805
|
-
defaultConfigurationName:
|
|
4755
|
+
defaultConfigurationName: text2(json["default-configuration"]) ?? "Debug",
|
|
3806
4756
|
buildConfigurations: configurations.map(({ name, file }) => {
|
|
3807
4757
|
const base = lookup(specialized.has(name) ? specialized.get(name) : file);
|
|
3808
4758
|
return add({
|
|
@@ -3816,37 +4766,37 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3816
4766
|
const packageIds = /* @__PURE__ */ new Map();
|
|
3817
4767
|
for (const entry of items(json.packages)) {
|
|
3818
4768
|
if (!isObject(entry)) continue;
|
|
3819
|
-
const repository =
|
|
3820
|
-
const local =
|
|
3821
|
-
const name = local !== void 0 ?
|
|
3822
|
-
const id =
|
|
4769
|
+
const repository = text2(entry.repository);
|
|
4770
|
+
const local = text2(entry.path);
|
|
4771
|
+
const name = local !== void 0 ? import_node_path12.default.basename(import_node_path12.default.resolve(import_node_path12.default.dirname(xcodeproj), local)) : import_node_path12.default.basename(repository ?? "").replace(/\.git$/, "");
|
|
4772
|
+
const id = text2(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
3823
4773
|
packageIds.set(name.toLowerCase(), id);
|
|
3824
4774
|
}
|
|
3825
4775
|
const productDependency = (entry) => add({
|
|
3826
4776
|
isa: "XCSwiftPackageProductDependency",
|
|
3827
|
-
productName:
|
|
4777
|
+
productName: text2(entry["product-name"]) ?? "",
|
|
3828
4778
|
// xcode finds a product by name across packages when none is named
|
|
3829
|
-
...packageIds.has(
|
|
4779
|
+
...packageIds.has(text2(entry.package)?.toLowerCase() ?? "") ? { package: packageIds.get(text2(entry.package).toLowerCase()) } : {}
|
|
3830
4780
|
});
|
|
3831
4781
|
const proxy = (entry, remote, proxyType) => add({
|
|
3832
4782
|
isa: "PBXContainerItemProxy",
|
|
3833
4783
|
containerPortal: lookup(entry.project) ?? "",
|
|
3834
4784
|
proxyType,
|
|
3835
4785
|
remoteGlobalIDString: remote ?? "",
|
|
3836
|
-
remoteInfo:
|
|
4786
|
+
remoteInfo: text2(entry.target) ?? ""
|
|
3837
4787
|
});
|
|
3838
4788
|
const phases = /* @__PURE__ */ new Map();
|
|
3839
4789
|
const targetIds = /* @__PURE__ */ new Map();
|
|
3840
4790
|
const targets = [];
|
|
3841
4791
|
for (const entry of items(json.targets)) {
|
|
3842
4792
|
if (!isObject(entry)) continue;
|
|
3843
|
-
const name =
|
|
3844
|
-
const productType =
|
|
4793
|
+
const name = text2(entry.name) ?? "";
|
|
4794
|
+
const productType = text2(entry["product-type"]);
|
|
3845
4795
|
const target = {
|
|
3846
|
-
isa:
|
|
4796
|
+
isa: text2(entry.kind) === "aggregate" ? "PBXAggregateTarget" : "PBXNativeTarget",
|
|
3847
4797
|
name,
|
|
3848
4798
|
productName: name,
|
|
3849
|
-
productType: productType ? `com.apple.product-type.${productType}` :
|
|
4799
|
+
productType: productType ? `com.apple.product-type.${productType}` : text2(entry["full-product-type"]) ?? "",
|
|
3850
4800
|
buildPhases: [],
|
|
3851
4801
|
dependencies: [],
|
|
3852
4802
|
packageProductDependencies: [],
|
|
@@ -3854,17 +4804,17 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3854
4804
|
};
|
|
3855
4805
|
const product = lookup(entry.product);
|
|
3856
4806
|
if (product) target.productReference = product;
|
|
3857
|
-
const id = add(target,
|
|
4807
|
+
const id = add(target, text2(entry.id));
|
|
3858
4808
|
targetIds.set(name, id);
|
|
3859
4809
|
targets.push({ id, target, entry });
|
|
3860
4810
|
for (const phase of items(entry["build-phases"])) {
|
|
3861
|
-
const kind = isObject(phase) ?
|
|
4811
|
+
const kind = isObject(phase) ? text2(phase.kind) : text2(phase);
|
|
3862
4812
|
const isa = kind ? PHASE_ISA[kind] : void 0;
|
|
3863
4813
|
if (!kind || !isa) continue;
|
|
3864
|
-
const phaseName = isObject(phase) ?
|
|
4814
|
+
const phaseName = isObject(phase) ? text2(phase.name) : void 0;
|
|
3865
4815
|
const phaseId = add(
|
|
3866
4816
|
{ isa, files: [] },
|
|
3867
|
-
isObject(phase) ?
|
|
4817
|
+
isObject(phase) ? text2(phase.id) : void 0
|
|
3868
4818
|
);
|
|
3869
4819
|
target.buildPhases.push(phaseId);
|
|
3870
4820
|
phases.set([name, kind, phaseName].filter(Boolean).join("/"), phaseId);
|
|
@@ -3872,28 +4822,28 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3872
4822
|
}
|
|
3873
4823
|
}
|
|
3874
4824
|
const phaseFiles = (reference, targetName) => {
|
|
3875
|
-
const value =
|
|
4825
|
+
const value = text2(reference);
|
|
3876
4826
|
if (value === void 0) return null;
|
|
3877
|
-
const
|
|
3878
|
-
const phase = objects[phases.get(
|
|
4827
|
+
const key2 = value.startsWith("id:") || !targetName ? value : `${targetName}/${value}`;
|
|
4828
|
+
const phase = objects[phases.get(key2) ?? ""];
|
|
3879
4829
|
return phase && typeof phase === "object" && !Array.isArray(phase) && Array.isArray(phase.files) ? phase.files : null;
|
|
3880
4830
|
};
|
|
3881
4831
|
for (const { refId, entry } of memberships) {
|
|
3882
|
-
const
|
|
3883
|
-
|
|
4832
|
+
const files2 = phaseFiles(isObject(entry) ? entry["build-phase"] : entry);
|
|
4833
|
+
files2?.push(add({ isa: "PBXBuildFile", fileRef: refId }));
|
|
3884
4834
|
}
|
|
3885
4835
|
for (const { target, entry } of targets) {
|
|
3886
|
-
const name =
|
|
4836
|
+
const name = text2(entry.name) ?? "";
|
|
3887
4837
|
target.buildConfigurationList = configurationList(
|
|
3888
4838
|
settingsOf(entry["build-settings"]),
|
|
3889
4839
|
new Map(
|
|
3890
4840
|
items(entry["specialized-configurations"]).flatMap(
|
|
3891
|
-
(configuration) => isObject(configuration) &&
|
|
4841
|
+
(configuration) => isObject(configuration) && text2(configuration.name) ? [[text2(configuration.name), configuration.file]] : []
|
|
3892
4842
|
)
|
|
3893
4843
|
)
|
|
3894
4844
|
);
|
|
3895
4845
|
for (const dependency of items(entry.dependencies)) {
|
|
3896
|
-
const kind = isObject(dependency) ?
|
|
4846
|
+
const kind = isObject(dependency) ? text2(dependency.kind) ?? "localTarget" : "localTarget";
|
|
3897
4847
|
if (kind === "package" && isObject(dependency)) {
|
|
3898
4848
|
;
|
|
3899
4849
|
target.dependencies.push(
|
|
@@ -3904,11 +4854,11 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3904
4854
|
target.dependencies.push(
|
|
3905
4855
|
add({
|
|
3906
4856
|
isa: "PBXTargetDependency",
|
|
3907
|
-
targetProxy: proxy(dependency,
|
|
4857
|
+
targetProxy: proxy(dependency, text2(dependency["target-id"]), "1")
|
|
3908
4858
|
})
|
|
3909
4859
|
);
|
|
3910
4860
|
} else {
|
|
3911
|
-
const local = isObject(dependency) ?
|
|
4861
|
+
const local = isObject(dependency) ? text2(dependency.target) : text2(dependency);
|
|
3912
4862
|
const id = local ? targetIds.get(local) : void 0;
|
|
3913
4863
|
if (id)
|
|
3914
4864
|
target.dependencies.push(
|
|
@@ -3930,9 +4880,9 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3930
4880
|
if (!isObject(imported)) continue;
|
|
3931
4881
|
const reference = add({
|
|
3932
4882
|
isa: "PBXReferenceProxy",
|
|
3933
|
-
path:
|
|
4883
|
+
path: text2(imported.name) ?? text2(imported.path) ?? "",
|
|
3934
4884
|
sourceTree: "BUILT_PRODUCTS_DIR",
|
|
3935
|
-
remoteRef: proxy(imported,
|
|
4885
|
+
remoteRef: proxy(imported, text2(imported["product-id"]), "2")
|
|
3936
4886
|
});
|
|
3937
4887
|
for (const membership of items(imported["target-membership"])) {
|
|
3938
4888
|
phaseFiles(isObject(membership) ? membership["build-phase"] : membership)?.push(
|
|
@@ -3944,7 +4894,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3944
4894
|
const exceptions = [];
|
|
3945
4895
|
for (const exception of items(folder["membership-exceptions"])) {
|
|
3946
4896
|
if (!isObject(exception)) continue;
|
|
3947
|
-
const target = targetIds.get(
|
|
4897
|
+
const target = targetIds.get(text2(exception.target) ?? "");
|
|
3948
4898
|
if (!target) continue;
|
|
3949
4899
|
exceptions.push(
|
|
3950
4900
|
add({
|
|
@@ -3962,7 +4912,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3962
4912
|
group.exceptions = exceptions;
|
|
3963
4913
|
for (const owner of items(folder["target-membership"])) {
|
|
3964
4914
|
const target = targets.find(
|
|
3965
|
-
(candidate) => candidate.id === targetIds.get(
|
|
4915
|
+
(candidate) => candidate.id === targetIds.get(text2(owner) ?? "")
|
|
3966
4916
|
);
|
|
3967
4917
|
target?.target.fileSystemSynchronizedGroups?.push(id);
|
|
3968
4918
|
}
|
|
@@ -3972,7 +4922,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3972
4922
|
isa: "PBXProject",
|
|
3973
4923
|
mainGroup,
|
|
3974
4924
|
projectDirPath: "",
|
|
3975
|
-
developmentRegion:
|
|
4925
|
+
developmentRegion: text2(localizations.development) ?? "en",
|
|
3976
4926
|
buildConfigurationList: configurationList(
|
|
3977
4927
|
settingsOf(json["build-settings"]),
|
|
3978
4928
|
/* @__PURE__ */ new Map()
|
|
@@ -3988,23 +4938,23 @@ function isJsonObject(value) {
|
|
|
3988
4938
|
}
|
|
3989
4939
|
|
|
3990
4940
|
// src/xcode-project.ts
|
|
3991
|
-
function parseOpenStepPlist(
|
|
4941
|
+
function parseOpenStepPlist(text3) {
|
|
3992
4942
|
let i = 0;
|
|
3993
4943
|
const fail = (message) => {
|
|
3994
|
-
const line =
|
|
4944
|
+
const line = text3.slice(0, i).split("\n").length;
|
|
3995
4945
|
throw new Error(`project.pbxproj line ${line}: ${message}`);
|
|
3996
4946
|
};
|
|
3997
4947
|
const skip = () => {
|
|
3998
4948
|
for (; ; ) {
|
|
3999
|
-
const ch =
|
|
4949
|
+
const ch = text3[i];
|
|
4000
4950
|
if (ch === " " || ch === " " || ch === "\n" || ch === "\r") i++;
|
|
4001
|
-
else if (ch === "/" &&
|
|
4002
|
-
const end =
|
|
4951
|
+
else if (ch === "/" && text3[i + 1] === "*") {
|
|
4952
|
+
const end = text3.indexOf("*/", i + 2);
|
|
4003
4953
|
if (end < 0) fail("unterminated comment");
|
|
4004
4954
|
i = end + 2;
|
|
4005
|
-
} else if (ch === "/" &&
|
|
4006
|
-
const end =
|
|
4007
|
-
i = end < 0 ?
|
|
4955
|
+
} else if (ch === "/" && text3[i + 1] === "/") {
|
|
4956
|
+
const end = text3.indexOf("\n", i);
|
|
4957
|
+
i = end < 0 ? text3.length : end + 1;
|
|
4008
4958
|
} else return;
|
|
4009
4959
|
}
|
|
4010
4960
|
};
|
|
@@ -4012,42 +4962,42 @@ function parseOpenStepPlist(text2) {
|
|
|
4012
4962
|
i++;
|
|
4013
4963
|
let out = "";
|
|
4014
4964
|
for (; ; ) {
|
|
4015
|
-
const ch =
|
|
4965
|
+
const ch = text3[i++];
|
|
4016
4966
|
if (ch === void 0) fail("unterminated string");
|
|
4017
4967
|
if (ch === '"') return out;
|
|
4018
4968
|
if (ch !== "\\") {
|
|
4019
4969
|
out += ch;
|
|
4020
4970
|
continue;
|
|
4021
4971
|
}
|
|
4022
|
-
const next =
|
|
4972
|
+
const next = text3[i++];
|
|
4023
4973
|
if (next === "n") out += "\n";
|
|
4024
4974
|
else if (next === "t") out += " ";
|
|
4025
4975
|
else if (next === "r") out += "\r";
|
|
4026
4976
|
else if (next === "U") {
|
|
4027
|
-
out += String.fromCharCode(parseInt(
|
|
4977
|
+
out += String.fromCharCode(parseInt(text3.slice(i, i + 4), 16));
|
|
4028
4978
|
i += 4;
|
|
4029
4979
|
} else out += next;
|
|
4030
4980
|
}
|
|
4031
4981
|
};
|
|
4032
4982
|
const value = () => {
|
|
4033
4983
|
skip();
|
|
4034
|
-
const ch =
|
|
4984
|
+
const ch = text3[i];
|
|
4035
4985
|
if (ch === "{") {
|
|
4036
4986
|
i++;
|
|
4037
4987
|
const dict = {};
|
|
4038
4988
|
for (; ; ) {
|
|
4039
4989
|
skip();
|
|
4040
|
-
if (
|
|
4990
|
+
if (text3[i] === "}") {
|
|
4041
4991
|
i++;
|
|
4042
4992
|
return dict;
|
|
4043
4993
|
}
|
|
4044
|
-
const
|
|
4045
|
-
if (typeof
|
|
4994
|
+
const key2 = value();
|
|
4995
|
+
if (typeof key2 !== "string") fail("dictionary key is not a string");
|
|
4046
4996
|
skip();
|
|
4047
|
-
if (
|
|
4048
|
-
dict[
|
|
4997
|
+
if (text3[i++] !== "=") fail("expected =");
|
|
4998
|
+
dict[key2] = value();
|
|
4049
4999
|
skip();
|
|
4050
|
-
if (
|
|
5000
|
+
if (text3[i++] !== ";") fail("expected ;");
|
|
4051
5001
|
}
|
|
4052
5002
|
}
|
|
4053
5003
|
if (ch === "(") {
|
|
@@ -4055,26 +5005,26 @@ function parseOpenStepPlist(text2) {
|
|
|
4055
5005
|
const list2 = [];
|
|
4056
5006
|
for (; ; ) {
|
|
4057
5007
|
skip();
|
|
4058
|
-
if (
|
|
5008
|
+
if (text3[i] === ")") {
|
|
4059
5009
|
i++;
|
|
4060
5010
|
return list2;
|
|
4061
5011
|
}
|
|
4062
5012
|
list2.push(value());
|
|
4063
5013
|
skip();
|
|
4064
|
-
if (
|
|
4065
|
-
else if (
|
|
5014
|
+
if (text3[i] === ",") i++;
|
|
5015
|
+
else if (text3[i] !== ")") fail("expected , or )");
|
|
4066
5016
|
}
|
|
4067
5017
|
}
|
|
4068
5018
|
if (ch === '"') return quoted();
|
|
4069
5019
|
const start = i;
|
|
4070
|
-
while (i <
|
|
5020
|
+
while (i < text3.length && /[A-Za-z0-9_$+/:.\-<>]/.test(text3[i])) i++;
|
|
4071
5021
|
if (i === start) fail(`unexpected ${JSON.stringify(ch ?? "end of file")}`);
|
|
4072
|
-
return
|
|
5022
|
+
return text3.slice(start, i);
|
|
4073
5023
|
};
|
|
4074
|
-
if (
|
|
5024
|
+
if (text3.startsWith("// !$*UTF8*$!")) i = text3.indexOf("\n") + 1;
|
|
4075
5025
|
const root = value();
|
|
4076
5026
|
skip();
|
|
4077
|
-
if (i !==
|
|
5027
|
+
if (i !== text3.length) fail("trailing content");
|
|
4078
5028
|
return root;
|
|
4079
5029
|
}
|
|
4080
5030
|
var isDict = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -4095,28 +5045,28 @@ var CONDITIONS = {
|
|
|
4095
5045
|
variant: "normal"
|
|
4096
5046
|
};
|
|
4097
5047
|
function walkFiles(dir) {
|
|
4098
|
-
if (!
|
|
5048
|
+
if (!import_node_fs11.default.existsSync(dir)) return [];
|
|
4099
5049
|
const out = [];
|
|
4100
|
-
for (const entry of
|
|
5050
|
+
for (const entry of import_node_fs11.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
4101
5051
|
if (entry.name.startsWith(".")) continue;
|
|
4102
|
-
const full =
|
|
5052
|
+
const full = import_node_path13.default.join(dir, entry.name);
|
|
4103
5053
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
4104
5054
|
else if (entry.isFile()) out.push(full);
|
|
4105
5055
|
}
|
|
4106
5056
|
return out;
|
|
4107
5057
|
}
|
|
4108
|
-
var isDirectory = (dir) =>
|
|
5058
|
+
var isDirectory = (dir) => import_node_fs11.default.existsSync(dir) && import_node_fs11.default.statSync(dir).isDirectory();
|
|
4109
5059
|
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
4110
|
-
if (seen.has(file) || !
|
|
5060
|
+
if (seen.has(file) || !import_node_fs11.default.existsSync(file)) return {};
|
|
4111
5061
|
seen.add(file);
|
|
4112
5062
|
const settings = {};
|
|
4113
|
-
for (const raw2 of
|
|
5063
|
+
for (const raw2 of import_node_fs11.default.readFileSync(file, "utf8").split("\n")) {
|
|
4114
5064
|
const line = raw2.replace(/\/\/.*$/, "").trim();
|
|
4115
5065
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
4116
5066
|
if (include) {
|
|
4117
5067
|
Object.assign(
|
|
4118
5068
|
settings,
|
|
4119
|
-
readXcconfig(
|
|
5069
|
+
readXcconfig(import_node_path13.default.resolve(import_node_path13.default.dirname(file), include[1]), seen)
|
|
4120
5070
|
);
|
|
4121
5071
|
continue;
|
|
4122
5072
|
}
|
|
@@ -4129,13 +5079,13 @@ function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
|
4129
5079
|
function applyConditions(raw2, configuration) {
|
|
4130
5080
|
const plain = {};
|
|
4131
5081
|
const conditional = {};
|
|
4132
|
-
for (const [
|
|
4133
|
-
const bracket =
|
|
5082
|
+
for (const [key2, value] of Object.entries(raw2)) {
|
|
5083
|
+
const bracket = key2.indexOf("[");
|
|
4134
5084
|
if (bracket === -1) {
|
|
4135
|
-
plain[
|
|
5085
|
+
plain[key2] = value;
|
|
4136
5086
|
continue;
|
|
4137
5087
|
}
|
|
4138
|
-
const matches = [...
|
|
5088
|
+
const matches = [...key2.slice(bracket).matchAll(/\[([^=\]]+)=([^\]]*)\]/g)].every(
|
|
4139
5089
|
([, name, pattern]) => {
|
|
4140
5090
|
const actual = name === "config" ? configuration : CONDITIONS[name];
|
|
4141
5091
|
return actual !== void 0 && new RegExp(
|
|
@@ -4143,7 +5093,7 @@ function applyConditions(raw2, configuration) {
|
|
|
4143
5093
|
).test(actual);
|
|
4144
5094
|
}
|
|
4145
5095
|
);
|
|
4146
|
-
if (matches) conditional[
|
|
5096
|
+
if (matches) conditional[key2.slice(0, bracket)] = value;
|
|
4147
5097
|
}
|
|
4148
5098
|
return { ...plain, ...conditional };
|
|
4149
5099
|
}
|
|
@@ -4162,26 +5112,26 @@ function applyOperator(value, operator) {
|
|
|
4162
5112
|
}
|
|
4163
5113
|
throw new Error(`unsupported build setting operator :${operator}`);
|
|
4164
5114
|
}
|
|
4165
|
-
function decodeXml(
|
|
4166
|
-
return
|
|
5115
|
+
function decodeXml(text3) {
|
|
5116
|
+
return text3.replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
4167
5117
|
}
|
|
4168
5118
|
function workspaceReferences(workspace) {
|
|
4169
|
-
const data =
|
|
4170
|
-
if (!
|
|
5119
|
+
const data = import_node_path13.default.join(workspace, "contents.xcworkspacedata");
|
|
5120
|
+
if (!import_node_fs11.default.existsSync(data))
|
|
4171
5121
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
4172
|
-
const container =
|
|
5122
|
+
const container = import_node_path13.default.dirname(workspace);
|
|
4173
5123
|
const locate = (location, base) => {
|
|
4174
5124
|
const colon = location.indexOf(":");
|
|
4175
5125
|
const kind = location.slice(0, colon);
|
|
4176
5126
|
const rest = location.slice(colon + 1);
|
|
4177
|
-
if (kind === "group") return
|
|
4178
|
-
if (kind === "container" || kind === "self") return
|
|
4179
|
-
if (kind === "absolute") return
|
|
4180
|
-
throw new Error(`${
|
|
5127
|
+
if (kind === "group") return import_node_path13.default.resolve(base, rest);
|
|
5128
|
+
if (kind === "container" || kind === "self") return import_node_path13.default.resolve(container, rest);
|
|
5129
|
+
if (kind === "absolute") return import_node_path13.default.resolve(rest);
|
|
5130
|
+
throw new Error(`${import_node_path13.default.basename(workspace)} has an unsupported location ${location}`);
|
|
4181
5131
|
};
|
|
4182
5132
|
const groups = [container];
|
|
4183
5133
|
const references = [];
|
|
4184
|
-
for (const [, closing, tag, attributes, selfClosing] of
|
|
5134
|
+
for (const [, closing, tag, attributes, selfClosing] of import_node_fs11.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
|
|
4185
5135
|
if (closing) {
|
|
4186
5136
|
if (tag === "Group") groups.pop();
|
|
4187
5137
|
continue;
|
|
@@ -4197,8 +5147,8 @@ function workspaceReferences(workspace) {
|
|
|
4197
5147
|
var loaded = /* @__PURE__ */ new Map();
|
|
4198
5148
|
function xcodeProjectFile(xcodeproj) {
|
|
4199
5149
|
for (const name of ["project.pbxproj", "project.xcproj"]) {
|
|
4200
|
-
const file =
|
|
4201
|
-
if (
|
|
5150
|
+
const file = import_node_path13.default.join(xcodeproj, name);
|
|
5151
|
+
if (import_node_fs11.default.existsSync(file)) return file;
|
|
4202
5152
|
}
|
|
4203
5153
|
return null;
|
|
4204
5154
|
}
|
|
@@ -4206,10 +5156,10 @@ function loadProject(xcodeproj) {
|
|
|
4206
5156
|
const projectFile = xcodeProjectFile(xcodeproj);
|
|
4207
5157
|
if (!projectFile)
|
|
4208
5158
|
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
4209
|
-
const mtimeMs =
|
|
5159
|
+
const mtimeMs = import_node_fs11.default.statSync(projectFile).mtimeMs;
|
|
4210
5160
|
const cached = loaded.get(projectFile);
|
|
4211
5161
|
if (cached?.mtimeMs === mtimeMs) return cached.project;
|
|
4212
|
-
const source =
|
|
5162
|
+
const source = import_node_fs11.default.readFileSync(projectFile, "utf8");
|
|
4213
5163
|
const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
|
|
4214
5164
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
4215
5165
|
throw new Error(`${projectFile} has no objects table`);
|
|
@@ -4223,8 +5173,8 @@ function loadProject(xcodeproj) {
|
|
|
4223
5173
|
if (!project || project.isa !== "PBXProject") {
|
|
4224
5174
|
throw new Error(`${projectFile} has no PBXProject root`);
|
|
4225
5175
|
}
|
|
4226
|
-
const projectDir =
|
|
4227
|
-
|
|
5176
|
+
const projectDir = import_node_fs11.default.realpathSync(
|
|
5177
|
+
import_node_path13.default.resolve(import_node_path13.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
4228
5178
|
);
|
|
4229
5179
|
const parent = /* @__PURE__ */ new Map();
|
|
4230
5180
|
for (const [id, entry] of Object.entries(objects)) {
|
|
@@ -4242,11 +5192,11 @@ function loadProject(xcodeproj) {
|
|
|
4242
5192
|
const own = str(entry.path) ?? "";
|
|
4243
5193
|
const tree = str(entry.sourceTree) ?? "<group>";
|
|
4244
5194
|
if (tree === "<absolute>") result2 = own;
|
|
4245
|
-
else if (tree === "SOURCE_ROOT") result2 =
|
|
5195
|
+
else if (tree === "SOURCE_ROOT") result2 = import_node_path13.default.join(projectDir, own);
|
|
4246
5196
|
else if (tree === "<group>") {
|
|
4247
5197
|
const up = parent.get(id);
|
|
4248
5198
|
const base = up ? resolvePath(up) : projectDir;
|
|
4249
|
-
result2 = base === null ? null :
|
|
5199
|
+
result2 = base === null ? null : import_node_path13.default.join(base, own);
|
|
4250
5200
|
}
|
|
4251
5201
|
}
|
|
4252
5202
|
resolvedPaths.set(id, result2);
|
|
@@ -4278,7 +5228,7 @@ function targetSettings(ref, builtins) {
|
|
|
4278
5228
|
applyConditions(
|
|
4279
5229
|
Object.fromEntries(
|
|
4280
5230
|
Object.entries(own).flatMap(
|
|
4281
|
-
([
|
|
5231
|
+
([key2, value]) => typeof value === "string" ? [[key2, value]] : Array.isArray(value) ? [[key2, list(value).join(" ")]] : []
|
|
4282
5232
|
)
|
|
4283
5233
|
),
|
|
4284
5234
|
name
|
|
@@ -4291,24 +5241,24 @@ function targetSettings(ref, builtins) {
|
|
|
4291
5241
|
...level(str(target.buildConfigurationList))
|
|
4292
5242
|
];
|
|
4293
5243
|
const resolving = /* @__PURE__ */ new Set();
|
|
4294
|
-
const valueAt = (
|
|
5244
|
+
const valueAt = (key2, top) => {
|
|
4295
5245
|
let at = top;
|
|
4296
|
-
while (at >= 0 && levels[at][
|
|
4297
|
-
if (at < 0) return derived(
|
|
4298
|
-
const marker = `${
|
|
5246
|
+
while (at >= 0 && levels[at][key2] === void 0) at--;
|
|
5247
|
+
if (at < 0) return derived(key2);
|
|
5248
|
+
const marker = `${key2}@${at}`;
|
|
4299
5249
|
if (resolving.has(marker))
|
|
4300
|
-
throw new Error(`${str(target.name)} has a cyclic build setting ${
|
|
5250
|
+
throw new Error(`${str(target.name)} has a cyclic build setting ${key2}`);
|
|
4301
5251
|
resolving.add(marker);
|
|
4302
5252
|
const value = expand(
|
|
4303
|
-
levels[at][
|
|
4304
|
-
(name) => name === "inherited" ? valueAt(
|
|
5253
|
+
levels[at][key2],
|
|
5254
|
+
(name) => name === "inherited" ? valueAt(key2, at - 1) : valueAt(name, levels.length - 1)
|
|
4305
5255
|
);
|
|
4306
5256
|
resolving.delete(marker);
|
|
4307
5257
|
return value;
|
|
4308
5258
|
};
|
|
4309
|
-
const derived = (
|
|
5259
|
+
const derived = (key2) => {
|
|
4310
5260
|
const get = (name) => valueAt(name, levels.length - 1);
|
|
4311
|
-
switch (
|
|
5261
|
+
switch (key2) {
|
|
4312
5262
|
case "PRODUCT_NAME":
|
|
4313
5263
|
return get("TARGET_NAME");
|
|
4314
5264
|
case "PRODUCT_MODULE_NAME":
|
|
@@ -4324,7 +5274,7 @@ function targetSettings(ref, builtins) {
|
|
|
4324
5274
|
return "";
|
|
4325
5275
|
};
|
|
4326
5276
|
return {
|
|
4327
|
-
get: (
|
|
5277
|
+
get: (key2) => valueAt(key2, levels.length - 1),
|
|
4328
5278
|
keys: new Set(levels.flatMap((values) => Object.keys(values)))
|
|
4329
5279
|
};
|
|
4330
5280
|
}
|
|
@@ -4346,7 +5296,7 @@ function targetMembers(ref) {
|
|
|
4346
5296
|
const addResource = (file) => {
|
|
4347
5297
|
if (isDirectory(file)) {
|
|
4348
5298
|
for (const inner of walkFiles(file)) resources.add(inner);
|
|
4349
|
-
} else if (
|
|
5299
|
+
} else if (import_node_fs11.default.existsSync(file)) resources.add(file);
|
|
4350
5300
|
};
|
|
4351
5301
|
const fileRefPaths = (refId) => {
|
|
4352
5302
|
const entry = project.object(refId);
|
|
@@ -4367,7 +5317,7 @@ function targetMembers(ref) {
|
|
|
4367
5317
|
for (const buildFileId of list(phase.files)) {
|
|
4368
5318
|
for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
|
|
4369
5319
|
if (phase.isa === "PBXSourcesBuildPhase") {
|
|
4370
|
-
if (!
|
|
5320
|
+
if (!import_node_fs11.default.existsSync(file)) continue;
|
|
4371
5321
|
allSources.add(file);
|
|
4372
5322
|
if (file.endsWith(".swift")) sources.add(file);
|
|
4373
5323
|
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
@@ -4375,7 +5325,7 @@ function targetMembers(ref) {
|
|
|
4375
5325
|
}
|
|
4376
5326
|
}
|
|
4377
5327
|
const addSynchronized = (folder, relative) => {
|
|
4378
|
-
const file =
|
|
5328
|
+
const file = import_node_path13.default.join(folder, relative);
|
|
4379
5329
|
if (NEVER_MEMBER.test(relative)) return;
|
|
4380
5330
|
if (file.endsWith(".swift")) {
|
|
4381
5331
|
if (!relative.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
|
|
@@ -4400,7 +5350,7 @@ function targetMembers(ref) {
|
|
|
4400
5350
|
}
|
|
4401
5351
|
if (owned.has(groupId)) {
|
|
4402
5352
|
for (const file of walkFiles(folder)) {
|
|
4403
|
-
const relative =
|
|
5353
|
+
const relative = import_node_path13.default.relative(folder, file).split(import_node_path13.default.sep).join("/");
|
|
4404
5354
|
if ([...exceptions].some(
|
|
4405
5355
|
(exception) => relative === exception || relative.startsWith(`${exception}/`)
|
|
4406
5356
|
))
|
|
@@ -4409,14 +5359,14 @@ function targetMembers(ref) {
|
|
|
4409
5359
|
}
|
|
4410
5360
|
} else {
|
|
4411
5361
|
for (const relative of exceptions) {
|
|
4412
|
-
const file =
|
|
5362
|
+
const file = import_node_path13.default.join(folder, relative);
|
|
4413
5363
|
if (isDirectory(file)) {
|
|
4414
5364
|
for (const inner of walkFiles(file))
|
|
4415
5365
|
addSynchronized(
|
|
4416
5366
|
folder,
|
|
4417
|
-
|
|
5367
|
+
import_node_path13.default.relative(folder, inner).split(import_node_path13.default.sep).join("/")
|
|
4418
5368
|
);
|
|
4419
|
-
} else if (
|
|
5369
|
+
} else if (import_node_fs11.default.existsSync(file)) addSynchronized(folder, relative);
|
|
4420
5370
|
}
|
|
4421
5371
|
}
|
|
4422
5372
|
}
|
|
@@ -4429,8 +5379,8 @@ function targetMembers(ref) {
|
|
|
4429
5379
|
function commonAncestor(dirs) {
|
|
4430
5380
|
let common = dirs[0];
|
|
4431
5381
|
for (const dir of dirs) {
|
|
4432
|
-
while (common !==
|
|
4433
|
-
common =
|
|
5382
|
+
while (common !== import_node_path13.default.dirname(common) && import_node_path13.default.relative(common, dir).startsWith(".."))
|
|
5383
|
+
common = import_node_path13.default.dirname(common);
|
|
4434
5384
|
}
|
|
4435
5385
|
return common;
|
|
4436
5386
|
}
|
|
@@ -4439,11 +5389,11 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
4439
5389
|
const projects2 = [];
|
|
4440
5390
|
const projectAt = /* @__PURE__ */ new Map();
|
|
4441
5391
|
const addProject = (xcodeproj) => {
|
|
4442
|
-
const
|
|
4443
|
-
if (projectAt.has(
|
|
4444
|
-
if (!xcodeProjectFile(
|
|
4445
|
-
const project = loadProject(
|
|
4446
|
-
projectAt.set(
|
|
5392
|
+
const key2 = import_node_path13.default.resolve(xcodeproj);
|
|
5393
|
+
if (projectAt.has(key2) || key2.split(import_node_path13.default.sep).includes("Pods")) return;
|
|
5394
|
+
if (!xcodeProjectFile(key2)) return;
|
|
5395
|
+
const project = loadProject(key2);
|
|
5396
|
+
projectAt.set(key2, project);
|
|
4447
5397
|
projects2.push(project);
|
|
4448
5398
|
const nested = project.project.projectReferences;
|
|
4449
5399
|
if (Array.isArray(nested)) {
|
|
@@ -4457,7 +5407,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
4457
5407
|
for (const reference of listed)
|
|
4458
5408
|
if (reference.endsWith(".xcodeproj")) addProject(reference);
|
|
4459
5409
|
if (projects2.length === 0) {
|
|
4460
|
-
throw new Error(`${
|
|
5410
|
+
throw new Error(`${import_node_path13.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
|
|
4461
5411
|
}
|
|
4462
5412
|
return { listed, projects: projects2, projectAt };
|
|
4463
5413
|
}
|
|
@@ -4479,7 +5429,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4479
5429
|
const allTargets = projects2.flatMap(nativeTargets);
|
|
4480
5430
|
const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
|
|
4481
5431
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
|
|
4482
|
-
const container =
|
|
5432
|
+
const container = import_node_path13.default.basename(xcodeprojOrWorkspace);
|
|
4483
5433
|
const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
|
|
4484
5434
|
if (named.length !== 1) {
|
|
4485
5435
|
throw new Error(
|
|
@@ -4491,14 +5441,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4491
5441
|
for (const ref of allTargets) {
|
|
4492
5442
|
const product = ref.project.object(str(ref.target.productReference));
|
|
4493
5443
|
const file = str(product?.path);
|
|
4494
|
-
if (file && !byProduct.has(
|
|
4495
|
-
byProduct.set(
|
|
5444
|
+
if (file && !byProduct.has(import_node_path13.default.basename(file)))
|
|
5445
|
+
byProduct.set(import_node_path13.default.basename(file), ref);
|
|
4496
5446
|
}
|
|
4497
5447
|
const proxied = (project, proxyId) => {
|
|
4498
5448
|
const proxy = project.object(proxyId);
|
|
4499
5449
|
if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
|
|
4500
5450
|
const portal = str(proxy.containerPortal);
|
|
4501
|
-
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(
|
|
5451
|
+
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path13.default.resolve(project.resolvePath(portal ?? "") ?? ""));
|
|
4502
5452
|
const remote = str(proxy.remoteGlobalIDString);
|
|
4503
5453
|
if (!owner || !remote) return void 0;
|
|
4504
5454
|
return nativeTargets(owner).find(
|
|
@@ -4519,7 +5469,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4519
5469
|
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
4520
5470
|
for (const buildFileId of list(phase.files)) {
|
|
4521
5471
|
const file = project.object(str(project.object(buildFileId)?.fileRef));
|
|
4522
|
-
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(
|
|
5472
|
+
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path13.default.basename(str(file.path) ?? "")) : void 0;
|
|
4523
5473
|
if (resolved) found.push(resolved);
|
|
4524
5474
|
}
|
|
4525
5475
|
}
|
|
@@ -4540,7 +5490,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4540
5490
|
const name = str(ref.target.name) ?? ref.id;
|
|
4541
5491
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
4542
5492
|
TARGET_NAME: name,
|
|
4543
|
-
PROJECT_NAME:
|
|
5493
|
+
PROJECT_NAME: import_node_path13.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
4544
5494
|
SRCROOT: ref.project.projectDir,
|
|
4545
5495
|
SOURCE_ROOT: ref.project.projectDir,
|
|
4546
5496
|
PROJECT_DIR: ref.project.projectDir,
|
|
@@ -4566,22 +5516,22 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4566
5516
|
if (Array.isArray(value)) return value.map(expandValue);
|
|
4567
5517
|
if (typeof value === "object" && !(value instanceof Date) && !Buffer.isBuffer(value)) {
|
|
4568
5518
|
return Object.fromEntries(
|
|
4569
|
-
Object.entries(value).map(([
|
|
5519
|
+
Object.entries(value).map(([key2, value2]) => [key2, expandValue(value2)])
|
|
4570
5520
|
);
|
|
4571
5521
|
}
|
|
4572
5522
|
return value;
|
|
4573
5523
|
};
|
|
4574
|
-
const infoPlistFile = settings("INFOPLIST_FILE") ?
|
|
4575
|
-
const sourceInfo = infoPlistFile ? import_plist.default.parse(
|
|
5524
|
+
const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path13.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
|
|
5525
|
+
const sourceInfo = infoPlistFile ? import_plist.default.parse(import_node_fs11.default.readFileSync(infoPlistFile, "utf8")) : {};
|
|
4576
5526
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
4577
5527
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
4578
5528
|
}
|
|
4579
5529
|
const info = {};
|
|
4580
|
-
for (const [
|
|
4581
|
-
for (const
|
|
4582
|
-
if (!
|
|
4583
|
-
const value = settings(
|
|
4584
|
-
info[
|
|
5530
|
+
for (const [key2, value] of Object.entries(sourceInfo)) info[key2] = expandValue(value);
|
|
5531
|
+
for (const key2 of settingKeys) {
|
|
5532
|
+
if (!key2.startsWith("INFOPLIST_KEY_") || key2.endsWith("_Generation")) continue;
|
|
5533
|
+
const value = settings(key2);
|
|
5534
|
+
info[key2.slice("INFOPLIST_KEY_".length)] = value === "YES" ? true : value === "NO" ? false : value;
|
|
4585
5535
|
}
|
|
4586
5536
|
if (settings("INFOPLIST_KEY_UIApplicationSceneManifest_Generation") === "YES" && info.UIApplicationSceneManifest === void 0) {
|
|
4587
5537
|
info.UIApplicationSceneManifest = {
|
|
@@ -4590,12 +5540,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4590
5540
|
};
|
|
4591
5541
|
}
|
|
4592
5542
|
const localPackageDirs = [
|
|
4593
|
-
...listed.filter((reference) =>
|
|
5543
|
+
...listed.filter((reference) => import_node_fs11.default.existsSync(import_node_path13.default.join(reference, "Package.swift"))),
|
|
4594
5544
|
...projects2.flatMap(
|
|
4595
5545
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
4596
5546
|
if (!isDict(entry)) return [];
|
|
4597
|
-
const candidate = entry.isa === "XCLocalSwiftPackageReference" ?
|
|
4598
|
-
return candidate &&
|
|
5547
|
+
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path13.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
|
|
5548
|
+
return candidate && import_node_fs11.default.existsSync(import_node_path13.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
4599
5549
|
})
|
|
4600
5550
|
)
|
|
4601
5551
|
];
|
|
@@ -4619,7 +5569,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4619
5569
|
product,
|
|
4620
5570
|
source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
|
|
4621
5571
|
kind: "local",
|
|
4622
|
-
dir:
|
|
5572
|
+
dir: import_node_path13.default.resolve(
|
|
4623
5573
|
project.projectDir,
|
|
4624
5574
|
str(reference.relativePath) ?? ""
|
|
4625
5575
|
)
|
|
@@ -4641,8 +5591,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4641
5591
|
}
|
|
4642
5592
|
}
|
|
4643
5593
|
}
|
|
4644
|
-
const resolvedFile =
|
|
4645
|
-
workspace ??
|
|
5594
|
+
const resolvedFile = import_node_path13.default.join(
|
|
5595
|
+
workspace ?? import_node_path13.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
|
|
4646
5596
|
"xcshareddata",
|
|
4647
5597
|
"swiftpm",
|
|
4648
5598
|
"Package.resolved"
|
|
@@ -4652,13 +5602,13 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4652
5602
|
...module2,
|
|
4653
5603
|
rootDir: commonAncestor(
|
|
4654
5604
|
[
|
|
4655
|
-
workspace ?
|
|
5605
|
+
workspace ? import_node_path13.default.dirname(workspace) : app.project.projectDir,
|
|
4656
5606
|
...used.map((project) => project.projectDir),
|
|
4657
5607
|
...localPackageDirs,
|
|
4658
5608
|
...linkedProducts.flatMap(
|
|
4659
|
-
({ source }) => source.kind === "local" &&
|
|
5609
|
+
({ source }) => source.kind === "local" && import_node_fs11.default.existsSync(source.dir) ? [source.dir] : []
|
|
4660
5610
|
)
|
|
4661
|
-
].map((dir) =>
|
|
5611
|
+
].map((dir) => import_node_fs11.default.realpathSync(dir))
|
|
4662
5612
|
),
|
|
4663
5613
|
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
4664
5614
|
infoPlist: import_plist.default.build(info),
|
|
@@ -4666,10 +5616,10 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4666
5616
|
frameworks,
|
|
4667
5617
|
linkedProducts,
|
|
4668
5618
|
localPackageDirs: [
|
|
4669
|
-
...new Set(localPackageDirs.map((dir) =>
|
|
5619
|
+
...new Set(localPackageDirs.map((dir) => import_node_fs11.default.realpathSync(dir)))
|
|
4670
5620
|
].sort(),
|
|
4671
5621
|
binaryFrameworks: [...binaryFrameworks].sort(),
|
|
4672
|
-
packageResolved:
|
|
5622
|
+
packageResolved: import_node_fs11.default.existsSync(resolvedFile) ? resolvedFile : null,
|
|
4673
5623
|
appTargets: appTargetNames
|
|
4674
5624
|
};
|
|
4675
5625
|
}
|
|
@@ -4689,17 +5639,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
|
|
|
4689
5639
|
var NATIVE_DESCRIPTOR = ".one-native-source.json";
|
|
4690
5640
|
var NATIVE_GLUE = ".one-native-source.swift.txt";
|
|
4691
5641
|
function swiftPackageId(packagePath) {
|
|
4692
|
-
return
|
|
5642
|
+
return import_node_path14.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
4693
5643
|
}
|
|
4694
5644
|
function nativeSourceDescriptor(packagePath) {
|
|
4695
|
-
packagePath =
|
|
4696
|
-
const file =
|
|
4697
|
-
if (!
|
|
5645
|
+
packagePath = import_node_fs12.default.realpathSync(packagePath);
|
|
5646
|
+
const file = import_node_path14.default.join(packagePath, NATIVE_DESCRIPTOR);
|
|
5647
|
+
if (!import_node_fs12.default.existsSync(file)) return null;
|
|
4698
5648
|
const value = JSON.parse(
|
|
4699
5649
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
4700
5650
|
);
|
|
4701
5651
|
const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
|
|
4702
|
-
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !
|
|
5652
|
+
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs12.default.existsSync(import_node_path14.default.join(packagePath, NATIVE_GLUE))) {
|
|
4703
5653
|
throw invalid();
|
|
4704
5654
|
}
|
|
4705
5655
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -4708,12 +5658,12 @@ function nativeSourceDescriptor(packagePath) {
|
|
|
4708
5658
|
return value;
|
|
4709
5659
|
}
|
|
4710
5660
|
function nativeSourceFiles(packagePath) {
|
|
4711
|
-
packagePath =
|
|
4712
|
-
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name) =>
|
|
5661
|
+
packagePath = import_node_fs12.default.realpathSync(packagePath);
|
|
5662
|
+
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name) => import_node_path14.default.join(packagePath, name)).filter((file) => import_node_fs12.default.existsSync(file));
|
|
4713
5663
|
}
|
|
4714
5664
|
var projects = /* @__PURE__ */ new Map();
|
|
4715
5665
|
function projectFor(packagePath, hosted) {
|
|
4716
|
-
packagePath =
|
|
5666
|
+
packagePath = import_node_fs12.default.realpathSync(packagePath);
|
|
4717
5667
|
const existing = projects.get(packagePath);
|
|
4718
5668
|
if (existing) {
|
|
4719
5669
|
if (hosted && !existing.hosted) {
|
|
@@ -4735,53 +5685,67 @@ function projectFor(packagePath, hosted) {
|
|
|
4735
5685
|
}
|
|
4736
5686
|
var xcodeProjects = /* @__PURE__ */ new Map();
|
|
4737
5687
|
function swiftPackages(entry, app) {
|
|
4738
|
-
const stamp = (file) => file &&
|
|
4739
|
-
const
|
|
5688
|
+
const stamp = (file) => file && import_node_fs12.default.existsSync(file) ? import_node_fs12.default.statSync(file).mtimeMs : 0;
|
|
5689
|
+
const key2 = JSON.stringify([
|
|
4740
5690
|
app.linkedProducts,
|
|
4741
5691
|
app.packageResolved,
|
|
4742
5692
|
stamp(app.packageResolved),
|
|
4743
|
-
app.localPackageDirs.map((dir) => stamp(
|
|
5693
|
+
app.localPackageDirs.map((dir) => stamp(import_node_path14.default.join(dir, "Package.swift"))),
|
|
4744
5694
|
app.linkedProducts.map(
|
|
4745
|
-
({ source }) => source.kind === "local" ? stamp(
|
|
5695
|
+
({ source }) => source.kind === "local" ? stamp(import_node_path14.default.join(source.dir, "Package.swift")) : 0
|
|
4746
5696
|
)
|
|
4747
5697
|
]);
|
|
4748
|
-
if (entry.packages?.key !==
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
5698
|
+
if (entry.packages?.key !== key2) {
|
|
5699
|
+
const resolve2 = (provided, binaryGaps) => resolveSwiftPackages({
|
|
5700
|
+
rootDir: app.rootDir,
|
|
5701
|
+
resolved: app.packageResolved,
|
|
5702
|
+
products: app.linkedProducts,
|
|
5703
|
+
localDirs: app.localPackageDirs,
|
|
5704
|
+
provided,
|
|
5705
|
+
binaryGaps
|
|
5706
|
+
});
|
|
5707
|
+
let packages = resolve2(entry.provided);
|
|
5708
|
+
let standins = [];
|
|
5709
|
+
const reached = packages.binaries.filter((binary) => binary.reached);
|
|
5710
|
+
if (entry.moduleRoot && entry.provided && reached.length > 0) {
|
|
5711
|
+
const built2 = swiftStandins(reached, {
|
|
5712
|
+
moduleRoot: entry.moduleRoot,
|
|
5713
|
+
toolchainBin: swiftModuleToolchain(entry.moduleRoot).toolchainBin
|
|
5714
|
+
});
|
|
5715
|
+
standins = built2.standins;
|
|
5716
|
+
packages = resolve2(
|
|
5717
|
+
/* @__PURE__ */ new Set([...entry.provided, ...standins.map((standin) => standin.target)]),
|
|
5718
|
+
built2.gaps
|
|
5719
|
+
);
|
|
5720
|
+
}
|
|
5721
|
+
entry.packages = { key: key2, packages, standins };
|
|
4759
5722
|
}
|
|
4760
|
-
return entry.packages
|
|
5723
|
+
return entry.packages;
|
|
4761
5724
|
}
|
|
4762
5725
|
var XCODE_APP_DIR = "__app__";
|
|
4763
5726
|
var XCODE_FRAMEWORKS_DIR = "__frameworks__";
|
|
4764
5727
|
var XCODE_PACKAGES_DIR = "__packages__";
|
|
4765
|
-
var
|
|
5728
|
+
var XCODE_STANDINS_DIR = "__standins__";
|
|
5729
|
+
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep)}/`;
|
|
4766
5730
|
function xcodeInputKey(layout, file, relative) {
|
|
4767
5731
|
const owner = layout.targetDirs.get(file);
|
|
4768
|
-
if (owner) return
|
|
4769
|
-
return relative.startsWith(CHECKOUTS_PREFIX) ?
|
|
5732
|
+
if (owner) return import_node_path14.default.posix.join(owner, relative);
|
|
5733
|
+
return relative.startsWith(CHECKOUTS_PREFIX) ? import_node_path14.default.posix.join(XCODE_PACKAGES_DIR, relative.slice(CHECKOUTS_PREFIX.length)) : relative;
|
|
4770
5734
|
}
|
|
4771
5735
|
function xcodeLayout(root) {
|
|
4772
5736
|
const registered = xcodeProjects.get(root);
|
|
4773
5737
|
if (!registered) return null;
|
|
4774
5738
|
const app = readXcodeAppTarget(registered.xcodeproj, registered.target);
|
|
4775
|
-
const
|
|
4776
|
-
if (app.infoPlistFile)
|
|
5739
|
+
const files2 = /* @__PURE__ */ new Set([...app.projectFiles, ...app.sources, ...app.resources]);
|
|
5740
|
+
if (app.infoPlistFile) files2.add(app.infoPlistFile);
|
|
4777
5741
|
const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
|
|
4778
5742
|
const targets = [];
|
|
4779
5743
|
for (const framework of app.frameworks) {
|
|
4780
|
-
const dir =
|
|
5744
|
+
const dir = import_node_path14.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
|
|
4781
5745
|
for (const file of framework.sources) {
|
|
4782
5746
|
if (targetDirs.has(file)) continue;
|
|
4783
5747
|
targetDirs.set(file, dir);
|
|
4784
|
-
|
|
5748
|
+
files2.add(file);
|
|
4785
5749
|
}
|
|
4786
5750
|
targets.push({
|
|
4787
5751
|
name: framework.moduleName,
|
|
@@ -4793,22 +5757,32 @@ function xcodeLayout(root) {
|
|
|
4793
5757
|
mainActorIsolation: framework.mainActorIsolation
|
|
4794
5758
|
});
|
|
4795
5759
|
}
|
|
4796
|
-
const packages = swiftPackages(registered, app);
|
|
5760
|
+
const { packages, standins } = swiftPackages(registered, app);
|
|
5761
|
+
for (const standin of standins)
|
|
5762
|
+
targets.push({
|
|
5763
|
+
name: standin.module,
|
|
5764
|
+
path: import_node_path14.default.posix.join(XCODE_STANDINS_DIR, standin.module),
|
|
5765
|
+
executable: false,
|
|
5766
|
+
resources: false,
|
|
5767
|
+
exclude: [],
|
|
5768
|
+
languageMode: 5,
|
|
5769
|
+
mainActorIsolation: false
|
|
5770
|
+
});
|
|
4797
5771
|
for (const target of packages.targets) {
|
|
4798
|
-
const relative =
|
|
4799
|
-
target.remote ?
|
|
5772
|
+
const relative = import_node_path14.default.relative(
|
|
5773
|
+
target.remote ? import_node_path14.default.join(root, REMOTE_CHECKOUTS) : root,
|
|
4800
5774
|
target.dir
|
|
4801
5775
|
);
|
|
4802
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
5776
|
+
if (relative === ".." || relative.startsWith(`..${import_node_path14.default.sep}`) || import_node_path14.default.isAbsolute(relative))
|
|
4803
5777
|
throw new Error(`swift input escapes the selected package: ${target.dir}`);
|
|
4804
|
-
const posix = relative.split(
|
|
5778
|
+
const posix = relative.split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep);
|
|
4805
5779
|
targets.push({
|
|
4806
5780
|
...target,
|
|
4807
|
-
path: target.remote ?
|
|
5781
|
+
path: target.remote ? import_node_path14.default.posix.join(XCODE_PACKAGES_DIR, posix) : posix,
|
|
4808
5782
|
exclude: []
|
|
4809
5783
|
});
|
|
4810
|
-
if (!target.remote)
|
|
4811
|
-
for (const file of target.files)
|
|
5784
|
+
if (!target.remote) files2.add(import_node_path14.default.join(target.packageDir, "Package.swift"));
|
|
5785
|
+
for (const file of target.files) files2.add(file);
|
|
4812
5786
|
}
|
|
4813
5787
|
for (const target of targets) {
|
|
4814
5788
|
target.exclude = targets.filter((other) => other.path.startsWith(`${target.path}/`)).map((other) => other.path.slice(target.path.length + 1));
|
|
@@ -4817,8 +5791,9 @@ function xcodeLayout(root) {
|
|
|
4817
5791
|
app,
|
|
4818
5792
|
targets,
|
|
4819
5793
|
packages,
|
|
5794
|
+
standins,
|
|
4820
5795
|
targetDirs,
|
|
4821
|
-
files: [...
|
|
5796
|
+
files: [...files2].sort()
|
|
4822
5797
|
};
|
|
4823
5798
|
}
|
|
4824
5799
|
function xcodeManifest(layout) {
|
|
@@ -4836,25 +5811,25 @@ function xcodeManifest(layout) {
|
|
|
4836
5811
|
].join("\n");
|
|
4837
5812
|
}
|
|
4838
5813
|
function packageFiles(root) {
|
|
4839
|
-
const canonicalRoot =
|
|
5814
|
+
const canonicalRoot = import_node_fs12.default.realpathSync(root);
|
|
4840
5815
|
const xcode = xcodeLayout(canonicalRoot);
|
|
4841
5816
|
return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
|
|
4842
5817
|
}
|
|
4843
5818
|
function sourceTreeFiles(dir, canonicalRoot) {
|
|
4844
5819
|
const found = [];
|
|
4845
5820
|
const walk2 = (dir2) => {
|
|
4846
|
-
for (const entry of
|
|
5821
|
+
for (const entry of import_node_fs12.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
4847
5822
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
4848
5823
|
continue;
|
|
4849
|
-
const full =
|
|
5824
|
+
const full = import_node_path14.default.join(dir2, entry.name);
|
|
4850
5825
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
4851
|
-
const real =
|
|
4852
|
-
const relative =
|
|
4853
|
-
if (relative.startsWith(`..${
|
|
5826
|
+
const real = import_node_fs12.default.realpathSync(full);
|
|
5827
|
+
const relative = import_node_path14.default.relative(canonicalRoot, real);
|
|
5828
|
+
if (relative.startsWith(`..${import_node_path14.default.sep}`) || relative === ".." || import_node_path14.default.isAbsolute(relative)) {
|
|
4854
5829
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
4855
5830
|
}
|
|
4856
5831
|
if (entry.isDirectory()) {
|
|
4857
|
-
if (
|
|
5832
|
+
if (import_node_fs12.default.existsSync(import_node_path14.default.join(full, "Package.swift"))) continue;
|
|
4858
5833
|
walk2(full);
|
|
4859
5834
|
} else if (entry.isFile()) {
|
|
4860
5835
|
found.push(full);
|
|
@@ -4862,29 +5837,29 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
4862
5837
|
}
|
|
4863
5838
|
}
|
|
4864
5839
|
};
|
|
4865
|
-
if (
|
|
5840
|
+
if (import_node_fs12.default.existsSync(dir)) walk2(import_node_fs12.default.realpathSync(dir));
|
|
4866
5841
|
return found;
|
|
4867
5842
|
}
|
|
4868
5843
|
function readPackageFile(root, file, maxBytes) {
|
|
4869
|
-
const canonicalRoot =
|
|
4870
|
-
const relative =
|
|
4871
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
5844
|
+
const canonicalRoot = import_node_fs12.default.realpathSync(root);
|
|
5845
|
+
const relative = import_node_path14.default.relative(canonicalRoot, import_node_fs12.default.realpathSync(file));
|
|
5846
|
+
if (relative === ".." || relative.startsWith(`..${import_node_path14.default.sep}`) || import_node_path14.default.isAbsolute(relative)) {
|
|
4872
5847
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
4873
5848
|
}
|
|
4874
|
-
let ancestor =
|
|
5849
|
+
let ancestor = import_node_path14.default.resolve(file);
|
|
4875
5850
|
while (ancestor !== canonicalRoot) {
|
|
4876
|
-
if (
|
|
5851
|
+
if (import_node_fs12.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
4877
5852
|
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
4878
5853
|
}
|
|
4879
|
-
const parent =
|
|
5854
|
+
const parent = import_node_path14.default.dirname(ancestor);
|
|
4880
5855
|
if (parent === ancestor)
|
|
4881
5856
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
4882
5857
|
ancestor = parent;
|
|
4883
5858
|
}
|
|
4884
|
-
const expected =
|
|
4885
|
-
const fd =
|
|
5859
|
+
const expected = import_node_fs12.default.statSync(file);
|
|
5860
|
+
const fd = import_node_fs12.default.openSync(file, import_node_fs12.default.constants.O_RDONLY | import_node_fs12.default.constants.O_NOFOLLOW);
|
|
4886
5861
|
try {
|
|
4887
|
-
const stat =
|
|
5862
|
+
const stat = import_node_fs12.default.fstatSync(fd);
|
|
4888
5863
|
if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
|
|
4889
5864
|
throw new Error(`swift input changed while opening: ${file}`);
|
|
4890
5865
|
}
|
|
@@ -4894,16 +5869,16 @@ function readPackageFile(root, file, maxBytes) {
|
|
|
4894
5869
|
const bytes = Buffer.alloc(stat.size + 1);
|
|
4895
5870
|
let offset = 0;
|
|
4896
5871
|
while (offset < bytes.length) {
|
|
4897
|
-
const count =
|
|
5872
|
+
const count = import_node_fs12.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
4898
5873
|
if (count === 0) break;
|
|
4899
5874
|
offset += count;
|
|
4900
5875
|
}
|
|
4901
|
-
if (offset !== stat.size ||
|
|
5876
|
+
if (offset !== stat.size || import_node_fs12.default.fstatSync(fd).size !== stat.size) {
|
|
4902
5877
|
throw new Error(`swift input changed while reading: ${file}`);
|
|
4903
5878
|
}
|
|
4904
5879
|
return bytes.subarray(0, offset);
|
|
4905
5880
|
} finally {
|
|
4906
|
-
|
|
5881
|
+
import_node_fs12.default.closeSync(fd);
|
|
4907
5882
|
}
|
|
4908
5883
|
}
|
|
4909
5884
|
function sourceFiles(root) {
|
|
@@ -4911,7 +5886,7 @@ function sourceFiles(root) {
|
|
|
4911
5886
|
}
|
|
4912
5887
|
function resourceCandidateFiles(root) {
|
|
4913
5888
|
return packageFiles(root).filter(
|
|
4914
|
-
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(
|
|
5889
|
+
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path14.default.basename(file))
|
|
4915
5890
|
);
|
|
4916
5891
|
}
|
|
4917
5892
|
var HOSTED_LIMITS = {
|
|
@@ -4945,7 +5920,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
4945
5920
|
const limits = inputLimits(Boolean(project.hosted));
|
|
4946
5921
|
const absolute = resourceCandidateFiles(project.packagePath);
|
|
4947
5922
|
const relative = absolute.map(
|
|
4948
|
-
(file) =>
|
|
5923
|
+
(file) => import_node_path14.default.relative(project.packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep)
|
|
4949
5924
|
);
|
|
4950
5925
|
const byRelative = new Map(absolute.map((file, index) => [relative[index], file]));
|
|
4951
5926
|
const readContents = (candidate) => {
|
|
@@ -4967,16 +5942,16 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
4967
5942
|
for (const { name, file, scale } of found) {
|
|
4968
5943
|
const disk = byRelative.get(file);
|
|
4969
5944
|
if (!disk) continue;
|
|
4970
|
-
if (Object.keys(images).length >= limits.images || imageBytes +
|
|
5945
|
+
if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs12.default.statSync(disk).size > limits.imageTotalBytes) {
|
|
4971
5946
|
throw new Error("swift image pack exceeds the compile service caps");
|
|
4972
5947
|
}
|
|
4973
5948
|
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
4974
5949
|
imageBytes += bytes.length;
|
|
4975
|
-
const hash = (0,
|
|
4976
|
-
const ext =
|
|
5950
|
+
const hash = (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
|
|
5951
|
+
const ext = import_node_path14.default.posix.extname(file).toLowerCase();
|
|
4977
5952
|
table[name] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
4978
5953
|
images[name] = {
|
|
4979
|
-
file:
|
|
5954
|
+
file: import_node_path14.default.posix.basename(file),
|
|
4980
5955
|
data: bytes.toString("base64")
|
|
4981
5956
|
};
|
|
4982
5957
|
watched.push(file);
|
|
@@ -4992,7 +5967,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
4992
5967
|
watched.push(file);
|
|
4993
5968
|
}
|
|
4994
5969
|
if (registered.size !== project.resourceFiles.size || [...registered].some(
|
|
4995
|
-
([
|
|
5970
|
+
([key2, value]) => !project.resourceFiles.get(key2)?.bytes.equals(value.bytes)
|
|
4996
5971
|
)) {
|
|
4997
5972
|
project.resourcesPrevious = project.resourceFiles;
|
|
4998
5973
|
project.resourceFiles = registered;
|
|
@@ -5000,12 +5975,12 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
5000
5975
|
return { table, images, colors, symbols, watched };
|
|
5001
5976
|
}
|
|
5002
5977
|
function buildSwiftBundleFiles(packagePath, hosted) {
|
|
5003
|
-
packagePath =
|
|
5978
|
+
packagePath = import_node_fs12.default.realpathSync(packagePath);
|
|
5004
5979
|
const limits = inputLimits(hosted);
|
|
5005
5980
|
const relative = resourceCandidateFiles(packagePath).map(
|
|
5006
|
-
(file) =>
|
|
5981
|
+
(file) => import_node_path14.default.relative(packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep)
|
|
5007
5982
|
);
|
|
5008
|
-
const
|
|
5983
|
+
const files2 = {};
|
|
5009
5984
|
const watched = [];
|
|
5010
5985
|
let total = 0;
|
|
5011
5986
|
const xcode = xcodeLayout(packagePath);
|
|
@@ -5013,37 +5988,37 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
5013
5988
|
const bytes = Buffer.from(xcode.app.infoPlist);
|
|
5014
5989
|
if (bytes.length > limits.resourceBytes || bytes.length > limits.resourceTotalBytes)
|
|
5015
5990
|
throw new Error("swift launch Info.plist exceeds bundle resource limits");
|
|
5016
|
-
|
|
5991
|
+
files2["Info.plist"] = bytes.toString("base64");
|
|
5017
5992
|
total += bytes.length;
|
|
5018
5993
|
if (xcode.app.infoPlistFile)
|
|
5019
5994
|
watched.push(
|
|
5020
|
-
|
|
5995
|
+
import_node_path14.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path14.default.sep).join("/")
|
|
5021
5996
|
);
|
|
5022
5997
|
}
|
|
5023
5998
|
for (const { base, file } of enumerateBundleJson(relative)) {
|
|
5024
5999
|
watched.push(file);
|
|
5025
|
-
const disk =
|
|
5026
|
-
if (Object.keys(
|
|
6000
|
+
const disk = import_node_path14.default.join(packagePath, ...file.split("/"));
|
|
6001
|
+
if (Object.keys(files2).length >= limits.resources || total + import_node_fs12.default.statSync(disk).size > limits.resourceTotalBytes) {
|
|
5027
6002
|
throw new Error(
|
|
5028
6003
|
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
5029
6004
|
);
|
|
5030
6005
|
}
|
|
5031
6006
|
const bytes = readPackageFile(packagePath, disk, limits.resourceBytes);
|
|
5032
|
-
|
|
6007
|
+
files2[base] = bytes.toString("base64");
|
|
5033
6008
|
total += bytes.length;
|
|
5034
6009
|
}
|
|
5035
|
-
return { files, watched };
|
|
6010
|
+
return { files: files2, watched };
|
|
5036
6011
|
}
|
|
5037
|
-
function serveSwiftResource(project,
|
|
5038
|
-
return project.resourceFiles.get(
|
|
6012
|
+
function serveSwiftResource(project, key2) {
|
|
6013
|
+
return project.resourceFiles.get(key2) ?? project.resourcesPrevious.get(key2) ?? null;
|
|
5039
6014
|
}
|
|
5040
6015
|
function linkedModuleRoots(packagePath) {
|
|
5041
|
-
packagePath =
|
|
6016
|
+
packagePath = import_node_fs12.default.realpathSync(packagePath);
|
|
5042
6017
|
let manifest;
|
|
5043
6018
|
try {
|
|
5044
6019
|
manifest = readPackageFile(
|
|
5045
6020
|
packagePath,
|
|
5046
|
-
|
|
6021
|
+
import_node_path14.default.join(packagePath, "Package.swift"),
|
|
5047
6022
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
5048
6023
|
).toString("utf8");
|
|
5049
6024
|
} catch {
|
|
@@ -5052,62 +6027,67 @@ function linkedModuleRoots(packagePath) {
|
|
|
5052
6027
|
const roots = /* @__PURE__ */ new Set();
|
|
5053
6028
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
5054
6029
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
5055
|
-
const root =
|
|
5056
|
-
if (
|
|
6030
|
+
const root = import_node_path14.default.resolve(packagePath, match[1]);
|
|
6031
|
+
if (import_node_fs12.default.existsSync(import_node_path14.default.join(root, "Package.swift"))) roots.add(root);
|
|
5057
6032
|
}
|
|
5058
6033
|
return [...roots].sort();
|
|
5059
6034
|
}
|
|
5060
6035
|
function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
5061
|
-
const hash = (0,
|
|
6036
|
+
const hash = (0, import_node_crypto7.createHash)("sha256");
|
|
5062
6037
|
hash.update(packagePath);
|
|
5063
6038
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
5064
6039
|
for (const file of [...projectInputs].sort()) {
|
|
5065
|
-
hash.update(
|
|
5066
|
-
const stat =
|
|
6040
|
+
hash.update(import_node_path14.default.relative(packagePath, file));
|
|
6041
|
+
const stat = import_node_fs12.default.statSync(file);
|
|
5067
6042
|
hash.update(`${stat.mtimeMs}/${stat.ctimeMs}/${stat.size}`);
|
|
5068
6043
|
}
|
|
5069
6044
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
5070
|
-
(root) =>
|
|
6045
|
+
(root) => import_node_fs12.default.existsSync(import_node_path14.default.join(root, "toolchain.json"))
|
|
5071
6046
|
);
|
|
5072
6047
|
if (moduleRoot) {
|
|
5073
6048
|
hash.update(moduleRoot);
|
|
5074
6049
|
for (const relative of swiftModuleInputFiles(moduleRoot)) {
|
|
5075
6050
|
hash.update(relative);
|
|
5076
|
-
hash.update(String(
|
|
6051
|
+
hash.update(String(import_node_fs12.default.statSync(import_node_path14.default.join(moduleRoot, relative)).mtimeMs));
|
|
5077
6052
|
}
|
|
5078
6053
|
}
|
|
5079
6054
|
return hash.digest("hex").slice(0, 16);
|
|
5080
6055
|
}
|
|
5081
6056
|
function entryRootId(packagePath, file) {
|
|
5082
|
-
const relative =
|
|
5083
|
-
return `${
|
|
6057
|
+
const relative = import_node_path14.default.relative(packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep);
|
|
6058
|
+
return `${import_node_path14.default.basename(packagePath)}${import_node_path14.default.posix.sep}${relative}`;
|
|
5084
6059
|
}
|
|
5085
6060
|
function icuUrl(origin, artifact) {
|
|
5086
6061
|
return "url" in artifact.icu ? artifact.icu.url : `${origin}${ICU_PATH}${artifact.icu.sha256}`;
|
|
5087
6062
|
}
|
|
5088
6063
|
function packageSources(packagePath) {
|
|
5089
6064
|
const xcode = xcodeLayout(packagePath);
|
|
5090
|
-
const
|
|
6065
|
+
const files2 = {};
|
|
5091
6066
|
for (const file of sourceFiles(packagePath)) {
|
|
5092
|
-
const relative =
|
|
5093
|
-
if (xcode &&
|
|
5094
|
-
|
|
6067
|
+
const relative = import_node_path14.default.relative(packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep);
|
|
6068
|
+
if (xcode && import_node_path14.default.basename(file) === "Package.swift") continue;
|
|
6069
|
+
files2[xcode ? xcodeInputKey(xcode, file, relative) : relative] = readPackageFile(
|
|
5095
6070
|
packagePath,
|
|
5096
6071
|
file,
|
|
5097
6072
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
5098
6073
|
).toString("utf8");
|
|
5099
6074
|
}
|
|
5100
|
-
if (xcode)
|
|
5101
|
-
|
|
6075
|
+
if (xcode) {
|
|
6076
|
+
files2["Package.swift"] = xcodeManifest(xcode);
|
|
6077
|
+
for (const standin of xcode.standins)
|
|
6078
|
+
for (const [file, text3] of Object.entries(standin.files))
|
|
6079
|
+
files2[import_node_path14.default.posix.join(XCODE_STANDINS_DIR, standin.module, file)] = text3;
|
|
6080
|
+
}
|
|
6081
|
+
return files2;
|
|
5102
6082
|
}
|
|
5103
6083
|
function packageSnapshot(project) {
|
|
5104
|
-
const
|
|
6084
|
+
const files2 = packageSources(project.packagePath);
|
|
5105
6085
|
const native = nativeSourceDescriptor(project.packagePath);
|
|
5106
6086
|
return {
|
|
5107
|
-
files,
|
|
6087
|
+
files: files2,
|
|
5108
6088
|
resourcePaths: swiftImplicitResourcePaths(
|
|
5109
6089
|
resourceCandidateFiles(project.packagePath).map(
|
|
5110
|
-
(file) =>
|
|
6090
|
+
(file) => import_node_path14.default.relative(project.packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep)
|
|
5111
6091
|
)
|
|
5112
6092
|
),
|
|
5113
6093
|
resources: buildSwiftResourceTable(project, ""),
|
|
@@ -5116,7 +6096,7 @@ function packageSnapshot(project) {
|
|
|
5116
6096
|
...native ? {
|
|
5117
6097
|
glue: readPackageFile(
|
|
5118
6098
|
project.packagePath,
|
|
5119
|
-
|
|
6099
|
+
import_node_path14.default.join(project.packagePath, NATIVE_GLUE),
|
|
5120
6100
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
5121
6101
|
).toString("utf8")
|
|
5122
6102
|
} : {}
|
|
@@ -5155,7 +6135,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
5155
6135
|
package: content
|
|
5156
6136
|
};
|
|
5157
6137
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
5158
|
-
(root) =>
|
|
6138
|
+
(root) => import_node_fs12.default.existsSync(import_node_path14.default.join(root, "toolchain.json"))
|
|
5159
6139
|
) ?? await swiftDistributionRoot();
|
|
5160
6140
|
if (!moduleRoot)
|
|
5161
6141
|
return {
|
|
@@ -5181,10 +6161,10 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
5181
6161
|
// server and a capture, or two checkouts) build each other's sources. so
|
|
5182
6162
|
// each app and module checkout gets its own root, which keeps the same
|
|
5183
6163
|
// app's incremental build across restarts.
|
|
5184
|
-
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ??
|
|
5185
|
-
|
|
6164
|
+
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path14.default.join(
|
|
6165
|
+
import_node_os8.default.tmpdir(),
|
|
5186
6166
|
"contrast-swift-build",
|
|
5187
|
-
(0,
|
|
6167
|
+
(0, import_node_crypto7.createHash)("sha256").update(`${moduleRoot}\0${import_node_path14.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
|
|
5188
6168
|
),
|
|
5189
6169
|
moduleRoot,
|
|
5190
6170
|
...toolchain
|
|
@@ -5223,21 +6203,21 @@ function swiftApiGapReport(output) {
|
|
|
5223
6203
|
const file = diagnostic[1].replace(new RegExp(`^(?:${XCODE_APP_DIR}|${XCODE_FRAMEWORKS_DIR}/[^/]+)/`), "").replace(new RegExp(`^${XCODE_PACKAGES_DIR}/`), "");
|
|
5224
6204
|
const message = diagnostic[4];
|
|
5225
6205
|
const rule = API_GAP_PATTERNS.find(([pattern]) => pattern.test(message));
|
|
5226
|
-
const
|
|
6206
|
+
const key2 = rule ? rule[1](rule[0].exec(message)) : message;
|
|
5227
6207
|
const table = rule ? gaps : other;
|
|
5228
|
-
const entry = table.get(
|
|
6208
|
+
const entry = table.get(key2) ?? { errors: 0, files: /* @__PURE__ */ new Set() };
|
|
5229
6209
|
entry.errors++;
|
|
5230
6210
|
entry.files.add(file);
|
|
5231
|
-
table.set(
|
|
6211
|
+
table.set(key2, entry);
|
|
5232
6212
|
}
|
|
5233
6213
|
if (gaps.size === 0) return null;
|
|
5234
6214
|
const rows = (table) => {
|
|
5235
6215
|
const sorted = [...table].sort(
|
|
5236
6216
|
([left, a], [right, b]) => b.errors - a.errors || left.localeCompare(right)
|
|
5237
6217
|
);
|
|
5238
|
-
const width = Math.min(48, Math.max(...sorted.map(([
|
|
6218
|
+
const width = Math.min(48, Math.max(...sorted.map(([key2]) => key2.length)));
|
|
5239
6219
|
return sorted.map(
|
|
5240
|
-
([
|
|
6220
|
+
([key2, entry]) => ` ${key2.padEnd(width)} ${String(entry.errors).padStart(3)} error${entry.errors === 1 ? " " : "s"} ${[...entry.files].sort().join(", ")}`
|
|
5241
6221
|
);
|
|
5242
6222
|
};
|
|
5243
6223
|
const errors = [...gaps.values()].reduce((sum, entry) => sum + entry.errors, 0);
|
|
@@ -5287,16 +6267,16 @@ async function missingModulesMessage(packagePath, missing) {
|
|
|
5287
6267
|
if (packaged.has(name))
|
|
5288
6268
|
gaps.set(name, {
|
|
5289
6269
|
source: binary.source,
|
|
5290
|
-
reason: `${binary.target} is a binary framework`
|
|
6270
|
+
reason: layout?.packages.modules.get(binary.target)?.reason ?? `${binary.target} is a binary framework`
|
|
5291
6271
|
});
|
|
5292
6272
|
})
|
|
5293
6273
|
);
|
|
5294
6274
|
const width = Math.max(...[...missing.keys()].map((name) => name.length));
|
|
5295
6275
|
return [
|
|
5296
6276
|
`Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
|
|
5297
|
-
...[...missing].map(([name,
|
|
6277
|
+
...[...missing].map(([name, files2]) => {
|
|
5298
6278
|
const gap = gaps.get(name);
|
|
5299
|
-
return ` ${name.padEnd(width)} ${
|
|
6279
|
+
return ` ${name.padEnd(width)} ${files2.length} file${files2.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${import_node_path14.default.relative(packagePath, gap.source) || "."}` : gap.source} (${gap.reason})` : ""}`;
|
|
5300
6280
|
})
|
|
5301
6281
|
].join("\n");
|
|
5302
6282
|
}
|
|
@@ -5304,7 +6284,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
5304
6284
|
const auth = hosted ? null : resolveCliAuth();
|
|
5305
6285
|
if (!hosted && (!auth || auth.kind === "github")) {
|
|
5306
6286
|
throw new Error(
|
|
5307
|
-
`compiling ${
|
|
6287
|
+
`compiling ${import_node_path14.default.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`
|
|
5308
6288
|
);
|
|
5309
6289
|
}
|
|
5310
6290
|
const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
|
|
@@ -5320,10 +6300,10 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
5320
6300
|
});
|
|
5321
6301
|
if (!submit) throw new Error("swift compile: no credential to submit with");
|
|
5322
6302
|
const sources = Object.values(snapshot.files);
|
|
5323
|
-
const bytes = sources.reduce((total2,
|
|
6303
|
+
const bytes = sources.reduce((total2, text3) => total2 + Buffer.byteLength(text3), 0);
|
|
5324
6304
|
if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
|
|
5325
6305
|
throw new Error(
|
|
5326
|
-
`${
|
|
6306
|
+
`${import_node_path14.default.basename(packagePath)} has ${sources.length} Swift files (${bytes} bytes), over Contrast's compile limits of ${MAX_SWIFT_COMPILE_FILES} files and ${MAX_SWIFT_COMPILE_SOURCE_BYTES} bytes; compile it on this machine with the Swift distribution instead`
|
|
5327
6307
|
);
|
|
5328
6308
|
}
|
|
5329
6309
|
const descriptor = snapshot.native;
|
|
@@ -5342,7 +6322,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
5342
6322
|
);
|
|
5343
6323
|
if (descriptor && address.native?.hash !== descriptor.hash) {
|
|
5344
6324
|
throw new Error(
|
|
5345
|
-
`${
|
|
6325
|
+
`${import_node_path14.default.basename(packagePath)}: Contrast compiled native contract ${address.native?.hash ?? "none"} but one typegen wrote ${descriptor.hash}; the app's One and the compile host's differ, or the compile host is older than this peachsim`
|
|
5346
6326
|
);
|
|
5347
6327
|
}
|
|
5348
6328
|
const response = await fetch(address.url, { signal });
|
|
@@ -5415,17 +6395,17 @@ function artifactFor(project, entry, moduleRoot) {
|
|
|
5415
6395
|
return fresh;
|
|
5416
6396
|
}
|
|
5417
6397
|
function swiftPackageWatchFiles(packagePath, moduleRoot) {
|
|
5418
|
-
packagePath =
|
|
6398
|
+
packagePath = import_node_fs12.default.realpathSync(packagePath);
|
|
5419
6399
|
return [
|
|
5420
|
-
...xcodeProjects.has(packagePath) ? [] : [
|
|
6400
|
+
...xcodeProjects.has(packagePath) ? [] : [import_node_path14.default.join(packagePath, "Package.swift")],
|
|
5421
6401
|
...sourceFiles(packagePath),
|
|
5422
6402
|
...nativeSourceFiles(packagePath),
|
|
5423
6403
|
...resourceCandidateFiles(packagePath),
|
|
5424
|
-
...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) =>
|
|
6404
|
+
...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) => import_node_path14.default.join(moduleRoot, file)) : []
|
|
5425
6405
|
];
|
|
5426
6406
|
}
|
|
5427
6407
|
async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin, hosted) {
|
|
5428
|
-
packagePath =
|
|
6408
|
+
packagePath = import_node_fs12.default.realpathSync(packagePath);
|
|
5429
6409
|
const mains = sourceFiles(packagePath).filter(
|
|
5430
6410
|
(file) => swiftApplicationEntry(
|
|
5431
6411
|
file,
|
|
@@ -5439,7 +6419,7 @@ async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin
|
|
|
5439
6419
|
);
|
|
5440
6420
|
}
|
|
5441
6421
|
const project = projectFor(packagePath, hosted);
|
|
5442
|
-
const entry = mains.length === 1 ?
|
|
6422
|
+
const entry = mains.length === 1 ? import_node_path14.default.relative(packagePath, mains[0]).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep) : Object.entries(native?.files ?? {}).find(
|
|
5443
6423
|
([_file, names]) => names.length > 0
|
|
5444
6424
|
)?.[0];
|
|
5445
6425
|
if (!entry) throw new Error(`swift package ${packageName} has no native module source`);
|
|
@@ -5528,12 +6508,12 @@ function artifactUrl(project, artifact) {
|
|
|
5528
6508
|
return `${serverOrigin()}${ARTIFACT_PATH2}${artifact.hash}.wasm`;
|
|
5529
6509
|
}
|
|
5530
6510
|
function packageFor(file) {
|
|
5531
|
-
let dir =
|
|
6511
|
+
let dir = import_node_path15.default.dirname(file);
|
|
5532
6512
|
const stop = devServer?.config.root;
|
|
5533
6513
|
for (; ; ) {
|
|
5534
|
-
if (
|
|
5535
|
-
if (stop !== void 0 && dir === stop ||
|
|
5536
|
-
dir =
|
|
6514
|
+
if (import_node_fs13.default.existsSync(import_node_path15.default.join(dir, "Package.swift"))) return dir;
|
|
6515
|
+
if (stop !== void 0 && dir === stop || import_node_path15.default.dirname(dir) === dir) break;
|
|
6516
|
+
dir = import_node_path15.default.dirname(dir);
|
|
5537
6517
|
}
|
|
5538
6518
|
throw new Error(
|
|
5539
6519
|
`no Package.swift above ${file}${stop === void 0 ? "" : ` (searched up to ${stop})`}; a .swift import needs a swiftpm package like the one in packages/sootsim-swift/example`
|
|
@@ -5554,9 +6534,9 @@ function swiftPlugin(options = {}) {
|
|
|
5554
6534
|
if (!resolved) throw new Error(`cannot resolve swift source ${source}`);
|
|
5555
6535
|
let id = resolved.id;
|
|
5556
6536
|
if (importer && (source.startsWith("./") || source.startsWith("../"))) {
|
|
5557
|
-
const raw2 =
|
|
6537
|
+
const raw2 = import_node_path15.default.resolve(import_node_path15.default.dirname(importer.split("?")[0] ?? importer), source);
|
|
5558
6538
|
try {
|
|
5559
|
-
if (
|
|
6539
|
+
if (import_node_fs13.default.realpathSync(raw2) === import_node_fs13.default.realpathSync(resolved.id)) id = raw2;
|
|
5560
6540
|
} catch {
|
|
5561
6541
|
}
|
|
5562
6542
|
}
|
|
@@ -5565,22 +6545,22 @@ function swiftPlugin(options = {}) {
|
|
|
5565
6545
|
async load(id) {
|
|
5566
6546
|
if (!id.startsWith(VIRTUAL_PREFIX)) return null;
|
|
5567
6547
|
const file = id.slice(VIRTUAL_PREFIX.length);
|
|
5568
|
-
if (!
|
|
6548
|
+
if (!import_node_fs13.default.existsSync(file)) throw new Error(`swift source ${file} no longer exists`);
|
|
5569
6549
|
const packagePath = options.packagePath ?? packageFor(file);
|
|
5570
6550
|
const project = projectFor(packagePath);
|
|
5571
|
-
const entry =
|
|
6551
|
+
const entry = import_node_path15.default.relative(packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep);
|
|
5572
6552
|
for (const source of [
|
|
5573
6553
|
...sourceFiles(packagePath),
|
|
5574
6554
|
...nativeSourceFiles(packagePath)
|
|
5575
6555
|
])
|
|
5576
6556
|
this.addWatchFile(source);
|
|
5577
|
-
this.addWatchFile(
|
|
6557
|
+
this.addWatchFile(import_node_path15.default.join(packagePath, "Package.swift"));
|
|
5578
6558
|
const moduleRoot = linkedModuleRoots(packagePath).find(
|
|
5579
|
-
(root) =>
|
|
6559
|
+
(root) => import_node_fs13.default.existsSync(import_node_path15.default.join(root, "toolchain.json"))
|
|
5580
6560
|
);
|
|
5581
6561
|
if (moduleRoot)
|
|
5582
6562
|
for (const relative of swiftModuleInputFiles(moduleRoot))
|
|
5583
|
-
this.addWatchFile(
|
|
6563
|
+
this.addWatchFile(import_node_path15.default.join(moduleRoot, relative));
|
|
5584
6564
|
let artifact;
|
|
5585
6565
|
try {
|
|
5586
6566
|
artifact = await artifactFor(project, entry);
|
|
@@ -5599,7 +6579,7 @@ function swiftPlugin(options = {}) {
|
|
|
5599
6579
|
...artifact.package.resources.watched,
|
|
5600
6580
|
...artifact.package.bundleFiles.watched
|
|
5601
6581
|
])
|
|
5602
|
-
this.addWatchFile(
|
|
6582
|
+
this.addWatchFile(import_node_path15.default.join(packagePath, ...watched.split(import_node_path15.default.posix.sep)));
|
|
5603
6583
|
const colors = artifact.package.resources.colors;
|
|
5604
6584
|
const symbols = artifact.package.resources.symbols;
|
|
5605
6585
|
const bundleFiles = artifact.package.bundleFiles.files;
|