@opentui/core 0.0.0-20251001-ad2d8bd4 → 0.0.0-20251006-283f60d7

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/3d.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  __export,
6
6
  __require,
7
7
  __toESM
8
- } from "./index-nyqttas2.js";
8
+ } from "./index-hxktycf0.js";
9
9
 
10
10
  // ../../node_modules/omggif/omggif.js
11
11
  var require_omggif = __commonJS((exports) => {
package/Renderable.d.ts CHANGED
@@ -98,6 +98,7 @@ export declare abstract class BaseRenderable extends EventEmitter {
98
98
  abstract getChildrenCount(): number;
99
99
  abstract getRenderable(id: string): BaseRenderable | undefined;
100
100
  abstract requestRender(): void;
101
+ abstract findDescendantById(id: string): BaseRenderable | undefined;
101
102
  get id(): string;
102
103
  set id(value: string);
103
104
  get isDirty(): boolean;
@@ -4416,6 +4416,55 @@ function hastToStyledText(hast, syntaxStyle) {
4416
4416
  return new StyledText(chunks);
4417
4417
  }
4418
4418
 
4419
+ // src/lib/scroll-acceleration.ts
4420
+ class LinearScrollAccel {
4421
+ tick(_now) {
4422
+ return 1;
4423
+ }
4424
+ reset() {}
4425
+ }
4426
+
4427
+ class MacOSScrollAccel {
4428
+ opts;
4429
+ lastTickTime = 0;
4430
+ velocityHistory = [];
4431
+ historySize = 3;
4432
+ streakTimeout = 150;
4433
+ constructor(opts = {}) {
4434
+ this.opts = opts;
4435
+ }
4436
+ tick(now = Date.now()) {
4437
+ const A = this.opts.A ?? 0.8;
4438
+ const tau = this.opts.tau ?? 3;
4439
+ const maxMultiplier = this.opts.maxMultiplier ?? 6;
4440
+ const dt = this.lastTickTime ? now - this.lastTickTime : Infinity;
4441
+ this.lastTickTime = now;
4442
+ if (dt > this.streakTimeout) {
4443
+ this.velocityHistory = [];
4444
+ return 1;
4445
+ }
4446
+ if (dt !== Infinity) {
4447
+ this.velocityHistory.push(dt);
4448
+ if (this.velocityHistory.length > this.historySize) {
4449
+ this.velocityHistory.shift();
4450
+ }
4451
+ }
4452
+ const avgInterval = this.velocityHistory.length > 0 ? this.velocityHistory.reduce((a, b) => a + b, 0) / this.velocityHistory.length : Infinity;
4453
+ if (avgInterval === Infinity) {
4454
+ return 1;
4455
+ }
4456
+ const referenceInterval = 100;
4457
+ const velocity = referenceInterval / avgInterval;
4458
+ const x = velocity / tau;
4459
+ const multiplier = 1 + A * (Math.exp(x) - 1);
4460
+ return Math.min(multiplier, maxMultiplier);
4461
+ }
4462
+ reset() {
4463
+ this.lastTickTime = 0;
4464
+ this.velocityHistory = [];
4465
+ }
4466
+ }
4467
+
4419
4468
  // src/lib/yoga.options.ts
4420
4469
  function parseAlign(value) {
4421
4470
  switch (value.toLowerCase()) {
@@ -5285,20 +5334,10 @@ class ProcessQueue {
5285
5334
  // src/lib/tree-sitter/default-parsers.ts
5286
5335
  import { resolve, dirname } from "path";
5287
5336
  import { fileURLToPath } from "url";
5288
-
5289
- // src/lib/tree-sitter/assets/javascript/highlights.scm
5290
- var highlights_default = "./highlights-ghv9g403.scm";
5291
-
5292
- // src/lib/tree-sitter/assets/javascript/tree-sitter-javascript.wasm
5293
- var tree_sitter_javascript_default = "./tree-sitter-javascript-nd0q4pe9.wasm";
5294
-
5295
- // src/lib/tree-sitter/assets/typescript/highlights.scm
5296
- var highlights_default2 = "./highlights-eq9cgrbb.scm";
5297
-
5298
- // src/lib/tree-sitter/assets/typescript/tree-sitter-typescript.wasm
5299
- var tree_sitter_typescript_default = "./tree-sitter-typescript-zxjzwt75.wasm";
5300
-
5301
- // src/lib/tree-sitter/default-parsers.ts
5337
+ import javascript_highlights from "./assets/javascript/highlights.scm" with { type: "file" };
5338
+ import javascript_language from "./assets/javascript/tree-sitter-javascript.wasm" with { type: "file" };
5339
+ import typescript_highlights from "./assets/typescript/highlights.scm" with { type: "file" };
5340
+ import typescript_language from "./assets/typescript/tree-sitter-typescript.wasm" with { type: "file" };
5302
5341
  var _cachedParsers;
5303
5342
  function getParsers() {
5304
5343
  if (!_cachedParsers) {
@@ -5306,16 +5345,16 @@ function getParsers() {
5306
5345
  {
5307
5346
  filetype: "javascript",
5308
5347
  queries: {
5309
- highlights: [resolve(dirname(fileURLToPath(import.meta.url)), highlights_default)]
5348
+ highlights: [resolve(dirname(fileURLToPath(import.meta.url)), javascript_highlights)]
5310
5349
  },
5311
- wasm: resolve(dirname(fileURLToPath(import.meta.url)), tree_sitter_javascript_default)
5350
+ wasm: resolve(dirname(fileURLToPath(import.meta.url)), javascript_language)
5312
5351
  },
5313
5352
  {
5314
5353
  filetype: "typescript",
5315
5354
  queries: {
5316
- highlights: [resolve(dirname(fileURLToPath(import.meta.url)), highlights_default2)]
5355
+ highlights: [resolve(dirname(fileURLToPath(import.meta.url)), typescript_highlights)]
5317
5356
  },
5318
- wasm: resolve(dirname(fileURLToPath(import.meta.url)), tree_sitter_typescript_default)
5357
+ wasm: resolve(dirname(fileURLToPath(import.meta.url)), typescript_language)
5319
5358
  }
5320
5359
  ];
5321
5360
  }
@@ -5325,6 +5364,13 @@ function getParsers() {
5325
5364
  // src/lib/tree-sitter/client.ts
5326
5365
  import { resolve as resolve2, isAbsolute } from "path";
5327
5366
  import { existsSync } from "fs";
5367
+ import { parse } from "path";
5368
+ registerEnvVar({
5369
+ name: "OTUI_TREE_SITTER_WORKER_PATH",
5370
+ description: "Path to the TreeSitter worker",
5371
+ type: "string",
5372
+ default: ""
5373
+ });
5328
5374
  var DEFAULT_PARSERS = getParsers();
5329
5375
  function addDefaultParsers(parsers) {
5330
5376
  for (const parser of parsers) {
@@ -5336,6 +5382,7 @@ function addDefaultParsers(parsers) {
5336
5382
  }
5337
5383
  }
5338
5384
  }
5385
+ var isUrl = (path) => path.startsWith("http://") || path.startsWith("https://");
5339
5386
 
5340
5387
  class TreeSitterClient extends EventEmitter2 {
5341
5388
  initialized = false;
@@ -5369,7 +5416,11 @@ class TreeSitterClient extends EventEmitter2 {
5369
5416
  return;
5370
5417
  }
5371
5418
  let worker_path;
5372
- if (this.options.workerPath) {
5419
+ if (env.OTUI_TREE_SITTER_WORKER_PATH) {
5420
+ worker_path = env.OTUI_TREE_SITTER_WORKER_PATH;
5421
+ } else if (typeof OTUI_TREE_SITTER_WORKER_PATH !== "undefined") {
5422
+ worker_path = OTUI_TREE_SITTER_WORKER_PATH;
5423
+ } else if (this.options.workerPath) {
5373
5424
  worker_path = this.options.workerPath;
5374
5425
  } else {
5375
5426
  worker_path = new URL("./parser.worker.js", import.meta.url).href;
@@ -5431,13 +5482,24 @@ class TreeSitterClient extends EventEmitter2 {
5431
5482
  this.addFiletypeParser(parser);
5432
5483
  }
5433
5484
  }
5485
+ resolvePath(path) {
5486
+ if (isUrl(path)) {
5487
+ return path;
5488
+ }
5489
+ if (/\$bunfs/.test(path)) {
5490
+ return "/$bunfs/root/" + parse(path).base;
5491
+ }
5492
+ if (!isAbsolute(path)) {
5493
+ return resolve2(path);
5494
+ }
5495
+ return path;
5496
+ }
5434
5497
  addFiletypeParser(filetypeParser) {
5435
- const isUrl = (path) => path.startsWith("http://") || path.startsWith("https://");
5436
5498
  const resolvedParser = {
5437
5499
  ...filetypeParser,
5438
- wasm: isUrl(filetypeParser.wasm) || isAbsolute(filetypeParser.wasm) ? filetypeParser.wasm : resolve2(filetypeParser.wasm),
5500
+ wasm: this.resolvePath(filetypeParser.wasm),
5439
5501
  queries: {
5440
- highlights: filetypeParser.queries.highlights.map((path) => isUrl(path) || isAbsolute(path) ? path : resolve2(path))
5502
+ highlights: filetypeParser.queries.highlights.map((path) => this.resolvePath(path))
5441
5503
  }
5442
5504
  };
5443
5505
  this.worker?.postMessage({ type: "ADD_FILETYPE_PARSER", filetypeParser: resolvedParser });
@@ -5939,8 +6001,8 @@ class DownloadUtils {
5939
6001
  return Math.abs(hash).toString(16);
5940
6002
  }
5941
6003
  static async downloadOrLoad(source, cacheDir, cacheSubdir, fileExtension, useHashForCache = true, filetype) {
5942
- const isUrl = source.startsWith("http://") || source.startsWith("https://");
5943
- if (isUrl) {
6004
+ const isUrl2 = source.startsWith("http://") || source.startsWith("https://");
6005
+ if (isUrl2) {
5944
6006
  let cacheFileName;
5945
6007
  if (useHashForCache) {
5946
6008
  const hash = this.hashUrl(source);
@@ -5985,9 +6047,9 @@ class DownloadUtils {
5985
6047
  }
5986
6048
  }
5987
6049
  static async downloadToPath(source, targetPath) {
5988
- const isUrl = source.startsWith("http://") || source.startsWith("https://");
6050
+ const isUrl2 = source.startsWith("http://") || source.startsWith("https://");
5989
6051
  await mkdir(path2.dirname(targetPath), { recursive: true });
5990
- if (isUrl) {
6052
+ if (isUrl2) {
5991
6053
  try {
5992
6054
  console.log(`Downloading from URL: ${source}`);
5993
6055
  const response = await fetch(source);
@@ -6033,7 +6095,7 @@ class DownloadUtils {
6033
6095
  }
6034
6096
 
6035
6097
  // src/lib/tree-sitter/assets/update.ts
6036
- var __dirname = "/Users/kmdr/workspace/opentui/packages/core/src/lib/tree-sitter/assets";
6098
+ var __dirname = "/Users/runner/work/opentui/opentui/packages/core/src/lib/tree-sitter/assets";
6037
6099
  function getDefaultOptions() {
6038
6100
  return {
6039
6101
  configPath: path3.resolve(__dirname, "../parsers-config.json"),
@@ -6381,6 +6443,9 @@ class OptimizedBuffer {
6381
6443
  // src/zig.ts
6382
6444
  var module = await import(`@opentui/core-${process.platform}-${process.arch}/index.ts`);
6383
6445
  var targetLibPath = module.default;
6446
+ if (/\$bunfs/.test(targetLibPath)) {
6447
+ targetLibPath = targetLibPath.replace("../", "");
6448
+ }
6384
6449
  if (!existsSync2(targetLibPath)) {
6385
6450
  throw new Error(`opentui is not supported on the current platform: ${process.platform}-${process.arch}`);
6386
6451
  }
@@ -8375,10 +8440,11 @@ class Renderable extends BaseRenderable {
8375
8440
  if (renderable.parent === this) {
8376
8441
  this.yogaNode.removeChild(renderable.getLayoutNode());
8377
8442
  this._childrenInLayoutOrder.splice(this._childrenInLayoutOrder.indexOf(renderable), 1);
8378
- } else if (renderable.parent) {
8443
+ } else {
8379
8444
  this.replaceParent(renderable);
8380
8445
  this.needsZIndexSort = true;
8381
8446
  this.renderableMapById.set(renderable.id, renderable);
8447
+ this._childrenInZIndexOrder.push(renderable);
8382
8448
  if (typeof renderable.onLifecyclePass === "function") {
8383
8449
  this._ctx.registerLifecyclePass(renderable);
8384
8450
  }
@@ -10815,7 +10881,7 @@ Captured output:
10815
10881
  }
10816
10882
  }
10817
10883
 
10818
- export { __toESM, __commonJS, __export, __require, Edge, Gutter, exports_src, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, ANSI, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, t, convertThemeToStyles, SyntaxStyle, hastToStyledText, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extToFiletype, pathToFiletype, main, getTreeSitterClient, TextBuffer, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, CliRenderer };
10884
+ export { __toESM, __commonJS, __export, __require, Edge, Gutter, exports_src, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, ANSI, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, t, convertThemeToStyles, SyntaxStyle, hastToStyledText, LinearScrollAccel, MacOSScrollAccel, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extToFiletype, pathToFiletype, main, getTreeSitterClient, TextBuffer, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, CliRenderer };
10819
10885
 
10820
- //# debugId=FB423E72911C491764756E2164756E21
10821
- //# sourceMappingURL=index-nyqttas2.js.map
10886
+ //# debugId=1CD01A0C7134010A64756E2164756E21
10887
+ //# sourceMappingURL=index-hxktycf0.js.map