@opentui/core 0.6.5 → 0.6.7

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.
@@ -2337,76 +2337,76 @@ function normalizeNodeDefinitions(definitions) {
2337
2337
  function wrapNodeSymbols(functions, definitions) {
2338
2338
  return Object.fromEntries(Object.entries(functions).map(([name, fn]) => [name, wrapNodeSymbol(fn, definitions[name])]));
2339
2339
  }
2340
+ var NODE_ARGUMENT_AS_IS = 0;
2341
+ var NODE_ARGUMENT_POINTER = 1;
2342
+ var NODE_ARGUMENT_INT32 = 2;
2343
+ function toNodeArgumentKind(type) {
2344
+ if (isNodePointerArgumentType(type))
2345
+ return NODE_ARGUMENT_POINTER;
2346
+ const nodeType = toNodeFFIType(type, "parameter");
2347
+ return nodeType === "i32" || nodeType === "u32" ? NODE_ARGUMENT_INT32 : NODE_ARGUMENT_AS_IS;
2348
+ }
2349
+ function toNodeArgument(value, kind) {
2350
+ if (kind === NODE_ARGUMENT_POINTER)
2351
+ return toNodePointerArgumentFast(value);
2352
+ return kind === NODE_ARGUMENT_INT32 && value === 0 ? 0 : value;
2353
+ }
2340
2354
  function wrapNodeSymbol(fn, definition) {
2341
- const pointerArgIndexes = (definition.args ?? []).flatMap((type, index) => isNodePointerArgumentType(type) ? [index] : []);
2342
- if (pointerArgIndexes.length === 0) {
2355
+ const kinds = (definition.args ?? []).map(toNodeArgumentKind);
2356
+ const pointerCount = kinds.filter((kind) => kind === NODE_ARGUMENT_POINTER).length;
2357
+ if (kinds.every((kind) => kind === NODE_ARGUMENT_AS_IS)) {
2343
2358
  return fn;
2344
2359
  }
2345
- if (definition.args?.length === 7 && pointerArgIndexes.length >= 2) {
2346
- return wrapNodeSymbol7(fn, pointerArgIndexes);
2360
+ if (kinds.length === 7 && pointerCount >= 2) {
2361
+ return wrapNodeSymbol7(fn, kinds);
2347
2362
  }
2348
- if (definition.args?.length === 8) {
2349
- return wrapNodeSymbol8(fn, pointerArgIndexes);
2363
+ if (kinds.length === 8) {
2364
+ return wrapNodeSymbol8(fn, kinds);
2350
2365
  }
2351
- const pointerArgs = new Set(pointerArgIndexes);
2352
- const normalize = (value, index) => pointerArgs.has(index) ? toNodePointerArgumentFast(value) : value;
2353
- switch (definition.args?.length) {
2366
+ const [kind0, kind1, kind2] = kinds;
2367
+ switch (kinds.length) {
2354
2368
  case 1:
2355
2369
  return function(arg0) {
2356
2370
  if (arguments.length !== 1)
2357
2371
  return Reflect.apply(fn, undefined, arguments);
2358
- return fn(normalize(arg0, 0));
2372
+ return fn(toNodeArgument(arg0, kind0));
2359
2373
  };
2360
2374
  case 2:
2361
2375
  return function(arg0, arg1) {
2362
2376
  if (arguments.length !== 2)
2363
2377
  return Reflect.apply(fn, undefined, arguments);
2364
- return fn(normalize(arg0, 0), normalize(arg1, 1));
2378
+ return fn(toNodeArgument(arg0, kind0), toNodeArgument(arg1, kind1));
2365
2379
  };
2366
2380
  case 3:
2367
2381
  return function(arg0, arg1, arg2) {
2368
2382
  if (arguments.length !== 3)
2369
2383
  return Reflect.apply(fn, undefined, arguments);
2370
- return fn(normalize(arg0, 0), normalize(arg1, 1), normalize(arg2, 2));
2384
+ return fn(toNodeArgument(arg0, kind0), toNodeArgument(arg1, kind1), toNodeArgument(arg2, kind2));
2371
2385
  };
2372
2386
  }
2387
+ const adaptedIndexes = kinds.flatMap((kind, index) => kind === NODE_ARGUMENT_AS_IS ? [] : [index]);
2373
2388
  return (...args) => {
2374
2389
  const normalizedArgs = args.slice();
2375
- for (const index of pointerArgIndexes) {
2376
- normalizedArgs[index] = toNodePointerArgument(normalizedArgs[index]);
2390
+ for (const index of adaptedIndexes) {
2391
+ normalizedArgs[index] = toNodeArgument(normalizedArgs[index], kinds[index]);
2377
2392
  }
2378
2393
  return fn(...normalizedArgs);
2379
2394
  };
2380
2395
  }
2381
- function wrapNodeSymbol7(fn, pointerArgIndexes) {
2382
- const pointer0 = pointerArgIndexes.includes(0);
2383
- const pointer1 = pointerArgIndexes.includes(1);
2384
- const pointer2 = pointerArgIndexes.includes(2);
2385
- const pointer3 = pointerArgIndexes.includes(3);
2386
- const pointer4 = pointerArgIndexes.includes(4);
2387
- const pointer5 = pointerArgIndexes.includes(5);
2388
- const pointer6 = pointerArgIndexes.includes(6);
2389
- const normalize = (value, pointer) => pointer ? toNodePointerArgumentFast(value) : value;
2396
+ function wrapNodeSymbol7(fn, kinds) {
2397
+ const [kind0, kind1, kind2, kind3, kind4, kind5, kind6] = kinds;
2390
2398
  return function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
2391
2399
  if (arguments.length !== 7)
2392
2400
  return Reflect.apply(fn, undefined, arguments);
2393
- return fn(normalize(arg0, pointer0), normalize(arg1, pointer1), normalize(arg2, pointer2), normalize(arg3, pointer3), normalize(arg4, pointer4), normalize(arg5, pointer5), normalize(arg6, pointer6));
2401
+ return fn(toNodeArgument(arg0, kind0), toNodeArgument(arg1, kind1), toNodeArgument(arg2, kind2), toNodeArgument(arg3, kind3), toNodeArgument(arg4, kind4), toNodeArgument(arg5, kind5), toNodeArgument(arg6, kind6));
2394
2402
  };
2395
2403
  }
2396
- function wrapNodeSymbol8(fn, pointerArgIndexes) {
2397
- const pointer0 = pointerArgIndexes.includes(0);
2398
- const pointer1 = pointerArgIndexes.includes(1);
2399
- const pointer2 = pointerArgIndexes.includes(2);
2400
- const pointer3 = pointerArgIndexes.includes(3);
2401
- const pointer4 = pointerArgIndexes.includes(4);
2402
- const pointer5 = pointerArgIndexes.includes(5);
2403
- const pointer6 = pointerArgIndexes.includes(6);
2404
- const pointer7 = pointerArgIndexes.includes(7);
2405
- const normalize = (value, pointer) => pointer ? toNodePointerArgumentFast(value) : value;
2404
+ function wrapNodeSymbol8(fn, kinds) {
2405
+ const [kind0, kind1, kind2, kind3, kind4, kind5, kind6, kind7] = kinds;
2406
2406
  return function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
2407
2407
  if (arguments.length !== 8)
2408
2408
  return Reflect.apply(fn, undefined, arguments);
2409
- return fn(normalize(arg0, pointer0), normalize(arg1, pointer1), normalize(arg2, pointer2), normalize(arg3, pointer3), normalize(arg4, pointer4), normalize(arg5, pointer5), normalize(arg6, pointer6), normalize(arg7, pointer7));
2409
+ return fn(toNodeArgument(arg0, kind0), toNodeArgument(arg1, kind1), toNodeArgument(arg2, kind2), toNodeArgument(arg3, kind3), toNodeArgument(arg4, kind4), toNodeArgument(arg5, kind5), toNodeArgument(arg6, kind6), toNodeArgument(arg7, kind7));
2410
2410
  };
2411
2411
  }
2412
2412
  function toNodePointerArgumentFast(value) {
@@ -5643,8 +5643,8 @@ var NativeStatus2;
5643
5643
  class NativeError2 extends Error {
5644
5644
  operation;
5645
5645
  status;
5646
- constructor(operation, status) {
5647
- super(`${operation} failed: ${NativeStatus2[status] ?? `status ${status}`}`);
5646
+ constructor(operation, status, reason = NativeStatus2[status] ?? `status ${status}`) {
5647
+ super(`${operation} failed: ${reason}`);
5648
5648
  this.operation = operation;
5649
5649
  this.status = status;
5650
5650
  this.name = "NativeError";
@@ -5867,9 +5867,10 @@ function toSafeByteCount(value, label) {
5867
5867
  return Number(value);
5868
5868
  }
5869
5869
  function toSafeFFIU32Length(value, label) {
5870
- if (!Number.isSafeInteger(value) || value < 0 || value > MAX_FFI_U32) {
5870
+ if (!Number.isInteger(value) || value < 0)
5871
+ throw new RangeError(`${label} must be a non-negative integer`);
5872
+ if (value > MAX_FFI_U32)
5871
5873
  throw new RangeError(`${label} exceeds native u32 length limit`);
5872
- }
5873
5874
  return value;
5874
5875
  }
5875
5876
  function isFFIU32(value) {
@@ -7768,8 +7769,8 @@ class FFIRenderLib2 {
7768
7769
  hitTestOutput = new Uint32Array(1);
7769
7770
  bufferStackInput = new Float32Array(1);
7770
7771
  bufferStackOutput = new Float32Array(1);
7771
- drawTextBytes;
7772
- drawBottomBytes;
7772
+ drawTextBytes = new Uint8Array(NATIVE_BUFFER_TEXT_BYTES_MAX2);
7773
+ drawBottomBytes = new Uint8Array(NATIVE_BUFFER_TEXT_BYTES_MAX2);
7773
7774
  opentui;
7774
7775
  iccCacheClient = false;
7775
7776
  yogaLayout = new Float32Array(6);
@@ -8555,8 +8556,8 @@ class FFIRenderLib2 {
8555
8556
  const destination = encodeContextHandle(context, target);
8556
8557
  const request = frame === null ? null : encodeSceneFrameRequest(context, frame);
8557
8558
  const source = encodeContextHandle(context, view);
8558
- const column = toFFII32(x, "Text view x") || 0;
8559
- const row = toFFII32(y, "Text view y") || 0;
8559
+ const column = toFFII32(x, "Text view x");
8560
+ const row = toFFII32(y, "Text view y");
8560
8561
  const pointer = this.nativeContextPointer(context, "ot_buffer_draw_text_view");
8561
8562
  nativeResult("ot_buffer_draw_text_view", this.opentui.symbols.ot_buffer_draw_text_view(pointer, destination, request, source, column, row));
8562
8563
  }
@@ -8565,8 +8566,8 @@ class FFIRenderLib2 {
8565
8566
  const destination = encodeContextHandle(context, target);
8566
8567
  const request = frame === null ? null : encodeSceneFrameRequest(context, frame);
8567
8568
  const source = encodeContextHandle(context, view);
8568
- const column = toFFII32(x, "Editor view x") || 0;
8569
- const row = toFFII32(y, "Editor view y") || 0;
8569
+ const column = toFFII32(x, "Editor view x");
8570
+ const row = toFFII32(y, "Editor view y");
8570
8571
  const pointer = this.nativeContextPointer(context, "ot_buffer_draw_editor_view");
8571
8572
  nativeResult("ot_buffer_draw_editor_view", this.opentui.symbols.ot_buffer_draw_editor_view(pointer, destination, request, source, column, row));
8572
8573
  }
@@ -8575,8 +8576,8 @@ class FFIRenderLib2 {
8575
8576
  const destination = encodeContextHandle(context, target);
8576
8577
  const request = frame === null ? null : encodeSceneFrameRequest(context, frame);
8577
8578
  const source = encodeContextHandle(context, node);
8578
- const column = toFFII32(x, "Scene text x") || 0;
8579
- const row = toFFII32(y, "Scene text y") || 0;
8579
+ const column = toFFII32(x, "Scene text x");
8580
+ const row = toFFII32(y, "Scene text y");
8580
8581
  const pointer = this.nativeContextPointer(context, "ot_buffer_draw_scene_text");
8581
8582
  nativeResult("ot_buffer_draw_scene_text", this.opentui.symbols.ot_buffer_draw_scene_text(pointer, destination, request, source, column, row));
8582
8583
  }
@@ -9217,8 +9218,8 @@ class FFIRenderLib2 {
9217
9218
  const encoded = encodeBufferDrawRecord(context, options, scratch.words, signed, colors, 0, scratch.source);
9218
9219
  const record = scratch.records[encoded.operation];
9219
9220
  const source = encoded.source;
9220
- const textBytes = this.drawTextBytes ??= new Uint8Array(NATIVE_BUFFER_TEXT_BYTES_MAX2);
9221
- const bottomBytes = this.drawBottomBytes ??= new Uint8Array(NATIVE_BUFFER_TEXT_BYTES_MAX2);
9221
+ const textBytes = this.drawTextBytes;
9222
+ const bottomBytes = this.drawBottomBytes;
9222
9223
  const textLength = encodeDrawText(text, textBytes);
9223
9224
  const bottomLength = encodeDrawText(bottom, bottomBytes);
9224
9225
  const pointer = this.nativeContextPointer(context, "ot_buffer_draw");
@@ -9941,7 +9942,10 @@ class FFIRenderLib2 {
9941
9942
  const destination = parent === null ? null : encodeContextHandle(context, parent, scratch.target.record, scratch.target.words);
9942
9943
  const childIndex = toSafeFFIU32Length(index, "Scene child index");
9943
9944
  const pointer = this.nativeContextPointer(context, "ot_scene_move_node");
9944
- nativeResult("ot_scene_move_node", this.opentui.symbols.ot_scene_move_node(pointer, handle, destination, childIndex));
9945
+ const status = this.opentui.symbols.ot_scene_move_node(pointer, handle, destination, childIndex);
9946
+ if (status === -16 /* ObjectLimit */)
9947
+ throw new NativeError2("ot_scene_move_node", status, "Scene nesting depth exceeds the native limit");
9948
+ nativeResult("ot_scene_move_node", status);
9945
9949
  } finally {
9946
9950
  this.sceneMoveRecord ??= scratch;
9947
9951
  }
@@ -9999,11 +10003,11 @@ class FFIRenderLib2 {
9999
10003
  const bottomTitle = details.bottomTitle ?? "";
10000
10004
  if (typeof title !== "string" || typeof bottomTitle !== "string")
10001
10005
  throw new TypeError("Box titles must be strings");
10002
- const topBytes = sessionBytes(this.encoder.encode(title), "Box title length");
10003
- const bottomBytes = sessionBytes(this.encoder.encode(bottomTitle), "Box bottom title length");
10006
+ const topLength = encodeDrawText(title, this.drawTextBytes);
10007
+ const bottomLength = encodeDrawText(bottomTitle, this.drawBottomBytes);
10004
10008
  this.getYogaHost().runMutation(() => {
10005
10009
  const pointer = this.nativeContextPointer(context, "ot_scene_set_box_details");
10006
- nativeResult("ot_scene_set_box_details", this.opentui.symbols.ot_scene_set_box_details(pointer, handle, record, viewOrNull(topBytes), topBytes.length, viewOrNull(bottomBytes), bottomBytes.length));
10010
+ nativeResult("ot_scene_set_box_details", this.opentui.symbols.ot_scene_set_box_details(pointer, handle, record, topLength === 0 ? null : this.drawTextBytes, topLength, bottomLength === 0 ? null : this.drawBottomBytes, bottomLength));
10007
10011
  });
10008
10012
  }
10009
10013
  sceneSetSurface(context, node, buffer) {
@@ -12605,5 +12609,5 @@ var yoga_default = Yoga;
12605
12609
 
12606
12610
  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, 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, 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 };
12607
12611
 
12608
- //# debugId=6E0E728A6EFFFB9864756E2164756E21
12609
- //# sourceMappingURL=chunk-node-bjkm7vf5.js.map
12612
+ //# debugId=84623B9793C8945E64756E2164756E21
12613
+ //# sourceMappingURL=chunk-node-jhq62x0c.js.map