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