@simon_he/vue-tui 0.0.8 → 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.
- package/README.md +130 -27
- package/dist/TSelect-BmSkar0D.js +8697 -0
- package/dist/ansi-palette-Bv5Vqr4k.js +1499 -0
- package/dist/ansi-styles.d.ts +200 -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 +12 -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 +10664 -0
- package/dist/cli.d.cts +22 -0
- package/dist/cli.d.ts +22 -0
- package/dist/cli.js +9521 -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 +7 -0
- package/dist/core/terminal/emitter.d.ts +7 -0
- package/dist/core/types.d.ts +107 -0
- package/dist/core.cjs +3072 -0
- package/dist/core.d.cts +14 -0
- package/dist/core.d.ts +14 -0
- package/dist/core.js +422 -0
- package/dist/create-terminal-app.d.ts +34 -0
- package/dist/dom-renderer-CDVQIcIL.js +1172 -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 +1777 -1244
- package/dist/experimental.d.cts +39 -0
- package/dist/experimental.d.ts +39 -825
- package/dist/experimental.js +492 -343
- package/dist/frame-perf-C-w8mjJL.js +98 -0
- package/dist/hyperlink-B5PD7a3Q.js +331 -0
- package/dist/index.cjs +13133 -19960
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -1528
- package/dist/index.js +13 -20026
- package/dist/markdown.cjs +8728 -7359
- package/dist/markdown.d.cts +10 -0
- package/dist/markdown.d.ts +10 -112
- package/dist/markdown.js +169 -101
- 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 +13 -0
- package/dist/observability/frame-perf.d.ts +40 -0
- package/dist/observability/trace.d.ts +40 -0
- package/dist/observability/tui-profiler.d.ts +33 -0
- package/dist/observability.cjs +99 -0
- package/dist/observability.d.cts +6 -0
- package/dist/observability.d.ts +6 -0
- package/dist/observability.js +3 -0
- package/dist/path-DDiSCXrQ.js +99 -0
- package/dist/path-suggest-0Q2BDsuj.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 +1511 -0
- package/dist/renderer-dom.d.cts +4 -0
- package/dist/renderer-dom.d.ts +4 -0
- package/dist/renderer-dom.js +6 -0
- package/dist/runtime/index.d.ts +36 -0
- package/dist/runtime/osc52.d.ts +9 -0
- package/dist/runtime-DtrcQidD.js +1197 -0
- package/dist/runtime.cjs +1697 -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 +122 -0
- package/dist/sgr-DMK2AvuT.js +304 -0
- package/dist/style-cache-i0ZABZRq.js +178 -0
- package/dist/terminal-selection-BCOh9jsL.js +329 -0
- package/dist/utils/env.d.ts +3 -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/components/TAnchor.d.ts +108 -0
- package/dist/vue/components/TBox.d.ts +144 -0
- package/dist/vue/components/TDebugOverlay.d.ts +43 -0
- package/dist/vue/components/TDialog.d.ts +256 -0
- package/dist/vue/components/TFlow.d.ts +85 -0
- package/dist/vue/components/TInput.d.ts +554 -0
- package/dist/vue/components/TInputBox.d.ts +158 -0
- package/dist/vue/components/TJsonEditor.d.ts +165 -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 +502 -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/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 +215 -0
- package/dist/vue/components/TText.d.ts +116 -0
- package/dist/vue/components/TTransition.d.ts +83 -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/TerminalProvider.d.ts +195 -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/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/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 +39 -0
- package/dist/vue/injection-key.d.ts +2 -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 +18 -0
- package/dist/vue/markdown/layout.d.ts +16 -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 +47 -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/utils/frame-task.d.ts +6 -0
- package/dist/vue/utils/rect.d.ts +4 -0
- package/dist/vue/utils/style-cache.d.ts +3 -0
- package/dist/vue/utils/text.d.ts +26 -0
- package/dist/vue/utils/wheel-scroll.d.ts +18 -0
- package/dist/vue.cjs +18882 -0
- package/dist/vue.d.cts +3 -0
- package/dist/vue.d.ts +3 -0
- package/dist/vue.js +3066 -0
- package/dist/{wheel-scroll-CiNsasLf.js → wheel-scroll-B-WlFuNB.js} +361 -367
- package/package.json +165 -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 } from "./hyperlink-B5PD7a3Q.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;
|
|
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}`);
|
|
32
8
|
}
|
|
33
9
|
|
|
34
10
|
//#endregion
|
|
35
|
-
//#region src/vue/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
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 };
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
//#endregion
|
|
132
|
-
//#region src/vue/composables/use-terminal-node.ts
|
|
133
|
-
function useTerminalNode(getOptions) {
|
|
134
|
-
const { events } = useTerminal();
|
|
135
|
-
const id = ref(null);
|
|
136
|
-
const options = computed(() => getOptions());
|
|
137
|
-
const stop = watchEffect(() => {
|
|
138
|
-
const manager = events.value;
|
|
139
|
-
if (!manager) return;
|
|
140
|
-
const opt = options.value;
|
|
141
|
-
if (!id.value) {
|
|
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
|
-
}
|
|
169
|
-
|
|
170
|
-
//#endregion
|
|
171
|
-
//#region src/vue/composables/use-visibility.ts
|
|
172
|
-
const VUE_TERMINAL_SHOW_CB = "__vueTerminalOnShow";
|
|
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
|
-
}
|
|
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");
|
|
234
21
|
|
|
235
22
|
//#endregion
|
|
236
|
-
//#region src/vue/
|
|
237
|
-
|
|
238
|
-
const x0 = Math.max(a.x, b.x);
|
|
239
|
-
const y0 = Math.max(a.y, b.y);
|
|
240
|
-
const x1 = Math.min(a.x + a.w, b.x + b.w);
|
|
241
|
-
const y1 = Math.min(a.y + a.h, b.y + b.h);
|
|
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
|
-
};
|
|
249
|
-
}
|
|
250
|
-
function translateRect(rect, dx, dy) {
|
|
251
|
-
return {
|
|
252
|
-
x: rect.x + dx,
|
|
253
|
-
y: rect.y + dy,
|
|
254
|
-
w: rect.w,
|
|
255
|
-
h: rect.h
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
function normalizeCellRect(rect) {
|
|
259
|
-
const x0 = Math.floor(rect.x);
|
|
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
|
-
};
|
|
269
|
-
}
|
|
23
|
+
//#region src/vue/render/context.ts
|
|
24
|
+
const RenderStackKey = injectionKey("RenderStack");
|
|
270
25
|
|
|
271
26
|
//#endregion
|
|
272
|
-
//#region src/
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
[
|
|
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;
|
|
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";
|
|
291
33
|
}
|
|
292
|
-
function
|
|
293
|
-
return
|
|
34
|
+
function hasAsciiFastPath(provider) {
|
|
35
|
+
return typeof provider !== "function";
|
|
294
36
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
extendedPictographicRe = new RegExp("\\p{Extended_Pictographic}", "u");
|
|
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;
|
|
37
|
+
function hasTextWidthAsciiFastPath() {
|
|
38
|
+
return hasAsciiFastPath(currentTextWidthProvider());
|
|
306
39
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
emojiRe = new RegExp("\\p{Emoji}", "u");
|
|
310
|
-
} catch {
|
|
311
|
-
emojiRe = null;
|
|
40
|
+
function canUseDefaultTextCache(provider) {
|
|
41
|
+
return provider === "default" || provider === "narrow-ambiguous";
|
|
312
42
|
}
|
|
313
|
-
function
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
//#endregion
|
|
335
|
-
//#region src/vue/utils/text.ts
|
|
336
|
-
let renderPassDepth = 0;
|
|
337
|
-
const renderPassTextWidthCache = new Map();
|
|
338
|
-
function withTextRenderPass(fn) {
|
|
50
|
+
}
|
|
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
|
}
|
|
@@ -362,7 +77,8 @@ function needsGraphemeSegmentation(text) {
|
|
|
362
77
|
}
|
|
363
78
|
let graphemeSegmenter = null;
|
|
364
79
|
try {
|
|
365
|
-
|
|
80
|
+
const Segmenter = typeof Intl !== "undefined" ? Intl.Segmenter : void 0;
|
|
81
|
+
graphemeSegmenter = Segmenter ? new Segmenter(void 0, { granularity: "grapheme" }) : null;
|
|
366
82
|
} catch {
|
|
367
83
|
graphemeSegmenter = null;
|
|
368
84
|
}
|
|
@@ -381,7 +97,7 @@ function forEachGrapheme(text, cb) {
|
|
|
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
102
|
const seg = graphemeSegmenter;
|
|
387
103
|
if (!seg || !needsGraphemeSegmentation(text)) {
|
|
@@ -390,7 +106,7 @@ function forEachTextCellSegment(text, cb) {
|
|
|
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
|
});
|
|
@@ -405,7 +121,7 @@ function forEachTextCellSegment(text, cb) {
|
|
|
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
|
});
|
|
@@ -469,21 +185,24 @@ function sanitizeTextBlock(text) {
|
|
|
469
185
|
}
|
|
470
186
|
return out.join("");
|
|
471
187
|
}
|
|
472
|
-
function textCellWidth(text) {
|
|
188
|
+
function textCellWidth(text, provider = currentTextWidthProvider()) {
|
|
473
189
|
if (!text) return 0;
|
|
474
|
-
if (isAscii(text)) return text.length;
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
190
|
+
if (hasAsciiFastPath(provider) && isAscii(text)) return text.length;
|
|
191
|
+
const useCache = canUseDefaultTextCache(provider);
|
|
192
|
+
if (useCache && renderPassDepth > 0) {
|
|
193
|
+
const cached = renderPassTextWidthCache.get(text);
|
|
194
|
+
if (cached != null) return cached;
|
|
195
|
+
}
|
|
196
|
+
if (useCache) {
|
|
197
|
+
const cached = textWidthCacheGet(text);
|
|
198
|
+
if (cached != null) return cached;
|
|
478
199
|
}
|
|
479
|
-
const cached = textWidthCacheGet(text);
|
|
480
|
-
if (cached != null) return cached;
|
|
481
200
|
let cells = 0;
|
|
482
201
|
forEachGrapheme(text, (g) => {
|
|
483
|
-
cells += charCellWidth(g);
|
|
202
|
+
cells += charCellWidth(g, provider);
|
|
484
203
|
});
|
|
485
|
-
if (renderPassDepth > 0) renderPassTextWidthCache.set(text, cells);
|
|
486
|
-
textWidthCacheSet(text, cells);
|
|
204
|
+
if (useCache && renderPassDepth > 0) renderPassTextWidthCache.set(text, cells);
|
|
205
|
+
if (useCache) textWidthCacheSet(text, cells);
|
|
487
206
|
return cells;
|
|
488
207
|
}
|
|
489
208
|
const spaceCache = new Map();
|
|
@@ -518,14 +237,14 @@ function repeatChar(ch, count) {
|
|
|
518
237
|
bucket.set(count, v);
|
|
519
238
|
return v;
|
|
520
239
|
}
|
|
521
|
-
function sliceByCells(text, maxCells) {
|
|
240
|
+
function sliceByCells(text, maxCells, provider = currentTextWidthProvider()) {
|
|
522
241
|
maxCells = Math.max(0, Math.floor(maxCells));
|
|
523
242
|
if (maxCells <= 0) return "";
|
|
524
|
-
if (text && isAscii(text)) return text.slice(0, maxCells);
|
|
243
|
+
if (text && hasAsciiFastPath(provider) && isAscii(text)) return text.slice(0, maxCells);
|
|
525
244
|
const out = [];
|
|
526
245
|
let cells = 0;
|
|
527
246
|
forEachGrapheme(text, (g) => {
|
|
528
|
-
const w = charCellWidth(g);
|
|
247
|
+
const w = charCellWidth(g, provider);
|
|
529
248
|
if (cells + w > maxCells) return false;
|
|
530
249
|
out.push(g);
|
|
531
250
|
cells += w;
|
|
@@ -533,16 +252,16 @@ function sliceByCells(text, maxCells) {
|
|
|
533
252
|
});
|
|
534
253
|
return out.length ? out.join("") : "";
|
|
535
254
|
}
|
|
536
|
-
function sliceByCellsRange(text, startCells, endCells) {
|
|
255
|
+
function sliceByCellsRange(text, startCells, endCells, provider = currentTextWidthProvider()) {
|
|
537
256
|
startCells = Math.max(0, Math.floor(startCells));
|
|
538
257
|
endCells = Math.max(0, Math.floor(endCells));
|
|
539
258
|
if (endCells <= startCells) return "";
|
|
540
259
|
if (!text) return "";
|
|
541
|
-
if (isAscii(text)) return text.slice(startCells, endCells);
|
|
260
|
+
if (hasAsciiFastPath(provider) && isAscii(text)) return text.slice(startCells, endCells);
|
|
542
261
|
const out = [];
|
|
543
262
|
let cells = 0;
|
|
544
263
|
forEachGrapheme(text, (g) => {
|
|
545
|
-
const w = charCellWidth(g);
|
|
264
|
+
const w = charCellWidth(g, provider);
|
|
546
265
|
const next = cells + w;
|
|
547
266
|
if (cells >= endCells) return false;
|
|
548
267
|
if (next <= startCells) {
|
|
@@ -564,9 +283,9 @@ function sliceByCellsRange(text, startCells, endCells) {
|
|
|
564
283
|
});
|
|
565
284
|
return out.length ? out.join("") : "";
|
|
566
285
|
}
|
|
567
|
-
function padEndByCells(text, width) {
|
|
286
|
+
function padEndByCells(text, width, provider = currentTextWidthProvider()) {
|
|
568
287
|
width = Math.max(0, Math.floor(width));
|
|
569
|
-
const cells = text && isAscii(text) ? text.length : textCellWidth(text);
|
|
288
|
+
const cells = text && hasAsciiFastPath(provider) && isAscii(text) ? text.length : textCellWidth(text, provider);
|
|
570
289
|
if (cells >= width) return text;
|
|
571
290
|
return `${text}${spaces(width - cells)}`;
|
|
572
291
|
}
|
|
@@ -581,23 +300,28 @@ function getInlineLineBucket(width) {
|
|
|
581
300
|
inlineLineCacheByWidth.set(width, bucket);
|
|
582
301
|
return bucket;
|
|
583
302
|
}
|
|
584
|
-
function formatInlineCellLine(text, width) {
|
|
303
|
+
function formatInlineCellLine(text, width, provider = currentTextWidthProvider()) {
|
|
585
304
|
width = Math.max(0, Math.floor(width));
|
|
586
305
|
if (width === 0) return "";
|
|
587
306
|
if (!text) return spaces(width);
|
|
588
|
-
const
|
|
589
|
-
const
|
|
307
|
+
const useCache = canUseDefaultTextCache(provider);
|
|
308
|
+
const bucket = useCache ? getInlineLineBucket(width) : null;
|
|
309
|
+
const cached = bucket?.get(text);
|
|
590
310
|
if (cached != null) return cached;
|
|
591
311
|
const sanitized = sanitizeInlineText(text);
|
|
592
|
-
if (sanitized && isAscii(sanitized)) {
|
|
312
|
+
if (sanitized && hasAsciiFastPath(provider) && isAscii(sanitized)) {
|
|
593
313
|
const out$1 = sanitized.length >= width ? sanitized.slice(0, width) : `${sanitized}${spaces(width - sanitized.length)}`;
|
|
594
|
-
if (bucket
|
|
595
|
-
|
|
314
|
+
if (bucket) {
|
|
315
|
+
if (bucket.size >= MAX_INLINE_LINE_CACHE_PER_WIDTH) bucket.clear();
|
|
316
|
+
bucket.set(text, out$1);
|
|
317
|
+
}
|
|
596
318
|
return out$1;
|
|
597
319
|
}
|
|
598
|
-
const out = padEndByCells(sliceByCells(sanitized, width), width);
|
|
599
|
-
if (bucket
|
|
600
|
-
|
|
320
|
+
const out = padEndByCells(sliceByCells(sanitized, width, provider), width, provider);
|
|
321
|
+
if (bucket) {
|
|
322
|
+
if (bucket.size >= MAX_INLINE_LINE_CACHE_PER_WIDTH) bucket.clear();
|
|
323
|
+
bucket.set(text, out);
|
|
324
|
+
}
|
|
601
325
|
return out;
|
|
602
326
|
}
|
|
603
327
|
const wrapCacheByWidth = new Map();
|
|
@@ -634,11 +358,12 @@ function clearTextCaches() {
|
|
|
634
358
|
textWidthCache.clear();
|
|
635
359
|
inlineLineCacheByWidth.clear();
|
|
636
360
|
}
|
|
637
|
-
function wrapByCells(text, width) {
|
|
361
|
+
function wrapByCells(text, width, provider = currentTextWidthProvider()) {
|
|
638
362
|
width = Math.max(1, Math.floor(width));
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
|
|
363
|
+
const useCache = canUseDefaultTextCache(provider);
|
|
364
|
+
const bucket = useCache ? getWrapBucket(width) : null;
|
|
365
|
+
if (text && hasAsciiFastPath(provider) && isAscii(text)) {
|
|
366
|
+
const cached$1 = bucket?.get(text);
|
|
642
367
|
if (cached$1) return cached$1;
|
|
643
368
|
const out$1 = [];
|
|
644
369
|
for (const rawLine of text.replace(/\r/g, "").split("\n")) {
|
|
@@ -648,11 +373,13 @@ function wrapByCells(text, width) {
|
|
|
648
373
|
}
|
|
649
374
|
for (let i = 0; i < rawLine.length; i += width) out$1.push(rawLine.slice(i, i + width));
|
|
650
375
|
}
|
|
651
|
-
if (bucket
|
|
652
|
-
|
|
376
|
+
if (bucket) {
|
|
377
|
+
if (bucket.size >= MAX_WRAP_CACHE_PER_WIDTH) bucket.clear();
|
|
378
|
+
bucket.set(text, out$1);
|
|
379
|
+
}
|
|
653
380
|
return out$1;
|
|
654
381
|
}
|
|
655
|
-
const cached = bucket
|
|
382
|
+
const cached = bucket?.get(text);
|
|
656
383
|
if (cached) return cached;
|
|
657
384
|
const out = [];
|
|
658
385
|
for (const rawLine of text.replace(/\r/g, "").split("\n")) {
|
|
@@ -667,7 +394,7 @@ function wrapByCells(text, width) {
|
|
|
667
394
|
for (const part of seg.segment(rawLine)) {
|
|
668
395
|
const g = part.segment;
|
|
669
396
|
const gIdx = part.index;
|
|
670
|
-
const w = charCellWidth(g);
|
|
397
|
+
const w = charCellWidth(g, provider);
|
|
671
398
|
if (cells > 0 && cells + w > width) {
|
|
672
399
|
out.push(rawLine.slice(lineStart, gIdx));
|
|
673
400
|
lineStart = gIdx;
|
|
@@ -687,7 +414,7 @@ function wrapByCells(text, width) {
|
|
|
687
414
|
let pos = 0;
|
|
688
415
|
let cells = 0;
|
|
689
416
|
for (const ch of rawLine) {
|
|
690
|
-
const w = charCellWidth(ch);
|
|
417
|
+
const w = charCellWidth(ch, provider);
|
|
691
418
|
if (cells > 0 && cells + w > width) {
|
|
692
419
|
out.push(rawLine.slice(lineStart, pos));
|
|
693
420
|
lineStart = pos;
|
|
@@ -705,11 +432,278 @@ function wrapByCells(text, width) {
|
|
|
705
432
|
}
|
|
706
433
|
}
|
|
707
434
|
const res = out.length ? out : [""];
|
|
708
|
-
if (bucket
|
|
709
|
-
|
|
435
|
+
if (bucket) {
|
|
436
|
+
if (bucket.size >= MAX_WRAP_CACHE_PER_WIDTH) bucket.clear();
|
|
437
|
+
bucket.set(text, res);
|
|
438
|
+
}
|
|
710
439
|
return res;
|
|
711
440
|
}
|
|
712
441
|
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/vue/composables/use-layout.ts
|
|
444
|
+
function useLayout() {
|
|
445
|
+
const ctx = inject(LayoutContextKey, null);
|
|
446
|
+
if (!ctx) throw new Error("LayoutContext is missing (TerminalProvider/TView)");
|
|
447
|
+
return ctx;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
//#endregion
|
|
451
|
+
//#region src/vue/composables/use-render-stack.ts
|
|
452
|
+
function useRenderStack() {
|
|
453
|
+
const stack = inject(RenderStackKey, null);
|
|
454
|
+
if (!stack) throw new Error("RenderStack is missing");
|
|
455
|
+
return stack;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
//#endregion
|
|
459
|
+
//#region src/vue/composables/use-terminal.ts
|
|
460
|
+
function useTerminal() {
|
|
461
|
+
const ctx = inject(TerminalContextKey, null);
|
|
462
|
+
if (!ctx) throw new Error("TerminalProvider is missing");
|
|
463
|
+
return ctx;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
//#endregion
|
|
467
|
+
//#region src/vue/composables/use-render-node.ts
|
|
468
|
+
const pendingInvalidateByScheduler = new WeakMap();
|
|
469
|
+
function mergePriority(prev, next) {
|
|
470
|
+
if (prev === "high" || next === "high") return "high";
|
|
471
|
+
if (prev === "normal" || next === "normal") return "normal";
|
|
472
|
+
return "low";
|
|
473
|
+
}
|
|
474
|
+
function requestBatchedInvalidate(scheduler, plane, priority) {
|
|
475
|
+
let state = pendingInvalidateByScheduler.get(scheduler);
|
|
476
|
+
if (!state) {
|
|
477
|
+
state = {
|
|
478
|
+
queued: false,
|
|
479
|
+
plane: null,
|
|
480
|
+
priority: "low"
|
|
481
|
+
};
|
|
482
|
+
pendingInvalidateByScheduler.set(scheduler, state);
|
|
483
|
+
}
|
|
484
|
+
if (state.queued) {
|
|
485
|
+
if (state.plane !== null && state.plane !== plane) state.plane = null;
|
|
486
|
+
state.priority = mergePriority(state.priority, priority);
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
state.plane = plane;
|
|
490
|
+
state.priority = priority;
|
|
491
|
+
state.queued = true;
|
|
492
|
+
queueMicrotask(() => {
|
|
493
|
+
state.queued = false;
|
|
494
|
+
const queuedPlane = state.plane;
|
|
495
|
+
const queuedPriority = state.priority;
|
|
496
|
+
state.plane = null;
|
|
497
|
+
state.priority = "low";
|
|
498
|
+
scheduler.invalidate({
|
|
499
|
+
plane: queuedPlane ?? void 0,
|
|
500
|
+
priority: queuedPriority
|
|
501
|
+
});
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
function useRenderNode(getOptions) {
|
|
505
|
+
const { scheduler, render, widthProvider } = useTerminal();
|
|
506
|
+
const parentStack = useRenderStack();
|
|
507
|
+
const plane = inject(RenderPlaneContextKey, ref("default"));
|
|
508
|
+
const id = ref(null);
|
|
509
|
+
const lastPlane = ref(plane.value);
|
|
510
|
+
const options = computed(() => withTextWidthProvider(widthProvider, getOptions));
|
|
511
|
+
const stop = watchEffect(() => {
|
|
512
|
+
const opt = options.value;
|
|
513
|
+
opt.deps;
|
|
514
|
+
const stack = opt.stack ?? parentStack.value;
|
|
515
|
+
const nextPlane = plane.value;
|
|
516
|
+
if (!stack) return;
|
|
517
|
+
if (!id.value) {
|
|
518
|
+
const node = render.register({
|
|
519
|
+
stack,
|
|
520
|
+
zIndex: opt.zIndex,
|
|
521
|
+
rect: opt.rect,
|
|
522
|
+
plane: nextPlane,
|
|
523
|
+
paint: opt.paint
|
|
524
|
+
});
|
|
525
|
+
id.value = node.id;
|
|
526
|
+
lastPlane.value = nextPlane;
|
|
527
|
+
requestBatchedInvalidate(scheduler, nextPlane, opt.priority ?? "normal");
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
const prevPlane = lastPlane.value;
|
|
531
|
+
const updatePayload = {
|
|
532
|
+
stack,
|
|
533
|
+
zIndex: opt.zIndex ?? 0,
|
|
534
|
+
dirtyRowsHint: opt.dirtyRowsHint,
|
|
535
|
+
plane: nextPlane,
|
|
536
|
+
paint: opt.paint
|
|
537
|
+
};
|
|
538
|
+
if (Object.prototype.hasOwnProperty.call(opt, "rect")) updatePayload.rect = opt.rect ?? null;
|
|
539
|
+
render.update(id.value, updatePayload);
|
|
540
|
+
lastPlane.value = nextPlane;
|
|
541
|
+
const priority = opt.priority ?? "normal";
|
|
542
|
+
requestBatchedInvalidate(scheduler, prevPlane, priority);
|
|
543
|
+
if (prevPlane !== nextPlane) requestBatchedInvalidate(scheduler, nextPlane, priority);
|
|
544
|
+
});
|
|
545
|
+
onBeforeUnmount(() => {
|
|
546
|
+
stop();
|
|
547
|
+
if (id.value) {
|
|
548
|
+
render.unregister(id.value);
|
|
549
|
+
requestBatchedInvalidate(scheduler, lastPlane.value, "normal");
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
return { id };
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
//#endregion
|
|
556
|
+
//#region src/vue/composables/use-terminal-node.ts
|
|
557
|
+
function wrapHandlers(handlers, widthProvider) {
|
|
558
|
+
if (!handlers) return {};
|
|
559
|
+
const out = {};
|
|
560
|
+
for (const key of Object.keys(handlers)) {
|
|
561
|
+
const handler = handlers[key];
|
|
562
|
+
if (!handler) continue;
|
|
563
|
+
out[key] = (event) => withTextWidthProvider(widthProvider, () => handler(event));
|
|
564
|
+
}
|
|
565
|
+
return out;
|
|
566
|
+
}
|
|
567
|
+
function useTerminalNode(getOptions) {
|
|
568
|
+
const { events, widthProvider } = useTerminal();
|
|
569
|
+
const id = ref(null);
|
|
570
|
+
const options = computed(() => withTextWidthProvider(widthProvider, getOptions));
|
|
571
|
+
const stop = watchEffect(() => {
|
|
572
|
+
const manager = events.value;
|
|
573
|
+
if (!manager) return;
|
|
574
|
+
const opt = options.value;
|
|
575
|
+
if (!id.value) {
|
|
576
|
+
const node = manager.register({
|
|
577
|
+
rect: opt.rect,
|
|
578
|
+
zIndex: opt.zIndex ?? 0,
|
|
579
|
+
visible: opt.visible,
|
|
580
|
+
focusable: opt.focusable,
|
|
581
|
+
selectable: opt.selectable,
|
|
582
|
+
selectionScrollBy: opt.selectionScrollBy,
|
|
583
|
+
handlers: wrapHandlers(opt.handlers, widthProvider)
|
|
584
|
+
});
|
|
585
|
+
id.value = node.id;
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
manager.update(id.value, {
|
|
589
|
+
rect: opt.rect,
|
|
590
|
+
zIndex: opt.zIndex ?? 0,
|
|
591
|
+
visible: opt.visible,
|
|
592
|
+
focusable: opt.focusable,
|
|
593
|
+
selectable: opt.selectable,
|
|
594
|
+
selectionScrollBy: opt.selectionScrollBy,
|
|
595
|
+
handlers: wrapHandlers(opt.handlers, widthProvider)
|
|
596
|
+
});
|
|
597
|
+
});
|
|
598
|
+
onBeforeUnmount(() => {
|
|
599
|
+
stop();
|
|
600
|
+
const manager = events.value;
|
|
601
|
+
if (manager && id.value) manager.unregister(id.value);
|
|
602
|
+
});
|
|
603
|
+
return { id };
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
//#endregion
|
|
607
|
+
//#region src/vue/composables/use-visibility.ts
|
|
608
|
+
const VUE_TERMINAL_SHOW_CB = "__vueTerminalOnShow";
|
|
609
|
+
let vShowPatched = false;
|
|
610
|
+
function patchVShow() {
|
|
611
|
+
if (vShowPatched) return;
|
|
612
|
+
vShowPatched = true;
|
|
613
|
+
const dir = vShow;
|
|
614
|
+
const origBeforeMount = dir.beforeMount;
|
|
615
|
+
const origUpdated = dir.updated;
|
|
616
|
+
const origBeforeUnmount = dir.beforeUnmount;
|
|
617
|
+
const notify = (el, value) => {
|
|
618
|
+
if (!el || typeof el !== "object") return;
|
|
619
|
+
const cb = el[VUE_TERMINAL_SHOW_CB];
|
|
620
|
+
cb?.(Boolean(value));
|
|
621
|
+
};
|
|
622
|
+
if (typeof origBeforeMount === "function") dir.beforeMount = (el, binding, vnode) => {
|
|
623
|
+
origBeforeMount(el, binding, vnode);
|
|
624
|
+
notify(el, binding?.value);
|
|
625
|
+
};
|
|
626
|
+
if (typeof origUpdated === "function") dir.updated = (el, binding, vnode) => {
|
|
627
|
+
origUpdated(el, binding, vnode);
|
|
628
|
+
notify(el, binding?.value);
|
|
629
|
+
};
|
|
630
|
+
if (typeof origBeforeUnmount === "function") dir.beforeUnmount = (el, binding, vnode) => {
|
|
631
|
+
origBeforeUnmount(el, binding, vnode);
|
|
632
|
+
notify(el, binding?.value);
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
const PLACEHOLDER_STYLE = Object.freeze({
|
|
636
|
+
position: "absolute",
|
|
637
|
+
left: "-9999px",
|
|
638
|
+
top: "0",
|
|
639
|
+
width: "0",
|
|
640
|
+
height: "0",
|
|
641
|
+
overflow: "hidden"
|
|
642
|
+
});
|
|
643
|
+
function useVisibility(options) {
|
|
644
|
+
patchVShow();
|
|
645
|
+
const { scheduler } = useTerminal();
|
|
646
|
+
const parentVisible = inject(VisibilityContextKey, ref(true));
|
|
647
|
+
const localVisible = ref(true);
|
|
648
|
+
const visible = computed(() => parentVisible.value && localVisible.value);
|
|
649
|
+
if (options?.provide) provide(VisibilityContextKey, visible);
|
|
650
|
+
const onShow = (value) => {
|
|
651
|
+
localVisible.value = value;
|
|
652
|
+
scheduler.invalidate();
|
|
653
|
+
};
|
|
654
|
+
const rootProps = {
|
|
655
|
+
style: PLACEHOLDER_STYLE,
|
|
656
|
+
onVnodeBeforeMount: (vnode) => {
|
|
657
|
+
const el = vnode.el;
|
|
658
|
+
if (el && typeof el === "object") el[VUE_TERMINAL_SHOW_CB] = onShow;
|
|
659
|
+
},
|
|
660
|
+
onVnodeBeforeUnmount: (vnode) => {
|
|
661
|
+
const el = vnode.el;
|
|
662
|
+
if (el && typeof el === "object" && el[VUE_TERMINAL_SHOW_CB] === onShow) delete el[VUE_TERMINAL_SHOW_CB];
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
return {
|
|
666
|
+
visible,
|
|
667
|
+
rootProps
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
//#endregion
|
|
672
|
+
//#region src/vue/utils/rect.ts
|
|
673
|
+
function intersectRect(a, b) {
|
|
674
|
+
const x0 = Math.max(a.x, b.x);
|
|
675
|
+
const y0 = Math.max(a.y, b.y);
|
|
676
|
+
const x1 = Math.min(a.x + a.w, b.x + b.w);
|
|
677
|
+
const y1 = Math.min(a.y + a.h, b.y + b.h);
|
|
678
|
+
if (x1 <= x0 || y1 <= y0) return null;
|
|
679
|
+
return {
|
|
680
|
+
x: x0,
|
|
681
|
+
y: y0,
|
|
682
|
+
w: x1 - x0,
|
|
683
|
+
h: y1 - y0
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
function translateRect(rect, dx, dy) {
|
|
687
|
+
return {
|
|
688
|
+
x: rect.x + dx,
|
|
689
|
+
y: rect.y + dy,
|
|
690
|
+
w: rect.w,
|
|
691
|
+
h: rect.h
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
function normalizeCellRect(rect) {
|
|
695
|
+
const x0 = Math.floor(rect.x);
|
|
696
|
+
const y0 = Math.floor(rect.y);
|
|
697
|
+
const x1 = Math.floor(rect.x + rect.w);
|
|
698
|
+
const y1 = Math.floor(rect.y + rect.h);
|
|
699
|
+
return {
|
|
700
|
+
x: x0,
|
|
701
|
+
y: y0,
|
|
702
|
+
w: Math.max(0, x1 - x0),
|
|
703
|
+
h: Math.max(0, y1 - y0)
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
|
|
713
707
|
//#endregion
|
|
714
708
|
//#region src/vue/utils/wheel-scroll.ts
|
|
715
709
|
const LINE_UNIT_THRESHOLD = 3;
|
|
@@ -822,4 +816,4 @@ function applyWheelScroll(state, deltaY, scrollTop, maxTop, now = Date.now(), de
|
|
|
822
816
|
}
|
|
823
817
|
|
|
824
818
|
//#endregion
|
|
825
|
-
export { DialogContextKey, EventZIndexContextKey, ImeAnchorContextKey, LayoutContextKey, RenderPlaneContextKey, RenderStackKey, TInputPluginsContextKey, TPathPickerProviderContextKey, TerminalContextKey, VisibilityContextKey, applyWheelScroll,
|
|
819
|
+
export { DialogContextKey, EventZIndexContextKey, ImeAnchorContextKey, LayoutContextKey, RenderPlaneContextKey, RenderStackKey, TInputPluginsContextKey, TPathPickerProviderContextKey, TerminalContextKey, VisibilityContextKey, applyWheelScroll, clearTextCaches, createWheelScrollState, forEachTextCellSegment, formatInlineCellLine, graphemeRangeAt, hasTextWidthAsciiFastPath, injectionKey, intersectRect, normalizeCellRect, padEndByCells, repeatChar, resetWheelScrollState, sanitizeInlineText, sanitizeTextBlock, sliceByCells, sliceByCellsRange, spaces, textCellWidth, translateRect, useLayout, useRenderNode, useRenderStack, useTerminal, useTerminalNode, useVisibility, withTextRenderPass, withTextWidthProvider, wrapByCells };
|