peachsim 0.1.774 → 0.1.775
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 +1768 -799
- 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 +2136 -1154
- package/dist-lib/swift-compile.cjs +45 -15
- package/dist-lib/swift-compile.mjs +43 -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 +1382 -413
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/swift-compile.ts +56 -18
- package/src/swift-host.ts +60 -11
- package/src/swift-packages.ts +18 -3
- 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.775 | (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()
|
|
@@ -737,8 +746,8 @@ var OPTIONAL_FRAMEWORK_DEPENDENCIES = {
|
|
|
737
746
|
};
|
|
738
747
|
var OPTIONAL_FRAMEWORKS = new Set(Object.keys(OPTIONAL_FRAMEWORK_DEPENDENCIES));
|
|
739
748
|
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 =
|
|
749
|
+
function swiftCondition(text3, available) {
|
|
750
|
+
const tokens = text3.match(/\w+\s*\([^()]*\)|&&|\|\||!|\(|\)|\w+/g) ?? [];
|
|
742
751
|
let index = 0;
|
|
743
752
|
const atom = () => {
|
|
744
753
|
const token = tokens[index++];
|
|
@@ -816,20 +825,37 @@ function swiftPeachModules(moduleRoot) {
|
|
|
816
825
|
)
|
|
817
826
|
].map((match) => match[1]);
|
|
818
827
|
}
|
|
819
|
-
var
|
|
820
|
-
function
|
|
828
|
+
var sdkPaths = /* @__PURE__ */ new Map();
|
|
829
|
+
function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
821
830
|
const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
|
|
822
|
-
const
|
|
823
|
-
const cached =
|
|
831
|
+
const key2 = `${toolchainBin}\0${sdk}`;
|
|
832
|
+
const cached = sdkPaths.get(key2);
|
|
824
833
|
if (cached) return cached;
|
|
825
|
-
const modules = new Set(swiftPeachModules(moduleRoot));
|
|
826
834
|
const configuration = (0, import_node_child_process2.execFileSync)(
|
|
827
835
|
import_node_path2.default.join(toolchainBin, "swift"),
|
|
828
836
|
["sdk", "configure", "--show-configuration", sdk, "wasm32-unknown-wasip1"],
|
|
829
837
|
{ encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }
|
|
830
838
|
);
|
|
831
|
-
const
|
|
832
|
-
|
|
839
|
+
const field = (name) => {
|
|
840
|
+
const value = new RegExp(`^${name}:\\s*(.+)$`, "m").exec(configuration)?.[1]?.trim();
|
|
841
|
+
if (!value) throw new Error(`swift sdk ${sdk} reports no ${name}`);
|
|
842
|
+
return value;
|
|
843
|
+
};
|
|
844
|
+
const paths = {
|
|
845
|
+
sysroot: field("sdkRootPath"),
|
|
846
|
+
resources: field("swiftResourcesPath")
|
|
847
|
+
};
|
|
848
|
+
sdkPaths.set(key2, paths);
|
|
849
|
+
return paths;
|
|
850
|
+
}
|
|
851
|
+
var availableModules = /* @__PURE__ */ new Map();
|
|
852
|
+
function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
853
|
+
const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
|
|
854
|
+
const key2 = `${moduleRoot}\0${sdk}`;
|
|
855
|
+
const cached = availableModules.get(key2);
|
|
856
|
+
if (cached) return cached;
|
|
857
|
+
const modules = new Set(swiftPeachModules(moduleRoot));
|
|
858
|
+
const { resources } = swiftSdkPaths(moduleRoot, toolchainBin);
|
|
833
859
|
for (const entry of (0, import_node_fs2.readdirSync)(import_node_path2.default.join(resources, "wasi"))) {
|
|
834
860
|
if (entry.endsWith(".swiftmodule"))
|
|
835
861
|
modules.add(entry.slice(0, -".swiftmodule".length));
|
|
@@ -840,12 +866,12 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
|
840
866
|
for (const match of (0, import_node_fs2.readFileSync)(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
|
|
841
867
|
modules.add(match[1]);
|
|
842
868
|
}
|
|
843
|
-
availableModules.set(
|
|
869
|
+
availableModules.set(key2, modules);
|
|
844
870
|
return modules;
|
|
845
871
|
}
|
|
846
|
-
function missingSwiftModules(
|
|
872
|
+
function missingSwiftModules(files2, available) {
|
|
847
873
|
const missing = /* @__PURE__ */ new Map();
|
|
848
|
-
for (const [file, contents] of Object.entries(
|
|
874
|
+
for (const [file, contents] of Object.entries(files2)) {
|
|
849
875
|
if (!file.endsWith(".swift") || file === "Package.swift") continue;
|
|
850
876
|
for (const name of new Set(swiftImportNames(contents, available))) {
|
|
851
877
|
if (available.has(name)) continue;
|
|
@@ -854,13 +880,13 @@ function missingSwiftModules(files, available) {
|
|
|
854
880
|
}
|
|
855
881
|
return new Map([...missing].sort(([left], [right]) => left.localeCompare(right)));
|
|
856
882
|
}
|
|
857
|
-
function swiftTargetDependencies(
|
|
883
|
+
function swiftTargetDependencies(files2, targets) {
|
|
858
884
|
const names = /* @__PURE__ */ new Set([...OPTIONAL_FRAMEWORKS, ...targets.map((target) => target.name)]);
|
|
859
885
|
const siblings = /* @__PURE__ */ new Map();
|
|
860
886
|
for (const target of targets) {
|
|
861
887
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
862
888
|
const deps = /* @__PURE__ */ new Set();
|
|
863
|
-
for (const [file, contents] of Object.entries(
|
|
889
|
+
for (const [file, contents] of Object.entries(files2)) {
|
|
864
890
|
if (file === "Package.swift" || !file.startsWith(prefix)) continue;
|
|
865
891
|
if (targets.some(
|
|
866
892
|
(candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
|
|
@@ -876,7 +902,7 @@ function swiftTargetDependencies(files, targets) {
|
|
|
876
902
|
}
|
|
877
903
|
var ONE_PRODUCT = '.product(name: "One", package: "sootsim-swift")';
|
|
878
904
|
var SPRITEKIT_PRODUCT = '.product(name: "SpriteKit", package: "sootsim-swift")';
|
|
879
|
-
var importsSpriteKit = (
|
|
905
|
+
var importsSpriteKit = (files2) => Object.entries(files2).some(
|
|
880
906
|
([file, contents]) => file.endsWith(".swift") && swiftImportNames(contents).includes("SpriteKit")
|
|
881
907
|
);
|
|
882
908
|
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 +1017,18 @@ function emitSwiftPackageManifest(args) {
|
|
|
991
1017
|
""
|
|
992
1018
|
].join("\n");
|
|
993
1019
|
}
|
|
994
|
-
function syncSwiftTree(base,
|
|
1020
|
+
function syncSwiftTree(base, files2) {
|
|
995
1021
|
(0, import_node_fs2.mkdirSync)(base, { recursive: true });
|
|
996
1022
|
const walk2 = (dir) => {
|
|
997
1023
|
for (const entry of (0, import_node_fs2.readdirSync)(dir, { withFileTypes: true })) {
|
|
998
1024
|
const full = import_node_path2.default.join(dir, entry.name);
|
|
999
1025
|
if (dir === base && entry.name === ".build") continue;
|
|
1000
1026
|
if (entry.isDirectory()) walk2(full);
|
|
1001
|
-
else if (!
|
|
1027
|
+
else if (!files2.has(full)) (0, import_node_fs2.rmSync)(full, { force: true });
|
|
1002
1028
|
}
|
|
1003
1029
|
};
|
|
1004
1030
|
walk2(base);
|
|
1005
|
-
for (const [full, contents] of
|
|
1031
|
+
for (const [full, contents] of files2) {
|
|
1006
1032
|
if ((0, import_node_fs2.existsSync)(full) && (0, import_node_fs2.readFileSync)(full, "utf8") === contents) continue;
|
|
1007
1033
|
(0, import_node_fs2.mkdirSync)(import_node_path2.default.dirname(full), { recursive: true });
|
|
1008
1034
|
(0, import_node_fs2.writeFileSync)(full, contents, "utf8");
|
|
@@ -1028,21 +1054,21 @@ var CLASS_DECL = /^class\s+(?!(?:func|var|let|subscript)\b)([A-Za-z_]\w*)/;
|
|
|
1028
1054
|
var MODIFIERS = /(?:^|\s)(public|open|internal|fileprivate|private|final|nonisolated|@MainActor)(?=\s)/g;
|
|
1029
1055
|
var OVERRIDE_FUNC = /^override((?:\s+(?:public|open|internal|fileprivate|private|final|nonisolated|dynamic|@\w+))*)\s+func\s+([A-Za-z_]\w*)\s*(<[^>{}]*>)?\s*\(/;
|
|
1030
1056
|
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(
|
|
1057
|
+
function splitTopLevel(text3) {
|
|
1032
1058
|
const parts = [];
|
|
1033
1059
|
let depth = 0;
|
|
1034
1060
|
let start = 0;
|
|
1035
|
-
for (let i = 0; i <
|
|
1036
|
-
const char =
|
|
1061
|
+
for (let i = 0; i < text3.length; i++) {
|
|
1062
|
+
const char = text3[i];
|
|
1037
1063
|
if (char === "(" || char === "[" || char === "<") depth++;
|
|
1038
|
-
else if (char === ")" || char === "]" || char === ">" &&
|
|
1064
|
+
else if (char === ")" || char === "]" || char === ">" && text3[i - 1] !== "-")
|
|
1039
1065
|
depth--;
|
|
1040
1066
|
else if (char === "," && depth === 0) {
|
|
1041
|
-
parts.push(
|
|
1067
|
+
parts.push(text3.slice(start, i));
|
|
1042
1068
|
start = i + 1;
|
|
1043
1069
|
}
|
|
1044
1070
|
}
|
|
1045
|
-
parts.push(
|
|
1071
|
+
parts.push(text3.slice(start));
|
|
1046
1072
|
return parts.map((part) => part.trim()).filter((part) => part !== "");
|
|
1047
1073
|
}
|
|
1048
1074
|
function forwardedArguments(parameters) {
|
|
@@ -1758,7 +1784,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
1758
1784
|
resources: false
|
|
1759
1785
|
}
|
|
1760
1786
|
] : compileTargets(input);
|
|
1761
|
-
const
|
|
1787
|
+
const files2 = /* @__PURE__ */ new Map();
|
|
1762
1788
|
const modulePlan = (0, import_node_crypto2.createHash)("sha256").update(
|
|
1763
1789
|
swiftModuleInputFiles(moduleRoot).join("\n")
|
|
1764
1790
|
);
|
|
@@ -1780,7 +1806,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
1780
1806
|
if (targets.length === 0) {
|
|
1781
1807
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
1782
1808
|
if (file === "Package.swift") continue;
|
|
1783
|
-
|
|
1809
|
+
files2.set(
|
|
1784
1810
|
import_node_path2.default.join(layout.sources, file),
|
|
1785
1811
|
compiledSource(file, contents, objcExtensions)
|
|
1786
1812
|
);
|
|
@@ -1824,14 +1850,14 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
1824
1850
|
manifest = manifest.replace(anchor, `${anchor}
|
|
1825
1851
|
${SPRITEKIT_PRODUCT},`);
|
|
1826
1852
|
}
|
|
1827
|
-
|
|
1853
|
+
files2.set(import_node_path2.default.join(layout.root, "Package.swift"), manifest + moduleFiles);
|
|
1828
1854
|
} else {
|
|
1829
1855
|
const base = layout.multi ? layout.root : layout.sources;
|
|
1830
1856
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
1831
1857
|
if (file === "Package.swift") continue;
|
|
1832
|
-
|
|
1858
|
+
files2.set(import_node_path2.default.join(base, file), compiledSource(file, contents, objcExtensions));
|
|
1833
1859
|
}
|
|
1834
|
-
|
|
1860
|
+
files2.set(
|
|
1835
1861
|
import_node_path2.default.join(layout.root, "Package.swift"),
|
|
1836
1862
|
emitSwiftPackageManifest({
|
|
1837
1863
|
targets,
|
|
@@ -1849,7 +1875,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
1849
1875
|
for (const target of resourceTargets) {
|
|
1850
1876
|
if (!target.resources) continue;
|
|
1851
1877
|
const directory = layout.multi ? import_node_path2.default.join(layout.root, target.path) : layout.sources;
|
|
1852
|
-
|
|
1878
|
+
files2.set(
|
|
1853
1879
|
import_node_path2.default.join(directory, "ResourceBundleAccessor.generated.swift"),
|
|
1854
1880
|
[
|
|
1855
1881
|
"import Foundation",
|
|
@@ -1861,7 +1887,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
1861
1887
|
].join("\n")
|
|
1862
1888
|
);
|
|
1863
1889
|
}
|
|
1864
|
-
syncSwiftTree(layout.root,
|
|
1890
|
+
syncSwiftTree(layout.root, files2);
|
|
1865
1891
|
}
|
|
1866
1892
|
function streamText(value) {
|
|
1867
1893
|
if (typeof value === "string") return value.trim();
|
|
@@ -1975,10 +2001,10 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
1975
2001
|
}
|
|
1976
2002
|
|
|
1977
2003
|
// src/swift-host.ts
|
|
1978
|
-
var
|
|
1979
|
-
var
|
|
1980
|
-
var
|
|
1981
|
-
var
|
|
2004
|
+
var import_node_crypto7 = require("node:crypto");
|
|
2005
|
+
var import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
2006
|
+
var import_node_os8 = __toESM(require("node:os"), 1);
|
|
2007
|
+
var import_node_path14 = __toESM(require("node:path"), 1);
|
|
1982
2008
|
|
|
1983
2009
|
// ../sootsim-swift/src/bundleAssets.ts
|
|
1984
2010
|
var import_svgpath = __toESM(require("svgpath"), 1);
|
|
@@ -2012,14 +2038,14 @@ function pickImagesetFile(images) {
|
|
|
2012
2038
|
scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
|
|
2013
2039
|
};
|
|
2014
2040
|
}
|
|
2015
|
-
function flatScale(
|
|
2016
|
-
const match = /@([23])x\.[^./]+$/.exec(
|
|
2041
|
+
function flatScale(path15) {
|
|
2042
|
+
const match = /@([23])x\.[^./]+$/.exec(path15);
|
|
2017
2043
|
return match ? Number(match[1]) : 1;
|
|
2018
2044
|
}
|
|
2019
|
-
function providesNamespace(
|
|
2020
|
-
if (
|
|
2045
|
+
function providesNamespace(text3) {
|
|
2046
|
+
if (text3 === null) return false;
|
|
2021
2047
|
try {
|
|
2022
|
-
const parsed = JSON.parse(
|
|
2048
|
+
const parsed = JSON.parse(text3);
|
|
2023
2049
|
return parsed?.properties?.["provides-namespace"] === true;
|
|
2024
2050
|
} catch {
|
|
2025
2051
|
return false;
|
|
@@ -2027,9 +2053,9 @@ function providesNamespace(text2) {
|
|
|
2027
2053
|
}
|
|
2028
2054
|
function catalogEntryName(contentsPath, kind, readText) {
|
|
2029
2055
|
const parts = contentsPath.split("/");
|
|
2030
|
-
const
|
|
2031
|
-
if (!
|
|
2032
|
-
const short =
|
|
2056
|
+
const leaf2 = parts[parts.length - 2] ?? "";
|
|
2057
|
+
if (!leaf2.endsWith(kind)) return null;
|
|
2058
|
+
const short = leaf2.slice(0, -kind.length) || null;
|
|
2033
2059
|
if (short === null) return null;
|
|
2034
2060
|
const segments = [short];
|
|
2035
2061
|
for (let depth = parts.length - 3; depth >= 0; depth -= 1) {
|
|
@@ -2040,21 +2066,21 @@ function catalogEntryName(contentsPath, kind, readText) {
|
|
|
2040
2066
|
}
|
|
2041
2067
|
return segments.join("/");
|
|
2042
2068
|
}
|
|
2043
|
-
function isFlatResourceImage(
|
|
2044
|
-
return
|
|
2069
|
+
function isFlatResourceImage(path15) {
|
|
2070
|
+
return path15.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path15));
|
|
2045
2071
|
}
|
|
2046
2072
|
function enumerateBundleImages(paths, readText) {
|
|
2047
2073
|
const table = [];
|
|
2048
2074
|
const seen = /* @__PURE__ */ new Set();
|
|
2049
|
-
const catalogs = paths.filter((
|
|
2075
|
+
const catalogs = paths.filter((path15) => baseOf(path15) === "Contents.json");
|
|
2050
2076
|
for (const contentsPath of catalogs) {
|
|
2051
2077
|
const name = catalogEntryName(contentsPath, ".imageset", readText);
|
|
2052
2078
|
if (name === null || seen.has(name)) continue;
|
|
2053
2079
|
let parsed;
|
|
2054
2080
|
try {
|
|
2055
|
-
const
|
|
2056
|
-
if (
|
|
2057
|
-
parsed = JSON.parse(
|
|
2081
|
+
const text3 = readText(contentsPath);
|
|
2082
|
+
if (text3 === null) continue;
|
|
2083
|
+
parsed = JSON.parse(text3);
|
|
2058
2084
|
} catch {
|
|
2059
2085
|
continue;
|
|
2060
2086
|
}
|
|
@@ -2067,12 +2093,12 @@ function enumerateBundleImages(paths, readText) {
|
|
|
2067
2093
|
seen.add(name);
|
|
2068
2094
|
table.push({ name, file: `${dir}/${pick.filename}`, scale: pick.scale });
|
|
2069
2095
|
}
|
|
2070
|
-
for (const
|
|
2071
|
-
if (!isFlatResourceImage(
|
|
2072
|
-
const name = baseOf(
|
|
2096
|
+
for (const path15 of paths) {
|
|
2097
|
+
if (!isFlatResourceImage(path15)) continue;
|
|
2098
|
+
const name = baseOf(path15).slice(0, -extOf(path15).length);
|
|
2073
2099
|
if (name === "" || seen.has(name)) continue;
|
|
2074
2100
|
seen.add(name);
|
|
2075
|
-
table.push({ name, file:
|
|
2101
|
+
table.push({ name, file: path15, scale: flatScale(path15) });
|
|
2076
2102
|
}
|
|
2077
2103
|
return table;
|
|
2078
2104
|
}
|
|
@@ -2092,7 +2118,7 @@ function colorsetValue(color) {
|
|
|
2092
2118
|
const components = Reflect.get(color, "components");
|
|
2093
2119
|
if (typeof components !== "object" || components === null) return null;
|
|
2094
2120
|
const [red, green, blue, alpha] = ["red", "green", "blue", "alpha"].map(
|
|
2095
|
-
(
|
|
2121
|
+
(key2) => colorComponent(Reflect.get(components, key2))
|
|
2096
2122
|
);
|
|
2097
2123
|
if (red === null || green === null || blue === null || alpha === null) return null;
|
|
2098
2124
|
if (![red, green, blue].every((value) => value >= 0 && value <= 1)) return null;
|
|
@@ -2101,14 +2127,14 @@ function colorsetValue(color) {
|
|
|
2101
2127
|
}
|
|
2102
2128
|
function enumerateBundleColors(paths, readText) {
|
|
2103
2129
|
const table = {};
|
|
2104
|
-
for (const contentsPath of paths.filter((
|
|
2130
|
+
for (const contentsPath of paths.filter((path15) => baseOf(path15) === "Contents.json")) {
|
|
2105
2131
|
const name = catalogEntryName(contentsPath, ".colorset", readText);
|
|
2106
2132
|
if (name === null || name in table) continue;
|
|
2107
2133
|
let colors;
|
|
2108
2134
|
try {
|
|
2109
|
-
const
|
|
2110
|
-
if (
|
|
2111
|
-
colors = Reflect.get(JSON.parse(
|
|
2135
|
+
const text3 = readText(contentsPath);
|
|
2136
|
+
if (text3 === null) continue;
|
|
2137
|
+
colors = Reflect.get(JSON.parse(text3), "colors");
|
|
2112
2138
|
} catch {
|
|
2113
2139
|
continue;
|
|
2114
2140
|
}
|
|
@@ -2166,8 +2192,8 @@ function axisExtremes(points) {
|
|
|
2166
2192
|
function pathBounds(d) {
|
|
2167
2193
|
const xs = [];
|
|
2168
2194
|
const ys = [];
|
|
2169
|
-
for (const
|
|
2170
|
-
(0, import_svgpath.default)(
|
|
2195
|
+
for (const path15 of d)
|
|
2196
|
+
(0, import_svgpath.default)(path15).abs().unshort().unarc().iterate((segment, _index, x, y) => {
|
|
2171
2197
|
const [command, ...args] = segment;
|
|
2172
2198
|
if (command === "M" || command === "L") {
|
|
2173
2199
|
xs.push(Number(args[0]));
|
|
@@ -2194,7 +2220,7 @@ function guide(svg, id, axis) {
|
|
|
2194
2220
|
}
|
|
2195
2221
|
function enumerateBundleSymbols(paths, readText) {
|
|
2196
2222
|
const table = {};
|
|
2197
|
-
for (const contentsPath of paths.filter((
|
|
2223
|
+
for (const contentsPath of paths.filter((path15) => baseOf(path15) === "Contents.json")) {
|
|
2198
2224
|
const name = catalogEntryName(contentsPath, ".symbolset", readText);
|
|
2199
2225
|
if (name === null || name in table) continue;
|
|
2200
2226
|
let symbols;
|
|
@@ -2227,8 +2253,8 @@ function enumerateBundleSymbols(paths, readText) {
|
|
|
2227
2253
|
viewBox: "0 0 24 24",
|
|
2228
2254
|
advance,
|
|
2229
2255
|
box: [12 - advance / 2, 12 - tall / 2, advance, tall],
|
|
2230
|
-
layers: d.map((
|
|
2231
|
-
d: (0, import_svgpath.default)(
|
|
2256
|
+
layers: d.map((path15) => ({
|
|
2257
|
+
d: (0, import_svgpath.default)(path15).abs().scale(scale).translate(translateX, translateY).round(3).toString()
|
|
2232
2258
|
}))
|
|
2233
2259
|
};
|
|
2234
2260
|
}
|
|
@@ -2238,7 +2264,7 @@ function enumerateBundleJson(paths) {
|
|
|
2238
2264
|
const found = [];
|
|
2239
2265
|
const seen = /* @__PURE__ */ new Set();
|
|
2240
2266
|
const ordered = [...paths].filter(
|
|
2241
|
-
(
|
|
2267
|
+
(path15) => path15.split("/").includes("Resources") && path15.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path15) === ".json" || extOf(path15) === ".xcstrings")
|
|
2242
2268
|
).sort((a, b) => {
|
|
2243
2269
|
const aDepth = a.split("/").length;
|
|
2244
2270
|
const bDepth = b.split("/").length;
|
|
@@ -3123,12 +3149,12 @@ var evaluated = /* @__PURE__ */ new Map();
|
|
|
3123
3149
|
function dump(dir) {
|
|
3124
3150
|
const manifests = import_node_fs8.default.readdirSync(dir).filter((name) => /^Package(@swift-[\d.]+)?\.swift$/.test(name)).sort();
|
|
3125
3151
|
const command = swiftCommand();
|
|
3126
|
-
const
|
|
3152
|
+
const key2 = (0, import_node_crypto5.createHash)("sha256").update(JSON.stringify([command, import_node_path9.default.resolve(dir)])).update(
|
|
3127
3153
|
manifests.map((name) => `${name}\0${import_node_fs8.default.readFileSync(import_node_path9.default.join(dir, name), "utf8")}`).join("\0")
|
|
3128
3154
|
).digest("hex").slice(0, 32);
|
|
3129
|
-
const cached = import_node_path9.default.join(cacheDir2, `${
|
|
3155
|
+
const cached = import_node_path9.default.join(cacheDir2, `${key2}.json`);
|
|
3130
3156
|
if (import_node_fs8.default.existsSync(cached))
|
|
3131
|
-
return { key, raw: record(JSON.parse(import_node_fs8.default.readFileSync(cached, "utf8"))) };
|
|
3157
|
+
return { key: key2, raw: record(JSON.parse(import_node_fs8.default.readFileSync(cached, "utf8"))) };
|
|
3132
3158
|
let output;
|
|
3133
3159
|
try {
|
|
3134
3160
|
output = (0, import_node_child_process5.execFileSync)(
|
|
@@ -3140,7 +3166,7 @@ function dump(dir) {
|
|
|
3140
3166
|
dir,
|
|
3141
3167
|
// swiftpm's scratch files never land in the app's own package
|
|
3142
3168
|
"--scratch-path",
|
|
3143
|
-
import_node_path9.default.join(cacheDir2, `${
|
|
3169
|
+
import_node_path9.default.join(cacheDir2, `${key2}.build`),
|
|
3144
3170
|
"dump-package"
|
|
3145
3171
|
],
|
|
3146
3172
|
{
|
|
@@ -3157,7 +3183,7 @@ function dump(dir) {
|
|
|
3157
3183
|
}
|
|
3158
3184
|
import_node_fs8.default.mkdirSync(cacheDir2, { recursive: true });
|
|
3159
3185
|
import_node_fs8.default.writeFileSync(cached, output);
|
|
3160
|
-
return { key, raw: record(JSON.parse(output)) };
|
|
3186
|
+
return { key: key2, raw: record(JSON.parse(output)) };
|
|
3161
3187
|
}
|
|
3162
3188
|
function defaultTraits(manifest) {
|
|
3163
3189
|
const traits = new Map(
|
|
@@ -3185,8 +3211,8 @@ function linksOnIOS(condition, traits) {
|
|
|
3185
3211
|
}
|
|
3186
3212
|
function swiftPackageManifest(dir) {
|
|
3187
3213
|
dir = import_node_fs8.default.realpathSync(dir);
|
|
3188
|
-
const { key, raw: raw2 } = dump(dir);
|
|
3189
|
-
const known = evaluated.get(
|
|
3214
|
+
const { key: key2, raw: raw2 } = dump(dir);
|
|
3215
|
+
const known = evaluated.get(key2);
|
|
3190
3216
|
if (known) return known;
|
|
3191
3217
|
const traits = defaultTraits(raw2);
|
|
3192
3218
|
const tools = Number(
|
|
@@ -3279,7 +3305,7 @@ function swiftPackageManifest(dir) {
|
|
|
3279
3305
|
});
|
|
3280
3306
|
}
|
|
3281
3307
|
const manifest = { dir, products, targets, packages };
|
|
3282
|
-
evaluated.set(
|
|
3308
|
+
evaluated.set(key2, manifest);
|
|
3283
3309
|
return manifest;
|
|
3284
3310
|
}
|
|
3285
3311
|
var within = (file, roots) => roots.some((root) => file === root || file.startsWith(`${root}${import_node_path9.default.sep}`));
|
|
@@ -3329,8 +3355,8 @@ function readPins(resolved) {
|
|
|
3329
3355
|
var verified2 = /* @__PURE__ */ new Set();
|
|
3330
3356
|
function checkout(checkouts, identity, pin) {
|
|
3331
3357
|
const dir = import_node_path10.default.join(checkouts, identity);
|
|
3332
|
-
const
|
|
3333
|
-
if (verified2.has(
|
|
3358
|
+
const key2 = `${dir}\0${pin.revision}`;
|
|
3359
|
+
if (verified2.has(key2)) return dir;
|
|
3334
3360
|
const git = (...args) => (0, import_node_child_process6.execFileSync)("git", ["-C", dir, ...args], {
|
|
3335
3361
|
encoding: "utf8",
|
|
3336
3362
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -3351,7 +3377,7 @@ function checkout(checkouts, identity, pin) {
|
|
|
3351
3377
|
);
|
|
3352
3378
|
}
|
|
3353
3379
|
}
|
|
3354
|
-
verified2.add(
|
|
3380
|
+
verified2.add(key2);
|
|
3355
3381
|
return dir;
|
|
3356
3382
|
}
|
|
3357
3383
|
function resolveSwiftPackages(options) {
|
|
@@ -3367,12 +3393,12 @@ function resolveSwiftPackages(options) {
|
|
|
3367
3393
|
const checkouts = import_node_path10.default.join(rootDir, REMOTE_CHECKOUTS);
|
|
3368
3394
|
const packages = /* @__PURE__ */ new Map();
|
|
3369
3395
|
const load2 = (source) => {
|
|
3370
|
-
const
|
|
3371
|
-
const cached = packages.get(
|
|
3396
|
+
const key2 = source.kind === "local" ? import_node_path10.default.resolve(source.dir) : source.url;
|
|
3397
|
+
const cached = packages.get(key2);
|
|
3372
3398
|
if (cached !== void 0) return cached;
|
|
3373
3399
|
let loaded2;
|
|
3374
3400
|
if (source.kind === "local") {
|
|
3375
|
-
loaded2 = { source:
|
|
3401
|
+
loaded2 = { source: key2, remote: false, manifest: swiftPackageManifest(key2) };
|
|
3376
3402
|
} else {
|
|
3377
3403
|
const identity = swiftPackageIdentity(source.url);
|
|
3378
3404
|
const pin = pins?.get(identity);
|
|
@@ -3388,24 +3414,27 @@ function resolveSwiftPackages(options) {
|
|
|
3388
3414
|
};
|
|
3389
3415
|
}
|
|
3390
3416
|
}
|
|
3391
|
-
packages.set(
|
|
3417
|
+
packages.set(key2, loaded2);
|
|
3392
3418
|
return loaded2;
|
|
3393
3419
|
};
|
|
3394
3420
|
const targets = /* @__PURE__ */ new Map();
|
|
3395
3421
|
const targetOutcomes = /* @__PURE__ */ new Map();
|
|
3396
3422
|
const resolveTarget = (pkg, name) => {
|
|
3397
|
-
const
|
|
3398
|
-
if (targetOutcomes.has(
|
|
3399
|
-
targetOutcomes.set(
|
|
3423
|
+
const key2 = `${pkg.manifest.dir}\0${name}`;
|
|
3424
|
+
if (targetOutcomes.has(key2)) return targetOutcomes.get(key2);
|
|
3425
|
+
targetOutcomes.set(key2, null);
|
|
3400
3426
|
const outcome = (() => {
|
|
3401
3427
|
if (provided.has(name)) return null;
|
|
3402
3428
|
const target = pkg.manifest.targets.get(name);
|
|
3403
3429
|
if (!target) return `${import_node_path10.default.basename(pkg.manifest.dir)} declares no target ${name}`;
|
|
3404
|
-
if (target.type === "binary")
|
|
3430
|
+
if (target.type === "binary") {
|
|
3431
|
+
const gap = options.binaryGaps?.get(name);
|
|
3432
|
+
return `${name} ${BINARY}${gap ? `; ${gap}` : ""}`;
|
|
3433
|
+
}
|
|
3405
3434
|
if (target.type === "system") return `${name} is a system C library`;
|
|
3406
3435
|
if (target.type !== "regular") return `${name} is a ${target.type} target`;
|
|
3407
|
-
const
|
|
3408
|
-
if (
|
|
3436
|
+
const files2 = swiftTargetFiles(pkg.manifest, target);
|
|
3437
|
+
if (files2.some((file) => C_FAMILY.test(file)))
|
|
3409
3438
|
return `${name} is a C or Objective-C target`;
|
|
3410
3439
|
const reasons = target.dependencies.map((dependency) => {
|
|
3411
3440
|
if (dependency.kind === "target") return resolveTarget(pkg, dependency.name);
|
|
@@ -3414,12 +3443,12 @@ function resolveSwiftPackages(options) {
|
|
|
3414
3443
|
});
|
|
3415
3444
|
const blocked = blocker(reasons);
|
|
3416
3445
|
if (blocked) return blocked;
|
|
3417
|
-
const relative =
|
|
3446
|
+
const relative = files2.map((file) => import_node_path10.default.relative(target.dir, file));
|
|
3418
3447
|
targets.set(`${pkg.manifest.dir}\0${name}`, {
|
|
3419
3448
|
name,
|
|
3420
3449
|
path: "",
|
|
3421
3450
|
dir: target.dir,
|
|
3422
|
-
files,
|
|
3451
|
+
files: files2,
|
|
3423
3452
|
packageDir: pkg.manifest.dir,
|
|
3424
3453
|
remote: pkg.remote,
|
|
3425
3454
|
executable: false,
|
|
@@ -3429,7 +3458,7 @@ function resolveSwiftPackages(options) {
|
|
|
3429
3458
|
});
|
|
3430
3459
|
return null;
|
|
3431
3460
|
})();
|
|
3432
|
-
targetOutcomes.set(
|
|
3461
|
+
targetOutcomes.set(key2, outcome);
|
|
3433
3462
|
return outcome;
|
|
3434
3463
|
};
|
|
3435
3464
|
const productOutcomes = /* @__PURE__ */ new Map();
|
|
@@ -3476,23 +3505,24 @@ function resolveSwiftPackages(options) {
|
|
|
3476
3505
|
target: name,
|
|
3477
3506
|
source: pkg.source,
|
|
3478
3507
|
url: target.url,
|
|
3479
|
-
dir: target.dir
|
|
3508
|
+
dir: target.dir,
|
|
3509
|
+
reached: false
|
|
3480
3510
|
});
|
|
3481
3511
|
const reason = resolveTarget(pkg, name);
|
|
3482
3512
|
if (reason && !result.modules.has(name))
|
|
3483
3513
|
result.modules.set(name, { source: pkg.source, reason });
|
|
3484
3514
|
}
|
|
3485
3515
|
}
|
|
3486
|
-
for (const [
|
|
3487
|
-
const product =
|
|
3516
|
+
for (const [key2, { pkg, reason }] of productOutcomes) {
|
|
3517
|
+
const product = key2.slice(key2.indexOf("\0") + 1);
|
|
3488
3518
|
if (reason && !result.modules.has(product))
|
|
3489
3519
|
result.modules.set(product, { source: pkg.source, reason });
|
|
3490
3520
|
}
|
|
3491
3521
|
const reached = /* @__PURE__ */ new Set();
|
|
3492
3522
|
const reach = (pkg, name) => {
|
|
3493
|
-
const
|
|
3494
|
-
if (reached.has(
|
|
3495
|
-
reached.add(
|
|
3523
|
+
const key2 = `${pkg.manifest.dir}\0${name}`;
|
|
3524
|
+
if (reached.has(key2)) return;
|
|
3525
|
+
reached.add(key2);
|
|
3496
3526
|
for (const dependency of pkg.manifest.targets.get(name)?.dependencies ?? []) {
|
|
3497
3527
|
if (dependency.kind === "target") reach(pkg, dependency.name);
|
|
3498
3528
|
else {
|
|
@@ -3509,9 +3539,918 @@ function resolveSwiftPackages(options) {
|
|
|
3509
3539
|
if (!pkg || typeof pkg === "string") continue;
|
|
3510
3540
|
for (const root of pkg.manifest.products.get(product) ?? []) reach(pkg, root);
|
|
3511
3541
|
}
|
|
3512
|
-
|
|
3542
|
+
for (const binary of result.binaries) {
|
|
3543
|
+
const pkg = packages.get(binary.source);
|
|
3544
|
+
if (pkg && typeof pkg !== "string")
|
|
3545
|
+
binary.reached = reached.has(`${pkg.manifest.dir}\0${binary.target}`);
|
|
3546
|
+
}
|
|
3547
|
+
result.targets = [...targets.entries()].filter(([key2]) => reached.has(key2)).map(([, target]) => target);
|
|
3548
|
+
return result;
|
|
3549
|
+
}
|
|
3550
|
+
|
|
3551
|
+
// src/swift-standins.ts
|
|
3552
|
+
var import_node_child_process7 = require("node:child_process");
|
|
3553
|
+
var import_node_crypto6 = require("node:crypto");
|
|
3554
|
+
var import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
3555
|
+
var import_node_os7 = __toESM(require("node:os"), 1);
|
|
3556
|
+
var import_node_path11 = __toESM(require("node:path"), 1);
|
|
3557
|
+
|
|
3558
|
+
// src/swift-standin-emit.ts
|
|
3559
|
+
var TYPE_KINDS = /* @__PURE__ */ new Set([
|
|
3560
|
+
"swift.class",
|
|
3561
|
+
"swift.struct",
|
|
3562
|
+
"swift.enum",
|
|
3563
|
+
"swift.protocol",
|
|
3564
|
+
"swift.typealias"
|
|
3565
|
+
]);
|
|
3566
|
+
var MEMBER_KINDS = /* @__PURE__ */ new Set([
|
|
3567
|
+
"swift.method",
|
|
3568
|
+
"swift.type.method",
|
|
3569
|
+
"swift.func.op",
|
|
3570
|
+
"swift.init",
|
|
3571
|
+
"swift.property",
|
|
3572
|
+
"swift.type.property",
|
|
3573
|
+
"swift.subscript",
|
|
3574
|
+
"swift.type.subscript"
|
|
3575
|
+
]);
|
|
3576
|
+
var ACCESSORS = /\{\s*get(\s+async)?(\s+throws)?(\s+set)?\s*\}\s*$/;
|
|
3577
|
+
var KEEP_EXTERNAL = /* @__PURE__ */ new Map([
|
|
3578
|
+
["s:SH", "Hashable"],
|
|
3579
|
+
["s:SQ", "Equatable"],
|
|
3580
|
+
["s:s5ErrorP", "Error"],
|
|
3581
|
+
["s:s8SendableP", "Sendable"],
|
|
3582
|
+
["s:s12IdentifiableP", "Identifiable"],
|
|
3583
|
+
["s:SY", "RawRepresentable"],
|
|
3584
|
+
["s:s9OptionSetP", "OptionSet"],
|
|
3585
|
+
["s:s12CaseIterableP", "CaseIterable"],
|
|
3586
|
+
["s:SE", "Encodable"],
|
|
3587
|
+
["s:Se", "Decodable"],
|
|
3588
|
+
["s:s23CustomStringConvertibleP", "CustomStringConvertible"]
|
|
3589
|
+
]);
|
|
3590
|
+
var LEADING_ATTRS = /^((?:@\w+(?:\([^)]*\))?\s*|nonisolated\s+)*)(.*)$/s;
|
|
3591
|
+
var OBJC_ONLY = /@(?:objcMembers|objc|IBOutlet|IBInspectable|IBAction|IBSegueAction|GKInspectable|nonobjc|NSCopying|NSManaged)(?:\([^)]*\))?\s*|\bdynamic\s+/g;
|
|
3592
|
+
var text = (symbol) => (symbol.declarationFragments ?? []).map((fragment) => fragment.spelling).join("").replace(OBJC_ONLY, "").replace(/(^|\s)optional (?=func|var|init|subscript|static|class)/, "$1");
|
|
3593
|
+
var leaf = (symbol) => symbol.pathComponents[symbol.pathComponents.length - 1];
|
|
3594
|
+
var pathOf = (symbol) => symbol.pathComponents.join(".");
|
|
3595
|
+
var unavailable = (symbol) => (symbol.availability ?? []).some(
|
|
3596
|
+
(entry) => entry.isUnconditionallyUnavailable || entry.obsoleted !== void 0
|
|
3597
|
+
);
|
|
3598
|
+
var witnessKey = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.") ? "type" : "instance"}|${leaf(symbol)}`;
|
|
3599
|
+
var isObjC = (symbol) => symbol.identifier.precise.startsWith("c:");
|
|
3600
|
+
var trap = (path15) => `fatalError("${path15} is a binary framework peach cannot run")`;
|
|
3601
|
+
function emitSwiftStandin(graphs, options) {
|
|
3602
|
+
const skipped = [];
|
|
3603
|
+
const behavior = options.behavior ?? /* @__PURE__ */ new Map();
|
|
3604
|
+
const used = /* @__PURE__ */ new Set();
|
|
3605
|
+
const values = options.values ?? /* @__PURE__ */ new Map();
|
|
3606
|
+
const family = /* @__PURE__ */ new Set([options.module, ...options.family ?? []]);
|
|
3607
|
+
const byId = /* @__PURE__ */ new Map();
|
|
3608
|
+
const twins = /* @__PURE__ */ new Map();
|
|
3609
|
+
const owner = /* @__PURE__ */ new Map();
|
|
3610
|
+
for (const graph of graphs)
|
|
3611
|
+
for (const symbol of graph.symbols) {
|
|
3612
|
+
if (symbol.accessLevel !== "public" && symbol.accessLevel !== "open") continue;
|
|
3613
|
+
const id = symbol.identifier.precise;
|
|
3614
|
+
if (!byId.has(id)) byId.set(id, symbol);
|
|
3615
|
+
twins.set(id, [...twins.get(id) ?? [], symbol]);
|
|
3616
|
+
}
|
|
3617
|
+
const all = (id) => twins.get(id) ?? [];
|
|
3618
|
+
const children = /* @__PURE__ */ new Map();
|
|
3619
|
+
const superclass = /* @__PURE__ */ new Map();
|
|
3620
|
+
const superId = /* @__PURE__ */ new Map();
|
|
3621
|
+
const conforms = /* @__PURE__ */ new Map();
|
|
3622
|
+
const conformIds = /* @__PURE__ */ new Map();
|
|
3623
|
+
const protocolParents = /* @__PURE__ */ new Map();
|
|
3624
|
+
const requirement = /* @__PURE__ */ new Set();
|
|
3625
|
+
const optional = /* @__PURE__ */ new Set();
|
|
3626
|
+
const overrides = /* @__PURE__ */ new Set();
|
|
3627
|
+
const external = /* @__PURE__ */ new Map();
|
|
3628
|
+
const nameOf = (id, fallback) => {
|
|
3629
|
+
const local = byId.get(id);
|
|
3630
|
+
if (local) return { name: pathOf(local), local: true };
|
|
3631
|
+
if (!fallback) return null;
|
|
3632
|
+
const parts = fallback.split(".");
|
|
3633
|
+
return { name: parts.slice(1).join(".") || parts[0], module: parts[0], local: false };
|
|
3634
|
+
};
|
|
3635
|
+
for (const graph of graphs)
|
|
3636
|
+
for (const edge of graph.relationships) {
|
|
3637
|
+
const source = byId.get(edge.source);
|
|
3638
|
+
if (!source) continue;
|
|
3639
|
+
switch (edge.kind) {
|
|
3640
|
+
case "memberOf": {
|
|
3641
|
+
const parent = byId.get(edge.target);
|
|
3642
|
+
if (parent) {
|
|
3643
|
+
owner.set(edge.source, edge.target);
|
|
3644
|
+
children.set(edge.target, [...children.get(edge.target) ?? [], ...all(edge.source)]);
|
|
3645
|
+
} else if (edge.targetFallback) {
|
|
3646
|
+
const name = nameOf(edge.target, edge.targetFallback).name;
|
|
3647
|
+
external.set(name, [...external.get(name) ?? [], ...all(edge.source)]);
|
|
3648
|
+
owner.set(edge.source, edge.target);
|
|
3649
|
+
}
|
|
3650
|
+
break;
|
|
3651
|
+
}
|
|
3652
|
+
case "inheritsFrom": {
|
|
3653
|
+
const target = nameOf(edge.target, edge.targetFallback);
|
|
3654
|
+
if (target) superclass.set(edge.source, target.name);
|
|
3655
|
+
superId.set(edge.source, edge.target);
|
|
3656
|
+
break;
|
|
3657
|
+
}
|
|
3658
|
+
case "conformsTo": {
|
|
3659
|
+
const target = nameOf(edge.target, edge.targetFallback);
|
|
3660
|
+
const kept = KEEP_EXTERNAL.get(edge.target);
|
|
3661
|
+
const name = kept ?? (target && (target.local || family.has(target.module ?? "")) ? target.name : null);
|
|
3662
|
+
if (name) conforms.set(edge.source, [...conforms.get(edge.source) ?? [], name]);
|
|
3663
|
+
if (byId.has(edge.target)) {
|
|
3664
|
+
const map = source.kind.identifier === "swift.protocol" ? protocolParents : conformIds;
|
|
3665
|
+
map.set(edge.source, [...map.get(edge.source) ?? [], edge.target]);
|
|
3666
|
+
}
|
|
3667
|
+
break;
|
|
3668
|
+
}
|
|
3669
|
+
case "requirementOf":
|
|
3670
|
+
case "optionalRequirementOf":
|
|
3671
|
+
requirement.add(edge.source);
|
|
3672
|
+
if (edge.kind === "optionalRequirementOf") optional.add(edge.source);
|
|
3673
|
+
if (byId.has(edge.target) && !owner.has(edge.source)) {
|
|
3674
|
+
owner.set(edge.source, edge.target);
|
|
3675
|
+
children.set(edge.target, [...children.get(edge.target) ?? [], ...all(edge.source)]);
|
|
3676
|
+
}
|
|
3677
|
+
break;
|
|
3678
|
+
case "overrides":
|
|
3679
|
+
overrides.add(edge.source);
|
|
3680
|
+
break;
|
|
3681
|
+
}
|
|
3682
|
+
}
|
|
3683
|
+
const lines = [];
|
|
3684
|
+
const owners = [];
|
|
3685
|
+
const omit = options.omit ?? /* @__PURE__ */ new Map();
|
|
3686
|
+
let current = "";
|
|
3687
|
+
const emit = (line) => {
|
|
3688
|
+
lines.push(line);
|
|
3689
|
+
owners.push(current);
|
|
3690
|
+
};
|
|
3691
|
+
const scoped = (body) => (symbol, ...rest) => {
|
|
3692
|
+
const path15 = pathOf(symbol);
|
|
3693
|
+
if (omit.has(path15)) return void skipped.push({ path: path15, reason: omit.get(path15) });
|
|
3694
|
+
const previous = current;
|
|
3695
|
+
current = path15;
|
|
3696
|
+
try {
|
|
3697
|
+
body(symbol, ...rest);
|
|
3698
|
+
} finally {
|
|
3699
|
+
current = previous;
|
|
3700
|
+
}
|
|
3701
|
+
};
|
|
3702
|
+
const membersOf = (id) => {
|
|
3703
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3704
|
+
return (children.get(id) ?? []).filter((member) => {
|
|
3705
|
+
if (unavailable(member)) return false;
|
|
3706
|
+
const key2 = `${member.kind.identifier}|${text(member)}`;
|
|
3707
|
+
if (seen.has(key2)) return false;
|
|
3708
|
+
seen.add(key2);
|
|
3709
|
+
return true;
|
|
3710
|
+
});
|
|
3711
|
+
};
|
|
3712
|
+
const access = (symbol, openOwner) => symbol.accessLevel === "open" && openOwner ? "open" : "public";
|
|
3713
|
+
const emitMember = scoped((member, indent, context) => {
|
|
3714
|
+
const path15 = pathOf(member);
|
|
3715
|
+
if (TYPE_KINDS.has(member.kind.identifier)) {
|
|
3716
|
+
emitType(member, indent);
|
|
3717
|
+
return;
|
|
3718
|
+
}
|
|
3719
|
+
if (member.kind.identifier === "swift.enum.case") return;
|
|
3720
|
+
if (!MEMBER_KINDS.has(member.kind.identifier)) {
|
|
3721
|
+
skipped.push({ path: path15, reason: `unhandled ${member.kind.identifier}` });
|
|
3722
|
+
return;
|
|
3723
|
+
}
|
|
3724
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
3725
|
+
const modifiers = /^((?:(?:required|final|override|convenience|unowned(?:\(\w+\))?|weak|lazy|nonisolated|mutating|nonmutating) )*)(.*)$/s.exec(rest);
|
|
3726
|
+
const flags = new Set(modifiers[1].trim().split(/\s+/).filter(Boolean).map((flag) => flag.replace(/\(.*/, "")));
|
|
3727
|
+
const required = context.inClass && flags.has("required");
|
|
3728
|
+
const final = context.inClass && flags.has("final") ? "final " : "";
|
|
3729
|
+
const mutating = flags.has("mutating") ? "mutating " : flags.has("nonmutating") ? "nonmutating " : "";
|
|
3730
|
+
let core = `${context.inClass && flags.has("convenience") ? "convenience " : ""}${modifiers[2]}`;
|
|
3731
|
+
const override = context.inClass && !options.plain?.has(path15) && (flags.has("override") || overrides.has(member.identifier.precise) || isObjC(member) && path15.endsWith(".init()")) ? "override " : "";
|
|
3732
|
+
const head = `${indent}${attrs}${access(member, context.openOwner)} ${required ? "required " : ""}${final}${override}${mutating}`;
|
|
3733
|
+
const measured = behavior.get(path15);
|
|
3734
|
+
if (measured) used.add(path15);
|
|
3735
|
+
const body = measured?.body ?? trap(path15);
|
|
3736
|
+
switch (member.kind.identifier) {
|
|
3737
|
+
case "swift.property":
|
|
3738
|
+
case "swift.type.property":
|
|
3739
|
+
case "swift.subscript":
|
|
3740
|
+
case "swift.type.subscript": {
|
|
3741
|
+
const accessors = ACCESSORS.exec(core);
|
|
3742
|
+
const decl = core.replace(ACCESSORS, "").trimEnd();
|
|
3743
|
+
const effects = `${accessors?.[1] ?? ""}${accessors?.[2] ?? ""}`;
|
|
3744
|
+
const settable = accessors ? Boolean(accessors[3]) : /^(?:static |class )?var /.test(core);
|
|
3745
|
+
const computed = decl.replace(/^((?:static |class )*)let /, "$1var ");
|
|
3746
|
+
if (measured?.stored !== void 0) {
|
|
3747
|
+
const ownership = flags.has("weak") ? "weak " : flags.has("unowned") ? "unowned " : "";
|
|
3748
|
+
const setter = settable ? "" : "internal(set) ";
|
|
3749
|
+
const value = measured.stored ? ` = ${measured.stored}` : "";
|
|
3750
|
+
emit(`${indent}${attrs}${access(member, context.openOwner)} ${setter}${final}${override}${ownership}${computed}${value}`);
|
|
3751
|
+
return;
|
|
3752
|
+
}
|
|
3753
|
+
emit(`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` set { ${measured?.set ?? trap(path15)} }` : ""} }`);
|
|
3754
|
+
return;
|
|
3755
|
+
}
|
|
3756
|
+
default:
|
|
3757
|
+
emit(`${head}${core} { ${body} }`);
|
|
3758
|
+
}
|
|
3759
|
+
});
|
|
3760
|
+
const header = (symbol, keyword, indent) => {
|
|
3761
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
3762
|
+
const shape = new RegExp(`^(?:final )?${keyword}\\s+\`?(\\w+)\`?(<[^>]*>)?\\s*(?::\\s*([^{]*?))?(\\s+where\\s+.*)?$`).exec(rest);
|
|
3763
|
+
if (!shape) return null;
|
|
3764
|
+
return { attrs, name: shape[1], generics: shape[2] ?? "", where: shape[4] ?? "", indent };
|
|
3765
|
+
};
|
|
3766
|
+
const externalRoot = (id) => {
|
|
3767
|
+
for (let at = id; at; at = superId.get(at)) {
|
|
3768
|
+
const next = superId.get(at);
|
|
3769
|
+
if (next && !byId.has(next)) return superclass.get(at) ?? null;
|
|
3770
|
+
}
|
|
3771
|
+
return null;
|
|
3772
|
+
};
|
|
3773
|
+
const classBlocked = (id) => {
|
|
3774
|
+
const parent = superId.get(id);
|
|
3775
|
+
const parentSymbol = parent ? byId.get(parent) : void 0;
|
|
3776
|
+
if (!parentSymbol) return null;
|
|
3777
|
+
if (/^(?:final )?class\s+\w+</.test(LEADING_ATTRS.exec(text(parentSymbol))[2]))
|
|
3778
|
+
return `superclass ${pathOf(parentSymbol)} is generic and the graph omits its arguments`;
|
|
3779
|
+
if (unavailable(parentSymbol)) return `superclass ${pathOf(parentSymbol)} is unavailable`;
|
|
3780
|
+
return classBlocked(parent) && `superclass ${pathOf(parentSymbol)} is left out`;
|
|
3781
|
+
};
|
|
3782
|
+
const inheritance = (id, first) => {
|
|
3783
|
+
const list2 = [...first ? [first] : [], ...conforms.get(id) ?? []];
|
|
3784
|
+
return [...new Set(list2)];
|
|
3785
|
+
};
|
|
3786
|
+
const emitType = scoped((symbol, indent) => {
|
|
3787
|
+
const path15 = pathOf(symbol);
|
|
3788
|
+
const id = symbol.identifier.precise;
|
|
3789
|
+
const inner = `${indent} `;
|
|
3790
|
+
switch (symbol.kind.identifier) {
|
|
3791
|
+
case "swift.typealias": {
|
|
3792
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
3793
|
+
emit(`${indent}${attrs}public ${rest}`);
|
|
3794
|
+
return;
|
|
3795
|
+
}
|
|
3796
|
+
case "swift.class": {
|
|
3797
|
+
const shape = header(symbol, "class", indent);
|
|
3798
|
+
if (!shape) return void skipped.push({ path: path15, reason: `unparsed class ${text(symbol)}` });
|
|
3799
|
+
const parent = superclass.get(id);
|
|
3800
|
+
const blocked = classBlocked(id);
|
|
3801
|
+
if (blocked) return void skipped.push({ path: path15, reason: blocked });
|
|
3802
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
3803
|
+
for (let at = superId.get(id); at; at = superId.get(at))
|
|
3804
|
+
for (const name of conforms.get(at) ?? []) ancestors.add(name);
|
|
3805
|
+
const list2 = [
|
|
3806
|
+
...parent ? [parent] : [],
|
|
3807
|
+
...(conforms.get(id) ?? []).filter(
|
|
3808
|
+
(name) => !ancestors.has(name) && !(parent && [...KEEP_EXTERNAL.values()].includes(name))
|
|
3809
|
+
)
|
|
3810
|
+
].filter((name, at, all2) => all2.indexOf(name) === at);
|
|
3811
|
+
const parentSymbol = superId.has(id) ? byId.get(superId.get(id)) : void 0;
|
|
3812
|
+
const open = symbol.accessLevel === "open" && (!parentSymbol || parentSymbol.accessLevel === "open");
|
|
3813
|
+
emit(`${indent}${shape.attrs}${open ? "open" : "public"} class ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`);
|
|
3814
|
+
const members = membersOf(id);
|
|
3815
|
+
for (const member of members)
|
|
3816
|
+
emitMember(member, inner, { openOwner: open, inClass: true, ownerName: shape.name });
|
|
3817
|
+
const designated = members.some(
|
|
3818
|
+
(member) => member.kind.identifier === "swift.init" && !text(member).startsWith("convenience")
|
|
3819
|
+
);
|
|
3820
|
+
const have = /* @__PURE__ */ new Set();
|
|
3821
|
+
for (let at = id; at; at = superId.get(at))
|
|
3822
|
+
for (const member of children.get(at) ?? []) have.add(witnessKey(member));
|
|
3823
|
+
const protocols = [];
|
|
3824
|
+
const visit = (protocolId) => {
|
|
3825
|
+
if (protocols.includes(protocolId)) return;
|
|
3826
|
+
protocols.push(protocolId);
|
|
3827
|
+
for (const edge of protocolParents.get(protocolId) ?? []) visit(edge);
|
|
3828
|
+
};
|
|
3829
|
+
for (const protocolId of conformIds.get(id) ?? []) visit(protocolId);
|
|
3830
|
+
for (const protocolId of protocols)
|
|
3831
|
+
for (const member of children.get(protocolId) ?? []) {
|
|
3832
|
+
if (!requirement.has(member.identifier.precise) || optional.has(member.identifier.precise)) continue;
|
|
3833
|
+
if (isObjC(member) && / async\b/.test(text(member))) continue;
|
|
3834
|
+
if (have.has(witnessKey(member)) || member.kind.identifier === "swift.associatedtype") continue;
|
|
3835
|
+
have.add(witnessKey(member));
|
|
3836
|
+
emitWitness(member, inner, path15);
|
|
3837
|
+
}
|
|
3838
|
+
const coder = members.some((member) => leaf(member) === "init(coder:)");
|
|
3839
|
+
if (designated && !coder && externalRoot(id) !== "NSObject" && externalRoot(id) !== null)
|
|
3840
|
+
emit(`${inner}public required init?(coder: NSCoder) { ${trap(`${path15}.init(coder:)`)} }`);
|
|
3841
|
+
emit(`${indent}}`);
|
|
3842
|
+
return;
|
|
3843
|
+
}
|
|
3844
|
+
case "swift.struct": {
|
|
3845
|
+
const shape = header(symbol, "struct", indent);
|
|
3846
|
+
if (!shape) return void skipped.push({ path: path15, reason: `unparsed struct ${text(symbol)}` });
|
|
3847
|
+
const members = membersOf(id);
|
|
3848
|
+
const raw2 = rawType(members);
|
|
3849
|
+
const list2 = inheritance(id);
|
|
3850
|
+
emit(`${indent}${shape.attrs}public struct ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`);
|
|
3851
|
+
if (raw2) {
|
|
3852
|
+
emit(`${inner}public let rawValue: ${raw2}`);
|
|
3853
|
+
emit(`${inner}public init(rawValue: ${raw2}) { self.rawValue = rawValue }`);
|
|
3854
|
+
}
|
|
3855
|
+
for (const member of members) {
|
|
3856
|
+
if (raw2 && (leaf(member) === "rawValue" || leaf(member) === "init(rawValue:)" || leaf(member) === "init(_:)"))
|
|
3857
|
+
continue;
|
|
3858
|
+
const value = values.get(member.identifier.precise);
|
|
3859
|
+
if (value !== void 0 && member.kind.identifier === "swift.type.property") {
|
|
3860
|
+
emit(`${inner}public static let ${tick(leaf(member))} = ${shape.name}(rawValue: ${value})`);
|
|
3861
|
+
continue;
|
|
3862
|
+
}
|
|
3863
|
+
emitMember(member, inner, { openOwner: false, inClass: false, ownerName: shape.name });
|
|
3864
|
+
}
|
|
3865
|
+
emit(`${indent}}`);
|
|
3866
|
+
return;
|
|
3867
|
+
}
|
|
3868
|
+
case "swift.enum": {
|
|
3869
|
+
const shape = header(symbol, "enum", indent);
|
|
3870
|
+
if (!shape) return void skipped.push({ path: path15, reason: `unparsed enum ${text(symbol)}` });
|
|
3871
|
+
const members = membersOf(id);
|
|
3872
|
+
const raw2 = rawType(members);
|
|
3873
|
+
const cases = (children.get(id) ?? []).filter((member) => member.kind.identifier === "swift.enum.case");
|
|
3874
|
+
const missing = raw2 ? cases.filter((member) => !values.has(member.identifier.precise)) : [];
|
|
3875
|
+
if (raw2 && isObjC(symbol) && missing.length > 0)
|
|
3876
|
+
return void skipped.push({ path: path15, reason: `no header value for ${missing.map(leaf).join(", ")}` });
|
|
3877
|
+
const list2 = inheritance(id, raw2 ?? void 0).filter((name) => name !== "RawRepresentable");
|
|
3878
|
+
emit(`${indent}${shape.attrs}public enum ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`);
|
|
3879
|
+
const seenValues = /* @__PURE__ */ new Map();
|
|
3880
|
+
for (const member of cases) {
|
|
3881
|
+
const value = values.get(member.identifier.precise);
|
|
3882
|
+
if (value !== void 0 && seenValues.has(value)) {
|
|
3883
|
+
emit(`${inner}public static var ${tick(leaf(member))}: ${shape.name} { .${seenValues.get(value)} }`);
|
|
3884
|
+
continue;
|
|
3885
|
+
}
|
|
3886
|
+
if (value !== void 0) seenValues.set(value, tick(leaf(member)));
|
|
3887
|
+
const caseText = text(member).replace(/^case\s+/, "");
|
|
3888
|
+
emit(`${inner}case ${caseText}${value !== void 0 ? ` = ${value}` : ""}`);
|
|
3889
|
+
}
|
|
3890
|
+
for (const member of members) {
|
|
3891
|
+
if (member.kind.identifier === "swift.enum.case") continue;
|
|
3892
|
+
if (raw2 && (leaf(member) === "rawValue" || leaf(member) === "init(rawValue:)")) continue;
|
|
3893
|
+
emitMember(member, inner, { openOwner: false, inClass: false, ownerName: shape.name });
|
|
3894
|
+
}
|
|
3895
|
+
emit(`${indent}}`);
|
|
3896
|
+
return;
|
|
3897
|
+
}
|
|
3898
|
+
case "swift.protocol": {
|
|
3899
|
+
const shape = header(symbol, "protocol", indent);
|
|
3900
|
+
if (!shape) return void skipped.push({ path: path15, reason: `unparsed protocol ${text(symbol)}` });
|
|
3901
|
+
const list2 = [...isObjC(symbol) ? ["AnyObject"] : [], ...inheritance(id)];
|
|
3902
|
+
emit(`${indent}${shape.attrs}public protocol ${shape.name}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`);
|
|
3903
|
+
const members = membersOf(id);
|
|
3904
|
+
const defaults = [];
|
|
3905
|
+
for (const member of members) {
|
|
3906
|
+
if (member.kind.identifier === "swift.associatedtype") {
|
|
3907
|
+
emit(`${inner}${text(member)}`);
|
|
3908
|
+
continue;
|
|
3909
|
+
}
|
|
3910
|
+
const asyncTwin = isObjC(member) && / async\b/.test(text(member));
|
|
3911
|
+
if (!requirement.has(member.identifier.precise) || asyncTwin) {
|
|
3912
|
+
defaults.push(member);
|
|
3913
|
+
continue;
|
|
3914
|
+
}
|
|
3915
|
+
emitRequirement(member, inner);
|
|
3916
|
+
if (optional.has(member.identifier.precise)) defaults.push(member);
|
|
3917
|
+
}
|
|
3918
|
+
emit(`${indent}}`);
|
|
3919
|
+
if (defaults.length > 0) {
|
|
3920
|
+
emit(`${indent}extension ${path15} {`);
|
|
3921
|
+
for (const member of defaults) {
|
|
3922
|
+
const decl = text(member);
|
|
3923
|
+
if (optional.has(member.identifier.precise) && member.kind.identifier === "swift.method" && !/->/.test(decl.replace(/\([^)]*\)/g, "")) && !/ async\b/.test(decl))
|
|
3924
|
+
emitNoop(member, inner);
|
|
3925
|
+
else emitMember(member, inner, { openOwner: false, inClass: false, ownerName: shape.name });
|
|
3926
|
+
}
|
|
3927
|
+
emit(`${indent}}`);
|
|
3928
|
+
}
|
|
3929
|
+
return;
|
|
3930
|
+
}
|
|
3931
|
+
}
|
|
3932
|
+
});
|
|
3933
|
+
const emitWitness = (member, indent, owner2) => {
|
|
3934
|
+
const { 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
3935
|
+
const decl = rest.replace(/^(?:weak |unowned )/, "").replace(/^((?:static )?)let /, "$1var ");
|
|
3936
|
+
const witness = `${owner2}.${leaf(member)}`;
|
|
3937
|
+
const body = trap(witness);
|
|
3938
|
+
if (member.kind.identifier === "swift.property" || member.kind.identifier === "swift.type.property") {
|
|
3939
|
+
const accessors = ACCESSORS.exec(decl);
|
|
3940
|
+
const bare = decl.replace(ACCESSORS, "").trimEnd();
|
|
3941
|
+
emit(`${indent}public ${bare} { get { ${body} }${accessors?.[3] ? ` set { ${body} }` : ""} }`);
|
|
3942
|
+
} else emit(`${indent}public ${member.kind.identifier === "swift.init" ? "required " : ""}${stripDefaults(decl)} { ${body} }`);
|
|
3943
|
+
};
|
|
3944
|
+
const emitNoop = scoped((member, indent) => {
|
|
3945
|
+
emit(`${indent}public ${stripDefaults(text(member))} {}`);
|
|
3946
|
+
});
|
|
3947
|
+
const emitRequirement = scoped((member, indent) => {
|
|
3948
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
3949
|
+
emit(`${indent}${attrs}${stripDefaults(rest.replace(/^(?:weak |unowned )/, "").replace(/^((?:static )?)let /, "$1var "))}`);
|
|
3950
|
+
});
|
|
3951
|
+
const rawType = (members) => {
|
|
3952
|
+
const init = members.find((member) => leaf(member) === "init(rawValue:)");
|
|
3953
|
+
return init ? /rawValue:\s*([^)]+)\)/.exec(text(init))?.[1]?.trim() ?? null : null;
|
|
3954
|
+
};
|
|
3955
|
+
const emitGlobal = scoped((symbol) => {
|
|
3956
|
+
const path15 = pathOf(symbol);
|
|
3957
|
+
if (symbol.kind.identifier === "swift.func" || symbol.kind.identifier === "swift.func.op") {
|
|
3958
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
3959
|
+
emit(`${attrs}public ${rest} { ${trap(path15)} }`);
|
|
3960
|
+
} else if (symbol.kind.identifier === "swift.var") {
|
|
3961
|
+
const decl = text(symbol).replace(/^let /, "var ").replace(ACCESSORS, "").trimEnd();
|
|
3962
|
+
emit(`public ${decl} { ${trap(path15)} }`);
|
|
3963
|
+
} else skipped.push({ path: path15, reason: `unhandled top-level ${symbol.kind.identifier}` });
|
|
3964
|
+
});
|
|
3965
|
+
const roots = [...byId.values()].filter((symbol) => !owner.has(symbol.identifier.precise) && !unavailable(symbol)).sort((a, b) => pathOf(a).localeCompare(pathOf(b)));
|
|
3966
|
+
for (const symbol of roots) {
|
|
3967
|
+
const path15 = pathOf(symbol);
|
|
3968
|
+
if (TYPE_KINDS.has(symbol.kind.identifier)) emitType(symbol, "");
|
|
3969
|
+
else emitGlobal(symbol);
|
|
3970
|
+
}
|
|
3971
|
+
for (const [name, members] of [...external].sort(([a], [b]) => a.localeCompare(b))) {
|
|
3972
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3973
|
+
const kept = members.filter((member) => {
|
|
3974
|
+
const key2 = `${member.kind.identifier}|${text(member)}`;
|
|
3975
|
+
if (unavailable(member) || seen.has(key2)) return false;
|
|
3976
|
+
seen.add(key2);
|
|
3977
|
+
return true;
|
|
3978
|
+
});
|
|
3979
|
+
if (kept.length === 0) continue;
|
|
3980
|
+
emit(`extension ${name} {`);
|
|
3981
|
+
for (const member of kept)
|
|
3982
|
+
if (member.kind.identifier === "swift.init" && !text(member).startsWith("convenience"))
|
|
3983
|
+
emitMember({ ...member, declarationFragments: [{ kind: "text", spelling: `convenience ${text(member)}` }] }, " ", {
|
|
3984
|
+
openOwner: false,
|
|
3985
|
+
inClass: true,
|
|
3986
|
+
ownerName: name
|
|
3987
|
+
});
|
|
3988
|
+
else emitMember(member, " ", { openOwner: false, inClass: false, ownerName: name });
|
|
3989
|
+
emit(`}`);
|
|
3990
|
+
}
|
|
3991
|
+
const imports = ["Foundation", "UIKit", ...options.imports ?? []];
|
|
3992
|
+
const banner = [
|
|
3993
|
+
`// stand-in for the binary ${options.module} module, generated from ${options.source}.`,
|
|
3994
|
+
`// do not hand-edit: every body traps because the vendor binary cannot run`,
|
|
3995
|
+
`// in peach; behavior a hand file measures lives beside this file.`,
|
|
3996
|
+
"",
|
|
3997
|
+
...imports.map((name) => `import ${name}`),
|
|
3998
|
+
""
|
|
3999
|
+
];
|
|
4000
|
+
for (const path15 of behavior.keys())
|
|
4001
|
+
if (!used.has(path15)) skipped.push({ path: path15, reason: "behavior names no emitted declaration" });
|
|
4002
|
+
return {
|
|
4003
|
+
source: `${[...banner, ...lines].join("\n")}
|
|
4004
|
+
`,
|
|
4005
|
+
skipped,
|
|
4006
|
+
owners: [...banner.map(() => ""), ...owners]
|
|
4007
|
+
};
|
|
4008
|
+
}
|
|
4009
|
+
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"]);
|
|
4010
|
+
var tick = (name) => KEYWORDS.has(name) ? `\`${name}\`` : name;
|
|
4011
|
+
function stripDefaults(decl) {
|
|
4012
|
+
let out = "";
|
|
4013
|
+
let depth = 0;
|
|
4014
|
+
for (let at = 0; at < decl.length; at++) {
|
|
4015
|
+
const char = decl[at];
|
|
4016
|
+
if (char === "(" || char === "[" || char === "<") depth++;
|
|
4017
|
+
if (char === ")" || char === "]" || char === ">" && decl[at - 1] !== "-") depth--;
|
|
4018
|
+
if (char === "=" && depth === 1 && decl[at - 1] === " ") {
|
|
4019
|
+
let skip = at + 1;
|
|
4020
|
+
let inner = 0;
|
|
4021
|
+
while (skip < decl.length) {
|
|
4022
|
+
const next = decl[skip];
|
|
4023
|
+
if (next === "(" || next === "[") inner++;
|
|
4024
|
+
if (next === ")" || next === "]") {
|
|
4025
|
+
if (inner === 0) break;
|
|
4026
|
+
inner--;
|
|
4027
|
+
}
|
|
4028
|
+
if (next === "," && inner === 0) break;
|
|
4029
|
+
skip++;
|
|
4030
|
+
}
|
|
4031
|
+
out = out.trimEnd();
|
|
4032
|
+
at = skip - 1;
|
|
4033
|
+
continue;
|
|
4034
|
+
}
|
|
4035
|
+
out += char;
|
|
4036
|
+
}
|
|
4037
|
+
return out;
|
|
4038
|
+
}
|
|
4039
|
+
|
|
4040
|
+
// src/swift-standins.ts
|
|
4041
|
+
var TRIPLE = "wasm32-unknown-wasip1";
|
|
4042
|
+
var cacheDir3 = import_node_path11.default.join(import_node_os7.default.tmpdir(), "peach-swift-standins");
|
|
4043
|
+
function exec(file, args, cwd) {
|
|
4044
|
+
return (0, import_node_child_process7.execFileSync)(file, args, {
|
|
4045
|
+
cwd,
|
|
4046
|
+
encoding: "utf8",
|
|
4047
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
4048
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
4049
|
+
});
|
|
4050
|
+
}
|
|
4051
|
+
function failure(error) {
|
|
4052
|
+
const output = error && typeof error === "object" && "stderr" in error ? `${String(error.stderr)}
|
|
4053
|
+
${"stdout" in error ? String(error.stdout) : ""}` : String(error);
|
|
4054
|
+
const errors = output.split("\n").filter((line) => /\berror:/.test(line)).map((line) => line.replace(/^.*?error:\s*/, "").trim());
|
|
4055
|
+
return [...new Set(errors)].slice(0, 3).join("; ") || output.trim().slice(0, 400);
|
|
4056
|
+
}
|
|
4057
|
+
var key = (...parts) => (0, import_node_crypto6.createHash)("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
4058
|
+
function xcframework(binary) {
|
|
4059
|
+
if (!binary.url && !binary.dir.endsWith(".zip")) return binary.dir;
|
|
4060
|
+
const dir = import_node_path11.default.join(cacheDir3, "archives", key(binary.url ?? binary.dir));
|
|
4061
|
+
if (!import_node_fs10.default.existsSync(import_node_path11.default.join(dir, ".complete"))) {
|
|
4062
|
+
import_node_fs10.default.rmSync(dir, { recursive: true, force: true });
|
|
4063
|
+
import_node_fs10.default.mkdirSync(dir, { recursive: true });
|
|
4064
|
+
const archive = import_node_path11.default.join(dir, "archive.zip");
|
|
4065
|
+
if (binary.url) exec("curl", ["-fsSL", "--retry", "2", "-o", archive, binary.url]);
|
|
4066
|
+
else import_node_fs10.default.copyFileSync(binary.dir, archive);
|
|
4067
|
+
exec("unzip", ["-q", archive, "-d", import_node_path11.default.join(dir, "tree")]);
|
|
4068
|
+
import_node_fs10.default.rmSync(archive);
|
|
4069
|
+
import_node_fs10.default.writeFileSync(import_node_path11.default.join(dir, ".complete"), "");
|
|
4070
|
+
}
|
|
4071
|
+
const find = (root, depth) => {
|
|
4072
|
+
for (const entry of import_node_fs10.default.readdirSync(root, { withFileTypes: true })) {
|
|
4073
|
+
if (!entry.isDirectory() || entry.name === "__MACOSX") continue;
|
|
4074
|
+
const full = import_node_path11.default.join(root, entry.name);
|
|
4075
|
+
if (entry.name.endsWith(".xcframework")) return full;
|
|
4076
|
+
const nested = depth > 0 ? find(full, depth - 1) : null;
|
|
4077
|
+
if (nested) return nested;
|
|
4078
|
+
}
|
|
4079
|
+
return null;
|
|
4080
|
+
};
|
|
4081
|
+
const found = find(import_node_path11.default.join(dir, "tree"), 2);
|
|
4082
|
+
if (!found) throw new Error("its archive holds no .xcframework");
|
|
4083
|
+
return found;
|
|
4084
|
+
}
|
|
4085
|
+
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() : [];
|
|
4086
|
+
function surfaces(xcframeworkDir) {
|
|
4087
|
+
const slice = import_node_fs10.default.readdirSync(xcframeworkDir).filter((name) => /^ios-.+-simulator$/.test(name)).sort()[0];
|
|
4088
|
+
if (!slice) throw new Error("it has no iOS simulator slice");
|
|
4089
|
+
const root = import_node_path11.default.join(xcframeworkDir, slice);
|
|
4090
|
+
const found = [];
|
|
4091
|
+
for (const entry of import_node_fs10.default.readdirSync(root).sort()) {
|
|
4092
|
+
if (!entry.endsWith(".framework")) continue;
|
|
4093
|
+
const module2 = entry.slice(0, -".framework".length);
|
|
4094
|
+
const framework = import_node_path11.default.join(root, entry);
|
|
4095
|
+
const swiftmodule = import_node_path11.default.join(framework, "Modules", `${module2}.swiftmodule`);
|
|
4096
|
+
const interfaces = files(
|
|
4097
|
+
swiftmodule,
|
|
4098
|
+
(name) => name.endsWith(".swiftinterface") && !name.endsWith(".private.swiftinterface") && !name.endsWith(".package.swiftinterface")
|
|
4099
|
+
);
|
|
4100
|
+
const chosen = interfaces.find((name) => name.startsWith("arm64-")) ?? interfaces[0] ?? null;
|
|
4101
|
+
if (chosen) {
|
|
4102
|
+
found.push({
|
|
4103
|
+
kind: "swift",
|
|
4104
|
+
module: module2,
|
|
4105
|
+
interface: import_node_path11.default.join(swiftmodule, chosen)
|
|
4106
|
+
});
|
|
4107
|
+
continue;
|
|
4108
|
+
}
|
|
4109
|
+
const modulemap = import_node_path11.default.join(framework, "Modules", "module.modulemap");
|
|
4110
|
+
if (import_node_fs10.default.existsSync(modulemap))
|
|
4111
|
+
found.push({
|
|
4112
|
+
kind: "c",
|
|
4113
|
+
module: module2,
|
|
4114
|
+
modulemap,
|
|
4115
|
+
headers: import_node_path11.default.join(framework, "Headers")
|
|
4116
|
+
});
|
|
4117
|
+
}
|
|
4118
|
+
const headers = import_node_path11.default.join(root, "Headers");
|
|
4119
|
+
for (const map of files(headers, (name) => name === "module.modulemap")) {
|
|
4120
|
+
const modulemap = import_node_path11.default.join(headers, map);
|
|
4121
|
+
const module2 = /(?:^|\s)module\s+(\w+)/.exec(import_node_fs10.default.readFileSync(modulemap, "utf8"))?.[1];
|
|
4122
|
+
if (module2) found.push({ kind: "c", module: module2, modulemap, headers });
|
|
4123
|
+
}
|
|
4124
|
+
return found;
|
|
4125
|
+
}
|
|
4126
|
+
function peachModuleDirs(toolchain, imports) {
|
|
4127
|
+
const { moduleRoot, toolchainBin } = toolchain;
|
|
4128
|
+
if (swiftDistributionAt(moduleRoot)) return [import_node_path11.default.join(moduleRoot, "modules")];
|
|
4129
|
+
const peach = new Set(swiftPeachModules(moduleRoot));
|
|
4130
|
+
const plugins = swiftMacroPlugins(moduleRoot);
|
|
4131
|
+
if (plugins.stale)
|
|
4132
|
+
exec("sh", [
|
|
4133
|
+
import_node_path11.default.join(moduleRoot, "scripts/build-preview-plugin.sh"),
|
|
4134
|
+
toolchainBin,
|
|
4135
|
+
plugins.libraries[0]
|
|
4136
|
+
]);
|
|
4137
|
+
for (const target of imports.filter((name) => peach.has(name)))
|
|
4138
|
+
exec(
|
|
4139
|
+
import_node_path11.default.join(toolchainBin, "swift"),
|
|
4140
|
+
[
|
|
4141
|
+
"build",
|
|
4142
|
+
"--swift-sdk",
|
|
4143
|
+
swiftModuleSdk(moduleRoot).wasmSdkId,
|
|
4144
|
+
"-c",
|
|
4145
|
+
"release",
|
|
4146
|
+
"--target",
|
|
4147
|
+
target,
|
|
4148
|
+
"-Xswiftc",
|
|
4149
|
+
"-Osize",
|
|
4150
|
+
...plugins.libraries.flatMap((library) => [
|
|
4151
|
+
"-Xswiftc",
|
|
4152
|
+
"-load-plugin-library",
|
|
4153
|
+
"-Xswiftc",
|
|
4154
|
+
library
|
|
4155
|
+
])
|
|
4156
|
+
],
|
|
4157
|
+
moduleRoot
|
|
4158
|
+
);
|
|
4159
|
+
return [import_node_path11.default.join(moduleRoot, ".build", TRIPLE, "release", "Modules")];
|
|
4160
|
+
}
|
|
4161
|
+
function swiftInterfaceForWasm(text3) {
|
|
4162
|
+
return text3.replace(
|
|
4163
|
+
/^(\/\/ swift-module-flags:.*)$/m,
|
|
4164
|
+
(flags) => flags.replace(/-target \S+/, `-target ${TRIPLE}`).replace(/\s-enable-objc-interop\b/, "").replace(/\s-target-variant \S+/, "")
|
|
4165
|
+
).replace(
|
|
4166
|
+
/@(?:objc(?:\s*\([^()]*\))?|objcMembers|nonobjc|IBOutlet|IBAction|IBInspectable|IBDesignable|_objcRuntimeName\([^()]*\))(?![\w(])/g,
|
|
4167
|
+
""
|
|
4168
|
+
);
|
|
4169
|
+
}
|
|
4170
|
+
function swiftStandin(surface, binary, toolchain, work) {
|
|
4171
|
+
const text3 = swiftInterfaceForWasm(import_node_fs10.default.readFileSync(surface.interface, "utf8"));
|
|
4172
|
+
const search = import_node_path11.default.join(work, "interfaces");
|
|
4173
|
+
const moduleDir = import_node_path11.default.join(search, `${surface.module}.swiftmodule`);
|
|
4174
|
+
import_node_fs10.default.mkdirSync(moduleDir, { recursive: true });
|
|
4175
|
+
import_node_fs10.default.writeFileSync(import_node_path11.default.join(moduleDir, `${TRIPLE}.swiftinterface`), text3);
|
|
4176
|
+
const imports = [
|
|
4177
|
+
...text3.matchAll(
|
|
4178
|
+
/^(?:@_exported[ \t]+)?import[ \t]+(?:(?:struct|class|enum|protocol|typealias|func|var|let)[ \t]+)?(\w+)/gm
|
|
4179
|
+
)
|
|
4180
|
+
].map((match) => match[1]);
|
|
4181
|
+
const { sysroot, resources } = swiftSdkPaths(
|
|
4182
|
+
toolchain.moduleRoot,
|
|
4183
|
+
toolchain.toolchainBin
|
|
4184
|
+
);
|
|
4185
|
+
const target = ["-target", TRIPLE, "-sdk", sysroot, "-resource-dir", resources];
|
|
4186
|
+
const peach = peachModuleDirs(toolchain, imports).flatMap((dir) => ["-I", dir]);
|
|
4187
|
+
const out = import_node_path11.default.join(work, "graphs");
|
|
4188
|
+
import_node_fs10.default.mkdirSync(out, { recursive: true });
|
|
4189
|
+
exec(import_node_path11.default.join(toolchain.toolchainBin, "swift-symbolgraph-extract"), [
|
|
4190
|
+
"-module-name",
|
|
4191
|
+
surface.module,
|
|
4192
|
+
...target,
|
|
4193
|
+
"-I",
|
|
4194
|
+
search,
|
|
4195
|
+
...peach,
|
|
4196
|
+
"-minimum-access-level",
|
|
4197
|
+
"public",
|
|
4198
|
+
"-skip-synthesized-members",
|
|
4199
|
+
"-omit-extension-block-symbols",
|
|
4200
|
+
"-output-dir",
|
|
4201
|
+
out
|
|
4202
|
+
]);
|
|
4203
|
+
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")));
|
|
4204
|
+
const omit = /* @__PURE__ */ new Map();
|
|
4205
|
+
const plain = /* @__PURE__ */ new Set();
|
|
4206
|
+
const file = import_node_path11.default.join(work, `${surface.module}.swift`);
|
|
4207
|
+
for (; ; ) {
|
|
4208
|
+
const { source, owners } = emitSwiftStandin(graphs, {
|
|
4209
|
+
module: surface.module,
|
|
4210
|
+
source: `${binary.target} (${binary.source})`,
|
|
4211
|
+
omit,
|
|
4212
|
+
plain
|
|
4213
|
+
});
|
|
4214
|
+
import_node_fs10.default.writeFileSync(file, source);
|
|
4215
|
+
const check = (0, import_node_child_process7.spawnSync)(
|
|
4216
|
+
import_node_path11.default.join(toolchain.toolchainBin, "swiftc"),
|
|
4217
|
+
[
|
|
4218
|
+
"-typecheck",
|
|
4219
|
+
"-parse-as-library",
|
|
4220
|
+
"-swift-version",
|
|
4221
|
+
"5",
|
|
4222
|
+
"-module-name",
|
|
4223
|
+
surface.module,
|
|
4224
|
+
...target,
|
|
4225
|
+
...peach,
|
|
4226
|
+
file
|
|
4227
|
+
],
|
|
4228
|
+
{ encoding: "utf8", maxBuffer: 256 * 1024 * 1024 }
|
|
4229
|
+
);
|
|
4230
|
+
if (check.status === 0)
|
|
4231
|
+
return {
|
|
4232
|
+
module: surface.module,
|
|
4233
|
+
target: binary.target,
|
|
4234
|
+
files: { [`${surface.module}.swift`]: source }
|
|
4235
|
+
};
|
|
4236
|
+
const before = omit.size + plain.size;
|
|
4237
|
+
const elsewhere = [];
|
|
4238
|
+
for (const match of check.stderr.matchAll(/^(\S+?):(\d+):\d+: error: (.*)$/gm)) {
|
|
4239
|
+
const owner = match[1] === file ? owners[Number(match[2]) - 1] : void 0;
|
|
4240
|
+
if (owner && /does not override any|overrides nothing/.test(match[3]))
|
|
4241
|
+
plain.add(owner);
|
|
4242
|
+
else if (owner) omit.set(owner, `rejected by swiftc: ${match[3]}`);
|
|
4243
|
+
else elsewhere.push(match[3]);
|
|
4244
|
+
}
|
|
4245
|
+
if (omit.size + plain.size === before)
|
|
4246
|
+
throw new Error(
|
|
4247
|
+
`its generated source does not typecheck: ${elsewhere.slice(0, 3).join("; ") || check.stderr.trim().slice(0, 400)}`
|
|
4248
|
+
);
|
|
4249
|
+
}
|
|
4250
|
+
}
|
|
4251
|
+
var OBJC = /^\s*(?:@interface|@protocol|@class|@import|#import)\b/m;
|
|
4252
|
+
function functionDeclarations(ast, headers) {
|
|
4253
|
+
const found = [];
|
|
4254
|
+
let file = "";
|
|
4255
|
+
const note = (location) => {
|
|
4256
|
+
if (!location || typeof location !== "object") return;
|
|
4257
|
+
const expansion = Reflect.get(location, "expansionLoc");
|
|
4258
|
+
const at = expansion && typeof expansion === "object" ? expansion : location;
|
|
4259
|
+
const named = Reflect.get(at, "file");
|
|
4260
|
+
if (typeof named === "string") file = named;
|
|
4261
|
+
};
|
|
4262
|
+
const walk2 = (node) => {
|
|
4263
|
+
if (Array.isArray(node)) {
|
|
4264
|
+
for (const item of node) walk2(item);
|
|
4265
|
+
return;
|
|
4266
|
+
}
|
|
4267
|
+
if (!node || typeof node !== "object") return;
|
|
4268
|
+
for (const [field, value] of Object.entries(node)) {
|
|
4269
|
+
if (field === "loc") note(value);
|
|
4270
|
+
else if (field === "range" && value && typeof value === "object") {
|
|
4271
|
+
note(Reflect.get(value, "begin"));
|
|
4272
|
+
note(Reflect.get(value, "end"));
|
|
4273
|
+
} else if (value && typeof value === "object") walk2(value);
|
|
4274
|
+
}
|
|
4275
|
+
};
|
|
4276
|
+
const top = ast && typeof ast === "object" ? Reflect.get(ast, "inner") : null;
|
|
4277
|
+
for (const decl of Array.isArray(top) ? top : []) {
|
|
4278
|
+
note(Reflect.get(decl, "loc"));
|
|
4279
|
+
const declFile = file;
|
|
4280
|
+
walk2(decl);
|
|
4281
|
+
if (Reflect.get(decl, "kind") !== "FunctionDecl" || !headers.has(declFile)) continue;
|
|
4282
|
+
if (Reflect.get(decl, "isImplicit") || Reflect.get(decl, "storageClass") === "static")
|
|
4283
|
+
continue;
|
|
4284
|
+
const inner = Reflect.get(decl, "inner");
|
|
4285
|
+
if (Array.isArray(inner) && inner.some((child) => Reflect.get(child, "kind") === "CompoundStmt"))
|
|
4286
|
+
continue;
|
|
4287
|
+
const range2 = Reflect.get(decl, "range");
|
|
4288
|
+
const offset = (end) => {
|
|
4289
|
+
const at = Reflect.get(range2, end);
|
|
4290
|
+
const expansion = Reflect.get(at, "expansionLoc");
|
|
4291
|
+
return Number(Reflect.get(expansion ?? at, "offset"));
|
|
4292
|
+
};
|
|
4293
|
+
found.push({
|
|
4294
|
+
name: String(Reflect.get(decl, "name")),
|
|
4295
|
+
file: declFile,
|
|
4296
|
+
begin: offset("begin"),
|
|
4297
|
+
end: offset("end")
|
|
4298
|
+
});
|
|
4299
|
+
}
|
|
4300
|
+
return found;
|
|
4301
|
+
}
|
|
4302
|
+
function cStandin(surface, binary, toolchain, work) {
|
|
4303
|
+
const named = [
|
|
4304
|
+
...import_node_fs10.default.readFileSync(surface.modulemap, "utf8").matchAll(/(?:umbrella\s+)?header\s+"([^"]+)"/g)
|
|
4305
|
+
].map((match) => match[1]);
|
|
4306
|
+
const headers = files(surface.headers, (name) => name.endsWith(".h"));
|
|
4307
|
+
const texts = new Map(
|
|
4308
|
+
headers.map((file) => [
|
|
4309
|
+
file,
|
|
4310
|
+
import_node_fs10.default.readFileSync(import_node_path11.default.join(surface.headers, file), "utf8")
|
|
4311
|
+
])
|
|
4312
|
+
);
|
|
4313
|
+
const objc = headers.find((file) => OBJC.test(texts.get(file)));
|
|
4314
|
+
if (objc) throw new Error(`its header ${objc} is Objective-C`);
|
|
4315
|
+
const include = import_node_path11.default.join(work, "include");
|
|
4316
|
+
for (const [file, text3] of texts) {
|
|
4317
|
+
import_node_fs10.default.mkdirSync(import_node_path11.default.dirname(import_node_path11.default.join(include, file)), { recursive: true });
|
|
4318
|
+
import_node_fs10.default.writeFileSync(import_node_path11.default.join(include, file), text3);
|
|
4319
|
+
}
|
|
4320
|
+
const roots = named.length > 0 ? named : headers;
|
|
4321
|
+
const modulemap = `module ${surface.module} {
|
|
4322
|
+
${roots.map((file) => ` header "${file}"
|
|
4323
|
+
`).join("")} export *
|
|
4324
|
+
}
|
|
4325
|
+
`;
|
|
4326
|
+
const probe = import_node_path11.default.join(work, "declarations.c");
|
|
4327
|
+
import_node_fs10.default.writeFileSync(probe, roots.map((file) => `#include "${file}"
|
|
4328
|
+
`).join(""));
|
|
4329
|
+
const { sysroot } = swiftSdkPaths(toolchain.moduleRoot, toolchain.toolchainBin);
|
|
4330
|
+
const ast = JSON.parse(
|
|
4331
|
+
exec(import_node_path11.default.join(toolchain.toolchainBin, "clang"), [
|
|
4332
|
+
"-target",
|
|
4333
|
+
TRIPLE,
|
|
4334
|
+
"--sysroot",
|
|
4335
|
+
sysroot,
|
|
4336
|
+
"-fsyntax-only",
|
|
4337
|
+
"-I",
|
|
4338
|
+
include,
|
|
4339
|
+
"-Xclang",
|
|
4340
|
+
"-ast-dump=json",
|
|
4341
|
+
probe
|
|
4342
|
+
])
|
|
4343
|
+
);
|
|
4344
|
+
const byPath = new Map(headers.map((file) => [import_node_path11.default.join(include, file), file]));
|
|
4345
|
+
const declarations = functionDeclarations(ast, new Set(byPath.keys()));
|
|
4346
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4347
|
+
const definitions = [];
|
|
4348
|
+
for (const { name, file, begin, end } of declarations) {
|
|
4349
|
+
if (seen.has(name)) continue;
|
|
4350
|
+
seen.add(name);
|
|
4351
|
+
const text3 = texts.get(byPath.get(file));
|
|
4352
|
+
const close = text3.indexOf(";", end);
|
|
4353
|
+
if (close < 0)
|
|
4354
|
+
throw new Error(`${name} has no declaration end in ${byPath.get(file)}`);
|
|
4355
|
+
definitions.push(
|
|
4356
|
+
`${text3.slice(begin, close).trim()} {
|
|
4357
|
+
peach_standin_trap("${name}");
|
|
4358
|
+
}
|
|
4359
|
+
`
|
|
4360
|
+
);
|
|
4361
|
+
}
|
|
4362
|
+
const sdk = JSON.stringify(`${binary.target} (${binary.source})`);
|
|
4363
|
+
const source = [
|
|
4364
|
+
`// generated by peach from ${surface.module}'s headers: ${binary.target} ships`,
|
|
4365
|
+
"// iOS machine code only, so every function traps naming itself.",
|
|
4366
|
+
...roots.map((file) => `#include "${file}"`),
|
|
4367
|
+
"#include <stdio.h>",
|
|
4368
|
+
"#include <stdlib.h>",
|
|
4369
|
+
"",
|
|
4370
|
+
"static _Noreturn void peach_standin_trap(const char *symbol) {",
|
|
4371
|
+
` fprintf(stderr, "Peach: %s is a vendored binary framework with no WebAssembly build; ${surface.module}.%s cannot run\\n", ${sdk}, symbol);`,
|
|
4372
|
+
" abort();",
|
|
4373
|
+
"}",
|
|
4374
|
+
"",
|
|
4375
|
+
...definitions
|
|
4376
|
+
].join("\n");
|
|
4377
|
+
return {
|
|
4378
|
+
module: surface.module,
|
|
4379
|
+
target: binary.target,
|
|
4380
|
+
files: {
|
|
4381
|
+
...Object.fromEntries(
|
|
4382
|
+
[...texts].map(([file, text3]) => [`include/${file}`, text3])
|
|
4383
|
+
),
|
|
4384
|
+
"include/module.modulemap": modulemap,
|
|
4385
|
+
[`${surface.module}.c`]: source
|
|
4386
|
+
}
|
|
4387
|
+
};
|
|
4388
|
+
}
|
|
4389
|
+
var built = /* @__PURE__ */ new Map();
|
|
4390
|
+
function binaryStandins(binary, toolchain) {
|
|
4391
|
+
let found;
|
|
4392
|
+
try {
|
|
4393
|
+
found = surfaces(xcframework(binary));
|
|
4394
|
+
} catch (error) {
|
|
4395
|
+
return error instanceof Error ? error.message : String(error);
|
|
4396
|
+
}
|
|
4397
|
+
if (found.length === 0)
|
|
4398
|
+
return "its iOS simulator slice has no Swift interface or C modulemap";
|
|
4399
|
+
const hash = (0, import_node_crypto6.createHash)("sha256").update(
|
|
4400
|
+
`standin/v1\0${toolchain.toolchainBin}\0${swiftModuleSdk(toolchain.moduleRoot).wasmSdkId}\0${toolchain.moduleRoot}\0${binary.target}\0${binary.source}\0`
|
|
4401
|
+
);
|
|
4402
|
+
for (const surface of found) {
|
|
4403
|
+
hash.update(`${surface.kind}\0${surface.module}\0`);
|
|
4404
|
+
for (const file of surface.kind === "swift" ? [surface.interface] : [
|
|
4405
|
+
surface.modulemap,
|
|
4406
|
+
...files(surface.headers, (name) => name.endsWith(".h")).map(
|
|
4407
|
+
(file2) => import_node_path11.default.join(surface.headers, file2)
|
|
4408
|
+
)
|
|
4409
|
+
])
|
|
4410
|
+
hash.update(import_node_fs10.default.readFileSync(file));
|
|
4411
|
+
}
|
|
4412
|
+
const id = hash.digest("hex").slice(0, 32);
|
|
4413
|
+
const memo2 = built.get(id);
|
|
4414
|
+
if (memo2) return memo2;
|
|
4415
|
+
const cached = import_node_path11.default.join(cacheDir3, "standins", `${id}.json`);
|
|
4416
|
+
if (import_node_fs10.default.existsSync(cached)) {
|
|
4417
|
+
const value = JSON.parse(import_node_fs10.default.readFileSync(cached, "utf8"));
|
|
4418
|
+
built.set(id, value);
|
|
4419
|
+
return value;
|
|
4420
|
+
}
|
|
4421
|
+
const work = import_node_fs10.default.mkdtempSync(import_node_path11.default.join(import_node_os7.default.tmpdir(), "peach-standin-"));
|
|
4422
|
+
let result;
|
|
4423
|
+
try {
|
|
4424
|
+
result = found.map((surface) => {
|
|
4425
|
+
const dir = import_node_path11.default.join(work, surface.module);
|
|
4426
|
+
try {
|
|
4427
|
+
return surface.kind === "swift" ? swiftStandin(surface, binary, toolchain, dir) : cStandin(surface, binary, toolchain, dir);
|
|
4428
|
+
} catch (error) {
|
|
4429
|
+
throw new Error(
|
|
4430
|
+
`no stand-in for ${surface.module}: ${error instanceof Error && !("stderr" in error) ? error.message : failure(error)}`
|
|
4431
|
+
);
|
|
4432
|
+
}
|
|
4433
|
+
});
|
|
4434
|
+
import_node_fs10.default.mkdirSync(import_node_path11.default.dirname(cached), { recursive: true });
|
|
4435
|
+
import_node_fs10.default.writeFileSync(cached, JSON.stringify(result));
|
|
4436
|
+
built.set(id, result);
|
|
4437
|
+
} catch (error) {
|
|
4438
|
+
result = error instanceof Error ? error.message : String(error);
|
|
4439
|
+
} finally {
|
|
4440
|
+
import_node_fs10.default.rmSync(work, { recursive: true, force: true });
|
|
4441
|
+
}
|
|
3513
4442
|
return result;
|
|
3514
4443
|
}
|
|
4444
|
+
function swiftStandins(binaries, toolchain) {
|
|
4445
|
+
const standins = [];
|
|
4446
|
+
const gaps = /* @__PURE__ */ new Map();
|
|
4447
|
+
for (const binary of binaries) {
|
|
4448
|
+
const result = binaryStandins(binary, toolchain);
|
|
4449
|
+
if (typeof result === "string") gaps.set(binary.target, result);
|
|
4450
|
+
else standins.push(...result);
|
|
4451
|
+
}
|
|
4452
|
+
return { standins, gaps };
|
|
4453
|
+
}
|
|
3515
4454
|
|
|
3516
4455
|
// src/swift-submit.ts
|
|
3517
4456
|
var SWIFT_COMPILE_PATH = "/api/swift-compile";
|
|
@@ -3650,15 +4589,15 @@ async function compileSwiftProject(submit, work, origin, signal) {
|
|
|
3650
4589
|
}
|
|
3651
4590
|
|
|
3652
4591
|
// src/xcode-project.ts
|
|
3653
|
-
var
|
|
3654
|
-
var
|
|
4592
|
+
var import_node_fs11 = __toESM(require("node:fs"), 1);
|
|
4593
|
+
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
3655
4594
|
var import_plist = __toESM(require_plist(), 1);
|
|
3656
4595
|
|
|
3657
4596
|
// src/xcode-json-project.ts
|
|
3658
|
-
var
|
|
4597
|
+
var import_node_path12 = __toESM(require("node:path"), 1);
|
|
3659
4598
|
var import_json5 = __toESM(require("json5"), 1);
|
|
3660
4599
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3661
|
-
var
|
|
4600
|
+
var text2 = (value) => typeof value === "string" ? value : void 0;
|
|
3662
4601
|
var items = (value) => Array.isArray(value) ? value : [];
|
|
3663
4602
|
var PHASE_ISA = {
|
|
3664
4603
|
"compile-sources": "PBXSourcesBuildPhase",
|
|
@@ -3671,20 +4610,20 @@ var PHASE_ISA = {
|
|
|
3671
4610
|
function readXcodeJsonProject(xcodeproj, source) {
|
|
3672
4611
|
const json = import_json5.default.parse(source);
|
|
3673
4612
|
if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
|
|
3674
|
-
const projectDir =
|
|
4613
|
+
const projectDir = import_node_path12.default.dirname(xcodeproj);
|
|
3675
4614
|
const objects = {};
|
|
3676
4615
|
let next = 0;
|
|
3677
4616
|
const add = (entry, id) => {
|
|
3678
|
-
const
|
|
3679
|
-
objects[
|
|
3680
|
-
return
|
|
4617
|
+
const key2 = id ?? `XCPROJ${(next++).toString(16).toUpperCase().padStart(18, "0")}`;
|
|
4618
|
+
objects[key2] = entry;
|
|
4619
|
+
return key2;
|
|
3681
4620
|
};
|
|
3682
4621
|
const locate = (raw2, groupDir) => {
|
|
3683
4622
|
if (raw2.startsWith("<USER:")) return null;
|
|
3684
4623
|
const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
|
|
3685
4624
|
if (base) {
|
|
3686
4625
|
if (base[1] === "PROJECT")
|
|
3687
|
-
return { sourceTree: "<absolute>", path:
|
|
4626
|
+
return { sourceTree: "<absolute>", path: import_node_path12.default.join(projectDir, base[2]) };
|
|
3688
4627
|
if (base[1] === "PRODUCTS")
|
|
3689
4628
|
return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
|
|
3690
4629
|
return null;
|
|
@@ -3692,7 +4631,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3692
4631
|
const unescaped = raw2.replaceAll("\\<", "<");
|
|
3693
4632
|
if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
|
|
3694
4633
|
if (unescaped.startsWith("~")) return null;
|
|
3695
|
-
return groupDir === null ? null : { sourceTree: "<absolute>", path:
|
|
4634
|
+
return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path12.default.join(groupDir, unescaped) };
|
|
3696
4635
|
};
|
|
3697
4636
|
const memberships = [];
|
|
3698
4637
|
const folders = [];
|
|
@@ -3700,10 +4639,10 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3700
4639
|
const root = { id: "", name: "", dir: projectDir, parent: null, children: [] };
|
|
3701
4640
|
const walk2 = (entries, parent) => entries.flatMap((entry) => {
|
|
3702
4641
|
if (!isObject(entry)) return [];
|
|
3703
|
-
const kind =
|
|
3704
|
-
const raw2 =
|
|
4642
|
+
const kind = text2(entry.kind) ?? "file-reference";
|
|
4643
|
+
const raw2 = text2(entry.path) ?? "";
|
|
3705
4644
|
const located = raw2 === "" ? null : locate(raw2, parent.dir);
|
|
3706
|
-
const name =
|
|
4645
|
+
const name = text2(entry.name) ?? import_node_path12.default.basename(raw2);
|
|
3707
4646
|
const node = { id: "", name, dir: null, parent, children: [] };
|
|
3708
4647
|
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
3709
4648
|
node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
@@ -3719,7 +4658,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3719
4658
|
...kind === "variant-group" ? {} : { sourceTree: "<absolute>", path: node.dir ?? "" },
|
|
3720
4659
|
name
|
|
3721
4660
|
},
|
|
3722
|
-
|
|
4661
|
+
text2(entry.id)
|
|
3723
4662
|
);
|
|
3724
4663
|
} else if (kind === "folder") {
|
|
3725
4664
|
node.id = add(
|
|
@@ -3727,7 +4666,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3727
4666
|
isa: "PBXFileSystemSynchronizedRootGroup",
|
|
3728
4667
|
...located ?? { sourceTree: "SDKROOT", path: raw2 }
|
|
3729
4668
|
},
|
|
3730
|
-
|
|
4669
|
+
text2(entry.id)
|
|
3731
4670
|
);
|
|
3732
4671
|
folders.push({ id: node.id, folder: entry });
|
|
3733
4672
|
} else {
|
|
@@ -3737,7 +4676,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3737
4676
|
...located ?? { sourceTree: "SDKROOT", path: raw2 },
|
|
3738
4677
|
name
|
|
3739
4678
|
},
|
|
3740
|
-
|
|
4679
|
+
text2(entry.id)
|
|
3741
4680
|
);
|
|
3742
4681
|
if (located?.sourceTree === "<absolute>" && located.path.endsWith(".xcodeproj"))
|
|
3743
4682
|
projectFiles.push(node.id);
|
|
@@ -3764,7 +4703,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3764
4703
|
if (Array.isArray(reference)) {
|
|
3765
4704
|
return lookupNode(
|
|
3766
4705
|
reference.map(
|
|
3767
|
-
(component) => isObject(component) ?
|
|
4706
|
+
(component) => isObject(component) ? text2(component.name) ?? "" : text2(component) ?? ""
|
|
3768
4707
|
).join("/"),
|
|
3769
4708
|
from
|
|
3770
4709
|
)?.id;
|
|
@@ -3772,7 +4711,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3772
4711
|
return lookupNode(reference, from)?.id;
|
|
3773
4712
|
};
|
|
3774
4713
|
const lookupNode = (reference, from) => {
|
|
3775
|
-
const value =
|
|
4714
|
+
const value = text2(reference);
|
|
3776
4715
|
if (value === void 0) return void 0;
|
|
3777
4716
|
if (value.startsWith("id:")) {
|
|
3778
4717
|
const id = value.slice(3);
|
|
@@ -3787,14 +4726,14 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3787
4726
|
return node;
|
|
3788
4727
|
};
|
|
3789
4728
|
const configurations = items(json.configurations).flatMap((entry) => {
|
|
3790
|
-
const name = isObject(entry) ?
|
|
4729
|
+
const name = isObject(entry) ? text2(entry.name) : text2(entry);
|
|
3791
4730
|
return name ? [{ name, file: isObject(entry) ? entry.file : void 0 }] : [];
|
|
3792
4731
|
});
|
|
3793
4732
|
const settingsOf = (value) => Object.fromEntries(
|
|
3794
4733
|
Object.entries(isObject(value) ? value : {}).flatMap(
|
|
3795
|
-
([
|
|
4734
|
+
([key2, setting]) => typeof setting === "string" ? [[key2, setting]] : Array.isArray(setting) ? [
|
|
3796
4735
|
[
|
|
3797
|
-
|
|
4736
|
+
key2,
|
|
3798
4737
|
setting.filter((item) => typeof item === "string")
|
|
3799
4738
|
]
|
|
3800
4739
|
] : []
|
|
@@ -3802,7 +4741,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3802
4741
|
);
|
|
3803
4742
|
const configurationList = (settings, specialized) => add({
|
|
3804
4743
|
isa: "XCConfigurationList",
|
|
3805
|
-
defaultConfigurationName:
|
|
4744
|
+
defaultConfigurationName: text2(json["default-configuration"]) ?? "Debug",
|
|
3806
4745
|
buildConfigurations: configurations.map(({ name, file }) => {
|
|
3807
4746
|
const base = lookup(specialized.has(name) ? specialized.get(name) : file);
|
|
3808
4747
|
return add({
|
|
@@ -3816,37 +4755,37 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3816
4755
|
const packageIds = /* @__PURE__ */ new Map();
|
|
3817
4756
|
for (const entry of items(json.packages)) {
|
|
3818
4757
|
if (!isObject(entry)) continue;
|
|
3819
|
-
const repository =
|
|
3820
|
-
const local =
|
|
3821
|
-
const name = local !== void 0 ?
|
|
3822
|
-
const id =
|
|
4758
|
+
const repository = text2(entry.repository);
|
|
4759
|
+
const local = text2(entry.path);
|
|
4760
|
+
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$/, "");
|
|
4761
|
+
const id = text2(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
3823
4762
|
packageIds.set(name.toLowerCase(), id);
|
|
3824
4763
|
}
|
|
3825
4764
|
const productDependency = (entry) => add({
|
|
3826
4765
|
isa: "XCSwiftPackageProductDependency",
|
|
3827
|
-
productName:
|
|
4766
|
+
productName: text2(entry["product-name"]) ?? "",
|
|
3828
4767
|
// xcode finds a product by name across packages when none is named
|
|
3829
|
-
...packageIds.has(
|
|
4768
|
+
...packageIds.has(text2(entry.package)?.toLowerCase() ?? "") ? { package: packageIds.get(text2(entry.package).toLowerCase()) } : {}
|
|
3830
4769
|
});
|
|
3831
4770
|
const proxy = (entry, remote, proxyType) => add({
|
|
3832
4771
|
isa: "PBXContainerItemProxy",
|
|
3833
4772
|
containerPortal: lookup(entry.project) ?? "",
|
|
3834
4773
|
proxyType,
|
|
3835
4774
|
remoteGlobalIDString: remote ?? "",
|
|
3836
|
-
remoteInfo:
|
|
4775
|
+
remoteInfo: text2(entry.target) ?? ""
|
|
3837
4776
|
});
|
|
3838
4777
|
const phases = /* @__PURE__ */ new Map();
|
|
3839
4778
|
const targetIds = /* @__PURE__ */ new Map();
|
|
3840
4779
|
const targets = [];
|
|
3841
4780
|
for (const entry of items(json.targets)) {
|
|
3842
4781
|
if (!isObject(entry)) continue;
|
|
3843
|
-
const name =
|
|
3844
|
-
const productType =
|
|
4782
|
+
const name = text2(entry.name) ?? "";
|
|
4783
|
+
const productType = text2(entry["product-type"]);
|
|
3845
4784
|
const target = {
|
|
3846
|
-
isa:
|
|
4785
|
+
isa: text2(entry.kind) === "aggregate" ? "PBXAggregateTarget" : "PBXNativeTarget",
|
|
3847
4786
|
name,
|
|
3848
4787
|
productName: name,
|
|
3849
|
-
productType: productType ? `com.apple.product-type.${productType}` :
|
|
4788
|
+
productType: productType ? `com.apple.product-type.${productType}` : text2(entry["full-product-type"]) ?? "",
|
|
3850
4789
|
buildPhases: [],
|
|
3851
4790
|
dependencies: [],
|
|
3852
4791
|
packageProductDependencies: [],
|
|
@@ -3854,17 +4793,17 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3854
4793
|
};
|
|
3855
4794
|
const product = lookup(entry.product);
|
|
3856
4795
|
if (product) target.productReference = product;
|
|
3857
|
-
const id = add(target,
|
|
4796
|
+
const id = add(target, text2(entry.id));
|
|
3858
4797
|
targetIds.set(name, id);
|
|
3859
4798
|
targets.push({ id, target, entry });
|
|
3860
4799
|
for (const phase of items(entry["build-phases"])) {
|
|
3861
|
-
const kind = isObject(phase) ?
|
|
4800
|
+
const kind = isObject(phase) ? text2(phase.kind) : text2(phase);
|
|
3862
4801
|
const isa = kind ? PHASE_ISA[kind] : void 0;
|
|
3863
4802
|
if (!kind || !isa) continue;
|
|
3864
|
-
const phaseName = isObject(phase) ?
|
|
4803
|
+
const phaseName = isObject(phase) ? text2(phase.name) : void 0;
|
|
3865
4804
|
const phaseId = add(
|
|
3866
4805
|
{ isa, files: [] },
|
|
3867
|
-
isObject(phase) ?
|
|
4806
|
+
isObject(phase) ? text2(phase.id) : void 0
|
|
3868
4807
|
);
|
|
3869
4808
|
target.buildPhases.push(phaseId);
|
|
3870
4809
|
phases.set([name, kind, phaseName].filter(Boolean).join("/"), phaseId);
|
|
@@ -3872,28 +4811,28 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3872
4811
|
}
|
|
3873
4812
|
}
|
|
3874
4813
|
const phaseFiles = (reference, targetName) => {
|
|
3875
|
-
const value =
|
|
4814
|
+
const value = text2(reference);
|
|
3876
4815
|
if (value === void 0) return null;
|
|
3877
|
-
const
|
|
3878
|
-
const phase = objects[phases.get(
|
|
4816
|
+
const key2 = value.startsWith("id:") || !targetName ? value : `${targetName}/${value}`;
|
|
4817
|
+
const phase = objects[phases.get(key2) ?? ""];
|
|
3879
4818
|
return phase && typeof phase === "object" && !Array.isArray(phase) && Array.isArray(phase.files) ? phase.files : null;
|
|
3880
4819
|
};
|
|
3881
4820
|
for (const { refId, entry } of memberships) {
|
|
3882
|
-
const
|
|
3883
|
-
|
|
4821
|
+
const files2 = phaseFiles(isObject(entry) ? entry["build-phase"] : entry);
|
|
4822
|
+
files2?.push(add({ isa: "PBXBuildFile", fileRef: refId }));
|
|
3884
4823
|
}
|
|
3885
4824
|
for (const { target, entry } of targets) {
|
|
3886
|
-
const name =
|
|
4825
|
+
const name = text2(entry.name) ?? "";
|
|
3887
4826
|
target.buildConfigurationList = configurationList(
|
|
3888
4827
|
settingsOf(entry["build-settings"]),
|
|
3889
4828
|
new Map(
|
|
3890
4829
|
items(entry["specialized-configurations"]).flatMap(
|
|
3891
|
-
(configuration) => isObject(configuration) &&
|
|
4830
|
+
(configuration) => isObject(configuration) && text2(configuration.name) ? [[text2(configuration.name), configuration.file]] : []
|
|
3892
4831
|
)
|
|
3893
4832
|
)
|
|
3894
4833
|
);
|
|
3895
4834
|
for (const dependency of items(entry.dependencies)) {
|
|
3896
|
-
const kind = isObject(dependency) ?
|
|
4835
|
+
const kind = isObject(dependency) ? text2(dependency.kind) ?? "localTarget" : "localTarget";
|
|
3897
4836
|
if (kind === "package" && isObject(dependency)) {
|
|
3898
4837
|
;
|
|
3899
4838
|
target.dependencies.push(
|
|
@@ -3904,11 +4843,11 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3904
4843
|
target.dependencies.push(
|
|
3905
4844
|
add({
|
|
3906
4845
|
isa: "PBXTargetDependency",
|
|
3907
|
-
targetProxy: proxy(dependency,
|
|
4846
|
+
targetProxy: proxy(dependency, text2(dependency["target-id"]), "1")
|
|
3908
4847
|
})
|
|
3909
4848
|
);
|
|
3910
4849
|
} else {
|
|
3911
|
-
const local = isObject(dependency) ?
|
|
4850
|
+
const local = isObject(dependency) ? text2(dependency.target) : text2(dependency);
|
|
3912
4851
|
const id = local ? targetIds.get(local) : void 0;
|
|
3913
4852
|
if (id)
|
|
3914
4853
|
target.dependencies.push(
|
|
@@ -3930,9 +4869,9 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3930
4869
|
if (!isObject(imported)) continue;
|
|
3931
4870
|
const reference = add({
|
|
3932
4871
|
isa: "PBXReferenceProxy",
|
|
3933
|
-
path:
|
|
4872
|
+
path: text2(imported.name) ?? text2(imported.path) ?? "",
|
|
3934
4873
|
sourceTree: "BUILT_PRODUCTS_DIR",
|
|
3935
|
-
remoteRef: proxy(imported,
|
|
4874
|
+
remoteRef: proxy(imported, text2(imported["product-id"]), "2")
|
|
3936
4875
|
});
|
|
3937
4876
|
for (const membership of items(imported["target-membership"])) {
|
|
3938
4877
|
phaseFiles(isObject(membership) ? membership["build-phase"] : membership)?.push(
|
|
@@ -3944,7 +4883,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3944
4883
|
const exceptions = [];
|
|
3945
4884
|
for (const exception of items(folder["membership-exceptions"])) {
|
|
3946
4885
|
if (!isObject(exception)) continue;
|
|
3947
|
-
const target = targetIds.get(
|
|
4886
|
+
const target = targetIds.get(text2(exception.target) ?? "");
|
|
3948
4887
|
if (!target) continue;
|
|
3949
4888
|
exceptions.push(
|
|
3950
4889
|
add({
|
|
@@ -3962,7 +4901,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3962
4901
|
group.exceptions = exceptions;
|
|
3963
4902
|
for (const owner of items(folder["target-membership"])) {
|
|
3964
4903
|
const target = targets.find(
|
|
3965
|
-
(candidate) => candidate.id === targetIds.get(
|
|
4904
|
+
(candidate) => candidate.id === targetIds.get(text2(owner) ?? "")
|
|
3966
4905
|
);
|
|
3967
4906
|
target?.target.fileSystemSynchronizedGroups?.push(id);
|
|
3968
4907
|
}
|
|
@@ -3972,7 +4911,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
3972
4911
|
isa: "PBXProject",
|
|
3973
4912
|
mainGroup,
|
|
3974
4913
|
projectDirPath: "",
|
|
3975
|
-
developmentRegion:
|
|
4914
|
+
developmentRegion: text2(localizations.development) ?? "en",
|
|
3976
4915
|
buildConfigurationList: configurationList(
|
|
3977
4916
|
settingsOf(json["build-settings"]),
|
|
3978
4917
|
/* @__PURE__ */ new Map()
|
|
@@ -3988,23 +4927,23 @@ function isJsonObject(value) {
|
|
|
3988
4927
|
}
|
|
3989
4928
|
|
|
3990
4929
|
// src/xcode-project.ts
|
|
3991
|
-
function parseOpenStepPlist(
|
|
4930
|
+
function parseOpenStepPlist(text3) {
|
|
3992
4931
|
let i = 0;
|
|
3993
4932
|
const fail = (message) => {
|
|
3994
|
-
const line =
|
|
4933
|
+
const line = text3.slice(0, i).split("\n").length;
|
|
3995
4934
|
throw new Error(`project.pbxproj line ${line}: ${message}`);
|
|
3996
4935
|
};
|
|
3997
4936
|
const skip = () => {
|
|
3998
4937
|
for (; ; ) {
|
|
3999
|
-
const ch =
|
|
4938
|
+
const ch = text3[i];
|
|
4000
4939
|
if (ch === " " || ch === " " || ch === "\n" || ch === "\r") i++;
|
|
4001
|
-
else if (ch === "/" &&
|
|
4002
|
-
const end =
|
|
4940
|
+
else if (ch === "/" && text3[i + 1] === "*") {
|
|
4941
|
+
const end = text3.indexOf("*/", i + 2);
|
|
4003
4942
|
if (end < 0) fail("unterminated comment");
|
|
4004
4943
|
i = end + 2;
|
|
4005
|
-
} else if (ch === "/" &&
|
|
4006
|
-
const end =
|
|
4007
|
-
i = end < 0 ?
|
|
4944
|
+
} else if (ch === "/" && text3[i + 1] === "/") {
|
|
4945
|
+
const end = text3.indexOf("\n", i);
|
|
4946
|
+
i = end < 0 ? text3.length : end + 1;
|
|
4008
4947
|
} else return;
|
|
4009
4948
|
}
|
|
4010
4949
|
};
|
|
@@ -4012,42 +4951,42 @@ function parseOpenStepPlist(text2) {
|
|
|
4012
4951
|
i++;
|
|
4013
4952
|
let out = "";
|
|
4014
4953
|
for (; ; ) {
|
|
4015
|
-
const ch =
|
|
4954
|
+
const ch = text3[i++];
|
|
4016
4955
|
if (ch === void 0) fail("unterminated string");
|
|
4017
4956
|
if (ch === '"') return out;
|
|
4018
4957
|
if (ch !== "\\") {
|
|
4019
4958
|
out += ch;
|
|
4020
4959
|
continue;
|
|
4021
4960
|
}
|
|
4022
|
-
const next =
|
|
4961
|
+
const next = text3[i++];
|
|
4023
4962
|
if (next === "n") out += "\n";
|
|
4024
4963
|
else if (next === "t") out += " ";
|
|
4025
4964
|
else if (next === "r") out += "\r";
|
|
4026
4965
|
else if (next === "U") {
|
|
4027
|
-
out += String.fromCharCode(parseInt(
|
|
4966
|
+
out += String.fromCharCode(parseInt(text3.slice(i, i + 4), 16));
|
|
4028
4967
|
i += 4;
|
|
4029
4968
|
} else out += next;
|
|
4030
4969
|
}
|
|
4031
4970
|
};
|
|
4032
4971
|
const value = () => {
|
|
4033
4972
|
skip();
|
|
4034
|
-
const ch =
|
|
4973
|
+
const ch = text3[i];
|
|
4035
4974
|
if (ch === "{") {
|
|
4036
4975
|
i++;
|
|
4037
4976
|
const dict = {};
|
|
4038
4977
|
for (; ; ) {
|
|
4039
4978
|
skip();
|
|
4040
|
-
if (
|
|
4979
|
+
if (text3[i] === "}") {
|
|
4041
4980
|
i++;
|
|
4042
4981
|
return dict;
|
|
4043
4982
|
}
|
|
4044
|
-
const
|
|
4045
|
-
if (typeof
|
|
4983
|
+
const key2 = value();
|
|
4984
|
+
if (typeof key2 !== "string") fail("dictionary key is not a string");
|
|
4046
4985
|
skip();
|
|
4047
|
-
if (
|
|
4048
|
-
dict[
|
|
4986
|
+
if (text3[i++] !== "=") fail("expected =");
|
|
4987
|
+
dict[key2] = value();
|
|
4049
4988
|
skip();
|
|
4050
|
-
if (
|
|
4989
|
+
if (text3[i++] !== ";") fail("expected ;");
|
|
4051
4990
|
}
|
|
4052
4991
|
}
|
|
4053
4992
|
if (ch === "(") {
|
|
@@ -4055,26 +4994,26 @@ function parseOpenStepPlist(text2) {
|
|
|
4055
4994
|
const list2 = [];
|
|
4056
4995
|
for (; ; ) {
|
|
4057
4996
|
skip();
|
|
4058
|
-
if (
|
|
4997
|
+
if (text3[i] === ")") {
|
|
4059
4998
|
i++;
|
|
4060
4999
|
return list2;
|
|
4061
5000
|
}
|
|
4062
5001
|
list2.push(value());
|
|
4063
5002
|
skip();
|
|
4064
|
-
if (
|
|
4065
|
-
else if (
|
|
5003
|
+
if (text3[i] === ",") i++;
|
|
5004
|
+
else if (text3[i] !== ")") fail("expected , or )");
|
|
4066
5005
|
}
|
|
4067
5006
|
}
|
|
4068
5007
|
if (ch === '"') return quoted();
|
|
4069
5008
|
const start = i;
|
|
4070
|
-
while (i <
|
|
5009
|
+
while (i < text3.length && /[A-Za-z0-9_$+/:.\-<>]/.test(text3[i])) i++;
|
|
4071
5010
|
if (i === start) fail(`unexpected ${JSON.stringify(ch ?? "end of file")}`);
|
|
4072
|
-
return
|
|
5011
|
+
return text3.slice(start, i);
|
|
4073
5012
|
};
|
|
4074
|
-
if (
|
|
5013
|
+
if (text3.startsWith("// !$*UTF8*$!")) i = text3.indexOf("\n") + 1;
|
|
4075
5014
|
const root = value();
|
|
4076
5015
|
skip();
|
|
4077
|
-
if (i !==
|
|
5016
|
+
if (i !== text3.length) fail("trailing content");
|
|
4078
5017
|
return root;
|
|
4079
5018
|
}
|
|
4080
5019
|
var isDict = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -4095,28 +5034,28 @@ var CONDITIONS = {
|
|
|
4095
5034
|
variant: "normal"
|
|
4096
5035
|
};
|
|
4097
5036
|
function walkFiles(dir) {
|
|
4098
|
-
if (!
|
|
5037
|
+
if (!import_node_fs11.default.existsSync(dir)) return [];
|
|
4099
5038
|
const out = [];
|
|
4100
|
-
for (const entry of
|
|
5039
|
+
for (const entry of import_node_fs11.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
4101
5040
|
if (entry.name.startsWith(".")) continue;
|
|
4102
|
-
const full =
|
|
5041
|
+
const full = import_node_path13.default.join(dir, entry.name);
|
|
4103
5042
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
4104
5043
|
else if (entry.isFile()) out.push(full);
|
|
4105
5044
|
}
|
|
4106
5045
|
return out;
|
|
4107
5046
|
}
|
|
4108
|
-
var isDirectory = (dir) =>
|
|
5047
|
+
var isDirectory = (dir) => import_node_fs11.default.existsSync(dir) && import_node_fs11.default.statSync(dir).isDirectory();
|
|
4109
5048
|
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
4110
|
-
if (seen.has(file) || !
|
|
5049
|
+
if (seen.has(file) || !import_node_fs11.default.existsSync(file)) return {};
|
|
4111
5050
|
seen.add(file);
|
|
4112
5051
|
const settings = {};
|
|
4113
|
-
for (const raw2 of
|
|
5052
|
+
for (const raw2 of import_node_fs11.default.readFileSync(file, "utf8").split("\n")) {
|
|
4114
5053
|
const line = raw2.replace(/\/\/.*$/, "").trim();
|
|
4115
5054
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
4116
5055
|
if (include) {
|
|
4117
5056
|
Object.assign(
|
|
4118
5057
|
settings,
|
|
4119
|
-
readXcconfig(
|
|
5058
|
+
readXcconfig(import_node_path13.default.resolve(import_node_path13.default.dirname(file), include[1]), seen)
|
|
4120
5059
|
);
|
|
4121
5060
|
continue;
|
|
4122
5061
|
}
|
|
@@ -4129,13 +5068,13 @@ function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
|
4129
5068
|
function applyConditions(raw2, configuration) {
|
|
4130
5069
|
const plain = {};
|
|
4131
5070
|
const conditional = {};
|
|
4132
|
-
for (const [
|
|
4133
|
-
const bracket =
|
|
5071
|
+
for (const [key2, value] of Object.entries(raw2)) {
|
|
5072
|
+
const bracket = key2.indexOf("[");
|
|
4134
5073
|
if (bracket === -1) {
|
|
4135
|
-
plain[
|
|
5074
|
+
plain[key2] = value;
|
|
4136
5075
|
continue;
|
|
4137
5076
|
}
|
|
4138
|
-
const matches = [...
|
|
5077
|
+
const matches = [...key2.slice(bracket).matchAll(/\[([^=\]]+)=([^\]]*)\]/g)].every(
|
|
4139
5078
|
([, name, pattern]) => {
|
|
4140
5079
|
const actual = name === "config" ? configuration : CONDITIONS[name];
|
|
4141
5080
|
return actual !== void 0 && new RegExp(
|
|
@@ -4143,7 +5082,7 @@ function applyConditions(raw2, configuration) {
|
|
|
4143
5082
|
).test(actual);
|
|
4144
5083
|
}
|
|
4145
5084
|
);
|
|
4146
|
-
if (matches) conditional[
|
|
5085
|
+
if (matches) conditional[key2.slice(0, bracket)] = value;
|
|
4147
5086
|
}
|
|
4148
5087
|
return { ...plain, ...conditional };
|
|
4149
5088
|
}
|
|
@@ -4162,26 +5101,26 @@ function applyOperator(value, operator) {
|
|
|
4162
5101
|
}
|
|
4163
5102
|
throw new Error(`unsupported build setting operator :${operator}`);
|
|
4164
5103
|
}
|
|
4165
|
-
function decodeXml(
|
|
4166
|
-
return
|
|
5104
|
+
function decodeXml(text3) {
|
|
5105
|
+
return text3.replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
4167
5106
|
}
|
|
4168
5107
|
function workspaceReferences(workspace) {
|
|
4169
|
-
const data =
|
|
4170
|
-
if (!
|
|
5108
|
+
const data = import_node_path13.default.join(workspace, "contents.xcworkspacedata");
|
|
5109
|
+
if (!import_node_fs11.default.existsSync(data))
|
|
4171
5110
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
4172
|
-
const container =
|
|
5111
|
+
const container = import_node_path13.default.dirname(workspace);
|
|
4173
5112
|
const locate = (location, base) => {
|
|
4174
5113
|
const colon = location.indexOf(":");
|
|
4175
5114
|
const kind = location.slice(0, colon);
|
|
4176
5115
|
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(`${
|
|
5116
|
+
if (kind === "group") return import_node_path13.default.resolve(base, rest);
|
|
5117
|
+
if (kind === "container" || kind === "self") return import_node_path13.default.resolve(container, rest);
|
|
5118
|
+
if (kind === "absolute") return import_node_path13.default.resolve(rest);
|
|
5119
|
+
throw new Error(`${import_node_path13.default.basename(workspace)} has an unsupported location ${location}`);
|
|
4181
5120
|
};
|
|
4182
5121
|
const groups = [container];
|
|
4183
5122
|
const references = [];
|
|
4184
|
-
for (const [, closing, tag, attributes, selfClosing] of
|
|
5123
|
+
for (const [, closing, tag, attributes, selfClosing] of import_node_fs11.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
|
|
4185
5124
|
if (closing) {
|
|
4186
5125
|
if (tag === "Group") groups.pop();
|
|
4187
5126
|
continue;
|
|
@@ -4197,8 +5136,8 @@ function workspaceReferences(workspace) {
|
|
|
4197
5136
|
var loaded = /* @__PURE__ */ new Map();
|
|
4198
5137
|
function xcodeProjectFile(xcodeproj) {
|
|
4199
5138
|
for (const name of ["project.pbxproj", "project.xcproj"]) {
|
|
4200
|
-
const file =
|
|
4201
|
-
if (
|
|
5139
|
+
const file = import_node_path13.default.join(xcodeproj, name);
|
|
5140
|
+
if (import_node_fs11.default.existsSync(file)) return file;
|
|
4202
5141
|
}
|
|
4203
5142
|
return null;
|
|
4204
5143
|
}
|
|
@@ -4206,10 +5145,10 @@ function loadProject(xcodeproj) {
|
|
|
4206
5145
|
const projectFile = xcodeProjectFile(xcodeproj);
|
|
4207
5146
|
if (!projectFile)
|
|
4208
5147
|
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
4209
|
-
const mtimeMs =
|
|
5148
|
+
const mtimeMs = import_node_fs11.default.statSync(projectFile).mtimeMs;
|
|
4210
5149
|
const cached = loaded.get(projectFile);
|
|
4211
5150
|
if (cached?.mtimeMs === mtimeMs) return cached.project;
|
|
4212
|
-
const source =
|
|
5151
|
+
const source = import_node_fs11.default.readFileSync(projectFile, "utf8");
|
|
4213
5152
|
const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
|
|
4214
5153
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
4215
5154
|
throw new Error(`${projectFile} has no objects table`);
|
|
@@ -4223,8 +5162,8 @@ function loadProject(xcodeproj) {
|
|
|
4223
5162
|
if (!project || project.isa !== "PBXProject") {
|
|
4224
5163
|
throw new Error(`${projectFile} has no PBXProject root`);
|
|
4225
5164
|
}
|
|
4226
|
-
const projectDir =
|
|
4227
|
-
|
|
5165
|
+
const projectDir = import_node_fs11.default.realpathSync(
|
|
5166
|
+
import_node_path13.default.resolve(import_node_path13.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
4228
5167
|
);
|
|
4229
5168
|
const parent = /* @__PURE__ */ new Map();
|
|
4230
5169
|
for (const [id, entry] of Object.entries(objects)) {
|
|
@@ -4242,11 +5181,11 @@ function loadProject(xcodeproj) {
|
|
|
4242
5181
|
const own = str(entry.path) ?? "";
|
|
4243
5182
|
const tree = str(entry.sourceTree) ?? "<group>";
|
|
4244
5183
|
if (tree === "<absolute>") result2 = own;
|
|
4245
|
-
else if (tree === "SOURCE_ROOT") result2 =
|
|
5184
|
+
else if (tree === "SOURCE_ROOT") result2 = import_node_path13.default.join(projectDir, own);
|
|
4246
5185
|
else if (tree === "<group>") {
|
|
4247
5186
|
const up = parent.get(id);
|
|
4248
5187
|
const base = up ? resolvePath(up) : projectDir;
|
|
4249
|
-
result2 = base === null ? null :
|
|
5188
|
+
result2 = base === null ? null : import_node_path13.default.join(base, own);
|
|
4250
5189
|
}
|
|
4251
5190
|
}
|
|
4252
5191
|
resolvedPaths.set(id, result2);
|
|
@@ -4278,7 +5217,7 @@ function targetSettings(ref, builtins) {
|
|
|
4278
5217
|
applyConditions(
|
|
4279
5218
|
Object.fromEntries(
|
|
4280
5219
|
Object.entries(own).flatMap(
|
|
4281
|
-
([
|
|
5220
|
+
([key2, value]) => typeof value === "string" ? [[key2, value]] : Array.isArray(value) ? [[key2, list(value).join(" ")]] : []
|
|
4282
5221
|
)
|
|
4283
5222
|
),
|
|
4284
5223
|
name
|
|
@@ -4291,24 +5230,24 @@ function targetSettings(ref, builtins) {
|
|
|
4291
5230
|
...level(str(target.buildConfigurationList))
|
|
4292
5231
|
];
|
|
4293
5232
|
const resolving = /* @__PURE__ */ new Set();
|
|
4294
|
-
const valueAt = (
|
|
5233
|
+
const valueAt = (key2, top) => {
|
|
4295
5234
|
let at = top;
|
|
4296
|
-
while (at >= 0 && levels[at][
|
|
4297
|
-
if (at < 0) return derived(
|
|
4298
|
-
const marker = `${
|
|
5235
|
+
while (at >= 0 && levels[at][key2] === void 0) at--;
|
|
5236
|
+
if (at < 0) return derived(key2);
|
|
5237
|
+
const marker = `${key2}@${at}`;
|
|
4299
5238
|
if (resolving.has(marker))
|
|
4300
|
-
throw new Error(`${str(target.name)} has a cyclic build setting ${
|
|
5239
|
+
throw new Error(`${str(target.name)} has a cyclic build setting ${key2}`);
|
|
4301
5240
|
resolving.add(marker);
|
|
4302
5241
|
const value = expand(
|
|
4303
|
-
levels[at][
|
|
4304
|
-
(name) => name === "inherited" ? valueAt(
|
|
5242
|
+
levels[at][key2],
|
|
5243
|
+
(name) => name === "inherited" ? valueAt(key2, at - 1) : valueAt(name, levels.length - 1)
|
|
4305
5244
|
);
|
|
4306
5245
|
resolving.delete(marker);
|
|
4307
5246
|
return value;
|
|
4308
5247
|
};
|
|
4309
|
-
const derived = (
|
|
5248
|
+
const derived = (key2) => {
|
|
4310
5249
|
const get = (name) => valueAt(name, levels.length - 1);
|
|
4311
|
-
switch (
|
|
5250
|
+
switch (key2) {
|
|
4312
5251
|
case "PRODUCT_NAME":
|
|
4313
5252
|
return get("TARGET_NAME");
|
|
4314
5253
|
case "PRODUCT_MODULE_NAME":
|
|
@@ -4324,7 +5263,7 @@ function targetSettings(ref, builtins) {
|
|
|
4324
5263
|
return "";
|
|
4325
5264
|
};
|
|
4326
5265
|
return {
|
|
4327
|
-
get: (
|
|
5266
|
+
get: (key2) => valueAt(key2, levels.length - 1),
|
|
4328
5267
|
keys: new Set(levels.flatMap((values) => Object.keys(values)))
|
|
4329
5268
|
};
|
|
4330
5269
|
}
|
|
@@ -4346,7 +5285,7 @@ function targetMembers(ref) {
|
|
|
4346
5285
|
const addResource = (file) => {
|
|
4347
5286
|
if (isDirectory(file)) {
|
|
4348
5287
|
for (const inner of walkFiles(file)) resources.add(inner);
|
|
4349
|
-
} else if (
|
|
5288
|
+
} else if (import_node_fs11.default.existsSync(file)) resources.add(file);
|
|
4350
5289
|
};
|
|
4351
5290
|
const fileRefPaths = (refId) => {
|
|
4352
5291
|
const entry = project.object(refId);
|
|
@@ -4367,7 +5306,7 @@ function targetMembers(ref) {
|
|
|
4367
5306
|
for (const buildFileId of list(phase.files)) {
|
|
4368
5307
|
for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
|
|
4369
5308
|
if (phase.isa === "PBXSourcesBuildPhase") {
|
|
4370
|
-
if (!
|
|
5309
|
+
if (!import_node_fs11.default.existsSync(file)) continue;
|
|
4371
5310
|
allSources.add(file);
|
|
4372
5311
|
if (file.endsWith(".swift")) sources.add(file);
|
|
4373
5312
|
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
@@ -4375,7 +5314,7 @@ function targetMembers(ref) {
|
|
|
4375
5314
|
}
|
|
4376
5315
|
}
|
|
4377
5316
|
const addSynchronized = (folder, relative) => {
|
|
4378
|
-
const file =
|
|
5317
|
+
const file = import_node_path13.default.join(folder, relative);
|
|
4379
5318
|
if (NEVER_MEMBER.test(relative)) return;
|
|
4380
5319
|
if (file.endsWith(".swift")) {
|
|
4381
5320
|
if (!relative.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
|
|
@@ -4400,7 +5339,7 @@ function targetMembers(ref) {
|
|
|
4400
5339
|
}
|
|
4401
5340
|
if (owned.has(groupId)) {
|
|
4402
5341
|
for (const file of walkFiles(folder)) {
|
|
4403
|
-
const relative =
|
|
5342
|
+
const relative = import_node_path13.default.relative(folder, file).split(import_node_path13.default.sep).join("/");
|
|
4404
5343
|
if ([...exceptions].some(
|
|
4405
5344
|
(exception) => relative === exception || relative.startsWith(`${exception}/`)
|
|
4406
5345
|
))
|
|
@@ -4409,14 +5348,14 @@ function targetMembers(ref) {
|
|
|
4409
5348
|
}
|
|
4410
5349
|
} else {
|
|
4411
5350
|
for (const relative of exceptions) {
|
|
4412
|
-
const file =
|
|
5351
|
+
const file = import_node_path13.default.join(folder, relative);
|
|
4413
5352
|
if (isDirectory(file)) {
|
|
4414
5353
|
for (const inner of walkFiles(file))
|
|
4415
5354
|
addSynchronized(
|
|
4416
5355
|
folder,
|
|
4417
|
-
|
|
5356
|
+
import_node_path13.default.relative(folder, inner).split(import_node_path13.default.sep).join("/")
|
|
4418
5357
|
);
|
|
4419
|
-
} else if (
|
|
5358
|
+
} else if (import_node_fs11.default.existsSync(file)) addSynchronized(folder, relative);
|
|
4420
5359
|
}
|
|
4421
5360
|
}
|
|
4422
5361
|
}
|
|
@@ -4429,8 +5368,8 @@ function targetMembers(ref) {
|
|
|
4429
5368
|
function commonAncestor(dirs) {
|
|
4430
5369
|
let common = dirs[0];
|
|
4431
5370
|
for (const dir of dirs) {
|
|
4432
|
-
while (common !==
|
|
4433
|
-
common =
|
|
5371
|
+
while (common !== import_node_path13.default.dirname(common) && import_node_path13.default.relative(common, dir).startsWith(".."))
|
|
5372
|
+
common = import_node_path13.default.dirname(common);
|
|
4434
5373
|
}
|
|
4435
5374
|
return common;
|
|
4436
5375
|
}
|
|
@@ -4439,11 +5378,11 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
4439
5378
|
const projects2 = [];
|
|
4440
5379
|
const projectAt = /* @__PURE__ */ new Map();
|
|
4441
5380
|
const addProject = (xcodeproj) => {
|
|
4442
|
-
const
|
|
4443
|
-
if (projectAt.has(
|
|
4444
|
-
if (!xcodeProjectFile(
|
|
4445
|
-
const project = loadProject(
|
|
4446
|
-
projectAt.set(
|
|
5381
|
+
const key2 = import_node_path13.default.resolve(xcodeproj);
|
|
5382
|
+
if (projectAt.has(key2) || key2.split(import_node_path13.default.sep).includes("Pods")) return;
|
|
5383
|
+
if (!xcodeProjectFile(key2)) return;
|
|
5384
|
+
const project = loadProject(key2);
|
|
5385
|
+
projectAt.set(key2, project);
|
|
4447
5386
|
projects2.push(project);
|
|
4448
5387
|
const nested = project.project.projectReferences;
|
|
4449
5388
|
if (Array.isArray(nested)) {
|
|
@@ -4457,7 +5396,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
4457
5396
|
for (const reference of listed)
|
|
4458
5397
|
if (reference.endsWith(".xcodeproj")) addProject(reference);
|
|
4459
5398
|
if (projects2.length === 0) {
|
|
4460
|
-
throw new Error(`${
|
|
5399
|
+
throw new Error(`${import_node_path13.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
|
|
4461
5400
|
}
|
|
4462
5401
|
return { listed, projects: projects2, projectAt };
|
|
4463
5402
|
}
|
|
@@ -4479,7 +5418,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4479
5418
|
const allTargets = projects2.flatMap(nativeTargets);
|
|
4480
5419
|
const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
|
|
4481
5420
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
|
|
4482
|
-
const container =
|
|
5421
|
+
const container = import_node_path13.default.basename(xcodeprojOrWorkspace);
|
|
4483
5422
|
const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
|
|
4484
5423
|
if (named.length !== 1) {
|
|
4485
5424
|
throw new Error(
|
|
@@ -4491,14 +5430,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4491
5430
|
for (const ref of allTargets) {
|
|
4492
5431
|
const product = ref.project.object(str(ref.target.productReference));
|
|
4493
5432
|
const file = str(product?.path);
|
|
4494
|
-
if (file && !byProduct.has(
|
|
4495
|
-
byProduct.set(
|
|
5433
|
+
if (file && !byProduct.has(import_node_path13.default.basename(file)))
|
|
5434
|
+
byProduct.set(import_node_path13.default.basename(file), ref);
|
|
4496
5435
|
}
|
|
4497
5436
|
const proxied = (project, proxyId) => {
|
|
4498
5437
|
const proxy = project.object(proxyId);
|
|
4499
5438
|
if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
|
|
4500
5439
|
const portal = str(proxy.containerPortal);
|
|
4501
|
-
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(
|
|
5440
|
+
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path13.default.resolve(project.resolvePath(portal ?? "") ?? ""));
|
|
4502
5441
|
const remote = str(proxy.remoteGlobalIDString);
|
|
4503
5442
|
if (!owner || !remote) return void 0;
|
|
4504
5443
|
return nativeTargets(owner).find(
|
|
@@ -4519,7 +5458,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4519
5458
|
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
4520
5459
|
for (const buildFileId of list(phase.files)) {
|
|
4521
5460
|
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(
|
|
5461
|
+
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
5462
|
if (resolved) found.push(resolved);
|
|
4524
5463
|
}
|
|
4525
5464
|
}
|
|
@@ -4540,7 +5479,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4540
5479
|
const name = str(ref.target.name) ?? ref.id;
|
|
4541
5480
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
4542
5481
|
TARGET_NAME: name,
|
|
4543
|
-
PROJECT_NAME:
|
|
5482
|
+
PROJECT_NAME: import_node_path13.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
4544
5483
|
SRCROOT: ref.project.projectDir,
|
|
4545
5484
|
SOURCE_ROOT: ref.project.projectDir,
|
|
4546
5485
|
PROJECT_DIR: ref.project.projectDir,
|
|
@@ -4566,22 +5505,22 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4566
5505
|
if (Array.isArray(value)) return value.map(expandValue);
|
|
4567
5506
|
if (typeof value === "object" && !(value instanceof Date) && !Buffer.isBuffer(value)) {
|
|
4568
5507
|
return Object.fromEntries(
|
|
4569
|
-
Object.entries(value).map(([
|
|
5508
|
+
Object.entries(value).map(([key2, value2]) => [key2, expandValue(value2)])
|
|
4570
5509
|
);
|
|
4571
5510
|
}
|
|
4572
5511
|
return value;
|
|
4573
5512
|
};
|
|
4574
|
-
const infoPlistFile = settings("INFOPLIST_FILE") ?
|
|
4575
|
-
const sourceInfo = infoPlistFile ? import_plist.default.parse(
|
|
5513
|
+
const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path13.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
|
|
5514
|
+
const sourceInfo = infoPlistFile ? import_plist.default.parse(import_node_fs11.default.readFileSync(infoPlistFile, "utf8")) : {};
|
|
4576
5515
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
4577
5516
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
4578
5517
|
}
|
|
4579
5518
|
const info = {};
|
|
4580
|
-
for (const [
|
|
4581
|
-
for (const
|
|
4582
|
-
if (!
|
|
4583
|
-
const value = settings(
|
|
4584
|
-
info[
|
|
5519
|
+
for (const [key2, value] of Object.entries(sourceInfo)) info[key2] = expandValue(value);
|
|
5520
|
+
for (const key2 of settingKeys) {
|
|
5521
|
+
if (!key2.startsWith("INFOPLIST_KEY_") || key2.endsWith("_Generation")) continue;
|
|
5522
|
+
const value = settings(key2);
|
|
5523
|
+
info[key2.slice("INFOPLIST_KEY_".length)] = value === "YES" ? true : value === "NO" ? false : value;
|
|
4585
5524
|
}
|
|
4586
5525
|
if (settings("INFOPLIST_KEY_UIApplicationSceneManifest_Generation") === "YES" && info.UIApplicationSceneManifest === void 0) {
|
|
4587
5526
|
info.UIApplicationSceneManifest = {
|
|
@@ -4590,12 +5529,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4590
5529
|
};
|
|
4591
5530
|
}
|
|
4592
5531
|
const localPackageDirs = [
|
|
4593
|
-
...listed.filter((reference) =>
|
|
5532
|
+
...listed.filter((reference) => import_node_fs11.default.existsSync(import_node_path13.default.join(reference, "Package.swift"))),
|
|
4594
5533
|
...projects2.flatMap(
|
|
4595
5534
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
4596
5535
|
if (!isDict(entry)) return [];
|
|
4597
|
-
const candidate = entry.isa === "XCLocalSwiftPackageReference" ?
|
|
4598
|
-
return candidate &&
|
|
5536
|
+
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path13.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
|
|
5537
|
+
return candidate && import_node_fs11.default.existsSync(import_node_path13.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
4599
5538
|
})
|
|
4600
5539
|
)
|
|
4601
5540
|
];
|
|
@@ -4619,7 +5558,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4619
5558
|
product,
|
|
4620
5559
|
source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
|
|
4621
5560
|
kind: "local",
|
|
4622
|
-
dir:
|
|
5561
|
+
dir: import_node_path13.default.resolve(
|
|
4623
5562
|
project.projectDir,
|
|
4624
5563
|
str(reference.relativePath) ?? ""
|
|
4625
5564
|
)
|
|
@@ -4641,8 +5580,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4641
5580
|
}
|
|
4642
5581
|
}
|
|
4643
5582
|
}
|
|
4644
|
-
const resolvedFile =
|
|
4645
|
-
workspace ??
|
|
5583
|
+
const resolvedFile = import_node_path13.default.join(
|
|
5584
|
+
workspace ?? import_node_path13.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
|
|
4646
5585
|
"xcshareddata",
|
|
4647
5586
|
"swiftpm",
|
|
4648
5587
|
"Package.resolved"
|
|
@@ -4652,13 +5591,13 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4652
5591
|
...module2,
|
|
4653
5592
|
rootDir: commonAncestor(
|
|
4654
5593
|
[
|
|
4655
|
-
workspace ?
|
|
5594
|
+
workspace ? import_node_path13.default.dirname(workspace) : app.project.projectDir,
|
|
4656
5595
|
...used.map((project) => project.projectDir),
|
|
4657
5596
|
...localPackageDirs,
|
|
4658
5597
|
...linkedProducts.flatMap(
|
|
4659
|
-
({ source }) => source.kind === "local" &&
|
|
5598
|
+
({ source }) => source.kind === "local" && import_node_fs11.default.existsSync(source.dir) ? [source.dir] : []
|
|
4660
5599
|
)
|
|
4661
|
-
].map((dir) =>
|
|
5600
|
+
].map((dir) => import_node_fs11.default.realpathSync(dir))
|
|
4662
5601
|
),
|
|
4663
5602
|
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
4664
5603
|
infoPlist: import_plist.default.build(info),
|
|
@@ -4666,10 +5605,10 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
4666
5605
|
frameworks,
|
|
4667
5606
|
linkedProducts,
|
|
4668
5607
|
localPackageDirs: [
|
|
4669
|
-
...new Set(localPackageDirs.map((dir) =>
|
|
5608
|
+
...new Set(localPackageDirs.map((dir) => import_node_fs11.default.realpathSync(dir)))
|
|
4670
5609
|
].sort(),
|
|
4671
5610
|
binaryFrameworks: [...binaryFrameworks].sort(),
|
|
4672
|
-
packageResolved:
|
|
5611
|
+
packageResolved: import_node_fs11.default.existsSync(resolvedFile) ? resolvedFile : null,
|
|
4673
5612
|
appTargets: appTargetNames
|
|
4674
5613
|
};
|
|
4675
5614
|
}
|
|
@@ -4689,17 +5628,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
|
|
|
4689
5628
|
var NATIVE_DESCRIPTOR = ".one-native-source.json";
|
|
4690
5629
|
var NATIVE_GLUE = ".one-native-source.swift.txt";
|
|
4691
5630
|
function swiftPackageId(packagePath) {
|
|
4692
|
-
return
|
|
5631
|
+
return import_node_path14.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
4693
5632
|
}
|
|
4694
5633
|
function nativeSourceDescriptor(packagePath) {
|
|
4695
|
-
packagePath =
|
|
4696
|
-
const file =
|
|
4697
|
-
if (!
|
|
5634
|
+
packagePath = import_node_fs12.default.realpathSync(packagePath);
|
|
5635
|
+
const file = import_node_path14.default.join(packagePath, NATIVE_DESCRIPTOR);
|
|
5636
|
+
if (!import_node_fs12.default.existsSync(file)) return null;
|
|
4698
5637
|
const value = JSON.parse(
|
|
4699
5638
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
4700
5639
|
);
|
|
4701
5640
|
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" || !
|
|
5641
|
+
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
5642
|
throw invalid();
|
|
4704
5643
|
}
|
|
4705
5644
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -4708,12 +5647,12 @@ function nativeSourceDescriptor(packagePath) {
|
|
|
4708
5647
|
return value;
|
|
4709
5648
|
}
|
|
4710
5649
|
function nativeSourceFiles(packagePath) {
|
|
4711
|
-
packagePath =
|
|
4712
|
-
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name) =>
|
|
5650
|
+
packagePath = import_node_fs12.default.realpathSync(packagePath);
|
|
5651
|
+
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name) => import_node_path14.default.join(packagePath, name)).filter((file) => import_node_fs12.default.existsSync(file));
|
|
4713
5652
|
}
|
|
4714
5653
|
var projects = /* @__PURE__ */ new Map();
|
|
4715
5654
|
function projectFor(packagePath, hosted) {
|
|
4716
|
-
packagePath =
|
|
5655
|
+
packagePath = import_node_fs12.default.realpathSync(packagePath);
|
|
4717
5656
|
const existing = projects.get(packagePath);
|
|
4718
5657
|
if (existing) {
|
|
4719
5658
|
if (hosted && !existing.hosted) {
|
|
@@ -4735,53 +5674,67 @@ function projectFor(packagePath, hosted) {
|
|
|
4735
5674
|
}
|
|
4736
5675
|
var xcodeProjects = /* @__PURE__ */ new Map();
|
|
4737
5676
|
function swiftPackages(entry, app) {
|
|
4738
|
-
const stamp = (file) => file &&
|
|
4739
|
-
const
|
|
5677
|
+
const stamp = (file) => file && import_node_fs12.default.existsSync(file) ? import_node_fs12.default.statSync(file).mtimeMs : 0;
|
|
5678
|
+
const key2 = JSON.stringify([
|
|
4740
5679
|
app.linkedProducts,
|
|
4741
5680
|
app.packageResolved,
|
|
4742
5681
|
stamp(app.packageResolved),
|
|
4743
|
-
app.localPackageDirs.map((dir) => stamp(
|
|
5682
|
+
app.localPackageDirs.map((dir) => stamp(import_node_path14.default.join(dir, "Package.swift"))),
|
|
4744
5683
|
app.linkedProducts.map(
|
|
4745
|
-
({ source }) => source.kind === "local" ? stamp(
|
|
5684
|
+
({ source }) => source.kind === "local" ? stamp(import_node_path14.default.join(source.dir, "Package.swift")) : 0
|
|
4746
5685
|
)
|
|
4747
5686
|
]);
|
|
4748
|
-
if (entry.packages?.key !==
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
5687
|
+
if (entry.packages?.key !== key2) {
|
|
5688
|
+
const resolve2 = (provided, binaryGaps) => resolveSwiftPackages({
|
|
5689
|
+
rootDir: app.rootDir,
|
|
5690
|
+
resolved: app.packageResolved,
|
|
5691
|
+
products: app.linkedProducts,
|
|
5692
|
+
localDirs: app.localPackageDirs,
|
|
5693
|
+
provided,
|
|
5694
|
+
binaryGaps
|
|
5695
|
+
});
|
|
5696
|
+
let packages = resolve2(entry.provided);
|
|
5697
|
+
let standins = [];
|
|
5698
|
+
const reached = packages.binaries.filter((binary) => binary.reached);
|
|
5699
|
+
if (entry.moduleRoot && entry.provided && reached.length > 0) {
|
|
5700
|
+
const built2 = swiftStandins(reached, {
|
|
5701
|
+
moduleRoot: entry.moduleRoot,
|
|
5702
|
+
toolchainBin: swiftModuleToolchain(entry.moduleRoot).toolchainBin
|
|
5703
|
+
});
|
|
5704
|
+
standins = built2.standins;
|
|
5705
|
+
packages = resolve2(
|
|
5706
|
+
/* @__PURE__ */ new Set([...entry.provided, ...standins.map((standin) => standin.target)]),
|
|
5707
|
+
built2.gaps
|
|
5708
|
+
);
|
|
5709
|
+
}
|
|
5710
|
+
entry.packages = { key: key2, packages, standins };
|
|
4759
5711
|
}
|
|
4760
|
-
return entry.packages
|
|
5712
|
+
return entry.packages;
|
|
4761
5713
|
}
|
|
4762
5714
|
var XCODE_APP_DIR = "__app__";
|
|
4763
5715
|
var XCODE_FRAMEWORKS_DIR = "__frameworks__";
|
|
4764
5716
|
var XCODE_PACKAGES_DIR = "__packages__";
|
|
4765
|
-
var
|
|
5717
|
+
var XCODE_STANDINS_DIR = "__standins__";
|
|
5718
|
+
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep)}/`;
|
|
4766
5719
|
function xcodeInputKey(layout, file, relative) {
|
|
4767
5720
|
const owner = layout.targetDirs.get(file);
|
|
4768
|
-
if (owner) return
|
|
4769
|
-
return relative.startsWith(CHECKOUTS_PREFIX) ?
|
|
5721
|
+
if (owner) return import_node_path14.default.posix.join(owner, relative);
|
|
5722
|
+
return relative.startsWith(CHECKOUTS_PREFIX) ? import_node_path14.default.posix.join(XCODE_PACKAGES_DIR, relative.slice(CHECKOUTS_PREFIX.length)) : relative;
|
|
4770
5723
|
}
|
|
4771
5724
|
function xcodeLayout(root) {
|
|
4772
5725
|
const registered = xcodeProjects.get(root);
|
|
4773
5726
|
if (!registered) return null;
|
|
4774
5727
|
const app = readXcodeAppTarget(registered.xcodeproj, registered.target);
|
|
4775
|
-
const
|
|
4776
|
-
if (app.infoPlistFile)
|
|
5728
|
+
const files2 = /* @__PURE__ */ new Set([...app.projectFiles, ...app.sources, ...app.resources]);
|
|
5729
|
+
if (app.infoPlistFile) files2.add(app.infoPlistFile);
|
|
4777
5730
|
const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
|
|
4778
5731
|
const targets = [];
|
|
4779
5732
|
for (const framework of app.frameworks) {
|
|
4780
|
-
const dir =
|
|
5733
|
+
const dir = import_node_path14.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
|
|
4781
5734
|
for (const file of framework.sources) {
|
|
4782
5735
|
if (targetDirs.has(file)) continue;
|
|
4783
5736
|
targetDirs.set(file, dir);
|
|
4784
|
-
|
|
5737
|
+
files2.add(file);
|
|
4785
5738
|
}
|
|
4786
5739
|
targets.push({
|
|
4787
5740
|
name: framework.moduleName,
|
|
@@ -4793,22 +5746,32 @@ function xcodeLayout(root) {
|
|
|
4793
5746
|
mainActorIsolation: framework.mainActorIsolation
|
|
4794
5747
|
});
|
|
4795
5748
|
}
|
|
4796
|
-
const packages = swiftPackages(registered, app);
|
|
5749
|
+
const { packages, standins } = swiftPackages(registered, app);
|
|
5750
|
+
for (const standin of standins)
|
|
5751
|
+
targets.push({
|
|
5752
|
+
name: standin.module,
|
|
5753
|
+
path: import_node_path14.default.posix.join(XCODE_STANDINS_DIR, standin.module),
|
|
5754
|
+
executable: false,
|
|
5755
|
+
resources: false,
|
|
5756
|
+
exclude: [],
|
|
5757
|
+
languageMode: 5,
|
|
5758
|
+
mainActorIsolation: false
|
|
5759
|
+
});
|
|
4797
5760
|
for (const target of packages.targets) {
|
|
4798
|
-
const relative =
|
|
4799
|
-
target.remote ?
|
|
5761
|
+
const relative = import_node_path14.default.relative(
|
|
5762
|
+
target.remote ? import_node_path14.default.join(root, REMOTE_CHECKOUTS) : root,
|
|
4800
5763
|
target.dir
|
|
4801
5764
|
);
|
|
4802
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
5765
|
+
if (relative === ".." || relative.startsWith(`..${import_node_path14.default.sep}`) || import_node_path14.default.isAbsolute(relative))
|
|
4803
5766
|
throw new Error(`swift input escapes the selected package: ${target.dir}`);
|
|
4804
|
-
const posix = relative.split(
|
|
5767
|
+
const posix = relative.split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep);
|
|
4805
5768
|
targets.push({
|
|
4806
5769
|
...target,
|
|
4807
|
-
path: target.remote ?
|
|
5770
|
+
path: target.remote ? import_node_path14.default.posix.join(XCODE_PACKAGES_DIR, posix) : posix,
|
|
4808
5771
|
exclude: []
|
|
4809
5772
|
});
|
|
4810
|
-
if (!target.remote)
|
|
4811
|
-
for (const file of target.files)
|
|
5773
|
+
if (!target.remote) files2.add(import_node_path14.default.join(target.packageDir, "Package.swift"));
|
|
5774
|
+
for (const file of target.files) files2.add(file);
|
|
4812
5775
|
}
|
|
4813
5776
|
for (const target of targets) {
|
|
4814
5777
|
target.exclude = targets.filter((other) => other.path.startsWith(`${target.path}/`)).map((other) => other.path.slice(target.path.length + 1));
|
|
@@ -4817,8 +5780,9 @@ function xcodeLayout(root) {
|
|
|
4817
5780
|
app,
|
|
4818
5781
|
targets,
|
|
4819
5782
|
packages,
|
|
5783
|
+
standins,
|
|
4820
5784
|
targetDirs,
|
|
4821
|
-
files: [...
|
|
5785
|
+
files: [...files2].sort()
|
|
4822
5786
|
};
|
|
4823
5787
|
}
|
|
4824
5788
|
function xcodeManifest(layout) {
|
|
@@ -4836,25 +5800,25 @@ function xcodeManifest(layout) {
|
|
|
4836
5800
|
].join("\n");
|
|
4837
5801
|
}
|
|
4838
5802
|
function packageFiles(root) {
|
|
4839
|
-
const canonicalRoot =
|
|
5803
|
+
const canonicalRoot = import_node_fs12.default.realpathSync(root);
|
|
4840
5804
|
const xcode = xcodeLayout(canonicalRoot);
|
|
4841
5805
|
return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
|
|
4842
5806
|
}
|
|
4843
5807
|
function sourceTreeFiles(dir, canonicalRoot) {
|
|
4844
5808
|
const found = [];
|
|
4845
5809
|
const walk2 = (dir2) => {
|
|
4846
|
-
for (const entry of
|
|
5810
|
+
for (const entry of import_node_fs12.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
4847
5811
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
4848
5812
|
continue;
|
|
4849
|
-
const full =
|
|
5813
|
+
const full = import_node_path14.default.join(dir2, entry.name);
|
|
4850
5814
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
4851
|
-
const real =
|
|
4852
|
-
const relative =
|
|
4853
|
-
if (relative.startsWith(`..${
|
|
5815
|
+
const real = import_node_fs12.default.realpathSync(full);
|
|
5816
|
+
const relative = import_node_path14.default.relative(canonicalRoot, real);
|
|
5817
|
+
if (relative.startsWith(`..${import_node_path14.default.sep}`) || relative === ".." || import_node_path14.default.isAbsolute(relative)) {
|
|
4854
5818
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
4855
5819
|
}
|
|
4856
5820
|
if (entry.isDirectory()) {
|
|
4857
|
-
if (
|
|
5821
|
+
if (import_node_fs12.default.existsSync(import_node_path14.default.join(full, "Package.swift"))) continue;
|
|
4858
5822
|
walk2(full);
|
|
4859
5823
|
} else if (entry.isFile()) {
|
|
4860
5824
|
found.push(full);
|
|
@@ -4862,29 +5826,29 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
4862
5826
|
}
|
|
4863
5827
|
}
|
|
4864
5828
|
};
|
|
4865
|
-
if (
|
|
5829
|
+
if (import_node_fs12.default.existsSync(dir)) walk2(import_node_fs12.default.realpathSync(dir));
|
|
4866
5830
|
return found;
|
|
4867
5831
|
}
|
|
4868
5832
|
function readPackageFile(root, file, maxBytes) {
|
|
4869
|
-
const canonicalRoot =
|
|
4870
|
-
const relative =
|
|
4871
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
5833
|
+
const canonicalRoot = import_node_fs12.default.realpathSync(root);
|
|
5834
|
+
const relative = import_node_path14.default.relative(canonicalRoot, import_node_fs12.default.realpathSync(file));
|
|
5835
|
+
if (relative === ".." || relative.startsWith(`..${import_node_path14.default.sep}`) || import_node_path14.default.isAbsolute(relative)) {
|
|
4872
5836
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
4873
5837
|
}
|
|
4874
|
-
let ancestor =
|
|
5838
|
+
let ancestor = import_node_path14.default.resolve(file);
|
|
4875
5839
|
while (ancestor !== canonicalRoot) {
|
|
4876
|
-
if (
|
|
5840
|
+
if (import_node_fs12.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
4877
5841
|
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
4878
5842
|
}
|
|
4879
|
-
const parent =
|
|
5843
|
+
const parent = import_node_path14.default.dirname(ancestor);
|
|
4880
5844
|
if (parent === ancestor)
|
|
4881
5845
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
4882
5846
|
ancestor = parent;
|
|
4883
5847
|
}
|
|
4884
|
-
const expected =
|
|
4885
|
-
const fd =
|
|
5848
|
+
const expected = import_node_fs12.default.statSync(file);
|
|
5849
|
+
const fd = import_node_fs12.default.openSync(file, import_node_fs12.default.constants.O_RDONLY | import_node_fs12.default.constants.O_NOFOLLOW);
|
|
4886
5850
|
try {
|
|
4887
|
-
const stat =
|
|
5851
|
+
const stat = import_node_fs12.default.fstatSync(fd);
|
|
4888
5852
|
if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
|
|
4889
5853
|
throw new Error(`swift input changed while opening: ${file}`);
|
|
4890
5854
|
}
|
|
@@ -4894,16 +5858,16 @@ function readPackageFile(root, file, maxBytes) {
|
|
|
4894
5858
|
const bytes = Buffer.alloc(stat.size + 1);
|
|
4895
5859
|
let offset = 0;
|
|
4896
5860
|
while (offset < bytes.length) {
|
|
4897
|
-
const count =
|
|
5861
|
+
const count = import_node_fs12.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
4898
5862
|
if (count === 0) break;
|
|
4899
5863
|
offset += count;
|
|
4900
5864
|
}
|
|
4901
|
-
if (offset !== stat.size ||
|
|
5865
|
+
if (offset !== stat.size || import_node_fs12.default.fstatSync(fd).size !== stat.size) {
|
|
4902
5866
|
throw new Error(`swift input changed while reading: ${file}`);
|
|
4903
5867
|
}
|
|
4904
5868
|
return bytes.subarray(0, offset);
|
|
4905
5869
|
} finally {
|
|
4906
|
-
|
|
5870
|
+
import_node_fs12.default.closeSync(fd);
|
|
4907
5871
|
}
|
|
4908
5872
|
}
|
|
4909
5873
|
function sourceFiles(root) {
|
|
@@ -4911,7 +5875,7 @@ function sourceFiles(root) {
|
|
|
4911
5875
|
}
|
|
4912
5876
|
function resourceCandidateFiles(root) {
|
|
4913
5877
|
return packageFiles(root).filter(
|
|
4914
|
-
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(
|
|
5878
|
+
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path14.default.basename(file))
|
|
4915
5879
|
);
|
|
4916
5880
|
}
|
|
4917
5881
|
var HOSTED_LIMITS = {
|
|
@@ -4945,7 +5909,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
4945
5909
|
const limits = inputLimits(Boolean(project.hosted));
|
|
4946
5910
|
const absolute = resourceCandidateFiles(project.packagePath);
|
|
4947
5911
|
const relative = absolute.map(
|
|
4948
|
-
(file) =>
|
|
5912
|
+
(file) => import_node_path14.default.relative(project.packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep)
|
|
4949
5913
|
);
|
|
4950
5914
|
const byRelative = new Map(absolute.map((file, index) => [relative[index], file]));
|
|
4951
5915
|
const readContents = (candidate) => {
|
|
@@ -4967,16 +5931,16 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
4967
5931
|
for (const { name, file, scale } of found) {
|
|
4968
5932
|
const disk = byRelative.get(file);
|
|
4969
5933
|
if (!disk) continue;
|
|
4970
|
-
if (Object.keys(images).length >= limits.images || imageBytes +
|
|
5934
|
+
if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs12.default.statSync(disk).size > limits.imageTotalBytes) {
|
|
4971
5935
|
throw new Error("swift image pack exceeds the compile service caps");
|
|
4972
5936
|
}
|
|
4973
5937
|
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
4974
5938
|
imageBytes += bytes.length;
|
|
4975
|
-
const hash = (0,
|
|
4976
|
-
const ext =
|
|
5939
|
+
const hash = (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
|
|
5940
|
+
const ext = import_node_path14.default.posix.extname(file).toLowerCase();
|
|
4977
5941
|
table[name] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
4978
5942
|
images[name] = {
|
|
4979
|
-
file:
|
|
5943
|
+
file: import_node_path14.default.posix.basename(file),
|
|
4980
5944
|
data: bytes.toString("base64")
|
|
4981
5945
|
};
|
|
4982
5946
|
watched.push(file);
|
|
@@ -4992,7 +5956,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
4992
5956
|
watched.push(file);
|
|
4993
5957
|
}
|
|
4994
5958
|
if (registered.size !== project.resourceFiles.size || [...registered].some(
|
|
4995
|
-
([
|
|
5959
|
+
([key2, value]) => !project.resourceFiles.get(key2)?.bytes.equals(value.bytes)
|
|
4996
5960
|
)) {
|
|
4997
5961
|
project.resourcesPrevious = project.resourceFiles;
|
|
4998
5962
|
project.resourceFiles = registered;
|
|
@@ -5000,12 +5964,12 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
5000
5964
|
return { table, images, colors, symbols, watched };
|
|
5001
5965
|
}
|
|
5002
5966
|
function buildSwiftBundleFiles(packagePath, hosted) {
|
|
5003
|
-
packagePath =
|
|
5967
|
+
packagePath = import_node_fs12.default.realpathSync(packagePath);
|
|
5004
5968
|
const limits = inputLimits(hosted);
|
|
5005
5969
|
const relative = resourceCandidateFiles(packagePath).map(
|
|
5006
|
-
(file) =>
|
|
5970
|
+
(file) => import_node_path14.default.relative(packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep)
|
|
5007
5971
|
);
|
|
5008
|
-
const
|
|
5972
|
+
const files2 = {};
|
|
5009
5973
|
const watched = [];
|
|
5010
5974
|
let total = 0;
|
|
5011
5975
|
const xcode = xcodeLayout(packagePath);
|
|
@@ -5013,37 +5977,37 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
5013
5977
|
const bytes = Buffer.from(xcode.app.infoPlist);
|
|
5014
5978
|
if (bytes.length > limits.resourceBytes || bytes.length > limits.resourceTotalBytes)
|
|
5015
5979
|
throw new Error("swift launch Info.plist exceeds bundle resource limits");
|
|
5016
|
-
|
|
5980
|
+
files2["Info.plist"] = bytes.toString("base64");
|
|
5017
5981
|
total += bytes.length;
|
|
5018
5982
|
if (xcode.app.infoPlistFile)
|
|
5019
5983
|
watched.push(
|
|
5020
|
-
|
|
5984
|
+
import_node_path14.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path14.default.sep).join("/")
|
|
5021
5985
|
);
|
|
5022
5986
|
}
|
|
5023
5987
|
for (const { base, file } of enumerateBundleJson(relative)) {
|
|
5024
5988
|
watched.push(file);
|
|
5025
|
-
const disk =
|
|
5026
|
-
if (Object.keys(
|
|
5989
|
+
const disk = import_node_path14.default.join(packagePath, ...file.split("/"));
|
|
5990
|
+
if (Object.keys(files2).length >= limits.resources || total + import_node_fs12.default.statSync(disk).size > limits.resourceTotalBytes) {
|
|
5027
5991
|
throw new Error(
|
|
5028
5992
|
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
5029
5993
|
);
|
|
5030
5994
|
}
|
|
5031
5995
|
const bytes = readPackageFile(packagePath, disk, limits.resourceBytes);
|
|
5032
|
-
|
|
5996
|
+
files2[base] = bytes.toString("base64");
|
|
5033
5997
|
total += bytes.length;
|
|
5034
5998
|
}
|
|
5035
|
-
return { files, watched };
|
|
5999
|
+
return { files: files2, watched };
|
|
5036
6000
|
}
|
|
5037
|
-
function serveSwiftResource(project,
|
|
5038
|
-
return project.resourceFiles.get(
|
|
6001
|
+
function serveSwiftResource(project, key2) {
|
|
6002
|
+
return project.resourceFiles.get(key2) ?? project.resourcesPrevious.get(key2) ?? null;
|
|
5039
6003
|
}
|
|
5040
6004
|
function linkedModuleRoots(packagePath) {
|
|
5041
|
-
packagePath =
|
|
6005
|
+
packagePath = import_node_fs12.default.realpathSync(packagePath);
|
|
5042
6006
|
let manifest;
|
|
5043
6007
|
try {
|
|
5044
6008
|
manifest = readPackageFile(
|
|
5045
6009
|
packagePath,
|
|
5046
|
-
|
|
6010
|
+
import_node_path14.default.join(packagePath, "Package.swift"),
|
|
5047
6011
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
5048
6012
|
).toString("utf8");
|
|
5049
6013
|
} catch {
|
|
@@ -5052,62 +6016,67 @@ function linkedModuleRoots(packagePath) {
|
|
|
5052
6016
|
const roots = /* @__PURE__ */ new Set();
|
|
5053
6017
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
5054
6018
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
5055
|
-
const root =
|
|
5056
|
-
if (
|
|
6019
|
+
const root = import_node_path14.default.resolve(packagePath, match[1]);
|
|
6020
|
+
if (import_node_fs12.default.existsSync(import_node_path14.default.join(root, "Package.swift"))) roots.add(root);
|
|
5057
6021
|
}
|
|
5058
6022
|
return [...roots].sort();
|
|
5059
6023
|
}
|
|
5060
6024
|
function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
5061
|
-
const hash = (0,
|
|
6025
|
+
const hash = (0, import_node_crypto7.createHash)("sha256");
|
|
5062
6026
|
hash.update(packagePath);
|
|
5063
6027
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
5064
6028
|
for (const file of [...projectInputs].sort()) {
|
|
5065
|
-
hash.update(
|
|
5066
|
-
const stat =
|
|
6029
|
+
hash.update(import_node_path14.default.relative(packagePath, file));
|
|
6030
|
+
const stat = import_node_fs12.default.statSync(file);
|
|
5067
6031
|
hash.update(`${stat.mtimeMs}/${stat.ctimeMs}/${stat.size}`);
|
|
5068
6032
|
}
|
|
5069
6033
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
5070
|
-
(root) =>
|
|
6034
|
+
(root) => import_node_fs12.default.existsSync(import_node_path14.default.join(root, "toolchain.json"))
|
|
5071
6035
|
);
|
|
5072
6036
|
if (moduleRoot) {
|
|
5073
6037
|
hash.update(moduleRoot);
|
|
5074
6038
|
for (const relative of swiftModuleInputFiles(moduleRoot)) {
|
|
5075
6039
|
hash.update(relative);
|
|
5076
|
-
hash.update(String(
|
|
6040
|
+
hash.update(String(import_node_fs12.default.statSync(import_node_path14.default.join(moduleRoot, relative)).mtimeMs));
|
|
5077
6041
|
}
|
|
5078
6042
|
}
|
|
5079
6043
|
return hash.digest("hex").slice(0, 16);
|
|
5080
6044
|
}
|
|
5081
6045
|
function entryRootId(packagePath, file) {
|
|
5082
|
-
const relative =
|
|
5083
|
-
return `${
|
|
6046
|
+
const relative = import_node_path14.default.relative(packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep);
|
|
6047
|
+
return `${import_node_path14.default.basename(packagePath)}${import_node_path14.default.posix.sep}${relative}`;
|
|
5084
6048
|
}
|
|
5085
6049
|
function icuUrl(origin, artifact) {
|
|
5086
6050
|
return "url" in artifact.icu ? artifact.icu.url : `${origin}${ICU_PATH}${artifact.icu.sha256}`;
|
|
5087
6051
|
}
|
|
5088
6052
|
function packageSources(packagePath) {
|
|
5089
6053
|
const xcode = xcodeLayout(packagePath);
|
|
5090
|
-
const
|
|
6054
|
+
const files2 = {};
|
|
5091
6055
|
for (const file of sourceFiles(packagePath)) {
|
|
5092
|
-
const relative =
|
|
5093
|
-
if (xcode &&
|
|
5094
|
-
|
|
6056
|
+
const relative = import_node_path14.default.relative(packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep);
|
|
6057
|
+
if (xcode && import_node_path14.default.basename(file) === "Package.swift") continue;
|
|
6058
|
+
files2[xcode ? xcodeInputKey(xcode, file, relative) : relative] = readPackageFile(
|
|
5095
6059
|
packagePath,
|
|
5096
6060
|
file,
|
|
5097
6061
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
5098
6062
|
).toString("utf8");
|
|
5099
6063
|
}
|
|
5100
|
-
if (xcode)
|
|
5101
|
-
|
|
6064
|
+
if (xcode) {
|
|
6065
|
+
files2["Package.swift"] = xcodeManifest(xcode);
|
|
6066
|
+
for (const standin of xcode.standins)
|
|
6067
|
+
for (const [file, text3] of Object.entries(standin.files))
|
|
6068
|
+
files2[import_node_path14.default.posix.join(XCODE_STANDINS_DIR, standin.module, file)] = text3;
|
|
6069
|
+
}
|
|
6070
|
+
return files2;
|
|
5102
6071
|
}
|
|
5103
6072
|
function packageSnapshot(project) {
|
|
5104
|
-
const
|
|
6073
|
+
const files2 = packageSources(project.packagePath);
|
|
5105
6074
|
const native = nativeSourceDescriptor(project.packagePath);
|
|
5106
6075
|
return {
|
|
5107
|
-
files,
|
|
6076
|
+
files: files2,
|
|
5108
6077
|
resourcePaths: swiftImplicitResourcePaths(
|
|
5109
6078
|
resourceCandidateFiles(project.packagePath).map(
|
|
5110
|
-
(file) =>
|
|
6079
|
+
(file) => import_node_path14.default.relative(project.packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep)
|
|
5111
6080
|
)
|
|
5112
6081
|
),
|
|
5113
6082
|
resources: buildSwiftResourceTable(project, ""),
|
|
@@ -5116,7 +6085,7 @@ function packageSnapshot(project) {
|
|
|
5116
6085
|
...native ? {
|
|
5117
6086
|
glue: readPackageFile(
|
|
5118
6087
|
project.packagePath,
|
|
5119
|
-
|
|
6088
|
+
import_node_path14.default.join(project.packagePath, NATIVE_GLUE),
|
|
5120
6089
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
5121
6090
|
).toString("utf8")
|
|
5122
6091
|
} : {}
|
|
@@ -5155,7 +6124,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
5155
6124
|
package: content
|
|
5156
6125
|
};
|
|
5157
6126
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
5158
|
-
(root) =>
|
|
6127
|
+
(root) => import_node_fs12.default.existsSync(import_node_path14.default.join(root, "toolchain.json"))
|
|
5159
6128
|
) ?? await swiftDistributionRoot();
|
|
5160
6129
|
if (!moduleRoot)
|
|
5161
6130
|
return {
|
|
@@ -5181,10 +6150,10 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
5181
6150
|
// server and a capture, or two checkouts) build each other's sources. so
|
|
5182
6151
|
// each app and module checkout gets its own root, which keeps the same
|
|
5183
6152
|
// app's incremental build across restarts.
|
|
5184
|
-
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ??
|
|
5185
|
-
|
|
6153
|
+
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path14.default.join(
|
|
6154
|
+
import_node_os8.default.tmpdir(),
|
|
5186
6155
|
"contrast-swift-build",
|
|
5187
|
-
(0,
|
|
6156
|
+
(0, import_node_crypto7.createHash)("sha256").update(`${moduleRoot}\0${import_node_path14.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
|
|
5188
6157
|
),
|
|
5189
6158
|
moduleRoot,
|
|
5190
6159
|
...toolchain
|
|
@@ -5223,21 +6192,21 @@ function swiftApiGapReport(output) {
|
|
|
5223
6192
|
const file = diagnostic[1].replace(new RegExp(`^(?:${XCODE_APP_DIR}|${XCODE_FRAMEWORKS_DIR}/[^/]+)/`), "").replace(new RegExp(`^${XCODE_PACKAGES_DIR}/`), "");
|
|
5224
6193
|
const message = diagnostic[4];
|
|
5225
6194
|
const rule = API_GAP_PATTERNS.find(([pattern]) => pattern.test(message));
|
|
5226
|
-
const
|
|
6195
|
+
const key2 = rule ? rule[1](rule[0].exec(message)) : message;
|
|
5227
6196
|
const table = rule ? gaps : other;
|
|
5228
|
-
const entry = table.get(
|
|
6197
|
+
const entry = table.get(key2) ?? { errors: 0, files: /* @__PURE__ */ new Set() };
|
|
5229
6198
|
entry.errors++;
|
|
5230
6199
|
entry.files.add(file);
|
|
5231
|
-
table.set(
|
|
6200
|
+
table.set(key2, entry);
|
|
5232
6201
|
}
|
|
5233
6202
|
if (gaps.size === 0) return null;
|
|
5234
6203
|
const rows = (table) => {
|
|
5235
6204
|
const sorted = [...table].sort(
|
|
5236
6205
|
([left, a], [right, b]) => b.errors - a.errors || left.localeCompare(right)
|
|
5237
6206
|
);
|
|
5238
|
-
const width = Math.min(48, Math.max(...sorted.map(([
|
|
6207
|
+
const width = Math.min(48, Math.max(...sorted.map(([key2]) => key2.length)));
|
|
5239
6208
|
return sorted.map(
|
|
5240
|
-
([
|
|
6209
|
+
([key2, entry]) => ` ${key2.padEnd(width)} ${String(entry.errors).padStart(3)} error${entry.errors === 1 ? " " : "s"} ${[...entry.files].sort().join(", ")}`
|
|
5241
6210
|
);
|
|
5242
6211
|
};
|
|
5243
6212
|
const errors = [...gaps.values()].reduce((sum, entry) => sum + entry.errors, 0);
|
|
@@ -5287,16 +6256,16 @@ async function missingModulesMessage(packagePath, missing) {
|
|
|
5287
6256
|
if (packaged.has(name))
|
|
5288
6257
|
gaps.set(name, {
|
|
5289
6258
|
source: binary.source,
|
|
5290
|
-
reason: `${binary.target} is a binary framework`
|
|
6259
|
+
reason: layout?.packages.modules.get(binary.target)?.reason ?? `${binary.target} is a binary framework`
|
|
5291
6260
|
});
|
|
5292
6261
|
})
|
|
5293
6262
|
);
|
|
5294
6263
|
const width = Math.max(...[...missing.keys()].map((name) => name.length));
|
|
5295
6264
|
return [
|
|
5296
6265
|
`Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
|
|
5297
|
-
...[...missing].map(([name,
|
|
6266
|
+
...[...missing].map(([name, files2]) => {
|
|
5298
6267
|
const gap = gaps.get(name);
|
|
5299
|
-
return ` ${name.padEnd(width)} ${
|
|
6268
|
+
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
6269
|
})
|
|
5301
6270
|
].join("\n");
|
|
5302
6271
|
}
|
|
@@ -5304,7 +6273,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
5304
6273
|
const auth = hosted ? null : resolveCliAuth();
|
|
5305
6274
|
if (!hosted && (!auth || auth.kind === "github")) {
|
|
5306
6275
|
throw new Error(
|
|
5307
|
-
`compiling ${
|
|
6276
|
+
`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
6277
|
);
|
|
5309
6278
|
}
|
|
5310
6279
|
const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
|
|
@@ -5320,10 +6289,10 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
5320
6289
|
});
|
|
5321
6290
|
if (!submit) throw new Error("swift compile: no credential to submit with");
|
|
5322
6291
|
const sources = Object.values(snapshot.files);
|
|
5323
|
-
const bytes = sources.reduce((total2,
|
|
6292
|
+
const bytes = sources.reduce((total2, text3) => total2 + Buffer.byteLength(text3), 0);
|
|
5324
6293
|
if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
|
|
5325
6294
|
throw new Error(
|
|
5326
|
-
`${
|
|
6295
|
+
`${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
6296
|
);
|
|
5328
6297
|
}
|
|
5329
6298
|
const descriptor = snapshot.native;
|
|
@@ -5342,7 +6311,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
5342
6311
|
);
|
|
5343
6312
|
if (descriptor && address.native?.hash !== descriptor.hash) {
|
|
5344
6313
|
throw new Error(
|
|
5345
|
-
`${
|
|
6314
|
+
`${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
6315
|
);
|
|
5347
6316
|
}
|
|
5348
6317
|
const response = await fetch(address.url, { signal });
|
|
@@ -5415,17 +6384,17 @@ function artifactFor(project, entry, moduleRoot) {
|
|
|
5415
6384
|
return fresh;
|
|
5416
6385
|
}
|
|
5417
6386
|
function swiftPackageWatchFiles(packagePath, moduleRoot) {
|
|
5418
|
-
packagePath =
|
|
6387
|
+
packagePath = import_node_fs12.default.realpathSync(packagePath);
|
|
5419
6388
|
return [
|
|
5420
|
-
...xcodeProjects.has(packagePath) ? [] : [
|
|
6389
|
+
...xcodeProjects.has(packagePath) ? [] : [import_node_path14.default.join(packagePath, "Package.swift")],
|
|
5421
6390
|
...sourceFiles(packagePath),
|
|
5422
6391
|
...nativeSourceFiles(packagePath),
|
|
5423
6392
|
...resourceCandidateFiles(packagePath),
|
|
5424
|
-
...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) =>
|
|
6393
|
+
...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) => import_node_path14.default.join(moduleRoot, file)) : []
|
|
5425
6394
|
];
|
|
5426
6395
|
}
|
|
5427
6396
|
async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin, hosted) {
|
|
5428
|
-
packagePath =
|
|
6397
|
+
packagePath = import_node_fs12.default.realpathSync(packagePath);
|
|
5429
6398
|
const mains = sourceFiles(packagePath).filter(
|
|
5430
6399
|
(file) => swiftApplicationEntry(
|
|
5431
6400
|
file,
|
|
@@ -5439,7 +6408,7 @@ async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin
|
|
|
5439
6408
|
);
|
|
5440
6409
|
}
|
|
5441
6410
|
const project = projectFor(packagePath, hosted);
|
|
5442
|
-
const entry = mains.length === 1 ?
|
|
6411
|
+
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
6412
|
([_file, names]) => names.length > 0
|
|
5444
6413
|
)?.[0];
|
|
5445
6414
|
if (!entry) throw new Error(`swift package ${packageName} has no native module source`);
|
|
@@ -5528,12 +6497,12 @@ function artifactUrl(project, artifact) {
|
|
|
5528
6497
|
return `${serverOrigin()}${ARTIFACT_PATH2}${artifact.hash}.wasm`;
|
|
5529
6498
|
}
|
|
5530
6499
|
function packageFor(file) {
|
|
5531
|
-
let dir =
|
|
6500
|
+
let dir = import_node_path15.default.dirname(file);
|
|
5532
6501
|
const stop = devServer?.config.root;
|
|
5533
6502
|
for (; ; ) {
|
|
5534
|
-
if (
|
|
5535
|
-
if (stop !== void 0 && dir === stop ||
|
|
5536
|
-
dir =
|
|
6503
|
+
if (import_node_fs13.default.existsSync(import_node_path15.default.join(dir, "Package.swift"))) return dir;
|
|
6504
|
+
if (stop !== void 0 && dir === stop || import_node_path15.default.dirname(dir) === dir) break;
|
|
6505
|
+
dir = import_node_path15.default.dirname(dir);
|
|
5537
6506
|
}
|
|
5538
6507
|
throw new Error(
|
|
5539
6508
|
`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 +6523,9 @@ function swiftPlugin(options = {}) {
|
|
|
5554
6523
|
if (!resolved) throw new Error(`cannot resolve swift source ${source}`);
|
|
5555
6524
|
let id = resolved.id;
|
|
5556
6525
|
if (importer && (source.startsWith("./") || source.startsWith("../"))) {
|
|
5557
|
-
const raw2 =
|
|
6526
|
+
const raw2 = import_node_path15.default.resolve(import_node_path15.default.dirname(importer.split("?")[0] ?? importer), source);
|
|
5558
6527
|
try {
|
|
5559
|
-
if (
|
|
6528
|
+
if (import_node_fs13.default.realpathSync(raw2) === import_node_fs13.default.realpathSync(resolved.id)) id = raw2;
|
|
5560
6529
|
} catch {
|
|
5561
6530
|
}
|
|
5562
6531
|
}
|
|
@@ -5565,22 +6534,22 @@ function swiftPlugin(options = {}) {
|
|
|
5565
6534
|
async load(id) {
|
|
5566
6535
|
if (!id.startsWith(VIRTUAL_PREFIX)) return null;
|
|
5567
6536
|
const file = id.slice(VIRTUAL_PREFIX.length);
|
|
5568
|
-
if (!
|
|
6537
|
+
if (!import_node_fs13.default.existsSync(file)) throw new Error(`swift source ${file} no longer exists`);
|
|
5569
6538
|
const packagePath = options.packagePath ?? packageFor(file);
|
|
5570
6539
|
const project = projectFor(packagePath);
|
|
5571
|
-
const entry =
|
|
6540
|
+
const entry = import_node_path15.default.relative(packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep);
|
|
5572
6541
|
for (const source of [
|
|
5573
6542
|
...sourceFiles(packagePath),
|
|
5574
6543
|
...nativeSourceFiles(packagePath)
|
|
5575
6544
|
])
|
|
5576
6545
|
this.addWatchFile(source);
|
|
5577
|
-
this.addWatchFile(
|
|
6546
|
+
this.addWatchFile(import_node_path15.default.join(packagePath, "Package.swift"));
|
|
5578
6547
|
const moduleRoot = linkedModuleRoots(packagePath).find(
|
|
5579
|
-
(root) =>
|
|
6548
|
+
(root) => import_node_fs13.default.existsSync(import_node_path15.default.join(root, "toolchain.json"))
|
|
5580
6549
|
);
|
|
5581
6550
|
if (moduleRoot)
|
|
5582
6551
|
for (const relative of swiftModuleInputFiles(moduleRoot))
|
|
5583
|
-
this.addWatchFile(
|
|
6552
|
+
this.addWatchFile(import_node_path15.default.join(moduleRoot, relative));
|
|
5584
6553
|
let artifact;
|
|
5585
6554
|
try {
|
|
5586
6555
|
artifact = await artifactFor(project, entry);
|
|
@@ -5599,7 +6568,7 @@ function swiftPlugin(options = {}) {
|
|
|
5599
6568
|
...artifact.package.resources.watched,
|
|
5600
6569
|
...artifact.package.bundleFiles.watched
|
|
5601
6570
|
])
|
|
5602
|
-
this.addWatchFile(
|
|
6571
|
+
this.addWatchFile(import_node_path15.default.join(packagePath, ...watched.split(import_node_path15.default.posix.sep)));
|
|
5603
6572
|
const colors = artifact.package.resources.colors;
|
|
5604
6573
|
const symbols = artifact.package.resources.symbols;
|
|
5605
6574
|
const bundleFiles = artifact.package.bundleFiles.files;
|