@opentui/core 0.6.1 → 0.6.3

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.
@@ -244,6 +244,7 @@ var nativeSymbols = {
244
244
  returns: "i32"
245
245
  },
246
246
  ot_edit_buffer_measure_text: { args: ["ptr", "buffer", "ptr", "u32", "buffer"], returns: "i32" },
247
+ ot_edit_measure_text: { args: ["ptr", "ptr", "u32", "u32", "u32", "buffer"], returns: "i32" },
247
248
  ot_edit_buffer_set_defaults: { args: ["ptr", "buffer", "u32", "buffer"], returns: "i32" },
248
249
  ot_syntax_style_register: { args: ["ptr", "buffer", "ptr", "u32", "buffer", "buffer"], returns: "i32" },
249
250
  ot_syntax_style_resolve: { args: ["ptr", "buffer", "ptr", "u32", "buffer"], returns: "i32" },
@@ -1311,6 +1312,20 @@ var nativeLayouts = {
1311
1312
  color: { offset: 16, size: 8, alignment: 2, type: "[4]u16" }
1312
1313
  }
1313
1314
  },
1315
+ ot_session_program_status: {
1316
+ size: 32,
1317
+ alignment: 4,
1318
+ fields: {
1319
+ state: { offset: 0, size: 4, alignment: 4, type: "u32" },
1320
+ kind: { offset: 4, size: 4, alignment: 4, type: "u32" },
1321
+ fields: { offset: 8, size: 4, alignment: 4, type: "u32" },
1322
+ progress: { offset: 12, size: 4, alignment: 4, type: "u32" },
1323
+ id_len: { offset: 16, size: 4, alignment: 4, type: "u32" },
1324
+ app_len: { offset: 20, size: 4, alignment: 4, type: "u32" },
1325
+ title_len: { offset: 24, size: 4, alignment: 4, type: "u32" },
1326
+ message_len: { offset: 28, size: 4, alignment: 4, type: "u32" }
1327
+ }
1328
+ },
1314
1329
  ot_session_capabilities: {
1315
1330
  size: 144,
1316
1331
  alignment: 4,
@@ -1951,11 +1966,22 @@ var nativeConstants = {
1951
1966
  OT_CONTROL_CURSOR: 8,
1952
1967
  OT_CONTROL_RESET_BACKGROUND: 9,
1953
1968
  OT_CONTROL_PALETTE_QUERY: 10,
1969
+ OT_CONTROL_PROGRAM_STATUS: 11,
1954
1970
  OT_CURSOR_POSITION: 1,
1955
1971
  OT_CURSOR_STYLE: 2,
1956
1972
  OT_CURSOR_BLINKING: 4,
1957
1973
  OT_CURSOR_COLOR: 8,
1958
1974
  OT_CURSOR_MOUSE_POINTER: 16,
1975
+ OT_PROGRAM_STATE_IDLE: 1,
1976
+ OT_PROGRAM_STATE_WORKING: 2,
1977
+ OT_PROGRAM_STATE_DONE: 3,
1978
+ OT_PROGRAM_STATE_BLOCKED: 4,
1979
+ OT_PROGRAM_STATE_ERROR: 5,
1980
+ OT_PROGRAM_STATE_CLEAR: 6,
1981
+ OT_PROGRAM_KIND_PERMISSION: 1,
1982
+ OT_PROGRAM_KIND_QUESTION: 2,
1983
+ OT_PROGRAM_KIND_AUTH: 3,
1984
+ OT_PROGRAM_STATUS_PROGRESS: 1,
1959
1985
  OT_CAP_KITTY_KEYBOARD: 1,
1960
1986
  OT_CAP_KITTY_GRAPHICS: 2,
1961
1987
  OT_CAP_RGB: 4,
@@ -1973,6 +1999,7 @@ var nativeConstants = {
1973
1999
  OT_CAP_NOTIFICATIONS: 16384,
1974
2000
  OT_CAP_EXPLICIT_CURSOR_POSITIONING: 32768,
1975
2001
  OT_CAP_REMOTE: 65536,
2002
+ OT_CAP_PROGRAM_STATUS: 131072,
1976
2003
  OT_TERMINAL_UNINITIALIZED: 0,
1977
2004
  OT_TERMINAL_SETTING_UP: 1,
1978
2005
  OT_TERMINAL_ACTIVE: 2,
@@ -5741,6 +5768,19 @@ registerEnvVar2({
5741
5768
  });
5742
5769
  var CURSOR_STYLE_TO_ID = { block: 0, line: 1, underline: 2, default: 3 };
5743
5770
  var CURSOR_ID_TO_STYLE = ["block", "line", "underline", "default"];
5771
+ var PROGRAM_STATE_TO_ID = {
5772
+ idle: nativeConstants.OT_PROGRAM_STATE_IDLE,
5773
+ working: nativeConstants.OT_PROGRAM_STATE_WORKING,
5774
+ done: nativeConstants.OT_PROGRAM_STATE_DONE,
5775
+ blocked: nativeConstants.OT_PROGRAM_STATE_BLOCKED,
5776
+ error: nativeConstants.OT_PROGRAM_STATE_ERROR,
5777
+ clear: nativeConstants.OT_PROGRAM_STATE_CLEAR
5778
+ };
5779
+ var PROGRAM_KIND_TO_ID = {
5780
+ permission: nativeConstants.OT_PROGRAM_KIND_PERMISSION,
5781
+ question: nativeConstants.OT_PROGRAM_KIND_QUESTION,
5782
+ auth: nativeConstants.OT_PROGRAM_KIND_AUTH
5783
+ };
5744
5784
  var MOUSE_STYLE_TO_ID = {
5745
5785
  auto: nativeConstants.OT_MOUSE_POINTER_AUTO,
5746
5786
  default: nativeConstants.OT_MOUSE_POINTER_DEFAULT,
@@ -5875,6 +5915,50 @@ function sessionBytes(bytes, label) {
5875
5915
  }
5876
5916
  return new Uint8Array(typedArrayAccessors.buffer.get.call(bytes), typedArrayAccessors.byteOffset.get.call(bytes), length);
5877
5917
  }
5918
+ function programStatusPayload(status, encoder) {
5919
+ const layout = nativeLayouts.ot_session_program_status;
5920
+ const { state, kind, progress, id, app, title, message } = status;
5921
+ const stateId = typeof state === "string" ? PROGRAM_STATE_TO_ID[state] : undefined;
5922
+ if (typeof stateId !== "number")
5923
+ throw new TypeError("Unknown program status state");
5924
+ const header = new Uint32Array(layout.size / 4);
5925
+ header[layout.fields.state.offset / 4] = stateId;
5926
+ if (kind != null) {
5927
+ const kindId = typeof kind === "string" ? PROGRAM_KIND_TO_ID[kind] : undefined;
5928
+ if (typeof kindId !== "number")
5929
+ throw new TypeError("Unknown program status kind");
5930
+ header[layout.fields.kind.offset / 4] = kindId;
5931
+ }
5932
+ if (progress != null) {
5933
+ if (typeof progress !== "number")
5934
+ throw new TypeError("Program status progress must be a number");
5935
+ if (!isFFIU32(progress))
5936
+ throw new RangeError("Program status progress must be an integer percentage");
5937
+ header[layout.fields.fields.offset / 4] = nativeConstants.OT_PROGRAM_STATUS_PROGRESS;
5938
+ header[layout.fields.progress.offset / 4] = progress;
5939
+ }
5940
+ if (id === "")
5941
+ throw new RangeError("Program status id must not be empty; omit it for the root record");
5942
+ const text = { id, app, title, message };
5943
+ const parts = ["id", "app", "title", "message"].map((name) => {
5944
+ const value = text[name];
5945
+ if (value == null)
5946
+ return new Uint8Array(0);
5947
+ if (typeof value !== "string")
5948
+ throw new TypeError(`Program status ${name} must be a string`);
5949
+ const bytes = encoder.encode(value.slice(0, NATIVE_SESSION_CONTROL_PACKET_BYTES2 + 1));
5950
+ header[layout.fields[`${name}_len`].offset / 4] = bytes.byteLength;
5951
+ return bytes;
5952
+ });
5953
+ const payload = new Uint8Array(layout.size + parts.reduce((total, part) => total + part.byteLength, 0));
5954
+ payload.set(new Uint8Array(header.buffer));
5955
+ let offset = layout.size;
5956
+ for (const part of parts) {
5957
+ payload.set(part, offset);
5958
+ offset += part.byteLength;
5959
+ }
5960
+ return payload;
5961
+ }
5878
5962
  function pixelInput(data, length) {
5879
5963
  if (typeof data === "number" || typeof data === "bigint")
5880
5964
  return toPointer(data);
@@ -7715,6 +7799,7 @@ class FFIRenderLib2 {
7715
7799
  clipboardServices = new Map;
7716
7800
  clipboardOperations = new Map;
7717
7801
  audioEngines = new Map;
7802
+ editMeasureContext;
7718
7803
  invalidStandaloneHandle = new BigUint64Array(nativeLayouts.ot_handle.size / 8);
7719
7804
  encoder = new TextEncoder;
7720
7805
  emptyBytes = new Uint8Array(0);
@@ -8672,6 +8757,16 @@ class FFIRenderLib2 {
8672
8757
  nativeResult("ot_edit_buffer_measure_text", this.opentui.symbols.ot_edit_buffer_measure_text(pointer, handle, viewOrNull(input), input.length, output));
8673
8758
  return output[0];
8674
8759
  }
8760
+ editMeasureText(bytes, widthMethod, tabWidth) {
8761
+ const method = widthMethodId(widthMethod, "editor");
8762
+ const width = toSafeFFIU32Length(tabWidth, "Edit buffer tab width");
8763
+ const input = sessionBytes(bytes, "Edit buffer measure length");
8764
+ const output = new Uint32Array(1);
8765
+ this.editMeasureContext ??= this.createContext({ objectCapacity: 1, renderCellsMax: 1 });
8766
+ const pointer = this.nativeContextPointer(this.editMeasureContext, "ot_edit_measure_text");
8767
+ nativeResult("ot_edit_measure_text", this.opentui.symbols.ot_edit_measure_text(pointer, viewOrNull(input), input.length, method, width, output));
8768
+ return output[0];
8769
+ }
8675
8770
  contextEditBufferSetDefaults(context, editBuffer, mask, style) {
8676
8771
  const handle = encodeContextHandle(context, editBuffer);
8677
8772
  const fields = toSafeFFIU32Length(mask, "Editor default style mask");
@@ -9527,6 +9622,10 @@ class FFIRenderLib2 {
9527
9622
  record[kind] = nativeConstants.OT_CONTROL_KITTY_KEYBOARD_FLAGS;
9528
9623
  record[layout.fields.argument.offset / 4] = toSafeFFIU32Length(command.flags, "Session Kitty keyboard flags");
9529
9624
  break;
9625
+ case "program-status":
9626
+ record[kind] = nativeConstants.OT_CONTROL_PROGRAM_STATUS;
9627
+ bytes = programStatusPayload(command.status, this.encoder);
9628
+ break;
9530
9629
  case "restore-modes":
9531
9630
  record[kind] = nativeConstants.OT_CONTROL_RESTORE_MODES;
9532
9631
  break;
@@ -9660,6 +9759,7 @@ class FFIRenderLib2 {
9660
9759
  notifications: flag(nativeConstants.OT_CAP_NOTIFICATIONS),
9661
9760
  explicit_cursor_positioning: flag(nativeConstants.OT_CAP_EXPLICIT_CURSOR_POSITIONING),
9662
9761
  remote: flag(nativeConstants.OT_CAP_REMOTE),
9762
+ program_status: flag(nativeConstants.OT_CAP_PROGRAM_STATUS),
9663
9763
  unicode: widthMethodFromCode(output[layout.fields.width_method.offset / 4]),
9664
9764
  multiplexer: ["none", "tmux", "zellij", "screen", "unknown"][output[layout.fields.multiplexer.offset / 4]],
9665
9765
  image_protocol: ["auto", "kitty", "sixel", "blocks"][output[layout.fields.image_protocol.offset / 4]],
@@ -10534,10 +10634,13 @@ class FFIRenderLib2 {
10534
10634
  if (this.clipboardServices.size > 0) {
10535
10635
  throw new Error("Cannot dispose OpenTUI native library while clipboard services are active");
10536
10636
  }
10537
- if (this.nativeContexts.size !== this.audioEngines.size) {
10637
+ if (this.nativeContexts.size !== this.audioEngines.size + Number(this.editMeasureContext !== undefined)) {
10538
10638
  throw new NativeError2("dispose", -6 /* ContextBusy */);
10539
10639
  }
10540
10640
  this.yogaHost?.dispose();
10641
+ if (this.editMeasureContext)
10642
+ this.releaseContext(this.editMeasureContext);
10643
+ this.editMeasureContext = undefined;
10541
10644
  for (const [engine, context] of this.audioEngines) {
10542
10645
  this.releaseContext(context);
10543
10646
  this.audioEngines.delete(engine);
@@ -12499,5 +12602,5 @@ var yoga_default = Yoga;
12499
12602
 
12500
12603
  export { 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, 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, NativeEditPositionQuery2, NativeEditorStyleMask2, NativeEditHighlightOperation2, NativeEditorCommand2, NativeEditorSelectionOperation2, NativeEditorPositionQuery2, NativeEditEvent2, NativeStyleGroup, NativeStyleFlags, NATIVE_EDGE_NONE2, NativeBorder2, NativeSceneHook2, NativeSceneFrame2, NativeScenePaintPhase2, 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 };
12501
12604
 
12502
- //# debugId=81C2FE168242701064756E2164756E21
12503
- //# sourceMappingURL=chunk-node-f7c1g447.js.map
12605
+ //# debugId=43D93278DFBE8F4F64756E2164756E21
12606
+ //# sourceMappingURL=chunk-node-6rc18den.js.map