@opentui/core 0.8.4 → 0.9.0
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/NativeScene.d.ts +10 -2
- package/Renderable.d.ts +16 -6
- package/ansi.d.ts +1 -1
- package/{chunk-bun-83k2gdpc.js → chunk-bun-rgb7yx3r.js} +10449 -11486
- package/chunk-bun-rgb7yx3r.js.map +68 -0
- package/{chunk-bun-dsfc571f.js → chunk-bun-ywheza3e.js} +656 -102
- package/chunk-bun-ywheza3e.js.map +35 -0
- package/{chunk-node-3ssb37vb.js → chunk-node-fcberveq.js} +10449 -11486
- package/chunk-node-fcberveq.js.map +68 -0
- package/{chunk-node-5nvhjp1a.js → chunk-node-k5s8s41v.js} +656 -102
- package/chunk-node-k5s8s41v.js.map +34 -0
- package/edit-buffer.d.ts +40 -5
- package/editor-view.d.ts +28 -0
- package/index.bun.js +1252 -4790
- package/index.bun.js.map +18 -24
- package/index.node.js +1252 -4790
- package/index.node.js.map +19 -31
- package/lib/KeyHandler.d.ts +1 -1
- package/lib/extmarks.d.ts +15 -51
- package/lib/index.d.ts +1 -2
- package/lib/kitty-keys.d.ts +2 -0
- package/lib/parse.keypress.d.ts +8 -3
- package/lib/parse.mouse.d.ts +0 -13
- package/lib/stdin-parser-native.d.ts +36 -24
- package/lib/terminal-capability-detection.d.ts +3 -3
- package/lib/terminal-palette.d.ts +3 -0
- package/lib/tree-sitter/client.d.ts +14 -3
- package/lib/tree-sitter/types.d.ts +10 -0
- package/lib/tree-sitter-styled-text.d.ts +2 -0
- package/lib/yoga.options.d.ts +3 -0
- package/native-abi.generated.d.ts +1391 -0
- package/package.json +9 -10
- package/parser.worker.js +112 -29
- package/parser.worker.js.map +3 -3
- package/plugins/core-slot.d.ts +1 -1
- package/renderables/ASCIIFont.d.ts +5 -0
- package/renderables/Code.d.ts +25 -2
- package/renderables/Diff.d.ts +3 -1
- package/renderables/EditBufferRenderable.d.ts +30 -1
- package/renderables/EmbeddedTerminal.d.ts +1 -1
- package/renderables/Input.d.ts +6 -3
- package/renderables/LineNumberRenderable.d.ts +4 -0
- package/renderables/Markdown.d.ts +208 -124
- package/renderables/ScrollBox.d.ts +7 -2
- package/renderables/ScrollBoxParts.d.ts +4 -5
- package/renderables/Select.d.ts +2 -2
- package/renderables/TabSelect.d.ts +2 -2
- package/renderables/Text.d.ts +3 -1
- package/renderables/TextBufferRenderable.d.ts +2 -0
- package/renderables/TextTable.d.ts +6 -0
- package/renderables/Textarea.d.ts +2 -1
- package/renderables/__tests__/code-model-harness.d.ts +40 -0
- package/renderables/index.d.ts +1 -3
- package/renderables/markdown-document.d.ts +37 -0
- package/renderables/props.d.ts +10 -0
- package/renderer-theme-mode.d.ts +5 -1
- package/renderer.d.ts +23 -9
- package/runtime-plugin.js +32 -57
- package/runtime-plugin.js.map +1 -1
- package/syntax-style.d.ts +5 -0
- package/testing/mock-tree-sitter-client.d.ts +5 -0
- package/testing/model.d.ts +15 -0
- package/testing.bun.js +8 -31
- package/testing.bun.js.map +4 -4
- package/testing.js +8 -31
- package/testing.js.map +4 -4
- package/tests/shrink-same-check.d.ts +4 -0
- package/tests/yoga-upstream/tools/utils.d.ts +9 -2
- package/text-buffer.d.ts +4 -0
- package/types.d.ts +2 -2
- package/yoga.bun.js +1 -1
- package/yoga.internal.d.ts +1 -0
- package/yoga.js +1 -1
- package/zig.d.ts +103 -5
- package/chunk-bun-83k2gdpc.js.map +0 -70
- package/chunk-bun-dsfc571f.js.map +0 -35
- package/chunk-node-3ssb37vb.js.map +0 -70
- package/chunk-node-5nvhjp1a.js.map +0 -34
- package/lib/debounce.d.ts +0 -42
- package/lib/extmarks-history.d.ts +0 -17
- package/lib/parse.keypress-kitty.d.ts +0 -5
- package/lib/queue.d.ts +0 -15
- package/lib/stdin-parser.d.ts +0 -97
- package/renderables/composition/VRenderable.d.ts +0 -16
- package/renderables/composition/constructs.d.ts +0 -35
- package/renderables/composition/vnode.d.ts +0 -46
- package/renderables/markdown-parser.d.ts +0 -12
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "index.node.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.9.0",
|
|
8
8
|
"description": "OpenTUI is a TypeScript library on a native Zig core for building terminal user interfaces (TUIs)",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -71,20 +71,19 @@
|
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"bun-ffi-structs": "0.3.1",
|
|
73
73
|
"diff": "9.0.0",
|
|
74
|
-
"marked": "17.0.1",
|
|
75
74
|
"string-width": "7.2.0"
|
|
76
75
|
},
|
|
77
76
|
"peerDependencies": {
|
|
78
77
|
"web-tree-sitter": "0.25.10"
|
|
79
78
|
},
|
|
80
79
|
"optionalDependencies": {
|
|
81
|
-
"@opentui/core-darwin-x64": "0.
|
|
82
|
-
"@opentui/core-darwin-arm64": "0.
|
|
83
|
-
"@opentui/core-linux-x64": "0.
|
|
84
|
-
"@opentui/core-linux-arm64": "0.
|
|
85
|
-
"@opentui/core-win32-x64": "0.
|
|
86
|
-
"@opentui/core-win32-arm64": "0.
|
|
87
|
-
"@opentui/core-linux-x64-musl": "0.
|
|
88
|
-
"@opentui/core-linux-arm64-musl": "0.
|
|
80
|
+
"@opentui/core-darwin-x64": "0.9.0",
|
|
81
|
+
"@opentui/core-darwin-arm64": "0.9.0",
|
|
82
|
+
"@opentui/core-linux-x64": "0.9.0",
|
|
83
|
+
"@opentui/core-linux-arm64": "0.9.0",
|
|
84
|
+
"@opentui/core-win32-x64": "0.9.0",
|
|
85
|
+
"@opentui/core-win32-arm64": "0.9.0",
|
|
86
|
+
"@opentui/core-linux-x64-musl": "0.9.0",
|
|
87
|
+
"@opentui/core-linux-arm64-musl": "0.9.0"
|
|
89
88
|
}
|
|
90
89
|
}
|
package/parser.worker.js
CHANGED
|
@@ -3763,6 +3763,7 @@ function translateLuaMatch(query) {
|
|
|
3763
3763
|
|
|
3764
3764
|
class ParserWorker {
|
|
3765
3765
|
bufferParsers = new Map;
|
|
3766
|
+
copies = new Map;
|
|
3766
3767
|
filetypeParserOptions = new Map;
|
|
3767
3768
|
filetypeAliases = new Map;
|
|
3768
3769
|
filetypeParsers = new Map;
|
|
@@ -3959,7 +3960,12 @@ class ParserWorker {
|
|
|
3959
3960
|
return;
|
|
3960
3961
|
}
|
|
3961
3962
|
const parser = new Parser;
|
|
3962
|
-
|
|
3963
|
+
try {
|
|
3964
|
+
parser.setLanguage(filetypeParser.language);
|
|
3965
|
+
} catch (error) {
|
|
3966
|
+
parser.delete();
|
|
3967
|
+
throw error;
|
|
3968
|
+
}
|
|
3963
3969
|
const reusableState = {
|
|
3964
3970
|
parser,
|
|
3965
3971
|
filetypeParser,
|
|
@@ -3980,8 +3986,14 @@ class ParserWorker {
|
|
|
3980
3986
|
return;
|
|
3981
3987
|
}
|
|
3982
3988
|
const parser = new Parser;
|
|
3983
|
-
|
|
3984
|
-
|
|
3989
|
+
let tree = null;
|
|
3990
|
+
try {
|
|
3991
|
+
parser.setLanguage(filetypeParser.language);
|
|
3992
|
+
tree = parser.parse(content);
|
|
3993
|
+
} finally {
|
|
3994
|
+
if (!tree)
|
|
3995
|
+
parser.delete();
|
|
3996
|
+
}
|
|
3985
3997
|
if (!tree) {
|
|
3986
3998
|
postWorkerMessage({
|
|
3987
3999
|
type: "PARSER_INIT_RESPONSE",
|
|
@@ -4157,6 +4169,7 @@ class ParserWorker {
|
|
|
4157
4169
|
return { error: "Failed to parse buffer" };
|
|
4158
4170
|
}
|
|
4159
4171
|
const changedRanges = parserState.tree.getChangedRanges(newTree);
|
|
4172
|
+
parserState.tree.delete();
|
|
4160
4173
|
parserState.tree = newTree;
|
|
4161
4174
|
const startQuery = performance.now();
|
|
4162
4175
|
const matches = [];
|
|
@@ -4308,6 +4321,7 @@ class ParserWorker {
|
|
|
4308
4321
|
if (!newTree) {
|
|
4309
4322
|
return { error: "Failed to parse buffer during reset" };
|
|
4310
4323
|
}
|
|
4324
|
+
parserState.tree.delete();
|
|
4311
4325
|
parserState.tree = newTree;
|
|
4312
4326
|
const matches = parserState.queries.highlights.captures(parserState.tree.rootNode);
|
|
4313
4327
|
let injectionRanges = new Map;
|
|
@@ -4318,14 +4332,17 @@ class ParserWorker {
|
|
|
4318
4332
|
}
|
|
4319
4333
|
return this.getHighlights(parserState, matches, injectionRanges);
|
|
4320
4334
|
}
|
|
4321
|
-
disposeBuffer(bufferId) {
|
|
4322
|
-
const parserState =
|
|
4335
|
+
disposeBuffer(bufferId, parsers = this.bufferParsers) {
|
|
4336
|
+
const parserState = parsers.get(bufferId);
|
|
4323
4337
|
if (!parserState) {
|
|
4324
4338
|
return;
|
|
4325
4339
|
}
|
|
4326
4340
|
parserState.tree.delete();
|
|
4327
4341
|
parserState.parser.delete();
|
|
4328
|
-
|
|
4342
|
+
parsers.delete(bufferId);
|
|
4343
|
+
}
|
|
4344
|
+
disposeCopy(copyId) {
|
|
4345
|
+
this.disposeBuffer(copyId, this.copies);
|
|
4329
4346
|
}
|
|
4330
4347
|
async handleOneShotHighlight(content, filetype, messageId) {
|
|
4331
4348
|
const reusableState = await this.getReusableParser(filetype);
|
|
@@ -4351,32 +4368,71 @@ class ParserWorker {
|
|
|
4351
4368
|
return;
|
|
4352
4369
|
}
|
|
4353
4370
|
try {
|
|
4354
|
-
const
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
filetype,
|
|
4362
|
-
content,
|
|
4363
|
-
injectionMapping: reusableState.filetypeParser.injectionMapping
|
|
4364
|
-
};
|
|
4365
|
-
const injectionResult = await this.processInjections(parserState);
|
|
4366
|
-
matches.push(...injectionResult.captures);
|
|
4367
|
-
injectionRanges = injectionResult.injectionRanges;
|
|
4368
|
-
}
|
|
4369
|
-
const highlights = this.getSimpleHighlights(matches, injectionRanges);
|
|
4370
|
-
postWorkerMessage({
|
|
4371
|
-
type: "ONESHOT_HIGHLIGHT_RESPONSE",
|
|
4372
|
-
messageId,
|
|
4373
|
-
hasParser: true,
|
|
4374
|
-
highlights
|
|
4371
|
+
const highlights = await this.simpleHighlights({
|
|
4372
|
+
parser: reusableState.parser,
|
|
4373
|
+
tree,
|
|
4374
|
+
queries: reusableState.filetypeParser.queries,
|
|
4375
|
+
filetype,
|
|
4376
|
+
content,
|
|
4377
|
+
injectionMapping: reusableState.filetypeParser.injectionMapping
|
|
4375
4378
|
});
|
|
4379
|
+
postWorkerMessage({ type: "ONESHOT_HIGHLIGHT_RESPONSE", messageId, hasParser: true, highlights });
|
|
4376
4380
|
} finally {
|
|
4377
4381
|
tree.delete();
|
|
4378
4382
|
}
|
|
4379
4383
|
}
|
|
4384
|
+
async handleAppendHighlight(copyId, offset, text, filetype, messageId) {
|
|
4385
|
+
const reply = (answer) => postWorkerMessage({ type: "ONESHOT_HIGHLIGHT_RESPONSE", messageId, hasParser: true, ...answer });
|
|
4386
|
+
let state = this.copies.get(copyId);
|
|
4387
|
+
if ((state?.content.length ?? 0) !== offset)
|
|
4388
|
+
return reply({ error: "Append does not continue the buffer" });
|
|
4389
|
+
if (!state) {
|
|
4390
|
+
const filetypeParser = await this.resolveFiletypeParser(filetype);
|
|
4391
|
+
if (!filetypeParser)
|
|
4392
|
+
return reply({ hasParser: false, warning: `No parser available for filetype ${filetype}` });
|
|
4393
|
+
const parser = new Parser;
|
|
4394
|
+
let tree = null;
|
|
4395
|
+
try {
|
|
4396
|
+
parser.setLanguage(filetypeParser.language);
|
|
4397
|
+
tree = parser.parse(text);
|
|
4398
|
+
} finally {
|
|
4399
|
+
if (!tree)
|
|
4400
|
+
parser.delete();
|
|
4401
|
+
}
|
|
4402
|
+
if (!tree)
|
|
4403
|
+
return reply({ error: "Failed to parse buffer" });
|
|
4404
|
+
const { queries, injectionMapping } = filetypeParser;
|
|
4405
|
+
state = { parser, tree, queries, filetype, content: text, injectionMapping };
|
|
4406
|
+
this.copies.set(copyId, state);
|
|
4407
|
+
} else if (text) {
|
|
4408
|
+
const content = state.content + text;
|
|
4409
|
+
const position = endPosition(state.content);
|
|
4410
|
+
state.tree.edit({
|
|
4411
|
+
startIndex: offset,
|
|
4412
|
+
oldEndIndex: offset,
|
|
4413
|
+
newEndIndex: content.length,
|
|
4414
|
+
startPosition: position,
|
|
4415
|
+
oldEndPosition: position,
|
|
4416
|
+
newEndPosition: endPosition(content)
|
|
4417
|
+
});
|
|
4418
|
+
const tree = state.parser.parse(content, state.tree);
|
|
4419
|
+
if (!tree)
|
|
4420
|
+
return reply({ error: "Failed to parse buffer" });
|
|
4421
|
+
state.tree.delete();
|
|
4422
|
+
state.tree = tree;
|
|
4423
|
+
state.content = content;
|
|
4424
|
+
}
|
|
4425
|
+
if (filetype === "markdown" && state.content.endsWith("```")) {
|
|
4426
|
+
return this.handleOneShotHighlight(state.content, filetype, messageId);
|
|
4427
|
+
}
|
|
4428
|
+
reply({ highlights: await this.simpleHighlights(state) });
|
|
4429
|
+
}
|
|
4430
|
+
async simpleHighlights(parserState) {
|
|
4431
|
+
const matches = parserState.queries.highlights.captures(parserState.tree.rootNode);
|
|
4432
|
+
const { captures, injectionRanges } = await this.processInjections(parserState);
|
|
4433
|
+
matches.push(...captures);
|
|
4434
|
+
return this.getSimpleHighlights(matches, injectionRanges);
|
|
4435
|
+
}
|
|
4380
4436
|
async updateDataPath(dataPath) {
|
|
4381
4437
|
this.dataPath = dataPath;
|
|
4382
4438
|
this.tsDataPath = path2.join(dataPath, "tree-sitter");
|
|
@@ -4399,6 +4455,8 @@ class ParserWorker {
|
|
|
4399
4455
|
await mkdir2(path2.join(treeSitterPath, "queries"), { recursive: true });
|
|
4400
4456
|
this.filetypeParsers.clear();
|
|
4401
4457
|
this.filetypeParserPromises.clear();
|
|
4458
|
+
for (const { parser } of this.reusableParsers.values())
|
|
4459
|
+
parser.delete();
|
|
4402
4460
|
this.reusableParsers.clear();
|
|
4403
4461
|
this.reusableParserPromises.clear();
|
|
4404
4462
|
} catch (error) {
|
|
@@ -4406,6 +4464,15 @@ class ParserWorker {
|
|
|
4406
4464
|
}
|
|
4407
4465
|
}
|
|
4408
4466
|
}
|
|
4467
|
+
function endPosition(text) {
|
|
4468
|
+
let row = 0;
|
|
4469
|
+
for (let at = text.indexOf(`
|
|
4470
|
+
`);at !== -1; at = text.indexOf(`
|
|
4471
|
+
`, at + 1))
|
|
4472
|
+
row++;
|
|
4473
|
+
return { row, column: text.length - text.lastIndexOf(`
|
|
4474
|
+
`) - 1 };
|
|
4475
|
+
}
|
|
4409
4476
|
function logMessage(type, ...args2) {
|
|
4410
4477
|
postWorkerMessage({
|
|
4411
4478
|
type: "WORKER_LOG",
|
|
@@ -4426,7 +4493,7 @@ if (isWorkerRuntime) {
|
|
|
4426
4493
|
console.log = (...args2) => logMessage("log", ...args2);
|
|
4427
4494
|
console.error = (...args2) => logMessage("error", ...args2);
|
|
4428
4495
|
console.warn = (...args2) => logMessage("warn", ...args2);
|
|
4429
|
-
|
|
4496
|
+
const handleMessage = async (event) => {
|
|
4430
4497
|
const message = event.data;
|
|
4431
4498
|
const messageType = String(event.data.type ?? "unknown");
|
|
4432
4499
|
try {
|
|
@@ -4522,6 +4589,12 @@ if (isWorkerRuntime) {
|
|
|
4522
4589
|
case "ONESHOT_HIGHLIGHT":
|
|
4523
4590
|
await worker.handleOneShotHighlight(message.content, message.filetype, message.messageId);
|
|
4524
4591
|
break;
|
|
4592
|
+
case "DISPOSE_COPY":
|
|
4593
|
+
worker.disposeCopy(message.copyId);
|
|
4594
|
+
break;
|
|
4595
|
+
case "APPEND_HIGHLIGHT":
|
|
4596
|
+
await worker.handleAppendHighlight(message.copyId, message.offset, message.text, message.filetype, message.messageId);
|
|
4597
|
+
break;
|
|
4525
4598
|
case "UPDATE_DATA_PATH":
|
|
4526
4599
|
try {
|
|
4527
4600
|
await worker.updateDataPath(message.dataPath);
|
|
@@ -4566,8 +4639,18 @@ if (isWorkerRuntime) {
|
|
|
4566
4639
|
postWorkerError(undefined, messageId, error);
|
|
4567
4640
|
}
|
|
4568
4641
|
}
|
|
4642
|
+
};
|
|
4643
|
+
const bufferQueues = new Map;
|
|
4644
|
+
setWorkerMessageHandler((event) => {
|
|
4645
|
+
const { data } = event;
|
|
4646
|
+
const key = "bufferId" in data ? data.bufferId : ("copyId" in data) ? `copy ${data.copyId}` : undefined;
|
|
4647
|
+
if (key === undefined)
|
|
4648
|
+
return handleMessage(event);
|
|
4649
|
+
const queued = (bufferQueues.get(key) ?? Promise.resolve()).then(() => handleMessage(event));
|
|
4650
|
+
bufferQueues.set(key, queued);
|
|
4651
|
+
queued.then(() => bufferQueues.get(key) === queued && bufferQueues.delete(key));
|
|
4569
4652
|
});
|
|
4570
4653
|
}
|
|
4571
4654
|
|
|
4572
|
-
//# debugId=
|
|
4655
|
+
//# debugId=B34B2C3B634686F564756E2164756E21
|
|
4573
4656
|
//# sourceMappingURL=parser.worker.js.map
|