@opentui/core 0.0.0-20250930-d50102aa → 0.0.0-20251001-ad2d8bd4
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 +3 -5
- package/3d.js.map +2 -2
- package/{index-0p8687g8.js → index-nyqttas2.js} +173 -33
- package/{index-0p8687g8.js.map → index-nyqttas2.js.map} +5 -4
- package/index.js +2 -3
- package/index.js.map +2 -2
- package/lib/tree-sitter/parser.worker.d.ts +1 -1
- package/package.json +19 -11
- package/parser.worker.js +609 -2
- package/parser.worker.js.map +5 -3
- package/testing.js +2 -3
- package/testing.js.map +2 -2
- package/index-cc14z67g.js +0 -3846
- package/index-cc14z67g.js.map +0 -12
- package/parser.worker.d.ts +0 -1
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 (
|
|
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);
|
|
@@ -5303,6 +5324,7 @@ function getParsers() {
|
|
|
5303
5324
|
|
|
5304
5325
|
// src/lib/tree-sitter/client.ts
|
|
5305
5326
|
import { resolve as resolve2, isAbsolute } from "path";
|
|
5327
|
+
import { existsSync } from "fs";
|
|
5306
5328
|
var DEFAULT_PARSERS = getParsers();
|
|
5307
5329
|
function addDefaultParsers(parsers) {
|
|
5308
5330
|
for (const parser of parsers) {
|
|
@@ -5346,8 +5368,16 @@ class TreeSitterClient extends EventEmitter2 {
|
|
|
5346
5368
|
if (this.worker) {
|
|
5347
5369
|
return;
|
|
5348
5370
|
}
|
|
5349
|
-
|
|
5350
|
-
this.
|
|
5371
|
+
let worker_path;
|
|
5372
|
+
if (this.options.workerPath) {
|
|
5373
|
+
worker_path = this.options.workerPath;
|
|
5374
|
+
} else {
|
|
5375
|
+
worker_path = new URL("./parser.worker.js", import.meta.url).href;
|
|
5376
|
+
if (!existsSync(resolve2(import.meta.dirname, "parser.worker.js"))) {
|
|
5377
|
+
worker_path = new URL("./parser.worker.ts", import.meta.url).href;
|
|
5378
|
+
}
|
|
5379
|
+
}
|
|
5380
|
+
this.worker = new Worker(worker_path);
|
|
5351
5381
|
this.worker.onmessage = this.handleWorkerMessage.bind(this);
|
|
5352
5382
|
this.worker.onerror = (error) => {
|
|
5353
5383
|
console.error("TreeSitter worker error:", error.message);
|
|
@@ -5891,14 +5921,124 @@ function pathToFiletype(path2) {
|
|
|
5891
5921
|
}
|
|
5892
5922
|
|
|
5893
5923
|
// src/lib/tree-sitter/assets/update.ts
|
|
5894
|
-
import { readFile, writeFile, mkdir } from "fs/promises";
|
|
5924
|
+
import { readFile, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
5925
|
+
import * as path3 from "path";
|
|
5926
|
+
|
|
5927
|
+
// src/lib/tree-sitter/download-utils.ts
|
|
5928
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
5895
5929
|
import * as path2 from "path";
|
|
5896
|
-
|
|
5930
|
+
|
|
5931
|
+
class DownloadUtils {
|
|
5932
|
+
static hashUrl(url) {
|
|
5933
|
+
let hash = 0;
|
|
5934
|
+
for (let i = 0;i < url.length; i++) {
|
|
5935
|
+
const char = url.charCodeAt(i);
|
|
5936
|
+
hash = (hash << 5) - hash + char;
|
|
5937
|
+
hash = hash & hash;
|
|
5938
|
+
}
|
|
5939
|
+
return Math.abs(hash).toString(16);
|
|
5940
|
+
}
|
|
5941
|
+
static async downloadOrLoad(source, cacheDir, cacheSubdir, fileExtension, useHashForCache = true, filetype) {
|
|
5942
|
+
const isUrl = source.startsWith("http://") || source.startsWith("https://");
|
|
5943
|
+
if (isUrl) {
|
|
5944
|
+
let cacheFileName;
|
|
5945
|
+
if (useHashForCache) {
|
|
5946
|
+
const hash = this.hashUrl(source);
|
|
5947
|
+
cacheFileName = filetype ? `${filetype}-${hash}${fileExtension}` : `${hash}${fileExtension}`;
|
|
5948
|
+
} else {
|
|
5949
|
+
cacheFileName = path2.basename(source);
|
|
5950
|
+
}
|
|
5951
|
+
const cacheFile = path2.join(cacheDir, cacheSubdir, cacheFileName);
|
|
5952
|
+
await mkdir(path2.dirname(cacheFile), { recursive: true });
|
|
5953
|
+
try {
|
|
5954
|
+
const cachedContent = await Bun.file(cacheFile).arrayBuffer();
|
|
5955
|
+
if (cachedContent.byteLength > 0) {
|
|
5956
|
+
console.log(`Loaded from cache: ${cacheFile} (${source})`);
|
|
5957
|
+
return { content: cachedContent, filePath: cacheFile };
|
|
5958
|
+
}
|
|
5959
|
+
} catch (error) {}
|
|
5960
|
+
try {
|
|
5961
|
+
console.log(`Downloading from URL: ${source}`);
|
|
5962
|
+
const response = await fetch(source);
|
|
5963
|
+
if (!response.ok) {
|
|
5964
|
+
return { error: `Failed to fetch from ${source}: ${response.statusText}` };
|
|
5965
|
+
}
|
|
5966
|
+
const content = await response.arrayBuffer();
|
|
5967
|
+
try {
|
|
5968
|
+
await writeFile(cacheFile, Buffer.from(content));
|
|
5969
|
+
console.log(`Cached: ${source}`);
|
|
5970
|
+
} catch (cacheError) {
|
|
5971
|
+
console.warn(`Failed to cache: ${cacheError}`);
|
|
5972
|
+
}
|
|
5973
|
+
return { content, filePath: cacheFile };
|
|
5974
|
+
} catch (error) {
|
|
5975
|
+
return { error: `Error downloading from ${source}: ${error}` };
|
|
5976
|
+
}
|
|
5977
|
+
} else {
|
|
5978
|
+
try {
|
|
5979
|
+
console.log(`Loading from local path: ${source}`);
|
|
5980
|
+
const content = await Bun.file(source).arrayBuffer();
|
|
5981
|
+
return { content, filePath: source };
|
|
5982
|
+
} catch (error) {
|
|
5983
|
+
return { error: `Error loading from local path ${source}: ${error}` };
|
|
5984
|
+
}
|
|
5985
|
+
}
|
|
5986
|
+
}
|
|
5987
|
+
static async downloadToPath(source, targetPath) {
|
|
5988
|
+
const isUrl = source.startsWith("http://") || source.startsWith("https://");
|
|
5989
|
+
await mkdir(path2.dirname(targetPath), { recursive: true });
|
|
5990
|
+
if (isUrl) {
|
|
5991
|
+
try {
|
|
5992
|
+
console.log(`Downloading from URL: ${source}`);
|
|
5993
|
+
const response = await fetch(source);
|
|
5994
|
+
if (!response.ok) {
|
|
5995
|
+
return { error: `Failed to fetch from ${source}: ${response.statusText}` };
|
|
5996
|
+
}
|
|
5997
|
+
const content = await response.arrayBuffer();
|
|
5998
|
+
await writeFile(targetPath, Buffer.from(content));
|
|
5999
|
+
console.log(`Downloaded: ${source} -> ${targetPath}`);
|
|
6000
|
+
return { content, filePath: targetPath };
|
|
6001
|
+
} catch (error) {
|
|
6002
|
+
return { error: `Error downloading from ${source}: ${error}` };
|
|
6003
|
+
}
|
|
6004
|
+
} else {
|
|
6005
|
+
try {
|
|
6006
|
+
console.log(`Copying from local path: ${source}`);
|
|
6007
|
+
const content = await Bun.file(source).arrayBuffer();
|
|
6008
|
+
await writeFile(targetPath, Buffer.from(content));
|
|
6009
|
+
return { content, filePath: targetPath };
|
|
6010
|
+
} catch (error) {
|
|
6011
|
+
return { error: `Error copying from local path ${source}: ${error}` };
|
|
6012
|
+
}
|
|
6013
|
+
}
|
|
6014
|
+
}
|
|
6015
|
+
static async fetchHighlightQueries(sources, cacheDir, filetype) {
|
|
6016
|
+
const queryPromises = sources.map((source) => this.fetchHighlightQuery(source, cacheDir, filetype));
|
|
6017
|
+
const queryResults = await Promise.all(queryPromises);
|
|
6018
|
+
const validQueries = queryResults.filter((query) => query.trim().length > 0);
|
|
6019
|
+
return validQueries.join(`
|
|
6020
|
+
`);
|
|
6021
|
+
}
|
|
6022
|
+
static async fetchHighlightQuery(source, cacheDir, filetype) {
|
|
6023
|
+
const result = await this.downloadOrLoad(source, cacheDir, "queries", ".scm", true, filetype);
|
|
6024
|
+
if (result.error) {
|
|
6025
|
+
console.error(`Error fetching highlight query from ${source}:`, result.error);
|
|
6026
|
+
return "";
|
|
6027
|
+
}
|
|
6028
|
+
if (result.content) {
|
|
6029
|
+
return new TextDecoder().decode(result.content);
|
|
6030
|
+
}
|
|
6031
|
+
return "";
|
|
6032
|
+
}
|
|
6033
|
+
}
|
|
6034
|
+
|
|
6035
|
+
// src/lib/tree-sitter/assets/update.ts
|
|
6036
|
+
var __dirname = "/Users/kmdr/workspace/opentui/packages/core/src/lib/tree-sitter/assets";
|
|
5897
6037
|
function getDefaultOptions() {
|
|
5898
6038
|
return {
|
|
5899
|
-
configPath:
|
|
5900
|
-
assetsDir:
|
|
5901
|
-
outputPath:
|
|
6039
|
+
configPath: path3.resolve(__dirname, "../parsers-config.json"),
|
|
6040
|
+
assetsDir: path3.resolve(__dirname),
|
|
6041
|
+
outputPath: path3.resolve(__dirname, "../default-parsers.ts")
|
|
5902
6042
|
};
|
|
5903
6043
|
}
|
|
5904
6044
|
async function loadConfig(configPath) {
|
|
@@ -5906,18 +6046,18 @@ async function loadConfig(configPath) {
|
|
|
5906
6046
|
return JSON.parse(configContent);
|
|
5907
6047
|
}
|
|
5908
6048
|
async function downloadLanguage(filetype, languageUrl, assetsDir, outputPath) {
|
|
5909
|
-
const languageDir =
|
|
5910
|
-
const languageFilename =
|
|
5911
|
-
const languagePath =
|
|
6049
|
+
const languageDir = path3.join(assetsDir, filetype);
|
|
6050
|
+
const languageFilename = path3.basename(languageUrl);
|
|
6051
|
+
const languagePath = path3.join(languageDir, languageFilename);
|
|
5912
6052
|
const result = await DownloadUtils.downloadToPath(languageUrl, languagePath);
|
|
5913
6053
|
if (result.error) {
|
|
5914
6054
|
throw new Error(`Failed to download language for ${filetype}: ${result.error}`);
|
|
5915
6055
|
}
|
|
5916
|
-
return "./" +
|
|
6056
|
+
return "./" + path3.relative(path3.dirname(outputPath), languagePath);
|
|
5917
6057
|
}
|
|
5918
6058
|
async function downloadAndCombineQueries(filetype, queryUrls, assetsDir, outputPath) {
|
|
5919
|
-
const queriesDir =
|
|
5920
|
-
const highlightsPath =
|
|
6059
|
+
const queriesDir = path3.join(assetsDir, filetype);
|
|
6060
|
+
const highlightsPath = path3.join(queriesDir, "highlights.scm");
|
|
5921
6061
|
const queryContents = [];
|
|
5922
6062
|
for (let i = 0;i < queryUrls.length; i++) {
|
|
5923
6063
|
const queryUrl = queryUrls[i];
|
|
@@ -5943,9 +6083,9 @@ ${content}`);
|
|
|
5943
6083
|
const combinedContent = queryContents.join(`
|
|
5944
6084
|
|
|
5945
6085
|
`);
|
|
5946
|
-
await
|
|
6086
|
+
await writeFile2(highlightsPath, combinedContent, "utf-8");
|
|
5947
6087
|
console.log(` Combined ${queryContents.length} queries into ${highlightsPath}`);
|
|
5948
|
-
return "./" +
|
|
6088
|
+
return "./" + path3.relative(path3.dirname(outputPath), highlightsPath);
|
|
5949
6089
|
}
|
|
5950
6090
|
async function generateDefaultParsersFile(parsers, outputPath) {
|
|
5951
6091
|
const imports = parsers.map((parser) => {
|
|
@@ -5987,9 +6127,9 @@ ${parserDefinitions},
|
|
|
5987
6127
|
return _cachedParsers
|
|
5988
6128
|
}
|
|
5989
6129
|
`;
|
|
5990
|
-
await
|
|
5991
|
-
await
|
|
5992
|
-
console.log(`Generated ${
|
|
6130
|
+
await mkdir2(path3.dirname(outputPath), { recursive: true });
|
|
6131
|
+
await writeFile2(outputPath, fileContent, "utf-8");
|
|
6132
|
+
console.log(`Generated ${path3.basename(outputPath)} with ${parsers.length} parsers`);
|
|
5993
6133
|
}
|
|
5994
6134
|
async function main(options) {
|
|
5995
6135
|
const opts = { ...getDefaultOptions(), ...options };
|
|
@@ -6040,7 +6180,7 @@ function getTreeSitterClient() {
|
|
|
6040
6180
|
}
|
|
6041
6181
|
// src/zig.ts
|
|
6042
6182
|
import { dlopen, toArrayBuffer as toArrayBuffer2, JSCallback, ptr } from "bun:ffi";
|
|
6043
|
-
import { existsSync } from "fs";
|
|
6183
|
+
import { existsSync as existsSync2 } from "fs";
|
|
6044
6184
|
|
|
6045
6185
|
// src/buffer.ts
|
|
6046
6186
|
import { toArrayBuffer } from "bun:ffi";
|
|
@@ -6241,7 +6381,7 @@ class OptimizedBuffer {
|
|
|
6241
6381
|
// src/zig.ts
|
|
6242
6382
|
var module = await import(`@opentui/core-${process.platform}-${process.arch}/index.ts`);
|
|
6243
6383
|
var targetLibPath = module.default;
|
|
6244
|
-
if (!
|
|
6384
|
+
if (!existsSync2(targetLibPath)) {
|
|
6245
6385
|
throw new Error(`opentui is not supported on the current platform: ${process.platform}-${process.arch}`);
|
|
6246
6386
|
}
|
|
6247
6387
|
registerEnvVar({
|
|
@@ -8744,7 +8884,7 @@ function delegate(mapping, vnode) {
|
|
|
8744
8884
|
import { EventEmitter as EventEmitter6 } from "events";
|
|
8745
8885
|
import { Console } from "console";
|
|
8746
8886
|
import fs from "fs";
|
|
8747
|
-
import
|
|
8887
|
+
import path4 from "path";
|
|
8748
8888
|
import util2 from "util";
|
|
8749
8889
|
|
|
8750
8890
|
// src/lib/output.capture.ts
|
|
@@ -9387,7 +9527,7 @@ class TerminalConsole extends EventEmitter6 {
|
|
|
9387
9527
|
try {
|
|
9388
9528
|
const timestamp = Date.now();
|
|
9389
9529
|
const filename = `_console_${timestamp}.log`;
|
|
9390
|
-
const filepath =
|
|
9530
|
+
const filepath = path4.join(process.cwd(), filename);
|
|
9391
9531
|
const allLogEntries = [...this._allLogEntries, ...terminalConsoleCache.cachedLogs];
|
|
9392
9532
|
const logLines = [];
|
|
9393
9533
|
for (const [date, level, args, callerInfo] of allLogEntries) {
|
|
@@ -10675,7 +10815,7 @@ Captured output:
|
|
|
10675
10815
|
}
|
|
10676
10816
|
}
|
|
10677
10817
|
|
|
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 };
|
|
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 };
|
|
10679
10819
|
|
|
10680
|
-
//# debugId=
|
|
10681
|
-
//# sourceMappingURL=index-
|
|
10820
|
+
//# debugId=FB423E72911C491764756E2164756E21
|
|
10821
|
+
//# sourceMappingURL=index-nyqttas2.js.map
|