@opentui/core 0.0.0-20250930-d50102aa → 0.0.0-20251001-886e38c1

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.
@@ -1,10 +1,31 @@
1
1
  // @bun
2
- import {
3
- DownloadUtils,
4
- __export,
5
- __require,
6
- parser_worker_default
7
- } from "./index-cc14z67g.js";
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
18
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, {
22
+ get: all[name],
23
+ enumerable: true,
24
+ configurable: true,
25
+ set: (newValue) => all[name] = () => newValue
26
+ });
27
+ };
28
+ var __require = import.meta.require;
8
29
 
9
30
  // ../../node_modules/yoga-layout/dist/src/index.js
10
31
  var exports_src = {};
@@ -1742,7 +1763,7 @@ var BorderCharArrays = {
1742
1763
  };
1743
1764
 
1744
1765
  // src/lib/parse.keypress.ts
1745
- import { Buffer } from "buffer";
1766
+ import { Buffer as Buffer2 } from "buffer";
1746
1767
 
1747
1768
  // src/lib/parse.keypress-kitty.ts
1748
1769
  var kittyKeyMap = {
@@ -2059,7 +2080,7 @@ var isCtrlKey = (code) => {
2059
2080
  };
2060
2081
  var parseKeypress = (s = "", options = {}) => {
2061
2082
  let parts;
2062
- if (Buffer.isBuffer(s)) {
2083
+ if (Buffer2.isBuffer(s)) {
2063
2084
  if (s[0] > 127 && s[1] === undefined) {
2064
2085
  s[0] -= 128;
2065
2086
  s = "\x1B" + String(s);
@@ -5301,6 +5322,10 @@ function getParsers() {
5301
5322
  return _cachedParsers;
5302
5323
  }
5303
5324
 
5325
+ // src/lib/tree-sitter/parser.worker.path.ts
5326
+ var workerPath = new URL("./parser.worker.js", import.meta.url).href;
5327
+ var parser_worker_path_default = workerPath;
5328
+
5304
5329
  // src/lib/tree-sitter/client.ts
5305
5330
  import { resolve as resolve2, isAbsolute } from "path";
5306
5331
  var DEFAULT_PARSERS = getParsers();
@@ -5346,8 +5371,8 @@ class TreeSitterClient extends EventEmitter2 {
5346
5371
  if (this.worker) {
5347
5372
  return;
5348
5373
  }
5349
- const workerPath = this.options.workerPath || parser_worker_default;
5350
- this.worker = new Worker(workerPath);
5374
+ const workerPath2 = this.options.workerPath || parser_worker_path_default;
5375
+ this.worker = new Worker(workerPath2);
5351
5376
  this.worker.onmessage = this.handleWorkerMessage.bind(this);
5352
5377
  this.worker.onerror = (error) => {
5353
5378
  console.error("TreeSitter worker error:", error.message);
@@ -5891,14 +5916,124 @@ function pathToFiletype(path2) {
5891
5916
  }
5892
5917
 
5893
5918
  // src/lib/tree-sitter/assets/update.ts
5894
- import { readFile, writeFile, mkdir } from "fs/promises";
5919
+ import { readFile, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
5920
+ import * as path3 from "path";
5921
+
5922
+ // src/lib/tree-sitter/download-utils.ts
5923
+ import { mkdir, writeFile } from "fs/promises";
5895
5924
  import * as path2 from "path";
5925
+
5926
+ class DownloadUtils {
5927
+ static hashUrl(url) {
5928
+ let hash = 0;
5929
+ for (let i = 0;i < url.length; i++) {
5930
+ const char = url.charCodeAt(i);
5931
+ hash = (hash << 5) - hash + char;
5932
+ hash = hash & hash;
5933
+ }
5934
+ return Math.abs(hash).toString(16);
5935
+ }
5936
+ static async downloadOrLoad(source, cacheDir, cacheSubdir, fileExtension, useHashForCache = true, filetype) {
5937
+ const isUrl = source.startsWith("http://") || source.startsWith("https://");
5938
+ if (isUrl) {
5939
+ let cacheFileName;
5940
+ if (useHashForCache) {
5941
+ const hash = this.hashUrl(source);
5942
+ cacheFileName = filetype ? `${filetype}-${hash}${fileExtension}` : `${hash}${fileExtension}`;
5943
+ } else {
5944
+ cacheFileName = path2.basename(source);
5945
+ }
5946
+ const cacheFile = path2.join(cacheDir, cacheSubdir, cacheFileName);
5947
+ await mkdir(path2.dirname(cacheFile), { recursive: true });
5948
+ try {
5949
+ const cachedContent = await Bun.file(cacheFile).arrayBuffer();
5950
+ if (cachedContent.byteLength > 0) {
5951
+ console.log(`Loaded from cache: ${cacheFile} (${source})`);
5952
+ return { content: cachedContent, filePath: cacheFile };
5953
+ }
5954
+ } catch (error) {}
5955
+ try {
5956
+ console.log(`Downloading from URL: ${source}`);
5957
+ const response = await fetch(source);
5958
+ if (!response.ok) {
5959
+ return { error: `Failed to fetch from ${source}: ${response.statusText}` };
5960
+ }
5961
+ const content = await response.arrayBuffer();
5962
+ try {
5963
+ await writeFile(cacheFile, Buffer.from(content));
5964
+ console.log(`Cached: ${source}`);
5965
+ } catch (cacheError) {
5966
+ console.warn(`Failed to cache: ${cacheError}`);
5967
+ }
5968
+ return { content, filePath: cacheFile };
5969
+ } catch (error) {
5970
+ return { error: `Error downloading from ${source}: ${error}` };
5971
+ }
5972
+ } else {
5973
+ try {
5974
+ console.log(`Loading from local path: ${source}`);
5975
+ const content = await Bun.file(source).arrayBuffer();
5976
+ return { content, filePath: source };
5977
+ } catch (error) {
5978
+ return { error: `Error loading from local path ${source}: ${error}` };
5979
+ }
5980
+ }
5981
+ }
5982
+ static async downloadToPath(source, targetPath) {
5983
+ const isUrl = source.startsWith("http://") || source.startsWith("https://");
5984
+ await mkdir(path2.dirname(targetPath), { recursive: true });
5985
+ if (isUrl) {
5986
+ try {
5987
+ console.log(`Downloading from URL: ${source}`);
5988
+ const response = await fetch(source);
5989
+ if (!response.ok) {
5990
+ return { error: `Failed to fetch from ${source}: ${response.statusText}` };
5991
+ }
5992
+ const content = await response.arrayBuffer();
5993
+ await writeFile(targetPath, Buffer.from(content));
5994
+ console.log(`Downloaded: ${source} -> ${targetPath}`);
5995
+ return { content, filePath: targetPath };
5996
+ } catch (error) {
5997
+ return { error: `Error downloading from ${source}: ${error}` };
5998
+ }
5999
+ } else {
6000
+ try {
6001
+ console.log(`Copying from local path: ${source}`);
6002
+ const content = await Bun.file(source).arrayBuffer();
6003
+ await writeFile(targetPath, Buffer.from(content));
6004
+ return { content, filePath: targetPath };
6005
+ } catch (error) {
6006
+ return { error: `Error copying from local path ${source}: ${error}` };
6007
+ }
6008
+ }
6009
+ }
6010
+ static async fetchHighlightQueries(sources, cacheDir, filetype) {
6011
+ const queryPromises = sources.map((source) => this.fetchHighlightQuery(source, cacheDir, filetype));
6012
+ const queryResults = await Promise.all(queryPromises);
6013
+ const validQueries = queryResults.filter((query) => query.trim().length > 0);
6014
+ return validQueries.join(`
6015
+ `);
6016
+ }
6017
+ static async fetchHighlightQuery(source, cacheDir, filetype) {
6018
+ const result = await this.downloadOrLoad(source, cacheDir, "queries", ".scm", true, filetype);
6019
+ if (result.error) {
6020
+ console.error(`Error fetching highlight query from ${source}:`, result.error);
6021
+ return "";
6022
+ }
6023
+ if (result.content) {
6024
+ return new TextDecoder().decode(result.content);
6025
+ }
6026
+ return "";
6027
+ }
6028
+ }
6029
+
6030
+ // src/lib/tree-sitter/assets/update.ts
5896
6031
  var __dirname = "/Users/runner/work/opentui/opentui/packages/core/src/lib/tree-sitter/assets";
5897
6032
  function getDefaultOptions() {
5898
6033
  return {
5899
- configPath: path2.resolve(__dirname, "../parsers-config.json"),
5900
- assetsDir: path2.resolve(__dirname),
5901
- outputPath: path2.resolve(__dirname, "../default-parsers.ts")
6034
+ configPath: path3.resolve(__dirname, "../parsers-config.json"),
6035
+ assetsDir: path3.resolve(__dirname),
6036
+ outputPath: path3.resolve(__dirname, "../default-parsers.ts")
5902
6037
  };
5903
6038
  }
5904
6039
  async function loadConfig(configPath) {
@@ -5906,18 +6041,18 @@ async function loadConfig(configPath) {
5906
6041
  return JSON.parse(configContent);
5907
6042
  }
5908
6043
  async function downloadLanguage(filetype, languageUrl, assetsDir, outputPath) {
5909
- const languageDir = path2.join(assetsDir, filetype);
5910
- const languageFilename = path2.basename(languageUrl);
5911
- const languagePath = path2.join(languageDir, languageFilename);
6044
+ const languageDir = path3.join(assetsDir, filetype);
6045
+ const languageFilename = path3.basename(languageUrl);
6046
+ const languagePath = path3.join(languageDir, languageFilename);
5912
6047
  const result = await DownloadUtils.downloadToPath(languageUrl, languagePath);
5913
6048
  if (result.error) {
5914
6049
  throw new Error(`Failed to download language for ${filetype}: ${result.error}`);
5915
6050
  }
5916
- return "./" + path2.relative(path2.dirname(outputPath), languagePath);
6051
+ return "./" + path3.relative(path3.dirname(outputPath), languagePath);
5917
6052
  }
5918
6053
  async function downloadAndCombineQueries(filetype, queryUrls, assetsDir, outputPath) {
5919
- const queriesDir = path2.join(assetsDir, filetype);
5920
- const highlightsPath = path2.join(queriesDir, "highlights.scm");
6054
+ const queriesDir = path3.join(assetsDir, filetype);
6055
+ const highlightsPath = path3.join(queriesDir, "highlights.scm");
5921
6056
  const queryContents = [];
5922
6057
  for (let i = 0;i < queryUrls.length; i++) {
5923
6058
  const queryUrl = queryUrls[i];
@@ -5943,9 +6078,9 @@ ${content}`);
5943
6078
  const combinedContent = queryContents.join(`
5944
6079
 
5945
6080
  `);
5946
- await writeFile(highlightsPath, combinedContent, "utf-8");
6081
+ await writeFile2(highlightsPath, combinedContent, "utf-8");
5947
6082
  console.log(` Combined ${queryContents.length} queries into ${highlightsPath}`);
5948
- return "./" + path2.relative(path2.dirname(outputPath), highlightsPath);
6083
+ return "./" + path3.relative(path3.dirname(outputPath), highlightsPath);
5949
6084
  }
5950
6085
  async function generateDefaultParsersFile(parsers, outputPath) {
5951
6086
  const imports = parsers.map((parser) => {
@@ -5987,9 +6122,9 @@ ${parserDefinitions},
5987
6122
  return _cachedParsers
5988
6123
  }
5989
6124
  `;
5990
- await mkdir(path2.dirname(outputPath), { recursive: true });
5991
- await writeFile(outputPath, fileContent, "utf-8");
5992
- console.log(`Generated ${path2.basename(outputPath)} with ${parsers.length} parsers`);
6125
+ await mkdir2(path3.dirname(outputPath), { recursive: true });
6126
+ await writeFile2(outputPath, fileContent, "utf-8");
6127
+ console.log(`Generated ${path3.basename(outputPath)} with ${parsers.length} parsers`);
5993
6128
  }
5994
6129
  async function main(options) {
5995
6130
  const opts = { ...getDefaultOptions(), ...options };
@@ -8744,7 +8879,7 @@ function delegate(mapping, vnode) {
8744
8879
  import { EventEmitter as EventEmitter6 } from "events";
8745
8880
  import { Console } from "console";
8746
8881
  import fs from "fs";
8747
- import path3 from "path";
8882
+ import path4 from "path";
8748
8883
  import util2 from "util";
8749
8884
 
8750
8885
  // src/lib/output.capture.ts
@@ -9387,7 +9522,7 @@ class TerminalConsole extends EventEmitter6 {
9387
9522
  try {
9388
9523
  const timestamp = Date.now();
9389
9524
  const filename = `_console_${timestamp}.log`;
9390
- const filepath = path3.join(process.cwd(), filename);
9525
+ const filepath = path4.join(process.cwd(), filename);
9391
9526
  const allLogEntries = [...this._allLogEntries, ...terminalConsoleCache.cachedLogs];
9392
9527
  const logLines = [];
9393
9528
  for (const [date, level, args, callerInfo] of allLogEntries) {
@@ -10675,7 +10810,7 @@ Captured output:
10675
10810
  }
10676
10811
  }
10677
10812
 
10678
- export { 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 };
10813
+ 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 };
10679
10814
 
10680
- //# debugId=68D4874E884EA10964756E2164756E21
10681
- //# sourceMappingURL=index-0p8687g8.js.map
10815
+ //# debugId=3A66ED403B9C39DF64756E2164756E21
10816
+ //# sourceMappingURL=index-r19wz8xa.js.map