peachsim 0.1.780 → 0.1.782
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/commands/detox.ts +6 -2
- package/detox/expectations.ts +1 -1
- package/detox/gestures.ts +1 -1
- package/detox/index.ts +27 -3
- package/detox/navigation-lifecycle.ts +1 -1
- 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 +3533 -133
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +6781 -2442
- 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 +4664 -1266
- 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 +1114 -2
- 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 +9017 -366
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +2229 -583
- package/dist-lib/vite.cjs +38 -16
- package/package.json +1 -1
- package/skills/contrast/SKILL.md +2 -0
- package/src/one-widget-package.ts +202 -0
- package/src/oneWidgetContract.ts +16 -0
- package/src/swift-host.ts +56 -29
- package/src/swift-standin-emit.ts +471 -242
- package/src/swift-standins.ts +288 -40
- package/src/vite-plugin-one.ts +45 -17
- package/src/vite-plugin-swift.ts +2 -0
package/dist-lib/vite-swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.782 | (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;
|
|
@@ -11,8 +11,8 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
11
11
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
12
|
};
|
|
13
13
|
var __export = (target, all) => {
|
|
14
|
-
for (var
|
|
15
|
-
__defProp(target,
|
|
14
|
+
for (var name2 in all)
|
|
15
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
16
16
|
};
|
|
17
17
|
var __copyProps = (to, from, except, desc) => {
|
|
18
18
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -217,8 +217,8 @@ var require_build = __commonJS({
|
|
|
217
217
|
}
|
|
218
218
|
function walk_obj(next, next_child) {
|
|
219
219
|
var tag_type, i, prop;
|
|
220
|
-
var
|
|
221
|
-
if ("Undefined" ==
|
|
220
|
+
var name2 = type(next);
|
|
221
|
+
if ("Undefined" == name2) {
|
|
222
222
|
return;
|
|
223
223
|
} else if (Array.isArray(next)) {
|
|
224
224
|
next_child = next_child.ele("array");
|
|
@@ -227,7 +227,7 @@ var require_build = __commonJS({
|
|
|
227
227
|
}
|
|
228
228
|
} else if (Buffer.isBuffer(next)) {
|
|
229
229
|
next_child.ele("data").raw(next.toString("base64"));
|
|
230
|
-
} else if ("Object" ==
|
|
230
|
+
} else if ("Object" == name2) {
|
|
231
231
|
next_child = next_child.ele("dict");
|
|
232
232
|
for (prop in next) {
|
|
233
233
|
if (next.hasOwnProperty(prop)) {
|
|
@@ -235,22 +235,22 @@ var require_build = __commonJS({
|
|
|
235
235
|
walk_obj(next[prop], next_child);
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
|
-
} else if ("Number" ==
|
|
238
|
+
} else if ("Number" == name2) {
|
|
239
239
|
tag_type = next % 1 === 0 ? "integer" : "real";
|
|
240
240
|
next_child.ele(tag_type).txt(next.toString());
|
|
241
|
-
} else if ("BigInt" ==
|
|
241
|
+
} else if ("BigInt" == name2) {
|
|
242
242
|
next_child.ele("integer").txt(next);
|
|
243
|
-
} else if ("Date" ==
|
|
243
|
+
} else if ("Date" == name2) {
|
|
244
244
|
next_child.ele("date").txt(ISODateString(new Date(next)));
|
|
245
|
-
} else if ("Boolean" ==
|
|
245
|
+
} else if ("Boolean" == name2) {
|
|
246
246
|
next_child.ele(next ? "true" : "false");
|
|
247
|
-
} else if ("String" ==
|
|
247
|
+
} else if ("String" == name2) {
|
|
248
248
|
next_child.ele("string").txt(next);
|
|
249
|
-
} else if ("ArrayBuffer" ==
|
|
249
|
+
} else if ("ArrayBuffer" == name2) {
|
|
250
250
|
next_child.ele("data").raw(base64.fromByteArray(next));
|
|
251
251
|
} else if (next && next.buffer && "ArrayBuffer" == type(next.buffer)) {
|
|
252
252
|
next_child.ele("data").raw(base64.fromByteArray(new Uint8Array(next.buffer), next_child));
|
|
253
|
-
} else if ("Null" ===
|
|
253
|
+
} else if ("Null" === name2) {
|
|
254
254
|
next_child.ele("null").txt("");
|
|
255
255
|
}
|
|
256
256
|
}
|
|
@@ -271,14 +271,1128 @@ var require_plist = __commonJS({
|
|
|
271
271
|
}
|
|
272
272
|
});
|
|
273
273
|
|
|
274
|
+
// ../../node_modules/json5/lib/unicode.js
|
|
275
|
+
var require_unicode = __commonJS({
|
|
276
|
+
"../../node_modules/json5/lib/unicode.js"(exports2, module2) {
|
|
277
|
+
module2.exports.Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
|
|
278
|
+
module2.exports.ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/;
|
|
279
|
+
module2.exports.ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/;
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
// ../../node_modules/json5/lib/util.js
|
|
284
|
+
var require_util = __commonJS({
|
|
285
|
+
"../../node_modules/json5/lib/util.js"(exports2, module2) {
|
|
286
|
+
var unicode = require_unicode();
|
|
287
|
+
module2.exports = {
|
|
288
|
+
isSpaceSeparator(c) {
|
|
289
|
+
return typeof c === "string" && unicode.Space_Separator.test(c);
|
|
290
|
+
},
|
|
291
|
+
isIdStartChar(c) {
|
|
292
|
+
return typeof c === "string" && (c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c === "$" || c === "_" || unicode.ID_Start.test(c));
|
|
293
|
+
},
|
|
294
|
+
isIdContinueChar(c) {
|
|
295
|
+
return typeof c === "string" && (c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c >= "0" && c <= "9" || c === "$" || c === "_" || c === "\u200C" || c === "\u200D" || unicode.ID_Continue.test(c));
|
|
296
|
+
},
|
|
297
|
+
isDigit(c) {
|
|
298
|
+
return typeof c === "string" && /[0-9]/.test(c);
|
|
299
|
+
},
|
|
300
|
+
isHexDigit(c) {
|
|
301
|
+
return typeof c === "string" && /[0-9A-Fa-f]/.test(c);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
// ../../node_modules/json5/lib/parse.js
|
|
308
|
+
var require_parse2 = __commonJS({
|
|
309
|
+
"../../node_modules/json5/lib/parse.js"(exports2, module2) {
|
|
310
|
+
var util = require_util();
|
|
311
|
+
var source;
|
|
312
|
+
var parseState;
|
|
313
|
+
var stack;
|
|
314
|
+
var pos;
|
|
315
|
+
var line;
|
|
316
|
+
var column;
|
|
317
|
+
var token;
|
|
318
|
+
var key2;
|
|
319
|
+
var root;
|
|
320
|
+
module2.exports = function parse(text3, reviver) {
|
|
321
|
+
source = String(text3);
|
|
322
|
+
parseState = "start";
|
|
323
|
+
stack = [];
|
|
324
|
+
pos = 0;
|
|
325
|
+
line = 1;
|
|
326
|
+
column = 0;
|
|
327
|
+
token = void 0;
|
|
328
|
+
key2 = void 0;
|
|
329
|
+
root = void 0;
|
|
330
|
+
do {
|
|
331
|
+
token = lex();
|
|
332
|
+
parseStates[parseState]();
|
|
333
|
+
} while (token.type !== "eof");
|
|
334
|
+
if (typeof reviver === "function") {
|
|
335
|
+
return internalize({ "": root }, "", reviver);
|
|
336
|
+
}
|
|
337
|
+
return root;
|
|
338
|
+
};
|
|
339
|
+
function internalize(holder, name2, reviver) {
|
|
340
|
+
const value = holder[name2];
|
|
341
|
+
if (value != null && typeof value === "object") {
|
|
342
|
+
if (Array.isArray(value)) {
|
|
343
|
+
for (let i = 0; i < value.length; i++) {
|
|
344
|
+
const key3 = String(i);
|
|
345
|
+
const replacement = internalize(value, key3, reviver);
|
|
346
|
+
if (replacement === void 0) {
|
|
347
|
+
delete value[key3];
|
|
348
|
+
} else {
|
|
349
|
+
Object.defineProperty(value, key3, {
|
|
350
|
+
value: replacement,
|
|
351
|
+
writable: true,
|
|
352
|
+
enumerable: true,
|
|
353
|
+
configurable: true
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
} else {
|
|
358
|
+
for (const key3 in value) {
|
|
359
|
+
const replacement = internalize(value, key3, reviver);
|
|
360
|
+
if (replacement === void 0) {
|
|
361
|
+
delete value[key3];
|
|
362
|
+
} else {
|
|
363
|
+
Object.defineProperty(value, key3, {
|
|
364
|
+
value: replacement,
|
|
365
|
+
writable: true,
|
|
366
|
+
enumerable: true,
|
|
367
|
+
configurable: true
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return reviver.call(holder, name2, value);
|
|
374
|
+
}
|
|
375
|
+
var lexState;
|
|
376
|
+
var buffer;
|
|
377
|
+
var doubleQuote;
|
|
378
|
+
var sign;
|
|
379
|
+
var c;
|
|
380
|
+
function lex() {
|
|
381
|
+
lexState = "default";
|
|
382
|
+
buffer = "";
|
|
383
|
+
doubleQuote = false;
|
|
384
|
+
sign = 1;
|
|
385
|
+
for (; ; ) {
|
|
386
|
+
c = peek();
|
|
387
|
+
const token2 = lexStates[lexState]();
|
|
388
|
+
if (token2) {
|
|
389
|
+
return token2;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function peek() {
|
|
394
|
+
if (source[pos]) {
|
|
395
|
+
return String.fromCodePoint(source.codePointAt(pos));
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
function read() {
|
|
399
|
+
const c2 = peek();
|
|
400
|
+
if (c2 === "\n") {
|
|
401
|
+
line++;
|
|
402
|
+
column = 0;
|
|
403
|
+
} else if (c2) {
|
|
404
|
+
column += c2.length;
|
|
405
|
+
} else {
|
|
406
|
+
column++;
|
|
407
|
+
}
|
|
408
|
+
if (c2) {
|
|
409
|
+
pos += c2.length;
|
|
410
|
+
}
|
|
411
|
+
return c2;
|
|
412
|
+
}
|
|
413
|
+
var lexStates = {
|
|
414
|
+
default() {
|
|
415
|
+
switch (c) {
|
|
416
|
+
case " ":
|
|
417
|
+
case "\v":
|
|
418
|
+
case "\f":
|
|
419
|
+
case " ":
|
|
420
|
+
case "\xA0":
|
|
421
|
+
case "\uFEFF":
|
|
422
|
+
case "\n":
|
|
423
|
+
case "\r":
|
|
424
|
+
case "\u2028":
|
|
425
|
+
case "\u2029":
|
|
426
|
+
read();
|
|
427
|
+
return;
|
|
428
|
+
case "/":
|
|
429
|
+
read();
|
|
430
|
+
lexState = "comment";
|
|
431
|
+
return;
|
|
432
|
+
case void 0:
|
|
433
|
+
read();
|
|
434
|
+
return newToken("eof");
|
|
435
|
+
}
|
|
436
|
+
if (util.isSpaceSeparator(c)) {
|
|
437
|
+
read();
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
return lexStates[parseState]();
|
|
441
|
+
},
|
|
442
|
+
comment() {
|
|
443
|
+
switch (c) {
|
|
444
|
+
case "*":
|
|
445
|
+
read();
|
|
446
|
+
lexState = "multiLineComment";
|
|
447
|
+
return;
|
|
448
|
+
case "/":
|
|
449
|
+
read();
|
|
450
|
+
lexState = "singleLineComment";
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
throw invalidChar(read());
|
|
454
|
+
},
|
|
455
|
+
multiLineComment() {
|
|
456
|
+
switch (c) {
|
|
457
|
+
case "*":
|
|
458
|
+
read();
|
|
459
|
+
lexState = "multiLineCommentAsterisk";
|
|
460
|
+
return;
|
|
461
|
+
case void 0:
|
|
462
|
+
throw invalidChar(read());
|
|
463
|
+
}
|
|
464
|
+
read();
|
|
465
|
+
},
|
|
466
|
+
multiLineCommentAsterisk() {
|
|
467
|
+
switch (c) {
|
|
468
|
+
case "*":
|
|
469
|
+
read();
|
|
470
|
+
return;
|
|
471
|
+
case "/":
|
|
472
|
+
read();
|
|
473
|
+
lexState = "default";
|
|
474
|
+
return;
|
|
475
|
+
case void 0:
|
|
476
|
+
throw invalidChar(read());
|
|
477
|
+
}
|
|
478
|
+
read();
|
|
479
|
+
lexState = "multiLineComment";
|
|
480
|
+
},
|
|
481
|
+
singleLineComment() {
|
|
482
|
+
switch (c) {
|
|
483
|
+
case "\n":
|
|
484
|
+
case "\r":
|
|
485
|
+
case "\u2028":
|
|
486
|
+
case "\u2029":
|
|
487
|
+
read();
|
|
488
|
+
lexState = "default";
|
|
489
|
+
return;
|
|
490
|
+
case void 0:
|
|
491
|
+
read();
|
|
492
|
+
return newToken("eof");
|
|
493
|
+
}
|
|
494
|
+
read();
|
|
495
|
+
},
|
|
496
|
+
value() {
|
|
497
|
+
switch (c) {
|
|
498
|
+
case "{":
|
|
499
|
+
case "[":
|
|
500
|
+
return newToken("punctuator", read());
|
|
501
|
+
case "n":
|
|
502
|
+
read();
|
|
503
|
+
literal("ull");
|
|
504
|
+
return newToken("null", null);
|
|
505
|
+
case "t":
|
|
506
|
+
read();
|
|
507
|
+
literal("rue");
|
|
508
|
+
return newToken("boolean", true);
|
|
509
|
+
case "f":
|
|
510
|
+
read();
|
|
511
|
+
literal("alse");
|
|
512
|
+
return newToken("boolean", false);
|
|
513
|
+
case "-":
|
|
514
|
+
case "+":
|
|
515
|
+
if (read() === "-") {
|
|
516
|
+
sign = -1;
|
|
517
|
+
}
|
|
518
|
+
lexState = "sign";
|
|
519
|
+
return;
|
|
520
|
+
case ".":
|
|
521
|
+
buffer = read();
|
|
522
|
+
lexState = "decimalPointLeading";
|
|
523
|
+
return;
|
|
524
|
+
case "0":
|
|
525
|
+
buffer = read();
|
|
526
|
+
lexState = "zero";
|
|
527
|
+
return;
|
|
528
|
+
case "1":
|
|
529
|
+
case "2":
|
|
530
|
+
case "3":
|
|
531
|
+
case "4":
|
|
532
|
+
case "5":
|
|
533
|
+
case "6":
|
|
534
|
+
case "7":
|
|
535
|
+
case "8":
|
|
536
|
+
case "9":
|
|
537
|
+
buffer = read();
|
|
538
|
+
lexState = "decimalInteger";
|
|
539
|
+
return;
|
|
540
|
+
case "I":
|
|
541
|
+
read();
|
|
542
|
+
literal("nfinity");
|
|
543
|
+
return newToken("numeric", Infinity);
|
|
544
|
+
case "N":
|
|
545
|
+
read();
|
|
546
|
+
literal("aN");
|
|
547
|
+
return newToken("numeric", NaN);
|
|
548
|
+
case '"':
|
|
549
|
+
case "'":
|
|
550
|
+
doubleQuote = read() === '"';
|
|
551
|
+
buffer = "";
|
|
552
|
+
lexState = "string";
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
throw invalidChar(read());
|
|
556
|
+
},
|
|
557
|
+
identifierNameStartEscape() {
|
|
558
|
+
if (c !== "u") {
|
|
559
|
+
throw invalidChar(read());
|
|
560
|
+
}
|
|
561
|
+
read();
|
|
562
|
+
const u = unicodeEscape();
|
|
563
|
+
switch (u) {
|
|
564
|
+
case "$":
|
|
565
|
+
case "_":
|
|
566
|
+
break;
|
|
567
|
+
default:
|
|
568
|
+
if (!util.isIdStartChar(u)) {
|
|
569
|
+
throw invalidIdentifier();
|
|
570
|
+
}
|
|
571
|
+
break;
|
|
572
|
+
}
|
|
573
|
+
buffer += u;
|
|
574
|
+
lexState = "identifierName";
|
|
575
|
+
},
|
|
576
|
+
identifierName() {
|
|
577
|
+
switch (c) {
|
|
578
|
+
case "$":
|
|
579
|
+
case "_":
|
|
580
|
+
case "\u200C":
|
|
581
|
+
case "\u200D":
|
|
582
|
+
buffer += read();
|
|
583
|
+
return;
|
|
584
|
+
case "\\":
|
|
585
|
+
read();
|
|
586
|
+
lexState = "identifierNameEscape";
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
if (util.isIdContinueChar(c)) {
|
|
590
|
+
buffer += read();
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
return newToken("identifier", buffer);
|
|
594
|
+
},
|
|
595
|
+
identifierNameEscape() {
|
|
596
|
+
if (c !== "u") {
|
|
597
|
+
throw invalidChar(read());
|
|
598
|
+
}
|
|
599
|
+
read();
|
|
600
|
+
const u = unicodeEscape();
|
|
601
|
+
switch (u) {
|
|
602
|
+
case "$":
|
|
603
|
+
case "_":
|
|
604
|
+
case "\u200C":
|
|
605
|
+
case "\u200D":
|
|
606
|
+
break;
|
|
607
|
+
default:
|
|
608
|
+
if (!util.isIdContinueChar(u)) {
|
|
609
|
+
throw invalidIdentifier();
|
|
610
|
+
}
|
|
611
|
+
break;
|
|
612
|
+
}
|
|
613
|
+
buffer += u;
|
|
614
|
+
lexState = "identifierName";
|
|
615
|
+
},
|
|
616
|
+
sign() {
|
|
617
|
+
switch (c) {
|
|
618
|
+
case ".":
|
|
619
|
+
buffer = read();
|
|
620
|
+
lexState = "decimalPointLeading";
|
|
621
|
+
return;
|
|
622
|
+
case "0":
|
|
623
|
+
buffer = read();
|
|
624
|
+
lexState = "zero";
|
|
625
|
+
return;
|
|
626
|
+
case "1":
|
|
627
|
+
case "2":
|
|
628
|
+
case "3":
|
|
629
|
+
case "4":
|
|
630
|
+
case "5":
|
|
631
|
+
case "6":
|
|
632
|
+
case "7":
|
|
633
|
+
case "8":
|
|
634
|
+
case "9":
|
|
635
|
+
buffer = read();
|
|
636
|
+
lexState = "decimalInteger";
|
|
637
|
+
return;
|
|
638
|
+
case "I":
|
|
639
|
+
read();
|
|
640
|
+
literal("nfinity");
|
|
641
|
+
return newToken("numeric", sign * Infinity);
|
|
642
|
+
case "N":
|
|
643
|
+
read();
|
|
644
|
+
literal("aN");
|
|
645
|
+
return newToken("numeric", NaN);
|
|
646
|
+
}
|
|
647
|
+
throw invalidChar(read());
|
|
648
|
+
},
|
|
649
|
+
zero() {
|
|
650
|
+
switch (c) {
|
|
651
|
+
case ".":
|
|
652
|
+
buffer += read();
|
|
653
|
+
lexState = "decimalPoint";
|
|
654
|
+
return;
|
|
655
|
+
case "e":
|
|
656
|
+
case "E":
|
|
657
|
+
buffer += read();
|
|
658
|
+
lexState = "decimalExponent";
|
|
659
|
+
return;
|
|
660
|
+
case "x":
|
|
661
|
+
case "X":
|
|
662
|
+
buffer += read();
|
|
663
|
+
lexState = "hexadecimal";
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
return newToken("numeric", sign * 0);
|
|
667
|
+
},
|
|
668
|
+
decimalInteger() {
|
|
669
|
+
switch (c) {
|
|
670
|
+
case ".":
|
|
671
|
+
buffer += read();
|
|
672
|
+
lexState = "decimalPoint";
|
|
673
|
+
return;
|
|
674
|
+
case "e":
|
|
675
|
+
case "E":
|
|
676
|
+
buffer += read();
|
|
677
|
+
lexState = "decimalExponent";
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
if (util.isDigit(c)) {
|
|
681
|
+
buffer += read();
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
return newToken("numeric", sign * Number(buffer));
|
|
685
|
+
},
|
|
686
|
+
decimalPointLeading() {
|
|
687
|
+
if (util.isDigit(c)) {
|
|
688
|
+
buffer += read();
|
|
689
|
+
lexState = "decimalFraction";
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
throw invalidChar(read());
|
|
693
|
+
},
|
|
694
|
+
decimalPoint() {
|
|
695
|
+
switch (c) {
|
|
696
|
+
case "e":
|
|
697
|
+
case "E":
|
|
698
|
+
buffer += read();
|
|
699
|
+
lexState = "decimalExponent";
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
if (util.isDigit(c)) {
|
|
703
|
+
buffer += read();
|
|
704
|
+
lexState = "decimalFraction";
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
return newToken("numeric", sign * Number(buffer));
|
|
708
|
+
},
|
|
709
|
+
decimalFraction() {
|
|
710
|
+
switch (c) {
|
|
711
|
+
case "e":
|
|
712
|
+
case "E":
|
|
713
|
+
buffer += read();
|
|
714
|
+
lexState = "decimalExponent";
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
if (util.isDigit(c)) {
|
|
718
|
+
buffer += read();
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
return newToken("numeric", sign * Number(buffer));
|
|
722
|
+
},
|
|
723
|
+
decimalExponent() {
|
|
724
|
+
switch (c) {
|
|
725
|
+
case "+":
|
|
726
|
+
case "-":
|
|
727
|
+
buffer += read();
|
|
728
|
+
lexState = "decimalExponentSign";
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
if (util.isDigit(c)) {
|
|
732
|
+
buffer += read();
|
|
733
|
+
lexState = "decimalExponentInteger";
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
throw invalidChar(read());
|
|
737
|
+
},
|
|
738
|
+
decimalExponentSign() {
|
|
739
|
+
if (util.isDigit(c)) {
|
|
740
|
+
buffer += read();
|
|
741
|
+
lexState = "decimalExponentInteger";
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
throw invalidChar(read());
|
|
745
|
+
},
|
|
746
|
+
decimalExponentInteger() {
|
|
747
|
+
if (util.isDigit(c)) {
|
|
748
|
+
buffer += read();
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
return newToken("numeric", sign * Number(buffer));
|
|
752
|
+
},
|
|
753
|
+
hexadecimal() {
|
|
754
|
+
if (util.isHexDigit(c)) {
|
|
755
|
+
buffer += read();
|
|
756
|
+
lexState = "hexadecimalInteger";
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
throw invalidChar(read());
|
|
760
|
+
},
|
|
761
|
+
hexadecimalInteger() {
|
|
762
|
+
if (util.isHexDigit(c)) {
|
|
763
|
+
buffer += read();
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
return newToken("numeric", sign * Number(buffer));
|
|
767
|
+
},
|
|
768
|
+
string() {
|
|
769
|
+
switch (c) {
|
|
770
|
+
case "\\":
|
|
771
|
+
read();
|
|
772
|
+
buffer += escape();
|
|
773
|
+
return;
|
|
774
|
+
case '"':
|
|
775
|
+
if (doubleQuote) {
|
|
776
|
+
read();
|
|
777
|
+
return newToken("string", buffer);
|
|
778
|
+
}
|
|
779
|
+
buffer += read();
|
|
780
|
+
return;
|
|
781
|
+
case "'":
|
|
782
|
+
if (!doubleQuote) {
|
|
783
|
+
read();
|
|
784
|
+
return newToken("string", buffer);
|
|
785
|
+
}
|
|
786
|
+
buffer += read();
|
|
787
|
+
return;
|
|
788
|
+
case "\n":
|
|
789
|
+
case "\r":
|
|
790
|
+
throw invalidChar(read());
|
|
791
|
+
case "\u2028":
|
|
792
|
+
case "\u2029":
|
|
793
|
+
separatorChar(c);
|
|
794
|
+
break;
|
|
795
|
+
case void 0:
|
|
796
|
+
throw invalidChar(read());
|
|
797
|
+
}
|
|
798
|
+
buffer += read();
|
|
799
|
+
},
|
|
800
|
+
start() {
|
|
801
|
+
switch (c) {
|
|
802
|
+
case "{":
|
|
803
|
+
case "[":
|
|
804
|
+
return newToken("punctuator", read());
|
|
805
|
+
}
|
|
806
|
+
lexState = "value";
|
|
807
|
+
},
|
|
808
|
+
beforePropertyName() {
|
|
809
|
+
switch (c) {
|
|
810
|
+
case "$":
|
|
811
|
+
case "_":
|
|
812
|
+
buffer = read();
|
|
813
|
+
lexState = "identifierName";
|
|
814
|
+
return;
|
|
815
|
+
case "\\":
|
|
816
|
+
read();
|
|
817
|
+
lexState = "identifierNameStartEscape";
|
|
818
|
+
return;
|
|
819
|
+
case "}":
|
|
820
|
+
return newToken("punctuator", read());
|
|
821
|
+
case '"':
|
|
822
|
+
case "'":
|
|
823
|
+
doubleQuote = read() === '"';
|
|
824
|
+
lexState = "string";
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
if (util.isIdStartChar(c)) {
|
|
828
|
+
buffer += read();
|
|
829
|
+
lexState = "identifierName";
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
throw invalidChar(read());
|
|
833
|
+
},
|
|
834
|
+
afterPropertyName() {
|
|
835
|
+
if (c === ":") {
|
|
836
|
+
return newToken("punctuator", read());
|
|
837
|
+
}
|
|
838
|
+
throw invalidChar(read());
|
|
839
|
+
},
|
|
840
|
+
beforePropertyValue() {
|
|
841
|
+
lexState = "value";
|
|
842
|
+
},
|
|
843
|
+
afterPropertyValue() {
|
|
844
|
+
switch (c) {
|
|
845
|
+
case ",":
|
|
846
|
+
case "}":
|
|
847
|
+
return newToken("punctuator", read());
|
|
848
|
+
}
|
|
849
|
+
throw invalidChar(read());
|
|
850
|
+
},
|
|
851
|
+
beforeArrayValue() {
|
|
852
|
+
if (c === "]") {
|
|
853
|
+
return newToken("punctuator", read());
|
|
854
|
+
}
|
|
855
|
+
lexState = "value";
|
|
856
|
+
},
|
|
857
|
+
afterArrayValue() {
|
|
858
|
+
switch (c) {
|
|
859
|
+
case ",":
|
|
860
|
+
case "]":
|
|
861
|
+
return newToken("punctuator", read());
|
|
862
|
+
}
|
|
863
|
+
throw invalidChar(read());
|
|
864
|
+
},
|
|
865
|
+
end() {
|
|
866
|
+
throw invalidChar(read());
|
|
867
|
+
}
|
|
868
|
+
};
|
|
869
|
+
function newToken(type, value) {
|
|
870
|
+
return {
|
|
871
|
+
type,
|
|
872
|
+
value,
|
|
873
|
+
line,
|
|
874
|
+
column
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
function literal(s) {
|
|
878
|
+
for (const c2 of s) {
|
|
879
|
+
const p = peek();
|
|
880
|
+
if (p !== c2) {
|
|
881
|
+
throw invalidChar(read());
|
|
882
|
+
}
|
|
883
|
+
read();
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
function escape() {
|
|
887
|
+
const c2 = peek();
|
|
888
|
+
switch (c2) {
|
|
889
|
+
case "b":
|
|
890
|
+
read();
|
|
891
|
+
return "\b";
|
|
892
|
+
case "f":
|
|
893
|
+
read();
|
|
894
|
+
return "\f";
|
|
895
|
+
case "n":
|
|
896
|
+
read();
|
|
897
|
+
return "\n";
|
|
898
|
+
case "r":
|
|
899
|
+
read();
|
|
900
|
+
return "\r";
|
|
901
|
+
case "t":
|
|
902
|
+
read();
|
|
903
|
+
return " ";
|
|
904
|
+
case "v":
|
|
905
|
+
read();
|
|
906
|
+
return "\v";
|
|
907
|
+
case "0":
|
|
908
|
+
read();
|
|
909
|
+
if (util.isDigit(peek())) {
|
|
910
|
+
throw invalidChar(read());
|
|
911
|
+
}
|
|
912
|
+
return "\0";
|
|
913
|
+
case "x":
|
|
914
|
+
read();
|
|
915
|
+
return hexEscape();
|
|
916
|
+
case "u":
|
|
917
|
+
read();
|
|
918
|
+
return unicodeEscape();
|
|
919
|
+
case "\n":
|
|
920
|
+
case "\u2028":
|
|
921
|
+
case "\u2029":
|
|
922
|
+
read();
|
|
923
|
+
return "";
|
|
924
|
+
case "\r":
|
|
925
|
+
read();
|
|
926
|
+
if (peek() === "\n") {
|
|
927
|
+
read();
|
|
928
|
+
}
|
|
929
|
+
return "";
|
|
930
|
+
case "1":
|
|
931
|
+
case "2":
|
|
932
|
+
case "3":
|
|
933
|
+
case "4":
|
|
934
|
+
case "5":
|
|
935
|
+
case "6":
|
|
936
|
+
case "7":
|
|
937
|
+
case "8":
|
|
938
|
+
case "9":
|
|
939
|
+
throw invalidChar(read());
|
|
940
|
+
case void 0:
|
|
941
|
+
throw invalidChar(read());
|
|
942
|
+
}
|
|
943
|
+
return read();
|
|
944
|
+
}
|
|
945
|
+
function hexEscape() {
|
|
946
|
+
let buffer2 = "";
|
|
947
|
+
let c2 = peek();
|
|
948
|
+
if (!util.isHexDigit(c2)) {
|
|
949
|
+
throw invalidChar(read());
|
|
950
|
+
}
|
|
951
|
+
buffer2 += read();
|
|
952
|
+
c2 = peek();
|
|
953
|
+
if (!util.isHexDigit(c2)) {
|
|
954
|
+
throw invalidChar(read());
|
|
955
|
+
}
|
|
956
|
+
buffer2 += read();
|
|
957
|
+
return String.fromCodePoint(parseInt(buffer2, 16));
|
|
958
|
+
}
|
|
959
|
+
function unicodeEscape() {
|
|
960
|
+
let buffer2 = "";
|
|
961
|
+
let count = 4;
|
|
962
|
+
while (count-- > 0) {
|
|
963
|
+
const c2 = peek();
|
|
964
|
+
if (!util.isHexDigit(c2)) {
|
|
965
|
+
throw invalidChar(read());
|
|
966
|
+
}
|
|
967
|
+
buffer2 += read();
|
|
968
|
+
}
|
|
969
|
+
return String.fromCodePoint(parseInt(buffer2, 16));
|
|
970
|
+
}
|
|
971
|
+
var parseStates = {
|
|
972
|
+
start() {
|
|
973
|
+
if (token.type === "eof") {
|
|
974
|
+
throw invalidEOF();
|
|
975
|
+
}
|
|
976
|
+
push();
|
|
977
|
+
},
|
|
978
|
+
beforePropertyName() {
|
|
979
|
+
switch (token.type) {
|
|
980
|
+
case "identifier":
|
|
981
|
+
case "string":
|
|
982
|
+
key2 = token.value;
|
|
983
|
+
parseState = "afterPropertyName";
|
|
984
|
+
return;
|
|
985
|
+
case "punctuator":
|
|
986
|
+
pop();
|
|
987
|
+
return;
|
|
988
|
+
case "eof":
|
|
989
|
+
throw invalidEOF();
|
|
990
|
+
}
|
|
991
|
+
},
|
|
992
|
+
afterPropertyName() {
|
|
993
|
+
if (token.type === "eof") {
|
|
994
|
+
throw invalidEOF();
|
|
995
|
+
}
|
|
996
|
+
parseState = "beforePropertyValue";
|
|
997
|
+
},
|
|
998
|
+
beforePropertyValue() {
|
|
999
|
+
if (token.type === "eof") {
|
|
1000
|
+
throw invalidEOF();
|
|
1001
|
+
}
|
|
1002
|
+
push();
|
|
1003
|
+
},
|
|
1004
|
+
beforeArrayValue() {
|
|
1005
|
+
if (token.type === "eof") {
|
|
1006
|
+
throw invalidEOF();
|
|
1007
|
+
}
|
|
1008
|
+
if (token.type === "punctuator" && token.value === "]") {
|
|
1009
|
+
pop();
|
|
1010
|
+
return;
|
|
1011
|
+
}
|
|
1012
|
+
push();
|
|
1013
|
+
},
|
|
1014
|
+
afterPropertyValue() {
|
|
1015
|
+
if (token.type === "eof") {
|
|
1016
|
+
throw invalidEOF();
|
|
1017
|
+
}
|
|
1018
|
+
switch (token.value) {
|
|
1019
|
+
case ",":
|
|
1020
|
+
parseState = "beforePropertyName";
|
|
1021
|
+
return;
|
|
1022
|
+
case "}":
|
|
1023
|
+
pop();
|
|
1024
|
+
}
|
|
1025
|
+
},
|
|
1026
|
+
afterArrayValue() {
|
|
1027
|
+
if (token.type === "eof") {
|
|
1028
|
+
throw invalidEOF();
|
|
1029
|
+
}
|
|
1030
|
+
switch (token.value) {
|
|
1031
|
+
case ",":
|
|
1032
|
+
parseState = "beforeArrayValue";
|
|
1033
|
+
return;
|
|
1034
|
+
case "]":
|
|
1035
|
+
pop();
|
|
1036
|
+
}
|
|
1037
|
+
},
|
|
1038
|
+
end() {
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
function push() {
|
|
1042
|
+
let value;
|
|
1043
|
+
switch (token.type) {
|
|
1044
|
+
case "punctuator":
|
|
1045
|
+
switch (token.value) {
|
|
1046
|
+
case "{":
|
|
1047
|
+
value = {};
|
|
1048
|
+
break;
|
|
1049
|
+
case "[":
|
|
1050
|
+
value = [];
|
|
1051
|
+
break;
|
|
1052
|
+
}
|
|
1053
|
+
break;
|
|
1054
|
+
case "null":
|
|
1055
|
+
case "boolean":
|
|
1056
|
+
case "numeric":
|
|
1057
|
+
case "string":
|
|
1058
|
+
value = token.value;
|
|
1059
|
+
break;
|
|
1060
|
+
}
|
|
1061
|
+
if (root === void 0) {
|
|
1062
|
+
root = value;
|
|
1063
|
+
} else {
|
|
1064
|
+
const parent = stack[stack.length - 1];
|
|
1065
|
+
if (Array.isArray(parent)) {
|
|
1066
|
+
parent.push(value);
|
|
1067
|
+
} else {
|
|
1068
|
+
Object.defineProperty(parent, key2, {
|
|
1069
|
+
value,
|
|
1070
|
+
writable: true,
|
|
1071
|
+
enumerable: true,
|
|
1072
|
+
configurable: true
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
if (value !== null && typeof value === "object") {
|
|
1077
|
+
stack.push(value);
|
|
1078
|
+
if (Array.isArray(value)) {
|
|
1079
|
+
parseState = "beforeArrayValue";
|
|
1080
|
+
} else {
|
|
1081
|
+
parseState = "beforePropertyName";
|
|
1082
|
+
}
|
|
1083
|
+
} else {
|
|
1084
|
+
const current = stack[stack.length - 1];
|
|
1085
|
+
if (current == null) {
|
|
1086
|
+
parseState = "end";
|
|
1087
|
+
} else if (Array.isArray(current)) {
|
|
1088
|
+
parseState = "afterArrayValue";
|
|
1089
|
+
} else {
|
|
1090
|
+
parseState = "afterPropertyValue";
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
function pop() {
|
|
1095
|
+
stack.pop();
|
|
1096
|
+
const current = stack[stack.length - 1];
|
|
1097
|
+
if (current == null) {
|
|
1098
|
+
parseState = "end";
|
|
1099
|
+
} else if (Array.isArray(current)) {
|
|
1100
|
+
parseState = "afterArrayValue";
|
|
1101
|
+
} else {
|
|
1102
|
+
parseState = "afterPropertyValue";
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
function invalidChar(c2) {
|
|
1106
|
+
if (c2 === void 0) {
|
|
1107
|
+
return syntaxError(`JSON5: invalid end of input at ${line}:${column}`);
|
|
1108
|
+
}
|
|
1109
|
+
return syntaxError(`JSON5: invalid character '${formatChar(c2)}' at ${line}:${column}`);
|
|
1110
|
+
}
|
|
1111
|
+
function invalidEOF() {
|
|
1112
|
+
return syntaxError(`JSON5: invalid end of input at ${line}:${column}`);
|
|
1113
|
+
}
|
|
1114
|
+
function invalidIdentifier() {
|
|
1115
|
+
column -= 5;
|
|
1116
|
+
return syntaxError(`JSON5: invalid identifier character at ${line}:${column}`);
|
|
1117
|
+
}
|
|
1118
|
+
function separatorChar(c2) {
|
|
1119
|
+
console.warn(`JSON5: '${formatChar(c2)}' in strings is not valid ECMAScript; consider escaping`);
|
|
1120
|
+
}
|
|
1121
|
+
function formatChar(c2) {
|
|
1122
|
+
const replacements = {
|
|
1123
|
+
"'": "\\'",
|
|
1124
|
+
'"': '\\"',
|
|
1125
|
+
"\\": "\\\\",
|
|
1126
|
+
"\b": "\\b",
|
|
1127
|
+
"\f": "\\f",
|
|
1128
|
+
"\n": "\\n",
|
|
1129
|
+
"\r": "\\r",
|
|
1130
|
+
" ": "\\t",
|
|
1131
|
+
"\v": "\\v",
|
|
1132
|
+
"\0": "\\0",
|
|
1133
|
+
"\u2028": "\\u2028",
|
|
1134
|
+
"\u2029": "\\u2029"
|
|
1135
|
+
};
|
|
1136
|
+
if (replacements[c2]) {
|
|
1137
|
+
return replacements[c2];
|
|
1138
|
+
}
|
|
1139
|
+
if (c2 < " ") {
|
|
1140
|
+
const hexString = c2.charCodeAt(0).toString(16);
|
|
1141
|
+
return "\\x" + ("00" + hexString).substring(hexString.length);
|
|
1142
|
+
}
|
|
1143
|
+
return c2;
|
|
1144
|
+
}
|
|
1145
|
+
function syntaxError(message) {
|
|
1146
|
+
const err = new SyntaxError(message);
|
|
1147
|
+
err.lineNumber = line;
|
|
1148
|
+
err.columnNumber = column;
|
|
1149
|
+
return err;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
});
|
|
1153
|
+
|
|
1154
|
+
// ../../node_modules/json5/lib/stringify.js
|
|
1155
|
+
var require_stringify = __commonJS({
|
|
1156
|
+
"../../node_modules/json5/lib/stringify.js"(exports2, module2) {
|
|
1157
|
+
var util = require_util();
|
|
1158
|
+
module2.exports = function stringify(value, replacer, space) {
|
|
1159
|
+
const stack = [];
|
|
1160
|
+
let indent = "";
|
|
1161
|
+
let propertyList;
|
|
1162
|
+
let replacerFunc;
|
|
1163
|
+
let gap = "";
|
|
1164
|
+
let quote;
|
|
1165
|
+
if (replacer != null && typeof replacer === "object" && !Array.isArray(replacer)) {
|
|
1166
|
+
space = replacer.space;
|
|
1167
|
+
quote = replacer.quote;
|
|
1168
|
+
replacer = replacer.replacer;
|
|
1169
|
+
}
|
|
1170
|
+
if (typeof replacer === "function") {
|
|
1171
|
+
replacerFunc = replacer;
|
|
1172
|
+
} else if (Array.isArray(replacer)) {
|
|
1173
|
+
propertyList = [];
|
|
1174
|
+
for (const v of replacer) {
|
|
1175
|
+
let item;
|
|
1176
|
+
if (typeof v === "string") {
|
|
1177
|
+
item = v;
|
|
1178
|
+
} else if (typeof v === "number" || v instanceof String || v instanceof Number) {
|
|
1179
|
+
item = String(v);
|
|
1180
|
+
}
|
|
1181
|
+
if (item !== void 0 && propertyList.indexOf(item) < 0) {
|
|
1182
|
+
propertyList.push(item);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
if (space instanceof Number) {
|
|
1187
|
+
space = Number(space);
|
|
1188
|
+
} else if (space instanceof String) {
|
|
1189
|
+
space = String(space);
|
|
1190
|
+
}
|
|
1191
|
+
if (typeof space === "number") {
|
|
1192
|
+
if (space > 0) {
|
|
1193
|
+
space = Math.min(10, Math.floor(space));
|
|
1194
|
+
gap = " ".substr(0, space);
|
|
1195
|
+
}
|
|
1196
|
+
} else if (typeof space === "string") {
|
|
1197
|
+
gap = space.substr(0, 10);
|
|
1198
|
+
}
|
|
1199
|
+
return serializeProperty("", { "": value });
|
|
1200
|
+
function serializeProperty(key2, holder) {
|
|
1201
|
+
let value2 = holder[key2];
|
|
1202
|
+
if (value2 != null) {
|
|
1203
|
+
if (typeof value2.toJSON5 === "function") {
|
|
1204
|
+
value2 = value2.toJSON5(key2);
|
|
1205
|
+
} else if (typeof value2.toJSON === "function") {
|
|
1206
|
+
value2 = value2.toJSON(key2);
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
if (replacerFunc) {
|
|
1210
|
+
value2 = replacerFunc.call(holder, key2, value2);
|
|
1211
|
+
}
|
|
1212
|
+
if (value2 instanceof Number) {
|
|
1213
|
+
value2 = Number(value2);
|
|
1214
|
+
} else if (value2 instanceof String) {
|
|
1215
|
+
value2 = String(value2);
|
|
1216
|
+
} else if (value2 instanceof Boolean) {
|
|
1217
|
+
value2 = value2.valueOf();
|
|
1218
|
+
}
|
|
1219
|
+
switch (value2) {
|
|
1220
|
+
case null:
|
|
1221
|
+
return "null";
|
|
1222
|
+
case true:
|
|
1223
|
+
return "true";
|
|
1224
|
+
case false:
|
|
1225
|
+
return "false";
|
|
1226
|
+
}
|
|
1227
|
+
if (typeof value2 === "string") {
|
|
1228
|
+
return quoteString(value2, false);
|
|
1229
|
+
}
|
|
1230
|
+
if (typeof value2 === "number") {
|
|
1231
|
+
return String(value2);
|
|
1232
|
+
}
|
|
1233
|
+
if (typeof value2 === "object") {
|
|
1234
|
+
return Array.isArray(value2) ? serializeArray(value2) : serializeObject(value2);
|
|
1235
|
+
}
|
|
1236
|
+
return void 0;
|
|
1237
|
+
}
|
|
1238
|
+
function quoteString(value2) {
|
|
1239
|
+
const quotes = {
|
|
1240
|
+
"'": 0.1,
|
|
1241
|
+
'"': 0.2
|
|
1242
|
+
};
|
|
1243
|
+
const replacements = {
|
|
1244
|
+
"'": "\\'",
|
|
1245
|
+
'"': '\\"',
|
|
1246
|
+
"\\": "\\\\",
|
|
1247
|
+
"\b": "\\b",
|
|
1248
|
+
"\f": "\\f",
|
|
1249
|
+
"\n": "\\n",
|
|
1250
|
+
"\r": "\\r",
|
|
1251
|
+
" ": "\\t",
|
|
1252
|
+
"\v": "\\v",
|
|
1253
|
+
"\0": "\\0",
|
|
1254
|
+
"\u2028": "\\u2028",
|
|
1255
|
+
"\u2029": "\\u2029"
|
|
1256
|
+
};
|
|
1257
|
+
let product = "";
|
|
1258
|
+
for (let i = 0; i < value2.length; i++) {
|
|
1259
|
+
const c = value2[i];
|
|
1260
|
+
switch (c) {
|
|
1261
|
+
case "'":
|
|
1262
|
+
case '"':
|
|
1263
|
+
quotes[c]++;
|
|
1264
|
+
product += c;
|
|
1265
|
+
continue;
|
|
1266
|
+
case "\0":
|
|
1267
|
+
if (util.isDigit(value2[i + 1])) {
|
|
1268
|
+
product += "\\x00";
|
|
1269
|
+
continue;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
if (replacements[c]) {
|
|
1273
|
+
product += replacements[c];
|
|
1274
|
+
continue;
|
|
1275
|
+
}
|
|
1276
|
+
if (c < " ") {
|
|
1277
|
+
let hexString = c.charCodeAt(0).toString(16);
|
|
1278
|
+
product += "\\x" + ("00" + hexString).substring(hexString.length);
|
|
1279
|
+
continue;
|
|
1280
|
+
}
|
|
1281
|
+
product += c;
|
|
1282
|
+
}
|
|
1283
|
+
const quoteChar = quote || Object.keys(quotes).reduce((a, b) => quotes[a] < quotes[b] ? a : b);
|
|
1284
|
+
product = product.replace(new RegExp(quoteChar, "g"), replacements[quoteChar]);
|
|
1285
|
+
return quoteChar + product + quoteChar;
|
|
1286
|
+
}
|
|
1287
|
+
function serializeObject(value2) {
|
|
1288
|
+
if (stack.indexOf(value2) >= 0) {
|
|
1289
|
+
throw TypeError("Converting circular structure to JSON5");
|
|
1290
|
+
}
|
|
1291
|
+
stack.push(value2);
|
|
1292
|
+
let stepback = indent;
|
|
1293
|
+
indent = indent + gap;
|
|
1294
|
+
let keys = propertyList || Object.keys(value2);
|
|
1295
|
+
let partial = [];
|
|
1296
|
+
for (const key2 of keys) {
|
|
1297
|
+
const propertyString = serializeProperty(key2, value2);
|
|
1298
|
+
if (propertyString !== void 0) {
|
|
1299
|
+
let member = serializeKey(key2) + ":";
|
|
1300
|
+
if (gap !== "") {
|
|
1301
|
+
member += " ";
|
|
1302
|
+
}
|
|
1303
|
+
member += propertyString;
|
|
1304
|
+
partial.push(member);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
let final;
|
|
1308
|
+
if (partial.length === 0) {
|
|
1309
|
+
final = "{}";
|
|
1310
|
+
} else {
|
|
1311
|
+
let properties;
|
|
1312
|
+
if (gap === "") {
|
|
1313
|
+
properties = partial.join(",");
|
|
1314
|
+
final = "{" + properties + "}";
|
|
1315
|
+
} else {
|
|
1316
|
+
let separator = ",\n" + indent;
|
|
1317
|
+
properties = partial.join(separator);
|
|
1318
|
+
final = "{\n" + indent + properties + ",\n" + stepback + "}";
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
stack.pop();
|
|
1322
|
+
indent = stepback;
|
|
1323
|
+
return final;
|
|
1324
|
+
}
|
|
1325
|
+
function serializeKey(key2) {
|
|
1326
|
+
if (key2.length === 0) {
|
|
1327
|
+
return quoteString(key2, true);
|
|
1328
|
+
}
|
|
1329
|
+
const firstChar = String.fromCodePoint(key2.codePointAt(0));
|
|
1330
|
+
if (!util.isIdStartChar(firstChar)) {
|
|
1331
|
+
return quoteString(key2, true);
|
|
1332
|
+
}
|
|
1333
|
+
for (let i = firstChar.length; i < key2.length; i++) {
|
|
1334
|
+
if (!util.isIdContinueChar(String.fromCodePoint(key2.codePointAt(i)))) {
|
|
1335
|
+
return quoteString(key2, true);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
return key2;
|
|
1339
|
+
}
|
|
1340
|
+
function serializeArray(value2) {
|
|
1341
|
+
if (stack.indexOf(value2) >= 0) {
|
|
1342
|
+
throw TypeError("Converting circular structure to JSON5");
|
|
1343
|
+
}
|
|
1344
|
+
stack.push(value2);
|
|
1345
|
+
let stepback = indent;
|
|
1346
|
+
indent = indent + gap;
|
|
1347
|
+
let partial = [];
|
|
1348
|
+
for (let i = 0; i < value2.length; i++) {
|
|
1349
|
+
const propertyString = serializeProperty(String(i), value2);
|
|
1350
|
+
partial.push(propertyString !== void 0 ? propertyString : "null");
|
|
1351
|
+
}
|
|
1352
|
+
let final;
|
|
1353
|
+
if (partial.length === 0) {
|
|
1354
|
+
final = "[]";
|
|
1355
|
+
} else {
|
|
1356
|
+
if (gap === "") {
|
|
1357
|
+
let properties = partial.join(",");
|
|
1358
|
+
final = "[" + properties + "]";
|
|
1359
|
+
} else {
|
|
1360
|
+
let separator = ",\n" + indent;
|
|
1361
|
+
let properties = partial.join(separator);
|
|
1362
|
+
final = "[\n" + indent + properties + ",\n" + stepback + "]";
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
stack.pop();
|
|
1366
|
+
indent = stepback;
|
|
1367
|
+
return final;
|
|
1368
|
+
}
|
|
1369
|
+
};
|
|
1370
|
+
}
|
|
1371
|
+
});
|
|
1372
|
+
|
|
1373
|
+
// ../../node_modules/json5/lib/index.js
|
|
1374
|
+
var require_lib = __commonJS({
|
|
1375
|
+
"../../node_modules/json5/lib/index.js"(exports2, module2) {
|
|
1376
|
+
var parse = require_parse2();
|
|
1377
|
+
var stringify = require_stringify();
|
|
1378
|
+
var JSON52 = {
|
|
1379
|
+
parse,
|
|
1380
|
+
stringify
|
|
1381
|
+
};
|
|
1382
|
+
module2.exports = JSON52;
|
|
1383
|
+
}
|
|
1384
|
+
});
|
|
1385
|
+
|
|
274
1386
|
// src/vite-plugin-swift.ts
|
|
275
1387
|
var vite_plugin_swift_exports = {};
|
|
276
1388
|
__export(vite_plugin_swift_exports, {
|
|
1389
|
+
ONE_WIDGET_PACKAGE: () => ONE_WIDGET_PACKAGE,
|
|
277
1390
|
buildSwiftBundleFiles: () => buildSwiftBundleFiles,
|
|
278
1391
|
buildSwiftResourceTable: () => buildSwiftResourceTable,
|
|
279
1392
|
compileInput: () => compileInput,
|
|
280
1393
|
entryRootId: () => entryRootId,
|
|
281
1394
|
linkedModuleRoots: () => linkedModuleRoots,
|
|
1395
|
+
oneWidgetPackage: () => oneWidgetPackage,
|
|
282
1396
|
serveSwiftPackageAsset: () => serveSwiftPackageAsset,
|
|
283
1397
|
serveSwiftResource: () => serveSwiftResource,
|
|
284
1398
|
sourceStamp: () => sourceStamp,
|
|
@@ -287,18 +1401,18 @@ __export(vite_plugin_swift_exports, {
|
|
|
287
1401
|
swiftPlugin: () => swiftPlugin
|
|
288
1402
|
});
|
|
289
1403
|
module.exports = __toCommonJS(vite_plugin_swift_exports);
|
|
290
|
-
var
|
|
291
|
-
var
|
|
1404
|
+
var import_node_fs15 = __toESM(require("node:fs"), 1);
|
|
1405
|
+
var import_node_path16 = __toESM(require("node:path"), 1);
|
|
292
1406
|
|
|
293
1407
|
// ../sootsim-swift/src/entryModule.ts
|
|
294
1408
|
function nativeExportLines(args, commonjs) {
|
|
295
1409
|
const native = args.native;
|
|
296
1410
|
if (!native) return [];
|
|
297
|
-
return Object.entries(native.modules).map(([
|
|
1411
|
+
return Object.entries(native.modules).map(([name2, methods]) => {
|
|
298
1412
|
const calls = methods.map(
|
|
299
|
-
(method) => `${method}: (...args) => callSwiftModule(options, ${JSON.stringify(`${native.packageId}.${
|
|
1413
|
+
(method) => `${method}: (...args) => callSwiftModule(options, ${JSON.stringify(`${native.packageId}.${name2}`)}, ${JSON.stringify(method)}, args, ${JSON.stringify(native.contractHash)})`
|
|
300
1414
|
).join(", ");
|
|
301
|
-
return commonjs ? `module.exports.${
|
|
1415
|
+
return commonjs ? `module.exports.${name2} = Object.freeze({ ${calls} })` : `export const ${name2} = Object.freeze({ ${calls} })`;
|
|
302
1416
|
});
|
|
303
1417
|
}
|
|
304
1418
|
function swiftEntryModuleEsm(args) {
|
|
@@ -433,7 +1547,7 @@ async function load(toolchainBin, sdk) {
|
|
|
433
1547
|
icuSegment(archiveMember((0, import_node_fs.readFileSync)(import_node_path.default.join(resources, ARCHIVE)), MEMBER))
|
|
434
1548
|
);
|
|
435
1549
|
}
|
|
436
|
-
function archiveMember(archive,
|
|
1550
|
+
function archiveMember(archive, name2) {
|
|
437
1551
|
if (archive.toString("latin1", 0, 8) !== "!<arch>\n")
|
|
438
1552
|
throw new Error("swift-icu: not an ar archive");
|
|
439
1553
|
let names = "";
|
|
@@ -443,10 +1557,10 @@ function archiveMember(archive, name) {
|
|
|
443
1557
|
const body = archive.subarray(at + 60, at + 60 + size);
|
|
444
1558
|
if (raw2 === "//") names = body.toString("latin1");
|
|
445
1559
|
const member = /^\/\d+$/.test(raw2) ? names.slice(Number(raw2.slice(1)), names.indexOf("/\n", Number(raw2.slice(1)))) : raw2.replace(/\/$/, "");
|
|
446
|
-
if (member ===
|
|
1560
|
+
if (member === name2) return body;
|
|
447
1561
|
at += 60 + size + size % 2;
|
|
448
1562
|
}
|
|
449
|
-
throw new Error(`swift-icu: ${
|
|
1563
|
+
throw new Error(`swift-icu: ${name2} is not in the sdk's icu archive`);
|
|
450
1564
|
}
|
|
451
1565
|
function icuSegment(object) {
|
|
452
1566
|
let at = 8;
|
|
@@ -555,10 +1669,10 @@ function swiftManifestTargets(manifest, resourcePaths = []) {
|
|
|
555
1669
|
"target"
|
|
556
1670
|
])) {
|
|
557
1671
|
const executable = kind === "executableTarget";
|
|
558
|
-
const
|
|
559
|
-
if (!
|
|
1672
|
+
const name2 = /\bname\s*:\s*"([^"]+)"/.exec(flat)?.[1];
|
|
1673
|
+
if (!name2) continue;
|
|
560
1674
|
const rawPath = /\bpath\s*:\s*"([^"]*)"/.exec(flat)?.[1];
|
|
561
|
-
const targetPath = rawPath == null || rawPath === "" ? `Sources/${
|
|
1675
|
+
const targetPath = rawPath == null || rawPath === "" ? `Sources/${name2}` : rawPath.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
562
1676
|
const languageMode = Number(
|
|
563
1677
|
/\.swiftLanguageMode\(\s*\.v(\d+)\s*\)/.exec(call)?.[1] ?? "5"
|
|
564
1678
|
);
|
|
@@ -577,7 +1691,7 @@ function swiftManifestTargets(manifest, resourcePaths = []) {
|
|
|
577
1691
|
return true;
|
|
578
1692
|
});
|
|
579
1693
|
targets.push({
|
|
580
|
-
name,
|
|
1694
|
+
name: name2,
|
|
581
1695
|
path: targetPath,
|
|
582
1696
|
executable,
|
|
583
1697
|
languageMode,
|
|
@@ -685,8 +1799,8 @@ function swiftModuleDigest(root) {
|
|
|
685
1799
|
);
|
|
686
1800
|
}
|
|
687
1801
|
const stamp = stampHash.digest("hex");
|
|
688
|
-
const
|
|
689
|
-
if (
|
|
1802
|
+
const cached2 = linkedModuleDigests.get(root);
|
|
1803
|
+
if (cached2?.stamp === stamp) return cached2.digest;
|
|
690
1804
|
const hash = (0, import_node_crypto2.createHash)("sha256");
|
|
691
1805
|
for (const file of files2) {
|
|
692
1806
|
hash.update((0, import_node_crypto2.createHash)("sha256").update(file).digest());
|
|
@@ -773,11 +1887,11 @@ function swiftCondition(text3, available) {
|
|
|
773
1887
|
if (token === "false") return false;
|
|
774
1888
|
const call = /^(\w+)\s*\(\s*([^,()]*?)\s*(?:,[^()]*)?\)$/.exec(token ?? "");
|
|
775
1889
|
if (!call) return void 0;
|
|
776
|
-
const [,
|
|
777
|
-
if (
|
|
778
|
-
if (
|
|
779
|
-
if (
|
|
780
|
-
if (
|
|
1890
|
+
const [, name2, argument] = call;
|
|
1891
|
+
if (name2 === "os") return argument === "iOS" || argument === "WASI";
|
|
1892
|
+
if (name2 === "canImport") return available.has(argument);
|
|
1893
|
+
if (name2 === "targetEnvironment") return false;
|
|
1894
|
+
if (name2 === "arch") return argument === "wasm32";
|
|
781
1895
|
return void 0;
|
|
782
1896
|
};
|
|
783
1897
|
const both = () => {
|
|
@@ -821,8 +1935,8 @@ function swiftImportNames(contents, available) {
|
|
|
821
1935
|
continue;
|
|
822
1936
|
}
|
|
823
1937
|
if (available && frames.some((frame) => frame.active !== true)) continue;
|
|
824
|
-
const
|
|
825
|
-
if (
|
|
1938
|
+
const name2 = SWIFT_IMPORT.exec(line)?.[1];
|
|
1939
|
+
if (name2) names.push(name2);
|
|
826
1940
|
}
|
|
827
1941
|
return names;
|
|
828
1942
|
}
|
|
@@ -838,16 +1952,16 @@ var sdkPaths = /* @__PURE__ */ new Map();
|
|
|
838
1952
|
function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
839
1953
|
const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
|
|
840
1954
|
const key2 = `${toolchainBin}\0${sdk}`;
|
|
841
|
-
const
|
|
842
|
-
if (
|
|
1955
|
+
const cached2 = sdkPaths.get(key2);
|
|
1956
|
+
if (cached2) return cached2;
|
|
843
1957
|
const configuration = (0, import_node_child_process2.execFileSync)(
|
|
844
1958
|
import_node_path2.default.join(toolchainBin, "swift"),
|
|
845
1959
|
["sdk", "configure", "--show-configuration", sdk, "wasm32-unknown-wasip1"],
|
|
846
1960
|
{ encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }
|
|
847
1961
|
);
|
|
848
|
-
const field = (
|
|
849
|
-
const value = new RegExp(`^${
|
|
850
|
-
if (!value) throw new Error(`swift sdk ${sdk} reports no ${
|
|
1962
|
+
const field = (name2) => {
|
|
1963
|
+
const value = new RegExp(`^${name2}:\\s*(.+)$`, "m").exec(configuration)?.[1]?.trim();
|
|
1964
|
+
if (!value) throw new Error(`swift sdk ${sdk} reports no ${name2}`);
|
|
851
1965
|
return value;
|
|
852
1966
|
};
|
|
853
1967
|
const paths = {
|
|
@@ -861,8 +1975,8 @@ var availableModules = /* @__PURE__ */ new Map();
|
|
|
861
1975
|
function swiftAvailableModules(moduleRoot, toolchainBin) {
|
|
862
1976
|
const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
|
|
863
1977
|
const key2 = `${moduleRoot}\0${sdk}`;
|
|
864
|
-
const
|
|
865
|
-
if (
|
|
1978
|
+
const cached2 = availableModules.get(key2);
|
|
1979
|
+
if (cached2) return cached2;
|
|
866
1980
|
const modules = new Set(swiftPeachModules(moduleRoot));
|
|
867
1981
|
const { resources } = swiftSdkPaths(moduleRoot, toolchainBin);
|
|
868
1982
|
for (const entry of (0, import_node_fs2.readdirSync)(import_node_path2.default.join(resources, "wasi"))) {
|
|
@@ -882,9 +1996,9 @@ function missingSwiftModules(files2, available) {
|
|
|
882
1996
|
const missing = /* @__PURE__ */ new Map();
|
|
883
1997
|
for (const [file, contents] of Object.entries(files2)) {
|
|
884
1998
|
if (!file.endsWith(".swift") || file === "Package.swift") continue;
|
|
885
|
-
for (const
|
|
886
|
-
if (available.has(
|
|
887
|
-
missing.set(
|
|
1999
|
+
for (const name2 of new Set(swiftImportNames(contents, available))) {
|
|
2000
|
+
if (available.has(name2)) continue;
|
|
2001
|
+
missing.set(name2, [...missing.get(name2) ?? [], file]);
|
|
888
2002
|
}
|
|
889
2003
|
}
|
|
890
2004
|
return new Map([...missing].sort(([left], [right]) => left.localeCompare(right)));
|
|
@@ -901,8 +2015,8 @@ function swiftTargetDependencies(files2, targets) {
|
|
|
901
2015
|
(candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
|
|
902
2016
|
))
|
|
903
2017
|
continue;
|
|
904
|
-
for (const
|
|
905
|
-
if (names.has(
|
|
2018
|
+
for (const name2 of swiftImportNames(contents)) {
|
|
2019
|
+
if (names.has(name2) && name2 !== target.name) deps.add(name2);
|
|
906
2020
|
}
|
|
907
2021
|
}
|
|
908
2022
|
siblings.set(target.name, [...deps].sort());
|
|
@@ -934,10 +2048,10 @@ ${release}
|
|
|
934
2048
|
(0, import_node_crypto2.createHash)("sha256").update(input.resources?.[base] ?? "").digest()
|
|
935
2049
|
);
|
|
936
2050
|
}
|
|
937
|
-
for (const
|
|
938
|
-
const image = input.images?.[
|
|
2051
|
+
for (const name2 of Object.keys(input.images ?? {}).sort()) {
|
|
2052
|
+
const image = input.images?.[name2];
|
|
939
2053
|
if (!image) continue;
|
|
940
|
-
hash.update((0, import_node_crypto2.createHash)("sha256").update(
|
|
2054
|
+
hash.update((0, import_node_crypto2.createHash)("sha256").update(name2).digest());
|
|
941
2055
|
hash.update((0, import_node_crypto2.createHash)("sha256").update(image.file).digest());
|
|
942
2056
|
hash.update((0, import_node_crypto2.createHash)("sha256").update(image.data).digest());
|
|
943
2057
|
}
|
|
@@ -964,12 +2078,12 @@ function emitSwiftPackageManifest(args) {
|
|
|
964
2078
|
const { targets, siblings, moduleRoot, oneModule, spriteKit, distribution } = args;
|
|
965
2079
|
const reachedFrameworks = new Set(
|
|
966
2080
|
[...siblings.values()].flat().filter(
|
|
967
|
-
(
|
|
968
|
-
).flatMap((
|
|
2081
|
+
(name2) => OPTIONAL_FRAMEWORKS.has(name2) && !targets.some((target) => target.name === name2)
|
|
2082
|
+
).flatMap((name2) => [name2, ...OPTIONAL_FRAMEWORK_DEPENDENCIES[name2] ?? []])
|
|
969
2083
|
);
|
|
970
2084
|
const distributionObjects = distribution?.objects.filter(
|
|
971
2085
|
(object) => [...OPTIONAL_FRAMEWORKS].every(
|
|
972
|
-
(
|
|
2086
|
+
(name2) => !object.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
|
|
973
2087
|
)
|
|
974
2088
|
);
|
|
975
2089
|
const executable = targets.find((target) => target.executable);
|
|
@@ -1253,7 +2367,7 @@ function liftExtensionOverrides(source, extraObjCExtensions) {
|
|
|
1253
2367
|
if (top?.kind !== "extension") continue;
|
|
1254
2368
|
const func = OVERRIDE_FUNC.exec(rest);
|
|
1255
2369
|
if (func) {
|
|
1256
|
-
const
|
|
2370
|
+
const name2 = func[2];
|
|
1257
2371
|
const open = at + func[0].length - 1;
|
|
1258
2372
|
let depth = 0;
|
|
1259
2373
|
let close = open;
|
|
@@ -1266,12 +2380,12 @@ function liftExtensionOverrides(source, extraObjCExtensions) {
|
|
|
1266
2380
|
const clause = source.slice(close + 1, body).trim();
|
|
1267
2381
|
const args = forwardedArguments(source.slice(open + 1, close));
|
|
1268
2382
|
if (args === null) continue;
|
|
1269
|
-
const call = (clause.includes("->") ? "return " : "") + (/\b(?:throws|rethrows)\b/.test(clause) ? "try " : "") + (/\basync\b/.test(clause) ? "await " : "") + `__peach_ext_${
|
|
1270
|
-
const signature2 = `func ${
|
|
1271
|
-
const nameAt = at + rest.indexOf(
|
|
2383
|
+
const call = (clause.includes("->") ? "return " : "") + (/\b(?:throws|rethrows)\b/.test(clause) ? "try " : "") + (/\basync\b/.test(clause) ? "await " : "") + `__peach_ext_${name2}(${args})`;
|
|
2384
|
+
const signature2 = `func ${name2}${func[3] ?? ""}${source.slice(open, close + 1)}${clause ? ` ${clause}` : ""}`;
|
|
2385
|
+
const nameAt = at + rest.indexOf(name2, rest.indexOf("func", "override".length + func[1].length) + 4);
|
|
1272
2386
|
lifted.push({
|
|
1273
2387
|
type: top.name,
|
|
1274
|
-
member:
|
|
2388
|
+
member: name2,
|
|
1275
2389
|
at,
|
|
1276
2390
|
modifiers,
|
|
1277
2391
|
decl: signature2,
|
|
@@ -1288,15 +2402,15 @@ function liftExtensionOverrides(source, extraObjCExtensions) {
|
|
|
1288
2402
|
if (property) {
|
|
1289
2403
|
const open = at + property[0].length - 1;
|
|
1290
2404
|
if (/\b(?:set|willSet|didSet)\b/.test(source.slice(open, closing(open)))) continue;
|
|
1291
|
-
const
|
|
1292
|
-
const nameAt = at + rest.indexOf(
|
|
2405
|
+
const name2 = property[2];
|
|
2406
|
+
const nameAt = at + rest.indexOf(name2, rest.indexOf("var"));
|
|
1293
2407
|
lifted.push({
|
|
1294
2408
|
type: top.name,
|
|
1295
|
-
member:
|
|
2409
|
+
member: name2,
|
|
1296
2410
|
at,
|
|
1297
2411
|
modifiers,
|
|
1298
|
-
decl: `var ${
|
|
1299
|
-
forward: `{ __peach_ext_${
|
|
2412
|
+
decl: `var ${name2}: ${property[3].trim()}`,
|
|
2413
|
+
forward: `{ __peach_ext_${name2} };`,
|
|
1300
2414
|
nameAt,
|
|
1301
2415
|
edits: [
|
|
1302
2416
|
[at, "override".length, " ".repeat("override".length)],
|
|
@@ -1834,7 +2948,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
1834
2948
|
[
|
|
1835
2949
|
product,
|
|
1836
2950
|
...optionalProducts.map(
|
|
1837
|
-
(
|
|
2951
|
+
(name2) => `.product(name: "${name2}", package: "sootsim-swift"),`
|
|
1838
2952
|
)
|
|
1839
2953
|
].join("\n ")
|
|
1840
2954
|
);
|
|
@@ -1922,7 +3036,7 @@ function builtArtifact(layout) {
|
|
|
1922
3036
|
}
|
|
1923
3037
|
const file = import_node_path2.default.join(binDir, `${executable.name}.wasm`);
|
|
1924
3038
|
if (!(0, import_node_fs2.existsSync)(file)) {
|
|
1925
|
-
const found = (0, import_node_fs2.existsSync)(binDir) ? (0, import_node_fs2.readdirSync)(binDir).filter((
|
|
3039
|
+
const found = (0, import_node_fs2.existsSync)(binDir) ? (0, import_node_fs2.readdirSync)(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
|
|
1926
3040
|
throw new Error(
|
|
1927
3041
|
`swift-compile: the build produced no ${executable.name}.wasm (found: ${found.join(", ") || "none"})`
|
|
1928
3042
|
);
|
|
@@ -2011,7 +3125,7 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
2011
3125
|
|
|
2012
3126
|
// src/swift-host.ts
|
|
2013
3127
|
var import_node_crypto7 = require("node:crypto");
|
|
2014
|
-
var
|
|
3128
|
+
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
2015
3129
|
var import_node_os8 = __toESM(require("node:os"), 1);
|
|
2016
3130
|
var import_node_path14 = __toESM(require("node:path"), 1);
|
|
2017
3131
|
|
|
@@ -2047,8 +3161,8 @@ function pickImagesetFile(images) {
|
|
|
2047
3161
|
scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
|
|
2048
3162
|
};
|
|
2049
3163
|
}
|
|
2050
|
-
function flatScale(
|
|
2051
|
-
const match = /@([23])x\.[^./]+$/.exec(
|
|
3164
|
+
function flatScale(path16) {
|
|
3165
|
+
const match = /@([23])x\.[^./]+$/.exec(path16);
|
|
2052
3166
|
return match ? Number(match[1]) : 1;
|
|
2053
3167
|
}
|
|
2054
3168
|
function providesNamespace(text3) {
|
|
@@ -2075,16 +3189,16 @@ function catalogEntryName(contentsPath, kind, readText) {
|
|
|
2075
3189
|
}
|
|
2076
3190
|
return segments.join("/");
|
|
2077
3191
|
}
|
|
2078
|
-
function isFlatResourceImage(
|
|
2079
|
-
return
|
|
3192
|
+
function isFlatResourceImage(path16) {
|
|
3193
|
+
return path16.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path16));
|
|
2080
3194
|
}
|
|
2081
3195
|
function enumerateBundleImages(paths, readText) {
|
|
2082
3196
|
const table = [];
|
|
2083
3197
|
const seen = /* @__PURE__ */ new Set();
|
|
2084
|
-
const catalogs = paths.filter((
|
|
3198
|
+
const catalogs = paths.filter((path16) => baseOf(path16) === "Contents.json");
|
|
2085
3199
|
for (const contentsPath of catalogs) {
|
|
2086
|
-
const
|
|
2087
|
-
if (
|
|
3200
|
+
const name2 = catalogEntryName(contentsPath, ".imageset", readText);
|
|
3201
|
+
if (name2 === null || seen.has(name2)) continue;
|
|
2088
3202
|
let parsed;
|
|
2089
3203
|
try {
|
|
2090
3204
|
const text3 = readText(contentsPath);
|
|
@@ -2099,15 +3213,15 @@ function enumerateBundleImages(paths, readText) {
|
|
|
2099
3213
|
const pick = pickImagesetFile(images);
|
|
2100
3214
|
if (pick === null || pick.filename.includes("/") || pick.filename.includes("\\"))
|
|
2101
3215
|
continue;
|
|
2102
|
-
seen.add(
|
|
2103
|
-
table.push({ name, file: `${dir}/${pick.filename}`, scale: pick.scale });
|
|
3216
|
+
seen.add(name2);
|
|
3217
|
+
table.push({ name: name2, file: `${dir}/${pick.filename}`, scale: pick.scale });
|
|
2104
3218
|
}
|
|
2105
|
-
for (const
|
|
2106
|
-
if (!isFlatResourceImage(
|
|
2107
|
-
const
|
|
2108
|
-
if (
|
|
2109
|
-
seen.add(
|
|
2110
|
-
table.push({ name, file:
|
|
3219
|
+
for (const path16 of paths) {
|
|
3220
|
+
if (!isFlatResourceImage(path16)) continue;
|
|
3221
|
+
const name2 = baseOf(path16).slice(0, -extOf(path16).length);
|
|
3222
|
+
if (name2 === "" || seen.has(name2)) continue;
|
|
3223
|
+
seen.add(name2);
|
|
3224
|
+
table.push({ name: name2, file: path16, scale: flatScale(path16) });
|
|
2111
3225
|
}
|
|
2112
3226
|
return table;
|
|
2113
3227
|
}
|
|
@@ -2136,9 +3250,9 @@ function colorsetValue(color) {
|
|
|
2136
3250
|
}
|
|
2137
3251
|
function enumerateBundleColors(paths, readText) {
|
|
2138
3252
|
const table = {};
|
|
2139
|
-
for (const contentsPath of paths.filter((
|
|
2140
|
-
const
|
|
2141
|
-
if (
|
|
3253
|
+
for (const contentsPath of paths.filter((path16) => baseOf(path16) === "Contents.json")) {
|
|
3254
|
+
const name2 = catalogEntryName(contentsPath, ".colorset", readText);
|
|
3255
|
+
if (name2 === null || name2 in table) continue;
|
|
2142
3256
|
let colors;
|
|
2143
3257
|
try {
|
|
2144
3258
|
const text3 = readText(contentsPath);
|
|
@@ -2167,8 +3281,8 @@ function enumerateBundleColors(paths, readText) {
|
|
|
2167
3281
|
else light = value;
|
|
2168
3282
|
}
|
|
2169
3283
|
if (light === null) continue;
|
|
2170
|
-
if (typeof light === "object") table[
|
|
2171
|
-
else table[
|
|
3284
|
+
if (typeof light === "object") table[name2] = light;
|
|
3285
|
+
else table[name2] = { light, dark: typeof dark === "string" ? dark : light };
|
|
2172
3286
|
}
|
|
2173
3287
|
return table;
|
|
2174
3288
|
}
|
|
@@ -2201,8 +3315,8 @@ function axisExtremes(points) {
|
|
|
2201
3315
|
function pathBounds(d) {
|
|
2202
3316
|
const xs = [];
|
|
2203
3317
|
const ys = [];
|
|
2204
|
-
for (const
|
|
2205
|
-
(0, import_svgpath.default)(
|
|
3318
|
+
for (const path16 of d)
|
|
3319
|
+
(0, import_svgpath.default)(path16).abs().unshort().unarc().iterate((segment, _index, x, y) => {
|
|
2206
3320
|
const [command, ...args] = segment;
|
|
2207
3321
|
if (command === "M" || command === "L") {
|
|
2208
3322
|
xs.push(Number(args[0]));
|
|
@@ -2229,9 +3343,9 @@ function guide(svg, id, axis) {
|
|
|
2229
3343
|
}
|
|
2230
3344
|
function enumerateBundleSymbols(paths, readText) {
|
|
2231
3345
|
const table = {};
|
|
2232
|
-
for (const contentsPath of paths.filter((
|
|
2233
|
-
const
|
|
2234
|
-
if (
|
|
3346
|
+
for (const contentsPath of paths.filter((path16) => baseOf(path16) === "Contents.json")) {
|
|
3347
|
+
const name2 = catalogEntryName(contentsPath, ".symbolset", readText);
|
|
3348
|
+
if (name2 === null || name2 in table) continue;
|
|
2235
3349
|
let symbols;
|
|
2236
3350
|
try {
|
|
2237
3351
|
symbols = Reflect.get(JSON.parse(readText(contentsPath) ?? "null") ?? {}, "symbols");
|
|
@@ -2258,12 +3372,12 @@ function enumerateBundleSymbols(paths, readText) {
|
|
|
2258
3372
|
const translateY = 12 - (box.minY + box.maxY) * scale / 2;
|
|
2259
3373
|
const advance = Math.round((right - left) * scale * 1e3) / 1e3;
|
|
2260
3374
|
const tall = (box.maxY - box.minY) * scale + 0.175 * 24;
|
|
2261
|
-
table[
|
|
3375
|
+
table[name2] = {
|
|
2262
3376
|
viewBox: "0 0 24 24",
|
|
2263
3377
|
advance,
|
|
2264
3378
|
box: [12 - advance / 2, 12 - tall / 2, advance, tall],
|
|
2265
|
-
layers: d.map((
|
|
2266
|
-
d: (0, import_svgpath.default)(
|
|
3379
|
+
layers: d.map((path16) => ({
|
|
3380
|
+
d: (0, import_svgpath.default)(path16).abs().scale(scale).translate(translateX, translateY).round(3).toString()
|
|
2267
3381
|
}))
|
|
2268
3382
|
};
|
|
2269
3383
|
}
|
|
@@ -2273,7 +3387,7 @@ function enumerateBundleJson(paths) {
|
|
|
2273
3387
|
const found = [];
|
|
2274
3388
|
const seen = /* @__PURE__ */ new Set();
|
|
2275
3389
|
const ordered = [...paths].filter(
|
|
2276
|
-
(
|
|
3390
|
+
(path16) => path16.split("/").includes("Resources") && path16.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path16) === ".json" || extOf(path16) === ".xcstrings")
|
|
2277
3391
|
).sort((a, b) => {
|
|
2278
3392
|
const aDepth = a.split("/").length;
|
|
2279
3393
|
const bDepth = b.split("/").length;
|
|
@@ -2848,18 +3962,18 @@ function localEntries(dir) {
|
|
|
2848
3962
|
}
|
|
2849
3963
|
async function swiftBinaryModules(binary) {
|
|
2850
3964
|
if (!binary.url) return frameworkModules(localEntries(binary.dir));
|
|
2851
|
-
const
|
|
3965
|
+
const cached2 = import_node_path5.default.join(
|
|
2852
3966
|
cacheDir,
|
|
2853
3967
|
`${(0, import_node_crypto3.createHash)("sha256").update(binary.url).digest("hex").slice(0, 32)}.json`
|
|
2854
3968
|
);
|
|
2855
|
-
if (import_node_fs4.default.existsSync(
|
|
2856
|
-
const value = JSON.parse(import_node_fs4.default.readFileSync(
|
|
2857
|
-
if (Array.isArray(value) && value.every((
|
|
3969
|
+
if (import_node_fs4.default.existsSync(cached2)) {
|
|
3970
|
+
const value = JSON.parse(import_node_fs4.default.readFileSync(cached2, "utf8"));
|
|
3971
|
+
if (Array.isArray(value) && value.every((name2) => typeof name2 === "string"))
|
|
2858
3972
|
return value;
|
|
2859
3973
|
}
|
|
2860
3974
|
const modules = frameworkModules(await zipEntries(binary.url));
|
|
2861
3975
|
import_node_fs4.default.mkdirSync(cacheDir, { recursive: true });
|
|
2862
|
-
import_node_fs4.default.writeFileSync(
|
|
3976
|
+
import_node_fs4.default.writeFileSync(cached2, JSON.stringify(modules));
|
|
2863
3977
|
return modules;
|
|
2864
3978
|
}
|
|
2865
3979
|
|
|
@@ -3021,8 +4135,8 @@ function swiftToolchainBin(release) {
|
|
|
3021
4135
|
}
|
|
3022
4136
|
var verified = /* @__PURE__ */ new Map();
|
|
3023
4137
|
function swiftToolchain(release, sdk) {
|
|
3024
|
-
const
|
|
3025
|
-
if (
|
|
4138
|
+
const cached2 = verified.get(`${release}\0${sdk.wasmSdkId}`);
|
|
4139
|
+
if (cached2) return cached2;
|
|
3026
4140
|
const bin = swiftToolchainBin(release);
|
|
3027
4141
|
const swift = import_node_path7.default.join(bin, "swift");
|
|
3028
4142
|
const version = import_node_fs6.default.existsSync(swift) ? (0, import_node_child_process4.execFileSync)(swift, ["--version"], {
|
|
@@ -3063,11 +4177,11 @@ function swiftInstallSteps(release, wasmSdk) {
|
|
|
3063
4177
|
].join("\n");
|
|
3064
4178
|
}
|
|
3065
4179
|
const platform = `debian12${process.arch === "arm64" ? "-aarch64" : ""}`;
|
|
3066
|
-
const
|
|
4180
|
+
const name2 = `${release}-${platform}`;
|
|
3067
4181
|
return [
|
|
3068
4182
|
"install it (Debian 12 shown; other distributions: https://www.swift.org/install/linux/):",
|
|
3069
|
-
` curl -fsSL ${downloads}/${platform}/${release}/${
|
|
3070
|
-
` export PATH=/opt/${
|
|
4183
|
+
` curl -fsSL ${downloads}/${platform}/${release}/${name2}.tar.gz | tar -xz -C /opt`,
|
|
4184
|
+
` export PATH=/opt/${name2}/usr/bin:$PATH`,
|
|
3071
4185
|
` ${sdk}`
|
|
3072
4186
|
].join("\n");
|
|
3073
4187
|
}
|
|
@@ -3156,14 +4270,14 @@ function swiftCommand() {
|
|
|
3156
4270
|
var cacheDir2 = import_node_path9.default.join(import_node_os6.default.tmpdir(), "peach-swift-manifests");
|
|
3157
4271
|
var evaluated = /* @__PURE__ */ new Map();
|
|
3158
4272
|
function dump(dir) {
|
|
3159
|
-
const manifests = import_node_fs8.default.readdirSync(dir).filter((
|
|
4273
|
+
const manifests = import_node_fs8.default.readdirSync(dir).filter((name2) => /^Package(@swift-[\d.]+)?\.swift$/.test(name2)).sort();
|
|
3160
4274
|
const command = swiftCommand();
|
|
3161
4275
|
const key2 = (0, import_node_crypto5.createHash)("sha256").update(JSON.stringify([command, import_node_path9.default.resolve(dir)])).update(
|
|
3162
|
-
manifests.map((
|
|
4276
|
+
manifests.map((name2) => `${name2}\0${import_node_fs8.default.readFileSync(import_node_path9.default.join(dir, name2), "utf8")}`).join("\0")
|
|
3163
4277
|
).digest("hex").slice(0, 32);
|
|
3164
|
-
const
|
|
3165
|
-
if (import_node_fs8.default.existsSync(
|
|
3166
|
-
return { key: key2, raw: record(JSON.parse(import_node_fs8.default.readFileSync(
|
|
4278
|
+
const cached2 = import_node_path9.default.join(cacheDir2, `${key2}.json`);
|
|
4279
|
+
if (import_node_fs8.default.existsSync(cached2))
|
|
4280
|
+
return { key: key2, raw: record(JSON.parse(import_node_fs8.default.readFileSync(cached2, "utf8"))) };
|
|
3167
4281
|
let output;
|
|
3168
4282
|
try {
|
|
3169
4283
|
output = (0, import_node_child_process5.execFileSync)(
|
|
@@ -3191,23 +4305,23 @@ function dump(dir) {
|
|
|
3191
4305
|
);
|
|
3192
4306
|
}
|
|
3193
4307
|
import_node_fs8.default.mkdirSync(cacheDir2, { recursive: true });
|
|
3194
|
-
import_node_fs8.default.writeFileSync(
|
|
4308
|
+
import_node_fs8.default.writeFileSync(cached2, output);
|
|
3195
4309
|
return { key: key2, raw: record(JSON.parse(output)) };
|
|
3196
4310
|
}
|
|
3197
4311
|
function defaultTraits(manifest) {
|
|
3198
4312
|
const traits = new Map(
|
|
3199
4313
|
array(manifest.traits).map((trait) => [
|
|
3200
4314
|
string(record(trait).name) ?? "",
|
|
3201
|
-
array(record(trait).enabledTraits).flatMap((
|
|
4315
|
+
array(record(trait).enabledTraits).flatMap((name2) => string(name2) ?? [])
|
|
3202
4316
|
])
|
|
3203
4317
|
);
|
|
3204
4318
|
const enabled = /* @__PURE__ */ new Set();
|
|
3205
4319
|
const pending = [...traits.get("default") ?? []];
|
|
3206
4320
|
while (pending.length > 0) {
|
|
3207
|
-
const
|
|
3208
|
-
if (enabled.has(
|
|
3209
|
-
enabled.add(
|
|
3210
|
-
pending.push(...traits.get(
|
|
4321
|
+
const name2 = pending.pop();
|
|
4322
|
+
if (enabled.has(name2)) continue;
|
|
4323
|
+
enabled.add(name2);
|
|
4324
|
+
pending.push(...traits.get(name2) ?? []);
|
|
3211
4325
|
}
|
|
3212
4326
|
return enabled;
|
|
3213
4327
|
}
|
|
@@ -3216,7 +4330,7 @@ function linksOnIOS(condition, traits) {
|
|
|
3216
4330
|
const platforms = array(platformNames);
|
|
3217
4331
|
if (platforms.length > 0 && !platforms.includes("ios")) return false;
|
|
3218
4332
|
const gates = array(needed);
|
|
3219
|
-
return gates.length === 0 || gates.some((
|
|
4333
|
+
return gates.length === 0 || gates.some((name2) => traits.has(string(name2) ?? ""));
|
|
3220
4334
|
}
|
|
3221
4335
|
function swiftPackageManifest(dir) {
|
|
3222
4336
|
dir = import_node_fs8.default.realpathSync(dir);
|
|
@@ -3251,10 +4365,10 @@ function swiftPackageManifest(dir) {
|
|
|
3251
4365
|
}
|
|
3252
4366
|
const products = /* @__PURE__ */ new Map();
|
|
3253
4367
|
for (const product of array(raw2.products)) {
|
|
3254
|
-
const { name, targets: targets2, type } = record(product);
|
|
3255
|
-
if (!string(
|
|
4368
|
+
const { name: name2, targets: targets2, type } = record(product);
|
|
4369
|
+
if (!string(name2) || !("library" in record(type))) continue;
|
|
3256
4370
|
products.set(
|
|
3257
|
-
string(
|
|
4371
|
+
string(name2),
|
|
3258
4372
|
array(targets2).flatMap((target) => string(target) ?? [])
|
|
3259
4373
|
);
|
|
3260
4374
|
}
|
|
@@ -3262,12 +4376,12 @@ function swiftPackageManifest(dir) {
|
|
|
3262
4376
|
const names = new Set(array(raw2.targets).map((target) => string(record(target).name)));
|
|
3263
4377
|
for (const entry of array(raw2.targets)) {
|
|
3264
4378
|
const target = record(entry);
|
|
3265
|
-
const
|
|
4379
|
+
const name2 = string(target.name);
|
|
3266
4380
|
const kind = string(target.type);
|
|
3267
|
-
if (!
|
|
4381
|
+
if (!name2 || !isTargetType(kind)) continue;
|
|
3268
4382
|
const declared = string(target.path);
|
|
3269
4383
|
const roots = kind === "test" ? ["Tests"] : ["Sources", "Source", "src", "srcs"];
|
|
3270
|
-
const targetDir = declared ? import_node_path9.default.resolve(dir, declared) : roots.map((root) => import_node_path9.default.join(dir, root,
|
|
4384
|
+
const targetDir = declared ? import_node_path9.default.resolve(dir, declared) : roots.map((root) => import_node_path9.default.join(dir, root, name2)).find((candidate) => import_node_fs8.default.existsSync(candidate)) ?? import_node_path9.default.join(dir, roots[0], name2);
|
|
3271
4385
|
const dependencies = [];
|
|
3272
4386
|
for (const dependency of array(target.dependencies)) {
|
|
3273
4387
|
const { target: local, product, byName } = record(dependency);
|
|
@@ -3300,8 +4414,8 @@ function swiftPackageManifest(dir) {
|
|
|
3300
4414
|
if (string(record(settingKind.defaultIsolation)._0) === "MainActor")
|
|
3301
4415
|
mainActorIsolation = true;
|
|
3302
4416
|
}
|
|
3303
|
-
targets.set(
|
|
3304
|
-
name,
|
|
4417
|
+
targets.set(name2, {
|
|
4418
|
+
name: name2,
|
|
3305
4419
|
type: kind,
|
|
3306
4420
|
dir: targetDir,
|
|
3307
4421
|
sources: target.sources == null ? null : array(target.sources).flatMap((file) => string(file) ?? []),
|
|
@@ -3403,8 +4517,8 @@ function resolveSwiftPackages(options) {
|
|
|
3403
4517
|
const packages = /* @__PURE__ */ new Map();
|
|
3404
4518
|
const load2 = (source) => {
|
|
3405
4519
|
const key2 = source.kind === "local" ? import_node_path10.default.resolve(source.dir) : source.url;
|
|
3406
|
-
const
|
|
3407
|
-
if (
|
|
4520
|
+
const cached2 = packages.get(key2);
|
|
4521
|
+
if (cached2 !== void 0) return cached2;
|
|
3408
4522
|
let loaded2;
|
|
3409
4523
|
if (source.kind === "local") {
|
|
3410
4524
|
loaded2 = { source: key2, remote: false, manifest: swiftPackageManifest(key2) };
|
|
@@ -3428,23 +4542,23 @@ function resolveSwiftPackages(options) {
|
|
|
3428
4542
|
};
|
|
3429
4543
|
const targets = /* @__PURE__ */ new Map();
|
|
3430
4544
|
const targetOutcomes = /* @__PURE__ */ new Map();
|
|
3431
|
-
const resolveTarget = (pkg,
|
|
3432
|
-
const key2 = `${pkg.manifest.dir}\0${
|
|
4545
|
+
const resolveTarget = (pkg, name2) => {
|
|
4546
|
+
const key2 = `${pkg.manifest.dir}\0${name2}`;
|
|
3433
4547
|
if (targetOutcomes.has(key2)) return targetOutcomes.get(key2);
|
|
3434
4548
|
targetOutcomes.set(key2, null);
|
|
3435
4549
|
const outcome = (() => {
|
|
3436
|
-
if (provided.has(
|
|
3437
|
-
const target = pkg.manifest.targets.get(
|
|
3438
|
-
if (!target) return `${import_node_path10.default.basename(pkg.manifest.dir)} declares no target ${
|
|
4550
|
+
if (provided.has(name2)) return null;
|
|
4551
|
+
const target = pkg.manifest.targets.get(name2);
|
|
4552
|
+
if (!target) return `${import_node_path10.default.basename(pkg.manifest.dir)} declares no target ${name2}`;
|
|
3439
4553
|
if (target.type === "binary") {
|
|
3440
|
-
const gap = options.binaryGaps?.get(
|
|
3441
|
-
return `${
|
|
4554
|
+
const gap = options.binaryGaps?.get(name2);
|
|
4555
|
+
return `${name2} ${BINARY}${gap ? `; ${gap}` : ""}`;
|
|
3442
4556
|
}
|
|
3443
|
-
if (target.type === "system") return `${
|
|
3444
|
-
if (target.type !== "regular") return `${
|
|
4557
|
+
if (target.type === "system") return `${name2} is a system C library`;
|
|
4558
|
+
if (target.type !== "regular") return `${name2} is a ${target.type} target`;
|
|
3445
4559
|
const files2 = swiftTargetFiles(pkg.manifest, target);
|
|
3446
4560
|
if (files2.some((file) => C_FAMILY.test(file)))
|
|
3447
|
-
return `${
|
|
4561
|
+
return `${name2} is a C or Objective-C target`;
|
|
3448
4562
|
const reasons = target.dependencies.map((dependency) => {
|
|
3449
4563
|
if (dependency.kind === "target") return resolveTarget(pkg, dependency.name);
|
|
3450
4564
|
const nested = resolveDependencyProduct(pkg, dependency.package, dependency.name);
|
|
@@ -3453,8 +4567,8 @@ function resolveSwiftPackages(options) {
|
|
|
3453
4567
|
const blocked = blocker(reasons);
|
|
3454
4568
|
if (blocked) return blocked;
|
|
3455
4569
|
const relative = files2.map((file) => import_node_path10.default.relative(target.dir, file));
|
|
3456
|
-
targets.set(`${pkg.manifest.dir}\0${
|
|
3457
|
-
name,
|
|
4570
|
+
targets.set(`${pkg.manifest.dir}\0${name2}`, {
|
|
4571
|
+
name: name2,
|
|
3458
4572
|
path: "",
|
|
3459
4573
|
dir: target.dir,
|
|
3460
4574
|
files: files2,
|
|
@@ -3474,7 +4588,7 @@ function resolveSwiftPackages(options) {
|
|
|
3474
4588
|
const resolveProduct = (pkg, product) => {
|
|
3475
4589
|
if (provided.has(product)) return null;
|
|
3476
4590
|
const roots = pkg.manifest.products.get(product);
|
|
3477
|
-
const reason = !roots ? `${import_node_path10.default.basename(pkg.manifest.dir)} has no library ${product}` : blocker(roots.map((
|
|
4591
|
+
const reason = !roots ? `${import_node_path10.default.basename(pkg.manifest.dir)} has no library ${product}` : blocker(roots.map((name2) => resolveTarget(pkg, name2)));
|
|
3478
4592
|
productOutcomes.set(`${pkg.manifest.dir}\0${product}`, { pkg, reason });
|
|
3479
4593
|
return reason;
|
|
3480
4594
|
};
|
|
@@ -3505,21 +4619,21 @@ function resolveSwiftPackages(options) {
|
|
|
3505
4619
|
}
|
|
3506
4620
|
for (const pkg of packages.values()) {
|
|
3507
4621
|
if (typeof pkg === "string") continue;
|
|
3508
|
-
for (const [
|
|
4622
|
+
for (const [name2, target] of pkg.manifest.targets) {
|
|
3509
4623
|
if (target.type === "test" || target.type === "plugin" || target.type === "macro")
|
|
3510
4624
|
continue;
|
|
3511
4625
|
if (target.type === "executable") continue;
|
|
3512
4626
|
if (target.type === "binary")
|
|
3513
4627
|
result.binaries.push({
|
|
3514
|
-
target:
|
|
4628
|
+
target: name2,
|
|
3515
4629
|
source: pkg.source,
|
|
3516
4630
|
url: target.url,
|
|
3517
4631
|
dir: target.dir,
|
|
3518
4632
|
reached: false
|
|
3519
4633
|
});
|
|
3520
|
-
const reason = resolveTarget(pkg,
|
|
3521
|
-
if (reason && !result.modules.has(
|
|
3522
|
-
result.modules.set(
|
|
4634
|
+
const reason = resolveTarget(pkg, name2);
|
|
4635
|
+
if (reason && !result.modules.has(name2))
|
|
4636
|
+
result.modules.set(name2, { source: pkg.source, reason });
|
|
3523
4637
|
}
|
|
3524
4638
|
}
|
|
3525
4639
|
for (const [key2, { pkg, reason }] of productOutcomes) {
|
|
@@ -3528,11 +4642,11 @@ function resolveSwiftPackages(options) {
|
|
|
3528
4642
|
result.modules.set(product, { source: pkg.source, reason });
|
|
3529
4643
|
}
|
|
3530
4644
|
const reached = /* @__PURE__ */ new Set();
|
|
3531
|
-
const reach = (pkg,
|
|
3532
|
-
const key2 = `${pkg.manifest.dir}\0${
|
|
4645
|
+
const reach = (pkg, name2) => {
|
|
4646
|
+
const key2 = `${pkg.manifest.dir}\0${name2}`;
|
|
3533
4647
|
if (reached.has(key2)) return;
|
|
3534
4648
|
reached.add(key2);
|
|
3535
|
-
for (const dependency of pkg.manifest.targets.get(
|
|
4649
|
+
for (const dependency of pkg.manifest.targets.get(name2)?.dependencies ?? []) {
|
|
3536
4650
|
if (dependency.kind === "target") reach(pkg, dependency.name);
|
|
3537
4651
|
else {
|
|
3538
4652
|
const source = pkg.manifest.packages.get(dependency.package);
|
|
@@ -3560,11 +4674,54 @@ function resolveSwiftPackages(options) {
|
|
|
3560
4674
|
// src/swift-standins.ts
|
|
3561
4675
|
var import_node_child_process7 = require("node:child_process");
|
|
3562
4676
|
var import_node_crypto6 = require("node:crypto");
|
|
3563
|
-
var
|
|
4677
|
+
var import_node_fs11 = __toESM(require("node:fs"), 1);
|
|
3564
4678
|
var import_node_os7 = __toESM(require("node:os"), 1);
|
|
3565
4679
|
var import_node_path11 = __toESM(require("node:path"), 1);
|
|
3566
4680
|
|
|
4681
|
+
// src/cli-version.ts
|
|
4682
|
+
var import_node_fs10 = require("node:fs");
|
|
4683
|
+
var import_node_url = require("node:url");
|
|
4684
|
+
|
|
4685
|
+
// src/public-brand.ts
|
|
4686
|
+
var name = "Peach";
|
|
4687
|
+
var peachPublicBrand = Object.freeze({
|
|
4688
|
+
name,
|
|
4689
|
+
packageName: "peachsim",
|
|
4690
|
+
commandName: "peach",
|
|
4691
|
+
domain: "peachsim.com",
|
|
4692
|
+
origin: "https://peachsim.com"
|
|
4693
|
+
});
|
|
4694
|
+
var rnxPublicBrand = peachPublicBrand;
|
|
4695
|
+
|
|
4696
|
+
// src/cli-version.ts
|
|
4697
|
+
var import_meta = {};
|
|
4698
|
+
var cached = null;
|
|
4699
|
+
function getCliVersion() {
|
|
4700
|
+
if (cached != null) return cached;
|
|
4701
|
+
if (typeof __PEACH_CLI_VERSION__ !== "undefined" && typeof __PEACH_CLI_VERSION__ === "string" && __PEACH_CLI_VERSION__) {
|
|
4702
|
+
cached = __PEACH_CLI_VERSION__;
|
|
4703
|
+
return cached;
|
|
4704
|
+
}
|
|
4705
|
+
const candidates = [
|
|
4706
|
+
() => (0, import_node_url.fileURLToPath)(import_meta.resolve(`${rnxPublicBrand.packageName}/package.json`)),
|
|
4707
|
+
() => (0, import_node_url.fileURLToPath)(new URL("../package.json", __sootsim_import_meta_url))
|
|
4708
|
+
];
|
|
4709
|
+
for (const resolve2 of candidates) {
|
|
4710
|
+
try {
|
|
4711
|
+
const version = JSON.parse((0, import_node_fs10.readFileSync)(resolve2(), "utf8")).version;
|
|
4712
|
+
if (typeof version === "string" && version) {
|
|
4713
|
+
cached = version;
|
|
4714
|
+
return cached;
|
|
4715
|
+
}
|
|
4716
|
+
} catch {
|
|
4717
|
+
}
|
|
4718
|
+
}
|
|
4719
|
+
cached = "0.0.0";
|
|
4720
|
+
return cached;
|
|
4721
|
+
}
|
|
4722
|
+
|
|
3567
4723
|
// src/swift-standin-emit.ts
|
|
4724
|
+
var STANDIN_EMIT_VERSION = "1";
|
|
3568
4725
|
var TYPE_KINDS = /* @__PURE__ */ new Set([
|
|
3569
4726
|
"swift.class",
|
|
3570
4727
|
"swift.struct",
|
|
@@ -3598,7 +4755,7 @@ var KEEP_EXTERNAL = /* @__PURE__ */ new Map([
|
|
|
3598
4755
|
]);
|
|
3599
4756
|
var LEADING_ATTRS = /^((?:@\w+(?:\([^)]*\))?\s*|nonisolated\s+)*)(.*)$/s;
|
|
3600
4757
|
var OBJC_ONLY = /@(?:objcMembers|objc|IBOutlet|IBInspectable|IBAction|IBSegueAction|GKInspectable|nonobjc|NSCopying|NSManaged)(?:\([^)]*\))?\s*|\bdynamic\s+/g;
|
|
3601
|
-
var text = (symbol) => (symbol.declarationFragments ?? []).map((fragment) => fragment.spelling).join("").replace(OBJC_ONLY, "").replace(/(^|\s)optional (?=func|var|init|subscript|static|class)/, "$1");
|
|
4758
|
+
var text = (symbol) => (symbol.declarationFragments ?? []).map((fragment) => fragment.spelling).join("").replace(OBJC_ONLY, "").replace(/(^|\s)optional (?=func|var|init|subscript|static|class)/, "$1").replace(/\bAutoreleasingUnsafeMutablePointer</g, "UnsafeMutablePointer<");
|
|
3602
4759
|
var leaf = (symbol) => symbol.pathComponents[symbol.pathComponents.length - 1];
|
|
3603
4760
|
var pathOf = (symbol) => symbol.pathComponents.join(".");
|
|
3604
4761
|
var unavailable = (symbol) => (symbol.availability ?? []).some(
|
|
@@ -3606,7 +4763,7 @@ var unavailable = (symbol) => (symbol.availability ?? []).some(
|
|
|
3606
4763
|
);
|
|
3607
4764
|
var witnessKey = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.") ? "type" : "instance"}|${leaf(symbol)}`;
|
|
3608
4765
|
var isObjC = (symbol) => symbol.identifier.precise.startsWith("c:");
|
|
3609
|
-
var trap = (
|
|
4766
|
+
var trap = (path16) => `fatalError("${path16} is a binary framework peach cannot run")`;
|
|
3610
4767
|
function emitSwiftStandin(graphs, options) {
|
|
3611
4768
|
const skipped = [];
|
|
3612
4769
|
const behavior = options.behavior ?? /* @__PURE__ */ new Map();
|
|
@@ -3639,7 +4796,11 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3639
4796
|
if (local) return { name: pathOf(local), local: true };
|
|
3640
4797
|
if (!fallback) return null;
|
|
3641
4798
|
const parts = fallback.split(".");
|
|
3642
|
-
return {
|
|
4799
|
+
return {
|
|
4800
|
+
name: family.has(parts[0]) ? parts.join(".") : parts.slice(1).join(".") || parts[0],
|
|
4801
|
+
module: parts[0],
|
|
4802
|
+
local: false
|
|
4803
|
+
};
|
|
3643
4804
|
};
|
|
3644
4805
|
for (const graph of graphs)
|
|
3645
4806
|
for (const edge of graph.relationships) {
|
|
@@ -3650,10 +4811,13 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3650
4811
|
const parent = byId.get(edge.target);
|
|
3651
4812
|
if (parent) {
|
|
3652
4813
|
owner.set(edge.source, edge.target);
|
|
3653
|
-
children.set(edge.target, [
|
|
4814
|
+
children.set(edge.target, [
|
|
4815
|
+
...children.get(edge.target) ?? [],
|
|
4816
|
+
...all(edge.source)
|
|
4817
|
+
]);
|
|
3654
4818
|
} else if (edge.targetFallback) {
|
|
3655
|
-
const
|
|
3656
|
-
external.set(
|
|
4819
|
+
const name2 = nameOf(edge.target, edge.targetFallback).name;
|
|
4820
|
+
external.set(name2, [...external.get(name2) ?? [], ...all(edge.source)]);
|
|
3657
4821
|
owner.set(edge.source, edge.target);
|
|
3658
4822
|
}
|
|
3659
4823
|
break;
|
|
@@ -3667,8 +4831,9 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3667
4831
|
case "conformsTo": {
|
|
3668
4832
|
const target = nameOf(edge.target, edge.targetFallback);
|
|
3669
4833
|
const kept = KEEP_EXTERNAL.get(edge.target);
|
|
3670
|
-
const
|
|
3671
|
-
if (
|
|
4834
|
+
const name2 = kept ?? (target && (target.local || family.has(target.module ?? "")) ? target.name : null);
|
|
4835
|
+
if (name2)
|
|
4836
|
+
conforms.set(edge.source, [...conforms.get(edge.source) ?? [], name2]);
|
|
3672
4837
|
if (byId.has(edge.target)) {
|
|
3673
4838
|
const map = source.kind.identifier === "swift.protocol" ? protocolParents : conformIds;
|
|
3674
4839
|
map.set(edge.source, [...map.get(edge.source) ?? [], edge.target]);
|
|
@@ -3681,7 +4846,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3681
4846
|
if (edge.kind === "optionalRequirementOf") optional.add(edge.source);
|
|
3682
4847
|
if (byId.has(edge.target) && !owner.has(edge.source)) {
|
|
3683
4848
|
owner.set(edge.source, edge.target);
|
|
3684
|
-
children.set(edge.target, [
|
|
4849
|
+
children.set(edge.target, [
|
|
4850
|
+
...children.get(edge.target) ?? [],
|
|
4851
|
+
...all(edge.source)
|
|
4852
|
+
]);
|
|
3685
4853
|
}
|
|
3686
4854
|
break;
|
|
3687
4855
|
case "overrides":
|
|
@@ -3699,10 +4867,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3699
4867
|
owners.push(...physical.map(() => current));
|
|
3700
4868
|
};
|
|
3701
4869
|
const scoped = (body) => (symbol, ...rest) => {
|
|
3702
|
-
const
|
|
3703
|
-
if (omit.has(
|
|
4870
|
+
const path16 = pathOf(symbol);
|
|
4871
|
+
if (omit.has(path16)) return void skipped.push({ path: path16, reason: omit.get(path16) });
|
|
3704
4872
|
const previous = current;
|
|
3705
|
-
current =
|
|
4873
|
+
current = path16;
|
|
3706
4874
|
try {
|
|
3707
4875
|
body(symbol, ...rest);
|
|
3708
4876
|
} finally {
|
|
@@ -3720,59 +4888,77 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3720
4888
|
});
|
|
3721
4889
|
};
|
|
3722
4890
|
const access = (symbol, openOwner) => symbol.accessLevel === "open" && openOwner ? "open" : "public";
|
|
3723
|
-
const emitMember = scoped(
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
const
|
|
3759
|
-
const
|
|
3760
|
-
const
|
|
3761
|
-
|
|
4891
|
+
const emitMember = scoped(
|
|
4892
|
+
(member, indent, context) => {
|
|
4893
|
+
const path16 = pathOf(member);
|
|
4894
|
+
if (TYPE_KINDS.has(member.kind.identifier)) {
|
|
4895
|
+
emitType(member, indent);
|
|
4896
|
+
return;
|
|
4897
|
+
}
|
|
4898
|
+
if (member.kind.identifier === "swift.enum.case") return;
|
|
4899
|
+
if (!MEMBER_KINDS.has(member.kind.identifier)) {
|
|
4900
|
+
skipped.push({ path: path16, reason: `unhandled ${member.kind.identifier}` });
|
|
4901
|
+
return;
|
|
4902
|
+
}
|
|
4903
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
4904
|
+
const modifiers = /^((?:(?:required|final|override|convenience|unowned(?:\(\w+\))?|weak|lazy|nonisolated|mutating|nonmutating) )*)(.*)$/s.exec(
|
|
4905
|
+
rest
|
|
4906
|
+
);
|
|
4907
|
+
const flags = new Set(
|
|
4908
|
+
modifiers[1].trim().split(/\s+/).filter(Boolean).map((flag) => flag.replace(/\(.*/, ""))
|
|
4909
|
+
);
|
|
4910
|
+
const required = context.inClass && flags.has("required");
|
|
4911
|
+
const final = context.inClass && flags.has("final") ? "final " : "";
|
|
4912
|
+
const mutating = flags.has("mutating") ? "mutating " : flags.has("nonmutating") ? "nonmutating " : "";
|
|
4913
|
+
let core = `${context.inClass && flags.has("convenience") ? "convenience " : ""}${modifiers[2]}`;
|
|
4914
|
+
const override = context.inClass && !options.plain?.has(path16) && (flags.has("override") || overrides.has(member.identifier.precise) || isObjC(member) && path16.endsWith(".init()")) ? "override " : "";
|
|
4915
|
+
const head = `${indent}${attrs}${access(member, context.openOwner)} ${required ? "required " : ""}${final}${override}${mutating}`;
|
|
4916
|
+
const measured = behavior.get(path16);
|
|
4917
|
+
if (measured) used.add(path16);
|
|
4918
|
+
const overloadBody = /\basync\b/.test(core) ? measured?.asyncBody : /\bResult</.test(core) ? measured?.resultBody : void 0;
|
|
4919
|
+
const body = overloadBody ?? measured?.body ?? trap(path16);
|
|
4920
|
+
switch (member.kind.identifier) {
|
|
4921
|
+
case "swift.property":
|
|
4922
|
+
case "swift.type.property":
|
|
4923
|
+
case "swift.subscript":
|
|
4924
|
+
case "swift.type.subscript": {
|
|
4925
|
+
const accessors = ACCESSORS.exec(core);
|
|
4926
|
+
const decl = core.replace(ACCESSORS, "").trimEnd();
|
|
4927
|
+
const effects = `${accessors?.[1] ?? ""}${accessors?.[2] ?? ""}`;
|
|
4928
|
+
const settable = accessors ? Boolean(accessors[3]) : /^(?:static |class )?var /.test(core);
|
|
4929
|
+
const computed = decl.replace(/^((?:static |class )*)let /, "$1var ");
|
|
4930
|
+
if (measured?.stored !== void 0) {
|
|
4931
|
+
const ownership = flags.has("weak") ? "weak " : flags.has("unowned") ? "unowned " : "";
|
|
4932
|
+
const setter = settable ? "" : "internal(set) ";
|
|
4933
|
+
const value = measured.stored ? ` = ${measured.stored}` : "";
|
|
4934
|
+
emit(
|
|
4935
|
+
`${indent}${attrs}${access(member, context.openOwner)} ${setter}${final}${override}${ownership}${computed}${value}`
|
|
4936
|
+
);
|
|
4937
|
+
return;
|
|
4938
|
+
}
|
|
4939
|
+
emit(
|
|
4940
|
+
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` set { ${measured?.set ?? trap(path16)} }` : ""} }`
|
|
4941
|
+
);
|
|
3762
4942
|
return;
|
|
3763
4943
|
}
|
|
3764
|
-
|
|
3765
|
-
|
|
4944
|
+
default:
|
|
4945
|
+
emit(`${head}${core} { ${body} }`);
|
|
3766
4946
|
}
|
|
3767
|
-
default:
|
|
3768
|
-
emit(`${head}${core} { ${body} }`);
|
|
3769
4947
|
}
|
|
3770
|
-
|
|
4948
|
+
);
|
|
3771
4949
|
const header = (symbol, keyword, indent) => {
|
|
3772
4950
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
3773
|
-
const shape = new RegExp(
|
|
4951
|
+
const shape = new RegExp(
|
|
4952
|
+
`^(?:final )?${keyword}\\s+\`?(\\w+)\`?(<[^>]*>)?\\s*(?::\\s*([^{]*?))?(\\s+where\\s+.*)?$`
|
|
4953
|
+
).exec(rest);
|
|
3774
4954
|
if (!shape) return null;
|
|
3775
|
-
return {
|
|
4955
|
+
return {
|
|
4956
|
+
attrs,
|
|
4957
|
+
name: shape[1],
|
|
4958
|
+
generics: shape[2] ?? "",
|
|
4959
|
+
where: shape[4] ?? "",
|
|
4960
|
+
indent
|
|
4961
|
+
};
|
|
3776
4962
|
};
|
|
3777
4963
|
const externalRoot = (id) => {
|
|
3778
4964
|
for (let at = id; at; at = superId.get(at)) {
|
|
@@ -3787,7 +4973,8 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3787
4973
|
if (!parentSymbol) return null;
|
|
3788
4974
|
if (/^(?:final )?class\s+\w+</.test(LEADING_ATTRS.exec(text(parentSymbol))[2]) && !options.superclasses?.has(pathOf(byId.get(id))))
|
|
3789
4975
|
return `superclass ${pathOf(parentSymbol)} is generic and the graph omits its arguments`;
|
|
3790
|
-
if (unavailable(parentSymbol))
|
|
4976
|
+
if (unavailable(parentSymbol))
|
|
4977
|
+
return `superclass ${pathOf(parentSymbol)} is unavailable`;
|
|
3791
4978
|
return classBlocked(parent) && `superclass ${pathOf(parentSymbol)} is left out`;
|
|
3792
4979
|
};
|
|
3793
4980
|
const objcProtocols = new Set(
|
|
@@ -3801,153 +4988,203 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3801
4988
|
const list2 = [...first ? [first] : [], ...conforms.get(id) ?? []];
|
|
3802
4989
|
return [...new Set(list2)];
|
|
3803
4990
|
};
|
|
3804
|
-
const emitType = scoped(
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
case "swift.class": {
|
|
3815
|
-
const shape = header(symbol, "class", indent);
|
|
3816
|
-
if (!shape) return void skipped.push({ path: path15, reason: `unparsed class ${text(symbol)}` });
|
|
3817
|
-
const parent = options.superclasses?.get(path15) ?? superclass.get(id);
|
|
3818
|
-
const blocked = classBlocked(id);
|
|
3819
|
-
if (blocked) return void skipped.push({ path: path15, reason: blocked });
|
|
3820
|
-
const ancestors = /* @__PURE__ */ new Set();
|
|
3821
|
-
for (let at = superId.get(id); at; at = superId.get(at))
|
|
3822
|
-
for (const name of conforms.get(at) ?? []) ancestors.add(name);
|
|
3823
|
-
const list2 = [
|
|
3824
|
-
...parent ? [parent] : [],
|
|
3825
|
-
...(conforms.get(id) ?? []).filter(
|
|
3826
|
-
(name) => !ancestors.has(name) && !(parent && [...KEEP_EXTERNAL.values()].includes(name))
|
|
3827
|
-
)
|
|
3828
|
-
].filter((name, at, all2) => all2.indexOf(name) === at);
|
|
3829
|
-
const parentSymbol = superId.has(id) ? byId.get(superId.get(id)) : void 0;
|
|
3830
|
-
const open = symbol.accessLevel === "open" && (!parentSymbol || parentSymbol.accessLevel === "open");
|
|
3831
|
-
emit(`${indent}${shape.attrs}${open ? "open" : "public"} class ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${selfConforming(shape.where)} {`);
|
|
3832
|
-
const members = membersOf(id);
|
|
3833
|
-
for (const member of members)
|
|
3834
|
-
emitMember(member, inner, { openOwner: open, inClass: true, ownerName: shape.name });
|
|
3835
|
-
const designated = members.some(
|
|
3836
|
-
(member) => member.kind.identifier === "swift.init" && !text(member).startsWith("convenience")
|
|
3837
|
-
);
|
|
3838
|
-
const have = /* @__PURE__ */ new Set();
|
|
3839
|
-
for (let at = id; at; at = superId.get(at))
|
|
3840
|
-
for (const member of children.get(at) ?? []) have.add(witnessKey(member));
|
|
3841
|
-
const protocols = [];
|
|
3842
|
-
const visit = (protocolId) => {
|
|
3843
|
-
if (protocols.includes(protocolId)) return;
|
|
3844
|
-
protocols.push(protocolId);
|
|
3845
|
-
for (const edge of protocolParents.get(protocolId) ?? []) visit(edge);
|
|
3846
|
-
};
|
|
3847
|
-
for (const protocolId of conformIds.get(id) ?? []) visit(protocolId);
|
|
3848
|
-
for (const protocolId of protocols)
|
|
3849
|
-
for (const member of children.get(protocolId) ?? []) {
|
|
3850
|
-
if (!requirement.has(member.identifier.precise) || optional.has(member.identifier.precise)) continue;
|
|
3851
|
-
if (isObjC(member) && / async\b/.test(text(member))) continue;
|
|
3852
|
-
if (have.has(witnessKey(member)) || member.kind.identifier === "swift.associatedtype") continue;
|
|
3853
|
-
have.add(witnessKey(member));
|
|
3854
|
-
emitWitness(member, inner, path15);
|
|
3855
|
-
}
|
|
3856
|
-
const coder = members.some((member) => leaf(member) === "init(coder:)");
|
|
3857
|
-
if (designated && !coder && externalRoot(id) !== "NSObject" && externalRoot(id) !== null)
|
|
3858
|
-
emit(`${inner}public required init?(coder: NSCoder) { ${trap(`${path15}.init(coder:)`)} }`);
|
|
3859
|
-
emit(`${indent}}`);
|
|
3860
|
-
return;
|
|
3861
|
-
}
|
|
3862
|
-
case "swift.struct": {
|
|
3863
|
-
const shape = header(symbol, "struct", indent);
|
|
3864
|
-
if (!shape) return void skipped.push({ path: path15, reason: `unparsed struct ${text(symbol)}` });
|
|
3865
|
-
const members = membersOf(id);
|
|
3866
|
-
const raw2 = rawType(members);
|
|
3867
|
-
const list2 = inheritance(id);
|
|
3868
|
-
emit(`${indent}${shape.attrs}public struct ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`);
|
|
3869
|
-
if (raw2) {
|
|
3870
|
-
emit(`${inner}public let rawValue: ${raw2}`);
|
|
3871
|
-
emit(`${inner}public init(rawValue: ${raw2}) { self.rawValue = rawValue }`);
|
|
4991
|
+
const emitType = scoped(
|
|
4992
|
+
(symbol, indent) => {
|
|
4993
|
+
const path16 = pathOf(symbol);
|
|
4994
|
+
const id = symbol.identifier.precise;
|
|
4995
|
+
const inner = `${indent} `;
|
|
4996
|
+
switch (symbol.kind.identifier) {
|
|
4997
|
+
case "swift.typealias": {
|
|
4998
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
4999
|
+
emit(`${indent}${attrs}public ${rest}`);
|
|
5000
|
+
return;
|
|
3872
5001
|
}
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
5002
|
+
case "swift.class": {
|
|
5003
|
+
const shape = header(symbol, "class", indent);
|
|
5004
|
+
if (!shape)
|
|
5005
|
+
return void skipped.push({ path: path16, reason: `unparsed class ${text(symbol)}` });
|
|
5006
|
+
const parent = options.superclasses?.get(path16) ?? superclass.get(id);
|
|
5007
|
+
const blocked = classBlocked(id);
|
|
5008
|
+
if (blocked) return void skipped.push({ path: path16, reason: blocked });
|
|
5009
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
5010
|
+
for (let at = superId.get(id); at; at = superId.get(at))
|
|
5011
|
+
for (const name2 of conforms.get(at) ?? []) ancestors.add(name2);
|
|
5012
|
+
const list2 = [
|
|
5013
|
+
...parent ? [parent] : [],
|
|
5014
|
+
...(conforms.get(id) ?? []).filter(
|
|
5015
|
+
(name2) => !ancestors.has(name2) && !(parent && [...KEEP_EXTERNAL.values()].includes(name2))
|
|
5016
|
+
)
|
|
5017
|
+
].filter((name2, at, all2) => all2.indexOf(name2) === at);
|
|
5018
|
+
const parentSymbol = superId.has(id) ? byId.get(superId.get(id)) : void 0;
|
|
5019
|
+
const open = symbol.accessLevel === "open" && (!parentSymbol || parentSymbol.accessLevel === "open");
|
|
5020
|
+
emit(
|
|
5021
|
+
`${indent}${shape.attrs}${open ? "open" : "public"} class ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${selfConforming(shape.where)} {`
|
|
5022
|
+
);
|
|
5023
|
+
const members = membersOf(id);
|
|
5024
|
+
for (const member of members)
|
|
5025
|
+
emitMember(member, inner, {
|
|
5026
|
+
openOwner: open,
|
|
5027
|
+
inClass: true,
|
|
5028
|
+
ownerName: shape.name
|
|
5029
|
+
});
|
|
5030
|
+
const designated = members.some(
|
|
5031
|
+
(member) => member.kind.identifier === "swift.init" && !text(member).startsWith("convenience")
|
|
5032
|
+
);
|
|
5033
|
+
const have = /* @__PURE__ */ new Set();
|
|
5034
|
+
for (let at = id; at; at = superId.get(at))
|
|
5035
|
+
for (const member of children.get(at) ?? []) have.add(witnessKey(member));
|
|
5036
|
+
const protocols = [];
|
|
5037
|
+
const visit = (protocolId) => {
|
|
5038
|
+
if (protocols.includes(protocolId)) return;
|
|
5039
|
+
protocols.push(protocolId);
|
|
5040
|
+
for (const edge of protocolParents.get(protocolId) ?? []) visit(edge);
|
|
5041
|
+
};
|
|
5042
|
+
for (const protocolId of conformIds.get(id) ?? []) visit(protocolId);
|
|
5043
|
+
for (const protocolId of protocols)
|
|
5044
|
+
for (const member of children.get(protocolId) ?? []) {
|
|
5045
|
+
if (!requirement.has(member.identifier.precise) || optional.has(member.identifier.precise))
|
|
5046
|
+
continue;
|
|
5047
|
+
if (isObjC(member) && / async\b/.test(text(member))) continue;
|
|
5048
|
+
if (have.has(witnessKey(member)) || member.kind.identifier === "swift.associatedtype")
|
|
5049
|
+
continue;
|
|
5050
|
+
have.add(witnessKey(member));
|
|
5051
|
+
emitWitness(member, inner, path16);
|
|
5052
|
+
}
|
|
5053
|
+
const coder = members.some((member) => leaf(member) === "init(coder:)");
|
|
5054
|
+
if (designated && !coder && externalRoot(id) !== "NSObject" && externalRoot(id) !== null)
|
|
5055
|
+
emit(
|
|
5056
|
+
`${inner}public required init?(coder: NSCoder) { ${trap(`${path16}.init(coder:)`)} }`
|
|
5057
|
+
);
|
|
5058
|
+
emit(`${indent}}`);
|
|
5059
|
+
return;
|
|
3882
5060
|
}
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
emit(`${indent}${shape.attrs}public enum ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`);
|
|
3897
|
-
const seenValues = /* @__PURE__ */ new Map();
|
|
3898
|
-
for (const member of cases) {
|
|
3899
|
-
const value = values.get(member.identifier.precise);
|
|
3900
|
-
if (value !== void 0 && seenValues.has(value)) {
|
|
3901
|
-
emit(`${inner}public static var ${tick(leaf(member))}: ${shape.name} { .${seenValues.get(value)} }`);
|
|
3902
|
-
continue;
|
|
5061
|
+
case "swift.struct": {
|
|
5062
|
+
const shape = header(symbol, "struct", indent);
|
|
5063
|
+
if (!shape)
|
|
5064
|
+
return void skipped.push({ path: path16, reason: `unparsed struct ${text(symbol)}` });
|
|
5065
|
+
const members = membersOf(id);
|
|
5066
|
+
const raw2 = rawType(members);
|
|
5067
|
+
const list2 = inheritance(id);
|
|
5068
|
+
emit(
|
|
5069
|
+
`${indent}${shape.attrs}public struct ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`
|
|
5070
|
+
);
|
|
5071
|
+
if (raw2) {
|
|
5072
|
+
emit(`${inner}public let rawValue: ${raw2}`);
|
|
5073
|
+
emit(`${inner}public init(rawValue: ${raw2}) { self.rawValue = rawValue }`);
|
|
3903
5074
|
}
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
5075
|
+
for (const member of members) {
|
|
5076
|
+
if (raw2 && (leaf(member) === "rawValue" || leaf(member) === "init(rawValue:)" || leaf(member) === "init(_:)"))
|
|
5077
|
+
continue;
|
|
5078
|
+
const value = values.get(member.identifier.precise);
|
|
5079
|
+
if (value !== void 0 && member.kind.identifier === "swift.type.property") {
|
|
5080
|
+
emit(
|
|
5081
|
+
`${inner}public static let ${tick(leaf(member))} = ${shape.name}(rawValue: ${value})`
|
|
5082
|
+
);
|
|
5083
|
+
continue;
|
|
5084
|
+
}
|
|
5085
|
+
emitMember(member, inner, {
|
|
5086
|
+
openOwner: false,
|
|
5087
|
+
inClass: false,
|
|
5088
|
+
ownerName: shape.name
|
|
5089
|
+
});
|
|
5090
|
+
}
|
|
5091
|
+
emit(`${indent}}`);
|
|
5092
|
+
return;
|
|
3912
5093
|
}
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
5094
|
+
case "swift.enum": {
|
|
5095
|
+
const shape = header(symbol, "enum", indent);
|
|
5096
|
+
if (!shape)
|
|
5097
|
+
return void skipped.push({ path: path16, reason: `unparsed enum ${text(symbol)}` });
|
|
5098
|
+
const members = membersOf(id);
|
|
5099
|
+
const raw2 = rawType(members);
|
|
5100
|
+
const cases = (children.get(id) ?? []).filter(
|
|
5101
|
+
(member) => member.kind.identifier === "swift.enum.case"
|
|
5102
|
+
);
|
|
5103
|
+
const missing = raw2 ? cases.filter((member) => !values.has(member.identifier.precise)) : [];
|
|
5104
|
+
if (raw2 && isObjC(symbol) && missing.length > 0)
|
|
5105
|
+
return void skipped.push({
|
|
5106
|
+
path: path16,
|
|
5107
|
+
reason: `no header value for ${missing.map(leaf).join(", ")}`
|
|
5108
|
+
});
|
|
5109
|
+
const list2 = inheritance(id, raw2 ?? void 0).filter(
|
|
5110
|
+
(name2) => name2 !== "RawRepresentable"
|
|
5111
|
+
);
|
|
5112
|
+
emit(
|
|
5113
|
+
`${indent}${shape.attrs}public enum ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`
|
|
5114
|
+
);
|
|
5115
|
+
const seenValues = /* @__PURE__ */ new Map();
|
|
5116
|
+
for (const member of cases) {
|
|
5117
|
+
const value = values.get(member.identifier.precise);
|
|
5118
|
+
if (value !== void 0 && seenValues.has(value)) {
|
|
5119
|
+
emit(
|
|
5120
|
+
`${inner}public static var ${tick(leaf(member))}: ${shape.name} { .${seenValues.get(value)} }`
|
|
5121
|
+
);
|
|
5122
|
+
continue;
|
|
5123
|
+
}
|
|
5124
|
+
if (value !== void 0) seenValues.set(value, tick(leaf(member)));
|
|
5125
|
+
const caseText = text(member).replace(/^case\s+/, "");
|
|
5126
|
+
emit(`${inner}case ${caseText}${value !== void 0 ? ` = ${value}` : ""}`);
|
|
3927
5127
|
}
|
|
3928
|
-
const
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
5128
|
+
for (const member of members) {
|
|
5129
|
+
if (member.kind.identifier === "swift.enum.case") continue;
|
|
5130
|
+
if (raw2 && (leaf(member) === "rawValue" || leaf(member) === "init(rawValue:)"))
|
|
5131
|
+
continue;
|
|
5132
|
+
emitMember(member, inner, {
|
|
5133
|
+
openOwner: false,
|
|
5134
|
+
inClass: false,
|
|
5135
|
+
ownerName: shape.name
|
|
5136
|
+
});
|
|
3932
5137
|
}
|
|
3933
|
-
|
|
3934
|
-
|
|
5138
|
+
emit(`${indent}}`);
|
|
5139
|
+
return;
|
|
3935
5140
|
}
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
5141
|
+
case "swift.protocol": {
|
|
5142
|
+
const shape = header(symbol, "protocol", indent);
|
|
5143
|
+
if (!shape)
|
|
5144
|
+
return void skipped.push({
|
|
5145
|
+
path: path16,
|
|
5146
|
+
reason: `unparsed protocol ${text(symbol)}`
|
|
5147
|
+
});
|
|
5148
|
+
const list2 = [...isObjC(symbol) ? ["AnyObject"] : [], ...inheritance(id)];
|
|
5149
|
+
emit(
|
|
5150
|
+
`${indent}${shape.attrs}public protocol ${shape.name}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`
|
|
5151
|
+
);
|
|
5152
|
+
const members = membersOf(id);
|
|
5153
|
+
const defaults = [];
|
|
5154
|
+
for (const member of members) {
|
|
5155
|
+
if (member.kind.identifier === "swift.associatedtype") {
|
|
5156
|
+
emit(`${inner}${text(member)}`);
|
|
5157
|
+
continue;
|
|
5158
|
+
}
|
|
5159
|
+
const asyncTwin = isObjC(member) && / async\b/.test(text(member));
|
|
5160
|
+
if (!requirement.has(member.identifier.precise) || asyncTwin) {
|
|
5161
|
+
defaults.push(member);
|
|
5162
|
+
continue;
|
|
5163
|
+
}
|
|
5164
|
+
emitRequirement(member, inner);
|
|
5165
|
+
if (optional.has(member.identifier.precise)) defaults.push(member);
|
|
3944
5166
|
}
|
|
3945
5167
|
emit(`${indent}}`);
|
|
5168
|
+
if (defaults.length > 0) {
|
|
5169
|
+
emit(`${indent}extension ${path16} {`);
|
|
5170
|
+
for (const member of defaults) {
|
|
5171
|
+
const decl = text(member);
|
|
5172
|
+
if (optional.has(member.identifier.precise) && member.kind.identifier === "swift.method" && !decl.replace(/\([^)]*\)/g, "").includes("->") && !/ async\b/.test(decl))
|
|
5173
|
+
emitNoop(member, inner);
|
|
5174
|
+
else
|
|
5175
|
+
emitMember(member, inner, {
|
|
5176
|
+
openOwner: false,
|
|
5177
|
+
inClass: false,
|
|
5178
|
+
ownerName: shape.name
|
|
5179
|
+
});
|
|
5180
|
+
}
|
|
5181
|
+
emit(`${indent}}`);
|
|
5182
|
+
}
|
|
5183
|
+
return;
|
|
3946
5184
|
}
|
|
3947
|
-
return;
|
|
3948
5185
|
}
|
|
3949
5186
|
}
|
|
3950
|
-
|
|
5187
|
+
);
|
|
3951
5188
|
const emitWitness = (member, indent, owner2) => {
|
|
3952
5189
|
const { 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
3953
5190
|
const decl = rest.replace(/^(?:weak |unowned )/, "").replace(/^((?:static )?)let /, "$1var ");
|
|
@@ -3956,37 +5193,46 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3956
5193
|
if (member.kind.identifier === "swift.property" || member.kind.identifier === "swift.type.property") {
|
|
3957
5194
|
const accessors = ACCESSORS.exec(decl);
|
|
3958
5195
|
const bare = decl.replace(ACCESSORS, "").trimEnd();
|
|
3959
|
-
emit(
|
|
3960
|
-
|
|
5196
|
+
emit(
|
|
5197
|
+
`${indent}public ${bare} { get { ${body} }${accessors?.[3] ? ` set { ${body} }` : ""} }`
|
|
5198
|
+
);
|
|
5199
|
+
} else
|
|
5200
|
+
emit(
|
|
5201
|
+
`${indent}public ${member.kind.identifier === "swift.init" ? "required " : ""}${stripDefaults(decl)} { ${body} }`
|
|
5202
|
+
);
|
|
3961
5203
|
};
|
|
3962
5204
|
const emitNoop = scoped((member, indent) => {
|
|
3963
5205
|
emit(`${indent}public ${stripDefaults(text(member))} {}`);
|
|
3964
5206
|
});
|
|
3965
5207
|
const emitRequirement = scoped((member, indent) => {
|
|
3966
5208
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
3967
|
-
emit(
|
|
5209
|
+
emit(
|
|
5210
|
+
`${indent}${attrs}${stripDefaults(rest.replace(/^(?:weak |unowned )/, "").replace(/^((?:static )?)let /, "$1var "))}`
|
|
5211
|
+
);
|
|
3968
5212
|
});
|
|
3969
5213
|
const rawType = (members) => {
|
|
3970
5214
|
const init = members.find((member) => leaf(member) === "init(rawValue:)");
|
|
3971
5215
|
return init ? /rawValue:\s*([^)]+)\)/.exec(text(init))?.[1]?.trim() ?? null : null;
|
|
3972
5216
|
};
|
|
3973
5217
|
const emitGlobal = scoped((symbol) => {
|
|
3974
|
-
const
|
|
5218
|
+
const path16 = pathOf(symbol);
|
|
3975
5219
|
if (symbol.kind.identifier === "swift.func" || symbol.kind.identifier === "swift.func.op") {
|
|
3976
5220
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
3977
|
-
emit(`${attrs}public ${rest} { ${trap(
|
|
5221
|
+
emit(`${attrs}public ${rest} { ${trap(path16)} }`);
|
|
3978
5222
|
} else if (symbol.kind.identifier === "swift.var") {
|
|
3979
5223
|
const decl = text(symbol).replace(/^let /, "var ").replace(ACCESSORS, "").trimEnd();
|
|
3980
|
-
|
|
3981
|
-
|
|
5224
|
+
const measured = behavior.get(path16);
|
|
5225
|
+
if (measured) used.add(path16);
|
|
5226
|
+
emit(`public ${decl} { ${measured?.body ?? trap(path16)} }`);
|
|
5227
|
+
} else skipped.push({ path: path16, reason: `unhandled top-level ${symbol.kind.identifier}` });
|
|
3982
5228
|
});
|
|
3983
5229
|
const roots = [...byId.values()].filter((symbol) => !owner.has(symbol.identifier.precise) && !unavailable(symbol)).sort((a, b) => pathOf(a).localeCompare(pathOf(b)));
|
|
3984
5230
|
for (const symbol of roots) {
|
|
3985
|
-
const
|
|
5231
|
+
const path16 = pathOf(symbol);
|
|
3986
5232
|
if (TYPE_KINDS.has(symbol.kind.identifier)) emitType(symbol, "");
|
|
3987
5233
|
else emitGlobal(symbol);
|
|
3988
5234
|
}
|
|
3989
|
-
for (const [
|
|
5235
|
+
for (const [name2, members] of [...external].sort(([a], [b]) => a.localeCompare(b))) {
|
|
3990
5236
|
const seen = /* @__PURE__ */ new Set();
|
|
3991
5237
|
const kept = members.filter((member) => {
|
|
3992
5238
|
const key2 = `${member.kind.identifier}|${text(member)}`;
|
|
@@ -3995,15 +5241,24 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3995
5241
|
return true;
|
|
3996
5242
|
});
|
|
3997
5243
|
if (kept.length === 0) continue;
|
|
3998
|
-
emit(`extension ${
|
|
5244
|
+
emit(`extension ${name2} {`);
|
|
3999
5245
|
for (const member of kept)
|
|
4000
5246
|
if (member.kind.identifier === "swift.init" && !text(member).startsWith("convenience"))
|
|
4001
|
-
emitMember(
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
5247
|
+
emitMember(
|
|
5248
|
+
{
|
|
5249
|
+
...member,
|
|
5250
|
+
declarationFragments: [
|
|
5251
|
+
{ kind: "text", spelling: `convenience ${text(member)}` }
|
|
5252
|
+
]
|
|
5253
|
+
},
|
|
5254
|
+
" ",
|
|
5255
|
+
{
|
|
5256
|
+
openOwner: false,
|
|
5257
|
+
inClass: true,
|
|
5258
|
+
ownerName: name2
|
|
5259
|
+
}
|
|
5260
|
+
);
|
|
5261
|
+
else emitMember(member, " ", { openOwner: false, inClass: false, ownerName: name2 });
|
|
4007
5262
|
emit(`}`);
|
|
4008
5263
|
}
|
|
4009
5264
|
const imports = ["Foundation", "UIKit", ...options.imports ?? []];
|
|
@@ -4012,11 +5267,12 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4012
5267
|
`// do not hand-edit: every body traps because the vendor binary cannot run`,
|
|
4013
5268
|
`// in peach; behavior a hand file measures lives beside this file.`,
|
|
4014
5269
|
"",
|
|
4015
|
-
...imports.map((
|
|
5270
|
+
...imports.map((name2) => `import ${name2}`),
|
|
4016
5271
|
""
|
|
4017
5272
|
];
|
|
4018
|
-
for (const
|
|
4019
|
-
if (!used.has(
|
|
5273
|
+
for (const path16 of behavior.keys())
|
|
5274
|
+
if (!used.has(path16))
|
|
5275
|
+
skipped.push({ path: path16, reason: "behavior names no emitted declaration" });
|
|
4020
5276
|
return {
|
|
4021
5277
|
source: `${[...banner, ...lines].join("\n")}
|
|
4022
5278
|
`,
|
|
@@ -4024,8 +5280,42 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4024
5280
|
owners: [...banner.map(() => ""), ...owners]
|
|
4025
5281
|
};
|
|
4026
5282
|
}
|
|
4027
|
-
var KEYWORDS = /* @__PURE__ */ new Set([
|
|
4028
|
-
|
|
5283
|
+
var KEYWORDS = /* @__PURE__ */ new Set([
|
|
5284
|
+
"Type",
|
|
5285
|
+
"Protocol",
|
|
5286
|
+
"Self",
|
|
5287
|
+
"default",
|
|
5288
|
+
"init",
|
|
5289
|
+
"self",
|
|
5290
|
+
"class",
|
|
5291
|
+
"func",
|
|
5292
|
+
"var",
|
|
5293
|
+
"let",
|
|
5294
|
+
"in",
|
|
5295
|
+
"is",
|
|
5296
|
+
"as",
|
|
5297
|
+
"repeat",
|
|
5298
|
+
"internal",
|
|
5299
|
+
"public",
|
|
5300
|
+
"private",
|
|
5301
|
+
"operator",
|
|
5302
|
+
"extension",
|
|
5303
|
+
"subscript",
|
|
5304
|
+
"static",
|
|
5305
|
+
"struct",
|
|
5306
|
+
"protocol",
|
|
5307
|
+
"enum",
|
|
5308
|
+
"case",
|
|
5309
|
+
"where",
|
|
5310
|
+
"return",
|
|
5311
|
+
"throw",
|
|
5312
|
+
"throws",
|
|
5313
|
+
"import",
|
|
5314
|
+
"true",
|
|
5315
|
+
"false",
|
|
5316
|
+
"nil"
|
|
5317
|
+
]);
|
|
5318
|
+
var tick = (name2) => KEYWORDS.has(name2) ? `\`${name2}\`` : name2;
|
|
4029
5319
|
function stripDefaults(decl) {
|
|
4030
5320
|
let out = "";
|
|
4031
5321
|
let depth = 0;
|
|
@@ -4073,21 +5363,36 @@ ${"stdout" in error ? String(error.stdout) : ""}` : String(error);
|
|
|
4073
5363
|
return [...new Set(errors)].slice(0, 3).join("; ") || output.trim().slice(0, 400);
|
|
4074
5364
|
}
|
|
4075
5365
|
var key = (...parts) => (0, import_node_crypto6.createHash)("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
const
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
5366
|
+
var digests = /* @__PURE__ */ new Map();
|
|
5367
|
+
function treeDigest(root) {
|
|
5368
|
+
const names = [];
|
|
5369
|
+
const walk2 = (dir) => {
|
|
5370
|
+
for (const entry of import_node_fs11.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name < right.name ? -1 : 1)) {
|
|
5371
|
+
const full = import_node_path11.default.join(dir, entry.name);
|
|
5372
|
+
if (entry.isDirectory()) walk2(full);
|
|
5373
|
+
else if (entry.isFile()) names.push(import_node_path11.default.relative(root, full));
|
|
5374
|
+
}
|
|
5375
|
+
};
|
|
5376
|
+
walk2(root);
|
|
5377
|
+
const stamp = names.map((name2) => {
|
|
5378
|
+
const stat = import_node_fs11.default.statSync(import_node_path11.default.join(root, name2));
|
|
5379
|
+
return `${name2}\0${stat.size}:${stat.mtimeMs}`;
|
|
5380
|
+
}).join("\n");
|
|
5381
|
+
const memo2 = digests.get(`tree\0${root}`);
|
|
5382
|
+
if (memo2?.stamp === stamp) return memo2.digest;
|
|
5383
|
+
const hash = (0, import_node_crypto6.createHash)("sha256");
|
|
5384
|
+
for (const name2 of names) {
|
|
5385
|
+
hash.update(`${name2}\0`);
|
|
5386
|
+
hash.update(import_node_fs11.default.readFileSync(import_node_path11.default.join(root, name2)));
|
|
5387
|
+
hash.update("\0");
|
|
5388
|
+
}
|
|
5389
|
+
const digest = hash.digest("hex");
|
|
5390
|
+
digests.set(`tree\0${root}`, { stamp, digest });
|
|
5391
|
+
return digest;
|
|
5392
|
+
}
|
|
5393
|
+
function locateXcframework(tree) {
|
|
4089
5394
|
const find = (root, depth) => {
|
|
4090
|
-
for (const entry of
|
|
5395
|
+
for (const entry of import_node_fs11.default.readdirSync(root, { withFileTypes: true })) {
|
|
4091
5396
|
if (!entry.isDirectory() || entry.name === "__MACOSX") continue;
|
|
4092
5397
|
const full = import_node_path11.default.join(root, entry.name);
|
|
4093
5398
|
if (entry.name.endsWith(".xcframework")) return full;
|
|
@@ -4096,26 +5401,70 @@ function xcframework(binary) {
|
|
|
4096
5401
|
}
|
|
4097
5402
|
return null;
|
|
4098
5403
|
};
|
|
4099
|
-
|
|
5404
|
+
return find(tree, 2);
|
|
5405
|
+
}
|
|
5406
|
+
function xcframework(binary) {
|
|
5407
|
+
if (!binary.url && !binary.dir.endsWith(".zip"))
|
|
5408
|
+
return { dir: binary.dir, digest: treeDigest(binary.dir) };
|
|
5409
|
+
const dir = import_node_path11.default.join(cacheDir3, "archives", key(binary.url ?? binary.dir));
|
|
5410
|
+
const archive = import_node_path11.default.join(dir, "archive.zip");
|
|
5411
|
+
const fingerprint = import_node_path11.default.join(dir, ".fingerprint");
|
|
5412
|
+
const stored = (() => {
|
|
5413
|
+
try {
|
|
5414
|
+
const parsed = JSON.parse(import_node_fs11.default.readFileSync(fingerprint, "utf8"));
|
|
5415
|
+
return parsed && typeof parsed === "object" && "sha" in parsed ? parsed : null;
|
|
5416
|
+
} catch {
|
|
5417
|
+
return null;
|
|
5418
|
+
}
|
|
5419
|
+
})();
|
|
5420
|
+
if (!binary.url) {
|
|
5421
|
+
const stat = import_node_fs11.default.statSync(binary.dir);
|
|
5422
|
+
const stamp = `${stat.size}:${stat.mtimeMs}`;
|
|
5423
|
+
if (stored?.stamp === stamp) {
|
|
5424
|
+
const found3 = locateXcframework(import_node_path11.default.join(dir, "tree"));
|
|
5425
|
+
if (found3) return { dir: found3, digest: stored.sha };
|
|
5426
|
+
}
|
|
5427
|
+
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs11.default.readFileSync(binary.dir)).digest("hex");
|
|
5428
|
+
if (sha2 !== stored?.sha || !locateXcframework(import_node_path11.default.join(dir, "tree"))) {
|
|
5429
|
+
import_node_fs11.default.rmSync(dir, { recursive: true, force: true });
|
|
5430
|
+
import_node_fs11.default.mkdirSync(import_node_path11.default.join(dir, "tree"), { recursive: true });
|
|
5431
|
+
exec("unzip", ["-q", binary.dir, "-d", import_node_path11.default.join(dir, "tree")]);
|
|
5432
|
+
}
|
|
5433
|
+
import_node_fs11.default.writeFileSync(fingerprint, JSON.stringify({ stamp, sha: sha2 }));
|
|
5434
|
+
const found2 = locateXcframework(import_node_path11.default.join(dir, "tree"));
|
|
5435
|
+
if (!found2) throw new Error("its archive holds no .xcframework");
|
|
5436
|
+
return { dir: found2, digest: sha2 };
|
|
5437
|
+
}
|
|
5438
|
+
if (stored && import_node_fs11.default.existsSync(archive)) {
|
|
5439
|
+
const found2 = locateXcframework(import_node_path11.default.join(dir, "tree"));
|
|
5440
|
+
if (found2) return { dir: found2, digest: stored.sha };
|
|
5441
|
+
}
|
|
5442
|
+
import_node_fs11.default.rmSync(dir, { recursive: true, force: true });
|
|
5443
|
+
import_node_fs11.default.mkdirSync(import_node_path11.default.join(dir, "tree"), { recursive: true });
|
|
5444
|
+
exec("curl", ["-fsSL", "--retry", "2", "-o", archive, binary.url]);
|
|
5445
|
+
const sha = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs11.default.readFileSync(archive)).digest("hex");
|
|
5446
|
+
exec("unzip", ["-q", archive, "-d", import_node_path11.default.join(dir, "tree")]);
|
|
5447
|
+
import_node_fs11.default.writeFileSync(fingerprint, JSON.stringify({ sha }));
|
|
5448
|
+
const found = locateXcframework(import_node_path11.default.join(dir, "tree"));
|
|
4100
5449
|
if (!found) throw new Error("its archive holds no .xcframework");
|
|
4101
|
-
return found;
|
|
5450
|
+
return { dir: found, digest: sha };
|
|
4102
5451
|
}
|
|
4103
|
-
var files = (dir, test) =>
|
|
5452
|
+
var files = (dir, test) => import_node_fs11.default.existsSync(dir) ? import_node_fs11.default.readdirSync(dir, { recursive: true, encoding: "utf8" }).filter((file) => test(import_node_path11.default.basename(file))).sort() : [];
|
|
4104
5453
|
function surfaces(xcframeworkDir) {
|
|
4105
|
-
const slice =
|
|
5454
|
+
const slice = import_node_fs11.default.readdirSync(xcframeworkDir).filter((name2) => /^ios-.+-simulator$/.test(name2)).sort()[0];
|
|
4106
5455
|
if (!slice) throw new Error("it has no iOS simulator slice");
|
|
4107
5456
|
const root = import_node_path11.default.join(xcframeworkDir, slice);
|
|
4108
5457
|
const found = [];
|
|
4109
|
-
for (const entry of
|
|
5458
|
+
for (const entry of import_node_fs11.default.readdirSync(root).sort()) {
|
|
4110
5459
|
if (!entry.endsWith(".framework")) continue;
|
|
4111
5460
|
const module2 = entry.slice(0, -".framework".length);
|
|
4112
5461
|
const framework = import_node_path11.default.join(root, entry);
|
|
4113
5462
|
const swiftmodule = import_node_path11.default.join(framework, "Modules", `${module2}.swiftmodule`);
|
|
4114
5463
|
const interfaces = files(
|
|
4115
5464
|
swiftmodule,
|
|
4116
|
-
(
|
|
5465
|
+
(name2) => name2.endsWith(".swiftinterface") && !name2.endsWith(".private.swiftinterface") && !name2.endsWith(".package.swiftinterface")
|
|
4117
5466
|
);
|
|
4118
|
-
const chosen = interfaces.find((
|
|
5467
|
+
const chosen = interfaces.find((name2) => name2.startsWith("arm64-")) ?? interfaces[0] ?? null;
|
|
4119
5468
|
if (chosen) {
|
|
4120
5469
|
found.push({
|
|
4121
5470
|
kind: "swift",
|
|
@@ -4125,7 +5474,7 @@ function surfaces(xcframeworkDir) {
|
|
|
4125
5474
|
continue;
|
|
4126
5475
|
}
|
|
4127
5476
|
const modulemap = import_node_path11.default.join(framework, "Modules", "module.modulemap");
|
|
4128
|
-
if (
|
|
5477
|
+
if (import_node_fs11.default.existsSync(modulemap))
|
|
4129
5478
|
found.push({
|
|
4130
5479
|
kind: "c",
|
|
4131
5480
|
module: module2,
|
|
@@ -4134,9 +5483,9 @@ function surfaces(xcframeworkDir) {
|
|
|
4134
5483
|
});
|
|
4135
5484
|
}
|
|
4136
5485
|
const headers = import_node_path11.default.join(root, "Headers");
|
|
4137
|
-
for (const map of files(headers, (
|
|
5486
|
+
for (const map of files(headers, (name2) => name2 === "module.modulemap")) {
|
|
4138
5487
|
const modulemap = import_node_path11.default.join(headers, map);
|
|
4139
|
-
const module2 = /(?:^|\s)module\s+(\w+)/.exec(
|
|
5488
|
+
const module2 = /(?:^|\s)module\s+(\w+)/.exec(import_node_fs11.default.readFileSync(modulemap, "utf8"))?.[1];
|
|
4140
5489
|
if (module2) found.push({ kind: "c", module: module2, modulemap, headers });
|
|
4141
5490
|
}
|
|
4142
5491
|
return found;
|
|
@@ -4152,7 +5501,7 @@ function peachModuleDirs(toolchain, imports) {
|
|
|
4152
5501
|
toolchainBin,
|
|
4153
5502
|
plugins.libraries[0]
|
|
4154
5503
|
]);
|
|
4155
|
-
for (const target of imports.filter((
|
|
5504
|
+
for (const target of imports.filter((name2) => peach.has(name2)))
|
|
4156
5505
|
exec(
|
|
4157
5506
|
import_node_path11.default.join(toolchainBin, "swift"),
|
|
4158
5507
|
[
|
|
@@ -4186,11 +5535,11 @@ function swiftInterfaceForWasm(text3) {
|
|
|
4186
5535
|
);
|
|
4187
5536
|
}
|
|
4188
5537
|
function swiftStandin(surface, binary, toolchain, work) {
|
|
4189
|
-
const text3 = swiftInterfaceForWasm(
|
|
5538
|
+
const text3 = swiftInterfaceForWasm(import_node_fs11.default.readFileSync(surface.interface, "utf8"));
|
|
4190
5539
|
const search = import_node_path11.default.join(work, "interfaces");
|
|
4191
5540
|
const moduleDir = import_node_path11.default.join(search, `${surface.module}.swiftmodule`);
|
|
4192
|
-
|
|
4193
|
-
|
|
5541
|
+
import_node_fs11.default.mkdirSync(moduleDir, { recursive: true });
|
|
5542
|
+
import_node_fs11.default.writeFileSync(import_node_path11.default.join(moduleDir, `${TRIPLE}.swiftinterface`), text3);
|
|
4194
5543
|
const imports = [
|
|
4195
5544
|
...text3.matchAll(
|
|
4196
5545
|
/^(?:@_exported[ \t]+)?import[ \t]+(?:(?:struct|class|enum|protocol|typealias|func|var|let)[ \t]+)?(\w+)/gm
|
|
@@ -4203,7 +5552,7 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
4203
5552
|
const target = ["-target", TRIPLE, "-sdk", sysroot, "-resource-dir", resources];
|
|
4204
5553
|
const peach = peachModuleDirs(toolchain, imports).flatMap((dir) => ["-I", dir]);
|
|
4205
5554
|
const out = import_node_path11.default.join(work, "graphs");
|
|
4206
|
-
|
|
5555
|
+
import_node_fs11.default.mkdirSync(out, { recursive: true });
|
|
4207
5556
|
exec(import_node_path11.default.join(toolchain.toolchainBin, "swift-symbolgraph-extract"), [
|
|
4208
5557
|
"-module-name",
|
|
4209
5558
|
surface.module,
|
|
@@ -4218,7 +5567,7 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
4218
5567
|
"-output-dir",
|
|
4219
5568
|
out
|
|
4220
5569
|
]);
|
|
4221
|
-
const graphs =
|
|
5570
|
+
const graphs = import_node_fs11.default.readdirSync(out).filter((name2) => name2.endsWith(".symbols.json")).sort().map((name2) => JSON.parse(import_node_fs11.default.readFileSync(import_node_path11.default.join(out, name2), "utf8")));
|
|
4222
5571
|
const omit = /* @__PURE__ */ new Map();
|
|
4223
5572
|
const plain = /* @__PURE__ */ new Set();
|
|
4224
5573
|
const file = import_node_path11.default.join(work, `${surface.module}.swift`);
|
|
@@ -4229,7 +5578,7 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
4229
5578
|
omit,
|
|
4230
5579
|
plain
|
|
4231
5580
|
});
|
|
4232
|
-
|
|
5581
|
+
import_node_fs11.default.writeFileSync(file, source);
|
|
4233
5582
|
const check = (0, import_node_child_process7.spawnSync)(
|
|
4234
5583
|
import_node_path11.default.join(toolchain.toolchainBin, "swiftc"),
|
|
4235
5584
|
[
|
|
@@ -4317,23 +5666,79 @@ function functionDeclarations(ast, headers) {
|
|
|
4317
5666
|
}
|
|
4318
5667
|
return found;
|
|
4319
5668
|
}
|
|
5669
|
+
function matchOpen(text3, close) {
|
|
5670
|
+
const open = text3[close] === ")" ? "(" : "[";
|
|
5671
|
+
let depth = 0;
|
|
5672
|
+
for (let index = close; index >= 0; index--) {
|
|
5673
|
+
if (text3[index] === text3[close]) depth++;
|
|
5674
|
+
else if (text3[index] === open && --depth === 0) return index;
|
|
5675
|
+
}
|
|
5676
|
+
return -1;
|
|
5677
|
+
}
|
|
5678
|
+
var identChar = (char) => char !== void 0 && /[\w$]/.test(char);
|
|
5679
|
+
function splitDeclarators(statement, names) {
|
|
5680
|
+
const chunks = [];
|
|
5681
|
+
let depth = 0;
|
|
5682
|
+
let quote = null;
|
|
5683
|
+
let start = 0;
|
|
5684
|
+
for (let index = 0; index < statement.length; index++) {
|
|
5685
|
+
const char = statement[index];
|
|
5686
|
+
if (quote) {
|
|
5687
|
+
if (char === "\\") index++;
|
|
5688
|
+
else if (char === quote) quote = null;
|
|
5689
|
+
} else if (char === '"' || char === "'") quote = char;
|
|
5690
|
+
else if (char === "(" || char === "[" || char === "{") depth++;
|
|
5691
|
+
else if (char === ")" || char === "]" || char === "}") depth--;
|
|
5692
|
+
else if (char === "," && depth === 0) {
|
|
5693
|
+
chunks.push(statement.slice(start, index));
|
|
5694
|
+
start = index + 1;
|
|
5695
|
+
}
|
|
5696
|
+
}
|
|
5697
|
+
chunks.push(statement.slice(start));
|
|
5698
|
+
if (chunks.length !== names.length)
|
|
5699
|
+
throw new Error(
|
|
5700
|
+
`${names[0]} has an unexpected grouped declaration in ${JSON.stringify(statement.trim().slice(0, 80))}`
|
|
5701
|
+
);
|
|
5702
|
+
let end = chunks[0].indexOf(names[0]);
|
|
5703
|
+
if (end < 0) throw new Error(`${names[0]} names no declarator in its own declaration`);
|
|
5704
|
+
for (; ; ) {
|
|
5705
|
+
while (end > 0 && /[\s*]/.test(chunks[0][end - 1])) end--;
|
|
5706
|
+
if (end > 0 && (chunks[0][end - 1] === ")" || chunks[0][end - 1] === "]")) {
|
|
5707
|
+
end = matchOpen(chunks[0], end - 1);
|
|
5708
|
+
if (end < 0) throw new Error(`${names[0]} has unbalanced groups in its declaration`);
|
|
5709
|
+
while (end > 0 && identChar(chunks[0][end - 1])) end--;
|
|
5710
|
+
continue;
|
|
5711
|
+
}
|
|
5712
|
+
if (end > 1 && chunks[0][end - 1] === "(" && identChar(chunks[0][end - 2])) {
|
|
5713
|
+
end--;
|
|
5714
|
+
while (end > 0 && identChar(chunks[0][end - 1])) end--;
|
|
5715
|
+
continue;
|
|
5716
|
+
}
|
|
5717
|
+
break;
|
|
5718
|
+
}
|
|
5719
|
+
if (end > 0 && chunks[0][end - 1] === "(") end--;
|
|
5720
|
+
const specifiers = chunks[0].slice(0, end);
|
|
5721
|
+
return chunks.map(
|
|
5722
|
+
(chunk, index) => index === 0 ? chunk : `${specifiers} ${chunk.trim()}`
|
|
5723
|
+
);
|
|
5724
|
+
}
|
|
4320
5725
|
function cStandin(surface, binary, toolchain, work) {
|
|
4321
5726
|
const named = [
|
|
4322
|
-
...
|
|
5727
|
+
...import_node_fs11.default.readFileSync(surface.modulemap, "utf8").matchAll(/(?:umbrella\s+)?header\s+"([^"]+)"/g)
|
|
4323
5728
|
].map((match) => match[1]);
|
|
4324
|
-
const headers = files(surface.headers, (
|
|
5729
|
+
const headers = files(surface.headers, (name2) => name2.endsWith(".h"));
|
|
4325
5730
|
const texts = new Map(
|
|
4326
5731
|
headers.map((file) => [
|
|
4327
5732
|
file,
|
|
4328
|
-
|
|
5733
|
+
import_node_fs11.default.readFileSync(import_node_path11.default.join(surface.headers, file), "utf8")
|
|
4329
5734
|
])
|
|
4330
5735
|
);
|
|
4331
5736
|
const objc = headers.find((file) => OBJC.test(texts.get(file)));
|
|
4332
5737
|
if (objc) throw new Error(`its header ${objc} is Objective-C`);
|
|
4333
5738
|
const include = import_node_path11.default.join(work, "include");
|
|
4334
5739
|
for (const [file, text3] of texts) {
|
|
4335
|
-
|
|
4336
|
-
|
|
5740
|
+
import_node_fs11.default.mkdirSync(import_node_path11.default.dirname(import_node_path11.default.join(include, file)), { recursive: true });
|
|
5741
|
+
import_node_fs11.default.writeFileSync(import_node_path11.default.join(include, file), text3);
|
|
4337
5742
|
}
|
|
4338
5743
|
const roots = named.length > 0 ? named : headers;
|
|
4339
5744
|
const modulemap = `module ${surface.module} {
|
|
@@ -4342,7 +5747,7 @@ ${roots.map((file) => ` header "${file}"
|
|
|
4342
5747
|
}
|
|
4343
5748
|
`;
|
|
4344
5749
|
const probe = import_node_path11.default.join(work, "declarations.c");
|
|
4345
|
-
|
|
5750
|
+
import_node_fs11.default.writeFileSync(probe, roots.map((file) => `#include "${file}"
|
|
4346
5751
|
`).join(""));
|
|
4347
5752
|
const { sysroot } = swiftSdkPaths(toolchain.moduleRoot, toolchain.toolchainBin);
|
|
4348
5753
|
const ast = JSON.parse(
|
|
@@ -4361,26 +5766,40 @@ ${roots.map((file) => ` header "${file}"
|
|
|
4361
5766
|
);
|
|
4362
5767
|
const byPath = new Map(headers.map((file) => [import_node_path11.default.join(include, file), file]));
|
|
4363
5768
|
const declarations = functionDeclarations(ast, new Set(byPath.keys()));
|
|
5769
|
+
const groups = /* @__PURE__ */ new Map();
|
|
5770
|
+
for (const declaration of declarations) {
|
|
5771
|
+
const group = groups.get(`${declaration.file}\0${declaration.begin}`) ?? [];
|
|
5772
|
+
group.push(declaration);
|
|
5773
|
+
groups.set(`${declaration.file}\0${declaration.begin}`, group);
|
|
5774
|
+
}
|
|
4364
5775
|
const seen = /* @__PURE__ */ new Set();
|
|
4365
5776
|
const definitions = [];
|
|
4366
|
-
for (const
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
const
|
|
4370
|
-
const close = text3.indexOf(";", end);
|
|
5777
|
+
for (const group of groups.values()) {
|
|
5778
|
+
const first = group[0];
|
|
5779
|
+
const text3 = texts.get(byPath.get(first.file));
|
|
5780
|
+
const close = text3.indexOf(";", first.end);
|
|
4371
5781
|
if (close < 0)
|
|
4372
|
-
throw new Error(`${name} has no declaration end in ${byPath.get(file)}`);
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
5782
|
+
throw new Error(`${first.name} has no declaration end in ${byPath.get(first.file)}`);
|
|
5783
|
+
const statement = text3.slice(first.begin, close);
|
|
5784
|
+
const declarators = group.length === 1 ? [statement] : splitDeclarators(
|
|
5785
|
+
statement,
|
|
5786
|
+
group.map((declaration) => declaration.name)
|
|
5787
|
+
);
|
|
5788
|
+
group.forEach((declaration, index) => {
|
|
5789
|
+
if (seen.has(declaration.name)) return;
|
|
5790
|
+
seen.add(declaration.name);
|
|
5791
|
+
definitions.push(
|
|
5792
|
+
`${declarators[index].trim()} {
|
|
5793
|
+
peach_standin_trap("${declaration.name}");
|
|
4376
5794
|
}
|
|
4377
5795
|
`
|
|
4378
|
-
|
|
5796
|
+
);
|
|
5797
|
+
});
|
|
4379
5798
|
}
|
|
4380
5799
|
const sdk = JSON.stringify(`${binary.target} (${binary.source})`);
|
|
4381
5800
|
const source = [
|
|
4382
5801
|
`// generated by peach from ${surface.module}'s headers: ${binary.target} ships`,
|
|
4383
|
-
"// iOS machine code only, so every function traps naming itself.",
|
|
5802
|
+
"// iOS machine code only, so every extern function traps naming itself.",
|
|
4384
5803
|
...roots.map((file) => `#include "${file}"`),
|
|
4385
5804
|
"#include <stdio.h>",
|
|
4386
5805
|
"#include <stdlib.h>",
|
|
@@ -4392,6 +5811,22 @@ ${roots.map((file) => ` header "${file}"
|
|
|
4392
5811
|
"",
|
|
4393
5812
|
...definitions
|
|
4394
5813
|
].join("\n");
|
|
5814
|
+
const out = import_node_path11.default.join(work, `${surface.module}.c`);
|
|
5815
|
+
import_node_fs11.default.writeFileSync(out, source);
|
|
5816
|
+
try {
|
|
5817
|
+
exec(import_node_path11.default.join(toolchain.toolchainBin, "clang"), [
|
|
5818
|
+
"-target",
|
|
5819
|
+
TRIPLE,
|
|
5820
|
+
"--sysroot",
|
|
5821
|
+
sysroot,
|
|
5822
|
+
"-fsyntax-only",
|
|
5823
|
+
"-I",
|
|
5824
|
+
include,
|
|
5825
|
+
out
|
|
5826
|
+
]);
|
|
5827
|
+
} catch (error) {
|
|
5828
|
+
throw new Error(`its generated source does not compile: ${failure(error)}`);
|
|
5829
|
+
}
|
|
4395
5830
|
return {
|
|
4396
5831
|
module: surface.module,
|
|
4397
5832
|
target: binary.target,
|
|
@@ -4405,38 +5840,70 @@ ${roots.map((file) => ` header "${file}"
|
|
|
4405
5840
|
};
|
|
4406
5841
|
}
|
|
4407
5842
|
var built = /* @__PURE__ */ new Map();
|
|
4408
|
-
function
|
|
4409
|
-
|
|
5843
|
+
function standinGenerationInputs(binaries, toolchain) {
|
|
5844
|
+
const { moduleRoot, toolchainBin, release } = toolchain;
|
|
5845
|
+
const parts = [
|
|
5846
|
+
"standin/v2",
|
|
5847
|
+
toolchainBin,
|
|
5848
|
+
release,
|
|
5849
|
+
swiftModuleSdk(moduleRoot).wasmSdkId,
|
|
5850
|
+
swiftModuleDigest(moduleRoot).toString("hex"),
|
|
5851
|
+
`emit/${STANDIN_EMIT_VERSION}`,
|
|
5852
|
+
// a released cli can change the emitter without anyone bumping the constant
|
|
5853
|
+
`cli/${getCliVersion()}`
|
|
5854
|
+
];
|
|
5855
|
+
for (const binary of binaries) {
|
|
5856
|
+
try {
|
|
5857
|
+
parts.push(
|
|
5858
|
+
binary.target,
|
|
5859
|
+
binary.source,
|
|
5860
|
+
binary.url ?? "",
|
|
5861
|
+
xcframework(binary).digest
|
|
5862
|
+
);
|
|
5863
|
+
} catch {
|
|
5864
|
+
parts.push(binary.target, binary.source, binary.url ?? "", "unreadable");
|
|
5865
|
+
}
|
|
5866
|
+
}
|
|
5867
|
+
return (0, import_node_crypto6.createHash)("sha256").update(parts.join("\0")).digest("hex");
|
|
5868
|
+
}
|
|
5869
|
+
function binaryStandins(binary, toolchain, provided) {
|
|
5870
|
+
if (provided.has(binary.target)) return [];
|
|
5871
|
+
let all;
|
|
5872
|
+
let digest;
|
|
4410
5873
|
try {
|
|
4411
|
-
|
|
5874
|
+
const artifact = xcframework(binary);
|
|
5875
|
+
all = surfaces(artifact.dir);
|
|
5876
|
+
digest = artifact.digest;
|
|
4412
5877
|
} catch (error) {
|
|
4413
5878
|
return error instanceof Error ? error.message : String(error);
|
|
4414
5879
|
}
|
|
4415
|
-
|
|
5880
|
+
const found = all.filter((surface) => !provided.has(surface.module));
|
|
5881
|
+
if (found.length === 0) {
|
|
5882
|
+
if (all.length > 0) return [];
|
|
4416
5883
|
return "its iOS simulator slice has no Swift interface or C modulemap";
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
);
|
|
5884
|
+
}
|
|
5885
|
+
const hash = (0, import_node_crypto6.createHash)("sha256").update(standinGenerationInputs([binary], toolchain));
|
|
5886
|
+
hash.update(digest);
|
|
4420
5887
|
for (const surface of found) {
|
|
4421
5888
|
hash.update(`${surface.kind}\0${surface.module}\0`);
|
|
4422
5889
|
for (const file of surface.kind === "swift" ? [surface.interface] : [
|
|
4423
5890
|
surface.modulemap,
|
|
4424
|
-
...files(surface.headers, (
|
|
5891
|
+
...files(surface.headers, (name2) => name2.endsWith(".h")).map(
|
|
4425
5892
|
(file2) => import_node_path11.default.join(surface.headers, file2)
|
|
4426
5893
|
)
|
|
4427
5894
|
])
|
|
4428
|
-
hash.update(
|
|
5895
|
+
hash.update(import_node_fs11.default.readFileSync(file));
|
|
4429
5896
|
}
|
|
4430
5897
|
const id = hash.digest("hex").slice(0, 32);
|
|
4431
5898
|
const memo2 = built.get(id);
|
|
4432
5899
|
if (memo2) return memo2;
|
|
4433
|
-
const
|
|
4434
|
-
if (
|
|
4435
|
-
const value = JSON.parse(
|
|
5900
|
+
const cached2 = import_node_path11.default.join(cacheDir3, "standins", `${id}.json`);
|
|
5901
|
+
if (import_node_fs11.default.existsSync(cached2)) {
|
|
5902
|
+
const value = JSON.parse(import_node_fs11.default.readFileSync(cached2, "utf8"));
|
|
4436
5903
|
built.set(id, value);
|
|
4437
5904
|
return value;
|
|
4438
5905
|
}
|
|
4439
|
-
const work =
|
|
5906
|
+
const work = import_node_fs11.default.mkdtempSync(import_node_path11.default.join(import_node_os7.default.tmpdir(), "peach-standin-"));
|
|
4440
5907
|
let result;
|
|
4441
5908
|
try {
|
|
4442
5909
|
result = found.map((surface) => {
|
|
@@ -4449,21 +5916,21 @@ function binaryStandins(binary, toolchain) {
|
|
|
4449
5916
|
);
|
|
4450
5917
|
}
|
|
4451
5918
|
});
|
|
4452
|
-
|
|
4453
|
-
|
|
5919
|
+
import_node_fs11.default.mkdirSync(import_node_path11.default.dirname(cached2), { recursive: true });
|
|
5920
|
+
import_node_fs11.default.writeFileSync(cached2, JSON.stringify(result));
|
|
4454
5921
|
built.set(id, result);
|
|
4455
5922
|
} catch (error) {
|
|
4456
5923
|
result = error instanceof Error ? error.message : String(error);
|
|
4457
5924
|
} finally {
|
|
4458
|
-
|
|
5925
|
+
import_node_fs11.default.rmSync(work, { recursive: true, force: true });
|
|
4459
5926
|
}
|
|
4460
5927
|
return result;
|
|
4461
5928
|
}
|
|
4462
|
-
function swiftStandins(binaries, toolchain) {
|
|
5929
|
+
function swiftStandins(binaries, toolchain, provided = /* @__PURE__ */ new Set()) {
|
|
4463
5930
|
const standins = [];
|
|
4464
5931
|
const gaps = /* @__PURE__ */ new Map();
|
|
4465
5932
|
for (const binary of binaries) {
|
|
4466
|
-
const result = binaryStandins(binary, toolchain);
|
|
5933
|
+
const result = binaryStandins(binary, toolchain, provided);
|
|
4467
5934
|
if (typeof result === "string") gaps.set(binary.target, result);
|
|
4468
5935
|
else standins.push(...result);
|
|
4469
5936
|
}
|
|
@@ -4487,7 +5954,7 @@ function swiftNativeEntry(native, file) {
|
|
|
4487
5954
|
packageId: native.packageId,
|
|
4488
5955
|
contractHash: native.hash,
|
|
4489
5956
|
modules: Object.fromEntries(
|
|
4490
|
-
(native.files[file] ?? []).map((
|
|
5957
|
+
(native.files[file] ?? []).map((name2) => [name2, native.modules[name2] ?? []])
|
|
4491
5958
|
),
|
|
4492
5959
|
defaultView: native.defaultViewFiles.includes(file)
|
|
4493
5960
|
};
|
|
@@ -4536,7 +6003,7 @@ function isRecord2(value) {
|
|
|
4536
6003
|
}
|
|
4537
6004
|
function isSwiftNativeModules(value) {
|
|
4538
6005
|
return isRecord2(value) && typeof value.packageId === "string" && typeof value.hash === "string" && isRecord2(value.files) && isRecord2(value.modules) && [...Object.values(value.files), ...Object.values(value.modules)].every(
|
|
4539
|
-
(names) => Array.isArray(names) && names.every((
|
|
6006
|
+
(names) => Array.isArray(names) && names.every((name2) => typeof name2 === "string")
|
|
4540
6007
|
) && Array.isArray(value.defaultViewFiles) && value.defaultViewFiles.every((file) => typeof file === "string");
|
|
4541
6008
|
}
|
|
4542
6009
|
function isSwiftCompileOutcome(value) {
|
|
@@ -4562,8 +6029,8 @@ function compileAssetUrl(value, origin) {
|
|
|
4562
6029
|
}
|
|
4563
6030
|
function resolveImageUrls(urls, origin) {
|
|
4564
6031
|
const resolved = {};
|
|
4565
|
-
for (const [
|
|
4566
|
-
resolved[
|
|
6032
|
+
for (const [name2, url] of Object.entries(urls)) {
|
|
6033
|
+
resolved[name2] = compileAssetUrl(url, origin);
|
|
4567
6034
|
}
|
|
4568
6035
|
return resolved;
|
|
4569
6036
|
}
|
|
@@ -4607,13 +6074,13 @@ async function compileSwiftProject(submit, work, origin, signal) {
|
|
|
4607
6074
|
}
|
|
4608
6075
|
|
|
4609
6076
|
// src/xcode-project.ts
|
|
4610
|
-
var
|
|
6077
|
+
var import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
4611
6078
|
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
4612
6079
|
var import_plist = __toESM(require_plist(), 1);
|
|
4613
6080
|
|
|
4614
6081
|
// src/xcode-json-project.ts
|
|
4615
6082
|
var import_node_path12 = __toESM(require("node:path"), 1);
|
|
4616
|
-
var import_json5 = __toESM(
|
|
6083
|
+
var import_json5 = __toESM(require_lib(), 1);
|
|
4617
6084
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4618
6085
|
var text2 = (value) => typeof value === "string" ? value : void 0;
|
|
4619
6086
|
var items = (value) => Array.isArray(value) ? value : [];
|
|
@@ -4660,8 +6127,8 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
4660
6127
|
const kind = text2(entry.kind) ?? "file-reference";
|
|
4661
6128
|
const raw2 = text2(entry.path) ?? "";
|
|
4662
6129
|
const located = raw2 === "" ? null : locate(raw2, parent.dir);
|
|
4663
|
-
const
|
|
4664
|
-
const node = { id: "", name, dir: null, parent, children: [] };
|
|
6130
|
+
const name2 = text2(entry.name) ?? import_node_path12.default.basename(raw2);
|
|
6131
|
+
const node = { id: "", name: name2, dir: null, parent, children: [] };
|
|
4665
6132
|
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
4666
6133
|
node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
4667
6134
|
const childIds = walk2(items(entry.children), node);
|
|
@@ -4674,7 +6141,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
4674
6141
|
isa: kind === "variant-group" ? "PBXVariantGroup" : "PBXGroup",
|
|
4675
6142
|
children: childIds,
|
|
4676
6143
|
...kind === "variant-group" ? {} : { sourceTree: "<absolute>", path: node.dir ?? "" },
|
|
4677
|
-
name
|
|
6144
|
+
name: name2
|
|
4678
6145
|
},
|
|
4679
6146
|
text2(entry.id)
|
|
4680
6147
|
);
|
|
@@ -4692,7 +6159,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
4692
6159
|
{
|
|
4693
6160
|
isa: "PBXFileReference",
|
|
4694
6161
|
...located ?? { sourceTree: "SDKROOT", path: raw2 },
|
|
4695
|
-
name
|
|
6162
|
+
name: name2
|
|
4696
6163
|
},
|
|
4697
6164
|
text2(entry.id)
|
|
4698
6165
|
);
|
|
@@ -4744,8 +6211,8 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
4744
6211
|
return node;
|
|
4745
6212
|
};
|
|
4746
6213
|
const configurations = items(json.configurations).flatMap((entry) => {
|
|
4747
|
-
const
|
|
4748
|
-
return
|
|
6214
|
+
const name2 = isObject(entry) ? text2(entry.name) : text2(entry);
|
|
6215
|
+
return name2 ? [{ name: name2, file: isObject(entry) ? entry.file : void 0 }] : [];
|
|
4749
6216
|
});
|
|
4750
6217
|
const settingsOf = (value) => Object.fromEntries(
|
|
4751
6218
|
Object.entries(isObject(value) ? value : {}).flatMap(
|
|
@@ -4760,11 +6227,11 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
4760
6227
|
const configurationList = (settings, specialized) => add({
|
|
4761
6228
|
isa: "XCConfigurationList",
|
|
4762
6229
|
defaultConfigurationName: text2(json["default-configuration"]) ?? "Debug",
|
|
4763
|
-
buildConfigurations: configurations.map(({ name, file }) => {
|
|
4764
|
-
const base = lookup(specialized.has(
|
|
6230
|
+
buildConfigurations: configurations.map(({ name: name2, file }) => {
|
|
6231
|
+
const base = lookup(specialized.has(name2) ? specialized.get(name2) : file);
|
|
4765
6232
|
return add({
|
|
4766
6233
|
isa: "XCBuildConfiguration",
|
|
4767
|
-
name,
|
|
6234
|
+
name: name2,
|
|
4768
6235
|
buildSettings: settings,
|
|
4769
6236
|
...base ? { baseConfigurationReference: base } : {}
|
|
4770
6237
|
});
|
|
@@ -4775,9 +6242,9 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
4775
6242
|
if (!isObject(entry)) continue;
|
|
4776
6243
|
const repository = text2(entry.repository);
|
|
4777
6244
|
const local = text2(entry.path);
|
|
4778
|
-
const
|
|
6245
|
+
const name2 = 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$/, "");
|
|
4779
6246
|
const id = text2(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
4780
|
-
packageIds.set(
|
|
6247
|
+
packageIds.set(name2.toLowerCase(), id);
|
|
4781
6248
|
}
|
|
4782
6249
|
const productDependency = (entry) => add({
|
|
4783
6250
|
isa: "XCSwiftPackageProductDependency",
|
|
@@ -4797,12 +6264,12 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
4797
6264
|
const targets = [];
|
|
4798
6265
|
for (const entry of items(json.targets)) {
|
|
4799
6266
|
if (!isObject(entry)) continue;
|
|
4800
|
-
const
|
|
6267
|
+
const name2 = text2(entry.name) ?? "";
|
|
4801
6268
|
const productType = text2(entry["product-type"]);
|
|
4802
6269
|
const target = {
|
|
4803
6270
|
isa: text2(entry.kind) === "aggregate" ? "PBXAggregateTarget" : "PBXNativeTarget",
|
|
4804
|
-
name,
|
|
4805
|
-
productName:
|
|
6271
|
+
name: name2,
|
|
6272
|
+
productName: name2,
|
|
4806
6273
|
productType: productType ? `com.apple.product-type.${productType}` : text2(entry["full-product-type"]) ?? "",
|
|
4807
6274
|
buildPhases: [],
|
|
4808
6275
|
dependencies: [],
|
|
@@ -4812,7 +6279,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
4812
6279
|
const product = lookup(entry.product);
|
|
4813
6280
|
if (product) target.productReference = product;
|
|
4814
6281
|
const id = add(target, text2(entry.id));
|
|
4815
|
-
targetIds.set(
|
|
6282
|
+
targetIds.set(name2, id);
|
|
4816
6283
|
targets.push({ id, target, entry });
|
|
4817
6284
|
for (const phase of items(entry["build-phases"])) {
|
|
4818
6285
|
const kind = isObject(phase) ? text2(phase.kind) : text2(phase);
|
|
@@ -4824,7 +6291,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
4824
6291
|
isObject(phase) ? text2(phase.id) : void 0
|
|
4825
6292
|
);
|
|
4826
6293
|
target.buildPhases.push(phaseId);
|
|
4827
|
-
phases.set([
|
|
6294
|
+
phases.set([name2, kind, phaseName].filter(Boolean).join("/"), phaseId);
|
|
4828
6295
|
phases.set(`id:${phaseId}`, phaseId);
|
|
4829
6296
|
}
|
|
4830
6297
|
}
|
|
@@ -4840,7 +6307,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
4840
6307
|
files2?.push(add({ isa: "PBXBuildFile", fileRef: refId }));
|
|
4841
6308
|
}
|
|
4842
6309
|
for (const { target, entry } of targets) {
|
|
4843
|
-
const
|
|
6310
|
+
const name2 = text2(entry.name) ?? "";
|
|
4844
6311
|
target.buildConfigurationList = configurationList(
|
|
4845
6312
|
settingsOf(entry["build-settings"]),
|
|
4846
6313
|
new Map(
|
|
@@ -4878,7 +6345,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
4878
6345
|
const dependency = productDependency(member);
|
|
4879
6346
|
target.packageProductDependencies.push(dependency);
|
|
4880
6347
|
const buildFile = member["build-phase"];
|
|
4881
|
-
phaseFiles(isObject(buildFile) ? buildFile["build-phase"] : buildFile,
|
|
6348
|
+
phaseFiles(isObject(buildFile) ? buildFile["build-phase"] : buildFile, name2)?.push(
|
|
4882
6349
|
add({ isa: "PBXBuildFile", productRef: dependency })
|
|
4883
6350
|
);
|
|
4884
6351
|
}
|
|
@@ -5052,9 +6519,9 @@ var CONDITIONS = {
|
|
|
5052
6519
|
variant: "normal"
|
|
5053
6520
|
};
|
|
5054
6521
|
function walkFiles(dir) {
|
|
5055
|
-
if (!
|
|
6522
|
+
if (!import_node_fs12.default.existsSync(dir)) return [];
|
|
5056
6523
|
const out = [];
|
|
5057
|
-
for (const entry of
|
|
6524
|
+
for (const entry of import_node_fs12.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
5058
6525
|
if (entry.name.startsWith(".")) continue;
|
|
5059
6526
|
const full = import_node_path13.default.join(dir, entry.name);
|
|
5060
6527
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
@@ -5062,12 +6529,12 @@ function walkFiles(dir) {
|
|
|
5062
6529
|
}
|
|
5063
6530
|
return out;
|
|
5064
6531
|
}
|
|
5065
|
-
var isDirectory = (dir) =>
|
|
6532
|
+
var isDirectory = (dir) => import_node_fs12.default.existsSync(dir) && import_node_fs12.default.statSync(dir).isDirectory();
|
|
5066
6533
|
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
5067
|
-
if (seen.has(file) || !
|
|
6534
|
+
if (seen.has(file) || !import_node_fs12.default.existsSync(file)) return {};
|
|
5068
6535
|
seen.add(file);
|
|
5069
6536
|
const settings = {};
|
|
5070
|
-
for (const raw2 of
|
|
6537
|
+
for (const raw2 of import_node_fs12.default.readFileSync(file, "utf8").split("\n")) {
|
|
5071
6538
|
const line = raw2.replace(/\/\/.*$/, "").trim();
|
|
5072
6539
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
5073
6540
|
if (include) {
|
|
@@ -5093,8 +6560,8 @@ function applyConditions(raw2, configuration) {
|
|
|
5093
6560
|
continue;
|
|
5094
6561
|
}
|
|
5095
6562
|
const matches = [...key2.slice(bracket).matchAll(/\[([^=\]]+)=([^\]]*)\]/g)].every(
|
|
5096
|
-
([,
|
|
5097
|
-
const actual =
|
|
6563
|
+
([, name2, pattern]) => {
|
|
6564
|
+
const actual = name2 === "config" ? configuration : CONDITIONS[name2];
|
|
5098
6565
|
return actual !== void 0 && new RegExp(
|
|
5099
6566
|
`^${pattern.replace(/[.+^${}()|\\]/g, "\\$&").replaceAll("*", ".*").replaceAll("?", ".")}$`
|
|
5100
6567
|
).test(actual);
|
|
@@ -5124,7 +6591,7 @@ function decodeXml(text3) {
|
|
|
5124
6591
|
}
|
|
5125
6592
|
function workspaceReferences(workspace) {
|
|
5126
6593
|
const data = import_node_path13.default.join(workspace, "contents.xcworkspacedata");
|
|
5127
|
-
if (!
|
|
6594
|
+
if (!import_node_fs12.default.existsSync(data))
|
|
5128
6595
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
5129
6596
|
const container = import_node_path13.default.dirname(workspace);
|
|
5130
6597
|
const locate = (location, base) => {
|
|
@@ -5138,7 +6605,7 @@ function workspaceReferences(workspace) {
|
|
|
5138
6605
|
};
|
|
5139
6606
|
const groups = [container];
|
|
5140
6607
|
const references = [];
|
|
5141
|
-
for (const [, closing, tag, attributes, selfClosing] of
|
|
6608
|
+
for (const [, closing, tag, attributes, selfClosing] of import_node_fs12.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
|
|
5142
6609
|
if (closing) {
|
|
5143
6610
|
if (tag === "Group") groups.pop();
|
|
5144
6611
|
continue;
|
|
@@ -5153,9 +6620,9 @@ function workspaceReferences(workspace) {
|
|
|
5153
6620
|
}
|
|
5154
6621
|
var loaded = /* @__PURE__ */ new Map();
|
|
5155
6622
|
function xcodeProjectFile(xcodeproj) {
|
|
5156
|
-
for (const
|
|
5157
|
-
const file = import_node_path13.default.join(xcodeproj,
|
|
5158
|
-
if (
|
|
6623
|
+
for (const name2 of ["project.pbxproj", "project.xcproj"]) {
|
|
6624
|
+
const file = import_node_path13.default.join(xcodeproj, name2);
|
|
6625
|
+
if (import_node_fs12.default.existsSync(file)) return file;
|
|
5159
6626
|
}
|
|
5160
6627
|
return null;
|
|
5161
6628
|
}
|
|
@@ -5163,10 +6630,10 @@ function loadProject(xcodeproj) {
|
|
|
5163
6630
|
const projectFile = xcodeProjectFile(xcodeproj);
|
|
5164
6631
|
if (!projectFile)
|
|
5165
6632
|
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
5166
|
-
const mtimeMs =
|
|
5167
|
-
const
|
|
5168
|
-
if (
|
|
5169
|
-
const source =
|
|
6633
|
+
const mtimeMs = import_node_fs12.default.statSync(projectFile).mtimeMs;
|
|
6634
|
+
const cached2 = loaded.get(projectFile);
|
|
6635
|
+
if (cached2?.mtimeMs === mtimeMs) return cached2.project;
|
|
6636
|
+
const source = import_node_fs12.default.readFileSync(projectFile, "utf8");
|
|
5170
6637
|
const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
|
|
5171
6638
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
5172
6639
|
throw new Error(`${projectFile} has no objects table`);
|
|
@@ -5180,7 +6647,7 @@ function loadProject(xcodeproj) {
|
|
|
5180
6647
|
if (!project || project.isa !== "PBXProject") {
|
|
5181
6648
|
throw new Error(`${projectFile} has no PBXProject root`);
|
|
5182
6649
|
}
|
|
5183
|
-
const projectDir =
|
|
6650
|
+
const projectDir = import_node_fs12.default.realpathSync(
|
|
5184
6651
|
import_node_path13.default.resolve(import_node_path13.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
5185
6652
|
);
|
|
5186
6653
|
const parent = /* @__PURE__ */ new Map();
|
|
@@ -5224,21 +6691,21 @@ function loadProject(xcodeproj) {
|
|
|
5224
6691
|
function targetSettings(ref, builtins) {
|
|
5225
6692
|
const { project, target } = ref;
|
|
5226
6693
|
const level = (listId) => {
|
|
5227
|
-
const
|
|
5228
|
-
const config =
|
|
6694
|
+
const configs2 = list(project.object(listId)?.buildConfigurations).map(project.object);
|
|
6695
|
+
const config = configs2.find((entry) => entry?.name === "Debug") ?? configs2.find(Boolean);
|
|
5229
6696
|
if (!config) return [];
|
|
5230
|
-
const
|
|
6697
|
+
const name2 = str(config.name) ?? "Debug";
|
|
5231
6698
|
const base = str(config.baseConfigurationReference);
|
|
5232
6699
|
const own = isDict(config.buildSettings) ? config.buildSettings : {};
|
|
5233
6700
|
return [
|
|
5234
|
-
applyConditions(base ? readXcconfig(project.resolvePath(base) ?? "") : {},
|
|
6701
|
+
applyConditions(base ? readXcconfig(project.resolvePath(base) ?? "") : {}, name2),
|
|
5235
6702
|
applyConditions(
|
|
5236
6703
|
Object.fromEntries(
|
|
5237
6704
|
Object.entries(own).flatMap(
|
|
5238
6705
|
([key2, value]) => typeof value === "string" ? [[key2, value]] : Array.isArray(value) ? [[key2, list(value).join(" ")]] : []
|
|
5239
6706
|
)
|
|
5240
6707
|
),
|
|
5241
|
-
|
|
6708
|
+
name2
|
|
5242
6709
|
)
|
|
5243
6710
|
];
|
|
5244
6711
|
};
|
|
@@ -5258,13 +6725,13 @@ function targetSettings(ref, builtins) {
|
|
|
5258
6725
|
resolving.add(marker);
|
|
5259
6726
|
const value = expand(
|
|
5260
6727
|
levels[at][key2],
|
|
5261
|
-
(
|
|
6728
|
+
(name2) => name2 === "inherited" ? valueAt(key2, at - 1) : valueAt(name2, levels.length - 1)
|
|
5262
6729
|
);
|
|
5263
6730
|
resolving.delete(marker);
|
|
5264
6731
|
return value;
|
|
5265
6732
|
};
|
|
5266
6733
|
const derived = (key2) => {
|
|
5267
|
-
const get = (
|
|
6734
|
+
const get = (name2) => valueAt(name2, levels.length - 1);
|
|
5268
6735
|
switch (key2) {
|
|
5269
6736
|
case "PRODUCT_NAME":
|
|
5270
6737
|
return get("TARGET_NAME");
|
|
@@ -5289,9 +6756,9 @@ function expand(value, lookup) {
|
|
|
5289
6756
|
return value.replace(
|
|
5290
6757
|
/\$(?:\(([A-Za-z_][A-Za-z0-9_]*)((?::[^)]*)?)\)|\{([A-Za-z_][A-Za-z0-9_]*)((?::[^}]*)?)\}|([A-Za-z_][A-Za-z0-9_]*))/g,
|
|
5291
6758
|
(_match, paren, parenOps, brace, braceOps, bare) => {
|
|
5292
|
-
const
|
|
6759
|
+
const name2 = paren ?? brace ?? bare;
|
|
5293
6760
|
const operators = parenOps ?? braceOps ?? "";
|
|
5294
|
-
return operators.split(":").slice(1).reduce((current, operator) => applyOperator(current, operator), lookup(
|
|
6761
|
+
return operators.split(":").slice(1).reduce((current, operator) => applyOperator(current, operator), lookup(name2));
|
|
5295
6762
|
}
|
|
5296
6763
|
);
|
|
5297
6764
|
}
|
|
@@ -5303,7 +6770,7 @@ function targetMembers(ref) {
|
|
|
5303
6770
|
const addResource = (file) => {
|
|
5304
6771
|
if (isDirectory(file)) {
|
|
5305
6772
|
for (const inner of walkFiles(file)) resources.add(inner);
|
|
5306
|
-
} else if (
|
|
6773
|
+
} else if (import_node_fs12.default.existsSync(file)) resources.add(file);
|
|
5307
6774
|
};
|
|
5308
6775
|
const fileRefPaths = (refId) => {
|
|
5309
6776
|
const entry = project.object(refId);
|
|
@@ -5324,7 +6791,7 @@ function targetMembers(ref) {
|
|
|
5324
6791
|
for (const buildFileId of list(phase.files)) {
|
|
5325
6792
|
for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
|
|
5326
6793
|
if (phase.isa === "PBXSourcesBuildPhase") {
|
|
5327
|
-
if (!
|
|
6794
|
+
if (!import_node_fs12.default.existsSync(file)) continue;
|
|
5328
6795
|
allSources.add(file);
|
|
5329
6796
|
if (file.endsWith(".swift")) sources.add(file);
|
|
5330
6797
|
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
@@ -5373,7 +6840,7 @@ function targetMembers(ref) {
|
|
|
5373
6840
|
folder,
|
|
5374
6841
|
import_node_path13.default.relative(folder, inner).split(import_node_path13.default.sep).join("/")
|
|
5375
6842
|
);
|
|
5376
|
-
} else if (
|
|
6843
|
+
} else if (import_node_fs12.default.existsSync(file)) addSynchronized(folder, relative);
|
|
5377
6844
|
}
|
|
5378
6845
|
}
|
|
5379
6846
|
}
|
|
@@ -5494,9 +6961,9 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
5494
6961
|
};
|
|
5495
6962
|
visit(app);
|
|
5496
6963
|
const moduleTarget = (ref) => {
|
|
5497
|
-
const
|
|
6964
|
+
const name2 = str(ref.target.name) ?? ref.id;
|
|
5498
6965
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
5499
|
-
TARGET_NAME:
|
|
6966
|
+
TARGET_NAME: name2,
|
|
5500
6967
|
PROJECT_NAME: import_node_path13.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
5501
6968
|
SRCROOT: ref.project.projectDir,
|
|
5502
6969
|
SOURCE_ROOT: ref.project.projectDir,
|
|
@@ -5508,7 +6975,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
5508
6975
|
settings: settings2,
|
|
5509
6976
|
keys,
|
|
5510
6977
|
module: {
|
|
5511
|
-
name,
|
|
6978
|
+
name: name2,
|
|
5512
6979
|
moduleName: applyOperator(settings2("PRODUCT_MODULE_NAME"), "c99extidentifier"),
|
|
5513
6980
|
...targetMembers(ref),
|
|
5514
6981
|
languageMode: swiftVersion >= 6 ? 6 : 5,
|
|
@@ -5529,7 +6996,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
5529
6996
|
return value;
|
|
5530
6997
|
};
|
|
5531
6998
|
const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path13.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
|
|
5532
|
-
const sourceInfo = infoPlistFile ? import_plist.default.parse(
|
|
6999
|
+
const sourceInfo = infoPlistFile ? import_plist.default.parse(import_node_fs12.default.readFileSync(infoPlistFile, "utf8")) : {};
|
|
5533
7000
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
5534
7001
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
5535
7002
|
}
|
|
@@ -5547,12 +7014,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
5547
7014
|
};
|
|
5548
7015
|
}
|
|
5549
7016
|
const localPackageDirs = [
|
|
5550
|
-
...listed.filter((reference) =>
|
|
7017
|
+
...listed.filter((reference) => import_node_fs12.default.existsSync(import_node_path13.default.join(reference, "Package.swift"))),
|
|
5551
7018
|
...projects2.flatMap(
|
|
5552
7019
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
5553
7020
|
if (!isDict(entry)) return [];
|
|
5554
7021
|
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path13.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
|
|
5555
|
-
return candidate &&
|
|
7022
|
+
return candidate && import_node_fs12.default.existsSync(import_node_path13.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
5556
7023
|
})
|
|
5557
7024
|
)
|
|
5558
7025
|
];
|
|
@@ -5590,11 +7057,11 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
5590
7057
|
const fileId = str(project.object(buildFileId)?.fileRef);
|
|
5591
7058
|
const file = project.object(fileId);
|
|
5592
7059
|
const tree = str(file?.sourceTree);
|
|
5593
|
-
const
|
|
5594
|
-
if (file?.isa !== "PBXFileReference" || !
|
|
7060
|
+
const name2 = /([^/]+)\.(xc)?framework$/.exec(str(file?.path) ?? "")?.[1];
|
|
7061
|
+
if (file?.isa !== "PBXFileReference" || !name2) continue;
|
|
5595
7062
|
if (tree === "BUILT_PRODUCTS_DIR" || tree === "SDKROOT" || tree === "DEVELOPER_DIR")
|
|
5596
7063
|
continue;
|
|
5597
|
-
binaryFrameworks.add(
|
|
7064
|
+
binaryFrameworks.add(name2);
|
|
5598
7065
|
}
|
|
5599
7066
|
}
|
|
5600
7067
|
}
|
|
@@ -5613,9 +7080,9 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
5613
7080
|
...used.map((project) => project.projectDir),
|
|
5614
7081
|
...localPackageDirs,
|
|
5615
7082
|
...linkedProducts.flatMap(
|
|
5616
|
-
({ source }) => source.kind === "local" &&
|
|
7083
|
+
({ source }) => source.kind === "local" && import_node_fs12.default.existsSync(source.dir) ? [source.dir] : []
|
|
5617
7084
|
)
|
|
5618
|
-
].map((dir) =>
|
|
7085
|
+
].map((dir) => import_node_fs12.default.realpathSync(dir))
|
|
5619
7086
|
),
|
|
5620
7087
|
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
5621
7088
|
infoPlist: import_plist.default.build(info),
|
|
@@ -5623,10 +7090,10 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
5623
7090
|
frameworks,
|
|
5624
7091
|
linkedProducts,
|
|
5625
7092
|
localPackageDirs: [
|
|
5626
|
-
...new Set(localPackageDirs.map((dir) =>
|
|
7093
|
+
...new Set(localPackageDirs.map((dir) => import_node_fs12.default.realpathSync(dir)))
|
|
5627
7094
|
].sort(),
|
|
5628
7095
|
binaryFrameworks: [...binaryFrameworks].sort(),
|
|
5629
|
-
packageResolved:
|
|
7096
|
+
packageResolved: import_node_fs12.default.existsSync(resolvedFile) ? resolvedFile : null,
|
|
5630
7097
|
appTargets: appTargetNames
|
|
5631
7098
|
};
|
|
5632
7099
|
}
|
|
@@ -5649,14 +7116,14 @@ function swiftPackageId(packagePath) {
|
|
|
5649
7116
|
return import_node_path14.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
5650
7117
|
}
|
|
5651
7118
|
function nativeSourceDescriptor(packagePath) {
|
|
5652
|
-
packagePath =
|
|
7119
|
+
packagePath = import_node_fs13.default.realpathSync(packagePath);
|
|
5653
7120
|
const file = import_node_path14.default.join(packagePath, NATIVE_DESCRIPTOR);
|
|
5654
|
-
if (!
|
|
7121
|
+
if (!import_node_fs13.default.existsSync(file)) return null;
|
|
5655
7122
|
const value = JSON.parse(
|
|
5656
7123
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
5657
7124
|
);
|
|
5658
7125
|
const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
|
|
5659
|
-
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !
|
|
7126
|
+
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs13.default.existsSync(import_node_path14.default.join(packagePath, NATIVE_GLUE))) {
|
|
5660
7127
|
throw invalid();
|
|
5661
7128
|
}
|
|
5662
7129
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -5665,12 +7132,12 @@ function nativeSourceDescriptor(packagePath) {
|
|
|
5665
7132
|
return value;
|
|
5666
7133
|
}
|
|
5667
7134
|
function nativeSourceFiles(packagePath) {
|
|
5668
|
-
packagePath =
|
|
5669
|
-
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((
|
|
7135
|
+
packagePath = import_node_fs13.default.realpathSync(packagePath);
|
|
7136
|
+
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name2) => import_node_path14.default.join(packagePath, name2)).filter((file) => import_node_fs13.default.existsSync(file));
|
|
5670
7137
|
}
|
|
5671
7138
|
var projects = /* @__PURE__ */ new Map();
|
|
5672
7139
|
function projectFor(packagePath, hosted) {
|
|
5673
|
-
packagePath =
|
|
7140
|
+
packagePath = import_node_fs13.default.realpathSync(packagePath);
|
|
5674
7141
|
const existing = projects.get(packagePath);
|
|
5675
7142
|
if (existing) {
|
|
5676
7143
|
if (hosted && !existing.hosted) {
|
|
@@ -5692,7 +7159,7 @@ function projectFor(packagePath, hosted) {
|
|
|
5692
7159
|
}
|
|
5693
7160
|
var xcodeProjects = /* @__PURE__ */ new Map();
|
|
5694
7161
|
function swiftPackages(entry, app) {
|
|
5695
|
-
const stamp = (file) => file &&
|
|
7162
|
+
const stamp = (file) => file && import_node_fs13.default.existsSync(file) ? import_node_fs13.default.statSync(file).mtimeMs : 0;
|
|
5696
7163
|
const key2 = JSON.stringify([
|
|
5697
7164
|
app.linkedProducts,
|
|
5698
7165
|
app.packageResolved,
|
|
@@ -5702,32 +7169,49 @@ function swiftPackages(entry, app) {
|
|
|
5702
7169
|
({ source }) => source.kind === "local" ? stamp(import_node_path14.default.join(source.dir, "Package.swift")) : 0
|
|
5703
7170
|
)
|
|
5704
7171
|
]);
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
7172
|
+
let cached2 = entry.packages;
|
|
7173
|
+
if (cached2?.key !== key2) {
|
|
7174
|
+
cached2 = {
|
|
7175
|
+
key: key2,
|
|
7176
|
+
standinKey: "",
|
|
7177
|
+
packages: resolveSwiftPackages({
|
|
7178
|
+
rootDir: app.rootDir,
|
|
7179
|
+
resolved: app.packageResolved,
|
|
7180
|
+
products: app.linkedProducts,
|
|
7181
|
+
localDirs: app.localPackageDirs,
|
|
7182
|
+
provided: entry.provided
|
|
7183
|
+
}),
|
|
7184
|
+
standins: []
|
|
7185
|
+
};
|
|
7186
|
+
entry.packages = cached2;
|
|
7187
|
+
}
|
|
7188
|
+
const reached = cached2.packages.binaries.filter((binary) => binary.reached);
|
|
7189
|
+
if (entry.moduleRoot && entry.provided && reached.length > 0) {
|
|
7190
|
+
const resolved = swiftModuleToolchain(entry.moduleRoot);
|
|
7191
|
+
const toolchain = {
|
|
7192
|
+
moduleRoot: entry.moduleRoot,
|
|
7193
|
+
toolchainBin: resolved.toolchainBin,
|
|
7194
|
+
release: resolved.release
|
|
7195
|
+
};
|
|
7196
|
+
const generation = standinGenerationInputs(reached, toolchain);
|
|
7197
|
+
if (cached2.standinKey !== generation) {
|
|
7198
|
+
const built2 = swiftStandins(reached, toolchain, entry.provided);
|
|
7199
|
+
cached2.packages = resolveSwiftPackages({
|
|
7200
|
+
rootDir: app.rootDir,
|
|
7201
|
+
resolved: app.packageResolved,
|
|
7202
|
+
products: app.linkedProducts,
|
|
7203
|
+
localDirs: app.localPackageDirs,
|
|
7204
|
+
provided: /* @__PURE__ */ new Set([
|
|
7205
|
+
...entry.provided,
|
|
7206
|
+
...built2.standins.map((standin) => standin.target)
|
|
7207
|
+
]),
|
|
7208
|
+
binaryGaps: built2.gaps
|
|
5721
7209
|
});
|
|
5722
|
-
standins = built2.standins;
|
|
5723
|
-
|
|
5724
|
-
/* @__PURE__ */ new Set([...entry.provided, ...standins.map((standin) => standin.target)]),
|
|
5725
|
-
built2.gaps
|
|
5726
|
-
);
|
|
7210
|
+
cached2.standins = built2.standins;
|
|
7211
|
+
cached2.standinKey = generation;
|
|
5727
7212
|
}
|
|
5728
|
-
entry.packages = { key: key2, packages, standins };
|
|
5729
7213
|
}
|
|
5730
|
-
return
|
|
7214
|
+
return cached2;
|
|
5731
7215
|
}
|
|
5732
7216
|
var XCODE_APP_DIR = "__app__";
|
|
5733
7217
|
var XCODE_FRAMEWORKS_DIR = "__frameworks__";
|
|
@@ -5818,25 +7302,25 @@ function xcodeManifest(layout) {
|
|
|
5818
7302
|
].join("\n");
|
|
5819
7303
|
}
|
|
5820
7304
|
function packageFiles(root) {
|
|
5821
|
-
const canonicalRoot =
|
|
7305
|
+
const canonicalRoot = import_node_fs13.default.realpathSync(root);
|
|
5822
7306
|
const xcode = xcodeLayout(canonicalRoot);
|
|
5823
7307
|
return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
|
|
5824
7308
|
}
|
|
5825
7309
|
function sourceTreeFiles(dir, canonicalRoot) {
|
|
5826
7310
|
const found = [];
|
|
5827
7311
|
const walk2 = (dir2) => {
|
|
5828
|
-
for (const entry of
|
|
7312
|
+
for (const entry of import_node_fs13.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
5829
7313
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
5830
7314
|
continue;
|
|
5831
7315
|
const full = import_node_path14.default.join(dir2, entry.name);
|
|
5832
7316
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
5833
|
-
const real =
|
|
7317
|
+
const real = import_node_fs13.default.realpathSync(full);
|
|
5834
7318
|
const relative = import_node_path14.default.relative(canonicalRoot, real);
|
|
5835
7319
|
if (relative.startsWith(`..${import_node_path14.default.sep}`) || relative === ".." || import_node_path14.default.isAbsolute(relative)) {
|
|
5836
7320
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
5837
7321
|
}
|
|
5838
7322
|
if (entry.isDirectory()) {
|
|
5839
|
-
if (
|
|
7323
|
+
if (import_node_fs13.default.existsSync(import_node_path14.default.join(full, "Package.swift"))) continue;
|
|
5840
7324
|
walk2(full);
|
|
5841
7325
|
} else if (entry.isFile()) {
|
|
5842
7326
|
found.push(full);
|
|
@@ -5844,18 +7328,18 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
5844
7328
|
}
|
|
5845
7329
|
}
|
|
5846
7330
|
};
|
|
5847
|
-
if (
|
|
7331
|
+
if (import_node_fs13.default.existsSync(dir)) walk2(import_node_fs13.default.realpathSync(dir));
|
|
5848
7332
|
return found;
|
|
5849
7333
|
}
|
|
5850
7334
|
function readPackageFile(root, file, maxBytes) {
|
|
5851
|
-
const canonicalRoot =
|
|
5852
|
-
const relative = import_node_path14.default.relative(canonicalRoot,
|
|
7335
|
+
const canonicalRoot = import_node_fs13.default.realpathSync(root);
|
|
7336
|
+
const relative = import_node_path14.default.relative(canonicalRoot, import_node_fs13.default.realpathSync(file));
|
|
5853
7337
|
if (relative === ".." || relative.startsWith(`..${import_node_path14.default.sep}`) || import_node_path14.default.isAbsolute(relative)) {
|
|
5854
7338
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
5855
7339
|
}
|
|
5856
7340
|
let ancestor = import_node_path14.default.resolve(file);
|
|
5857
7341
|
while (ancestor !== canonicalRoot) {
|
|
5858
|
-
if (
|
|
7342
|
+
if (import_node_fs13.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
5859
7343
|
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
5860
7344
|
}
|
|
5861
7345
|
const parent = import_node_path14.default.dirname(ancestor);
|
|
@@ -5863,10 +7347,10 @@ function readPackageFile(root, file, maxBytes) {
|
|
|
5863
7347
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
5864
7348
|
ancestor = parent;
|
|
5865
7349
|
}
|
|
5866
|
-
const expected =
|
|
5867
|
-
const fd =
|
|
7350
|
+
const expected = import_node_fs13.default.statSync(file);
|
|
7351
|
+
const fd = import_node_fs13.default.openSync(file, import_node_fs13.default.constants.O_RDONLY | import_node_fs13.default.constants.O_NOFOLLOW);
|
|
5868
7352
|
try {
|
|
5869
|
-
const stat =
|
|
7353
|
+
const stat = import_node_fs13.default.fstatSync(fd);
|
|
5870
7354
|
if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
|
|
5871
7355
|
throw new Error(`swift input changed while opening: ${file}`);
|
|
5872
7356
|
}
|
|
@@ -5876,16 +7360,16 @@ function readPackageFile(root, file, maxBytes) {
|
|
|
5876
7360
|
const bytes = Buffer.alloc(stat.size + 1);
|
|
5877
7361
|
let offset = 0;
|
|
5878
7362
|
while (offset < bytes.length) {
|
|
5879
|
-
const count =
|
|
7363
|
+
const count = import_node_fs13.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
5880
7364
|
if (count === 0) break;
|
|
5881
7365
|
offset += count;
|
|
5882
7366
|
}
|
|
5883
|
-
if (offset !== stat.size ||
|
|
7367
|
+
if (offset !== stat.size || import_node_fs13.default.fstatSync(fd).size !== stat.size) {
|
|
5884
7368
|
throw new Error(`swift input changed while reading: ${file}`);
|
|
5885
7369
|
}
|
|
5886
7370
|
return bytes.subarray(0, offset);
|
|
5887
7371
|
} finally {
|
|
5888
|
-
|
|
7372
|
+
import_node_fs13.default.closeSync(fd);
|
|
5889
7373
|
}
|
|
5890
7374
|
}
|
|
5891
7375
|
function sourceFiles(root) {
|
|
@@ -5946,18 +7430,18 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
5946
7430
|
const watched = [];
|
|
5947
7431
|
const registered = /* @__PURE__ */ new Map();
|
|
5948
7432
|
let imageBytes = 0;
|
|
5949
|
-
for (const { name, file, scale } of found) {
|
|
7433
|
+
for (const { name: name2, file, scale } of found) {
|
|
5950
7434
|
const disk = byRelative.get(file);
|
|
5951
7435
|
if (!disk) continue;
|
|
5952
|
-
if (Object.keys(images).length >= limits.images || imageBytes +
|
|
7436
|
+
if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs13.default.statSync(disk).size > limits.imageTotalBytes) {
|
|
5953
7437
|
throw new Error("swift image pack exceeds the compile service caps");
|
|
5954
7438
|
}
|
|
5955
7439
|
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
5956
7440
|
imageBytes += bytes.length;
|
|
5957
7441
|
const hash = (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
|
|
5958
7442
|
const ext = import_node_path14.default.posix.extname(file).toLowerCase();
|
|
5959
|
-
table[
|
|
5960
|
-
images[
|
|
7443
|
+
table[name2] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
7444
|
+
images[name2] = {
|
|
5961
7445
|
file: import_node_path14.default.posix.basename(file),
|
|
5962
7446
|
data: bytes.toString("base64")
|
|
5963
7447
|
};
|
|
@@ -5982,7 +7466,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
5982
7466
|
return { table, images, colors, symbols, watched };
|
|
5983
7467
|
}
|
|
5984
7468
|
function buildSwiftBundleFiles(packagePath, hosted) {
|
|
5985
|
-
packagePath =
|
|
7469
|
+
packagePath = import_node_fs13.default.realpathSync(packagePath);
|
|
5986
7470
|
const limits = inputLimits(hosted);
|
|
5987
7471
|
const relative = resourceCandidateFiles(packagePath).map(
|
|
5988
7472
|
(file) => import_node_path14.default.relative(packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep)
|
|
@@ -6005,7 +7489,7 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
6005
7489
|
for (const { base, file } of enumerateBundleJson(relative)) {
|
|
6006
7490
|
watched.push(file);
|
|
6007
7491
|
const disk = import_node_path14.default.join(packagePath, ...file.split("/"));
|
|
6008
|
-
if (Object.keys(files2).length >= limits.resources || total +
|
|
7492
|
+
if (Object.keys(files2).length >= limits.resources || total + import_node_fs13.default.statSync(disk).size > limits.resourceTotalBytes) {
|
|
6009
7493
|
throw new Error(
|
|
6010
7494
|
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
6011
7495
|
);
|
|
@@ -6020,7 +7504,7 @@ function serveSwiftResource(project, key2) {
|
|
|
6020
7504
|
return project.resourceFiles.get(key2) ?? project.resourcesPrevious.get(key2) ?? null;
|
|
6021
7505
|
}
|
|
6022
7506
|
function linkedModuleRoots(packagePath) {
|
|
6023
|
-
packagePath =
|
|
7507
|
+
packagePath = import_node_fs13.default.realpathSync(packagePath);
|
|
6024
7508
|
let manifest;
|
|
6025
7509
|
try {
|
|
6026
7510
|
manifest = readPackageFile(
|
|
@@ -6035,7 +7519,7 @@ function linkedModuleRoots(packagePath) {
|
|
|
6035
7519
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
6036
7520
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
6037
7521
|
const root = import_node_path14.default.resolve(packagePath, match[1]);
|
|
6038
|
-
if (
|
|
7522
|
+
if (import_node_fs13.default.existsSync(import_node_path14.default.join(root, "Package.swift"))) roots.add(root);
|
|
6039
7523
|
}
|
|
6040
7524
|
return [...roots].sort();
|
|
6041
7525
|
}
|
|
@@ -6045,17 +7529,17 @@ function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
|
6045
7529
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
6046
7530
|
for (const file of [...projectInputs].sort()) {
|
|
6047
7531
|
hash.update(import_node_path14.default.relative(packagePath, file));
|
|
6048
|
-
const stat =
|
|
7532
|
+
const stat = import_node_fs13.default.statSync(file);
|
|
6049
7533
|
hash.update(`${stat.mtimeMs}/${stat.ctimeMs}/${stat.size}`);
|
|
6050
7534
|
}
|
|
6051
7535
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
6052
|
-
(root) =>
|
|
7536
|
+
(root) => import_node_fs13.default.existsSync(import_node_path14.default.join(root, "toolchain.json"))
|
|
6053
7537
|
);
|
|
6054
7538
|
if (moduleRoot) {
|
|
6055
7539
|
hash.update(moduleRoot);
|
|
6056
7540
|
for (const relative of swiftModuleInputFiles(moduleRoot)) {
|
|
6057
7541
|
hash.update(relative);
|
|
6058
|
-
hash.update(String(
|
|
7542
|
+
hash.update(String(import_node_fs13.default.statSync(import_node_path14.default.join(moduleRoot, relative)).mtimeMs));
|
|
6059
7543
|
}
|
|
6060
7544
|
}
|
|
6061
7545
|
return hash.digest("hex").slice(0, 16);
|
|
@@ -6142,7 +7626,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
6142
7626
|
package: content
|
|
6143
7627
|
};
|
|
6144
7628
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
6145
|
-
(root) =>
|
|
7629
|
+
(root) => import_node_fs13.default.existsSync(import_node_path14.default.join(root, "toolchain.json"))
|
|
6146
7630
|
) ?? await swiftDistributionRoot();
|
|
6147
7631
|
if (!moduleRoot)
|
|
6148
7632
|
return {
|
|
@@ -6243,17 +7727,17 @@ async function missingModulesMessage(packagePath, missing) {
|
|
|
6243
7727
|
const layout = xcodeLayout(packagePath);
|
|
6244
7728
|
const gaps = new Map([
|
|
6245
7729
|
...(layout?.app.binaryFrameworks ?? []).map(
|
|
6246
|
-
(
|
|
7730
|
+
(name2) => [name2, { source: "the project", reason: "a vendored binary framework" }]
|
|
6247
7731
|
),
|
|
6248
7732
|
...[...missing.keys()].flatMap(
|
|
6249
|
-
(
|
|
7733
|
+
(name2) => UNPROVIDED_PLATFORM_MODULES[name2] ? [
|
|
6250
7734
|
[
|
|
6251
|
-
|
|
6252
|
-
{ source: "the iOS SDK", reason: UNPROVIDED_PLATFORM_MODULES[
|
|
7735
|
+
name2,
|
|
7736
|
+
{ source: "the iOS SDK", reason: UNPROVIDED_PLATFORM_MODULES[name2] }
|
|
6253
7737
|
]
|
|
6254
|
-
] : IOS_SDK_FRAMEWORKS.has(
|
|
7738
|
+
] : IOS_SDK_FRAMEWORKS.has(name2) ? [
|
|
6255
7739
|
[
|
|
6256
|
-
|
|
7740
|
+
name2,
|
|
6257
7741
|
{ source: "the iOS SDK", reason: "a framework Peach does not provide" }
|
|
6258
7742
|
]
|
|
6259
7743
|
] : []
|
|
@@ -6263,27 +7747,27 @@ async function missingModulesMessage(packagePath, missing) {
|
|
|
6263
7747
|
]);
|
|
6264
7748
|
const packaged = new Set(
|
|
6265
7749
|
[...missing.keys()].filter(
|
|
6266
|
-
(
|
|
7750
|
+
(name2) => !UNPROVIDED_PLATFORM_MODULES[name2] && !IOS_SDK_FRAMEWORKS.has(name2)
|
|
6267
7751
|
)
|
|
6268
7752
|
);
|
|
6269
7753
|
if (packaged.size > 0)
|
|
6270
7754
|
await Promise.all(
|
|
6271
7755
|
(layout?.packages.binaries ?? []).map(async (binary) => {
|
|
6272
7756
|
const modules = await swiftBinaryModules(binary).catch(() => []);
|
|
6273
|
-
for (const
|
|
6274
|
-
if (packaged.has(
|
|
6275
|
-
gaps.set(
|
|
7757
|
+
for (const name2 of modules)
|
|
7758
|
+
if (packaged.has(name2))
|
|
7759
|
+
gaps.set(name2, {
|
|
6276
7760
|
source: binary.source,
|
|
6277
7761
|
reason: layout?.packages.modules.get(binary.target)?.reason ?? `${binary.target} is a binary framework`
|
|
6278
7762
|
});
|
|
6279
7763
|
})
|
|
6280
7764
|
);
|
|
6281
|
-
const width = Math.max(...[...missing.keys()].map((
|
|
7765
|
+
const width = Math.max(...[...missing.keys()].map((name2) => name2.length));
|
|
6282
7766
|
return [
|
|
6283
7767
|
`Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
|
|
6284
|
-
...[...missing].map(([
|
|
6285
|
-
const gap = gaps.get(
|
|
6286
|
-
return ` ${
|
|
7768
|
+
...[...missing].map(([name2, files2]) => {
|
|
7769
|
+
const gap = gaps.get(name2);
|
|
7770
|
+
return ` ${name2.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})` : ""}`;
|
|
6287
7771
|
})
|
|
6288
7772
|
].join("\n");
|
|
6289
7773
|
}
|
|
@@ -6402,7 +7886,7 @@ function artifactFor(project, entry, moduleRoot) {
|
|
|
6402
7886
|
return fresh;
|
|
6403
7887
|
}
|
|
6404
7888
|
function swiftPackageWatchFiles(packagePath, moduleRoot) {
|
|
6405
|
-
packagePath =
|
|
7889
|
+
packagePath = import_node_fs13.default.realpathSync(packagePath);
|
|
6406
7890
|
return [
|
|
6407
7891
|
...xcodeProjects.has(packagePath) ? [] : [import_node_path14.default.join(packagePath, "Package.swift")],
|
|
6408
7892
|
...sourceFiles(packagePath),
|
|
@@ -6412,7 +7896,7 @@ function swiftPackageWatchFiles(packagePath, moduleRoot) {
|
|
|
6412
7896
|
];
|
|
6413
7897
|
}
|
|
6414
7898
|
async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin, hosted) {
|
|
6415
|
-
packagePath =
|
|
7899
|
+
packagePath = import_node_fs13.default.realpathSync(packagePath);
|
|
6416
7900
|
const mains = sourceFiles(packagePath).filter(
|
|
6417
7901
|
(file) => swiftApplicationEntry(
|
|
6418
7902
|
file,
|
|
@@ -6439,8 +7923,8 @@ async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin
|
|
|
6439
7923
|
icuUrl: icuUrl(origin, artifact),
|
|
6440
7924
|
rootId: `${packageName}/${entry}`,
|
|
6441
7925
|
resources: Object.fromEntries(
|
|
6442
|
-
Object.entries(resources.table).map(([
|
|
6443
|
-
|
|
7926
|
+
Object.entries(resources.table).map(([name2, image]) => [
|
|
7927
|
+
name2,
|
|
6444
7928
|
{ ...image, uri: `${origin}${image.uri}` }
|
|
6445
7929
|
])
|
|
6446
7930
|
),
|
|
@@ -6501,6 +7985,166 @@ function serveSwiftPackageAsset(pathname, res) {
|
|
|
6501
7985
|
return true;
|
|
6502
7986
|
}
|
|
6503
7987
|
|
|
7988
|
+
// src/one-widget-package.ts
|
|
7989
|
+
var import_node_child_process8 = require("node:child_process");
|
|
7990
|
+
var import_node_crypto8 = require("node:crypto");
|
|
7991
|
+
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
7992
|
+
var import_node_module = require("node:module");
|
|
7993
|
+
var import_node_os9 = __toESM(require("node:os"), 1);
|
|
7994
|
+
var import_node_path15 = __toESM(require("node:path"), 1);
|
|
7995
|
+
var import_node_util3 = require("node:util");
|
|
7996
|
+
|
|
7997
|
+
// cli/internal-child.ts
|
|
7998
|
+
var RNX_FORKED_SCRIPT_ENV = "PEACH_RUNS_FORKED_SCRIPTS";
|
|
7999
|
+
|
|
8000
|
+
// src/one-widget-package.ts
|
|
8001
|
+
var run3 = (0, import_node_util3.promisify)(import_node_child_process8.execFile);
|
|
8002
|
+
var ONE_WIDGET_PACKAGE = "OneWidgets";
|
|
8003
|
+
var configs = /* @__PURE__ */ new Map();
|
|
8004
|
+
var reads = /* @__PURE__ */ new Map();
|
|
8005
|
+
var CONFIG_CHILD = `
|
|
8006
|
+
import fs from 'node:fs';
|
|
8007
|
+
import { loadUserOneOptions } from 'one/vite';
|
|
8008
|
+
const { config, oneOptions } = await loadUserOneOptions('serve', true);
|
|
8009
|
+
const app = oneOptions.native?.app;
|
|
8010
|
+
const widgets = app?.ios?.widgets;
|
|
8011
|
+
fs.writeFileSync(process.argv[2], JSON.stringify({
|
|
8012
|
+
widget: widgets ? { appName: app.name, bundleId: app.ios.bundleId,
|
|
8013
|
+
suite: widgets.appGroup, kind: widgets.kind, displayName: widgets.displayName,
|
|
8014
|
+
description: widgets.description } : null,
|
|
8015
|
+
watched: [config.path, ...config.dependencies]
|
|
8016
|
+
}));
|
|
8017
|
+
`;
|
|
8018
|
+
function configStamp(files2) {
|
|
8019
|
+
return JSON.stringify(
|
|
8020
|
+
files2.map((file) => {
|
|
8021
|
+
if (!import_node_fs14.default.existsSync(file)) return [file, null];
|
|
8022
|
+
const stat = import_node_fs14.default.statSync(file);
|
|
8023
|
+
return [file, stat.mtimeMs, stat.ctimeMs, stat.size];
|
|
8024
|
+
})
|
|
8025
|
+
);
|
|
8026
|
+
}
|
|
8027
|
+
async function readConfig(root) {
|
|
8028
|
+
const cached2 = configs.get(root);
|
|
8029
|
+
if (cached2 && cached2.stamp === configStamp(cached2.watched)) return cached2;
|
|
8030
|
+
const reading = reads.get(root);
|
|
8031
|
+
if (reading) return reading;
|
|
8032
|
+
const promise = (async () => {
|
|
8033
|
+
(0, import_node_module.createRequire)(import_node_path15.default.join(root, "package.json")).resolve("one/vite");
|
|
8034
|
+
const cache = import_node_path15.default.join(root, "node_modules/.cache/peach-widget-config");
|
|
8035
|
+
import_node_fs14.default.mkdirSync(cache, { recursive: true });
|
|
8036
|
+
const directory = import_node_fs14.default.mkdtempSync(import_node_path15.default.join(cache, "read-"));
|
|
8037
|
+
const script = import_node_path15.default.join(directory, "read.mjs");
|
|
8038
|
+
const result = import_node_path15.default.join(directory, "result.json");
|
|
8039
|
+
import_node_fs14.default.writeFileSync(script, CONFIG_CHILD);
|
|
8040
|
+
try {
|
|
8041
|
+
await run3(process.execPath, [script, result], {
|
|
8042
|
+
cwd: root,
|
|
8043
|
+
env: { ...process.env, [RNX_FORKED_SCRIPT_ENV]: "1" },
|
|
8044
|
+
timeout: 3e4,
|
|
8045
|
+
maxBuffer: 1024 * 1024
|
|
8046
|
+
});
|
|
8047
|
+
const value = JSON.parse(import_node_fs14.default.readFileSync(result, "utf8"));
|
|
8048
|
+
if (!isRecord(value) || !Array.isArray(value.watched) || !value.watched.every((file) => typeof file === "string"))
|
|
8049
|
+
throw new Error("One config loader returned invalid dependencies");
|
|
8050
|
+
let widget = null;
|
|
8051
|
+
if (value.widget !== null) {
|
|
8052
|
+
const entry = value.widget;
|
|
8053
|
+
if (!isRecord(entry) || typeof entry.appName !== "string" || !/^[A-Za-z][A-Za-z0-9_]*$/.test(entry.appName) || typeof entry.bundleId !== "string" || !entry.bundleId || typeof entry.suite !== "string" || !entry.suite || typeof entry.kind !== "string" || !entry.kind || typeof entry.displayName !== "string" || !entry.displayName || typeof entry.description !== "string" || !entry.description)
|
|
8054
|
+
throw new Error("One config loader returned invalid native.app.ios.widgets");
|
|
8055
|
+
widget = {
|
|
8056
|
+
appName: entry.appName,
|
|
8057
|
+
bundleId: entry.bundleId,
|
|
8058
|
+
suite: entry.suite,
|
|
8059
|
+
kind: entry.kind,
|
|
8060
|
+
displayName: entry.displayName,
|
|
8061
|
+
description: entry.description
|
|
8062
|
+
};
|
|
8063
|
+
}
|
|
8064
|
+
const watched = [
|
|
8065
|
+
.../* @__PURE__ */ new Set([
|
|
8066
|
+
import_node_path15.default.join(root, "package.json"),
|
|
8067
|
+
...value.watched.map((file) => import_node_path15.default.resolve(root, file))
|
|
8068
|
+
])
|
|
8069
|
+
];
|
|
8070
|
+
const loaded2 = { widget, watched, stamp: configStamp(watched) };
|
|
8071
|
+
configs.set(root, loaded2);
|
|
8072
|
+
return loaded2;
|
|
8073
|
+
} finally {
|
|
8074
|
+
import_node_fs14.default.rmSync(directory, { recursive: true, force: true });
|
|
8075
|
+
}
|
|
8076
|
+
})();
|
|
8077
|
+
reads.set(root, promise);
|
|
8078
|
+
try {
|
|
8079
|
+
return await promise;
|
|
8080
|
+
} finally {
|
|
8081
|
+
reads.delete(root);
|
|
8082
|
+
}
|
|
8083
|
+
}
|
|
8084
|
+
async function oneWidgetPackage(appRoot) {
|
|
8085
|
+
const root = import_node_fs14.default.realpathSync(appRoot);
|
|
8086
|
+
const config = await readConfig(root);
|
|
8087
|
+
if (!config.widget) return null;
|
|
8088
|
+
const widget = config.widget;
|
|
8089
|
+
const sourceFiles2 = {
|
|
8090
|
+
"OneWidget.swift": import_node_path15.default.join(root, "ios/OneWidgets/OneWidget.swift"),
|
|
8091
|
+
"OneWidgetContract.swift": import_node_path15.default.join(
|
|
8092
|
+
root,
|
|
8093
|
+
"ios",
|
|
8094
|
+
widget.appName,
|
|
8095
|
+
"OneWidgetContract.swift"
|
|
8096
|
+
)
|
|
8097
|
+
};
|
|
8098
|
+
const files2 = /* @__PURE__ */ new Map();
|
|
8099
|
+
const sources = {};
|
|
8100
|
+
for (const [name2, file] of Object.entries(sourceFiles2)) {
|
|
8101
|
+
if (!import_node_fs14.default.existsSync(file))
|
|
8102
|
+
throw new Error(`missing One widget prebuild source ${file}; run one prebuild`);
|
|
8103
|
+
const bytes = readPackageFile(root, file, MAX_SWIFT_COMPILE_SOURCE_BYTES);
|
|
8104
|
+
const text3 = bytes.toString("utf8");
|
|
8105
|
+
if (!Buffer.from(text3).equals(bytes))
|
|
8106
|
+
throw new Error(`One widget prebuild source is not UTF-8: ${file}`);
|
|
8107
|
+
files2.set(name2, text3);
|
|
8108
|
+
sources[import_node_path15.default.relative(root, file).split(import_node_path15.default.sep).join("/")] = (0, import_node_crypto8.createHash)("sha256").update(bytes).digest("hex");
|
|
8109
|
+
}
|
|
8110
|
+
const contract = files2.get("OneWidgetContract.swift") ?? "";
|
|
8111
|
+
const source = files2.get("OneWidget.swift") ?? "";
|
|
8112
|
+
if (!contract.includes(`static let appGroup = ${JSON.stringify(widget.suite)}`) || !contract.includes(`static let kind = ${JSON.stringify(widget.kind)}`) || !source.includes(
|
|
8113
|
+
`.configurationDisplayName(${JSON.stringify(widget.displayName)})`
|
|
8114
|
+
) || !source.includes(`.description(${JSON.stringify(widget.description)})`))
|
|
8115
|
+
throw new Error(
|
|
8116
|
+
"One widget prebuild sources disagree with native.app.ios.widgets; run one prebuild"
|
|
8117
|
+
);
|
|
8118
|
+
files2.set(
|
|
8119
|
+
"Package.swift",
|
|
8120
|
+
[
|
|
8121
|
+
"// swift-tools-version: 6.2",
|
|
8122
|
+
`// One widget config ${JSON.stringify(widget)}`,
|
|
8123
|
+
"import PackageDescription",
|
|
8124
|
+
'let package = Package(name: "OneWidgets", targets: [',
|
|
8125
|
+
' .executableTarget(name: "OneWidgets", path: ".", swiftSettings: [.swiftLanguageMode(.v5)]),',
|
|
8126
|
+
"])",
|
|
8127
|
+
""
|
|
8128
|
+
].join("\n")
|
|
8129
|
+
);
|
|
8130
|
+
const packagePath = import_node_path15.default.join(
|
|
8131
|
+
import_node_os9.default.tmpdir(),
|
|
8132
|
+
"peach-one-widgets",
|
|
8133
|
+
(0, import_node_crypto8.createHash)("sha256").update(root).digest("hex"),
|
|
8134
|
+
ONE_WIDGET_PACKAGE
|
|
8135
|
+
);
|
|
8136
|
+
import_node_fs14.default.mkdirSync(packagePath, { recursive: true });
|
|
8137
|
+
syncSwiftTree(
|
|
8138
|
+
packagePath,
|
|
8139
|
+
new Map([...files2].map(([file, text3]) => [import_node_path15.default.join(packagePath, file), text3]))
|
|
8140
|
+
);
|
|
8141
|
+
return {
|
|
8142
|
+
packagePath,
|
|
8143
|
+
watched: [...config.watched, ...Object.values(sourceFiles2)],
|
|
8144
|
+
widget: { ...widget, sources }
|
|
8145
|
+
};
|
|
8146
|
+
}
|
|
8147
|
+
|
|
6504
8148
|
// src/vite-plugin-swift.ts
|
|
6505
8149
|
var ARTIFACT_PATH2 = "/__peach/swift/";
|
|
6506
8150
|
var VIRTUAL_PREFIX = "\0peach-swift:";
|
|
@@ -6515,12 +8159,12 @@ function artifactUrl(project, artifact) {
|
|
|
6515
8159
|
return `${serverOrigin()}${ARTIFACT_PATH2}${artifact.hash}.wasm`;
|
|
6516
8160
|
}
|
|
6517
8161
|
function packageFor(file) {
|
|
6518
|
-
let dir =
|
|
8162
|
+
let dir = import_node_path16.default.dirname(file);
|
|
6519
8163
|
const stop = devServer?.config.root;
|
|
6520
8164
|
for (; ; ) {
|
|
6521
|
-
if (
|
|
6522
|
-
if (stop !== void 0 && dir === stop ||
|
|
6523
|
-
dir =
|
|
8165
|
+
if (import_node_fs15.default.existsSync(import_node_path16.default.join(dir, "Package.swift"))) return dir;
|
|
8166
|
+
if (stop !== void 0 && dir === stop || import_node_path16.default.dirname(dir) === dir) break;
|
|
8167
|
+
dir = import_node_path16.default.dirname(dir);
|
|
6524
8168
|
}
|
|
6525
8169
|
throw new Error(
|
|
6526
8170
|
`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`
|
|
@@ -6541,9 +8185,9 @@ function swiftPlugin(options = {}) {
|
|
|
6541
8185
|
if (!resolved) throw new Error(`cannot resolve swift source ${source}`);
|
|
6542
8186
|
let id = resolved.id;
|
|
6543
8187
|
if (importer && (source.startsWith("./") || source.startsWith("../"))) {
|
|
6544
|
-
const raw2 =
|
|
8188
|
+
const raw2 = import_node_path16.default.resolve(import_node_path16.default.dirname(importer.split("?")[0] ?? importer), source);
|
|
6545
8189
|
try {
|
|
6546
|
-
if (
|
|
8190
|
+
if (import_node_fs15.default.realpathSync(raw2) === import_node_fs15.default.realpathSync(resolved.id)) id = raw2;
|
|
6547
8191
|
} catch {
|
|
6548
8192
|
}
|
|
6549
8193
|
}
|
|
@@ -6552,22 +8196,22 @@ function swiftPlugin(options = {}) {
|
|
|
6552
8196
|
async load(id) {
|
|
6553
8197
|
if (!id.startsWith(VIRTUAL_PREFIX)) return null;
|
|
6554
8198
|
const file = id.slice(VIRTUAL_PREFIX.length);
|
|
6555
|
-
if (!
|
|
8199
|
+
if (!import_node_fs15.default.existsSync(file)) throw new Error(`swift source ${file} no longer exists`);
|
|
6556
8200
|
const packagePath = options.packagePath ?? packageFor(file);
|
|
6557
8201
|
const project = projectFor(packagePath);
|
|
6558
|
-
const entry =
|
|
8202
|
+
const entry = import_node_path16.default.relative(packagePath, file).split(import_node_path16.default.sep).join(import_node_path16.default.posix.sep);
|
|
6559
8203
|
for (const source of [
|
|
6560
8204
|
...sourceFiles(packagePath),
|
|
6561
8205
|
...nativeSourceFiles(packagePath)
|
|
6562
8206
|
])
|
|
6563
8207
|
this.addWatchFile(source);
|
|
6564
|
-
this.addWatchFile(
|
|
8208
|
+
this.addWatchFile(import_node_path16.default.join(packagePath, "Package.swift"));
|
|
6565
8209
|
const moduleRoot = linkedModuleRoots(packagePath).find(
|
|
6566
|
-
(root) =>
|
|
8210
|
+
(root) => import_node_fs15.default.existsSync(import_node_path16.default.join(root, "toolchain.json"))
|
|
6567
8211
|
);
|
|
6568
8212
|
if (moduleRoot)
|
|
6569
8213
|
for (const relative of swiftModuleInputFiles(moduleRoot))
|
|
6570
|
-
this.addWatchFile(
|
|
8214
|
+
this.addWatchFile(import_node_path16.default.join(moduleRoot, relative));
|
|
6571
8215
|
let artifact;
|
|
6572
8216
|
try {
|
|
6573
8217
|
artifact = await artifactFor(project, entry);
|
|
@@ -6577,8 +8221,8 @@ function swiftPlugin(options = {}) {
|
|
|
6577
8221
|
artifact = project.artifact;
|
|
6578
8222
|
}
|
|
6579
8223
|
const resources = Object.fromEntries(
|
|
6580
|
-
Object.entries(artifact.package.resources.table).map(([
|
|
6581
|
-
|
|
8224
|
+
Object.entries(artifact.package.resources.table).map(([name2, image]) => [
|
|
8225
|
+
name2,
|
|
6582
8226
|
{ ...image, uri: `${serverOrigin()}${image.uri}` }
|
|
6583
8227
|
])
|
|
6584
8228
|
);
|
|
@@ -6586,7 +8230,7 @@ function swiftPlugin(options = {}) {
|
|
|
6586
8230
|
...artifact.package.resources.watched,
|
|
6587
8231
|
...artifact.package.bundleFiles.watched
|
|
6588
8232
|
])
|
|
6589
|
-
this.addWatchFile(
|
|
8233
|
+
this.addWatchFile(import_node_path16.default.join(packagePath, ...watched.split(import_node_path16.default.posix.sep)));
|
|
6590
8234
|
const colors = artifact.package.resources.colors;
|
|
6591
8235
|
const symbols = artifact.package.resources.symbols;
|
|
6592
8236
|
const bundleFiles = artifact.package.bundleFiles.files;
|
|
@@ -6613,11 +8257,13 @@ function swiftPlugin(options = {}) {
|
|
|
6613
8257
|
}
|
|
6614
8258
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6615
8259
|
0 && (module.exports = {
|
|
8260
|
+
ONE_WIDGET_PACKAGE,
|
|
6616
8261
|
buildSwiftBundleFiles,
|
|
6617
8262
|
buildSwiftResourceTable,
|
|
6618
8263
|
compileInput,
|
|
6619
8264
|
entryRootId,
|
|
6620
8265
|
linkedModuleRoots,
|
|
8266
|
+
oneWidgetPackage,
|
|
6621
8267
|
serveSwiftPackageAsset,
|
|
6622
8268
|
serveSwiftResource,
|
|
6623
8269
|
sourceStamp,
|