@opentui/core 0.5.0 → 0.5.2

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.
@@ -8883,6 +8883,13 @@ class TreeSitterClient extends EventEmitter2 {
8883
8883
  return;
8884
8884
  }
8885
8885
  case "ERROR": {
8886
+ if (message.messageId) {
8887
+ const callback = this.messageCallbacks.get(message.messageId);
8888
+ if (callback) {
8889
+ this.messageCallbacks.delete(message.messageId);
8890
+ callback.reject(new Error(message.error));
8891
+ }
8892
+ }
8886
8893
  this.emitError(message.error, message.bufferId);
8887
8894
  return;
8888
8895
  }
@@ -10548,7 +10555,575 @@ function decodePasteBytes(bytes) {
10548
10555
  function stripAnsiSequences(text) {
10549
10556
  return stripANSI(text);
10550
10557
  }
10558
+ // src/lib/host-clipboard.internal.ts
10559
+ var DEFAULT_CLIPBOARD_TIMEOUT_MS = 1000;
10560
+ var DEFAULT_CLIPBOARD_MAX_BYTES = 8 * 1024 * 1024;
10561
+ var DEFAULT_CLIPBOARD_MAX_IMAGE_PIXELS = 64 * 1024 * 1024;
10562
+ var DEFAULT_CLIPBOARD_MAX_CONVERSION_BYTES = 512 * 1024 * 1024;
10563
+ var DEFAULT_CLIPBOARD_MAX_CONCURRENT_OPERATIONS = 16;
10564
+ var DEFAULT_CLIPBOARD_MAX_PROVIDER_TRANSFERS = 16;
10565
+ var MAX_U32 = 4294967295;
10566
+ var MIME_ESSENCE_PATTERN = /^[a-z0-9!#$%&'*+.^_`|~-]+\/[a-z0-9!#$%&'*+.^_`|~-]+$/i;
10567
+ var HOST_CLIPBOARD_MIME_PREFERENCE_COUNT_MAX = 64;
10568
+ var HOST_CLIPBOARD_MIME_ESSENCE_BYTES_MAX = 255;
10569
+ var validateU32 = (name, value) => {
10570
+ if (!Number.isInteger(value) || value < 0 || value > MAX_U32) {
10571
+ throw new RangeError(`${name} must be an integer from 0 through ${MAX_U32}`);
10572
+ }
10573
+ return value;
10574
+ };
10575
+ var validatePositiveU32 = (name, value) => {
10576
+ const validated = validateU32(name, value);
10577
+ if (validated === 0)
10578
+ throw new RangeError(`${name} must be greater than zero`);
10579
+ return validated;
10580
+ };
10581
+ var normalizeOptions = (options) => {
10582
+ const waylandSeat = options.waylandSeat;
10583
+ if (waylandSeat !== undefined && (typeof waylandSeat !== "string" || waylandSeat.length === 0 || waylandSeat.includes("\x00"))) {
10584
+ throw new TypeError("waylandSeat must be a non-empty string without NUL characters");
10585
+ }
10586
+ return {
10587
+ timeoutMs: validateU32("timeoutMs", options.timeoutMs ?? DEFAULT_CLIPBOARD_TIMEOUT_MS),
10588
+ maxReadBytes: validateU32("maxReadBytes", options.maxReadBytes ?? DEFAULT_CLIPBOARD_MAX_BYTES),
10589
+ maxWriteBytes: validateU32("maxWriteBytes", options.maxWriteBytes ?? DEFAULT_CLIPBOARD_MAX_BYTES),
10590
+ maxImagePixels: validateU32("maxImagePixels", options.maxImagePixels ?? DEFAULT_CLIPBOARD_MAX_IMAGE_PIXELS),
10591
+ maxConversionBytes: validateU32("maxConversionBytes", options.maxConversionBytes ?? DEFAULT_CLIPBOARD_MAX_CONVERSION_BYTES),
10592
+ maxConcurrentOperations: validatePositiveU32("maxConcurrentOperations", options.maxConcurrentOperations ?? DEFAULT_CLIPBOARD_MAX_CONCURRENT_OPERATIONS),
10593
+ maxProviderTransfers: validatePositiveU32("maxProviderTransfers", options.maxProviderTransfers ?? DEFAULT_CLIPBOARD_MAX_PROVIDER_TRANSFERS),
10594
+ waylandSeat
10595
+ };
10596
+ };
10597
+ var normalizePreferredTypes = (preferredTypes) => {
10598
+ if (!Array.isArray(preferredTypes) || preferredTypes.length === 0) {
10599
+ throw new TypeError("preferredTypes must contain at least one MIME essence type");
10600
+ }
10601
+ if (preferredTypes.length > HOST_CLIPBOARD_MIME_PREFERENCE_COUNT_MAX) {
10602
+ throw new RangeError(`preferredTypes must contain at most ${HOST_CLIPBOARD_MIME_PREFERENCE_COUNT_MAX} MIME essence types`);
10603
+ }
10604
+ const normalized = preferredTypes.map((mimeType) => {
10605
+ if (typeof mimeType !== "string") {
10606
+ throw new TypeError("preferredTypes must contain valid MIME essence types without parameters");
10607
+ }
10608
+ if (mimeType.length > HOST_CLIPBOARD_MIME_ESSENCE_BYTES_MAX) {
10609
+ throw new RangeError(`preferredTypes MIME essences must be at most ${HOST_CLIPBOARD_MIME_ESSENCE_BYTES_MAX} ASCII bytes`);
10610
+ }
10611
+ if (!MIME_ESSENCE_PATTERN.test(mimeType)) {
10612
+ throw new TypeError("preferredTypes must contain valid MIME essence types without parameters");
10613
+ }
10614
+ return mimeType.toLowerCase();
10615
+ });
10616
+ return normalized;
10617
+ };
10618
+ var normalizeSelection = (selection) => {
10619
+ const normalized = selection ?? "clipboard";
10620
+ if (normalized !== "clipboard" && normalized !== "primary") {
10621
+ throw new TypeError("selection must be clipboard or primary");
10622
+ }
10623
+ return normalized;
10624
+ };
10625
+ var validateClipboardText = (text, maxWriteBytes) => {
10626
+ if (typeof text !== "string" || text.length === 0)
10627
+ throw new TypeError("writeText requires non-empty text");
10628
+ if (text.includes("\x00"))
10629
+ throw new TypeError("writeText does not support NUL characters");
10630
+ const byteLimit = Math.min(maxWriteBytes, MAX_U32);
10631
+ let byteLength = 0;
10632
+ for (const character of text) {
10633
+ const codePoint = character.codePointAt(0);
10634
+ if (codePoint >= 55296 && codePoint <= 57343) {
10635
+ throw new TypeError("writeText does not support unpaired UTF-16 surrogates");
10636
+ }
10637
+ if (codePoint <= 127) {
10638
+ byteLength += 1;
10639
+ } else if (codePoint <= 2047) {
10640
+ byteLength += 2;
10641
+ } else if (codePoint <= 65535) {
10642
+ byteLength += 3;
10643
+ } else {
10644
+ byteLength += 4;
10645
+ }
10646
+ if (byteLength > byteLimit) {
10647
+ throw new RangeError(`writeText exceeds the configured ${maxWriteBytes} byte limit`);
10648
+ }
10649
+ }
10650
+ };
10651
+ var createActiveOperation = (callerSignal) => {
10652
+ const controller = new AbortController;
10653
+ let settle = () => {};
10654
+ const settled = new Promise((resolve3) => {
10655
+ settle = resolve3;
10656
+ });
10657
+ if (callerSignal) {
10658
+ callerSignal.addEventListener("abort", () => controller.abort(callerSignal.reason), {
10659
+ once: true,
10660
+ signal: controller.signal
10661
+ });
10662
+ }
10663
+ return { controller, settled, settle };
10664
+ };
10665
+ var runTrackedOperation = (active, callerSignal, operation) => {
10666
+ const state = createActiveOperation(callerSignal);
10667
+ active.add(state);
10668
+ let result;
10669
+ try {
10670
+ result = operation(state.controller.signal);
10671
+ } catch (error) {
10672
+ result = Promise.reject(error);
10673
+ }
10674
+ return result.finally(() => {
10675
+ active.delete(state);
10676
+ state.controller.abort();
10677
+ state.settle();
10678
+ });
10679
+ };
10680
+ var createHostClipboardWithBackend = (options, createBackend) => {
10681
+ const config = normalizeOptions(options);
10682
+ const backend2 = createBackend(config);
10683
+ const active = new Set;
10684
+ let disposed = false;
10685
+ let disposePromise;
10686
+ const assertUsable = () => {
10687
+ if (disposed)
10688
+ throw new Error("Host clipboard service is disposed");
10689
+ };
10690
+ return {
10691
+ maxWriteBytes: config.maxWriteBytes,
10692
+ read(readOptions) {
10693
+ try {
10694
+ assertUsable();
10695
+ const preferredTypes = normalizePreferredTypes(readOptions.preferredTypes);
10696
+ const selection = normalizeSelection(readOptions.selection);
10697
+ if (readOptions.signal?.aborted)
10698
+ return Promise.resolve({ status: "cancelled" });
10699
+ if (config.timeoutMs === 0)
10700
+ return Promise.resolve({ status: "timed-out" });
10701
+ return runTrackedOperation(active, readOptions.signal, async (signal) => {
10702
+ const result = await backend2.read({
10703
+ preferredTypes,
10704
+ selection,
10705
+ maxBytes: config.maxReadBytes,
10706
+ timeoutMs: config.timeoutMs,
10707
+ signal
10708
+ });
10709
+ if (result.status !== "read")
10710
+ return result;
10711
+ if (result.representation.bytes.byteLength > config.maxReadBytes)
10712
+ return { status: "limit-exceeded" };
10713
+ return { status: "read", representation: result.representation };
10714
+ });
10715
+ } catch (error) {
10716
+ return Promise.reject(error);
10717
+ }
10718
+ },
10719
+ writeText(text, operationOptions = {}) {
10720
+ try {
10721
+ assertUsable();
10722
+ validateClipboardText(text, config.maxWriteBytes);
10723
+ const selection = normalizeSelection(operationOptions.selection);
10724
+ if (operationOptions.signal?.aborted)
10725
+ return Promise.resolve({ status: "cancelled" });
10726
+ if (config.timeoutMs === 0)
10727
+ return Promise.resolve({ status: "timed-out" });
10728
+ return runTrackedOperation(active, operationOptions.signal, (signal) => backend2.writeText(text, { selection, timeoutMs: config.timeoutMs, signal }));
10729
+ } catch (error) {
10730
+ return Promise.reject(error);
10731
+ }
10732
+ },
10733
+ clear(operationOptions = {}) {
10734
+ try {
10735
+ assertUsable();
10736
+ const selection = normalizeSelection(operationOptions.selection);
10737
+ if (operationOptions.signal?.aborted)
10738
+ return Promise.resolve({ status: "cancelled" });
10739
+ if (config.timeoutMs === 0)
10740
+ return Promise.resolve({ status: "timed-out" });
10741
+ return runTrackedOperation(active, operationOptions.signal, (signal) => backend2.clear({ selection, timeoutMs: config.timeoutMs, signal }));
10742
+ } catch (error) {
10743
+ return Promise.reject(error);
10744
+ }
10745
+ },
10746
+ dispose() {
10747
+ if (disposePromise)
10748
+ return disposePromise;
10749
+ disposed = true;
10750
+ for (const operation of active)
10751
+ operation.controller.abort();
10752
+ disposePromise = (async () => {
10753
+ await Promise.all([...active].map((operation) => operation.settled));
10754
+ await backend2.dispose();
10755
+ })();
10756
+ return disposePromise;
10757
+ }
10758
+ };
10759
+ };
10760
+
10761
+ // src/lib/host-clipboard.native.ts
10762
+ var SHUTDOWN_POLL_INTERVAL_MS = 1;
10763
+ var OPERATION_POLL_INTERVAL_MS = 1;
10764
+ var PROVIDER_POLL_INTERVAL_MS = 8;
10765
+ var MAX_WORK_UNITS_PER_DRAIN = 64;
10766
+ var selectionValue = (selection) => selection === "clipboard" ? 0 : 1;
10767
+ var encodeReadRequest = (preferredTypes) => {
10768
+ const encoder = new TextEncoder;
10769
+ const encoded = preferredTypes.map((mimeType) => encoder.encode(mimeType));
10770
+ const size = encoded.reduce((total, mimeType) => total + 4 + mimeType.byteLength, 4);
10771
+ const request = new Uint8Array(size);
10772
+ const view = new DataView(request.buffer);
10773
+ view.setUint32(0, encoded.length, true);
10774
+ let offset = 4;
10775
+ for (const mimeType of encoded) {
10776
+ view.setUint32(offset, mimeType.byteLength, true);
10777
+ offset += 4;
10778
+ request.set(mimeType, offset);
10779
+ offset += mimeType.byteLength;
10780
+ }
10781
+ return request;
10782
+ };
10783
+ var startFailure = (status) => ({
10784
+ status: "failed",
10785
+ error: new Error(`Native clipboard operation failed to start (${NativeClipboardStartStatus[status]})`)
10786
+ });
10787
+
10788
+ class NativeClipboardBackend {
10789
+ maxImagePixels;
10790
+ maxConversionBytes;
10791
+ library;
10792
+ service;
10793
+ pending = new Map;
10794
+ pollTimer;
10795
+ pollTimerForOperation = false;
10796
+ providerActive = false;
10797
+ disposed = false;
10798
+ disposePromise;
10799
+ constructor(maxImagePixels, maxConversionBytes, maxConcurrentOperations, maxProviderTransfers, waylandSeat) {
10800
+ this.maxImagePixels = maxImagePixels;
10801
+ this.maxConversionBytes = maxConversionBytes;
10802
+ this.library = resolveRenderLib();
10803
+ const service = this.library.clipboardServiceCreate(maxConcurrentOperations, maxProviderTransfers, waylandSeat);
10804
+ if (!service)
10805
+ throw new Error("Failed to create native clipboard service");
10806
+ this.service = service;
10807
+ }
10808
+ read(options) {
10809
+ const request = encodeReadRequest(options.preferredTypes);
10810
+ const started = this.library.clipboardReadOperationStart(this.service, request, selectionValue(options.selection), options.maxBytes, this.maxImagePixels, this.maxConversionBytes, options.timeoutMs);
10811
+ return this.track(started, options.signal, "read");
10812
+ }
10813
+ writeText(text, options) {
10814
+ const started = this.library.clipboardWriteOperationStart(this.service, new TextEncoder().encode(text), selectionValue(options.selection), options.timeoutMs);
10815
+ return this.track(started, options.signal, "write");
10816
+ }
10817
+ clear(options) {
10818
+ const started = this.library.clipboardClearOperationStart(this.service, selectionValue(options.selection), options.timeoutMs);
10819
+ return this.track(started, options.signal, "clear");
10820
+ }
10821
+ dispose() {
10822
+ if (this.disposePromise)
10823
+ return this.disposePromise;
10824
+ this.disposed = true;
10825
+ this.disposePromise = this.shutdown();
10826
+ return this.disposePromise;
10827
+ }
10828
+ track(started, signal, kind) {
10829
+ if (this.disposed)
10830
+ return Promise.reject(new Error("Native clipboard backend is disposed"));
10831
+ if (started.status !== 0 /* Ok */ || !started.operation) {
10832
+ return Promise.resolve(startFailure(started.status));
10833
+ }
10834
+ return new Promise((resolve3, reject) => {
10835
+ const operation = { handle: started.operation, kind, signal, resolve: resolve3, reject };
10836
+ this.pending.set(operation.handle, operation);
10837
+ signal.addEventListener("abort", () => this.requestCancel(operation), { once: true });
10838
+ this.ensureScheduled();
10839
+ this.drain();
10840
+ });
10841
+ }
10842
+ requestCancel(operation) {
10843
+ if (!this.pending.has(operation.handle))
10844
+ return;
10845
+ try {
10846
+ this.library.clipboardOperationCancel(operation.handle);
10847
+ } catch (error) {
10848
+ operation.cleanupError ??= error;
10849
+ }
10850
+ this.ensureScheduled();
10851
+ }
10852
+ ensureScheduled() {
10853
+ const hasPendingOperation = this.pending.size > 0;
10854
+ if (!hasPendingOperation && !this.providerActive) {
10855
+ this.clearPollTimer();
10856
+ return;
10857
+ }
10858
+ if (this.pollTimer !== undefined) {
10859
+ if (hasPendingOperation && !this.pollTimerForOperation)
10860
+ this.clearPollTimer();
10861
+ else {
10862
+ if (hasPendingOperation)
10863
+ this.pollTimer.ref();
10864
+ else
10865
+ this.pollTimer.unref();
10866
+ return;
10867
+ }
10868
+ }
10869
+ this.pollTimerForOperation = hasPendingOperation;
10870
+ this.pollTimer = setTimeout(() => {
10871
+ this.pollTimer = undefined;
10872
+ this.pollTimerForOperation = false;
10873
+ this.drain();
10874
+ }, hasPendingOperation ? OPERATION_POLL_INTERVAL_MS : PROVIDER_POLL_INTERVAL_MS);
10875
+ if (!hasPendingOperation)
10876
+ this.pollTimer.unref();
10877
+ }
10878
+ clearPollTimer() {
10879
+ if (this.pollTimer === undefined)
10880
+ return;
10881
+ clearTimeout(this.pollTimer);
10882
+ this.pollTimer = undefined;
10883
+ this.pollTimerForOperation = false;
10884
+ }
10885
+ drain() {
10886
+ this.providerActive = false;
10887
+ try {
10888
+ this.providerActive = this.library.clipboardServiceDrain(this.service) === 1;
10889
+ } catch (error) {
10890
+ for (const operation of this.pending.values()) {
10891
+ operation.cleanupError ??= error;
10892
+ try {
10893
+ this.library.clipboardOperationCancel(operation.handle);
10894
+ } catch {}
10895
+ }
10896
+ }
10897
+ let workUnits = 0;
10898
+ while (workUnits < MAX_WORK_UNITS_PER_DRAIN && this.pending.size > 0) {
10899
+ const operation = this.pending.values().next().value;
10900
+ if (!operation)
10901
+ break;
10902
+ workUnits += 1;
10903
+ try {
10904
+ if (operation.cleanupError !== undefined) {
10905
+ try {
10906
+ this.library.clipboardOperationCancel(operation.handle);
10907
+ } catch {}
10908
+ const status2 = this.library.clipboardOperationPoll(operation.handle);
10909
+ if (status2 === 0 /* Pending */) {
10910
+ this.rotate(operation);
10911
+ continue;
10912
+ }
10913
+ this.providerActive = true;
10914
+ const destroyed2 = this.library.clipboardOperationDestroy(operation.handle);
10915
+ if (destroyed2 === 1 /* NotReady */) {
10916
+ this.rotate(operation);
10917
+ continue;
10918
+ }
10919
+ this.pending.delete(operation.handle);
10920
+ operation.reject(operation.cleanupError);
10921
+ continue;
10922
+ }
10923
+ if (operation.signal.aborted)
10924
+ this.library.clipboardOperationCancel(operation.handle);
10925
+ const status = this.library.clipboardOperationPoll(operation.handle);
10926
+ if (status === 0 /* Pending */) {
10927
+ this.rotate(operation);
10928
+ continue;
10929
+ }
10930
+ this.providerActive = true;
10931
+ const result = this.readResult(operation.handle, operation.kind, status);
10932
+ const destroyed = this.library.clipboardOperationDestroy(operation.handle);
10933
+ if (destroyed === 1 /* NotReady */) {
10934
+ this.rotate(operation);
10935
+ continue;
10936
+ }
10937
+ this.pending.delete(operation.handle);
10938
+ operation.resolve(destroyed === 0 /* Destroyed */ ? result : { status: "failed", error: new Error("Native clipboard operation became invalid before destruction") });
10939
+ } catch (error) {
10940
+ operation.cleanupError ??= error;
10941
+ try {
10942
+ this.library.clipboardOperationCancel(operation.handle);
10943
+ } catch {}
10944
+ this.rotate(operation);
10945
+ }
10946
+ }
10947
+ this.ensureScheduled();
10948
+ }
10949
+ rotate(operation) {
10950
+ this.pending.delete(operation.handle);
10951
+ this.pending.set(operation.handle, operation);
10952
+ }
10953
+ readResult(handle, kind, status) {
10954
+ switch (status) {
10955
+ case 1 /* Read */:
10956
+ return kind === "read" ? this.readRepresentation(handle) : this.invalidResult(kind, status);
10957
+ case 2 /* Empty */:
10958
+ return kind === "read" ? { status: "empty" } : this.invalidResult(kind, status);
10959
+ case 3 /* Written */:
10960
+ return kind === "write" ? { status: "written" } : this.invalidResult(kind, status);
10961
+ case 4 /* Cleared */:
10962
+ return kind === "clear" ? { status: "cleared" } : this.invalidResult(kind, status);
10963
+ case 5 /* Unsupported */:
10964
+ return { status: "unsupported" };
10965
+ case 6 /* Cancelled */:
10966
+ return { status: "cancelled" };
10967
+ case 7 /* TimedOut */:
10968
+ return { status: "timed-out" };
10969
+ case 8 /* LimitExceeded */:
10970
+ return kind === "read" ? { status: "limit-exceeded" } : this.invalidResult(kind, status);
10971
+ case 9 /* Failed */:
10972
+ return { status: "failed", error: this.readError(handle) };
10973
+ default:
10974
+ return { status: "failed", error: new Error("Native clipboard operation returned an invalid status") };
10975
+ }
10976
+ }
10977
+ invalidResult(kind, status) {
10978
+ return {
10979
+ status: "failed",
10980
+ error: new Error(`Native clipboard ${kind} returned inapplicable status ${NativeClipboardOperationStatus[status]}`)
10981
+ };
10982
+ }
10983
+ readRepresentation(handle) {
10984
+ const mimeLength = this.library.clipboardOperationResultMimeLength(handle);
10985
+ const dataLength = this.library.clipboardOperationResultDataLength(handle);
10986
+ if (mimeLength.status !== 0 /* Ok */ || dataLength.status !== 0 /* Ok */) {
10987
+ return { status: "failed", error: new Error("Failed to read native clipboard result lengths") };
10988
+ }
10989
+ const mime = new Uint8Array(mimeLength.length);
10990
+ const bytes = new Uint8Array(dataLength.length);
10991
+ if (this.library.clipboardOperationResultMimeCopy(handle, mime) !== 0 /* Ok */ || this.library.clipboardOperationResultDataCopy(handle, bytes) !== 0 /* Ok */) {
10992
+ return { status: "failed", error: new Error("Failed to copy native clipboard result") };
10993
+ }
10994
+ return { status: "read", representation: { mimeType: new TextDecoder().decode(mime), bytes } };
10995
+ }
10996
+ readError(handle) {
10997
+ const code = this.library.clipboardOperationResultErrorCode(handle);
10998
+ const length = this.library.clipboardOperationResultDiagnosticLength(handle);
10999
+ if (code.status !== 0 /* Ok */ || length.status !== 0 /* Ok */) {
11000
+ return new Error("Native clipboard operation failed without a readable diagnostic");
11001
+ }
11002
+ const diagnostic = new Uint8Array(length.length);
11003
+ if (this.library.clipboardOperationResultDiagnosticCopy(handle, diagnostic) !== 0 /* Ok */) {
11004
+ return new Error("Native clipboard operation failed without a readable diagnostic");
11005
+ }
11006
+ return Object.assign(new Error(new TextDecoder().decode(diagnostic)), { code: code.errorCode });
11007
+ }
11008
+ async shutdown() {
11009
+ this.clearPollTimer();
11010
+ let status = this.library.clipboardServiceBeginShutdown(this.service);
11011
+ while (status === 0 /* Pending */) {
11012
+ await new Promise((resolve3) => setTimeout(resolve3, SHUTDOWN_POLL_INTERVAL_MS));
11013
+ status = this.library.clipboardServicePollShutdown(this.service);
11014
+ }
11015
+ if (status !== 1 /* Ready */)
11016
+ throw new Error("Native clipboard service became invalid");
11017
+ if (this.library.clipboardServiceDestroy(this.service) !== 0 /* Destroyed */) {
11018
+ throw new Error("Failed to destroy native clipboard service");
11019
+ }
11020
+ }
11021
+ }
11022
+ var createNativeHostClipboardBackend = (options) => new NativeClipboardBackend(options.maxImagePixels, options.maxConversionBytes, options.maxConcurrentOperations, options.maxProviderTransfers, options.waylandSeat);
11023
+
10551
11024
  // src/lib/clipboard.ts
11025
+ var NOT_ATTEMPTED_TERMINAL = {
11026
+ status: "not-attempted",
11027
+ capability: "unknown"
11028
+ };
11029
+ var validateSelection = (selection) => {
11030
+ const normalized = selection ?? "clipboard";
11031
+ if (normalized !== "clipboard" && normalized !== "primary") {
11032
+ throw new TypeError("selection must be clipboard or primary");
11033
+ }
11034
+ return normalized;
11035
+ };
11036
+ var createHostClipboard = (options = {}) => createHostClipboardWithBackend(options, createNativeHostClipboardBackend);
11037
+ var validateDestination = (destination) => {
11038
+ if (destination !== "terminal-only" && destination !== "host-only" && destination !== "best-available" && destination !== "all-available") {
11039
+ throw new TypeError("destination is not a supported clipboard policy");
11040
+ }
11041
+ };
11042
+ var createClipboard = ({ host, terminal }) => {
11043
+ const active = new Set;
11044
+ let disposed = false;
11045
+ let disposePromise;
11046
+ const assertUsable = () => {
11047
+ if (disposed)
11048
+ throw new Error("Clipboard service is disposed");
11049
+ };
11050
+ const canUseRemoteHost = (options) => !terminal.remote || options.allowRemoteHost === true;
11051
+ const composeMutation = async (options, signal, hostOperation, terminalOperation) => {
11052
+ if (options.destination === "terminal-only") {
11053
+ return { host: { status: "not-attempted" }, terminal: terminalOperation() };
11054
+ }
11055
+ if (options.destination === "host-only") {
11056
+ const hostResult = canUseRemoteHost(options) ? await hostOperation() : { status: "not-attempted" };
11057
+ return { host: hostResult, terminal: NOT_ATTEMPTED_TERMINAL };
11058
+ }
11059
+ if (options.destination === "best-available") {
11060
+ if (terminal.remote) {
11061
+ return { host: { status: "not-attempted" }, terminal: terminalOperation() };
11062
+ }
11063
+ const hostResult = await hostOperation();
11064
+ const terminalResult2 = !signal.aborted && (hostResult.status === "unsupported" || hostResult.status === "failed") ? terminalOperation() : NOT_ATTEMPTED_TERMINAL;
11065
+ return { host: hostResult, terminal: terminalResult2 };
11066
+ }
11067
+ const hostPromise = canUseRemoteHost(options) ? hostOperation() : Promise.resolve({ status: "not-attempted" });
11068
+ const terminalResult = terminalOperation();
11069
+ return { host: await hostPromise, terminal: terminalResult };
11070
+ };
11071
+ return {
11072
+ read(options) {
11073
+ try {
11074
+ assertUsable();
11075
+ return host.read(options);
11076
+ } catch (error) {
11077
+ return Promise.reject(error);
11078
+ }
11079
+ },
11080
+ writeText(text, options) {
11081
+ try {
11082
+ assertUsable();
11083
+ validateDestination(options.destination);
11084
+ validateClipboardText(text, host.maxWriteBytes);
11085
+ const selection = validateSelection(options.selection);
11086
+ if (options.signal?.aborted) {
11087
+ return Promise.resolve({ host: { status: "not-attempted" }, terminal: NOT_ATTEMPTED_TERMINAL });
11088
+ }
11089
+ return runTrackedOperation(active, options.signal, (signal) => {
11090
+ const operationOptions = { selection, signal };
11091
+ return composeMutation(options, signal, () => host.writeText(text, operationOptions), () => terminal.writeText(text, selection));
11092
+ });
11093
+ } catch (error) {
11094
+ return Promise.reject(error);
11095
+ }
11096
+ },
11097
+ clear(options) {
11098
+ try {
11099
+ assertUsable();
11100
+ validateDestination(options.destination);
11101
+ const selection = validateSelection(options.selection);
11102
+ if (options.signal?.aborted) {
11103
+ return Promise.resolve({ host: { status: "not-attempted" }, terminal: NOT_ATTEMPTED_TERMINAL });
11104
+ }
11105
+ return runTrackedOperation(active, options.signal, (signal) => {
11106
+ const operationOptions = { selection, signal };
11107
+ return composeMutation(options, signal, () => host.clear(operationOptions), () => terminal.clear(selection));
11108
+ });
11109
+ } catch (error) {
11110
+ return Promise.reject(error);
11111
+ }
11112
+ },
11113
+ dispose() {
11114
+ if (disposePromise)
11115
+ return disposePromise;
11116
+ disposed = true;
11117
+ for (const operation of active)
11118
+ operation.controller.abort();
11119
+ disposePromise = (async () => {
11120
+ await Promise.all([...active].map((operation) => operation.settled));
11121
+ await host.dispose();
11122
+ })();
11123
+ return disposePromise;
11124
+ }
11125
+ };
11126
+ };
10552
11127
  var ClipboardTarget;
10553
11128
  ((ClipboardTarget2) => {
10554
11129
  ClipboardTarget2[ClipboardTarget2["Clipboard"] = 0] = "Clipboard";
@@ -10556,6 +11131,33 @@ var ClipboardTarget;
10556
11131
  ClipboardTarget2[ClipboardTarget2["Select"] = 2] = "Select";
10557
11132
  ClipboardTarget2[ClipboardTarget2["Secondary"] = 3] = "Secondary";
10558
11133
  })(ClipboardTarget ||= {});
11134
+ var createRendererClipboardAdapter = (renderer) => {
11135
+ const targetFor = (selection) => selection === "primary" ? 1 /* Primary */ : 0 /* Clipboard */;
11136
+ const capability = () => renderer.capabilities?.osc52_support ?? "unknown";
11137
+ return {
11138
+ get remote() {
11139
+ return renderer.capabilities?.remote ?? true;
11140
+ },
11141
+ writeText(text, selection) {
11142
+ const currentCapability = capability();
11143
+ if (currentCapability === "unsupported")
11144
+ return { status: "not-attempted", capability: currentCapability };
11145
+ return {
11146
+ status: renderer.copyToClipboardOSC52(text, targetFor(selection)) ? "attempted" : "local-failure",
11147
+ capability: currentCapability
11148
+ };
11149
+ },
11150
+ clear(selection) {
11151
+ const currentCapability = capability();
11152
+ if (currentCapability === "unsupported")
11153
+ return { status: "not-attempted", capability: currentCapability };
11154
+ return {
11155
+ status: renderer.clearClipboardOSC52(targetFor(selection)) ? "attempted" : "local-failure",
11156
+ capability: currentCapability
11157
+ };
11158
+ }
11159
+ };
11160
+ };
10559
11161
 
10560
11162
  class Clipboard {
10561
11163
  lib;
@@ -12782,6 +13384,55 @@ registerEnvVar({
12782
13384
  type: "string",
12783
13385
  default: ""
12784
13386
  });
13387
+ var NativeClipboardOperationStatus;
13388
+ ((NativeClipboardOperationStatus2) => {
13389
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["Pending"] = 0] = "Pending";
13390
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["Read"] = 1] = "Read";
13391
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["Empty"] = 2] = "Empty";
13392
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["Written"] = 3] = "Written";
13393
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["Cleared"] = 4] = "Cleared";
13394
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["Unsupported"] = 5] = "Unsupported";
13395
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["Cancelled"] = 6] = "Cancelled";
13396
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["TimedOut"] = 7] = "TimedOut";
13397
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["LimitExceeded"] = 8] = "LimitExceeded";
13398
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["Failed"] = 9] = "Failed";
13399
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["InvalidHandle"] = 10] = "InvalidHandle";
13400
+ })(NativeClipboardOperationStatus ||= {});
13401
+ var NativeClipboardStartStatus;
13402
+ ((NativeClipboardStartStatus2) => {
13403
+ NativeClipboardStartStatus2[NativeClipboardStartStatus2["Ok"] = 0] = "Ok";
13404
+ NativeClipboardStartStatus2[NativeClipboardStartStatus2["InvalidService"] = 1] = "InvalidService";
13405
+ NativeClipboardStartStatus2[NativeClipboardStartStatus2["ShuttingDown"] = 2] = "ShuttingDown";
13406
+ NativeClipboardStartStatus2[NativeClipboardStartStatus2["LimitExceeded"] = 3] = "LimitExceeded";
13407
+ NativeClipboardStartStatus2[NativeClipboardStartStatus2["InvalidArgument"] = 4] = "InvalidArgument";
13408
+ NativeClipboardStartStatus2[NativeClipboardStartStatus2["OutOfMemory"] = 5] = "OutOfMemory";
13409
+ })(NativeClipboardStartStatus ||= {});
13410
+ var NativeClipboardCancelStatus;
13411
+ ((NativeClipboardCancelStatus2) => {
13412
+ NativeClipboardCancelStatus2[NativeClipboardCancelStatus2["Requested"] = 0] = "Requested";
13413
+ NativeClipboardCancelStatus2[NativeClipboardCancelStatus2["AlreadyTerminal"] = 1] = "AlreadyTerminal";
13414
+ NativeClipboardCancelStatus2[NativeClipboardCancelStatus2["InvalidHandle"] = 2] = "InvalidHandle";
13415
+ })(NativeClipboardCancelStatus ||= {});
13416
+ var NativeClipboardCopyStatus;
13417
+ ((NativeClipboardCopyStatus2) => {
13418
+ NativeClipboardCopyStatus2[NativeClipboardCopyStatus2["Ok"] = 0] = "Ok";
13419
+ NativeClipboardCopyStatus2[NativeClipboardCopyStatus2["BufferTooSmall"] = 1] = "BufferTooSmall";
13420
+ NativeClipboardCopyStatus2[NativeClipboardCopyStatus2["InvalidHandle"] = 2] = "InvalidHandle";
13421
+ NativeClipboardCopyStatus2[NativeClipboardCopyStatus2["InvalidState"] = 3] = "InvalidState";
13422
+ NativeClipboardCopyStatus2[NativeClipboardCopyStatus2["InvalidArgument"] = 4] = "InvalidArgument";
13423
+ })(NativeClipboardCopyStatus ||= {});
13424
+ var NativeClipboardDestroyStatus;
13425
+ ((NativeClipboardDestroyStatus2) => {
13426
+ NativeClipboardDestroyStatus2[NativeClipboardDestroyStatus2["Destroyed"] = 0] = "Destroyed";
13427
+ NativeClipboardDestroyStatus2[NativeClipboardDestroyStatus2["NotReady"] = 1] = "NotReady";
13428
+ NativeClipboardDestroyStatus2[NativeClipboardDestroyStatus2["InvalidHandle"] = 2] = "InvalidHandle";
13429
+ })(NativeClipboardDestroyStatus ||= {});
13430
+ var NativeClipboardShutdownStatus;
13431
+ ((NativeClipboardShutdownStatus2) => {
13432
+ NativeClipboardShutdownStatus2[NativeClipboardShutdownStatus2["Pending"] = 0] = "Pending";
13433
+ NativeClipboardShutdownStatus2[NativeClipboardShutdownStatus2["Ready"] = 1] = "Ready";
13434
+ NativeClipboardShutdownStatus2[NativeClipboardShutdownStatus2["InvalidHandle"] = 2] = "InvalidHandle";
13435
+ })(NativeClipboardShutdownStatus ||= {});
12785
13436
  var targetLibPath;
12786
13437
  var targetLibError;
12787
13438
  try {
@@ -13144,6 +13795,78 @@ function getOpenTUILib(libPath) {
13144
13795
  args: ["u32", "u8"],
13145
13796
  returns: "bool"
13146
13797
  },
13798
+ clipboardServiceCreate: {
13799
+ args: ["u32", "u32", "ptr", "u32"],
13800
+ returns: "u32"
13801
+ },
13802
+ clipboardServiceBeginShutdown: {
13803
+ args: ["u32"],
13804
+ returns: "u8"
13805
+ },
13806
+ clipboardServicePollShutdown: {
13807
+ args: ["u32"],
13808
+ returns: "u8"
13809
+ },
13810
+ clipboardServiceDestroy: {
13811
+ args: ["u32"],
13812
+ returns: "u8"
13813
+ },
13814
+ clipboardServiceDrain: {
13815
+ args: ["u32"],
13816
+ returns: "u8"
13817
+ },
13818
+ clipboardReadOperationStart: {
13819
+ args: ["u32", "ptr", "u32", "u8", "u32", "u32", "u32", "u32", "ptr"],
13820
+ returns: "u8"
13821
+ },
13822
+ clipboardWriteOperationStart: {
13823
+ args: ["u32", "ptr", "u32", "u8", "u32", "ptr"],
13824
+ returns: "u8"
13825
+ },
13826
+ clipboardClearOperationStart: {
13827
+ args: ["u32", "u8", "u32", "ptr"],
13828
+ returns: "u8"
13829
+ },
13830
+ clipboardOperationPoll: {
13831
+ args: ["u32"],
13832
+ returns: "u8"
13833
+ },
13834
+ clipboardOperationCancel: {
13835
+ args: ["u32"],
13836
+ returns: "u8"
13837
+ },
13838
+ clipboardOperationResultMimeLength: {
13839
+ args: ["u32", "ptr"],
13840
+ returns: "u8"
13841
+ },
13842
+ clipboardOperationResultMimeCopy: {
13843
+ args: ["u32", "ptr", "u32"],
13844
+ returns: "u8"
13845
+ },
13846
+ clipboardOperationResultDataLength: {
13847
+ args: ["u32", "ptr"],
13848
+ returns: "u8"
13849
+ },
13850
+ clipboardOperationResultDataCopy: {
13851
+ args: ["u32", "ptr", "u32"],
13852
+ returns: "u8"
13853
+ },
13854
+ clipboardOperationResultErrorCode: {
13855
+ args: ["u32", "ptr"],
13856
+ returns: "u8"
13857
+ },
13858
+ clipboardOperationResultDiagnosticLength: {
13859
+ args: ["u32", "ptr"],
13860
+ returns: "u8"
13861
+ },
13862
+ clipboardOperationResultDiagnosticCopy: {
13863
+ args: ["u32", "ptr", "u32"],
13864
+ returns: "u8"
13865
+ },
13866
+ clipboardOperationDestroy: {
13867
+ args: ["u32"],
13868
+ returns: "u8"
13869
+ },
13147
13870
  triggerNotification: {
13148
13871
  args: ["u32", "ptr", "u32", "ptr", "u32"],
13149
13872
  returns: "bool"
@@ -13857,10 +14580,16 @@ function getOpenTUILib(libPath) {
13857
14580
  returns: "u32"
13858
14581
  },
13859
14582
  imageInfo: { args: ["ptr", "u32", "ptr"], returns: "u32" },
14583
+ imageRetainIccCache: { args: [], returns: "void" },
14584
+ imageReleaseIccCache: { args: [], returns: "void" },
14585
+ imageTestFailIccProfileCopyAllocationOnce: { args: [], returns: "void" },
13860
14586
  imageDecode: { args: ["ptr", "u32", "ptr"], returns: "u32" },
13861
14587
  imageCreateFromRgba: { args: ["ptr", "u64", "u32", "u32", "u32", "ptr"], returns: "u32" },
13862
14588
  imageDestroy: { args: ["u32"], returns: "void" },
14589
+ imageRetain: { args: ["u32", "ptr"], returns: "u32" },
13863
14590
  imageGetInfo: { args: ["u32", "ptr"], returns: "u32" },
14591
+ imageMaterialize: { args: ["u32"], returns: "u32" },
14592
+ imageEnsureEncodedPng: { args: ["u32"], returns: "u32" },
13864
14593
  imageGetPixelsPtr: { args: ["u32"], returns: "ptr" },
13865
14594
  imageClone: { args: ["u32", "ptr"], returns: "u32" },
13866
14595
  imageCopyPixels: { args: ["u32", "ptr", "u64", "u32", "u8"], returns: "u32" },
@@ -14467,6 +15196,7 @@ var NativeMeasureTargetKind = {
14467
15196
 
14468
15197
  class FFIRenderLib {
14469
15198
  opentui;
15199
+ iccCacheClient = false;
14470
15200
  yogaLayout = new Float32Array(6);
14471
15201
  yogaLayoutPtr = ptr(this.yogaLayout);
14472
15202
  ffiStructStorage = {
@@ -14507,6 +15237,8 @@ class FFIRenderLib {
14507
15237
  imageDrawOptions: allocStruct(ImageDrawOptionsStruct),
14508
15238
  gridDrawOptions: allocStruct(GridDrawOptionsStruct)
14509
15239
  };
15240
+ disposed = false;
15241
+ clipboardServices = new Set;
14510
15242
  encoder = new TextEncoder;
14511
15243
  decoder = new TextDecoder;
14512
15244
  logCallbackWrapper = null;
@@ -14533,6 +15265,8 @@ class FFIRenderLib {
14533
15265
  }
14534
15266
  constructor(libPath) {
14535
15267
  this.opentui = getOpenTUILib(libPath);
15268
+ this.imageRetainIccCache();
15269
+ this.iccCacheClient = true;
14536
15270
  try {
14537
15271
  this.setupLogging();
14538
15272
  this.setupEventBus();
@@ -14586,6 +15320,12 @@ class FFIRenderLib {
14586
15320
  this.opentui.symbols.setLogCallback(callbackPtr);
14587
15321
  }
14588
15322
  dispose() {
15323
+ if (this.disposed)
15324
+ return;
15325
+ if (this.clipboardServices.size > 0) {
15326
+ throw new Error("Cannot dispose OpenTUI native library while clipboard services are active");
15327
+ }
15328
+ this.disposed = true;
14589
15329
  try {
14590
15330
  if (this.eventSinkPtr) {
14591
15331
  this.opentui.symbols.destroyEventSink(this.eventSinkPtr);
@@ -14596,12 +15336,19 @@ class FFIRenderLib {
14596
15336
  this.setLogCallback(null);
14597
15337
  } finally {
14598
15338
  try {
14599
- this.opentui.close();
15339
+ if (this.iccCacheClient) {
15340
+ this.iccCacheClient = false;
15341
+ this.imageReleaseIccCache();
15342
+ }
14600
15343
  } finally {
14601
- this.eventCallbackWrapper = null;
14602
- this.logCallbackWrapper = null;
14603
- this.nativeSpanFeedCallbackWrapper = null;
14604
- this.nativeSpanFeedHandlers.clear();
15344
+ try {
15345
+ this.opentui.close();
15346
+ } finally {
15347
+ this.eventCallbackWrapper = null;
15348
+ this.logCallbackWrapper = null;
15349
+ this.nativeSpanFeedCallbackWrapper = null;
15350
+ this.nativeSpanFeedHandlers.clear();
15351
+ }
14605
15352
  }
14606
15353
  }
14607
15354
  }
@@ -14977,6 +15724,96 @@ class FFIRenderLib {
14977
15724
  clearClipboardOSC52(renderer, target) {
14978
15725
  return Boolean(this.opentui.symbols.clearClipboardOSC52(renderer, target));
14979
15726
  }
15727
+ clipboardServiceCreate(maxConcurrentOperations, maxProviderTransfers, waylandSeat) {
15728
+ const seat = waylandSeat === undefined ? null : this.encoder.encode(waylandSeat);
15729
+ const handle = this.opentui.symbols.clipboardServiceCreate(toSafeFFIU32Length(maxConcurrentOperations, "clipboard operation limit"), toSafeFFIU32Length(maxProviderTransfers, "clipboard provider transfer limit"), seat, seat?.byteLength ?? 0);
15730
+ if (handle === 0)
15731
+ return null;
15732
+ const service = handle;
15733
+ this.clipboardServices.add(service);
15734
+ return service;
15735
+ }
15736
+ clipboardServiceBeginShutdown(service) {
15737
+ if (!this.clipboardServices.has(service))
15738
+ return 2 /* InvalidHandle */;
15739
+ return this.opentui.symbols.clipboardServiceBeginShutdown(service);
15740
+ }
15741
+ clipboardServicePollShutdown(service) {
15742
+ if (!this.clipboardServices.has(service))
15743
+ return 2 /* InvalidHandle */;
15744
+ return this.opentui.symbols.clipboardServicePollShutdown(service);
15745
+ }
15746
+ clipboardServiceDestroy(service) {
15747
+ if (!this.clipboardServices.has(service))
15748
+ return 2 /* InvalidHandle */;
15749
+ const status = this.opentui.symbols.clipboardServiceDestroy(service);
15750
+ if (status === 0 /* Destroyed */)
15751
+ this.clipboardServices.delete(service);
15752
+ return status;
15753
+ }
15754
+ clipboardServiceDrain(service) {
15755
+ if (!this.clipboardServices.has(service))
15756
+ return 2;
15757
+ return this.opentui.symbols.clipboardServiceDrain(service);
15758
+ }
15759
+ clipboardStartResult(status, output) {
15760
+ return {
15761
+ status,
15762
+ operation: output[0] === 0 ? null : output[0]
15763
+ };
15764
+ }
15765
+ clipboardReadOperationStart(service, request, selection2, maxBytes, maxImagePixels, maxConversionBytes, timeoutMs) {
15766
+ const output = new Uint32Array(1);
15767
+ const status = this.opentui.symbols.clipboardReadOperationStart(service, request, toSafeFFIU32Length(request.byteLength, "clipboard read request"), selection2, toSafeFFIU32Length(maxBytes, "clipboard read byte limit"), toSafeFFIU32Length(maxImagePixels, "clipboard image pixel limit"), toSafeFFIU32Length(maxConversionBytes, "clipboard conversion byte limit"), toSafeFFIU32Length(timeoutMs, "clipboard read timeout"), output);
15768
+ return this.clipboardStartResult(status, output);
15769
+ }
15770
+ clipboardWriteOperationStart(service, textUtf8, selection2, timeoutMs) {
15771
+ const output = new Uint32Array(1);
15772
+ const status = this.opentui.symbols.clipboardWriteOperationStart(service, textUtf8, toSafeFFIU32Length(textUtf8.byteLength, "clipboard write text"), selection2, toSafeFFIU32Length(timeoutMs, "clipboard write timeout"), output);
15773
+ return this.clipboardStartResult(status, output);
15774
+ }
15775
+ clipboardClearOperationStart(service, selection2, timeoutMs) {
15776
+ const output = new Uint32Array(1);
15777
+ const status = this.opentui.symbols.clipboardClearOperationStart(service, selection2, toSafeFFIU32Length(timeoutMs, "clipboard clear timeout"), output);
15778
+ return this.clipboardStartResult(status, output);
15779
+ }
15780
+ clipboardOperationPoll(operation) {
15781
+ return this.opentui.symbols.clipboardOperationPoll(operation);
15782
+ }
15783
+ clipboardOperationCancel(operation) {
15784
+ return this.opentui.symbols.clipboardOperationCancel(operation);
15785
+ }
15786
+ clipboardResultLength(symbol, operation) {
15787
+ const output = new Uint32Array(1);
15788
+ const status = symbol(operation, output);
15789
+ return { status, length: output[0] };
15790
+ }
15791
+ clipboardOperationResultMimeLength(operation) {
15792
+ return this.clipboardResultLength(this.opentui.symbols.clipboardOperationResultMimeLength, operation);
15793
+ }
15794
+ clipboardOperationResultMimeCopy(operation, output) {
15795
+ return this.opentui.symbols.clipboardOperationResultMimeCopy(operation, output.byteLength === 0 ? null : output, toSafeFFIU32Length(output.byteLength, "clipboard MIME output"));
15796
+ }
15797
+ clipboardOperationResultDataLength(operation) {
15798
+ return this.clipboardResultLength(this.opentui.symbols.clipboardOperationResultDataLength, operation);
15799
+ }
15800
+ clipboardOperationResultDataCopy(operation, output) {
15801
+ return this.opentui.symbols.clipboardOperationResultDataCopy(operation, output.byteLength === 0 ? null : output, toSafeFFIU32Length(output.byteLength, "clipboard data output"));
15802
+ }
15803
+ clipboardOperationResultErrorCode(operation) {
15804
+ const output = new Uint32Array(1);
15805
+ const status = this.opentui.symbols.clipboardOperationResultErrorCode(operation, output);
15806
+ return { status, errorCode: output[0] };
15807
+ }
15808
+ clipboardOperationResultDiagnosticLength(operation) {
15809
+ return this.clipboardResultLength(this.opentui.symbols.clipboardOperationResultDiagnosticLength, operation);
15810
+ }
15811
+ clipboardOperationResultDiagnosticCopy(operation, output) {
15812
+ return this.opentui.symbols.clipboardOperationResultDiagnosticCopy(operation, output.byteLength === 0 ? null : output, toSafeFFIU32Length(output.byteLength, "clipboard diagnostic output"));
15813
+ }
15814
+ clipboardOperationDestroy(operation) {
15815
+ return this.opentui.symbols.clipboardOperationDestroy(operation);
15816
+ }
14980
15817
  triggerNotification(renderer, message, title) {
14981
15818
  const messageBytes = this.encoder.encode(message);
14982
15819
  const titleBytes = title === undefined ? null : this.encoder.encode(title);
@@ -16358,6 +17195,19 @@ class FFIRenderLib {
16358
17195
  imageDestroy(image) {
16359
17196
  this.opentui.symbols.imageDestroy(image);
16360
17197
  }
17198
+ imageRetain(image) {
17199
+ const output = new Uint32Array(1);
17200
+ return this.imageHandleResult(this.opentui.symbols.imageRetain(image, output), output);
17201
+ }
17202
+ imageRetainIccCache() {
17203
+ this.opentui.symbols.imageRetainIccCache();
17204
+ }
17205
+ imageReleaseIccCache() {
17206
+ this.opentui.symbols.imageReleaseIccCache();
17207
+ }
17208
+ imageTestFailIccProfileCopyAllocationOnce() {
17209
+ this.opentui.symbols.imageTestFailIccProfileCopyAllocationOnce();
17210
+ }
16361
17211
  imageGetInfo(image) {
16362
17212
  const output = new ArrayBuffer(NativeImageInfoStruct.size);
16363
17213
  const status = this.opentui.symbols.imageGetInfo(image, output);
@@ -16367,6 +17217,12 @@ class FFIRenderLib {
16367
17217
  const pointer = this.opentui.symbols.imageGetPixelsPtr(image);
16368
17218
  return pointer === null || pointer === 0 || pointer === 0n ? null : pointer;
16369
17219
  }
17220
+ imageMaterialize(image) {
17221
+ return this.opentui.symbols.imageMaterialize(image);
17222
+ }
17223
+ imageEnsureEncodedPng(image) {
17224
+ return this.opentui.symbols.imageEnsureEncodedPng(image);
17225
+ }
16370
17226
  imageClone(image) {
16371
17227
  const output = new Uint32Array(1);
16372
17228
  return this.imageHandleResult(this.opentui.symbols.imageClone(image, output), output);
@@ -17410,7 +18266,7 @@ var Yoga = {
17410
18266
  };
17411
18267
  var yoga_default = Yoga;
17412
18268
 
17413
- export { toArrayBuffer, singleton, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, sleep, stringWidth2 as stringWidth, resolveBundledFilePath, DEFAULT_FOREGROUND_RGB, DEFAULT_BACKGROUND_RGB, normalizeIndexedColorIndex, ansi256IndexToRgb, RGBA, normalizeColorValue, hexToRgb, rgbToHex, hsvToRgb, parseColor, isValidBorderStyle, parseBorderStyle, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, 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, StdinParser, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extensionToFiletype, basenameToFiletype, extToFiletype, pathToFiletype, infoStringToFiletype, getTreeSitterClient, destroyTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, normalizeTerminalPalette, buildTerminalPaletteSignature, decodePasteBytes, stripAnsiSequences, ClipboardTarget, Clipboard, detectLinks, OptimizedBuffer, TextBuffer, SpanInfoStruct, NativeAudioStreamFormat, NativeAudioStreamState, NativeAudioStreamStateNames, NativeAudioStreamCloseReason, NativeAudioStreamState2 as NativeAudioStreamState1, NativeAudioStreamCloseReason2 as NativeAudioStreamCloseReason1, NativeAudioStreamFormat2 as NativeAudioStreamFormat1, LogLevel2 as LogLevel, NativeMeasureTargetKind, setRenderLibPath, resolveRenderLib, Align, BoxSizing, Dimension, Direction, Display, Edge, Errata, ExperimentalFeature, FlexDirection, Gutter, Justify, LogLevel as LogLevel1, MeasureMode, NodeType, Overflow, PositionType, Unit, Wrap, ALIGN_AUTO, ALIGN_FLEX_START, ALIGN_CENTER, ALIGN_FLEX_END, ALIGN_STRETCH, ALIGN_BASELINE, ALIGN_SPACE_BETWEEN, ALIGN_SPACE_AROUND, ALIGN_SPACE_EVENLY, BOX_SIZING_BORDER_BOX, BOX_SIZING_CONTENT_BOX, DIMENSION_WIDTH, DIMENSION_HEIGHT, DIRECTION_INHERIT, DIRECTION_LTR, DIRECTION_RTL, DISPLAY_FLEX, DISPLAY_NONE, DISPLAY_CONTENTS, EDGE_LEFT, EDGE_TOP, EDGE_RIGHT, EDGE_BOTTOM, EDGE_START, EDGE_END, EDGE_HORIZONTAL, EDGE_VERTICAL, EDGE_ALL, ERRATA_NONE, ERRATA_STRETCH_FLEX_BASIS, ERRATA_ABSOLUTE_POSITION_WITHOUT_INSETS_EXCLUDES_PADDING, ERRATA_ABSOLUTE_PERCENT_AGAINST_INNER_SIZE, ERRATA_ALL, ERRATA_CLASSIC, EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS, FLEX_DIRECTION_COLUMN, FLEX_DIRECTION_COLUMN_REVERSE, FLEX_DIRECTION_ROW, FLEX_DIRECTION_ROW_REVERSE, GUTTER_COLUMN, GUTTER_ROW, GUTTER_ALL, JUSTIFY_FLEX_START, JUSTIFY_CENTER, JUSTIFY_FLEX_END, JUSTIFY_SPACE_BETWEEN, JUSTIFY_SPACE_AROUND, JUSTIFY_SPACE_EVENLY, LOG_LEVEL_ERROR, LOG_LEVEL_WARN, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_VERBOSE, LOG_LEVEL_FATAL, MEASURE_MODE_UNDEFINED, MEASURE_MODE_EXACTLY, MEASURE_MODE_AT_MOST, NODE_TYPE_DEFAULT, NODE_TYPE_TEXT, OVERFLOW_VISIBLE, OVERFLOW_HIDDEN, OVERFLOW_SCROLL, POSITION_TYPE_STATIC, POSITION_TYPE_RELATIVE, POSITION_TYPE_ABSOLUTE, UNIT_UNDEFINED, UNIT_POINT, UNIT_PERCENT, UNIT_AUTO, WRAP_NO_WRAP, WRAP_WRAP, WRAP_WRAP_REVERSE, Config, Node, exports_yoga, yoga_default };
18269
+ export { toArrayBuffer, singleton, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, sleep, stringWidth2 as stringWidth, resolveBundledFilePath, DEFAULT_FOREGROUND_RGB, DEFAULT_BACKGROUND_RGB, normalizeIndexedColorIndex, ansi256IndexToRgb, RGBA, normalizeColorValue, hexToRgb, rgbToHex, hsvToRgb, parseColor, isValidBorderStyle, parseBorderStyle, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, 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, StdinParser, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extensionToFiletype, basenameToFiletype, extToFiletype, pathToFiletype, infoStringToFiletype, getTreeSitterClient, destroyTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, normalizeTerminalPalette, buildTerminalPaletteSignature, decodePasteBytes, stripAnsiSequences, createHostClipboard, createClipboard, ClipboardTarget, createRendererClipboardAdapter, Clipboard, detectLinks, OptimizedBuffer, TextBuffer, SpanInfoStruct, NativeAudioStreamFormat, NativeAudioStreamState, NativeAudioStreamStateNames, NativeAudioStreamCloseReason, NativeAudioStreamState2 as NativeAudioStreamState1, NativeAudioStreamCloseReason2 as NativeAudioStreamCloseReason1, NativeAudioStreamFormat2 as NativeAudioStreamFormat1, NativeClipboardOperationStatus, NativeClipboardStartStatus, NativeClipboardCancelStatus, NativeClipboardCopyStatus, NativeClipboardDestroyStatus, NativeClipboardShutdownStatus, LogLevel2 as LogLevel, NativeMeasureTargetKind, setRenderLibPath, resolveRenderLib, Align, BoxSizing, Dimension, Direction, Display, Edge, Errata, ExperimentalFeature, FlexDirection, Gutter, Justify, LogLevel as LogLevel1, MeasureMode, NodeType, Overflow, PositionType, Unit, Wrap, ALIGN_AUTO, ALIGN_FLEX_START, ALIGN_CENTER, ALIGN_FLEX_END, ALIGN_STRETCH, ALIGN_BASELINE, ALIGN_SPACE_BETWEEN, ALIGN_SPACE_AROUND, ALIGN_SPACE_EVENLY, BOX_SIZING_BORDER_BOX, BOX_SIZING_CONTENT_BOX, DIMENSION_WIDTH, DIMENSION_HEIGHT, DIRECTION_INHERIT, DIRECTION_LTR, DIRECTION_RTL, DISPLAY_FLEX, DISPLAY_NONE, DISPLAY_CONTENTS, EDGE_LEFT, EDGE_TOP, EDGE_RIGHT, EDGE_BOTTOM, EDGE_START, EDGE_END, EDGE_HORIZONTAL, EDGE_VERTICAL, EDGE_ALL, ERRATA_NONE, ERRATA_STRETCH_FLEX_BASIS, ERRATA_ABSOLUTE_POSITION_WITHOUT_INSETS_EXCLUDES_PADDING, ERRATA_ABSOLUTE_PERCENT_AGAINST_INNER_SIZE, ERRATA_ALL, ERRATA_CLASSIC, EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS, FLEX_DIRECTION_COLUMN, FLEX_DIRECTION_COLUMN_REVERSE, FLEX_DIRECTION_ROW, FLEX_DIRECTION_ROW_REVERSE, GUTTER_COLUMN, GUTTER_ROW, GUTTER_ALL, JUSTIFY_FLEX_START, JUSTIFY_CENTER, JUSTIFY_FLEX_END, JUSTIFY_SPACE_BETWEEN, JUSTIFY_SPACE_AROUND, JUSTIFY_SPACE_EVENLY, LOG_LEVEL_ERROR, LOG_LEVEL_WARN, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_VERBOSE, LOG_LEVEL_FATAL, MEASURE_MODE_UNDEFINED, MEASURE_MODE_EXACTLY, MEASURE_MODE_AT_MOST, NODE_TYPE_DEFAULT, NODE_TYPE_TEXT, OVERFLOW_VISIBLE, OVERFLOW_HIDDEN, OVERFLOW_SCROLL, POSITION_TYPE_STATIC, POSITION_TYPE_RELATIVE, POSITION_TYPE_ABSOLUTE, UNIT_UNDEFINED, UNIT_POINT, UNIT_PERCENT, UNIT_AUTO, WRAP_NO_WRAP, WRAP_WRAP, WRAP_WRAP_REVERSE, Config, Node, exports_yoga, yoga_default };
17414
18270
 
17415
- //# debugId=A5B84FFA1E40FFEB64756E2164756E21
17416
- //# sourceMappingURL=chunk-bun-ctxxvhwz.js.map
18271
+ //# debugId=B3125C50E879066564756E2164756E21
18272
+ //# sourceMappingURL=chunk-bun-26r5c5w5.js.map