@opentui/core 0.2.1 → 0.2.3
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/NativeSpanFeed.d.ts +2 -2
- package/buffer.d.ts +3 -3
- package/edit-buffer.d.ts +1 -1
- package/editor-view.d.ts +1 -1
- package/{index-hxymw48q.js → index-4w8751xf.js} +14 -16
- package/{index-hxymw48q.js.map → index-4w8751xf.js.map} +5 -5
- package/{index-htg1x5tj.js → index-8csdw3z7.js} +3 -3
- package/index-gdtdtsgp.js +44 -0
- package/index-gdtdtsgp.js.map +10 -0
- package/{index-b9g14b8c.js → index-hmk8xzt3.js} +1320 -1023
- package/{index-b9g14b8c.js.map → index-hmk8xzt3.js.map} +27 -20
- package/index.js +2 -2
- package/lib/clipboard.d.ts +1 -1
- package/lib/terminal-palette.d.ts +12 -5
- package/package.json +13 -8
- package/platform/ffi.d.ts +5 -5
- package/renderer.d.ts +10 -4
- package/runtime-plugin-support-configure.d.ts +4 -0
- package/runtime-plugin-support-configure.js +18 -0
- package/runtime-plugin-support-configure.js.map +9 -0
- package/runtime-plugin-support.d.ts +3 -3
- package/runtime-plugin-support.js +7 -16
- package/runtime-plugin-support.js.map +3 -3
- package/runtime-plugin.js +3 -3
- package/syntax-style.d.ts +1 -1
- package/testing.js +1 -1
- package/text-buffer-view.d.ts +1 -1
- package/text-buffer.d.ts +1 -1
- package/zig-structs.d.ts +2 -2
- package/zig.d.ts +1 -1
- /package/{index-htg1x5tj.js.map → index-8csdw3z7.js.map} +0 -0
|
@@ -9752,6 +9752,128 @@ function getTreeSitterClient() {
|
|
|
9752
9752
|
});
|
|
9753
9753
|
}
|
|
9754
9754
|
|
|
9755
|
+
// src/platform/runtime.ts
|
|
9756
|
+
import { mkdir as mkdir3, writeFile as writeFileNode } from "fs/promises";
|
|
9757
|
+
import { dirname as dirname4 } from "path";
|
|
9758
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
9759
|
+
|
|
9760
|
+
// ../../node_modules/.bun/ansi-regex@6.2.2/node_modules/ansi-regex/index.js
|
|
9761
|
+
function ansiRegex({ onlyFirst = false } = {}) {
|
|
9762
|
+
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
9763
|
+
const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
|
|
9764
|
+
const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
|
|
9765
|
+
const pattern = `${osc}|${csi}`;
|
|
9766
|
+
return new RegExp(pattern, onlyFirst ? undefined : "g");
|
|
9767
|
+
}
|
|
9768
|
+
|
|
9769
|
+
// ../../node_modules/.bun/strip-ansi@7.1.2/node_modules/strip-ansi/index.js
|
|
9770
|
+
var regex = ansiRegex();
|
|
9771
|
+
function stripAnsi(string) {
|
|
9772
|
+
if (typeof string !== "string") {
|
|
9773
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
9774
|
+
}
|
|
9775
|
+
return string.replace(regex, "");
|
|
9776
|
+
}
|
|
9777
|
+
|
|
9778
|
+
// ../../node_modules/.bun/get-east-asian-width@1.4.0/node_modules/get-east-asian-width/lookup.js
|
|
9779
|
+
function isAmbiguous(x) {
|
|
9780
|
+
return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
|
|
9781
|
+
}
|
|
9782
|
+
function isFullWidth(x) {
|
|
9783
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
9784
|
+
}
|
|
9785
|
+
function isWide(x) {
|
|
9786
|
+
return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x >= 94192 && x <= 94198 || x >= 94208 && x <= 101589 || x >= 101631 && x <= 101662 || x >= 101760 && x <= 101874 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128728 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129674 || x >= 129678 && x <= 129734 || x === 129736 || x >= 129741 && x <= 129756 || x >= 129759 && x <= 129770 || x >= 129775 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
9787
|
+
}
|
|
9788
|
+
|
|
9789
|
+
// ../../node_modules/.bun/get-east-asian-width@1.4.0/node_modules/get-east-asian-width/index.js
|
|
9790
|
+
function validate(codePoint) {
|
|
9791
|
+
if (!Number.isSafeInteger(codePoint)) {
|
|
9792
|
+
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
9793
|
+
}
|
|
9794
|
+
}
|
|
9795
|
+
function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
|
|
9796
|
+
validate(codePoint);
|
|
9797
|
+
if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
|
|
9798
|
+
return 2;
|
|
9799
|
+
}
|
|
9800
|
+
return 1;
|
|
9801
|
+
}
|
|
9802
|
+
|
|
9803
|
+
// ../../node_modules/.bun/emoji-regex@10.6.0/node_modules/emoji-regex/index.mjs
|
|
9804
|
+
var emoji_regex_default = () => {
|
|
9805
|
+
return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
|
|
9806
|
+
};
|
|
9807
|
+
|
|
9808
|
+
// ../../node_modules/.bun/string-width@7.2.0/node_modules/string-width/index.js
|
|
9809
|
+
var segmenter = new Intl.Segmenter;
|
|
9810
|
+
var defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
|
|
9811
|
+
function stringWidth(string, options = {}) {
|
|
9812
|
+
if (typeof string !== "string" || string.length === 0) {
|
|
9813
|
+
return 0;
|
|
9814
|
+
}
|
|
9815
|
+
const {
|
|
9816
|
+
ambiguousIsNarrow = true,
|
|
9817
|
+
countAnsiEscapeCodes = false
|
|
9818
|
+
} = options;
|
|
9819
|
+
if (!countAnsiEscapeCodes) {
|
|
9820
|
+
string = stripAnsi(string);
|
|
9821
|
+
}
|
|
9822
|
+
if (string.length === 0) {
|
|
9823
|
+
return 0;
|
|
9824
|
+
}
|
|
9825
|
+
let width = 0;
|
|
9826
|
+
const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
|
|
9827
|
+
for (const { segment: character } of segmenter.segment(string)) {
|
|
9828
|
+
const codePoint = character.codePointAt(0);
|
|
9829
|
+
if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
|
|
9830
|
+
continue;
|
|
9831
|
+
}
|
|
9832
|
+
if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) {
|
|
9833
|
+
continue;
|
|
9834
|
+
}
|
|
9835
|
+
if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) {
|
|
9836
|
+
continue;
|
|
9837
|
+
}
|
|
9838
|
+
if (codePoint >= 55296 && codePoint <= 57343) {
|
|
9839
|
+
continue;
|
|
9840
|
+
}
|
|
9841
|
+
if (codePoint >= 65024 && codePoint <= 65039) {
|
|
9842
|
+
continue;
|
|
9843
|
+
}
|
|
9844
|
+
if (defaultIgnorableCodePointRegex.test(character)) {
|
|
9845
|
+
continue;
|
|
9846
|
+
}
|
|
9847
|
+
if (emoji_regex_default().test(character)) {
|
|
9848
|
+
width += 2;
|
|
9849
|
+
continue;
|
|
9850
|
+
}
|
|
9851
|
+
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
|
|
9852
|
+
}
|
|
9853
|
+
return width;
|
|
9854
|
+
}
|
|
9855
|
+
|
|
9856
|
+
// src/platform/runtime.ts
|
|
9857
|
+
var TEXT_ENCODER = new TextEncoder;
|
|
9858
|
+
var bun = globalThis.Bun;
|
|
9859
|
+
var sleep = bun?.sleep ?? standardSleep;
|
|
9860
|
+
var stringWidth2 = bun?.stringWidth ?? stringWidth;
|
|
9861
|
+
var stripANSI = bun?.stripANSI ?? stripAnsi;
|
|
9862
|
+
var writeFile3 = bun?.write ?? writeFilePortable;
|
|
9863
|
+
function standardSleep(msOrDate) {
|
|
9864
|
+
const ms = msOrDate instanceof Date ? msOrDate.getTime() - Date.now() : msOrDate;
|
|
9865
|
+
return new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
9866
|
+
}
|
|
9867
|
+
async function writeFilePortable(destination, data, options) {
|
|
9868
|
+
const destinationPath = destination instanceof URL ? fileURLToPath2(destination) : destination;
|
|
9869
|
+
if (options?.createPath) {
|
|
9870
|
+
await mkdir3(dirname4(destinationPath), { recursive: true });
|
|
9871
|
+
}
|
|
9872
|
+
const bytes = typeof data === "string" ? TEXT_ENCODER.encode(data) : new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
9873
|
+
await writeFileNode(destinationPath, bytes, { mode: options?.mode });
|
|
9874
|
+
return bytes.byteLength;
|
|
9875
|
+
}
|
|
9876
|
+
|
|
9755
9877
|
// src/lib/extmarks-history.ts
|
|
9756
9878
|
class ExtmarksHistory {
|
|
9757
9879
|
undoStack = [];
|
|
@@ -10267,13 +10389,13 @@ class ExtmarksController {
|
|
|
10267
10389
|
j++;
|
|
10268
10390
|
}
|
|
10269
10391
|
const chunk = text.substring(i, j);
|
|
10270
|
-
const chunkWidth =
|
|
10392
|
+
const chunkWidth = stringWidth2(chunk);
|
|
10271
10393
|
if (displayWidthSoFar + chunkWidth < offset) {
|
|
10272
10394
|
displayWidthSoFar += chunkWidth;
|
|
10273
10395
|
i = j;
|
|
10274
10396
|
} else {
|
|
10275
10397
|
for (let k = i;k < j && displayWidthSoFar < offset; k++) {
|
|
10276
|
-
const charWidth =
|
|
10398
|
+
const charWidth = stringWidth2(text[k]);
|
|
10277
10399
|
displayWidthSoFar += charWidth;
|
|
10278
10400
|
}
|
|
10279
10401
|
break;
|
|
@@ -10462,6 +10584,12 @@ function createExtmarksController(editBuffer, editorView) {
|
|
|
10462
10584
|
|
|
10463
10585
|
// src/lib/terminal-palette.ts
|
|
10464
10586
|
var SYSTEM_CLOCK2 = new SystemClock;
|
|
10587
|
+
registerEnvVar({
|
|
10588
|
+
name: "OTUI_PALETTE_IDLE_TIMEOUT_MS",
|
|
10589
|
+
description: "Milliseconds of silence after palette queries before using fallback colors.",
|
|
10590
|
+
type: "number",
|
|
10591
|
+
default: 300
|
|
10592
|
+
});
|
|
10465
10593
|
var OSC4_RESPONSE = /\x1b]4;(\d+);(?:(?:rgb:)([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)|#([0-9a-fA-F]{6}))(?:\x07|\x1b\\)/g;
|
|
10466
10594
|
var OSC_SPECIAL_RESPONSE = /\x1b](\d+);(?:(?:rgb:)([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)|#([0-9a-fA-F]{6}))(?:\x07|\x1b\\)/g;
|
|
10467
10595
|
function scaleComponent(comp) {
|
|
@@ -10487,18 +10615,21 @@ class TerminalPalette {
|
|
|
10487
10615
|
writeFn;
|
|
10488
10616
|
activeQuerySessions = [];
|
|
10489
10617
|
inLegacyTmux;
|
|
10618
|
+
inTmux;
|
|
10490
10619
|
oscSource;
|
|
10491
10620
|
clock;
|
|
10492
|
-
constructor(
|
|
10621
|
+
constructor(options) {
|
|
10622
|
+
const { stdin, stdout, writeFn, isLegacyTmux, isTmux, oscSource, clock } = options;
|
|
10493
10623
|
this.stdin = stdin;
|
|
10494
10624
|
this.stdout = stdout;
|
|
10495
10625
|
this.writeFn = writeFn || ((data) => stdout.write(data));
|
|
10496
10626
|
this.inLegacyTmux = isLegacyTmux ?? false;
|
|
10627
|
+
this.inTmux = isTmux ?? this.inLegacyTmux;
|
|
10497
10628
|
this.oscSource = oscSource;
|
|
10498
10629
|
this.clock = clock ?? SYSTEM_CLOCK2;
|
|
10499
10630
|
}
|
|
10500
|
-
writeOsc(osc) {
|
|
10501
|
-
const data = this.inLegacyTmux ? wrapForTmux(osc) : osc;
|
|
10631
|
+
writeOsc(osc, wrapForLegacyTmux = false) {
|
|
10632
|
+
const data = wrapForLegacyTmux && this.inLegacyTmux ? wrapForTmux(osc) : osc;
|
|
10502
10633
|
return this.writeFn(data);
|
|
10503
10634
|
}
|
|
10504
10635
|
cleanup() {
|
|
@@ -10593,10 +10724,10 @@ class TerminalPalette {
|
|
|
10593
10724
|
finish(false);
|
|
10594
10725
|
}, timeoutMs);
|
|
10595
10726
|
session.subscribeInput(onData);
|
|
10596
|
-
this.writeOsc("\x1B]4;0;?\x07");
|
|
10727
|
+
this.writeOsc("\x1B]4;0;?\x07", true);
|
|
10597
10728
|
});
|
|
10598
10729
|
}
|
|
10599
|
-
async queryPalette(indices, timeoutMs = 1200) {
|
|
10730
|
+
async queryPalette(indices, timeoutMs = 1200, idleTimeoutMs = env.OTUI_PALETTE_IDLE_TIMEOUT_MS) {
|
|
10600
10731
|
const out = this.stdout;
|
|
10601
10732
|
const results = new Map;
|
|
10602
10733
|
indices.forEach((i) => results.set(i, null));
|
|
@@ -10631,14 +10762,15 @@ class TerminalPalette {
|
|
|
10631
10762
|
finish();
|
|
10632
10763
|
return;
|
|
10633
10764
|
}
|
|
10634
|
-
idleTimer = session.resetTimer(idleTimer, finish,
|
|
10765
|
+
idleTimer = session.resetTimer(idleTimer, finish, idleTimeoutMs);
|
|
10635
10766
|
};
|
|
10636
10767
|
session.setTimer(finish, timeoutMs);
|
|
10637
10768
|
session.subscribeInput(onData);
|
|
10638
|
-
this.writeOsc(indices.map((i) => `\x1B]4;${i};?\x07`).join(""));
|
|
10769
|
+
this.writeOsc(indices.map((i) => `\x1B]4;${i};?\x07`).join(""), true);
|
|
10770
|
+
idleTimer = session.resetTimer(idleTimer, finish, idleTimeoutMs);
|
|
10639
10771
|
});
|
|
10640
10772
|
}
|
|
10641
|
-
async querySpecialColors(timeoutMs = 1200) {
|
|
10773
|
+
async querySpecialColors(timeoutMs = 1200, idleTimeoutMs = env.OTUI_PALETTE_IDLE_TIMEOUT_MS) {
|
|
10642
10774
|
const out = this.stdout;
|
|
10643
10775
|
const results = {
|
|
10644
10776
|
10: null,
|
|
@@ -10651,6 +10783,7 @@ class TerminalPalette {
|
|
|
10651
10783
|
17: null,
|
|
10652
10784
|
19: null
|
|
10653
10785
|
};
|
|
10786
|
+
const queries = this.inTmux ? [10, 11, 12] : [10, 11, 12, 13, 14, 15, 16, 17, 19];
|
|
10654
10787
|
if (!out.isTTY || !this.stdin.isTTY) {
|
|
10655
10788
|
return results;
|
|
10656
10789
|
}
|
|
@@ -10680,28 +10813,18 @@ class TerminalPalette {
|
|
|
10680
10813
|
}
|
|
10681
10814
|
if (buffer.length > 8192)
|
|
10682
10815
|
buffer = buffer.slice(-4096);
|
|
10683
|
-
|
|
10684
|
-
if (done === Object.keys(results).length) {
|
|
10816
|
+
if (queries.every((idx) => results[idx] !== null)) {
|
|
10685
10817
|
finish();
|
|
10686
10818
|
return;
|
|
10687
10819
|
}
|
|
10688
10820
|
if (!updated)
|
|
10689
10821
|
return;
|
|
10690
|
-
idleTimer = session.resetTimer(idleTimer, finish,
|
|
10822
|
+
idleTimer = session.resetTimer(idleTimer, finish, idleTimeoutMs);
|
|
10691
10823
|
};
|
|
10692
10824
|
session.setTimer(finish, timeoutMs);
|
|
10693
10825
|
session.subscribeInput(onData);
|
|
10694
|
-
this.writeOsc(
|
|
10695
|
-
|
|
10696
|
-
"\x1B]11;?\x07",
|
|
10697
|
-
"\x1B]12;?\x07",
|
|
10698
|
-
"\x1B]13;?\x07",
|
|
10699
|
-
"\x1B]14;?\x07",
|
|
10700
|
-
"\x1B]15;?\x07",
|
|
10701
|
-
"\x1B]16;?\x07",
|
|
10702
|
-
"\x1B]17;?\x07",
|
|
10703
|
-
"\x1B]19;?\x07"
|
|
10704
|
-
].join(""));
|
|
10826
|
+
this.writeOsc(queries.map((idx) => `\x1B]${idx};?\x07`).join(""));
|
|
10827
|
+
idleTimer = session.resetTimer(idleTimer, finish, idleTimeoutMs);
|
|
10705
10828
|
});
|
|
10706
10829
|
}
|
|
10707
10830
|
async detect(options) {
|
|
@@ -10722,9 +10845,10 @@ class TerminalPalette {
|
|
|
10722
10845
|
};
|
|
10723
10846
|
}
|
|
10724
10847
|
const indicesToQuery = [...Array(size).keys()];
|
|
10848
|
+
const idleTimeout = env.OTUI_PALETTE_IDLE_TIMEOUT_MS;
|
|
10725
10849
|
const [paletteResults, specialColors] = await Promise.all([
|
|
10726
|
-
this.queryPalette(indicesToQuery, timeout),
|
|
10727
|
-
this.querySpecialColors(timeout)
|
|
10850
|
+
this.queryPalette(indicesToQuery, timeout, idleTimeout),
|
|
10851
|
+
this.querySpecialColors(timeout, idleTimeout)
|
|
10728
10852
|
]);
|
|
10729
10853
|
return {
|
|
10730
10854
|
palette: [...Array(size).keys()].map((i) => paletteResults.get(i) ?? null),
|
|
@@ -10740,8 +10864,8 @@ class TerminalPalette {
|
|
|
10740
10864
|
};
|
|
10741
10865
|
}
|
|
10742
10866
|
}
|
|
10743
|
-
function createTerminalPalette(
|
|
10744
|
-
return new TerminalPalette(
|
|
10867
|
+
function createTerminalPalette(options) {
|
|
10868
|
+
return new TerminalPalette(options);
|
|
10745
10869
|
}
|
|
10746
10870
|
var DEFAULT_FOREGROUND_FALLBACK = RGBA.fromInts(...DEFAULT_FOREGROUND_RGB);
|
|
10747
10871
|
var DEFAULT_BACKGROUND_FALLBACK = RGBA.fromInts(...DEFAULT_BACKGROUND_RGB);
|
|
@@ -10782,7 +10906,7 @@ function decodePasteBytes(bytes) {
|
|
|
10782
10906
|
return PASTE_TEXT_DECODER.decode(bytes);
|
|
10783
10907
|
}
|
|
10784
10908
|
function stripAnsiSequences(text) {
|
|
10785
|
-
return
|
|
10909
|
+
return stripANSI(text);
|
|
10786
10910
|
}
|
|
10787
10911
|
|
|
10788
10912
|
// src/lib/detect-links.ts
|
|
@@ -10826,174 +10950,512 @@ function detectLinks(chunks, context) {
|
|
|
10826
10950
|
}
|
|
10827
10951
|
return chunks;
|
|
10828
10952
|
}
|
|
10829
|
-
// src/
|
|
10830
|
-
import {
|
|
10831
|
-
|
|
10832
|
-
|
|
10833
|
-
|
|
10834
|
-
|
|
10835
|
-
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
|
|
10848
|
-
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
|
|
10861
|
-
|
|
10862
|
-
|
|
10953
|
+
// src/platform/ffi.ts
|
|
10954
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
10955
|
+
var FFIType = {
|
|
10956
|
+
char: "char",
|
|
10957
|
+
int8_t: "int8_t",
|
|
10958
|
+
i8: "i8",
|
|
10959
|
+
uint8_t: "uint8_t",
|
|
10960
|
+
u8: "u8",
|
|
10961
|
+
int16_t: "int16_t",
|
|
10962
|
+
i16: "i16",
|
|
10963
|
+
uint16_t: "uint16_t",
|
|
10964
|
+
u16: "u16",
|
|
10965
|
+
int32_t: "int32_t",
|
|
10966
|
+
i32: "i32",
|
|
10967
|
+
int: "int",
|
|
10968
|
+
uint32_t: "uint32_t",
|
|
10969
|
+
u32: "u32",
|
|
10970
|
+
int64_t: "int64_t",
|
|
10971
|
+
i64: "i64",
|
|
10972
|
+
uint64_t: "uint64_t",
|
|
10973
|
+
u64: "u64",
|
|
10974
|
+
double: "double",
|
|
10975
|
+
f64: "f64",
|
|
10976
|
+
float: "float",
|
|
10977
|
+
f32: "f32",
|
|
10978
|
+
bool: "bool",
|
|
10979
|
+
ptr: "ptr",
|
|
10980
|
+
pointer: "pointer",
|
|
10981
|
+
void: "void",
|
|
10982
|
+
cstring: "cstring",
|
|
10983
|
+
function: "function",
|
|
10984
|
+
usize: "usize",
|
|
10985
|
+
callback: "callback",
|
|
10986
|
+
napi_env: "napi_env",
|
|
10987
|
+
napi_value: "napi_value",
|
|
10988
|
+
buffer: "buffer"
|
|
10989
|
+
};
|
|
10990
|
+
var FFI_UNAVAILABLE = "OpenTUI native FFI is not available for this runtime yet";
|
|
10991
|
+
var BUN_DLOPEN_NULL = "Bun FFI backend does not support dlopen(null)";
|
|
10992
|
+
var LIBRARY_CLOSED = "Cannot create FFI callback after library.close() has been called";
|
|
10993
|
+
var NODE_CALLBACK_THREADSAFE = "Node FFI callbacks are same-thread only and do not support threadsafe callbacks";
|
|
10994
|
+
var NODE_NAPI_UNSUPPORTED = "Node FFI backend does not support Bun N-API FFI types";
|
|
10995
|
+
var NODE_POINTER_OVERRIDE = "Node FFI backend does not support FFIFunction.ptr overrides";
|
|
10996
|
+
var NODE_PTR_VALUE = "node:ffi ptr() only supports ArrayBuffer and ArrayBufferView values backed by ArrayBuffer";
|
|
10997
|
+
var NODE_STRING_RETURN = "Node FFI backend does not normalize string return values (yet)";
|
|
10998
|
+
var NODE_USIZE_UNSUPPORTED = "Node FFI backend does not support usize until (yet)";
|
|
10999
|
+
var POINTER_NEGATIVE = "Pointer must be non-negative";
|
|
11000
|
+
var POINTER_UNSAFE = "Pointer exceeds safe integer range";
|
|
11001
|
+
function unavailable(cause) {
|
|
11002
|
+
throw new Error(FFI_UNAVAILABLE, { cause });
|
|
10863
11003
|
}
|
|
10864
|
-
|
|
10865
|
-
|
|
10866
|
-
|
|
10867
|
-
|
|
10868
|
-
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
|
|
10873
|
-
|
|
10874
|
-
|
|
10875
|
-
_destroyed = false;
|
|
10876
|
-
get ptr() {
|
|
10877
|
-
return this.bufferPtr;
|
|
10878
|
-
}
|
|
10879
|
-
guard() {
|
|
10880
|
-
if (this._destroyed)
|
|
10881
|
-
throw new Error(`Buffer ${this.id} is destroyed`);
|
|
10882
|
-
}
|
|
10883
|
-
ensureRawBufferViews() {
|
|
10884
|
-
if (this._rawBuffers !== null) {
|
|
10885
|
-
return;
|
|
11004
|
+
function createUnsupportedBackend(cause) {
|
|
11005
|
+
return {
|
|
11006
|
+
dlopen() {
|
|
11007
|
+
return unavailable(cause);
|
|
11008
|
+
},
|
|
11009
|
+
ptr() {
|
|
11010
|
+
return unavailable(cause);
|
|
11011
|
+
},
|
|
11012
|
+
suffix: "",
|
|
11013
|
+
toArrayBuffer() {
|
|
11014
|
+
return unavailable(cause);
|
|
10886
11015
|
}
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
|
|
10890
|
-
|
|
10891
|
-
|
|
10892
|
-
|
|
10893
|
-
|
|
10894
|
-
|
|
10895
|
-
|
|
10896
|
-
|
|
10897
|
-
};
|
|
10898
|
-
}
|
|
10899
|
-
get buffers() {
|
|
10900
|
-
this.guard();
|
|
10901
|
-
this.ensureRawBufferViews();
|
|
10902
|
-
return this._rawBuffers;
|
|
10903
|
-
}
|
|
10904
|
-
constructor(lib, ptr2, width, height, options) {
|
|
10905
|
-
this.id = options.id || `fb_${OptimizedBuffer.fbIdCounter++}`;
|
|
10906
|
-
this.lib = lib;
|
|
10907
|
-
this.respectAlpha = options.respectAlpha || false;
|
|
10908
|
-
this._width = width;
|
|
10909
|
-
this._height = height;
|
|
10910
|
-
this._widthMethod = options.widthMethod || "unicode";
|
|
10911
|
-
this.bufferPtr = ptr2;
|
|
11016
|
+
};
|
|
11017
|
+
}
|
|
11018
|
+
var isBun = typeof process !== "undefined" && typeof process.versions === "object" && process.versions !== null && typeof process.versions.bun === "string";
|
|
11019
|
+
var backend = await loadBackend();
|
|
11020
|
+
function importModule(specifier) {
|
|
11021
|
+
return import(specifier);
|
|
11022
|
+
}
|
|
11023
|
+
async function loadBackend() {
|
|
11024
|
+
if (isBun) {
|
|
11025
|
+
return createBunBackend(await importModule("bun:ffi"));
|
|
10912
11026
|
}
|
|
10913
|
-
|
|
10914
|
-
const
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
|
|
10918
|
-
return buffer;
|
|
11027
|
+
try {
|
|
11028
|
+
const nodeFfi = await importModule("node:ffi");
|
|
11029
|
+
return createNodeBackend(nodeFfi.default ?? nodeFfi);
|
|
11030
|
+
} catch (error) {
|
|
11031
|
+
return createUnsupportedBackend(error);
|
|
10919
11032
|
}
|
|
10920
|
-
|
|
10921
|
-
|
|
11033
|
+
}
|
|
11034
|
+
function toPointer(value) {
|
|
11035
|
+
if (isBun && typeof value === "bigint") {
|
|
11036
|
+
return toSafeNumberPointer(value);
|
|
10922
11037
|
}
|
|
10923
|
-
|
|
10924
|
-
return
|
|
11038
|
+
if (!isBun && typeof value === "number") {
|
|
11039
|
+
return toSafeBigIntPointer(value);
|
|
10925
11040
|
}
|
|
10926
|
-
|
|
10927
|
-
|
|
11041
|
+
return value;
|
|
11042
|
+
}
|
|
11043
|
+
function ffiBool(value) {
|
|
11044
|
+
return value ? 1 : 0;
|
|
11045
|
+
}
|
|
11046
|
+
function toSafeNumberPointer(pointer) {
|
|
11047
|
+
if (pointer < 0n) {
|
|
11048
|
+
throw new Error(POINTER_NEGATIVE);
|
|
10928
11049
|
}
|
|
10929
|
-
|
|
10930
|
-
|
|
10931
|
-
this.lib.bufferSetRespectAlpha(this.bufferPtr, respectAlpha);
|
|
10932
|
-
this.respectAlpha = respectAlpha;
|
|
11050
|
+
if (pointer > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
11051
|
+
throw new Error(POINTER_UNSAFE);
|
|
10933
11052
|
}
|
|
10934
|
-
|
|
10935
|
-
|
|
10936
|
-
|
|
11053
|
+
return Number(pointer);
|
|
11054
|
+
}
|
|
11055
|
+
function toSafeBigIntPointer(pointer) {
|
|
11056
|
+
if (pointer < 0) {
|
|
11057
|
+
throw new Error(POINTER_NEGATIVE);
|
|
10937
11058
|
}
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
const realSize = this.lib.bufferGetRealCharSize(this.bufferPtr);
|
|
10941
|
-
const outputBuffer = new Uint8Array(realSize);
|
|
10942
|
-
const bytesWritten = this.lib.bufferWriteResolvedChars(this.bufferPtr, outputBuffer, addLineBreaks);
|
|
10943
|
-
return outputBuffer.slice(0, bytesWritten);
|
|
11059
|
+
if (!Number.isSafeInteger(pointer)) {
|
|
11060
|
+
throw new Error(POINTER_UNSAFE);
|
|
10944
11061
|
}
|
|
10945
|
-
|
|
10946
|
-
|
|
10947
|
-
|
|
10948
|
-
|
|
10949
|
-
|
|
10950
|
-
|
|
10951
|
-
|
|
10952
|
-
|
|
10953
|
-
|
|
10954
|
-
|
|
10955
|
-
|
|
10956
|
-
|
|
10957
|
-
|
|
10958
|
-
|
|
10959
|
-
|
|
10960
|
-
|
|
10961
|
-
|
|
10962
|
-
|
|
10963
|
-
|
|
10964
|
-
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
|
|
10969
|
-
|
|
10970
|
-
|
|
10971
|
-
|
|
10972
|
-
|
|
11062
|
+
return BigInt(pointer);
|
|
11063
|
+
}
|
|
11064
|
+
function createManagedCallback(raw, callbacks) {
|
|
11065
|
+
let ptr = raw.ptr;
|
|
11066
|
+
let closed = false;
|
|
11067
|
+
const instance = {
|
|
11068
|
+
get ptr() {
|
|
11069
|
+
return ptr;
|
|
11070
|
+
},
|
|
11071
|
+
get threadsafe() {
|
|
11072
|
+
return raw.threadsafe;
|
|
11073
|
+
},
|
|
11074
|
+
close() {
|
|
11075
|
+
if (closed) {
|
|
11076
|
+
return;
|
|
11077
|
+
}
|
|
11078
|
+
closed = true;
|
|
11079
|
+
callbacks.delete(instance);
|
|
11080
|
+
try {
|
|
11081
|
+
raw.close();
|
|
11082
|
+
} finally {
|
|
11083
|
+
ptr = null;
|
|
11084
|
+
}
|
|
11085
|
+
}
|
|
11086
|
+
};
|
|
11087
|
+
callbacks.add(instance);
|
|
11088
|
+
return instance;
|
|
11089
|
+
}
|
|
11090
|
+
function normalizeBunDefinitions(definitions) {
|
|
11091
|
+
return Object.fromEntries(Object.entries(definitions).map(([name, definition]) => [name, normalizeBunDefinition(definition)]));
|
|
11092
|
+
}
|
|
11093
|
+
function normalizeBunDefinition(definition) {
|
|
11094
|
+
return {
|
|
11095
|
+
args: definition.args,
|
|
11096
|
+
returns: definition.returns,
|
|
11097
|
+
ptr: definition.ptr == null ? undefined : toBunPointer(definition.ptr),
|
|
11098
|
+
threadsafe: definition.threadsafe
|
|
11099
|
+
};
|
|
11100
|
+
}
|
|
11101
|
+
function toBunPointer(pointer) {
|
|
11102
|
+
return typeof pointer === "bigint" ? toSafeNumberPointer(pointer) : pointer;
|
|
11103
|
+
}
|
|
11104
|
+
function createBunBackend(bun2) {
|
|
11105
|
+
return {
|
|
11106
|
+
dlopen(path5, symbols) {
|
|
11107
|
+
if (path5 === null) {
|
|
11108
|
+
throw new Error(BUN_DLOPEN_NULL);
|
|
11109
|
+
}
|
|
11110
|
+
const library = bun2.dlopen(path5, normalizeBunDefinitions(symbols));
|
|
11111
|
+
const callbacks = new Set;
|
|
11112
|
+
let closed = false;
|
|
11113
|
+
return {
|
|
11114
|
+
symbols: library.symbols,
|
|
11115
|
+
createCallback(callback, definition) {
|
|
11116
|
+
if (closed) {
|
|
11117
|
+
throw new Error(LIBRARY_CLOSED);
|
|
10973
11118
|
}
|
|
10974
|
-
|
|
10975
|
-
|
|
10976
|
-
|
|
10977
|
-
|
|
10978
|
-
|
|
10979
|
-
|
|
11119
|
+
const raw = new bun2.JSCallback(callback, normalizeBunDefinition(definition));
|
|
11120
|
+
return createManagedCallback(raw, callbacks);
|
|
11121
|
+
},
|
|
11122
|
+
close() {
|
|
11123
|
+
if (closed) {
|
|
11124
|
+
return;
|
|
11125
|
+
}
|
|
11126
|
+
closed = true;
|
|
11127
|
+
try {
|
|
11128
|
+
library.close();
|
|
11129
|
+
} finally {
|
|
11130
|
+
for (const callback of [...callbacks]) {
|
|
11131
|
+
callback.close();
|
|
11132
|
+
}
|
|
11133
|
+
}
|
|
11134
|
+
}
|
|
11135
|
+
};
|
|
11136
|
+
},
|
|
11137
|
+
ptr: bun2.ptr,
|
|
11138
|
+
suffix: bun2.suffix,
|
|
11139
|
+
toArrayBuffer(pointer, offset, length) {
|
|
11140
|
+
return bun2.toArrayBuffer(toBunPointer(pointer), offset, length);
|
|
11141
|
+
}
|
|
11142
|
+
};
|
|
11143
|
+
}
|
|
11144
|
+
function createNodeBackend(nodeFfi) {
|
|
11145
|
+
return {
|
|
11146
|
+
dlopen(path5, symbols) {
|
|
11147
|
+
const { lib, functions } = nodeFfi.dlopen(toNodeLibraryPath(path5), normalizeNodeDefinitions(symbols));
|
|
11148
|
+
const callbacks = new Set;
|
|
11149
|
+
let closed = false;
|
|
11150
|
+
let libraryClosed = false;
|
|
11151
|
+
return {
|
|
11152
|
+
symbols: functions,
|
|
11153
|
+
createCallback(callback, definition) {
|
|
11154
|
+
if (closed) {
|
|
11155
|
+
throw new Error(LIBRARY_CLOSED);
|
|
11156
|
+
}
|
|
11157
|
+
if (definition.threadsafe) {
|
|
11158
|
+
throw new Error(NODE_CALLBACK_THREADSAFE);
|
|
11159
|
+
}
|
|
11160
|
+
const callbackPointer = lib.registerCallback(normalizeNodeDefinition(definition), callback);
|
|
11161
|
+
const raw = {
|
|
11162
|
+
ptr: callbackPointer,
|
|
11163
|
+
threadsafe: false,
|
|
11164
|
+
close() {
|
|
11165
|
+
if (!libraryClosed) {
|
|
11166
|
+
lib.unregisterCallback(callbackPointer);
|
|
11167
|
+
}
|
|
11168
|
+
}
|
|
10980
11169
|
};
|
|
11170
|
+
return createManagedCallback(raw, callbacks);
|
|
11171
|
+
},
|
|
11172
|
+
close() {
|
|
11173
|
+
if (closed) {
|
|
11174
|
+
return;
|
|
11175
|
+
}
|
|
11176
|
+
closed = true;
|
|
11177
|
+
try {
|
|
11178
|
+
libraryClosed = true;
|
|
11179
|
+
lib.close();
|
|
11180
|
+
} finally {
|
|
11181
|
+
for (const callback of [...callbacks]) {
|
|
11182
|
+
callback.close();
|
|
11183
|
+
}
|
|
11184
|
+
}
|
|
11185
|
+
}
|
|
11186
|
+
};
|
|
11187
|
+
},
|
|
11188
|
+
ptr(value) {
|
|
11189
|
+
if (ArrayBuffer.isView(value)) {
|
|
11190
|
+
if (!(value.buffer instanceof ArrayBuffer)) {
|
|
11191
|
+
throw new TypeError(NODE_PTR_VALUE);
|
|
10981
11192
|
}
|
|
11193
|
+
return nodeFfi.getRawPointer(value.buffer) + BigInt(value.byteOffset);
|
|
10982
11194
|
}
|
|
10983
|
-
if (
|
|
10984
|
-
|
|
11195
|
+
if (value instanceof ArrayBuffer) {
|
|
11196
|
+
return nodeFfi.getRawPointer(value);
|
|
10985
11197
|
}
|
|
10986
|
-
|
|
11198
|
+
throw new TypeError(NODE_PTR_VALUE);
|
|
11199
|
+
},
|
|
11200
|
+
suffix: nodeFfi.suffix,
|
|
11201
|
+
toArrayBuffer(pointer, offset, length) {
|
|
11202
|
+
return nodeFfi.toArrayBuffer(toBigIntPointer(pointer) + BigInt(offset ?? 0), length, false);
|
|
10987
11203
|
}
|
|
10988
|
-
|
|
11204
|
+
};
|
|
11205
|
+
}
|
|
11206
|
+
function toNodeLibraryPath(path5) {
|
|
11207
|
+
return path5 instanceof URL ? fileURLToPath3(path5) : path5;
|
|
11208
|
+
}
|
|
11209
|
+
function normalizeNodeDefinitions(definitions) {
|
|
11210
|
+
return Object.fromEntries(Object.entries(definitions).map(([name, definition]) => [name, normalizeNodeDefinition(definition)]));
|
|
11211
|
+
}
|
|
11212
|
+
function normalizeNodeDefinition(definition) {
|
|
11213
|
+
if (definition.ptr != null) {
|
|
11214
|
+
throw new Error(NODE_POINTER_OVERRIDE);
|
|
10989
11215
|
}
|
|
10990
|
-
|
|
10991
|
-
|
|
10992
|
-
|
|
11216
|
+
return {
|
|
11217
|
+
parameters: (definition.args ?? []).map((type) => toNodeFFIType(type, "parameter")),
|
|
11218
|
+
result: toNodeFFIType(definition.returns ?? FFIType.void, "result")
|
|
11219
|
+
};
|
|
11220
|
+
}
|
|
11221
|
+
function toNodeFFIType(type, position) {
|
|
11222
|
+
switch (type) {
|
|
11223
|
+
case FFIType.char:
|
|
11224
|
+
return "char";
|
|
11225
|
+
case FFIType.int8_t:
|
|
11226
|
+
case FFIType.i8:
|
|
11227
|
+
return "i8";
|
|
11228
|
+
case FFIType.uint8_t:
|
|
11229
|
+
case FFIType.u8:
|
|
11230
|
+
return "u8";
|
|
11231
|
+
case FFIType.int16_t:
|
|
11232
|
+
case FFIType.i16:
|
|
11233
|
+
return "i16";
|
|
11234
|
+
case FFIType.uint16_t:
|
|
11235
|
+
case FFIType.u16:
|
|
11236
|
+
return "u16";
|
|
11237
|
+
case FFIType.int32_t:
|
|
11238
|
+
case FFIType.int:
|
|
11239
|
+
case FFIType.i32:
|
|
11240
|
+
return "i32";
|
|
11241
|
+
case FFIType.uint32_t:
|
|
11242
|
+
case FFIType.u32:
|
|
11243
|
+
return "u32";
|
|
11244
|
+
case FFIType.int64_t:
|
|
11245
|
+
case FFIType.i64:
|
|
11246
|
+
return "i64";
|
|
11247
|
+
case FFIType.uint64_t:
|
|
11248
|
+
case FFIType.u64:
|
|
11249
|
+
return "u64";
|
|
11250
|
+
case FFIType.double:
|
|
11251
|
+
case FFIType.f64:
|
|
11252
|
+
return "f64";
|
|
11253
|
+
case FFIType.float:
|
|
11254
|
+
case FFIType.f32:
|
|
11255
|
+
return "f32";
|
|
11256
|
+
case FFIType.bool:
|
|
11257
|
+
return "bool";
|
|
11258
|
+
case FFIType.ptr:
|
|
11259
|
+
case FFIType.pointer:
|
|
11260
|
+
return "pointer";
|
|
11261
|
+
case FFIType.void:
|
|
11262
|
+
return "void";
|
|
11263
|
+
case FFIType.cstring:
|
|
11264
|
+
if (position === "result") {
|
|
11265
|
+
throw new Error(NODE_STRING_RETURN);
|
|
11266
|
+
}
|
|
11267
|
+
return "string";
|
|
11268
|
+
case FFIType.function:
|
|
11269
|
+
case FFIType.callback:
|
|
11270
|
+
return "pointer";
|
|
11271
|
+
case FFIType.usize:
|
|
11272
|
+
throw new Error(NODE_USIZE_UNSUPPORTED);
|
|
11273
|
+
case FFIType.napi_env:
|
|
11274
|
+
case FFIType.napi_value:
|
|
11275
|
+
throw new Error(NODE_NAPI_UNSUPPORTED);
|
|
11276
|
+
case FFIType.buffer:
|
|
11277
|
+
return "buffer";
|
|
11278
|
+
default:
|
|
11279
|
+
return unsupportedNodeFFIType(type);
|
|
10993
11280
|
}
|
|
10994
|
-
|
|
10995
|
-
|
|
10996
|
-
|
|
11281
|
+
}
|
|
11282
|
+
function unsupportedNodeFFIType(type) {
|
|
11283
|
+
throw new Error(`Unsupported FFIType for node:ffi: ${String(type)}`);
|
|
11284
|
+
}
|
|
11285
|
+
function toBigIntPointer(pointer) {
|
|
11286
|
+
return typeof pointer === "bigint" ? pointer : BigInt(pointer);
|
|
11287
|
+
}
|
|
11288
|
+
var dlopen = backend.dlopen;
|
|
11289
|
+
var ptr = backend.ptr;
|
|
11290
|
+
var suffix = backend.suffix;
|
|
11291
|
+
var toArrayBuffer = backend.toArrayBuffer;
|
|
11292
|
+
|
|
11293
|
+
// src/zig.ts
|
|
11294
|
+
import { existsSync as existsSync2, writeFileSync } from "fs";
|
|
11295
|
+
import { EventEmitter as EventEmitter4 } from "events";
|
|
11296
|
+
|
|
11297
|
+
// src/buffer.ts
|
|
11298
|
+
function packDrawOptions(border2, shouldFill, titleAlignment, bottomTitleAlignment) {
|
|
11299
|
+
let packed = 0;
|
|
11300
|
+
if (border2 === true) {
|
|
11301
|
+
packed |= 15;
|
|
11302
|
+
} else if (Array.isArray(border2)) {
|
|
11303
|
+
if (border2.includes("top"))
|
|
11304
|
+
packed |= 8;
|
|
11305
|
+
if (border2.includes("right"))
|
|
11306
|
+
packed |= 4;
|
|
11307
|
+
if (border2.includes("bottom"))
|
|
11308
|
+
packed |= 2;
|
|
11309
|
+
if (border2.includes("left"))
|
|
11310
|
+
packed |= 1;
|
|
11311
|
+
}
|
|
11312
|
+
if (shouldFill) {
|
|
11313
|
+
packed |= 1 << 4;
|
|
11314
|
+
}
|
|
11315
|
+
const alignmentMap = {
|
|
11316
|
+
left: 0,
|
|
11317
|
+
center: 1,
|
|
11318
|
+
right: 2
|
|
11319
|
+
};
|
|
11320
|
+
const alignment = alignmentMap[titleAlignment];
|
|
11321
|
+
const bottomAlignment = alignmentMap[bottomTitleAlignment];
|
|
11322
|
+
packed |= alignment << 5;
|
|
11323
|
+
packed |= bottomAlignment << 7;
|
|
11324
|
+
return packed;
|
|
11325
|
+
}
|
|
11326
|
+
|
|
11327
|
+
class OptimizedBuffer {
|
|
11328
|
+
static fbIdCounter = 0;
|
|
11329
|
+
id;
|
|
11330
|
+
lib;
|
|
11331
|
+
bufferPtr;
|
|
11332
|
+
_width;
|
|
11333
|
+
_height;
|
|
11334
|
+
_widthMethod;
|
|
11335
|
+
respectAlpha = false;
|
|
11336
|
+
_rawBuffers = null;
|
|
11337
|
+
_destroyed = false;
|
|
11338
|
+
get ptr() {
|
|
11339
|
+
return this.bufferPtr;
|
|
11340
|
+
}
|
|
11341
|
+
guard() {
|
|
11342
|
+
if (this._destroyed)
|
|
11343
|
+
throw new Error(`Buffer ${this.id} is destroyed`);
|
|
11344
|
+
}
|
|
11345
|
+
ensureRawBufferViews() {
|
|
11346
|
+
if (this._rawBuffers !== null) {
|
|
11347
|
+
return;
|
|
11348
|
+
}
|
|
11349
|
+
const size = this._width * this._height;
|
|
11350
|
+
const charPtr = this.lib.bufferGetCharPtr(this.bufferPtr);
|
|
11351
|
+
const fgPtr = this.lib.bufferGetFgPtr(this.bufferPtr);
|
|
11352
|
+
const bgPtr = this.lib.bufferGetBgPtr(this.bufferPtr);
|
|
11353
|
+
const attributesPtr = this.lib.bufferGetAttributesPtr(this.bufferPtr);
|
|
11354
|
+
this._rawBuffers = {
|
|
11355
|
+
char: new Uint32Array(toArrayBuffer(charPtr, 0, size * 4)),
|
|
11356
|
+
fg: new Uint16Array(toArrayBuffer(fgPtr, 0, size * 4 * 2)),
|
|
11357
|
+
bg: new Uint16Array(toArrayBuffer(bgPtr, 0, size * 4 * 2)),
|
|
11358
|
+
attributes: new Uint32Array(toArrayBuffer(attributesPtr, 0, size * 4))
|
|
11359
|
+
};
|
|
11360
|
+
}
|
|
11361
|
+
get buffers() {
|
|
11362
|
+
this.guard();
|
|
11363
|
+
this.ensureRawBufferViews();
|
|
11364
|
+
return this._rawBuffers;
|
|
11365
|
+
}
|
|
11366
|
+
constructor(lib, ptr2, width, height, options) {
|
|
11367
|
+
this.id = options.id || `fb_${OptimizedBuffer.fbIdCounter++}`;
|
|
11368
|
+
this.lib = lib;
|
|
11369
|
+
this.respectAlpha = options.respectAlpha || false;
|
|
11370
|
+
this._width = width;
|
|
11371
|
+
this._height = height;
|
|
11372
|
+
this._widthMethod = options.widthMethod || "unicode";
|
|
11373
|
+
this.bufferPtr = ptr2;
|
|
11374
|
+
}
|
|
11375
|
+
static create(width, height, widthMethod, options = {}) {
|
|
11376
|
+
const lib = resolveRenderLib();
|
|
11377
|
+
const respectAlpha = options.respectAlpha || false;
|
|
11378
|
+
const id = options.id && options.id.trim() !== "" ? options.id : "unnamed buffer";
|
|
11379
|
+
const buffer = lib.createOptimizedBuffer(width, height, widthMethod, respectAlpha, id);
|
|
11380
|
+
return buffer;
|
|
11381
|
+
}
|
|
11382
|
+
get widthMethod() {
|
|
11383
|
+
return this._widthMethod;
|
|
11384
|
+
}
|
|
11385
|
+
get width() {
|
|
11386
|
+
return this._width;
|
|
11387
|
+
}
|
|
11388
|
+
get height() {
|
|
11389
|
+
return this._height;
|
|
11390
|
+
}
|
|
11391
|
+
setRespectAlpha(respectAlpha) {
|
|
11392
|
+
this.guard();
|
|
11393
|
+
this.lib.bufferSetRespectAlpha(this.bufferPtr, respectAlpha);
|
|
11394
|
+
this.respectAlpha = respectAlpha;
|
|
11395
|
+
}
|
|
11396
|
+
getNativeId() {
|
|
11397
|
+
this.guard();
|
|
11398
|
+
return this.lib.bufferGetId(this.bufferPtr);
|
|
11399
|
+
}
|
|
11400
|
+
getRealCharBytes(addLineBreaks = false) {
|
|
11401
|
+
this.guard();
|
|
11402
|
+
const realSize = this.lib.bufferGetRealCharSize(this.bufferPtr);
|
|
11403
|
+
const outputBuffer = new Uint8Array(realSize);
|
|
11404
|
+
const bytesWritten = this.lib.bufferWriteResolvedChars(this.bufferPtr, outputBuffer, addLineBreaks);
|
|
11405
|
+
return outputBuffer.slice(0, bytesWritten);
|
|
11406
|
+
}
|
|
11407
|
+
getSpanLines() {
|
|
11408
|
+
this.guard();
|
|
11409
|
+
const { char, fg: fg2, bg: bg2, attributes } = this.buffers;
|
|
11410
|
+
const lines = [];
|
|
11411
|
+
const CHAR_FLAG_CONTINUATION = 3221225472 | 0;
|
|
11412
|
+
const CHAR_FLAG_MASK = 3221225472 | 0;
|
|
11413
|
+
const realTextBytes = this.getRealCharBytes(true);
|
|
11414
|
+
const realTextLines = new TextDecoder().decode(realTextBytes).split(`
|
|
11415
|
+
`);
|
|
11416
|
+
for (let y = 0;y < this._height; y++) {
|
|
11417
|
+
const spans = [];
|
|
11418
|
+
let currentSpan = null;
|
|
11419
|
+
const lineChars = [...realTextLines[y] || ""];
|
|
11420
|
+
let charIdx = 0;
|
|
11421
|
+
for (let x = 0;x < this._width; x++) {
|
|
11422
|
+
const i = y * this._width + x;
|
|
11423
|
+
const cp = char[i];
|
|
11424
|
+
const cellFg = RGBA.fromArray(fg2.slice(i * 4, i * 4 + 4));
|
|
11425
|
+
const cellBg = RGBA.fromArray(bg2.slice(i * 4, i * 4 + 4));
|
|
11426
|
+
const cellAttrs = attributes[i] & 255;
|
|
11427
|
+
const isContinuation = (cp & CHAR_FLAG_MASK) === CHAR_FLAG_CONTINUATION;
|
|
11428
|
+
const cellChar = isContinuation ? "" : lineChars[charIdx++] ?? " ";
|
|
11429
|
+
if (currentSpan && currentSpan.fg.equals(cellFg) && currentSpan.bg.equals(cellBg) && currentSpan.attributes === cellAttrs) {
|
|
11430
|
+
currentSpan.text += cellChar;
|
|
11431
|
+
currentSpan.width += 1;
|
|
11432
|
+
} else {
|
|
11433
|
+
if (currentSpan) {
|
|
11434
|
+
spans.push(currentSpan);
|
|
11435
|
+
}
|
|
11436
|
+
currentSpan = {
|
|
11437
|
+
text: cellChar,
|
|
11438
|
+
fg: cellFg,
|
|
11439
|
+
bg: cellBg,
|
|
11440
|
+
attributes: cellAttrs,
|
|
11441
|
+
width: 1
|
|
11442
|
+
};
|
|
11443
|
+
}
|
|
11444
|
+
}
|
|
11445
|
+
if (currentSpan) {
|
|
11446
|
+
spans.push(currentSpan);
|
|
11447
|
+
}
|
|
11448
|
+
lines.push({ spans });
|
|
11449
|
+
}
|
|
11450
|
+
return lines;
|
|
11451
|
+
}
|
|
11452
|
+
clear(bg2 = RGBA.fromValues(0, 0, 0, 1)) {
|
|
11453
|
+
this.guard();
|
|
11454
|
+
this.lib.bufferClear(this.bufferPtr, bg2);
|
|
11455
|
+
}
|
|
11456
|
+
setCell(x, y, char, fg2, bg2, attributes = 0) {
|
|
11457
|
+
this.guard();
|
|
11458
|
+
this.lib.bufferSetCell(this.bufferPtr, x, y, char, fg2, bg2, attributes);
|
|
10997
11459
|
}
|
|
10998
11460
|
setCellWithAlphaBlending(x, y, char, fg2, bg2, attributes = 0) {
|
|
10999
11461
|
this.guard();
|
|
@@ -11067,11 +11529,11 @@ class OptimizedBuffer {
|
|
|
11067
11529
|
}
|
|
11068
11530
|
drawSuperSampleBuffer(x, y, pixelDataPtr, pixelDataLength, format, alignedBytesPerRow) {
|
|
11069
11531
|
this.guard();
|
|
11070
|
-
this.lib.bufferDrawSuperSampleBuffer(this.bufferPtr, x, y, pixelDataPtr, pixelDataLength, format, alignedBytesPerRow);
|
|
11532
|
+
this.lib.bufferDrawSuperSampleBuffer(this.bufferPtr, x, y, toPointer(pixelDataPtr), pixelDataLength, format, alignedBytesPerRow);
|
|
11071
11533
|
}
|
|
11072
11534
|
drawPackedBuffer(dataPtr, dataLen, posX, posY, terminalWidthCells, terminalHeightCells) {
|
|
11073
11535
|
this.guard();
|
|
11074
|
-
this.lib.bufferDrawPackedBuffer(this.bufferPtr, dataPtr, dataLen, posX, posY, terminalWidthCells, terminalHeightCells);
|
|
11536
|
+
this.lib.bufferDrawPackedBuffer(this.bufferPtr, toPointer(dataPtr), dataLen, posX, posY, terminalWidthCells, terminalHeightCells);
|
|
11075
11537
|
}
|
|
11076
11538
|
drawGrayscaleBuffer(posX, posY, intensities, srcWidth, srcHeight, fg2 = null, bg2 = null) {
|
|
11077
11539
|
this.guard();
|
|
@@ -11148,14 +11610,63 @@ class OptimizedBuffer {
|
|
|
11148
11610
|
}
|
|
11149
11611
|
}
|
|
11150
11612
|
|
|
11151
|
-
// ../../node_modules/.bun/bun-ffi-structs@0.
|
|
11152
|
-
|
|
11613
|
+
// ../../node_modules/.bun/bun-ffi-structs@0.2.2+1fb4c65d43e298b9/node_modules/bun-ffi-structs/dist/index.js
|
|
11614
|
+
var FFI_LOAD_ERROR = "bun-ffi-structs requires Bun or Node.js with node:ffi enabled (--experimental-ffi --allow-ffi).";
|
|
11615
|
+
var backend2 = await loadBackend2();
|
|
11616
|
+
async function loadBackend2() {
|
|
11617
|
+
if (typeof process !== "undefined" && "bun" in process.versions) {
|
|
11618
|
+
return createBunBackend2(await importModule2("bun:ffi"));
|
|
11619
|
+
}
|
|
11620
|
+
try {
|
|
11621
|
+
return createNodeBackend2(await importModule2("node:ffi"));
|
|
11622
|
+
} catch (error) {
|
|
11623
|
+
throw new Error(FFI_LOAD_ERROR, {
|
|
11624
|
+
cause: error instanceof Error ? error : undefined
|
|
11625
|
+
});
|
|
11626
|
+
}
|
|
11627
|
+
}
|
|
11628
|
+
function importModule2(specifier) {
|
|
11629
|
+
return import(specifier).then((module) => module.default ?? module);
|
|
11630
|
+
}
|
|
11631
|
+
function createBunBackend2(bun2) {
|
|
11632
|
+
return {
|
|
11633
|
+
ptr: bun2.ptr,
|
|
11634
|
+
toArrayBuffer(pointer, offset, length) {
|
|
11635
|
+
return bun2.toArrayBuffer(toBunPointer2(pointer), offset, length);
|
|
11636
|
+
}
|
|
11637
|
+
};
|
|
11638
|
+
}
|
|
11639
|
+
function createNodeBackend2(nodeFfi) {
|
|
11640
|
+
return {
|
|
11641
|
+
ptr(value) {
|
|
11642
|
+
if (ArrayBuffer.isView(value)) {
|
|
11643
|
+
return nodeFfi.getRawPointer(value.buffer) + BigInt(value.byteOffset);
|
|
11644
|
+
}
|
|
11645
|
+
if (value instanceof ArrayBuffer) {
|
|
11646
|
+
return nodeFfi.getRawPointer(value);
|
|
11647
|
+
}
|
|
11648
|
+
throw new TypeError("node:ffi ptr() only supports ArrayBuffer and ArrayBufferView values.");
|
|
11649
|
+
},
|
|
11650
|
+
toArrayBuffer(pointer, offset, length) {
|
|
11651
|
+
return nodeFfi.toArrayBuffer(toBigIntPointer2(pointer) + BigInt(offset ?? 0), length, false);
|
|
11652
|
+
}
|
|
11653
|
+
};
|
|
11654
|
+
}
|
|
11655
|
+
function toBigIntPointer2(pointer) {
|
|
11656
|
+
return typeof pointer === "bigint" ? pointer : BigInt(pointer);
|
|
11657
|
+
}
|
|
11658
|
+
function toBunPointer2(pointer) {
|
|
11659
|
+
return typeof pointer === "bigint" ? Number(pointer) : pointer;
|
|
11660
|
+
}
|
|
11661
|
+
var ptr2 = backend2.ptr;
|
|
11662
|
+
var toArrayBuffer2 = backend2.toArrayBuffer;
|
|
11153
11663
|
function fatalError(...args) {
|
|
11154
11664
|
const message = args.join(" ");
|
|
11155
11665
|
console.error("FATAL ERROR:", message);
|
|
11156
11666
|
throw new Error(message);
|
|
11157
11667
|
}
|
|
11158
11668
|
var pointerSize = process.arch === "x64" || process.arch === "arm64" ? 8 : 4;
|
|
11669
|
+
var isBun2 = typeof process !== "undefined" && "bun" in process.versions;
|
|
11159
11670
|
var typeSizes = {
|
|
11160
11671
|
u8: 1,
|
|
11161
11672
|
bool_u8: 1,
|
|
@@ -11167,7 +11678,8 @@ var typeSizes = {
|
|
|
11167
11678
|
f32: 4,
|
|
11168
11679
|
f64: 8,
|
|
11169
11680
|
pointer: pointerSize,
|
|
11170
|
-
i32: 4
|
|
11681
|
+
i32: 4,
|
|
11682
|
+
i64: 8
|
|
11171
11683
|
};
|
|
11172
11684
|
var primitiveKeys = Object.keys(typeSizes);
|
|
11173
11685
|
function isPrimitiveType(type) {
|
|
@@ -11185,6 +11697,7 @@ var typeGetters = {
|
|
|
11185
11697
|
f32: (view, offset) => view.getFloat32(offset, true),
|
|
11186
11698
|
f64: (view, offset) => view.getFloat64(offset, true),
|
|
11187
11699
|
i32: (view, offset) => view.getInt32(offset, true),
|
|
11700
|
+
i64: (view, offset) => view.getBigInt64(offset, true),
|
|
11188
11701
|
pointer: (view, offset) => pointerSize === 8 ? view.getBigUint64(offset, true) : BigInt(view.getUint32(offset, true))
|
|
11189
11702
|
};
|
|
11190
11703
|
function isObjectPointerDef(type) {
|
|
@@ -11248,6 +11761,10 @@ function primitivePackers(type) {
|
|
|
11248
11761
|
pack = (view, off, val) => view.setInt32(off, val, true);
|
|
11249
11762
|
unpack = (view, off) => view.getInt32(off, true);
|
|
11250
11763
|
break;
|
|
11764
|
+
case "i64":
|
|
11765
|
+
pack = (view, off, val) => view.setBigInt64(off, BigInt(val), true);
|
|
11766
|
+
unpack = (view, off) => view.getBigInt64(off, true);
|
|
11767
|
+
break;
|
|
11251
11768
|
case "u64":
|
|
11252
11769
|
pack = (view, off, val) => view.setBigUint64(off, BigInt(val), true);
|
|
11253
11770
|
unpack = (view, off) => view.getBigUint64(off, true);
|
|
@@ -11265,8 +11782,11 @@ function primitivePackers(type) {
|
|
|
11265
11782
|
pointerSize === 8 ? view.setBigUint64(off, val ? BigInt(val) : 0n, true) : view.setUint32(off, val ? Number(val) : 0, true);
|
|
11266
11783
|
};
|
|
11267
11784
|
unpack = (view, off) => {
|
|
11268
|
-
|
|
11269
|
-
|
|
11785
|
+
if (pointerSize === 8) {
|
|
11786
|
+
const value = view.getBigUint64(off, true);
|
|
11787
|
+
return isBun2 ? Number(value) : value;
|
|
11788
|
+
}
|
|
11789
|
+
return view.getUint32(off, true);
|
|
11270
11790
|
};
|
|
11271
11791
|
break;
|
|
11272
11792
|
default:
|
|
@@ -11275,6 +11795,26 @@ function primitivePackers(type) {
|
|
|
11275
11795
|
return { pack, unpack };
|
|
11276
11796
|
}
|
|
11277
11797
|
var { pack: pointerPacker, unpack: pointerUnpacker } = primitivePackers("pointer");
|
|
11798
|
+
var retainedPointerTargets = new WeakMap;
|
|
11799
|
+
function retainPointerTarget(owner, target) {
|
|
11800
|
+
const retained = retainedPointerTargets.get(owner);
|
|
11801
|
+
if (retained) {
|
|
11802
|
+
retained.push(target);
|
|
11803
|
+
} else {
|
|
11804
|
+
retainedPointerTargets.set(owner, [target]);
|
|
11805
|
+
}
|
|
11806
|
+
}
|
|
11807
|
+
function retainIfPointerTargets(owner, target) {
|
|
11808
|
+
if (retainedPointerTargets.has(target)) {
|
|
11809
|
+
retainPointerTarget(owner, target);
|
|
11810
|
+
}
|
|
11811
|
+
}
|
|
11812
|
+
function isNullPointer(pointer) {
|
|
11813
|
+
return pointer == null || pointer === 0 || pointer === 0n;
|
|
11814
|
+
}
|
|
11815
|
+
function toItemCount(length) {
|
|
11816
|
+
return typeof length === "bigint" ? Number(length) : length;
|
|
11817
|
+
}
|
|
11278
11818
|
function packObjectArray(val) {
|
|
11279
11819
|
const buffer = new ArrayBuffer(val.length * pointerSize);
|
|
11280
11820
|
const bufferView = new DataView(buffer);
|
|
@@ -11311,8 +11851,14 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11311
11851
|
size = pointerSize;
|
|
11312
11852
|
align = pointerSize;
|
|
11313
11853
|
pack = (view, off, val) => {
|
|
11314
|
-
|
|
11854
|
+
if (!val) {
|
|
11855
|
+
pointerPacker(view, off, null);
|
|
11856
|
+
return;
|
|
11857
|
+
}
|
|
11858
|
+
const bytes = encoder.encode(val + "\x00");
|
|
11859
|
+
const bufPtr = ptr2(bytes);
|
|
11315
11860
|
pointerPacker(view, off, bufPtr);
|
|
11861
|
+
retainPointerTarget(view.buffer, bytes);
|
|
11316
11862
|
};
|
|
11317
11863
|
unpack = (view, off) => {
|
|
11318
11864
|
const ptrVal = pointerUnpacker(view, off);
|
|
@@ -11322,8 +11868,14 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11322
11868
|
size = pointerSize;
|
|
11323
11869
|
align = pointerSize;
|
|
11324
11870
|
pack = (view, off, val) => {
|
|
11325
|
-
|
|
11871
|
+
if (!val) {
|
|
11872
|
+
pointerPacker(view, off, null);
|
|
11873
|
+
return;
|
|
11874
|
+
}
|
|
11875
|
+
const bytes = encoder.encode(val);
|
|
11876
|
+
const bufPtr = ptr2(bytes);
|
|
11326
11877
|
pointerPacker(view, off, bufPtr);
|
|
11878
|
+
retainPointerTarget(view.buffer, bytes);
|
|
11327
11879
|
};
|
|
11328
11880
|
unpack = (view, off) => {
|
|
11329
11881
|
const ptrVal = pointerUnpacker(view, off);
|
|
@@ -11354,6 +11906,7 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11354
11906
|
}
|
|
11355
11907
|
const nestedBuf = typeOrStruct.pack(val, options2);
|
|
11356
11908
|
pointerPacker(view, off, ptr2(nestedBuf));
|
|
11909
|
+
retainPointerTarget(view.buffer, nestedBuf);
|
|
11357
11910
|
};
|
|
11358
11911
|
unpack = (view, off) => {
|
|
11359
11912
|
throw new Error("Not implemented yet");
|
|
@@ -11366,6 +11919,7 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11366
11919
|
const nestedView = new Uint8Array(nestedBuf);
|
|
11367
11920
|
const dView = new Uint8Array(view.buffer);
|
|
11368
11921
|
dView.set(nestedView, off);
|
|
11922
|
+
retainIfPointerTargets(view.buffer, nestedBuf);
|
|
11369
11923
|
};
|
|
11370
11924
|
unpack = (view, off) => {
|
|
11371
11925
|
const slice = view.buffer.slice(off, off + size);
|
|
@@ -11406,6 +11960,7 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11406
11960
|
bufferView.setUint32(i * arrayElementSize, num, true);
|
|
11407
11961
|
}
|
|
11408
11962
|
pointerPacker(view, off, ptr2(buffer));
|
|
11963
|
+
retainPointerTarget(view.buffer, buffer);
|
|
11409
11964
|
};
|
|
11410
11965
|
unpack = null;
|
|
11411
11966
|
needsLengthOf = true;
|
|
@@ -11423,6 +11978,7 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11423
11978
|
def.packInto(val[i], bufferView, i * arrayElementSize, options2);
|
|
11424
11979
|
}
|
|
11425
11980
|
pointerPacker(view, off, ptr2(buffer));
|
|
11981
|
+
retainPointerTarget(view.buffer, buffer);
|
|
11426
11982
|
};
|
|
11427
11983
|
unpack = (view, off) => {
|
|
11428
11984
|
throw new Error("Not implemented yet");
|
|
@@ -11441,6 +11997,7 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11441
11997
|
primitivePack(bufferView, i * arrayElementSize, val[i]);
|
|
11442
11998
|
}
|
|
11443
11999
|
pointerPacker(view, off, ptr2(buffer));
|
|
12000
|
+
retainPointerTarget(view.buffer, buffer);
|
|
11444
12001
|
};
|
|
11445
12002
|
unpack = null;
|
|
11446
12003
|
needsLengthOf = true;
|
|
@@ -11454,6 +12011,7 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11454
12011
|
}
|
|
11455
12012
|
const packedView = packObjectArray(val);
|
|
11456
12013
|
pointerPacker(view, off, ptr2(packedView.buffer));
|
|
12014
|
+
retainPointerTarget(view.buffer, packedView.buffer);
|
|
11457
12015
|
};
|
|
11458
12016
|
unpack = () => {
|
|
11459
12017
|
throw new Error("not implemented yet");
|
|
@@ -11549,13 +12107,14 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11549
12107
|
throw new Error(`lengthOf field not found for array field ${requester.name}`);
|
|
11550
12108
|
}
|
|
11551
12109
|
if (def === "char*") {
|
|
12110
|
+
const relativeOffset = lengthOfField.offset - requester.offset;
|
|
11552
12111
|
requester.unpack = (view, off) => {
|
|
11553
12112
|
const ptrAddress = pointerUnpacker(view, off);
|
|
11554
|
-
const length = lengthOfField.unpack(view,
|
|
11555
|
-
if (ptrAddress
|
|
12113
|
+
const length = lengthOfField.unpack(view, off + relativeOffset);
|
|
12114
|
+
if (isNullPointer(ptrAddress)) {
|
|
11556
12115
|
return null;
|
|
11557
12116
|
}
|
|
11558
|
-
const byteLength =
|
|
12117
|
+
const byteLength = toItemCount(length);
|
|
11559
12118
|
if (byteLength === 0) {
|
|
11560
12119
|
return "";
|
|
11561
12120
|
}
|
|
@@ -11565,710 +12124,389 @@ function defineStruct(fields, structDefOptions) {
|
|
|
11565
12124
|
} else if (isPrimitiveType(def)) {
|
|
11566
12125
|
const elemSize = typeSizes[def];
|
|
11567
12126
|
const { unpack: primitiveUnpack } = primitivePackers(def);
|
|
12127
|
+
const relativeOffset = lengthOfField.offset - requester.offset;
|
|
11568
12128
|
requester.unpack = (view, off) => {
|
|
11569
12129
|
const result = [];
|
|
11570
|
-
const length = lengthOfField.unpack(view,
|
|
12130
|
+
const length = lengthOfField.unpack(view, off + relativeOffset);
|
|
12131
|
+
const itemCount = toItemCount(length);
|
|
11571
12132
|
const ptrAddress = pointerUnpacker(view, off);
|
|
11572
|
-
if (ptrAddress
|
|
12133
|
+
if (isNullPointer(ptrAddress) && itemCount > 0) {
|
|
11573
12134
|
throw new Error(`Array field ${requester.name} has null pointer but length ${length}.`);
|
|
11574
12135
|
}
|
|
11575
|
-
if (ptrAddress
|
|
12136
|
+
if (isNullPointer(ptrAddress) || itemCount === 0) {
|
|
11576
12137
|
return [];
|
|
11577
12138
|
}
|
|
11578
|
-
const buffer = toArrayBuffer2(ptrAddress, 0,
|
|
12139
|
+
const buffer = toArrayBuffer2(ptrAddress, 0, itemCount * elemSize);
|
|
11579
12140
|
const bufferView = new DataView(buffer);
|
|
11580
|
-
for (let i = 0;i <
|
|
12141
|
+
for (let i = 0;i < itemCount; i++) {
|
|
11581
12142
|
result.push(primitiveUnpack(bufferView, i * elemSize));
|
|
11582
12143
|
}
|
|
11583
|
-
return result;
|
|
11584
|
-
};
|
|
11585
|
-
} else {
|
|
11586
|
-
const elemSize = def.type === "u32" ? 4 : 8;
|
|
11587
|
-
|
|
11588
|
-
|
|
11589
|
-
const
|
|
11590
|
-
const
|
|
11591
|
-
|
|
11592
|
-
|
|
11593
|
-
|
|
11594
|
-
|
|
11595
|
-
|
|
11596
|
-
|
|
11597
|
-
|
|
11598
|
-
|
|
11599
|
-
|
|
11600
|
-
|
|
11601
|
-
|
|
11602
|
-
|
|
11603
|
-
|
|
11604
|
-
|
|
11605
|
-
}
|
|
11606
|
-
const totalSize = alignOffset(offset, maxAlign);
|
|
11607
|
-
const description = layout.map((f) => ({
|
|
11608
|
-
name: f.name,
|
|
11609
|
-
offset: f.offset,
|
|
11610
|
-
size: f.size,
|
|
11611
|
-
align: f.align,
|
|
11612
|
-
optional: f.optional,
|
|
11613
|
-
type: f.type,
|
|
11614
|
-
lengthOf: f.lengthOf
|
|
11615
|
-
}));
|
|
11616
|
-
const layoutByName = new Map(description.map((f) => [f.name, f]));
|
|
11617
|
-
const arrayFields = new Map(Object.entries(arrayFieldsMetadata));
|
|
11618
|
-
return {
|
|
11619
|
-
__type: "struct",
|
|
11620
|
-
size: totalSize,
|
|
11621
|
-
align: maxAlign,
|
|
11622
|
-
hasMapValue: !!structDefOptions?.mapValue,
|
|
11623
|
-
layoutByName,
|
|
11624
|
-
arrayFields,
|
|
11625
|
-
pack(obj, options) {
|
|
11626
|
-
const buf = new ArrayBuffer(totalSize);
|
|
11627
|
-
const view = new DataView(buf);
|
|
11628
|
-
let mappedObj = obj;
|
|
11629
|
-
if (structDefOptions?.mapValue) {
|
|
11630
|
-
mappedObj = structDefOptions.mapValue(obj);
|
|
11631
|
-
}
|
|
11632
|
-
for (const field of layout) {
|
|
11633
|
-
const value = mappedObj[field.name] ?? field.default;
|
|
11634
|
-
if (!field.optional && value === undefined) {
|
|
11635
|
-
fatalError(`Packing non-optional field '${field.name}' but value is undefined (and no default provided)`);
|
|
11636
|
-
}
|
|
11637
|
-
if (field.validate) {
|
|
11638
|
-
for (const validateFn of field.validate) {
|
|
11639
|
-
validateFn(value, field.name, {
|
|
11640
|
-
hints: options?.validationHints,
|
|
11641
|
-
input: mappedObj
|
|
11642
|
-
});
|
|
11643
|
-
}
|
|
11644
|
-
}
|
|
11645
|
-
field.pack(view, field.offset, value, mappedObj, options);
|
|
11646
|
-
}
|
|
11647
|
-
return view.buffer;
|
|
11648
|
-
},
|
|
11649
|
-
packInto(obj, view, offset2, options) {
|
|
11650
|
-
let mappedObj = obj;
|
|
11651
|
-
if (structDefOptions?.mapValue) {
|
|
11652
|
-
mappedObj = structDefOptions.mapValue(obj);
|
|
11653
|
-
}
|
|
11654
|
-
for (const field of layout) {
|
|
11655
|
-
const value = mappedObj[field.name] ?? field.default;
|
|
11656
|
-
if (!field.optional && value === undefined) {
|
|
11657
|
-
console.warn(`packInto missing value for non-optional field '${field.name}' at offset ${offset2 + field.offset}. Writing default or zero.`);
|
|
11658
|
-
}
|
|
11659
|
-
if (field.validate) {
|
|
11660
|
-
for (const validateFn of field.validate) {
|
|
11661
|
-
validateFn(value, field.name, {
|
|
11662
|
-
hints: options?.validationHints,
|
|
11663
|
-
input: mappedObj
|
|
11664
|
-
});
|
|
11665
|
-
}
|
|
11666
|
-
}
|
|
11667
|
-
field.pack(view, offset2 + field.offset, value, mappedObj, options);
|
|
11668
|
-
}
|
|
11669
|
-
},
|
|
11670
|
-
unpack(buf) {
|
|
11671
|
-
if (buf.byteLength < totalSize) {
|
|
11672
|
-
fatalError(`Buffer size (${buf.byteLength}) is smaller than struct size (${totalSize}) for unpacking.`);
|
|
11673
|
-
}
|
|
11674
|
-
const view = new DataView(buf);
|
|
11675
|
-
const result = structDefOptions?.default ? { ...structDefOptions.default } : {};
|
|
11676
|
-
for (const field of layout) {
|
|
11677
|
-
if (!field.unpack) {
|
|
11678
|
-
continue;
|
|
11679
|
-
}
|
|
11680
|
-
try {
|
|
11681
|
-
result[field.name] = field.unpack(view, field.offset);
|
|
11682
|
-
} catch (e) {
|
|
11683
|
-
console.error(`Error unpacking field '${field.name}' at offset ${field.offset}:`, e);
|
|
11684
|
-
throw e;
|
|
11685
|
-
}
|
|
11686
|
-
}
|
|
11687
|
-
if (structDefOptions?.reduceValue) {
|
|
11688
|
-
return structDefOptions.reduceValue(result);
|
|
11689
|
-
}
|
|
11690
|
-
return result;
|
|
11691
|
-
},
|
|
11692
|
-
packList(objects, options) {
|
|
11693
|
-
if (objects.length === 0) {
|
|
11694
|
-
return new ArrayBuffer(0);
|
|
11695
|
-
}
|
|
11696
|
-
const buffer = new ArrayBuffer(totalSize * objects.length);
|
|
11697
|
-
const view = new DataView(buffer);
|
|
11698
|
-
for (let i = 0;i < objects.length; i++) {
|
|
11699
|
-
let mappedObj = objects[i];
|
|
11700
|
-
if (structDefOptions?.mapValue) {
|
|
11701
|
-
mappedObj = structDefOptions.mapValue(objects[i]);
|
|
11702
|
-
}
|
|
11703
|
-
for (const field of layout) {
|
|
11704
|
-
const value = mappedObj[field.name] ?? field.default;
|
|
11705
|
-
if (!field.optional && value === undefined) {
|
|
11706
|
-
fatalError(`Packing non-optional field '${field.name}' at index ${i} but value is undefined (and no default provided)`);
|
|
11707
|
-
}
|
|
11708
|
-
if (field.validate) {
|
|
11709
|
-
for (const validateFn of field.validate) {
|
|
11710
|
-
validateFn(value, field.name, {
|
|
11711
|
-
hints: options?.validationHints,
|
|
11712
|
-
input: mappedObj
|
|
11713
|
-
});
|
|
11714
|
-
}
|
|
11715
|
-
}
|
|
11716
|
-
field.pack(view, i * totalSize + field.offset, value, mappedObj, options);
|
|
11717
|
-
}
|
|
11718
|
-
}
|
|
11719
|
-
return buffer;
|
|
11720
|
-
},
|
|
11721
|
-
unpackList(buf, count) {
|
|
11722
|
-
if (count === 0) {
|
|
11723
|
-
return [];
|
|
11724
|
-
}
|
|
11725
|
-
const expectedSize = totalSize * count;
|
|
11726
|
-
if (buf.byteLength < expectedSize) {
|
|
11727
|
-
fatalError(`Buffer size (${buf.byteLength}) is smaller than expected size (${expectedSize}) for unpacking ${count} structs.`);
|
|
11728
|
-
}
|
|
11729
|
-
const view = new DataView(buf);
|
|
11730
|
-
const results = [];
|
|
11731
|
-
for (let i = 0;i < count; i++) {
|
|
11732
|
-
const offset2 = i * totalSize;
|
|
11733
|
-
const result = structDefOptions?.default ? { ...structDefOptions.default } : {};
|
|
11734
|
-
for (const field of layout) {
|
|
11735
|
-
if (!field.unpack) {
|
|
11736
|
-
continue;
|
|
11737
|
-
}
|
|
11738
|
-
try {
|
|
11739
|
-
result[field.name] = field.unpack(view, offset2 + field.offset);
|
|
11740
|
-
} catch (e) {
|
|
11741
|
-
console.error(`Error unpacking field '${field.name}' at index ${i}, offset ${offset2 + field.offset}:`, e);
|
|
11742
|
-
throw e;
|
|
11743
|
-
}
|
|
11744
|
-
}
|
|
11745
|
-
if (structDefOptions?.reduceValue) {
|
|
11746
|
-
results.push(structDefOptions.reduceValue(result));
|
|
11747
|
-
} else {
|
|
11748
|
-
results.push(result);
|
|
11749
|
-
}
|
|
11750
|
-
}
|
|
11751
|
-
return results;
|
|
11752
|
-
},
|
|
11753
|
-
describe() {
|
|
11754
|
-
return description;
|
|
11755
|
-
}
|
|
11756
|
-
};
|
|
11757
|
-
}
|
|
11758
|
-
|
|
11759
|
-
// src/zig-structs.ts
|
|
11760
|
-
import { ptr as ptr3, toArrayBuffer as toArrayBuffer3 } from "bun:ffi";
|
|
11761
|
-
var rgbaPackTransform = (rgba) => rgba ? ptr3(rgba.buffer) : null;
|
|
11762
|
-
var rgbaUnpackTransform = (ptr4) => ptr4 ? RGBA.fromArray(new Uint16Array(toArrayBuffer3(ptr4, 0, 8))) : undefined;
|
|
11763
|
-
var StyledChunkStruct = defineStruct([
|
|
11764
|
-
["text", "char*"],
|
|
11765
|
-
["text_len", "u64", { lengthOf: "text" }],
|
|
11766
|
-
[
|
|
11767
|
-
"fg",
|
|
11768
|
-
"pointer",
|
|
11769
|
-
{
|
|
11770
|
-
optional: true,
|
|
11771
|
-
packTransform: rgbaPackTransform,
|
|
11772
|
-
unpackTransform: rgbaUnpackTransform
|
|
11773
|
-
}
|
|
11774
|
-
],
|
|
11775
|
-
[
|
|
11776
|
-
"bg",
|
|
11777
|
-
"pointer",
|
|
11778
|
-
{
|
|
11779
|
-
optional: true,
|
|
11780
|
-
packTransform: rgbaPackTransform,
|
|
11781
|
-
unpackTransform: rgbaUnpackTransform
|
|
11782
|
-
}
|
|
11783
|
-
],
|
|
11784
|
-
["attributes", "u32", { default: 0 }],
|
|
11785
|
-
["link", "char*", { default: "" }],
|
|
11786
|
-
["link_len", "u64", { lengthOf: "link" }]
|
|
11787
|
-
], {
|
|
11788
|
-
mapValue: (chunk) => {
|
|
11789
|
-
const normalizedFg = normalizeColorValue(chunk.fg ?? null);
|
|
11790
|
-
const normalizedBg = normalizeColorValue(chunk.bg ?? null);
|
|
11791
|
-
if (!chunk.link || typeof chunk.link === "string") {
|
|
11792
|
-
return {
|
|
11793
|
-
...chunk,
|
|
11794
|
-
fg: normalizedFg?.rgba ?? null,
|
|
11795
|
-
bg: normalizedBg?.rgba ?? null
|
|
11796
|
-
};
|
|
11797
|
-
}
|
|
11798
|
-
return {
|
|
11799
|
-
...chunk,
|
|
11800
|
-
fg: normalizedFg?.rgba ?? null,
|
|
11801
|
-
bg: normalizedBg?.rgba ?? null,
|
|
11802
|
-
link: chunk.link.url
|
|
11803
|
-
};
|
|
11804
|
-
}
|
|
11805
|
-
});
|
|
11806
|
-
var HighlightStruct = defineStruct([
|
|
11807
|
-
["start", "u32"],
|
|
11808
|
-
["end", "u32"],
|
|
11809
|
-
["styleId", "u32"],
|
|
11810
|
-
["priority", "u8", { default: 0 }],
|
|
11811
|
-
["hlRef", "u16", { default: 0 }]
|
|
11812
|
-
]);
|
|
11813
|
-
var LogicalCursorStruct = defineStruct([
|
|
11814
|
-
["row", "u32"],
|
|
11815
|
-
["col", "u32"],
|
|
11816
|
-
["offset", "u32"]
|
|
11817
|
-
]);
|
|
11818
|
-
var VisualCursorStruct = defineStruct([
|
|
11819
|
-
["visualRow", "u32"],
|
|
11820
|
-
["visualCol", "u32"],
|
|
11821
|
-
["logicalRow", "u32"],
|
|
11822
|
-
["logicalCol", "u32"],
|
|
11823
|
-
["offset", "u32"]
|
|
11824
|
-
]);
|
|
11825
|
-
var UnicodeMethodEnum = defineEnum({ wcwidth: 0, unicode: 1 }, "u8");
|
|
11826
|
-
var TerminalCapabilitiesStruct = defineStruct([
|
|
11827
|
-
["kitty_keyboard", "bool_u8"],
|
|
11828
|
-
["kitty_graphics", "bool_u8"],
|
|
11829
|
-
["rgb", "bool_u8"],
|
|
11830
|
-
["ansi256", "bool_u8"],
|
|
11831
|
-
["unicode", UnicodeMethodEnum],
|
|
11832
|
-
["sgr_pixels", "bool_u8"],
|
|
11833
|
-
["color_scheme_updates", "bool_u8"],
|
|
11834
|
-
["explicit_width", "bool_u8"],
|
|
11835
|
-
["scaled_text", "bool_u8"],
|
|
11836
|
-
["sixel", "bool_u8"],
|
|
11837
|
-
["focus_tracking", "bool_u8"],
|
|
11838
|
-
["sync", "bool_u8"],
|
|
11839
|
-
["bracketed_paste", "bool_u8"],
|
|
11840
|
-
["hyperlinks", "bool_u8"],
|
|
11841
|
-
["osc52", "bool_u8"],
|
|
11842
|
-
["explicit_cursor_positioning", "bool_u8"],
|
|
11843
|
-
["term_name", "char*"],
|
|
11844
|
-
["term_name_len", "u64", { lengthOf: "term_name" }],
|
|
11845
|
-
["term_version", "char*"],
|
|
11846
|
-
["term_version_len", "u64", { lengthOf: "term_version" }],
|
|
11847
|
-
["term_from_xtversion", "bool_u8"]
|
|
11848
|
-
]);
|
|
11849
|
-
var EncodedCharStruct = defineStruct([
|
|
11850
|
-
["width", "u8"],
|
|
11851
|
-
["char", "u32"]
|
|
11852
|
-
]);
|
|
11853
|
-
var LineInfoStruct = defineStruct([
|
|
11854
|
-
["startCols", ["u32"]],
|
|
11855
|
-
["startColsLen", "u32", { lengthOf: "startCols" }],
|
|
11856
|
-
["widthCols", ["u32"]],
|
|
11857
|
-
["widthColsLen", "u32", { lengthOf: "widthCols" }],
|
|
11858
|
-
["sources", ["u32"]],
|
|
11859
|
-
["sourcesLen", "u32", { lengthOf: "sources" }],
|
|
11860
|
-
["wraps", ["u32"]],
|
|
11861
|
-
["wrapsLen", "u32", { lengthOf: "wraps" }],
|
|
11862
|
-
["widthColsMax", "u32"]
|
|
11863
|
-
]);
|
|
11864
|
-
var MeasureResultStruct = defineStruct([
|
|
11865
|
-
["lineCount", "u32"],
|
|
11866
|
-
["widthColsMax", "u32"]
|
|
11867
|
-
]);
|
|
11868
|
-
var CursorStateStruct = defineStruct([
|
|
11869
|
-
["x", "u32"],
|
|
11870
|
-
["y", "u32"],
|
|
11871
|
-
["visible", "bool_u8"],
|
|
11872
|
-
["style", "u8"],
|
|
11873
|
-
["blinking", "bool_u8"],
|
|
11874
|
-
["r", "f32"],
|
|
11875
|
-
["g", "f32"],
|
|
11876
|
-
["b", "f32"],
|
|
11877
|
-
["a", "f32"]
|
|
11878
|
-
]);
|
|
11879
|
-
var CursorStyleOptionsStruct = defineStruct([
|
|
11880
|
-
["style", "u8", { default: 255 }],
|
|
11881
|
-
["blinking", "u8", { default: 255 }],
|
|
11882
|
-
[
|
|
11883
|
-
"color",
|
|
11884
|
-
"pointer",
|
|
11885
|
-
{
|
|
11886
|
-
optional: true,
|
|
11887
|
-
packTransform: rgbaPackTransform,
|
|
11888
|
-
unpackTransform: rgbaUnpackTransform
|
|
11889
|
-
}
|
|
11890
|
-
],
|
|
11891
|
-
["cursor", "u8", { default: 255 }]
|
|
11892
|
-
]);
|
|
11893
|
-
var GridDrawOptionsStruct = defineStruct([
|
|
11894
|
-
["drawInner", "bool_u8", { default: true }],
|
|
11895
|
-
["drawOuter", "bool_u8", { default: true }]
|
|
11896
|
-
]);
|
|
11897
|
-
var BuildOptionsStruct = defineStruct([
|
|
11898
|
-
["gpaSafeStats", "bool_u8"],
|
|
11899
|
-
["gpaMemoryLimitTracking", "bool_u8"]
|
|
11900
|
-
]);
|
|
11901
|
-
var AllocatorStatsStruct = defineStruct([
|
|
11902
|
-
["totalRequestedBytes", "u64"],
|
|
11903
|
-
["activeAllocations", "u64"],
|
|
11904
|
-
["smallAllocations", "u64"],
|
|
11905
|
-
["largeAllocations", "u64"],
|
|
11906
|
-
["requestedBytesValid", "bool_u8"]
|
|
11907
|
-
]);
|
|
11908
|
-
var GrowthPolicyEnum = defineEnum({ grow: 0, block: 1 }, "u8");
|
|
11909
|
-
var NativeSpanFeedOptionsStruct = defineStruct([
|
|
11910
|
-
["chunkSize", "u32", { default: 64 * 1024 }],
|
|
11911
|
-
["initialChunks", "u32", { default: 2 }],
|
|
11912
|
-
["maxBytes", "u64", { default: 0n }],
|
|
11913
|
-
["growthPolicy", GrowthPolicyEnum, { default: "grow" }],
|
|
11914
|
-
["autoCommitOnFull", "bool_u8", { default: true }],
|
|
11915
|
-
["spanQueueCapacity", "u32", { default: 0 }]
|
|
11916
|
-
]);
|
|
11917
|
-
var NativeSpanFeedStatsStruct = defineStruct([
|
|
11918
|
-
["bytesWritten", "u64"],
|
|
11919
|
-
["spansCommitted", "u64"],
|
|
11920
|
-
["chunks", "u32"],
|
|
11921
|
-
["pendingSpans", "u32"]
|
|
11922
|
-
]);
|
|
11923
|
-
var SpanInfoStruct = defineStruct([
|
|
11924
|
-
["chunkPtr", "pointer"],
|
|
11925
|
-
["offset", "u32"],
|
|
11926
|
-
["len", "u32"],
|
|
11927
|
-
["chunkIndex", "u32"],
|
|
11928
|
-
["reserved", "u32", { default: 0 }]
|
|
11929
|
-
], {
|
|
11930
|
-
reduceValue: (value) => ({
|
|
11931
|
-
chunkPtr: value.chunkPtr,
|
|
11932
|
-
offset: value.offset,
|
|
11933
|
-
len: value.len,
|
|
11934
|
-
chunkIndex: value.chunkIndex
|
|
11935
|
-
})
|
|
11936
|
-
});
|
|
11937
|
-
var ReserveInfoStruct = defineStruct([
|
|
11938
|
-
["ptr", "pointer"],
|
|
11939
|
-
["len", "u32"],
|
|
11940
|
-
["reserved", "u32", { default: 0 }]
|
|
11941
|
-
], {
|
|
11942
|
-
reduceValue: (value) => ({
|
|
11943
|
-
ptr: value.ptr,
|
|
11944
|
-
len: value.len
|
|
11945
|
-
})
|
|
11946
|
-
});
|
|
11947
|
-
|
|
11948
|
-
// src/platform/ffi.ts
|
|
11949
|
-
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
11950
|
-
var FFIType = {
|
|
11951
|
-
char: "char",
|
|
11952
|
-
int8_t: "int8_t",
|
|
11953
|
-
i8: "i8",
|
|
11954
|
-
uint8_t: "uint8_t",
|
|
11955
|
-
u8: "u8",
|
|
11956
|
-
int16_t: "int16_t",
|
|
11957
|
-
i16: "i16",
|
|
11958
|
-
uint16_t: "uint16_t",
|
|
11959
|
-
u16: "u16",
|
|
11960
|
-
int32_t: "int32_t",
|
|
11961
|
-
i32: "i32",
|
|
11962
|
-
int: "int",
|
|
11963
|
-
uint32_t: "uint32_t",
|
|
11964
|
-
u32: "u32",
|
|
11965
|
-
int64_t: "int64_t",
|
|
11966
|
-
i64: "i64",
|
|
11967
|
-
uint64_t: "uint64_t",
|
|
11968
|
-
u64: "u64",
|
|
11969
|
-
double: "double",
|
|
11970
|
-
f64: "f64",
|
|
11971
|
-
float: "float",
|
|
11972
|
-
f32: "f32",
|
|
11973
|
-
bool: "bool",
|
|
11974
|
-
ptr: "ptr",
|
|
11975
|
-
pointer: "pointer",
|
|
11976
|
-
void: "void",
|
|
11977
|
-
cstring: "cstring",
|
|
11978
|
-
function: "function",
|
|
11979
|
-
usize: "usize",
|
|
11980
|
-
callback: "callback",
|
|
11981
|
-
napi_env: "napi_env",
|
|
11982
|
-
napi_value: "napi_value",
|
|
11983
|
-
buffer: "buffer"
|
|
11984
|
-
};
|
|
11985
|
-
var FFI_UNAVAILABLE = "OpenTUI native FFI is not available for this runtime yet";
|
|
11986
|
-
var BUN_DLOPEN_NULL = "Bun FFI backend does not support dlopen(null)";
|
|
11987
|
-
var LIBRARY_CLOSED = "Cannot create FFI callback after library.close() has been called";
|
|
11988
|
-
var NODE_CALLBACK_THREADSAFE = "Node FFI callbacks are same-thread only and do not support threadsafe callbacks";
|
|
11989
|
-
var NODE_NAPI_UNSUPPORTED = "Node FFI backend does not support Bun N-API FFI types";
|
|
11990
|
-
var NODE_POINTER_OVERRIDE = "Node FFI backend does not support FFIFunction.ptr overrides";
|
|
11991
|
-
var NODE_PTR_VALUE = "node:ffi ptr() only supports ArrayBuffer and ArrayBufferView values backed by ArrayBuffer";
|
|
11992
|
-
var NODE_STRING_RETURN = "Node FFI backend does not normalize string return values (yet)";
|
|
11993
|
-
var NODE_USIZE_UNSUPPORTED = "Node FFI backend does not support usize until (yet)";
|
|
11994
|
-
var POINTER_NEGATIVE = "Pointer must be non-negative";
|
|
11995
|
-
var POINTER_UNSAFE = "Pointer exceeds safe integer range";
|
|
11996
|
-
function unavailable(cause) {
|
|
11997
|
-
throw new Error(FFI_UNAVAILABLE, { cause });
|
|
11998
|
-
}
|
|
11999
|
-
function createUnsupportedBackend(cause) {
|
|
12000
|
-
return {
|
|
12001
|
-
dlopen() {
|
|
12002
|
-
return unavailable(cause);
|
|
12003
|
-
},
|
|
12004
|
-
ptr() {
|
|
12005
|
-
return unavailable(cause);
|
|
12006
|
-
},
|
|
12007
|
-
suffix: "",
|
|
12008
|
-
toArrayBuffer() {
|
|
12009
|
-
return unavailable(cause);
|
|
12010
|
-
}
|
|
12011
|
-
};
|
|
12012
|
-
}
|
|
12013
|
-
var isBun = typeof process !== "undefined" && typeof process.versions === "object" && process.versions !== null && typeof process.versions.bun === "string";
|
|
12014
|
-
var backend = await loadBackend();
|
|
12015
|
-
function importModule(specifier) {
|
|
12016
|
-
return import(specifier);
|
|
12017
|
-
}
|
|
12018
|
-
async function loadBackend() {
|
|
12019
|
-
if (isBun) {
|
|
12020
|
-
return createBunBackend(await importModule("bun:ffi"));
|
|
12021
|
-
}
|
|
12022
|
-
try {
|
|
12023
|
-
const nodeFfi = await importModule("node:ffi");
|
|
12024
|
-
return createNodeBackend(nodeFfi.default ?? nodeFfi);
|
|
12025
|
-
} catch (error) {
|
|
12026
|
-
return createUnsupportedBackend(error);
|
|
12027
|
-
}
|
|
12028
|
-
}
|
|
12029
|
-
function toPointer(value) {
|
|
12030
|
-
if (typeof value === "bigint") {
|
|
12031
|
-
return toSafeNumberPointer(value);
|
|
12032
|
-
}
|
|
12033
|
-
return value;
|
|
12034
|
-
}
|
|
12035
|
-
function toSafeNumberPointer(pointer) {
|
|
12036
|
-
if (pointer < 0n) {
|
|
12037
|
-
throw new Error(POINTER_NEGATIVE);
|
|
12038
|
-
}
|
|
12039
|
-
if (pointer > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
12040
|
-
throw new Error(POINTER_UNSAFE);
|
|
12041
|
-
}
|
|
12042
|
-
return Number(pointer);
|
|
12043
|
-
}
|
|
12044
|
-
function createManagedCallback(raw, callbacks) {
|
|
12045
|
-
let ptr4 = raw.ptr;
|
|
12046
|
-
let closed = false;
|
|
12047
|
-
const instance = {
|
|
12048
|
-
get ptr() {
|
|
12049
|
-
return ptr4;
|
|
12050
|
-
},
|
|
12051
|
-
get threadsafe() {
|
|
12052
|
-
return raw.threadsafe;
|
|
12053
|
-
},
|
|
12054
|
-
close() {
|
|
12055
|
-
if (closed) {
|
|
12056
|
-
return;
|
|
12057
|
-
}
|
|
12058
|
-
closed = true;
|
|
12059
|
-
callbacks.delete(instance);
|
|
12060
|
-
try {
|
|
12061
|
-
raw.close();
|
|
12062
|
-
} finally {
|
|
12063
|
-
ptr4 = null;
|
|
12064
|
-
}
|
|
12065
|
-
}
|
|
12066
|
-
};
|
|
12067
|
-
callbacks.add(instance);
|
|
12068
|
-
return instance;
|
|
12069
|
-
}
|
|
12070
|
-
function normalizeBunDefinitions(definitions) {
|
|
12071
|
-
return Object.fromEntries(Object.entries(definitions).map(([name, definition]) => [name, normalizeBunDefinition(definition)]));
|
|
12072
|
-
}
|
|
12073
|
-
function normalizeBunDefinition(definition) {
|
|
12074
|
-
return {
|
|
12075
|
-
args: definition.args,
|
|
12076
|
-
returns: definition.returns,
|
|
12077
|
-
ptr: definition.ptr == null ? undefined : toBunPointer(definition.ptr),
|
|
12078
|
-
threadsafe: definition.threadsafe
|
|
12079
|
-
};
|
|
12080
|
-
}
|
|
12081
|
-
function toBunPointer(pointer) {
|
|
12082
|
-
return typeof pointer === "bigint" ? toSafeNumberPointer(pointer) : pointer;
|
|
12083
|
-
}
|
|
12084
|
-
function createBunBackend(bun) {
|
|
12085
|
-
return {
|
|
12086
|
-
dlopen(path5, symbols) {
|
|
12087
|
-
if (path5 === null) {
|
|
12088
|
-
throw new Error(BUN_DLOPEN_NULL);
|
|
12089
|
-
}
|
|
12090
|
-
const library = bun.dlopen(path5, normalizeBunDefinitions(symbols));
|
|
12091
|
-
const callbacks = new Set;
|
|
12092
|
-
let closed = false;
|
|
12093
|
-
return {
|
|
12094
|
-
symbols: library.symbols,
|
|
12095
|
-
createCallback(callback, definition) {
|
|
12096
|
-
if (closed) {
|
|
12097
|
-
throw new Error(LIBRARY_CLOSED);
|
|
12098
|
-
}
|
|
12099
|
-
const raw = new bun.JSCallback(callback, normalizeBunDefinition(definition));
|
|
12100
|
-
return createManagedCallback(raw, callbacks);
|
|
12101
|
-
},
|
|
12102
|
-
close() {
|
|
12103
|
-
if (closed) {
|
|
12104
|
-
return;
|
|
12105
|
-
}
|
|
12106
|
-
closed = true;
|
|
12107
|
-
try {
|
|
12108
|
-
library.close();
|
|
12109
|
-
} finally {
|
|
12110
|
-
for (const callback of [...callbacks]) {
|
|
12111
|
-
callback.close();
|
|
12112
|
-
}
|
|
12113
|
-
}
|
|
12114
|
-
}
|
|
12144
|
+
return result;
|
|
12145
|
+
};
|
|
12146
|
+
} else {
|
|
12147
|
+
const elemSize = def.type === "u32" ? 4 : 8;
|
|
12148
|
+
const relativeOffset = lengthOfField.offset - requester.offset;
|
|
12149
|
+
requester.unpack = (view, off) => {
|
|
12150
|
+
const result = [];
|
|
12151
|
+
const length = lengthOfField.unpack(view, off + relativeOffset);
|
|
12152
|
+
const itemCount = toItemCount(length);
|
|
12153
|
+
const ptrAddress = pointerUnpacker(view, off);
|
|
12154
|
+
if (isNullPointer(ptrAddress) && itemCount > 0) {
|
|
12155
|
+
throw new Error(`Array field ${requester.name} has null pointer but length ${length}.`);
|
|
12156
|
+
}
|
|
12157
|
+
if (isNullPointer(ptrAddress) || itemCount === 0) {
|
|
12158
|
+
return [];
|
|
12159
|
+
}
|
|
12160
|
+
const buffer = toArrayBuffer2(ptrAddress, 0, itemCount * elemSize);
|
|
12161
|
+
const bufferView = new DataView(buffer);
|
|
12162
|
+
for (let i = 0;i < itemCount; i++) {
|
|
12163
|
+
result.push(def.from(bufferView.getUint32(i * elemSize, true)));
|
|
12164
|
+
}
|
|
12165
|
+
return result;
|
|
12115
12166
|
};
|
|
12116
|
-
},
|
|
12117
|
-
ptr: bun.ptr,
|
|
12118
|
-
suffix: bun.suffix,
|
|
12119
|
-
toArrayBuffer(pointer, offset, length) {
|
|
12120
|
-
return bun.toArrayBuffer(toBunPointer(pointer), offset, length);
|
|
12121
12167
|
}
|
|
12122
|
-
}
|
|
12123
|
-
|
|
12124
|
-
|
|
12168
|
+
}
|
|
12169
|
+
const totalSize = alignOffset(offset, maxAlign);
|
|
12170
|
+
const description = layout.map((f) => ({
|
|
12171
|
+
name: f.name,
|
|
12172
|
+
offset: f.offset,
|
|
12173
|
+
size: f.size,
|
|
12174
|
+
align: f.align,
|
|
12175
|
+
optional: f.optional,
|
|
12176
|
+
type: f.type,
|
|
12177
|
+
lengthOf: f.lengthOf
|
|
12178
|
+
}));
|
|
12179
|
+
const layoutByName = new Map(description.map((f) => [f.name, f]));
|
|
12180
|
+
const arrayFields = new Map(Object.entries(arrayFieldsMetadata));
|
|
12125
12181
|
return {
|
|
12126
|
-
|
|
12127
|
-
|
|
12128
|
-
|
|
12129
|
-
|
|
12130
|
-
|
|
12131
|
-
|
|
12132
|
-
|
|
12133
|
-
|
|
12134
|
-
|
|
12135
|
-
|
|
12182
|
+
__type: "struct",
|
|
12183
|
+
size: totalSize,
|
|
12184
|
+
align: maxAlign,
|
|
12185
|
+
hasMapValue: !!structDefOptions?.mapValue,
|
|
12186
|
+
layoutByName,
|
|
12187
|
+
arrayFields,
|
|
12188
|
+
pack(obj, options) {
|
|
12189
|
+
const buf = new ArrayBuffer(totalSize);
|
|
12190
|
+
const view = new DataView(buf);
|
|
12191
|
+
let mappedObj = obj;
|
|
12192
|
+
if (structDefOptions?.mapValue) {
|
|
12193
|
+
mappedObj = structDefOptions.mapValue(obj);
|
|
12194
|
+
}
|
|
12195
|
+
for (const field of layout) {
|
|
12196
|
+
const value = mappedObj[field.name] ?? field.default;
|
|
12197
|
+
if (!field.optional && value === undefined) {
|
|
12198
|
+
fatalError(`Packing non-optional field '${field.name}' but value is undefined (and no default provided)`);
|
|
12199
|
+
}
|
|
12200
|
+
if (field.validate) {
|
|
12201
|
+
for (const validateFn of field.validate) {
|
|
12202
|
+
validateFn(value, field.name, {
|
|
12203
|
+
hints: options?.validationHints,
|
|
12204
|
+
input: mappedObj
|
|
12205
|
+
});
|
|
12136
12206
|
}
|
|
12137
|
-
|
|
12138
|
-
|
|
12207
|
+
}
|
|
12208
|
+
field.pack(view, field.offset, value, mappedObj, options);
|
|
12209
|
+
}
|
|
12210
|
+
return view.buffer;
|
|
12211
|
+
},
|
|
12212
|
+
packInto(obj, view, offset2, options) {
|
|
12213
|
+
let mappedObj = obj;
|
|
12214
|
+
if (structDefOptions?.mapValue) {
|
|
12215
|
+
mappedObj = structDefOptions.mapValue(obj);
|
|
12216
|
+
}
|
|
12217
|
+
for (const field of layout) {
|
|
12218
|
+
const value = mappedObj[field.name] ?? field.default;
|
|
12219
|
+
if (!field.optional && value === undefined) {
|
|
12220
|
+
console.warn(`packInto missing value for non-optional field '${field.name}' at offset ${offset2 + field.offset}. Writing default or zero.`);
|
|
12221
|
+
}
|
|
12222
|
+
if (field.validate) {
|
|
12223
|
+
for (const validateFn of field.validate) {
|
|
12224
|
+
validateFn(value, field.name, {
|
|
12225
|
+
hints: options?.validationHints,
|
|
12226
|
+
input: mappedObj
|
|
12227
|
+
});
|
|
12139
12228
|
}
|
|
12140
|
-
|
|
12141
|
-
|
|
12142
|
-
|
|
12143
|
-
|
|
12144
|
-
|
|
12145
|
-
|
|
12146
|
-
|
|
12147
|
-
|
|
12148
|
-
|
|
12149
|
-
|
|
12150
|
-
|
|
12151
|
-
|
|
12152
|
-
|
|
12153
|
-
|
|
12154
|
-
|
|
12229
|
+
}
|
|
12230
|
+
field.pack(view, offset2 + field.offset, value, mappedObj, options);
|
|
12231
|
+
}
|
|
12232
|
+
},
|
|
12233
|
+
unpack(buf) {
|
|
12234
|
+
if (buf.byteLength < totalSize) {
|
|
12235
|
+
fatalError(`Buffer size (${buf.byteLength}) is smaller than struct size (${totalSize}) for unpacking.`);
|
|
12236
|
+
}
|
|
12237
|
+
const view = new DataView(buf);
|
|
12238
|
+
const result = structDefOptions?.default ? { ...structDefOptions.default } : {};
|
|
12239
|
+
for (const field of layout) {
|
|
12240
|
+
if (!field.unpack) {
|
|
12241
|
+
continue;
|
|
12242
|
+
}
|
|
12243
|
+
try {
|
|
12244
|
+
result[field.name] = field.unpack(view, field.offset);
|
|
12245
|
+
} catch (e) {
|
|
12246
|
+
console.error(`Error unpacking field '${field.name}' at offset ${field.offset}:`, e);
|
|
12247
|
+
throw e;
|
|
12248
|
+
}
|
|
12249
|
+
}
|
|
12250
|
+
if (structDefOptions?.reduceValue) {
|
|
12251
|
+
return structDefOptions.reduceValue(result);
|
|
12252
|
+
}
|
|
12253
|
+
return result;
|
|
12254
|
+
},
|
|
12255
|
+
packList(objects, options) {
|
|
12256
|
+
if (objects.length === 0) {
|
|
12257
|
+
return new ArrayBuffer(0);
|
|
12258
|
+
}
|
|
12259
|
+
const buffer = new ArrayBuffer(totalSize * objects.length);
|
|
12260
|
+
const view = new DataView(buffer);
|
|
12261
|
+
for (let i = 0;i < objects.length; i++) {
|
|
12262
|
+
let mappedObj = objects[i];
|
|
12263
|
+
if (structDefOptions?.mapValue) {
|
|
12264
|
+
mappedObj = structDefOptions.mapValue(objects[i]);
|
|
12265
|
+
}
|
|
12266
|
+
for (const field of layout) {
|
|
12267
|
+
const value = mappedObj[field.name] ?? field.default;
|
|
12268
|
+
if (!field.optional && value === undefined) {
|
|
12269
|
+
fatalError(`Packing non-optional field '${field.name}' at index ${i} but value is undefined (and no default provided)`);
|
|
12155
12270
|
}
|
|
12156
|
-
|
|
12157
|
-
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
|
|
12161
|
-
|
|
12162
|
-
callback.close();
|
|
12271
|
+
if (field.validate) {
|
|
12272
|
+
for (const validateFn of field.validate) {
|
|
12273
|
+
validateFn(value, field.name, {
|
|
12274
|
+
hints: options?.validationHints,
|
|
12275
|
+
input: mappedObj
|
|
12276
|
+
});
|
|
12163
12277
|
}
|
|
12164
12278
|
}
|
|
12279
|
+
field.pack(view, i * totalSize + field.offset, value, mappedObj, options);
|
|
12165
12280
|
}
|
|
12166
|
-
}
|
|
12281
|
+
}
|
|
12282
|
+
return buffer;
|
|
12167
12283
|
},
|
|
12168
|
-
|
|
12169
|
-
if (
|
|
12170
|
-
|
|
12171
|
-
throw new TypeError(NODE_PTR_VALUE);
|
|
12172
|
-
}
|
|
12173
|
-
return nodeFfi.getRawPointer(value.buffer) + BigInt(value.byteOffset);
|
|
12284
|
+
unpackList(buf, count) {
|
|
12285
|
+
if (count === 0) {
|
|
12286
|
+
return [];
|
|
12174
12287
|
}
|
|
12175
|
-
|
|
12176
|
-
|
|
12288
|
+
const expectedSize = totalSize * count;
|
|
12289
|
+
if (buf.byteLength < expectedSize) {
|
|
12290
|
+
fatalError(`Buffer size (${buf.byteLength}) is smaller than expected size (${expectedSize}) for unpacking ${count} structs.`);
|
|
12177
12291
|
}
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
|
|
12182
|
-
|
|
12183
|
-
|
|
12184
|
-
|
|
12185
|
-
|
|
12186
|
-
|
|
12187
|
-
|
|
12188
|
-
|
|
12189
|
-
|
|
12190
|
-
|
|
12191
|
-
|
|
12192
|
-
|
|
12193
|
-
|
|
12194
|
-
|
|
12195
|
-
|
|
12196
|
-
|
|
12197
|
-
|
|
12198
|
-
|
|
12199
|
-
};
|
|
12200
|
-
}
|
|
12201
|
-
function toNodeFFIType(type, position) {
|
|
12202
|
-
switch (type) {
|
|
12203
|
-
case FFIType.char:
|
|
12204
|
-
return "char";
|
|
12205
|
-
case FFIType.int8_t:
|
|
12206
|
-
case FFIType.i8:
|
|
12207
|
-
return "i8";
|
|
12208
|
-
case FFIType.uint8_t:
|
|
12209
|
-
case FFIType.u8:
|
|
12210
|
-
return "u8";
|
|
12211
|
-
case FFIType.int16_t:
|
|
12212
|
-
case FFIType.i16:
|
|
12213
|
-
return "i16";
|
|
12214
|
-
case FFIType.uint16_t:
|
|
12215
|
-
case FFIType.u16:
|
|
12216
|
-
return "u16";
|
|
12217
|
-
case FFIType.int32_t:
|
|
12218
|
-
case FFIType.int:
|
|
12219
|
-
case FFIType.i32:
|
|
12220
|
-
return "i32";
|
|
12221
|
-
case FFIType.uint32_t:
|
|
12222
|
-
case FFIType.u32:
|
|
12223
|
-
return "u32";
|
|
12224
|
-
case FFIType.int64_t:
|
|
12225
|
-
case FFIType.i64:
|
|
12226
|
-
return "i64";
|
|
12227
|
-
case FFIType.uint64_t:
|
|
12228
|
-
case FFIType.u64:
|
|
12229
|
-
return "u64";
|
|
12230
|
-
case FFIType.double:
|
|
12231
|
-
case FFIType.f64:
|
|
12232
|
-
return "f64";
|
|
12233
|
-
case FFIType.float:
|
|
12234
|
-
case FFIType.f32:
|
|
12235
|
-
return "f32";
|
|
12236
|
-
case FFIType.bool:
|
|
12237
|
-
return "bool";
|
|
12238
|
-
case FFIType.ptr:
|
|
12239
|
-
case FFIType.pointer:
|
|
12240
|
-
return "pointer";
|
|
12241
|
-
case FFIType.void:
|
|
12242
|
-
return "void";
|
|
12243
|
-
case FFIType.cstring:
|
|
12244
|
-
if (position === "result") {
|
|
12245
|
-
throw new Error(NODE_STRING_RETURN);
|
|
12292
|
+
const view = new DataView(buf);
|
|
12293
|
+
const results = [];
|
|
12294
|
+
for (let i = 0;i < count; i++) {
|
|
12295
|
+
const offset2 = i * totalSize;
|
|
12296
|
+
const result = structDefOptions?.default ? { ...structDefOptions.default } : {};
|
|
12297
|
+
for (const field of layout) {
|
|
12298
|
+
if (!field.unpack) {
|
|
12299
|
+
continue;
|
|
12300
|
+
}
|
|
12301
|
+
try {
|
|
12302
|
+
result[field.name] = field.unpack(view, offset2 + field.offset);
|
|
12303
|
+
} catch (e) {
|
|
12304
|
+
console.error(`Error unpacking field '${field.name}' at index ${i}, offset ${offset2 + field.offset}:`, e);
|
|
12305
|
+
throw e;
|
|
12306
|
+
}
|
|
12307
|
+
}
|
|
12308
|
+
if (structDefOptions?.reduceValue) {
|
|
12309
|
+
results.push(structDefOptions.reduceValue(result));
|
|
12310
|
+
} else {
|
|
12311
|
+
results.push(result);
|
|
12312
|
+
}
|
|
12246
12313
|
}
|
|
12247
|
-
return
|
|
12248
|
-
|
|
12249
|
-
|
|
12250
|
-
return
|
|
12251
|
-
|
|
12252
|
-
|
|
12253
|
-
case FFIType.napi_env:
|
|
12254
|
-
case FFIType.napi_value:
|
|
12255
|
-
throw new Error(NODE_NAPI_UNSUPPORTED);
|
|
12256
|
-
case FFIType.buffer:
|
|
12257
|
-
return "buffer";
|
|
12258
|
-
default:
|
|
12259
|
-
return unsupportedNodeFFIType(type);
|
|
12260
|
-
}
|
|
12261
|
-
}
|
|
12262
|
-
function unsupportedNodeFFIType(type) {
|
|
12263
|
-
throw new Error(`Unsupported FFIType for node:ffi: ${String(type)}`);
|
|
12264
|
-
}
|
|
12265
|
-
function toBigIntPointer(pointer) {
|
|
12266
|
-
return typeof pointer === "bigint" ? pointer : BigInt(pointer);
|
|
12314
|
+
return results;
|
|
12315
|
+
},
|
|
12316
|
+
describe() {
|
|
12317
|
+
return description;
|
|
12318
|
+
}
|
|
12319
|
+
};
|
|
12267
12320
|
}
|
|
12268
|
-
|
|
12269
|
-
|
|
12270
|
-
var
|
|
12271
|
-
var
|
|
12321
|
+
|
|
12322
|
+
// src/zig-structs.ts
|
|
12323
|
+
var rgbaPackTransform = (rgba) => rgba ? ptr(rgba.buffer) : null;
|
|
12324
|
+
var rgbaUnpackTransform = (ptr3) => ptr3 ? RGBA.fromArray(new Uint16Array(toArrayBuffer(ptr3, 0, 8))) : undefined;
|
|
12325
|
+
var StyledChunkStruct = defineStruct([
|
|
12326
|
+
["text", "char*"],
|
|
12327
|
+
["text_len", "u64", { lengthOf: "text" }],
|
|
12328
|
+
[
|
|
12329
|
+
"fg",
|
|
12330
|
+
"pointer",
|
|
12331
|
+
{
|
|
12332
|
+
optional: true,
|
|
12333
|
+
packTransform: rgbaPackTransform,
|
|
12334
|
+
unpackTransform: rgbaUnpackTransform
|
|
12335
|
+
}
|
|
12336
|
+
],
|
|
12337
|
+
[
|
|
12338
|
+
"bg",
|
|
12339
|
+
"pointer",
|
|
12340
|
+
{
|
|
12341
|
+
optional: true,
|
|
12342
|
+
packTransform: rgbaPackTransform,
|
|
12343
|
+
unpackTransform: rgbaUnpackTransform
|
|
12344
|
+
}
|
|
12345
|
+
],
|
|
12346
|
+
["attributes", "u32", { default: 0 }],
|
|
12347
|
+
["link", "char*", { default: "" }],
|
|
12348
|
+
["link_len", "u64", { lengthOf: "link" }]
|
|
12349
|
+
], {
|
|
12350
|
+
mapValue: (chunk) => {
|
|
12351
|
+
const normalizedFg = normalizeColorValue(chunk.fg ?? null);
|
|
12352
|
+
const normalizedBg = normalizeColorValue(chunk.bg ?? null);
|
|
12353
|
+
if (!chunk.link || typeof chunk.link === "string") {
|
|
12354
|
+
return {
|
|
12355
|
+
...chunk,
|
|
12356
|
+
fg: normalizedFg?.rgba ?? null,
|
|
12357
|
+
bg: normalizedBg?.rgba ?? null
|
|
12358
|
+
};
|
|
12359
|
+
}
|
|
12360
|
+
return {
|
|
12361
|
+
...chunk,
|
|
12362
|
+
fg: normalizedFg?.rgba ?? null,
|
|
12363
|
+
bg: normalizedBg?.rgba ?? null,
|
|
12364
|
+
link: chunk.link.url
|
|
12365
|
+
};
|
|
12366
|
+
}
|
|
12367
|
+
});
|
|
12368
|
+
var HighlightStruct = defineStruct([
|
|
12369
|
+
["start", "u32"],
|
|
12370
|
+
["end", "u32"],
|
|
12371
|
+
["styleId", "u32"],
|
|
12372
|
+
["priority", "u8", { default: 0 }],
|
|
12373
|
+
["hlRef", "u16", { default: 0 }]
|
|
12374
|
+
]);
|
|
12375
|
+
var LogicalCursorStruct = defineStruct([
|
|
12376
|
+
["row", "u32"],
|
|
12377
|
+
["col", "u32"],
|
|
12378
|
+
["offset", "u32"]
|
|
12379
|
+
]);
|
|
12380
|
+
var VisualCursorStruct = defineStruct([
|
|
12381
|
+
["visualRow", "u32"],
|
|
12382
|
+
["visualCol", "u32"],
|
|
12383
|
+
["logicalRow", "u32"],
|
|
12384
|
+
["logicalCol", "u32"],
|
|
12385
|
+
["offset", "u32"]
|
|
12386
|
+
]);
|
|
12387
|
+
var UnicodeMethodEnum = defineEnum({ wcwidth: 0, unicode: 1 }, "u8");
|
|
12388
|
+
var TerminalCapabilitiesStruct = defineStruct([
|
|
12389
|
+
["kitty_keyboard", "bool_u8"],
|
|
12390
|
+
["kitty_graphics", "bool_u8"],
|
|
12391
|
+
["rgb", "bool_u8"],
|
|
12392
|
+
["ansi256", "bool_u8"],
|
|
12393
|
+
["unicode", UnicodeMethodEnum],
|
|
12394
|
+
["sgr_pixels", "bool_u8"],
|
|
12395
|
+
["color_scheme_updates", "bool_u8"],
|
|
12396
|
+
["explicit_width", "bool_u8"],
|
|
12397
|
+
["scaled_text", "bool_u8"],
|
|
12398
|
+
["sixel", "bool_u8"],
|
|
12399
|
+
["focus_tracking", "bool_u8"],
|
|
12400
|
+
["sync", "bool_u8"],
|
|
12401
|
+
["bracketed_paste", "bool_u8"],
|
|
12402
|
+
["hyperlinks", "bool_u8"],
|
|
12403
|
+
["osc52", "bool_u8"],
|
|
12404
|
+
["explicit_cursor_positioning", "bool_u8"],
|
|
12405
|
+
["in_tmux", "bool_u8"],
|
|
12406
|
+
["term_name", "char*"],
|
|
12407
|
+
["term_name_len", "u64", { lengthOf: "term_name" }],
|
|
12408
|
+
["term_version", "char*"],
|
|
12409
|
+
["term_version_len", "u64", { lengthOf: "term_version" }],
|
|
12410
|
+
["term_from_xtversion", "bool_u8"]
|
|
12411
|
+
]);
|
|
12412
|
+
var EncodedCharStruct = defineStruct([
|
|
12413
|
+
["width", "u8"],
|
|
12414
|
+
["char", "u32"]
|
|
12415
|
+
]);
|
|
12416
|
+
var LineInfoStruct = defineStruct([
|
|
12417
|
+
["startCols", ["u32"]],
|
|
12418
|
+
["startColsLen", "u32", { lengthOf: "startCols" }],
|
|
12419
|
+
["widthCols", ["u32"]],
|
|
12420
|
+
["widthColsLen", "u32", { lengthOf: "widthCols" }],
|
|
12421
|
+
["sources", ["u32"]],
|
|
12422
|
+
["sourcesLen", "u32", { lengthOf: "sources" }],
|
|
12423
|
+
["wraps", ["u32"]],
|
|
12424
|
+
["wrapsLen", "u32", { lengthOf: "wraps" }],
|
|
12425
|
+
["widthColsMax", "u32"]
|
|
12426
|
+
]);
|
|
12427
|
+
var MeasureResultStruct = defineStruct([
|
|
12428
|
+
["lineCount", "u32"],
|
|
12429
|
+
["widthColsMax", "u32"]
|
|
12430
|
+
]);
|
|
12431
|
+
var CursorStateStruct = defineStruct([
|
|
12432
|
+
["x", "u32"],
|
|
12433
|
+
["y", "u32"],
|
|
12434
|
+
["visible", "bool_u8"],
|
|
12435
|
+
["style", "u8"],
|
|
12436
|
+
["blinking", "bool_u8"],
|
|
12437
|
+
["r", "f32"],
|
|
12438
|
+
["g", "f32"],
|
|
12439
|
+
["b", "f32"],
|
|
12440
|
+
["a", "f32"]
|
|
12441
|
+
]);
|
|
12442
|
+
var CursorStyleOptionsStruct = defineStruct([
|
|
12443
|
+
["style", "u8", { default: 255 }],
|
|
12444
|
+
["blinking", "u8", { default: 255 }],
|
|
12445
|
+
[
|
|
12446
|
+
"color",
|
|
12447
|
+
"pointer",
|
|
12448
|
+
{
|
|
12449
|
+
optional: true,
|
|
12450
|
+
packTransform: rgbaPackTransform,
|
|
12451
|
+
unpackTransform: rgbaUnpackTransform
|
|
12452
|
+
}
|
|
12453
|
+
],
|
|
12454
|
+
["cursor", "u8", { default: 255 }]
|
|
12455
|
+
]);
|
|
12456
|
+
var GridDrawOptionsStruct = defineStruct([
|
|
12457
|
+
["drawInner", "bool_u8", { default: true }],
|
|
12458
|
+
["drawOuter", "bool_u8", { default: true }]
|
|
12459
|
+
]);
|
|
12460
|
+
var BuildOptionsStruct = defineStruct([
|
|
12461
|
+
["gpaSafeStats", "bool_u8"],
|
|
12462
|
+
["gpaMemoryLimitTracking", "bool_u8"]
|
|
12463
|
+
]);
|
|
12464
|
+
var AllocatorStatsStruct = defineStruct([
|
|
12465
|
+
["totalRequestedBytes", "u64"],
|
|
12466
|
+
["activeAllocations", "u64"],
|
|
12467
|
+
["smallAllocations", "u64"],
|
|
12468
|
+
["largeAllocations", "u64"],
|
|
12469
|
+
["requestedBytesValid", "bool_u8"]
|
|
12470
|
+
]);
|
|
12471
|
+
var GrowthPolicyEnum = defineEnum({ grow: 0, block: 1 }, "u8");
|
|
12472
|
+
var NativeSpanFeedOptionsStruct = defineStruct([
|
|
12473
|
+
["chunkSize", "u32", { default: 64 * 1024 }],
|
|
12474
|
+
["initialChunks", "u32", { default: 2 }],
|
|
12475
|
+
["maxBytes", "u64", { default: 0n }],
|
|
12476
|
+
["growthPolicy", GrowthPolicyEnum, { default: "grow" }],
|
|
12477
|
+
["autoCommitOnFull", "bool_u8", { default: true }],
|
|
12478
|
+
["spanQueueCapacity", "u32", { default: 0 }]
|
|
12479
|
+
]);
|
|
12480
|
+
var NativeSpanFeedStatsStruct = defineStruct([
|
|
12481
|
+
["bytesWritten", "u64"],
|
|
12482
|
+
["spansCommitted", "u64"],
|
|
12483
|
+
["chunks", "u32"],
|
|
12484
|
+
["pendingSpans", "u32"]
|
|
12485
|
+
]);
|
|
12486
|
+
var SpanInfoStruct = defineStruct([
|
|
12487
|
+
["chunkPtr", "pointer"],
|
|
12488
|
+
["offset", "u32"],
|
|
12489
|
+
["len", "u32"],
|
|
12490
|
+
["chunkIndex", "u32"],
|
|
12491
|
+
["reserved", "u32", { default: 0 }]
|
|
12492
|
+
], {
|
|
12493
|
+
reduceValue: (value) => ({
|
|
12494
|
+
chunkPtr: value.chunkPtr,
|
|
12495
|
+
offset: value.offset,
|
|
12496
|
+
len: value.len,
|
|
12497
|
+
chunkIndex: value.chunkIndex
|
|
12498
|
+
})
|
|
12499
|
+
});
|
|
12500
|
+
var ReserveInfoStruct = defineStruct([
|
|
12501
|
+
["ptr", "pointer"],
|
|
12502
|
+
["len", "u32"],
|
|
12503
|
+
["reserved", "u32", { default: 0 }]
|
|
12504
|
+
], {
|
|
12505
|
+
reduceValue: (value) => ({
|
|
12506
|
+
ptr: value.ptr,
|
|
12507
|
+
len: value.len
|
|
12508
|
+
})
|
|
12509
|
+
});
|
|
12272
12510
|
|
|
12273
12511
|
// src/zig.ts
|
|
12274
12512
|
var module = await import(`@opentui/core-${process.platform}-${process.arch}/index.ts`);
|
|
@@ -12321,19 +12559,18 @@ var MOUSE_STYLE_TO_ID = { default: 0, pointer: 1, text: 2, crosshair: 3, move: 4
|
|
|
12321
12559
|
var globalTraceSymbols = null;
|
|
12322
12560
|
var globalFFILogPath = null;
|
|
12323
12561
|
var exitHandlerRegistered = false;
|
|
12324
|
-
var toPointer2 = toPointer;
|
|
12325
12562
|
function toNumber(value) {
|
|
12326
12563
|
return typeof value === "bigint" ? Number(value) : value;
|
|
12327
12564
|
}
|
|
12328
12565
|
function rgbaPtr(value) {
|
|
12329
|
-
return
|
|
12566
|
+
return ptr(value.buffer);
|
|
12330
12567
|
}
|
|
12331
12568
|
function optionalRgbaPtr(value) {
|
|
12332
12569
|
return value ? rgbaPtr(value) : null;
|
|
12333
12570
|
}
|
|
12334
12571
|
function getOpenTUILib(libPath) {
|
|
12335
12572
|
const resolvedLibPath = libPath || targetLibPath;
|
|
12336
|
-
const rawSymbols =
|
|
12573
|
+
const rawSymbols = dlopen(resolvedLibPath, {
|
|
12337
12574
|
setLogCallback: {
|
|
12338
12575
|
args: ["ptr"],
|
|
12339
12576
|
returns: "void"
|
|
@@ -13345,6 +13582,7 @@ function getOpenTUILib(libPath) {
|
|
|
13345
13582
|
});
|
|
13346
13583
|
if (env.OTUI_DEBUG_FFI || env.OTUI_TRACE_FFI) {
|
|
13347
13584
|
return {
|
|
13585
|
+
...rawSymbols,
|
|
13348
13586
|
symbols: convertToDebugSymbols(rawSymbols.symbols)
|
|
13349
13587
|
};
|
|
13350
13588
|
}
|
|
@@ -13473,7 +13711,9 @@ function convertToDebugSymbols(symbols) {
|
|
|
13473
13711
|
const now = new Date;
|
|
13474
13712
|
const timestamp = now.toISOString().replace(/[:.]/g, "-").replace(/T/, "_").split("Z")[0];
|
|
13475
13713
|
const traceFilePath = `ffi_otui_trace_${timestamp}.log`;
|
|
13476
|
-
|
|
13714
|
+
writeFile3(traceFilePath, output).catch((error) => {
|
|
13715
|
+
console.error("Failed to write FFI trace file:", error);
|
|
13716
|
+
});
|
|
13477
13717
|
} catch (e) {
|
|
13478
13718
|
console.error("Failed to write FFI trace file:", e);
|
|
13479
13719
|
}
|
|
@@ -13494,8 +13734,8 @@ class FFIRenderLib {
|
|
|
13494
13734
|
opentui;
|
|
13495
13735
|
encoder = new TextEncoder;
|
|
13496
13736
|
decoder = new TextDecoder;
|
|
13497
|
-
logCallbackWrapper;
|
|
13498
|
-
eventCallbackWrapper;
|
|
13737
|
+
logCallbackWrapper = null;
|
|
13738
|
+
eventCallbackWrapper = null;
|
|
13499
13739
|
_nativeEvents = new EventEmitter4;
|
|
13500
13740
|
_anyEventHandlers = [];
|
|
13501
13741
|
nativeSpanFeedCallbackWrapper = null;
|
|
@@ -13509,13 +13749,13 @@ class FFIRenderLib {
|
|
|
13509
13749
|
if (this.logCallbackWrapper) {
|
|
13510
13750
|
return;
|
|
13511
13751
|
}
|
|
13512
|
-
const logCallback =
|
|
13752
|
+
const logCallback = this.opentui.createCallback((level, msgPtr, msgLenBigInt) => {
|
|
13513
13753
|
try {
|
|
13514
13754
|
const msgLen = typeof msgLenBigInt === "bigint" ? Number(msgLenBigInt) : msgLenBigInt;
|
|
13515
13755
|
if (msgLen === 0 || !msgPtr) {
|
|
13516
13756
|
return;
|
|
13517
13757
|
}
|
|
13518
|
-
const msgBuffer =
|
|
13758
|
+
const msgBuffer = toArrayBuffer(msgPtr, 0, msgLen);
|
|
13519
13759
|
const msgBytes = new Uint8Array(msgBuffer);
|
|
13520
13760
|
const message = this.decoder.decode(msgBytes);
|
|
13521
13761
|
switch (level) {
|
|
@@ -13554,19 +13794,19 @@ class FFIRenderLib {
|
|
|
13554
13794
|
if (this.eventCallbackWrapper) {
|
|
13555
13795
|
return;
|
|
13556
13796
|
}
|
|
13557
|
-
const eventCallback =
|
|
13797
|
+
const eventCallback = this.opentui.createCallback((namePtr, nameLenBigInt, dataPtr, dataLenBigInt) => {
|
|
13558
13798
|
try {
|
|
13559
13799
|
const nameLen = typeof nameLenBigInt === "bigint" ? Number(nameLenBigInt) : nameLenBigInt;
|
|
13560
13800
|
const dataLen = typeof dataLenBigInt === "bigint" ? Number(dataLenBigInt) : dataLenBigInt;
|
|
13561
13801
|
if (nameLen === 0 || !namePtr) {
|
|
13562
13802
|
return;
|
|
13563
13803
|
}
|
|
13564
|
-
const nameBuffer =
|
|
13804
|
+
const nameBuffer = toArrayBuffer(namePtr, 0, nameLen);
|
|
13565
13805
|
const nameBytes = new Uint8Array(nameBuffer);
|
|
13566
13806
|
const eventName = this.decoder.decode(nameBytes);
|
|
13567
13807
|
let eventData;
|
|
13568
13808
|
if (dataLen > 0 && dataPtr) {
|
|
13569
|
-
eventData =
|
|
13809
|
+
eventData = toArrayBuffer(dataPtr, 0, dataLen).slice();
|
|
13570
13810
|
} else {
|
|
13571
13811
|
eventData = new ArrayBuffer(0);
|
|
13572
13812
|
}
|
|
@@ -13593,8 +13833,8 @@ class FFIRenderLib {
|
|
|
13593
13833
|
if (this.nativeSpanFeedCallbackWrapper) {
|
|
13594
13834
|
return this.nativeSpanFeedCallbackWrapper;
|
|
13595
13835
|
}
|
|
13596
|
-
const callback =
|
|
13597
|
-
const handler = this.nativeSpanFeedHandlers.get(
|
|
13836
|
+
const callback = this.opentui.createCallback((streamPtr, eventId, arg0, arg1) => {
|
|
13837
|
+
const handler = this.nativeSpanFeedHandlers.get(streamPtr);
|
|
13598
13838
|
if (handler) {
|
|
13599
13839
|
handler(eventId, arg0, arg1);
|
|
13600
13840
|
}
|
|
@@ -13614,7 +13854,7 @@ class FFIRenderLib {
|
|
|
13614
13854
|
createRenderer(width, height, options = {}) {
|
|
13615
13855
|
const testing = options.testing ?? false;
|
|
13616
13856
|
const remote = options.remote ?? false;
|
|
13617
|
-
return this.opentui.symbols.createRenderer(width, height, testing, remote);
|
|
13857
|
+
return this.opentui.symbols.createRenderer(width, height, ffiBool(testing), ffiBool(remote));
|
|
13618
13858
|
}
|
|
13619
13859
|
setTerminalEnvVar(renderer, key, value) {
|
|
13620
13860
|
const keyBytes = this.encoder.encode(key);
|
|
@@ -13625,10 +13865,10 @@ class FFIRenderLib {
|
|
|
13625
13865
|
this.opentui.symbols.destroyRenderer(renderer);
|
|
13626
13866
|
}
|
|
13627
13867
|
setUseThread(renderer, useThread) {
|
|
13628
|
-
this.opentui.symbols.setUseThread(renderer, useThread);
|
|
13868
|
+
this.opentui.symbols.setUseThread(renderer, ffiBool(useThread));
|
|
13629
13869
|
}
|
|
13630
13870
|
setClearOnShutdown(renderer, clear) {
|
|
13631
|
-
this.opentui.symbols.setClearOnShutdown(renderer, clear);
|
|
13871
|
+
this.opentui.symbols.setClearOnShutdown(renderer, ffiBool(clear));
|
|
13632
13872
|
}
|
|
13633
13873
|
setBackgroundColor(renderer, color) {
|
|
13634
13874
|
this.opentui.symbols.setBackgroundColor(renderer, rgbaPtr(color));
|
|
@@ -13677,41 +13917,41 @@ class FFIRenderLib {
|
|
|
13677
13917
|
for (let index = 0;index < palette.length; index++) {
|
|
13678
13918
|
paletteBuffer.set(palette[index].buffer, index * 4);
|
|
13679
13919
|
}
|
|
13680
|
-
this.opentui.symbols.rendererSetPaletteState(renderer,
|
|
13920
|
+
this.opentui.symbols.rendererSetPaletteState(renderer, ptr(paletteBuffer), palette.length, rgbaPtr(defaultForeground), rgbaPtr(defaultBackground), paletteEpoch >>> 0);
|
|
13681
13921
|
}
|
|
13682
13922
|
bufferGetCharPtr(buffer) {
|
|
13683
|
-
const
|
|
13684
|
-
if (!
|
|
13923
|
+
const ptr3 = this.opentui.symbols.bufferGetCharPtr(buffer);
|
|
13924
|
+
if (!ptr3) {
|
|
13685
13925
|
throw new Error("Failed to get char pointer");
|
|
13686
13926
|
}
|
|
13687
|
-
return
|
|
13927
|
+
return ptr3;
|
|
13688
13928
|
}
|
|
13689
13929
|
bufferGetFgPtr(buffer) {
|
|
13690
|
-
const
|
|
13691
|
-
if (!
|
|
13930
|
+
const ptr3 = this.opentui.symbols.bufferGetFgPtr(buffer);
|
|
13931
|
+
if (!ptr3) {
|
|
13692
13932
|
throw new Error("Failed to get fg pointer");
|
|
13693
13933
|
}
|
|
13694
|
-
return
|
|
13934
|
+
return ptr3;
|
|
13695
13935
|
}
|
|
13696
13936
|
bufferGetBgPtr(buffer) {
|
|
13697
|
-
const
|
|
13698
|
-
if (!
|
|
13937
|
+
const ptr3 = this.opentui.symbols.bufferGetBgPtr(buffer);
|
|
13938
|
+
if (!ptr3) {
|
|
13699
13939
|
throw new Error("Failed to get bg pointer");
|
|
13700
13940
|
}
|
|
13701
|
-
return
|
|
13941
|
+
return ptr3;
|
|
13702
13942
|
}
|
|
13703
13943
|
bufferGetAttributesPtr(buffer) {
|
|
13704
|
-
const
|
|
13705
|
-
if (!
|
|
13944
|
+
const ptr3 = this.opentui.symbols.bufferGetAttributesPtr(buffer);
|
|
13945
|
+
if (!ptr3) {
|
|
13706
13946
|
throw new Error("Failed to get attributes pointer");
|
|
13707
13947
|
}
|
|
13708
|
-
return
|
|
13948
|
+
return ptr3;
|
|
13709
13949
|
}
|
|
13710
13950
|
bufferGetRespectAlpha(buffer) {
|
|
13711
13951
|
return this.opentui.symbols.bufferGetRespectAlpha(buffer);
|
|
13712
13952
|
}
|
|
13713
13953
|
bufferSetRespectAlpha(buffer, respectAlpha) {
|
|
13714
|
-
this.opentui.symbols.bufferSetRespectAlpha(buffer, respectAlpha);
|
|
13954
|
+
this.opentui.symbols.bufferSetRespectAlpha(buffer, ffiBool(respectAlpha));
|
|
13715
13955
|
}
|
|
13716
13956
|
bufferGetId(buffer) {
|
|
13717
13957
|
const maxLen = 256;
|
|
@@ -13724,7 +13964,7 @@ class FFIRenderLib {
|
|
|
13724
13964
|
return this.opentui.symbols.bufferGetRealCharSize(buffer);
|
|
13725
13965
|
}
|
|
13726
13966
|
bufferWriteResolvedChars(buffer, outputBuffer, addLineBreaks) {
|
|
13727
|
-
const bytesWritten = this.opentui.symbols.bufferWriteResolvedChars(buffer, outputBuffer, outputBuffer.length, addLineBreaks);
|
|
13967
|
+
const bytesWritten = this.opentui.symbols.bufferWriteResolvedChars(buffer, outputBuffer, outputBuffer.length, ffiBool(addLineBreaks));
|
|
13728
13968
|
return typeof bytesWritten === "bigint" ? Number(bytesWritten) : bytesWritten;
|
|
13729
13969
|
}
|
|
13730
13970
|
getBufferWidth(buffer) {
|
|
@@ -13783,7 +14023,7 @@ class FFIRenderLib {
|
|
|
13783
14023
|
drawInner: options.drawInner,
|
|
13784
14024
|
drawOuter: options.drawOuter
|
|
13785
14025
|
});
|
|
13786
|
-
this.opentui.symbols.bufferDrawGrid(buffer, borderChars, rgbaPtr(borderFg), rgbaPtr(borderBg), columnOffsets, columnCount, rowOffsets, rowCount,
|
|
14026
|
+
this.opentui.symbols.bufferDrawGrid(buffer, borderChars, rgbaPtr(borderFg), rgbaPtr(borderBg), columnOffsets, columnCount, rowOffsets, rowCount, ptr(optionsBuffer));
|
|
13787
14027
|
}
|
|
13788
14028
|
bufferDrawBox(buffer, x, y, width, height, borderChars, packedOptions, borderColor, backgroundColor, title, bottomTitle) {
|
|
13789
14029
|
const titleBytes = title ? this.encoder.encode(title) : null;
|
|
@@ -13816,14 +14056,14 @@ class FFIRenderLib {
|
|
|
13816
14056
|
this.opentui.symbols.resizeRenderer(renderer, width, height);
|
|
13817
14057
|
}
|
|
13818
14058
|
setCursorPosition(renderer, x, y, visible) {
|
|
13819
|
-
this.opentui.symbols.setCursorPosition(renderer, x, y, visible);
|
|
14059
|
+
this.opentui.symbols.setCursorPosition(renderer, x, y, ffiBool(visible));
|
|
13820
14060
|
}
|
|
13821
14061
|
setCursorColor(renderer, color) {
|
|
13822
14062
|
this.opentui.symbols.setCursorColor(renderer, rgbaPtr(color));
|
|
13823
14063
|
}
|
|
13824
14064
|
getCursorState(renderer) {
|
|
13825
14065
|
const cursorBuffer = new ArrayBuffer(CursorStateStruct.size);
|
|
13826
|
-
this.opentui.symbols.getCursorState(renderer,
|
|
14066
|
+
this.opentui.symbols.getCursorState(renderer, ptr(cursorBuffer));
|
|
13827
14067
|
const struct = CursorStateStruct.unpack(cursorBuffer);
|
|
13828
14068
|
return {
|
|
13829
14069
|
x: struct.x,
|
|
@@ -13839,16 +14079,16 @@ class FFIRenderLib {
|
|
|
13839
14079
|
const blinking = options.blinking != null ? options.blinking ? 1 : 0 : 255;
|
|
13840
14080
|
const cursor = options.cursor != null ? MOUSE_STYLE_TO_ID[options.cursor] : 255;
|
|
13841
14081
|
const buffer = CursorStyleOptionsStruct.pack({ style, blinking, color: options.color, cursor });
|
|
13842
|
-
this.opentui.symbols.setCursorStyleOptions(renderer,
|
|
14082
|
+
this.opentui.symbols.setCursorStyleOptions(renderer, ptr(buffer));
|
|
13843
14083
|
}
|
|
13844
14084
|
render(renderer, force) {
|
|
13845
|
-
this.opentui.symbols.render(renderer, force);
|
|
14085
|
+
this.opentui.symbols.render(renderer, ffiBool(force));
|
|
13846
14086
|
}
|
|
13847
14087
|
repaintSplitFooter(renderer, pinnedRenderOffset, force) {
|
|
13848
|
-
return this.opentui.symbols.repaintSplitFooter(renderer, pinnedRenderOffset, force);
|
|
14088
|
+
return this.opentui.symbols.repaintSplitFooter(renderer, pinnedRenderOffset, ffiBool(force));
|
|
13849
14089
|
}
|
|
13850
14090
|
commitSplitFooterSnapshot(renderer, snapshot, rowColumns, startOnNewLine, trailingNewline, pinnedRenderOffset, force, beginFrame = true, finalizeFrame = true) {
|
|
13851
|
-
return this.opentui.symbols.commitSplitFooterSnapshot(renderer, snapshot.ptr, rowColumns, startOnNewLine, trailingNewline, pinnedRenderOffset, force, beginFrame, finalizeFrame);
|
|
14091
|
+
return this.opentui.symbols.commitSplitFooterSnapshot(renderer, snapshot.ptr, rowColumns, ffiBool(startOnNewLine), ffiBool(trailingNewline), pinnedRenderOffset, ffiBool(force), ffiBool(beginFrame), ffiBool(finalizeFrame));
|
|
13852
14092
|
}
|
|
13853
14093
|
createOptimizedBuffer(width, height, widthMethod, respectAlpha = false, id) {
|
|
13854
14094
|
if (Number.isNaN(width) || Number.isNaN(height)) {
|
|
@@ -13857,7 +14097,7 @@ class FFIRenderLib {
|
|
|
13857
14097
|
const widthMethodCode = widthMethod === "wcwidth" ? 0 : 1;
|
|
13858
14098
|
const idToUse = id || "unnamed buffer";
|
|
13859
14099
|
const idBytes = this.encoder.encode(idToUse);
|
|
13860
|
-
const bufferPtr = this.opentui.symbols.createOptimizedBuffer(width, height, respectAlpha, widthMethodCode, idBytes, idBytes.length);
|
|
14100
|
+
const bufferPtr = this.opentui.symbols.createOptimizedBuffer(width, height, ffiBool(respectAlpha), widthMethodCode, idBytes, idBytes.length);
|
|
13861
14101
|
if (!bufferPtr) {
|
|
13862
14102
|
throw new Error(`Failed to create optimized buffer: ${width}x${height}`);
|
|
13863
14103
|
}
|
|
@@ -13874,7 +14114,7 @@ class FFIRenderLib {
|
|
|
13874
14114
|
this.opentui.symbols.drawFrameBuffer(targetBufferPtr, destX, destY, bufferPtr, srcX, srcY, srcWidth, srcHeight);
|
|
13875
14115
|
}
|
|
13876
14116
|
setDebugOverlay(renderer, enabled, corner) {
|
|
13877
|
-
this.opentui.symbols.setDebugOverlay(renderer, enabled, corner);
|
|
14117
|
+
this.opentui.symbols.setDebugOverlay(renderer, ffiBool(enabled), corner);
|
|
13878
14118
|
}
|
|
13879
14119
|
clearTerminal(renderer) {
|
|
13880
14120
|
this.opentui.symbols.clearTerminal(renderer);
|
|
@@ -13928,7 +14168,7 @@ class FFIRenderLib {
|
|
|
13928
14168
|
this.opentui.symbols.restoreTerminalModes(renderer);
|
|
13929
14169
|
}
|
|
13930
14170
|
enableMouse(renderer, enableMovement) {
|
|
13931
|
-
this.opentui.symbols.enableMouse(renderer, enableMovement);
|
|
14171
|
+
this.opentui.symbols.enableMouse(renderer, ffiBool(enableMovement));
|
|
13932
14172
|
}
|
|
13933
14173
|
disableMouse(renderer) {
|
|
13934
14174
|
this.opentui.symbols.disableMouse(renderer);
|
|
@@ -13946,7 +14186,7 @@ class FFIRenderLib {
|
|
|
13946
14186
|
return this.opentui.symbols.getKittyKeyboardFlags(renderer);
|
|
13947
14187
|
}
|
|
13948
14188
|
setupTerminal(renderer, useAlternateScreen) {
|
|
13949
|
-
this.opentui.symbols.setupTerminal(renderer, useAlternateScreen);
|
|
14189
|
+
this.opentui.symbols.setupTerminal(renderer, ffiBool(useAlternateScreen));
|
|
13950
14190
|
}
|
|
13951
14191
|
suspendRenderer(renderer) {
|
|
13952
14192
|
this.opentui.symbols.suspendRenderer(renderer);
|
|
@@ -13964,7 +14204,7 @@ class FFIRenderLib {
|
|
|
13964
14204
|
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
13965
14205
|
if (bytes.length === 0)
|
|
13966
14206
|
return;
|
|
13967
|
-
this.opentui.symbols.writeOut(renderer,
|
|
14207
|
+
this.opentui.symbols.writeOut(renderer, ptr(bytes), bytes.length);
|
|
13968
14208
|
}
|
|
13969
14209
|
createTextBuffer(widthMethod) {
|
|
13970
14210
|
const widthMethodCode = widthMethod === "wcwidth" ? 0 : 1;
|
|
@@ -14011,14 +14251,14 @@ class FFIRenderLib {
|
|
|
14011
14251
|
this.opentui.symbols.textBufferSetTabWidth(buffer, width);
|
|
14012
14252
|
}
|
|
14013
14253
|
textBufferRegisterMemBuffer(buffer, bytes, owned = false) {
|
|
14014
|
-
const result = this.opentui.symbols.textBufferRegisterMemBuffer(buffer, bytes, bytes.length, owned);
|
|
14254
|
+
const result = this.opentui.symbols.textBufferRegisterMemBuffer(buffer, bytes, bytes.length, ffiBool(owned));
|
|
14015
14255
|
if (result === 65535) {
|
|
14016
14256
|
throw new Error("Failed to register memory buffer");
|
|
14017
14257
|
}
|
|
14018
14258
|
return result;
|
|
14019
14259
|
}
|
|
14020
14260
|
textBufferReplaceMemBuffer(buffer, memId, bytes, owned = false) {
|
|
14021
|
-
return this.opentui.symbols.textBufferReplaceMemBuffer(buffer, memId, bytes, bytes.length, owned);
|
|
14261
|
+
return this.opentui.symbols.textBufferReplaceMemBuffer(buffer, memId, bytes, bytes.length, ffiBool(owned));
|
|
14022
14262
|
}
|
|
14023
14263
|
textBufferClearMemRegistry(buffer) {
|
|
14024
14264
|
this.opentui.symbols.textBufferClearMemRegistry(buffer);
|
|
@@ -14042,7 +14282,7 @@ class FFIRenderLib {
|
|
|
14042
14282
|
return;
|
|
14043
14283
|
}
|
|
14044
14284
|
const chunksBuffer = StyledChunkStruct.packList(chunks);
|
|
14045
|
-
this.opentui.symbols.textBufferSetStyledText(buffer,
|
|
14285
|
+
this.opentui.symbols.textBufferSetStyledText(buffer, ptr(chunksBuffer), chunks.length);
|
|
14046
14286
|
}
|
|
14047
14287
|
textBufferGetLineCount(buffer) {
|
|
14048
14288
|
return this.opentui.symbols.textBufferGetLineCount(buffer);
|
|
@@ -14053,7 +14293,7 @@ class FFIRenderLib {
|
|
|
14053
14293
|
}
|
|
14054
14294
|
getPlainTextBytes(buffer, maxLength) {
|
|
14055
14295
|
const outBuffer = new Uint8Array(maxLength);
|
|
14056
|
-
const actualLen = this.textBufferGetPlainText(buffer,
|
|
14296
|
+
const actualLen = this.textBufferGetPlainText(buffer, ptr(outBuffer), maxLength);
|
|
14057
14297
|
if (actualLen === 0) {
|
|
14058
14298
|
return null;
|
|
14059
14299
|
}
|
|
@@ -14061,7 +14301,7 @@ class FFIRenderLib {
|
|
|
14061
14301
|
}
|
|
14062
14302
|
textBufferGetTextRange(buffer, startOffset, endOffset, maxLength) {
|
|
14063
14303
|
const outBuffer = new Uint8Array(maxLength);
|
|
14064
|
-
const actualLen = this.opentui.symbols.textBufferGetTextRange(buffer, startOffset, endOffset,
|
|
14304
|
+
const actualLen = this.opentui.symbols.textBufferGetTextRange(buffer, startOffset, endOffset, ptr(outBuffer), maxLength);
|
|
14065
14305
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
14066
14306
|
if (len === 0) {
|
|
14067
14307
|
return null;
|
|
@@ -14070,7 +14310,7 @@ class FFIRenderLib {
|
|
|
14070
14310
|
}
|
|
14071
14311
|
textBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, maxLength) {
|
|
14072
14312
|
const outBuffer = new Uint8Array(maxLength);
|
|
14073
|
-
const actualLen = this.opentui.symbols.textBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol,
|
|
14313
|
+
const actualLen = this.opentui.symbols.textBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, ptr(outBuffer), maxLength);
|
|
14074
14314
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
14075
14315
|
if (len === 0) {
|
|
14076
14316
|
return null;
|
|
@@ -14143,7 +14383,7 @@ class FFIRenderLib {
|
|
|
14143
14383
|
}
|
|
14144
14384
|
textBufferViewGetLineInfo(view) {
|
|
14145
14385
|
const outBuffer = new ArrayBuffer(LineInfoStruct.size);
|
|
14146
|
-
this.textBufferViewGetLineInfoDirect(view,
|
|
14386
|
+
this.textBufferViewGetLineInfoDirect(view, ptr(outBuffer));
|
|
14147
14387
|
const struct = LineInfoStruct.unpack(outBuffer);
|
|
14148
14388
|
const lineStartCols = struct.startCols;
|
|
14149
14389
|
const lineWidthCols = struct.widthCols;
|
|
@@ -14158,7 +14398,7 @@ class FFIRenderLib {
|
|
|
14158
14398
|
}
|
|
14159
14399
|
textBufferViewGetLogicalLineInfo(view) {
|
|
14160
14400
|
const outBuffer = new ArrayBuffer(LineInfoStruct.size);
|
|
14161
|
-
this.textBufferViewGetLogicalLineInfoDirect(view,
|
|
14401
|
+
this.textBufferViewGetLogicalLineInfoDirect(view, ptr(outBuffer));
|
|
14162
14402
|
const struct = LineInfoStruct.unpack(outBuffer);
|
|
14163
14403
|
const lineStartCols = struct.startCols;
|
|
14164
14404
|
const lineWidthCols = struct.widthCols;
|
|
@@ -14190,7 +14430,7 @@ class FFIRenderLib {
|
|
|
14190
14430
|
}
|
|
14191
14431
|
textBufferViewGetSelectedTextBytes(view, maxLength) {
|
|
14192
14432
|
const outBuffer = new Uint8Array(maxLength);
|
|
14193
|
-
const actualLen = this.textBufferViewGetSelectedText(view,
|
|
14433
|
+
const actualLen = this.textBufferViewGetSelectedText(view, ptr(outBuffer), maxLength);
|
|
14194
14434
|
if (actualLen === 0) {
|
|
14195
14435
|
return null;
|
|
14196
14436
|
}
|
|
@@ -14198,7 +14438,7 @@ class FFIRenderLib {
|
|
|
14198
14438
|
}
|
|
14199
14439
|
textBufferViewGetPlainTextBytes(view, maxLength) {
|
|
14200
14440
|
const outBuffer = new Uint8Array(maxLength);
|
|
14201
|
-
const actualLen = this.textBufferViewGetPlainText(view,
|
|
14441
|
+
const actualLen = this.textBufferViewGetPlainText(view, ptr(outBuffer), maxLength);
|
|
14202
14442
|
if (actualLen === 0) {
|
|
14203
14443
|
return null;
|
|
14204
14444
|
}
|
|
@@ -14211,11 +14451,11 @@ class FFIRenderLib {
|
|
|
14211
14451
|
this.opentui.symbols.textBufferViewSetTabIndicatorColor(view, rgbaPtr(color));
|
|
14212
14452
|
}
|
|
14213
14453
|
textBufferViewSetTruncate(view, truncate) {
|
|
14214
|
-
this.opentui.symbols.textBufferViewSetTruncate(view, truncate);
|
|
14454
|
+
this.opentui.symbols.textBufferViewSetTruncate(view, ffiBool(truncate));
|
|
14215
14455
|
}
|
|
14216
14456
|
textBufferViewMeasureForDimensions(view, width, height) {
|
|
14217
14457
|
const resultBuffer = new ArrayBuffer(MeasureResultStruct.size);
|
|
14218
|
-
const resultPtr =
|
|
14458
|
+
const resultPtr = ptr(new Uint8Array(resultBuffer));
|
|
14219
14459
|
const success = this.opentui.symbols.textBufferViewMeasureForDimensions(view, width, height, resultPtr);
|
|
14220
14460
|
if (!success) {
|
|
14221
14461
|
return null;
|
|
@@ -14225,11 +14465,11 @@ class FFIRenderLib {
|
|
|
14225
14465
|
}
|
|
14226
14466
|
textBufferAddHighlightByCharRange(buffer, highlight) {
|
|
14227
14467
|
const packedHighlight = HighlightStruct.pack(highlight);
|
|
14228
|
-
this.opentui.symbols.textBufferAddHighlightByCharRange(buffer,
|
|
14468
|
+
this.opentui.symbols.textBufferAddHighlightByCharRange(buffer, ptr(packedHighlight));
|
|
14229
14469
|
}
|
|
14230
14470
|
textBufferAddHighlight(buffer, lineIdx, highlight) {
|
|
14231
14471
|
const packedHighlight = HighlightStruct.pack(highlight);
|
|
14232
|
-
this.opentui.symbols.textBufferAddHighlight(buffer, lineIdx,
|
|
14472
|
+
this.opentui.symbols.textBufferAddHighlight(buffer, lineIdx, ptr(packedHighlight));
|
|
14233
14473
|
}
|
|
14234
14474
|
textBufferRemoveHighlightsByRef(buffer, hlRef) {
|
|
14235
14475
|
this.opentui.symbols.textBufferRemoveHighlightsByRef(buffer, hlRef);
|
|
@@ -14245,12 +14485,12 @@ class FFIRenderLib {
|
|
|
14245
14485
|
}
|
|
14246
14486
|
textBufferGetLineHighlights(buffer, lineIdx) {
|
|
14247
14487
|
const outCountBuf = new BigUint64Array(1);
|
|
14248
|
-
const nativePtr = this.opentui.symbols.textBufferGetLineHighlightsPtr(buffer, lineIdx,
|
|
14488
|
+
const nativePtr = this.opentui.symbols.textBufferGetLineHighlightsPtr(buffer, lineIdx, ptr(outCountBuf));
|
|
14249
14489
|
if (!nativePtr)
|
|
14250
14490
|
return [];
|
|
14251
14491
|
const count = Number(outCountBuf[0]);
|
|
14252
14492
|
const byteLen = count * HighlightStruct.size;
|
|
14253
|
-
const raw =
|
|
14493
|
+
const raw = toArrayBuffer(nativePtr, 0, byteLen);
|
|
14254
14494
|
const results = HighlightStruct.unpackList(raw, count);
|
|
14255
14495
|
this.opentui.symbols.textBufferFreeLineHighlights(nativePtr, count);
|
|
14256
14496
|
return results;
|
|
@@ -14264,7 +14504,7 @@ class FFIRenderLib {
|
|
|
14264
14504
|
}
|
|
14265
14505
|
getBuildOptions() {
|
|
14266
14506
|
const optionsBuffer = new ArrayBuffer(BuildOptionsStruct.size);
|
|
14267
|
-
this.opentui.symbols.getBuildOptions(
|
|
14507
|
+
this.opentui.symbols.getBuildOptions(ptr(optionsBuffer));
|
|
14268
14508
|
const options = BuildOptionsStruct.unpack(optionsBuffer);
|
|
14269
14509
|
return {
|
|
14270
14510
|
gpaSafeStats: !!options.gpaSafeStats,
|
|
@@ -14273,7 +14513,7 @@ class FFIRenderLib {
|
|
|
14273
14513
|
}
|
|
14274
14514
|
getAllocatorStats() {
|
|
14275
14515
|
const statsBuffer = new ArrayBuffer(AllocatorStatsStruct.size);
|
|
14276
|
-
this.opentui.symbols.getAllocatorStats(
|
|
14516
|
+
this.opentui.symbols.getAllocatorStats(ptr(statsBuffer));
|
|
14277
14517
|
const stats = AllocatorStatsStruct.unpack(statsBuffer);
|
|
14278
14518
|
return {
|
|
14279
14519
|
totalRequestedBytes: toNumber(stats.totalRequestedBytes),
|
|
@@ -14303,14 +14543,14 @@ class FFIRenderLib {
|
|
|
14303
14543
|
this.opentui.symbols.editorViewSetViewportSize(view, width, height);
|
|
14304
14544
|
}
|
|
14305
14545
|
editorViewSetViewport(view, x, y, width, height, moveCursor) {
|
|
14306
|
-
this.opentui.symbols.editorViewSetViewport(view, x, y, width, height, moveCursor);
|
|
14546
|
+
this.opentui.symbols.editorViewSetViewport(view, x, y, width, height, ffiBool(moveCursor));
|
|
14307
14547
|
}
|
|
14308
14548
|
editorViewGetViewport(view) {
|
|
14309
14549
|
const x = new Uint32Array(1);
|
|
14310
14550
|
const y = new Uint32Array(1);
|
|
14311
14551
|
const width = new Uint32Array(1);
|
|
14312
14552
|
const height = new Uint32Array(1);
|
|
14313
|
-
this.opentui.symbols.editorViewGetViewport(view,
|
|
14553
|
+
this.opentui.symbols.editorViewGetViewport(view, ptr(x), ptr(y), ptr(width), ptr(height));
|
|
14314
14554
|
return {
|
|
14315
14555
|
offsetX: x[0],
|
|
14316
14556
|
offsetY: y[0],
|
|
@@ -14340,7 +14580,7 @@ class FFIRenderLib {
|
|
|
14340
14580
|
}
|
|
14341
14581
|
editorViewGetLineInfo(view) {
|
|
14342
14582
|
const outBuffer = new ArrayBuffer(LineInfoStruct.size);
|
|
14343
|
-
this.opentui.symbols.editorViewGetLineInfoDirect(view,
|
|
14583
|
+
this.opentui.symbols.editorViewGetLineInfoDirect(view, ptr(outBuffer));
|
|
14344
14584
|
const struct = LineInfoStruct.unpack(outBuffer);
|
|
14345
14585
|
const lineStartCols = struct.startCols;
|
|
14346
14586
|
const lineWidthCols = struct.widthCols;
|
|
@@ -14355,7 +14595,7 @@ class FFIRenderLib {
|
|
|
14355
14595
|
}
|
|
14356
14596
|
editorViewGetLogicalLineInfo(view) {
|
|
14357
14597
|
const outBuffer = new ArrayBuffer(LineInfoStruct.size);
|
|
14358
|
-
this.opentui.symbols.editorViewGetLogicalLineInfoDirect(view,
|
|
14598
|
+
this.opentui.symbols.editorViewGetLogicalLineInfoDirect(view, ptr(outBuffer));
|
|
14359
14599
|
const struct = LineInfoStruct.unpack(outBuffer);
|
|
14360
14600
|
const lineStartCols = struct.startCols;
|
|
14361
14601
|
const lineWidthCols = struct.widthCols;
|
|
@@ -14393,7 +14633,7 @@ class FFIRenderLib {
|
|
|
14393
14633
|
}
|
|
14394
14634
|
editBufferGetText(buffer, maxLength) {
|
|
14395
14635
|
const outBuffer = new Uint8Array(maxLength);
|
|
14396
|
-
const actualLen = this.opentui.symbols.editBufferGetText(buffer,
|
|
14636
|
+
const actualLen = this.opentui.symbols.editBufferGetText(buffer, ptr(outBuffer), maxLength);
|
|
14397
14637
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
14398
14638
|
if (len === 0)
|
|
14399
14639
|
return null;
|
|
@@ -14448,7 +14688,7 @@ class FFIRenderLib {
|
|
|
14448
14688
|
}
|
|
14449
14689
|
editBufferGetCursorPosition(buffer) {
|
|
14450
14690
|
const cursorBuffer = new ArrayBuffer(LogicalCursorStruct.size);
|
|
14451
|
-
this.opentui.symbols.editBufferGetCursorPosition(buffer,
|
|
14691
|
+
this.opentui.symbols.editBufferGetCursorPosition(buffer, ptr(cursorBuffer));
|
|
14452
14692
|
return LogicalCursorStruct.unpack(cursorBuffer);
|
|
14453
14693
|
}
|
|
14454
14694
|
editBufferGetId(buffer) {
|
|
@@ -14466,7 +14706,7 @@ class FFIRenderLib {
|
|
|
14466
14706
|
}
|
|
14467
14707
|
editBufferUndo(buffer, maxLength) {
|
|
14468
14708
|
const outBuffer = new Uint8Array(maxLength);
|
|
14469
|
-
const actualLen = this.opentui.symbols.editBufferUndo(buffer,
|
|
14709
|
+
const actualLen = this.opentui.symbols.editBufferUndo(buffer, ptr(outBuffer), maxLength);
|
|
14470
14710
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
14471
14711
|
if (len === 0)
|
|
14472
14712
|
return null;
|
|
@@ -14474,7 +14714,7 @@ class FFIRenderLib {
|
|
|
14474
14714
|
}
|
|
14475
14715
|
editBufferRedo(buffer, maxLength) {
|
|
14476
14716
|
const outBuffer = new Uint8Array(maxLength);
|
|
14477
|
-
const actualLen = this.opentui.symbols.editBufferRedo(buffer,
|
|
14717
|
+
const actualLen = this.opentui.symbols.editBufferRedo(buffer, ptr(outBuffer), maxLength);
|
|
14478
14718
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
14479
14719
|
if (len === 0)
|
|
14480
14720
|
return null;
|
|
@@ -14494,22 +14734,22 @@ class FFIRenderLib {
|
|
|
14494
14734
|
}
|
|
14495
14735
|
editBufferGetNextWordBoundary(buffer) {
|
|
14496
14736
|
const cursorBuffer = new ArrayBuffer(LogicalCursorStruct.size);
|
|
14497
|
-
this.opentui.symbols.editBufferGetNextWordBoundary(buffer,
|
|
14737
|
+
this.opentui.symbols.editBufferGetNextWordBoundary(buffer, ptr(cursorBuffer));
|
|
14498
14738
|
return LogicalCursorStruct.unpack(cursorBuffer);
|
|
14499
14739
|
}
|
|
14500
14740
|
editBufferGetPrevWordBoundary(buffer) {
|
|
14501
14741
|
const cursorBuffer = new ArrayBuffer(LogicalCursorStruct.size);
|
|
14502
|
-
this.opentui.symbols.editBufferGetPrevWordBoundary(buffer,
|
|
14742
|
+
this.opentui.symbols.editBufferGetPrevWordBoundary(buffer, ptr(cursorBuffer));
|
|
14503
14743
|
return LogicalCursorStruct.unpack(cursorBuffer);
|
|
14504
14744
|
}
|
|
14505
14745
|
editBufferGetEOL(buffer) {
|
|
14506
14746
|
const cursorBuffer = new ArrayBuffer(LogicalCursorStruct.size);
|
|
14507
|
-
this.opentui.symbols.editBufferGetEOL(buffer,
|
|
14747
|
+
this.opentui.symbols.editBufferGetEOL(buffer, ptr(cursorBuffer));
|
|
14508
14748
|
return LogicalCursorStruct.unpack(cursorBuffer);
|
|
14509
14749
|
}
|
|
14510
14750
|
editBufferOffsetToPosition(buffer, offset) {
|
|
14511
14751
|
const cursorBuffer = new ArrayBuffer(LogicalCursorStruct.size);
|
|
14512
|
-
const success = this.opentui.symbols.editBufferOffsetToPosition(buffer, offset,
|
|
14752
|
+
const success = this.opentui.symbols.editBufferOffsetToPosition(buffer, offset, ptr(cursorBuffer));
|
|
14513
14753
|
if (!success)
|
|
14514
14754
|
return null;
|
|
14515
14755
|
return LogicalCursorStruct.unpack(cursorBuffer);
|
|
@@ -14522,7 +14762,7 @@ class FFIRenderLib {
|
|
|
14522
14762
|
}
|
|
14523
14763
|
editBufferGetTextRange(buffer, startOffset, endOffset, maxLength) {
|
|
14524
14764
|
const outBuffer = new Uint8Array(maxLength);
|
|
14525
|
-
const actualLen = this.opentui.symbols.editBufferGetTextRange(buffer, startOffset, endOffset,
|
|
14765
|
+
const actualLen = this.opentui.symbols.editBufferGetTextRange(buffer, startOffset, endOffset, ptr(outBuffer), maxLength);
|
|
14526
14766
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
14527
14767
|
if (len === 0)
|
|
14528
14768
|
return null;
|
|
@@ -14530,7 +14770,7 @@ class FFIRenderLib {
|
|
|
14530
14770
|
}
|
|
14531
14771
|
editBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, maxLength) {
|
|
14532
14772
|
const outBuffer = new Uint8Array(maxLength);
|
|
14533
|
-
const actualLen = this.opentui.symbols.editBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol,
|
|
14773
|
+
const actualLen = this.opentui.symbols.editBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, ptr(outBuffer), maxLength);
|
|
14534
14774
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
14535
14775
|
if (len === 0)
|
|
14536
14776
|
return null;
|
|
@@ -14556,7 +14796,7 @@ class FFIRenderLib {
|
|
|
14556
14796
|
editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor) {
|
|
14557
14797
|
const bg2 = optionalRgbaPtr(bgColor);
|
|
14558
14798
|
const fg2 = optionalRgbaPtr(fgColor);
|
|
14559
|
-
return this.opentui.symbols.editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, updateCursor, followCursor);
|
|
14799
|
+
return this.opentui.symbols.editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, ffiBool(updateCursor), ffiBool(followCursor));
|
|
14560
14800
|
}
|
|
14561
14801
|
editorViewUpdateSelection(view, end, bgColor, fgColor) {
|
|
14562
14802
|
const bg2 = optionalRgbaPtr(bgColor);
|
|
@@ -14566,14 +14806,14 @@ class FFIRenderLib {
|
|
|
14566
14806
|
editorViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor) {
|
|
14567
14807
|
const bg2 = optionalRgbaPtr(bgColor);
|
|
14568
14808
|
const fg2 = optionalRgbaPtr(fgColor);
|
|
14569
|
-
return this.opentui.symbols.editorViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, updateCursor, followCursor);
|
|
14809
|
+
return this.opentui.symbols.editorViewUpdateLocalSelection(view, anchorX, anchorY, focusX, focusY, bg2, fg2, ffiBool(updateCursor), ffiBool(followCursor));
|
|
14570
14810
|
}
|
|
14571
14811
|
editorViewResetLocalSelection(view) {
|
|
14572
14812
|
this.opentui.symbols.editorViewResetLocalSelection(view);
|
|
14573
14813
|
}
|
|
14574
14814
|
editorViewGetSelectedTextBytes(view, maxLength) {
|
|
14575
14815
|
const outBuffer = new Uint8Array(maxLength);
|
|
14576
|
-
const actualLen = this.opentui.symbols.editorViewGetSelectedTextBytes(view,
|
|
14816
|
+
const actualLen = this.opentui.symbols.editorViewGetSelectedTextBytes(view, ptr(outBuffer), maxLength);
|
|
14577
14817
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
14578
14818
|
if (len === 0)
|
|
14579
14819
|
return null;
|
|
@@ -14582,12 +14822,12 @@ class FFIRenderLib {
|
|
|
14582
14822
|
editorViewGetCursor(view) {
|
|
14583
14823
|
const row = new Uint32Array(1);
|
|
14584
14824
|
const col = new Uint32Array(1);
|
|
14585
|
-
this.opentui.symbols.editorViewGetCursor(view,
|
|
14825
|
+
this.opentui.symbols.editorViewGetCursor(view, ptr(row), ptr(col));
|
|
14586
14826
|
return { row: row[0], col: col[0] };
|
|
14587
14827
|
}
|
|
14588
14828
|
editorViewGetText(view, maxLength) {
|
|
14589
14829
|
const outBuffer = new Uint8Array(maxLength);
|
|
14590
|
-
const actualLen = this.opentui.symbols.editorViewGetText(view,
|
|
14830
|
+
const actualLen = this.opentui.symbols.editorViewGetText(view, ptr(outBuffer), maxLength);
|
|
14591
14831
|
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
14592
14832
|
if (len === 0)
|
|
14593
14833
|
return null;
|
|
@@ -14595,7 +14835,7 @@ class FFIRenderLib {
|
|
|
14595
14835
|
}
|
|
14596
14836
|
editorViewGetVisualCursor(view) {
|
|
14597
14837
|
const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
|
|
14598
|
-
this.opentui.symbols.editorViewGetVisualCursor(view,
|
|
14838
|
+
this.opentui.symbols.editorViewGetVisualCursor(view, ptr(cursorBuffer));
|
|
14599
14839
|
return VisualCursorStruct.unpack(cursorBuffer);
|
|
14600
14840
|
}
|
|
14601
14841
|
editorViewMoveUpVisual(view) {
|
|
@@ -14612,27 +14852,27 @@ class FFIRenderLib {
|
|
|
14612
14852
|
}
|
|
14613
14853
|
editorViewGetNextWordBoundary(view) {
|
|
14614
14854
|
const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
|
|
14615
|
-
this.opentui.symbols.editorViewGetNextWordBoundary(view,
|
|
14855
|
+
this.opentui.symbols.editorViewGetNextWordBoundary(view, ptr(cursorBuffer));
|
|
14616
14856
|
return VisualCursorStruct.unpack(cursorBuffer);
|
|
14617
14857
|
}
|
|
14618
14858
|
editorViewGetPrevWordBoundary(view) {
|
|
14619
14859
|
const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
|
|
14620
|
-
this.opentui.symbols.editorViewGetPrevWordBoundary(view,
|
|
14860
|
+
this.opentui.symbols.editorViewGetPrevWordBoundary(view, ptr(cursorBuffer));
|
|
14621
14861
|
return VisualCursorStruct.unpack(cursorBuffer);
|
|
14622
14862
|
}
|
|
14623
14863
|
editorViewGetEOL(view) {
|
|
14624
14864
|
const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
|
|
14625
|
-
this.opentui.symbols.editorViewGetEOL(view,
|
|
14865
|
+
this.opentui.symbols.editorViewGetEOL(view, ptr(cursorBuffer));
|
|
14626
14866
|
return VisualCursorStruct.unpack(cursorBuffer);
|
|
14627
14867
|
}
|
|
14628
14868
|
editorViewGetVisualSOL(view) {
|
|
14629
14869
|
const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
|
|
14630
|
-
this.opentui.symbols.editorViewGetVisualSOL(view,
|
|
14870
|
+
this.opentui.symbols.editorViewGetVisualSOL(view, ptr(cursorBuffer));
|
|
14631
14871
|
return VisualCursorStruct.unpack(cursorBuffer);
|
|
14632
14872
|
}
|
|
14633
14873
|
editorViewGetVisualEOL(view) {
|
|
14634
14874
|
const cursorBuffer = new ArrayBuffer(VisualCursorStruct.size);
|
|
14635
|
-
this.opentui.symbols.editorViewGetVisualEOL(view,
|
|
14875
|
+
this.opentui.symbols.editorViewGetVisualEOL(view, ptr(cursorBuffer));
|
|
14636
14876
|
return VisualCursorStruct.unpack(cursorBuffer);
|
|
14637
14877
|
}
|
|
14638
14878
|
bufferPushScissorRect(buffer, x, y, width, height) {
|
|
@@ -14658,7 +14898,7 @@ class FFIRenderLib {
|
|
|
14658
14898
|
}
|
|
14659
14899
|
getTerminalCapabilities(renderer) {
|
|
14660
14900
|
const capsBuffer = new ArrayBuffer(TerminalCapabilitiesStruct.size);
|
|
14661
|
-
this.opentui.symbols.getTerminalCapabilities(renderer,
|
|
14901
|
+
this.opentui.symbols.getTerminalCapabilities(renderer, ptr(capsBuffer));
|
|
14662
14902
|
const caps = TerminalCapabilitiesStruct.unpack(capsBuffer);
|
|
14663
14903
|
return {
|
|
14664
14904
|
kitty_keyboard: caps.kitty_keyboard,
|
|
@@ -14677,6 +14917,7 @@ class FFIRenderLib {
|
|
|
14677
14917
|
hyperlinks: caps.hyperlinks,
|
|
14678
14918
|
osc52: caps.osc52,
|
|
14679
14919
|
explicit_cursor_positioning: caps.explicit_cursor_positioning,
|
|
14920
|
+
in_tmux: caps.in_tmux,
|
|
14680
14921
|
terminal: {
|
|
14681
14922
|
name: caps.term_name ?? "",
|
|
14682
14923
|
version: caps.term_version ?? "",
|
|
@@ -14693,7 +14934,7 @@ class FFIRenderLib {
|
|
|
14693
14934
|
const widthMethodCode = widthMethod === "wcwidth" ? 0 : 1;
|
|
14694
14935
|
const outPtrBuffer = new ArrayBuffer(8);
|
|
14695
14936
|
const outLenBuffer = new ArrayBuffer(8);
|
|
14696
|
-
const success = this.opentui.symbols.encodeUnicode(textBytes, textBytes.length,
|
|
14937
|
+
const success = this.opentui.symbols.encodeUnicode(textBytes, textBytes.length, ptr(outPtrBuffer), ptr(outLenBuffer), widthMethodCode);
|
|
14697
14938
|
if (!success) {
|
|
14698
14939
|
return null;
|
|
14699
14940
|
}
|
|
@@ -14705,7 +14946,7 @@ class FFIRenderLib {
|
|
|
14705
14946
|
return { ptr: resultPtr, data: [] };
|
|
14706
14947
|
}
|
|
14707
14948
|
const byteLen = resultLen * EncodedCharStruct.size;
|
|
14708
|
-
const raw =
|
|
14949
|
+
const raw = toArrayBuffer(resultPtr, 0, byteLen);
|
|
14709
14950
|
const data = EncodedCharStruct.unpackList(raw, resultLen);
|
|
14710
14951
|
return { ptr: resultPtr, data };
|
|
14711
14952
|
}
|
|
@@ -14717,37 +14958,37 @@ class FFIRenderLib {
|
|
|
14717
14958
|
}
|
|
14718
14959
|
registerNativeSpanFeedStream(stream, handler) {
|
|
14719
14960
|
const callback = this.ensureNativeSpanFeedCallback();
|
|
14720
|
-
this.nativeSpanFeedHandlers.set(
|
|
14961
|
+
this.nativeSpanFeedHandlers.set(stream, handler);
|
|
14721
14962
|
this.opentui.symbols.streamSetCallback(stream, callback.ptr);
|
|
14722
14963
|
}
|
|
14723
14964
|
unregisterNativeSpanFeedStream(stream) {
|
|
14724
14965
|
this.opentui.symbols.streamSetCallback(stream, null);
|
|
14725
|
-
this.nativeSpanFeedHandlers.delete(
|
|
14966
|
+
this.nativeSpanFeedHandlers.delete(stream);
|
|
14726
14967
|
}
|
|
14727
14968
|
createNativeSpanFeed(options) {
|
|
14728
14969
|
const optionsBuffer = options == null ? null : NativeSpanFeedOptionsStruct.pack(options);
|
|
14729
|
-
const streamPtr = this.opentui.symbols.createNativeSpanFeed(optionsBuffer ?
|
|
14970
|
+
const streamPtr = this.opentui.symbols.createNativeSpanFeed(optionsBuffer ? ptr(optionsBuffer) : null);
|
|
14730
14971
|
if (!streamPtr) {
|
|
14731
14972
|
throw new Error("Failed to create stream");
|
|
14732
14973
|
}
|
|
14733
|
-
return
|
|
14974
|
+
return streamPtr;
|
|
14734
14975
|
}
|
|
14735
14976
|
attachNativeSpanFeed(stream) {
|
|
14736
14977
|
return this.opentui.symbols.attachNativeSpanFeed(stream);
|
|
14737
14978
|
}
|
|
14738
14979
|
destroyNativeSpanFeed(stream) {
|
|
14739
14980
|
this.opentui.symbols.destroyNativeSpanFeed(stream);
|
|
14740
|
-
this.nativeSpanFeedHandlers.delete(
|
|
14981
|
+
this.nativeSpanFeedHandlers.delete(stream);
|
|
14741
14982
|
}
|
|
14742
14983
|
streamWrite(stream, data) {
|
|
14743
14984
|
const bytes = typeof data === "string" ? this.encoder.encode(data) : data;
|
|
14744
|
-
return this.opentui.symbols.streamWrite(stream,
|
|
14985
|
+
return this.opentui.symbols.streamWrite(stream, ptr(bytes), bytes.length);
|
|
14745
14986
|
}
|
|
14746
14987
|
streamCommit(stream) {
|
|
14747
14988
|
return this.opentui.symbols.streamCommit(stream);
|
|
14748
14989
|
}
|
|
14749
14990
|
streamDrainSpans(stream, outBuffer, maxSpans) {
|
|
14750
|
-
const count = this.opentui.symbols.streamDrainSpans(stream,
|
|
14991
|
+
const count = this.opentui.symbols.streamDrainSpans(stream, ptr(outBuffer), maxSpans);
|
|
14751
14992
|
return toNumber(count);
|
|
14752
14993
|
}
|
|
14753
14994
|
streamClose(stream) {
|
|
@@ -14755,11 +14996,11 @@ class FFIRenderLib {
|
|
|
14755
14996
|
}
|
|
14756
14997
|
streamSetOptions(stream, options) {
|
|
14757
14998
|
const optionsBuffer = NativeSpanFeedOptionsStruct.pack(options);
|
|
14758
|
-
return this.opentui.symbols.streamSetOptions(stream,
|
|
14999
|
+
return this.opentui.symbols.streamSetOptions(stream, ptr(optionsBuffer));
|
|
14759
15000
|
}
|
|
14760
15001
|
streamGetStats(stream) {
|
|
14761
15002
|
const statsBuffer = new ArrayBuffer(NativeSpanFeedStatsStruct.size);
|
|
14762
|
-
const status = this.opentui.symbols.streamGetStats(stream,
|
|
15003
|
+
const status = this.opentui.symbols.streamGetStats(stream, ptr(statsBuffer));
|
|
14763
15004
|
if (status !== 0) {
|
|
14764
15005
|
return null;
|
|
14765
15006
|
}
|
|
@@ -14773,7 +15014,7 @@ class FFIRenderLib {
|
|
|
14773
15014
|
}
|
|
14774
15015
|
streamReserve(stream, minLen) {
|
|
14775
15016
|
const reserveBuffer = new ArrayBuffer(ReserveInfoStruct.size);
|
|
14776
|
-
const status = this.opentui.symbols.streamReserve(stream, minLen,
|
|
15017
|
+
const status = this.opentui.symbols.streamReserve(stream, minLen, ptr(reserveBuffer));
|
|
14777
15018
|
if (status !== 0) {
|
|
14778
15019
|
return { status, info: null };
|
|
14779
15020
|
}
|
|
@@ -14814,7 +15055,7 @@ class FFIRenderLib {
|
|
|
14814
15055
|
return;
|
|
14815
15056
|
}
|
|
14816
15057
|
const chunksBuffer = StyledChunkStruct.packList(nonEmptyChunks);
|
|
14817
|
-
this.opentui.symbols.editorViewSetPlaceholderStyledText(view,
|
|
15058
|
+
this.opentui.symbols.editorViewSetPlaceholderStyledText(view, ptr(chunksBuffer), nonEmptyChunks.length);
|
|
14818
15059
|
}
|
|
14819
15060
|
editorViewSetTabIndicator(view, indicator) {
|
|
14820
15061
|
this.opentui.symbols.editorViewSetTabIndicator(view, indicator);
|
|
@@ -14869,9 +15110,9 @@ class TextBuffer {
|
|
|
14869
15110
|
_textBytes;
|
|
14870
15111
|
_memId;
|
|
14871
15112
|
_appendedChunks = [];
|
|
14872
|
-
constructor(lib,
|
|
15113
|
+
constructor(lib, ptr3) {
|
|
14873
15114
|
this.lib = lib;
|
|
14874
|
-
this.bufferPtr =
|
|
15115
|
+
this.bufferPtr = ptr3;
|
|
14875
15116
|
}
|
|
14876
15117
|
static create(widthMethod) {
|
|
14877
15118
|
const lib = resolveRenderLib();
|
|
@@ -16597,9 +16838,9 @@ class TextBufferView {
|
|
|
16597
16838
|
viewPtr;
|
|
16598
16839
|
textBuffer;
|
|
16599
16840
|
_destroyed = false;
|
|
16600
|
-
constructor(lib,
|
|
16841
|
+
constructor(lib, ptr3, textBuffer) {
|
|
16601
16842
|
this.lib = lib;
|
|
16602
|
-
this.viewPtr =
|
|
16843
|
+
this.viewPtr = ptr3;
|
|
16603
16844
|
this.textBuffer = textBuffer;
|
|
16604
16845
|
}
|
|
16605
16846
|
static create(textBuffer) {
|
|
@@ -16739,19 +16980,19 @@ class EditBuffer extends EventEmitter6 {
|
|
|
16739
16980
|
_singleTextBytes = null;
|
|
16740
16981
|
_singleTextMemId = null;
|
|
16741
16982
|
_syntaxStyle;
|
|
16742
|
-
constructor(lib,
|
|
16983
|
+
constructor(lib, ptr3) {
|
|
16743
16984
|
super();
|
|
16744
16985
|
this.lib = lib;
|
|
16745
|
-
this.bufferPtr =
|
|
16746
|
-
this.textBufferPtr = lib.editBufferGetTextBuffer(
|
|
16747
|
-
this.id = lib.editBufferGetId(
|
|
16986
|
+
this.bufferPtr = ptr3;
|
|
16987
|
+
this.textBufferPtr = lib.editBufferGetTextBuffer(ptr3);
|
|
16988
|
+
this.id = lib.editBufferGetId(ptr3);
|
|
16748
16989
|
EditBuffer.registry.set(this.id, this);
|
|
16749
16990
|
EditBuffer.subscribeToNativeEvents(lib);
|
|
16750
16991
|
}
|
|
16751
16992
|
static create(widthMethod) {
|
|
16752
16993
|
const lib = resolveRenderLib();
|
|
16753
|
-
const
|
|
16754
|
-
return new EditBuffer(lib,
|
|
16994
|
+
const ptr3 = lib.createEditBuffer(widthMethod);
|
|
16995
|
+
return new EditBuffer(lib, ptr3);
|
|
16755
16996
|
}
|
|
16756
16997
|
static subscribeToNativeEvents(lib) {
|
|
16757
16998
|
if (EditBuffer.nativeEventsSubscribed)
|
|
@@ -17044,9 +17285,9 @@ class EditorView {
|
|
|
17044
17285
|
_destroyed = false;
|
|
17045
17286
|
_extmarksController;
|
|
17046
17287
|
_textBufferViewPtr;
|
|
17047
|
-
constructor(lib,
|
|
17288
|
+
constructor(lib, ptr3, editBuffer) {
|
|
17048
17289
|
this.lib = lib;
|
|
17049
|
-
this.viewPtr =
|
|
17290
|
+
this.viewPtr = ptr3;
|
|
17050
17291
|
this.editBuffer = editBuffer;
|
|
17051
17292
|
}
|
|
17052
17293
|
static create(editBuffer, viewportWidth, viewportHeight) {
|
|
@@ -17265,14 +17506,14 @@ class SyntaxStyle {
|
|
|
17265
17506
|
nameCache = new Map;
|
|
17266
17507
|
styleDefs = new Map;
|
|
17267
17508
|
mergedCache = new Map;
|
|
17268
|
-
constructor(lib,
|
|
17509
|
+
constructor(lib, ptr3) {
|
|
17269
17510
|
this.lib = lib;
|
|
17270
|
-
this.stylePtr =
|
|
17511
|
+
this.stylePtr = ptr3;
|
|
17271
17512
|
}
|
|
17272
17513
|
static create() {
|
|
17273
17514
|
const lib = resolveRenderLib();
|
|
17274
|
-
const
|
|
17275
|
-
return new SyntaxStyle(lib,
|
|
17515
|
+
const ptr3 = lib.createSyntaxStyle();
|
|
17516
|
+
return new SyntaxStyle(lib, ptr3);
|
|
17276
17517
|
}
|
|
17277
17518
|
static fromTheme(theme) {
|
|
17278
17519
|
const style = SyntaxStyle.create();
|
|
@@ -18226,6 +18467,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
18226
18467
|
try {
|
|
18227
18468
|
const result = await this._treeSitterClient.highlightOnce(content, filetype);
|
|
18228
18469
|
if (snapshotId !== this._highlightSnapshotId) {
|
|
18470
|
+
this.requestRender();
|
|
18229
18471
|
return;
|
|
18230
18472
|
}
|
|
18231
18473
|
if (this.isDestroyed)
|
|
@@ -18243,6 +18485,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
18243
18485
|
}
|
|
18244
18486
|
}
|
|
18245
18487
|
if (snapshotId !== this._highlightSnapshotId) {
|
|
18488
|
+
this.requestRender();
|
|
18246
18489
|
return;
|
|
18247
18490
|
}
|
|
18248
18491
|
if (this.isDestroyed)
|
|
@@ -18264,6 +18507,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
18264
18507
|
});
|
|
18265
18508
|
chunks = await this.transformChunks(chunks, context);
|
|
18266
18509
|
if (snapshotId !== this._highlightSnapshotId) {
|
|
18510
|
+
this.requestRender();
|
|
18267
18511
|
return;
|
|
18268
18512
|
}
|
|
18269
18513
|
if (this.isDestroyed)
|
|
@@ -18280,6 +18524,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
18280
18524
|
this.requestRender();
|
|
18281
18525
|
} catch (error) {
|
|
18282
18526
|
if (snapshotId !== this._highlightSnapshotId) {
|
|
18527
|
+
this.requestRender();
|
|
18283
18528
|
return;
|
|
18284
18529
|
}
|
|
18285
18530
|
console.warn("Code highlighting failed, falling back to plain text:", error);
|
|
@@ -18844,8 +19089,8 @@ function getCallerInfo() {
|
|
|
18844
19089
|
if (!stackLines.length)
|
|
18845
19090
|
return null;
|
|
18846
19091
|
const callerLine = stackLines[0].trim();
|
|
18847
|
-
const
|
|
18848
|
-
const match = callerLine.match(
|
|
19092
|
+
const regex2 = /at\s+(?:([\w$.<>]+)\s+\()?((?:\/|[A-Za-z]:\\)[^:]+):(\d+):(\d+)\)?/;
|
|
19093
|
+
const match = callerLine.match(regex2);
|
|
18849
19094
|
if (!match)
|
|
18850
19095
|
return null;
|
|
18851
19096
|
const functionName = match[1] || "<anonymous>";
|
|
@@ -18920,6 +19165,9 @@ class TerminalConsoleCache extends EventEmitter8 {
|
|
|
18920
19165
|
console.debug = (...args) => {
|
|
18921
19166
|
this.appendToConsole("DEBUG" /* DEBUG */, ...args);
|
|
18922
19167
|
};
|
|
19168
|
+
if (typeof console.timeStamp !== "function") {
|
|
19169
|
+
console.timeStamp = () => {};
|
|
19170
|
+
}
|
|
18923
19171
|
}
|
|
18924
19172
|
setCollectCallerInfo(enabled) {
|
|
18925
19173
|
this._collectCallerInfo = enabled;
|
|
@@ -21372,6 +21620,7 @@ var CliRenderEvents;
|
|
|
21372
21620
|
CliRenderEvents2["FOCUSED_RENDERABLE"] = "focused_renderable";
|
|
21373
21621
|
CliRenderEvents2["FOCUSED_EDITOR"] = "focused_editor";
|
|
21374
21622
|
CliRenderEvents2["THEME_MODE"] = "theme_mode";
|
|
21623
|
+
CliRenderEvents2["PALETTE"] = "palette";
|
|
21375
21624
|
CliRenderEvents2["CAPABILITIES"] = "capabilities";
|
|
21376
21625
|
CliRenderEvents2["SELECTION"] = "selection";
|
|
21377
21626
|
CliRenderEvents2["DEBUG_OVERLAY_TOGGLE"] = "debugOverlay:toggle";
|
|
@@ -21459,6 +21708,7 @@ class CliRenderer extends EventEmitter9 {
|
|
|
21459
21708
|
animationRequest = new Map;
|
|
21460
21709
|
resizeTimeoutId = null;
|
|
21461
21710
|
capabilityTimeoutId = null;
|
|
21711
|
+
xtVersionWaiters = new Set;
|
|
21462
21712
|
splitStartupSeedTimeoutId = null;
|
|
21463
21713
|
pendingSplitStartupCursorSeed = false;
|
|
21464
21714
|
resizeDebounceDelay = 100;
|
|
@@ -21508,11 +21758,11 @@ class CliRenderer extends EventEmitter9 {
|
|
|
21508
21758
|
_openConsoleOnError = true;
|
|
21509
21759
|
_paletteDetector = null;
|
|
21510
21760
|
_paletteCache = new Map;
|
|
21511
|
-
_cachedPalette = null;
|
|
21512
21761
|
_paletteDetectionPromise = null;
|
|
21513
21762
|
_paletteDetectionSize = 0;
|
|
21514
21763
|
_paletteEpoch = 0;
|
|
21515
|
-
|
|
21764
|
+
_nativePaletteSignature = null;
|
|
21765
|
+
_emittedPaletteSignature = null;
|
|
21516
21766
|
_palettePublishGeneration = 0;
|
|
21517
21767
|
_onDestroy;
|
|
21518
21768
|
themeModeState;
|
|
@@ -21567,7 +21817,7 @@ Captured external output:
|
|
|
21567
21817
|
exitHandler = (() => {
|
|
21568
21818
|
this.destroy();
|
|
21569
21819
|
if (env.OTUI_DUMP_CAPTURES) {
|
|
21570
|
-
|
|
21820
|
+
sleep(100).then(() => {
|
|
21571
21821
|
this.dumpOutputCache(`=== CAPTURED OUTPUT ===
|
|
21572
21822
|
`);
|
|
21573
21823
|
});
|
|
@@ -21631,6 +21881,10 @@ Captured external output:
|
|
|
21631
21881
|
this.themeModeHandler = (sequence) => {
|
|
21632
21882
|
const result = this.themeModeState.handleSequence(sequence);
|
|
21633
21883
|
if (result.changedMode) {
|
|
21884
|
+
this.clearPaletteCache();
|
|
21885
|
+
if (this.shouldSyncNativePaletteState() || this.listenerCount("palette" /* PALETTE */) > 0) {
|
|
21886
|
+
this.refreshPalette();
|
|
21887
|
+
}
|
|
21634
21888
|
this.emit("theme_mode" /* THEME_MODE */, result.changedMode);
|
|
21635
21889
|
}
|
|
21636
21890
|
return result.handled;
|
|
@@ -22797,6 +23051,7 @@ Captured external output:
|
|
|
22797
23051
|
explicitWidthCprActive: false,
|
|
22798
23052
|
startupCursorCprActive: false
|
|
22799
23053
|
}, true);
|
|
23054
|
+
this.resolveXtVersionWaiters();
|
|
22800
23055
|
}, 5000);
|
|
22801
23056
|
if (this._useMouse) {
|
|
22802
23057
|
this.enableMouse();
|
|
@@ -22818,7 +23073,9 @@ Captured external output:
|
|
|
22818
23073
|
}, 120);
|
|
22819
23074
|
}
|
|
22820
23075
|
this.queryPixelResolution();
|
|
22821
|
-
this.
|
|
23076
|
+
if (this.shouldSyncNativePaletteState()) {
|
|
23077
|
+
this.refreshPalette();
|
|
23078
|
+
}
|
|
22822
23079
|
}
|
|
22823
23080
|
stdinListener = ((chunk) => {
|
|
22824
23081
|
const data = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
@@ -22861,6 +23118,9 @@ Captured external output:
|
|
|
22861
23118
|
}
|
|
22862
23119
|
this.lib.processCapabilityResponse(this.rendererPtr, sequence);
|
|
22863
23120
|
this._capabilities = this.lib.getTerminalCapabilities(this.rendererPtr);
|
|
23121
|
+
if (this._capabilities?.terminal?.from_xtversion) {
|
|
23122
|
+
this.resolveXtVersionWaiters();
|
|
23123
|
+
}
|
|
22864
23124
|
if (hasStandardCapabilitySignature) {
|
|
22865
23125
|
this.forceFullRepaintRequested = true;
|
|
22866
23126
|
this.requestRender();
|
|
@@ -23462,7 +23722,7 @@ Captured external output:
|
|
|
23462
23722
|
if (this._suspendedMouseEnabled) {
|
|
23463
23723
|
this.enableMouse();
|
|
23464
23724
|
}
|
|
23465
|
-
this.
|
|
23725
|
+
this.forceFullRepaintRequested = true;
|
|
23466
23726
|
this._controlState = this._previousControlState;
|
|
23467
23727
|
if (this._previousControlState === "auto_started" /* AUTO_STARTED */ || this._previousControlState === "explicit_started" /* EXPLICIT_STARTED */) {
|
|
23468
23728
|
this.internalStart();
|
|
@@ -23579,9 +23839,10 @@ Captured external output:
|
|
|
23579
23839
|
this._paletteCache.clear();
|
|
23580
23840
|
this._paletteDetectionPromise = null;
|
|
23581
23841
|
this._paletteDetectionSize = 0;
|
|
23582
|
-
this.
|
|
23583
|
-
this.
|
|
23842
|
+
this._nativePaletteSignature = null;
|
|
23843
|
+
this._emittedPaletteSignature = null;
|
|
23584
23844
|
this._paletteEpoch = 0;
|
|
23845
|
+
this.resolveXtVersionWaiters();
|
|
23585
23846
|
this.themeModeState.dispose();
|
|
23586
23847
|
this.emit("destroy" /* DESTROY */);
|
|
23587
23848
|
try {
|
|
@@ -23898,40 +24159,72 @@ Captured external output:
|
|
|
23898
24159
|
}
|
|
23899
24160
|
ensurePaletteDetector() {
|
|
23900
24161
|
if (!this._paletteDetector) {
|
|
24162
|
+
const isTmux = Boolean(this.capabilities?.in_tmux || this.capabilities?.terminal?.name?.toLowerCase()?.includes("tmux"));
|
|
23901
24163
|
const isLegacyTmux = this.capabilities?.terminal?.name?.toLowerCase()?.includes("tmux") && this.capabilities?.terminal?.version?.localeCompare("3.6") < 0;
|
|
23902
|
-
this._paletteDetector = createTerminalPalette(
|
|
23903
|
-
|
|
23904
|
-
|
|
24164
|
+
this._paletteDetector = createTerminalPalette({
|
|
24165
|
+
stdin: this.stdin,
|
|
24166
|
+
stdout: this.stdout,
|
|
24167
|
+
writeFn: (data) => this._isDestroyed ? false : this.writeOut(data),
|
|
24168
|
+
isLegacyTmux,
|
|
24169
|
+
isTmux,
|
|
24170
|
+
oscSource: {
|
|
24171
|
+
subscribeOsc: this.subscribeOsc.bind(this)
|
|
24172
|
+
},
|
|
24173
|
+
clock: this.clock
|
|
24174
|
+
});
|
|
23905
24175
|
}
|
|
23906
24176
|
return this._paletteDetector;
|
|
23907
24177
|
}
|
|
23908
24178
|
syncNativePaletteState(colors) {
|
|
23909
24179
|
const signature = buildTerminalPaletteSignature(colors);
|
|
23910
|
-
if (this.
|
|
24180
|
+
if (this._nativePaletteSignature !== signature) {
|
|
23911
24181
|
this._paletteEpoch = this._paletteEpoch + 1 >>> 0;
|
|
23912
24182
|
}
|
|
23913
|
-
this.
|
|
24183
|
+
this._nativePaletteSignature = signature;
|
|
23914
24184
|
const normalized = normalizeTerminalPalette(colors);
|
|
23915
24185
|
this.lib.rendererSetPaletteState(this.rendererPtr, normalized.palette, normalized.defaultForeground, normalized.defaultBackground, this._paletteEpoch);
|
|
23916
24186
|
}
|
|
23917
|
-
|
|
23918
|
-
if (
|
|
24187
|
+
emitPaletteChange(colors) {
|
|
24188
|
+
if (this.listenerCount("palette" /* PALETTE */) === 0)
|
|
24189
|
+
return;
|
|
24190
|
+
const signature = buildTerminalPaletteSignature(colors);
|
|
24191
|
+
if (this._emittedPaletteSignature === signature)
|
|
24192
|
+
return;
|
|
24193
|
+
this._emittedPaletteSignature = signature;
|
|
24194
|
+
this.emit("palette" /* PALETTE */, colors);
|
|
24195
|
+
}
|
|
24196
|
+
resolveXtVersionWaiters() {
|
|
24197
|
+
if (this.xtVersionWaiters.size === 0)
|
|
23919
24198
|
return;
|
|
24199
|
+
const resolvers = [...this.xtVersionWaiters];
|
|
24200
|
+
this.xtVersionWaiters.clear();
|
|
24201
|
+
for (const resolve4 of resolvers) {
|
|
24202
|
+
resolve4();
|
|
24203
|
+
}
|
|
24204
|
+
}
|
|
24205
|
+
waitForXtVersion() {
|
|
24206
|
+
if (this.capabilityTimeoutId === null || this._capabilities?.terminal?.from_xtversion) {
|
|
24207
|
+
return Promise.resolve();
|
|
24208
|
+
}
|
|
24209
|
+
return new Promise((resolve4) => {
|
|
24210
|
+
this.xtVersionWaiters.add(resolve4);
|
|
24211
|
+
});
|
|
24212
|
+
}
|
|
24213
|
+
shouldSyncNativePaletteState() {
|
|
24214
|
+
return Boolean(this._terminalIsSetup && !this._isDestroyed && this._capabilities?.ansi256 && !this._capabilities?.rgb);
|
|
24215
|
+
}
|
|
24216
|
+
refreshPalette() {
|
|
23920
24217
|
const publishGeneration = this._palettePublishGeneration;
|
|
23921
|
-
this.getPalette({ size: NATIVE_PALETTE_QUERY_SIZE }).then((
|
|
24218
|
+
this.getPalette({ size: NATIVE_PALETTE_QUERY_SIZE }).then(() => {
|
|
23922
24219
|
if (this._isDestroyed)
|
|
23923
24220
|
return;
|
|
23924
|
-
if (this._palettePublishGeneration === publishGeneration)
|
|
23925
|
-
this.
|
|
23926
|
-
}
|
|
23927
|
-
if (this._isDestroyed)
|
|
23928
|
-
return;
|
|
23929
|
-
this.requestRender();
|
|
24221
|
+
if (this._palettePublishGeneration === publishGeneration)
|
|
24222
|
+
this.requestRender();
|
|
23930
24223
|
}).catch(() => {});
|
|
23931
24224
|
}
|
|
23932
24225
|
clearPaletteCache() {
|
|
24226
|
+
this._palettePublishGeneration++;
|
|
23933
24227
|
this._paletteCache.clear();
|
|
23934
|
-
this._cachedPalette = null;
|
|
23935
24228
|
}
|
|
23936
24229
|
async getPalette(options) {
|
|
23937
24230
|
if (this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
|
|
@@ -23941,15 +24234,22 @@ Captured external output:
|
|
|
23941
24234
|
const detectionTimeout = options?.timeout;
|
|
23942
24235
|
const cachedPalette = this.getCachedPaletteBySize(requestedSize);
|
|
23943
24236
|
if (cachedPalette) {
|
|
23944
|
-
this._cachedPalette = cachedPalette;
|
|
23945
24237
|
return cachedPalette;
|
|
23946
24238
|
}
|
|
24239
|
+
const terminal = this._capabilities?.terminal;
|
|
24240
|
+
const hasTmuxVersion = terminal?.name?.toLowerCase() === "tmux" && Boolean(terminal.version);
|
|
24241
|
+
if (this._capabilities?.in_tmux && !hasTmuxVersion) {
|
|
24242
|
+
await this.waitForXtVersion();
|
|
24243
|
+
const afterCapabilityWait = this.getCachedPaletteBySize(requestedSize);
|
|
24244
|
+
if (afterCapabilityWait) {
|
|
24245
|
+
return afterCapabilityWait;
|
|
24246
|
+
}
|
|
24247
|
+
}
|
|
23947
24248
|
if (this._paletteDetectionPromise) {
|
|
23948
24249
|
if (this._paletteDetectionSize >= requestedSize) {
|
|
23949
24250
|
return this._paletteDetectionPromise.then((palette) => {
|
|
23950
24251
|
const cached = this.getCachedPaletteBySize(requestedSize);
|
|
23951
24252
|
if (cached) {
|
|
23952
|
-
this._cachedPalette = cached;
|
|
23953
24253
|
return cached;
|
|
23954
24254
|
}
|
|
23955
24255
|
const projected = {
|
|
@@ -23957,14 +24257,12 @@ Captured external output:
|
|
|
23957
24257
|
palette: palette.palette.slice(0, requestedSize)
|
|
23958
24258
|
};
|
|
23959
24259
|
this._paletteCache.set(requestedSize, projected);
|
|
23960
|
-
this._cachedPalette = projected;
|
|
23961
24260
|
return projected;
|
|
23962
24261
|
});
|
|
23963
24262
|
}
|
|
23964
24263
|
await this._paletteDetectionPromise;
|
|
23965
24264
|
const afterWait = this.getCachedPaletteBySize(requestedSize);
|
|
23966
24265
|
if (afterWait) {
|
|
23967
|
-
this._cachedPalette = afterWait;
|
|
23968
24266
|
return afterWait;
|
|
23969
24267
|
}
|
|
23970
24268
|
}
|
|
@@ -23973,14 +24271,14 @@ Captured external output:
|
|
|
23973
24271
|
this._paletteDetectionSize = requestedSize;
|
|
23974
24272
|
this._paletteDetectionPromise = detector.detect({ ...options, timeout: detectionTimeout }).then((result) => {
|
|
23975
24273
|
this._paletteCache.set(result.palette.length, result);
|
|
23976
|
-
this._cachedPalette = result;
|
|
23977
24274
|
this._paletteDetectionPromise = null;
|
|
23978
24275
|
this._paletteDetectionSize = 0;
|
|
23979
24276
|
if (!this._isDestroyed && this._palettePublishGeneration === publishGeneration) {
|
|
23980
|
-
|
|
24277
|
+
this.emitPaletteChange(result);
|
|
24278
|
+
if (this.shouldSyncNativePaletteState() && result.palette.length >= NATIVE_PALETTE_QUERY_SIZE) {
|
|
23981
24279
|
this.syncNativePaletteState(result);
|
|
23982
|
-
} else if (this.
|
|
23983
|
-
this.
|
|
24280
|
+
} else if (this.shouldSyncNativePaletteState() && !this._paletteCache.has(NATIVE_PALETTE_QUERY_SIZE)) {
|
|
24281
|
+
this.refreshPalette();
|
|
23984
24282
|
}
|
|
23985
24283
|
}
|
|
23986
24284
|
return result;
|
|
@@ -23991,12 +24289,11 @@ Captured external output:
|
|
|
23991
24289
|
});
|
|
23992
24290
|
const detected = await this._paletteDetectionPromise;
|
|
23993
24291
|
const finalPalette = this.getCachedPaletteBySize(requestedSize) ?? detected;
|
|
23994
|
-
this._cachedPalette = finalPalette;
|
|
23995
24292
|
return finalPalette;
|
|
23996
24293
|
}
|
|
23997
24294
|
}
|
|
23998
24295
|
|
|
23999
|
-
export { __export, __require, MeasureMode, exports_src, isValidBorderStyle, parseBorderStyle, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, DEFAULT_FOREGROUND_RGB, DEFAULT_BACKGROUND_RGB, normalizeIndexedColorIndex, ansi256IndexToRgb, RGBA, normalizeColorValue, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, ATTRIBUTE_BASE_BITS, ATTRIBUTE_BASE_MASK, getBaseAttributes, DebugOverlayCorner, TargetChannel, createTextAttributes, attributesWithLink, getLinkId, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, link, t, hastToStyledText, SystemClock, nonAlphanumericKeys, terminalNamedSingleStrokeKeys, parseKeypress, LinearScrollAccel, MacOSScrollAccel, parseAlign, parseAlignItems, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, StdinParser, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extensionToFiletype, basenameToFiletype, extToFiletype, pathToFiletype, infoStringToFiletype, main, getTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, normalizeTerminalPalette, buildTerminalPaletteSignature, decodePasteBytes, stripAnsiSequences, detectLinks, TextBuffer, SpanInfoStruct,
|
|
24296
|
+
export { __export, __require, MeasureMode, exports_src, isValidBorderStyle, parseBorderStyle, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, DEFAULT_FOREGROUND_RGB, DEFAULT_BACKGROUND_RGB, normalizeIndexedColorIndex, ansi256IndexToRgb, RGBA, normalizeColorValue, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, ATTRIBUTE_BASE_BITS, ATTRIBUTE_BASE_MASK, getBaseAttributes, DebugOverlayCorner, TargetChannel, createTextAttributes, attributesWithLink, getLinkId, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, link, t, hastToStyledText, SystemClock, nonAlphanumericKeys, terminalNamedSingleStrokeKeys, parseKeypress, LinearScrollAccel, MacOSScrollAccel, parseAlign, parseAlignItems, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, StdinParser, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extensionToFiletype, basenameToFiletype, extToFiletype, pathToFiletype, infoStringToFiletype, main, getTreeSitterClient, stringWidth2 as stringWidth, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, normalizeTerminalPalette, buildTerminalPaletteSignature, decodePasteBytes, stripAnsiSequences, detectLinks, toArrayBuffer, TextBuffer, SpanInfoStruct, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, TextBufferView, EditBuffer, EditorView, convertThemeToStyles, SyntaxStyle, ANSI, BoxRenderable, TextBufferRenderable, CodeRenderable, isTextNodeRenderable, TextNodeRenderable, RootTextNodeRenderable, TextRenderable, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingAction, buildKeyBindingsMap, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, EditBufferRenderableEvents, isEditBufferRenderable, EditBufferRenderable, calculateRenderGeometry, buildKittyKeyboardFlags, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
|
|
24000
24297
|
|
|
24001
|
-
//# debugId=
|
|
24002
|
-
//# sourceMappingURL=index-
|
|
24298
|
+
//# debugId=A8199A30ABCACF0064756E2164756E21
|
|
24299
|
+
//# sourceMappingURL=index-hmk8xzt3.js.map
|