@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.
@@ -8862,6 +8862,13 @@ class TreeSitterClient extends EventEmitter2 {
8862
8862
  return;
8863
8863
  }
8864
8864
  case "ERROR": {
8865
+ if (message.messageId) {
8866
+ const callback = this.messageCallbacks.get(message.messageId);
8867
+ if (callback) {
8868
+ this.messageCallbacks.delete(message.messageId);
8869
+ callback.reject(new Error(message.error));
8870
+ }
8871
+ }
8865
8872
  this.emitError(message.error, message.bufferId);
8866
8873
  return;
8867
8874
  }
@@ -10527,7 +10534,575 @@ function decodePasteBytes(bytes) {
10527
10534
  function stripAnsiSequences(text) {
10528
10535
  return stripANSI(text);
10529
10536
  }
10537
+ // src/lib/host-clipboard.internal.ts
10538
+ var DEFAULT_CLIPBOARD_TIMEOUT_MS = 1000;
10539
+ var DEFAULT_CLIPBOARD_MAX_BYTES = 8 * 1024 * 1024;
10540
+ var DEFAULT_CLIPBOARD_MAX_IMAGE_PIXELS = 64 * 1024 * 1024;
10541
+ var DEFAULT_CLIPBOARD_MAX_CONVERSION_BYTES = 512 * 1024 * 1024;
10542
+ var DEFAULT_CLIPBOARD_MAX_CONCURRENT_OPERATIONS = 16;
10543
+ var DEFAULT_CLIPBOARD_MAX_PROVIDER_TRANSFERS = 16;
10544
+ var MAX_U32 = 4294967295;
10545
+ var MIME_ESSENCE_PATTERN = /^[a-z0-9!#$%&'*+.^_`|~-]+\/[a-z0-9!#$%&'*+.^_`|~-]+$/i;
10546
+ var HOST_CLIPBOARD_MIME_PREFERENCE_COUNT_MAX = 64;
10547
+ var HOST_CLIPBOARD_MIME_ESSENCE_BYTES_MAX = 255;
10548
+ var validateU32 = (name, value) => {
10549
+ if (!Number.isInteger(value) || value < 0 || value > MAX_U32) {
10550
+ throw new RangeError(`${name} must be an integer from 0 through ${MAX_U32}`);
10551
+ }
10552
+ return value;
10553
+ };
10554
+ var validatePositiveU32 = (name, value) => {
10555
+ const validated = validateU32(name, value);
10556
+ if (validated === 0)
10557
+ throw new RangeError(`${name} must be greater than zero`);
10558
+ return validated;
10559
+ };
10560
+ var normalizeOptions = (options) => {
10561
+ const waylandSeat = options.waylandSeat;
10562
+ if (waylandSeat !== undefined && (typeof waylandSeat !== "string" || waylandSeat.length === 0 || waylandSeat.includes("\x00"))) {
10563
+ throw new TypeError("waylandSeat must be a non-empty string without NUL characters");
10564
+ }
10565
+ return {
10566
+ timeoutMs: validateU32("timeoutMs", options.timeoutMs ?? DEFAULT_CLIPBOARD_TIMEOUT_MS),
10567
+ maxReadBytes: validateU32("maxReadBytes", options.maxReadBytes ?? DEFAULT_CLIPBOARD_MAX_BYTES),
10568
+ maxWriteBytes: validateU32("maxWriteBytes", options.maxWriteBytes ?? DEFAULT_CLIPBOARD_MAX_BYTES),
10569
+ maxImagePixels: validateU32("maxImagePixels", options.maxImagePixels ?? DEFAULT_CLIPBOARD_MAX_IMAGE_PIXELS),
10570
+ maxConversionBytes: validateU32("maxConversionBytes", options.maxConversionBytes ?? DEFAULT_CLIPBOARD_MAX_CONVERSION_BYTES),
10571
+ maxConcurrentOperations: validatePositiveU32("maxConcurrentOperations", options.maxConcurrentOperations ?? DEFAULT_CLIPBOARD_MAX_CONCURRENT_OPERATIONS),
10572
+ maxProviderTransfers: validatePositiveU32("maxProviderTransfers", options.maxProviderTransfers ?? DEFAULT_CLIPBOARD_MAX_PROVIDER_TRANSFERS),
10573
+ waylandSeat
10574
+ };
10575
+ };
10576
+ var normalizePreferredTypes = (preferredTypes) => {
10577
+ if (!Array.isArray(preferredTypes) || preferredTypes.length === 0) {
10578
+ throw new TypeError("preferredTypes must contain at least one MIME essence type");
10579
+ }
10580
+ if (preferredTypes.length > HOST_CLIPBOARD_MIME_PREFERENCE_COUNT_MAX) {
10581
+ throw new RangeError(`preferredTypes must contain at most ${HOST_CLIPBOARD_MIME_PREFERENCE_COUNT_MAX} MIME essence types`);
10582
+ }
10583
+ const normalized = preferredTypes.map((mimeType) => {
10584
+ if (typeof mimeType !== "string") {
10585
+ throw new TypeError("preferredTypes must contain valid MIME essence types without parameters");
10586
+ }
10587
+ if (mimeType.length > HOST_CLIPBOARD_MIME_ESSENCE_BYTES_MAX) {
10588
+ throw new RangeError(`preferredTypes MIME essences must be at most ${HOST_CLIPBOARD_MIME_ESSENCE_BYTES_MAX} ASCII bytes`);
10589
+ }
10590
+ if (!MIME_ESSENCE_PATTERN.test(mimeType)) {
10591
+ throw new TypeError("preferredTypes must contain valid MIME essence types without parameters");
10592
+ }
10593
+ return mimeType.toLowerCase();
10594
+ });
10595
+ return normalized;
10596
+ };
10597
+ var normalizeSelection = (selection) => {
10598
+ const normalized = selection ?? "clipboard";
10599
+ if (normalized !== "clipboard" && normalized !== "primary") {
10600
+ throw new TypeError("selection must be clipboard or primary");
10601
+ }
10602
+ return normalized;
10603
+ };
10604
+ var validateClipboardText = (text, maxWriteBytes) => {
10605
+ if (typeof text !== "string" || text.length === 0)
10606
+ throw new TypeError("writeText requires non-empty text");
10607
+ if (text.includes("\x00"))
10608
+ throw new TypeError("writeText does not support NUL characters");
10609
+ const byteLimit = Math.min(maxWriteBytes, MAX_U32);
10610
+ let byteLength = 0;
10611
+ for (const character of text) {
10612
+ const codePoint = character.codePointAt(0);
10613
+ if (codePoint >= 55296 && codePoint <= 57343) {
10614
+ throw new TypeError("writeText does not support unpaired UTF-16 surrogates");
10615
+ }
10616
+ if (codePoint <= 127) {
10617
+ byteLength += 1;
10618
+ } else if (codePoint <= 2047) {
10619
+ byteLength += 2;
10620
+ } else if (codePoint <= 65535) {
10621
+ byteLength += 3;
10622
+ } else {
10623
+ byteLength += 4;
10624
+ }
10625
+ if (byteLength > byteLimit) {
10626
+ throw new RangeError(`writeText exceeds the configured ${maxWriteBytes} byte limit`);
10627
+ }
10628
+ }
10629
+ };
10630
+ var createActiveOperation = (callerSignal) => {
10631
+ const controller = new AbortController;
10632
+ let settle = () => {};
10633
+ const settled = new Promise((resolve3) => {
10634
+ settle = resolve3;
10635
+ });
10636
+ if (callerSignal) {
10637
+ callerSignal.addEventListener("abort", () => controller.abort(callerSignal.reason), {
10638
+ once: true,
10639
+ signal: controller.signal
10640
+ });
10641
+ }
10642
+ return { controller, settled, settle };
10643
+ };
10644
+ var runTrackedOperation = (active, callerSignal, operation) => {
10645
+ const state = createActiveOperation(callerSignal);
10646
+ active.add(state);
10647
+ let result;
10648
+ try {
10649
+ result = operation(state.controller.signal);
10650
+ } catch (error) {
10651
+ result = Promise.reject(error);
10652
+ }
10653
+ return result.finally(() => {
10654
+ active.delete(state);
10655
+ state.controller.abort();
10656
+ state.settle();
10657
+ });
10658
+ };
10659
+ var createHostClipboardWithBackend = (options, createBackend) => {
10660
+ const config = normalizeOptions(options);
10661
+ const backend2 = createBackend(config);
10662
+ const active = new Set;
10663
+ let disposed = false;
10664
+ let disposePromise;
10665
+ const assertUsable = () => {
10666
+ if (disposed)
10667
+ throw new Error("Host clipboard service is disposed");
10668
+ };
10669
+ return {
10670
+ maxWriteBytes: config.maxWriteBytes,
10671
+ read(readOptions) {
10672
+ try {
10673
+ assertUsable();
10674
+ const preferredTypes = normalizePreferredTypes(readOptions.preferredTypes);
10675
+ const selection = normalizeSelection(readOptions.selection);
10676
+ if (readOptions.signal?.aborted)
10677
+ return Promise.resolve({ status: "cancelled" });
10678
+ if (config.timeoutMs === 0)
10679
+ return Promise.resolve({ status: "timed-out" });
10680
+ return runTrackedOperation(active, readOptions.signal, async (signal) => {
10681
+ const result = await backend2.read({
10682
+ preferredTypes,
10683
+ selection,
10684
+ maxBytes: config.maxReadBytes,
10685
+ timeoutMs: config.timeoutMs,
10686
+ signal
10687
+ });
10688
+ if (result.status !== "read")
10689
+ return result;
10690
+ if (result.representation.bytes.byteLength > config.maxReadBytes)
10691
+ return { status: "limit-exceeded" };
10692
+ return { status: "read", representation: result.representation };
10693
+ });
10694
+ } catch (error) {
10695
+ return Promise.reject(error);
10696
+ }
10697
+ },
10698
+ writeText(text, operationOptions = {}) {
10699
+ try {
10700
+ assertUsable();
10701
+ validateClipboardText(text, config.maxWriteBytes);
10702
+ const selection = normalizeSelection(operationOptions.selection);
10703
+ if (operationOptions.signal?.aborted)
10704
+ return Promise.resolve({ status: "cancelled" });
10705
+ if (config.timeoutMs === 0)
10706
+ return Promise.resolve({ status: "timed-out" });
10707
+ return runTrackedOperation(active, operationOptions.signal, (signal) => backend2.writeText(text, { selection, timeoutMs: config.timeoutMs, signal }));
10708
+ } catch (error) {
10709
+ return Promise.reject(error);
10710
+ }
10711
+ },
10712
+ clear(operationOptions = {}) {
10713
+ try {
10714
+ assertUsable();
10715
+ const selection = normalizeSelection(operationOptions.selection);
10716
+ if (operationOptions.signal?.aborted)
10717
+ return Promise.resolve({ status: "cancelled" });
10718
+ if (config.timeoutMs === 0)
10719
+ return Promise.resolve({ status: "timed-out" });
10720
+ return runTrackedOperation(active, operationOptions.signal, (signal) => backend2.clear({ selection, timeoutMs: config.timeoutMs, signal }));
10721
+ } catch (error) {
10722
+ return Promise.reject(error);
10723
+ }
10724
+ },
10725
+ dispose() {
10726
+ if (disposePromise)
10727
+ return disposePromise;
10728
+ disposed = true;
10729
+ for (const operation of active)
10730
+ operation.controller.abort();
10731
+ disposePromise = (async () => {
10732
+ await Promise.all([...active].map((operation) => operation.settled));
10733
+ await backend2.dispose();
10734
+ })();
10735
+ return disposePromise;
10736
+ }
10737
+ };
10738
+ };
10739
+
10740
+ // src/lib/host-clipboard.native.ts
10741
+ var SHUTDOWN_POLL_INTERVAL_MS = 1;
10742
+ var OPERATION_POLL_INTERVAL_MS = 1;
10743
+ var PROVIDER_POLL_INTERVAL_MS = 8;
10744
+ var MAX_WORK_UNITS_PER_DRAIN = 64;
10745
+ var selectionValue = (selection) => selection === "clipboard" ? 0 : 1;
10746
+ var encodeReadRequest = (preferredTypes) => {
10747
+ const encoder = new TextEncoder;
10748
+ const encoded = preferredTypes.map((mimeType) => encoder.encode(mimeType));
10749
+ const size = encoded.reduce((total, mimeType) => total + 4 + mimeType.byteLength, 4);
10750
+ const request = new Uint8Array(size);
10751
+ const view = new DataView(request.buffer);
10752
+ view.setUint32(0, encoded.length, true);
10753
+ let offset = 4;
10754
+ for (const mimeType of encoded) {
10755
+ view.setUint32(offset, mimeType.byteLength, true);
10756
+ offset += 4;
10757
+ request.set(mimeType, offset);
10758
+ offset += mimeType.byteLength;
10759
+ }
10760
+ return request;
10761
+ };
10762
+ var startFailure = (status) => ({
10763
+ status: "failed",
10764
+ error: new Error(`Native clipboard operation failed to start (${NativeClipboardStartStatus[status]})`)
10765
+ });
10766
+
10767
+ class NativeClipboardBackend {
10768
+ maxImagePixels;
10769
+ maxConversionBytes;
10770
+ library;
10771
+ service;
10772
+ pending = new Map;
10773
+ pollTimer;
10774
+ pollTimerForOperation = false;
10775
+ providerActive = false;
10776
+ disposed = false;
10777
+ disposePromise;
10778
+ constructor(maxImagePixels, maxConversionBytes, maxConcurrentOperations, maxProviderTransfers, waylandSeat) {
10779
+ this.maxImagePixels = maxImagePixels;
10780
+ this.maxConversionBytes = maxConversionBytes;
10781
+ this.library = resolveRenderLib();
10782
+ const service = this.library.clipboardServiceCreate(maxConcurrentOperations, maxProviderTransfers, waylandSeat);
10783
+ if (!service)
10784
+ throw new Error("Failed to create native clipboard service");
10785
+ this.service = service;
10786
+ }
10787
+ read(options) {
10788
+ const request = encodeReadRequest(options.preferredTypes);
10789
+ const started = this.library.clipboardReadOperationStart(this.service, request, selectionValue(options.selection), options.maxBytes, this.maxImagePixels, this.maxConversionBytes, options.timeoutMs);
10790
+ return this.track(started, options.signal, "read");
10791
+ }
10792
+ writeText(text, options) {
10793
+ const started = this.library.clipboardWriteOperationStart(this.service, new TextEncoder().encode(text), selectionValue(options.selection), options.timeoutMs);
10794
+ return this.track(started, options.signal, "write");
10795
+ }
10796
+ clear(options) {
10797
+ const started = this.library.clipboardClearOperationStart(this.service, selectionValue(options.selection), options.timeoutMs);
10798
+ return this.track(started, options.signal, "clear");
10799
+ }
10800
+ dispose() {
10801
+ if (this.disposePromise)
10802
+ return this.disposePromise;
10803
+ this.disposed = true;
10804
+ this.disposePromise = this.shutdown();
10805
+ return this.disposePromise;
10806
+ }
10807
+ track(started, signal, kind) {
10808
+ if (this.disposed)
10809
+ return Promise.reject(new Error("Native clipboard backend is disposed"));
10810
+ if (started.status !== 0 /* Ok */ || !started.operation) {
10811
+ return Promise.resolve(startFailure(started.status));
10812
+ }
10813
+ return new Promise((resolve3, reject) => {
10814
+ const operation = { handle: started.operation, kind, signal, resolve: resolve3, reject };
10815
+ this.pending.set(operation.handle, operation);
10816
+ signal.addEventListener("abort", () => this.requestCancel(operation), { once: true });
10817
+ this.ensureScheduled();
10818
+ this.drain();
10819
+ });
10820
+ }
10821
+ requestCancel(operation) {
10822
+ if (!this.pending.has(operation.handle))
10823
+ return;
10824
+ try {
10825
+ this.library.clipboardOperationCancel(operation.handle);
10826
+ } catch (error) {
10827
+ operation.cleanupError ??= error;
10828
+ }
10829
+ this.ensureScheduled();
10830
+ }
10831
+ ensureScheduled() {
10832
+ const hasPendingOperation = this.pending.size > 0;
10833
+ if (!hasPendingOperation && !this.providerActive) {
10834
+ this.clearPollTimer();
10835
+ return;
10836
+ }
10837
+ if (this.pollTimer !== undefined) {
10838
+ if (hasPendingOperation && !this.pollTimerForOperation)
10839
+ this.clearPollTimer();
10840
+ else {
10841
+ if (hasPendingOperation)
10842
+ this.pollTimer.ref();
10843
+ else
10844
+ this.pollTimer.unref();
10845
+ return;
10846
+ }
10847
+ }
10848
+ this.pollTimerForOperation = hasPendingOperation;
10849
+ this.pollTimer = setTimeout(() => {
10850
+ this.pollTimer = undefined;
10851
+ this.pollTimerForOperation = false;
10852
+ this.drain();
10853
+ }, hasPendingOperation ? OPERATION_POLL_INTERVAL_MS : PROVIDER_POLL_INTERVAL_MS);
10854
+ if (!hasPendingOperation)
10855
+ this.pollTimer.unref();
10856
+ }
10857
+ clearPollTimer() {
10858
+ if (this.pollTimer === undefined)
10859
+ return;
10860
+ clearTimeout(this.pollTimer);
10861
+ this.pollTimer = undefined;
10862
+ this.pollTimerForOperation = false;
10863
+ }
10864
+ drain() {
10865
+ this.providerActive = false;
10866
+ try {
10867
+ this.providerActive = this.library.clipboardServiceDrain(this.service) === 1;
10868
+ } catch (error) {
10869
+ for (const operation of this.pending.values()) {
10870
+ operation.cleanupError ??= error;
10871
+ try {
10872
+ this.library.clipboardOperationCancel(operation.handle);
10873
+ } catch {}
10874
+ }
10875
+ }
10876
+ let workUnits = 0;
10877
+ while (workUnits < MAX_WORK_UNITS_PER_DRAIN && this.pending.size > 0) {
10878
+ const operation = this.pending.values().next().value;
10879
+ if (!operation)
10880
+ break;
10881
+ workUnits += 1;
10882
+ try {
10883
+ if (operation.cleanupError !== undefined) {
10884
+ try {
10885
+ this.library.clipboardOperationCancel(operation.handle);
10886
+ } catch {}
10887
+ const status2 = this.library.clipboardOperationPoll(operation.handle);
10888
+ if (status2 === 0 /* Pending */) {
10889
+ this.rotate(operation);
10890
+ continue;
10891
+ }
10892
+ this.providerActive = true;
10893
+ const destroyed2 = this.library.clipboardOperationDestroy(operation.handle);
10894
+ if (destroyed2 === 1 /* NotReady */) {
10895
+ this.rotate(operation);
10896
+ continue;
10897
+ }
10898
+ this.pending.delete(operation.handle);
10899
+ operation.reject(operation.cleanupError);
10900
+ continue;
10901
+ }
10902
+ if (operation.signal.aborted)
10903
+ this.library.clipboardOperationCancel(operation.handle);
10904
+ const status = this.library.clipboardOperationPoll(operation.handle);
10905
+ if (status === 0 /* Pending */) {
10906
+ this.rotate(operation);
10907
+ continue;
10908
+ }
10909
+ this.providerActive = true;
10910
+ const result = this.readResult(operation.handle, operation.kind, status);
10911
+ const destroyed = this.library.clipboardOperationDestroy(operation.handle);
10912
+ if (destroyed === 1 /* NotReady */) {
10913
+ this.rotate(operation);
10914
+ continue;
10915
+ }
10916
+ this.pending.delete(operation.handle);
10917
+ operation.resolve(destroyed === 0 /* Destroyed */ ? result : { status: "failed", error: new Error("Native clipboard operation became invalid before destruction") });
10918
+ } catch (error) {
10919
+ operation.cleanupError ??= error;
10920
+ try {
10921
+ this.library.clipboardOperationCancel(operation.handle);
10922
+ } catch {}
10923
+ this.rotate(operation);
10924
+ }
10925
+ }
10926
+ this.ensureScheduled();
10927
+ }
10928
+ rotate(operation) {
10929
+ this.pending.delete(operation.handle);
10930
+ this.pending.set(operation.handle, operation);
10931
+ }
10932
+ readResult(handle, kind, status) {
10933
+ switch (status) {
10934
+ case 1 /* Read */:
10935
+ return kind === "read" ? this.readRepresentation(handle) : this.invalidResult(kind, status);
10936
+ case 2 /* Empty */:
10937
+ return kind === "read" ? { status: "empty" } : this.invalidResult(kind, status);
10938
+ case 3 /* Written */:
10939
+ return kind === "write" ? { status: "written" } : this.invalidResult(kind, status);
10940
+ case 4 /* Cleared */:
10941
+ return kind === "clear" ? { status: "cleared" } : this.invalidResult(kind, status);
10942
+ case 5 /* Unsupported */:
10943
+ return { status: "unsupported" };
10944
+ case 6 /* Cancelled */:
10945
+ return { status: "cancelled" };
10946
+ case 7 /* TimedOut */:
10947
+ return { status: "timed-out" };
10948
+ case 8 /* LimitExceeded */:
10949
+ return kind === "read" ? { status: "limit-exceeded" } : this.invalidResult(kind, status);
10950
+ case 9 /* Failed */:
10951
+ return { status: "failed", error: this.readError(handle) };
10952
+ default:
10953
+ return { status: "failed", error: new Error("Native clipboard operation returned an invalid status") };
10954
+ }
10955
+ }
10956
+ invalidResult(kind, status) {
10957
+ return {
10958
+ status: "failed",
10959
+ error: new Error(`Native clipboard ${kind} returned inapplicable status ${NativeClipboardOperationStatus[status]}`)
10960
+ };
10961
+ }
10962
+ readRepresentation(handle) {
10963
+ const mimeLength = this.library.clipboardOperationResultMimeLength(handle);
10964
+ const dataLength = this.library.clipboardOperationResultDataLength(handle);
10965
+ if (mimeLength.status !== 0 /* Ok */ || dataLength.status !== 0 /* Ok */) {
10966
+ return { status: "failed", error: new Error("Failed to read native clipboard result lengths") };
10967
+ }
10968
+ const mime = new Uint8Array(mimeLength.length);
10969
+ const bytes = new Uint8Array(dataLength.length);
10970
+ if (this.library.clipboardOperationResultMimeCopy(handle, mime) !== 0 /* Ok */ || this.library.clipboardOperationResultDataCopy(handle, bytes) !== 0 /* Ok */) {
10971
+ return { status: "failed", error: new Error("Failed to copy native clipboard result") };
10972
+ }
10973
+ return { status: "read", representation: { mimeType: new TextDecoder().decode(mime), bytes } };
10974
+ }
10975
+ readError(handle) {
10976
+ const code = this.library.clipboardOperationResultErrorCode(handle);
10977
+ const length = this.library.clipboardOperationResultDiagnosticLength(handle);
10978
+ if (code.status !== 0 /* Ok */ || length.status !== 0 /* Ok */) {
10979
+ return new Error("Native clipboard operation failed without a readable diagnostic");
10980
+ }
10981
+ const diagnostic = new Uint8Array(length.length);
10982
+ if (this.library.clipboardOperationResultDiagnosticCopy(handle, diagnostic) !== 0 /* Ok */) {
10983
+ return new Error("Native clipboard operation failed without a readable diagnostic");
10984
+ }
10985
+ return Object.assign(new Error(new TextDecoder().decode(diagnostic)), { code: code.errorCode });
10986
+ }
10987
+ async shutdown() {
10988
+ this.clearPollTimer();
10989
+ let status = this.library.clipboardServiceBeginShutdown(this.service);
10990
+ while (status === 0 /* Pending */) {
10991
+ await new Promise((resolve3) => setTimeout(resolve3, SHUTDOWN_POLL_INTERVAL_MS));
10992
+ status = this.library.clipboardServicePollShutdown(this.service);
10993
+ }
10994
+ if (status !== 1 /* Ready */)
10995
+ throw new Error("Native clipboard service became invalid");
10996
+ if (this.library.clipboardServiceDestroy(this.service) !== 0 /* Destroyed */) {
10997
+ throw new Error("Failed to destroy native clipboard service");
10998
+ }
10999
+ }
11000
+ }
11001
+ var createNativeHostClipboardBackend = (options) => new NativeClipboardBackend(options.maxImagePixels, options.maxConversionBytes, options.maxConcurrentOperations, options.maxProviderTransfers, options.waylandSeat);
11002
+
10530
11003
  // src/lib/clipboard.ts
11004
+ var NOT_ATTEMPTED_TERMINAL = {
11005
+ status: "not-attempted",
11006
+ capability: "unknown"
11007
+ };
11008
+ var validateSelection = (selection) => {
11009
+ const normalized = selection ?? "clipboard";
11010
+ if (normalized !== "clipboard" && normalized !== "primary") {
11011
+ throw new TypeError("selection must be clipboard or primary");
11012
+ }
11013
+ return normalized;
11014
+ };
11015
+ var createHostClipboard = (options = {}) => createHostClipboardWithBackend(options, createNativeHostClipboardBackend);
11016
+ var validateDestination = (destination) => {
11017
+ if (destination !== "terminal-only" && destination !== "host-only" && destination !== "best-available" && destination !== "all-available") {
11018
+ throw new TypeError("destination is not a supported clipboard policy");
11019
+ }
11020
+ };
11021
+ var createClipboard = ({ host, terminal }) => {
11022
+ const active = new Set;
11023
+ let disposed = false;
11024
+ let disposePromise;
11025
+ const assertUsable = () => {
11026
+ if (disposed)
11027
+ throw new Error("Clipboard service is disposed");
11028
+ };
11029
+ const canUseRemoteHost = (options) => !terminal.remote || options.allowRemoteHost === true;
11030
+ const composeMutation = async (options, signal, hostOperation, terminalOperation) => {
11031
+ if (options.destination === "terminal-only") {
11032
+ return { host: { status: "not-attempted" }, terminal: terminalOperation() };
11033
+ }
11034
+ if (options.destination === "host-only") {
11035
+ const hostResult = canUseRemoteHost(options) ? await hostOperation() : { status: "not-attempted" };
11036
+ return { host: hostResult, terminal: NOT_ATTEMPTED_TERMINAL };
11037
+ }
11038
+ if (options.destination === "best-available") {
11039
+ if (terminal.remote) {
11040
+ return { host: { status: "not-attempted" }, terminal: terminalOperation() };
11041
+ }
11042
+ const hostResult = await hostOperation();
11043
+ const terminalResult2 = !signal.aborted && (hostResult.status === "unsupported" || hostResult.status === "failed") ? terminalOperation() : NOT_ATTEMPTED_TERMINAL;
11044
+ return { host: hostResult, terminal: terminalResult2 };
11045
+ }
11046
+ const hostPromise = canUseRemoteHost(options) ? hostOperation() : Promise.resolve({ status: "not-attempted" });
11047
+ const terminalResult = terminalOperation();
11048
+ return { host: await hostPromise, terminal: terminalResult };
11049
+ };
11050
+ return {
11051
+ read(options) {
11052
+ try {
11053
+ assertUsable();
11054
+ return host.read(options);
11055
+ } catch (error) {
11056
+ return Promise.reject(error);
11057
+ }
11058
+ },
11059
+ writeText(text, options) {
11060
+ try {
11061
+ assertUsable();
11062
+ validateDestination(options.destination);
11063
+ validateClipboardText(text, host.maxWriteBytes);
11064
+ const selection = validateSelection(options.selection);
11065
+ if (options.signal?.aborted) {
11066
+ return Promise.resolve({ host: { status: "not-attempted" }, terminal: NOT_ATTEMPTED_TERMINAL });
11067
+ }
11068
+ return runTrackedOperation(active, options.signal, (signal) => {
11069
+ const operationOptions = { selection, signal };
11070
+ return composeMutation(options, signal, () => host.writeText(text, operationOptions), () => terminal.writeText(text, selection));
11071
+ });
11072
+ } catch (error) {
11073
+ return Promise.reject(error);
11074
+ }
11075
+ },
11076
+ clear(options) {
11077
+ try {
11078
+ assertUsable();
11079
+ validateDestination(options.destination);
11080
+ const selection = validateSelection(options.selection);
11081
+ if (options.signal?.aborted) {
11082
+ return Promise.resolve({ host: { status: "not-attempted" }, terminal: NOT_ATTEMPTED_TERMINAL });
11083
+ }
11084
+ return runTrackedOperation(active, options.signal, (signal) => {
11085
+ const operationOptions = { selection, signal };
11086
+ return composeMutation(options, signal, () => host.clear(operationOptions), () => terminal.clear(selection));
11087
+ });
11088
+ } catch (error) {
11089
+ return Promise.reject(error);
11090
+ }
11091
+ },
11092
+ dispose() {
11093
+ if (disposePromise)
11094
+ return disposePromise;
11095
+ disposed = true;
11096
+ for (const operation of active)
11097
+ operation.controller.abort();
11098
+ disposePromise = (async () => {
11099
+ await Promise.all([...active].map((operation) => operation.settled));
11100
+ await host.dispose();
11101
+ })();
11102
+ return disposePromise;
11103
+ }
11104
+ };
11105
+ };
10531
11106
  var ClipboardTarget;
10532
11107
  ((ClipboardTarget2) => {
10533
11108
  ClipboardTarget2[ClipboardTarget2["Clipboard"] = 0] = "Clipboard";
@@ -10535,6 +11110,33 @@ var ClipboardTarget;
10535
11110
  ClipboardTarget2[ClipboardTarget2["Select"] = 2] = "Select";
10536
11111
  ClipboardTarget2[ClipboardTarget2["Secondary"] = 3] = "Secondary";
10537
11112
  })(ClipboardTarget ||= {});
11113
+ var createRendererClipboardAdapter = (renderer) => {
11114
+ const targetFor = (selection) => selection === "primary" ? 1 /* Primary */ : 0 /* Clipboard */;
11115
+ const capability = () => renderer.capabilities?.osc52_support ?? "unknown";
11116
+ return {
11117
+ get remote() {
11118
+ return renderer.capabilities?.remote ?? true;
11119
+ },
11120
+ writeText(text, selection) {
11121
+ const currentCapability = capability();
11122
+ if (currentCapability === "unsupported")
11123
+ return { status: "not-attempted", capability: currentCapability };
11124
+ return {
11125
+ status: renderer.copyToClipboardOSC52(text, targetFor(selection)) ? "attempted" : "local-failure",
11126
+ capability: currentCapability
11127
+ };
11128
+ },
11129
+ clear(selection) {
11130
+ const currentCapability = capability();
11131
+ if (currentCapability === "unsupported")
11132
+ return { status: "not-attempted", capability: currentCapability };
11133
+ return {
11134
+ status: renderer.clearClipboardOSC52(targetFor(selection)) ? "attempted" : "local-failure",
11135
+ capability: currentCapability
11136
+ };
11137
+ }
11138
+ };
11139
+ };
10538
11140
 
10539
11141
  class Clipboard {
10540
11142
  lib;
@@ -12761,6 +13363,55 @@ registerEnvVar({
12761
13363
  type: "string",
12762
13364
  default: ""
12763
13365
  });
13366
+ var NativeClipboardOperationStatus;
13367
+ ((NativeClipboardOperationStatus2) => {
13368
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["Pending"] = 0] = "Pending";
13369
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["Read"] = 1] = "Read";
13370
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["Empty"] = 2] = "Empty";
13371
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["Written"] = 3] = "Written";
13372
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["Cleared"] = 4] = "Cleared";
13373
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["Unsupported"] = 5] = "Unsupported";
13374
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["Cancelled"] = 6] = "Cancelled";
13375
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["TimedOut"] = 7] = "TimedOut";
13376
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["LimitExceeded"] = 8] = "LimitExceeded";
13377
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["Failed"] = 9] = "Failed";
13378
+ NativeClipboardOperationStatus2[NativeClipboardOperationStatus2["InvalidHandle"] = 10] = "InvalidHandle";
13379
+ })(NativeClipboardOperationStatus ||= {});
13380
+ var NativeClipboardStartStatus;
13381
+ ((NativeClipboardStartStatus2) => {
13382
+ NativeClipboardStartStatus2[NativeClipboardStartStatus2["Ok"] = 0] = "Ok";
13383
+ NativeClipboardStartStatus2[NativeClipboardStartStatus2["InvalidService"] = 1] = "InvalidService";
13384
+ NativeClipboardStartStatus2[NativeClipboardStartStatus2["ShuttingDown"] = 2] = "ShuttingDown";
13385
+ NativeClipboardStartStatus2[NativeClipboardStartStatus2["LimitExceeded"] = 3] = "LimitExceeded";
13386
+ NativeClipboardStartStatus2[NativeClipboardStartStatus2["InvalidArgument"] = 4] = "InvalidArgument";
13387
+ NativeClipboardStartStatus2[NativeClipboardStartStatus2["OutOfMemory"] = 5] = "OutOfMemory";
13388
+ })(NativeClipboardStartStatus ||= {});
13389
+ var NativeClipboardCancelStatus;
13390
+ ((NativeClipboardCancelStatus2) => {
13391
+ NativeClipboardCancelStatus2[NativeClipboardCancelStatus2["Requested"] = 0] = "Requested";
13392
+ NativeClipboardCancelStatus2[NativeClipboardCancelStatus2["AlreadyTerminal"] = 1] = "AlreadyTerminal";
13393
+ NativeClipboardCancelStatus2[NativeClipboardCancelStatus2["InvalidHandle"] = 2] = "InvalidHandle";
13394
+ })(NativeClipboardCancelStatus ||= {});
13395
+ var NativeClipboardCopyStatus;
13396
+ ((NativeClipboardCopyStatus2) => {
13397
+ NativeClipboardCopyStatus2[NativeClipboardCopyStatus2["Ok"] = 0] = "Ok";
13398
+ NativeClipboardCopyStatus2[NativeClipboardCopyStatus2["BufferTooSmall"] = 1] = "BufferTooSmall";
13399
+ NativeClipboardCopyStatus2[NativeClipboardCopyStatus2["InvalidHandle"] = 2] = "InvalidHandle";
13400
+ NativeClipboardCopyStatus2[NativeClipboardCopyStatus2["InvalidState"] = 3] = "InvalidState";
13401
+ NativeClipboardCopyStatus2[NativeClipboardCopyStatus2["InvalidArgument"] = 4] = "InvalidArgument";
13402
+ })(NativeClipboardCopyStatus ||= {});
13403
+ var NativeClipboardDestroyStatus;
13404
+ ((NativeClipboardDestroyStatus2) => {
13405
+ NativeClipboardDestroyStatus2[NativeClipboardDestroyStatus2["Destroyed"] = 0] = "Destroyed";
13406
+ NativeClipboardDestroyStatus2[NativeClipboardDestroyStatus2["NotReady"] = 1] = "NotReady";
13407
+ NativeClipboardDestroyStatus2[NativeClipboardDestroyStatus2["InvalidHandle"] = 2] = "InvalidHandle";
13408
+ })(NativeClipboardDestroyStatus ||= {});
13409
+ var NativeClipboardShutdownStatus;
13410
+ ((NativeClipboardShutdownStatus2) => {
13411
+ NativeClipboardShutdownStatus2[NativeClipboardShutdownStatus2["Pending"] = 0] = "Pending";
13412
+ NativeClipboardShutdownStatus2[NativeClipboardShutdownStatus2["Ready"] = 1] = "Ready";
13413
+ NativeClipboardShutdownStatus2[NativeClipboardShutdownStatus2["InvalidHandle"] = 2] = "InvalidHandle";
13414
+ })(NativeClipboardShutdownStatus ||= {});
12764
13415
  var targetLibPath;
12765
13416
  var targetLibError;
12766
13417
  try {
@@ -13123,6 +13774,78 @@ function getOpenTUILib(libPath) {
13123
13774
  args: ["u32", "u8"],
13124
13775
  returns: "bool"
13125
13776
  },
13777
+ clipboardServiceCreate: {
13778
+ args: ["u32", "u32", "ptr", "u32"],
13779
+ returns: "u32"
13780
+ },
13781
+ clipboardServiceBeginShutdown: {
13782
+ args: ["u32"],
13783
+ returns: "u8"
13784
+ },
13785
+ clipboardServicePollShutdown: {
13786
+ args: ["u32"],
13787
+ returns: "u8"
13788
+ },
13789
+ clipboardServiceDestroy: {
13790
+ args: ["u32"],
13791
+ returns: "u8"
13792
+ },
13793
+ clipboardServiceDrain: {
13794
+ args: ["u32"],
13795
+ returns: "u8"
13796
+ },
13797
+ clipboardReadOperationStart: {
13798
+ args: ["u32", "ptr", "u32", "u8", "u32", "u32", "u32", "u32", "ptr"],
13799
+ returns: "u8"
13800
+ },
13801
+ clipboardWriteOperationStart: {
13802
+ args: ["u32", "ptr", "u32", "u8", "u32", "ptr"],
13803
+ returns: "u8"
13804
+ },
13805
+ clipboardClearOperationStart: {
13806
+ args: ["u32", "u8", "u32", "ptr"],
13807
+ returns: "u8"
13808
+ },
13809
+ clipboardOperationPoll: {
13810
+ args: ["u32"],
13811
+ returns: "u8"
13812
+ },
13813
+ clipboardOperationCancel: {
13814
+ args: ["u32"],
13815
+ returns: "u8"
13816
+ },
13817
+ clipboardOperationResultMimeLength: {
13818
+ args: ["u32", "ptr"],
13819
+ returns: "u8"
13820
+ },
13821
+ clipboardOperationResultMimeCopy: {
13822
+ args: ["u32", "ptr", "u32"],
13823
+ returns: "u8"
13824
+ },
13825
+ clipboardOperationResultDataLength: {
13826
+ args: ["u32", "ptr"],
13827
+ returns: "u8"
13828
+ },
13829
+ clipboardOperationResultDataCopy: {
13830
+ args: ["u32", "ptr", "u32"],
13831
+ returns: "u8"
13832
+ },
13833
+ clipboardOperationResultErrorCode: {
13834
+ args: ["u32", "ptr"],
13835
+ returns: "u8"
13836
+ },
13837
+ clipboardOperationResultDiagnosticLength: {
13838
+ args: ["u32", "ptr"],
13839
+ returns: "u8"
13840
+ },
13841
+ clipboardOperationResultDiagnosticCopy: {
13842
+ args: ["u32", "ptr", "u32"],
13843
+ returns: "u8"
13844
+ },
13845
+ clipboardOperationDestroy: {
13846
+ args: ["u32"],
13847
+ returns: "u8"
13848
+ },
13126
13849
  triggerNotification: {
13127
13850
  args: ["u32", "ptr", "u32", "ptr", "u32"],
13128
13851
  returns: "bool"
@@ -13836,10 +14559,16 @@ function getOpenTUILib(libPath) {
13836
14559
  returns: "u32"
13837
14560
  },
13838
14561
  imageInfo: { args: ["ptr", "u32", "ptr"], returns: "u32" },
14562
+ imageRetainIccCache: { args: [], returns: "void" },
14563
+ imageReleaseIccCache: { args: [], returns: "void" },
14564
+ imageTestFailIccProfileCopyAllocationOnce: { args: [], returns: "void" },
13839
14565
  imageDecode: { args: ["ptr", "u32", "ptr"], returns: "u32" },
13840
14566
  imageCreateFromRgba: { args: ["ptr", "u64", "u32", "u32", "u32", "ptr"], returns: "u32" },
13841
14567
  imageDestroy: { args: ["u32"], returns: "void" },
14568
+ imageRetain: { args: ["u32", "ptr"], returns: "u32" },
13842
14569
  imageGetInfo: { args: ["u32", "ptr"], returns: "u32" },
14570
+ imageMaterialize: { args: ["u32"], returns: "u32" },
14571
+ imageEnsureEncodedPng: { args: ["u32"], returns: "u32" },
13843
14572
  imageGetPixelsPtr: { args: ["u32"], returns: "ptr" },
13844
14573
  imageClone: { args: ["u32", "ptr"], returns: "u32" },
13845
14574
  imageCopyPixels: { args: ["u32", "ptr", "u64", "u32", "u8"], returns: "u32" },
@@ -14446,6 +15175,7 @@ var NativeMeasureTargetKind = {
14446
15175
 
14447
15176
  class FFIRenderLib {
14448
15177
  opentui;
15178
+ iccCacheClient = false;
14449
15179
  yogaLayout = new Float32Array(6);
14450
15180
  yogaLayoutPtr = ptr(this.yogaLayout);
14451
15181
  ffiStructStorage = {
@@ -14486,6 +15216,8 @@ class FFIRenderLib {
14486
15216
  imageDrawOptions: allocStruct(ImageDrawOptionsStruct),
14487
15217
  gridDrawOptions: allocStruct(GridDrawOptionsStruct)
14488
15218
  };
15219
+ disposed = false;
15220
+ clipboardServices = new Set;
14489
15221
  encoder = new TextEncoder;
14490
15222
  decoder = new TextDecoder;
14491
15223
  logCallbackWrapper = null;
@@ -14512,6 +15244,8 @@ class FFIRenderLib {
14512
15244
  }
14513
15245
  constructor(libPath) {
14514
15246
  this.opentui = getOpenTUILib(libPath);
15247
+ this.imageRetainIccCache();
15248
+ this.iccCacheClient = true;
14515
15249
  try {
14516
15250
  this.setupLogging();
14517
15251
  this.setupEventBus();
@@ -14565,6 +15299,12 @@ class FFIRenderLib {
14565
15299
  this.opentui.symbols.setLogCallback(callbackPtr);
14566
15300
  }
14567
15301
  dispose() {
15302
+ if (this.disposed)
15303
+ return;
15304
+ if (this.clipboardServices.size > 0) {
15305
+ throw new Error("Cannot dispose OpenTUI native library while clipboard services are active");
15306
+ }
15307
+ this.disposed = true;
14568
15308
  try {
14569
15309
  if (this.eventSinkPtr) {
14570
15310
  this.opentui.symbols.destroyEventSink(this.eventSinkPtr);
@@ -14575,12 +15315,19 @@ class FFIRenderLib {
14575
15315
  this.setLogCallback(null);
14576
15316
  } finally {
14577
15317
  try {
14578
- this.opentui.close();
15318
+ if (this.iccCacheClient) {
15319
+ this.iccCacheClient = false;
15320
+ this.imageReleaseIccCache();
15321
+ }
14579
15322
  } finally {
14580
- this.eventCallbackWrapper = null;
14581
- this.logCallbackWrapper = null;
14582
- this.nativeSpanFeedCallbackWrapper = null;
14583
- this.nativeSpanFeedHandlers.clear();
15323
+ try {
15324
+ this.opentui.close();
15325
+ } finally {
15326
+ this.eventCallbackWrapper = null;
15327
+ this.logCallbackWrapper = null;
15328
+ this.nativeSpanFeedCallbackWrapper = null;
15329
+ this.nativeSpanFeedHandlers.clear();
15330
+ }
14584
15331
  }
14585
15332
  }
14586
15333
  }
@@ -14956,6 +15703,96 @@ class FFIRenderLib {
14956
15703
  clearClipboardOSC52(renderer, target) {
14957
15704
  return Boolean(this.opentui.symbols.clearClipboardOSC52(renderer, target));
14958
15705
  }
15706
+ clipboardServiceCreate(maxConcurrentOperations, maxProviderTransfers, waylandSeat) {
15707
+ const seat = waylandSeat === undefined ? null : this.encoder.encode(waylandSeat);
15708
+ const handle = this.opentui.symbols.clipboardServiceCreate(toSafeFFIU32Length(maxConcurrentOperations, "clipboard operation limit"), toSafeFFIU32Length(maxProviderTransfers, "clipboard provider transfer limit"), seat, seat?.byteLength ?? 0);
15709
+ if (handle === 0)
15710
+ return null;
15711
+ const service = handle;
15712
+ this.clipboardServices.add(service);
15713
+ return service;
15714
+ }
15715
+ clipboardServiceBeginShutdown(service) {
15716
+ if (!this.clipboardServices.has(service))
15717
+ return 2 /* InvalidHandle */;
15718
+ return this.opentui.symbols.clipboardServiceBeginShutdown(service);
15719
+ }
15720
+ clipboardServicePollShutdown(service) {
15721
+ if (!this.clipboardServices.has(service))
15722
+ return 2 /* InvalidHandle */;
15723
+ return this.opentui.symbols.clipboardServicePollShutdown(service);
15724
+ }
15725
+ clipboardServiceDestroy(service) {
15726
+ if (!this.clipboardServices.has(service))
15727
+ return 2 /* InvalidHandle */;
15728
+ const status = this.opentui.symbols.clipboardServiceDestroy(service);
15729
+ if (status === 0 /* Destroyed */)
15730
+ this.clipboardServices.delete(service);
15731
+ return status;
15732
+ }
15733
+ clipboardServiceDrain(service) {
15734
+ if (!this.clipboardServices.has(service))
15735
+ return 2;
15736
+ return this.opentui.symbols.clipboardServiceDrain(service);
15737
+ }
15738
+ clipboardStartResult(status, output) {
15739
+ return {
15740
+ status,
15741
+ operation: output[0] === 0 ? null : output[0]
15742
+ };
15743
+ }
15744
+ clipboardReadOperationStart(service, request, selection2, maxBytes, maxImagePixels, maxConversionBytes, timeoutMs) {
15745
+ const output = new Uint32Array(1);
15746
+ 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);
15747
+ return this.clipboardStartResult(status, output);
15748
+ }
15749
+ clipboardWriteOperationStart(service, textUtf8, selection2, timeoutMs) {
15750
+ const output = new Uint32Array(1);
15751
+ const status = this.opentui.symbols.clipboardWriteOperationStart(service, textUtf8, toSafeFFIU32Length(textUtf8.byteLength, "clipboard write text"), selection2, toSafeFFIU32Length(timeoutMs, "clipboard write timeout"), output);
15752
+ return this.clipboardStartResult(status, output);
15753
+ }
15754
+ clipboardClearOperationStart(service, selection2, timeoutMs) {
15755
+ const output = new Uint32Array(1);
15756
+ const status = this.opentui.symbols.clipboardClearOperationStart(service, selection2, toSafeFFIU32Length(timeoutMs, "clipboard clear timeout"), output);
15757
+ return this.clipboardStartResult(status, output);
15758
+ }
15759
+ clipboardOperationPoll(operation) {
15760
+ return this.opentui.symbols.clipboardOperationPoll(operation);
15761
+ }
15762
+ clipboardOperationCancel(operation) {
15763
+ return this.opentui.symbols.clipboardOperationCancel(operation);
15764
+ }
15765
+ clipboardResultLength(symbol, operation) {
15766
+ const output = new Uint32Array(1);
15767
+ const status = symbol(operation, output);
15768
+ return { status, length: output[0] };
15769
+ }
15770
+ clipboardOperationResultMimeLength(operation) {
15771
+ return this.clipboardResultLength(this.opentui.symbols.clipboardOperationResultMimeLength, operation);
15772
+ }
15773
+ clipboardOperationResultMimeCopy(operation, output) {
15774
+ return this.opentui.symbols.clipboardOperationResultMimeCopy(operation, output.byteLength === 0 ? null : output, toSafeFFIU32Length(output.byteLength, "clipboard MIME output"));
15775
+ }
15776
+ clipboardOperationResultDataLength(operation) {
15777
+ return this.clipboardResultLength(this.opentui.symbols.clipboardOperationResultDataLength, operation);
15778
+ }
15779
+ clipboardOperationResultDataCopy(operation, output) {
15780
+ return this.opentui.symbols.clipboardOperationResultDataCopy(operation, output.byteLength === 0 ? null : output, toSafeFFIU32Length(output.byteLength, "clipboard data output"));
15781
+ }
15782
+ clipboardOperationResultErrorCode(operation) {
15783
+ const output = new Uint32Array(1);
15784
+ const status = this.opentui.symbols.clipboardOperationResultErrorCode(operation, output);
15785
+ return { status, errorCode: output[0] };
15786
+ }
15787
+ clipboardOperationResultDiagnosticLength(operation) {
15788
+ return this.clipboardResultLength(this.opentui.symbols.clipboardOperationResultDiagnosticLength, operation);
15789
+ }
15790
+ clipboardOperationResultDiagnosticCopy(operation, output) {
15791
+ return this.opentui.symbols.clipboardOperationResultDiagnosticCopy(operation, output.byteLength === 0 ? null : output, toSafeFFIU32Length(output.byteLength, "clipboard diagnostic output"));
15792
+ }
15793
+ clipboardOperationDestroy(operation) {
15794
+ return this.opentui.symbols.clipboardOperationDestroy(operation);
15795
+ }
14959
15796
  triggerNotification(renderer, message, title) {
14960
15797
  const messageBytes = this.encoder.encode(message);
14961
15798
  const titleBytes = title === undefined ? null : this.encoder.encode(title);
@@ -16337,6 +17174,19 @@ class FFIRenderLib {
16337
17174
  imageDestroy(image) {
16338
17175
  this.opentui.symbols.imageDestroy(image);
16339
17176
  }
17177
+ imageRetain(image) {
17178
+ const output = new Uint32Array(1);
17179
+ return this.imageHandleResult(this.opentui.symbols.imageRetain(image, output), output);
17180
+ }
17181
+ imageRetainIccCache() {
17182
+ this.opentui.symbols.imageRetainIccCache();
17183
+ }
17184
+ imageReleaseIccCache() {
17185
+ this.opentui.symbols.imageReleaseIccCache();
17186
+ }
17187
+ imageTestFailIccProfileCopyAllocationOnce() {
17188
+ this.opentui.symbols.imageTestFailIccProfileCopyAllocationOnce();
17189
+ }
16340
17190
  imageGetInfo(image) {
16341
17191
  const output = new ArrayBuffer(NativeImageInfoStruct.size);
16342
17192
  const status = this.opentui.symbols.imageGetInfo(image, output);
@@ -16346,6 +17196,12 @@ class FFIRenderLib {
16346
17196
  const pointer = this.opentui.symbols.imageGetPixelsPtr(image);
16347
17197
  return pointer === null || pointer === 0 || pointer === 0n ? null : pointer;
16348
17198
  }
17199
+ imageMaterialize(image) {
17200
+ return this.opentui.symbols.imageMaterialize(image);
17201
+ }
17202
+ imageEnsureEncodedPng(image) {
17203
+ return this.opentui.symbols.imageEnsureEncodedPng(image);
17204
+ }
16349
17205
  imageClone(image) {
16350
17206
  const output = new Uint32Array(1);
16351
17207
  return this.imageHandleResult(this.opentui.symbols.imageClone(image, output), output);
@@ -17389,7 +18245,7 @@ var Yoga = {
17389
18245
  };
17390
18246
  var yoga_default = Yoga;
17391
18247
 
17392
- 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 };
18248
+ 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 };
17393
18249
 
17394
- //# debugId=5F4E42714FBFA7AA64756E2164756E21
17395
- //# sourceMappingURL=chunk-node-savhj5rp.js.map
18250
+ //# debugId=E0363CDF983A3D2164756E2164756E21
18251
+ //# sourceMappingURL=chunk-node-aj3n20gq.js.map