@simon_he/vue-tui 0.0.8 → 1.0.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.
Files changed (249) hide show
  1. package/README.md +142 -30
  2. package/dist/TSelect-BwJJbuTt.js +6089 -0
  3. package/dist/TTree-DK_DQBYm.js +6480 -0
  4. package/dist/agent.cjs +39416 -0
  5. package/dist/agent.d.cts +44 -0
  6. package/dist/agent.d.ts +44 -0
  7. package/dist/agent.js +828 -0
  8. package/dist/ansi-palette-CNXqFciC.js +57 -0
  9. package/dist/ansi-styles.d.ts +200 -0
  10. package/dist/block-source-CKUOnkgT.js +1663 -0
  11. package/dist/cli/headless-renderer.d.ts +29 -0
  12. package/dist/cli/input.d.ts +49 -0
  13. package/dist/cli/node-file-writers.d.ts +13 -0
  14. package/dist/cli/node-module.d.ts +2 -0
  15. package/dist/cli/parse-kitty.d.ts +2 -0
  16. package/dist/cli/parse-mouse.d.ts +2 -0
  17. package/dist/cli/parse-utils.d.ts +14 -0
  18. package/dist/cli/parse-xterm.d.ts +2 -0
  19. package/dist/cli/path-provider-types.d.ts +1 -0
  20. package/dist/cli/path-provider.d.ts +4 -0
  21. package/dist/cli/path-suggest-core.d.ts +1 -0
  22. package/dist/cli/path-suggest.d.ts +15 -0
  23. package/dist/cli/recording.d.ts +4 -0
  24. package/dist/cli/stdin-buffer.d.ts +33 -0
  25. package/dist/cli.cjs +11061 -0
  26. package/dist/cli.d.cts +23 -0
  27. package/dist/cli.d.ts +23 -0
  28. package/dist/cli.js +9875 -0
  29. package/dist/core/ansi/capability.d.ts +20 -0
  30. package/dist/core/ansi/colors.d.ts +41 -0
  31. package/dist/core/ansi/sgr.d.ts +7 -0
  32. package/dist/core/ansi/theme.d.ts +6 -0
  33. package/dist/core/ansi-palette.d.ts +14 -0
  34. package/dist/core/buffer/buffer.d.ts +54 -0
  35. package/dist/core/buffer/width.d.ts +4 -0
  36. package/dist/core/debug-logger.d.ts +18 -0
  37. package/dist/core/hyperlink.d.ts +9 -0
  38. package/dist/core/index.d.ts +4 -0
  39. package/dist/core/path-provider-types.d.ts +24 -0
  40. package/dist/core/path-suggest.d.ts +35 -0
  41. package/dist/core/render-plane.d.ts +3 -0
  42. package/dist/core/terminal/create-terminal.d.ts +8 -0
  43. package/dist/core/terminal/emitter.d.ts +7 -0
  44. package/dist/core/types.d.ts +107 -0
  45. package/dist/core.cjs +3153 -0
  46. package/dist/core.d.cts +14 -0
  47. package/dist/core.d.ts +14 -0
  48. package/dist/core.js +424 -0
  49. package/dist/create-terminal-C2oiWFJU.js +1434 -0
  50. package/dist/create-terminal-app.d.ts +36 -0
  51. package/dist/dom-renderer-BqGijQID.js +1173 -0
  52. package/dist/env-Cl8qmNFN.js +19 -0
  53. package/dist/events/index.d.ts +6 -0
  54. package/dist/events/manager/cli-event-manager.d.ts +22 -0
  55. package/dist/events/manager/event-manager.d.ts +30 -0
  56. package/dist/events/manager/selection-suppression.d.ts +3 -0
  57. package/dist/events/manager/types.d.ts +108 -0
  58. package/dist/events/recording.d.ts +44 -0
  59. package/dist/experimental.cjs +4412 -1641
  60. package/dist/experimental.d.cts +42 -0
  61. package/dist/experimental.d.ts +42 -825
  62. package/dist/experimental.js +31 -7392
  63. package/dist/frame-perf-C6Xfg85O.js +24 -0
  64. package/dist/hyperlink-Bn02UXJb.js +419 -0
  65. package/dist/index.cjs +14765 -17582
  66. package/dist/index.d.cts +35 -0
  67. package/dist/index.d.ts +35 -1528
  68. package/dist/index.js +17 -20026
  69. package/dist/linkify-D_gzn9Xq.js +562 -0
  70. package/dist/markdown.cjs +9321 -7623
  71. package/dist/markdown.d.cts +11 -0
  72. package/dist/markdown.d.ts +11 -112
  73. package/dist/markdown.js +36 -1427
  74. package/dist/observability/cli-latency-node.d.ts +3 -0
  75. package/dist/observability/cli-latency-types.d.ts +41 -0
  76. package/dist/observability/cli-latency.d.ts +3 -0
  77. package/dist/observability/frame-perf-store.d.ts +18 -0
  78. package/dist/observability/frame-perf.d.ts +40 -0
  79. package/dist/observability/perf-sink.d.ts +56 -0
  80. package/dist/observability/trace.d.ts +40 -0
  81. package/dist/observability/tui-profiler.d.ts +33 -0
  82. package/dist/observability.cjs +221 -0
  83. package/dist/observability.d.cts +8 -0
  84. package/dist/observability.d.ts +8 -0
  85. package/dist/observability.js +4 -0
  86. package/dist/path-mnSgEpCm.js +81 -0
  87. package/dist/path-suggest-BNqcuE3-.js +274 -0
  88. package/dist/path-suggest-Dk9TRLh5.js +3 -0
  89. package/dist/{path-suggest-DmrmeueH.js → path-suggest-bvR9SY6Q.js} +86 -18
  90. package/dist/renderer/capabilities.d.ts +13 -0
  91. package/dist/renderer/cli/index.d.ts +2 -0
  92. package/dist/renderer/cli/stdout-metrics.d.ts +18 -0
  93. package/dist/renderer/cli/stdout-renderer.d.ts +48 -0
  94. package/dist/renderer/dom/dom-renderer.d.ts +157 -0
  95. package/dist/renderer/dom/index.d.ts +2 -0
  96. package/dist/renderer/index.d.ts +2 -0
  97. package/dist/renderer-dom.cjs +1505 -0
  98. package/dist/renderer-dom.d.cts +4 -0
  99. package/dist/renderer-dom.d.ts +4 -0
  100. package/dist/renderer-dom.js +7 -0
  101. package/dist/runtime/index.d.ts +36 -0
  102. package/dist/runtime/osc52.d.ts +9 -0
  103. package/dist/runtime-rfcZCyJq.js +1197 -0
  104. package/dist/runtime.cjs +1698 -0
  105. package/dist/runtime.d.cts +9 -0
  106. package/dist/runtime.d.ts +9 -0
  107. package/dist/runtime.js +4 -0
  108. package/dist/selection/terminal-selection.d.ts +123 -0
  109. package/dist/sgr-BmzxEjAO.js +304 -0
  110. package/dist/terminal-selection-DBinO6p5.js +330 -0
  111. package/dist/tlog-theme-qPBt5rge.js +9254 -0
  112. package/dist/trace-CjzYeIxN.js +182 -0
  113. package/dist/utils/env.d.ts +3 -0
  114. package/dist/utils/grapheme.d.ts +5 -0
  115. package/dist/utils/newlines.d.ts +1 -0
  116. package/dist/utils/path.d.ts +7 -0
  117. package/dist/utils/url-safety.d.ts +2 -0
  118. package/dist/vue/agent/view-models.d.ts +98 -0
  119. package/dist/vue/components/TAnchor.d.ts +108 -0
  120. package/dist/vue/components/TBox.d.ts +144 -0
  121. package/dist/vue/components/TCommandPalette.d.ts +587 -0
  122. package/dist/vue/components/TDataTable.d.ts +367 -0
  123. package/dist/vue/components/TDebugOverlay.d.ts +43 -0
  124. package/dist/vue/components/TDialog.d.ts +255 -0
  125. package/dist/vue/components/TFeedback.d.ts +635 -0
  126. package/dist/vue/components/TFlow.d.ts +85 -0
  127. package/dist/vue/components/TForm.d.ts +1230 -0
  128. package/dist/vue/components/TInput.d.ts +545 -0
  129. package/dist/vue/components/TInputBox.d.ts +158 -0
  130. package/dist/vue/components/TJsonEditor.d.ts +165 -0
  131. package/dist/vue/components/TLink.d.ts +239 -0
  132. package/dist/vue/components/TLinkifyText.d.ts +141 -0
  133. package/dist/vue/components/TList.d.ts +119 -0
  134. package/dist/vue/components/TLogLinksPanel.d.ts +238 -0
  135. package/dist/vue/components/TLogMinimap.d.ts +263 -0
  136. package/dist/vue/components/TLogScrollbar.d.ts +236 -0
  137. package/dist/vue/components/TLogSearchBar.d.ts +267 -0
  138. package/dist/vue/components/TLogSearchPager.d.ts +162 -0
  139. package/dist/vue/components/TLogSearchResults.d.ts +200 -0
  140. package/dist/vue/components/TLogView.d.ts +536 -0
  141. package/dist/vue/components/TLogVirtualLinksPanel.d.ts +141 -0
  142. package/dist/vue/components/TLogVirtualSearchResults.d.ts +146 -0
  143. package/dist/vue/components/TMarkdownText.d.ts +134 -0
  144. package/dist/vue/components/TMultilineModal.d.ts +62 -0
  145. package/dist/vue/components/TNavigation.d.ts +324 -0
  146. package/dist/vue/components/TOverlay.d.ts +366 -0
  147. package/dist/vue/components/TPanels.d.ts +244 -0
  148. package/dist/vue/components/TPathPicker.d.ts +213 -0
  149. package/dist/vue/components/TRenderLayer.d.ts +16 -0
  150. package/dist/vue/components/TRenderPlane.d.ts +17 -0
  151. package/dist/vue/components/TSelect.d.ts +335 -0
  152. package/dist/vue/components/TTable.d.ts +317 -0
  153. package/dist/vue/components/TText.d.ts +116 -0
  154. package/dist/vue/components/TThinkingView.d.ts +233 -0
  155. package/dist/vue/components/TToolCallView.d.ts +384 -0
  156. package/dist/vue/components/TTranscriptView.d.ts +221 -0
  157. package/dist/vue/components/TTransition.d.ts +83 -0
  158. package/dist/vue/components/TTree.d.ts +200 -0
  159. package/dist/vue/components/TUserMessageView.d.ts +344 -0
  160. package/dist/vue/components/TView.d.ts +127 -0
  161. package/dist/vue/components/TVirtualList.d.ts +182 -0
  162. package/dist/vue/components/TVirtualMarkdown.d.ts +168 -0
  163. package/dist/vue/components/TVirtualRows.d.ts +247 -0
  164. package/dist/vue/components/TerminalProvider.d.ts +218 -0
  165. package/dist/vue/components/input/host.d.ts +17 -0
  166. package/dist/vue/components/input/plugins/hostPlugin.d.ts +7 -0
  167. package/dist/vue/components/input/plugins/hostPlugin.node.d.ts +15 -0
  168. package/dist/vue/components/input/plugins/mentionUtils.d.ts +17 -0
  169. package/dist/vue/components/input/plugins/nodeMentionPathProvider.d.ts +2 -0
  170. package/dist/vue/components/input/plugins/promptMentionPlugin.d.ts +8 -0
  171. package/dist/vue/components/input/plugins/promptMentionState.d.ts +98 -0
  172. package/dist/vue/components/input/plugins/restrictText.d.ts +27 -0
  173. package/dist/vue/components/input/plugins/types.d.ts +90 -0
  174. package/dist/vue/components/input/utils/inlineText.d.ts +57 -0
  175. package/dist/vue/components/input/utils/inlineTextTokens.d.ts +34 -0
  176. package/dist/vue/components/input/utils/primitives.d.ts +3 -0
  177. package/dist/vue/components/input/utils/wordNavigation.d.ts +6 -0
  178. package/dist/vue/components/link/host.d.ts +15 -0
  179. package/dist/vue/components/list/list-geometry.d.ts +16 -0
  180. package/dist/vue/components/list/list-paint.d.ts +1 -0
  181. package/dist/vue/components/list/scroll-state.d.ts +25 -0
  182. package/dist/vue/components/list/selection-state.d.ts +6 -0
  183. package/dist/vue/components/simple-utils.d.ts +5 -0
  184. package/dist/vue/components/terminal-provider/copy-toast.d.ts +6 -0
  185. package/dist/vue/components/terminal-provider/portals.d.ts +17 -0
  186. package/dist/vue/components/terminal-provider/scheduler.d.ts +29 -0
  187. package/dist/vue/components/terminal-provider/selection-config.d.ts +15 -0
  188. package/dist/vue/components/terminal-provider/utils.d.ts +5 -0
  189. package/dist/vue/composables/use-layout.d.ts +2 -0
  190. package/dist/vue/composables/use-render-node.d.ts +19 -0
  191. package/dist/vue/composables/use-render-stack.d.ts +3 -0
  192. package/dist/vue/composables/use-runtime.d.ts +5 -0
  193. package/dist/vue/composables/use-terminal-node.d.ts +14 -0
  194. package/dist/vue/composables/use-terminal.d.ts +2 -0
  195. package/dist/vue/composables/use-visibility.d.ts +12 -0
  196. package/dist/vue/context.d.ts +153 -0
  197. package/dist/vue/index.d.ts +69 -0
  198. package/dist/vue/injection-key.d.ts +2 -0
  199. package/dist/vue/linkify.d.ts +11 -0
  200. package/dist/vue/log/append-only-log-store.d.ts +2 -0
  201. package/dist/vue/log/tlog-keymap.d.ts +28 -0
  202. package/dist/vue/log/tlog-plugins.d.ts +144 -0
  203. package/dist/vue/log/tlog-session.d.ts +81 -0
  204. package/dist/vue/log/tlog-theme.d.ts +68 -0
  205. package/dist/vue/log/types.d.ts +43 -0
  206. package/dist/vue/log/use-tlog-link-controller.d.ts +31 -0
  207. package/dist/vue/log/use-tlog-retained-index.d.ts +26 -0
  208. package/dist/vue/log/use-tlog-search-controller.d.ts +51 -0
  209. package/dist/vue/log/use-tlog-search-results-page.d.ts +31 -0
  210. package/dist/vue/log/use-tlog-virtual-search-results.d.ts +22 -0
  211. package/dist/vue/markdown/ast.d.ts +3 -0
  212. package/dist/vue/markdown/block-source.d.ts +22 -0
  213. package/dist/vue/markdown/document.d.ts +20 -0
  214. package/dist/vue/markdown/layout.d.ts +21 -0
  215. package/dist/vue/markdown/parser.d.ts +11 -0
  216. package/dist/vue/markdown/render.d.ts +10 -0
  217. package/dist/vue/markdown/theme.d.ts +186 -0
  218. package/dist/vue/markdown/types.d.ts +59 -0
  219. package/dist/vue/overlay.d.ts +27 -0
  220. package/dist/vue/render/context.d.ts +3 -0
  221. package/dist/vue/render/render-manager.d.ts +94 -0
  222. package/dist/vue/router/RouterView.d.ts +25 -0
  223. package/dist/vue/router/composables.d.ts +4 -0
  224. package/dist/vue/router/context.d.ts +4 -0
  225. package/dist/vue/router/router.d.ts +7 -0
  226. package/dist/vue/router/types.d.ts +29 -0
  227. package/dist/vue/scheduler/frame-mailbox.d.ts +55 -0
  228. package/dist/vue/scheduler/frame-scheduler.d.ts +51 -0
  229. package/dist/vue/theme.d.ts +48 -0
  230. package/dist/vue/transcript/hit-regions.d.ts +2 -0
  231. package/dist/vue/transcript/layout.d.ts +20 -0
  232. package/dist/vue/transcript/plain-text.d.ts +2 -0
  233. package/dist/vue/transcript/types.d.ts +122 -0
  234. package/dist/vue/utils/frame-task.d.ts +6 -0
  235. package/dist/vue/utils/rect.d.ts +4 -0
  236. package/dist/vue/utils/row-scroll.d.ts +25 -0
  237. package/dist/vue/utils/style-cache.d.ts +3 -0
  238. package/dist/vue/utils/text.d.ts +27 -0
  239. package/dist/vue/utils/wheel-scroll.d.ts +18 -0
  240. package/dist/vue.cjs +23668 -0
  241. package/dist/vue.d.cts +1 -0
  242. package/dist/vue.d.ts +1 -0
  243. package/dist/vue.js +3957 -0
  244. package/dist/{wheel-scroll-CiNsasLf.js → wheel-scroll-vBRaQ7p-.js} +404 -405
  245. package/package.json +185 -35
  246. package/dist/path-suggest-BeV6n7m-.js +0 -3
  247. package/dist/sgr-Tko2EQ0U.js +0 -484
  248. package/dist/theme-Bsm65g8k.d.ts +0 -32
  249. package/dist/types-ClIV2h1o.d.ts +0 -103
@@ -0,0 +1,24 @@
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
+ function framePerfNow() {
13
+ const p = globalThis.performance;
14
+ if (p && typeof p.now === "function") return p.now();
15
+ return Date.now();
16
+ }
17
+ function mergeFramePerfReason(prev, next) {
18
+ const a = prev ?? "unknown";
19
+ const b = next ?? "unknown";
20
+ return FRAME_PERF_REASON_PRIORITY[b] > FRAME_PERF_REASON_PRIORITY[a] ? b : a;
21
+ }
22
+
23
+ //#endregion
24
+ export { framePerfNow, mergeFramePerfReason };
@@ -0,0 +1,419 @@
1
+ //#region src/utils/grapheme.ts
2
+ let graphemeSegmenter = null;
3
+ try {
4
+ const Segmenter = typeof Intl !== "undefined" ? Intl.Segmenter : void 0;
5
+ graphemeSegmenter = Segmenter ? new Segmenter(void 0, { granularity: "grapheme" }) : null;
6
+ } catch {
7
+ graphemeSegmenter = null;
8
+ }
9
+ let unicodeMarkRe = null;
10
+ try {
11
+ unicodeMarkRe = new RegExp("\\p{Mark}", "u");
12
+ } catch {
13
+ unicodeMarkRe = null;
14
+ }
15
+ function needsGraphemeSegmentation(text) {
16
+ for (const ch of text) {
17
+ const cp = ch.codePointAt(0);
18
+ if (cp === 8205) return true;
19
+ if (cp >= 65024 && cp <= 65039 || cp >= 917760 && cp <= 917999) return true;
20
+ if (isCombiningMark(cp)) return true;
21
+ if (cp >= 127995 && cp <= 127999) return true;
22
+ if (cp >= 127462 && cp <= 127487) return true;
23
+ if (cp >= 917504 && cp <= 917631) return true;
24
+ }
25
+ return false;
26
+ }
27
+ function isVariationSelector(codePoint) {
28
+ return codePoint >= 65024 && codePoint <= 65039 || codePoint >= 917760 && codePoint <= 917999;
29
+ }
30
+ function isCombiningMark(codePoint) {
31
+ return codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071 || isDevanagariMark(codePoint) || unicodeMarkRe?.test(String.fromCodePoint(codePoint)) === true;
32
+ }
33
+ function isDevanagariMark(codePoint) {
34
+ return codePoint >= 2304 && codePoint <= 2307 || codePoint >= 2362 && codePoint <= 2364 || codePoint >= 2366 && codePoint <= 2383 || codePoint >= 2385 && codePoint <= 2391 || codePoint >= 2402 && codePoint <= 2403;
35
+ }
36
+ function isVirama(codePoint) {
37
+ return codePoint === 2381;
38
+ }
39
+ function isEmojiModifier(codePoint) {
40
+ return codePoint >= 127995 && codePoint <= 127999;
41
+ }
42
+ function isRegionalIndicator(codePoint) {
43
+ return codePoint >= 127462 && codePoint <= 127487;
44
+ }
45
+ function isEmojiTag(codePoint) {
46
+ return codePoint >= 917504 && codePoint <= 917631;
47
+ }
48
+ function fallbackGraphemeSegments(text) {
49
+ const out = [];
50
+ let segment = "";
51
+ let segmentStart = 0;
52
+ let pos = 0;
53
+ let regionalIndicators = 0;
54
+ let joinNext = false;
55
+ const pushSegment = () => {
56
+ if (segment) out.push({
57
+ segment,
58
+ index: segmentStart
59
+ });
60
+ };
61
+ for (const ch of text) {
62
+ const codePoint = ch.codePointAt(0);
63
+ const chStart = pos;
64
+ pos += ch.length;
65
+ const attach = segment !== "" && (joinNext || codePoint === 8205 || isVariationSelector(codePoint) || isCombiningMark(codePoint) || isEmojiModifier(codePoint) || isEmojiTag(codePoint) || isRegionalIndicator(codePoint) && regionalIndicators === 1);
66
+ if (!attach) {
67
+ pushSegment();
68
+ segment = ch;
69
+ segmentStart = chStart;
70
+ regionalIndicators = isRegionalIndicator(codePoint) ? 1 : 0;
71
+ } else {
72
+ segment += ch;
73
+ if (isRegionalIndicator(codePoint)) regionalIndicators++;
74
+ else if (!isVariationSelector(codePoint) && !isCombiningMark(codePoint)) regionalIndicators = 0;
75
+ }
76
+ if (codePoint === 8205 || isVirama(codePoint)) joinNext = true;
77
+ else if (joinNext && !isVariationSelector(codePoint) && !isCombiningMark(codePoint)) joinNext = false;
78
+ }
79
+ pushSegment();
80
+ return out;
81
+ }
82
+ function segmentedGraphemes(text) {
83
+ if (!needsGraphemeSegmentation(text)) return null;
84
+ if (graphemeSegmenter) return graphemeSegmenter.segment(text);
85
+ return fallbackGraphemeSegments(text);
86
+ }
87
+
88
+ //#endregion
89
+ //#region src/core/buffer/width.ts
90
+ const fullWidthRanges = [
91
+ [4352, 4447],
92
+ [9001, 9002],
93
+ [11904, 42191],
94
+ [44032, 55203],
95
+ [63744, 64255],
96
+ [65040, 65049],
97
+ [65072, 65135],
98
+ [65280, 65376],
99
+ [65504, 65510]
100
+ ];
101
+ const ambiguousWidthRanges = [
102
+ [161, 161],
103
+ [164, 164],
104
+ [167, 168],
105
+ [170, 170],
106
+ [173, 174],
107
+ [176, 180],
108
+ [182, 186],
109
+ [188, 191],
110
+ [198, 198],
111
+ [208, 208],
112
+ [215, 216],
113
+ [222, 225],
114
+ [230, 230],
115
+ [232, 234],
116
+ [236, 237],
117
+ [240, 240],
118
+ [242, 243],
119
+ [247, 250],
120
+ [252, 252],
121
+ [254, 254],
122
+ [257, 257],
123
+ [273, 273],
124
+ [275, 275],
125
+ [283, 283],
126
+ [294, 295],
127
+ [299, 299],
128
+ [305, 307],
129
+ [312, 312],
130
+ [319, 322],
131
+ [324, 324],
132
+ [328, 331],
133
+ [333, 333],
134
+ [338, 339],
135
+ [358, 359],
136
+ [363, 363],
137
+ [462, 462],
138
+ [464, 464],
139
+ [466, 466],
140
+ [468, 468],
141
+ [470, 470],
142
+ [472, 472],
143
+ [474, 474],
144
+ [476, 476],
145
+ [593, 593],
146
+ [609, 609],
147
+ [708, 708],
148
+ [711, 711],
149
+ [713, 715],
150
+ [717, 717],
151
+ [720, 720],
152
+ [728, 731],
153
+ [733, 733],
154
+ [735, 735],
155
+ [913, 929],
156
+ [931, 937],
157
+ [945, 961],
158
+ [963, 969],
159
+ [1025, 1025],
160
+ [1040, 1103],
161
+ [1105, 1105],
162
+ [8208, 8213],
163
+ [8216, 8217],
164
+ [8220, 8221],
165
+ [8224, 8226],
166
+ [8228, 8231],
167
+ [8240, 8240],
168
+ [8242, 8243],
169
+ [8245, 8245],
170
+ [8251, 8251],
171
+ [8254, 8254],
172
+ [8308, 8308],
173
+ [8319, 8319],
174
+ [8321, 8324],
175
+ [8364, 8364],
176
+ [8451, 8451],
177
+ [8453, 8453],
178
+ [8457, 8457],
179
+ [8467, 8467],
180
+ [8470, 8470],
181
+ [8481, 8482],
182
+ [8486, 8486],
183
+ [8491, 8491],
184
+ [8531, 8532],
185
+ [8539, 8542],
186
+ [8544, 8555],
187
+ [8560, 8569],
188
+ [8585, 8585],
189
+ [8592, 8601],
190
+ [8632, 8633],
191
+ [8658, 8658],
192
+ [8660, 8660],
193
+ [8679, 8679],
194
+ [8704, 8704],
195
+ [8706, 8707],
196
+ [8711, 8712],
197
+ [8715, 8715],
198
+ [8719, 8719],
199
+ [8721, 8721],
200
+ [8725, 8725],
201
+ [8730, 8730],
202
+ [8733, 8736],
203
+ [8739, 8739],
204
+ [8741, 8741],
205
+ [8743, 8748],
206
+ [8750, 8750],
207
+ [8756, 8759],
208
+ [8764, 8765],
209
+ [8776, 8776],
210
+ [8780, 8780],
211
+ [8786, 8786],
212
+ [8800, 8801],
213
+ [8804, 8807],
214
+ [8810, 8811],
215
+ [8814, 8815],
216
+ [8834, 8835],
217
+ [8838, 8839],
218
+ [8853, 8853],
219
+ [8857, 8857],
220
+ [8869, 8869],
221
+ [8895, 8895],
222
+ [8978, 8978],
223
+ [9312, 9449],
224
+ [9451, 9471],
225
+ [9600, 9615],
226
+ [9618, 9621],
227
+ [9632, 9633],
228
+ [9635, 9641],
229
+ [9650, 9651],
230
+ [9654, 9655],
231
+ [9660, 9661],
232
+ [9664, 9665],
233
+ [9670, 9672],
234
+ [9675, 9675],
235
+ [9678, 9681],
236
+ [9698, 9701],
237
+ [9711, 9711],
238
+ [9733, 9734],
239
+ [9737, 9737],
240
+ [9742, 9743],
241
+ [9756, 9756],
242
+ [9758, 9758],
243
+ [9792, 9792],
244
+ [9794, 9794],
245
+ [9824, 9825],
246
+ [9827, 9829],
247
+ [9831, 9834],
248
+ [9836, 9837],
249
+ [9839, 9839],
250
+ [10045, 10045],
251
+ [10102, 10111],
252
+ [11094, 11094],
253
+ [57344, 63743],
254
+ [65533, 65533]
255
+ ];
256
+ function isFullWidthCodePoint(codePoint) {
257
+ if (codePoint < 4352 || codePoint > 65510) return false;
258
+ for (const [start, end] of fullWidthRanges) {
259
+ if (codePoint < start) return false;
260
+ if (codePoint <= end) return true;
261
+ }
262
+ return false;
263
+ }
264
+ function isAmbiguousWidthCodePoint(codePoint) {
265
+ if (codePoint < 161 || codePoint > 65533) return false;
266
+ for (const [start, end] of ambiguousWidthRanges) {
267
+ if (codePoint < start) return false;
268
+ if (codePoint <= end) return true;
269
+ }
270
+ return false;
271
+ }
272
+ function isEmojiLike(codePoint) {
273
+ return codePoint >= 127744 && codePoint <= 129791 || codePoint >= 127462 && codePoint <= 127487;
274
+ }
275
+ let extendedPictographicRe = null;
276
+ try {
277
+ extendedPictographicRe = new RegExp("\\p{Extended_Pictographic}", "u");
278
+ } catch {
279
+ extendedPictographicRe = null;
280
+ }
281
+ let emojiPresentationRe = null;
282
+ try {
283
+ emojiPresentationRe = new RegExp("\\p{Emoji_Presentation}", "u");
284
+ } catch {
285
+ emojiPresentationRe = null;
286
+ }
287
+ let emojiRe = null;
288
+ try {
289
+ emojiRe = new RegExp("\\p{Emoji}", "u");
290
+ } catch {
291
+ emojiRe = null;
292
+ }
293
+ function normalizeCustomWidth(width) {
294
+ return width === 2 ? 2 : 1;
295
+ }
296
+ function charCellWidth(text, provider = "default") {
297
+ if (!text) return 1;
298
+ if (typeof provider === "function") return normalizeCustomWidth(provider(text));
299
+ if (provider !== "cjk" && text.length === 1) {
300
+ const code = text.charCodeAt(0);
301
+ if (code < 4352) return 1;
302
+ }
303
+ const codePoint = text.codePointAt(0);
304
+ if (codePoint == null) return 1;
305
+ const hasVs16 = text.includes("️");
306
+ if (isFullWidthCodePoint(codePoint)) return 2;
307
+ if (provider === "cjk" && isAmbiguousWidthCodePoint(codePoint)) return 2;
308
+ if (isEmojiLike(codePoint)) return 2;
309
+ if (emojiPresentationRe?.test(text)) return 2;
310
+ if (text.includes("⃣")) return 2;
311
+ if (hasVs16 && emojiRe?.test(text)) return 2;
312
+ if (extendedPictographicRe?.test(text)) {
313
+ if (codePoint <= 65535) return hasVs16 ? 2 : 1;
314
+ return 2;
315
+ }
316
+ return 1;
317
+ }
318
+
319
+ //#endregion
320
+ //#region src/utils/url-safety.ts
321
+ const ENCODED_ASCII_CONTROL_RE = /%(?:0[0-9a-f]|1[0-9a-f]|7f)/i;
322
+ function hasControlCodePoint(value) {
323
+ for (let i = 0; i < value.length; i++) {
324
+ const code = value.charCodeAt(i);
325
+ if (code <= 31 || code >= 127 && code <= 159) return true;
326
+ }
327
+ return false;
328
+ }
329
+ function hasEncodedControl(value) {
330
+ let current = String(value ?? "");
331
+ for (let depth = 0; depth < 3; depth++) {
332
+ if (ENCODED_ASCII_CONTROL_RE.test(current)) return true;
333
+ let decoded;
334
+ try {
335
+ decoded = decodeURIComponent(current);
336
+ } catch {
337
+ return true;
338
+ }
339
+ if (hasControlCodePoint(decoded)) return true;
340
+ if (decoded === current) return false;
341
+ current = decoded;
342
+ }
343
+ return ENCODED_ASCII_CONTROL_RE.test(current) || hasControlCodePoint(current);
344
+ }
345
+
346
+ //#endregion
347
+ //#region src/core/hyperlink.ts
348
+ const SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;
349
+ const BLOCKED_SCHEME_RE = /^(?:javascript|data|vbscript):/i;
350
+ const SAFE_RELATIVE_HREF_RE = /^(?:[A-Za-z0-9._~!$&()*+,;=:@/?#-]|%[0-9A-Fa-f]{2})+$/u;
351
+ function normalizeRawHref(value) {
352
+ if (typeof value !== "string") return null;
353
+ const raw = value.trim();
354
+ if (!raw) return null;
355
+ if (raw !== value) return null;
356
+ for (let i = 0; i < value.length; i++) {
357
+ const code = value.charCodeAt(i);
358
+ if (code <= 31 || code >= 127 && code <= 159) return null;
359
+ }
360
+ if (/\s/u.test(raw)) return null;
361
+ if (raw.startsWith("//")) return null;
362
+ if (BLOCKED_SCHEME_RE.test(raw)) return null;
363
+ if (hasEncodedControl(raw)) return null;
364
+ return raw;
365
+ }
366
+ function hrefScheme(raw) {
367
+ return raw.match(SCHEME_RE)?.[0].toLowerCase() ?? null;
368
+ }
369
+ function parseSafeAbsoluteUrl(raw) {
370
+ if (raw.includes("\\")) return null;
371
+ try {
372
+ return new URL(raw);
373
+ } catch {
374
+ return null;
375
+ }
376
+ }
377
+ function sanitizeAbsoluteHref(raw, options = {}) {
378
+ const url = parseSafeAbsoluteUrl(raw);
379
+ if (!url) return null;
380
+ if (url.protocol === "http:" || url.protocol === "https:") {
381
+ if (!/^https?:\/\//i.test(raw)) return null;
382
+ return options.preserveHttpHref ? raw : url.toString();
383
+ }
384
+ if (url.protocol === "mailto:") return raw;
385
+ return null;
386
+ }
387
+ function isSafeNormalizedRelativeHref(raw) {
388
+ if (raw.includes("\\")) return false;
389
+ if (raw.startsWith("//")) return false;
390
+ if (SCHEME_RE.test(raw)) return false;
391
+ if (hasEncodedControl(raw)) return false;
392
+ if (!SAFE_RELATIVE_HREF_RE.test(raw)) return false;
393
+ return raw.startsWith("#") || raw.startsWith("?") || raw.startsWith("/") || raw.startsWith("./") || raw.startsWith("../") || /^[A-Za-z0-9._~-]/u.test(raw);
394
+ }
395
+ function isSafeRelativeHref(value) {
396
+ const raw = normalizeRawHref(value);
397
+ return raw != null && isSafeNormalizedRelativeHref(raw);
398
+ }
399
+ function sanitizeTerminalHref(value, options = {}) {
400
+ const raw = normalizeRawHref(value);
401
+ if (!raw) return null;
402
+ const sanitized = sanitizeAbsoluteHref(raw, { preserveHttpHref: true });
403
+ if (sanitized) return sanitized;
404
+ if (options.allowFileUrls) {
405
+ const url = parseSafeAbsoluteUrl(raw);
406
+ if (url?.protocol === "file:") return url.toString();
407
+ }
408
+ return null;
409
+ }
410
+ function sanitizeDomHref(value, options = {}) {
411
+ const raw = normalizeRawHref(value);
412
+ if (!raw) return null;
413
+ const scheme = hrefScheme(raw);
414
+ if (!scheme) return options.allowRelative !== false && isSafeNormalizedRelativeHref(raw) ? raw : null;
415
+ return sanitizeAbsoluteHref(raw);
416
+ }
417
+
418
+ //#endregion
419
+ export { charCellWidth, hasEncodedControl, isSafeRelativeHref, sanitizeDomHref, sanitizeTerminalHref, segmentedGraphemes };