@simon_he/vue-tui 1.0.2 → 1.1.1

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.
Files changed (104) hide show
  1. package/README.md +44 -26
  2. package/dist/TMermaidText-CXm_L969.js +885 -0
  3. package/dist/{TSelect-DR0FomSu.js → TSelect-CiyMvwl-.js} +60 -81
  4. package/dist/{TTree-kzhlB5P0.js → TTree-DKGiuIcM.js} +140 -103
  5. package/dist/agent/mermaid.cjs +2 -0
  6. package/dist/agent/mermaid.d.cts +2 -0
  7. package/dist/agent/mermaid.d.ts +2 -0
  8. package/dist/agent/mermaid.js +1 -0
  9. package/dist/agent.cjs +31184 -24907
  10. package/dist/agent.d.cts +11 -1
  11. package/dist/agent.d.ts +11 -1
  12. package/dist/agent.js +1700 -13
  13. package/dist/block-source-5CQp4tF8.js +3230 -0
  14. package/dist/cli/stdin-buffer.d.ts +1 -1
  15. package/dist/cli.cjs +5037 -6767
  16. package/dist/cli.d.cts +4 -0
  17. package/dist/cli.d.ts +4 -0
  18. package/dist/cli.js +2733 -148
  19. package/dist/core/buffer/eaw-ranges-unicode-17.d.ts +14 -0
  20. package/dist/core/perf/instrumentation-noop.d.ts +48 -0
  21. package/dist/core/perf/instrumentation.d.ts +136 -0
  22. package/dist/core/terminal/create-terminal.d.ts +1 -0
  23. package/dist/core.cjs +843 -1469
  24. package/dist/core.js +6 -6
  25. package/dist/{create-terminal-DBFNYr8f.js → create-terminal-DXuZ2fci.js} +39 -13
  26. package/dist/debug-logger-ChY_PXVk.js +74 -0
  27. package/dist/{dom-renderer-BniJSQyX.js → dom-renderer-DNzmg2As.js} +2 -2
  28. package/dist/experimental.cjs +4115 -5928
  29. package/dist/experimental.d.cts +2 -0
  30. package/dist/experimental.d.ts +2 -0
  31. package/dist/experimental.js +1490 -9
  32. package/dist/frame-perf-BBhE-iuS.js +111 -0
  33. package/dist/{sgr-BmzxEjAO.js → hyperlink-B35-O-cW.js} +100 -1
  34. package/dist/index.cjs +5017 -10339
  35. package/dist/index.js +16 -14
  36. package/dist/{linkify-D_gzn9Xq.js → linkify-CuuquMQT.js} +32 -3
  37. package/dist/markdown.cjs +21295 -12691
  38. package/dist/markdown.d.cts +1 -1
  39. package/dist/markdown.d.ts +1 -1
  40. package/dist/markdown.js +211 -51
  41. package/dist/mermaid-CWto52Wk.js +123 -0
  42. package/dist/mermaid.cjs +1707 -0
  43. package/dist/mermaid.d.cts +3 -0
  44. package/dist/mermaid.d.ts +3 -0
  45. package/dist/mermaid.js +6 -0
  46. package/dist/observability/frame-perf-store.d.ts +2 -1
  47. package/dist/observability/frame-perf.d.ts +33 -0
  48. package/dist/observability.cjs +106 -107
  49. package/dist/observability.d.cts +2 -2
  50. package/dist/observability.d.ts +2 -2
  51. package/dist/observability.js +3 -3
  52. package/dist/{path-suggest-BNqcuE3-.js → path-suggest-fPzRsgPv.js} +1 -1
  53. package/dist/{wheel-scroll-vBRaQ7p-.js → rect-Ng-3eKzF.js} +253 -117
  54. package/dist/renderer/cli/stdout-metrics.d.ts +10 -0
  55. package/dist/renderer/cli/stdout-renderer.d.ts +3 -0
  56. package/dist/renderer/terminal-graphic-render-queue.d.ts +50 -0
  57. package/dist/renderer/terminal-graphics-trace.d.ts +53 -0
  58. package/dist/renderer/terminal-graphics.d.ts +146 -0
  59. package/dist/renderer-dom.cjs +364 -903
  60. package/dist/renderer-dom.js +4 -4
  61. package/dist/runtime/index.d.ts +2 -0
  62. package/dist/{runtime-rfcZCyJq.js → runtime-D77C03RM.js} +28 -15
  63. package/dist/runtime.cjs +427 -889
  64. package/dist/runtime.js +2 -2
  65. package/dist/{terminal-selection-DBinO6p5.js → terminal-selection-CQYr--26.js} +4 -1
  66. package/dist/{tlog-theme-CvLFNMwk.js → tlog-theme-CopRt9SC.js} +37 -6
  67. package/dist/{trace-CjzYeIxN.js → trace-CYHDKM1m.js} +5 -0
  68. package/dist/vue/agent/create-png-terminal-graphic-renderer.d.ts +19 -0
  69. package/dist/vue/components/TAgentTerminalGraphic.d.ts +481 -0
  70. package/dist/vue/components/TCharts.d.ts +1121 -0
  71. package/dist/vue/components/TFeedback.d.ts +1 -1
  72. package/dist/vue/components/TFlex.d.ts +389 -0
  73. package/dist/vue/components/TForm.d.ts +4 -4
  74. package/dist/vue/components/TLogSearchBar.d.ts +3 -3
  75. package/dist/vue/components/TLogSearchPager.d.ts +2 -2
  76. package/dist/vue/components/TMarkdownText.d.ts +162 -4
  77. package/dist/vue/components/TMermaidText.d.ts +900 -0
  78. package/dist/vue/components/TVirtualList.d.ts +9 -0
  79. package/dist/vue/components/TVirtualMarkdown.d.ts +170 -9
  80. package/dist/vue/components/TVirtualRows.d.ts +9 -0
  81. package/dist/vue/components/TerminalProvider.d.ts +2 -0
  82. package/dist/vue/context.d.ts +24 -0
  83. package/dist/vue/index.d.ts +5 -0
  84. package/dist/vue/layout/flex.d.ts +67 -0
  85. package/dist/vue/markdown/ast.d.ts +5 -2
  86. package/dist/vue/markdown/document.d.ts +5 -0
  87. package/dist/vue/markdown/image-actions.d.ts +14 -0
  88. package/dist/vue/markdown/image.d.ts +11 -0
  89. package/dist/vue/markdown/link-actions.d.ts +14 -0
  90. package/dist/vue/markdown/math-actions.d.ts +14 -0
  91. package/dist/vue/markdown/math.d.ts +6 -0
  92. package/dist/vue/markdown/render.d.ts +28 -0
  93. package/dist/vue/markdown/types.d.ts +78 -0
  94. package/dist/vue/mermaid/beautiful-mermaid.d.ts +1436 -0
  95. package/dist/vue/render/render-manager.d.ts +7 -0
  96. package/dist/vue.cjs +7207 -12437
  97. package/dist/vue.js +706 -39
  98. package/dist/wheel-scroll-CQ22Hcyj.js +106 -0
  99. package/dist/{hyperlink-Bn02UXJb.js → width-GqllnV8C.js} +166 -111
  100. package/package.json +85 -14
  101. package/dist/block-source-CKUOnkgT.js +0 -1663
  102. package/dist/frame-perf-C6Xfg85O.js +0 -24
  103. /package/dist/{env-Cl8qmNFN.js → env-DNCzvX8b.js} +0 -0
  104. /package/dist/{path-mnSgEpCm.js → path-BI9W15Zt.js} +0 -0
@@ -0,0 +1,111 @@
1
+ //#region src/observability/frame-perf.ts
2
+ const FRAME_PERF_REASON_PRIORITY = {
3
+ unknown: 0,
4
+ manual: 1,
5
+ data: 2,
6
+ selection: 3,
7
+ stream: 4,
8
+ resize: 5,
9
+ scroll: 6,
10
+ input: 7
11
+ };
12
+ const EMPTY_METRIC_STATS = Object.freeze({
13
+ avg: 0,
14
+ max: 0,
15
+ min: 0
16
+ });
17
+ function metricStats(values) {
18
+ if (!values.length) return EMPTY_METRIC_STATS;
19
+ let sum = 0;
20
+ let max = Number.NEGATIVE_INFINITY;
21
+ let min = Number.POSITIVE_INFINITY;
22
+ for (const value of values) {
23
+ sum += value;
24
+ if (value > max) max = value;
25
+ if (value < min) min = value;
26
+ }
27
+ return {
28
+ avg: sum / values.length,
29
+ max,
30
+ min
31
+ };
32
+ }
33
+ function summarizeFramePerf(samples) {
34
+ const durationMs = [];
35
+ const renderManagerMs = [];
36
+ const commitMs = [];
37
+ const domFlushMs = [];
38
+ const stdoutFlushMs = [];
39
+ const dirtyRows = [];
40
+ const scannedNodes = [];
41
+ const paintedNodes = [];
42
+ const reasons = {};
43
+ const activePlanes = {};
44
+ let fullDirtyFrames = 0;
45
+ let coalescedInvalidates = 0;
46
+ let coalescedFrameTasks = 0;
47
+ let droppedUpdates = 0;
48
+ let maxQueueDepth = 0;
49
+ let rowBucketFallbacks = 0;
50
+ for (const sample of samples) {
51
+ durationMs.push(sample.durationMs);
52
+ renderManagerMs.push(sample.renderManagerMs);
53
+ commitMs.push(sample.commitMs);
54
+ scannedNodes.push(sample.scannedNodes);
55
+ paintedNodes.push(sample.paintedNodes);
56
+ if (sample.domFlushMs != null) domFlushMs.push(sample.domFlushMs);
57
+ if (sample.stdoutFlushMs != null) stdoutFlushMs.push(sample.stdoutFlushMs);
58
+ if (sample.dirtyRows == null) fullDirtyFrames++;
59
+ else dirtyRows.push(sample.dirtyRows);
60
+ reasons[sample.reason] = (reasons[sample.reason] ?? 0) + 1;
61
+ const planes = sample.activePlanes;
62
+ if (!planes) activePlanes.all = (activePlanes.all ?? 0) + 1;
63
+ else for (const plane of planes) activePlanes[plane] = (activePlanes[plane] ?? 0) + 1;
64
+ coalescedInvalidates += sample.coalescedInvalidates;
65
+ coalescedFrameTasks += sample.coalescedFrameTasks;
66
+ droppedUpdates += sample.droppedUpdates;
67
+ if (sample.queueDepth > maxQueueDepth) maxQueueDepth = sample.queueDepth;
68
+ rowBucketFallbacks += sample.rowBucketFallbacks?.length ?? 0;
69
+ }
70
+ const first = samples[0] ?? null;
71
+ const latest = samples[samples.length - 1] ?? null;
72
+ return {
73
+ frames: samples.length,
74
+ firstFrameId: first?.frameId ?? null,
75
+ latestFrameId: latest?.frameId ?? null,
76
+ windowMs: first && latest ? Math.max(0, latest.startedAt - first.startedAt) : 0,
77
+ durationMs: metricStats(durationMs),
78
+ renderManagerMs: metricStats(renderManagerMs),
79
+ commitMs: metricStats(commitMs),
80
+ domFlushMs: metricStats(domFlushMs),
81
+ stdoutFlushMs: metricStats(stdoutFlushMs),
82
+ dirtyRows: {
83
+ avg: dirtyRows.length ? dirtyRows.reduce((sum, value) => sum + value, 0) / dirtyRows.length : 0,
84
+ max: dirtyRows.length ? Math.max(...dirtyRows) : 0,
85
+ sampledFrames: dirtyRows.length,
86
+ fullFrames: fullDirtyFrames
87
+ },
88
+ scannedNodes: metricStats(scannedNodes),
89
+ paintedNodes: metricStats(paintedNodes),
90
+ coalescedInvalidates,
91
+ coalescedFrameTasks,
92
+ droppedUpdates,
93
+ maxQueueDepth,
94
+ rowBucketFallbacks,
95
+ reasons,
96
+ activePlanes
97
+ };
98
+ }
99
+ function framePerfNow() {
100
+ const p = globalThis.performance;
101
+ if (p && typeof p.now === "function") return p.now();
102
+ return Date.now();
103
+ }
104
+ function mergeFramePerfReason(prev, next) {
105
+ const a = prev ?? "unknown";
106
+ const b = next ?? "unknown";
107
+ return FRAME_PERF_REASON_PRIORITY[b] > FRAME_PERF_REASON_PRIORITY[a] ? b : a;
108
+ }
109
+
110
+ //#endregion
111
+ export { framePerfNow, mergeFramePerfReason, summarizeFramePerf };
@@ -301,4 +301,103 @@ function parseAnsiSgr(input, baseStyle = {}) {
301
301
  }
302
302
 
303
303
  //#endregion
304
- export { applyAnsiSgrStyle, parseAnsiSgr };
304
+ //#region src/utils/url-safety.ts
305
+ const ENCODED_ASCII_CONTROL_RE = /%(?:0[0-9a-f]|1[0-9a-f]|7f)/i;
306
+ function hasControlCodePoint(value) {
307
+ for (let i = 0; i < value.length; i++) {
308
+ const code = value.charCodeAt(i);
309
+ if (code <= 31 || code >= 127 && code <= 159) return true;
310
+ }
311
+ return false;
312
+ }
313
+ function hasEncodedControl(value) {
314
+ let current = String(value ?? "");
315
+ for (let depth = 0; depth < 3; depth++) {
316
+ if (ENCODED_ASCII_CONTROL_RE.test(current)) return true;
317
+ let decoded;
318
+ try {
319
+ decoded = decodeURIComponent(current);
320
+ } catch {
321
+ return true;
322
+ }
323
+ if (hasControlCodePoint(decoded)) return true;
324
+ if (decoded === current) return false;
325
+ current = decoded;
326
+ }
327
+ return ENCODED_ASCII_CONTROL_RE.test(current) || hasControlCodePoint(current);
328
+ }
329
+
330
+ //#endregion
331
+ //#region src/core/hyperlink.ts
332
+ const SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;
333
+ const BLOCKED_SCHEME_RE = /^(?:javascript|data|vbscript):/i;
334
+ const SAFE_RELATIVE_HREF_RE = /^(?:[A-Za-z0-9._~!$&()*+,;=:@/?#-]|%[0-9A-Fa-f]{2})+$/u;
335
+ function normalizeRawHref(value) {
336
+ if (typeof value !== "string") return null;
337
+ const raw = value.trim();
338
+ if (!raw) return null;
339
+ if (raw !== value) return null;
340
+ for (let i = 0; i < value.length; i++) {
341
+ const code = value.charCodeAt(i);
342
+ if (code <= 31 || code >= 127 && code <= 159) return null;
343
+ }
344
+ if (/\s/u.test(raw)) return null;
345
+ if (raw.startsWith("//")) return null;
346
+ if (BLOCKED_SCHEME_RE.test(raw)) return null;
347
+ if (hasEncodedControl(raw)) return null;
348
+ return raw;
349
+ }
350
+ function hrefScheme(raw) {
351
+ return raw.match(SCHEME_RE)?.[0].toLowerCase() ?? null;
352
+ }
353
+ function parseSafeAbsoluteUrl(raw) {
354
+ if (raw.includes("\\")) return null;
355
+ try {
356
+ return new URL(raw);
357
+ } catch {
358
+ return null;
359
+ }
360
+ }
361
+ function sanitizeAbsoluteHref(raw, options = {}) {
362
+ const url = parseSafeAbsoluteUrl(raw);
363
+ if (!url) return null;
364
+ if (url.protocol === "http:" || url.protocol === "https:") {
365
+ if (!/^https?:\/\//i.test(raw)) return null;
366
+ return options.preserveHttpHref ? raw : url.toString();
367
+ }
368
+ if (url.protocol === "mailto:") return raw;
369
+ return null;
370
+ }
371
+ function isSafeNormalizedRelativeHref(raw) {
372
+ if (raw.includes("\\")) return false;
373
+ if (raw.startsWith("//")) return false;
374
+ if (SCHEME_RE.test(raw)) return false;
375
+ if (hasEncodedControl(raw)) return false;
376
+ if (!SAFE_RELATIVE_HREF_RE.test(raw)) return false;
377
+ return raw.startsWith("#") || raw.startsWith("?") || raw.startsWith("/") || raw.startsWith("./") || raw.startsWith("../") || /^[A-Za-z0-9._~-]/u.test(raw);
378
+ }
379
+ function isSafeRelativeHref(value) {
380
+ const raw = normalizeRawHref(value);
381
+ return raw != null && isSafeNormalizedRelativeHref(raw);
382
+ }
383
+ function sanitizeTerminalHref(value, options = {}) {
384
+ const raw = normalizeRawHref(value);
385
+ if (!raw) return null;
386
+ const sanitized = sanitizeAbsoluteHref(raw, { preserveHttpHref: true });
387
+ if (sanitized) return sanitized;
388
+ if (options.allowFileUrls) {
389
+ const url = parseSafeAbsoluteUrl(raw);
390
+ if (url?.protocol === "file:") return url.toString();
391
+ }
392
+ return null;
393
+ }
394
+ function sanitizeDomHref(value, options = {}) {
395
+ const raw = normalizeRawHref(value);
396
+ if (!raw) return null;
397
+ const scheme = hrefScheme(raw);
398
+ if (!scheme) return options.allowRelative !== false && isSafeNormalizedRelativeHref(raw) ? raw : null;
399
+ return sanitizeAbsoluteHref(raw);
400
+ }
401
+
402
+ //#endregion
403
+ export { applyAnsiSgrStyle, hasEncodedControl, isSafeRelativeHref, parseAnsiSgr, sanitizeDomHref, sanitizeTerminalHref };