@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.
package/image.d.ts CHANGED
@@ -88,6 +88,7 @@ export declare class NativeImage {
88
88
  get width(): number;
89
89
  get height(): number;
90
90
  clone(): NativeImage;
91
+ retain(): NativeImage;
91
92
  resize(options: ResizeOptions): NativeImage;
92
93
  extract(options: ExtractOptions): NativeImage;
93
94
  extend(options?: ExtendOptions): NativeImage;
@@ -95,6 +96,7 @@ export declare class NativeImage {
95
96
  flip(): NativeImage;
96
97
  flop(): NativeImage;
97
98
  composite(overlay: NativeImage, options?: CompositeOptions): NativeImage;
99
+ ensureEncodedPng(): void;
98
100
  raw(format?: PixelFormat): RawImage;
99
101
  takeRaw(): OwnedRawImage;
100
102
  copyTo(destination: Uint8Array, options?: {
package/index.bun.js CHANGED
@@ -44,7 +44,7 @@ import {
44
44
  mergeKeyAliases,
45
45
  mergeKeyBindings,
46
46
  wrapWithDelegates
47
- } from "./chunk-bun-v3e63tzw.js";
47
+ } from "./chunk-bun-t68f2fmr.js";
48
48
  import {
49
49
  ASCIIFontSelectionHelper,
50
50
  ATTRIBUTE_BASE_BITS,
@@ -72,6 +72,12 @@ import {
72
72
  NativeAudioStreamState,
73
73
  NativeAudioStreamState1 as NativeAudioStreamState2,
74
74
  NativeAudioStreamStateNames,
75
+ NativeClipboardCancelStatus,
76
+ NativeClipboardCopyStatus,
77
+ NativeClipboardDestroyStatus,
78
+ NativeClipboardOperationStatus,
79
+ NativeClipboardShutdownStatus,
80
+ NativeClipboardStartStatus,
75
81
  NativeMeasureTargetKind,
76
82
  OptimizedBuffer,
77
83
  PasteEvent,
@@ -115,7 +121,10 @@ import {
115
121
  clearEnvCache,
116
122
  convertGlobalToLocalSelection,
117
123
  coordinateToCharacterIndex,
124
+ createClipboard,
118
125
  createExtmarksController,
126
+ createHostClipboard,
127
+ createRendererClipboardAdapter,
119
128
  createTerminalPalette,
120
129
  createTextAttributes,
121
130
  cyan,
@@ -195,7 +204,7 @@ import {
195
204
  visualizeRenderableTree,
196
205
  white,
197
206
  yellow
198
- } from "./chunk-bun-ctxxvhwz.js";
207
+ } from "./chunk-bun-26r5c5w5.js";
199
208
  // src/post/effects.ts
200
209
  function toU8(value) {
201
210
  return Math.round(Math.max(0, Math.min(1, Number.isFinite(value) ? value : 0)) * 255);
@@ -5680,6 +5689,7 @@ var STATUS_CODES = [
5680
5689
  "internal-error",
5681
5690
  "unsupported-feature"
5682
5691
  ];
5692
+ var INVALID_ARGUMENT_STATUS = 7;
5683
5693
 
5684
5694
  class ImageError extends Error {
5685
5695
  code;
@@ -5984,6 +5994,9 @@ class NativeImage {
5984
5994
  clone() {
5985
5995
  return this.wrap(this.lib.imageClone(this.guard()));
5986
5996
  }
5997
+ retain() {
5998
+ return this.wrap(this.lib.imageRetain(this.guard()));
5999
+ }
5987
6000
  resize(options) {
5988
6001
  if (!options || options.width === undefined && options.height === undefined) {
5989
6002
  throw new TypeError("resize requires width, height, or both");
@@ -6033,6 +6046,9 @@ class NativeImage {
6033
6046
  throw new RangeError("opacity must be between 0 and 1");
6034
6047
  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
6048
  }
6049
+ ensureEncodedPng() {
6050
+ checkStatus(this.lib.imageEnsureEncodedPng(this.guard()));
6051
+ }
6036
6052
  raw(format = "rgba8") {
6037
6053
  const stride = this.width * 4;
6038
6054
  const data = new Uint8Array(stride * this.height);
@@ -6041,6 +6057,11 @@ class NativeImage {
6041
6057
  }
6042
6058
  takeRaw() {
6043
6059
  const handle = this.guard();
6060
+ const materializeStatus = this.lib.imageMaterialize(handle);
6061
+ if (materializeStatus === INVALID_ARGUMENT_STATUS) {
6062
+ throw new Error("Cannot transfer image pixels while native buffers retain the image");
6063
+ }
6064
+ checkStatus(materializeStatus);
6044
6065
  const pointer = this.lib.imageGetPixelsPtr(handle);
6045
6066
  if (!pointer)
6046
6067
  throw new Error("Cannot transfer image pixels while native buffers retain the image");
@@ -8720,6 +8741,7 @@ function pixelResolution(ctx) {
8720
8741
  class ImageRenderable extends Renderable {
8721
8742
  _source;
8722
8743
  _image = null;
8744
+ _pendingImage = null;
8723
8745
  _loadError = null;
8724
8746
  _loadController = null;
8725
8747
  onLoad;
@@ -8746,6 +8768,8 @@ class ImageRenderable extends Renderable {
8746
8768
  this._source = source;
8747
8769
  this._loadController?.abort();
8748
8770
  this._loadController = null;
8771
+ this._pendingImage?.dispose();
8772
+ this._pendingImage = null;
8749
8773
  if (source === undefined) {
8750
8774
  this._loadError = null;
8751
8775
  this._image?.dispose();
@@ -8757,7 +8781,19 @@ class ImageRenderable extends Renderable {
8757
8781
  const controller = new AbortController;
8758
8782
  this._loadController = controller;
8759
8783
  this._loadError = null;
8760
- this.loadPromise = this.load(source, controller);
8784
+ let imagePromise;
8785
+ if (source instanceof NativeImage) {
8786
+ try {
8787
+ const image = source.retain();
8788
+ this._pendingImage = image;
8789
+ imagePromise = Promise.resolve(image);
8790
+ } catch (error) {
8791
+ imagePromise = Promise.reject(error);
8792
+ }
8793
+ } else {
8794
+ imagePromise = NativeImage.load(source, { signal: controller.signal });
8795
+ }
8796
+ this.loadPromise = this.load(imagePromise, controller);
8761
8797
  }
8762
8798
  get image() {
8763
8799
  return this._image;
@@ -8846,10 +8882,10 @@ class ImageRenderable extends Renderable {
8846
8882
  }
8847
8883
  buffer.drawImage(this._image, x, y, fitted.width, fitted.height, pixelWidth, pixelHeight, sourceX, sourceY, sourceWidth, sourceHeight, this._protocol);
8848
8884
  }
8849
- async load(source, controller) {
8885
+ async load(imagePromise, controller) {
8850
8886
  let image;
8851
8887
  try {
8852
- image = await NativeImage.load(source, { signal: controller.signal });
8888
+ image = await imagePromise;
8853
8889
  } catch (error) {
8854
8890
  if (controller.signal.aborted || this.isDestroyed || this._loadController !== controller)
8855
8891
  return;
@@ -8862,6 +8898,8 @@ class ImageRenderable extends Renderable {
8862
8898
  image.dispose();
8863
8899
  return;
8864
8900
  }
8901
+ if (this._pendingImage === image)
8902
+ this._pendingImage = null;
8865
8903
  const previous = this._image;
8866
8904
  this._image = image;
8867
8905
  this._loadController = null;
@@ -8872,6 +8910,8 @@ class ImageRenderable extends Renderable {
8872
8910
  destroySelf() {
8873
8911
  this._loadController?.abort();
8874
8912
  this._loadController = null;
8913
+ this._pendingImage?.dispose();
8914
+ this._pendingImage = null;
8875
8915
  this._image?.dispose();
8876
8916
  this._image = null;
8877
8917
  super.destroySelf();
@@ -14950,10 +14990,13 @@ export {
14950
14990
  createTextAttributes,
14951
14991
  createTerminalPalette,
14952
14992
  createSlotRegistry,
14993
+ createRendererClipboardAdapter,
14953
14994
  createMarkdownCodeBlockRenderer,
14954
14995
  createIcyStreamDemuxer,
14996
+ createHostClipboard,
14955
14997
  createExtmarksController,
14956
14998
  createCoreSlotRegistry,
14999
+ createClipboard,
14957
15000
  createCliRenderer,
14958
15001
  coordinateToCharacterIndex,
14959
15002
  convertThemeToStyles,
@@ -15051,6 +15094,12 @@ export {
15051
15094
  NativeSpanFeed,
15052
15095
  NativeMeasureTargetKind,
15053
15096
  NativeImage,
15097
+ NativeClipboardStartStatus,
15098
+ NativeClipboardShutdownStatus,
15099
+ NativeClipboardOperationStatus,
15100
+ NativeClipboardDestroyStatus,
15101
+ NativeClipboardCopyStatus,
15102
+ NativeClipboardCancelStatus,
15054
15103
  NativeAudioStreamState2 as NativeAudioStreamState,
15055
15104
  NativeAudioStreamFormat2 as NativeAudioStreamFormat,
15056
15105
  NativeAudioStreamCloseReason2 as NativeAudioStreamCloseReason,
@@ -15124,5 +15173,5 @@ export {
15124
15173
  ACHROMATOPSIA_MATRIX
15125
15174
  };
15126
15175
 
15127
- //# debugId=B425557204321C4364756E2164756E21
15176
+ //# debugId=7EDEA741834B885264756E2164756E21
15128
15177
  //# sourceMappingURL=index.bun.js.map