restty 0.1.35 → 0.2.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 +49 -343
- package/dist/chunk-30px21q2.js +0 -0
- package/dist/{chunk-zqscavsh.js → chunk-db9dt7pr.js} +48146 -63236
- package/dist/chunk-s26trws6.js +9136 -0
- package/dist/chunk-wdme6j9c.js +1776 -0
- package/dist/chunk-xykzfd81.js +0 -0
- package/dist/chunk-y6hfk43b.js +1690 -0
- package/dist/fonts/local-font-access.types.d.ts +19 -0
- package/dist/fonts/manager/entries.d.ts +7 -0
- package/dist/headless.d.ts +102 -0
- package/dist/headless.js +350 -0
- package/dist/index.d.ts +8 -4
- package/dist/input/keymap/default-mapping.d.ts +1 -0
- package/dist/input/mouse.d.ts +13 -0
- package/dist/input/types.d.ts +10 -1
- package/dist/internal/runtime.d.ts +4 -0
- package/dist/internal/runtime.js +12 -0
- package/dist/internal/surface.d.ts +6 -0
- package/dist/internal/surface.js +15 -0
- package/dist/internal.d.ts +2 -5
- package/dist/internal.js +23 -5
- package/dist/restty.esm.js +32 -11368
- package/dist/restty.js +8 -2
- package/dist/runtime/core/api.d.ts +112 -0
- package/dist/runtime/core/config.d.ts +133 -0
- package/dist/runtime/core/lifecycle.d.ts +1 -0
- package/dist/runtime/core/models.d.ts +124 -0
- package/dist/runtime/core/resources.d.ts +50 -0
- package/dist/runtime/core/runtime-events.d.ts +28 -0
- package/dist/runtime/core/session.d.ts +9 -0
- package/dist/runtime/{codepoint-utils.d.ts → create-runtime/codepoint-utils.d.ts} +1 -1
- package/dist/runtime/create-runtime/{color-glyph-atlas.d.ts → font-runtime/color-glyph-atlas.d.ts} +2 -2
- package/dist/runtime/create-runtime/font-runtime/grid.d.ts +6 -0
- package/dist/runtime/create-runtime/font-runtime/grid.types.d.ts +22 -0
- package/dist/runtime/create-runtime/font-runtime/index.d.ts +15 -0
- package/dist/runtime/create-runtime/font-runtime/text.d.ts +12 -0
- package/dist/runtime/create-runtime/font-runtime/text.types.d.ts +10 -0
- package/dist/runtime/create-runtime/{font-runtime-helpers.types.d.ts → font-runtime/types.d.ts} +5 -8
- package/dist/runtime/create-runtime/font-runtime/webgpu-atlas.d.ts +7 -0
- package/dist/runtime/create-runtime/font-runtime/webgpu-atlas.types.d.ts +23 -0
- package/dist/runtime/create-runtime/highlight-terminal-color-utils.d.ts +1 -8
- package/dist/runtime/create-runtime/highlight-terminal-color-utils.types.d.ts +9 -0
- package/dist/runtime/create-runtime/input-hooks.d.ts +2 -12
- package/dist/runtime/create-runtime/input-hooks.types.d.ts +10 -0
- package/dist/runtime/create-runtime/interaction-runtime/bind-ime-events.d.ts +2 -1
- package/dist/runtime/create-runtime/interaction-runtime/bind-pointer-aux-handlers.d.ts +1 -1
- package/dist/runtime/create-runtime/interaction-runtime/bind-pointer-events.d.ts +2 -1
- package/dist/runtime/create-runtime/interaction-runtime/bind-pointer-up-handler.d.ts +1 -1
- package/dist/runtime/create-runtime/{interaction-runtime.d.ts → interaction-runtime/index.d.ts} +3 -2
- package/dist/runtime/create-runtime/interaction-runtime/kitty-image-cache.d.ts +2 -17
- package/dist/runtime/create-runtime/interaction-runtime/kitty-image-cache.types.d.ts +17 -0
- package/dist/runtime/create-runtime/interaction-runtime/{types.d.ts → runtime.types.d.ts} +1 -47
- package/dist/runtime/create-runtime/interaction-runtime/scrollbar-runtime.d.ts +1 -23
- package/dist/runtime/create-runtime/interaction-runtime/scrollbar-runtime.types.d.ts +23 -0
- package/dist/runtime/create-runtime/interaction-runtime/state.types.d.ts +47 -0
- package/dist/runtime/create-runtime/kitty-render-runtime.d.ts +2 -36
- package/dist/runtime/create-runtime/kitty-render-runtime.types.d.ts +33 -0
- package/dist/runtime/create-runtime/{lifecycle-theme-size-canvas.d.ts → lifecycle-theme-size/canvas.d.ts} +1 -1
- package/dist/runtime/create-runtime/{lifecycle-theme-size.d.ts → lifecycle-theme-size/index.d.ts} +3 -3
- package/dist/runtime/create-runtime/lifecycle-theme-size/theme.d.ts +6 -0
- package/dist/runtime/create-runtime/{lifecycle-theme-size.types.d.ts → lifecycle-theme-size/types.d.ts} +1 -6
- package/dist/runtime/{max-scrollback.d.ts → create-runtime/max-scrollback.d.ts} +2 -5
- package/dist/runtime/create-runtime/max-scrollback.types.d.ts +4 -0
- package/dist/runtime/create-runtime/native-scrollbar-host.d.ts +2 -15
- package/dist/runtime/create-runtime/native-scrollbar-host.types.d.ts +13 -0
- package/dist/runtime/{overlay-scrollbar.d.ts → create-runtime/overlay-scrollbar.d.ts} +1 -12
- package/dist/runtime/create-runtime/overlay-scrollbar.types.d.ts +12 -0
- package/dist/runtime/create-runtime/pty-input-runtime.d.ts +2 -46
- package/dist/runtime/create-runtime/pty-input-runtime.types.d.ts +41 -0
- package/dist/runtime/{render-color-utils.d.ts → create-runtime/render-color-utils.d.ts} +1 -1
- package/dist/runtime/{render-stage-runtime.d.ts → create-runtime/render-stage-runtime.d.ts} +2 -2
- package/dist/runtime/{create-app-types.d.ts → create-runtime/render-stage-runtime.types.d.ts} +1 -29
- package/dist/runtime/create-runtime/render-tick-webgl-overlays.d.ts +1 -1
- package/dist/runtime/create-runtime/render-tick-webgl-scene.d.ts +1 -1
- package/dist/runtime/create-runtime/render-tick-webgl.types.d.ts +2 -5
- package/dist/runtime/create-runtime/render-tick-webgpu-cell-pass.d.ts +1 -1
- package/dist/runtime/create-runtime/render-tick-webgpu.types.d.ts +5 -9
- package/dist/runtime/create-runtime/runtime-controller.api.types.d.ts +96 -0
- package/dist/runtime/create-runtime/runtime-controller.clipboard.d.ts +10 -0
- package/dist/runtime/create-runtime/runtime-controller.d.ts +3 -0
- package/dist/runtime/create-runtime/runtime-controller.input.d.ts +24 -0
- package/dist/runtime/create-runtime/runtime-controller.keyboard.d.ts +19 -0
- package/dist/runtime/create-runtime/runtime-controller.lifecycle.d.ts +50 -0
- package/dist/runtime/create-runtime/runtime-controller.public-api.capabilities.d.ts +57 -0
- package/dist/runtime/create-runtime/runtime-controller.public-api.d.ts +28 -0
- package/dist/runtime/create-runtime/runtime-controller.render-loop.d.ts +20 -0
- package/dist/runtime/create-runtime/runtime-controller.state.types.d.ts +24 -0
- package/dist/runtime/create-runtime/runtime-reporting.d.ts +3 -21
- package/dist/runtime/create-runtime/runtime-reporting.types.d.ts +18 -0
- package/dist/runtime/{create-app-symbols.d.ts → create-runtime/runtime-symbols.d.ts} +2 -2
- package/dist/runtime/create-runtime/search-highlight-utils.d.ts +1 -1
- package/dist/runtime/create-runtime/search-runtime/index.d.ts +2 -0
- package/dist/runtime/create-runtime/{search-runtime.d.ts → search-runtime/types.d.ts} +9 -6
- package/dist/runtime/create-runtime/shader-stage-runtime.d.ts +2 -29
- package/dist/runtime/create-runtime/shader-stage-runtime.types.d.ts +27 -0
- package/dist/runtime/{text-decoration.d.ts → create-runtime/text-decoration.d.ts} +1 -1
- package/dist/runtime/create-runtime.d.ts +7 -7
- package/dist/runtime/font-atlas-utils/glyph-atlas-builder.d.ts +1 -1
- package/dist/runtime/font-atlas-utils/nerd-metrics-utils.d.ts +1 -1
- package/dist/runtime/{atlas-builder.d.ts → fonts/atlas-builder.d.ts} +1 -1
- package/dist/runtime/{font-resource-store.d.ts → fonts/font-resource-store.d.ts} +3 -2
- package/dist/runtime/fonts/font-sources.d.ts +4 -0
- package/dist/runtime/shader-stages.d.ts +1 -1
- package/dist/runtime/types.d.ts +6 -393
- package/dist/surface/{panes-context-menu.d.ts → panes/context-menu.d.ts} +1 -1
- package/dist/surface/panes/default-context-menu-items.d.ts +2 -2
- package/dist/surface/panes/layout.d.ts +1 -1
- package/dist/surface/panes/managed-pane-create.d.ts +3 -0
- package/dist/surface/panes/managed-pane-create.types.d.ts +17 -0
- package/dist/surface/panes/managed-pane-dom.d.ts +13 -0
- package/dist/surface/panes/managed-pane-manager.d.ts +6 -0
- package/dist/surface/panes/managed-pane-options.d.ts +6 -0
- package/dist/surface/panes/managed-pane-options.types.d.ts +7 -0
- package/dist/surface/panes/managed-pane-runtime-config.d.ts +3 -0
- package/dist/surface/panes/managed-pane-runtime-config.types.d.ts +9 -0
- package/dist/surface/panes/managed-pane-runtime.d.ts +3 -0
- package/dist/surface/panes/managed-pane-runtime.types.d.ts +10 -0
- package/dist/surface/panes/managed-pane-search-ui.d.ts +9 -0
- package/dist/surface/{pane-app-manager.d.ts → panes/managed-pane-types.d.ts} +34 -36
- package/dist/surface/panes/manager.d.ts +1 -1
- package/dist/surface/panes/pane-interactions.d.ts +2 -2
- package/dist/surface/{panes-styles.d.ts → panes/styles.d.ts} +1 -1
- package/dist/surface/{panes-types.d.ts → panes/types.d.ts} +48 -7
- package/dist/surface/panes/window-events.d.ts +1 -1
- package/dist/surface/{restty-plugin-types.d.ts → plugins/context.types.d.ts} +32 -88
- package/dist/surface/{restty/plugin-dispatcher.d.ts → plugins/dispatcher.d.ts} +4 -13
- package/dist/surface/plugins/dispatcher.types.d.ts +6 -0
- package/dist/surface/{restty/plugin-ops.d.ts → plugins/host.d.ts} +4 -3
- package/dist/surface/plugins/runtime.d.ts +18 -0
- package/dist/surface/plugins/runtime.types.d.ts +47 -0
- package/dist/surface/plugins/types.d.ts +83 -0
- package/dist/surface/restty/active-pane-api.d.ts +33 -23
- package/dist/surface/restty/assembly.d.ts +23 -0
- package/dist/surface/restty/bootstrap.d.ts +21 -0
- package/dist/surface/restty/config.d.ts +46 -0
- package/dist/surface/restty/controller.d.ts +45 -0
- package/dist/surface/restty/events.d.ts +14 -0
- package/dist/surface/restty/manager-options.d.ts +4 -23
- package/dist/surface/restty/manager-options.types.d.ts +32 -0
- package/dist/surface/restty/pane-command-ops.d.ts +37 -0
- package/dist/surface/restty/pane-handle-ops.d.ts +24 -0
- package/dist/surface/{restty-pane-handle.d.ts → restty/pane-handle.d.ts} +42 -40
- package/dist/surface/restty/pane-lookup.d.ts +22 -0
- package/dist/surface/restty/pane-manager-assembly.d.ts +18 -0
- package/dist/surface/restty/pane-ops.d.ts +3 -51
- package/dist/surface/restty/pane-style-ops.d.ts +6 -0
- package/dist/surface/restty/plugin-surface.d.ts +5 -0
- package/dist/surface/restty/shader-ops.d.ts +6 -5
- package/dist/surface/restty.d.ts +28 -49
- package/dist/surface/search-ui/controller.d.ts +2 -0
- package/dist/surface/search-ui/index.d.ts +2 -0
- package/dist/surface/search-ui/styles.d.ts +5 -0
- package/dist/surface/{pane-search-ui.d.ts → search-ui/types.d.ts} +22 -13
- package/dist/wasm/embedded.d.ts +1 -1
- package/dist/wasm/runtime/types.d.ts +0 -6
- package/dist/xterm/compat-services.d.ts +2 -0
- package/dist/xterm.d.ts +4 -3
- package/dist/xterm.js +14 -8
- package/package.json +52 -33
- package/dist/internal.esm.js +0 -22285
- package/dist/runtime/create-runtime/debug-tools/create-dump-glyph-render.d.ts +0 -2
- package/dist/runtime/create-runtime/debug-tools/diagnose-codepoint.d.ts +0 -2
- package/dist/runtime/create-runtime/debug-tools/dump-atlas-for-codepoint.d.ts +0 -2
- package/dist/runtime/create-runtime/debug-tools/read-texture-to-image-data.d.ts +0 -1
- package/dist/runtime/create-runtime/debug-tools/setup-debug-expose.d.ts +0 -2
- package/dist/runtime/create-runtime/debug-tools/types.d.ts +0 -63
- package/dist/runtime/create-runtime/debug-tools.d.ts +0 -6
- package/dist/runtime/create-runtime/font-runtime-grid-helpers.d.ts +0 -31
- package/dist/runtime/create-runtime/font-runtime-helpers.d.ts +0 -15
- package/dist/runtime/create-runtime/font-runtime-text-helpers.d.ts +0 -21
- package/dist/runtime/create-runtime/font-runtime-webgpu-atlas.d.ts +0 -29
- package/dist/runtime/create-runtime/lifecycle-theme-size-theme.d.ts +0 -6
- package/dist/runtime/create-runtime/runtime-app-api.d.ts +0 -113
- package/dist/runtime/create-runtime/runtime-logger.d.ts +0 -17
- package/dist/runtime/font-sources.d.ts +0 -5
- package/dist/runtime/pty-output-buffer.d.ts +0 -12
- package/dist/runtime/session.d.ts +0 -9
- package/dist/surface/app-factory.d.ts +0 -3
- package/dist/surface/restty-plugin-runtime.d.ts +0 -57
- package/dist/xterm/app-options.d.ts +0 -2
- package/dist/xterm.esm.js +0 -12210
- /package/dist/runtime/create-runtime/{atlas-debug-utils.d.ts → atlas-bitmap-utils.d.ts} +0 -0
- /package/dist/runtime/{clipboard-paste.d.ts → create-runtime/clipboard-paste.d.ts} +0 -0
- /package/dist/runtime/{render-stage-shaders.d.ts → create-runtime/render-stage-shaders.d.ts} +0 -0
- /package/dist/runtime/{create-app-io-utils.d.ts → create-runtime/runtime-io-utils.d.ts} +0 -0
- /package/dist/surface/{restty-plugin-utils.d.ts → plugins/utils.d.ts} +0 -0
|
@@ -0,0 +1,1776 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createResttyManagedPaneManager
|
|
3
|
+
} from "./chunk-y6hfk43b.js";
|
|
4
|
+
import {
|
|
5
|
+
cloneShaderStages,
|
|
6
|
+
normalizeShaderStage,
|
|
7
|
+
normalizeShaderStages,
|
|
8
|
+
sortShaderStages
|
|
9
|
+
} from "./chunk-db9dt7pr.js";
|
|
10
|
+
|
|
11
|
+
// src/surface/plugins/types.ts
|
|
12
|
+
var RESTTY_PLUGIN_API_VERSION = 1;
|
|
13
|
+
|
|
14
|
+
// src/surface/restty/pane-handle.ts
|
|
15
|
+
class ResttyPaneHandle {
|
|
16
|
+
resolvePane;
|
|
17
|
+
searchUiOps;
|
|
18
|
+
constructor(resolvePane, searchUiOps) {
|
|
19
|
+
this.resolvePane = resolvePane;
|
|
20
|
+
this.searchUiOps = searchUiOps;
|
|
21
|
+
}
|
|
22
|
+
get id() {
|
|
23
|
+
return this.resolvePane().id;
|
|
24
|
+
}
|
|
25
|
+
setRenderer(value) {
|
|
26
|
+
this.resolvePane().setRenderer(value);
|
|
27
|
+
}
|
|
28
|
+
setPaused(value) {
|
|
29
|
+
this.resolvePane().setPaused(value);
|
|
30
|
+
}
|
|
31
|
+
togglePause() {
|
|
32
|
+
this.resolvePane().togglePause();
|
|
33
|
+
}
|
|
34
|
+
setFontSize(value) {
|
|
35
|
+
this.resolvePane().setFontSize(value);
|
|
36
|
+
}
|
|
37
|
+
setLigatures(value) {
|
|
38
|
+
this.resolvePane().setLigatures(value);
|
|
39
|
+
}
|
|
40
|
+
setFontHinting(value) {
|
|
41
|
+
this.resolvePane().setFontHinting(value);
|
|
42
|
+
}
|
|
43
|
+
setFontHintTarget(value) {
|
|
44
|
+
this.resolvePane().setFontHintTarget(value);
|
|
45
|
+
}
|
|
46
|
+
setFonts(fonts) {
|
|
47
|
+
return this.resolvePane().setFonts(fonts);
|
|
48
|
+
}
|
|
49
|
+
applyTheme(theme, sourceLabel) {
|
|
50
|
+
this.resolvePane().applyTheme(theme, sourceLabel);
|
|
51
|
+
}
|
|
52
|
+
resetTheme() {
|
|
53
|
+
this.resolvePane().resetTheme();
|
|
54
|
+
}
|
|
55
|
+
sendInput(text, source) {
|
|
56
|
+
this.resolvePane().sendInput(text, source);
|
|
57
|
+
}
|
|
58
|
+
sendKeyInput(text, source) {
|
|
59
|
+
this.resolvePane().sendKeyInput(text, source);
|
|
60
|
+
}
|
|
61
|
+
clearScreen() {
|
|
62
|
+
this.resolvePane().clearScreen();
|
|
63
|
+
}
|
|
64
|
+
connectPty(url = "") {
|
|
65
|
+
this.resolvePane().connectPty(url);
|
|
66
|
+
}
|
|
67
|
+
disconnectPty() {
|
|
68
|
+
this.resolvePane().disconnectPty();
|
|
69
|
+
}
|
|
70
|
+
isPtyConnected() {
|
|
71
|
+
return this.resolvePane().isPtyConnected();
|
|
72
|
+
}
|
|
73
|
+
setMouseMode(value) {
|
|
74
|
+
this.resolvePane().setMouseMode(value);
|
|
75
|
+
}
|
|
76
|
+
getMouseStatus() {
|
|
77
|
+
return this.resolvePane().getMouseStatus();
|
|
78
|
+
}
|
|
79
|
+
copySelectionToClipboard() {
|
|
80
|
+
return this.resolvePane().copySelectionToClipboard();
|
|
81
|
+
}
|
|
82
|
+
pasteFromClipboard() {
|
|
83
|
+
return this.resolvePane().pasteFromClipboard();
|
|
84
|
+
}
|
|
85
|
+
selectWordAtClientPoint(clientX, clientY) {
|
|
86
|
+
return this.resolvePane().selectWordAtClientPoint(clientX, clientY);
|
|
87
|
+
}
|
|
88
|
+
setSearchQuery(query) {
|
|
89
|
+
this.resolvePane().setSearchQuery(query);
|
|
90
|
+
}
|
|
91
|
+
clearSearch() {
|
|
92
|
+
this.resolvePane().clearSearch();
|
|
93
|
+
}
|
|
94
|
+
searchNext() {
|
|
95
|
+
this.resolvePane().searchNext();
|
|
96
|
+
}
|
|
97
|
+
searchPrevious() {
|
|
98
|
+
this.resolvePane().searchPrevious();
|
|
99
|
+
}
|
|
100
|
+
getSearchState() {
|
|
101
|
+
return this.resolvePane().getSearchState();
|
|
102
|
+
}
|
|
103
|
+
openSearch(options) {
|
|
104
|
+
this.searchUiOps.open(this.id, options);
|
|
105
|
+
}
|
|
106
|
+
closeSearch(options) {
|
|
107
|
+
this.searchUiOps.close(this.id, options);
|
|
108
|
+
}
|
|
109
|
+
toggleSearch(options) {
|
|
110
|
+
this.searchUiOps.toggle(this.id, options);
|
|
111
|
+
}
|
|
112
|
+
isSearchOpen() {
|
|
113
|
+
return this.searchUiOps.isOpen(this.id);
|
|
114
|
+
}
|
|
115
|
+
resize(cols, rows) {
|
|
116
|
+
this.resolvePane().resize(cols, rows);
|
|
117
|
+
}
|
|
118
|
+
focus() {
|
|
119
|
+
this.resolvePane().focus();
|
|
120
|
+
}
|
|
121
|
+
blur() {
|
|
122
|
+
this.resolvePane().blur();
|
|
123
|
+
}
|
|
124
|
+
updateSize(force) {
|
|
125
|
+
this.resolvePane().updateSize(force);
|
|
126
|
+
}
|
|
127
|
+
getBackend() {
|
|
128
|
+
return this.resolvePane().getBackend();
|
|
129
|
+
}
|
|
130
|
+
getSearchUiStyleOptions() {
|
|
131
|
+
return this.searchUiOps.getStyleOptions();
|
|
132
|
+
}
|
|
133
|
+
setSearchUiStyleOptions(options) {
|
|
134
|
+
this.searchUiOps.setStyleOptions(options);
|
|
135
|
+
}
|
|
136
|
+
setShaderStages(stages) {
|
|
137
|
+
this.resolvePane().setShaderStages(stages);
|
|
138
|
+
}
|
|
139
|
+
getShaderStages() {
|
|
140
|
+
return this.resolvePane().getShaderStages();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/surface/restty/active-pane-api.ts
|
|
145
|
+
class ResttyActivePaneApi {
|
|
146
|
+
isPtyConnected() {
|
|
147
|
+
return this.requireActivePaneHandle().isPtyConnected();
|
|
148
|
+
}
|
|
149
|
+
setRenderer(value) {
|
|
150
|
+
this.requireActivePaneHandle().setRenderer(value);
|
|
151
|
+
}
|
|
152
|
+
setPaused(value) {
|
|
153
|
+
this.requireActivePaneHandle().setPaused(value);
|
|
154
|
+
}
|
|
155
|
+
togglePause() {
|
|
156
|
+
this.requireActivePaneHandle().togglePause();
|
|
157
|
+
}
|
|
158
|
+
setFontSize(value) {
|
|
159
|
+
this.requireActivePaneHandle().setFontSize(value);
|
|
160
|
+
}
|
|
161
|
+
setLigatures(value) {
|
|
162
|
+
this.requireActivePaneHandle().setLigatures(value);
|
|
163
|
+
}
|
|
164
|
+
setFontHinting(value) {
|
|
165
|
+
this.requireActivePaneHandle().setFontHinting(value);
|
|
166
|
+
}
|
|
167
|
+
setFontHintTarget(value) {
|
|
168
|
+
this.requireActivePaneHandle().setFontHintTarget(value);
|
|
169
|
+
}
|
|
170
|
+
setFonts(fonts) {
|
|
171
|
+
return this.requireActivePaneHandle().setFonts(fonts);
|
|
172
|
+
}
|
|
173
|
+
applyTheme(theme, sourceLabel) {
|
|
174
|
+
this.requireActivePaneHandle().applyTheme(theme, sourceLabel);
|
|
175
|
+
}
|
|
176
|
+
resetTheme() {
|
|
177
|
+
this.requireActivePaneHandle().resetTheme();
|
|
178
|
+
}
|
|
179
|
+
sendInput(text, source) {
|
|
180
|
+
this.requireActivePaneHandle().sendInput(text, source);
|
|
181
|
+
}
|
|
182
|
+
sendKeyInput(text, source) {
|
|
183
|
+
this.requireActivePaneHandle().sendKeyInput(text, source);
|
|
184
|
+
}
|
|
185
|
+
clearScreen() {
|
|
186
|
+
this.requireActivePaneHandle().clearScreen();
|
|
187
|
+
}
|
|
188
|
+
connectPty(url = "") {
|
|
189
|
+
this.requireActivePaneHandle().connectPty(url);
|
|
190
|
+
}
|
|
191
|
+
disconnectPty() {
|
|
192
|
+
this.requireActivePaneHandle().disconnectPty();
|
|
193
|
+
}
|
|
194
|
+
setMouseMode(value) {
|
|
195
|
+
this.requireActivePaneHandle().setMouseMode(value);
|
|
196
|
+
}
|
|
197
|
+
getMouseStatus() {
|
|
198
|
+
return this.requireActivePaneHandle().getMouseStatus();
|
|
199
|
+
}
|
|
200
|
+
copySelectionToClipboard() {
|
|
201
|
+
return this.requireActivePaneHandle().copySelectionToClipboard();
|
|
202
|
+
}
|
|
203
|
+
pasteFromClipboard() {
|
|
204
|
+
return this.requireActivePaneHandle().pasteFromClipboard();
|
|
205
|
+
}
|
|
206
|
+
selectWordAtClientPoint(clientX, clientY) {
|
|
207
|
+
return this.requireActivePaneHandle().selectWordAtClientPoint(clientX, clientY);
|
|
208
|
+
}
|
|
209
|
+
setSearchQuery(query) {
|
|
210
|
+
this.requireActivePaneHandle().setSearchQuery(query);
|
|
211
|
+
}
|
|
212
|
+
clearSearch() {
|
|
213
|
+
this.requireActivePaneHandle().clearSearch();
|
|
214
|
+
}
|
|
215
|
+
searchNext() {
|
|
216
|
+
this.requireActivePaneHandle().searchNext();
|
|
217
|
+
}
|
|
218
|
+
searchPrevious() {
|
|
219
|
+
this.requireActivePaneHandle().searchPrevious();
|
|
220
|
+
}
|
|
221
|
+
getSearchState() {
|
|
222
|
+
return this.requireActivePaneHandle().getSearchState();
|
|
223
|
+
}
|
|
224
|
+
openSearch(options) {
|
|
225
|
+
this.requireActivePaneHandle().openSearch(options);
|
|
226
|
+
}
|
|
227
|
+
closeSearch(options) {
|
|
228
|
+
this.requireActivePaneHandle().closeSearch(options);
|
|
229
|
+
}
|
|
230
|
+
toggleSearch(options) {
|
|
231
|
+
this.requireActivePaneHandle().toggleSearch(options);
|
|
232
|
+
}
|
|
233
|
+
isSearchOpen() {
|
|
234
|
+
return this.requireActivePaneHandle().isSearchOpen();
|
|
235
|
+
}
|
|
236
|
+
getSearchUiStyleOptions() {
|
|
237
|
+
return this.requireActivePaneHandle().getSearchUiStyleOptions();
|
|
238
|
+
}
|
|
239
|
+
setSearchUiStyleOptions(options) {
|
|
240
|
+
this.requireActivePaneHandle().setSearchUiStyleOptions(options);
|
|
241
|
+
}
|
|
242
|
+
setShaderStages(stages) {
|
|
243
|
+
this.requireActivePaneHandle().setShaderStages(stages);
|
|
244
|
+
}
|
|
245
|
+
getShaderStages() {
|
|
246
|
+
return this.requireActivePaneHandle().getShaderStages();
|
|
247
|
+
}
|
|
248
|
+
updateSize(force) {
|
|
249
|
+
this.requireActivePaneHandle().updateSize(force);
|
|
250
|
+
}
|
|
251
|
+
getBackend() {
|
|
252
|
+
return this.requireActivePaneHandle().getBackend();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// src/surface/restty/manager-options.ts
|
|
257
|
+
function createMergedPaneTerminalConfig(deps) {
|
|
258
|
+
return (context) => {
|
|
259
|
+
const paneId = context.id;
|
|
260
|
+
const resolved = typeof deps.terminal === "function" ? deps.terminal(context) : deps.terminal ?? {};
|
|
261
|
+
const paneBaseStages = deps.shaderOps.normalizePaneShaderStages(resolved.shaderStages, paneId);
|
|
262
|
+
deps.shaderOps.setPaneBaseShaderStages(paneId, paneBaseStages);
|
|
263
|
+
const fonts = deps.getFonts();
|
|
264
|
+
return {
|
|
265
|
+
...resolved,
|
|
266
|
+
...fonts ? { fonts } : {},
|
|
267
|
+
shaderStages: deps.shaderOps.buildMergedShaderStages(paneBaseStages)
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
function createMergedPaneServicesConfig(deps) {
|
|
272
|
+
return (context) => {
|
|
273
|
+
const paneId = context.id;
|
|
274
|
+
const resolved = typeof deps.services === "function" ? deps.services(context) : deps.services ?? {};
|
|
275
|
+
const resolvedBeforeInput = resolved.beforeInput;
|
|
276
|
+
const resolvedBeforeRenderOutput = resolved.beforeRenderOutput;
|
|
277
|
+
const resolvedCallbacks = resolved.callbacks;
|
|
278
|
+
return {
|
|
279
|
+
...resolved,
|
|
280
|
+
callbacks: deps.onDesktopNotification || resolvedCallbacks?.onDesktopNotification ? {
|
|
281
|
+
...resolvedCallbacks,
|
|
282
|
+
onDesktopNotification: (notification) => {
|
|
283
|
+
resolvedCallbacks?.onDesktopNotification?.(notification);
|
|
284
|
+
deps.onDesktopNotification?.({ ...notification, paneId });
|
|
285
|
+
}
|
|
286
|
+
} : resolvedCallbacks,
|
|
287
|
+
beforeInput: ({ text, source }) => {
|
|
288
|
+
const maybeUserText = resolvedBeforeInput?.({ text, source });
|
|
289
|
+
if (maybeUserText === null)
|
|
290
|
+
return null;
|
|
291
|
+
const current = maybeUserText === undefined ? text : maybeUserText;
|
|
292
|
+
return deps.pluginHost.applyInputInterceptors(paneId, current, source);
|
|
293
|
+
},
|
|
294
|
+
beforeRenderOutput: ({ text, source }) => {
|
|
295
|
+
deps.runRenderHooks({
|
|
296
|
+
phase: "before",
|
|
297
|
+
paneId,
|
|
298
|
+
text,
|
|
299
|
+
source,
|
|
300
|
+
dropped: false
|
|
301
|
+
});
|
|
302
|
+
const maybeUserText = resolvedBeforeRenderOutput?.({ text, source });
|
|
303
|
+
if (maybeUserText === null) {
|
|
304
|
+
deps.runRenderHooks({
|
|
305
|
+
phase: "after",
|
|
306
|
+
paneId,
|
|
307
|
+
text,
|
|
308
|
+
source,
|
|
309
|
+
dropped: true
|
|
310
|
+
});
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
const current = maybeUserText === undefined ? text : maybeUserText;
|
|
314
|
+
const next = deps.pluginHost.applyOutputInterceptors(paneId, current, source);
|
|
315
|
+
deps.runRenderHooks({
|
|
316
|
+
phase: "after",
|
|
317
|
+
paneId,
|
|
318
|
+
text: next === null ? current : next,
|
|
319
|
+
source,
|
|
320
|
+
dropped: next === null
|
|
321
|
+
});
|
|
322
|
+
return next;
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function createPaneManagerEventHandlers(deps) {
|
|
328
|
+
return {
|
|
329
|
+
onPaneCreated: (pane) => {
|
|
330
|
+
deps.shaderOps.syncPaneShaderStages(pane.id);
|
|
331
|
+
deps.emitPluginEvent("pane:created", { paneId: pane.id });
|
|
332
|
+
deps.onPaneCreated?.(pane);
|
|
333
|
+
},
|
|
334
|
+
onPaneClosed: (pane) => {
|
|
335
|
+
deps.shaderOps.removePaneBaseShaderStages(pane.id);
|
|
336
|
+
deps.emitPluginEvent("pane:closed", { paneId: pane.id });
|
|
337
|
+
deps.onPaneClosed?.(pane);
|
|
338
|
+
},
|
|
339
|
+
onPaneSplit: (sourcePane, createdPane, direction) => {
|
|
340
|
+
deps.emitPluginEvent("pane:split", {
|
|
341
|
+
sourcePaneId: sourcePane.id,
|
|
342
|
+
createdPaneId: createdPane.id,
|
|
343
|
+
direction
|
|
344
|
+
});
|
|
345
|
+
deps.onPaneSplit?.(sourcePane, createdPane, direction);
|
|
346
|
+
},
|
|
347
|
+
onActivePaneChange: (pane) => {
|
|
348
|
+
deps.emitPluginEvent("pane:active-changed", { paneId: pane?.id ?? null });
|
|
349
|
+
deps.onActivePaneChange?.(pane);
|
|
350
|
+
},
|
|
351
|
+
onLayoutChanged: () => {
|
|
352
|
+
deps.emitPluginEvent("layout:changed", {});
|
|
353
|
+
deps.onLayoutChanged?.();
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// src/surface/restty/pane-manager-assembly.ts
|
|
359
|
+
function createResttyPaneManagerAssembly({
|
|
360
|
+
shaderOps,
|
|
361
|
+
controller,
|
|
362
|
+
getFonts,
|
|
363
|
+
terminal,
|
|
364
|
+
services,
|
|
365
|
+
events
|
|
366
|
+
}) {
|
|
367
|
+
const controllerHooks = controller.paneManagerHooks;
|
|
368
|
+
const {
|
|
369
|
+
onPaneCreated,
|
|
370
|
+
onPaneClosed,
|
|
371
|
+
onPaneSplit,
|
|
372
|
+
onActivePaneChange,
|
|
373
|
+
onLayoutChanged,
|
|
374
|
+
onDesktopNotification
|
|
375
|
+
} = events ?? {};
|
|
376
|
+
const mergedTerminalConfig = createMergedPaneTerminalConfig({
|
|
377
|
+
terminal,
|
|
378
|
+
getFonts,
|
|
379
|
+
shaderOps
|
|
380
|
+
});
|
|
381
|
+
const mergedServicesConfig = createMergedPaneServicesConfig({
|
|
382
|
+
services,
|
|
383
|
+
onDesktopNotification,
|
|
384
|
+
pluginHost: controller,
|
|
385
|
+
runRenderHooks: controllerHooks.runRenderHooks
|
|
386
|
+
});
|
|
387
|
+
const paneManagerEventHandlers = createPaneManagerEventHandlers({
|
|
388
|
+
shaderOps,
|
|
389
|
+
emitPluginEvent: controllerHooks.emitPluginEvent,
|
|
390
|
+
onPaneCreated,
|
|
391
|
+
onPaneClosed,
|
|
392
|
+
onPaneSplit,
|
|
393
|
+
onActivePaneChange,
|
|
394
|
+
onLayoutChanged
|
|
395
|
+
});
|
|
396
|
+
return {
|
|
397
|
+
mergedTerminalConfig,
|
|
398
|
+
mergedServicesConfig,
|
|
399
|
+
paneManagerEventHandlers
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// src/surface/plugins/runtime.ts
|
|
404
|
+
function registerPluginInterceptor(bucket, pluginId, interceptor, options, seq) {
|
|
405
|
+
const entry = {
|
|
406
|
+
id: seq.nextId,
|
|
407
|
+
pluginId,
|
|
408
|
+
priority: Number.isFinite(options?.priority) ? Number(options?.priority) : 0,
|
|
409
|
+
order: seq.nextOrder,
|
|
410
|
+
interceptor
|
|
411
|
+
};
|
|
412
|
+
bucket.push(entry);
|
|
413
|
+
bucket.sort((a, b) => {
|
|
414
|
+
if (a.priority !== b.priority)
|
|
415
|
+
return a.priority - b.priority;
|
|
416
|
+
return a.order - b.order;
|
|
417
|
+
});
|
|
418
|
+
return {
|
|
419
|
+
nextId: seq.nextId + 1,
|
|
420
|
+
nextOrder: seq.nextOrder + 1,
|
|
421
|
+
dispose: () => {
|
|
422
|
+
const index = bucket.findIndex((current) => current.id === entry.id);
|
|
423
|
+
if (index >= 0) {
|
|
424
|
+
bucket.splice(index, 1);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
function applyPluginInterceptors(bucket, kind, payload) {
|
|
430
|
+
let currentText = payload.text;
|
|
431
|
+
for (let i = 0;i < bucket.length; i += 1) {
|
|
432
|
+
const entry = bucket[i];
|
|
433
|
+
try {
|
|
434
|
+
const result = entry.interceptor({ ...payload, text: currentText });
|
|
435
|
+
if (result === null)
|
|
436
|
+
return null;
|
|
437
|
+
if (typeof result === "string")
|
|
438
|
+
currentText = result;
|
|
439
|
+
} catch (error) {
|
|
440
|
+
console.error(`[restty plugin] ${kind} interceptor error (${entry.pluginId}):`, error);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
return currentText;
|
|
444
|
+
}
|
|
445
|
+
function runPluginHooks(bucket, kind, payload) {
|
|
446
|
+
for (let i = 0;i < bucket.length; i += 1) {
|
|
447
|
+
const entry = bucket[i];
|
|
448
|
+
try {
|
|
449
|
+
entry.interceptor(payload);
|
|
450
|
+
} catch (error) {
|
|
451
|
+
console.error(`[restty plugin] ${kind} hook error (${entry.pluginId}):`, error);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
function attachRuntimeDisposer(runtime, kind, dispose) {
|
|
456
|
+
const entry = {
|
|
457
|
+
kind,
|
|
458
|
+
active: true,
|
|
459
|
+
dispose: () => {
|
|
460
|
+
if (!entry.active)
|
|
461
|
+
return;
|
|
462
|
+
entry.active = false;
|
|
463
|
+
dispose();
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
runtime.disposers.push(entry);
|
|
467
|
+
return entry.dispose;
|
|
468
|
+
}
|
|
469
|
+
function teardownPluginRuntime(runtime) {
|
|
470
|
+
for (let i = 0;i < runtime.disposers.length; i += 1) {
|
|
471
|
+
try {
|
|
472
|
+
runtime.disposers[i].dispose();
|
|
473
|
+
} catch {}
|
|
474
|
+
}
|
|
475
|
+
runtime.disposers.length = 0;
|
|
476
|
+
const cleanup = runtime.cleanup;
|
|
477
|
+
runtime.cleanup = null;
|
|
478
|
+
if (!cleanup)
|
|
479
|
+
return;
|
|
480
|
+
try {
|
|
481
|
+
cleanup();
|
|
482
|
+
} catch (error) {
|
|
483
|
+
console.error(`[restty plugin] cleanup error (${runtime.plugin.id}):`, error);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
function setPluginLoadError(pluginDiagnostics, pluginId, message) {
|
|
487
|
+
pluginDiagnostics.set(pluginId, {
|
|
488
|
+
id: pluginId,
|
|
489
|
+
version: null,
|
|
490
|
+
apiVersion: null,
|
|
491
|
+
requires: null,
|
|
492
|
+
active: false,
|
|
493
|
+
activatedAt: null,
|
|
494
|
+
lastError: message
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
function patchPluginDiagnostic(pluginDiagnostics, pluginId, patch) {
|
|
498
|
+
const current = pluginDiagnostics.get(pluginId);
|
|
499
|
+
if (!current)
|
|
500
|
+
return;
|
|
501
|
+
pluginDiagnostics.set(pluginId, {
|
|
502
|
+
...current,
|
|
503
|
+
...patch
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
function countActiveDisposers(runtime, kind) {
|
|
507
|
+
if (!runtime)
|
|
508
|
+
return 0;
|
|
509
|
+
let count = 0;
|
|
510
|
+
for (let i = 0;i < runtime.disposers.length; i += 1) {
|
|
511
|
+
const entry = runtime.disposers[i];
|
|
512
|
+
if (entry.active && entry.kind === kind)
|
|
513
|
+
count += 1;
|
|
514
|
+
}
|
|
515
|
+
return count;
|
|
516
|
+
}
|
|
517
|
+
function buildPluginInfo(pluginId, pluginDiagnostics, pluginRuntimes) {
|
|
518
|
+
const diagnostic = pluginDiagnostics.get(pluginId) ?? null;
|
|
519
|
+
const runtime = pluginRuntimes.get(pluginId) ?? null;
|
|
520
|
+
if (!diagnostic && !runtime)
|
|
521
|
+
return null;
|
|
522
|
+
const plugin = runtime?.plugin;
|
|
523
|
+
return {
|
|
524
|
+
id: pluginId,
|
|
525
|
+
version: plugin?.version?.trim?.() || diagnostic?.version || null,
|
|
526
|
+
apiVersion: plugin?.apiVersion ?? (Number.isFinite(diagnostic?.apiVersion) ? diagnostic?.apiVersion : null),
|
|
527
|
+
requires: plugin?.requires ?? diagnostic?.requires ?? null,
|
|
528
|
+
active: runtime ? true : diagnostic?.active ?? false,
|
|
529
|
+
activatedAt: runtime?.activatedAt ?? diagnostic?.activatedAt ?? null,
|
|
530
|
+
lastError: diagnostic?.lastError ?? null,
|
|
531
|
+
listeners: countActiveDisposers(runtime, "event"),
|
|
532
|
+
inputInterceptors: countActiveDisposers(runtime, "input-interceptor"),
|
|
533
|
+
outputInterceptors: countActiveDisposers(runtime, "output-interceptor"),
|
|
534
|
+
lifecycleHooks: countActiveDisposers(runtime, "lifecycle-hook"),
|
|
535
|
+
renderHooks: countActiveDisposers(runtime, "render-hook"),
|
|
536
|
+
renderStages: countActiveDisposers(runtime, "render-stage")
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
function onPluginEvent(pluginListeners, event, listener) {
|
|
540
|
+
let listeners = pluginListeners.get(event);
|
|
541
|
+
if (!listeners) {
|
|
542
|
+
listeners = new Set;
|
|
543
|
+
pluginListeners.set(event, listeners);
|
|
544
|
+
}
|
|
545
|
+
const wrapped = listener;
|
|
546
|
+
listeners.add(wrapped);
|
|
547
|
+
return () => {
|
|
548
|
+
const current = pluginListeners.get(event);
|
|
549
|
+
if (!current)
|
|
550
|
+
return;
|
|
551
|
+
current.delete(wrapped);
|
|
552
|
+
if (current.size === 0) {
|
|
553
|
+
pluginListeners.delete(event);
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
function emitPluginEvent(pluginListeners, event, payload) {
|
|
558
|
+
const listeners = pluginListeners.get(event);
|
|
559
|
+
if (!listeners || listeners.size === 0)
|
|
560
|
+
return;
|
|
561
|
+
const snapshot = Array.from(listeners);
|
|
562
|
+
for (let i = 0;i < snapshot.length; i += 1) {
|
|
563
|
+
try {
|
|
564
|
+
snapshot[i](payload);
|
|
565
|
+
} catch (error) {
|
|
566
|
+
console.error(`[restty plugin] listener error (${String(event)}):`, error);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// src/surface/plugins/utils.ts
|
|
572
|
+
function errorToMessage(error) {
|
|
573
|
+
if (error instanceof Error)
|
|
574
|
+
return error.message || error.name || "Unknown error";
|
|
575
|
+
return String(error);
|
|
576
|
+
}
|
|
577
|
+
function normalizePluginMetadata(plugin, pluginId) {
|
|
578
|
+
return {
|
|
579
|
+
...plugin,
|
|
580
|
+
id: pluginId,
|
|
581
|
+
version: plugin.version?.trim?.() || undefined,
|
|
582
|
+
apiVersion: Number.isFinite(plugin.apiVersion) ? Math.trunc(Number(plugin.apiVersion)) : undefined,
|
|
583
|
+
requires: plugin.requires ?? undefined
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
function assertPluginCompatibility(pluginId, plugin, pluginApiVersion) {
|
|
587
|
+
const version = plugin.version?.trim?.();
|
|
588
|
+
if (version !== undefined && !version) {
|
|
589
|
+
throw new Error(`Restty plugin ${pluginId} has an empty version`);
|
|
590
|
+
}
|
|
591
|
+
if (plugin.apiVersion !== undefined) {
|
|
592
|
+
if (!Number.isInteger(plugin.apiVersion) || plugin.apiVersion < 1) {
|
|
593
|
+
throw new Error(`Restty plugin ${pluginId} has invalid apiVersion ${String(plugin.apiVersion)}`);
|
|
594
|
+
}
|
|
595
|
+
if (plugin.apiVersion !== pluginApiVersion) {
|
|
596
|
+
throw new Error(`Restty plugin ${pluginId} requires apiVersion ${plugin.apiVersion}, current is ${pluginApiVersion}`);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
const requirement = plugin.requires?.pluginApi;
|
|
600
|
+
if (requirement === undefined)
|
|
601
|
+
return;
|
|
602
|
+
if (typeof requirement === "number") {
|
|
603
|
+
if (!Number.isInteger(requirement) || requirement < 1) {
|
|
604
|
+
throw new Error(`Restty plugin ${pluginId} has invalid requires.pluginApi value`);
|
|
605
|
+
}
|
|
606
|
+
if (requirement !== pluginApiVersion) {
|
|
607
|
+
throw new Error(`Restty plugin ${pluginId} requires pluginApi ${requirement}, current is ${pluginApiVersion}`);
|
|
608
|
+
}
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
const min = requirement.min;
|
|
612
|
+
const max = requirement.max;
|
|
613
|
+
if (!Number.isInteger(min) || min < 1) {
|
|
614
|
+
throw new Error(`Restty plugin ${pluginId} has invalid requires.pluginApi.min`);
|
|
615
|
+
}
|
|
616
|
+
if (max !== undefined && (!Number.isInteger(max) || max < min)) {
|
|
617
|
+
throw new Error(`Restty plugin ${pluginId} has invalid requires.pluginApi.max`);
|
|
618
|
+
}
|
|
619
|
+
if (pluginApiVersion < min || max !== undefined && pluginApiVersion > max) {
|
|
620
|
+
const range = max === undefined ? `>=${min}` : `${min}-${max}`;
|
|
621
|
+
throw new Error(`Restty plugin ${pluginId} requires pluginApi range ${range}, current is ${pluginApiVersion}`);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
function lookupPluginRegistryEntry(registry, pluginId) {
|
|
625
|
+
if (registry instanceof Map) {
|
|
626
|
+
return registry.get(pluginId) ?? null;
|
|
627
|
+
}
|
|
628
|
+
if (Object.prototype.hasOwnProperty.call(registry, pluginId)) {
|
|
629
|
+
return registry[pluginId];
|
|
630
|
+
}
|
|
631
|
+
return null;
|
|
632
|
+
}
|
|
633
|
+
async function resolvePluginRegistryEntry(entry) {
|
|
634
|
+
if (typeof entry === "function") {
|
|
635
|
+
return await entry();
|
|
636
|
+
}
|
|
637
|
+
return entry;
|
|
638
|
+
}
|
|
639
|
+
function normalizePluginCleanup(cleanup) {
|
|
640
|
+
if (!cleanup)
|
|
641
|
+
return null;
|
|
642
|
+
if (typeof cleanup === "function")
|
|
643
|
+
return cleanup;
|
|
644
|
+
if (typeof cleanup === "object" && typeof cleanup.dispose === "function") {
|
|
645
|
+
return () => cleanup.dispose();
|
|
646
|
+
}
|
|
647
|
+
return null;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// src/surface/plugins/dispatcher.ts
|
|
651
|
+
class ResttyPluginDispatcher {
|
|
652
|
+
deps;
|
|
653
|
+
pluginListeners = new Map;
|
|
654
|
+
inputInterceptors = [];
|
|
655
|
+
outputInterceptors = [];
|
|
656
|
+
lifecycleHooks = [];
|
|
657
|
+
renderHooks = [];
|
|
658
|
+
nextInterceptorId = 1;
|
|
659
|
+
nextInterceptorOrder = 1;
|
|
660
|
+
constructor(deps) {
|
|
661
|
+
this.deps = deps;
|
|
662
|
+
}
|
|
663
|
+
createPluginContext(runtime) {
|
|
664
|
+
return {
|
|
665
|
+
restty: this.deps.restty,
|
|
666
|
+
options: runtime.options,
|
|
667
|
+
on: (event, listener) => {
|
|
668
|
+
return {
|
|
669
|
+
dispose: this.attachRuntimeDisposer(runtime, "event", this.onPluginEvent(event, listener))
|
|
670
|
+
};
|
|
671
|
+
},
|
|
672
|
+
addInputInterceptor: (interceptor, options) => {
|
|
673
|
+
return {
|
|
674
|
+
dispose: this.attachRuntimeDisposer(runtime, "input-interceptor", this.addInputInterceptor(runtime.plugin.id, interceptor, options))
|
|
675
|
+
};
|
|
676
|
+
},
|
|
677
|
+
addOutputInterceptor: (interceptor, options) => {
|
|
678
|
+
return {
|
|
679
|
+
dispose: this.attachRuntimeDisposer(runtime, "output-interceptor", this.addOutputInterceptor(runtime.plugin.id, interceptor, options))
|
|
680
|
+
};
|
|
681
|
+
},
|
|
682
|
+
addLifecycleHook: (hook, options) => {
|
|
683
|
+
return {
|
|
684
|
+
dispose: this.attachRuntimeDisposer(runtime, "lifecycle-hook", this.addLifecycleHook(runtime.plugin.id, hook, options))
|
|
685
|
+
};
|
|
686
|
+
},
|
|
687
|
+
addRenderHook: (hook, options) => {
|
|
688
|
+
return {
|
|
689
|
+
dispose: this.attachRuntimeDisposer(runtime, "render-hook", this.addRenderHook(runtime.plugin.id, hook, options))
|
|
690
|
+
};
|
|
691
|
+
},
|
|
692
|
+
addRenderStage: (stage) => {
|
|
693
|
+
const rawId = stage?.id?.trim?.() ?? "";
|
|
694
|
+
if (!rawId) {
|
|
695
|
+
throw new Error(`Restty plugin ${runtime.plugin.id} render stage id is required`);
|
|
696
|
+
}
|
|
697
|
+
const stageId = `${runtime.plugin.id}:${rawId}`;
|
|
698
|
+
const normalized = normalizeShaderStage({ ...stage, id: stageId });
|
|
699
|
+
const handle = this.deps.addRenderStage(normalized, runtime.plugin.id);
|
|
700
|
+
return {
|
|
701
|
+
...handle,
|
|
702
|
+
dispose: this.attachRuntimeDisposer(runtime, "render-stage", handle.dispose)
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
applyInputInterceptors(paneId, text, source) {
|
|
708
|
+
return this.applyInterceptors(this.inputInterceptors, "input", { paneId, text, source });
|
|
709
|
+
}
|
|
710
|
+
applyOutputInterceptors(paneId, text, source) {
|
|
711
|
+
return this.applyInterceptors(this.outputInterceptors, "output", { paneId, text, source });
|
|
712
|
+
}
|
|
713
|
+
runLifecycleHooks(payload) {
|
|
714
|
+
this.runHooks(this.lifecycleHooks, "lifecycle", payload);
|
|
715
|
+
}
|
|
716
|
+
runRenderHooks(payload) {
|
|
717
|
+
this.runHooks(this.renderHooks, "render", payload);
|
|
718
|
+
}
|
|
719
|
+
emitPluginEvent(event, payload) {
|
|
720
|
+
emitPluginEvent(this.pluginListeners, event, payload);
|
|
721
|
+
}
|
|
722
|
+
attachRuntimeDisposer(runtime, kind, dispose) {
|
|
723
|
+
return attachRuntimeDisposer(runtime, kind, dispose);
|
|
724
|
+
}
|
|
725
|
+
addInputInterceptor(pluginId, interceptor, options) {
|
|
726
|
+
return this.registerInterceptor(this.inputInterceptors, pluginId, interceptor, options);
|
|
727
|
+
}
|
|
728
|
+
addOutputInterceptor(pluginId, interceptor, options) {
|
|
729
|
+
return this.registerInterceptor(this.outputInterceptors, pluginId, interceptor, options);
|
|
730
|
+
}
|
|
731
|
+
addLifecycleHook(pluginId, hook, options) {
|
|
732
|
+
return this.registerInterceptor(this.lifecycleHooks, pluginId, hook, options);
|
|
733
|
+
}
|
|
734
|
+
addRenderHook(pluginId, hook, options) {
|
|
735
|
+
return this.registerInterceptor(this.renderHooks, pluginId, hook, options);
|
|
736
|
+
}
|
|
737
|
+
registerInterceptor(bucket, pluginId, interceptor, options) {
|
|
738
|
+
const result = registerPluginInterceptor(bucket, pluginId, interceptor, options, {
|
|
739
|
+
nextId: this.nextInterceptorId,
|
|
740
|
+
nextOrder: this.nextInterceptorOrder
|
|
741
|
+
});
|
|
742
|
+
this.nextInterceptorId = result.nextId;
|
|
743
|
+
this.nextInterceptorOrder = result.nextOrder;
|
|
744
|
+
return result.dispose;
|
|
745
|
+
}
|
|
746
|
+
applyInterceptors(bucket, kind, payload) {
|
|
747
|
+
return applyPluginInterceptors(bucket, kind, payload);
|
|
748
|
+
}
|
|
749
|
+
runHooks(bucket, kind, payload) {
|
|
750
|
+
runPluginHooks(bucket, kind, payload);
|
|
751
|
+
}
|
|
752
|
+
onPluginEvent(event, listener) {
|
|
753
|
+
return onPluginEvent(this.pluginListeners, event, listener);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
// src/surface/plugins/host.ts
|
|
758
|
+
class ResttyPluginHost {
|
|
759
|
+
pluginRuntimes = new Map;
|
|
760
|
+
pluginDiagnostics = new Map;
|
|
761
|
+
dispatcher;
|
|
762
|
+
constructor(deps) {
|
|
763
|
+
this.dispatcher = new ResttyPluginDispatcher(deps);
|
|
764
|
+
}
|
|
765
|
+
async use(plugin, options) {
|
|
766
|
+
if (!plugin || typeof plugin !== "object") {
|
|
767
|
+
throw new Error("Restty plugin must be an object");
|
|
768
|
+
}
|
|
769
|
+
const pluginId = plugin.id?.trim?.() ?? "";
|
|
770
|
+
if (!pluginId) {
|
|
771
|
+
throw new Error("Restty plugin id is required");
|
|
772
|
+
}
|
|
773
|
+
if (typeof plugin.activate !== "function") {
|
|
774
|
+
throw new Error(`Restty plugin ${pluginId} must define activate(context)`);
|
|
775
|
+
}
|
|
776
|
+
if (this.pluginRuntimes.has(pluginId))
|
|
777
|
+
return;
|
|
778
|
+
try {
|
|
779
|
+
assertPluginCompatibility(pluginId, plugin, RESTTY_PLUGIN_API_VERSION);
|
|
780
|
+
} catch (error) {
|
|
781
|
+
this.pluginDiagnostics.set(pluginId, {
|
|
782
|
+
id: pluginId,
|
|
783
|
+
version: plugin.version?.trim?.() || null,
|
|
784
|
+
apiVersion: Number.isFinite(plugin.apiVersion) ? Number(plugin.apiVersion) : null,
|
|
785
|
+
requires: plugin.requires ?? null,
|
|
786
|
+
active: false,
|
|
787
|
+
activatedAt: null,
|
|
788
|
+
lastError: errorToMessage(error)
|
|
789
|
+
});
|
|
790
|
+
throw error;
|
|
791
|
+
}
|
|
792
|
+
const runtime = {
|
|
793
|
+
plugin: normalizePluginMetadata(plugin, pluginId),
|
|
794
|
+
cleanup: null,
|
|
795
|
+
activatedAt: Date.now(),
|
|
796
|
+
options,
|
|
797
|
+
disposers: []
|
|
798
|
+
};
|
|
799
|
+
this.pluginDiagnostics.set(pluginId, {
|
|
800
|
+
id: pluginId,
|
|
801
|
+
version: runtime.plugin.version?.trim?.() || null,
|
|
802
|
+
apiVersion: Number.isFinite(runtime.plugin.apiVersion) ? Number(runtime.plugin.apiVersion) : null,
|
|
803
|
+
requires: runtime.plugin.requires ?? null,
|
|
804
|
+
active: false,
|
|
805
|
+
activatedAt: null,
|
|
806
|
+
lastError: null
|
|
807
|
+
});
|
|
808
|
+
this.pluginRuntimes.set(pluginId, runtime);
|
|
809
|
+
try {
|
|
810
|
+
const cleanup = await runtime.plugin.activate(this.dispatcher.createPluginContext(runtime), runtime.options);
|
|
811
|
+
runtime.cleanup = normalizePluginCleanup(cleanup);
|
|
812
|
+
runtime.activatedAt = Date.now();
|
|
813
|
+
this.updatePluginDiagnostic(pluginId, {
|
|
814
|
+
active: true,
|
|
815
|
+
activatedAt: runtime.activatedAt,
|
|
816
|
+
lastError: null
|
|
817
|
+
});
|
|
818
|
+
this.emitPluginEvent("plugin:activated", { pluginId });
|
|
819
|
+
} catch (error) {
|
|
820
|
+
this.teardownPluginRuntime(runtime);
|
|
821
|
+
this.pluginRuntimes.delete(pluginId);
|
|
822
|
+
this.updatePluginDiagnostic(pluginId, {
|
|
823
|
+
active: false,
|
|
824
|
+
activatedAt: null,
|
|
825
|
+
lastError: errorToMessage(error)
|
|
826
|
+
});
|
|
827
|
+
throw error;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
async loadPlugins(manifest, registry) {
|
|
831
|
+
const results = [];
|
|
832
|
+
for (let i = 0;i < manifest.length; i += 1) {
|
|
833
|
+
const item = manifest[i];
|
|
834
|
+
const pluginId = item.id?.trim?.() ?? "";
|
|
835
|
+
if (!pluginId) {
|
|
836
|
+
results.push({
|
|
837
|
+
id: "",
|
|
838
|
+
status: "failed",
|
|
839
|
+
error: "Restty plugin manifest entry is missing id"
|
|
840
|
+
});
|
|
841
|
+
continue;
|
|
842
|
+
}
|
|
843
|
+
if (item.enabled === false) {
|
|
844
|
+
results.push({ id: pluginId, status: "skipped", error: null });
|
|
845
|
+
continue;
|
|
846
|
+
}
|
|
847
|
+
const entry = lookupPluginRegistryEntry(registry, pluginId);
|
|
848
|
+
if (!entry) {
|
|
849
|
+
const message = `Restty plugin ${pluginId} was not found in registry`;
|
|
850
|
+
this.setPluginLoadError(pluginId, message);
|
|
851
|
+
results.push({ id: pluginId, status: "missing", error: message });
|
|
852
|
+
continue;
|
|
853
|
+
}
|
|
854
|
+
let plugin;
|
|
855
|
+
try {
|
|
856
|
+
plugin = await resolvePluginRegistryEntry(entry);
|
|
857
|
+
} catch (error) {
|
|
858
|
+
const message = errorToMessage(error);
|
|
859
|
+
this.setPluginLoadError(pluginId, message);
|
|
860
|
+
results.push({ id: pluginId, status: "failed", error: message });
|
|
861
|
+
continue;
|
|
862
|
+
}
|
|
863
|
+
const resolvedId = plugin.id?.trim?.() ?? "";
|
|
864
|
+
if (resolvedId !== pluginId) {
|
|
865
|
+
const message = `Restty plugin registry entry ${pluginId} resolved to id ${resolvedId || "(empty)"}`;
|
|
866
|
+
this.setPluginLoadError(pluginId, message);
|
|
867
|
+
results.push({ id: pluginId, status: "failed", error: message });
|
|
868
|
+
continue;
|
|
869
|
+
}
|
|
870
|
+
try {
|
|
871
|
+
await this.use(plugin, item.options);
|
|
872
|
+
results.push({ id: pluginId, status: "loaded", error: null });
|
|
873
|
+
} catch (error) {
|
|
874
|
+
results.push({
|
|
875
|
+
id: pluginId,
|
|
876
|
+
status: "failed",
|
|
877
|
+
error: errorToMessage(error)
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
return results;
|
|
882
|
+
}
|
|
883
|
+
unuse(pluginId) {
|
|
884
|
+
const key = pluginId?.trim?.() ?? "";
|
|
885
|
+
if (!key)
|
|
886
|
+
return false;
|
|
887
|
+
const runtime = this.pluginRuntimes.get(key);
|
|
888
|
+
if (!runtime)
|
|
889
|
+
return false;
|
|
890
|
+
this.pluginRuntimes.delete(key);
|
|
891
|
+
this.teardownPluginRuntime(runtime);
|
|
892
|
+
this.updatePluginDiagnostic(key, {
|
|
893
|
+
active: false,
|
|
894
|
+
activatedAt: null
|
|
895
|
+
});
|
|
896
|
+
this.emitPluginEvent("plugin:deactivated", { pluginId: key });
|
|
897
|
+
return true;
|
|
898
|
+
}
|
|
899
|
+
plugins() {
|
|
900
|
+
return Array.from(this.pluginRuntimes.keys());
|
|
901
|
+
}
|
|
902
|
+
pluginInfo(pluginId) {
|
|
903
|
+
if (typeof pluginId === "string") {
|
|
904
|
+
const key = pluginId.trim();
|
|
905
|
+
if (!key)
|
|
906
|
+
return null;
|
|
907
|
+
return this.buildPluginInfo(key);
|
|
908
|
+
}
|
|
909
|
+
const keys = new Set;
|
|
910
|
+
for (const key of this.pluginDiagnostics.keys())
|
|
911
|
+
keys.add(key);
|
|
912
|
+
for (const key of this.pluginRuntimes.keys())
|
|
913
|
+
keys.add(key);
|
|
914
|
+
return Array.from(keys).sort((a, b) => a.localeCompare(b)).map((key) => this.buildPluginInfo(key)).filter((entry) => entry !== null);
|
|
915
|
+
}
|
|
916
|
+
destroy() {
|
|
917
|
+
const pluginIds = this.plugins();
|
|
918
|
+
for (let i = 0;i < pluginIds.length; i += 1) {
|
|
919
|
+
this.unuse(pluginIds[i]);
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
applyInputInterceptors(paneId, text, source) {
|
|
923
|
+
return this.dispatcher.applyInputInterceptors(paneId, text, source);
|
|
924
|
+
}
|
|
925
|
+
applyOutputInterceptors(paneId, text, source) {
|
|
926
|
+
return this.dispatcher.applyOutputInterceptors(paneId, text, source);
|
|
927
|
+
}
|
|
928
|
+
runLifecycleHooks(payload) {
|
|
929
|
+
this.dispatcher.runLifecycleHooks(payload);
|
|
930
|
+
}
|
|
931
|
+
runRenderHooks(payload) {
|
|
932
|
+
this.dispatcher.runRenderHooks(payload);
|
|
933
|
+
}
|
|
934
|
+
emitPluginEvent(event, payload) {
|
|
935
|
+
this.dispatcher.emitPluginEvent(event, payload);
|
|
936
|
+
}
|
|
937
|
+
setPluginLoadError(pluginId, message) {
|
|
938
|
+
setPluginLoadError(this.pluginDiagnostics, pluginId, message);
|
|
939
|
+
}
|
|
940
|
+
updatePluginDiagnostic(pluginId, patch) {
|
|
941
|
+
patchPluginDiagnostic(this.pluginDiagnostics, pluginId, patch);
|
|
942
|
+
}
|
|
943
|
+
buildPluginInfo(pluginId) {
|
|
944
|
+
return buildPluginInfo(pluginId, this.pluginDiagnostics, this.pluginRuntimes);
|
|
945
|
+
}
|
|
946
|
+
teardownPluginRuntime(runtime) {
|
|
947
|
+
teardownPluginRuntime(runtime);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
// src/surface/restty/controller.ts
|
|
952
|
+
var resttyPluginSurfacePassthroughKeys = [
|
|
953
|
+
"panes",
|
|
954
|
+
"pane",
|
|
955
|
+
"activePane",
|
|
956
|
+
"focusedPane",
|
|
957
|
+
"forEachPane",
|
|
958
|
+
"isPtyConnected",
|
|
959
|
+
"setRenderer",
|
|
960
|
+
"setPaused",
|
|
961
|
+
"togglePause",
|
|
962
|
+
"setFontSize",
|
|
963
|
+
"setLigatures",
|
|
964
|
+
"setFontHinting",
|
|
965
|
+
"setFontHintTarget",
|
|
966
|
+
"setFonts",
|
|
967
|
+
"applyTheme",
|
|
968
|
+
"resetTheme",
|
|
969
|
+
"sendInput",
|
|
970
|
+
"sendKeyInput",
|
|
971
|
+
"clearScreen",
|
|
972
|
+
"connectPty",
|
|
973
|
+
"disconnectPty",
|
|
974
|
+
"setMouseMode",
|
|
975
|
+
"getMouseStatus",
|
|
976
|
+
"copySelectionToClipboard",
|
|
977
|
+
"pasteFromClipboard",
|
|
978
|
+
"selectWordAtClientPoint",
|
|
979
|
+
"setSearchQuery",
|
|
980
|
+
"clearSearch",
|
|
981
|
+
"searchNext",
|
|
982
|
+
"searchPrevious",
|
|
983
|
+
"getSearchState",
|
|
984
|
+
"openSearch",
|
|
985
|
+
"closeSearch",
|
|
986
|
+
"toggleSearch",
|
|
987
|
+
"isSearchOpen",
|
|
988
|
+
"resize",
|
|
989
|
+
"focus",
|
|
990
|
+
"blur",
|
|
991
|
+
"updateSize",
|
|
992
|
+
"getBackend",
|
|
993
|
+
"setShaderStages",
|
|
994
|
+
"getShaderStages",
|
|
995
|
+
"addShaderStage",
|
|
996
|
+
"removeShaderStage",
|
|
997
|
+
"closePane",
|
|
998
|
+
"getPaneStyleOptions",
|
|
999
|
+
"setPaneStyleOptions",
|
|
1000
|
+
"getSearchUiStyleOptions",
|
|
1001
|
+
"setSearchUiStyleOptions",
|
|
1002
|
+
"setActivePane",
|
|
1003
|
+
"markPaneFocused",
|
|
1004
|
+
"requestLayoutSync",
|
|
1005
|
+
"hideContextMenu"
|
|
1006
|
+
];
|
|
1007
|
+
function createResttyPluginSurfacePassthroughApi(source) {
|
|
1008
|
+
const passthrough = {};
|
|
1009
|
+
for (const key of resttyPluginSurfacePassthroughKeys) {
|
|
1010
|
+
passthrough[key] = source[key].bind(source);
|
|
1011
|
+
}
|
|
1012
|
+
return passthrough;
|
|
1013
|
+
}
|
|
1014
|
+
function createResttyPluginSurfaceApi(source) {
|
|
1015
|
+
const surfaceApi = createResttyPluginSurfacePassthroughApi(source);
|
|
1016
|
+
const requirePaneHandle = (id) => {
|
|
1017
|
+
const handle = surfaceApi.pane(id);
|
|
1018
|
+
if (!handle) {
|
|
1019
|
+
throw new Error(`Restty plugin surface could not resolve pane ${id}`);
|
|
1020
|
+
}
|
|
1021
|
+
return handle;
|
|
1022
|
+
};
|
|
1023
|
+
return {
|
|
1024
|
+
...surfaceApi,
|
|
1025
|
+
createInitialPane: (options) => {
|
|
1026
|
+
const pane = source.createInitialPane(options);
|
|
1027
|
+
return requirePaneHandle(pane.id);
|
|
1028
|
+
},
|
|
1029
|
+
splitActivePane: (direction) => {
|
|
1030
|
+
const pane = source.splitActivePane(direction);
|
|
1031
|
+
return pane ? requirePaneHandle(pane.id) : null;
|
|
1032
|
+
},
|
|
1033
|
+
splitPane: (id, direction) => {
|
|
1034
|
+
const pane = source.splitPane(id, direction);
|
|
1035
|
+
return pane ? requirePaneHandle(pane.id) : null;
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
class ResttyController {
|
|
1041
|
+
pluginHost;
|
|
1042
|
+
lifecycleHooks;
|
|
1043
|
+
lifecycleAndPluginHooks;
|
|
1044
|
+
paneManagerHooks;
|
|
1045
|
+
constructor(deps) {
|
|
1046
|
+
this.pluginHost = new ResttyPluginHost(deps);
|
|
1047
|
+
this.lifecycleHooks = {
|
|
1048
|
+
runLifecycleHooks: (payload) => this.runLifecycleHooks(payload)
|
|
1049
|
+
};
|
|
1050
|
+
this.lifecycleAndPluginHooks = {
|
|
1051
|
+
runLifecycleHooks: (payload) => this.runLifecycleHooks(payload),
|
|
1052
|
+
emitPluginEvent: (event, payload) => this.emitPluginEvent(event, payload)
|
|
1053
|
+
};
|
|
1054
|
+
this.paneManagerHooks = {
|
|
1055
|
+
runRenderHooks: (payload) => this.runRenderHooks(payload),
|
|
1056
|
+
emitPluginEvent: (event, payload) => this.emitPluginEvent(event, payload)
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
async use(plugin, options) {
|
|
1060
|
+
await this.pluginHost.use(plugin, options);
|
|
1061
|
+
}
|
|
1062
|
+
async loadPlugins(manifest, registry) {
|
|
1063
|
+
return this.pluginHost.loadPlugins(manifest, registry);
|
|
1064
|
+
}
|
|
1065
|
+
unuse(pluginId) {
|
|
1066
|
+
return this.pluginHost.unuse(pluginId);
|
|
1067
|
+
}
|
|
1068
|
+
plugins() {
|
|
1069
|
+
return this.pluginHost.plugins();
|
|
1070
|
+
}
|
|
1071
|
+
pluginInfo(pluginId) {
|
|
1072
|
+
if (typeof pluginId === "string")
|
|
1073
|
+
return this.pluginHost.pluginInfo(pluginId);
|
|
1074
|
+
return this.pluginHost.pluginInfo();
|
|
1075
|
+
}
|
|
1076
|
+
applyInputInterceptors(paneId, text, source) {
|
|
1077
|
+
return this.pluginHost.applyInputInterceptors(paneId, text, source);
|
|
1078
|
+
}
|
|
1079
|
+
applyOutputInterceptors(paneId, text, source) {
|
|
1080
|
+
return this.pluginHost.applyOutputInterceptors(paneId, text, source);
|
|
1081
|
+
}
|
|
1082
|
+
runLifecycleHooks(payload) {
|
|
1083
|
+
this.pluginHost.runLifecycleHooks(payload);
|
|
1084
|
+
}
|
|
1085
|
+
runRenderHooks(payload) {
|
|
1086
|
+
this.pluginHost.runRenderHooks(payload);
|
|
1087
|
+
}
|
|
1088
|
+
emitPluginEvent(event, payload) {
|
|
1089
|
+
this.pluginHost.emitPluginEvent(event, payload);
|
|
1090
|
+
}
|
|
1091
|
+
destroy() {
|
|
1092
|
+
this.pluginHost.destroy();
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
// src/surface/restty/plugin-surface.ts
|
|
1097
|
+
function createResttyPluginSurfaceBridge(restty) {
|
|
1098
|
+
return createResttyPluginSurfaceApi(restty);
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
// src/surface/restty/shader-ops.ts
|
|
1102
|
+
class ResttyShaderOps {
|
|
1103
|
+
paneBaseShaderStages = new Map;
|
|
1104
|
+
globalShaderStages = new Map;
|
|
1105
|
+
nextShaderStageOrder = 1;
|
|
1106
|
+
deps;
|
|
1107
|
+
constructor(deps, shaderStages) {
|
|
1108
|
+
this.deps = deps;
|
|
1109
|
+
if (shaderStages?.length) {
|
|
1110
|
+
const normalized = sortShaderStages(normalizeShaderStages(shaderStages));
|
|
1111
|
+
for (let i = 0;i < normalized.length; i += 1) {
|
|
1112
|
+
const stage = normalized[i];
|
|
1113
|
+
this.globalShaderStages.set(stage.id, {
|
|
1114
|
+
id: stage.id,
|
|
1115
|
+
stage,
|
|
1116
|
+
order: this.nextShaderStageOrder++,
|
|
1117
|
+
ownerPluginId: null
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
setShaderStages(stages) {
|
|
1123
|
+
this.globalShaderStages.clear();
|
|
1124
|
+
const normalized = sortShaderStages(normalizeShaderStages(stages ?? []));
|
|
1125
|
+
for (let i = 0;i < normalized.length; i += 1) {
|
|
1126
|
+
const stage = normalized[i];
|
|
1127
|
+
this.globalShaderStages.set(stage.id, {
|
|
1128
|
+
id: stage.id,
|
|
1129
|
+
stage,
|
|
1130
|
+
order: this.nextShaderStageOrder++,
|
|
1131
|
+
ownerPluginId: null
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
this.syncPaneShaderStages();
|
|
1135
|
+
}
|
|
1136
|
+
getShaderStages() {
|
|
1137
|
+
return cloneShaderStages(this.listGlobalShaderStages().map((entry) => entry.stage));
|
|
1138
|
+
}
|
|
1139
|
+
addShaderStage(stage) {
|
|
1140
|
+
const normalized = normalizeShaderStage(stage);
|
|
1141
|
+
return this.addManagedShaderStage(normalized, null);
|
|
1142
|
+
}
|
|
1143
|
+
addManagedShaderStage(stage, ownerPluginId) {
|
|
1144
|
+
const normalized = normalizeShaderStage(stage);
|
|
1145
|
+
this.globalShaderStages.set(normalized.id, {
|
|
1146
|
+
id: normalized.id,
|
|
1147
|
+
stage: normalized,
|
|
1148
|
+
order: this.nextShaderStageOrder++,
|
|
1149
|
+
ownerPluginId
|
|
1150
|
+
});
|
|
1151
|
+
this.syncPaneShaderStages();
|
|
1152
|
+
return {
|
|
1153
|
+
id: normalized.id,
|
|
1154
|
+
setUniforms: (uniforms) => {
|
|
1155
|
+
const current = this.globalShaderStages.get(normalized.id);
|
|
1156
|
+
if (!current)
|
|
1157
|
+
return;
|
|
1158
|
+
const next = normalizeShaderStage({
|
|
1159
|
+
...current.stage,
|
|
1160
|
+
uniforms
|
|
1161
|
+
});
|
|
1162
|
+
this.globalShaderStages.set(normalized.id, {
|
|
1163
|
+
...current,
|
|
1164
|
+
stage: next
|
|
1165
|
+
});
|
|
1166
|
+
this.syncPaneShaderStages();
|
|
1167
|
+
},
|
|
1168
|
+
setEnabled: (value) => {
|
|
1169
|
+
const current = this.globalShaderStages.get(normalized.id);
|
|
1170
|
+
if (!current)
|
|
1171
|
+
return;
|
|
1172
|
+
const next = normalizeShaderStage({
|
|
1173
|
+
...current.stage,
|
|
1174
|
+
enabled: Boolean(value)
|
|
1175
|
+
});
|
|
1176
|
+
this.globalShaderStages.set(normalized.id, {
|
|
1177
|
+
...current,
|
|
1178
|
+
stage: next
|
|
1179
|
+
});
|
|
1180
|
+
this.syncPaneShaderStages();
|
|
1181
|
+
},
|
|
1182
|
+
dispose: () => {
|
|
1183
|
+
this.removeShaderStage(normalized.id);
|
|
1184
|
+
}
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
removeShaderStage(id) {
|
|
1188
|
+
const stageId = id?.trim?.() ?? "";
|
|
1189
|
+
if (!stageId)
|
|
1190
|
+
return false;
|
|
1191
|
+
const removed = this.globalShaderStages.delete(stageId);
|
|
1192
|
+
if (removed) {
|
|
1193
|
+
this.syncPaneShaderStages();
|
|
1194
|
+
}
|
|
1195
|
+
return removed;
|
|
1196
|
+
}
|
|
1197
|
+
normalizePaneShaderStages(stages, paneId) {
|
|
1198
|
+
if (!stages?.length)
|
|
1199
|
+
return [];
|
|
1200
|
+
try {
|
|
1201
|
+
return sortShaderStages(normalizeShaderStages(stages));
|
|
1202
|
+
} catch (error) {
|
|
1203
|
+
console.warn(`[restty shader-stage] invalid pane stage config for pane ${paneId}:`, error);
|
|
1204
|
+
return [];
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
setPaneBaseShaderStages(paneId, stages) {
|
|
1208
|
+
this.paneBaseShaderStages.set(paneId, stages);
|
|
1209
|
+
}
|
|
1210
|
+
removePaneBaseShaderStages(paneId) {
|
|
1211
|
+
this.paneBaseShaderStages.delete(paneId);
|
|
1212
|
+
}
|
|
1213
|
+
buildMergedShaderStages(baseStages) {
|
|
1214
|
+
const merged = new Map;
|
|
1215
|
+
for (let i = 0;i < baseStages.length; i += 1) {
|
|
1216
|
+
const stage = baseStages[i];
|
|
1217
|
+
merged.set(stage.id, stage);
|
|
1218
|
+
}
|
|
1219
|
+
const globals = this.listGlobalShaderStages();
|
|
1220
|
+
for (let i = 0;i < globals.length; i += 1) {
|
|
1221
|
+
const stage = globals[i].stage;
|
|
1222
|
+
if (merged.has(stage.id))
|
|
1223
|
+
merged.delete(stage.id);
|
|
1224
|
+
merged.set(stage.id, stage);
|
|
1225
|
+
}
|
|
1226
|
+
return sortShaderStages(Array.from(merged.values()));
|
|
1227
|
+
}
|
|
1228
|
+
syncPaneShaderStages(paneId) {
|
|
1229
|
+
const panes = [];
|
|
1230
|
+
if (paneId === undefined) {
|
|
1231
|
+
this.deps.forEachPane((pane) => {
|
|
1232
|
+
panes.push(pane);
|
|
1233
|
+
});
|
|
1234
|
+
} else {
|
|
1235
|
+
const pane = this.deps.getPaneHandleById(paneId);
|
|
1236
|
+
if (pane)
|
|
1237
|
+
panes.push(pane);
|
|
1238
|
+
}
|
|
1239
|
+
for (let i = 0;i < panes.length; i += 1) {
|
|
1240
|
+
const pane = panes[i];
|
|
1241
|
+
const base = this.paneBaseShaderStages.get(pane.id) ?? [];
|
|
1242
|
+
pane.setShaderStages(this.buildMergedShaderStages(base));
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
clear() {
|
|
1246
|
+
this.globalShaderStages.clear();
|
|
1247
|
+
this.paneBaseShaderStages.clear();
|
|
1248
|
+
}
|
|
1249
|
+
listGlobalShaderStages() {
|
|
1250
|
+
return Array.from(this.globalShaderStages.values()).sort((a, b) => a.order - b.order);
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
// src/surface/restty/assembly.ts
|
|
1255
|
+
function createResttySurfaceAssembly({
|
|
1256
|
+
restty,
|
|
1257
|
+
forEachPane,
|
|
1258
|
+
getPaneHandleById,
|
|
1259
|
+
getFonts,
|
|
1260
|
+
terminal,
|
|
1261
|
+
services,
|
|
1262
|
+
events
|
|
1263
|
+
}) {
|
|
1264
|
+
const shaderOps = new ResttyShaderOps({
|
|
1265
|
+
forEachPane,
|
|
1266
|
+
getPaneHandleById
|
|
1267
|
+
});
|
|
1268
|
+
const controller = new ResttyController({
|
|
1269
|
+
restty: createResttyPluginSurfaceBridge(restty),
|
|
1270
|
+
addRenderStage: (stage, ownerPluginId) => shaderOps.addManagedShaderStage(stage, ownerPluginId)
|
|
1271
|
+
});
|
|
1272
|
+
const paneManagerAssembly = createResttyPaneManagerAssembly({
|
|
1273
|
+
shaderOps,
|
|
1274
|
+
controller,
|
|
1275
|
+
getFonts,
|
|
1276
|
+
terminal,
|
|
1277
|
+
services,
|
|
1278
|
+
events
|
|
1279
|
+
});
|
|
1280
|
+
return {
|
|
1281
|
+
shaderOps,
|
|
1282
|
+
controller,
|
|
1283
|
+
...paneManagerAssembly
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
// src/surface/restty/bootstrap.ts
|
|
1288
|
+
function bootstrapResttySurface({
|
|
1289
|
+
restty,
|
|
1290
|
+
forEachPane,
|
|
1291
|
+
getPaneHandleById,
|
|
1292
|
+
getFonts,
|
|
1293
|
+
options
|
|
1294
|
+
}) {
|
|
1295
|
+
const { root, session, surface, terminal, services } = options;
|
|
1296
|
+
const {
|
|
1297
|
+
paneDom,
|
|
1298
|
+
autoInit,
|
|
1299
|
+
minPaneSize,
|
|
1300
|
+
paneStyles,
|
|
1301
|
+
searchUi,
|
|
1302
|
+
shortcuts,
|
|
1303
|
+
contextMenu,
|
|
1304
|
+
defaultContextMenu,
|
|
1305
|
+
createInitialPane = true,
|
|
1306
|
+
events
|
|
1307
|
+
} = surface ?? {};
|
|
1308
|
+
const {
|
|
1309
|
+
shaderOps,
|
|
1310
|
+
controller,
|
|
1311
|
+
mergedTerminalConfig,
|
|
1312
|
+
mergedServicesConfig,
|
|
1313
|
+
paneManagerEventHandlers
|
|
1314
|
+
} = createResttySurfaceAssembly({
|
|
1315
|
+
restty,
|
|
1316
|
+
forEachPane,
|
|
1317
|
+
getPaneHandleById,
|
|
1318
|
+
getFonts,
|
|
1319
|
+
terminal,
|
|
1320
|
+
services,
|
|
1321
|
+
events
|
|
1322
|
+
});
|
|
1323
|
+
const paneManager = createResttyManagedPaneManager({
|
|
1324
|
+
root,
|
|
1325
|
+
session,
|
|
1326
|
+
paneDom,
|
|
1327
|
+
autoInit,
|
|
1328
|
+
minPaneSize,
|
|
1329
|
+
paneStyles,
|
|
1330
|
+
searchUi,
|
|
1331
|
+
shortcuts,
|
|
1332
|
+
contextMenu,
|
|
1333
|
+
defaultContextMenu,
|
|
1334
|
+
terminal: mergedTerminalConfig,
|
|
1335
|
+
services: mergedServicesConfig,
|
|
1336
|
+
...paneManagerEventHandlers
|
|
1337
|
+
});
|
|
1338
|
+
return {
|
|
1339
|
+
shaderOps,
|
|
1340
|
+
controller,
|
|
1341
|
+
paneManager,
|
|
1342
|
+
createInitialPane
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
// src/surface/restty/pane-lookup.ts
|
|
1347
|
+
function createResttyPaneLookup(options) {
|
|
1348
|
+
return {
|
|
1349
|
+
getPanes: () => options.getPanes(),
|
|
1350
|
+
getPaneById: (id) => options.getPaneById(id),
|
|
1351
|
+
getActivePane: () => options.getActivePane(),
|
|
1352
|
+
getFocusedPane: () => options.getFocusedPane(),
|
|
1353
|
+
openPaneSearch: (id, searchOptions) => {
|
|
1354
|
+
options.paneManager.openPaneSearch(id, searchOptions);
|
|
1355
|
+
},
|
|
1356
|
+
closePaneSearch: (id, searchOptions) => {
|
|
1357
|
+
options.paneManager.closePaneSearch(id, searchOptions);
|
|
1358
|
+
},
|
|
1359
|
+
togglePaneSearch: (id, searchOptions) => {
|
|
1360
|
+
options.paneManager.togglePaneSearch(id, searchOptions);
|
|
1361
|
+
},
|
|
1362
|
+
isPaneSearchOpen: (id) => options.paneManager.isPaneSearchOpen(id),
|
|
1363
|
+
getSearchUiStyleOptions: () => options.paneManager.getSearchUiStyleOptions(),
|
|
1364
|
+
setSearchUiStyleOptions: (searchOptions) => {
|
|
1365
|
+
options.paneManager.setSearchUiStyleOptions(searchOptions);
|
|
1366
|
+
}
|
|
1367
|
+
};
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
// src/surface/restty/pane-handle-ops.ts
|
|
1371
|
+
function requirePaneById(getPaneById, id) {
|
|
1372
|
+
const pane = getPaneById(id);
|
|
1373
|
+
if (!pane)
|
|
1374
|
+
throw new Error(`Restty pane ${id} does not exist`);
|
|
1375
|
+
return pane;
|
|
1376
|
+
}
|
|
1377
|
+
function makePaneHandle(lookup, id) {
|
|
1378
|
+
return new ResttyPaneHandle(() => requirePaneById(lookup.getPaneById, id), {
|
|
1379
|
+
open: (paneId, options) => {
|
|
1380
|
+
lookup.openPaneSearch(paneId, options);
|
|
1381
|
+
},
|
|
1382
|
+
close: (paneId, options) => {
|
|
1383
|
+
lookup.closePaneSearch(paneId, options);
|
|
1384
|
+
},
|
|
1385
|
+
toggle: (paneId, options) => {
|
|
1386
|
+
lookup.togglePaneSearch(paneId, options);
|
|
1387
|
+
},
|
|
1388
|
+
isOpen: (paneId) => lookup.isPaneSearchOpen(paneId),
|
|
1389
|
+
getStyleOptions: () => lookup.getSearchUiStyleOptions(),
|
|
1390
|
+
setStyleOptions: (options) => {
|
|
1391
|
+
lookup.setSearchUiStyleOptions(options);
|
|
1392
|
+
}
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
function requireActivePaneHandle(lookup) {
|
|
1396
|
+
const pane = lookup.getActivePane();
|
|
1397
|
+
if (!pane) {
|
|
1398
|
+
throw new Error("Restty has no active pane. Create or focus a pane first.");
|
|
1399
|
+
}
|
|
1400
|
+
return makePaneHandle(lookup, pane.id);
|
|
1401
|
+
}
|
|
1402
|
+
function panes(lookup) {
|
|
1403
|
+
return lookup.getPanes().map((pane) => makePaneHandle(lookup, pane.id));
|
|
1404
|
+
}
|
|
1405
|
+
function pane(lookup, id) {
|
|
1406
|
+
if (!lookup.getPaneById(id))
|
|
1407
|
+
return null;
|
|
1408
|
+
return makePaneHandle(lookup, id);
|
|
1409
|
+
}
|
|
1410
|
+
function activePane(lookup) {
|
|
1411
|
+
const active = lookup.getActivePane();
|
|
1412
|
+
if (!active)
|
|
1413
|
+
return null;
|
|
1414
|
+
return makePaneHandle(lookup, active.id);
|
|
1415
|
+
}
|
|
1416
|
+
function focusedPane(lookup) {
|
|
1417
|
+
const focused = lookup.getFocusedPane();
|
|
1418
|
+
if (!focused)
|
|
1419
|
+
return null;
|
|
1420
|
+
return makePaneHandle(lookup, focused.id);
|
|
1421
|
+
}
|
|
1422
|
+
function forEachPane(lookup, visitor) {
|
|
1423
|
+
const all = lookup.getPanes();
|
|
1424
|
+
for (let i = 0;i < all.length; i += 1) {
|
|
1425
|
+
visitor(makePaneHandle(lookup, all[i].id));
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
// src/surface/restty/pane-command-ops.ts
|
|
1430
|
+
function createInitialPane(paneManager, hooks, options) {
|
|
1431
|
+
hooks.runLifecycleHooks({ phase: "before", action: "create-initial-pane" });
|
|
1432
|
+
const pane2 = paneManager.createInitialPane(options);
|
|
1433
|
+
hooks.runLifecycleHooks({
|
|
1434
|
+
phase: "after",
|
|
1435
|
+
action: "create-initial-pane",
|
|
1436
|
+
paneId: pane2.id,
|
|
1437
|
+
ok: true
|
|
1438
|
+
});
|
|
1439
|
+
return pane2;
|
|
1440
|
+
}
|
|
1441
|
+
function splitActivePane(paneManager, lookup, hooks, direction) {
|
|
1442
|
+
const sourcePaneId = lookup.getActivePane()?.id ?? null;
|
|
1443
|
+
hooks.runLifecycleHooks({
|
|
1444
|
+
phase: "before",
|
|
1445
|
+
action: "split-active-pane",
|
|
1446
|
+
paneId: sourcePaneId,
|
|
1447
|
+
direction
|
|
1448
|
+
});
|
|
1449
|
+
const pane2 = paneManager.splitActivePane(direction);
|
|
1450
|
+
hooks.runLifecycleHooks({
|
|
1451
|
+
phase: "after",
|
|
1452
|
+
action: "split-active-pane",
|
|
1453
|
+
sourcePaneId: sourcePaneId ?? undefined,
|
|
1454
|
+
createdPaneId: pane2?.id ?? null,
|
|
1455
|
+
direction,
|
|
1456
|
+
ok: !!pane2
|
|
1457
|
+
});
|
|
1458
|
+
return pane2;
|
|
1459
|
+
}
|
|
1460
|
+
function splitPane(paneManager, hooks, id, direction) {
|
|
1461
|
+
hooks.runLifecycleHooks({
|
|
1462
|
+
phase: "before",
|
|
1463
|
+
action: "split-pane",
|
|
1464
|
+
paneId: id,
|
|
1465
|
+
direction
|
|
1466
|
+
});
|
|
1467
|
+
const pane2 = paneManager.splitPane(id, direction);
|
|
1468
|
+
hooks.runLifecycleHooks({
|
|
1469
|
+
phase: "after",
|
|
1470
|
+
action: "split-pane",
|
|
1471
|
+
sourcePaneId: id,
|
|
1472
|
+
createdPaneId: pane2?.id ?? null,
|
|
1473
|
+
direction,
|
|
1474
|
+
ok: !!pane2
|
|
1475
|
+
});
|
|
1476
|
+
return pane2;
|
|
1477
|
+
}
|
|
1478
|
+
function closePane(paneManager, hooks, id) {
|
|
1479
|
+
hooks.runLifecycleHooks({ phase: "before", action: "close-pane", paneId: id });
|
|
1480
|
+
const ok = paneManager.closePane(id);
|
|
1481
|
+
hooks.runLifecycleHooks({
|
|
1482
|
+
phase: "after",
|
|
1483
|
+
action: "close-pane",
|
|
1484
|
+
paneId: id,
|
|
1485
|
+
ok
|
|
1486
|
+
});
|
|
1487
|
+
return ok;
|
|
1488
|
+
}
|
|
1489
|
+
function setActivePane(paneManager, lookup, hooks, id, options) {
|
|
1490
|
+
hooks.runLifecycleHooks({
|
|
1491
|
+
phase: "before",
|
|
1492
|
+
action: "set-active-pane",
|
|
1493
|
+
paneId: id
|
|
1494
|
+
});
|
|
1495
|
+
paneManager.setActivePane(id, options);
|
|
1496
|
+
const activePaneId = lookup.getActivePane()?.id ?? null;
|
|
1497
|
+
hooks.runLifecycleHooks({
|
|
1498
|
+
phase: "after",
|
|
1499
|
+
action: "set-active-pane",
|
|
1500
|
+
paneId: activePaneId,
|
|
1501
|
+
ok: activePaneId === id
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
function markPaneFocused(paneManager, lookup, hooks, id, options) {
|
|
1505
|
+
hooks.runLifecycleHooks({
|
|
1506
|
+
phase: "before",
|
|
1507
|
+
action: "mark-pane-focused",
|
|
1508
|
+
paneId: id
|
|
1509
|
+
});
|
|
1510
|
+
paneManager.markPaneFocused(id, options);
|
|
1511
|
+
const focusedPaneId = lookup.getFocusedPane()?.id ?? null;
|
|
1512
|
+
hooks.runLifecycleHooks({
|
|
1513
|
+
phase: "after",
|
|
1514
|
+
action: "mark-pane-focused",
|
|
1515
|
+
paneId: focusedPaneId,
|
|
1516
|
+
ok: focusedPaneId === id
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
function connectPty(lookup, hooks, url = "") {
|
|
1520
|
+
const pane2 = requireActivePaneHandle(lookup);
|
|
1521
|
+
hooks.runLifecycleHooks({
|
|
1522
|
+
phase: "before",
|
|
1523
|
+
action: "connect-pty",
|
|
1524
|
+
paneId: pane2.id
|
|
1525
|
+
});
|
|
1526
|
+
pane2.connectPty(url);
|
|
1527
|
+
hooks.runLifecycleHooks({
|
|
1528
|
+
phase: "after",
|
|
1529
|
+
action: "connect-pty",
|
|
1530
|
+
paneId: pane2.id,
|
|
1531
|
+
ok: true
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
function disconnectPty(lookup, hooks) {
|
|
1535
|
+
const pane2 = requireActivePaneHandle(lookup);
|
|
1536
|
+
hooks.runLifecycleHooks({
|
|
1537
|
+
phase: "before",
|
|
1538
|
+
action: "disconnect-pty",
|
|
1539
|
+
paneId: pane2.id
|
|
1540
|
+
});
|
|
1541
|
+
pane2.disconnectPty();
|
|
1542
|
+
hooks.runLifecycleHooks({
|
|
1543
|
+
phase: "after",
|
|
1544
|
+
action: "disconnect-pty",
|
|
1545
|
+
paneId: pane2.id,
|
|
1546
|
+
ok: true
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1549
|
+
function resize(lookup, hooks, cols, rows) {
|
|
1550
|
+
const pane2 = requireActivePaneHandle(lookup);
|
|
1551
|
+
hooks.runLifecycleHooks({
|
|
1552
|
+
phase: "before",
|
|
1553
|
+
action: "resize",
|
|
1554
|
+
paneId: pane2.id,
|
|
1555
|
+
cols,
|
|
1556
|
+
rows
|
|
1557
|
+
});
|
|
1558
|
+
pane2.resize(cols, rows);
|
|
1559
|
+
hooks.runLifecycleHooks({
|
|
1560
|
+
phase: "after",
|
|
1561
|
+
action: "resize",
|
|
1562
|
+
paneId: pane2.id,
|
|
1563
|
+
cols,
|
|
1564
|
+
rows,
|
|
1565
|
+
ok: true
|
|
1566
|
+
});
|
|
1567
|
+
hooks.emitPluginEvent("pane:resized", { paneId: pane2.id, cols, rows });
|
|
1568
|
+
}
|
|
1569
|
+
function focus(lookup, hooks) {
|
|
1570
|
+
const pane2 = requireActivePaneHandle(lookup);
|
|
1571
|
+
hooks.runLifecycleHooks({
|
|
1572
|
+
phase: "before",
|
|
1573
|
+
action: "focus",
|
|
1574
|
+
paneId: pane2.id
|
|
1575
|
+
});
|
|
1576
|
+
pane2.focus();
|
|
1577
|
+
hooks.runLifecycleHooks({
|
|
1578
|
+
phase: "after",
|
|
1579
|
+
action: "focus",
|
|
1580
|
+
paneId: pane2.id,
|
|
1581
|
+
ok: true
|
|
1582
|
+
});
|
|
1583
|
+
hooks.emitPluginEvent("pane:focused", { paneId: pane2.id });
|
|
1584
|
+
}
|
|
1585
|
+
function blur(lookup, hooks) {
|
|
1586
|
+
const pane2 = requireActivePaneHandle(lookup);
|
|
1587
|
+
hooks.runLifecycleHooks({
|
|
1588
|
+
phase: "before",
|
|
1589
|
+
action: "blur",
|
|
1590
|
+
paneId: pane2.id
|
|
1591
|
+
});
|
|
1592
|
+
pane2.blur();
|
|
1593
|
+
hooks.runLifecycleHooks({
|
|
1594
|
+
phase: "after",
|
|
1595
|
+
action: "blur",
|
|
1596
|
+
paneId: pane2.id,
|
|
1597
|
+
ok: true
|
|
1598
|
+
});
|
|
1599
|
+
hooks.emitPluginEvent("pane:blurred", { paneId: pane2.id });
|
|
1600
|
+
}
|
|
1601
|
+
// src/surface/restty/pane-style-ops.ts
|
|
1602
|
+
function getPaneStyleOptions(paneManager) {
|
|
1603
|
+
return paneManager.getStyleOptions();
|
|
1604
|
+
}
|
|
1605
|
+
function setPaneStyleOptions(paneManager, options) {
|
|
1606
|
+
paneManager.setStyleOptions(options);
|
|
1607
|
+
}
|
|
1608
|
+
function getSearchUiStyleOptions(paneManager) {
|
|
1609
|
+
return paneManager.getSearchUiStyleOptions();
|
|
1610
|
+
}
|
|
1611
|
+
function setSearchUiStyleOptions(paneManager, options) {
|
|
1612
|
+
paneManager.setSearchUiStyleOptions(options);
|
|
1613
|
+
}
|
|
1614
|
+
// src/surface/restty.ts
|
|
1615
|
+
class Restty extends ResttyActivePaneApi {
|
|
1616
|
+
paneManager;
|
|
1617
|
+
fonts;
|
|
1618
|
+
shaderOps;
|
|
1619
|
+
controller;
|
|
1620
|
+
paneLookupOps;
|
|
1621
|
+
constructor(options) {
|
|
1622
|
+
super();
|
|
1623
|
+
this.fonts = undefined;
|
|
1624
|
+
const { shaderOps, controller, paneManager, createInitialPane: createInitialPane2 } = bootstrapResttySurface({
|
|
1625
|
+
restty: this,
|
|
1626
|
+
forEachPane: (visitor) => {
|
|
1627
|
+
this.forEachPane(visitor);
|
|
1628
|
+
},
|
|
1629
|
+
getPaneHandleById: (id) => this.pane(id),
|
|
1630
|
+
getFonts: () => this.fonts,
|
|
1631
|
+
options
|
|
1632
|
+
});
|
|
1633
|
+
this.shaderOps = shaderOps;
|
|
1634
|
+
this.controller = controller;
|
|
1635
|
+
this.paneManager = paneManager;
|
|
1636
|
+
this.paneLookupOps = createResttyPaneLookup({
|
|
1637
|
+
paneManager: this.paneManager,
|
|
1638
|
+
getPanes: () => this.getPanes(),
|
|
1639
|
+
getPaneById: (id) => this.getPaneById(id),
|
|
1640
|
+
getActivePane: () => this.getActivePane(),
|
|
1641
|
+
getFocusedPane: () => this.getFocusedPane()
|
|
1642
|
+
});
|
|
1643
|
+
if (createInitialPane2) {
|
|
1644
|
+
const focus2 = typeof createInitialPane2 === "object" ? createInitialPane2.focus ?? true : true;
|
|
1645
|
+
this.createInitialPane({ focus: focus2 });
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
getPanes() {
|
|
1649
|
+
return this.paneManager.getPanes();
|
|
1650
|
+
}
|
|
1651
|
+
getPaneById(id) {
|
|
1652
|
+
return this.paneManager.getPaneById(id);
|
|
1653
|
+
}
|
|
1654
|
+
getActivePane() {
|
|
1655
|
+
return this.paneManager.getActivePane();
|
|
1656
|
+
}
|
|
1657
|
+
getFocusedPane() {
|
|
1658
|
+
return this.paneManager.getFocusedPane();
|
|
1659
|
+
}
|
|
1660
|
+
panes() {
|
|
1661
|
+
return panes(this.paneLookupOps);
|
|
1662
|
+
}
|
|
1663
|
+
pane(id) {
|
|
1664
|
+
return pane(this.paneLookupOps, id);
|
|
1665
|
+
}
|
|
1666
|
+
activePane() {
|
|
1667
|
+
return activePane(this.paneLookupOps);
|
|
1668
|
+
}
|
|
1669
|
+
focusedPane() {
|
|
1670
|
+
return focusedPane(this.paneLookupOps);
|
|
1671
|
+
}
|
|
1672
|
+
forEachPane(visitor) {
|
|
1673
|
+
forEachPane(this.paneLookupOps, visitor);
|
|
1674
|
+
}
|
|
1675
|
+
async setFonts(fonts) {
|
|
1676
|
+
this.fonts = [...fonts];
|
|
1677
|
+
const updates = [];
|
|
1678
|
+
this.forEachPane((pane2) => {
|
|
1679
|
+
updates.push(pane2.setFonts(this.fonts ?? []));
|
|
1680
|
+
});
|
|
1681
|
+
await Promise.all(updates);
|
|
1682
|
+
}
|
|
1683
|
+
setShaderStages(stages) {
|
|
1684
|
+
this.shaderOps.setShaderStages(stages);
|
|
1685
|
+
}
|
|
1686
|
+
getShaderStages() {
|
|
1687
|
+
return this.shaderOps.getShaderStages();
|
|
1688
|
+
}
|
|
1689
|
+
addShaderStage(stage) {
|
|
1690
|
+
return this.shaderOps.addShaderStage(stage);
|
|
1691
|
+
}
|
|
1692
|
+
removeShaderStage(id) {
|
|
1693
|
+
return this.shaderOps.removeShaderStage(id);
|
|
1694
|
+
}
|
|
1695
|
+
createInitialPane(options) {
|
|
1696
|
+
return createInitialPane(this.paneManager, this.controller.lifecycleHooks, options);
|
|
1697
|
+
}
|
|
1698
|
+
splitActivePane(direction) {
|
|
1699
|
+
return splitActivePane(this.paneManager, this.paneLookupOps, this.controller.lifecycleHooks, direction);
|
|
1700
|
+
}
|
|
1701
|
+
splitPane(id, direction) {
|
|
1702
|
+
return splitPane(this.paneManager, this.controller.lifecycleHooks, id, direction);
|
|
1703
|
+
}
|
|
1704
|
+
closePane(id) {
|
|
1705
|
+
return closePane(this.paneManager, this.controller.lifecycleHooks, id);
|
|
1706
|
+
}
|
|
1707
|
+
getPaneStyleOptions() {
|
|
1708
|
+
return getPaneStyleOptions(this.paneManager);
|
|
1709
|
+
}
|
|
1710
|
+
setPaneStyleOptions(options) {
|
|
1711
|
+
setPaneStyleOptions(this.paneManager, options);
|
|
1712
|
+
}
|
|
1713
|
+
getSearchUiStyleOptions() {
|
|
1714
|
+
return getSearchUiStyleOptions(this.paneManager);
|
|
1715
|
+
}
|
|
1716
|
+
setSearchUiStyleOptions(options) {
|
|
1717
|
+
setSearchUiStyleOptions(this.paneManager, options);
|
|
1718
|
+
}
|
|
1719
|
+
setActivePane(id, options) {
|
|
1720
|
+
setActivePane(this.paneManager, this.paneLookupOps, this.controller.lifecycleHooks, id, options);
|
|
1721
|
+
}
|
|
1722
|
+
markPaneFocused(id, options) {
|
|
1723
|
+
markPaneFocused(this.paneManager, this.paneLookupOps, this.controller.lifecycleHooks, id, options);
|
|
1724
|
+
}
|
|
1725
|
+
requestLayoutSync() {
|
|
1726
|
+
this.paneManager.requestLayoutSync();
|
|
1727
|
+
}
|
|
1728
|
+
hideContextMenu() {
|
|
1729
|
+
this.paneManager.hideContextMenu();
|
|
1730
|
+
}
|
|
1731
|
+
async use(plugin, options) {
|
|
1732
|
+
await this.controller.use(plugin, options);
|
|
1733
|
+
}
|
|
1734
|
+
async loadPlugins(manifest, registry) {
|
|
1735
|
+
return this.controller.loadPlugins(manifest, registry);
|
|
1736
|
+
}
|
|
1737
|
+
unuse(pluginId) {
|
|
1738
|
+
return this.controller.unuse(pluginId);
|
|
1739
|
+
}
|
|
1740
|
+
plugins() {
|
|
1741
|
+
return this.controller.plugins();
|
|
1742
|
+
}
|
|
1743
|
+
pluginInfo(pluginId) {
|
|
1744
|
+
if (typeof pluginId === "string")
|
|
1745
|
+
return this.controller.pluginInfo(pluginId);
|
|
1746
|
+
return this.controller.pluginInfo();
|
|
1747
|
+
}
|
|
1748
|
+
destroy() {
|
|
1749
|
+
this.controller.destroy();
|
|
1750
|
+
this.shaderOps.clear();
|
|
1751
|
+
this.paneManager.destroy();
|
|
1752
|
+
}
|
|
1753
|
+
connectPty(url = "") {
|
|
1754
|
+
connectPty(this.paneLookupOps, this.controller.lifecycleHooks, url);
|
|
1755
|
+
}
|
|
1756
|
+
disconnectPty() {
|
|
1757
|
+
disconnectPty(this.paneLookupOps, this.controller.lifecycleHooks);
|
|
1758
|
+
}
|
|
1759
|
+
resize(cols, rows) {
|
|
1760
|
+
resize(this.paneLookupOps, this.controller.lifecycleAndPluginHooks, cols, rows);
|
|
1761
|
+
}
|
|
1762
|
+
focus() {
|
|
1763
|
+
focus(this.paneLookupOps, this.controller.lifecycleAndPluginHooks);
|
|
1764
|
+
}
|
|
1765
|
+
blur() {
|
|
1766
|
+
blur(this.paneLookupOps, this.controller.lifecycleAndPluginHooks);
|
|
1767
|
+
}
|
|
1768
|
+
requireActivePaneHandle() {
|
|
1769
|
+
return requireActivePaneHandle(this.paneLookupOps);
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
function createRestty(options) {
|
|
1773
|
+
return new Restty(options);
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
export { RESTTY_PLUGIN_API_VERSION, ResttyPaneHandle, Restty, createRestty };
|