@opentui/core 0.5.1 → 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.
package/index.node.js CHANGED
@@ -43,7 +43,7 @@ import {
43
43
  mergeKeyAliases,
44
44
  mergeKeyBindings,
45
45
  wrapWithDelegates
46
- } from "./chunk-node-0yw3x5m7.js";
46
+ } from "./chunk-node-kq7as74d.js";
47
47
  import {
48
48
  ASCIIFontSelectionHelper,
49
49
  ATTRIBUTE_BASE_BITS,
@@ -71,6 +71,12 @@ import {
71
71
  NativeAudioStreamState,
72
72
  NativeAudioStreamState1 as NativeAudioStreamState2,
73
73
  NativeAudioStreamStateNames,
74
+ NativeClipboardCancelStatus,
75
+ NativeClipboardCopyStatus,
76
+ NativeClipboardDestroyStatus,
77
+ NativeClipboardOperationStatus,
78
+ NativeClipboardShutdownStatus,
79
+ NativeClipboardStartStatus,
74
80
  NativeMeasureTargetKind,
75
81
  OptimizedBuffer,
76
82
  PasteEvent,
@@ -114,7 +120,10 @@ import {
114
120
  clearEnvCache,
115
121
  convertGlobalToLocalSelection,
116
122
  coordinateToCharacterIndex,
123
+ createClipboard,
117
124
  createExtmarksController,
125
+ createHostClipboard,
126
+ createRendererClipboardAdapter,
118
127
  createTerminalPalette,
119
128
  createTextAttributes,
120
129
  cyan,
@@ -194,7 +203,7 @@ import {
194
203
  visualizeRenderableTree,
195
204
  white,
196
205
  yellow
197
- } from "./chunk-node-m23dbcww.js";
206
+ } from "./chunk-node-aj3n20gq.js";
198
207
  // src/post/effects.ts
199
208
  function toU8(value) {
200
209
  return Math.round(Math.max(0, Math.min(1, Number.isFinite(value) ? value : 0)) * 255);
@@ -5984,6 +5993,9 @@ class NativeImage {
5984
5993
  clone() {
5985
5994
  return this.wrap(this.lib.imageClone(this.guard()));
5986
5995
  }
5996
+ retain() {
5997
+ return this.wrap(this.lib.imageRetain(this.guard()));
5998
+ }
5987
5999
  resize(options) {
5988
6000
  if (!options || options.width === undefined && options.height === undefined) {
5989
6001
  throw new TypeError("resize requires width, height, or both");
@@ -6033,6 +6045,9 @@ class NativeImage {
6033
6045
  throw new RangeError("opacity must be between 0 and 1");
6034
6046
  return this.wrap(this.lib.imageComposite(this.guard(), overlay.guard(), requireI32(options.left ?? 0, "left"), requireI32(options.top ?? 0, "top"), requireMappedOption(BLEND_IDS, options.blend ?? "source-over", "blend mode"), Math.round(opacity * 255)));
6035
6047
  }
6048
+ ensureEncodedPng() {
6049
+ checkStatus(this.lib.imageEnsureEncodedPng(this.guard()));
6050
+ }
6036
6051
  raw(format = "rgba8") {
6037
6052
  const stride = this.width * 4;
6038
6053
  const data = new Uint8Array(stride * this.height);
@@ -8725,6 +8740,7 @@ function pixelResolution(ctx) {
8725
8740
  class ImageRenderable extends Renderable {
8726
8741
  _source;
8727
8742
  _image = null;
8743
+ _pendingImage = null;
8728
8744
  _loadError = null;
8729
8745
  _loadController = null;
8730
8746
  onLoad;
@@ -8751,6 +8767,8 @@ class ImageRenderable extends Renderable {
8751
8767
  this._source = source;
8752
8768
  this._loadController?.abort();
8753
8769
  this._loadController = null;
8770
+ this._pendingImage?.dispose();
8771
+ this._pendingImage = null;
8754
8772
  if (source === undefined) {
8755
8773
  this._loadError = null;
8756
8774
  this._image?.dispose();
@@ -8762,7 +8780,19 @@ class ImageRenderable extends Renderable {
8762
8780
  const controller = new AbortController;
8763
8781
  this._loadController = controller;
8764
8782
  this._loadError = null;
8765
- this.loadPromise = this.load(source, controller);
8783
+ let imagePromise;
8784
+ if (source instanceof NativeImage) {
8785
+ try {
8786
+ const image = source.retain();
8787
+ this._pendingImage = image;
8788
+ imagePromise = Promise.resolve(image);
8789
+ } catch (error) {
8790
+ imagePromise = Promise.reject(error);
8791
+ }
8792
+ } else {
8793
+ imagePromise = NativeImage.load(source, { signal: controller.signal });
8794
+ }
8795
+ this.loadPromise = this.load(imagePromise, controller);
8766
8796
  }
8767
8797
  get image() {
8768
8798
  return this._image;
@@ -8851,10 +8881,10 @@ class ImageRenderable extends Renderable {
8851
8881
  }
8852
8882
  buffer.drawImage(this._image, x, y, fitted.width, fitted.height, pixelWidth, pixelHeight, sourceX, sourceY, sourceWidth, sourceHeight, this._protocol);
8853
8883
  }
8854
- async load(source, controller) {
8884
+ async load(imagePromise, controller) {
8855
8885
  let image;
8856
8886
  try {
8857
- image = await NativeImage.load(source, { signal: controller.signal });
8887
+ image = await imagePromise;
8858
8888
  } catch (error) {
8859
8889
  if (controller.signal.aborted || this.isDestroyed || this._loadController !== controller)
8860
8890
  return;
@@ -8867,6 +8897,8 @@ class ImageRenderable extends Renderable {
8867
8897
  image.dispose();
8868
8898
  return;
8869
8899
  }
8900
+ if (this._pendingImage === image)
8901
+ this._pendingImage = null;
8870
8902
  const previous = this._image;
8871
8903
  this._image = image;
8872
8904
  this._loadController = null;
@@ -8877,6 +8909,8 @@ class ImageRenderable extends Renderable {
8877
8909
  destroySelf() {
8878
8910
  this._loadController?.abort();
8879
8911
  this._loadController = null;
8912
+ this._pendingImage?.dispose();
8913
+ this._pendingImage = null;
8880
8914
  this._image?.dispose();
8881
8915
  this._image = null;
8882
8916
  super.destroySelf();
@@ -14955,10 +14989,13 @@ export {
14955
14989
  createTextAttributes,
14956
14990
  createTerminalPalette,
14957
14991
  createSlotRegistry,
14992
+ createRendererClipboardAdapter,
14958
14993
  createMarkdownCodeBlockRenderer,
14959
14994
  createIcyStreamDemuxer,
14995
+ createHostClipboard,
14960
14996
  createExtmarksController,
14961
14997
  createCoreSlotRegistry,
14998
+ createClipboard,
14962
14999
  createCliRenderer,
14963
15000
  coordinateToCharacterIndex,
14964
15001
  convertThemeToStyles,
@@ -15056,6 +15093,12 @@ export {
15056
15093
  NativeSpanFeed,
15057
15094
  NativeMeasureTargetKind,
15058
15095
  NativeImage,
15096
+ NativeClipboardStartStatus,
15097
+ NativeClipboardShutdownStatus,
15098
+ NativeClipboardOperationStatus,
15099
+ NativeClipboardDestroyStatus,
15100
+ NativeClipboardCopyStatus,
15101
+ NativeClipboardCancelStatus,
15059
15102
  NativeAudioStreamState2 as NativeAudioStreamState,
15060
15103
  NativeAudioStreamFormat2 as NativeAudioStreamFormat,
15061
15104
  NativeAudioStreamCloseReason2 as NativeAudioStreamCloseReason,
@@ -15129,5 +15172,5 @@ export {
15129
15172
  ACHROMATOPSIA_MATRIX
15130
15173
  };
15131
15174
 
15132
- //# debugId=4D35D75044909E8F64756E2164756E21
15175
+ //# debugId=461568FAFCC40A8864756E2164756E21
15133
15176
  //# sourceMappingURL=index.node.js.map