@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.
- package/README.md +142 -30
- package/dist/TSelect-BwJJbuTt.js +6089 -0
- package/dist/TTree-DK_DQBYm.js +6480 -0
- package/dist/agent.cjs +39416 -0
- package/dist/agent.d.cts +44 -0
- package/dist/agent.d.ts +44 -0
- package/dist/agent.js +828 -0
- package/dist/ansi-palette-CNXqFciC.js +57 -0
- package/dist/ansi-styles.d.ts +200 -0
- package/dist/block-source-CKUOnkgT.js +1663 -0
- package/dist/cli/headless-renderer.d.ts +29 -0
- package/dist/cli/input.d.ts +49 -0
- package/dist/cli/node-file-writers.d.ts +13 -0
- package/dist/cli/node-module.d.ts +2 -0
- package/dist/cli/parse-kitty.d.ts +2 -0
- package/dist/cli/parse-mouse.d.ts +2 -0
- package/dist/cli/parse-utils.d.ts +14 -0
- package/dist/cli/parse-xterm.d.ts +2 -0
- package/dist/cli/path-provider-types.d.ts +1 -0
- package/dist/cli/path-provider.d.ts +4 -0
- package/dist/cli/path-suggest-core.d.ts +1 -0
- package/dist/cli/path-suggest.d.ts +15 -0
- package/dist/cli/recording.d.ts +4 -0
- package/dist/cli/stdin-buffer.d.ts +33 -0
- package/dist/cli.cjs +11061 -0
- package/dist/cli.d.cts +23 -0
- package/dist/cli.d.ts +23 -0
- package/dist/cli.js +9875 -0
- package/dist/core/ansi/capability.d.ts +20 -0
- package/dist/core/ansi/colors.d.ts +41 -0
- package/dist/core/ansi/sgr.d.ts +7 -0
- package/dist/core/ansi/theme.d.ts +6 -0
- package/dist/core/ansi-palette.d.ts +14 -0
- package/dist/core/buffer/buffer.d.ts +54 -0
- package/dist/core/buffer/width.d.ts +4 -0
- package/dist/core/debug-logger.d.ts +18 -0
- package/dist/core/hyperlink.d.ts +9 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/path-provider-types.d.ts +24 -0
- package/dist/core/path-suggest.d.ts +35 -0
- package/dist/core/render-plane.d.ts +3 -0
- package/dist/core/terminal/create-terminal.d.ts +8 -0
- package/dist/core/terminal/emitter.d.ts +7 -0
- package/dist/core/types.d.ts +107 -0
- package/dist/core.cjs +3153 -0
- package/dist/core.d.cts +14 -0
- package/dist/core.d.ts +14 -0
- package/dist/core.js +424 -0
- package/dist/create-terminal-C2oiWFJU.js +1434 -0
- package/dist/create-terminal-app.d.ts +36 -0
- package/dist/dom-renderer-BqGijQID.js +1173 -0
- package/dist/env-Cl8qmNFN.js +19 -0
- package/dist/events/index.d.ts +6 -0
- package/dist/events/manager/cli-event-manager.d.ts +22 -0
- package/dist/events/manager/event-manager.d.ts +30 -0
- package/dist/events/manager/selection-suppression.d.ts +3 -0
- package/dist/events/manager/types.d.ts +108 -0
- package/dist/events/recording.d.ts +44 -0
- package/dist/experimental.cjs +4412 -1641
- package/dist/experimental.d.cts +42 -0
- package/dist/experimental.d.ts +42 -825
- package/dist/experimental.js +31 -7392
- package/dist/frame-perf-C6Xfg85O.js +24 -0
- package/dist/hyperlink-Bn02UXJb.js +419 -0
- package/dist/index.cjs +14765 -17582
- package/dist/index.d.cts +35 -0
- package/dist/index.d.ts +35 -1528
- package/dist/index.js +17 -20026
- package/dist/linkify-D_gzn9Xq.js +562 -0
- package/dist/markdown.cjs +9321 -7623
- package/dist/markdown.d.cts +11 -0
- package/dist/markdown.d.ts +11 -112
- package/dist/markdown.js +36 -1427
- package/dist/observability/cli-latency-node.d.ts +3 -0
- package/dist/observability/cli-latency-types.d.ts +41 -0
- package/dist/observability/cli-latency.d.ts +3 -0
- package/dist/observability/frame-perf-store.d.ts +18 -0
- package/dist/observability/frame-perf.d.ts +40 -0
- package/dist/observability/perf-sink.d.ts +56 -0
- package/dist/observability/trace.d.ts +40 -0
- package/dist/observability/tui-profiler.d.ts +33 -0
- package/dist/observability.cjs +221 -0
- package/dist/observability.d.cts +8 -0
- package/dist/observability.d.ts +8 -0
- package/dist/observability.js +4 -0
- package/dist/path-mnSgEpCm.js +81 -0
- package/dist/path-suggest-BNqcuE3-.js +274 -0
- package/dist/path-suggest-Dk9TRLh5.js +3 -0
- package/dist/{path-suggest-DmrmeueH.js → path-suggest-bvR9SY6Q.js} +86 -18
- package/dist/renderer/capabilities.d.ts +13 -0
- package/dist/renderer/cli/index.d.ts +2 -0
- package/dist/renderer/cli/stdout-metrics.d.ts +18 -0
- package/dist/renderer/cli/stdout-renderer.d.ts +48 -0
- package/dist/renderer/dom/dom-renderer.d.ts +157 -0
- package/dist/renderer/dom/index.d.ts +2 -0
- package/dist/renderer/index.d.ts +2 -0
- package/dist/renderer-dom.cjs +1505 -0
- package/dist/renderer-dom.d.cts +4 -0
- package/dist/renderer-dom.d.ts +4 -0
- package/dist/renderer-dom.js +7 -0
- package/dist/runtime/index.d.ts +36 -0
- package/dist/runtime/osc52.d.ts +9 -0
- package/dist/runtime-rfcZCyJq.js +1197 -0
- package/dist/runtime.cjs +1698 -0
- package/dist/runtime.d.cts +9 -0
- package/dist/runtime.d.ts +9 -0
- package/dist/runtime.js +4 -0
- package/dist/selection/terminal-selection.d.ts +123 -0
- package/dist/sgr-BmzxEjAO.js +304 -0
- package/dist/terminal-selection-DBinO6p5.js +330 -0
- package/dist/tlog-theme-qPBt5rge.js +9254 -0
- package/dist/trace-CjzYeIxN.js +182 -0
- package/dist/utils/env.d.ts +3 -0
- package/dist/utils/grapheme.d.ts +5 -0
- package/dist/utils/newlines.d.ts +1 -0
- package/dist/utils/path.d.ts +7 -0
- package/dist/utils/url-safety.d.ts +2 -0
- package/dist/vue/agent/view-models.d.ts +98 -0
- package/dist/vue/components/TAnchor.d.ts +108 -0
- package/dist/vue/components/TBox.d.ts +144 -0
- package/dist/vue/components/TCommandPalette.d.ts +587 -0
- package/dist/vue/components/TDataTable.d.ts +367 -0
- package/dist/vue/components/TDebugOverlay.d.ts +43 -0
- package/dist/vue/components/TDialog.d.ts +255 -0
- package/dist/vue/components/TFeedback.d.ts +635 -0
- package/dist/vue/components/TFlow.d.ts +85 -0
- package/dist/vue/components/TForm.d.ts +1230 -0
- package/dist/vue/components/TInput.d.ts +545 -0
- package/dist/vue/components/TInputBox.d.ts +158 -0
- package/dist/vue/components/TJsonEditor.d.ts +165 -0
- package/dist/vue/components/TLink.d.ts +239 -0
- package/dist/vue/components/TLinkifyText.d.ts +141 -0
- package/dist/vue/components/TList.d.ts +119 -0
- package/dist/vue/components/TLogLinksPanel.d.ts +238 -0
- package/dist/vue/components/TLogMinimap.d.ts +263 -0
- package/dist/vue/components/TLogScrollbar.d.ts +236 -0
- package/dist/vue/components/TLogSearchBar.d.ts +267 -0
- package/dist/vue/components/TLogSearchPager.d.ts +162 -0
- package/dist/vue/components/TLogSearchResults.d.ts +200 -0
- package/dist/vue/components/TLogView.d.ts +536 -0
- package/dist/vue/components/TLogVirtualLinksPanel.d.ts +141 -0
- package/dist/vue/components/TLogVirtualSearchResults.d.ts +146 -0
- package/dist/vue/components/TMarkdownText.d.ts +134 -0
- package/dist/vue/components/TMultilineModal.d.ts +62 -0
- package/dist/vue/components/TNavigation.d.ts +324 -0
- package/dist/vue/components/TOverlay.d.ts +366 -0
- package/dist/vue/components/TPanels.d.ts +244 -0
- package/dist/vue/components/TPathPicker.d.ts +213 -0
- package/dist/vue/components/TRenderLayer.d.ts +16 -0
- package/dist/vue/components/TRenderPlane.d.ts +17 -0
- package/dist/vue/components/TSelect.d.ts +335 -0
- package/dist/vue/components/TTable.d.ts +317 -0
- package/dist/vue/components/TText.d.ts +116 -0
- package/dist/vue/components/TThinkingView.d.ts +233 -0
- package/dist/vue/components/TToolCallView.d.ts +384 -0
- package/dist/vue/components/TTranscriptView.d.ts +221 -0
- package/dist/vue/components/TTransition.d.ts +83 -0
- package/dist/vue/components/TTree.d.ts +200 -0
- package/dist/vue/components/TUserMessageView.d.ts +344 -0
- package/dist/vue/components/TView.d.ts +127 -0
- package/dist/vue/components/TVirtualList.d.ts +182 -0
- package/dist/vue/components/TVirtualMarkdown.d.ts +168 -0
- package/dist/vue/components/TVirtualRows.d.ts +247 -0
- package/dist/vue/components/TerminalProvider.d.ts +218 -0
- package/dist/vue/components/input/host.d.ts +17 -0
- package/dist/vue/components/input/plugins/hostPlugin.d.ts +7 -0
- package/dist/vue/components/input/plugins/hostPlugin.node.d.ts +15 -0
- package/dist/vue/components/input/plugins/mentionUtils.d.ts +17 -0
- package/dist/vue/components/input/plugins/nodeMentionPathProvider.d.ts +2 -0
- package/dist/vue/components/input/plugins/promptMentionPlugin.d.ts +8 -0
- package/dist/vue/components/input/plugins/promptMentionState.d.ts +98 -0
- package/dist/vue/components/input/plugins/restrictText.d.ts +27 -0
- package/dist/vue/components/input/plugins/types.d.ts +90 -0
- package/dist/vue/components/input/utils/inlineText.d.ts +57 -0
- package/dist/vue/components/input/utils/inlineTextTokens.d.ts +34 -0
- package/dist/vue/components/input/utils/primitives.d.ts +3 -0
- package/dist/vue/components/input/utils/wordNavigation.d.ts +6 -0
- package/dist/vue/components/link/host.d.ts +15 -0
- package/dist/vue/components/list/list-geometry.d.ts +16 -0
- package/dist/vue/components/list/list-paint.d.ts +1 -0
- package/dist/vue/components/list/scroll-state.d.ts +25 -0
- package/dist/vue/components/list/selection-state.d.ts +6 -0
- package/dist/vue/components/simple-utils.d.ts +5 -0
- package/dist/vue/components/terminal-provider/copy-toast.d.ts +6 -0
- package/dist/vue/components/terminal-provider/portals.d.ts +17 -0
- package/dist/vue/components/terminal-provider/scheduler.d.ts +29 -0
- package/dist/vue/components/terminal-provider/selection-config.d.ts +15 -0
- package/dist/vue/components/terminal-provider/utils.d.ts +5 -0
- package/dist/vue/composables/use-layout.d.ts +2 -0
- package/dist/vue/composables/use-render-node.d.ts +19 -0
- package/dist/vue/composables/use-render-stack.d.ts +3 -0
- package/dist/vue/composables/use-runtime.d.ts +5 -0
- package/dist/vue/composables/use-terminal-node.d.ts +14 -0
- package/dist/vue/composables/use-terminal.d.ts +2 -0
- package/dist/vue/composables/use-visibility.d.ts +12 -0
- package/dist/vue/context.d.ts +153 -0
- package/dist/vue/index.d.ts +69 -0
- package/dist/vue/injection-key.d.ts +2 -0
- package/dist/vue/linkify.d.ts +11 -0
- package/dist/vue/log/append-only-log-store.d.ts +2 -0
- package/dist/vue/log/tlog-keymap.d.ts +28 -0
- package/dist/vue/log/tlog-plugins.d.ts +144 -0
- package/dist/vue/log/tlog-session.d.ts +81 -0
- package/dist/vue/log/tlog-theme.d.ts +68 -0
- package/dist/vue/log/types.d.ts +43 -0
- package/dist/vue/log/use-tlog-link-controller.d.ts +31 -0
- package/dist/vue/log/use-tlog-retained-index.d.ts +26 -0
- package/dist/vue/log/use-tlog-search-controller.d.ts +51 -0
- package/dist/vue/log/use-tlog-search-results-page.d.ts +31 -0
- package/dist/vue/log/use-tlog-virtual-search-results.d.ts +22 -0
- package/dist/vue/markdown/ast.d.ts +3 -0
- package/dist/vue/markdown/block-source.d.ts +22 -0
- package/dist/vue/markdown/document.d.ts +20 -0
- package/dist/vue/markdown/layout.d.ts +21 -0
- package/dist/vue/markdown/parser.d.ts +11 -0
- package/dist/vue/markdown/render.d.ts +10 -0
- package/dist/vue/markdown/theme.d.ts +186 -0
- package/dist/vue/markdown/types.d.ts +59 -0
- package/dist/vue/overlay.d.ts +27 -0
- package/dist/vue/render/context.d.ts +3 -0
- package/dist/vue/render/render-manager.d.ts +94 -0
- package/dist/vue/router/RouterView.d.ts +25 -0
- package/dist/vue/router/composables.d.ts +4 -0
- package/dist/vue/router/context.d.ts +4 -0
- package/dist/vue/router/router.d.ts +7 -0
- package/dist/vue/router/types.d.ts +29 -0
- package/dist/vue/scheduler/frame-mailbox.d.ts +55 -0
- package/dist/vue/scheduler/frame-scheduler.d.ts +51 -0
- package/dist/vue/theme.d.ts +48 -0
- package/dist/vue/transcript/hit-regions.d.ts +2 -0
- package/dist/vue/transcript/layout.d.ts +20 -0
- package/dist/vue/transcript/plain-text.d.ts +2 -0
- package/dist/vue/transcript/types.d.ts +122 -0
- package/dist/vue/utils/frame-task.d.ts +6 -0
- package/dist/vue/utils/rect.d.ts +4 -0
- package/dist/vue/utils/row-scroll.d.ts +25 -0
- package/dist/vue/utils/style-cache.d.ts +3 -0
- package/dist/vue/utils/text.d.ts +27 -0
- package/dist/vue/utils/wheel-scroll.d.ts +18 -0
- package/dist/vue.cjs +23668 -0
- package/dist/vue.d.cts +1 -0
- package/dist/vue.d.ts +1 -0
- package/dist/vue.js +3957 -0
- package/dist/{wheel-scroll-CiNsasLf.js → wheel-scroll-vBRaQ7p-.js} +404 -405
- package/package.json +185 -35
- package/dist/path-suggest-BeV6n7m-.js +0 -3
- package/dist/sgr-Tko2EQ0U.js +0 -484
- package/dist/theme-Bsm65g8k.d.ts +0 -32
- package/dist/types-ClIV2h1o.d.ts +0 -103
|
@@ -1,346 +1,61 @@
|
|
|
1
|
+
import { charCellWidth, segmentedGraphemes } from "./hyperlink-Bn02UXJb.js";
|
|
1
2
|
import { computed, inject, onBeforeUnmount, provide, ref, vShow, watchEffect } from "vue";
|
|
2
3
|
|
|
3
|
-
//#region src/vue/
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const EventZIndexContextKey = Symbol("EventZIndex");
|
|
8
|
-
const RenderPlaneContextKey = Symbol("RenderPlane");
|
|
9
|
-
const ImeAnchorContextKey = Symbol("ImeAnchor");
|
|
10
|
-
const TInputPluginsContextKey = Symbol("TInputPlugins");
|
|
11
|
-
const TPathPickerProviderContextKey = Symbol("TPathPickerProvider");
|
|
12
|
-
const DialogContextKey = Symbol("DialogContext");
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/vue/composables/use-layout.ts
|
|
16
|
-
function useLayout() {
|
|
17
|
-
const ctx = inject(LayoutContextKey, null);
|
|
18
|
-
if (!ctx) throw new Error("LayoutContext is missing (TerminalProvider/TView)");
|
|
19
|
-
return ctx;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
//#endregion
|
|
23
|
-
//#region src/vue/render/context.ts
|
|
24
|
-
const RenderStackKey = Symbol("RenderStack");
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/vue/composables/use-render-stack.ts
|
|
28
|
-
function useRenderStack() {
|
|
29
|
-
const stack = inject(RenderStackKey, null);
|
|
30
|
-
if (!stack) throw new Error("RenderStack is missing");
|
|
31
|
-
return stack;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/vue/composables/use-terminal.ts
|
|
36
|
-
function useTerminal() {
|
|
37
|
-
const ctx = inject(TerminalContextKey, null);
|
|
38
|
-
if (!ctx) throw new Error("TerminalProvider is missing");
|
|
39
|
-
return ctx;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region src/vue/composables/use-render-node.ts
|
|
44
|
-
const pendingInvalidateByScheduler = new WeakMap();
|
|
45
|
-
function mergePriority(prev, next) {
|
|
46
|
-
if (prev === "high" || next === "high") return "high";
|
|
47
|
-
if (prev === "normal" || next === "normal") return "normal";
|
|
48
|
-
return "low";
|
|
49
|
-
}
|
|
50
|
-
function requestBatchedInvalidate(scheduler, plane, priority) {
|
|
51
|
-
let state = pendingInvalidateByScheduler.get(scheduler);
|
|
52
|
-
if (!state) {
|
|
53
|
-
state = {
|
|
54
|
-
queued: false,
|
|
55
|
-
plane: null,
|
|
56
|
-
priority: "low"
|
|
57
|
-
};
|
|
58
|
-
pendingInvalidateByScheduler.set(scheduler, state);
|
|
59
|
-
}
|
|
60
|
-
if (state.queued) {
|
|
61
|
-
if (state.plane !== null && state.plane !== plane) state.plane = null;
|
|
62
|
-
state.priority = mergePriority(state.priority, priority);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
state.plane = plane;
|
|
66
|
-
state.priority = priority;
|
|
67
|
-
state.queued = true;
|
|
68
|
-
queueMicrotask(() => {
|
|
69
|
-
state.queued = false;
|
|
70
|
-
const queuedPlane = state.plane;
|
|
71
|
-
const queuedPriority = state.priority;
|
|
72
|
-
state.plane = null;
|
|
73
|
-
state.priority = "low";
|
|
74
|
-
scheduler.invalidate({
|
|
75
|
-
plane: queuedPlane ?? void 0,
|
|
76
|
-
priority: queuedPriority
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
function useRenderNode(getOptions) {
|
|
81
|
-
const { scheduler, render } = useTerminal();
|
|
82
|
-
const parentStack = useRenderStack();
|
|
83
|
-
const plane = inject(RenderPlaneContextKey, ref("default"));
|
|
84
|
-
const id = ref(null);
|
|
85
|
-
const lastPlane = ref(plane.value);
|
|
86
|
-
const options = computed(() => getOptions());
|
|
87
|
-
const stop = watchEffect(() => {
|
|
88
|
-
const opt = options.value;
|
|
89
|
-
opt.deps;
|
|
90
|
-
const stack = opt.stack ?? parentStack.value;
|
|
91
|
-
const nextPlane = plane.value;
|
|
92
|
-
if (!stack) return;
|
|
93
|
-
if (!id.value) {
|
|
94
|
-
const node = render.register({
|
|
95
|
-
stack,
|
|
96
|
-
zIndex: opt.zIndex,
|
|
97
|
-
rect: opt.rect,
|
|
98
|
-
plane: nextPlane,
|
|
99
|
-
paint: opt.paint
|
|
100
|
-
});
|
|
101
|
-
id.value = node.id;
|
|
102
|
-
lastPlane.value = nextPlane;
|
|
103
|
-
requestBatchedInvalidate(scheduler, nextPlane, opt.priority ?? "normal");
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
const prevPlane = lastPlane.value;
|
|
107
|
-
const updatePayload = {
|
|
108
|
-
stack,
|
|
109
|
-
zIndex: opt.zIndex ?? 0,
|
|
110
|
-
dirtyRowsHint: opt.dirtyRowsHint,
|
|
111
|
-
plane: nextPlane,
|
|
112
|
-
paint: opt.paint
|
|
113
|
-
};
|
|
114
|
-
if (Object.prototype.hasOwnProperty.call(opt, "rect")) updatePayload.rect = opt.rect ?? null;
|
|
115
|
-
render.update(id.value, updatePayload);
|
|
116
|
-
lastPlane.value = nextPlane;
|
|
117
|
-
const priority = opt.priority ?? "normal";
|
|
118
|
-
requestBatchedInvalidate(scheduler, prevPlane, priority);
|
|
119
|
-
if (prevPlane !== nextPlane) requestBatchedInvalidate(scheduler, nextPlane, priority);
|
|
120
|
-
});
|
|
121
|
-
onBeforeUnmount(() => {
|
|
122
|
-
stop();
|
|
123
|
-
if (id.value) {
|
|
124
|
-
render.unregister(id.value);
|
|
125
|
-
requestBatchedInvalidate(scheduler, lastPlane.value, "normal");
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
return { id };
|
|
4
|
+
//#region src/vue/injection-key.ts
|
|
5
|
+
const VUE_TUI_INJECTION_PROTOCOL = "v1";
|
|
6
|
+
function injectionKey(name) {
|
|
7
|
+
return Symbol.for(`@simon_he/vue-tui:${VUE_TUI_INJECTION_PROTOCOL}:${name}`);
|
|
129
8
|
}
|
|
130
9
|
|
|
131
10
|
//#endregion
|
|
132
|
-
//#region src/vue/
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const node = manager.register({
|
|
143
|
-
rect: opt.rect,
|
|
144
|
-
zIndex: opt.zIndex ?? 0,
|
|
145
|
-
visible: opt.visible,
|
|
146
|
-
focusable: opt.focusable,
|
|
147
|
-
selectable: opt.selectable,
|
|
148
|
-
handlers: opt.handlers ?? {}
|
|
149
|
-
});
|
|
150
|
-
id.value = node.id;
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
manager.update(id.value, {
|
|
154
|
-
rect: opt.rect,
|
|
155
|
-
zIndex: opt.zIndex ?? 0,
|
|
156
|
-
visible: opt.visible,
|
|
157
|
-
focusable: opt.focusable,
|
|
158
|
-
selectable: opt.selectable,
|
|
159
|
-
handlers: opt.handlers ?? {}
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
onBeforeUnmount(() => {
|
|
163
|
-
stop();
|
|
164
|
-
const manager = events.value;
|
|
165
|
-
if (manager && id.value) manager.unregister(id.value);
|
|
166
|
-
});
|
|
167
|
-
return { id };
|
|
168
|
-
}
|
|
11
|
+
//#region src/vue/context.ts
|
|
12
|
+
const TerminalContextKey = injectionKey("TerminalContext");
|
|
13
|
+
const LayoutContextKey = injectionKey("LayoutContext");
|
|
14
|
+
const VisibilityContextKey = injectionKey("VisibilityContext");
|
|
15
|
+
const EventZIndexContextKey = injectionKey("EventZIndex");
|
|
16
|
+
const RenderPlaneContextKey = injectionKey("RenderPlane");
|
|
17
|
+
const ImeAnchorContextKey = injectionKey("ImeAnchor");
|
|
18
|
+
const TInputPluginsContextKey = injectionKey("TInputPlugins");
|
|
19
|
+
const TPathPickerProviderContextKey = injectionKey("TPathPickerProvider");
|
|
20
|
+
const DialogContextKey = injectionKey("DialogContext");
|
|
169
21
|
|
|
170
22
|
//#endregion
|
|
171
|
-
//#region src/vue/
|
|
172
|
-
const
|
|
173
|
-
let vShowPatched = false;
|
|
174
|
-
function patchVShow() {
|
|
175
|
-
if (vShowPatched) return;
|
|
176
|
-
vShowPatched = true;
|
|
177
|
-
const dir = vShow;
|
|
178
|
-
const origBeforeMount = dir.beforeMount;
|
|
179
|
-
const origUpdated = dir.updated;
|
|
180
|
-
const origBeforeUnmount = dir.beforeUnmount;
|
|
181
|
-
const notify = (el, value) => {
|
|
182
|
-
if (!el || typeof el !== "object") return;
|
|
183
|
-
const cb = el[VUE_TERMINAL_SHOW_CB];
|
|
184
|
-
cb === null || cb === void 0 || cb(Boolean(value));
|
|
185
|
-
};
|
|
186
|
-
if (typeof origBeforeMount === "function") dir.beforeMount = (el, binding, vnode) => {
|
|
187
|
-
origBeforeMount(el, binding, vnode);
|
|
188
|
-
notify(el, binding === null || binding === void 0 ? void 0 : binding.value);
|
|
189
|
-
};
|
|
190
|
-
if (typeof origUpdated === "function") dir.updated = (el, binding, vnode) => {
|
|
191
|
-
origUpdated(el, binding, vnode);
|
|
192
|
-
notify(el, binding === null || binding === void 0 ? void 0 : binding.value);
|
|
193
|
-
};
|
|
194
|
-
if (typeof origBeforeUnmount === "function") dir.beforeUnmount = (el, binding, vnode) => {
|
|
195
|
-
origBeforeUnmount(el, binding, vnode);
|
|
196
|
-
notify(el, binding === null || binding === void 0 ? void 0 : binding.value);
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
const PLACEHOLDER_STYLE = Object.freeze({
|
|
200
|
-
position: "absolute",
|
|
201
|
-
left: "-9999px",
|
|
202
|
-
top: "0",
|
|
203
|
-
width: "0",
|
|
204
|
-
height: "0",
|
|
205
|
-
overflow: "hidden"
|
|
206
|
-
});
|
|
207
|
-
function useVisibility(options) {
|
|
208
|
-
patchVShow();
|
|
209
|
-
const { scheduler } = useTerminal();
|
|
210
|
-
const parentVisible = inject(VisibilityContextKey, ref(true));
|
|
211
|
-
const localVisible = ref(true);
|
|
212
|
-
const visible = computed(() => parentVisible.value && localVisible.value);
|
|
213
|
-
if (options === null || options === void 0 ? void 0 : options.provide) provide(VisibilityContextKey, visible);
|
|
214
|
-
const onShow = (value) => {
|
|
215
|
-
localVisible.value = value;
|
|
216
|
-
scheduler.invalidate();
|
|
217
|
-
};
|
|
218
|
-
const rootProps = {
|
|
219
|
-
style: PLACEHOLDER_STYLE,
|
|
220
|
-
onVnodeBeforeMount: (vnode) => {
|
|
221
|
-
const el = vnode.el;
|
|
222
|
-
if (el && typeof el === "object") el[VUE_TERMINAL_SHOW_CB] = onShow;
|
|
223
|
-
},
|
|
224
|
-
onVnodeBeforeUnmount: (vnode) => {
|
|
225
|
-
const el = vnode.el;
|
|
226
|
-
if (el && typeof el === "object" && el[VUE_TERMINAL_SHOW_CB] === onShow) delete el[VUE_TERMINAL_SHOW_CB];
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
return {
|
|
230
|
-
visible,
|
|
231
|
-
rootProps
|
|
232
|
-
};
|
|
233
|
-
}
|
|
23
|
+
//#region src/vue/render/context.ts
|
|
24
|
+
const RenderStackKey = injectionKey("RenderStack");
|
|
234
25
|
|
|
235
26
|
//#endregion
|
|
236
|
-
//#region src/vue/utils/
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if (x1 <= x0 || y1 <= y0) return null;
|
|
243
|
-
return {
|
|
244
|
-
x: x0,
|
|
245
|
-
y: y0,
|
|
246
|
-
w: x1 - x0,
|
|
247
|
-
h: y1 - y0
|
|
248
|
-
};
|
|
27
|
+
//#region src/vue/utils/text.ts
|
|
28
|
+
let renderPassDepth = 0;
|
|
29
|
+
const renderPassTextWidthCache = new Map();
|
|
30
|
+
const textWidthProviderStack = [];
|
|
31
|
+
function currentTextWidthProvider() {
|
|
32
|
+
return textWidthProviderStack[textWidthProviderStack.length - 1] ?? "default";
|
|
249
33
|
}
|
|
250
|
-
function
|
|
251
|
-
return
|
|
252
|
-
x: rect.x + dx,
|
|
253
|
-
y: rect.y + dy,
|
|
254
|
-
w: rect.w,
|
|
255
|
-
h: rect.h
|
|
256
|
-
};
|
|
34
|
+
function hasAsciiFastPath(provider) {
|
|
35
|
+
return typeof provider !== "function";
|
|
257
36
|
}
|
|
258
|
-
function
|
|
259
|
-
|
|
260
|
-
const y0 = Math.floor(rect.y);
|
|
261
|
-
const x1 = Math.floor(rect.x + rect.w);
|
|
262
|
-
const y1 = Math.floor(rect.y + rect.h);
|
|
263
|
-
return {
|
|
264
|
-
x: x0,
|
|
265
|
-
y: y0,
|
|
266
|
-
w: Math.max(0, x1 - x0),
|
|
267
|
-
h: Math.max(0, y1 - y0)
|
|
268
|
-
};
|
|
37
|
+
function hasTextWidthAsciiFastPath() {
|
|
38
|
+
return hasAsciiFastPath(currentTextWidthProvider());
|
|
269
39
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
//#region src/core/buffer/width.ts
|
|
273
|
-
const fullWidthRanges = [
|
|
274
|
-
[4352, 4447],
|
|
275
|
-
[9001, 9002],
|
|
276
|
-
[11904, 42191],
|
|
277
|
-
[44032, 55203],
|
|
278
|
-
[63744, 64255],
|
|
279
|
-
[65040, 65049],
|
|
280
|
-
[65072, 65135],
|
|
281
|
-
[65280, 65376],
|
|
282
|
-
[65504, 65510]
|
|
283
|
-
];
|
|
284
|
-
function isFullWidthCodePoint(codePoint) {
|
|
285
|
-
if (codePoint < 4352 || codePoint > 65510) return false;
|
|
286
|
-
for (const [start, end] of fullWidthRanges) {
|
|
287
|
-
if (codePoint < start) return false;
|
|
288
|
-
if (codePoint <= end) return true;
|
|
289
|
-
}
|
|
290
|
-
return false;
|
|
40
|
+
function canUseDefaultTextCache(provider) {
|
|
41
|
+
return provider === "default" || provider === "narrow-ambiguous";
|
|
291
42
|
}
|
|
292
|
-
function
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
} catch {
|
|
299
|
-
extendedPictographicRe = null;
|
|
300
|
-
}
|
|
301
|
-
let emojiPresentationRe = null;
|
|
302
|
-
try {
|
|
303
|
-
emojiPresentationRe = new RegExp("\\p{Emoji_Presentation}", "u");
|
|
304
|
-
} catch {
|
|
305
|
-
emojiPresentationRe = null;
|
|
306
|
-
}
|
|
307
|
-
let emojiRe = null;
|
|
308
|
-
try {
|
|
309
|
-
emojiRe = new RegExp("\\p{Emoji}", "u");
|
|
310
|
-
} catch {
|
|
311
|
-
emojiRe = null;
|
|
312
|
-
}
|
|
313
|
-
function charCellWidth(text) {
|
|
314
|
-
if (!text) return 1;
|
|
315
|
-
if (text.length === 1) {
|
|
316
|
-
const code = text.charCodeAt(0);
|
|
317
|
-
if (code < 4352) return 1;
|
|
318
|
-
}
|
|
319
|
-
const codePoint = text.codePointAt(0);
|
|
320
|
-
if (codePoint == null) return 1;
|
|
321
|
-
const hasVs16 = text.includes("️");
|
|
322
|
-
if (isFullWidthCodePoint(codePoint)) return 2;
|
|
323
|
-
if (isEmojiLike(codePoint)) return 2;
|
|
324
|
-
if (emojiPresentationRe === null || emojiPresentationRe === void 0 ? void 0 : emojiPresentationRe.test(text)) return 2;
|
|
325
|
-
if (text.includes("⃣")) return 2;
|
|
326
|
-
if (hasVs16 && (emojiRe === null || emojiRe === void 0 ? void 0 : emojiRe.test(text))) return 2;
|
|
327
|
-
if (extendedPictographicRe === null || extendedPictographicRe === void 0 ? void 0 : extendedPictographicRe.test(text)) {
|
|
328
|
-
if (codePoint <= 65535) return hasVs16 ? 2 : 1;
|
|
329
|
-
return 2;
|
|
43
|
+
function withTextWidthProvider(provider, fn) {
|
|
44
|
+
textWidthProviderStack.push(provider ?? "default");
|
|
45
|
+
try {
|
|
46
|
+
return fn();
|
|
47
|
+
} finally {
|
|
48
|
+
textWidthProviderStack.pop();
|
|
330
49
|
}
|
|
331
|
-
return 1;
|
|
332
50
|
}
|
|
333
|
-
|
|
334
|
-
//#endregion
|
|
335
|
-
//#region src/vue/utils/text.ts
|
|
336
|
-
let renderPassDepth = 0;
|
|
337
|
-
const renderPassTextWidthCache = new Map();
|
|
338
|
-
function withTextRenderPass(fn) {
|
|
51
|
+
function withTextRenderPass(fn, provider) {
|
|
339
52
|
renderPassDepth++;
|
|
53
|
+
textWidthProviderStack.push(provider ?? currentTextWidthProvider());
|
|
340
54
|
try {
|
|
341
55
|
if (renderPassDepth === 1) renderPassTextWidthCache.clear();
|
|
342
56
|
return fn();
|
|
343
57
|
} finally {
|
|
58
|
+
textWidthProviderStack.pop();
|
|
344
59
|
renderPassDepth--;
|
|
345
60
|
if (renderPassDepth === 0) renderPassTextWidthCache.clear();
|
|
346
61
|
}
|
|
@@ -349,48 +64,49 @@ function isAscii(text) {
|
|
|
349
64
|
for (let i = 0; i < text.length; i++) if (text.charCodeAt(i) > 127) return false;
|
|
350
65
|
return true;
|
|
351
66
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
if (
|
|
67
|
+
const UNSAFE_FORMAT_CONTROL_RE = /[\u061C\u00AD\u180E\u200B\u200C\u200E\u200F\u202A-\u202E\u2060-\u206F\uFEFF]/u;
|
|
68
|
+
function isUnsafeFormatControl(codePoint) {
|
|
69
|
+
return codePoint === 1564 || codePoint === 173 || codePoint === 6158 || codePoint === 8203 || codePoint === 8204 || codePoint === 8206 || codePoint === 8207 || codePoint >= 8234 && codePoint <= 8238 || codePoint >= 8288 && codePoint <= 8303 || codePoint === 65279;
|
|
70
|
+
}
|
|
71
|
+
function hasInlineAsciiControl(text) {
|
|
72
|
+
for (let i = 0; i < text.length; i++) {
|
|
73
|
+
const code = text.charCodeAt(i);
|
|
74
|
+
if (code === 10 || code === 13 || code === 9) return true;
|
|
360
75
|
}
|
|
361
76
|
return false;
|
|
362
77
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
78
|
+
function hasTextBlockAsciiControl(text) {
|
|
79
|
+
for (let i = 0; i < text.length; i++) {
|
|
80
|
+
const code = text.charCodeAt(i);
|
|
81
|
+
if (code === 9 || code <= 31 && code !== 10 || code === 127) return true;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
368
84
|
}
|
|
369
85
|
function forEachGrapheme(text, cb) {
|
|
370
86
|
if (!text) return;
|
|
371
|
-
const
|
|
372
|
-
if (!
|
|
87
|
+
const segments = segmentedGraphemes(text);
|
|
88
|
+
if (!segments) {
|
|
373
89
|
for (const ch of text) {
|
|
374
90
|
const r = cb(ch);
|
|
375
91
|
if (r === false) return;
|
|
376
92
|
}
|
|
377
93
|
return;
|
|
378
94
|
}
|
|
379
|
-
for (const part of
|
|
95
|
+
for (const part of segments) {
|
|
380
96
|
const r = cb(part.segment);
|
|
381
97
|
if (r === false) return;
|
|
382
98
|
}
|
|
383
99
|
}
|
|
384
|
-
function forEachTextCellSegment(text, cb) {
|
|
100
|
+
function forEachTextCellSegment(text, cb, provider = currentTextWidthProvider()) {
|
|
385
101
|
if (!text) return;
|
|
386
|
-
const
|
|
387
|
-
if (!
|
|
102
|
+
const segments = segmentedGraphemes(text);
|
|
103
|
+
if (!segments) {
|
|
388
104
|
let index$1 = 0;
|
|
389
105
|
for (const ch of text) {
|
|
390
106
|
const next = index$1 + ch.length;
|
|
391
107
|
const result = cb({
|
|
392
108
|
text: ch,
|
|
393
|
-
cells: charCellWidth(ch),
|
|
109
|
+
cells: charCellWidth(ch, provider),
|
|
394
110
|
start: index$1,
|
|
395
111
|
end: next
|
|
396
112
|
});
|
|
@@ -400,12 +116,12 @@ function forEachTextCellSegment(text, cb) {
|
|
|
400
116
|
return;
|
|
401
117
|
}
|
|
402
118
|
let index = 0;
|
|
403
|
-
for (const part of
|
|
119
|
+
for (const part of segments) {
|
|
404
120
|
const start = part.index ?? index;
|
|
405
121
|
const end = start + part.segment.length;
|
|
406
122
|
const result = cb({
|
|
407
123
|
text: part.segment,
|
|
408
|
-
cells: charCellWidth(part.segment),
|
|
124
|
+
cells: charCellWidth(part.segment, provider),
|
|
409
125
|
start,
|
|
410
126
|
end
|
|
411
127
|
});
|
|
@@ -421,11 +137,11 @@ function graphemeRangeAt(text, index) {
|
|
|
421
137
|
start: index,
|
|
422
138
|
end: index + 1
|
|
423
139
|
};
|
|
424
|
-
const
|
|
425
|
-
if (
|
|
140
|
+
const segments = segmentedGraphemes(text);
|
|
141
|
+
if (segments) {
|
|
426
142
|
let pos$1 = 0;
|
|
427
|
-
for (const part of
|
|
428
|
-
const start = pos$1;
|
|
143
|
+
for (const part of segments) {
|
|
144
|
+
const start = part.index ?? pos$1;
|
|
429
145
|
const end = start + part.segment.length;
|
|
430
146
|
if (index >= start && index < end) return {
|
|
431
147
|
start,
|
|
@@ -449,12 +165,22 @@ function graphemeRangeAt(text, index) {
|
|
|
449
165
|
}
|
|
450
166
|
function sanitizeInlineText(text) {
|
|
451
167
|
if (!text) return "";
|
|
452
|
-
if (
|
|
453
|
-
|
|
168
|
+
if (!UNSAFE_FORMAT_CONTROL_RE.test(text) && !hasInlineAsciiControl(text)) return text;
|
|
169
|
+
const out = [];
|
|
170
|
+
for (const ch of text) {
|
|
171
|
+
const cp = ch.codePointAt(0);
|
|
172
|
+
if (cp === 10 || cp === 13 || cp === 9) {
|
|
173
|
+
out.push(" ");
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (isUnsafeFormatControl(cp)) continue;
|
|
177
|
+
out.push(ch);
|
|
178
|
+
}
|
|
179
|
+
return out.join("");
|
|
454
180
|
}
|
|
455
181
|
function sanitizeTextBlock(text) {
|
|
456
182
|
if (!text) return "";
|
|
457
|
-
if (
|
|
183
|
+
if (!UNSAFE_FORMAT_CONTROL_RE.test(text) && !hasTextBlockAsciiControl(text)) return text;
|
|
458
184
|
const out = [];
|
|
459
185
|
out.length = 0;
|
|
460
186
|
for (const ch of text) {
|
|
@@ -465,25 +191,29 @@ function sanitizeTextBlock(text) {
|
|
|
465
191
|
continue;
|
|
466
192
|
}
|
|
467
193
|
if (cp <= 31 && cp !== 10 || cp === 127) continue;
|
|
194
|
+
if (isUnsafeFormatControl(cp)) continue;
|
|
468
195
|
out.push(ch);
|
|
469
196
|
}
|
|
470
197
|
return out.join("");
|
|
471
198
|
}
|
|
472
|
-
function textCellWidth(text) {
|
|
199
|
+
function textCellWidth(text, provider = currentTextWidthProvider()) {
|
|
473
200
|
if (!text) return 0;
|
|
474
|
-
if (isAscii(text)) return text.length;
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
201
|
+
if (hasAsciiFastPath(provider) && isAscii(text)) return text.length;
|
|
202
|
+
const useCache = canUseDefaultTextCache(provider);
|
|
203
|
+
if (useCache && renderPassDepth > 0) {
|
|
204
|
+
const cached = renderPassTextWidthCache.get(text);
|
|
205
|
+
if (cached != null) return cached;
|
|
206
|
+
}
|
|
207
|
+
if (useCache) {
|
|
208
|
+
const cached = textWidthCacheGet(text);
|
|
209
|
+
if (cached != null) return cached;
|
|
478
210
|
}
|
|
479
|
-
const cached = textWidthCacheGet(text);
|
|
480
|
-
if (cached != null) return cached;
|
|
481
211
|
let cells = 0;
|
|
482
212
|
forEachGrapheme(text, (g) => {
|
|
483
|
-
cells += charCellWidth(g);
|
|
213
|
+
cells += charCellWidth(g, provider);
|
|
484
214
|
});
|
|
485
|
-
if (renderPassDepth > 0) renderPassTextWidthCache.set(text, cells);
|
|
486
|
-
textWidthCacheSet(text, cells);
|
|
215
|
+
if (useCache && renderPassDepth > 0) renderPassTextWidthCache.set(text, cells);
|
|
216
|
+
if (useCache) textWidthCacheSet(text, cells);
|
|
487
217
|
return cells;
|
|
488
218
|
}
|
|
489
219
|
const spaceCache = new Map();
|
|
@@ -518,14 +248,14 @@ function repeatChar(ch, count) {
|
|
|
518
248
|
bucket.set(count, v);
|
|
519
249
|
return v;
|
|
520
250
|
}
|
|
521
|
-
function sliceByCells(text, maxCells) {
|
|
251
|
+
function sliceByCells(text, maxCells, provider = currentTextWidthProvider()) {
|
|
522
252
|
maxCells = Math.max(0, Math.floor(maxCells));
|
|
523
253
|
if (maxCells <= 0) return "";
|
|
524
|
-
if (text && isAscii(text)) return text.slice(0, maxCells);
|
|
254
|
+
if (text && hasAsciiFastPath(provider) && isAscii(text)) return text.slice(0, maxCells);
|
|
525
255
|
const out = [];
|
|
526
256
|
let cells = 0;
|
|
527
257
|
forEachGrapheme(text, (g) => {
|
|
528
|
-
const w = charCellWidth(g);
|
|
258
|
+
const w = charCellWidth(g, provider);
|
|
529
259
|
if (cells + w > maxCells) return false;
|
|
530
260
|
out.push(g);
|
|
531
261
|
cells += w;
|
|
@@ -533,16 +263,16 @@ function sliceByCells(text, maxCells) {
|
|
|
533
263
|
});
|
|
534
264
|
return out.length ? out.join("") : "";
|
|
535
265
|
}
|
|
536
|
-
function sliceByCellsRange(text, startCells, endCells) {
|
|
266
|
+
function sliceByCellsRange(text, startCells, endCells, provider = currentTextWidthProvider()) {
|
|
537
267
|
startCells = Math.max(0, Math.floor(startCells));
|
|
538
268
|
endCells = Math.max(0, Math.floor(endCells));
|
|
539
269
|
if (endCells <= startCells) return "";
|
|
540
270
|
if (!text) return "";
|
|
541
|
-
if (isAscii(text)) return text.slice(startCells, endCells);
|
|
271
|
+
if (hasAsciiFastPath(provider) && isAscii(text)) return text.slice(startCells, endCells);
|
|
542
272
|
const out = [];
|
|
543
273
|
let cells = 0;
|
|
544
274
|
forEachGrapheme(text, (g) => {
|
|
545
|
-
const w = charCellWidth(g);
|
|
275
|
+
const w = charCellWidth(g, provider);
|
|
546
276
|
const next = cells + w;
|
|
547
277
|
if (cells >= endCells) return false;
|
|
548
278
|
if (next <= startCells) {
|
|
@@ -564,9 +294,9 @@ function sliceByCellsRange(text, startCells, endCells) {
|
|
|
564
294
|
});
|
|
565
295
|
return out.length ? out.join("") : "";
|
|
566
296
|
}
|
|
567
|
-
function padEndByCells(text, width) {
|
|
297
|
+
function padEndByCells(text, width, provider = currentTextWidthProvider()) {
|
|
568
298
|
width = Math.max(0, Math.floor(width));
|
|
569
|
-
const cells = text && isAscii(text) ? text.length : textCellWidth(text);
|
|
299
|
+
const cells = text && hasAsciiFastPath(provider) && isAscii(text) ? text.length : textCellWidth(text, provider);
|
|
570
300
|
if (cells >= width) return text;
|
|
571
301
|
return `${text}${spaces(width - cells)}`;
|
|
572
302
|
}
|
|
@@ -581,23 +311,28 @@ function getInlineLineBucket(width) {
|
|
|
581
311
|
inlineLineCacheByWidth.set(width, bucket);
|
|
582
312
|
return bucket;
|
|
583
313
|
}
|
|
584
|
-
function formatInlineCellLine(text, width) {
|
|
314
|
+
function formatInlineCellLine(text, width, provider = currentTextWidthProvider()) {
|
|
585
315
|
width = Math.max(0, Math.floor(width));
|
|
586
316
|
if (width === 0) return "";
|
|
587
317
|
if (!text) return spaces(width);
|
|
588
|
-
const
|
|
589
|
-
const
|
|
318
|
+
const useCache = canUseDefaultTextCache(provider);
|
|
319
|
+
const bucket = useCache ? getInlineLineBucket(width) : null;
|
|
320
|
+
const cached = bucket?.get(text);
|
|
590
321
|
if (cached != null) return cached;
|
|
591
322
|
const sanitized = sanitizeInlineText(text);
|
|
592
|
-
if (sanitized && isAscii(sanitized)) {
|
|
323
|
+
if (sanitized && hasAsciiFastPath(provider) && isAscii(sanitized)) {
|
|
593
324
|
const out$1 = sanitized.length >= width ? sanitized.slice(0, width) : `${sanitized}${spaces(width - sanitized.length)}`;
|
|
594
|
-
if (bucket
|
|
595
|
-
|
|
325
|
+
if (bucket) {
|
|
326
|
+
if (bucket.size >= MAX_INLINE_LINE_CACHE_PER_WIDTH) bucket.clear();
|
|
327
|
+
bucket.set(text, out$1);
|
|
328
|
+
}
|
|
596
329
|
return out$1;
|
|
597
330
|
}
|
|
598
|
-
const out = padEndByCells(sliceByCells(sanitized, width), width);
|
|
599
|
-
if (bucket
|
|
600
|
-
|
|
331
|
+
const out = padEndByCells(sliceByCells(sanitized, width, provider), width, provider);
|
|
332
|
+
if (bucket) {
|
|
333
|
+
if (bucket.size >= MAX_INLINE_LINE_CACHE_PER_WIDTH) bucket.clear();
|
|
334
|
+
bucket.set(text, out);
|
|
335
|
+
}
|
|
601
336
|
return out;
|
|
602
337
|
}
|
|
603
338
|
const wrapCacheByWidth = new Map();
|
|
@@ -634,11 +369,12 @@ function clearTextCaches() {
|
|
|
634
369
|
textWidthCache.clear();
|
|
635
370
|
inlineLineCacheByWidth.clear();
|
|
636
371
|
}
|
|
637
|
-
function wrapByCells(text, width) {
|
|
372
|
+
function wrapByCells(text, width, provider = currentTextWidthProvider()) {
|
|
638
373
|
width = Math.max(1, Math.floor(width));
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
|
|
374
|
+
const useCache = canUseDefaultTextCache(provider);
|
|
375
|
+
const bucket = useCache ? getWrapBucket(width) : null;
|
|
376
|
+
if (text && hasAsciiFastPath(provider) && isAscii(text)) {
|
|
377
|
+
const cached$1 = bucket?.get(text);
|
|
642
378
|
if (cached$1) return cached$1;
|
|
643
379
|
const out$1 = [];
|
|
644
380
|
for (const rawLine of text.replace(/\r/g, "").split("\n")) {
|
|
@@ -648,11 +384,13 @@ function wrapByCells(text, width) {
|
|
|
648
384
|
}
|
|
649
385
|
for (let i = 0; i < rawLine.length; i += width) out$1.push(rawLine.slice(i, i + width));
|
|
650
386
|
}
|
|
651
|
-
if (bucket
|
|
652
|
-
|
|
387
|
+
if (bucket) {
|
|
388
|
+
if (bucket.size >= MAX_WRAP_CACHE_PER_WIDTH) bucket.clear();
|
|
389
|
+
bucket.set(text, out$1);
|
|
390
|
+
}
|
|
653
391
|
return out$1;
|
|
654
392
|
}
|
|
655
|
-
const cached = bucket
|
|
393
|
+
const cached = bucket?.get(text);
|
|
656
394
|
if (cached) return cached;
|
|
657
395
|
const out = [];
|
|
658
396
|
for (const rawLine of text.replace(/\r/g, "").split("\n")) {
|
|
@@ -660,14 +398,14 @@ function wrapByCells(text, width) {
|
|
|
660
398
|
out.push("");
|
|
661
399
|
continue;
|
|
662
400
|
}
|
|
663
|
-
const
|
|
664
|
-
if (
|
|
401
|
+
const segments = segmentedGraphemes(rawLine);
|
|
402
|
+
if (segments) {
|
|
665
403
|
let lineStart = 0;
|
|
666
404
|
let cells = 0;
|
|
667
|
-
for (const part of
|
|
405
|
+
for (const part of segments) {
|
|
668
406
|
const g = part.segment;
|
|
669
407
|
const gIdx = part.index;
|
|
670
|
-
const w = charCellWidth(g);
|
|
408
|
+
const w = charCellWidth(g, provider);
|
|
671
409
|
if (cells > 0 && cells + w > width) {
|
|
672
410
|
out.push(rawLine.slice(lineStart, gIdx));
|
|
673
411
|
lineStart = gIdx;
|
|
@@ -687,7 +425,7 @@ function wrapByCells(text, width) {
|
|
|
687
425
|
let pos = 0;
|
|
688
426
|
let cells = 0;
|
|
689
427
|
for (const ch of rawLine) {
|
|
690
|
-
const w = charCellWidth(ch);
|
|
428
|
+
const w = charCellWidth(ch, provider);
|
|
691
429
|
if (cells > 0 && cells + w > width) {
|
|
692
430
|
out.push(rawLine.slice(lineStart, pos));
|
|
693
431
|
lineStart = pos;
|
|
@@ -705,11 +443,278 @@ function wrapByCells(text, width) {
|
|
|
705
443
|
}
|
|
706
444
|
}
|
|
707
445
|
const res = out.length ? out : [""];
|
|
708
|
-
if (bucket
|
|
709
|
-
|
|
446
|
+
if (bucket) {
|
|
447
|
+
if (bucket.size >= MAX_WRAP_CACHE_PER_WIDTH) bucket.clear();
|
|
448
|
+
bucket.set(text, res);
|
|
449
|
+
}
|
|
710
450
|
return res;
|
|
711
451
|
}
|
|
712
452
|
|
|
453
|
+
//#endregion
|
|
454
|
+
//#region src/vue/composables/use-layout.ts
|
|
455
|
+
function useLayout() {
|
|
456
|
+
const ctx = inject(LayoutContextKey, null);
|
|
457
|
+
if (!ctx) throw new Error("LayoutContext is missing (TerminalProvider/TView)");
|
|
458
|
+
return ctx;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
//#endregion
|
|
462
|
+
//#region src/vue/composables/use-render-stack.ts
|
|
463
|
+
function useRenderStack() {
|
|
464
|
+
const stack = inject(RenderStackKey, null);
|
|
465
|
+
if (!stack) throw new Error("RenderStack is missing");
|
|
466
|
+
return stack;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
//#endregion
|
|
470
|
+
//#region src/vue/composables/use-terminal.ts
|
|
471
|
+
function useTerminal() {
|
|
472
|
+
const ctx = inject(TerminalContextKey, null);
|
|
473
|
+
if (!ctx) throw new Error("TerminalProvider is missing");
|
|
474
|
+
return ctx;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
//#endregion
|
|
478
|
+
//#region src/vue/composables/use-render-node.ts
|
|
479
|
+
const pendingInvalidateByScheduler = new WeakMap();
|
|
480
|
+
function mergePriority(prev, next) {
|
|
481
|
+
if (prev === "high" || next === "high") return "high";
|
|
482
|
+
if (prev === "normal" || next === "normal") return "normal";
|
|
483
|
+
return "low";
|
|
484
|
+
}
|
|
485
|
+
function requestBatchedInvalidate(scheduler, plane, priority) {
|
|
486
|
+
let state = pendingInvalidateByScheduler.get(scheduler);
|
|
487
|
+
if (!state) {
|
|
488
|
+
state = {
|
|
489
|
+
queued: false,
|
|
490
|
+
plane: null,
|
|
491
|
+
priority: "low"
|
|
492
|
+
};
|
|
493
|
+
pendingInvalidateByScheduler.set(scheduler, state);
|
|
494
|
+
}
|
|
495
|
+
if (state.queued) {
|
|
496
|
+
if (state.plane !== null && state.plane !== plane) state.plane = null;
|
|
497
|
+
state.priority = mergePriority(state.priority, priority);
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
state.plane = plane;
|
|
501
|
+
state.priority = priority;
|
|
502
|
+
state.queued = true;
|
|
503
|
+
queueMicrotask(() => {
|
|
504
|
+
state.queued = false;
|
|
505
|
+
const queuedPlane = state.plane;
|
|
506
|
+
const queuedPriority = state.priority;
|
|
507
|
+
state.plane = null;
|
|
508
|
+
state.priority = "low";
|
|
509
|
+
scheduler.invalidate({
|
|
510
|
+
plane: queuedPlane ?? void 0,
|
|
511
|
+
priority: queuedPriority
|
|
512
|
+
});
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
function useRenderNode(getOptions) {
|
|
516
|
+
const { scheduler, render, widthProvider } = useTerminal();
|
|
517
|
+
const parentStack = useRenderStack();
|
|
518
|
+
const plane = inject(RenderPlaneContextKey, ref("default"));
|
|
519
|
+
const id = ref(null);
|
|
520
|
+
const lastPlane = ref(plane.value);
|
|
521
|
+
const options = computed(() => withTextWidthProvider(widthProvider, getOptions));
|
|
522
|
+
const stop = watchEffect(() => {
|
|
523
|
+
const opt = options.value;
|
|
524
|
+
opt.deps;
|
|
525
|
+
const stack = opt.stack ?? parentStack.value;
|
|
526
|
+
const nextPlane = plane.value;
|
|
527
|
+
if (!stack) return;
|
|
528
|
+
if (!id.value) {
|
|
529
|
+
const node = render.register({
|
|
530
|
+
stack,
|
|
531
|
+
zIndex: opt.zIndex,
|
|
532
|
+
rect: opt.rect,
|
|
533
|
+
plane: nextPlane,
|
|
534
|
+
paint: opt.paint
|
|
535
|
+
});
|
|
536
|
+
id.value = node.id;
|
|
537
|
+
lastPlane.value = nextPlane;
|
|
538
|
+
requestBatchedInvalidate(scheduler, nextPlane, opt.priority ?? "normal");
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
const prevPlane = lastPlane.value;
|
|
542
|
+
const updatePayload = {
|
|
543
|
+
stack,
|
|
544
|
+
zIndex: opt.zIndex ?? 0,
|
|
545
|
+
dirtyRowsHint: opt.dirtyRowsHint,
|
|
546
|
+
plane: nextPlane,
|
|
547
|
+
paint: opt.paint
|
|
548
|
+
};
|
|
549
|
+
if (Object.prototype.hasOwnProperty.call(opt, "rect")) updatePayload.rect = opt.rect ?? null;
|
|
550
|
+
render.update(id.value, updatePayload);
|
|
551
|
+
lastPlane.value = nextPlane;
|
|
552
|
+
const priority = opt.priority ?? "normal";
|
|
553
|
+
requestBatchedInvalidate(scheduler, prevPlane, priority);
|
|
554
|
+
if (prevPlane !== nextPlane) requestBatchedInvalidate(scheduler, nextPlane, priority);
|
|
555
|
+
});
|
|
556
|
+
onBeforeUnmount(() => {
|
|
557
|
+
stop();
|
|
558
|
+
if (id.value) {
|
|
559
|
+
render.unregister(id.value);
|
|
560
|
+
requestBatchedInvalidate(scheduler, lastPlane.value, "normal");
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
return { id };
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
//#endregion
|
|
567
|
+
//#region src/vue/composables/use-terminal-node.ts
|
|
568
|
+
function wrapHandlers(handlers, widthProvider) {
|
|
569
|
+
if (!handlers) return {};
|
|
570
|
+
const out = {};
|
|
571
|
+
for (const key of Object.keys(handlers)) {
|
|
572
|
+
const handler = handlers[key];
|
|
573
|
+
if (!handler) continue;
|
|
574
|
+
out[key] = (event) => withTextWidthProvider(widthProvider, () => handler(event));
|
|
575
|
+
}
|
|
576
|
+
return out;
|
|
577
|
+
}
|
|
578
|
+
function useTerminalNode(getOptions) {
|
|
579
|
+
const { events, widthProvider } = useTerminal();
|
|
580
|
+
const id = ref(null);
|
|
581
|
+
const options = computed(() => withTextWidthProvider(widthProvider, getOptions));
|
|
582
|
+
const stop = watchEffect(() => {
|
|
583
|
+
const manager = events.value;
|
|
584
|
+
if (!manager) return;
|
|
585
|
+
const opt = options.value;
|
|
586
|
+
if (!id.value) {
|
|
587
|
+
const node = manager.register({
|
|
588
|
+
rect: opt.rect,
|
|
589
|
+
zIndex: opt.zIndex ?? 0,
|
|
590
|
+
visible: opt.visible,
|
|
591
|
+
focusable: opt.focusable,
|
|
592
|
+
selectable: opt.selectable,
|
|
593
|
+
selectionScrollBy: opt.selectionScrollBy,
|
|
594
|
+
handlers: wrapHandlers(opt.handlers, widthProvider)
|
|
595
|
+
});
|
|
596
|
+
id.value = node.id;
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
manager.update(id.value, {
|
|
600
|
+
rect: opt.rect,
|
|
601
|
+
zIndex: opt.zIndex ?? 0,
|
|
602
|
+
visible: opt.visible,
|
|
603
|
+
focusable: opt.focusable,
|
|
604
|
+
selectable: opt.selectable,
|
|
605
|
+
selectionScrollBy: opt.selectionScrollBy,
|
|
606
|
+
handlers: wrapHandlers(opt.handlers, widthProvider)
|
|
607
|
+
});
|
|
608
|
+
});
|
|
609
|
+
onBeforeUnmount(() => {
|
|
610
|
+
stop();
|
|
611
|
+
const manager = events.value;
|
|
612
|
+
if (manager && id.value) manager.unregister(id.value);
|
|
613
|
+
});
|
|
614
|
+
return { id };
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
//#endregion
|
|
618
|
+
//#region src/vue/composables/use-visibility.ts
|
|
619
|
+
const VUE_TERMINAL_SHOW_CB = "__vueTerminalOnShow";
|
|
620
|
+
let vShowPatched = false;
|
|
621
|
+
function patchVShow() {
|
|
622
|
+
if (vShowPatched) return;
|
|
623
|
+
vShowPatched = true;
|
|
624
|
+
const dir = vShow;
|
|
625
|
+
const origBeforeMount = dir.beforeMount;
|
|
626
|
+
const origUpdated = dir.updated;
|
|
627
|
+
const origBeforeUnmount = dir.beforeUnmount;
|
|
628
|
+
const notify = (el, value) => {
|
|
629
|
+
if (!el || typeof el !== "object") return;
|
|
630
|
+
const cb = el[VUE_TERMINAL_SHOW_CB];
|
|
631
|
+
cb?.(Boolean(value));
|
|
632
|
+
};
|
|
633
|
+
if (typeof origBeforeMount === "function") dir.beforeMount = (el, binding, vnode) => {
|
|
634
|
+
origBeforeMount(el, binding, vnode);
|
|
635
|
+
notify(el, binding?.value);
|
|
636
|
+
};
|
|
637
|
+
if (typeof origUpdated === "function") dir.updated = (el, binding, vnode) => {
|
|
638
|
+
origUpdated(el, binding, vnode);
|
|
639
|
+
notify(el, binding?.value);
|
|
640
|
+
};
|
|
641
|
+
if (typeof origBeforeUnmount === "function") dir.beforeUnmount = (el, binding, vnode) => {
|
|
642
|
+
origBeforeUnmount(el, binding, vnode);
|
|
643
|
+
notify(el, binding?.value);
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
const PLACEHOLDER_STYLE = Object.freeze({
|
|
647
|
+
position: "absolute",
|
|
648
|
+
left: "-9999px",
|
|
649
|
+
top: "0",
|
|
650
|
+
width: "0",
|
|
651
|
+
height: "0",
|
|
652
|
+
overflow: "hidden"
|
|
653
|
+
});
|
|
654
|
+
function useVisibility(options) {
|
|
655
|
+
patchVShow();
|
|
656
|
+
const { scheduler } = useTerminal();
|
|
657
|
+
const parentVisible = inject(VisibilityContextKey, ref(true));
|
|
658
|
+
const localVisible = ref(true);
|
|
659
|
+
const visible = computed(() => parentVisible.value && localVisible.value);
|
|
660
|
+
if (options?.provide) provide(VisibilityContextKey, visible);
|
|
661
|
+
const onShow = (value) => {
|
|
662
|
+
localVisible.value = value;
|
|
663
|
+
scheduler.invalidate();
|
|
664
|
+
};
|
|
665
|
+
const rootProps = {
|
|
666
|
+
style: PLACEHOLDER_STYLE,
|
|
667
|
+
onVnodeBeforeMount: (vnode) => {
|
|
668
|
+
const el = vnode.el;
|
|
669
|
+
if (el && typeof el === "object") el[VUE_TERMINAL_SHOW_CB] = onShow;
|
|
670
|
+
},
|
|
671
|
+
onVnodeBeforeUnmount: (vnode) => {
|
|
672
|
+
const el = vnode.el;
|
|
673
|
+
if (el && typeof el === "object" && el[VUE_TERMINAL_SHOW_CB] === onShow) delete el[VUE_TERMINAL_SHOW_CB];
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
return {
|
|
677
|
+
visible,
|
|
678
|
+
rootProps
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
//#endregion
|
|
683
|
+
//#region src/vue/utils/rect.ts
|
|
684
|
+
function intersectRect(a, b) {
|
|
685
|
+
const x0 = Math.max(a.x, b.x);
|
|
686
|
+
const y0 = Math.max(a.y, b.y);
|
|
687
|
+
const x1 = Math.min(a.x + a.w, b.x + b.w);
|
|
688
|
+
const y1 = Math.min(a.y + a.h, b.y + b.h);
|
|
689
|
+
if (x1 <= x0 || y1 <= y0) return null;
|
|
690
|
+
return {
|
|
691
|
+
x: x0,
|
|
692
|
+
y: y0,
|
|
693
|
+
w: x1 - x0,
|
|
694
|
+
h: y1 - y0
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
function translateRect(rect, dx, dy) {
|
|
698
|
+
return {
|
|
699
|
+
x: rect.x + dx,
|
|
700
|
+
y: rect.y + dy,
|
|
701
|
+
w: rect.w,
|
|
702
|
+
h: rect.h
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
function normalizeCellRect(rect) {
|
|
706
|
+
const x0 = Math.floor(rect.x);
|
|
707
|
+
const y0 = Math.floor(rect.y);
|
|
708
|
+
const x1 = Math.floor(rect.x + rect.w);
|
|
709
|
+
const y1 = Math.floor(rect.y + rect.h);
|
|
710
|
+
return {
|
|
711
|
+
x: x0,
|
|
712
|
+
y: y0,
|
|
713
|
+
w: Math.max(0, x1 - x0),
|
|
714
|
+
h: Math.max(0, y1 - y0)
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
|
|
713
718
|
//#endregion
|
|
714
719
|
//#region src/vue/utils/wheel-scroll.ts
|
|
715
720
|
const LINE_UNIT_THRESHOLD = 3;
|
|
@@ -717,7 +722,6 @@ const PIXELS_PER_LINE = 16;
|
|
|
717
722
|
const ACCEL_WINDOW_MS = 120;
|
|
718
723
|
const MAX_ACCEL = 26;
|
|
719
724
|
const EDGE_BOUNCE_MS = 120;
|
|
720
|
-
const MIN_TICK_INTERVAL_MS = 6;
|
|
721
725
|
function clamp(n, min, max) {
|
|
722
726
|
return Math.max(min, Math.min(max, n));
|
|
723
727
|
}
|
|
@@ -734,11 +738,11 @@ function normalizeDelta(deltaY, mode = "auto") {
|
|
|
734
738
|
if (abs <= LINE_UNIT_THRESHOLD && Number.isInteger(deltaY)) return deltaY;
|
|
735
739
|
return deltaY / PIXELS_PER_LINE;
|
|
736
740
|
}
|
|
737
|
-
function accelFactor(now, lastAt) {
|
|
741
|
+
function accelFactor(now, lastAt, maxAccel = MAX_ACCEL) {
|
|
738
742
|
const dt = now - lastAt;
|
|
739
743
|
if (!Number.isFinite(dt) || dt <= 0 || dt > ACCEL_WINDOW_MS) return 1;
|
|
740
744
|
const t = 1 - dt / ACCEL_WINDOW_MS;
|
|
741
|
-
return 1 + t * (
|
|
745
|
+
return 1 + t * (maxAccel - 1);
|
|
742
746
|
}
|
|
743
747
|
function createWheelScrollState() {
|
|
744
748
|
return {
|
|
@@ -767,16 +771,11 @@ function applyWheelScroll(state, deltaY, scrollTop, maxTop, now = Date.now(), de
|
|
|
767
771
|
lines: 0
|
|
768
772
|
};
|
|
769
773
|
}
|
|
770
|
-
const dt = state.lastAt ? now - state.lastAt : Infinity;
|
|
771
774
|
const lineUnits = isLineUnitDelta(deltaY, deltaMode);
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
dir: 0,
|
|
775
|
-
lines: 0
|
|
776
|
-
};
|
|
777
|
-
const accel = lineUnits ? 1 : options.disableAcceleration ? 1 : state.lastAt ? accelFactor(now, state.lastAt) : 1;
|
|
775
|
+
const normalizedDelta = normalizeDelta(deltaY, deltaMode);
|
|
776
|
+
const accel = options.disableAcceleration ? 1 : lineUnits ? 1 : state.lastAt ? accelFactor(now, state.lastAt) : 1;
|
|
778
777
|
state.lastAt = now;
|
|
779
|
-
state.accumulator +=
|
|
778
|
+
state.accumulator += normalizedDelta * accel;
|
|
780
779
|
const lines = Math.trunc(state.accumulator);
|
|
781
780
|
if (lines === 0) return {
|
|
782
781
|
nextTop: scrollTop,
|
|
@@ -822,4 +821,4 @@ function applyWheelScroll(state, deltaY, scrollTop, maxTop, now = Date.now(), de
|
|
|
822
821
|
}
|
|
823
822
|
|
|
824
823
|
//#endregion
|
|
825
|
-
export { DialogContextKey, EventZIndexContextKey, ImeAnchorContextKey, LayoutContextKey, RenderPlaneContextKey, RenderStackKey, TInputPluginsContextKey, TPathPickerProviderContextKey, TerminalContextKey, VisibilityContextKey, applyWheelScroll,
|
|
824
|
+
export { DialogContextKey, EventZIndexContextKey, ImeAnchorContextKey, LayoutContextKey, RenderPlaneContextKey, RenderStackKey, TInputPluginsContextKey, TPathPickerProviderContextKey, TerminalContextKey, VisibilityContextKey, applyWheelScroll, clearTextCaches, createWheelScrollState, currentTextWidthProvider, forEachTextCellSegment, formatInlineCellLine, graphemeRangeAt, hasTextWidthAsciiFastPath, injectionKey, intersectRect, normalizeCellRect, padEndByCells as padEndByCells$1, repeatChar, resetWheelScrollState, sanitizeInlineText, sanitizeTextBlock, sliceByCells, sliceByCellsRange, spaces, textCellWidth as textCellWidth$1, translateRect, useLayout, useRenderNode, useRenderStack, useTerminal, useTerminalNode, useVisibility, withTextRenderPass, withTextWidthProvider, wrapByCells };
|