peachsim 0.1.781 → 0.1.783
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 -0
- package/cli/main.ts +1 -0
- 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 +3534 -134
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +6975 -2893
- 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 +8560 -166
- 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 +1810 -413
- 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 +1 -1
- package/src/swift-standin-emit.ts +149 -39
- package/src/swift-standins.ts +3 -0
- 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.783 | (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,12 +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
|
|
3568
|
-
var STANDIN_EMIT_VERSION = "
|
|
4724
|
+
var STANDIN_EMIT_VERSION = "2";
|
|
3569
4725
|
var TYPE_KINDS = /* @__PURE__ */ new Set([
|
|
3570
4726
|
"swift.class",
|
|
3571
4727
|
"swift.struct",
|
|
@@ -3583,7 +4739,18 @@ var MEMBER_KINDS = /* @__PURE__ */ new Set([
|
|
|
3583
4739
|
"swift.subscript",
|
|
3584
4740
|
"swift.type.subscript"
|
|
3585
4741
|
]);
|
|
3586
|
-
var
|
|
4742
|
+
var ACCESSOR_WORD = /^(?:get|set|nonmutating|mutating|async|throws|rethrows|_read|_modify)$/;
|
|
4743
|
+
function splitAccessors(core) {
|
|
4744
|
+
const match = /\{\s*([^}]*)\}\s*$/.exec(core);
|
|
4745
|
+
const words = match ? match[1].trim().split(/\s+/).filter(Boolean) : [];
|
|
4746
|
+
const accessors = words.length > 0 && words.every((word) => ACCESSOR_WORD.test(word));
|
|
4747
|
+
return {
|
|
4748
|
+
decl: accessors ? core.slice(0, match.index).trimEnd() : core,
|
|
4749
|
+
effects: `${words.includes("async") ? " async" : ""}${words.includes("throws") ? " throws" : words.includes("rethrows") ? " rethrows" : ""}`,
|
|
4750
|
+
settable: accessors ? words.includes("set") : /^(?:static |class )?var /.test(core),
|
|
4751
|
+
nonmutating: words.includes("nonmutating")
|
|
4752
|
+
};
|
|
4753
|
+
}
|
|
3587
4754
|
var KEEP_EXTERNAL = /* @__PURE__ */ new Map([
|
|
3588
4755
|
["s:SH", "Hashable"],
|
|
3589
4756
|
["s:SQ", "Equatable"],
|
|
@@ -3605,9 +4772,12 @@ var pathOf = (symbol) => symbol.pathComponents.join(".");
|
|
|
3605
4772
|
var unavailable = (symbol) => (symbol.availability ?? []).some(
|
|
3606
4773
|
(entry) => entry.isUnconditionallyUnavailable || entry.obsoleted !== void 0
|
|
3607
4774
|
);
|
|
3608
|
-
var witnessKey = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.") ? "type" : "instance"}|${
|
|
4775
|
+
var witnessKey = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.") ? "type" : "instance"}|${stripDefaults(
|
|
4776
|
+
splitAccessors(text(symbol)).decl
|
|
4777
|
+
).replace(/\s+/g, " ").trim()}`;
|
|
4778
|
+
var sideLeaf = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.") ? "type" : "instance"}|leaf|${leaf(symbol)}`;
|
|
3609
4779
|
var isObjC = (symbol) => symbol.identifier.precise.startsWith("c:");
|
|
3610
|
-
var trap = (
|
|
4780
|
+
var trap = (path16) => `fatalError("${path16} is a binary framework peach cannot run")`;
|
|
3611
4781
|
function emitSwiftStandin(graphs, options) {
|
|
3612
4782
|
const skipped = [];
|
|
3613
4783
|
const behavior = options.behavior ?? /* @__PURE__ */ new Map();
|
|
@@ -3640,11 +4810,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3640
4810
|
if (local) return { name: pathOf(local), local: true };
|
|
3641
4811
|
if (!fallback) return null;
|
|
3642
4812
|
const parts = fallback.split(".");
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
};
|
|
4813
|
+
const module2 = parts[0] === "SwiftUICore" ? "SwiftUI" : parts[0];
|
|
4814
|
+
const unqualified = parts.slice(1).join(".") || parts[0];
|
|
4815
|
+
const name2 = family.has(parts[0]) && parts[0] !== "SwiftUICore" ? parts.join(".") : unqualified;
|
|
4816
|
+
return { name: name2, module: module2, local: false };
|
|
3648
4817
|
};
|
|
3649
4818
|
for (const graph of graphs)
|
|
3650
4819
|
for (const edge of graph.relationships) {
|
|
@@ -3660,8 +4829,8 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3660
4829
|
...all(edge.source)
|
|
3661
4830
|
]);
|
|
3662
4831
|
} else if (edge.targetFallback) {
|
|
3663
|
-
const
|
|
3664
|
-
external.set(
|
|
4832
|
+
const name2 = nameOf(edge.target, edge.targetFallback).name;
|
|
4833
|
+
external.set(name2, [...external.get(name2) ?? [], ...all(edge.source)]);
|
|
3665
4834
|
owner.set(edge.source, edge.target);
|
|
3666
4835
|
}
|
|
3667
4836
|
break;
|
|
@@ -3675,9 +4844,9 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3675
4844
|
case "conformsTo": {
|
|
3676
4845
|
const target = nameOf(edge.target, edge.targetFallback);
|
|
3677
4846
|
const kept = KEEP_EXTERNAL.get(edge.target);
|
|
3678
|
-
const
|
|
3679
|
-
if (
|
|
3680
|
-
conforms.set(edge.source, [...conforms.get(edge.source) ?? [],
|
|
4847
|
+
const name2 = kept ?? (target && (target.local || family.has(target.module ?? "")) ? target.name : null);
|
|
4848
|
+
if (name2)
|
|
4849
|
+
conforms.set(edge.source, [...conforms.get(edge.source) ?? [], name2]);
|
|
3681
4850
|
if (byId.has(edge.target)) {
|
|
3682
4851
|
const map = source.kind.identifier === "swift.protocol" ? protocolParents : conformIds;
|
|
3683
4852
|
map.set(edge.source, [...map.get(edge.source) ?? [], edge.target]);
|
|
@@ -3699,8 +4868,42 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3699
4868
|
case "overrides":
|
|
3700
4869
|
overrides.add(edge.source);
|
|
3701
4870
|
break;
|
|
4871
|
+
case "defaultImplementationOf":
|
|
4872
|
+
break;
|
|
3702
4873
|
}
|
|
3703
4874
|
}
|
|
4875
|
+
const requirementProtocol = /* @__PURE__ */ new Map();
|
|
4876
|
+
const hasDefault = /* @__PURE__ */ new Set();
|
|
4877
|
+
for (const graph of graphs)
|
|
4878
|
+
for (const edge of graph.relationships) {
|
|
4879
|
+
if ((edge.kind === "requirementOf" || edge.kind === "optionalRequirementOf") && byId.has(edge.target))
|
|
4880
|
+
requirementProtocol.set(edge.source, edge.target);
|
|
4881
|
+
if (edge.kind === "defaultImplementationOf") hasDefault.add(edge.target);
|
|
4882
|
+
}
|
|
4883
|
+
for (const graph of graphs)
|
|
4884
|
+
for (const edge of graph.relationships) {
|
|
4885
|
+
if (edge.kind !== "defaultImplementationOf" || !byId.has(edge.source) || owner.has(edge.source))
|
|
4886
|
+
continue;
|
|
4887
|
+
const protocolId = requirementProtocol.get(edge.target);
|
|
4888
|
+
if (!protocolId) continue;
|
|
4889
|
+
owner.set(edge.source, protocolId);
|
|
4890
|
+
children.set(protocolId, [...children.get(protocolId) ?? [], ...all(edge.source)]);
|
|
4891
|
+
}
|
|
4892
|
+
const typeByPath = /* @__PURE__ */ new Map();
|
|
4893
|
+
for (const symbol of byId.values())
|
|
4894
|
+
if (TYPE_KINDS.has(symbol.kind.identifier))
|
|
4895
|
+
typeByPath.set(pathOf(symbol), symbol.identifier.precise);
|
|
4896
|
+
for (const symbol of byId.values()) {
|
|
4897
|
+
if (owner.has(symbol.identifier.precise) || symbol.pathComponents.length < 2) continue;
|
|
4898
|
+
if (TYPE_KINDS.has(symbol.kind.identifier)) continue;
|
|
4899
|
+
const parent = typeByPath.get(symbol.pathComponents.slice(0, -1).join("."));
|
|
4900
|
+
if (!parent) continue;
|
|
4901
|
+
owner.set(symbol.identifier.precise, parent);
|
|
4902
|
+
children.set(parent, [
|
|
4903
|
+
...children.get(parent) ?? [],
|
|
4904
|
+
...all(symbol.identifier.precise)
|
|
4905
|
+
]);
|
|
4906
|
+
}
|
|
3704
4907
|
const lines = [];
|
|
3705
4908
|
const owners = [];
|
|
3706
4909
|
const omit = options.omit ?? /* @__PURE__ */ new Map();
|
|
@@ -3711,10 +4914,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3711
4914
|
owners.push(...physical.map(() => current));
|
|
3712
4915
|
};
|
|
3713
4916
|
const scoped = (body) => (symbol, ...rest) => {
|
|
3714
|
-
const
|
|
3715
|
-
if (omit.has(
|
|
4917
|
+
const path16 = pathOf(symbol);
|
|
4918
|
+
if (omit.has(path16)) return void skipped.push({ path: path16, reason: omit.get(path16) });
|
|
3716
4919
|
const previous = current;
|
|
3717
|
-
current =
|
|
4920
|
+
current = path16;
|
|
3718
4921
|
try {
|
|
3719
4922
|
body(symbol, ...rest);
|
|
3720
4923
|
} finally {
|
|
@@ -3725,7 +4928,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3725
4928
|
const seen = /* @__PURE__ */ new Set();
|
|
3726
4929
|
return (children.get(id) ?? []).filter((member) => {
|
|
3727
4930
|
if (unavailable(member)) return false;
|
|
3728
|
-
const key2 = `${member.kind.identifier}|${text(member)}`;
|
|
4931
|
+
const key2 = `${member.kind.identifier}|${requirement.has(member.identifier.precise) ? "req" : "ext"}|${text(member)}`;
|
|
3729
4932
|
if (seen.has(key2)) return false;
|
|
3730
4933
|
seen.add(key2);
|
|
3731
4934
|
return true;
|
|
@@ -3734,14 +4937,14 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3734
4937
|
const access = (symbol, openOwner) => symbol.accessLevel === "open" && openOwner ? "open" : "public";
|
|
3735
4938
|
const emitMember = scoped(
|
|
3736
4939
|
(member, indent, context) => {
|
|
3737
|
-
const
|
|
4940
|
+
const path16 = pathOf(member);
|
|
3738
4941
|
if (TYPE_KINDS.has(member.kind.identifier)) {
|
|
3739
4942
|
emitType(member, indent);
|
|
3740
4943
|
return;
|
|
3741
4944
|
}
|
|
3742
4945
|
if (member.kind.identifier === "swift.enum.case") return;
|
|
3743
4946
|
if (!MEMBER_KINDS.has(member.kind.identifier)) {
|
|
3744
|
-
skipped.push({ path:
|
|
4947
|
+
skipped.push({ path: path16, reason: `unhandled ${member.kind.identifier}` });
|
|
3745
4948
|
return;
|
|
3746
4949
|
}
|
|
3747
4950
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
@@ -3754,22 +4957,22 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3754
4957
|
const required = context.inClass && flags.has("required");
|
|
3755
4958
|
const final = context.inClass && flags.has("final") ? "final " : "";
|
|
3756
4959
|
const mutating = flags.has("mutating") ? "mutating " : flags.has("nonmutating") ? "nonmutating " : "";
|
|
3757
|
-
let core = `${
|
|
3758
|
-
const override = context.inClass && !options.plain?.has(
|
|
4960
|
+
let core = `${flags.has("convenience") ? "convenience " : ""}${modifiers[2]}`;
|
|
4961
|
+
const override = context.inClass && !options.plain?.has(path16) && (flags.has("override") || overrides.has(member.identifier.precise) || options.forcedOverride?.has(path16) || isObjC(member) && path16.endsWith(".init()")) ? "override " : "";
|
|
3759
4962
|
const head = `${indent}${attrs}${access(member, context.openOwner)} ${required ? "required " : ""}${final}${override}${mutating}`;
|
|
3760
|
-
const measured = behavior.get(
|
|
3761
|
-
if (measured) used.add(
|
|
4963
|
+
const measured = behavior.get(path16);
|
|
4964
|
+
if (measured) used.add(path16);
|
|
3762
4965
|
const overloadBody = /\basync\b/.test(core) ? measured?.asyncBody : /\bResult</.test(core) ? measured?.resultBody : void 0;
|
|
3763
|
-
const body = overloadBody ?? measured?.body ?? trap(
|
|
4966
|
+
const body = overloadBody ?? measured?.body ?? trap(path16);
|
|
3764
4967
|
switch (member.kind.identifier) {
|
|
3765
4968
|
case "swift.property":
|
|
3766
4969
|
case "swift.type.property":
|
|
3767
4970
|
case "swift.subscript":
|
|
3768
4971
|
case "swift.type.subscript": {
|
|
3769
|
-
const
|
|
3770
|
-
const decl =
|
|
3771
|
-
const effects =
|
|
3772
|
-
const settable =
|
|
4972
|
+
const parsed = splitAccessors(core);
|
|
4973
|
+
const decl = parsed.decl;
|
|
4974
|
+
const effects = parsed.effects;
|
|
4975
|
+
const settable = parsed.settable;
|
|
3773
4976
|
const computed = decl.replace(/^((?:static |class )*)let /, "$1var ");
|
|
3774
4977
|
if (measured?.stored !== void 0) {
|
|
3775
4978
|
const ownership = flags.has("weak") ? "weak " : flags.has("unowned") ? "unowned " : "";
|
|
@@ -3781,7 +4984,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3781
4984
|
return;
|
|
3782
4985
|
}
|
|
3783
4986
|
emit(
|
|
3784
|
-
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` set { ${measured?.set ?? trap(
|
|
4987
|
+
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` ${parsed.nonmutating ? "nonmutating " : ""}set { ${measured?.set ?? trap(path16)} }` : ""} }`
|
|
3785
4988
|
);
|
|
3786
4989
|
return;
|
|
3787
4990
|
}
|
|
@@ -3834,7 +5037,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3834
5037
|
};
|
|
3835
5038
|
const emitType = scoped(
|
|
3836
5039
|
(symbol, indent) => {
|
|
3837
|
-
const
|
|
5040
|
+
const path16 = pathOf(symbol);
|
|
3838
5041
|
const id = symbol.identifier.precise;
|
|
3839
5042
|
const inner = `${indent} `;
|
|
3840
5043
|
switch (symbol.kind.identifier) {
|
|
@@ -3846,19 +5049,19 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3846
5049
|
case "swift.class": {
|
|
3847
5050
|
const shape = header(symbol, "class", indent);
|
|
3848
5051
|
if (!shape)
|
|
3849
|
-
return void skipped.push({ path:
|
|
3850
|
-
const parent = options.superclasses?.get(
|
|
5052
|
+
return void skipped.push({ path: path16, reason: `unparsed class ${text(symbol)}` });
|
|
5053
|
+
const parent = options.superclasses?.get(path16) ?? superclass.get(id);
|
|
3851
5054
|
const blocked = classBlocked(id);
|
|
3852
|
-
if (blocked) return void skipped.push({ path:
|
|
5055
|
+
if (blocked) return void skipped.push({ path: path16, reason: blocked });
|
|
3853
5056
|
const ancestors = /* @__PURE__ */ new Set();
|
|
3854
5057
|
for (let at = superId.get(id); at; at = superId.get(at))
|
|
3855
|
-
for (const
|
|
5058
|
+
for (const name2 of conforms.get(at) ?? []) ancestors.add(name2);
|
|
3856
5059
|
const list2 = [
|
|
3857
5060
|
...parent ? [parent] : [],
|
|
3858
5061
|
...(conforms.get(id) ?? []).filter(
|
|
3859
|
-
(
|
|
5062
|
+
(name2) => !ancestors.has(name2) && !(parent && [...KEEP_EXTERNAL.values()].includes(name2))
|
|
3860
5063
|
)
|
|
3861
|
-
].filter((
|
|
5064
|
+
].filter((name2, at, all2) => all2.indexOf(name2) === at);
|
|
3862
5065
|
const parentSymbol = superId.has(id) ? byId.get(superId.get(id)) : void 0;
|
|
3863
5066
|
const open = symbol.accessLevel === "open" && (!parentSymbol || parentSymbol.accessLevel === "open");
|
|
3864
5067
|
emit(
|
|
@@ -3876,7 +5079,18 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3876
5079
|
);
|
|
3877
5080
|
const have = /* @__PURE__ */ new Set();
|
|
3878
5081
|
for (let at = id; at; at = superId.get(at))
|
|
3879
|
-
for (const member of children.get(at) ?? [])
|
|
5082
|
+
for (const member of children.get(at) ?? []) {
|
|
5083
|
+
have.add(witnessKey(member));
|
|
5084
|
+
have.add(sideLeaf(member));
|
|
5085
|
+
}
|
|
5086
|
+
const covered = /* @__PURE__ */ new Set();
|
|
5087
|
+
const cover = (protocolId) => {
|
|
5088
|
+
if (covered.has(protocolId)) return;
|
|
5089
|
+
covered.add(protocolId);
|
|
5090
|
+
for (const edge of protocolParents.get(protocolId) ?? []) cover(edge);
|
|
5091
|
+
};
|
|
5092
|
+
for (let at = superId.get(id); at; at = superId.get(at))
|
|
5093
|
+
for (const protocolId of conformIds.get(at) ?? []) cover(protocolId);
|
|
3880
5094
|
const protocols = [];
|
|
3881
5095
|
const visit = (protocolId) => {
|
|
3882
5096
|
if (protocols.includes(protocolId)) return;
|
|
@@ -3884,20 +5098,32 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3884
5098
|
for (const edge of protocolParents.get(protocolId) ?? []) visit(edge);
|
|
3885
5099
|
};
|
|
3886
5100
|
for (const protocolId of conformIds.get(id) ?? []) visit(protocolId);
|
|
5101
|
+
const overloaded = /* @__PURE__ */ new Set();
|
|
5102
|
+
const named = /* @__PURE__ */ new Set();
|
|
3887
5103
|
for (const protocolId of protocols)
|
|
5104
|
+
for (const member of children.get(protocolId) ?? []) {
|
|
5105
|
+
if (!requirement.has(member.identifier.precise)) continue;
|
|
5106
|
+
if (named.has(sideLeaf(member))) overloaded.add(sideLeaf(member));
|
|
5107
|
+
named.add(sideLeaf(member));
|
|
5108
|
+
}
|
|
5109
|
+
const met = (member) => have.has(witnessKey(member)) || !overloaded.has(sideLeaf(member)) && have.has(sideLeaf(member));
|
|
5110
|
+
for (const protocolId of protocols) {
|
|
5111
|
+
if (covered.has(protocolId)) continue;
|
|
3888
5112
|
for (const member of children.get(protocolId) ?? []) {
|
|
3889
5113
|
if (!requirement.has(member.identifier.precise) || optional.has(member.identifier.precise))
|
|
3890
5114
|
continue;
|
|
5115
|
+
if (hasDefault.has(member.identifier.precise)) continue;
|
|
3891
5116
|
if (isObjC(member) && / async\b/.test(text(member))) continue;
|
|
3892
|
-
if (
|
|
3893
|
-
continue;
|
|
5117
|
+
if (met(member) || member.kind.identifier === "swift.associatedtype") continue;
|
|
3894
5118
|
have.add(witnessKey(member));
|
|
3895
|
-
|
|
5119
|
+
have.add(sideLeaf(member));
|
|
5120
|
+
emitWitness(member, inner, path16);
|
|
3896
5121
|
}
|
|
5122
|
+
}
|
|
3897
5123
|
const coder = members.some((member) => leaf(member) === "init(coder:)");
|
|
3898
5124
|
if (designated && !coder && externalRoot(id) !== "NSObject" && externalRoot(id) !== null)
|
|
3899
5125
|
emit(
|
|
3900
|
-
`${inner}public required init?(coder: NSCoder) { ${trap(`${
|
|
5126
|
+
`${inner}public required init?(coder: NSCoder) { ${trap(`${path16}.init(coder:)`)} }`
|
|
3901
5127
|
);
|
|
3902
5128
|
emit(`${indent}}`);
|
|
3903
5129
|
return;
|
|
@@ -3905,7 +5131,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3905
5131
|
case "swift.struct": {
|
|
3906
5132
|
const shape = header(symbol, "struct", indent);
|
|
3907
5133
|
if (!shape)
|
|
3908
|
-
return void skipped.push({ path:
|
|
5134
|
+
return void skipped.push({ path: path16, reason: `unparsed struct ${text(symbol)}` });
|
|
3909
5135
|
const members = membersOf(id);
|
|
3910
5136
|
const raw2 = rawType(members);
|
|
3911
5137
|
const list2 = inheritance(id);
|
|
@@ -3938,7 +5164,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3938
5164
|
case "swift.enum": {
|
|
3939
5165
|
const shape = header(symbol, "enum", indent);
|
|
3940
5166
|
if (!shape)
|
|
3941
|
-
return void skipped.push({ path:
|
|
5167
|
+
return void skipped.push({ path: path16, reason: `unparsed enum ${text(symbol)}` });
|
|
3942
5168
|
const members = membersOf(id);
|
|
3943
5169
|
const raw2 = rawType(members);
|
|
3944
5170
|
const cases = (children.get(id) ?? []).filter(
|
|
@@ -3947,11 +5173,11 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3947
5173
|
const missing = raw2 ? cases.filter((member) => !values.has(member.identifier.precise)) : [];
|
|
3948
5174
|
if (raw2 && isObjC(symbol) && missing.length > 0)
|
|
3949
5175
|
return void skipped.push({
|
|
3950
|
-
path:
|
|
5176
|
+
path: path16,
|
|
3951
5177
|
reason: `no header value for ${missing.map(leaf).join(", ")}`
|
|
3952
5178
|
});
|
|
3953
5179
|
const list2 = inheritance(id, raw2 ?? void 0).filter(
|
|
3954
|
-
(
|
|
5180
|
+
(name2) => name2 !== "RawRepresentable"
|
|
3955
5181
|
);
|
|
3956
5182
|
emit(
|
|
3957
5183
|
`${indent}${shape.attrs}public enum ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`
|
|
@@ -3986,7 +5212,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3986
5212
|
const shape = header(symbol, "protocol", indent);
|
|
3987
5213
|
if (!shape)
|
|
3988
5214
|
return void skipped.push({
|
|
3989
|
-
path:
|
|
5215
|
+
path: path16,
|
|
3990
5216
|
reason: `unparsed protocol ${text(symbol)}`
|
|
3991
5217
|
});
|
|
3992
5218
|
const list2 = [...isObjC(symbol) ? ["AnyObject"] : [], ...inheritance(id)];
|
|
@@ -4006,11 +5232,12 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4006
5232
|
continue;
|
|
4007
5233
|
}
|
|
4008
5234
|
emitRequirement(member, inner);
|
|
4009
|
-
if (optional.has(member.identifier.precise)
|
|
5235
|
+
if (optional.has(member.identifier.precise) && !hasDefault.has(member.identifier.precise))
|
|
5236
|
+
defaults.push(member);
|
|
4010
5237
|
}
|
|
4011
5238
|
emit(`${indent}}`);
|
|
4012
5239
|
if (defaults.length > 0) {
|
|
4013
|
-
emit(`${indent}extension ${
|
|
5240
|
+
emit(`${indent}extension ${path16} {`);
|
|
4014
5241
|
for (const member of defaults) {
|
|
4015
5242
|
const decl = text(member);
|
|
4016
5243
|
if (optional.has(member.identifier.precise) && member.kind.identifier === "swift.method" && !decl.replace(/\([^)]*\)/g, "").includes("->") && !/ async\b/.test(decl))
|
|
@@ -4035,11 +5262,9 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4035
5262
|
const witness = `${owner2}.${leaf(member)}`;
|
|
4036
5263
|
const body = trap(witness);
|
|
4037
5264
|
if (member.kind.identifier === "swift.property" || member.kind.identifier === "swift.type.property") {
|
|
4038
|
-
const
|
|
4039
|
-
const
|
|
4040
|
-
emit(
|
|
4041
|
-
`${indent}public ${bare} { get { ${body} }${accessors?.[3] ? ` set { ${body} }` : ""} }`
|
|
4042
|
-
);
|
|
5265
|
+
const parsed = splitAccessors(decl);
|
|
5266
|
+
const setter = parsed.settable ? ` ${parsed.nonmutating ? "nonmutating " : ""}set { ${body} }` : "";
|
|
5267
|
+
emit(`${indent}public ${parsed.decl} { get${parsed.effects} { ${body} }${setter} }`);
|
|
4043
5268
|
} else
|
|
4044
5269
|
emit(
|
|
4045
5270
|
`${indent}public ${member.kind.identifier === "swift.init" ? "required " : ""}${stripDefaults(decl)} { ${body} }`
|
|
@@ -4059,24 +5284,32 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4059
5284
|
return init ? /rawValue:\s*([^)]+)\)/.exec(text(init))?.[1]?.trim() ?? null : null;
|
|
4060
5285
|
};
|
|
4061
5286
|
const emitGlobal = scoped((symbol) => {
|
|
4062
|
-
const
|
|
4063
|
-
|
|
5287
|
+
const path16 = pathOf(symbol);
|
|
5288
|
+
const kind = symbol.kind.identifier;
|
|
5289
|
+
if (kind === "swift.func" || kind === "swift.func.op" || kind === "swift.method" || kind === "swift.type.method") {
|
|
4064
5290
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
5291
|
+
let spelled = rest;
|
|
5292
|
+
if (kind === "swift.func.op") {
|
|
5293
|
+
const token = /func\s+(\S+)/.exec(spelled)?.[1];
|
|
5294
|
+
const fix = token ? options.operators?.get(token) : void 0;
|
|
5295
|
+
if (fix && !/^(?:prefix|infix|postfix)\b/.test(spelled))
|
|
5296
|
+
spelled = `${fix} ${spelled}`;
|
|
5297
|
+
}
|
|
5298
|
+
emit(`${attrs}public ${spelled} { ${trap(path16)} }`);
|
|
5299
|
+
} else if (kind === "swift.var") {
|
|
5300
|
+
const parsed = splitAccessors(text(symbol).replace(/^let /, "var "));
|
|
5301
|
+
const measured = behavior.get(path16);
|
|
5302
|
+
if (measured) used.add(path16);
|
|
5303
|
+
emit(`public ${parsed.decl} { ${measured?.body ?? trap(path16)} }`);
|
|
5304
|
+
} else skipped.push({ path: path16, reason: `unhandled top-level ${kind}` });
|
|
4072
5305
|
});
|
|
4073
5306
|
const roots = [...byId.values()].filter((symbol) => !owner.has(symbol.identifier.precise) && !unavailable(symbol)).sort((a, b) => pathOf(a).localeCompare(pathOf(b)));
|
|
4074
5307
|
for (const symbol of roots) {
|
|
4075
|
-
const
|
|
5308
|
+
const path16 = pathOf(symbol);
|
|
4076
5309
|
if (TYPE_KINDS.has(symbol.kind.identifier)) emitType(symbol, "");
|
|
4077
5310
|
else emitGlobal(symbol);
|
|
4078
5311
|
}
|
|
4079
|
-
for (const [
|
|
5312
|
+
for (const [name2, members] of [...external].sort(([a], [b]) => a.localeCompare(b))) {
|
|
4080
5313
|
const seen = /* @__PURE__ */ new Set();
|
|
4081
5314
|
const kept = members.filter((member) => {
|
|
4082
5315
|
const key2 = `${member.kind.identifier}|${text(member)}`;
|
|
@@ -4085,7 +5318,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4085
5318
|
return true;
|
|
4086
5319
|
});
|
|
4087
5320
|
if (kept.length === 0) continue;
|
|
4088
|
-
emit(`extension ${
|
|
5321
|
+
emit(`extension ${name2} {`);
|
|
4089
5322
|
for (const member of kept)
|
|
4090
5323
|
if (member.kind.identifier === "swift.init" && !text(member).startsWith("convenience"))
|
|
4091
5324
|
emitMember(
|
|
@@ -4099,10 +5332,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4099
5332
|
{
|
|
4100
5333
|
openOwner: false,
|
|
4101
5334
|
inClass: true,
|
|
4102
|
-
ownerName:
|
|
5335
|
+
ownerName: name2
|
|
4103
5336
|
}
|
|
4104
5337
|
);
|
|
4105
|
-
else emitMember(member, " ", { openOwner: false, inClass: false, ownerName:
|
|
5338
|
+
else emitMember(member, " ", { openOwner: false, inClass: false, ownerName: name2 });
|
|
4106
5339
|
emit(`}`);
|
|
4107
5340
|
}
|
|
4108
5341
|
const imports = ["Foundation", "UIKit", ...options.imports ?? []];
|
|
@@ -4111,12 +5344,12 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4111
5344
|
`// do not hand-edit: every body traps because the vendor binary cannot run`,
|
|
4112
5345
|
`// in peach; behavior a hand file measures lives beside this file.`,
|
|
4113
5346
|
"",
|
|
4114
|
-
...imports.map((
|
|
5347
|
+
...imports.map((name2) => `import ${name2}`),
|
|
4115
5348
|
""
|
|
4116
5349
|
];
|
|
4117
|
-
for (const
|
|
4118
|
-
if (!used.has(
|
|
4119
|
-
skipped.push({ path:
|
|
5350
|
+
for (const path16 of behavior.keys())
|
|
5351
|
+
if (!used.has(path16))
|
|
5352
|
+
skipped.push({ path: path16, reason: "behavior names no emitted declaration" });
|
|
4120
5353
|
return {
|
|
4121
5354
|
source: `${[...banner, ...lines].join("\n")}
|
|
4122
5355
|
`,
|
|
@@ -4159,7 +5392,7 @@ var KEYWORDS = /* @__PURE__ */ new Set([
|
|
|
4159
5392
|
"false",
|
|
4160
5393
|
"nil"
|
|
4161
5394
|
]);
|
|
4162
|
-
var tick = (
|
|
5395
|
+
var tick = (name2) => KEYWORDS.has(name2) ? `\`${name2}\`` : name2;
|
|
4163
5396
|
function stripDefaults(decl) {
|
|
4164
5397
|
let out = "";
|
|
4165
5398
|
let depth = 0;
|
|
@@ -4211,23 +5444,23 @@ var digests = /* @__PURE__ */ new Map();
|
|
|
4211
5444
|
function treeDigest(root) {
|
|
4212
5445
|
const names = [];
|
|
4213
5446
|
const walk2 = (dir) => {
|
|
4214
|
-
for (const entry of
|
|
5447
|
+
for (const entry of import_node_fs11.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name < right.name ? -1 : 1)) {
|
|
4215
5448
|
const full = import_node_path11.default.join(dir, entry.name);
|
|
4216
5449
|
if (entry.isDirectory()) walk2(full);
|
|
4217
5450
|
else if (entry.isFile()) names.push(import_node_path11.default.relative(root, full));
|
|
4218
5451
|
}
|
|
4219
5452
|
};
|
|
4220
5453
|
walk2(root);
|
|
4221
|
-
const stamp = names.map((
|
|
4222
|
-
const stat =
|
|
4223
|
-
return `${
|
|
5454
|
+
const stamp = names.map((name2) => {
|
|
5455
|
+
const stat = import_node_fs11.default.statSync(import_node_path11.default.join(root, name2));
|
|
5456
|
+
return `${name2}\0${stat.size}:${stat.mtimeMs}`;
|
|
4224
5457
|
}).join("\n");
|
|
4225
5458
|
const memo2 = digests.get(`tree\0${root}`);
|
|
4226
5459
|
if (memo2?.stamp === stamp) return memo2.digest;
|
|
4227
5460
|
const hash = (0, import_node_crypto6.createHash)("sha256");
|
|
4228
|
-
for (const
|
|
4229
|
-
hash.update(`${
|
|
4230
|
-
hash.update(
|
|
5461
|
+
for (const name2 of names) {
|
|
5462
|
+
hash.update(`${name2}\0`);
|
|
5463
|
+
hash.update(import_node_fs11.default.readFileSync(import_node_path11.default.join(root, name2)));
|
|
4231
5464
|
hash.update("\0");
|
|
4232
5465
|
}
|
|
4233
5466
|
const digest = hash.digest("hex");
|
|
@@ -4236,7 +5469,7 @@ function treeDigest(root) {
|
|
|
4236
5469
|
}
|
|
4237
5470
|
function locateXcframework(tree) {
|
|
4238
5471
|
const find = (root, depth) => {
|
|
4239
|
-
for (const entry of
|
|
5472
|
+
for (const entry of import_node_fs11.default.readdirSync(root, { withFileTypes: true })) {
|
|
4240
5473
|
if (!entry.isDirectory() || entry.name === "__MACOSX") continue;
|
|
4241
5474
|
const full = import_node_path11.default.join(root, entry.name);
|
|
4242
5475
|
if (entry.name.endsWith(".xcframework")) return full;
|
|
@@ -4255,60 +5488,60 @@ function xcframework(binary) {
|
|
|
4255
5488
|
const fingerprint = import_node_path11.default.join(dir, ".fingerprint");
|
|
4256
5489
|
const stored = (() => {
|
|
4257
5490
|
try {
|
|
4258
|
-
const parsed = JSON.parse(
|
|
5491
|
+
const parsed = JSON.parse(import_node_fs11.default.readFileSync(fingerprint, "utf8"));
|
|
4259
5492
|
return parsed && typeof parsed === "object" && "sha" in parsed ? parsed : null;
|
|
4260
5493
|
} catch {
|
|
4261
5494
|
return null;
|
|
4262
5495
|
}
|
|
4263
5496
|
})();
|
|
4264
5497
|
if (!binary.url) {
|
|
4265
|
-
const stat =
|
|
5498
|
+
const stat = import_node_fs11.default.statSync(binary.dir);
|
|
4266
5499
|
const stamp = `${stat.size}:${stat.mtimeMs}`;
|
|
4267
5500
|
if (stored?.stamp === stamp) {
|
|
4268
5501
|
const found3 = locateXcframework(import_node_path11.default.join(dir, "tree"));
|
|
4269
5502
|
if (found3) return { dir: found3, digest: stored.sha };
|
|
4270
5503
|
}
|
|
4271
|
-
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(
|
|
5504
|
+
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs11.default.readFileSync(binary.dir)).digest("hex");
|
|
4272
5505
|
if (sha2 !== stored?.sha || !locateXcframework(import_node_path11.default.join(dir, "tree"))) {
|
|
4273
|
-
|
|
4274
|
-
|
|
5506
|
+
import_node_fs11.default.rmSync(dir, { recursive: true, force: true });
|
|
5507
|
+
import_node_fs11.default.mkdirSync(import_node_path11.default.join(dir, "tree"), { recursive: true });
|
|
4275
5508
|
exec("unzip", ["-q", binary.dir, "-d", import_node_path11.default.join(dir, "tree")]);
|
|
4276
5509
|
}
|
|
4277
|
-
|
|
5510
|
+
import_node_fs11.default.writeFileSync(fingerprint, JSON.stringify({ stamp, sha: sha2 }));
|
|
4278
5511
|
const found2 = locateXcframework(import_node_path11.default.join(dir, "tree"));
|
|
4279
5512
|
if (!found2) throw new Error("its archive holds no .xcframework");
|
|
4280
5513
|
return { dir: found2, digest: sha2 };
|
|
4281
5514
|
}
|
|
4282
|
-
if (stored &&
|
|
5515
|
+
if (stored && import_node_fs11.default.existsSync(archive)) {
|
|
4283
5516
|
const found2 = locateXcframework(import_node_path11.default.join(dir, "tree"));
|
|
4284
5517
|
if (found2) return { dir: found2, digest: stored.sha };
|
|
4285
5518
|
}
|
|
4286
|
-
|
|
4287
|
-
|
|
5519
|
+
import_node_fs11.default.rmSync(dir, { recursive: true, force: true });
|
|
5520
|
+
import_node_fs11.default.mkdirSync(import_node_path11.default.join(dir, "tree"), { recursive: true });
|
|
4288
5521
|
exec("curl", ["-fsSL", "--retry", "2", "-o", archive, binary.url]);
|
|
4289
|
-
const sha = (0, import_node_crypto6.createHash)("sha256").update(
|
|
5522
|
+
const sha = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs11.default.readFileSync(archive)).digest("hex");
|
|
4290
5523
|
exec("unzip", ["-q", archive, "-d", import_node_path11.default.join(dir, "tree")]);
|
|
4291
|
-
|
|
5524
|
+
import_node_fs11.default.writeFileSync(fingerprint, JSON.stringify({ sha }));
|
|
4292
5525
|
const found = locateXcframework(import_node_path11.default.join(dir, "tree"));
|
|
4293
5526
|
if (!found) throw new Error("its archive holds no .xcframework");
|
|
4294
5527
|
return { dir: found, digest: sha };
|
|
4295
5528
|
}
|
|
4296
|
-
var files = (dir, test) =>
|
|
5529
|
+
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() : [];
|
|
4297
5530
|
function surfaces(xcframeworkDir) {
|
|
4298
|
-
const slice =
|
|
5531
|
+
const slice = import_node_fs11.default.readdirSync(xcframeworkDir).filter((name2) => /^ios-.+-simulator$/.test(name2)).sort()[0];
|
|
4299
5532
|
if (!slice) throw new Error("it has no iOS simulator slice");
|
|
4300
5533
|
const root = import_node_path11.default.join(xcframeworkDir, slice);
|
|
4301
5534
|
const found = [];
|
|
4302
|
-
for (const entry of
|
|
5535
|
+
for (const entry of import_node_fs11.default.readdirSync(root).sort()) {
|
|
4303
5536
|
if (!entry.endsWith(".framework")) continue;
|
|
4304
5537
|
const module2 = entry.slice(0, -".framework".length);
|
|
4305
5538
|
const framework = import_node_path11.default.join(root, entry);
|
|
4306
5539
|
const swiftmodule = import_node_path11.default.join(framework, "Modules", `${module2}.swiftmodule`);
|
|
4307
5540
|
const interfaces = files(
|
|
4308
5541
|
swiftmodule,
|
|
4309
|
-
(
|
|
5542
|
+
(name2) => name2.endsWith(".swiftinterface") && !name2.endsWith(".private.swiftinterface") && !name2.endsWith(".package.swiftinterface")
|
|
4310
5543
|
);
|
|
4311
|
-
const chosen = interfaces.find((
|
|
5544
|
+
const chosen = interfaces.find((name2) => name2.startsWith("arm64-")) ?? interfaces[0] ?? null;
|
|
4312
5545
|
if (chosen) {
|
|
4313
5546
|
found.push({
|
|
4314
5547
|
kind: "swift",
|
|
@@ -4318,7 +5551,7 @@ function surfaces(xcframeworkDir) {
|
|
|
4318
5551
|
continue;
|
|
4319
5552
|
}
|
|
4320
5553
|
const modulemap = import_node_path11.default.join(framework, "Modules", "module.modulemap");
|
|
4321
|
-
if (
|
|
5554
|
+
if (import_node_fs11.default.existsSync(modulemap))
|
|
4322
5555
|
found.push({
|
|
4323
5556
|
kind: "c",
|
|
4324
5557
|
module: module2,
|
|
@@ -4327,9 +5560,9 @@ function surfaces(xcframeworkDir) {
|
|
|
4327
5560
|
});
|
|
4328
5561
|
}
|
|
4329
5562
|
const headers = import_node_path11.default.join(root, "Headers");
|
|
4330
|
-
for (const map of files(headers, (
|
|
5563
|
+
for (const map of files(headers, (name2) => name2 === "module.modulemap")) {
|
|
4331
5564
|
const modulemap = import_node_path11.default.join(headers, map);
|
|
4332
|
-
const module2 = /(?:^|\s)module\s+(\w+)/.exec(
|
|
5565
|
+
const module2 = /(?:^|\s)module\s+(\w+)/.exec(import_node_fs11.default.readFileSync(modulemap, "utf8"))?.[1];
|
|
4333
5566
|
if (module2) found.push({ kind: "c", module: module2, modulemap, headers });
|
|
4334
5567
|
}
|
|
4335
5568
|
return found;
|
|
@@ -4345,7 +5578,7 @@ function peachModuleDirs(toolchain, imports) {
|
|
|
4345
5578
|
toolchainBin,
|
|
4346
5579
|
plugins.libraries[0]
|
|
4347
5580
|
]);
|
|
4348
|
-
for (const target of imports.filter((
|
|
5581
|
+
for (const target of imports.filter((name2) => peach.has(name2)))
|
|
4349
5582
|
exec(
|
|
4350
5583
|
import_node_path11.default.join(toolchainBin, "swift"),
|
|
4351
5584
|
[
|
|
@@ -4379,11 +5612,11 @@ function swiftInterfaceForWasm(text3) {
|
|
|
4379
5612
|
);
|
|
4380
5613
|
}
|
|
4381
5614
|
function swiftStandin(surface, binary, toolchain, work) {
|
|
4382
|
-
const text3 = swiftInterfaceForWasm(
|
|
5615
|
+
const text3 = swiftInterfaceForWasm(import_node_fs11.default.readFileSync(surface.interface, "utf8"));
|
|
4383
5616
|
const search = import_node_path11.default.join(work, "interfaces");
|
|
4384
5617
|
const moduleDir = import_node_path11.default.join(search, `${surface.module}.swiftmodule`);
|
|
4385
|
-
|
|
4386
|
-
|
|
5618
|
+
import_node_fs11.default.mkdirSync(moduleDir, { recursive: true });
|
|
5619
|
+
import_node_fs11.default.writeFileSync(import_node_path11.default.join(moduleDir, `${TRIPLE}.swiftinterface`), text3);
|
|
4387
5620
|
const imports = [
|
|
4388
5621
|
...text3.matchAll(
|
|
4389
5622
|
/^(?:@_exported[ \t]+)?import[ \t]+(?:(?:struct|class|enum|protocol|typealias|func|var|let)[ \t]+)?(\w+)/gm
|
|
@@ -4396,7 +5629,7 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
4396
5629
|
const target = ["-target", TRIPLE, "-sdk", sysroot, "-resource-dir", resources];
|
|
4397
5630
|
const peach = peachModuleDirs(toolchain, imports).flatMap((dir) => ["-I", dir]);
|
|
4398
5631
|
const out = import_node_path11.default.join(work, "graphs");
|
|
4399
|
-
|
|
5632
|
+
import_node_fs11.default.mkdirSync(out, { recursive: true });
|
|
4400
5633
|
exec(import_node_path11.default.join(toolchain.toolchainBin, "swift-symbolgraph-extract"), [
|
|
4401
5634
|
"-module-name",
|
|
4402
5635
|
surface.module,
|
|
@@ -4411,7 +5644,7 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
4411
5644
|
"-output-dir",
|
|
4412
5645
|
out
|
|
4413
5646
|
]);
|
|
4414
|
-
const graphs =
|
|
5647
|
+
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")));
|
|
4415
5648
|
const omit = /* @__PURE__ */ new Map();
|
|
4416
5649
|
const plain = /* @__PURE__ */ new Set();
|
|
4417
5650
|
const file = import_node_path11.default.join(work, `${surface.module}.swift`);
|
|
@@ -4422,7 +5655,7 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
4422
5655
|
omit,
|
|
4423
5656
|
plain
|
|
4424
5657
|
});
|
|
4425
|
-
|
|
5658
|
+
import_node_fs11.default.writeFileSync(file, source);
|
|
4426
5659
|
const check = (0, import_node_child_process7.spawnSync)(
|
|
4427
5660
|
import_node_path11.default.join(toolchain.toolchainBin, "swiftc"),
|
|
4428
5661
|
[
|
|
@@ -4568,21 +5801,21 @@ function splitDeclarators(statement, names) {
|
|
|
4568
5801
|
}
|
|
4569
5802
|
function cStandin(surface, binary, toolchain, work) {
|
|
4570
5803
|
const named = [
|
|
4571
|
-
...
|
|
5804
|
+
...import_node_fs11.default.readFileSync(surface.modulemap, "utf8").matchAll(/(?:umbrella\s+)?header\s+"([^"]+)"/g)
|
|
4572
5805
|
].map((match) => match[1]);
|
|
4573
|
-
const headers = files(surface.headers, (
|
|
5806
|
+
const headers = files(surface.headers, (name2) => name2.endsWith(".h"));
|
|
4574
5807
|
const texts = new Map(
|
|
4575
5808
|
headers.map((file) => [
|
|
4576
5809
|
file,
|
|
4577
|
-
|
|
5810
|
+
import_node_fs11.default.readFileSync(import_node_path11.default.join(surface.headers, file), "utf8")
|
|
4578
5811
|
])
|
|
4579
5812
|
);
|
|
4580
5813
|
const objc = headers.find((file) => OBJC.test(texts.get(file)));
|
|
4581
5814
|
if (objc) throw new Error(`its header ${objc} is Objective-C`);
|
|
4582
5815
|
const include = import_node_path11.default.join(work, "include");
|
|
4583
5816
|
for (const [file, text3] of texts) {
|
|
4584
|
-
|
|
4585
|
-
|
|
5817
|
+
import_node_fs11.default.mkdirSync(import_node_path11.default.dirname(import_node_path11.default.join(include, file)), { recursive: true });
|
|
5818
|
+
import_node_fs11.default.writeFileSync(import_node_path11.default.join(include, file), text3);
|
|
4586
5819
|
}
|
|
4587
5820
|
const roots = named.length > 0 ? named : headers;
|
|
4588
5821
|
const modulemap = `module ${surface.module} {
|
|
@@ -4591,7 +5824,7 @@ ${roots.map((file) => ` header "${file}"
|
|
|
4591
5824
|
}
|
|
4592
5825
|
`;
|
|
4593
5826
|
const probe = import_node_path11.default.join(work, "declarations.c");
|
|
4594
|
-
|
|
5827
|
+
import_node_fs11.default.writeFileSync(probe, roots.map((file) => `#include "${file}"
|
|
4595
5828
|
`).join(""));
|
|
4596
5829
|
const { sysroot } = swiftSdkPaths(toolchain.moduleRoot, toolchain.toolchainBin);
|
|
4597
5830
|
const ast = JSON.parse(
|
|
@@ -4656,7 +5889,7 @@ ${roots.map((file) => ` header "${file}"
|
|
|
4656
5889
|
...definitions
|
|
4657
5890
|
].join("\n");
|
|
4658
5891
|
const out = import_node_path11.default.join(work, `${surface.module}.c`);
|
|
4659
|
-
|
|
5892
|
+
import_node_fs11.default.writeFileSync(out, source);
|
|
4660
5893
|
try {
|
|
4661
5894
|
exec(import_node_path11.default.join(toolchain.toolchainBin, "clang"), [
|
|
4662
5895
|
"-target",
|
|
@@ -4692,7 +5925,9 @@ function standinGenerationInputs(binaries, toolchain) {
|
|
|
4692
5925
|
release,
|
|
4693
5926
|
swiftModuleSdk(moduleRoot).wasmSdkId,
|
|
4694
5927
|
swiftModuleDigest(moduleRoot).toString("hex"),
|
|
4695
|
-
`emit/${STANDIN_EMIT_VERSION}
|
|
5928
|
+
`emit/${STANDIN_EMIT_VERSION}`,
|
|
5929
|
+
// a released cli can change the emitter without anyone bumping the constant
|
|
5930
|
+
`cli/${getCliVersion()}`
|
|
4696
5931
|
];
|
|
4697
5932
|
for (const binary of binaries) {
|
|
4698
5933
|
try {
|
|
@@ -4730,22 +5965,22 @@ function binaryStandins(binary, toolchain, provided) {
|
|
|
4730
5965
|
hash.update(`${surface.kind}\0${surface.module}\0`);
|
|
4731
5966
|
for (const file of surface.kind === "swift" ? [surface.interface] : [
|
|
4732
5967
|
surface.modulemap,
|
|
4733
|
-
...files(surface.headers, (
|
|
5968
|
+
...files(surface.headers, (name2) => name2.endsWith(".h")).map(
|
|
4734
5969
|
(file2) => import_node_path11.default.join(surface.headers, file2)
|
|
4735
5970
|
)
|
|
4736
5971
|
])
|
|
4737
|
-
hash.update(
|
|
5972
|
+
hash.update(import_node_fs11.default.readFileSync(file));
|
|
4738
5973
|
}
|
|
4739
5974
|
const id = hash.digest("hex").slice(0, 32);
|
|
4740
5975
|
const memo2 = built.get(id);
|
|
4741
5976
|
if (memo2) return memo2;
|
|
4742
|
-
const
|
|
4743
|
-
if (
|
|
4744
|
-
const value = JSON.parse(
|
|
5977
|
+
const cached2 = import_node_path11.default.join(cacheDir3, "standins", `${id}.json`);
|
|
5978
|
+
if (import_node_fs11.default.existsSync(cached2)) {
|
|
5979
|
+
const value = JSON.parse(import_node_fs11.default.readFileSync(cached2, "utf8"));
|
|
4745
5980
|
built.set(id, value);
|
|
4746
5981
|
return value;
|
|
4747
5982
|
}
|
|
4748
|
-
const work =
|
|
5983
|
+
const work = import_node_fs11.default.mkdtempSync(import_node_path11.default.join(import_node_os7.default.tmpdir(), "peach-standin-"));
|
|
4749
5984
|
let result;
|
|
4750
5985
|
try {
|
|
4751
5986
|
result = found.map((surface) => {
|
|
@@ -4758,13 +5993,13 @@ function binaryStandins(binary, toolchain, provided) {
|
|
|
4758
5993
|
);
|
|
4759
5994
|
}
|
|
4760
5995
|
});
|
|
4761
|
-
|
|
4762
|
-
|
|
5996
|
+
import_node_fs11.default.mkdirSync(import_node_path11.default.dirname(cached2), { recursive: true });
|
|
5997
|
+
import_node_fs11.default.writeFileSync(cached2, JSON.stringify(result));
|
|
4763
5998
|
built.set(id, result);
|
|
4764
5999
|
} catch (error) {
|
|
4765
6000
|
result = error instanceof Error ? error.message : String(error);
|
|
4766
6001
|
} finally {
|
|
4767
|
-
|
|
6002
|
+
import_node_fs11.default.rmSync(work, { recursive: true, force: true });
|
|
4768
6003
|
}
|
|
4769
6004
|
return result;
|
|
4770
6005
|
}
|
|
@@ -4796,7 +6031,7 @@ function swiftNativeEntry(native, file) {
|
|
|
4796
6031
|
packageId: native.packageId,
|
|
4797
6032
|
contractHash: native.hash,
|
|
4798
6033
|
modules: Object.fromEntries(
|
|
4799
|
-
(native.files[file] ?? []).map((
|
|
6034
|
+
(native.files[file] ?? []).map((name2) => [name2, native.modules[name2] ?? []])
|
|
4800
6035
|
),
|
|
4801
6036
|
defaultView: native.defaultViewFiles.includes(file)
|
|
4802
6037
|
};
|
|
@@ -4845,7 +6080,7 @@ function isRecord2(value) {
|
|
|
4845
6080
|
}
|
|
4846
6081
|
function isSwiftNativeModules(value) {
|
|
4847
6082
|
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(
|
|
4848
|
-
(names) => Array.isArray(names) && names.every((
|
|
6083
|
+
(names) => Array.isArray(names) && names.every((name2) => typeof name2 === "string")
|
|
4849
6084
|
) && Array.isArray(value.defaultViewFiles) && value.defaultViewFiles.every((file) => typeof file === "string");
|
|
4850
6085
|
}
|
|
4851
6086
|
function isSwiftCompileOutcome(value) {
|
|
@@ -4871,8 +6106,8 @@ function compileAssetUrl(value, origin) {
|
|
|
4871
6106
|
}
|
|
4872
6107
|
function resolveImageUrls(urls, origin) {
|
|
4873
6108
|
const resolved = {};
|
|
4874
|
-
for (const [
|
|
4875
|
-
resolved[
|
|
6109
|
+
for (const [name2, url] of Object.entries(urls)) {
|
|
6110
|
+
resolved[name2] = compileAssetUrl(url, origin);
|
|
4876
6111
|
}
|
|
4877
6112
|
return resolved;
|
|
4878
6113
|
}
|
|
@@ -4916,13 +6151,13 @@ async function compileSwiftProject(submit, work, origin, signal) {
|
|
|
4916
6151
|
}
|
|
4917
6152
|
|
|
4918
6153
|
// src/xcode-project.ts
|
|
4919
|
-
var
|
|
6154
|
+
var import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
4920
6155
|
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
4921
6156
|
var import_plist = __toESM(require_plist(), 1);
|
|
4922
6157
|
|
|
4923
6158
|
// src/xcode-json-project.ts
|
|
4924
6159
|
var import_node_path12 = __toESM(require("node:path"), 1);
|
|
4925
|
-
var import_json5 = __toESM(
|
|
6160
|
+
var import_json5 = __toESM(require_lib(), 1);
|
|
4926
6161
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4927
6162
|
var text2 = (value) => typeof value === "string" ? value : void 0;
|
|
4928
6163
|
var items = (value) => Array.isArray(value) ? value : [];
|
|
@@ -4969,8 +6204,8 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
4969
6204
|
const kind = text2(entry.kind) ?? "file-reference";
|
|
4970
6205
|
const raw2 = text2(entry.path) ?? "";
|
|
4971
6206
|
const located = raw2 === "" ? null : locate(raw2, parent.dir);
|
|
4972
|
-
const
|
|
4973
|
-
const node = { id: "", name, dir: null, parent, children: [] };
|
|
6207
|
+
const name2 = text2(entry.name) ?? import_node_path12.default.basename(raw2);
|
|
6208
|
+
const node = { id: "", name: name2, dir: null, parent, children: [] };
|
|
4974
6209
|
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
4975
6210
|
node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
4976
6211
|
const childIds = walk2(items(entry.children), node);
|
|
@@ -4983,7 +6218,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
4983
6218
|
isa: kind === "variant-group" ? "PBXVariantGroup" : "PBXGroup",
|
|
4984
6219
|
children: childIds,
|
|
4985
6220
|
...kind === "variant-group" ? {} : { sourceTree: "<absolute>", path: node.dir ?? "" },
|
|
4986
|
-
name
|
|
6221
|
+
name: name2
|
|
4987
6222
|
},
|
|
4988
6223
|
text2(entry.id)
|
|
4989
6224
|
);
|
|
@@ -5001,7 +6236,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
5001
6236
|
{
|
|
5002
6237
|
isa: "PBXFileReference",
|
|
5003
6238
|
...located ?? { sourceTree: "SDKROOT", path: raw2 },
|
|
5004
|
-
name
|
|
6239
|
+
name: name2
|
|
5005
6240
|
},
|
|
5006
6241
|
text2(entry.id)
|
|
5007
6242
|
);
|
|
@@ -5053,8 +6288,8 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
5053
6288
|
return node;
|
|
5054
6289
|
};
|
|
5055
6290
|
const configurations = items(json.configurations).flatMap((entry) => {
|
|
5056
|
-
const
|
|
5057
|
-
return
|
|
6291
|
+
const name2 = isObject(entry) ? text2(entry.name) : text2(entry);
|
|
6292
|
+
return name2 ? [{ name: name2, file: isObject(entry) ? entry.file : void 0 }] : [];
|
|
5058
6293
|
});
|
|
5059
6294
|
const settingsOf = (value) => Object.fromEntries(
|
|
5060
6295
|
Object.entries(isObject(value) ? value : {}).flatMap(
|
|
@@ -5069,11 +6304,11 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
5069
6304
|
const configurationList = (settings, specialized) => add({
|
|
5070
6305
|
isa: "XCConfigurationList",
|
|
5071
6306
|
defaultConfigurationName: text2(json["default-configuration"]) ?? "Debug",
|
|
5072
|
-
buildConfigurations: configurations.map(({ name, file }) => {
|
|
5073
|
-
const base = lookup(specialized.has(
|
|
6307
|
+
buildConfigurations: configurations.map(({ name: name2, file }) => {
|
|
6308
|
+
const base = lookup(specialized.has(name2) ? specialized.get(name2) : file);
|
|
5074
6309
|
return add({
|
|
5075
6310
|
isa: "XCBuildConfiguration",
|
|
5076
|
-
name,
|
|
6311
|
+
name: name2,
|
|
5077
6312
|
buildSettings: settings,
|
|
5078
6313
|
...base ? { baseConfigurationReference: base } : {}
|
|
5079
6314
|
});
|
|
@@ -5084,9 +6319,9 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
5084
6319
|
if (!isObject(entry)) continue;
|
|
5085
6320
|
const repository = text2(entry.repository);
|
|
5086
6321
|
const local = text2(entry.path);
|
|
5087
|
-
const
|
|
6322
|
+
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$/, "");
|
|
5088
6323
|
const id = text2(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
5089
|
-
packageIds.set(
|
|
6324
|
+
packageIds.set(name2.toLowerCase(), id);
|
|
5090
6325
|
}
|
|
5091
6326
|
const productDependency = (entry) => add({
|
|
5092
6327
|
isa: "XCSwiftPackageProductDependency",
|
|
@@ -5106,12 +6341,12 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
5106
6341
|
const targets = [];
|
|
5107
6342
|
for (const entry of items(json.targets)) {
|
|
5108
6343
|
if (!isObject(entry)) continue;
|
|
5109
|
-
const
|
|
6344
|
+
const name2 = text2(entry.name) ?? "";
|
|
5110
6345
|
const productType = text2(entry["product-type"]);
|
|
5111
6346
|
const target = {
|
|
5112
6347
|
isa: text2(entry.kind) === "aggregate" ? "PBXAggregateTarget" : "PBXNativeTarget",
|
|
5113
|
-
name,
|
|
5114
|
-
productName:
|
|
6348
|
+
name: name2,
|
|
6349
|
+
productName: name2,
|
|
5115
6350
|
productType: productType ? `com.apple.product-type.${productType}` : text2(entry["full-product-type"]) ?? "",
|
|
5116
6351
|
buildPhases: [],
|
|
5117
6352
|
dependencies: [],
|
|
@@ -5121,7 +6356,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
5121
6356
|
const product = lookup(entry.product);
|
|
5122
6357
|
if (product) target.productReference = product;
|
|
5123
6358
|
const id = add(target, text2(entry.id));
|
|
5124
|
-
targetIds.set(
|
|
6359
|
+
targetIds.set(name2, id);
|
|
5125
6360
|
targets.push({ id, target, entry });
|
|
5126
6361
|
for (const phase of items(entry["build-phases"])) {
|
|
5127
6362
|
const kind = isObject(phase) ? text2(phase.kind) : text2(phase);
|
|
@@ -5133,7 +6368,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
5133
6368
|
isObject(phase) ? text2(phase.id) : void 0
|
|
5134
6369
|
);
|
|
5135
6370
|
target.buildPhases.push(phaseId);
|
|
5136
|
-
phases.set([
|
|
6371
|
+
phases.set([name2, kind, phaseName].filter(Boolean).join("/"), phaseId);
|
|
5137
6372
|
phases.set(`id:${phaseId}`, phaseId);
|
|
5138
6373
|
}
|
|
5139
6374
|
}
|
|
@@ -5149,7 +6384,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
5149
6384
|
files2?.push(add({ isa: "PBXBuildFile", fileRef: refId }));
|
|
5150
6385
|
}
|
|
5151
6386
|
for (const { target, entry } of targets) {
|
|
5152
|
-
const
|
|
6387
|
+
const name2 = text2(entry.name) ?? "";
|
|
5153
6388
|
target.buildConfigurationList = configurationList(
|
|
5154
6389
|
settingsOf(entry["build-settings"]),
|
|
5155
6390
|
new Map(
|
|
@@ -5187,7 +6422,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
5187
6422
|
const dependency = productDependency(member);
|
|
5188
6423
|
target.packageProductDependencies.push(dependency);
|
|
5189
6424
|
const buildFile = member["build-phase"];
|
|
5190
|
-
phaseFiles(isObject(buildFile) ? buildFile["build-phase"] : buildFile,
|
|
6425
|
+
phaseFiles(isObject(buildFile) ? buildFile["build-phase"] : buildFile, name2)?.push(
|
|
5191
6426
|
add({ isa: "PBXBuildFile", productRef: dependency })
|
|
5192
6427
|
);
|
|
5193
6428
|
}
|
|
@@ -5361,9 +6596,9 @@ var CONDITIONS = {
|
|
|
5361
6596
|
variant: "normal"
|
|
5362
6597
|
};
|
|
5363
6598
|
function walkFiles(dir) {
|
|
5364
|
-
if (!
|
|
6599
|
+
if (!import_node_fs12.default.existsSync(dir)) return [];
|
|
5365
6600
|
const out = [];
|
|
5366
|
-
for (const entry of
|
|
6601
|
+
for (const entry of import_node_fs12.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
5367
6602
|
if (entry.name.startsWith(".")) continue;
|
|
5368
6603
|
const full = import_node_path13.default.join(dir, entry.name);
|
|
5369
6604
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
@@ -5371,12 +6606,12 @@ function walkFiles(dir) {
|
|
|
5371
6606
|
}
|
|
5372
6607
|
return out;
|
|
5373
6608
|
}
|
|
5374
|
-
var isDirectory = (dir) =>
|
|
6609
|
+
var isDirectory = (dir) => import_node_fs12.default.existsSync(dir) && import_node_fs12.default.statSync(dir).isDirectory();
|
|
5375
6610
|
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
5376
|
-
if (seen.has(file) || !
|
|
6611
|
+
if (seen.has(file) || !import_node_fs12.default.existsSync(file)) return {};
|
|
5377
6612
|
seen.add(file);
|
|
5378
6613
|
const settings = {};
|
|
5379
|
-
for (const raw2 of
|
|
6614
|
+
for (const raw2 of import_node_fs12.default.readFileSync(file, "utf8").split("\n")) {
|
|
5380
6615
|
const line = raw2.replace(/\/\/.*$/, "").trim();
|
|
5381
6616
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
5382
6617
|
if (include) {
|
|
@@ -5402,8 +6637,8 @@ function applyConditions(raw2, configuration) {
|
|
|
5402
6637
|
continue;
|
|
5403
6638
|
}
|
|
5404
6639
|
const matches = [...key2.slice(bracket).matchAll(/\[([^=\]]+)=([^\]]*)\]/g)].every(
|
|
5405
|
-
([,
|
|
5406
|
-
const actual =
|
|
6640
|
+
([, name2, pattern]) => {
|
|
6641
|
+
const actual = name2 === "config" ? configuration : CONDITIONS[name2];
|
|
5407
6642
|
return actual !== void 0 && new RegExp(
|
|
5408
6643
|
`^${pattern.replace(/[.+^${}()|\\]/g, "\\$&").replaceAll("*", ".*").replaceAll("?", ".")}$`
|
|
5409
6644
|
).test(actual);
|
|
@@ -5433,7 +6668,7 @@ function decodeXml(text3) {
|
|
|
5433
6668
|
}
|
|
5434
6669
|
function workspaceReferences(workspace) {
|
|
5435
6670
|
const data = import_node_path13.default.join(workspace, "contents.xcworkspacedata");
|
|
5436
|
-
if (!
|
|
6671
|
+
if (!import_node_fs12.default.existsSync(data))
|
|
5437
6672
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
5438
6673
|
const container = import_node_path13.default.dirname(workspace);
|
|
5439
6674
|
const locate = (location, base) => {
|
|
@@ -5447,7 +6682,7 @@ function workspaceReferences(workspace) {
|
|
|
5447
6682
|
};
|
|
5448
6683
|
const groups = [container];
|
|
5449
6684
|
const references = [];
|
|
5450
|
-
for (const [, closing, tag, attributes, selfClosing] of
|
|
6685
|
+
for (const [, closing, tag, attributes, selfClosing] of import_node_fs12.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
|
|
5451
6686
|
if (closing) {
|
|
5452
6687
|
if (tag === "Group") groups.pop();
|
|
5453
6688
|
continue;
|
|
@@ -5462,9 +6697,9 @@ function workspaceReferences(workspace) {
|
|
|
5462
6697
|
}
|
|
5463
6698
|
var loaded = /* @__PURE__ */ new Map();
|
|
5464
6699
|
function xcodeProjectFile(xcodeproj) {
|
|
5465
|
-
for (const
|
|
5466
|
-
const file = import_node_path13.default.join(xcodeproj,
|
|
5467
|
-
if (
|
|
6700
|
+
for (const name2 of ["project.pbxproj", "project.xcproj"]) {
|
|
6701
|
+
const file = import_node_path13.default.join(xcodeproj, name2);
|
|
6702
|
+
if (import_node_fs12.default.existsSync(file)) return file;
|
|
5468
6703
|
}
|
|
5469
6704
|
return null;
|
|
5470
6705
|
}
|
|
@@ -5472,10 +6707,10 @@ function loadProject(xcodeproj) {
|
|
|
5472
6707
|
const projectFile = xcodeProjectFile(xcodeproj);
|
|
5473
6708
|
if (!projectFile)
|
|
5474
6709
|
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
5475
|
-
const mtimeMs =
|
|
5476
|
-
const
|
|
5477
|
-
if (
|
|
5478
|
-
const source =
|
|
6710
|
+
const mtimeMs = import_node_fs12.default.statSync(projectFile).mtimeMs;
|
|
6711
|
+
const cached2 = loaded.get(projectFile);
|
|
6712
|
+
if (cached2?.mtimeMs === mtimeMs) return cached2.project;
|
|
6713
|
+
const source = import_node_fs12.default.readFileSync(projectFile, "utf8");
|
|
5479
6714
|
const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
|
|
5480
6715
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
5481
6716
|
throw new Error(`${projectFile} has no objects table`);
|
|
@@ -5489,7 +6724,7 @@ function loadProject(xcodeproj) {
|
|
|
5489
6724
|
if (!project || project.isa !== "PBXProject") {
|
|
5490
6725
|
throw new Error(`${projectFile} has no PBXProject root`);
|
|
5491
6726
|
}
|
|
5492
|
-
const projectDir =
|
|
6727
|
+
const projectDir = import_node_fs12.default.realpathSync(
|
|
5493
6728
|
import_node_path13.default.resolve(import_node_path13.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
5494
6729
|
);
|
|
5495
6730
|
const parent = /* @__PURE__ */ new Map();
|
|
@@ -5533,21 +6768,21 @@ function loadProject(xcodeproj) {
|
|
|
5533
6768
|
function targetSettings(ref, builtins) {
|
|
5534
6769
|
const { project, target } = ref;
|
|
5535
6770
|
const level = (listId) => {
|
|
5536
|
-
const
|
|
5537
|
-
const config =
|
|
6771
|
+
const configs2 = list(project.object(listId)?.buildConfigurations).map(project.object);
|
|
6772
|
+
const config = configs2.find((entry) => entry?.name === "Debug") ?? configs2.find(Boolean);
|
|
5538
6773
|
if (!config) return [];
|
|
5539
|
-
const
|
|
6774
|
+
const name2 = str(config.name) ?? "Debug";
|
|
5540
6775
|
const base = str(config.baseConfigurationReference);
|
|
5541
6776
|
const own = isDict(config.buildSettings) ? config.buildSettings : {};
|
|
5542
6777
|
return [
|
|
5543
|
-
applyConditions(base ? readXcconfig(project.resolvePath(base) ?? "") : {},
|
|
6778
|
+
applyConditions(base ? readXcconfig(project.resolvePath(base) ?? "") : {}, name2),
|
|
5544
6779
|
applyConditions(
|
|
5545
6780
|
Object.fromEntries(
|
|
5546
6781
|
Object.entries(own).flatMap(
|
|
5547
6782
|
([key2, value]) => typeof value === "string" ? [[key2, value]] : Array.isArray(value) ? [[key2, list(value).join(" ")]] : []
|
|
5548
6783
|
)
|
|
5549
6784
|
),
|
|
5550
|
-
|
|
6785
|
+
name2
|
|
5551
6786
|
)
|
|
5552
6787
|
];
|
|
5553
6788
|
};
|
|
@@ -5567,13 +6802,13 @@ function targetSettings(ref, builtins) {
|
|
|
5567
6802
|
resolving.add(marker);
|
|
5568
6803
|
const value = expand(
|
|
5569
6804
|
levels[at][key2],
|
|
5570
|
-
(
|
|
6805
|
+
(name2) => name2 === "inherited" ? valueAt(key2, at - 1) : valueAt(name2, levels.length - 1)
|
|
5571
6806
|
);
|
|
5572
6807
|
resolving.delete(marker);
|
|
5573
6808
|
return value;
|
|
5574
6809
|
};
|
|
5575
6810
|
const derived = (key2) => {
|
|
5576
|
-
const get = (
|
|
6811
|
+
const get = (name2) => valueAt(name2, levels.length - 1);
|
|
5577
6812
|
switch (key2) {
|
|
5578
6813
|
case "PRODUCT_NAME":
|
|
5579
6814
|
return get("TARGET_NAME");
|
|
@@ -5598,9 +6833,9 @@ function expand(value, lookup) {
|
|
|
5598
6833
|
return value.replace(
|
|
5599
6834
|
/\$(?:\(([A-Za-z_][A-Za-z0-9_]*)((?::[^)]*)?)\)|\{([A-Za-z_][A-Za-z0-9_]*)((?::[^}]*)?)\}|([A-Za-z_][A-Za-z0-9_]*))/g,
|
|
5600
6835
|
(_match, paren, parenOps, brace, braceOps, bare) => {
|
|
5601
|
-
const
|
|
6836
|
+
const name2 = paren ?? brace ?? bare;
|
|
5602
6837
|
const operators = parenOps ?? braceOps ?? "";
|
|
5603
|
-
return operators.split(":").slice(1).reduce((current, operator) => applyOperator(current, operator), lookup(
|
|
6838
|
+
return operators.split(":").slice(1).reduce((current, operator) => applyOperator(current, operator), lookup(name2));
|
|
5604
6839
|
}
|
|
5605
6840
|
);
|
|
5606
6841
|
}
|
|
@@ -5612,7 +6847,7 @@ function targetMembers(ref) {
|
|
|
5612
6847
|
const addResource = (file) => {
|
|
5613
6848
|
if (isDirectory(file)) {
|
|
5614
6849
|
for (const inner of walkFiles(file)) resources.add(inner);
|
|
5615
|
-
} else if (
|
|
6850
|
+
} else if (import_node_fs12.default.existsSync(file)) resources.add(file);
|
|
5616
6851
|
};
|
|
5617
6852
|
const fileRefPaths = (refId) => {
|
|
5618
6853
|
const entry = project.object(refId);
|
|
@@ -5633,7 +6868,7 @@ function targetMembers(ref) {
|
|
|
5633
6868
|
for (const buildFileId of list(phase.files)) {
|
|
5634
6869
|
for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
|
|
5635
6870
|
if (phase.isa === "PBXSourcesBuildPhase") {
|
|
5636
|
-
if (!
|
|
6871
|
+
if (!import_node_fs12.default.existsSync(file)) continue;
|
|
5637
6872
|
allSources.add(file);
|
|
5638
6873
|
if (file.endsWith(".swift")) sources.add(file);
|
|
5639
6874
|
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
@@ -5682,7 +6917,7 @@ function targetMembers(ref) {
|
|
|
5682
6917
|
folder,
|
|
5683
6918
|
import_node_path13.default.relative(folder, inner).split(import_node_path13.default.sep).join("/")
|
|
5684
6919
|
);
|
|
5685
|
-
} else if (
|
|
6920
|
+
} else if (import_node_fs12.default.existsSync(file)) addSynchronized(folder, relative);
|
|
5686
6921
|
}
|
|
5687
6922
|
}
|
|
5688
6923
|
}
|
|
@@ -5803,9 +7038,9 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
5803
7038
|
};
|
|
5804
7039
|
visit(app);
|
|
5805
7040
|
const moduleTarget = (ref) => {
|
|
5806
|
-
const
|
|
7041
|
+
const name2 = str(ref.target.name) ?? ref.id;
|
|
5807
7042
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
5808
|
-
TARGET_NAME:
|
|
7043
|
+
TARGET_NAME: name2,
|
|
5809
7044
|
PROJECT_NAME: import_node_path13.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
5810
7045
|
SRCROOT: ref.project.projectDir,
|
|
5811
7046
|
SOURCE_ROOT: ref.project.projectDir,
|
|
@@ -5817,7 +7052,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
5817
7052
|
settings: settings2,
|
|
5818
7053
|
keys,
|
|
5819
7054
|
module: {
|
|
5820
|
-
name,
|
|
7055
|
+
name: name2,
|
|
5821
7056
|
moduleName: applyOperator(settings2("PRODUCT_MODULE_NAME"), "c99extidentifier"),
|
|
5822
7057
|
...targetMembers(ref),
|
|
5823
7058
|
languageMode: swiftVersion >= 6 ? 6 : 5,
|
|
@@ -5838,7 +7073,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
5838
7073
|
return value;
|
|
5839
7074
|
};
|
|
5840
7075
|
const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path13.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
|
|
5841
|
-
const sourceInfo = infoPlistFile ? import_plist.default.parse(
|
|
7076
|
+
const sourceInfo = infoPlistFile ? import_plist.default.parse(import_node_fs12.default.readFileSync(infoPlistFile, "utf8")) : {};
|
|
5842
7077
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
5843
7078
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
5844
7079
|
}
|
|
@@ -5856,12 +7091,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
5856
7091
|
};
|
|
5857
7092
|
}
|
|
5858
7093
|
const localPackageDirs = [
|
|
5859
|
-
...listed.filter((reference) =>
|
|
7094
|
+
...listed.filter((reference) => import_node_fs12.default.existsSync(import_node_path13.default.join(reference, "Package.swift"))),
|
|
5860
7095
|
...projects2.flatMap(
|
|
5861
7096
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
5862
7097
|
if (!isDict(entry)) return [];
|
|
5863
7098
|
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path13.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
|
|
5864
|
-
return candidate &&
|
|
7099
|
+
return candidate && import_node_fs12.default.existsSync(import_node_path13.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
5865
7100
|
})
|
|
5866
7101
|
)
|
|
5867
7102
|
];
|
|
@@ -5899,11 +7134,11 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
5899
7134
|
const fileId = str(project.object(buildFileId)?.fileRef);
|
|
5900
7135
|
const file = project.object(fileId);
|
|
5901
7136
|
const tree = str(file?.sourceTree);
|
|
5902
|
-
const
|
|
5903
|
-
if (file?.isa !== "PBXFileReference" || !
|
|
7137
|
+
const name2 = /([^/]+)\.(xc)?framework$/.exec(str(file?.path) ?? "")?.[1];
|
|
7138
|
+
if (file?.isa !== "PBXFileReference" || !name2) continue;
|
|
5904
7139
|
if (tree === "BUILT_PRODUCTS_DIR" || tree === "SDKROOT" || tree === "DEVELOPER_DIR")
|
|
5905
7140
|
continue;
|
|
5906
|
-
binaryFrameworks.add(
|
|
7141
|
+
binaryFrameworks.add(name2);
|
|
5907
7142
|
}
|
|
5908
7143
|
}
|
|
5909
7144
|
}
|
|
@@ -5922,9 +7157,9 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
5922
7157
|
...used.map((project) => project.projectDir),
|
|
5923
7158
|
...localPackageDirs,
|
|
5924
7159
|
...linkedProducts.flatMap(
|
|
5925
|
-
({ source }) => source.kind === "local" &&
|
|
7160
|
+
({ source }) => source.kind === "local" && import_node_fs12.default.existsSync(source.dir) ? [source.dir] : []
|
|
5926
7161
|
)
|
|
5927
|
-
].map((dir) =>
|
|
7162
|
+
].map((dir) => import_node_fs12.default.realpathSync(dir))
|
|
5928
7163
|
),
|
|
5929
7164
|
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
5930
7165
|
infoPlist: import_plist.default.build(info),
|
|
@@ -5932,10 +7167,10 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
5932
7167
|
frameworks,
|
|
5933
7168
|
linkedProducts,
|
|
5934
7169
|
localPackageDirs: [
|
|
5935
|
-
...new Set(localPackageDirs.map((dir) =>
|
|
7170
|
+
...new Set(localPackageDirs.map((dir) => import_node_fs12.default.realpathSync(dir)))
|
|
5936
7171
|
].sort(),
|
|
5937
7172
|
binaryFrameworks: [...binaryFrameworks].sort(),
|
|
5938
|
-
packageResolved:
|
|
7173
|
+
packageResolved: import_node_fs12.default.existsSync(resolvedFile) ? resolvedFile : null,
|
|
5939
7174
|
appTargets: appTargetNames
|
|
5940
7175
|
};
|
|
5941
7176
|
}
|
|
@@ -5958,14 +7193,14 @@ function swiftPackageId(packagePath) {
|
|
|
5958
7193
|
return import_node_path14.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
5959
7194
|
}
|
|
5960
7195
|
function nativeSourceDescriptor(packagePath) {
|
|
5961
|
-
packagePath =
|
|
7196
|
+
packagePath = import_node_fs13.default.realpathSync(packagePath);
|
|
5962
7197
|
const file = import_node_path14.default.join(packagePath, NATIVE_DESCRIPTOR);
|
|
5963
|
-
if (!
|
|
7198
|
+
if (!import_node_fs13.default.existsSync(file)) return null;
|
|
5964
7199
|
const value = JSON.parse(
|
|
5965
7200
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
5966
7201
|
);
|
|
5967
7202
|
const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
|
|
5968
|
-
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !
|
|
7203
|
+
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs13.default.existsSync(import_node_path14.default.join(packagePath, NATIVE_GLUE))) {
|
|
5969
7204
|
throw invalid();
|
|
5970
7205
|
}
|
|
5971
7206
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -5974,12 +7209,12 @@ function nativeSourceDescriptor(packagePath) {
|
|
|
5974
7209
|
return value;
|
|
5975
7210
|
}
|
|
5976
7211
|
function nativeSourceFiles(packagePath) {
|
|
5977
|
-
packagePath =
|
|
5978
|
-
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((
|
|
7212
|
+
packagePath = import_node_fs13.default.realpathSync(packagePath);
|
|
7213
|
+
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name2) => import_node_path14.default.join(packagePath, name2)).filter((file) => import_node_fs13.default.existsSync(file));
|
|
5979
7214
|
}
|
|
5980
7215
|
var projects = /* @__PURE__ */ new Map();
|
|
5981
7216
|
function projectFor(packagePath, hosted) {
|
|
5982
|
-
packagePath =
|
|
7217
|
+
packagePath = import_node_fs13.default.realpathSync(packagePath);
|
|
5983
7218
|
const existing = projects.get(packagePath);
|
|
5984
7219
|
if (existing) {
|
|
5985
7220
|
if (hosted && !existing.hosted) {
|
|
@@ -6001,7 +7236,7 @@ function projectFor(packagePath, hosted) {
|
|
|
6001
7236
|
}
|
|
6002
7237
|
var xcodeProjects = /* @__PURE__ */ new Map();
|
|
6003
7238
|
function swiftPackages(entry, app) {
|
|
6004
|
-
const stamp = (file) => file &&
|
|
7239
|
+
const stamp = (file) => file && import_node_fs13.default.existsSync(file) ? import_node_fs13.default.statSync(file).mtimeMs : 0;
|
|
6005
7240
|
const key2 = JSON.stringify([
|
|
6006
7241
|
app.linkedProducts,
|
|
6007
7242
|
app.packageResolved,
|
|
@@ -6011,9 +7246,9 @@ function swiftPackages(entry, app) {
|
|
|
6011
7246
|
({ source }) => source.kind === "local" ? stamp(import_node_path14.default.join(source.dir, "Package.swift")) : 0
|
|
6012
7247
|
)
|
|
6013
7248
|
]);
|
|
6014
|
-
let
|
|
6015
|
-
if (
|
|
6016
|
-
|
|
7249
|
+
let cached2 = entry.packages;
|
|
7250
|
+
if (cached2?.key !== key2) {
|
|
7251
|
+
cached2 = {
|
|
6017
7252
|
key: key2,
|
|
6018
7253
|
standinKey: "",
|
|
6019
7254
|
packages: resolveSwiftPackages({
|
|
@@ -6025,9 +7260,9 @@ function swiftPackages(entry, app) {
|
|
|
6025
7260
|
}),
|
|
6026
7261
|
standins: []
|
|
6027
7262
|
};
|
|
6028
|
-
entry.packages =
|
|
7263
|
+
entry.packages = cached2;
|
|
6029
7264
|
}
|
|
6030
|
-
const reached =
|
|
7265
|
+
const reached = cached2.packages.binaries.filter((binary) => binary.reached);
|
|
6031
7266
|
if (entry.moduleRoot && entry.provided && reached.length > 0) {
|
|
6032
7267
|
const resolved = swiftModuleToolchain(entry.moduleRoot);
|
|
6033
7268
|
const toolchain = {
|
|
@@ -6036,9 +7271,9 @@ function swiftPackages(entry, app) {
|
|
|
6036
7271
|
release: resolved.release
|
|
6037
7272
|
};
|
|
6038
7273
|
const generation = standinGenerationInputs(reached, toolchain);
|
|
6039
|
-
if (
|
|
7274
|
+
if (cached2.standinKey !== generation) {
|
|
6040
7275
|
const built2 = swiftStandins(reached, toolchain, entry.provided);
|
|
6041
|
-
|
|
7276
|
+
cached2.packages = resolveSwiftPackages({
|
|
6042
7277
|
rootDir: app.rootDir,
|
|
6043
7278
|
resolved: app.packageResolved,
|
|
6044
7279
|
products: app.linkedProducts,
|
|
@@ -6049,11 +7284,11 @@ function swiftPackages(entry, app) {
|
|
|
6049
7284
|
]),
|
|
6050
7285
|
binaryGaps: built2.gaps
|
|
6051
7286
|
});
|
|
6052
|
-
|
|
6053
|
-
|
|
7287
|
+
cached2.standins = built2.standins;
|
|
7288
|
+
cached2.standinKey = generation;
|
|
6054
7289
|
}
|
|
6055
7290
|
}
|
|
6056
|
-
return
|
|
7291
|
+
return cached2;
|
|
6057
7292
|
}
|
|
6058
7293
|
var XCODE_APP_DIR = "__app__";
|
|
6059
7294
|
var XCODE_FRAMEWORKS_DIR = "__frameworks__";
|
|
@@ -6144,25 +7379,25 @@ function xcodeManifest(layout) {
|
|
|
6144
7379
|
].join("\n");
|
|
6145
7380
|
}
|
|
6146
7381
|
function packageFiles(root) {
|
|
6147
|
-
const canonicalRoot =
|
|
7382
|
+
const canonicalRoot = import_node_fs13.default.realpathSync(root);
|
|
6148
7383
|
const xcode = xcodeLayout(canonicalRoot);
|
|
6149
7384
|
return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
|
|
6150
7385
|
}
|
|
6151
7386
|
function sourceTreeFiles(dir, canonicalRoot) {
|
|
6152
7387
|
const found = [];
|
|
6153
7388
|
const walk2 = (dir2) => {
|
|
6154
|
-
for (const entry of
|
|
7389
|
+
for (const entry of import_node_fs13.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
6155
7390
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
6156
7391
|
continue;
|
|
6157
7392
|
const full = import_node_path14.default.join(dir2, entry.name);
|
|
6158
7393
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
6159
|
-
const real =
|
|
7394
|
+
const real = import_node_fs13.default.realpathSync(full);
|
|
6160
7395
|
const relative = import_node_path14.default.relative(canonicalRoot, real);
|
|
6161
7396
|
if (relative.startsWith(`..${import_node_path14.default.sep}`) || relative === ".." || import_node_path14.default.isAbsolute(relative)) {
|
|
6162
7397
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
6163
7398
|
}
|
|
6164
7399
|
if (entry.isDirectory()) {
|
|
6165
|
-
if (
|
|
7400
|
+
if (import_node_fs13.default.existsSync(import_node_path14.default.join(full, "Package.swift"))) continue;
|
|
6166
7401
|
walk2(full);
|
|
6167
7402
|
} else if (entry.isFile()) {
|
|
6168
7403
|
found.push(full);
|
|
@@ -6170,18 +7405,18 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
6170
7405
|
}
|
|
6171
7406
|
}
|
|
6172
7407
|
};
|
|
6173
|
-
if (
|
|
7408
|
+
if (import_node_fs13.default.existsSync(dir)) walk2(import_node_fs13.default.realpathSync(dir));
|
|
6174
7409
|
return found;
|
|
6175
7410
|
}
|
|
6176
7411
|
function readPackageFile(root, file, maxBytes) {
|
|
6177
|
-
const canonicalRoot =
|
|
6178
|
-
const relative = import_node_path14.default.relative(canonicalRoot,
|
|
7412
|
+
const canonicalRoot = import_node_fs13.default.realpathSync(root);
|
|
7413
|
+
const relative = import_node_path14.default.relative(canonicalRoot, import_node_fs13.default.realpathSync(file));
|
|
6179
7414
|
if (relative === ".." || relative.startsWith(`..${import_node_path14.default.sep}`) || import_node_path14.default.isAbsolute(relative)) {
|
|
6180
7415
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
6181
7416
|
}
|
|
6182
7417
|
let ancestor = import_node_path14.default.resolve(file);
|
|
6183
7418
|
while (ancestor !== canonicalRoot) {
|
|
6184
|
-
if (
|
|
7419
|
+
if (import_node_fs13.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
6185
7420
|
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
6186
7421
|
}
|
|
6187
7422
|
const parent = import_node_path14.default.dirname(ancestor);
|
|
@@ -6189,10 +7424,10 @@ function readPackageFile(root, file, maxBytes) {
|
|
|
6189
7424
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
6190
7425
|
ancestor = parent;
|
|
6191
7426
|
}
|
|
6192
|
-
const expected =
|
|
6193
|
-
const fd =
|
|
7427
|
+
const expected = import_node_fs13.default.statSync(file);
|
|
7428
|
+
const fd = import_node_fs13.default.openSync(file, import_node_fs13.default.constants.O_RDONLY | import_node_fs13.default.constants.O_NOFOLLOW);
|
|
6194
7429
|
try {
|
|
6195
|
-
const stat =
|
|
7430
|
+
const stat = import_node_fs13.default.fstatSync(fd);
|
|
6196
7431
|
if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
|
|
6197
7432
|
throw new Error(`swift input changed while opening: ${file}`);
|
|
6198
7433
|
}
|
|
@@ -6202,16 +7437,16 @@ function readPackageFile(root, file, maxBytes) {
|
|
|
6202
7437
|
const bytes = Buffer.alloc(stat.size + 1);
|
|
6203
7438
|
let offset = 0;
|
|
6204
7439
|
while (offset < bytes.length) {
|
|
6205
|
-
const count =
|
|
7440
|
+
const count = import_node_fs13.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
6206
7441
|
if (count === 0) break;
|
|
6207
7442
|
offset += count;
|
|
6208
7443
|
}
|
|
6209
|
-
if (offset !== stat.size ||
|
|
7444
|
+
if (offset !== stat.size || import_node_fs13.default.fstatSync(fd).size !== stat.size) {
|
|
6210
7445
|
throw new Error(`swift input changed while reading: ${file}`);
|
|
6211
7446
|
}
|
|
6212
7447
|
return bytes.subarray(0, offset);
|
|
6213
7448
|
} finally {
|
|
6214
|
-
|
|
7449
|
+
import_node_fs13.default.closeSync(fd);
|
|
6215
7450
|
}
|
|
6216
7451
|
}
|
|
6217
7452
|
function sourceFiles(root) {
|
|
@@ -6272,18 +7507,18 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
6272
7507
|
const watched = [];
|
|
6273
7508
|
const registered = /* @__PURE__ */ new Map();
|
|
6274
7509
|
let imageBytes = 0;
|
|
6275
|
-
for (const { name, file, scale } of found) {
|
|
7510
|
+
for (const { name: name2, file, scale } of found) {
|
|
6276
7511
|
const disk = byRelative.get(file);
|
|
6277
7512
|
if (!disk) continue;
|
|
6278
|
-
if (Object.keys(images).length >= limits.images || imageBytes +
|
|
7513
|
+
if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs13.default.statSync(disk).size > limits.imageTotalBytes) {
|
|
6279
7514
|
throw new Error("swift image pack exceeds the compile service caps");
|
|
6280
7515
|
}
|
|
6281
7516
|
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
6282
7517
|
imageBytes += bytes.length;
|
|
6283
7518
|
const hash = (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
|
|
6284
7519
|
const ext = import_node_path14.default.posix.extname(file).toLowerCase();
|
|
6285
|
-
table[
|
|
6286
|
-
images[
|
|
7520
|
+
table[name2] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
7521
|
+
images[name2] = {
|
|
6287
7522
|
file: import_node_path14.default.posix.basename(file),
|
|
6288
7523
|
data: bytes.toString("base64")
|
|
6289
7524
|
};
|
|
@@ -6308,7 +7543,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
6308
7543
|
return { table, images, colors, symbols, watched };
|
|
6309
7544
|
}
|
|
6310
7545
|
function buildSwiftBundleFiles(packagePath, hosted) {
|
|
6311
|
-
packagePath =
|
|
7546
|
+
packagePath = import_node_fs13.default.realpathSync(packagePath);
|
|
6312
7547
|
const limits = inputLimits(hosted);
|
|
6313
7548
|
const relative = resourceCandidateFiles(packagePath).map(
|
|
6314
7549
|
(file) => import_node_path14.default.relative(packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep)
|
|
@@ -6331,7 +7566,7 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
6331
7566
|
for (const { base, file } of enumerateBundleJson(relative)) {
|
|
6332
7567
|
watched.push(file);
|
|
6333
7568
|
const disk = import_node_path14.default.join(packagePath, ...file.split("/"));
|
|
6334
|
-
if (Object.keys(files2).length >= limits.resources || total +
|
|
7569
|
+
if (Object.keys(files2).length >= limits.resources || total + import_node_fs13.default.statSync(disk).size > limits.resourceTotalBytes) {
|
|
6335
7570
|
throw new Error(
|
|
6336
7571
|
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
6337
7572
|
);
|
|
@@ -6346,7 +7581,7 @@ function serveSwiftResource(project, key2) {
|
|
|
6346
7581
|
return project.resourceFiles.get(key2) ?? project.resourcesPrevious.get(key2) ?? null;
|
|
6347
7582
|
}
|
|
6348
7583
|
function linkedModuleRoots(packagePath) {
|
|
6349
|
-
packagePath =
|
|
7584
|
+
packagePath = import_node_fs13.default.realpathSync(packagePath);
|
|
6350
7585
|
let manifest;
|
|
6351
7586
|
try {
|
|
6352
7587
|
manifest = readPackageFile(
|
|
@@ -6361,7 +7596,7 @@ function linkedModuleRoots(packagePath) {
|
|
|
6361
7596
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
6362
7597
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
6363
7598
|
const root = import_node_path14.default.resolve(packagePath, match[1]);
|
|
6364
|
-
if (
|
|
7599
|
+
if (import_node_fs13.default.existsSync(import_node_path14.default.join(root, "Package.swift"))) roots.add(root);
|
|
6365
7600
|
}
|
|
6366
7601
|
return [...roots].sort();
|
|
6367
7602
|
}
|
|
@@ -6371,17 +7606,17 @@ function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
|
6371
7606
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
6372
7607
|
for (const file of [...projectInputs].sort()) {
|
|
6373
7608
|
hash.update(import_node_path14.default.relative(packagePath, file));
|
|
6374
|
-
const stat =
|
|
7609
|
+
const stat = import_node_fs13.default.statSync(file);
|
|
6375
7610
|
hash.update(`${stat.mtimeMs}/${stat.ctimeMs}/${stat.size}`);
|
|
6376
7611
|
}
|
|
6377
7612
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
6378
|
-
(root) =>
|
|
7613
|
+
(root) => import_node_fs13.default.existsSync(import_node_path14.default.join(root, "toolchain.json"))
|
|
6379
7614
|
);
|
|
6380
7615
|
if (moduleRoot) {
|
|
6381
7616
|
hash.update(moduleRoot);
|
|
6382
7617
|
for (const relative of swiftModuleInputFiles(moduleRoot)) {
|
|
6383
7618
|
hash.update(relative);
|
|
6384
|
-
hash.update(String(
|
|
7619
|
+
hash.update(String(import_node_fs13.default.statSync(import_node_path14.default.join(moduleRoot, relative)).mtimeMs));
|
|
6385
7620
|
}
|
|
6386
7621
|
}
|
|
6387
7622
|
return hash.digest("hex").slice(0, 16);
|
|
@@ -6468,7 +7703,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
6468
7703
|
package: content
|
|
6469
7704
|
};
|
|
6470
7705
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
6471
|
-
(root) =>
|
|
7706
|
+
(root) => import_node_fs13.default.existsSync(import_node_path14.default.join(root, "toolchain.json"))
|
|
6472
7707
|
) ?? await swiftDistributionRoot();
|
|
6473
7708
|
if (!moduleRoot)
|
|
6474
7709
|
return {
|
|
@@ -6569,17 +7804,17 @@ async function missingModulesMessage(packagePath, missing) {
|
|
|
6569
7804
|
const layout = xcodeLayout(packagePath);
|
|
6570
7805
|
const gaps = new Map([
|
|
6571
7806
|
...(layout?.app.binaryFrameworks ?? []).map(
|
|
6572
|
-
(
|
|
7807
|
+
(name2) => [name2, { source: "the project", reason: "a vendored binary framework" }]
|
|
6573
7808
|
),
|
|
6574
7809
|
...[...missing.keys()].flatMap(
|
|
6575
|
-
(
|
|
7810
|
+
(name2) => UNPROVIDED_PLATFORM_MODULES[name2] ? [
|
|
6576
7811
|
[
|
|
6577
|
-
|
|
6578
|
-
{ source: "the iOS SDK", reason: UNPROVIDED_PLATFORM_MODULES[
|
|
7812
|
+
name2,
|
|
7813
|
+
{ source: "the iOS SDK", reason: UNPROVIDED_PLATFORM_MODULES[name2] }
|
|
6579
7814
|
]
|
|
6580
|
-
] : IOS_SDK_FRAMEWORKS.has(
|
|
7815
|
+
] : IOS_SDK_FRAMEWORKS.has(name2) ? [
|
|
6581
7816
|
[
|
|
6582
|
-
|
|
7817
|
+
name2,
|
|
6583
7818
|
{ source: "the iOS SDK", reason: "a framework Peach does not provide" }
|
|
6584
7819
|
]
|
|
6585
7820
|
] : []
|
|
@@ -6589,27 +7824,27 @@ async function missingModulesMessage(packagePath, missing) {
|
|
|
6589
7824
|
]);
|
|
6590
7825
|
const packaged = new Set(
|
|
6591
7826
|
[...missing.keys()].filter(
|
|
6592
|
-
(
|
|
7827
|
+
(name2) => !UNPROVIDED_PLATFORM_MODULES[name2] && !IOS_SDK_FRAMEWORKS.has(name2)
|
|
6593
7828
|
)
|
|
6594
7829
|
);
|
|
6595
7830
|
if (packaged.size > 0)
|
|
6596
7831
|
await Promise.all(
|
|
6597
7832
|
(layout?.packages.binaries ?? []).map(async (binary) => {
|
|
6598
7833
|
const modules = await swiftBinaryModules(binary).catch(() => []);
|
|
6599
|
-
for (const
|
|
6600
|
-
if (packaged.has(
|
|
6601
|
-
gaps.set(
|
|
7834
|
+
for (const name2 of modules)
|
|
7835
|
+
if (packaged.has(name2))
|
|
7836
|
+
gaps.set(name2, {
|
|
6602
7837
|
source: binary.source,
|
|
6603
7838
|
reason: layout?.packages.modules.get(binary.target)?.reason ?? `${binary.target} is a binary framework`
|
|
6604
7839
|
});
|
|
6605
7840
|
})
|
|
6606
7841
|
);
|
|
6607
|
-
const width = Math.max(...[...missing.keys()].map((
|
|
7842
|
+
const width = Math.max(...[...missing.keys()].map((name2) => name2.length));
|
|
6608
7843
|
return [
|
|
6609
7844
|
`Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
|
|
6610
|
-
...[...missing].map(([
|
|
6611
|
-
const gap = gaps.get(
|
|
6612
|
-
return ` ${
|
|
7845
|
+
...[...missing].map(([name2, files2]) => {
|
|
7846
|
+
const gap = gaps.get(name2);
|
|
7847
|
+
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})` : ""}`;
|
|
6613
7848
|
})
|
|
6614
7849
|
].join("\n");
|
|
6615
7850
|
}
|
|
@@ -6728,7 +7963,7 @@ function artifactFor(project, entry, moduleRoot) {
|
|
|
6728
7963
|
return fresh;
|
|
6729
7964
|
}
|
|
6730
7965
|
function swiftPackageWatchFiles(packagePath, moduleRoot) {
|
|
6731
|
-
packagePath =
|
|
7966
|
+
packagePath = import_node_fs13.default.realpathSync(packagePath);
|
|
6732
7967
|
return [
|
|
6733
7968
|
...xcodeProjects.has(packagePath) ? [] : [import_node_path14.default.join(packagePath, "Package.swift")],
|
|
6734
7969
|
...sourceFiles(packagePath),
|
|
@@ -6738,7 +7973,7 @@ function swiftPackageWatchFiles(packagePath, moduleRoot) {
|
|
|
6738
7973
|
];
|
|
6739
7974
|
}
|
|
6740
7975
|
async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin, hosted) {
|
|
6741
|
-
packagePath =
|
|
7976
|
+
packagePath = import_node_fs13.default.realpathSync(packagePath);
|
|
6742
7977
|
const mains = sourceFiles(packagePath).filter(
|
|
6743
7978
|
(file) => swiftApplicationEntry(
|
|
6744
7979
|
file,
|
|
@@ -6765,8 +8000,8 @@ async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin
|
|
|
6765
8000
|
icuUrl: icuUrl(origin, artifact),
|
|
6766
8001
|
rootId: `${packageName}/${entry}`,
|
|
6767
8002
|
resources: Object.fromEntries(
|
|
6768
|
-
Object.entries(resources.table).map(([
|
|
6769
|
-
|
|
8003
|
+
Object.entries(resources.table).map(([name2, image]) => [
|
|
8004
|
+
name2,
|
|
6770
8005
|
{ ...image, uri: `${origin}${image.uri}` }
|
|
6771
8006
|
])
|
|
6772
8007
|
),
|
|
@@ -6827,6 +8062,166 @@ function serveSwiftPackageAsset(pathname, res) {
|
|
|
6827
8062
|
return true;
|
|
6828
8063
|
}
|
|
6829
8064
|
|
|
8065
|
+
// src/one-widget-package.ts
|
|
8066
|
+
var import_node_child_process8 = require("node:child_process");
|
|
8067
|
+
var import_node_crypto8 = require("node:crypto");
|
|
8068
|
+
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
8069
|
+
var import_node_module = require("node:module");
|
|
8070
|
+
var import_node_os9 = __toESM(require("node:os"), 1);
|
|
8071
|
+
var import_node_path15 = __toESM(require("node:path"), 1);
|
|
8072
|
+
var import_node_util3 = require("node:util");
|
|
8073
|
+
|
|
8074
|
+
// cli/internal-child.ts
|
|
8075
|
+
var RNX_FORKED_SCRIPT_ENV = "PEACH_RUNS_FORKED_SCRIPTS";
|
|
8076
|
+
|
|
8077
|
+
// src/one-widget-package.ts
|
|
8078
|
+
var run3 = (0, import_node_util3.promisify)(import_node_child_process8.execFile);
|
|
8079
|
+
var ONE_WIDGET_PACKAGE = "OneWidgets";
|
|
8080
|
+
var configs = /* @__PURE__ */ new Map();
|
|
8081
|
+
var reads = /* @__PURE__ */ new Map();
|
|
8082
|
+
var CONFIG_CHILD = `
|
|
8083
|
+
import fs from 'node:fs';
|
|
8084
|
+
import { loadUserOneOptions } from 'one/vite';
|
|
8085
|
+
const { config, oneOptions } = await loadUserOneOptions('serve', true);
|
|
8086
|
+
const app = oneOptions.native?.app;
|
|
8087
|
+
const widgets = app?.ios?.widgets;
|
|
8088
|
+
fs.writeFileSync(process.argv[2], JSON.stringify({
|
|
8089
|
+
widget: widgets ? { appName: app.name, bundleId: app.ios.bundleId,
|
|
8090
|
+
suite: widgets.appGroup, kind: widgets.kind, displayName: widgets.displayName,
|
|
8091
|
+
description: widgets.description } : null,
|
|
8092
|
+
watched: [config.path, ...config.dependencies]
|
|
8093
|
+
}));
|
|
8094
|
+
`;
|
|
8095
|
+
function configStamp(files2) {
|
|
8096
|
+
return JSON.stringify(
|
|
8097
|
+
files2.map((file) => {
|
|
8098
|
+
if (!import_node_fs14.default.existsSync(file)) return [file, null];
|
|
8099
|
+
const stat = import_node_fs14.default.statSync(file);
|
|
8100
|
+
return [file, stat.mtimeMs, stat.ctimeMs, stat.size];
|
|
8101
|
+
})
|
|
8102
|
+
);
|
|
8103
|
+
}
|
|
8104
|
+
async function readConfig(root) {
|
|
8105
|
+
const cached2 = configs.get(root);
|
|
8106
|
+
if (cached2 && cached2.stamp === configStamp(cached2.watched)) return cached2;
|
|
8107
|
+
const reading = reads.get(root);
|
|
8108
|
+
if (reading) return reading;
|
|
8109
|
+
const promise = (async () => {
|
|
8110
|
+
(0, import_node_module.createRequire)(import_node_path15.default.join(root, "package.json")).resolve("one/vite");
|
|
8111
|
+
const cache = import_node_path15.default.join(root, "node_modules/.cache/peach-widget-config");
|
|
8112
|
+
import_node_fs14.default.mkdirSync(cache, { recursive: true });
|
|
8113
|
+
const directory = import_node_fs14.default.mkdtempSync(import_node_path15.default.join(cache, "read-"));
|
|
8114
|
+
const script = import_node_path15.default.join(directory, "read.mjs");
|
|
8115
|
+
const result = import_node_path15.default.join(directory, "result.json");
|
|
8116
|
+
import_node_fs14.default.writeFileSync(script, CONFIG_CHILD);
|
|
8117
|
+
try {
|
|
8118
|
+
await run3(process.execPath, [script, result], {
|
|
8119
|
+
cwd: root,
|
|
8120
|
+
env: { ...process.env, [RNX_FORKED_SCRIPT_ENV]: "1" },
|
|
8121
|
+
timeout: 3e4,
|
|
8122
|
+
maxBuffer: 1024 * 1024
|
|
8123
|
+
});
|
|
8124
|
+
const value = JSON.parse(import_node_fs14.default.readFileSync(result, "utf8"));
|
|
8125
|
+
if (!isRecord(value) || !Array.isArray(value.watched) || !value.watched.every((file) => typeof file === "string"))
|
|
8126
|
+
throw new Error("One config loader returned invalid dependencies");
|
|
8127
|
+
let widget = null;
|
|
8128
|
+
if (value.widget !== null) {
|
|
8129
|
+
const entry = value.widget;
|
|
8130
|
+
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)
|
|
8131
|
+
throw new Error("One config loader returned invalid native.app.ios.widgets");
|
|
8132
|
+
widget = {
|
|
8133
|
+
appName: entry.appName,
|
|
8134
|
+
bundleId: entry.bundleId,
|
|
8135
|
+
suite: entry.suite,
|
|
8136
|
+
kind: entry.kind,
|
|
8137
|
+
displayName: entry.displayName,
|
|
8138
|
+
description: entry.description
|
|
8139
|
+
};
|
|
8140
|
+
}
|
|
8141
|
+
const watched = [
|
|
8142
|
+
.../* @__PURE__ */ new Set([
|
|
8143
|
+
import_node_path15.default.join(root, "package.json"),
|
|
8144
|
+
...value.watched.map((file) => import_node_path15.default.resolve(root, file))
|
|
8145
|
+
])
|
|
8146
|
+
];
|
|
8147
|
+
const loaded2 = { widget, watched, stamp: configStamp(watched) };
|
|
8148
|
+
configs.set(root, loaded2);
|
|
8149
|
+
return loaded2;
|
|
8150
|
+
} finally {
|
|
8151
|
+
import_node_fs14.default.rmSync(directory, { recursive: true, force: true });
|
|
8152
|
+
}
|
|
8153
|
+
})();
|
|
8154
|
+
reads.set(root, promise);
|
|
8155
|
+
try {
|
|
8156
|
+
return await promise;
|
|
8157
|
+
} finally {
|
|
8158
|
+
reads.delete(root);
|
|
8159
|
+
}
|
|
8160
|
+
}
|
|
8161
|
+
async function oneWidgetPackage(appRoot) {
|
|
8162
|
+
const root = import_node_fs14.default.realpathSync(appRoot);
|
|
8163
|
+
const config = await readConfig(root);
|
|
8164
|
+
if (!config.widget) return null;
|
|
8165
|
+
const widget = config.widget;
|
|
8166
|
+
const sourceFiles2 = {
|
|
8167
|
+
"OneWidget.swift": import_node_path15.default.join(root, "ios/OneWidgets/OneWidget.swift"),
|
|
8168
|
+
"OneWidgetContract.swift": import_node_path15.default.join(
|
|
8169
|
+
root,
|
|
8170
|
+
"ios",
|
|
8171
|
+
widget.appName,
|
|
8172
|
+
"OneWidgetContract.swift"
|
|
8173
|
+
)
|
|
8174
|
+
};
|
|
8175
|
+
const files2 = /* @__PURE__ */ new Map();
|
|
8176
|
+
const sources = {};
|
|
8177
|
+
for (const [name2, file] of Object.entries(sourceFiles2)) {
|
|
8178
|
+
if (!import_node_fs14.default.existsSync(file))
|
|
8179
|
+
throw new Error(`missing One widget prebuild source ${file}; run one prebuild`);
|
|
8180
|
+
const bytes = readPackageFile(root, file, MAX_SWIFT_COMPILE_SOURCE_BYTES);
|
|
8181
|
+
const text3 = bytes.toString("utf8");
|
|
8182
|
+
if (!Buffer.from(text3).equals(bytes))
|
|
8183
|
+
throw new Error(`One widget prebuild source is not UTF-8: ${file}`);
|
|
8184
|
+
files2.set(name2, text3);
|
|
8185
|
+
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");
|
|
8186
|
+
}
|
|
8187
|
+
const contract = files2.get("OneWidgetContract.swift") ?? "";
|
|
8188
|
+
const source = files2.get("OneWidget.swift") ?? "";
|
|
8189
|
+
if (!contract.includes(`static let appGroup = ${JSON.stringify(widget.suite)}`) || !contract.includes(`static let kind = ${JSON.stringify(widget.kind)}`) || !source.includes(
|
|
8190
|
+
`.configurationDisplayName(${JSON.stringify(widget.displayName)})`
|
|
8191
|
+
) || !source.includes(`.description(${JSON.stringify(widget.description)})`))
|
|
8192
|
+
throw new Error(
|
|
8193
|
+
"One widget prebuild sources disagree with native.app.ios.widgets; run one prebuild"
|
|
8194
|
+
);
|
|
8195
|
+
files2.set(
|
|
8196
|
+
"Package.swift",
|
|
8197
|
+
[
|
|
8198
|
+
"// swift-tools-version: 6.2",
|
|
8199
|
+
`// One widget config ${JSON.stringify(widget)}`,
|
|
8200
|
+
"import PackageDescription",
|
|
8201
|
+
'let package = Package(name: "OneWidgets", targets: [',
|
|
8202
|
+
' .executableTarget(name: "OneWidgets", path: ".", swiftSettings: [.swiftLanguageMode(.v5)]),',
|
|
8203
|
+
"])",
|
|
8204
|
+
""
|
|
8205
|
+
].join("\n")
|
|
8206
|
+
);
|
|
8207
|
+
const packagePath = import_node_path15.default.join(
|
|
8208
|
+
import_node_os9.default.tmpdir(),
|
|
8209
|
+
"peach-one-widgets",
|
|
8210
|
+
(0, import_node_crypto8.createHash)("sha256").update(root).digest("hex"),
|
|
8211
|
+
ONE_WIDGET_PACKAGE
|
|
8212
|
+
);
|
|
8213
|
+
import_node_fs14.default.mkdirSync(packagePath, { recursive: true });
|
|
8214
|
+
syncSwiftTree(
|
|
8215
|
+
packagePath,
|
|
8216
|
+
new Map([...files2].map(([file, text3]) => [import_node_path15.default.join(packagePath, file), text3]))
|
|
8217
|
+
);
|
|
8218
|
+
return {
|
|
8219
|
+
packagePath,
|
|
8220
|
+
watched: [...config.watched, ...Object.values(sourceFiles2)],
|
|
8221
|
+
widget: { ...widget, sources }
|
|
8222
|
+
};
|
|
8223
|
+
}
|
|
8224
|
+
|
|
6830
8225
|
// src/vite-plugin-swift.ts
|
|
6831
8226
|
var ARTIFACT_PATH2 = "/__peach/swift/";
|
|
6832
8227
|
var VIRTUAL_PREFIX = "\0peach-swift:";
|
|
@@ -6841,12 +8236,12 @@ function artifactUrl(project, artifact) {
|
|
|
6841
8236
|
return `${serverOrigin()}${ARTIFACT_PATH2}${artifact.hash}.wasm`;
|
|
6842
8237
|
}
|
|
6843
8238
|
function packageFor(file) {
|
|
6844
|
-
let dir =
|
|
8239
|
+
let dir = import_node_path16.default.dirname(file);
|
|
6845
8240
|
const stop = devServer?.config.root;
|
|
6846
8241
|
for (; ; ) {
|
|
6847
|
-
if (
|
|
6848
|
-
if (stop !== void 0 && dir === stop ||
|
|
6849
|
-
dir =
|
|
8242
|
+
if (import_node_fs15.default.existsSync(import_node_path16.default.join(dir, "Package.swift"))) return dir;
|
|
8243
|
+
if (stop !== void 0 && dir === stop || import_node_path16.default.dirname(dir) === dir) break;
|
|
8244
|
+
dir = import_node_path16.default.dirname(dir);
|
|
6850
8245
|
}
|
|
6851
8246
|
throw new Error(
|
|
6852
8247
|
`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`
|
|
@@ -6867,9 +8262,9 @@ function swiftPlugin(options = {}) {
|
|
|
6867
8262
|
if (!resolved) throw new Error(`cannot resolve swift source ${source}`);
|
|
6868
8263
|
let id = resolved.id;
|
|
6869
8264
|
if (importer && (source.startsWith("./") || source.startsWith("../"))) {
|
|
6870
|
-
const raw2 =
|
|
8265
|
+
const raw2 = import_node_path16.default.resolve(import_node_path16.default.dirname(importer.split("?")[0] ?? importer), source);
|
|
6871
8266
|
try {
|
|
6872
|
-
if (
|
|
8267
|
+
if (import_node_fs15.default.realpathSync(raw2) === import_node_fs15.default.realpathSync(resolved.id)) id = raw2;
|
|
6873
8268
|
} catch {
|
|
6874
8269
|
}
|
|
6875
8270
|
}
|
|
@@ -6878,22 +8273,22 @@ function swiftPlugin(options = {}) {
|
|
|
6878
8273
|
async load(id) {
|
|
6879
8274
|
if (!id.startsWith(VIRTUAL_PREFIX)) return null;
|
|
6880
8275
|
const file = id.slice(VIRTUAL_PREFIX.length);
|
|
6881
|
-
if (!
|
|
8276
|
+
if (!import_node_fs15.default.existsSync(file)) throw new Error(`swift source ${file} no longer exists`);
|
|
6882
8277
|
const packagePath = options.packagePath ?? packageFor(file);
|
|
6883
8278
|
const project = projectFor(packagePath);
|
|
6884
|
-
const entry =
|
|
8279
|
+
const entry = import_node_path16.default.relative(packagePath, file).split(import_node_path16.default.sep).join(import_node_path16.default.posix.sep);
|
|
6885
8280
|
for (const source of [
|
|
6886
8281
|
...sourceFiles(packagePath),
|
|
6887
8282
|
...nativeSourceFiles(packagePath)
|
|
6888
8283
|
])
|
|
6889
8284
|
this.addWatchFile(source);
|
|
6890
|
-
this.addWatchFile(
|
|
8285
|
+
this.addWatchFile(import_node_path16.default.join(packagePath, "Package.swift"));
|
|
6891
8286
|
const moduleRoot = linkedModuleRoots(packagePath).find(
|
|
6892
|
-
(root) =>
|
|
8287
|
+
(root) => import_node_fs15.default.existsSync(import_node_path16.default.join(root, "toolchain.json"))
|
|
6893
8288
|
);
|
|
6894
8289
|
if (moduleRoot)
|
|
6895
8290
|
for (const relative of swiftModuleInputFiles(moduleRoot))
|
|
6896
|
-
this.addWatchFile(
|
|
8291
|
+
this.addWatchFile(import_node_path16.default.join(moduleRoot, relative));
|
|
6897
8292
|
let artifact;
|
|
6898
8293
|
try {
|
|
6899
8294
|
artifact = await artifactFor(project, entry);
|
|
@@ -6903,8 +8298,8 @@ function swiftPlugin(options = {}) {
|
|
|
6903
8298
|
artifact = project.artifact;
|
|
6904
8299
|
}
|
|
6905
8300
|
const resources = Object.fromEntries(
|
|
6906
|
-
Object.entries(artifact.package.resources.table).map(([
|
|
6907
|
-
|
|
8301
|
+
Object.entries(artifact.package.resources.table).map(([name2, image]) => [
|
|
8302
|
+
name2,
|
|
6908
8303
|
{ ...image, uri: `${serverOrigin()}${image.uri}` }
|
|
6909
8304
|
])
|
|
6910
8305
|
);
|
|
@@ -6912,7 +8307,7 @@ function swiftPlugin(options = {}) {
|
|
|
6912
8307
|
...artifact.package.resources.watched,
|
|
6913
8308
|
...artifact.package.bundleFiles.watched
|
|
6914
8309
|
])
|
|
6915
|
-
this.addWatchFile(
|
|
8310
|
+
this.addWatchFile(import_node_path16.default.join(packagePath, ...watched.split(import_node_path16.default.posix.sep)));
|
|
6916
8311
|
const colors = artifact.package.resources.colors;
|
|
6917
8312
|
const symbols = artifact.package.resources.symbols;
|
|
6918
8313
|
const bundleFiles = artifact.package.bundleFiles.files;
|
|
@@ -6939,11 +8334,13 @@ function swiftPlugin(options = {}) {
|
|
|
6939
8334
|
}
|
|
6940
8335
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6941
8336
|
0 && (module.exports = {
|
|
8337
|
+
ONE_WIDGET_PACKAGE,
|
|
6942
8338
|
buildSwiftBundleFiles,
|
|
6943
8339
|
buildSwiftResourceTable,
|
|
6944
8340
|
compileInput,
|
|
6945
8341
|
entryRootId,
|
|
6946
8342
|
linkedModuleRoots,
|
|
8343
|
+
oneWidgetPackage,
|
|
6947
8344
|
serveSwiftPackageAsset,
|
|
6948
8345
|
serveSwiftResource,
|
|
6949
8346
|
sourceStamp,
|