@simon_he/vue-tui 0.0.7 → 1.0.0-rc.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 (207) hide show
  1. package/README.md +222 -444
  2. package/dist/TSelect-BmSkar0D.js +8697 -0
  3. package/dist/ansi-palette-Bv5Vqr4k.js +1499 -0
  4. package/dist/ansi-styles.d.ts +200 -0
  5. package/dist/cli/headless-renderer.d.ts +29 -0
  6. package/dist/cli/input.d.ts +49 -0
  7. package/dist/cli/node-file-writers.d.ts +12 -0
  8. package/dist/cli/node-module.d.ts +2 -0
  9. package/dist/cli/parse-kitty.d.ts +2 -0
  10. package/dist/cli/parse-mouse.d.ts +2 -0
  11. package/dist/cli/parse-utils.d.ts +14 -0
  12. package/dist/cli/parse-xterm.d.ts +2 -0
  13. package/dist/cli/path-provider-types.d.ts +1 -0
  14. package/dist/cli/path-provider.d.ts +4 -0
  15. package/dist/cli/path-suggest-core.d.ts +1 -0
  16. package/dist/cli/path-suggest.d.ts +15 -0
  17. package/dist/cli/recording.d.ts +4 -0
  18. package/dist/cli/stdin-buffer.d.ts +33 -0
  19. package/dist/cli.cjs +10664 -0
  20. package/dist/cli.d.cts +22 -0
  21. package/dist/cli.d.ts +22 -0
  22. package/dist/cli.js +9521 -0
  23. package/dist/core/ansi/capability.d.ts +20 -0
  24. package/dist/core/ansi/colors.d.ts +41 -0
  25. package/dist/core/ansi/sgr.d.ts +7 -0
  26. package/dist/core/ansi/theme.d.ts +6 -0
  27. package/dist/core/ansi-palette.d.ts +14 -0
  28. package/dist/core/buffer/buffer.d.ts +54 -0
  29. package/dist/core/buffer/width.d.ts +4 -0
  30. package/dist/core/debug-logger.d.ts +18 -0
  31. package/dist/core/hyperlink.d.ts +9 -0
  32. package/dist/core/index.d.ts +4 -0
  33. package/dist/core/path-provider-types.d.ts +24 -0
  34. package/dist/core/path-suggest.d.ts +35 -0
  35. package/dist/core/render-plane.d.ts +3 -0
  36. package/dist/core/terminal/create-terminal.d.ts +7 -0
  37. package/dist/core/terminal/emitter.d.ts +7 -0
  38. package/dist/core/types.d.ts +107 -0
  39. package/dist/core.cjs +3072 -0
  40. package/dist/core.d.cts +14 -0
  41. package/dist/core.d.ts +14 -0
  42. package/dist/core.js +422 -0
  43. package/dist/create-terminal-app.d.ts +34 -0
  44. package/dist/dom-renderer-CDVQIcIL.js +1172 -0
  45. package/dist/events/index.d.ts +6 -0
  46. package/dist/events/manager/cli-event-manager.d.ts +22 -0
  47. package/dist/events/manager/event-manager.d.ts +30 -0
  48. package/dist/events/manager/selection-suppression.d.ts +3 -0
  49. package/dist/events/manager/types.d.ts +108 -0
  50. package/dist/events/recording.d.ts +44 -0
  51. package/dist/experimental.cjs +9380 -0
  52. package/dist/experimental.d.cts +39 -0
  53. package/dist/experimental.d.ts +39 -0
  54. package/dist/experimental.js +7624 -0
  55. package/dist/frame-perf-C-w8mjJL.js +98 -0
  56. package/dist/hyperlink-B5PD7a3Q.js +331 -0
  57. package/dist/index.cjs +12037 -16507
  58. package/dist/index.d.cts +13 -0
  59. package/dist/index.d.ts +13 -1353
  60. package/dist/index.js +13 -18738
  61. package/dist/markdown.cjs +21929 -0
  62. package/dist/markdown.d.cts +10 -0
  63. package/dist/markdown.d.ts +10 -0
  64. package/dist/markdown.js +1649 -0
  65. package/dist/observability/cli-latency-node.d.ts +3 -0
  66. package/dist/observability/cli-latency-types.d.ts +41 -0
  67. package/dist/observability/cli-latency.d.ts +3 -0
  68. package/dist/observability/frame-perf-store.d.ts +13 -0
  69. package/dist/observability/frame-perf.d.ts +40 -0
  70. package/dist/observability/trace.d.ts +40 -0
  71. package/dist/observability/tui-profiler.d.ts +33 -0
  72. package/dist/observability.cjs +99 -0
  73. package/dist/observability.d.cts +6 -0
  74. package/dist/observability.d.ts +6 -0
  75. package/dist/observability.js +3 -0
  76. package/dist/path-DDiSCXrQ.js +99 -0
  77. package/dist/path-suggest-0Q2BDsuj.js +274 -0
  78. package/dist/path-suggest-Dk9TRLh5.js +3 -0
  79. package/dist/{path-suggest-CZQYJIIg.js → path-suggest-bvR9SY6Q.js} +86 -18
  80. package/dist/renderer/capabilities.d.ts +13 -0
  81. package/dist/renderer/cli/index.d.ts +2 -0
  82. package/dist/renderer/cli/stdout-metrics.d.ts +18 -0
  83. package/dist/renderer/cli/stdout-renderer.d.ts +48 -0
  84. package/dist/renderer/dom/dom-renderer.d.ts +157 -0
  85. package/dist/renderer/dom/index.d.ts +2 -0
  86. package/dist/renderer/index.d.ts +2 -0
  87. package/dist/renderer-dom.cjs +1511 -0
  88. package/dist/renderer-dom.d.cts +4 -0
  89. package/dist/renderer-dom.d.ts +4 -0
  90. package/dist/renderer-dom.js +6 -0
  91. package/dist/runtime/index.d.ts +36 -0
  92. package/dist/runtime/osc52.d.ts +9 -0
  93. package/dist/runtime-DtrcQidD.js +1197 -0
  94. package/dist/runtime.cjs +1697 -0
  95. package/dist/runtime.d.cts +9 -0
  96. package/dist/runtime.d.ts +9 -0
  97. package/dist/runtime.js +4 -0
  98. package/dist/selection/terminal-selection.d.ts +122 -0
  99. package/dist/sgr-DMK2AvuT.js +304 -0
  100. package/dist/style-cache-i0ZABZRq.js +178 -0
  101. package/dist/terminal-selection-BCOh9jsL.js +329 -0
  102. package/dist/utils/env.d.ts +3 -0
  103. package/dist/utils/newlines.d.ts +1 -0
  104. package/dist/utils/path.d.ts +7 -0
  105. package/dist/utils/url-safety.d.ts +2 -0
  106. package/dist/vue/components/TAnchor.d.ts +108 -0
  107. package/dist/vue/components/TBox.d.ts +144 -0
  108. package/dist/vue/components/TDebugOverlay.d.ts +43 -0
  109. package/dist/vue/components/TDialog.d.ts +256 -0
  110. package/dist/vue/components/TFlow.d.ts +85 -0
  111. package/dist/vue/components/TInput.d.ts +554 -0
  112. package/dist/vue/components/TInputBox.d.ts +158 -0
  113. package/dist/vue/components/TJsonEditor.d.ts +165 -0
  114. package/dist/vue/components/TList.d.ts +119 -0
  115. package/dist/vue/components/TLogLinksPanel.d.ts +238 -0
  116. package/dist/vue/components/TLogMinimap.d.ts +263 -0
  117. package/dist/vue/components/TLogScrollbar.d.ts +236 -0
  118. package/dist/vue/components/TLogSearchBar.d.ts +267 -0
  119. package/dist/vue/components/TLogSearchPager.d.ts +162 -0
  120. package/dist/vue/components/TLogSearchResults.d.ts +200 -0
  121. package/dist/vue/components/TLogView.d.ts +502 -0
  122. package/dist/vue/components/TLogVirtualLinksPanel.d.ts +141 -0
  123. package/dist/vue/components/TLogVirtualSearchResults.d.ts +146 -0
  124. package/dist/vue/components/TMarkdownText.d.ts +134 -0
  125. package/dist/vue/components/TMultilineModal.d.ts +62 -0
  126. package/dist/vue/components/TPathPicker.d.ts +213 -0
  127. package/dist/vue/components/TRenderLayer.d.ts +16 -0
  128. package/dist/vue/components/TRenderPlane.d.ts +17 -0
  129. package/dist/vue/components/TSelect.d.ts +215 -0
  130. package/dist/vue/components/TText.d.ts +116 -0
  131. package/dist/vue/components/TTransition.d.ts +83 -0
  132. package/dist/vue/components/TView.d.ts +127 -0
  133. package/dist/vue/components/TVirtualList.d.ts +182 -0
  134. package/dist/vue/components/TVirtualMarkdown.d.ts +168 -0
  135. package/dist/vue/components/TerminalProvider.d.ts +195 -0
  136. package/dist/vue/components/input/host.d.ts +17 -0
  137. package/dist/vue/components/input/plugins/hostPlugin.d.ts +7 -0
  138. package/dist/vue/components/input/plugins/hostPlugin.node.d.ts +15 -0
  139. package/dist/vue/components/input/plugins/mentionUtils.d.ts +17 -0
  140. package/dist/vue/components/input/plugins/nodeMentionPathProvider.d.ts +2 -0
  141. package/dist/vue/components/input/plugins/promptMentionPlugin.d.ts +8 -0
  142. package/dist/vue/components/input/plugins/promptMentionState.d.ts +98 -0
  143. package/dist/vue/components/input/plugins/restrictText.d.ts +27 -0
  144. package/dist/vue/components/input/plugins/types.d.ts +90 -0
  145. package/dist/vue/components/input/utils/inlineText.d.ts +57 -0
  146. package/dist/vue/components/input/utils/inlineTextTokens.d.ts +34 -0
  147. package/dist/vue/components/input/utils/primitives.d.ts +3 -0
  148. package/dist/vue/components/input/utils/wordNavigation.d.ts +6 -0
  149. package/dist/vue/components/list/list-geometry.d.ts +16 -0
  150. package/dist/vue/components/list/list-paint.d.ts +1 -0
  151. package/dist/vue/components/list/scroll-state.d.ts +25 -0
  152. package/dist/vue/components/list/selection-state.d.ts +6 -0
  153. package/dist/vue/components/terminal-provider/copy-toast.d.ts +6 -0
  154. package/dist/vue/components/terminal-provider/portals.d.ts +17 -0
  155. package/dist/vue/components/terminal-provider/scheduler.d.ts +29 -0
  156. package/dist/vue/components/terminal-provider/selection-config.d.ts +15 -0
  157. package/dist/vue/components/terminal-provider/utils.d.ts +5 -0
  158. package/dist/vue/composables/use-layout.d.ts +2 -0
  159. package/dist/vue/composables/use-render-node.d.ts +19 -0
  160. package/dist/vue/composables/use-render-stack.d.ts +3 -0
  161. package/dist/vue/composables/use-runtime.d.ts +5 -0
  162. package/dist/vue/composables/use-terminal-node.d.ts +14 -0
  163. package/dist/vue/composables/use-terminal.d.ts +2 -0
  164. package/dist/vue/composables/use-visibility.d.ts +12 -0
  165. package/dist/vue/context.d.ts +153 -0
  166. package/dist/vue/index.d.ts +39 -0
  167. package/dist/vue/injection-key.d.ts +2 -0
  168. package/dist/vue/log/append-only-log-store.d.ts +2 -0
  169. package/dist/vue/log/tlog-keymap.d.ts +28 -0
  170. package/dist/vue/log/tlog-plugins.d.ts +144 -0
  171. package/dist/vue/log/tlog-session.d.ts +81 -0
  172. package/dist/vue/log/tlog-theme.d.ts +68 -0
  173. package/dist/vue/log/types.d.ts +43 -0
  174. package/dist/vue/log/use-tlog-link-controller.d.ts +31 -0
  175. package/dist/vue/log/use-tlog-retained-index.d.ts +26 -0
  176. package/dist/vue/log/use-tlog-search-controller.d.ts +51 -0
  177. package/dist/vue/log/use-tlog-search-results-page.d.ts +31 -0
  178. package/dist/vue/log/use-tlog-virtual-search-results.d.ts +22 -0
  179. package/dist/vue/markdown/ast.d.ts +3 -0
  180. package/dist/vue/markdown/block-source.d.ts +22 -0
  181. package/dist/vue/markdown/document.d.ts +18 -0
  182. package/dist/vue/markdown/layout.d.ts +16 -0
  183. package/dist/vue/markdown/parser.d.ts +11 -0
  184. package/dist/vue/markdown/render.d.ts +10 -0
  185. package/dist/vue/markdown/theme.d.ts +186 -0
  186. package/dist/vue/markdown/types.d.ts +47 -0
  187. package/dist/vue/render/context.d.ts +3 -0
  188. package/dist/vue/render/render-manager.d.ts +94 -0
  189. package/dist/vue/router/RouterView.d.ts +25 -0
  190. package/dist/vue/router/composables.d.ts +4 -0
  191. package/dist/vue/router/context.d.ts +4 -0
  192. package/dist/vue/router/router.d.ts +7 -0
  193. package/dist/vue/router/types.d.ts +29 -0
  194. package/dist/vue/scheduler/frame-mailbox.d.ts +55 -0
  195. package/dist/vue/scheduler/frame-scheduler.d.ts +51 -0
  196. package/dist/vue/utils/frame-task.d.ts +6 -0
  197. package/dist/vue/utils/rect.d.ts +4 -0
  198. package/dist/vue/utils/style-cache.d.ts +3 -0
  199. package/dist/vue/utils/text.d.ts +26 -0
  200. package/dist/vue/utils/wheel-scroll.d.ts +18 -0
  201. package/dist/vue.cjs +18882 -0
  202. package/dist/vue.d.cts +3 -0
  203. package/dist/vue.d.ts +3 -0
  204. package/dist/vue.js +3066 -0
  205. package/dist/wheel-scroll-B-WlFuNB.js +819 -0
  206. package/package.json +226 -58
  207. package/dist/path-suggest-DIMby3r0.js +0 -3
@@ -0,0 +1,98 @@
1
+ import { computed, ref, shallowReactive } from "vue";
2
+
3
+ //#region src/observability/frame-perf-store.ts
4
+ function createFramePerfStore(limit = 120, opts) {
5
+ const max = Math.max(1, Math.floor(limit));
6
+ const manualEnabled = ref(Boolean(opts?.enabled));
7
+ const leaseCount = ref(0);
8
+ const enabled = computed({
9
+ get: () => manualEnabled.value || leaseCount.value > 0,
10
+ set: (next) => {
11
+ manualEnabled.value = Boolean(next);
12
+ }
13
+ });
14
+ const samples = [];
15
+ function acquire(_reason) {
16
+ leaseCount.value++;
17
+ let released = false;
18
+ return () => {
19
+ if (released) return;
20
+ released = true;
21
+ leaseCount.value = Math.max(0, leaseCount.value - 1);
22
+ };
23
+ }
24
+ function push(sample) {
25
+ if (!enabled.value) return;
26
+ samples.push(sample);
27
+ if (samples.length > max) samples.splice(0, samples.length - max);
28
+ }
29
+ function latest() {
30
+ return samples.length > 0 ? samples[samples.length - 1] : null;
31
+ }
32
+ function list() {
33
+ return samples.slice();
34
+ }
35
+ function clear() {
36
+ samples.length = 0;
37
+ }
38
+ return {
39
+ enabled,
40
+ acquire,
41
+ push,
42
+ latest,
43
+ list,
44
+ clear
45
+ };
46
+ }
47
+
48
+ //#endregion
49
+ //#region src/observability/trace.ts
50
+ function createTraceStore(opts) {
51
+ const enabled = ref(Boolean(opts?.enabled));
52
+ const records = shallowReactive([]);
53
+ const max = Math.max(10, Math.floor(opts?.max ?? 400));
54
+ function push(record) {
55
+ if (!enabled.value) return;
56
+ records.push(record);
57
+ if (records.length > max) records.splice(0, records.length - max);
58
+ }
59
+ function clear() {
60
+ records.splice(0, records.length);
61
+ }
62
+ function snapshot() {
63
+ return records.slice();
64
+ }
65
+ return {
66
+ enabled,
67
+ records,
68
+ push,
69
+ clear,
70
+ snapshot
71
+ };
72
+ }
73
+
74
+ //#endregion
75
+ //#region src/observability/frame-perf.ts
76
+ const FRAME_PERF_REASON_PRIORITY = {
77
+ unknown: 0,
78
+ manual: 1,
79
+ data: 2,
80
+ selection: 3,
81
+ stream: 4,
82
+ resize: 5,
83
+ scroll: 6,
84
+ input: 7
85
+ };
86
+ function framePerfNow() {
87
+ const p = globalThis.performance;
88
+ if (p && typeof p.now === "function") return p.now();
89
+ return Date.now();
90
+ }
91
+ function mergeFramePerfReason(prev, next) {
92
+ const a = prev ?? "unknown";
93
+ const b = next ?? "unknown";
94
+ return FRAME_PERF_REASON_PRIORITY[b] > FRAME_PERF_REASON_PRIORITY[a] ? b : a;
95
+ }
96
+
97
+ //#endregion
98
+ export { createFramePerfStore, createTraceStore, framePerfNow, mergeFramePerfReason };
@@ -0,0 +1,331 @@
1
+ //#region src/core/buffer/width.ts
2
+ const fullWidthRanges = [
3
+ [4352, 4447],
4
+ [9001, 9002],
5
+ [11904, 42191],
6
+ [44032, 55203],
7
+ [63744, 64255],
8
+ [65040, 65049],
9
+ [65072, 65135],
10
+ [65280, 65376],
11
+ [65504, 65510]
12
+ ];
13
+ const ambiguousWidthRanges = [
14
+ [161, 161],
15
+ [164, 164],
16
+ [167, 168],
17
+ [170, 170],
18
+ [173, 174],
19
+ [176, 180],
20
+ [182, 186],
21
+ [188, 191],
22
+ [198, 198],
23
+ [208, 208],
24
+ [215, 216],
25
+ [222, 225],
26
+ [230, 230],
27
+ [232, 234],
28
+ [236, 237],
29
+ [240, 240],
30
+ [242, 243],
31
+ [247, 250],
32
+ [252, 252],
33
+ [254, 254],
34
+ [257, 257],
35
+ [273, 273],
36
+ [275, 275],
37
+ [283, 283],
38
+ [294, 295],
39
+ [299, 299],
40
+ [305, 307],
41
+ [312, 312],
42
+ [319, 322],
43
+ [324, 324],
44
+ [328, 331],
45
+ [333, 333],
46
+ [338, 339],
47
+ [358, 359],
48
+ [363, 363],
49
+ [462, 462],
50
+ [464, 464],
51
+ [466, 466],
52
+ [468, 468],
53
+ [470, 470],
54
+ [472, 472],
55
+ [474, 474],
56
+ [476, 476],
57
+ [593, 593],
58
+ [609, 609],
59
+ [708, 708],
60
+ [711, 711],
61
+ [713, 715],
62
+ [717, 717],
63
+ [720, 720],
64
+ [728, 731],
65
+ [733, 733],
66
+ [735, 735],
67
+ [913, 929],
68
+ [931, 937],
69
+ [945, 961],
70
+ [963, 969],
71
+ [1025, 1025],
72
+ [1040, 1103],
73
+ [1105, 1105],
74
+ [8208, 8213],
75
+ [8216, 8217],
76
+ [8220, 8221],
77
+ [8224, 8226],
78
+ [8228, 8231],
79
+ [8240, 8240],
80
+ [8242, 8243],
81
+ [8245, 8245],
82
+ [8251, 8251],
83
+ [8254, 8254],
84
+ [8308, 8308],
85
+ [8319, 8319],
86
+ [8321, 8324],
87
+ [8364, 8364],
88
+ [8451, 8451],
89
+ [8453, 8453],
90
+ [8457, 8457],
91
+ [8467, 8467],
92
+ [8470, 8470],
93
+ [8481, 8482],
94
+ [8486, 8486],
95
+ [8491, 8491],
96
+ [8531, 8532],
97
+ [8539, 8542],
98
+ [8544, 8555],
99
+ [8560, 8569],
100
+ [8585, 8585],
101
+ [8592, 8601],
102
+ [8632, 8633],
103
+ [8658, 8658],
104
+ [8660, 8660],
105
+ [8679, 8679],
106
+ [8704, 8704],
107
+ [8706, 8707],
108
+ [8711, 8712],
109
+ [8715, 8715],
110
+ [8719, 8719],
111
+ [8721, 8721],
112
+ [8725, 8725],
113
+ [8730, 8730],
114
+ [8733, 8736],
115
+ [8739, 8739],
116
+ [8741, 8741],
117
+ [8743, 8748],
118
+ [8750, 8750],
119
+ [8756, 8759],
120
+ [8764, 8765],
121
+ [8776, 8776],
122
+ [8780, 8780],
123
+ [8786, 8786],
124
+ [8800, 8801],
125
+ [8804, 8807],
126
+ [8810, 8811],
127
+ [8814, 8815],
128
+ [8834, 8835],
129
+ [8838, 8839],
130
+ [8853, 8853],
131
+ [8857, 8857],
132
+ [8869, 8869],
133
+ [8895, 8895],
134
+ [8978, 8978],
135
+ [9312, 9449],
136
+ [9451, 9471],
137
+ [9600, 9615],
138
+ [9618, 9621],
139
+ [9632, 9633],
140
+ [9635, 9641],
141
+ [9650, 9651],
142
+ [9654, 9655],
143
+ [9660, 9661],
144
+ [9664, 9665],
145
+ [9670, 9672],
146
+ [9675, 9675],
147
+ [9678, 9681],
148
+ [9698, 9701],
149
+ [9711, 9711],
150
+ [9733, 9734],
151
+ [9737, 9737],
152
+ [9742, 9743],
153
+ [9756, 9756],
154
+ [9758, 9758],
155
+ [9792, 9792],
156
+ [9794, 9794],
157
+ [9824, 9825],
158
+ [9827, 9829],
159
+ [9831, 9834],
160
+ [9836, 9837],
161
+ [9839, 9839],
162
+ [10045, 10045],
163
+ [10102, 10111],
164
+ [11094, 11094],
165
+ [57344, 63743],
166
+ [65533, 65533]
167
+ ];
168
+ function isFullWidthCodePoint(codePoint) {
169
+ if (codePoint < 4352 || codePoint > 65510) return false;
170
+ for (const [start, end] of fullWidthRanges) {
171
+ if (codePoint < start) return false;
172
+ if (codePoint <= end) return true;
173
+ }
174
+ return false;
175
+ }
176
+ function isAmbiguousWidthCodePoint(codePoint) {
177
+ if (codePoint < 161 || codePoint > 65533) return false;
178
+ for (const [start, end] of ambiguousWidthRanges) {
179
+ if (codePoint < start) return false;
180
+ if (codePoint <= end) return true;
181
+ }
182
+ return false;
183
+ }
184
+ function isEmojiLike(codePoint) {
185
+ return codePoint >= 127744 && codePoint <= 129791 || codePoint >= 127462 && codePoint <= 127487;
186
+ }
187
+ let extendedPictographicRe = null;
188
+ try {
189
+ extendedPictographicRe = new RegExp("\\p{Extended_Pictographic}", "u");
190
+ } catch {
191
+ extendedPictographicRe = null;
192
+ }
193
+ let emojiPresentationRe = null;
194
+ try {
195
+ emojiPresentationRe = new RegExp("\\p{Emoji_Presentation}", "u");
196
+ } catch {
197
+ emojiPresentationRe = null;
198
+ }
199
+ let emojiRe = null;
200
+ try {
201
+ emojiRe = new RegExp("\\p{Emoji}", "u");
202
+ } catch {
203
+ emojiRe = null;
204
+ }
205
+ function normalizeCustomWidth(width) {
206
+ return width === 2 ? 2 : 1;
207
+ }
208
+ function charCellWidth(text, provider = "default") {
209
+ if (!text) return 1;
210
+ if (typeof provider === "function") return normalizeCustomWidth(provider(text));
211
+ if (provider !== "cjk" && text.length === 1) {
212
+ const code = text.charCodeAt(0);
213
+ if (code < 4352) return 1;
214
+ }
215
+ const codePoint = text.codePointAt(0);
216
+ if (codePoint == null) return 1;
217
+ const hasVs16 = text.includes("️");
218
+ if (isFullWidthCodePoint(codePoint)) return 2;
219
+ if (provider === "cjk" && isAmbiguousWidthCodePoint(codePoint)) return 2;
220
+ if (isEmojiLike(codePoint)) return 2;
221
+ if (emojiPresentationRe?.test(text)) return 2;
222
+ if (text.includes("⃣")) return 2;
223
+ if (hasVs16 && emojiRe?.test(text)) return 2;
224
+ if (extendedPictographicRe?.test(text)) {
225
+ if (codePoint <= 65535) return hasVs16 ? 2 : 1;
226
+ return 2;
227
+ }
228
+ return 1;
229
+ }
230
+
231
+ //#endregion
232
+ //#region src/utils/url-safety.ts
233
+ const ENCODED_ASCII_CONTROL_RE = /%(?:0[0-9a-f]|1[0-9a-f]|7f)/i;
234
+ function hasControlCodePoint(value) {
235
+ for (let i = 0; i < value.length; i++) {
236
+ const code = value.charCodeAt(i);
237
+ if (code <= 31 || code >= 127 && code <= 159) return true;
238
+ }
239
+ return false;
240
+ }
241
+ function hasEncodedControl(value) {
242
+ let current = String(value ?? "");
243
+ for (let depth = 0; depth < 3; depth++) {
244
+ if (ENCODED_ASCII_CONTROL_RE.test(current)) return true;
245
+ let decoded;
246
+ try {
247
+ decoded = decodeURIComponent(current);
248
+ } catch {
249
+ return true;
250
+ }
251
+ if (hasControlCodePoint(decoded)) return true;
252
+ if (decoded === current) return false;
253
+ current = decoded;
254
+ }
255
+ return ENCODED_ASCII_CONTROL_RE.test(current) || hasControlCodePoint(current);
256
+ }
257
+
258
+ //#endregion
259
+ //#region src/core/hyperlink.ts
260
+ const SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;
261
+ const BLOCKED_SCHEME_RE = /^(?:javascript|data|vbscript):/i;
262
+ const SAFE_RELATIVE_HREF_RE = /^(?:[A-Za-z0-9._~!$&()*+,;=:@/?#-]|%[0-9A-Fa-f]{2})+$/u;
263
+ function normalizeRawHref(value) {
264
+ if (typeof value !== "string") return null;
265
+ const raw = value.trim();
266
+ if (!raw) return null;
267
+ if (raw !== value) return null;
268
+ for (let i = 0; i < value.length; i++) {
269
+ const code = value.charCodeAt(i);
270
+ if (code <= 31 || code >= 127 && code <= 159) return null;
271
+ }
272
+ if (/\s/u.test(raw)) return null;
273
+ if (raw.startsWith("//")) return null;
274
+ if (BLOCKED_SCHEME_RE.test(raw)) return null;
275
+ if (hasEncodedControl(raw)) return null;
276
+ return raw;
277
+ }
278
+ function hrefScheme(raw) {
279
+ return raw.match(SCHEME_RE)?.[0].toLowerCase() ?? null;
280
+ }
281
+ function parseSafeAbsoluteUrl(raw) {
282
+ if (raw.includes("\\")) return null;
283
+ try {
284
+ return new URL(raw);
285
+ } catch {
286
+ return null;
287
+ }
288
+ }
289
+ function sanitizeAbsoluteHref(raw, options = {}) {
290
+ const url = parseSafeAbsoluteUrl(raw);
291
+ if (!url) return null;
292
+ if (url.protocol === "http:" || url.protocol === "https:") {
293
+ if (!/^https?:\/\//i.test(raw)) return null;
294
+ return options.preserveHttpHref ? raw : url.toString();
295
+ }
296
+ if (url.protocol === "mailto:") return raw;
297
+ return null;
298
+ }
299
+ function isSafeNormalizedRelativeHref(raw) {
300
+ if (raw.includes("\\")) return false;
301
+ if (raw.startsWith("//")) return false;
302
+ if (SCHEME_RE.test(raw)) return false;
303
+ if (hasEncodedControl(raw)) return false;
304
+ if (!SAFE_RELATIVE_HREF_RE.test(raw)) return false;
305
+ return raw.startsWith("#") || raw.startsWith("?") || raw.startsWith("/") || raw.startsWith("./") || raw.startsWith("../") || /^[A-Za-z0-9._~-]/u.test(raw);
306
+ }
307
+ function isSafeRelativeHref(value) {
308
+ const raw = normalizeRawHref(value);
309
+ return raw != null && isSafeNormalizedRelativeHref(raw);
310
+ }
311
+ function sanitizeTerminalHref(value, options = {}) {
312
+ const raw = normalizeRawHref(value);
313
+ if (!raw) return null;
314
+ const sanitized = sanitizeAbsoluteHref(raw, { preserveHttpHref: true });
315
+ if (sanitized) return sanitized;
316
+ if (options.allowFileUrls) {
317
+ const url = parseSafeAbsoluteUrl(raw);
318
+ if (url?.protocol === "file:") return url.toString();
319
+ }
320
+ return null;
321
+ }
322
+ function sanitizeDomHref(value, options = {}) {
323
+ const raw = normalizeRawHref(value);
324
+ if (!raw) return null;
325
+ const scheme = hrefScheme(raw);
326
+ if (!scheme) return options.allowRelative !== false && isSafeNormalizedRelativeHref(raw) ? raw : null;
327
+ return sanitizeAbsoluteHref(raw);
328
+ }
329
+
330
+ //#endregion
331
+ export { charCellWidth, hasEncodedControl, isSafeRelativeHref, sanitizeDomHref, sanitizeTerminalHref };