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