@opentui/core 0.6.8 → 0.7.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 +5 -26
- package/Renderable.d.ts +27 -32
- package/audio.d.ts +1 -0
- package/{chunk-bun-ehr9v0n8.js → chunk-bun-qkpm62w1.js} +257 -69
- package/chunk-bun-qkpm62w1.js.map +35 -0
- package/{chunk-bun-4e5bpeqh.js → chunk-bun-zevtbcf6.js} +846 -785
- package/chunk-bun-zevtbcf6.js.map +70 -0
- package/{chunk-node-yyjd8p1g.js → chunk-node-7bcmqh18.js} +846 -785
- package/chunk-node-7bcmqh18.js.map +70 -0
- package/{chunk-node-jhq62x0c.js → chunk-node-mzgnr3sw.js} +257 -69
- package/chunk-node-mzgnr3sw.js.map +34 -0
- package/index.bun.js +313 -91
- package/index.bun.js.map +12 -11
- package/index.node.js +313 -91
- package/index.node.js.map +12 -10
- package/lib/detect-links.d.ts +2 -0
- package/lib/parse.keypress-kitty.d.ts +2 -0
- package/lib/scroll-chain.d.ts +16 -0
- package/lib/stdin-parser-native.d.ts +88 -0
- package/native-abi.generated.d.ts +394 -5
- package/package.json +9 -9
- package/renderables/Box.d.ts +2 -2
- package/renderables/Code.d.ts +2 -1
- package/renderables/Diff.d.ts +2 -2
- package/renderables/EditBufferRenderable.d.ts +2 -2
- package/renderables/EmbeddedTerminal.d.ts +2 -2
- package/renderables/FrameBuffer.d.ts +3 -3
- package/renderables/Image.d.ts +2 -2
- package/renderables/Markdown.d.ts +2 -2
- package/renderables/ScrollBar.d.ts +3 -3
- package/renderables/ScrollBox.d.ts +6 -3
- package/renderables/Slider.d.ts +2 -2
- package/renderables/Text.d.ts +2 -2
- package/renderables/TextBufferRenderable.d.ts +2 -4
- package/renderer.d.ts +8 -4
- package/testing/test-renderer.d.ts +2 -0
- package/testing.bun.js +11 -4
- package/testing.bun.js.map +3 -3
- package/testing.js +11 -4
- package/testing.js.map +3 -3
- package/yoga.bun.js +1 -1
- package/yoga.js +1 -1
- package/zig-structs.d.ts +25 -0
- package/zig.d.ts +20 -7
- package/chunk-bun-4e5bpeqh.js.map +0 -69
- package/chunk-bun-ehr9v0n8.js.map +0 -35
- package/chunk-node-jhq62x0c.js.map +0 -34
- package/chunk-node-yyjd8p1g.js.map +0 -69
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
nativeLayouts,
|
|
2
3
|
nativeConstants,
|
|
3
4
|
toArrayBuffer,
|
|
4
5
|
singleton,
|
|
@@ -63,7 +64,7 @@ import {
|
|
|
63
64
|
PositionType2,
|
|
64
65
|
Unit2,
|
|
65
66
|
Wrap2
|
|
66
|
-
} from "./chunk-node-
|
|
67
|
+
} from "./chunk-node-mzgnr3sw.js";
|
|
67
68
|
|
|
68
69
|
// src/lib/border.ts
|
|
69
70
|
var VALID_BORDER_STYLES = ["single", "double", "rounded", "heavy"];
|
|
@@ -3285,237 +3286,6 @@ function renderFontToFrameBuffer2(buffer, {
|
|
|
3285
3286
|
};
|
|
3286
3287
|
}
|
|
3287
3288
|
|
|
3288
|
-
// src/syntax-style.ts
|
|
3289
|
-
function cloneStyle(style) {
|
|
3290
|
-
return {
|
|
3291
|
-
...style,
|
|
3292
|
-
fg: style.fg ? RGBA2.clone(style.fg) : undefined,
|
|
3293
|
-
bg: style.bg ? RGBA2.clone(style.bg) : undefined
|
|
3294
|
-
};
|
|
3295
|
-
}
|
|
3296
|
-
function convertThemeToStyles2(theme) {
|
|
3297
|
-
const flatStyles = {};
|
|
3298
|
-
for (const tokenStyle of theme) {
|
|
3299
|
-
const styleDefinition = {};
|
|
3300
|
-
if (tokenStyle.style.foreground) {
|
|
3301
|
-
styleDefinition.fg = parseColor2(tokenStyle.style.foreground);
|
|
3302
|
-
}
|
|
3303
|
-
if (tokenStyle.style.background) {
|
|
3304
|
-
styleDefinition.bg = parseColor2(tokenStyle.style.background);
|
|
3305
|
-
}
|
|
3306
|
-
if (tokenStyle.style.bold !== undefined) {
|
|
3307
|
-
styleDefinition.bold = tokenStyle.style.bold;
|
|
3308
|
-
}
|
|
3309
|
-
if (tokenStyle.style.italic !== undefined) {
|
|
3310
|
-
styleDefinition.italic = tokenStyle.style.italic;
|
|
3311
|
-
}
|
|
3312
|
-
if (tokenStyle.style.underline !== undefined) {
|
|
3313
|
-
styleDefinition.underline = tokenStyle.style.underline;
|
|
3314
|
-
}
|
|
3315
|
-
if (tokenStyle.style.dim !== undefined) {
|
|
3316
|
-
styleDefinition.dim = tokenStyle.style.dim;
|
|
3317
|
-
}
|
|
3318
|
-
for (const scope of tokenStyle.scope) {
|
|
3319
|
-
flatStyles[scope] = cloneStyle(styleDefinition);
|
|
3320
|
-
}
|
|
3321
|
-
}
|
|
3322
|
-
return flatStyles;
|
|
3323
|
-
}
|
|
3324
|
-
|
|
3325
|
-
class SyntaxStyle2 {
|
|
3326
|
-
lib;
|
|
3327
|
-
native;
|
|
3328
|
-
_destroyed = false;
|
|
3329
|
-
nameCache = new Map;
|
|
3330
|
-
styleDefs = new Map;
|
|
3331
|
-
mergedCache = new Map;
|
|
3332
|
-
constructor(lib, handle, source) {
|
|
3333
|
-
const owner = source?.resourceContext;
|
|
3334
|
-
if (!owner)
|
|
3335
|
-
throw new Error("SyntaxStyle requires an explicit resource owner");
|
|
3336
|
-
owner.assertAlive();
|
|
3337
|
-
if (owner.renderLib !== lib || !handle || typeof handle !== "object" || handle.context !== owner.context) {
|
|
3338
|
-
throw new Error("SyntaxStyle Context owner mismatch");
|
|
3339
|
-
}
|
|
3340
|
-
this.lib = lib;
|
|
3341
|
-
this.native = { owner, handle };
|
|
3342
|
-
}
|
|
3343
|
-
static create(source) {
|
|
3344
|
-
const owner = source?.resourceContext;
|
|
3345
|
-
if (!owner)
|
|
3346
|
-
throw new Error("SyntaxStyle requires an explicit resource owner: pass renderer.nativeScene, or a ResourceContext when there is no renderer");
|
|
3347
|
-
owner.assertAlive();
|
|
3348
|
-
const lib = owner.renderLib;
|
|
3349
|
-
const handle = lib.createContextSyntaxStyle(owner.context);
|
|
3350
|
-
try {
|
|
3351
|
-
return new SyntaxStyle2(lib, handle, owner);
|
|
3352
|
-
} catch (error) {
|
|
3353
|
-
lib.destroyContextSyntaxStyle(owner.context, handle);
|
|
3354
|
-
throw error;
|
|
3355
|
-
}
|
|
3356
|
-
}
|
|
3357
|
-
static fromTheme(theme, owner) {
|
|
3358
|
-
return SyntaxStyle2.fromStyles(convertThemeToStyles2(theme), owner);
|
|
3359
|
-
}
|
|
3360
|
-
static fromStyles(styles, owner) {
|
|
3361
|
-
const style = SyntaxStyle2.create(owner);
|
|
3362
|
-
try {
|
|
3363
|
-
for (const [name, styleDef] of styles instanceof Map ? styles : Object.entries(styles)) {
|
|
3364
|
-
style.registerStyle(name, styleDef);
|
|
3365
|
-
}
|
|
3366
|
-
return style;
|
|
3367
|
-
} catch (error) {
|
|
3368
|
-
style.destroy();
|
|
3369
|
-
throw error;
|
|
3370
|
-
}
|
|
3371
|
-
}
|
|
3372
|
-
guard() {
|
|
3373
|
-
if (this._destroyed)
|
|
3374
|
-
throw new Error("NativeSyntaxStyle is destroyed");
|
|
3375
|
-
this.native.owner.assertAlive();
|
|
3376
|
-
}
|
|
3377
|
-
_getSceneHandle(scene) {
|
|
3378
|
-
this.guard();
|
|
3379
|
-
if (this.native.owner !== scene.resourceContext)
|
|
3380
|
-
throw new Error("SyntaxStyle owner mismatch: bind definitions in the destination Context");
|
|
3381
|
-
return this.native.handle;
|
|
3382
|
-
}
|
|
3383
|
-
registerStyle(name, style) {
|
|
3384
|
-
this.guard();
|
|
3385
|
-
const { bold, italic, underline, dim, fg: foreground, bg: background } = style;
|
|
3386
|
-
const definition = {
|
|
3387
|
-
bold,
|
|
3388
|
-
italic,
|
|
3389
|
-
underline,
|
|
3390
|
-
dim,
|
|
3391
|
-
fg: foreground ? RGBA2.clone(parseColor2(foreground)) : undefined,
|
|
3392
|
-
bg: background ? RGBA2.clone(parseColor2(background)) : undefined
|
|
3393
|
-
};
|
|
3394
|
-
const attributes = createTextAttributes2(definition);
|
|
3395
|
-
const fg = definition.fg ?? null;
|
|
3396
|
-
const bg = definition.bg ?? null;
|
|
3397
|
-
return this.lib.getYogaHost().runMutation(() => {
|
|
3398
|
-
const id = this.lib.contextSyntaxStyleRegister(this.native.handle.context, this.native.handle, name, {
|
|
3399
|
-
fg,
|
|
3400
|
-
bg,
|
|
3401
|
-
attributes
|
|
3402
|
-
});
|
|
3403
|
-
this.nameCache.set(name, id);
|
|
3404
|
-
this.styleDefs.set(name, definition);
|
|
3405
|
-
this.mergedCache.clear();
|
|
3406
|
-
return id;
|
|
3407
|
-
});
|
|
3408
|
-
}
|
|
3409
|
-
resolveStyleId(name) {
|
|
3410
|
-
this.guard();
|
|
3411
|
-
const cached = this.nameCache.get(name);
|
|
3412
|
-
if (cached !== undefined)
|
|
3413
|
-
return cached;
|
|
3414
|
-
const id = this.lib.contextSyntaxStyleResolveByName(this.native.handle.context, this.native.handle, name);
|
|
3415
|
-
if (id !== null) {
|
|
3416
|
-
this.nameCache.set(name, id);
|
|
3417
|
-
}
|
|
3418
|
-
return id;
|
|
3419
|
-
}
|
|
3420
|
-
getStyleId(name) {
|
|
3421
|
-
this.guard();
|
|
3422
|
-
const id = this.resolveStyleId(name);
|
|
3423
|
-
if (id !== null)
|
|
3424
|
-
return id;
|
|
3425
|
-
if (name.includes(".")) {
|
|
3426
|
-
const baseName = name.split(".")[0];
|
|
3427
|
-
return this.resolveStyleId(baseName);
|
|
3428
|
-
}
|
|
3429
|
-
return null;
|
|
3430
|
-
}
|
|
3431
|
-
getStyleCount() {
|
|
3432
|
-
this.guard();
|
|
3433
|
-
return this.lib.contextSyntaxStyleGetStyleCount(this.native.handle.context, this.native.handle);
|
|
3434
|
-
}
|
|
3435
|
-
clearNameCache() {
|
|
3436
|
-
this.guard();
|
|
3437
|
-
this.nameCache.clear();
|
|
3438
|
-
}
|
|
3439
|
-
getStyle(name) {
|
|
3440
|
-
this.guard();
|
|
3441
|
-
const style = this.styleDefs.get(name);
|
|
3442
|
-
if (style)
|
|
3443
|
-
return cloneStyle(style);
|
|
3444
|
-
if (name.includes(".")) {
|
|
3445
|
-
const baseName = name.split(".")[0];
|
|
3446
|
-
const base = this.styleDefs.get(baseName);
|
|
3447
|
-
return base ? cloneStyle(base) : undefined;
|
|
3448
|
-
}
|
|
3449
|
-
return;
|
|
3450
|
-
}
|
|
3451
|
-
mergeStyles(...styleNames) {
|
|
3452
|
-
this.guard();
|
|
3453
|
-
const cacheKey = styleNames.join(":");
|
|
3454
|
-
const cached = this.mergedCache.get(cacheKey);
|
|
3455
|
-
if (cached)
|
|
3456
|
-
return cloneStyle(cached);
|
|
3457
|
-
const styleDefinition = {};
|
|
3458
|
-
for (const name of styleNames) {
|
|
3459
|
-
const style = this.getStyle(name);
|
|
3460
|
-
if (!style)
|
|
3461
|
-
continue;
|
|
3462
|
-
if (style.fg)
|
|
3463
|
-
styleDefinition.fg = style.fg;
|
|
3464
|
-
if (style.bg)
|
|
3465
|
-
styleDefinition.bg = style.bg;
|
|
3466
|
-
if (style.bold !== undefined)
|
|
3467
|
-
styleDefinition.bold = style.bold;
|
|
3468
|
-
if (style.italic !== undefined)
|
|
3469
|
-
styleDefinition.italic = style.italic;
|
|
3470
|
-
if (style.underline !== undefined)
|
|
3471
|
-
styleDefinition.underline = style.underline;
|
|
3472
|
-
if (style.dim !== undefined)
|
|
3473
|
-
styleDefinition.dim = style.dim;
|
|
3474
|
-
}
|
|
3475
|
-
const attributes = createTextAttributes2({
|
|
3476
|
-
bold: styleDefinition.bold,
|
|
3477
|
-
italic: styleDefinition.italic,
|
|
3478
|
-
underline: styleDefinition.underline,
|
|
3479
|
-
dim: styleDefinition.dim
|
|
3480
|
-
});
|
|
3481
|
-
const merged = {
|
|
3482
|
-
fg: styleDefinition.fg,
|
|
3483
|
-
bg: styleDefinition.bg,
|
|
3484
|
-
attributes
|
|
3485
|
-
};
|
|
3486
|
-
this.mergedCache.set(cacheKey, merged);
|
|
3487
|
-
return cloneStyle(merged);
|
|
3488
|
-
}
|
|
3489
|
-
clearCache() {
|
|
3490
|
-
this.guard();
|
|
3491
|
-
this.mergedCache.clear();
|
|
3492
|
-
}
|
|
3493
|
-
getCacheSize() {
|
|
3494
|
-
this.guard();
|
|
3495
|
-
return this.mergedCache.size;
|
|
3496
|
-
}
|
|
3497
|
-
getAllStyles() {
|
|
3498
|
-
this.guard();
|
|
3499
|
-
return new Map(Array.from(this.styleDefs, ([name, style]) => [name, cloneStyle(style)]));
|
|
3500
|
-
}
|
|
3501
|
-
getRegisteredNames() {
|
|
3502
|
-
this.guard();
|
|
3503
|
-
return Array.from(this.styleDefs.keys());
|
|
3504
|
-
}
|
|
3505
|
-
destroy() {
|
|
3506
|
-
if (this._destroyed)
|
|
3507
|
-
return;
|
|
3508
|
-
this.lib.getYogaHost().runMutation(() => {
|
|
3509
|
-
if (!this.native.owner.disposed)
|
|
3510
|
-
this.lib.destroyContextSyntaxStyle(this.native.handle.context, this.native.handle);
|
|
3511
|
-
this._destroyed = true;
|
|
3512
|
-
this.nameCache.clear();
|
|
3513
|
-
this.styleDefs.clear();
|
|
3514
|
-
this.mergedCache.clear();
|
|
3515
|
-
});
|
|
3516
|
-
}
|
|
3517
|
-
}
|
|
3518
|
-
|
|
3519
3289
|
// src/lib/hast-styled-text.ts
|
|
3520
3290
|
function hastToTextChunks(node, syntaxStyle, parentStyles = []) {
|
|
3521
3291
|
const chunks = [];
|
|
@@ -8049,7 +7819,7 @@ class ExtmarksController2 {
|
|
|
8049
7819
|
this.originalMoveCursorLeft();
|
|
8050
7820
|
return;
|
|
8051
7821
|
}
|
|
8052
|
-
const currentOffset = this.
|
|
7822
|
+
const currentOffset = this.editBuffer.getCursorPosition().offset;
|
|
8053
7823
|
const hasSelection = this.editorView.hasSelection();
|
|
8054
7824
|
if (hasSelection) {
|
|
8055
7825
|
this.originalMoveCursorLeft();
|
|
@@ -8072,7 +7842,7 @@ class ExtmarksController2 {
|
|
|
8072
7842
|
this.originalMoveCursorRight();
|
|
8073
7843
|
return;
|
|
8074
7844
|
}
|
|
8075
|
-
const currentOffset = this.
|
|
7845
|
+
const currentOffset = this.editBuffer.getCursorPosition().offset;
|
|
8076
7846
|
const hasSelection = this.editorView.hasSelection();
|
|
8077
7847
|
if (hasSelection) {
|
|
8078
7848
|
this.originalMoveCursorRight();
|
|
@@ -8100,9 +7870,9 @@ class ExtmarksController2 {
|
|
|
8100
7870
|
this.originalMoveUpVisual();
|
|
8101
7871
|
return;
|
|
8102
7872
|
}
|
|
8103
|
-
const currentOffset = this.
|
|
7873
|
+
const currentOffset = this.editBuffer.getCursorPosition().offset;
|
|
8104
7874
|
this.originalMoveUpVisual();
|
|
8105
|
-
const newOffset = this.
|
|
7875
|
+
const newOffset = this.editBuffer.getCursorPosition().offset;
|
|
8106
7876
|
const virtualExtmark = this.findVirtualExtmarkContaining(newOffset);
|
|
8107
7877
|
if (virtualExtmark) {
|
|
8108
7878
|
const distanceToStart = newOffset - virtualExtmark.start;
|
|
@@ -8124,9 +7894,9 @@ class ExtmarksController2 {
|
|
|
8124
7894
|
this.originalMoveDownVisual();
|
|
8125
7895
|
return;
|
|
8126
7896
|
}
|
|
8127
|
-
const currentOffset = this.
|
|
7897
|
+
const currentOffset = this.editBuffer.getCursorPosition().offset;
|
|
8128
7898
|
this.originalMoveDownVisual();
|
|
8129
|
-
const newOffset = this.
|
|
7899
|
+
const newOffset = this.editBuffer.getCursorPosition().offset;
|
|
8130
7900
|
const virtualExtmark = this.findVirtualExtmarkContaining(newOffset);
|
|
8131
7901
|
if (virtualExtmark) {
|
|
8132
7902
|
const distanceToStart = newOffset - virtualExtmark.start;
|
|
@@ -8145,7 +7915,7 @@ class ExtmarksController2 {
|
|
|
8145
7915
|
this.originalSetCursorByOffset(offset);
|
|
8146
7916
|
return;
|
|
8147
7917
|
}
|
|
8148
|
-
const currentOffset = this.
|
|
7918
|
+
const currentOffset = this.editBuffer.getCursorPosition().offset;
|
|
8149
7919
|
const hasSelection = this.editorView.hasSelection();
|
|
8150
7920
|
if (hasSelection) {
|
|
8151
7921
|
this.originalSetCursorByOffset(offset);
|
|
@@ -8175,7 +7945,7 @@ class ExtmarksController2 {
|
|
|
8175
7945
|
this.originalDeleteCharBackward();
|
|
8176
7946
|
return;
|
|
8177
7947
|
}
|
|
8178
|
-
const currentOffset = this.
|
|
7948
|
+
const currentOffset = this.editBuffer.getCursorPosition().offset;
|
|
8179
7949
|
const hadSelection = this.editorView.hasSelection();
|
|
8180
7950
|
if (currentOffset === 0 || hadSelection) {
|
|
8181
7951
|
this.originalDeleteCharBackward();
|
|
@@ -8208,7 +7978,7 @@ class ExtmarksController2 {
|
|
|
8208
7978
|
this.originalDeleteChar();
|
|
8209
7979
|
return;
|
|
8210
7980
|
}
|
|
8211
|
-
const currentOffset = this.
|
|
7981
|
+
const currentOffset = this.editBuffer.getCursorPosition().offset;
|
|
8212
7982
|
const hadSelection = this.editorView.hasSelection();
|
|
8213
7983
|
if (hadSelection) {
|
|
8214
7984
|
this.originalDeleteChar();
|
|
@@ -8267,7 +8037,7 @@ class ExtmarksController2 {
|
|
|
8267
8037
|
this.originalInsertText(text);
|
|
8268
8038
|
return;
|
|
8269
8039
|
}
|
|
8270
|
-
const currentOffset = this.
|
|
8040
|
+
const currentOffset = this.editBuffer.getCursorPosition().offset;
|
|
8271
8041
|
this.originalInsertText(text);
|
|
8272
8042
|
this.saveSnapshot();
|
|
8273
8043
|
const insertLength = this.editBuffer.getCursorPosition().offset - currentOffset;
|
|
@@ -8280,7 +8050,7 @@ class ExtmarksController2 {
|
|
|
8280
8050
|
this.originalInsertChar(char);
|
|
8281
8051
|
return;
|
|
8282
8052
|
}
|
|
8283
|
-
const currentOffset = this.
|
|
8053
|
+
const currentOffset = this.editBuffer.getCursorPosition().offset;
|
|
8284
8054
|
this.originalInsertChar(char);
|
|
8285
8055
|
this.saveSnapshot();
|
|
8286
8056
|
const insertLength = this.editBuffer.getCursorPosition().offset - currentOffset;
|
|
@@ -8323,7 +8093,7 @@ class ExtmarksController2 {
|
|
|
8323
8093
|
this.originalNewLine();
|
|
8324
8094
|
return;
|
|
8325
8095
|
}
|
|
8326
|
-
const currentOffset = this.
|
|
8096
|
+
const currentOffset = this.editBuffer.getCursorPosition().offset;
|
|
8327
8097
|
this.originalNewLine();
|
|
8328
8098
|
this.saveSnapshot();
|
|
8329
8099
|
this.adjustExtmarksAfterInsertion(currentOffset, 1);
|
|
@@ -8443,7 +8213,7 @@ class ExtmarksController2 {
|
|
|
8443
8213
|
}
|
|
8444
8214
|
getNextCursorOffset(currentOffset) {
|
|
8445
8215
|
this.originalMoveCursorRight();
|
|
8446
|
-
const nextOffset = this.
|
|
8216
|
+
const nextOffset = this.editBuffer.getCursorPosition().offset;
|
|
8447
8217
|
this.originalSetCursorByOffset(currentOffset);
|
|
8448
8218
|
return nextOffset;
|
|
8449
8219
|
}
|
|
@@ -9687,12 +9457,13 @@ function detectLinks2(chunks, context) {
|
|
|
9687
9457
|
highlightedIndex++;
|
|
9688
9458
|
if (highlightedIndex < ranges.length && ranges[highlightedIndex].start < end)
|
|
9689
9459
|
continue;
|
|
9690
|
-
ranges.push({ start, end, url });
|
|
9460
|
+
ranges.push({ start, end, url, bare: true });
|
|
9691
9461
|
}
|
|
9692
9462
|
}
|
|
9693
9463
|
if (ranges.length === 0)
|
|
9694
9464
|
return chunks;
|
|
9695
9465
|
ranges.sort((a, b) => a.start - b.start || b.end - a.end || Number(b.label ?? false) - Number(a.label ?? false));
|
|
9466
|
+
const bareStyle = context.syntaxStyle?.mergeStyles("markup.link.label");
|
|
9696
9467
|
const linkedChunks = [];
|
|
9697
9468
|
let contentPos = 0;
|
|
9698
9469
|
let rangeIndex = 0;
|
|
@@ -9731,16 +9502,16 @@ function detectLinks2(chunks, context) {
|
|
|
9731
9502
|
if (linkStart > position) {
|
|
9732
9503
|
linkedChunks.push({ ...chunk, text: chunk.text.slice(position - start, linkStart - start) });
|
|
9733
9504
|
}
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
});
|
|
9505
|
+
const linked = linkStart === start && linkEnd === end ? chunk : { ...chunk, text: chunk.text.slice(linkStart - start, linkEnd - start) };
|
|
9506
|
+
linked.link = { url: range.url };
|
|
9507
|
+
if (range.bare && bareStyle) {
|
|
9508
|
+
if (bareStyle.fg)
|
|
9509
|
+
linked.fg = bareStyle.fg;
|
|
9510
|
+
if (bareStyle.bg)
|
|
9511
|
+
linked.bg = bareStyle.bg;
|
|
9512
|
+
linked.attributes = (linked.attributes ?? 0) | bareStyle.attributes;
|
|
9743
9513
|
}
|
|
9514
|
+
linkedChunks.push(linked);
|
|
9744
9515
|
position = linkEnd;
|
|
9745
9516
|
if (position === end)
|
|
9746
9517
|
break;
|
|
@@ -10533,26 +10304,16 @@ function isSizeType(value) {
|
|
|
10533
10304
|
|
|
10534
10305
|
// src/Renderable.ts
|
|
10535
10306
|
var BrandedRenderable = Symbol.for("@opentui/core/Renderable");
|
|
10536
|
-
var
|
|
10307
|
+
var hookNames = [
|
|
10537
10308
|
"renderSelf",
|
|
10538
10309
|
"onResize",
|
|
10539
10310
|
"onLayoutResize",
|
|
10540
10311
|
"onUpdate",
|
|
10541
10312
|
"renderBefore",
|
|
10542
10313
|
"renderAfter",
|
|
10543
|
-
"onLifecyclePass"
|
|
10544
|
-
"selectable"
|
|
10314
|
+
"onLifecyclePass"
|
|
10545
10315
|
];
|
|
10546
|
-
var nativeSceneMethodDefaults = {
|
|
10547
|
-
selectable: false,
|
|
10548
|
-
onLifecyclePass: null,
|
|
10549
|
-
renderBefore: undefined,
|
|
10550
|
-
renderAfter: undefined
|
|
10551
|
-
};
|
|
10552
|
-
var nativeSceneHookUpdates = nativeConstants.OT_SCENE_HOOK_UPDATE | nativeConstants.OT_SCENE_HOOK_IDLE_UPDATE;
|
|
10553
|
-
var nativeSceneHookListeners = nativeConstants.OT_SCENE_HOOK_RESIZE | nativeConstants.OT_SCENE_HOOK_LAYOUT_CHANGED;
|
|
10554
10316
|
var nativeSceneHookBeforeAfter = nativeConstants.OT_SCENE_HOOK_RENDER_BEFORE | nativeConstants.OT_SCENE_HOOK_RENDER_AFTER;
|
|
10555
|
-
var nativeSceneHookHostMethods = nativeConstants.OT_SCENE_HOOK_UPDATE | nativeSceneHookBeforeAfter | nativeConstants.OT_SCENE_HOOK_RENDER_SELF;
|
|
10556
10317
|
function isRowFlexDirection(direction) {
|
|
10557
10318
|
return direction === FlexDirection2.Row || direction === FlexDirection2.RowReverse;
|
|
10558
10319
|
}
|
|
@@ -10620,6 +10381,15 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
10620
10381
|
kind: "custom",
|
|
10621
10382
|
body: { native: this.prototype.renderSelf }
|
|
10622
10383
|
};
|
|
10384
|
+
static baseHooks = {
|
|
10385
|
+
renderSelf: this.prototype.renderSelf,
|
|
10386
|
+
onResize: this.prototype.onResize,
|
|
10387
|
+
onLayoutResize: this.prototype.onLayoutResize,
|
|
10388
|
+
onUpdate: this.prototype.onUpdate,
|
|
10389
|
+
renderBefore: undefined,
|
|
10390
|
+
renderAfter: undefined,
|
|
10391
|
+
onLifecyclePass: null
|
|
10392
|
+
};
|
|
10623
10393
|
nativeIntegration;
|
|
10624
10394
|
_isDestroyed = false;
|
|
10625
10395
|
_cleanupInProgress = false;
|
|
@@ -10644,18 +10414,14 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
10644
10414
|
_live = false;
|
|
10645
10415
|
_liveCount = 0;
|
|
10646
10416
|
_sizeChangeListener = undefined;
|
|
10647
|
-
|
|
10417
|
+
_hooks = Renderable2.baseHooks;
|
|
10648
10418
|
_nativeSceneHookGeneration = 0n;
|
|
10649
10419
|
_nativeSceneHooksRegistered = false;
|
|
10650
10420
|
_nativeSceneResize = false;
|
|
10651
|
-
|
|
10652
|
-
_nativeSceneHookLayout;
|
|
10421
|
+
_paintLayout;
|
|
10653
10422
|
_observedLayout;
|
|
10654
10423
|
_observedLayoutRevision = -1;
|
|
10655
|
-
|
|
10656
|
-
_computedLayoutRevision = -1;
|
|
10657
|
-
_nativeSceneMethods;
|
|
10658
|
-
_nativeSceneMethodsPending = false;
|
|
10424
|
+
_selectable = false;
|
|
10659
10425
|
_mouseListener = null;
|
|
10660
10426
|
_mouseListeners = {};
|
|
10661
10427
|
_pasteListener = undefined;
|
|
@@ -10667,6 +10433,24 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
10667
10433
|
_flexShrink = 1;
|
|
10668
10434
|
_childrenInLayoutOrder = [];
|
|
10669
10435
|
parent = null;
|
|
10436
|
+
get onLifecyclePass() {
|
|
10437
|
+
return this._hooks.onLifecyclePass;
|
|
10438
|
+
}
|
|
10439
|
+
set onLifecyclePass(value) {
|
|
10440
|
+
this.setHook("onLifecyclePass", value);
|
|
10441
|
+
}
|
|
10442
|
+
get renderBefore() {
|
|
10443
|
+
return this._hooks.renderBefore;
|
|
10444
|
+
}
|
|
10445
|
+
set renderBefore(value) {
|
|
10446
|
+
this.setHook("renderBefore", value);
|
|
10447
|
+
}
|
|
10448
|
+
get renderAfter() {
|
|
10449
|
+
return this._hooks.renderAfter;
|
|
10450
|
+
}
|
|
10451
|
+
set renderAfter(value) {
|
|
10452
|
+
this.setHook("renderAfter", value);
|
|
10453
|
+
}
|
|
10670
10454
|
constructor(ctx, options) {
|
|
10671
10455
|
super(options);
|
|
10672
10456
|
this._ctx = ctx;
|
|
@@ -10683,12 +10467,14 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
10683
10467
|
this._liveCount = this._live && this._visible ? 1 : 0;
|
|
10684
10468
|
this._opacity = clampOpacity(options.opacity);
|
|
10685
10469
|
ctx.nativeScene.createNode(this, options);
|
|
10686
|
-
|
|
10687
|
-
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
10470
|
+
const hooks = {};
|
|
10471
|
+
for (const name of hookNames)
|
|
10472
|
+
hooks[name] = this[name];
|
|
10473
|
+
for (const name of ["renderBefore", "renderAfter"]) {
|
|
10474
|
+
if (options[name] !== undefined)
|
|
10475
|
+
hooks[name] = Renderable2.normalizeHook(name, options[name]);
|
|
10476
|
+
}
|
|
10477
|
+
this.publishHooks(hooks);
|
|
10692
10478
|
this.setDisplay(this._visible ? 0 /* Flex */ : 1 /* None */);
|
|
10693
10479
|
this.setupYogaProperties(options);
|
|
10694
10480
|
if (this.nativeIntegration.measure)
|
|
@@ -10700,9 +10486,6 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
10700
10486
|
if (this.buffered) {
|
|
10701
10487
|
this.createFrameBuffer();
|
|
10702
10488
|
}
|
|
10703
|
-
if (!Object.hasOwn(new.target, "nativeIntegration") || this.nativeIntegration.construction !== "prototype") {
|
|
10704
|
-
ctx.nativeScene.scheduleHookScan(this);
|
|
10705
|
-
}
|
|
10706
10489
|
} catch (error) {
|
|
10707
10490
|
try {
|
|
10708
10491
|
this.destroyLayoutBacking();
|
|
@@ -10981,22 +10764,16 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
10981
10764
|
return this.isFreed() ? this._destroyedLayout?.screenY ?? 0 : this.getNativeSceneLayout().screenY;
|
|
10982
10765
|
}
|
|
10983
10766
|
get _screenX() {
|
|
10984
|
-
return this.
|
|
10767
|
+
return this._paintLayout?.screenX ?? this.screenX;
|
|
10985
10768
|
}
|
|
10986
10769
|
get _screenY() {
|
|
10987
|
-
return this.
|
|
10770
|
+
return this._paintLayout?.screenY ?? this.screenY;
|
|
10988
10771
|
}
|
|
10989
|
-
|
|
10990
|
-
|
|
10991
|
-
|
|
10992
|
-
|
|
10993
|
-
|
|
10994
|
-
const revision = scene.currentGeometryRevision;
|
|
10995
|
-
if (!this._isDestroyed && cached.paintRevision !== revision) {
|
|
10996
|
-
cached.paintLayout = scene.getLayout(this, "paint");
|
|
10997
|
-
cached.paintRevision = revision;
|
|
10998
|
-
}
|
|
10999
|
-
return cached.paintLayout;
|
|
10772
|
+
get _paintWidth() {
|
|
10773
|
+
return this._paintLayout?.width ?? this.width;
|
|
10774
|
+
}
|
|
10775
|
+
get _paintHeight() {
|
|
10776
|
+
return this._paintLayout?.height ?? this.height;
|
|
11000
10777
|
}
|
|
11001
10778
|
get x() {
|
|
11002
10779
|
if (!this.isFreed())
|
|
@@ -11079,22 +10856,16 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
11079
10856
|
return typeof value === "number" ? value : 0;
|
|
11080
10857
|
}
|
|
11081
10858
|
getNativeSceneLayout() {
|
|
11082
|
-
const
|
|
11083
|
-
|
|
11084
|
-
const revision = scene.currentGeometryRevision;
|
|
11085
|
-
if (cached?.layout && cached.revision === revision)
|
|
11086
|
-
return cached.layout;
|
|
11087
|
-
const layoutRevision = scene.observedLayoutRevision;
|
|
11088
|
-
if (layoutRevision !== undefined && this._observedLayoutRevision === layoutRevision)
|
|
10859
|
+
const revision = this._ctx.nativeScene.observedLayoutRevision;
|
|
10860
|
+
if (revision !== undefined && this._observedLayoutRevision === revision)
|
|
11089
10861
|
return this._observedLayout;
|
|
11090
|
-
|
|
11091
|
-
|
|
11092
|
-
|
|
11093
|
-
|
|
11094
|
-
|
|
11095
|
-
if (layoutRevision !== undefined) {
|
|
10862
|
+
return this.observeLayout(this._ctx.nativeScene.getLayout(this));
|
|
10863
|
+
}
|
|
10864
|
+
observeLayout(layout) {
|
|
10865
|
+
const revision = this._ctx.nativeScene.observedLayoutRevision;
|
|
10866
|
+
if (layout && revision !== undefined) {
|
|
11096
10867
|
this._observedLayout = layout;
|
|
11097
|
-
this._observedLayoutRevision =
|
|
10868
|
+
this._observedLayoutRevision = revision;
|
|
11098
10869
|
}
|
|
11099
10870
|
return layout;
|
|
11100
10871
|
}
|
|
@@ -11305,17 +11076,7 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
11305
11076
|
return this.yogaGetValue(YogaValueKind.Gap, gutter);
|
|
11306
11077
|
}
|
|
11307
11078
|
getComputedLayout() {
|
|
11308
|
-
const
|
|
11309
|
-
const revision = scene.observedLayoutRevision;
|
|
11310
|
-
let layout = this._computedLayout;
|
|
11311
|
-
if (revision === undefined || this._computedLayoutRevision !== revision || layout === undefined || this._yogaFreed) {
|
|
11312
|
-
layout = scene.getLayout(this, true);
|
|
11313
|
-
if (revision !== undefined) {
|
|
11314
|
-
this._computedLayout = layout;
|
|
11315
|
-
this._computedLayoutRevision = revision;
|
|
11316
|
-
}
|
|
11317
|
-
}
|
|
11318
|
-
const { left, top, right, bottom, width, height } = layout;
|
|
11079
|
+
const { left, top, right, bottom, width, height } = this._ctx.nativeScene.getLayout(this, true);
|
|
11319
11080
|
return { left, top, right, bottom, width, height };
|
|
11320
11081
|
}
|
|
11321
11082
|
setMeasureFunc(measure) {
|
|
@@ -11608,7 +11369,7 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
11608
11369
|
onLayoutResize(width, height) {
|
|
11609
11370
|
if (this._visible) {
|
|
11610
11371
|
this.handleFrameBufferResize(width, height);
|
|
11611
|
-
this.onResize(width, height);
|
|
11372
|
+
this._hooks.onResize.call(this, width, height);
|
|
11612
11373
|
this.requestRender();
|
|
11613
11374
|
}
|
|
11614
11375
|
}
|
|
@@ -11645,8 +11406,6 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
11645
11406
|
if (this._ctx.nativeScene !== child._ctx.nativeScene) {
|
|
11646
11407
|
throw new Error("Cannot move renderables between native scenes");
|
|
11647
11408
|
}
|
|
11648
|
-
if (!child.isDestroyed)
|
|
11649
|
-
this._ctx.nativeScene.refreshPendingHooks(child);
|
|
11650
11409
|
let previous = child.parent;
|
|
11651
11410
|
if (previous && previous !== this && previous.remove !== Renderable2.prototype.remove) {
|
|
11652
11411
|
previous.remove(child);
|
|
@@ -11876,252 +11635,123 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
11876
11635
|
return;
|
|
11877
11636
|
this._ctx.nativeScene.setPaint(this, paint);
|
|
11878
11637
|
}
|
|
11879
|
-
static nativeSceneMethods = nativeSceneMethodNames.map((name) => {
|
|
11880
|
-
const normalize = (value) => {
|
|
11881
|
-
if (name === "selectable")
|
|
11882
|
-
return value;
|
|
11883
|
-
if (name === "onLifecyclePass")
|
|
11884
|
-
value ??= null;
|
|
11885
|
-
else if (name === "renderBefore" || name === "renderAfter")
|
|
11886
|
-
value ??= undefined;
|
|
11887
|
-
else if (name === "onUpdate")
|
|
11888
|
-
value ??= nativeSceneMethodDefaults.onUpdate;
|
|
11889
|
-
if (typeof value !== "function" && !((name === "renderBefore" || name === "renderAfter" || name === "onLifecyclePass") && value == null))
|
|
11890
|
-
throw new TypeError(`Invalid ${name} hook`);
|
|
11891
|
-
return value;
|
|
11892
|
-
};
|
|
11893
|
-
return {
|
|
11894
|
-
name,
|
|
11895
|
-
normalize,
|
|
11896
|
-
descriptor: {
|
|
11897
|
-
configurable: true,
|
|
11898
|
-
get() {
|
|
11899
|
-
const methods = this._nativeSceneMethods;
|
|
11900
|
-
if (methods && name in methods)
|
|
11901
|
-
return methods[name];
|
|
11902
|
-
return nativeSceneMethodDefaults[name];
|
|
11903
|
-
},
|
|
11904
|
-
set(value) {
|
|
11905
|
-
if (name === "selectable") {
|
|
11906
|
-
if (this.isFreed())
|
|
11907
|
-
return;
|
|
11908
|
-
this.assertMutable();
|
|
11909
|
-
this.ensureNativeSceneMethods()[name] = value;
|
|
11910
|
-
return;
|
|
11911
|
-
}
|
|
11912
|
-
value = normalize(value);
|
|
11913
|
-
if (value === this[name])
|
|
11914
|
-
return;
|
|
11915
|
-
this.setNativeSceneHooks(this._nativeSceneHookFlags, { [name]: value });
|
|
11916
|
-
this.ensureNativeSceneMethods()[name] = value;
|
|
11917
|
-
if (name === "onLifecyclePass") {
|
|
11918
|
-
if (!value)
|
|
11919
|
-
this._ctx.unregisterLifecyclePass(this);
|
|
11920
|
-
else if (this.parent)
|
|
11921
|
-
this._ctx.registerLifecyclePass(this);
|
|
11922
|
-
else
|
|
11923
|
-
this._ctx.nativeScene.lifecyclePasses.refresh(this);
|
|
11924
|
-
}
|
|
11925
|
-
}
|
|
11926
|
-
}
|
|
11927
|
-
};
|
|
11928
|
-
});
|
|
11929
11638
|
static {
|
|
11930
|
-
|
|
11931
|
-
nativeSceneMethodDefaults.renderSelf = prototype.renderSelf;
|
|
11932
|
-
nativeSceneMethodDefaults.onResize = prototype.onResize;
|
|
11933
|
-
nativeSceneMethodDefaults.onLayoutResize = prototype.onLayoutResize;
|
|
11934
|
-
nativeSceneMethodDefaults.onUpdate = prototype.onUpdate;
|
|
11935
|
-
for (const method of this.nativeSceneMethods) {
|
|
11936
|
-
if (method.name === "renderSelf" || method.name === "onResize" || method.name === "onLayoutResize" || method.name === "onUpdate") {
|
|
11937
|
-
this.installNativeSceneMethod(prototype, method, nativeSceneMethodDefaults[method.name]);
|
|
11938
|
-
} else {
|
|
11939
|
-
Object.defineProperty(prototype, method.name, method.descriptor);
|
|
11940
|
-
}
|
|
11941
|
-
}
|
|
11942
|
-
}
|
|
11943
|
-
static defineNativeIntegration(integration) {
|
|
11944
|
-
for (const method of Renderable2.nativeSceneMethods) {
|
|
11945
|
-
let prototype = this.prototype;
|
|
11946
|
-
while (prototype) {
|
|
11947
|
-
const descriptor = Object.getOwnPropertyDescriptor(prototype, method.name);
|
|
11948
|
-
if (descriptor) {
|
|
11949
|
-
if ("value" in descriptor)
|
|
11950
|
-
this.installNativeSceneMethod(this.prototype, method, descriptor.value);
|
|
11951
|
-
break;
|
|
11952
|
-
}
|
|
11953
|
-
prototype = Object.getPrototypeOf(prototype);
|
|
11954
|
-
}
|
|
11955
|
-
}
|
|
11956
|
-
return integration;
|
|
11957
|
-
}
|
|
11958
|
-
static installNativeSceneMethod(prototype, method, handler) {
|
|
11959
|
-
const instance = {
|
|
11960
|
-
...method.descriptor,
|
|
11961
|
-
get() {
|
|
11962
|
-
const methods = this._nativeSceneMethods;
|
|
11963
|
-
return methods && method.name in methods ? methods[method.name] : handler;
|
|
11964
|
-
}
|
|
11965
|
-
};
|
|
11966
|
-
Object.defineProperty(prototype, method.name, {
|
|
11639
|
+
Object.defineProperty(this.prototype, "selectable", {
|
|
11967
11640
|
configurable: true,
|
|
11968
11641
|
get() {
|
|
11969
|
-
return
|
|
11642
|
+
return this._selectable;
|
|
11970
11643
|
},
|
|
11971
11644
|
set(value) {
|
|
11972
|
-
|
|
11973
|
-
|
|
11645
|
+
if (this.isFreed())
|
|
11646
|
+
return;
|
|
11647
|
+
this.assertMutable();
|
|
11648
|
+
this._selectable = value;
|
|
11974
11649
|
}
|
|
11975
11650
|
});
|
|
11976
11651
|
}
|
|
11652
|
+
static normalizeHook(name, value) {
|
|
11653
|
+
if (value == null && name !== "renderSelf" && name !== "onResize" && name !== "onLayoutResize") {
|
|
11654
|
+
return name === "onUpdate" ? Renderable2.baseHooks.onUpdate : name === "onLifecyclePass" ? null : undefined;
|
|
11655
|
+
}
|
|
11656
|
+
if (typeof value !== "function")
|
|
11657
|
+
throw new TypeError(`Invalid ${name} hook`);
|
|
11658
|
+
return value;
|
|
11659
|
+
}
|
|
11660
|
+
setHook(name, value) {
|
|
11661
|
+
value = Renderable2.normalizeHook(name, value);
|
|
11662
|
+
if (value === this._hooks[name])
|
|
11663
|
+
return;
|
|
11664
|
+
const hooks = { ...this._hooks, [name]: value };
|
|
11665
|
+
if (name !== "onLifecyclePass")
|
|
11666
|
+
return this.publishHooks(hooks);
|
|
11667
|
+
this._hooks = hooks;
|
|
11668
|
+
this.syncLifecyclePass();
|
|
11669
|
+
}
|
|
11670
|
+
syncLifecyclePass() {
|
|
11671
|
+
if (!this.onLifecyclePass)
|
|
11672
|
+
this._ctx.unregisterLifecyclePass(this);
|
|
11673
|
+
else if (this.parent)
|
|
11674
|
+
this._ctx.registerLifecyclePass(this);
|
|
11675
|
+
else
|
|
11676
|
+
this._ctx.nativeScene.lifecyclePasses.refresh(this);
|
|
11677
|
+
}
|
|
11977
11678
|
refreshHooks() {
|
|
11978
11679
|
if (this._isDestroyed)
|
|
11979
11680
|
return;
|
|
11980
11681
|
this.assertMutable();
|
|
11981
|
-
|
|
11982
|
-
|
|
11983
|
-
|
|
11984
|
-
|
|
11985
|
-
|
|
11682
|
+
const hooks = {};
|
|
11683
|
+
for (const name of hookNames)
|
|
11684
|
+
hooks[name] = Renderable2.normalizeHook(name, this[name]);
|
|
11685
|
+
this.publishHooks(hooks);
|
|
11686
|
+
for (const name of ["renderBefore", "renderAfter", "onLifecyclePass"]) {
|
|
11687
|
+
if (!Object.hasOwn(this, name))
|
|
11688
|
+
continue;
|
|
11689
|
+
delete this[name];
|
|
11690
|
+
if (this[name] !== hooks[name])
|
|
11691
|
+
Reflect.set(this, name, hooks[name]);
|
|
11986
11692
|
}
|
|
11693
|
+
this.syncLifecyclePass();
|
|
11694
|
+
this._refreshNativeSceneSurface();
|
|
11987
11695
|
this.requestRender();
|
|
11988
11696
|
}
|
|
11989
|
-
_scanNativeSceneHooks() {
|
|
11990
|
-
if (!this._isDestroyed)
|
|
11991
|
-
this.refreshNativeSceneMethods();
|
|
11992
|
-
}
|
|
11993
|
-
ensureNativeSceneMethods() {
|
|
11994
|
-
return this._nativeSceneMethods ??= {};
|
|
11995
|
-
}
|
|
11996
|
-
nativeSceneNeedsHookPublish() {
|
|
11997
|
-
if (this.buffered)
|
|
11998
|
-
return true;
|
|
11999
|
-
if (!this.usesNativeDrawing(this.renderSelf))
|
|
12000
|
-
return true;
|
|
12001
|
-
if (this.hostUpdateFlags(this.onUpdate) !== 0)
|
|
12002
|
-
return true;
|
|
12003
|
-
const onResize = this.onResize;
|
|
12004
|
-
const onLayoutResize = this.onLayoutResize;
|
|
12005
|
-
if (onLayoutResize !== nativeSceneMethodDefaults.onLayoutResize)
|
|
12006
|
-
return true;
|
|
12007
|
-
if (!this._nativeSceneHooksRegistered && this.nativeIntegration.beforeAfter !== false && (this.renderBefore || this.renderAfter))
|
|
12008
|
-
return true;
|
|
12009
|
-
return this.needsHostResize(onResize);
|
|
12010
|
-
}
|
|
12011
11697
|
usesNativeDrawing(renderSelf) {
|
|
12012
11698
|
const body = this.nativeIntegration.body;
|
|
12013
11699
|
return typeof body === "object" && "native" in body && (!this.buffered || body.buffered === true) && renderSelf === body.native;
|
|
12014
11700
|
}
|
|
12015
11701
|
needsHostResize(onResize) {
|
|
12016
11702
|
const resize = this.nativeIntegration.lifecycle?.resize;
|
|
12017
|
-
return onResize !==
|
|
11703
|
+
return onResize !== Renderable2.baseHooks.onResize && onResize !== resize?.native;
|
|
12018
11704
|
}
|
|
12019
11705
|
hostUpdateFlags(onUpdate) {
|
|
12020
11706
|
const update = this.nativeIntegration.lifecycle?.update;
|
|
12021
11707
|
if (update && onUpdate === update.idle) {
|
|
12022
11708
|
return update.active(this) ? NativeSceneHook2.Update : NativeSceneHook2.IdleUpdate;
|
|
12023
11709
|
}
|
|
12024
|
-
return onUpdate ===
|
|
12025
|
-
}
|
|
12026
|
-
refreshNativeSceneMethods() {
|
|
12027
|
-
this._refreshNativeSceneSurface();
|
|
12028
|
-
const methods = Renderable2.nativeSceneMethods;
|
|
12029
|
-
for (let index = 0;index < methods.length; index++) {
|
|
12030
|
-
const method = methods[index];
|
|
12031
|
-
const name = method.name;
|
|
12032
|
-
const own = Object.getOwnPropertyDescriptor(this, name);
|
|
12033
|
-
if (own?.set === method.descriptor.set)
|
|
12034
|
-
continue;
|
|
12035
|
-
const handler = method.normalize(this[name]);
|
|
12036
|
-
if (!own && handler === nativeSceneMethodDefaults[name])
|
|
12037
|
-
continue;
|
|
12038
|
-
this.ensureNativeSceneMethods()[name] = handler;
|
|
12039
|
-
Object.defineProperty(this, name, method.descriptor);
|
|
12040
|
-
if (own)
|
|
12041
|
-
this._nativeSceneMethodsPending = true;
|
|
12042
|
-
}
|
|
12043
|
-
if (this._nativeSceneMethodsPending) {
|
|
12044
|
-
this.setNativeSceneHooks(this._nativeSceneHookFlags, {
|
|
12045
|
-
onResize: this.onResize,
|
|
12046
|
-
onLayoutResize: this.onLayoutResize
|
|
12047
|
-
});
|
|
12048
|
-
if (!this.onLifecyclePass)
|
|
12049
|
-
this._ctx.unregisterLifecyclePass(this);
|
|
12050
|
-
else if (this.parent)
|
|
12051
|
-
this._ctx.registerLifecyclePass(this);
|
|
12052
|
-
else
|
|
12053
|
-
this._ctx.nativeScene.lifecyclePasses.refresh(this);
|
|
12054
|
-
this._nativeSceneMethodsPending = false;
|
|
12055
|
-
}
|
|
11710
|
+
return onUpdate === Renderable2.baseHooks.onUpdate ? 0 : NativeSceneHook2.Update;
|
|
12056
11711
|
}
|
|
12057
11712
|
refreshNativeSceneHooks() {
|
|
12058
|
-
this.
|
|
11713
|
+
this.publishHooks(this._hooks);
|
|
12059
11714
|
}
|
|
12060
11715
|
_refreshNativeSceneSurface() {}
|
|
12061
|
-
|
|
12062
|
-
if (this.isFreed())
|
|
12063
|
-
|
|
12064
|
-
|
|
12065
|
-
|
|
12066
|
-
|
|
12067
|
-
|
|
12068
|
-
|
|
12069
|
-
|
|
12070
|
-
|
|
12071
|
-
|
|
12072
|
-
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12076
|
-
|
|
12077
|
-
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
|
|
12083
|
-
|
|
12084
|
-
|
|
12085
|
-
|
|
12086
|
-
const update = "onUpdate" in overrides || previousGeneration === this._nativeSceneHookGeneration ? this.hostUpdateFlags(onUpdate) : this._nativeSceneHookFlags & nativeSceneHookUpdates;
|
|
12087
|
-
flags = flags & ~nativeSceneHookUpdates | update;
|
|
12088
|
-
const generation = this._nativeSceneHookGeneration + 1n;
|
|
12089
|
-
if (flags !== 0 || lineInfo || this._nativeSceneHooksRegistered) {
|
|
12090
|
-
let nativeFlags = flags;
|
|
12091
|
-
if (this.nativeIntegration.beforeAfter === false) {
|
|
12092
|
-
nativeFlags &= ~nativeSceneHookBeforeAfter;
|
|
12093
|
-
}
|
|
12094
|
-
const nativeResize = this.nativeIntegration.lifecycle?.resize;
|
|
12095
|
-
if (!resize && nativeResize) {
|
|
12096
|
-
nativeFlags = nativeFlags & ~NativeSceneHook2.Resize | (lineInfo && this.nativeIntegration.lineInfo ? NativeSceneHook2.Resize : 0);
|
|
12097
|
-
}
|
|
12098
|
-
if (nativeFlags & NativeSceneHook2.RenderSelf)
|
|
12099
|
-
nativeFlags |= NativeSceneHook2.RenderAfter;
|
|
12100
|
-
scene.setHooks(this, nativeFlags, generation, this.styledDimension("width"), this.styledDimension("height"));
|
|
12101
|
-
this._nativeSceneHooksRegistered = true;
|
|
12102
|
-
}
|
|
12103
|
-
this._nativeSceneResizeCallbacks = resize ? resizeCallbacks : undefined;
|
|
12104
|
-
this._nativeSceneResize = resize;
|
|
12105
|
-
this._nativeSceneHookFlags = flags;
|
|
12106
|
-
this._nativeSceneHookGeneration = generation;
|
|
11716
|
+
publishHooks(hooks, pending = {}) {
|
|
11717
|
+
if (!this.isFreed()) {
|
|
11718
|
+
const integration = this.nativeIntegration;
|
|
11719
|
+
const resize = this.buffered || hooks.onLayoutResize !== Renderable2.baseHooks.onLayoutResize || this.needsHostResize(hooks.onResize);
|
|
11720
|
+
const sizeChange = "sizeChange" in pending ? pending.sizeChange : this._sizeChangeListener;
|
|
11721
|
+
const lineInfo = pending.lineInfo ?? (!!integration.lineInfo && this.listenerCount("line-info-change") > 0);
|
|
11722
|
+
const flags = (hooks.renderBefore ? NativeSceneHook2.RenderBefore : 0) | (hooks.renderAfter ? NativeSceneHook2.RenderAfter : 0) | (this.usesNativeDrawing(hooks.renderSelf) ? 0 : NativeSceneHook2.RenderSelf) | this.hostUpdateFlags(hooks.onUpdate) | (resize || sizeChange || (pending.resize ?? this.listenerCount("resize")) > 0 ? NativeSceneHook2.Resize : 0) | ((pending.layout ?? this.listenerCount("layout-changed" /* LAYOUT_CHANGED */)) > 0 ? NativeSceneHook2.LayoutChanged : 0);
|
|
11723
|
+
const generation = this._nativeSceneHookGeneration + 1n;
|
|
11724
|
+
if (flags !== 0 || lineInfo || this._nativeSceneHooksRegistered) {
|
|
11725
|
+
let nativeFlags = flags;
|
|
11726
|
+
if (integration.beforeAfter === false)
|
|
11727
|
+
nativeFlags &= ~nativeSceneHookBeforeAfter;
|
|
11728
|
+
if (!resize && integration.lifecycle?.resize) {
|
|
11729
|
+
nativeFlags = nativeFlags & ~NativeSceneHook2.Resize | (lineInfo && integration.lineInfo ? NativeSceneHook2.Resize : 0);
|
|
11730
|
+
}
|
|
11731
|
+
if (nativeFlags & NativeSceneHook2.RenderSelf)
|
|
11732
|
+
nativeFlags |= NativeSceneHook2.RenderAfter;
|
|
11733
|
+
const scene = this._ctx.nativeScene;
|
|
11734
|
+
scene.setHooks(this, nativeFlags, generation, this.styledDimension("width"), this.styledDimension("height"));
|
|
11735
|
+
this._nativeSceneHooksRegistered = true;
|
|
11736
|
+
}
|
|
11737
|
+
this._nativeSceneResize = resize;
|
|
11738
|
+
this._nativeSceneHookGeneration = generation;
|
|
11739
|
+
}
|
|
11740
|
+
this._hooks = hooks;
|
|
12107
11741
|
}
|
|
12108
11742
|
_runNativeSceneHook(request, deltaTime) {
|
|
12109
11743
|
if (this._isDestroyed || request.hookGeneration !== this._nativeSceneHookGeneration)
|
|
12110
11744
|
return;
|
|
12111
|
-
|
|
12112
|
-
|
|
12113
|
-
const currentGeometry = request.geometryRevision === revision;
|
|
12114
|
-
this._nativeSceneHookLayout = { revision, layout: currentGeometry ? request.publicLayout : undefined };
|
|
11745
|
+
this.observeLayout(request.publicLayout);
|
|
11746
|
+
this._paintLayout = request.paintLayout;
|
|
12115
11747
|
try {
|
|
12116
11748
|
switch (request.kind) {
|
|
12117
11749
|
case NativeSceneFrame2.Update:
|
|
12118
|
-
this.onUpdate(deltaTime);
|
|
11750
|
+
this._hooks.onUpdate.call(this, deltaTime);
|
|
12119
11751
|
break;
|
|
12120
11752
|
case NativeSceneFrame2.Resize:
|
|
12121
11753
|
if (this._nativeSceneResize) {
|
|
12122
|
-
this.
|
|
12123
|
-
this._nativeSceneHookLayout.paintRevision = revision;
|
|
12124
|
-
this.onLayoutResize(request.width, request.height);
|
|
11754
|
+
this._hooks.onLayoutResize.call(this, request.width, request.height);
|
|
12125
11755
|
} else {
|
|
12126
11756
|
const resize = this.nativeIntegration.lifecycle?.resize;
|
|
12127
11757
|
if (!resize) {
|
|
@@ -12138,25 +11768,19 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
12138
11768
|
break;
|
|
12139
11769
|
}
|
|
12140
11770
|
} finally {
|
|
12141
|
-
this.
|
|
11771
|
+
this._paintLayout = undefined;
|
|
12142
11772
|
}
|
|
12143
11773
|
}
|
|
12144
|
-
_recordNativeScenePaint(slot, index, deltaTime, frame, recorder,
|
|
11774
|
+
_recordNativeScenePaint(slot, index, deltaTime, frame, recorder, publicLayout) {
|
|
12145
11775
|
if (this._isDestroyed)
|
|
12146
11776
|
return;
|
|
12147
|
-
|
|
12148
|
-
|
|
12149
|
-
this._nativeSceneHookLayout = {
|
|
12150
|
-
revision,
|
|
12151
|
-
layout: geometryRevision === revision ? slot.publicLayout : undefined,
|
|
12152
|
-
paintLayout: slot.paintLayout,
|
|
12153
|
-
paintRevision: revision
|
|
12154
|
-
};
|
|
11777
|
+
this.observeLayout(publicLayout);
|
|
11778
|
+
this._paintLayout = slot.paintLayout;
|
|
12155
11779
|
const buffer = this.nativeIntegration.paintBuffer !== "destination" && this.nativeIntegration.bufferComposition !== "native" && this.buffered && this.frameBuffer ? this.frameBuffer : frame;
|
|
12156
11780
|
try {
|
|
12157
11781
|
if (slot.hooks & NativeSceneHook2.RenderBefore) {
|
|
12158
11782
|
recorder.slot(index, NativeScenePaintPhase2.Before, slot.opacity);
|
|
12159
|
-
this.renderBefore?.call(this, buffer, deltaTime);
|
|
11783
|
+
this._hooks.renderBefore?.call(this, buffer, deltaTime);
|
|
12160
11784
|
if (this._isDestroyed)
|
|
12161
11785
|
return;
|
|
12162
11786
|
}
|
|
@@ -12171,18 +11795,18 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
12171
11795
|
if (slot.hooks & NativeSceneHook2.RenderAfter) {
|
|
12172
11796
|
recorder.slot(index, NativeScenePaintPhase2.After, slot.opacity);
|
|
12173
11797
|
if (this.nativeIntegration.beforeAfter !== false) {
|
|
12174
|
-
this.renderAfter?.call(this, buffer, deltaTime);
|
|
11798
|
+
this._hooks.renderAfter?.call(this, buffer, deltaTime);
|
|
12175
11799
|
this.markClean();
|
|
12176
11800
|
}
|
|
12177
11801
|
if (!this._isDestroyed && this.nativeIntegration.bufferComposition !== "native" && this.buffered && this.frameBuffer)
|
|
12178
11802
|
frame.drawFrameBuffer(Math.trunc(this._screenX), Math.trunc(this._screenY), this.frameBuffer);
|
|
12179
11803
|
}
|
|
12180
11804
|
} finally {
|
|
12181
|
-
this.
|
|
11805
|
+
this._paintLayout = undefined;
|
|
12182
11806
|
}
|
|
12183
11807
|
}
|
|
12184
11808
|
_invokeNativePaint(buffer, deltaTime) {
|
|
12185
|
-
this.renderSelf(buffer, deltaTime);
|
|
11809
|
+
this._hooks.renderSelf.call(this, buffer, deltaTime);
|
|
12186
11810
|
}
|
|
12187
11811
|
get isDestroyed() {
|
|
12188
11812
|
return this._isDestroyed;
|
|
@@ -12416,14 +12040,12 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
12416
12040
|
else
|
|
12417
12041
|
layout += delta;
|
|
12418
12042
|
}
|
|
12419
|
-
this.
|
|
12043
|
+
this.publishHooks(this._hooks, { resize, layout, lineInfo: lineInfo > 0 });
|
|
12420
12044
|
this.runCleanup((run) => {
|
|
12421
12045
|
run(change);
|
|
12422
12046
|
run(() => {
|
|
12423
|
-
if (!this._isDestroyed)
|
|
12424
|
-
|
|
12425
|
-
this.setNativeSceneHooks(flags);
|
|
12426
|
-
}
|
|
12047
|
+
if (!this._isDestroyed)
|
|
12048
|
+
this.publishHooks(this._hooks);
|
|
12427
12049
|
});
|
|
12428
12050
|
});
|
|
12429
12051
|
return this;
|
|
@@ -12508,8 +12130,7 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
12508
12130
|
if (handler !== this._sizeChangeListener) {
|
|
12509
12131
|
if (handler != null && typeof handler !== "function")
|
|
12510
12132
|
throw new TypeError("Invalid size change hook");
|
|
12511
|
-
|
|
12512
|
-
this.setNativeSceneHooks(flags | (handler || this.listenerCount("resize") > 0 ? NativeSceneHook2.Resize : 0));
|
|
12133
|
+
this.publishHooks(this._hooks, { sizeChange: handler });
|
|
12513
12134
|
}
|
|
12514
12135
|
this._sizeChangeListener = handler;
|
|
12515
12136
|
}
|
|
@@ -12534,11 +12155,10 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
12534
12155
|
}
|
|
12535
12156
|
|
|
12536
12157
|
class RootRenderable2 extends Renderable2 {
|
|
12537
|
-
static nativeIntegration =
|
|
12158
|
+
static nativeIntegration = {
|
|
12538
12159
|
...Renderable2.nativeIntegration,
|
|
12539
|
-
kind: "root"
|
|
12540
|
-
|
|
12541
|
-
});
|
|
12160
|
+
kind: "root"
|
|
12161
|
+
};
|
|
12542
12162
|
_currentRenderable;
|
|
12543
12163
|
constructor(ctx) {
|
|
12544
12164
|
super(ctx, {
|
|
@@ -12664,7 +12284,6 @@ function maybeMakeRenderable2(ctx, node) {
|
|
|
12664
12284
|
function wrapWithDelegates2(instance, delegateMap) {
|
|
12665
12285
|
if (!delegateMap || Object.keys(delegateMap).length === 0)
|
|
12666
12286
|
return instance;
|
|
12667
|
-
instance.refreshHooks();
|
|
12668
12287
|
const getDescendant = (id) => {
|
|
12669
12288
|
return instance.findDescendantById(id);
|
|
12670
12289
|
};
|
|
@@ -14225,11 +13844,10 @@ function borderMask(sides) {
|
|
|
14225
13844
|
}
|
|
14226
13845
|
|
|
14227
13846
|
class BoxRenderable2 extends Renderable2 {
|
|
14228
|
-
static nativeIntegration =
|
|
13847
|
+
static nativeIntegration = {
|
|
14229
13848
|
kind: "box",
|
|
14230
|
-
body: { native: this.prototype.renderSelf }
|
|
14231
|
-
|
|
14232
|
-
});
|
|
13849
|
+
body: { native: this.prototype.renderSelf }
|
|
13850
|
+
};
|
|
14233
13851
|
_backgroundColor;
|
|
14234
13852
|
_border;
|
|
14235
13853
|
_borderStyle;
|
|
@@ -14454,8 +14072,8 @@ class BoxRenderable2 extends Renderable2 {
|
|
|
14454
14072
|
buffer.drawBox({
|
|
14455
14073
|
x: screenX,
|
|
14456
14074
|
y: screenY,
|
|
14457
|
-
width: this.
|
|
14458
|
-
height: this.
|
|
14075
|
+
width: this._paintWidth,
|
|
14076
|
+
height: this._paintHeight,
|
|
14459
14077
|
borderStyle: this._borderStyle,
|
|
14460
14078
|
customBorderChars: this._customBorderChars,
|
|
14461
14079
|
border: this._border,
|
|
@@ -14523,16 +14141,31 @@ class BoxRenderable2 extends Renderable2 {
|
|
|
14523
14141
|
}
|
|
14524
14142
|
}
|
|
14525
14143
|
|
|
14144
|
+
// src/lib/scroll-chain.ts
|
|
14145
|
+
var takers = new WeakMap;
|
|
14146
|
+
function wheelDirection(event) {
|
|
14147
|
+
const direction = event.scroll?.direction;
|
|
14148
|
+
if (!direction || !event.modifiers?.shift)
|
|
14149
|
+
return direction;
|
|
14150
|
+
return direction === "up" ? "left" : direction === "down" ? "right" : direction === "right" ? "down" : "up";
|
|
14151
|
+
}
|
|
14152
|
+
function scrollOnce(event, scroller, scroll) {
|
|
14153
|
+
for (let node = takers.get(event) ?? null;node; node = node.parent)
|
|
14154
|
+
if (node === scroller)
|
|
14155
|
+
return;
|
|
14156
|
+
if (scroll())
|
|
14157
|
+
takers.set(event, scroller);
|
|
14158
|
+
}
|
|
14159
|
+
|
|
14526
14160
|
// src/renderables/TextBufferRenderable.ts
|
|
14527
14161
|
class TextBufferRenderable2 extends Renderable2 {
|
|
14528
|
-
static nativeIntegration =
|
|
14162
|
+
static nativeIntegration = {
|
|
14529
14163
|
kind: "text",
|
|
14530
14164
|
body: { native: this.prototype.renderSelf },
|
|
14531
14165
|
lifecycle: { resize: { native: this.prototype.onResize } },
|
|
14532
14166
|
beforeAfter: false,
|
|
14533
|
-
paintBuffer: "destination"
|
|
14534
|
-
|
|
14535
|
-
});
|
|
14167
|
+
paintBuffer: "destination"
|
|
14168
|
+
};
|
|
14536
14169
|
_defaultFg;
|
|
14537
14170
|
_defaultBg;
|
|
14538
14171
|
_defaultAttributes;
|
|
@@ -14549,7 +14182,6 @@ class TextBufferRenderable2 extends Renderable2 {
|
|
|
14549
14182
|
_firstLineOffset = 0;
|
|
14550
14183
|
textBuffer;
|
|
14551
14184
|
textBufferView;
|
|
14552
|
-
_textBufferSyntaxStyle;
|
|
14553
14185
|
nativeTextScene;
|
|
14554
14186
|
_defaultOptions = {
|
|
14555
14187
|
fg: RGBA2.fromValues(1, 1, 1, 1),
|
|
@@ -14569,7 +14201,6 @@ class TextBufferRenderable2 extends Renderable2 {
|
|
|
14569
14201
|
this.nativeTextScene = sharedText ? undefined : ctx.nativeScene;
|
|
14570
14202
|
let textBuffer;
|
|
14571
14203
|
let textBufferView;
|
|
14572
|
-
let syntaxStyle;
|
|
14573
14204
|
try {
|
|
14574
14205
|
this._defaultFg = RGBA2.clone(parseColor2(options.fg ?? this._defaultOptions.fg));
|
|
14575
14206
|
this._defaultBg = RGBA2.clone(parseColor2(options.bg ?? this._defaultOptions.bg));
|
|
@@ -14593,9 +14224,6 @@ class TextBufferRenderable2 extends Renderable2 {
|
|
|
14593
14224
|
textBufferView = TextBufferView2.create(textBuffer);
|
|
14594
14225
|
this.textBufferView = textBufferView;
|
|
14595
14226
|
this._firstLineOffset = ctx.claimFirstLineOffset?.(this) ?? 0;
|
|
14596
|
-
syntaxStyle = SyntaxStyle2.create(ctx.nativeScene);
|
|
14597
|
-
this._textBufferSyntaxStyle = syntaxStyle;
|
|
14598
|
-
textBuffer.setSyntaxStyle(syntaxStyle);
|
|
14599
14227
|
this.textBufferView.setWrapMode(this._wrapMode);
|
|
14600
14228
|
this.textBufferView.setTextAlign(this._textAlign);
|
|
14601
14229
|
this.textBufferView.setFirstLineOffset(this._firstLineOffset);
|
|
@@ -14616,8 +14244,6 @@ class TextBufferRenderable2 extends Renderable2 {
|
|
|
14616
14244
|
this.updateTextInfo();
|
|
14617
14245
|
} catch (error) {
|
|
14618
14246
|
this.abortConstruction(error, (run) => {
|
|
14619
|
-
run(() => textBuffer?.setSyntaxStyle(null));
|
|
14620
|
-
run(() => syntaxStyle?.destroy());
|
|
14621
14247
|
run(() => textBufferView?.destroy());
|
|
14622
14248
|
run(() => textBuffer?.destroy());
|
|
14623
14249
|
});
|
|
@@ -14625,13 +14251,18 @@ class TextBufferRenderable2 extends Renderable2 {
|
|
|
14625
14251
|
}
|
|
14626
14252
|
onMouseEvent(event) {
|
|
14627
14253
|
if (event.type === "scroll") {
|
|
14628
|
-
this
|
|
14254
|
+
scrollOnce(event, this, () => {
|
|
14255
|
+
const [x, y] = [this.scrollX, this.scrollY];
|
|
14256
|
+
this.handleScroll(event);
|
|
14257
|
+
return this.scrollX !== x || this.scrollY !== y;
|
|
14258
|
+
});
|
|
14629
14259
|
}
|
|
14630
14260
|
}
|
|
14631
14261
|
handleScroll(event) {
|
|
14632
14262
|
if (!event.scroll)
|
|
14633
14263
|
return;
|
|
14634
|
-
const {
|
|
14264
|
+
const { delta } = event.scroll;
|
|
14265
|
+
const direction = wheelDirection(event);
|
|
14635
14266
|
if (direction === "up") {
|
|
14636
14267
|
this.scrollY -= delta;
|
|
14637
14268
|
} else if (direction === "down") {
|
|
@@ -14981,8 +14612,6 @@ class TextBufferRenderable2 extends Renderable2 {
|
|
|
14981
14612
|
if (this.nativeTextScene)
|
|
14982
14613
|
return;
|
|
14983
14614
|
this.runCleanup((run) => {
|
|
14984
|
-
run(() => this.textBuffer.setSyntaxStyle(null));
|
|
14985
|
-
run(() => this._textBufferSyntaxStyle.destroy());
|
|
14986
14615
|
run(() => this.textBufferView.destroy());
|
|
14987
14616
|
run(() => this.textBuffer.destroy());
|
|
14988
14617
|
});
|
|
@@ -15010,7 +14639,7 @@ class TextBufferRenderable2 extends Renderable2 {
|
|
|
15010
14639
|
|
|
15011
14640
|
// src/renderables/Code.ts
|
|
15012
14641
|
class CodeRenderable2 extends TextBufferRenderable2 {
|
|
15013
|
-
static nativeIntegration =
|
|
14642
|
+
static nativeIntegration = {
|
|
15014
14643
|
...TextBufferRenderable2.nativeIntegration,
|
|
15015
14644
|
kind: "text_view",
|
|
15016
14645
|
body: { native: this.prototype.renderSelf },
|
|
@@ -15021,7 +14650,7 @@ class CodeRenderable2 extends TextBufferRenderable2 {
|
|
|
15021
14650
|
active: (renderable) => renderable._highlightsDirty
|
|
15022
14651
|
}
|
|
15023
14652
|
}
|
|
15024
|
-
}
|
|
14653
|
+
};
|
|
15025
14654
|
_content;
|
|
15026
14655
|
_filetype;
|
|
15027
14656
|
_syntaxStyle;
|
|
@@ -16189,12 +15818,11 @@ function pixelResolution(ctx) {
|
|
|
16189
15818
|
}
|
|
16190
15819
|
|
|
16191
15820
|
class ImageRenderable2 extends Renderable2 {
|
|
16192
|
-
static nativeIntegration =
|
|
15821
|
+
static nativeIntegration = {
|
|
16193
15822
|
kind: "image",
|
|
16194
15823
|
body: { native: this.prototype.renderSelf, buffered: true },
|
|
16195
|
-
bufferComposition: "native"
|
|
16196
|
-
|
|
16197
|
-
});
|
|
15824
|
+
bufferComposition: "native"
|
|
15825
|
+
};
|
|
16198
15826
|
_source;
|
|
16199
15827
|
_image = null;
|
|
16200
15828
|
_pendingImage = null;
|
|
@@ -16335,15 +15963,17 @@ class ImageRenderable2 extends Renderable2 {
|
|
|
16335
15963
|
}
|
|
16336
15964
|
}
|
|
16337
15965
|
renderSelf(buffer) {
|
|
16338
|
-
|
|
15966
|
+
const width = this._paintWidth;
|
|
15967
|
+
const height = this._paintHeight;
|
|
15968
|
+
if (!this._image || width <= 0 || height <= 0)
|
|
16339
15969
|
return;
|
|
16340
|
-
const fitted = this._fit === "cover" ? { width
|
|
15970
|
+
const fitted = this._fit === "cover" ? { width, height } : this.getFittedSize(width, height);
|
|
16341
15971
|
if (fitted.width <= 0 || fitted.height <= 0)
|
|
16342
15972
|
return;
|
|
16343
15973
|
const originX = this.buffered ? 0 : this._screenX;
|
|
16344
15974
|
const originY = this.buffered ? 0 : this._screenY;
|
|
16345
|
-
const x = originX + Math.floor((
|
|
16346
|
-
const y = originY + Math.floor((
|
|
15975
|
+
const x = originX + Math.floor((width - fitted.width) / 2);
|
|
15976
|
+
const y = originY + Math.floor((height - fitted.height) / 2);
|
|
16347
15977
|
const resolution = pixelResolution(this._ctx);
|
|
16348
15978
|
const pixelWidth = resolution ? Math.max(1, Math.round(fitted.width * resolution.width / this._ctx.terminalWidth)) : 0;
|
|
16349
15979
|
const pixelHeight = resolution ? Math.max(1, Math.round(fitted.height * resolution.height / this._ctx.terminalHeight)) : 0;
|
|
@@ -16352,7 +15982,7 @@ class ImageRenderable2 extends Renderable2 {
|
|
|
16352
15982
|
let sourceWidth = this._image.width;
|
|
16353
15983
|
let sourceHeight = this._image.height;
|
|
16354
15984
|
if (this._fit === "cover") {
|
|
16355
|
-
const targetAspect =
|
|
15985
|
+
const targetAspect = width / (height * this.cellAspectRatio);
|
|
16356
15986
|
const sourceAspect = sourceWidth / sourceHeight;
|
|
16357
15987
|
if (sourceAspect > targetAspect) {
|
|
16358
15988
|
sourceWidth = Math.max(1, Math.round(sourceHeight * targetAspect));
|
|
@@ -16738,10 +16368,10 @@ class RootTextNodeRenderable2 extends TextNodeRenderable2 {
|
|
|
16738
16368
|
|
|
16739
16369
|
// src/renderables/Text.ts
|
|
16740
16370
|
class TextRenderable2 extends TextBufferRenderable2 {
|
|
16741
|
-
static nativeIntegration =
|
|
16371
|
+
static nativeIntegration = {
|
|
16742
16372
|
...TextBufferRenderable2.nativeIntegration,
|
|
16743
16373
|
lineInfo: true
|
|
16744
|
-
}
|
|
16374
|
+
};
|
|
16745
16375
|
_text;
|
|
16746
16376
|
_hasManualStyledText = false;
|
|
16747
16377
|
rootTextNode;
|
|
@@ -18859,7 +18489,7 @@ function isEditBufferRenderable2(obj) {
|
|
|
18859
18489
|
}
|
|
18860
18490
|
|
|
18861
18491
|
class EditBufferRenderable2 extends Renderable2 {
|
|
18862
|
-
static nativeIntegration =
|
|
18492
|
+
static nativeIntegration = {
|
|
18863
18493
|
kind: "editor",
|
|
18864
18494
|
body: { native: this.prototype.renderSelf },
|
|
18865
18495
|
lifecycle: {
|
|
@@ -18871,9 +18501,8 @@ class EditBufferRenderable2 extends Renderable2 {
|
|
|
18871
18501
|
},
|
|
18872
18502
|
beforeAfter: false,
|
|
18873
18503
|
paintBuffer: "destination",
|
|
18874
|
-
bufferComposition: "native"
|
|
18875
|
-
|
|
18876
|
-
});
|
|
18504
|
+
bufferComposition: "native"
|
|
18505
|
+
};
|
|
18877
18506
|
[BrandedEditBufferRenderable] = true;
|
|
18878
18507
|
static defaultFocusable = true;
|
|
18879
18508
|
_traits = {};
|
|
@@ -19013,7 +18642,7 @@ class EditBufferRenderable2 extends Renderable2 {
|
|
|
19013
18642
|
return this.editorView.getVisualCursor();
|
|
19014
18643
|
}
|
|
19015
18644
|
get cursorOffset() {
|
|
19016
|
-
return this.
|
|
18645
|
+
return this.editorView.isDestroyed ? emptyVisualCursor.offset : this.editBuffer.getCursorPosition().offset;
|
|
19017
18646
|
}
|
|
19018
18647
|
set cursorOffset(offset) {
|
|
19019
18648
|
this.clearSelection();
|
|
@@ -19195,13 +18824,19 @@ class EditBufferRenderable2 extends Renderable2 {
|
|
|
19195
18824
|
}
|
|
19196
18825
|
onMouseEvent(event) {
|
|
19197
18826
|
if (event.type === "scroll") {
|
|
19198
|
-
this
|
|
18827
|
+
scrollOnce(event, this, () => {
|
|
18828
|
+
const before = this.editorView.getViewport();
|
|
18829
|
+
this.handleScroll(event);
|
|
18830
|
+
const after = this.editorView.getViewport();
|
|
18831
|
+
return after.offsetX !== before.offsetX || after.offsetY !== before.offsetY;
|
|
18832
|
+
});
|
|
19199
18833
|
}
|
|
19200
18834
|
}
|
|
19201
18835
|
handleScroll(event) {
|
|
19202
18836
|
if (!event.scroll)
|
|
19203
18837
|
return;
|
|
19204
|
-
const {
|
|
18838
|
+
const { delta } = event.scroll;
|
|
18839
|
+
const direction = wheelDirection(event);
|
|
19205
18840
|
const viewport = this.editorView.getViewport();
|
|
19206
18841
|
if (direction === "up") {
|
|
19207
18842
|
const newOffsetY = Math.max(0, viewport.offsetY - delta);
|
|
@@ -19220,7 +18855,8 @@ class EditBufferRenderable2 extends Renderable2 {
|
|
|
19220
18855
|
this.editorView.setViewport(newOffsetX, viewport.offsetY, viewport.width, viewport.height, true);
|
|
19221
18856
|
this.requestRender();
|
|
19222
18857
|
} else if (direction === "right") {
|
|
19223
|
-
const
|
|
18858
|
+
const maxOffsetX = Math.max(0, this.lineInfo.lineWidthColsMax - viewport.width);
|
|
18859
|
+
const newOffsetX = Math.min(viewport.offsetX + delta, Math.max(viewport.offsetX, maxOffsetX));
|
|
19224
18860
|
this.editorView.setViewport(newOffsetX, viewport.offsetY, viewport.width, viewport.height, true);
|
|
19225
18861
|
this.requestRender();
|
|
19226
18862
|
}
|
|
@@ -19871,7 +19507,6 @@ class NativeLifecyclePasses extends Set {
|
|
|
19871
19507
|
class NativeScene {
|
|
19872
19508
|
driver;
|
|
19873
19509
|
renderer;
|
|
19874
|
-
workBudget;
|
|
19875
19510
|
get resourceContext() {
|
|
19876
19511
|
return this.driver.resourceContext;
|
|
19877
19512
|
}
|
|
@@ -19880,27 +19515,19 @@ class NativeScene {
|
|
|
19880
19515
|
nodes = new Map;
|
|
19881
19516
|
paintedFrame = null;
|
|
19882
19517
|
paintRecording;
|
|
19883
|
-
cancelPaintYield = null;
|
|
19884
19518
|
destroyed = false;
|
|
19885
19519
|
destroying = false;
|
|
19886
|
-
geometryRevision = 0;
|
|
19887
19520
|
layoutRevision = 0;
|
|
19888
19521
|
staging = new SceneStaging;
|
|
19889
|
-
hookScans = new Set;
|
|
19890
|
-
scanningHooks = false;
|
|
19891
19522
|
yogaHost;
|
|
19892
|
-
constructor(driver, renderer
|
|
19523
|
+
constructor(driver, renderer) {
|
|
19893
19524
|
this.driver = driver;
|
|
19894
19525
|
this.renderer = renderer;
|
|
19895
|
-
this.workBudget = workBudget;
|
|
19896
19526
|
this.yogaHost = driver.renderLib.getYogaHost();
|
|
19897
19527
|
}
|
|
19898
19528
|
get frame() {
|
|
19899
19529
|
return this.paintedFrame;
|
|
19900
19530
|
}
|
|
19901
|
-
get currentGeometryRevision() {
|
|
19902
|
-
return this.geometryRevision;
|
|
19903
|
-
}
|
|
19904
19531
|
get observedLayoutRevision() {
|
|
19905
19532
|
if (this.yogaHost.inCallback || this.destroyed || this.driver.disposed)
|
|
19906
19533
|
return;
|
|
@@ -19909,10 +19536,6 @@ class NativeScene {
|
|
|
19909
19536
|
get stopped() {
|
|
19910
19537
|
return this.destroyed || this.destroying || this.driver.disposed || this.renderer.isDestroyed;
|
|
19911
19538
|
}
|
|
19912
|
-
changeGeometry() {
|
|
19913
|
-
this.geometryRevision = this.geometryRevision === Number.MAX_SAFE_INTEGER ? 0 : this.geometryRevision + 1;
|
|
19914
|
-
this.changeLayout();
|
|
19915
|
-
}
|
|
19916
19539
|
changeLayout() {
|
|
19917
19540
|
this.layoutRevision = this.layoutRevision === Number.MAX_SAFE_INTEGER ? 0 : this.layoutRevision + 1;
|
|
19918
19541
|
}
|
|
@@ -19938,54 +19561,6 @@ class NativeScene {
|
|
|
19938
19561
|
this.yogaHost.forgetScene(this);
|
|
19939
19562
|
}
|
|
19940
19563
|
}
|
|
19941
|
-
scheduleHookScan(renderable) {
|
|
19942
|
-
if (this.stopped)
|
|
19943
|
-
return;
|
|
19944
|
-
this.hookScans.add(renderable);
|
|
19945
|
-
}
|
|
19946
|
-
refreshPendingHooks(renderable) {
|
|
19947
|
-
if (this.scanningHooks || !this.hookScans.has(renderable))
|
|
19948
|
-
return;
|
|
19949
|
-
this.scanningHooks = true;
|
|
19950
|
-
try {
|
|
19951
|
-
renderable._scanNativeSceneHooks();
|
|
19952
|
-
} finally {
|
|
19953
|
-
this.scanningHooks = false;
|
|
19954
|
-
}
|
|
19955
|
-
}
|
|
19956
|
-
drainHookScans() {
|
|
19957
|
-
if (this.scanningHooks)
|
|
19958
|
-
throw new Error("Native scene hook discovery is already active");
|
|
19959
|
-
if (this.hookScans.size === 0)
|
|
19960
|
-
return;
|
|
19961
|
-
this.scanningHooks = true;
|
|
19962
|
-
let visits = 0;
|
|
19963
|
-
try {
|
|
19964
|
-
while (this.hookScans.size !== 0) {
|
|
19965
|
-
const pending = this.hookScans;
|
|
19966
|
-
this.hookScans = new Set;
|
|
19967
|
-
try {
|
|
19968
|
-
for (const renderable of pending) {
|
|
19969
|
-
if (this.stopped)
|
|
19970
|
-
return;
|
|
19971
|
-
if (++visits > maxHostRequests)
|
|
19972
|
-
throw new Error("Native scene hook discovery work limit exceeded");
|
|
19973
|
-
renderable._scanNativeSceneHooks();
|
|
19974
|
-
pending.delete(renderable);
|
|
19975
|
-
}
|
|
19976
|
-
} catch (error) {
|
|
19977
|
-
if (!this.stopped) {
|
|
19978
|
-
for (const renderable of this.hookScans)
|
|
19979
|
-
pending.add(renderable);
|
|
19980
|
-
this.hookScans = pending;
|
|
19981
|
-
}
|
|
19982
|
-
throw error;
|
|
19983
|
-
}
|
|
19984
|
-
}
|
|
19985
|
-
} finally {
|
|
19986
|
-
this.scanningHooks = false;
|
|
19987
|
-
}
|
|
19988
|
-
}
|
|
19989
19564
|
getRenderables() {
|
|
19990
19565
|
return this.nodes.values();
|
|
19991
19566
|
}
|
|
@@ -20016,7 +19591,7 @@ class NativeScene {
|
|
|
20016
19591
|
const handle = child._getSceneHandle(this);
|
|
20017
19592
|
const parentHandle = parent?._getSceneHandle(this) ?? null;
|
|
20018
19593
|
this.driver.renderLib.sceneMoveNode(this.driver.context, handle, parentHandle, index);
|
|
20019
|
-
this.
|
|
19594
|
+
this.changeLayout();
|
|
20020
19595
|
}
|
|
20021
19596
|
setViewport(content, viewport) {
|
|
20022
19597
|
this.flushStaged();
|
|
@@ -20040,10 +19615,9 @@ class NativeScene {
|
|
|
20040
19615
|
this.staging.discard(handle);
|
|
20041
19616
|
if (!this.staging.pending)
|
|
20042
19617
|
this.yogaHost.forgetScene(this);
|
|
20043
|
-
this.
|
|
19618
|
+
this.changeLayout();
|
|
20044
19619
|
renderable._releaseSceneHandle();
|
|
20045
19620
|
this.nodes.delete(renderable.num);
|
|
20046
|
-
this.hookScans.delete(renderable);
|
|
20047
19621
|
this.renderer.unregisterLifecyclePass(renderable);
|
|
20048
19622
|
} catch (error) {
|
|
20049
19623
|
if (flushFailure) {
|
|
@@ -20066,7 +19640,6 @@ class NativeScene {
|
|
|
20066
19640
|
if (this.staging.stageStyle(this.driver.context, handle, group, kind, edge, unit, value, flags)) {
|
|
20067
19641
|
this.yogaHost.stageScene(this);
|
|
20068
19642
|
}
|
|
20069
|
-
this.changeGeometry();
|
|
20070
19643
|
}
|
|
20071
19644
|
getStyle(node, group, kind, edge) {
|
|
20072
19645
|
const handle = node._getSceneHandle(this);
|
|
@@ -20106,7 +19679,9 @@ class NativeScene {
|
|
|
20106
19679
|
this.flushStaged();
|
|
20107
19680
|
if (this.staging.stagePaint(this.driver.context, handle, paint, renderable))
|
|
20108
19681
|
this.yogaHost.stageScene(this);
|
|
20109
|
-
|
|
19682
|
+
const { translateX = renderable.translateX, translateY = renderable.translateY } = paint;
|
|
19683
|
+
if (translateX !== renderable.translateX || translateY !== renderable.translateY)
|
|
19684
|
+
this.changeLayout();
|
|
20110
19685
|
}
|
|
20111
19686
|
setBackground(renderable, color) {
|
|
20112
19687
|
this.yogaHost.assertMutable();
|
|
@@ -20229,9 +19804,7 @@ class NativeScene {
|
|
|
20229
19804
|
if (!attached)
|
|
20230
19805
|
owner.add(root);
|
|
20231
19806
|
try {
|
|
20232
|
-
this.drainHookScans();
|
|
20233
19807
|
this.runLifecyclePasses();
|
|
20234
|
-
this.drainHookScans();
|
|
20235
19808
|
this.assertAlive();
|
|
20236
19809
|
this.flushStaged();
|
|
20237
19810
|
try {
|
|
@@ -20248,14 +19821,11 @@ class NativeScene {
|
|
|
20248
19821
|
paint(deltaTime, getPaintOptions) {
|
|
20249
19822
|
this.yogaHost.assertMutable();
|
|
20250
19823
|
this.assertAlive();
|
|
20251
|
-
if (this.
|
|
19824
|
+
if (this.paintedFrame)
|
|
20252
19825
|
throw new Error("Native scene is already painting a frame");
|
|
20253
19826
|
this.renderer.root._setCurrentRenderable(undefined);
|
|
20254
|
-
this.drainHookScans();
|
|
20255
19827
|
this.runLifecyclePasses();
|
|
20256
|
-
|
|
20257
|
-
if (continuation)
|
|
20258
|
-
return this.resumePaint(deltaTime, getPaintOptions, continuation);
|
|
19828
|
+
this.advancePaint(deltaTime, getPaintOptions);
|
|
20259
19829
|
}
|
|
20260
19830
|
runLifecyclePasses() {
|
|
20261
19831
|
if (this.renderer.root.visible) {
|
|
@@ -20268,67 +19838,29 @@ class NativeScene {
|
|
|
20268
19838
|
if (!renderable.isDestroyed) {
|
|
20269
19839
|
renderable.onLifecyclePass?.call(renderable);
|
|
20270
19840
|
}
|
|
20271
|
-
this.drainHookScans();
|
|
20272
|
-
}
|
|
20273
|
-
}
|
|
20274
|
-
}
|
|
20275
|
-
async resumePaint(deltaTime, getPaintOptions, continuation) {
|
|
20276
|
-
while (continuation) {
|
|
20277
|
-
await continuation.wait;
|
|
20278
|
-
this.cancelPaintYield = null;
|
|
20279
|
-
if (continuation.interrupted === "restart") {
|
|
20280
|
-
this.cancelAttempt(continuation.request);
|
|
20281
|
-
this.drainHookScans();
|
|
20282
|
-
this.runLifecyclePasses();
|
|
20283
|
-
continuation = undefined;
|
|
20284
19841
|
}
|
|
20285
|
-
continuation = this.advancePaint(deltaTime, getPaintOptions, continuation);
|
|
20286
19842
|
}
|
|
20287
19843
|
}
|
|
20288
|
-
advancePaint(deltaTime, getPaintOptions
|
|
20289
|
-
let request =
|
|
19844
|
+
advancePaint(deltaTime, getPaintOptions) {
|
|
19845
|
+
let request = null;
|
|
20290
19846
|
let recording = null;
|
|
20291
|
-
let yielded = false;
|
|
20292
19847
|
try {
|
|
20293
|
-
while (
|
|
20294
|
-
this.drainHookScans();
|
|
19848
|
+
while (!this.stopped) {
|
|
20295
19849
|
const options = { ...getPaintOptions(), maxLayoutRounds, maxHostRequests };
|
|
20296
19850
|
if (this.stopped || this.renderer.controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */)
|
|
20297
19851
|
return;
|
|
20298
19852
|
this.flushStaged();
|
|
20299
|
-
const geometryRevision = this.geometryRevision;
|
|
20300
19853
|
try {
|
|
20301
|
-
request = this.driver.renderLib.sceneFrameStep(this.driver.context, this.driver.session, request, options,
|
|
19854
|
+
request = this.driver.renderLib.sceneFrameStep(this.driver.context, this.driver.session, request, options, recording);
|
|
20302
19855
|
} finally {
|
|
20303
19856
|
this.changeLayout();
|
|
20304
19857
|
this.paintRecording?.recorder.settle();
|
|
20305
19858
|
}
|
|
20306
19859
|
recording = null;
|
|
20307
|
-
request.geometryRevision = geometryRevision;
|
|
20308
19860
|
if (request.kind === NativeSceneFrame2.Done) {
|
|
20309
19861
|
this.paintedFrame = request;
|
|
20310
19862
|
return;
|
|
20311
19863
|
}
|
|
20312
|
-
if (request.kind === NativeSceneFrame2.Yield) {
|
|
20313
|
-
const wait = Promise.withResolvers();
|
|
20314
|
-
const state = continuation ?? { request, wait: wait.promise };
|
|
20315
|
-
state.request = request;
|
|
20316
|
-
state.wait = wait.promise;
|
|
20317
|
-
const cancel = this.driver.scheduler.schedule(wait.resolve);
|
|
20318
|
-
this.cancelPaintYield = (restart = false) => {
|
|
20319
|
-
const first = state.interrupted === undefined;
|
|
20320
|
-
state.interrupted = restart && state.interrupted !== "cancel" ? "restart" : "cancel";
|
|
20321
|
-
if (!first)
|
|
20322
|
-
return;
|
|
20323
|
-
try {
|
|
20324
|
-
cancel();
|
|
20325
|
-
} finally {
|
|
20326
|
-
wait.resolve();
|
|
20327
|
-
}
|
|
20328
|
-
};
|
|
20329
|
-
yielded = true;
|
|
20330
|
-
return state;
|
|
20331
|
-
}
|
|
20332
19864
|
if (!sameHandle(request.session, this.driver.session) || !sameHandle(request.root, this.renderer.root._getSceneHandle(this))) {
|
|
20333
19865
|
throw new Error("Native scene returned a stale host request");
|
|
20334
19866
|
}
|
|
@@ -20346,7 +19878,7 @@ class NativeScene {
|
|
|
20346
19878
|
}
|
|
20347
19879
|
} finally {
|
|
20348
19880
|
this.paintRecording?.recorder.settle();
|
|
20349
|
-
if (
|
|
19881
|
+
if (request && request !== this.paintedFrame)
|
|
20350
19882
|
this.cancelAttempt(request);
|
|
20351
19883
|
}
|
|
20352
19884
|
}
|
|
@@ -20362,6 +19894,7 @@ class NativeScene {
|
|
|
20362
19894
|
const { renderLib: lib, context, session } = this.driver;
|
|
20363
19895
|
const slots = lib.sceneFrameGetPaintSlots(context, session, request);
|
|
20364
19896
|
const paint = this.paintRecording ??= this.createPaintRecording();
|
|
19897
|
+
const revision = this.layoutRevision;
|
|
20365
19898
|
paint.recorder.begin(context);
|
|
20366
19899
|
try {
|
|
20367
19900
|
for (let index = 0;index < slots.length; index++) {
|
|
@@ -20375,7 +19908,7 @@ class NativeScene {
|
|
|
20375
19908
|
throw new Error("Native scene returned a stale paint slot");
|
|
20376
19909
|
}
|
|
20377
19910
|
this.renderer.root._setCurrentRenderable(renderable);
|
|
20378
|
-
renderable._recordNativeScenePaint(slot, index, deltaTime, paint.buffer, paint.recorder,
|
|
19911
|
+
renderable._recordNativeScenePaint(slot, index, deltaTime, paint.buffer, paint.recorder, this.layoutRevision === revision ? slot.publicLayout : undefined);
|
|
20379
19912
|
this.renderer.root._setCurrentRenderable(undefined);
|
|
20380
19913
|
}
|
|
20381
19914
|
return paint.recorder.recording;
|
|
@@ -20405,18 +19938,11 @@ class NativeScene {
|
|
|
20405
19938
|
return result;
|
|
20406
19939
|
}
|
|
20407
19940
|
cancelFrame() {
|
|
20408
|
-
this.cancelPaintYield?.();
|
|
20409
19941
|
const frame = this.paintedFrame;
|
|
20410
19942
|
this.paintedFrame = null;
|
|
20411
19943
|
if (frame)
|
|
20412
19944
|
this.cancelAttempt(frame);
|
|
20413
19945
|
}
|
|
20414
|
-
interruptPaint() {
|
|
20415
|
-
this.cancelPaintYield?.();
|
|
20416
|
-
}
|
|
20417
|
-
restartPaint() {
|
|
20418
|
-
this.cancelPaintYield?.(true);
|
|
20419
|
-
}
|
|
20420
19946
|
hitTest(x, y) {
|
|
20421
19947
|
this.assertAlive();
|
|
20422
19948
|
const id = this.driver.renderLib.sceneHitTest(this.driver.context, this.driver.session, x, y);
|
|
@@ -20430,14 +19956,8 @@ class NativeScene {
|
|
|
20430
19956
|
this.destroying = true;
|
|
20431
19957
|
this.staging.clear();
|
|
20432
19958
|
this.yogaHost.forgetScene(this);
|
|
20433
|
-
this.hookScans.clear();
|
|
20434
19959
|
let failure;
|
|
20435
19960
|
try {
|
|
20436
|
-
try {
|
|
20437
|
-
this.cancelPaintYield?.();
|
|
20438
|
-
} catch (error) {
|
|
20439
|
-
failure = { error };
|
|
20440
|
-
}
|
|
20441
19961
|
for (const renderable of this.nodes.values()) {
|
|
20442
19962
|
try {
|
|
20443
19963
|
renderable.destroyRecursively();
|
|
@@ -20629,6 +20149,492 @@ function parsePixelResolution(sequence) {
|
|
|
20629
20149
|
return null;
|
|
20630
20150
|
}
|
|
20631
20151
|
|
|
20152
|
+
// src/lib/stdin-parser-native.ts
|
|
20153
|
+
import { Buffer as Buffer4 } from "node:buffer";
|
|
20154
|
+
var RECORD_CAPACITY = 64;
|
|
20155
|
+
var PAYLOAD_CAPACITY = 16 * 1024;
|
|
20156
|
+
var RECORD = nativeLayouts.ot_input_event;
|
|
20157
|
+
var FIELD = {
|
|
20158
|
+
kind: RECORD.fields.kind.offset,
|
|
20159
|
+
action: RECORD.fields.action.offset,
|
|
20160
|
+
modifiers: RECORD.fields.modifiers.offset,
|
|
20161
|
+
flags: RECORD.fields.flags.offset,
|
|
20162
|
+
code: RECORD.fields.code.offset / 4,
|
|
20163
|
+
baseCode: RECORD.fields.base_code.offset / 4,
|
|
20164
|
+
x: RECORD.fields.x.offset / 2,
|
|
20165
|
+
y: RECORD.fields.y.offset / 2,
|
|
20166
|
+
rawOffset: RECORD.fields.raw_offset.offset / 4,
|
|
20167
|
+
rawLength: RECORD.fields.raw_len.offset / 4,
|
|
20168
|
+
textOffset: RECORD.fields.text_offset.offset / 4,
|
|
20169
|
+
textLength: RECORD.fields.text_len.offset / 4
|
|
20170
|
+
};
|
|
20171
|
+
var C = nativeConstants;
|
|
20172
|
+
var EMPTY = new Uint8Array(0);
|
|
20173
|
+
var UTF8 = new TextDecoder;
|
|
20174
|
+
var MOUSE_TYPES = {
|
|
20175
|
+
[C.OT_INPUT_MOUSE_DOWN]: "down",
|
|
20176
|
+
[C.OT_INPUT_MOUSE_UP]: "up",
|
|
20177
|
+
[C.OT_INPUT_MOUSE_MOVE]: "move",
|
|
20178
|
+
[C.OT_INPUT_MOUSE_DRAG]: "drag",
|
|
20179
|
+
[C.OT_INPUT_MOUSE_SCROLL]: "scroll"
|
|
20180
|
+
};
|
|
20181
|
+
var SCROLL_DIRECTIONS = ["up", "down", "left", "right"];
|
|
20182
|
+
var NO_EXPECTATIONS = {
|
|
20183
|
+
kittyKeyboardEnabled: false,
|
|
20184
|
+
privateCapabilityRepliesActive: false,
|
|
20185
|
+
pixelResolutionQueryActive: false,
|
|
20186
|
+
explicitWidthCprActive: false,
|
|
20187
|
+
startupCursorCprActive: false
|
|
20188
|
+
};
|
|
20189
|
+
var REPLY_PROTOCOLS = {
|
|
20190
|
+
[C.OT_INPUT_REPLY_CSI]: "csi",
|
|
20191
|
+
[C.OT_INPUT_REPLY_SS3]: "unknown",
|
|
20192
|
+
[C.OT_INPUT_REPLY_OSC]: "osc",
|
|
20193
|
+
[C.OT_INPUT_REPLY_DCS]: "dcs",
|
|
20194
|
+
[C.OT_INPUT_REPLY_APC]: "apc"
|
|
20195
|
+
};
|
|
20196
|
+
var LEGACY_CODE_RE = /^\x1b+(O|\[\[?)(?:(\d+)(?:;\d+)?([~^$])|(?:1;)?\d*([a-zA-Z]))/;
|
|
20197
|
+
var LEGACY_SEQUENCE_RE = /^\x1b\x1b?[[O]./s;
|
|
20198
|
+
var KEYPAD_TEXT = new Set(Object.values(printableKeypadText));
|
|
20199
|
+
function concat(parts) {
|
|
20200
|
+
let length = 0;
|
|
20201
|
+
for (const part of parts)
|
|
20202
|
+
length += part.length;
|
|
20203
|
+
const bytes = new Uint8Array(length);
|
|
20204
|
+
let offset = 0;
|
|
20205
|
+
for (const part of parts) {
|
|
20206
|
+
bytes.set(part, offset);
|
|
20207
|
+
offset += part.length;
|
|
20208
|
+
}
|
|
20209
|
+
return bytes;
|
|
20210
|
+
}
|
|
20211
|
+
function latin1(bytes) {
|
|
20212
|
+
return Buffer4.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("latin1");
|
|
20213
|
+
}
|
|
20214
|
+
function expectationFlags(context) {
|
|
20215
|
+
const cursorPosition = context.explicitWidthCprActive || context.startupCursorCprActive;
|
|
20216
|
+
const replies = context.privateCapabilityRepliesActive || context.pixelResolutionQueryActive || cursorPosition;
|
|
20217
|
+
return (replies ? C.OT_INPUT_EXPECT_REPLIES : 0) | (context.kittyKeyboardEnabled ? C.OT_INPUT_EXPECT_KITTY_KEYBOARD : 0) | (cursorPosition ? C.OT_INPUT_EXPECT_CURSOR_POSITION : 0);
|
|
20218
|
+
}
|
|
20219
|
+
|
|
20220
|
+
class NativeStdinParser {
|
|
20221
|
+
lib;
|
|
20222
|
+
context;
|
|
20223
|
+
session;
|
|
20224
|
+
ownsContext;
|
|
20225
|
+
records = new Uint8Array(RECORD_CAPACITY * RECORD.size);
|
|
20226
|
+
words = new Uint32Array(this.records.buffer);
|
|
20227
|
+
halves = new Uint16Array(this.records.buffer);
|
|
20228
|
+
payload = new Uint8Array(PAYLOAD_CAPACITY);
|
|
20229
|
+
events = [];
|
|
20230
|
+
clock;
|
|
20231
|
+
armTimeouts;
|
|
20232
|
+
onTimeoutFlush;
|
|
20233
|
+
protocolContext;
|
|
20234
|
+
appliedExpectations = 0;
|
|
20235
|
+
timeoutId = null;
|
|
20236
|
+
deadlineNs = null;
|
|
20237
|
+
lastNs = 0n;
|
|
20238
|
+
paste = null;
|
|
20239
|
+
suspended = false;
|
|
20240
|
+
sessionGone = false;
|
|
20241
|
+
destroyed = false;
|
|
20242
|
+
constructor(options = {}) {
|
|
20243
|
+
this.clock = options.clock ?? new SystemClock2;
|
|
20244
|
+
this.armTimeouts = options.armTimeouts ?? true;
|
|
20245
|
+
this.onTimeoutFlush = options.onTimeoutFlush ?? null;
|
|
20246
|
+
this.protocolContext = { ...NO_EXPECTATIONS, ...options.protocolContext };
|
|
20247
|
+
if (options.session) {
|
|
20248
|
+
this.lib = options.session.lib;
|
|
20249
|
+
this.context = options.session.context;
|
|
20250
|
+
this.session = options.session.session;
|
|
20251
|
+
this.ownsContext = false;
|
|
20252
|
+
} else {
|
|
20253
|
+
this.lib = resolveRenderLib2();
|
|
20254
|
+
this.context = this.lib.createContext({ objectCapacity: 4, renderCellsMax: 1 });
|
|
20255
|
+
try {
|
|
20256
|
+
this.session = this.lib.createSession(this.context, { chunkSize: 4096, spanCapacity: 2, maxBytes: 8192n });
|
|
20257
|
+
} catch (error) {
|
|
20258
|
+
this.destroyContext();
|
|
20259
|
+
throw error;
|
|
20260
|
+
}
|
|
20261
|
+
this.ownsContext = true;
|
|
20262
|
+
}
|
|
20263
|
+
try {
|
|
20264
|
+
this.applyExpectations();
|
|
20265
|
+
} catch (error) {
|
|
20266
|
+
if (this.ownsContext)
|
|
20267
|
+
this.destroyContext();
|
|
20268
|
+
throw error;
|
|
20269
|
+
}
|
|
20270
|
+
}
|
|
20271
|
+
updateProtocolContext(patch) {
|
|
20272
|
+
this.ensureAlive();
|
|
20273
|
+
this.protocolContext = { ...this.protocolContext, ...patch };
|
|
20274
|
+
this.native(() => {
|
|
20275
|
+
this.applyExpectations();
|
|
20276
|
+
this.feed(EMPTY, this.nowNs());
|
|
20277
|
+
});
|
|
20278
|
+
this.reconcileTimeout(this.events.length > 0);
|
|
20279
|
+
}
|
|
20280
|
+
push(data) {
|
|
20281
|
+
this.ensureAlive();
|
|
20282
|
+
this.native(() => this.feed(data, this.nowNs()));
|
|
20283
|
+
this.reconcileTimeout();
|
|
20284
|
+
}
|
|
20285
|
+
read() {
|
|
20286
|
+
this.ensureAlive();
|
|
20287
|
+
return this.events.shift() ?? null;
|
|
20288
|
+
}
|
|
20289
|
+
drain(onEvent) {
|
|
20290
|
+
this.ensureAlive();
|
|
20291
|
+
while (!this.destroyed) {
|
|
20292
|
+
const event = this.events.shift();
|
|
20293
|
+
if (!event)
|
|
20294
|
+
return;
|
|
20295
|
+
onEvent(event);
|
|
20296
|
+
}
|
|
20297
|
+
}
|
|
20298
|
+
flushTimeout(nowMsValue = this.clock.now()) {
|
|
20299
|
+
this.ensureAlive();
|
|
20300
|
+
this.native(() => this.feed(EMPTY, this.toNs(nowMsValue)));
|
|
20301
|
+
this.reconcileTimeout();
|
|
20302
|
+
}
|
|
20303
|
+
suspend() {
|
|
20304
|
+
this.ensureAlive();
|
|
20305
|
+
this.suspended = true;
|
|
20306
|
+
this.clearTimeout();
|
|
20307
|
+
}
|
|
20308
|
+
resume() {
|
|
20309
|
+
this.ensureAlive();
|
|
20310
|
+
this.suspended = false;
|
|
20311
|
+
this.native(() => this.lib.sessionInputReset(this.context, this.session, C.OT_INPUT_RESET_KEEP_REPLY));
|
|
20312
|
+
this.paste = null;
|
|
20313
|
+
this.deadlineNs = null;
|
|
20314
|
+
}
|
|
20315
|
+
reset() {
|
|
20316
|
+
if (this.destroyed)
|
|
20317
|
+
return;
|
|
20318
|
+
this.clearTimeout();
|
|
20319
|
+
this.native(() => this.lib.sessionInputReset(this.context, this.session, 0));
|
|
20320
|
+
this.events.length = 0;
|
|
20321
|
+
this.paste = null;
|
|
20322
|
+
this.deadlineNs = null;
|
|
20323
|
+
}
|
|
20324
|
+
destroy() {
|
|
20325
|
+
if (this.destroyed)
|
|
20326
|
+
return;
|
|
20327
|
+
this.clearTimeout();
|
|
20328
|
+
this.destroyed = true;
|
|
20329
|
+
this.events.length = 0;
|
|
20330
|
+
this.paste = null;
|
|
20331
|
+
if (this.ownsContext)
|
|
20332
|
+
this.destroyContext();
|
|
20333
|
+
}
|
|
20334
|
+
ensureAlive() {
|
|
20335
|
+
if (this.destroyed)
|
|
20336
|
+
throw new Error("StdinParser has been destroyed");
|
|
20337
|
+
}
|
|
20338
|
+
native(call) {
|
|
20339
|
+
if (this.sessionGone)
|
|
20340
|
+
return;
|
|
20341
|
+
try {
|
|
20342
|
+
call();
|
|
20343
|
+
} catch (error) {
|
|
20344
|
+
if (!(error instanceof NativeError2) || error.status !== -12 /* SessionClosed */ && error.status !== -15 /* OutputFailed */ && error.status !== -9 /* StaleHandle */ && error.status !== -7 /* WrongContext */) {
|
|
20345
|
+
throw error;
|
|
20346
|
+
}
|
|
20347
|
+
this.sessionGone = true;
|
|
20348
|
+
this.deadlineNs = null;
|
|
20349
|
+
this.paste = null;
|
|
20350
|
+
this.clearTimeout();
|
|
20351
|
+
}
|
|
20352
|
+
}
|
|
20353
|
+
destroyContext() {
|
|
20354
|
+
this.lib.getYogaHost().runMutation(() => this.lib.destroyContext(this.context));
|
|
20355
|
+
}
|
|
20356
|
+
applyExpectations() {
|
|
20357
|
+
const flags = expectationFlags(this.protocolContext);
|
|
20358
|
+
if (flags === this.appliedExpectations)
|
|
20359
|
+
return;
|
|
20360
|
+
this.lib.sessionInputExpect(this.context, this.session, flags);
|
|
20361
|
+
this.appliedExpectations = flags;
|
|
20362
|
+
}
|
|
20363
|
+
toNs(ms) {
|
|
20364
|
+
const ns = BigInt(Math.max(0, Math.round(ms * 1e6)));
|
|
20365
|
+
return ns > this.lastNs ? ns : this.lastNs;
|
|
20366
|
+
}
|
|
20367
|
+
nowNs() {
|
|
20368
|
+
return this.suspended ? this.lastNs : this.toNs(this.clock.now());
|
|
20369
|
+
}
|
|
20370
|
+
feed(bytes, nowNs) {
|
|
20371
|
+
this.lastNs = nowNs;
|
|
20372
|
+
let offset = 0;
|
|
20373
|
+
do {
|
|
20374
|
+
const rest = offset === 0 ? bytes : bytes.subarray(offset);
|
|
20375
|
+
const drain = this.lib.sessionInputFeed(this.context, this.session, rest, nowNs, this.records, this.payload);
|
|
20376
|
+
this.deadlineNs = drain.deadlineNs;
|
|
20377
|
+
for (let index = 0;index < drain.count; index++)
|
|
20378
|
+
this.translate(index);
|
|
20379
|
+
if (drain.consumed === 0 && drain.count === 0 && offset < bytes.length) {
|
|
20380
|
+
throw new Error("native input parser made no progress");
|
|
20381
|
+
}
|
|
20382
|
+
offset += drain.consumed;
|
|
20383
|
+
} while (offset < bytes.length);
|
|
20384
|
+
}
|
|
20385
|
+
reconcileTimeout(flushNow = false) {
|
|
20386
|
+
if (!this.armTimeouts)
|
|
20387
|
+
return;
|
|
20388
|
+
this.clearTimeout();
|
|
20389
|
+
const deadline = flushNow ? null : this.deadlineNs;
|
|
20390
|
+
if (deadline === null && !flushNow || this.suspended || this.sessionGone)
|
|
20391
|
+
return;
|
|
20392
|
+
const delayMs = deadline === null ? 0 : Number((deadline - this.lastNs + 999999n) / 1000000n);
|
|
20393
|
+
this.timeoutId = this.clock.setTimeout(() => {
|
|
20394
|
+
this.timeoutId = null;
|
|
20395
|
+
if (this.destroyed)
|
|
20396
|
+
return;
|
|
20397
|
+
try {
|
|
20398
|
+
const now = this.nowNs();
|
|
20399
|
+
this.native(() => this.feed(EMPTY, deadline !== null && now < deadline ? deadline : now));
|
|
20400
|
+
this.reconcileTimeout();
|
|
20401
|
+
this.onTimeoutFlush?.();
|
|
20402
|
+
} catch (error) {
|
|
20403
|
+
console.error("stdin parser timeout flush failed", error);
|
|
20404
|
+
}
|
|
20405
|
+
}, delayMs);
|
|
20406
|
+
}
|
|
20407
|
+
clearTimeout() {
|
|
20408
|
+
if (this.timeoutId === null)
|
|
20409
|
+
return;
|
|
20410
|
+
this.clock.clearTimeout(this.timeoutId);
|
|
20411
|
+
this.timeoutId = null;
|
|
20412
|
+
}
|
|
20413
|
+
span(offset, length) {
|
|
20414
|
+
return this.payload.subarray(offset, offset + length);
|
|
20415
|
+
}
|
|
20416
|
+
translate(index) {
|
|
20417
|
+
const base = index * RECORD.size;
|
|
20418
|
+
const word = base / 4;
|
|
20419
|
+
const half = base / 2;
|
|
20420
|
+
const kind = this.records[base + FIELD.kind];
|
|
20421
|
+
const action = this.records[base + FIELD.action];
|
|
20422
|
+
const modifiers = this.records[base + FIELD.modifiers];
|
|
20423
|
+
const flags = this.records[base + FIELD.flags];
|
|
20424
|
+
const code = this.words[word + FIELD.code];
|
|
20425
|
+
const raw = this.span(this.words[word + FIELD.rawOffset], this.words[word + FIELD.rawLength]);
|
|
20426
|
+
const text = this.span(this.words[word + FIELD.textOffset], this.words[word + FIELD.textLength]);
|
|
20427
|
+
switch (kind) {
|
|
20428
|
+
case C.OT_INPUT_KEY: {
|
|
20429
|
+
const key = parsedKey(code, this.words[word + FIELD.baseCode], action, modifiers, flags, raw, text);
|
|
20430
|
+
this.events.push({ type: "key", raw: key.raw, key });
|
|
20431
|
+
return;
|
|
20432
|
+
}
|
|
20433
|
+
case C.OT_INPUT_MOUSE: {
|
|
20434
|
+
const sequence = latin1(raw);
|
|
20435
|
+
const encoding = raw[2] === 60 ? "sgr" : "x10";
|
|
20436
|
+
const event = rawMouseEvent(action, code, this.halves[half + FIELD.x], this.halves[half + FIELD.y], modifiers, encoding);
|
|
20437
|
+
this.events.push({ type: "mouse", raw: sequence, encoding, event });
|
|
20438
|
+
return;
|
|
20439
|
+
}
|
|
20440
|
+
case C.OT_INPUT_PASTE: {
|
|
20441
|
+
if (flags & C.OT_INPUT_PASTE_START)
|
|
20442
|
+
this.paste = [];
|
|
20443
|
+
if (text.length > 0)
|
|
20444
|
+
this.paste.push(Uint8Array.from(text));
|
|
20445
|
+
if (flags & C.OT_INPUT_PASTE_END) {
|
|
20446
|
+
const parts = this.paste;
|
|
20447
|
+
this.paste = null;
|
|
20448
|
+
this.events.push({ type: "paste", bytes: parts.length === 1 ? parts[0] : concat(parts) });
|
|
20449
|
+
}
|
|
20450
|
+
return;
|
|
20451
|
+
}
|
|
20452
|
+
case C.OT_INPUT_FOCUS:
|
|
20453
|
+
this.events.push({ type: "response", protocol: "csi", sequence: latin1(raw) });
|
|
20454
|
+
return;
|
|
20455
|
+
case C.OT_INPUT_REPLY: {
|
|
20456
|
+
const protocol = flags & C.OT_INPUT_REPLY_CURSOR_POSITION ? "cpr" : flags & C.OT_INPUT_REPLY_FRAGMENT ? "unknown" : REPLY_PROTOCOLS[code];
|
|
20457
|
+
this.events.push({ type: "response", protocol, sequence: latin1(raw) });
|
|
20458
|
+
return;
|
|
20459
|
+
}
|
|
20460
|
+
}
|
|
20461
|
+
throw new Error(`Unknown native input event kind: ${kind}`);
|
|
20462
|
+
}
|
|
20463
|
+
}
|
|
20464
|
+
function keyRaw(raw) {
|
|
20465
|
+
if (raw.length === 1 && raw[0] >= 128)
|
|
20466
|
+
return "\x1B" + String.fromCharCode(raw[0] & 127);
|
|
20467
|
+
return UTF8.decode(raw);
|
|
20468
|
+
}
|
|
20469
|
+
function compatCode(raw, code, kitty) {
|
|
20470
|
+
if (kitty) {
|
|
20471
|
+
if (!raw.endsWith("u") || kittyKeyMap[code] === undefined)
|
|
20472
|
+
return;
|
|
20473
|
+
return `[${/^\x1b+\[(\d+)/.exec(raw)[1]}u`;
|
|
20474
|
+
}
|
|
20475
|
+
if (kittyKeyMap[code] === undefined && !KEYPAD_TEXT.has(String.fromCodePoint(code)))
|
|
20476
|
+
return;
|
|
20477
|
+
const match = LEGACY_CODE_RE.exec(raw);
|
|
20478
|
+
return match ? [match[1], match[2], match[3], match[4]].filter(Boolean).join("") : undefined;
|
|
20479
|
+
}
|
|
20480
|
+
function parsedKey(code, baseCode, action, modifiers, flags, rawBytes, textBytes) {
|
|
20481
|
+
const kitty = (flags & C.OT_INPUT_KEY_KITTY) !== 0;
|
|
20482
|
+
const raw = keyRaw(rawBytes);
|
|
20483
|
+
const text = textBytes.length === 0 ? "" : UTF8.decode(textBytes);
|
|
20484
|
+
const alt = (modifiers & C.OT_INPUT_MOD_ALT) !== 0;
|
|
20485
|
+
const sequence = kitty || LEGACY_SEQUENCE_RE.test(raw);
|
|
20486
|
+
let shift = (modifiers & C.OT_INPUT_MOD_SHIFT) !== 0;
|
|
20487
|
+
let name;
|
|
20488
|
+
if (code === 0) {
|
|
20489
|
+
name = text;
|
|
20490
|
+
} else if (kittyKeyMap[code] !== undefined) {
|
|
20491
|
+
name = code === C.OT_INPUT_KEY_ENTER && !kitty && raw.endsWith(`
|
|
20492
|
+
`) ? "linefeed" : kittyKeyMap[code];
|
|
20493
|
+
} else if (code === 32) {
|
|
20494
|
+
name = "space";
|
|
20495
|
+
} else {
|
|
20496
|
+
name = String.fromCodePoint(code);
|
|
20497
|
+
if (!sequence && code >= 65 && code <= 90) {
|
|
20498
|
+
shift = true;
|
|
20499
|
+
if (!alt)
|
|
20500
|
+
name = name.toLowerCase();
|
|
20501
|
+
}
|
|
20502
|
+
}
|
|
20503
|
+
const key = {
|
|
20504
|
+
name,
|
|
20505
|
+
ctrl: (modifiers & C.OT_INPUT_MOD_CTRL) !== 0,
|
|
20506
|
+
meta: alt || (modifiers & C.OT_INPUT_MOD_META) !== 0,
|
|
20507
|
+
shift,
|
|
20508
|
+
option: alt && sequence,
|
|
20509
|
+
sequence: text || raw,
|
|
20510
|
+
number: /^[0-9]$/.test(name),
|
|
20511
|
+
raw,
|
|
20512
|
+
eventType: action === C.OT_INPUT_KEY_RELEASE ? "release" : "press",
|
|
20513
|
+
source: kitty ? "kitty" : "raw",
|
|
20514
|
+
super: (modifiers & C.OT_INPUT_MOD_SUPER) !== 0,
|
|
20515
|
+
hyper: (modifiers & C.OT_INPUT_MOD_HYPER) !== 0,
|
|
20516
|
+
capsLock: (modifiers & C.OT_INPUT_MOD_CAPS_LOCK) !== 0,
|
|
20517
|
+
numLock: (modifiers & C.OT_INPUT_MOD_NUM_LOCK) !== 0
|
|
20518
|
+
};
|
|
20519
|
+
if (action === C.OT_INPUT_KEY_REPEAT)
|
|
20520
|
+
key.repeated = true;
|
|
20521
|
+
if (baseCode !== 0)
|
|
20522
|
+
key.baseCode = baseCode;
|
|
20523
|
+
const legacy = compatCode(raw, code, kitty);
|
|
20524
|
+
if (legacy !== undefined)
|
|
20525
|
+
key.code = legacy;
|
|
20526
|
+
return key;
|
|
20527
|
+
}
|
|
20528
|
+
function rawMouseEvent(action, code, x, y, modifiers, encoding) {
|
|
20529
|
+
const type = MOUSE_TYPES[action];
|
|
20530
|
+
if (!type)
|
|
20531
|
+
throw new Error(`Unknown native mouse action: ${action}`);
|
|
20532
|
+
let button = code;
|
|
20533
|
+
if (code === C.OT_INPUT_MOUSE_BUTTON_NONE)
|
|
20534
|
+
button = encoding === "x10" ? -1 : 0;
|
|
20535
|
+
if (type === "scroll")
|
|
20536
|
+
button = encoding === "x10" || code === 3 ? 0 : code;
|
|
20537
|
+
const event = {
|
|
20538
|
+
type,
|
|
20539
|
+
button,
|
|
20540
|
+
x,
|
|
20541
|
+
y,
|
|
20542
|
+
modifiers: {
|
|
20543
|
+
shift: (modifiers & C.OT_INPUT_MOD_SHIFT) !== 0,
|
|
20544
|
+
alt: (modifiers & C.OT_INPUT_MOD_ALT) !== 0,
|
|
20545
|
+
ctrl: (modifiers & C.OT_INPUT_MOD_CTRL) !== 0
|
|
20546
|
+
}
|
|
20547
|
+
};
|
|
20548
|
+
if (type === "scroll")
|
|
20549
|
+
event.scroll = { direction: SCROLL_DIRECTIONS[code & 3], delta: 1 };
|
|
20550
|
+
return event;
|
|
20551
|
+
}
|
|
20552
|
+
var SHADOW_BACKLOG_MAX = 256;
|
|
20553
|
+
var SHADOW_WINDOW = 8;
|
|
20554
|
+
function describeEvent(event) {
|
|
20555
|
+
switch (event.type) {
|
|
20556
|
+
case "key": {
|
|
20557
|
+
const { name, ctrl, meta, shift, eventType } = event.key;
|
|
20558
|
+
return JSON.stringify(["key", event.raw, name, ctrl, meta, shift, eventType]);
|
|
20559
|
+
}
|
|
20560
|
+
case "mouse": {
|
|
20561
|
+
const { type, button, x, y, modifiers } = event.event;
|
|
20562
|
+
return JSON.stringify(["mouse", event.raw, type, button, x, y, modifiers.shift, modifiers.alt, modifiers.ctrl]);
|
|
20563
|
+
}
|
|
20564
|
+
case "paste":
|
|
20565
|
+
return JSON.stringify(["paste", event.bytes.length, Buffer4.from(event.bytes).toString("base64")]);
|
|
20566
|
+
case "response":
|
|
20567
|
+
return JSON.stringify(["response", event.protocol, event.sequence]);
|
|
20568
|
+
}
|
|
20569
|
+
}
|
|
20570
|
+
|
|
20571
|
+
class StdinShadowComparator {
|
|
20572
|
+
primaryName;
|
|
20573
|
+
log;
|
|
20574
|
+
delivered = [];
|
|
20575
|
+
shadowed = [];
|
|
20576
|
+
constructor(primaryName, log) {
|
|
20577
|
+
this.primaryName = primaryName;
|
|
20578
|
+
this.log = log;
|
|
20579
|
+
}
|
|
20580
|
+
primary(event) {
|
|
20581
|
+
this.queue(this.delivered, event);
|
|
20582
|
+
}
|
|
20583
|
+
shadow(event) {
|
|
20584
|
+
this.queue(this.shadowed, event);
|
|
20585
|
+
}
|
|
20586
|
+
flush() {
|
|
20587
|
+
this.pair(true);
|
|
20588
|
+
}
|
|
20589
|
+
queue(events, event) {
|
|
20590
|
+
events.push(describeEvent(event));
|
|
20591
|
+
this.pair(false);
|
|
20592
|
+
if (events.length > SHADOW_BACKLOG_MAX) {
|
|
20593
|
+
const dropped = events.shift();
|
|
20594
|
+
if (events === this.delivered)
|
|
20595
|
+
this.report(dropped, "");
|
|
20596
|
+
else
|
|
20597
|
+
this.report("", dropped);
|
|
20598
|
+
}
|
|
20599
|
+
}
|
|
20600
|
+
pair(final) {
|
|
20601
|
+
const { delivered, shadowed } = this;
|
|
20602
|
+
while (delivered.length > 0 && shadowed.length > 0) {
|
|
20603
|
+
const [i, j] = commonEvent(delivered, shadowed) ?? [-1, -1];
|
|
20604
|
+
if (i >= 0) {
|
|
20605
|
+
for (let k = 0;k < Math.max(i, j); k++)
|
|
20606
|
+
this.report(k < i ? delivered[k] : "", k < j ? shadowed[k] : "");
|
|
20607
|
+
delivered.splice(0, i + 1);
|
|
20608
|
+
shadowed.splice(0, j + 1);
|
|
20609
|
+
} else if (final || Math.min(delivered.length, shadowed.length) >= SHADOW_WINDOW) {
|
|
20610
|
+
this.report(delivered.shift(), shadowed.shift());
|
|
20611
|
+
} else
|
|
20612
|
+
return;
|
|
20613
|
+
}
|
|
20614
|
+
if (final) {
|
|
20615
|
+
for (const event of delivered.splice(0))
|
|
20616
|
+
this.report(event, "");
|
|
20617
|
+
for (const event of shadowed.splice(0))
|
|
20618
|
+
this.report("", event);
|
|
20619
|
+
}
|
|
20620
|
+
}
|
|
20621
|
+
report(delivered, shadowed) {
|
|
20622
|
+
const shadowName = this.primaryName === "native" ? "legacy" : "native";
|
|
20623
|
+
this.log(`[stdin-shadow] ${this.primaryName}=${delivered || "none"} ${shadowName}=${shadowed || "none"}`);
|
|
20624
|
+
}
|
|
20625
|
+
}
|
|
20626
|
+
function commonEvent(a, b) {
|
|
20627
|
+
const aEnd = Math.min(a.length, SHADOW_WINDOW);
|
|
20628
|
+
const bEnd = Math.min(b.length, SHADOW_WINDOW);
|
|
20629
|
+
for (let sum = 0;sum < aEnd + bEnd - 1; sum++) {
|
|
20630
|
+
for (let i = Math.max(0, sum - bEnd + 1);i <= Math.min(sum, aEnd - 1); i++) {
|
|
20631
|
+
if (a[i] === b[sum - i])
|
|
20632
|
+
return [i, sum - i];
|
|
20633
|
+
}
|
|
20634
|
+
}
|
|
20635
|
+
return null;
|
|
20636
|
+
}
|
|
20637
|
+
|
|
20632
20638
|
// src/renderer-theme-mode.ts
|
|
20633
20639
|
var OSC_THEME_RESPONSE = /\x1b](10|11);(?:(?:rgb:)([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)|#([0-9a-fA-F]{6}))(?:\x07|\x1b\\)/g;
|
|
20634
20640
|
function scaleOscThemeComponent(component) {
|
|
@@ -20814,6 +20820,18 @@ registerEnvVar2({
|
|
|
20814
20820
|
type: "boolean",
|
|
20815
20821
|
default: false
|
|
20816
20822
|
});
|
|
20823
|
+
registerEnvVar2({
|
|
20824
|
+
name: "OTUI_NATIVE_INPUT_PARSER",
|
|
20825
|
+
description: "Parse stdin with the experimental native input parser unless experimental_nativeInput is set.",
|
|
20826
|
+
type: "boolean",
|
|
20827
|
+
default: false
|
|
20828
|
+
});
|
|
20829
|
+
registerEnvVar2({
|
|
20830
|
+
name: "OTUI_NATIVE_INPUT_SHADOW",
|
|
20831
|
+
description: "Also run the other stdin parser and log one line for each event that differs.",
|
|
20832
|
+
type: "boolean",
|
|
20833
|
+
default: false
|
|
20834
|
+
});
|
|
20817
20835
|
var KITTY_IMAGE_TRANSPORTS = ["raw", "zlib", "file"];
|
|
20818
20836
|
var DEFAULT_FOOTER_HEIGHT = 12;
|
|
20819
20837
|
var MAX_SCROLLBACK_SURFACE_HEIGHT_PASSES = 4;
|
|
@@ -21315,6 +21333,7 @@ class CliRenderer2 extends EventEmitter8 {
|
|
|
21315
21333
|
_resolution = null;
|
|
21316
21334
|
_keyHandler;
|
|
21317
21335
|
stdinParser = null;
|
|
21336
|
+
stdinShadow = null;
|
|
21318
21337
|
oscSubscribers = new Set;
|
|
21319
21338
|
hasLoggedStdinParserError = false;
|
|
21320
21339
|
animationRequest = new Map;
|
|
@@ -21446,16 +21465,16 @@ Captured external output:
|
|
|
21446
21465
|
}).catch((error) => console.error("Native scene shutdown failed:", error));
|
|
21447
21466
|
}).bind(this);
|
|
21448
21467
|
nativeProcessExitHandler = () => {
|
|
21449
|
-
|
|
21450
|
-
|
|
21451
|
-
const restored = this.nativeSession.restoreOnExit();
|
|
21468
|
+
const disposed = this.nativeSession.disposed;
|
|
21469
|
+
const restored = !disposed && this.nativeSession.restoreOnExit();
|
|
21452
21470
|
try {
|
|
21471
|
+
this.leaveRawMode();
|
|
21453
21472
|
this.destroy();
|
|
21454
21473
|
if (this.flushTerminalInputOnClose)
|
|
21455
21474
|
this.lib.terminalFlushInput();
|
|
21456
21475
|
} finally {
|
|
21457
21476
|
this.nativeSession.dispose();
|
|
21458
|
-
if (!restored && this._terminalIsSetup) {
|
|
21477
|
+
if (!disposed && !restored && this._terminalIsSetup) {
|
|
21459
21478
|
console.error("Native scene output cancelled at process exit; terminal restoration did not complete");
|
|
21460
21479
|
}
|
|
21461
21480
|
}
|
|
@@ -21476,9 +21495,8 @@ Captured external output:
|
|
|
21476
21495
|
this.stdout = stdout;
|
|
21477
21496
|
this._usesProcessStdout = stdout === process.stdout;
|
|
21478
21497
|
this.realStdoutWrite = stdout.write;
|
|
21479
|
-
|
|
21480
|
-
|
|
21481
|
-
throw new Error("nativeSceneWorkBudget must be a positive u32");
|
|
21498
|
+
if (config.nativeSceneWorkBudget !== undefined) {
|
|
21499
|
+
throw new Error("nativeSceneWorkBudget was removed: frames always paint synchronously");
|
|
21482
21500
|
}
|
|
21483
21501
|
this.kittyTransportMode = config.kittyImageTransport ?? "raw";
|
|
21484
21502
|
const transportCode = KITTY_IMAGE_TRANSPORTS.indexOf(this.kittyTransportMode);
|
|
@@ -21533,12 +21551,14 @@ Captured external output:
|
|
|
21533
21551
|
this.nativeClosed = this.nativeSession.closed.finally(() => this.nativeDestroyWait.promise).finally(() => {
|
|
21534
21552
|
if (this.nativeSession.error && !this.nativeSession.disposed)
|
|
21535
21553
|
this.nativeSession.dispose();
|
|
21554
|
+
this.leaveRawMode();
|
|
21555
|
+
this.removeCleanupListener(process, "exit", this.nativeProcessExitHandler);
|
|
21536
21556
|
if (this.flushTerminalInputOnClose)
|
|
21537
21557
|
this.lib.terminalFlushInput();
|
|
21538
21558
|
this.releaseStreamLease();
|
|
21539
21559
|
});
|
|
21540
21560
|
this.nativeClosed.catch(() => {});
|
|
21541
|
-
this.nativeScene = new NativeScene(this.nativeSession, this
|
|
21561
|
+
this.nativeScene = new NativeScene(this.nativeSession, this);
|
|
21542
21562
|
this.nativeSession.setKittyImageTransport(transportCode);
|
|
21543
21563
|
} catch (error) {
|
|
21544
21564
|
if (!config.nativeSession || this.nativeSession)
|
|
@@ -21623,23 +21643,41 @@ Captured external output:
|
|
|
21623
21643
|
});
|
|
21624
21644
|
this.addExitListeners();
|
|
21625
21645
|
const stdinParserMaxBufferBytes = config.stdinParserMaxBufferBytes ?? DEFAULT_STDIN_PARSER_MAX_BUFFER_BYTES;
|
|
21626
|
-
|
|
21627
|
-
|
|
21628
|
-
maxPendingBytes: stdinParserMaxBufferBytes,
|
|
21629
|
-
armTimeouts: true,
|
|
21630
|
-
onTimeoutFlush: () => {
|
|
21631
|
-
this.drainStdinParser();
|
|
21632
|
-
},
|
|
21633
|
-
useKittyKeyboard: useKittyForParsing,
|
|
21634
|
-
protocolContext: {
|
|
21646
|
+
const createStdinParser = (native, onTimeoutFlush) => {
|
|
21647
|
+
const protocolContext = {
|
|
21635
21648
|
kittyKeyboardEnabled: useKittyForParsing,
|
|
21636
21649
|
privateCapabilityRepliesActive: false,
|
|
21637
21650
|
pixelResolutionQueryActive: false,
|
|
21638
21651
|
explicitWidthCprActive: false,
|
|
21639
21652
|
startupCursorCprActive: false
|
|
21640
|
-
}
|
|
21641
|
-
|
|
21642
|
-
|
|
21653
|
+
};
|
|
21654
|
+
if (native) {
|
|
21655
|
+
return new NativeStdinParser({
|
|
21656
|
+
armTimeouts: true,
|
|
21657
|
+
onTimeoutFlush,
|
|
21658
|
+
protocolContext,
|
|
21659
|
+
clock: this.clock,
|
|
21660
|
+
session: { lib: this.lib, context: this.nativeSession.context, session: this.nativeSession.session }
|
|
21661
|
+
});
|
|
21662
|
+
}
|
|
21663
|
+
return new StdinParser2({
|
|
21664
|
+
timeoutMs: 20,
|
|
21665
|
+
maxPendingBytes: stdinParserMaxBufferBytes,
|
|
21666
|
+
armTimeouts: true,
|
|
21667
|
+
onTimeoutFlush,
|
|
21668
|
+
useKittyKeyboard: useKittyForParsing,
|
|
21669
|
+
protocolContext,
|
|
21670
|
+
clock: this.clock
|
|
21671
|
+
});
|
|
21672
|
+
};
|
|
21673
|
+
const nativeInput = config.experimental_nativeInput ?? env2.OTUI_NATIVE_INPUT_PARSER;
|
|
21674
|
+
this.stdinParser = createStdinParser(nativeInput, () => this.drainStdinParser());
|
|
21675
|
+
if (env2.OTUI_NATIVE_INPUT_SHADOW) {
|
|
21676
|
+
this.stdinShadow = {
|
|
21677
|
+
parser: createStdinParser(!nativeInput, () => this.drainStdinShadow()),
|
|
21678
|
+
comparator: new StdinShadowComparator(nativeInput ? "native" : "legacy", (line) => console.warn(line))
|
|
21679
|
+
};
|
|
21680
|
+
}
|
|
21643
21681
|
this._console = new TerminalConsole2(this, {
|
|
21644
21682
|
...config.consoleOptions ?? {},
|
|
21645
21683
|
clock: this.clock
|
|
@@ -21653,9 +21691,8 @@ Captured external output:
|
|
|
21653
21691
|
this.stdout.write = externalOutputMode === "capture-stdout" ? this.interceptStdoutWrite : this.realStdoutWrite;
|
|
21654
21692
|
this._openConsoleOnError = config.openConsoleOnError ?? true;
|
|
21655
21693
|
this._onDestroy = config.onDestroy;
|
|
21656
|
-
this.setupInput();
|
|
21657
21694
|
process.on("exit", this.nativeProcessExitHandler);
|
|
21658
|
-
this.
|
|
21695
|
+
this.setupInput();
|
|
21659
21696
|
this.nativeSession.closed.catch((error) => {
|
|
21660
21697
|
if (this._isDestroyed)
|
|
21661
21698
|
return;
|
|
@@ -22700,7 +22737,8 @@ Captured external output:
|
|
|
22700
22737
|
}
|
|
22701
22738
|
abortSplitStartupCursorSeed() {
|
|
22702
22739
|
this.clearSplitStartupCursorSeed();
|
|
22703
|
-
this.
|
|
22740
|
+
for (const parser of this.legacyStdinParsers())
|
|
22741
|
+
parser.abortPendingStartupCursorCpr();
|
|
22704
22742
|
this.updateStdinParserProtocolContext({ startupCursorCprActive: false });
|
|
22705
22743
|
}
|
|
22706
22744
|
resetSplitScrollback(seedRows = 0) {
|
|
@@ -22931,7 +22969,8 @@ Captured external output:
|
|
|
22931
22969
|
}
|
|
22932
22970
|
this._useMouse = false;
|
|
22933
22971
|
this.capturedRenderable = undefined;
|
|
22934
|
-
this.
|
|
22972
|
+
for (const parser of this.legacyStdinParsers())
|
|
22973
|
+
parser.resetMouseState();
|
|
22935
22974
|
}
|
|
22936
22975
|
enableKittyKeyboard(flags = 3) {
|
|
22937
22976
|
if (this.nativeTerminalTransition || this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
|
|
@@ -23060,6 +23099,12 @@ Captured external output:
|
|
|
23060
23099
|
} catch (error) {
|
|
23061
23100
|
this.handleStdinParserFailure(error);
|
|
23062
23101
|
}
|
|
23102
|
+
try {
|
|
23103
|
+
this.stdinShadow?.parser.push(data);
|
|
23104
|
+
this.drainStdinShadow();
|
|
23105
|
+
} catch (error) {
|
|
23106
|
+
console.warn("[stdin-shadow] parser failure", error);
|
|
23107
|
+
}
|
|
23063
23108
|
}).bind(this);
|
|
23064
23109
|
addInputHandler(handler) {
|
|
23065
23110
|
this.sequenceHandlers.push(handler);
|
|
@@ -23074,8 +23119,13 @@ Captured external output:
|
|
|
23074
23119
|
if (!this.stdinParser)
|
|
23075
23120
|
return;
|
|
23076
23121
|
this.stdinParser.updateProtocolContext(patch);
|
|
23122
|
+
this.stdinShadow?.parser.updateProtocolContext(patch);
|
|
23077
23123
|
if (drain)
|
|
23078
23124
|
this.drainStdinParser();
|
|
23125
|
+
this.drainStdinShadow();
|
|
23126
|
+
}
|
|
23127
|
+
legacyStdinParsers() {
|
|
23128
|
+
return [this.stdinParser, this.stdinShadow?.parser].filter((parser) => parser instanceof StdinParser2);
|
|
23079
23129
|
}
|
|
23080
23130
|
subscribeOsc(handler) {
|
|
23081
23131
|
this.oscSubscribers.add(handler);
|
|
@@ -23159,9 +23209,14 @@ Captured external output:
|
|
|
23159
23209
|
if (!this.stdinParser)
|
|
23160
23210
|
return;
|
|
23161
23211
|
this.stdinParser.drain((event) => {
|
|
23212
|
+
this.stdinShadow?.comparator.primary(event);
|
|
23162
23213
|
this.handleStdinEvent(event);
|
|
23163
23214
|
});
|
|
23164
23215
|
}
|
|
23216
|
+
drainStdinShadow() {
|
|
23217
|
+
const shadow = this.stdinShadow;
|
|
23218
|
+
shadow?.parser.drain((event) => shadow.comparator.shadow(event));
|
|
23219
|
+
}
|
|
23165
23220
|
handleStdinEvent(event) {
|
|
23166
23221
|
if (event.type === "response" && event.sequence.startsWith("\x1B_G")) {
|
|
23167
23222
|
try {
|
|
@@ -23221,6 +23276,7 @@ Captured external output:
|
|
|
23221
23276
|
}
|
|
23222
23277
|
try {
|
|
23223
23278
|
this.stdinParser?.reset();
|
|
23279
|
+
this.stdinShadow?.parser.reset();
|
|
23224
23280
|
} catch (resetError) {
|
|
23225
23281
|
console.error("stdin parser reset failed after parser error", resetError);
|
|
23226
23282
|
}
|
|
@@ -23635,9 +23691,6 @@ Captured external output:
|
|
|
23635
23691
|
else {
|
|
23636
23692
|
this.nativeSession.setScreen(this._screenMode === "alternate-screen", nextGeometry.renderWidth, nextGeometry.renderHeight, this.lib.encoder.encode(ANSI.moveCursorAndClear(clearStart, 1)));
|
|
23637
23693
|
}
|
|
23638
|
-
if (nextGeometry.renderWidth !== this.width || nextGeometry.renderHeight !== this.height) {
|
|
23639
|
-
this.nativeScene.restartPaint();
|
|
23640
|
-
}
|
|
23641
23694
|
this._terminalWidth = width;
|
|
23642
23695
|
this._terminalHeight = height;
|
|
23643
23696
|
this._splitHeight = nextGeometry.effectiveFooterHeight;
|
|
@@ -23646,7 +23699,8 @@ Captured external output:
|
|
|
23646
23699
|
this._resolution = null;
|
|
23647
23700
|
this.lib.sessionSetImageResolution(this.nativeSession.context, this.nativeSession.session, 0, 0, 0, 0);
|
|
23648
23701
|
this.capturedRenderable = undefined;
|
|
23649
|
-
this.
|
|
23702
|
+
for (const parser of this.legacyStdinParsers())
|
|
23703
|
+
parser.resetMouseState();
|
|
23650
23704
|
if (splitFooterActive) {
|
|
23651
23705
|
this.forceFullRepaintRequested = true;
|
|
23652
23706
|
}
|
|
@@ -23913,7 +23967,6 @@ Captured external output:
|
|
|
23913
23967
|
this._controlState = "explicit_suspended" /* EXPLICIT_SUSPENDED */;
|
|
23914
23968
|
this._cancelPaletteDetection?.(new Error("Cannot detect palette while renderer is suspended"));
|
|
23915
23969
|
this.resolveXtVersionWaiters();
|
|
23916
|
-
this.nativeScene.interruptPaint();
|
|
23917
23970
|
this.halt(false);
|
|
23918
23971
|
this.clearSplitStartupCursorSeed();
|
|
23919
23972
|
this.disableMouse();
|
|
@@ -23923,11 +23976,8 @@ Captured external output:
|
|
|
23923
23976
|
pixelResolutionQueryActive: this.waitingForPixelResolution,
|
|
23924
23977
|
explicitWidthCprActive: false,
|
|
23925
23978
|
startupCursorCprActive: false
|
|
23926
|
-
});
|
|
23927
|
-
|
|
23928
|
-
this.stdinParser.pausePendingTimeout();
|
|
23929
|
-
else
|
|
23930
|
-
this.stdinParser?.reset();
|
|
23979
|
+
}, true);
|
|
23980
|
+
this.pauseStdinParsers(false);
|
|
23931
23981
|
this.stdin.removeListener("data", this.stdinListener);
|
|
23932
23982
|
this.stopTerminalKeepAlive();
|
|
23933
23983
|
this.themeModeState?.cancelRefresh();
|
|
@@ -23938,7 +23988,7 @@ Captured external output:
|
|
|
23938
23988
|
return nativeTransition;
|
|
23939
23989
|
}
|
|
23940
23990
|
resume() {
|
|
23941
|
-
if (!this._terminalIsSetup || this.nativeTerminalTransition || this._controlState !== "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
|
|
23991
|
+
if (!this._terminalIsSetup || this._isDestroyed || this.nativeTerminalTransition || this._controlState !== "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
|
|
23942
23992
|
throw new Error("Native scene resume requires completed suspension");
|
|
23943
23993
|
}
|
|
23944
23994
|
if (this.pendingSplitFooterTransition) {
|
|
@@ -23946,6 +23996,12 @@ Captured external output:
|
|
|
23946
23996
|
kind: "clear-transition"
|
|
23947
23997
|
});
|
|
23948
23998
|
}
|
|
23999
|
+
try {
|
|
24000
|
+
this.stdin.setRawMode?.(true);
|
|
24001
|
+
} catch (error) {
|
|
24002
|
+
return Promise.reject(error);
|
|
24003
|
+
}
|
|
24004
|
+
this.addExitListeners();
|
|
23949
24005
|
const resumed = this.trackNativeTerminalTransition(this.nativeSession.resume(), () => {
|
|
23950
24006
|
if (this._isDestroyed)
|
|
23951
24007
|
return;
|
|
@@ -23961,21 +24017,24 @@ Captured external output:
|
|
|
23961
24017
|
resumed.catch(() => {});
|
|
23962
24018
|
return resumed;
|
|
23963
24019
|
}
|
|
23964
|
-
|
|
23965
|
-
|
|
23966
|
-
|
|
24020
|
+
pauseStdinParsers(resuming) {
|
|
24021
|
+
for (const parser of [this.stdinParser, this.stdinShadow?.parser]) {
|
|
24022
|
+
if (parser instanceof NativeStdinParser)
|
|
24023
|
+
resuming ? parser.resume() : parser.suspend();
|
|
24024
|
+
else if (parser?.hasPendingPixelResolutionResponse())
|
|
24025
|
+
parser.pausePendingTimeout();
|
|
24026
|
+
else
|
|
24027
|
+
parser?.reset();
|
|
23967
24028
|
}
|
|
24029
|
+
}
|
|
24030
|
+
finishResume() {
|
|
23968
24031
|
let drained;
|
|
23969
24032
|
while ((drained = this.stdin.read()) !== null)
|
|
23970
24033
|
this.stdinListener(drained);
|
|
23971
|
-
|
|
23972
|
-
this.stdinParser.pausePendingTimeout();
|
|
23973
|
-
else
|
|
23974
|
-
this.stdinParser?.reset();
|
|
24034
|
+
this.pauseStdinParsers(true);
|
|
23975
24035
|
this.stdin.on("data", this.stdinListener);
|
|
23976
24036
|
this.stdin.resume();
|
|
23977
24037
|
this.startTerminalKeepAlive();
|
|
23978
|
-
this.addExitListeners();
|
|
23979
24038
|
this._useMouse = this._suspendedMouseEnabled;
|
|
23980
24039
|
if (this._screenMode === "split-footer" && this._splitHeight > 0) {
|
|
23981
24040
|
this.syncSplitFooterState();
|
|
@@ -23986,7 +24045,8 @@ Captured external output:
|
|
|
23986
24045
|
this._controlState = this._previousControlState;
|
|
23987
24046
|
if (this.pixelResolutionRequeryPending)
|
|
23988
24047
|
this.queryPixelResolution();
|
|
23989
|
-
this.
|
|
24048
|
+
for (const parser of this.legacyStdinParsers())
|
|
24049
|
+
parser.resumePendingTimeout();
|
|
23990
24050
|
this.applyPendingNativeResize();
|
|
23991
24051
|
if (this._previousControlState === "auto_started" /* AUTO_STARTED */ || this._previousControlState === "explicit_started" /* EXPLICIT_STARTED */) {
|
|
23992
24052
|
this.internalStart();
|
|
@@ -24097,13 +24157,6 @@ Captured external output:
|
|
|
24097
24157
|
this.capturedRenderable = undefined;
|
|
24098
24158
|
this.removeCleanupListener(this.stdin, "data", this.stdinListener);
|
|
24099
24159
|
this.stopTerminalKeepAlive();
|
|
24100
|
-
if (this.stdin.setRawMode) {
|
|
24101
|
-
try {
|
|
24102
|
-
this.stdin.setRawMode(false);
|
|
24103
|
-
} catch (e) {
|
|
24104
|
-
console.error("Error disabling raw mode during destroy:", e);
|
|
24105
|
-
}
|
|
24106
|
-
}
|
|
24107
24160
|
try {
|
|
24108
24161
|
this.stdin.pause();
|
|
24109
24162
|
} catch (e) {
|
|
@@ -24159,6 +24212,9 @@ Captured external output:
|
|
|
24159
24212
|
}
|
|
24160
24213
|
this.stdinParser?.destroy();
|
|
24161
24214
|
this.stdinParser = null;
|
|
24215
|
+
this.stdinShadow?.parser.destroy();
|
|
24216
|
+
this.stdinShadow?.comparator.flush();
|
|
24217
|
+
this.stdinShadow = null;
|
|
24162
24218
|
this.oscSubscribers.clear();
|
|
24163
24219
|
try {
|
|
24164
24220
|
this._console?.destroy();
|
|
@@ -24196,6 +24252,13 @@ Captured external output:
|
|
|
24196
24252
|
this.nativeDestroyWait?.resolve();
|
|
24197
24253
|
this.resolveIdleIfNeeded();
|
|
24198
24254
|
}
|
|
24255
|
+
leaveRawMode() {
|
|
24256
|
+
try {
|
|
24257
|
+
this.stdin.setRawMode?.(false);
|
|
24258
|
+
} catch (e) {
|
|
24259
|
+
console.error("Error disabling raw mode:", e);
|
|
24260
|
+
}
|
|
24261
|
+
}
|
|
24199
24262
|
releaseStreamLease() {
|
|
24200
24263
|
if (!this._streamLeaseAcquired)
|
|
24201
24264
|
return;
|
|
@@ -24288,13 +24351,11 @@ Captured external output:
|
|
|
24288
24351
|
const sceneStart = performance.now();
|
|
24289
24352
|
const requestedBeforeScene = this.immediateRerenderRequested;
|
|
24290
24353
|
try {
|
|
24291
|
-
|
|
24354
|
+
this.nativeScene.paint(deltaTime, () => ({
|
|
24292
24355
|
background: this.backgroundColor,
|
|
24293
24356
|
useMouse: this._useMouse,
|
|
24294
24357
|
excludedHitNum: this.capturedRenderable?.num ?? 0
|
|
24295
24358
|
}));
|
|
24296
|
-
if (painting)
|
|
24297
|
-
await painting;
|
|
24298
24359
|
} catch (error) {
|
|
24299
24360
|
this.immediateRerenderRequested = requestedBeforeScene;
|
|
24300
24361
|
throw error;
|
|
@@ -24880,7 +24941,7 @@ Captured external output:
|
|
|
24880
24941
|
}
|
|
24881
24942
|
}
|
|
24882
24943
|
|
|
24883
|
-
export { isValidBorderStyle2, parseBorderStyle2, BorderChars2, getBorderFromSides2, getBorderSides2, borderCharsToArray2, BorderCharArrays2, KeyEvent2, PasteEvent2, KeyHandler2, InternalKeyHandler2, fonts2, measureText2, getCharacterPositions2, coordinateToCharacterIndex2, renderFontToFrameBuffer2,
|
|
24944
|
+
export { isValidBorderStyle2, parseBorderStyle2, BorderChars2, getBorderFromSides2, getBorderSides2, borderCharsToArray2, BorderCharArrays2, KeyEvent2, PasteEvent2, KeyHandler2, InternalKeyHandler2, fonts2, measureText2, getCharacterPositions2, coordinateToCharacterIndex2, renderFontToFrameBuffer2, hastToStyledText2, SystemClock2, nonAlphanumericKeys2, terminalNamedSingleStrokeKeys2, parseKeypress2, LinearScrollAccel2, MacOSScrollAccel2, parseAlign2, parseAlignItems2, parseBoxSizing2, parseDimension2, parseDirection2, parseDisplay2, parseEdge2, parseFlexDirection2, parseGutter2, parseJustify2, parseLogLevel2, parseMeasureMode2, parseOverflow2, parsePositionType2, parseUnit2, parseWrap2, MouseParser2, Selection2, convertGlobalToLocalSelection2, ASCIIFontSelectionHelper2, StdinParser2, addDefaultParsers2, TreeSitterClient2, treeSitterToTextChunks2, treeSitterToStyledText2, DataPathsManager2, getDataPaths2, extensionToFiletype2, basenameToFiletype2, extToFiletype2, pathToFiletype2, infoStringToFiletype2, getTreeSitterClient2, destroyTreeSitterClient2, ExtmarksController2, createExtmarksController2, TerminalPalette2, createTerminalPalette2, normalizeTerminalPalette2, buildTerminalPaletteSignature2, decodePasteBytes2, stripAnsiSequences2, createHostClipboard2, createClipboard2, ClipboardTarget2, createRendererClipboardAdapter2, normalizeMarkdownLinkTarget, detectLinks2, acquireSessionBufferLease2, ResourceContext2, OptimizedBuffer2, h2, isVNode2, maybeMakeRenderable2, wrapWithDelegates2, instantiate2, delegate2, LayoutEvents2, RenderableEvents2, isRenderable2, BaseRenderable2, Renderable2, RootRenderable2, TextBuffer2, TextBufferView2, EditBuffer2, measureEditText2, EditorView2, Timeline2, engine2, getTimelineEngine2, createTimeline2, ANSI, BoxRenderable2, wheelDirection, scrollOnce, TextBufferRenderable2, CodeRenderable2, ImageLoadError2, ImageError2, imageInfo2, NativeImage2, NativeImagePool2, resolveImageRenderProtocol2, ImageRenderable2, isTextNodeRenderable2, TextNodeRenderable2, RootTextNodeRenderable2, TextRenderable2, NativeSession2, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingAction, buildKeyBindingsMap, capture2, ConsolePosition2, TerminalConsole2, EditBufferRenderableEvents2, isEditBufferRenderable2, EditBufferRenderable2, buildKittyKeyboardFlags2, MouseEvent2, MouseButton2, createCliRenderer2, CliRenderEvents2, RendererControlState2, CliRenderer2 };
|
|
24884
24945
|
|
|
24885
|
-
//# debugId=
|
|
24886
|
-
//# sourceMappingURL=chunk-node-
|
|
24946
|
+
//# debugId=37A13ADEE7EBAEBB64756E2164756E21
|
|
24947
|
+
//# sourceMappingURL=chunk-node-7bcmqh18.js.map
|