@opentui/core 0.9.0 → 0.9.1

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/NativeScene.d.ts CHANGED
@@ -153,7 +153,7 @@ export declare class NativeScene {
153
153
  getText(renderable: Renderable): string;
154
154
  /** @internal Inherited Text and Box drawing records or draws the native body at the caller's position. */
155
155
  drawBody(renderable: Renderable, buffer: OptimizedBuffer, x: number, y: number): void;
156
- setTextSelection(renderable: Renderable, operation: "set" | "update" | "reset", bounds: LocalSelectionBounds | null, bg?: RGBA, fg?: RGBA): boolean;
156
+ setTextSelection(renderable: Renderable, operation: "set" | "update" | "reset" | "colors", bounds: LocalSelectionBounds | null, bg?: RGBA, fg?: RGBA): boolean;
157
157
  getTextSelection(renderable: Renderable): {
158
158
  start: number;
159
159
  end: number;
package/Renderable.d.ts CHANGED
@@ -249,6 +249,12 @@ export declare abstract class Renderable extends BaseRenderable {
249
249
  requestRender(): void;
250
250
  /** @internal Native built-ins may suspend lifecycle work without losing their registration position. */
251
251
  _needsLifecyclePass(): boolean;
252
+ private _builtinLifecyclePass;
253
+ /** A widget's own lifecycle pass: it runs before `onLifecyclePass`, which callers may read, wrap or replace. */
254
+ protected setBuiltinLifecyclePass(pass: (() => void) | null): void;
255
+ /** @internal Runs the widget's own lifecycle pass, then the caller's published one: a hook defined on the
256
+ * instance runs only once `refreshHooks()` adopts it. */
257
+ _runLifecyclePass(): void;
252
258
  get translateX(): number;
253
259
  set translateX(value: number);
254
260
  get translateY(): number;
@@ -348,6 +348,7 @@ var nativeSymbols = {
348
348
  ot_text_buffer_get_range: { args: ["ptr", "buffer", "u32", "u32", "ptr", "u32", "buffer"], returns: "i32" },
349
349
  ot_text_buffer_set_defaults: { args: ["ptr", "buffer", "u32", "buffer"], returns: "i32" },
350
350
  ot_text_buffer_set_tab_width: { args: ["ptr", "buffer", "u32"], returns: "i32" },
351
+ ot_text_buffer_set_width_method: { args: ["ptr", "buffer", "u32"], returns: "i32" },
351
352
  ot_text_buffer_highlight: { args: ["ptr", "buffer", "u32", "u32", "ptr"], returns: "i32" },
352
353
  ot_text_buffer_get_highlights: { args: ["ptr", "buffer", "u32", "ptr", "u32", "buffer"], returns: "i32" },
353
354
  ot_text_buffer_set_layer: { args: ["ptr", "buffer", "u32", "u32", "u32", "ptr", "u32"], returns: "i32" },
@@ -1057,7 +1058,7 @@ var nativeLayouts = {
1057
1058
  struct_size: { offset: 0, size: 4, alignment: 4, type: "u32" },
1058
1059
  abi_version: { offset: 4, size: 4, alignment: 4, type: "u32" },
1059
1060
  width_method: { offset: 8, size: 4, alignment: 4, type: "u32" },
1060
- reserved: { offset: 12, size: 4, alignment: 4, type: "u32" }
1061
+ flags: { offset: 12, size: 4, alignment: 4, type: "u32" }
1061
1062
  }
1062
1063
  },
1063
1064
  ot_edit_buffer_info: {
@@ -2051,6 +2052,7 @@ var nativeConstants = {
2051
2052
  OT_SCENE_TEXT_SELECTION_RESET: 0,
2052
2053
  OT_SCENE_TEXT_SELECTION_SET: 1,
2053
2054
  OT_SCENE_TEXT_SELECTION_UPDATE: 2,
2055
+ OT_SCENE_TEXT_SELECTION_COLORS: 3,
2054
2056
  OT_SCENE_TEXT_SELECTION_CELL: 0,
2055
2057
  OT_SCENE_TEXT_SELECTION_WORD: 1,
2056
2058
  OT_SCENE_TEXT_SELECTION_LINE: 2,
@@ -2187,6 +2189,7 @@ var nativeConstants = {
2187
2189
  OT_EMBEDDED_TERMINAL_CLEAR_SELECTION: 2,
2188
2190
  OT_EMBEDDED_TERMINAL_SET_TRANSPARENT_BACKGROUND: 3,
2189
2191
  OT_EMBEDDED_TERMINAL_RESPONSE_BYTES_MAX: 1048576,
2192
+ OT_EDIT_BUFFER_FOLLOW_SESSION_WIDTH: 1,
2190
2193
  OT_EDIT_CURSOR_CHANGED: 1,
2191
2194
  OT_EDIT_CONTENT_CHANGED: 2,
2192
2195
  OT_EDIT_HISTORY_CURSOR_CHANGED: 4,
@@ -6092,6 +6095,14 @@ function allocFFIStruct(structDefinition) {
6092
6095
  const storage = allocStruct(structDefinition);
6093
6096
  return { ...storage, ffiView: new Uint8Array(storage.buffer) };
6094
6097
  }
6098
+ function editBufferOptions(options, kind) {
6099
+ const layout = nativeLayouts.ot_edit_buffer_options;
6100
+ const record = createContextRecord(layout);
6101
+ record[layout.fields.width_method.offset / 4] = widthMethodId(options.widthMethod ?? "unicode", kind);
6102
+ if (options.followSessionWidth)
6103
+ record[layout.fields.flags.offset / 4] = nativeConstants.OT_EDIT_BUFFER_FOLLOW_SESSION_WIDTH;
6104
+ return record;
6105
+ }
6095
6106
  var NativeTextViewCommand2;
6096
6107
  ((NativeTextViewCommand) => {
6097
6108
  NativeTextViewCommand[NativeTextViewCommand["WrapWidth"] = 0] = "WrapWidth";
@@ -8619,11 +8630,8 @@ class FFIRenderLib2 {
8619
8630
  return count[0] === 0 ? "" : this.decoder.decode(bytes.subarray(0, count[0]));
8620
8631
  }
8621
8632
  createContextTextBuffer(context, options = {}) {
8622
- const layout = nativeLayouts.ot_edit_buffer_options;
8623
8633
  this.getYogaHost().assertMutable();
8624
- const widthMethod = widthMethodId(options.widthMethod ?? "unicode", "text");
8625
- const record = createContextRecord(layout);
8626
- record[layout.fields.width_method.offset / 4] = widthMethod;
8634
+ const record = editBufferOptions(options, "text");
8627
8635
  const output = new Uint32Array(handleWords);
8628
8636
  const pointer = this.nativeContextPointer(context, "ot_text_buffer_create");
8629
8637
  nativeResult("ot_text_buffer_create", this.opentui.symbols.ot_text_buffer_create(pointer, record, output));
@@ -9160,6 +9168,14 @@ class FFIRenderLib2 {
9160
9168
  nativeResult("ot_text_buffer_set_tab_width", this.opentui.symbols.ot_text_buffer_set_tab_width(pointer, handle, value));
9161
9169
  });
9162
9170
  }
9171
+ contextTextBufferSetWidthMethod(context, text, widthMethod) {
9172
+ const handle = encodeContextHandle(context, text);
9173
+ const method = widthMethodId(widthMethod, "text");
9174
+ this.getYogaHost().runMutation(() => {
9175
+ const pointer = this.nativeContextPointer(context, "ot_text_buffer_set_width_method");
9176
+ nativeResult("ot_text_buffer_set_width_method", this.opentui.symbols.ot_text_buffer_set_width_method(pointer, handle, method));
9177
+ });
9178
+ }
9163
9179
  contextTextBufferHighlight(context, text, operation, argument = 0, highlight) {
9164
9180
  const handle = encodeContextHandle(context, text);
9165
9181
  const selector = toSafeFFIU32Length(operation, "Text highlight operation");
@@ -9362,11 +9378,8 @@ class FFIRenderLib2 {
9362
9378
  nativeResult("ot_buffer_draw_scene_body", this.opentui.symbols.ot_buffer_draw_scene_body(pointer, destination, request, source, column, row));
9363
9379
  }
9364
9380
  createContextEditBuffer(context, options = {}) {
9365
- const layout = nativeLayouts.ot_edit_buffer_options;
9366
9381
  this.getYogaHost().assertMutable();
9367
- const widthMethod = widthMethodId(options.widthMethod ?? "unicode", "editor");
9368
- const record = createContextRecord(layout);
9369
- record[layout.fields.width_method.offset / 4] = widthMethod;
9382
+ const record = editBufferOptions(options, "editor");
9370
9383
  const output = new Uint32Array(handleWords);
9371
9384
  const pointer = this.nativeContextPointer(context, "ot_edit_buffer_create");
9372
9385
  nativeResult("ot_edit_buffer_create", this.opentui.symbols.ot_edit_buffer_create(pointer, record, output));
@@ -11516,7 +11529,7 @@ class FFIRenderLib2 {
11516
11529
  this.getYogaHost().assertMutable();
11517
11530
  const handle = encodeContextHandle(context, node);
11518
11531
  const record = createContextRecord(layout);
11519
- const operation = ["reset", "set", "update"].indexOf(options.operation);
11532
+ const operation = ["reset", "set", "update", "colors"].indexOf(options.operation);
11520
11533
  const behavior = ["cell", "word", "line"].indexOf(options.behavior);
11521
11534
  if (operation < 0 || behavior < 0)
11522
11535
  throw new TypeError("Unknown scene text selection operation or behavior");
@@ -13891,5 +13904,5 @@ var yoga_default = Yoga;
13891
13904
 
13892
13905
  export { nativeLayouts, nativeConstants, toArrayBuffer, singleton, getSingleton, destroySingleton, envRegistry2, registerEnvVar2, clearEnvCache2, generateEnvMarkdown2, generateEnvColored2, env2, stringWidth, resolveBundledFilePath2, Worker, TextAttributes2, ATTRIBUTE_BASE_BITS2, ATTRIBUTE_BASE_MASK2, getBaseAttributes2, DebugOverlayCorner2, TargetChannel2, DEFAULT_FOREGROUND_RGB2, DEFAULT_BACKGROUND_RGB2, normalizeIndexedColorIndex2, ansi256IndexToRgb2, RGBA2, normalizeColorValue2, hexToRgb2, rgbToHex2, hsvToRgb2, parseColor2, createTextAttributes2, attributesWithLink2, getLinkId2, visualizeRenderableTree2, isStyledText2, StyledText2, stringToStyledText2, black2, red2, green2, yellow2, blue2, magenta2, cyan2, white2, brightBlack2, brightRed2, brightGreen2, brightYellow2, brightBlue2, brightMagenta2, brightCyan2, brightWhite2, bgBlack2, bgRed2, bgGreen2, bgYellow2, bgBlue2, bgMagenta2, bgCyan2, bgWhite2, bold2, italic2, underline2, strikethrough2, dim2, reverse2, blink2, fg2, bg2, link2, t2, YogaEnumKind, YogaFloatKind, YogaValueKind, sceneSetEnum, sceneGetEnum, sceneSetFloat, sceneGetFloat, sceneSetValue, sceneGetValue, sceneSetDimension, UNDEFINED_VALUE, parseYogaValue, SpanInfoStruct, NativeAudioStreamFormat2, NativeAudioStreamState2, NativeAudioStreamStateNames, NativeAudioStreamCloseReason2, isBunfsPath, normalizeBunfsPath, resolveDefaultParserAsset, resolveDefaultTreeSitterWorkerPath, resolveTreeSitterWasm, NativeAudioStreamState3, NativeAudioStreamCloseReason3, NativeAudioStreamFormat3, MAX_LINK_URL_BYTES2, NativeTextViewCommand2, NativeEditCommand2, NativeEditAtomic, NativeEditPositionQuery2, NativeEditorStyleMask2, NativeEditHighlightOperation2, NativeEditorCommand2, NativeEditorSelectionOperation2, NativeEditorPositionQuery2, NativeEditEvent2, NativeStyleGroup, NativeStyleFlags, NATIVE_EDGE_NONE2, NativeBorder2, NativeSceneHook2, NativeSceneFrame2, NativeScenePaintPhase2, emptySceneScrollState, NATIVE_BUFFER_TEXT_BYTES_MAX2, NativeSessionState2, NativeSessionRenderStatus2, NATIVE_SESSION_CONTROL_PACKET_BYTES2, NativeSessionTerminalPhase2, NativeSessionPumpStatus2, NativeStatus2, NativeError2, NativeClipboardOperationStatus2, NativeClipboardStartStatus2, NativeClipboardCancelStatus2, NativeClipboardCopyStatus2, NativeClipboardDestroyStatus2, NativeClipboardShutdownStatus2, SceneStaging, NativePaintRecorder, LogLevel2, FFIRenderLib2, setRenderLibPath2, resolveRenderLib2, Align2, BoxSizing2, Dimension2, Direction2, Display2, Edge2, Errata2, ExperimentalFeature2, FlexDirection2, Gutter2, Justify2, LogLevel3, MeasureMode2, NodeType2, Overflow2, PositionType2, Unit2, Wrap2, ALIGN_AUTO2, ALIGN_FLEX_START2, ALIGN_CENTER2, ALIGN_FLEX_END2, ALIGN_STRETCH2, ALIGN_BASELINE2, ALIGN_SPACE_BETWEEN2, ALIGN_SPACE_AROUND2, ALIGN_SPACE_EVENLY2, BOX_SIZING_BORDER_BOX2, BOX_SIZING_CONTENT_BOX2, DIMENSION_WIDTH2, DIMENSION_HEIGHT2, DIRECTION_INHERIT2, DIRECTION_LTR2, DIRECTION_RTL2, DISPLAY_FLEX2, DISPLAY_NONE2, DISPLAY_CONTENTS2, EDGE_LEFT2, EDGE_TOP2, EDGE_RIGHT2, EDGE_BOTTOM2, EDGE_START2, EDGE_END2, EDGE_HORIZONTAL2, EDGE_VERTICAL2, EDGE_ALL2, ERRATA_NONE2, ERRATA_STRETCH_FLEX_BASIS2, ERRATA_ABSOLUTE_POSITION_WITHOUT_INSETS_EXCLUDES_PADDING2, ERRATA_ABSOLUTE_PERCENT_AGAINST_INNER_SIZE2, ERRATA_ALL2, ERRATA_CLASSIC2, EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS2, FLEX_DIRECTION_COLUMN2, FLEX_DIRECTION_COLUMN_REVERSE2, FLEX_DIRECTION_ROW2, FLEX_DIRECTION_ROW_REVERSE2, GUTTER_COLUMN2, GUTTER_ROW2, GUTTER_ALL2, JUSTIFY_FLEX_START2, JUSTIFY_CENTER2, JUSTIFY_FLEX_END2, JUSTIFY_SPACE_BETWEEN2, JUSTIFY_SPACE_AROUND2, JUSTIFY_SPACE_EVENLY2, LOG_LEVEL_ERROR2, LOG_LEVEL_WARN2, LOG_LEVEL_INFO2, LOG_LEVEL_DEBUG2, LOG_LEVEL_VERBOSE2, LOG_LEVEL_FATAL2, MEASURE_MODE_UNDEFINED2, MEASURE_MODE_EXACTLY2, MEASURE_MODE_AT_MOST2, NODE_TYPE_DEFAULT2, NODE_TYPE_TEXT2, OVERFLOW_VISIBLE2, OVERFLOW_HIDDEN2, OVERFLOW_SCROLL2, POSITION_TYPE_STATIC2, POSITION_TYPE_RELATIVE2, POSITION_TYPE_ABSOLUTE2, UNIT_UNDEFINED2, UNIT_POINT2, UNIT_PERCENT2, UNIT_AUTO2, WRAP_NO_WRAP2, WRAP_WRAP2, WRAP_WRAP_REVERSE2, YogaStatus2, YogaError2, Config2, Node2, exports_yoga, yoga_default };
13893
13906
 
13894
- //# debugId=CC184CCF119C49F064756E2164756E21
13895
- //# sourceMappingURL=chunk-bun-ywheza3e.js.map
13907
+ //# debugId=9C4AF511A188811164756E2164756E21
13908
+ //# sourceMappingURL=chunk-bun-v1wzs0bj.js.map