@simon_he/vue-tui 0.0.6 → 0.0.8
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/README.md +145 -470
- package/dist/experimental.cjs +8847 -0
- package/dist/experimental.d.ts +825 -0
- package/dist/experimental.js +7475 -0
- package/dist/index.cjs +7695 -4695
- package/dist/index.d.ts +396 -164
- package/dist/index.js +6086 -4232
- package/dist/markdown.cjs +20560 -0
- package/dist/markdown.d.ts +112 -0
- package/dist/markdown.js +1581 -0
- package/dist/path-suggest-BeV6n7m-.js +3 -0
- package/dist/sgr-Tko2EQ0U.js +484 -0
- package/dist/theme-Bsm65g8k.d.ts +32 -0
- package/dist/types-ClIV2h1o.d.ts +103 -0
- package/dist/wheel-scroll-CiNsasLf.js +825 -0
- package/package.json +83 -45
- package/dist/path-suggest-DIMby3r0.js +0 -3
- /package/dist/{path-suggest-CZQYJIIg.js → path-suggest-DmrmeueH.js} +0 -0
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
//#region src/vue/scheduler/frame-mailbox.ts
|
|
2
|
+
const EMPTY = Symbol("frame-mailbox-empty");
|
|
3
|
+
/**
|
|
4
|
+
* Coalesces many producer updates into a single scheduler frame task.
|
|
5
|
+
*
|
|
6
|
+
* This helper is currently internal to vue-tui. It is used by library
|
|
7
|
+
* components and internal tests, but it is not exported from the package root.
|
|
8
|
+
*
|
|
9
|
+
* Default behavior keeps only the latest queued value. If `merge` is provided,
|
|
10
|
+
* the pending value is updated with `merge(prev, next)`.
|
|
11
|
+
*
|
|
12
|
+
* Only the first queue() call in a pending cycle schedules a frame task.
|
|
13
|
+
* Later queue() calls update the pending payload and are reported as dropped
|
|
14
|
+
* producer updates when the frame task runs.
|
|
15
|
+
*
|
|
16
|
+
* droppedUpdates are reported after apply() succeeds. They only appear in
|
|
17
|
+
* framePerf when apply() also invalidates and produces a rendered frame sample.
|
|
18
|
+
* If apply() throws, scheduler error stats include mailbox queued/dropped
|
|
19
|
+
* metadata for the failed delivery attempt. The pending payload has already
|
|
20
|
+
* been cleared; mailbox delivery is fail-fast and does not retry stale payloads
|
|
21
|
+
* on later frames.
|
|
22
|
+
*
|
|
23
|
+
* cancel() is best-effort at scheduler level. The run callback still guards
|
|
24
|
+
* `disposed || !hasPending`, because a scheduler may already have taken a
|
|
25
|
+
* snapshot of tasks for the current frame.
|
|
26
|
+
*
|
|
27
|
+
* queue() returns false only when the scheduler explicitly rejects the task.
|
|
28
|
+
* Legacy void-returning schedulers are treated as accepted for compatibility.
|
|
29
|
+
* Owners should call dispose() before the component/scope that owns the
|
|
30
|
+
* mailbox is destroyed.
|
|
31
|
+
*
|
|
32
|
+
* id is scheduler-global. Components should include instance id and producer
|
|
33
|
+
* name, for example `TList:${uid}:wheel`.
|
|
34
|
+
*/
|
|
35
|
+
function createFrameMailbox(options) {
|
|
36
|
+
let disposed = false;
|
|
37
|
+
let hasPending = false;
|
|
38
|
+
let pending = EMPTY;
|
|
39
|
+
let queued = 0;
|
|
40
|
+
let pendingTaskId = null;
|
|
41
|
+
function clearPending() {
|
|
42
|
+
hasPending = false;
|
|
43
|
+
pending = EMPTY;
|
|
44
|
+
queued = 0;
|
|
45
|
+
pendingTaskId = null;
|
|
46
|
+
}
|
|
47
|
+
function currentTaskId() {
|
|
48
|
+
if (pendingTaskId) return pendingTaskId;
|
|
49
|
+
const id = typeof options.id === "function" ? options.id() : options.id;
|
|
50
|
+
if (!id) throw new Error("createFrameMailbox requires a non-empty task id");
|
|
51
|
+
pendingTaskId = id;
|
|
52
|
+
return pendingTaskId;
|
|
53
|
+
}
|
|
54
|
+
function queue(value) {
|
|
55
|
+
if (disposed) return false;
|
|
56
|
+
const wasPending = hasPending;
|
|
57
|
+
const taskId = wasPending ? pendingTaskId : currentTaskId();
|
|
58
|
+
let nextPending;
|
|
59
|
+
try {
|
|
60
|
+
nextPending = hasPending && options.merge ? options.merge(pending, value) : value;
|
|
61
|
+
} catch (error) {
|
|
62
|
+
var _options$scheduler$ca, _options$scheduler;
|
|
63
|
+
clearPending();
|
|
64
|
+
if (wasPending) (_options$scheduler$ca = (_options$scheduler = options.scheduler).cancelFrameTask) === null || _options$scheduler$ca === void 0 || _options$scheduler$ca.call(_options$scheduler, taskId);
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
pending = nextPending;
|
|
68
|
+
hasPending = true;
|
|
69
|
+
queued++;
|
|
70
|
+
if (wasPending) return true;
|
|
71
|
+
let accepted;
|
|
72
|
+
try {
|
|
73
|
+
accepted = options.scheduler.queueFrameTask({
|
|
74
|
+
id: taskId,
|
|
75
|
+
reason: options.reason,
|
|
76
|
+
priority: options.priority,
|
|
77
|
+
sync: options.sync,
|
|
78
|
+
run(ctx) {
|
|
79
|
+
var _ctx$reportMailboxDel, _ctx$reportDroppedUpd;
|
|
80
|
+
if (disposed || !hasPending) return;
|
|
81
|
+
const value$1 = pending;
|
|
82
|
+
const count = queued;
|
|
83
|
+
const dropped = Math.max(0, count - 1);
|
|
84
|
+
clearPending();
|
|
85
|
+
(_ctx$reportMailboxDel = ctx.reportMailboxDeliveryAttempt) === null || _ctx$reportMailboxDel === void 0 || _ctx$reportMailboxDel.call(ctx, {
|
|
86
|
+
id: taskId,
|
|
87
|
+
queued: count,
|
|
88
|
+
dropped
|
|
89
|
+
});
|
|
90
|
+
options.apply(value$1, ctx, {
|
|
91
|
+
queued: count,
|
|
92
|
+
dropped
|
|
93
|
+
});
|
|
94
|
+
(_ctx$reportDroppedUpd = ctx.reportDroppedUpdates) === null || _ctx$reportDroppedUpd === void 0 || _ctx$reportDroppedUpd.call(ctx, dropped);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
} catch (error) {
|
|
98
|
+
clearPending();
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
if (accepted === false) {
|
|
102
|
+
clearPending();
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
function replacePending(value) {
|
|
108
|
+
if (disposed) return false;
|
|
109
|
+
if (!hasPending) return queue(value);
|
|
110
|
+
pending = value;
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
function cancel() {
|
|
114
|
+
var _options$scheduler$ca2, _options$scheduler2;
|
|
115
|
+
const taskId = pendingTaskId;
|
|
116
|
+
clearPending();
|
|
117
|
+
if (taskId) (_options$scheduler$ca2 = (_options$scheduler2 = options.scheduler).cancelFrameTask) === null || _options$scheduler$ca2 === void 0 || _options$scheduler$ca2.call(_options$scheduler2, taskId);
|
|
118
|
+
}
|
|
119
|
+
function dispose() {
|
|
120
|
+
cancel();
|
|
121
|
+
disposed = true;
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
queue,
|
|
125
|
+
replacePending,
|
|
126
|
+
cancel,
|
|
127
|
+
dispose,
|
|
128
|
+
hasPending: () => hasPending,
|
|
129
|
+
peek: () => hasPending ? pending : void 0
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/vue/utils/style-cache.ts
|
|
135
|
+
const EMPTY_STYLE = Object.freeze({});
|
|
136
|
+
const inverseStyleCache = new WeakMap();
|
|
137
|
+
const dimStyleCache = new WeakMap();
|
|
138
|
+
function cacheBase(base) {
|
|
139
|
+
for (const key in base) if (Object.prototype.hasOwnProperty.call(base, key)) return base;
|
|
140
|
+
return EMPTY_STYLE;
|
|
141
|
+
}
|
|
142
|
+
function cacheable(base) {
|
|
143
|
+
return Object.isFrozen(base);
|
|
144
|
+
}
|
|
145
|
+
function defaultActiveStyle(base) {
|
|
146
|
+
if (base.inverse) return base;
|
|
147
|
+
base = cacheBase(base);
|
|
148
|
+
if (!cacheable(base)) return {
|
|
149
|
+
...base,
|
|
150
|
+
inverse: true
|
|
151
|
+
};
|
|
152
|
+
let cached = inverseStyleCache.get(base);
|
|
153
|
+
if (!cached) {
|
|
154
|
+
cached = Object.freeze({
|
|
155
|
+
...base,
|
|
156
|
+
inverse: true
|
|
157
|
+
});
|
|
158
|
+
inverseStyleCache.set(base, cached);
|
|
159
|
+
}
|
|
160
|
+
return cached;
|
|
161
|
+
}
|
|
162
|
+
function defaultDimStyle(base) {
|
|
163
|
+
if (base.dim) return base;
|
|
164
|
+
base = cacheBase(base);
|
|
165
|
+
if (!cacheable(base)) return {
|
|
166
|
+
...base,
|
|
167
|
+
dim: true
|
|
168
|
+
};
|
|
169
|
+
let cached = dimStyleCache.get(base);
|
|
170
|
+
if (!cached) {
|
|
171
|
+
cached = Object.freeze({
|
|
172
|
+
...base,
|
|
173
|
+
dim: true
|
|
174
|
+
});
|
|
175
|
+
dimStyleCache.set(base, cached);
|
|
176
|
+
}
|
|
177
|
+
return cached;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/core/ansi/sgr.ts
|
|
182
|
+
const ESC = "\x1B";
|
|
183
|
+
function ansi16ToColorName(code) {
|
|
184
|
+
switch (code) {
|
|
185
|
+
case 30: return "black";
|
|
186
|
+
case 31: return "red";
|
|
187
|
+
case 32: return "green";
|
|
188
|
+
case 33: return "yellow";
|
|
189
|
+
case 34: return "blue";
|
|
190
|
+
case 35: return "magenta";
|
|
191
|
+
case 36: return "cyan";
|
|
192
|
+
case 37: return "white";
|
|
193
|
+
case 90: return "blackBright";
|
|
194
|
+
case 91: return "redBright";
|
|
195
|
+
case 92: return "greenBright";
|
|
196
|
+
case 93: return "yellowBright";
|
|
197
|
+
case 94: return "blueBright";
|
|
198
|
+
case 95: return "magentaBright";
|
|
199
|
+
case 96: return "cyanBright";
|
|
200
|
+
case 97: return "whiteBright";
|
|
201
|
+
default: return void 0;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function ansi16BgToColorName(code) {
|
|
205
|
+
const fgCode = code >= 40 && code <= 47 ? code - 10 : code >= 100 && code <= 107 ? code - 10 : null;
|
|
206
|
+
if (fgCode == null) return void 0;
|
|
207
|
+
return ansi16ToColorName(fgCode);
|
|
208
|
+
}
|
|
209
|
+
const ANSI16_RGB = {
|
|
210
|
+
black: {
|
|
211
|
+
r: 0,
|
|
212
|
+
g: 0,
|
|
213
|
+
b: 0
|
|
214
|
+
},
|
|
215
|
+
red: {
|
|
216
|
+
r: 201,
|
|
217
|
+
g: 27,
|
|
218
|
+
b: 0
|
|
219
|
+
},
|
|
220
|
+
green: {
|
|
221
|
+
r: 0,
|
|
222
|
+
g: 194,
|
|
223
|
+
b: 0
|
|
224
|
+
},
|
|
225
|
+
yellow: {
|
|
226
|
+
r: 199,
|
|
227
|
+
g: 196,
|
|
228
|
+
b: 0
|
|
229
|
+
},
|
|
230
|
+
blue: {
|
|
231
|
+
r: 2,
|
|
232
|
+
g: 37,
|
|
233
|
+
b: 199
|
|
234
|
+
},
|
|
235
|
+
magenta: {
|
|
236
|
+
r: 201,
|
|
237
|
+
g: 48,
|
|
238
|
+
b: 199
|
|
239
|
+
},
|
|
240
|
+
cyan: {
|
|
241
|
+
r: 0,
|
|
242
|
+
g: 197,
|
|
243
|
+
b: 199
|
|
244
|
+
},
|
|
245
|
+
white: {
|
|
246
|
+
r: 199,
|
|
247
|
+
g: 199,
|
|
248
|
+
b: 199
|
|
249
|
+
},
|
|
250
|
+
blackBright: {
|
|
251
|
+
r: 104,
|
|
252
|
+
g: 104,
|
|
253
|
+
b: 104
|
|
254
|
+
},
|
|
255
|
+
redBright: {
|
|
256
|
+
r: 255,
|
|
257
|
+
g: 110,
|
|
258
|
+
b: 103
|
|
259
|
+
},
|
|
260
|
+
greenBright: {
|
|
261
|
+
r: 95,
|
|
262
|
+
g: 250,
|
|
263
|
+
b: 104
|
|
264
|
+
},
|
|
265
|
+
yellowBright: {
|
|
266
|
+
r: 255,
|
|
267
|
+
g: 252,
|
|
268
|
+
b: 103
|
|
269
|
+
},
|
|
270
|
+
blueBright: {
|
|
271
|
+
r: 104,
|
|
272
|
+
g: 113,
|
|
273
|
+
b: 255
|
|
274
|
+
},
|
|
275
|
+
magentaBright: {
|
|
276
|
+
r: 255,
|
|
277
|
+
g: 118,
|
|
278
|
+
b: 255
|
|
279
|
+
},
|
|
280
|
+
cyanBright: {
|
|
281
|
+
r: 95,
|
|
282
|
+
g: 253,
|
|
283
|
+
b: 255
|
|
284
|
+
},
|
|
285
|
+
whiteBright: {
|
|
286
|
+
r: 255,
|
|
287
|
+
g: 255,
|
|
288
|
+
b: 255
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
function nearestAnsi16(r, g, b) {
|
|
292
|
+
let best = "white";
|
|
293
|
+
let bestDist = Number.POSITIVE_INFINITY;
|
|
294
|
+
for (const [name, rgb] of Object.entries(ANSI16_RGB)) {
|
|
295
|
+
const dr = r - rgb.r;
|
|
296
|
+
const dg = g - rgb.g;
|
|
297
|
+
const db = b - rgb.b;
|
|
298
|
+
const d = dr * dr + dg * dg + db * db;
|
|
299
|
+
if (d < bestDist) {
|
|
300
|
+
bestDist = d;
|
|
301
|
+
best = name;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return best;
|
|
305
|
+
}
|
|
306
|
+
function ansi256ToRgb(index) {
|
|
307
|
+
const n = Math.max(0, Math.min(255, Math.trunc(index)));
|
|
308
|
+
if (n < 16) {
|
|
309
|
+
const map = [
|
|
310
|
+
"black",
|
|
311
|
+
"red",
|
|
312
|
+
"green",
|
|
313
|
+
"yellow",
|
|
314
|
+
"blue",
|
|
315
|
+
"magenta",
|
|
316
|
+
"cyan",
|
|
317
|
+
"white",
|
|
318
|
+
"blackBright",
|
|
319
|
+
"redBright",
|
|
320
|
+
"greenBright",
|
|
321
|
+
"yellowBright",
|
|
322
|
+
"blueBright",
|
|
323
|
+
"magentaBright",
|
|
324
|
+
"cyanBright",
|
|
325
|
+
"whiteBright"
|
|
326
|
+
];
|
|
327
|
+
const name = map[n] ?? "white";
|
|
328
|
+
return ANSI16_RGB[name];
|
|
329
|
+
}
|
|
330
|
+
if (n >= 232) {
|
|
331
|
+
const c = 8 + (n - 232) * 10;
|
|
332
|
+
return {
|
|
333
|
+
r: c,
|
|
334
|
+
g: c,
|
|
335
|
+
b: c
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
const i = n - 16;
|
|
339
|
+
const rr = Math.floor(i / 36);
|
|
340
|
+
const gg = Math.floor(i % 36 / 6);
|
|
341
|
+
const bb = i % 6;
|
|
342
|
+
const toComponent = (v) => v === 0 ? 0 : 55 + v * 40;
|
|
343
|
+
return {
|
|
344
|
+
r: toComponent(rr),
|
|
345
|
+
g: toComponent(gg),
|
|
346
|
+
b: toComponent(bb)
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
function applyAnsiSgrStyle(current, codes) {
|
|
350
|
+
let next = { ...current };
|
|
351
|
+
for (let i = 0; i < codes.length; i++) {
|
|
352
|
+
const code = codes[i];
|
|
353
|
+
if (code === 0) {
|
|
354
|
+
next = {};
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
if (code === 1) next = {
|
|
358
|
+
...next,
|
|
359
|
+
bold: true
|
|
360
|
+
};
|
|
361
|
+
else if (code === 2) next = {
|
|
362
|
+
...next,
|
|
363
|
+
dim: true
|
|
364
|
+
};
|
|
365
|
+
else if (code === 3) next = {
|
|
366
|
+
...next,
|
|
367
|
+
italic: true
|
|
368
|
+
};
|
|
369
|
+
else if (code === 4) next = {
|
|
370
|
+
...next,
|
|
371
|
+
underline: true
|
|
372
|
+
};
|
|
373
|
+
else if (code === 7) next = {
|
|
374
|
+
...next,
|
|
375
|
+
inverse: true
|
|
376
|
+
};
|
|
377
|
+
else if (code === 22) next = {
|
|
378
|
+
...next,
|
|
379
|
+
bold: false,
|
|
380
|
+
dim: false
|
|
381
|
+
};
|
|
382
|
+
else if (code === 23) next = {
|
|
383
|
+
...next,
|
|
384
|
+
italic: false
|
|
385
|
+
};
|
|
386
|
+
else if (code === 24) next = {
|
|
387
|
+
...next,
|
|
388
|
+
underline: false
|
|
389
|
+
};
|
|
390
|
+
else if (code === 27) next = {
|
|
391
|
+
...next,
|
|
392
|
+
inverse: false
|
|
393
|
+
};
|
|
394
|
+
else if (code === 39) next = {
|
|
395
|
+
...next,
|
|
396
|
+
fg: void 0
|
|
397
|
+
};
|
|
398
|
+
else if (code === 49) next = {
|
|
399
|
+
...next,
|
|
400
|
+
bg: void 0
|
|
401
|
+
};
|
|
402
|
+
else if (code >= 30 && code <= 37 || code >= 90 && code <= 97) {
|
|
403
|
+
const fg = ansi16ToColorName(code);
|
|
404
|
+
next = {
|
|
405
|
+
...next,
|
|
406
|
+
fg: fg ?? next.fg
|
|
407
|
+
};
|
|
408
|
+
} else if (code >= 40 && code <= 47 || code >= 100 && code <= 107) {
|
|
409
|
+
const bg = ansi16BgToColorName(code);
|
|
410
|
+
next = {
|
|
411
|
+
...next,
|
|
412
|
+
bg: bg ?? next.bg
|
|
413
|
+
};
|
|
414
|
+
} else if (code === 38 || code === 48) {
|
|
415
|
+
const mode = codes[i + 1];
|
|
416
|
+
if (mode === 5) {
|
|
417
|
+
const idx = codes[i + 2];
|
|
418
|
+
if (idx != null) {
|
|
419
|
+
const { r, g, b } = ansi256ToRgb(idx);
|
|
420
|
+
const name = nearestAnsi16(r, g, b);
|
|
421
|
+
next = code === 38 ? {
|
|
422
|
+
...next,
|
|
423
|
+
fg: name
|
|
424
|
+
} : {
|
|
425
|
+
...next,
|
|
426
|
+
bg: name
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
i += 2;
|
|
430
|
+
} else if (mode === 2) {
|
|
431
|
+
const r = codes[i + 2];
|
|
432
|
+
const g = codes[i + 3];
|
|
433
|
+
const b = codes[i + 4];
|
|
434
|
+
if (r != null && g != null && b != null) {
|
|
435
|
+
const name = nearestAnsi16(r, g, b);
|
|
436
|
+
next = code === 38 ? {
|
|
437
|
+
...next,
|
|
438
|
+
fg: name
|
|
439
|
+
} : {
|
|
440
|
+
...next,
|
|
441
|
+
bg: name
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
i += 4;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
return next;
|
|
449
|
+
}
|
|
450
|
+
function parseAnsiSgr(input, baseStyle = {}) {
|
|
451
|
+
const segments = [];
|
|
452
|
+
let style = { ...baseStyle };
|
|
453
|
+
let lastIndex = 0;
|
|
454
|
+
for (let i = 0; i < input.length; i++) {
|
|
455
|
+
if (input[i] !== ESC || input[i + 1] !== "[") continue;
|
|
456
|
+
let j = i + 2;
|
|
457
|
+
while (j < input.length) {
|
|
458
|
+
const c = input.charCodeAt(j);
|
|
459
|
+
if (c >= 48 && c <= 57 || c === 59) {
|
|
460
|
+
j++;
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
break;
|
|
464
|
+
}
|
|
465
|
+
if (j >= input.length || input[j] !== "m") continue;
|
|
466
|
+
if (i > lastIndex) segments.push({
|
|
467
|
+
text: input.slice(lastIndex, i),
|
|
468
|
+
style
|
|
469
|
+
});
|
|
470
|
+
const body = input.slice(i + 2, j);
|
|
471
|
+
const codes = body.split(";").filter(Boolean).map((n) => Number.parseInt(n, 10)).filter((n) => Number.isFinite(n));
|
|
472
|
+
style = applyAnsiSgrStyle(style, codes.length ? codes : [0]);
|
|
473
|
+
lastIndex = j + 1;
|
|
474
|
+
i = j;
|
|
475
|
+
}
|
|
476
|
+
if (lastIndex < input.length) segments.push({
|
|
477
|
+
text: input.slice(lastIndex),
|
|
478
|
+
style
|
|
479
|
+
});
|
|
480
|
+
return segments;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
//#endregion
|
|
484
|
+
export { applyAnsiSgrStyle, createFrameMailbox, defaultActiveStyle, defaultDimStyle, parseAnsiSgr };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Style } from "./types-ClIV2h1o.js";
|
|
2
|
+
|
|
3
|
+
//#region src/vue/markdown/theme.d.ts
|
|
4
|
+
type TuiMarkdownTheme = Readonly<{
|
|
5
|
+
heading: readonly [Style, Style, Style, Style, Style, Style];
|
|
6
|
+
strong: Style;
|
|
7
|
+
emphasis: Style;
|
|
8
|
+
strikethrough: Style;
|
|
9
|
+
inlineCode: Style;
|
|
10
|
+
link: Style;
|
|
11
|
+
blockquote: Style;
|
|
12
|
+
listMarker: Style;
|
|
13
|
+
codeBlock: Style;
|
|
14
|
+
thematicBreak: Style;
|
|
15
|
+
html: Style;
|
|
16
|
+
}>;
|
|
17
|
+
type TuiMarkdownThemeOverrides = Readonly<Partial<{
|
|
18
|
+
heading: readonly Partial<Style>[];
|
|
19
|
+
strong: Partial<Style>;
|
|
20
|
+
emphasis: Partial<Style>;
|
|
21
|
+
strikethrough: Partial<Style>;
|
|
22
|
+
inlineCode: Partial<Style>;
|
|
23
|
+
link: Partial<Style>;
|
|
24
|
+
blockquote: Partial<Style>;
|
|
25
|
+
listMarker: Partial<Style>;
|
|
26
|
+
codeBlock: Partial<Style>;
|
|
27
|
+
thematicBreak: Partial<Style>;
|
|
28
|
+
html: Partial<Style>;
|
|
29
|
+
}>>;
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { TuiMarkdownTheme, TuiMarkdownThemeOverrides };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//#region src/core/render-plane.d.ts
|
|
2
|
+
declare const TERMINAL_RENDER_PLANES: readonly ["default", "transcript", "chrome", "overlay"];
|
|
3
|
+
type TerminalRenderPlane = (typeof TERMINAL_RENDER_PLANES)[number];
|
|
4
|
+
type TerminalRenderPlanes = readonly TerminalRenderPlane[];
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/core/types.d.ts
|
|
8
|
+
type ThemeModeId = "dark" | "light";
|
|
9
|
+
type AnsiColorName = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright";
|
|
10
|
+
type Style = Readonly<{
|
|
11
|
+
/**
|
|
12
|
+
* Foreground color. Accepts:
|
|
13
|
+
* - `AnsiColorName` (e.g. `'cyanBright'`) — resolved via palette or standard ANSI codes
|
|
14
|
+
* - Hex string (e.g. `'#a9dc76'`) — converted to truecolor/ansi256 RGB
|
|
15
|
+
* - `'transparent'` — resets to terminal default (`\e[39m`)
|
|
16
|
+
*/
|
|
17
|
+
fg?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Background color. Same value space as `fg`.
|
|
20
|
+
* `'transparent'` resets to terminal default (`\e[49m`).
|
|
21
|
+
*/
|
|
22
|
+
bg?: string;
|
|
23
|
+
bold?: boolean;
|
|
24
|
+
dim?: boolean;
|
|
25
|
+
italic?: boolean;
|
|
26
|
+
underline?: boolean;
|
|
27
|
+
inverse?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Optional terminal hyperlink target (OSC 8).
|
|
30
|
+
* When set, renderers may emit a clickable hyperlink while keeping text width unchanged.
|
|
31
|
+
*/
|
|
32
|
+
href?: string;
|
|
33
|
+
}>;
|
|
34
|
+
type Cell = Readonly<{
|
|
35
|
+
ch: string;
|
|
36
|
+
width: 1 | 2;
|
|
37
|
+
continuation?: true;
|
|
38
|
+
style: Style;
|
|
39
|
+
}>;
|
|
40
|
+
type BufferSnapshot = Readonly<{
|
|
41
|
+
cols: number;
|
|
42
|
+
rows: number;
|
|
43
|
+
lines: readonly string[];
|
|
44
|
+
}>;
|
|
45
|
+
type TerminalSize = Readonly<{
|
|
46
|
+
cols: number;
|
|
47
|
+
rows: number;
|
|
48
|
+
}>;
|
|
49
|
+
type TerminalScrollOperation = Readonly<{
|
|
50
|
+
startY: number;
|
|
51
|
+
endY: number;
|
|
52
|
+
delta: number;
|
|
53
|
+
}>;
|
|
54
|
+
type TerminalCommitEvent = Readonly<{
|
|
55
|
+
dirtyRows: readonly number[] | null;
|
|
56
|
+
planes: TerminalRenderPlanes | null;
|
|
57
|
+
/** Renderer hint: try same-frame flush within backend budget; large DOM work may defer. */
|
|
58
|
+
sync?: boolean;
|
|
59
|
+
scrollOperations?: readonly TerminalScrollOperation[] | null;
|
|
60
|
+
}>;
|
|
61
|
+
type TerminalResizeEvent = Readonly<{
|
|
62
|
+
cols: number;
|
|
63
|
+
rows: number;
|
|
64
|
+
}>;
|
|
65
|
+
interface TerminalEventMap {
|
|
66
|
+
commit: TerminalCommitEvent;
|
|
67
|
+
resize: TerminalResizeEvent;
|
|
68
|
+
}
|
|
69
|
+
interface Terminal {
|
|
70
|
+
resize: (cols: number, rows: number) => void;
|
|
71
|
+
clear: (x?: number, y?: number, w?: number, h?: number) => void;
|
|
72
|
+
write: (text: string, opts?: {
|
|
73
|
+
x?: number;
|
|
74
|
+
y?: number;
|
|
75
|
+
style?: Style;
|
|
76
|
+
}) => void;
|
|
77
|
+
writeAnsi: (text: string, opts?: {
|
|
78
|
+
x?: number;
|
|
79
|
+
y?: number;
|
|
80
|
+
}) => void;
|
|
81
|
+
put: (x: number, y: number, ch: string, style?: Style) => void;
|
|
82
|
+
fill: (x: number, y: number, w: number, h: number, ch?: string, style?: Style) => void;
|
|
83
|
+
scroll: (lines: number) => void;
|
|
84
|
+
setCursor: (x: number, y: number, visible?: boolean) => void;
|
|
85
|
+
batch: <T>(fn: () => T) => T;
|
|
86
|
+
commit: (meta?: {
|
|
87
|
+
planes?: TerminalRenderPlanes | null;
|
|
88
|
+
sync?: boolean;
|
|
89
|
+
}) => readonly number[] | null;
|
|
90
|
+
on: <K extends keyof TerminalEventMap>(event: K, cb: (payload: TerminalEventMap[K]) => void) => () => void;
|
|
91
|
+
dispose: () => void;
|
|
92
|
+
size: () => TerminalSize;
|
|
93
|
+
snapshot: () => BufferSnapshot;
|
|
94
|
+
getCell: (x: number, y: number) => Cell;
|
|
95
|
+
getRow: (y: number) => readonly Cell[];
|
|
96
|
+
setScrollbackLimit: (limit: number) => void;
|
|
97
|
+
getScrollbackLines: (count?: number) => readonly string[];
|
|
98
|
+
/** Register fingerprint function for SoA pre-computation on the composite buffer. */
|
|
99
|
+
setFingerprintFn: (fn: (ch: string, style: Style) => number) => void;
|
|
100
|
+
/** Get pre-computed fingerprints for a composite buffer row (null if not enabled). */
|
|
101
|
+
getRowFingerprints: (y: number) => Uint32Array | null;
|
|
102
|
+
} //#endregion
|
|
103
|
+
export { AnsiColorName, BufferSnapshot, Cell, Style, TERMINAL_RENDER_PLANES, Terminal, TerminalCommitEvent, TerminalEventMap, TerminalRenderPlane, TerminalRenderPlanes, TerminalResizeEvent, TerminalScrollOperation, ThemeModeId };
|