bitpull 0.1.23 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +2 -1
  2. package/bitpull.cjs +11701 -10690
  3. package/package.json +3 -2
  4. package/ui/ide-terminal.js +57 -0
  5. package/ui/ide.css +271 -0
  6. package/ui/ide.html +178 -0
  7. package/ui/ide.js +1336 -0
  8. package/ui/monaco/vs/abap-D-t0cyap.js +1 -0
  9. package/ui/monaco/vs/apex-CcIm7xu6.js +1 -0
  10. package/ui/monaco/vs/assets/css.worker-BpD9FCKP.js +97 -0
  11. package/ui/monaco/vs/assets/editor.worker-_vAIFJDs.js +30 -0
  12. package/ui/monaco/vs/assets/editorWebWorkerMain-DEgFqX2K.js +30 -0
  13. package/ui/monaco/vs/assets/html.worker-CLuInTTy.js +474 -0
  14. package/ui/monaco/vs/assets/json.worker-Csf_TLih.js +62 -0
  15. package/ui/monaco/vs/assets/ts.worker-g3pjEjl4.js +67722 -0
  16. package/ui/monaco/vs/azcli-BA0tQDCg.js +1 -0
  17. package/ui/monaco/vs/basic-languages/monaco.contribution.js +1 -0
  18. package/ui/monaco/vs/bat-C397hTD6.js +1 -0
  19. package/ui/monaco/vs/bicep-DF5aW17k.js +2 -0
  20. package/ui/monaco/vs/cameligo-plsz8qhj.js +1 -0
  21. package/ui/monaco/vs/clojure-Y2auQMzK.js +1 -0
  22. package/ui/monaco/vs/coffee-Bu45yuWE.js +1 -0
  23. package/ui/monaco/vs/cpp-CkKPQIni.js +1 -0
  24. package/ui/monaco/vs/csharp-CX28MZyh.js +1 -0
  25. package/ui/monaco/vs/csp-D8uWnyxW.js +1 -0
  26. package/ui/monaco/vs/css-CaeNmE3S.js +3 -0
  27. package/ui/monaco/vs/css.worker-BInK4lsP.js +1 -0
  28. package/ui/monaco/vs/cssMode-eIUIN_ru.js +1 -0
  29. package/ui/monaco/vs/cypher-DVThT8BS.js +1 -0
  30. package/ui/monaco/vs/dart-CmGfCvrO.js +1 -0
  31. package/ui/monaco/vs/dockerfile-CZqqYdch.js +1 -0
  32. package/ui/monaco/vs/ecl-30fUercY.js +1 -0
  33. package/ui/monaco/vs/editor/editor.main.css +1 -0
  34. package/ui/monaco/vs/editor/editor.main.js +1 -0
  35. package/ui/monaco/vs/editor/editor.worker.js +1 -0
  36. package/ui/monaco/vs/editor-BdtEMBbM.js +892 -0
  37. package/ui/monaco/vs/editor.js +1 -0
  38. package/ui/monaco/vs/editorWorkerHost-B_VpI68A.js +35 -0
  39. package/ui/monaco/vs/elixir-xjPaIfzF.js +1 -0
  40. package/ui/monaco/vs/flow9-DqtmStfK.js +1 -0
  41. package/ui/monaco/vs/freemarker2-B-FhRNBn.js +3 -0
  42. package/ui/monaco/vs/fsharp-BOMdg4U1.js +1 -0
  43. package/ui/monaco/vs/go-D_hbi-Jt.js +1 -0
  44. package/ui/monaco/vs/graphql-CKUU4kLG.js +1 -0
  45. package/ui/monaco/vs/handlebars-BJBfNnbX.js +1 -0
  46. package/ui/monaco/vs/hcl-DTaboeZW.js +1 -0
  47. package/ui/monaco/vs/html-BTio3wpy.js +1 -0
  48. package/ui/monaco/vs/html.worker-C1TNvQ72.js +1 -0
  49. package/ui/monaco/vs/htmlMode-aw5QYZo7.js +1 -0
  50. package/ui/monaco/vs/index-049xrXrp.js +1 -0
  51. package/ui/monaco/vs/index-DZH_zysX.js +5 -0
  52. package/ui/monaco/vs/index.js +1 -0
  53. package/ui/monaco/vs/ini-CsNwO04R.js +1 -0
  54. package/ui/monaco/vs/initialize-CAIC7-3s.js +1 -0
  55. package/ui/monaco/vs/java-CI4ZMsH9.js +1 -0
  56. package/ui/monaco/vs/javascript-B_IYblwB.js +1 -0
  57. package/ui/monaco/vs/json.worker-Bp7U0-9w.js +1 -0
  58. package/ui/monaco/vs/jsonMode-w7Q_ZLTt.js +1 -0
  59. package/ui/monaco/vs/julia-BwzEvaQw.js +1 -0
  60. package/ui/monaco/vs/kotlin-IUYPiTV8.js +1 -0
  61. package/ui/monaco/vs/less-C0eDYdqa.js +2 -0
  62. package/ui/monaco/vs/lexon-iON-Kj97.js +1 -0
  63. package/ui/monaco/vs/liquid-CXh4HpyA.js +1 -0
  64. package/ui/monaco/vs/loader.js +1368 -0
  65. package/ui/monaco/vs/lspLanguageFeatures-Cog3rVVE.js +2 -0
  66. package/ui/monaco/vs/lua-DtygF91M.js +1 -0
  67. package/ui/monaco/vs/m3-CsR4AuFi.js +1 -0
  68. package/ui/monaco/vs/main-BEx-Fmlo.js +15 -0
  69. package/ui/monaco/vs/main-DsK8pnKg.js +3 -0
  70. package/ui/monaco/vs/markdown-C_rD0bIw.js +1 -0
  71. package/ui/monaco/vs/mdx-BcFcCtz9.js +1 -0
  72. package/ui/monaco/vs/mips-CiYP61RB.js +1 -0
  73. package/ui/monaco/vs/monaco.contribution-BuX2NvO2.js +1 -0
  74. package/ui/monaco/vs/monaco.contribution-C7tY_xnl.js +1 -0
  75. package/ui/monaco/vs/monaco.contribution-CY2lwFI8.js +1 -0
  76. package/ui/monaco/vs/monaco.contribution-D1-wBxcq.js +1 -0
  77. package/ui/monaco/vs/msdax-C38-sJlp.js +1 -0
  78. package/ui/monaco/vs/mysql-CdtbpvbG.js +1 -0
  79. package/ui/monaco/vs/nls/lang/de.js +9 -0
  80. package/ui/monaco/vs/nls/lang/es.js +9 -0
  81. package/ui/monaco/vs/nls/lang/fr.js +9 -0
  82. package/ui/monaco/vs/nls/lang/it.js +9 -0
  83. package/ui/monaco/vs/nls/lang/pt-br.js +9 -0
  84. package/ui/monaco/vs/nls/lang/ru.js +9 -0
  85. package/ui/monaco/vs/nls/lang/zh-cn.js +9 -0
  86. package/ui/monaco/vs/nls.messages-loader.js +1 -0
  87. package/ui/monaco/vs/objective-c-CntZFaHX.js +1 -0
  88. package/ui/monaco/vs/pascal-r6kuqfl_.js +1 -0
  89. package/ui/monaco/vs/pascaligo-BiXoTmXh.js +1 -0
  90. package/ui/monaco/vs/perl-DABw_TcH.js +1 -0
  91. package/ui/monaco/vs/pgsql-me_jFXeX.js +1 -0
  92. package/ui/monaco/vs/php-D_kh-9LK.js +1 -0
  93. package/ui/monaco/vs/pla-VfZjczW0.js +1 -0
  94. package/ui/monaco/vs/postiats-BBSzz8Pk.js +1 -0
  95. package/ui/monaco/vs/powerquery-Dt-g_2cc.js +1 -0
  96. package/ui/monaco/vs/powershell-B-7ap1zc.js +1 -0
  97. package/ui/monaco/vs/protobuf-BmtuEB1A.js +2 -0
  98. package/ui/monaco/vs/pug-BRpRNeEb.js +1 -0
  99. package/ui/monaco/vs/python-CasA8BlK.js +1 -0
  100. package/ui/monaco/vs/qsharp-BzsFaUU9.js +1 -0
  101. package/ui/monaco/vs/r-f8dDdrp4.js +1 -0
  102. package/ui/monaco/vs/razor-IGOwKAHu.js +1 -0
  103. package/ui/monaco/vs/redis-fvZQY4PI.js +1 -0
  104. package/ui/monaco/vs/redshift-45Et0LQi.js +1 -0
  105. package/ui/monaco/vs/restructuredtext-C7UUFKFD.js +1 -0
  106. package/ui/monaco/vs/ruby-CZO8zYTz.js +1 -0
  107. package/ui/monaco/vs/rust-Bfetafyc.js +1 -0
  108. package/ui/monaco/vs/sb-3GYllVck.js +1 -0
  109. package/ui/monaco/vs/scala-foMgrKo1.js +1 -0
  110. package/ui/monaco/vs/scheme-CHdMtr7p.js +1 -0
  111. package/ui/monaco/vs/scss-C1cmLt9V.js +3 -0
  112. package/ui/monaco/vs/shell-ClXCKCEW.js +1 -0
  113. package/ui/monaco/vs/solidity-MZ6ExpPy.js +1 -0
  114. package/ui/monaco/vs/sophia-DWkuSsPQ.js +1 -0
  115. package/ui/monaco/vs/sparql-AUGFYSyk.js +1 -0
  116. package/ui/monaco/vs/sql-32GpJSV2.js +1 -0
  117. package/ui/monaco/vs/st-CuDFIVZ_.js +1 -0
  118. package/ui/monaco/vs/swift-t-PfMj7W.js +1 -0
  119. package/ui/monaco/vs/systemverilog-Ch4vA8Yt.js +1 -0
  120. package/ui/monaco/vs/tcl-D74tq1nH.js +1 -0
  121. package/ui/monaco/vs/toggleHighContrast-DuqAmExZ.js +65 -0
  122. package/ui/monaco/vs/ts.worker-BLYAhMkX.js +1 -0
  123. package/ui/monaco/vs/tsMode-DB1GiNun.js +11 -0
  124. package/ui/monaco/vs/twig-C6taOxMV.js +1 -0
  125. package/ui/monaco/vs/typescript-BTLNeq8B.js +1 -0
  126. package/ui/monaco/vs/typespec-8OfoLt6R.js +1 -0
  127. package/ui/monaco/vs/vb-Dyb2648j.js +1 -0
  128. package/ui/monaco/vs/wgsl-BhLXMOR0.js +298 -0
  129. package/ui/monaco/vs/workers-BeMslOxK.js +1 -0
  130. package/ui/monaco/vs/xml-DHCggo_L.js +1 -0
  131. package/ui/monaco/vs/yaml-C-RIivnc.js +1 -0
  132. package/ui/terminal.js +328 -0
  133. package/ui/vendor/addon-fit.mjs +18 -0
  134. package/ui/vendor/xterm.css +285 -0
  135. package/ui/vendor/xterm.mjs +53 -0
package/ui/terminal.js ADDED
@@ -0,0 +1,328 @@
1
+ // The person's own terminal in the dashboard: real shells on this computer, in tabs and split panes.
2
+ // What an agent runs is shown in its own read-only tab: it never types in the person's shells.
3
+ //
4
+ // const term = mountTerminal(el, { cwd, token, t });
5
+ // term.newTab(); term.split(); term.close(); term.runVisible("npm test");
6
+ //
7
+ // The server refuses anything but this page, on 127.0.0.1, with the dashboard's token.
8
+ import { Terminal } from "./vendor/xterm.mjs";
9
+ import { FitAddon } from "./vendor/addon-fit.mjs";
10
+
11
+ const MAX_INPUT = 200 * 1024;
12
+ let cssAdded = false;
13
+
14
+ function addCss() {
15
+ if (cssAdded) return;
16
+ cssAdded = true;
17
+ const link = document.createElement("link");
18
+ link.rel = "stylesheet";
19
+ link.href = new URL("./vendor/xterm.css", import.meta.url).href;
20
+ document.head.appendChild(link);
21
+ const style = document.createElement("style");
22
+ style.textContent = `
23
+ .bp-term { display:flex; flex-direction:column; height:100%; min-height:160px; background:var(--surface,#1e1e1c); color:var(--text,#ecebe6); }
24
+ .bp-term-bar { display:flex; align-items:center; gap:4px; padding:4px 6px; border-bottom:1px solid var(--line,#33322f); overflow-x:auto; }
25
+ .bp-term-bar .bp-tabs { display:flex; gap:2px; flex:1; min-width:0; }
26
+ .bp-term-bar button { background:transparent; color:var(--muted,#a2a19b); border:1px solid transparent; border-radius:6px; padding:3px 9px; font:inherit; font-size:12.5px; cursor:pointer; white-space:nowrap; }
27
+ .bp-term-bar button.on, .bp-term-bar button:hover { color:var(--text,#ecebe6); border-color:var(--line,#33322f); }
28
+ .bp-term-panes { flex:1; display:flex; min-height:0; }
29
+ .bp-term-pane { flex:1; min-width:0; padding:4px 0 0 6px; }
30
+ .bp-term-pane + .bp-term-pane { border-inline-start:1px solid var(--line,#33322f); }
31
+ .bp-term-msg { padding:14px; font-size:13px; color:var(--muted,#a2a19b); }
32
+ .bp-term-msg button { margin-top:8px; }
33
+ .bp-term-pane .xterm { height:100%; direction:ltr; }`;
34
+ document.head.appendChild(style);
35
+ }
36
+
37
+ function theme() {
38
+ const css = getComputedStyle(document.documentElement);
39
+ const v = (name, fallback) => css.getPropertyValue(name).trim() || fallback;
40
+ return { background: v("--surface", "#1e1e1c"), foreground: v("--text", "#ecebe6"), cursor: v("--accent", "#7c9cf2"), selectionBackground: "#7c9cf255" };
41
+ }
42
+
43
+ async function call(token, path, body) {
44
+ const res = await fetch(path, { method: body ? "POST" : "GET", headers: { "content-type": "application/json", "x-bitpull-token": token || "" }, body: body ? JSON.stringify(body) : undefined });
45
+ const data = await res.json().catch(() => ({}));
46
+ if (!res.ok) throw new Error(data.error || String(res.status));
47
+ return data;
48
+ }
49
+
50
+ /** Whether the terminal is on, and whether this computer has the component it needs. */
51
+ export const terminalStatus = (token) => call(token, "/api/terminal");
52
+ export const setTerminalEnabled = (token, enabled) => call(token, "/api/terminal/settings", { enabled });
53
+
54
+ /** The switch for the settings: off by default, with what turning it on means. */
55
+ export function mountTerminalSetting(el, { token, t = (k) => k, onChange } = {}) {
56
+ const render = (s) => {
57
+ el.replaceChildren();
58
+ const label = document.createElement("label");
59
+ const name = document.createElement("span");
60
+ name.textContent = t("term.setting");
61
+ const box = document.createElement("input");
62
+ box.type = "checkbox";
63
+ box.checked = !!s.enabled;
64
+ box.disabled = !s.available;
65
+ box.dataset.tip = "tip.term.setting";
66
+ label.append(name, " ", box);
67
+ const help = document.createElement("p");
68
+ help.className = "help";
69
+ help.textContent = s.available ? t("term.setting.hint") : t("term.unavailable");
70
+ el.append(label, help);
71
+ box.addEventListener("change", async () => {
72
+ box.disabled = true;
73
+ try {
74
+ const r = await setTerminalEnabled(token, box.checked);
75
+ onChange && onChange(r.enabled);
76
+ render({ ...s, enabled: r.enabled });
77
+ } catch {
78
+ box.checked = !box.checked;
79
+ box.disabled = false;
80
+ }
81
+ });
82
+ };
83
+ terminalStatus(token).then(render, () => render({ enabled: false, available: false }));
84
+ }
85
+
86
+ /**
87
+ * Mounts the terminal in `el`. `cwd` must be a folder the person authorised; `t` translates.
88
+ * Returns the controls the page and the Projects view use.
89
+ */
90
+ export function mountTerminal(el, { cwd, token, t = (k) => k } = {}) {
91
+ const ended = (code) => String(t("term.exited", { code })).replace("{code}", String(code));
92
+ addCss();
93
+ el.replaceChildren();
94
+ const root = document.createElement("div");
95
+ root.className = "bp-term";
96
+ const bar = document.createElement("div");
97
+ bar.className = "bp-term-bar";
98
+ const tabsEl = document.createElement("div");
99
+ tabsEl.className = "bp-tabs";
100
+ const button = (key, tip, fn) => {
101
+ const b = document.createElement("button");
102
+ b.type = "button";
103
+ b.textContent = t(key);
104
+ b.dataset.tip = tip;
105
+ b.dataset.action = key;
106
+ b.addEventListener("click", fn);
107
+ return b;
108
+ };
109
+ const panesEl = document.createElement("div");
110
+ panesEl.className = "bp-term-panes";
111
+ root.append(bar, panesEl);
112
+ el.appendChild(root);
113
+
114
+ const tabs = []; // { title, panes: [{ term, fit, id?, box, readonly }] }
115
+ let active = null;
116
+ let ws = null;
117
+ let ready = false;
118
+ let disposed = false;
119
+ const waiting = new Map();
120
+ let nextRef = 1;
121
+ const byId = new Map();
122
+
123
+ const message = (key, withEnable) => {
124
+ panesEl.replaceChildren();
125
+ const m = document.createElement("div");
126
+ m.className = "bp-term-msg";
127
+ m.textContent = t(key);
128
+ if (withEnable) {
129
+ const on = button("term.enable", "tip.term.enable", async () => {
130
+ try {
131
+ await setTerminalEnabled(token, true);
132
+ connect();
133
+ newTab();
134
+ } catch {
135
+ /* the switch stays off */
136
+ }
137
+ });
138
+ m.append(document.createElement("br"), on);
139
+ }
140
+ panesEl.appendChild(m);
141
+ };
142
+
143
+ const renderTabs = () => {
144
+ tabsEl.replaceChildren(
145
+ ...tabs.map((tab, i) => {
146
+ const b = button(tab.title, "tip.term.tab", () => show(tab));
147
+ b.textContent = tab.title || `${t("term.title")} ${i + 1}`;
148
+ if (tab === active) b.classList.add("on");
149
+ return b;
150
+ }),
151
+ );
152
+ };
153
+
154
+ const fitAll = () => {
155
+ if (!active) return;
156
+ for (const p of active.panes) {
157
+ try {
158
+ p.fit.fit();
159
+ } catch {
160
+ /* hidden */
161
+ }
162
+ if (p.id && ready) ws.send(JSON.stringify({ t: "resize", id: p.id, cols: p.term.cols, rows: p.term.rows }));
163
+ }
164
+ };
165
+
166
+ const show = (tab) => {
167
+ active = tab;
168
+ panesEl.replaceChildren(...tab.panes.map((p) => p.box));
169
+ renderTabs();
170
+ requestAnimationFrame(fitAll);
171
+ tab.panes[tab.panes.length - 1]?.term.focus();
172
+ };
173
+
174
+ const makePane = (readonly) => {
175
+ const box = document.createElement("div");
176
+ box.className = "bp-term-pane";
177
+ const term = new Terminal({ cursorBlink: !readonly, disableStdin: readonly, fontSize: 13, fontFamily: "ui-monospace, Menlo, Consolas, monospace", theme: theme(), scrollback: 5000, convertEol: readonly });
178
+ const fit = new FitAddon();
179
+ term.loadAddon(fit);
180
+ term.open(box);
181
+ return { term, fit, box, readonly };
182
+ };
183
+
184
+ const startShell = (pane) => {
185
+ pane.ref = nextRef++;
186
+ pane.go = () => ws.send(JSON.stringify({ t: "open", ref: pane.ref, cwd, cols: pane.term.cols, rows: pane.term.rows }));
187
+ waiting.set(pane.ref, pane);
188
+ if (ready) pane.go();
189
+ pane.term.onData((d) => {
190
+ if (!pane.id || !ready) return;
191
+ // Huge pastes go in pieces: a message has a size limit.
192
+ for (let i = 0; i < d.length; i += MAX_INPUT) ws.send(JSON.stringify({ t: "in", id: pane.id, d: d.slice(i, i + MAX_INPUT) }));
193
+ });
194
+ };
195
+
196
+ const connect = () => {
197
+ if (ws && ws.readyState <= 1) return;
198
+ ready = false;
199
+ ws = new WebSocket(`${location.protocol === "https:" ? "wss" : "ws"}://${location.host}/api/terminal`);
200
+ ws.onopen = () => ws.send(JSON.stringify({ t: "auth", token }));
201
+ ws.onmessage = (e) => {
202
+ let m;
203
+ try {
204
+ m = JSON.parse(e.data);
205
+ } catch {
206
+ return;
207
+ }
208
+ if (m.t === "ready") {
209
+ ready = true;
210
+ for (const p of waiting.values()) p.go();
211
+ } else if (m.t === "opened") {
212
+ const p = waiting.get(m.ref);
213
+ if (!p) return;
214
+ waiting.delete(m.ref);
215
+ p.id = m.id;
216
+ byId.set(m.id, p);
217
+ fitAll();
218
+ } else if (m.t === "out") byId.get(m.id)?.term.write(m.d);
219
+ else if (m.t === "exit") {
220
+ const p = byId.get(m.id);
221
+ if (p) {
222
+ p.term.write(`\r\n\x1b[2m${ended(m.code)}\x1b[0m\r\n`);
223
+ byId.delete(m.id);
224
+ p.id = undefined;
225
+ }
226
+ } else if (m.t === "error") {
227
+ const p = waiting.get(m.ref);
228
+ waiting.delete(m.ref);
229
+ const text = m.error === "folder_not_authorised" ? t("term.folder") : m.error === "too_many_terminals" ? t("term.many") : t("term.failed");
230
+ if (p) p.term.write(`\x1b[31m${text}\x1b[0m\r\n`);
231
+ }
232
+ };
233
+ ws.onclose = (e) => {
234
+ ready = false;
235
+ if (disposed) return;
236
+ if (e.code === 4409 || e.code === 1006) {
237
+ terminalStatus(token).then((s) => {
238
+ if (!s.available) message("term.unavailable", false);
239
+ else if (!s.enabled) message("term.off", true);
240
+ }, () => undefined);
241
+ }
242
+ };
243
+ };
244
+
245
+ function newTab() {
246
+ const pane = makePane(false);
247
+ const tab = { title: "", panes: [pane] };
248
+ tabs.push(tab);
249
+ show(tab);
250
+ startShell(pane);
251
+ return tab;
252
+ }
253
+
254
+ function split() {
255
+ if (!active || active.readonly) return newTab();
256
+ if (active.panes.length >= 2) return active;
257
+ const pane = makePane(false);
258
+ active.panes.push(pane);
259
+ show(active);
260
+ startShell(pane);
261
+ return active;
262
+ }
263
+
264
+ function close() {
265
+ if (!active) return;
266
+ for (const p of active.panes) {
267
+ if (p.id && ready) ws.send(JSON.stringify({ t: "close", id: p.id }));
268
+ byId.delete(p.id);
269
+ p.term.dispose();
270
+ }
271
+ tabs.splice(tabs.indexOf(active), 1);
272
+ if (tabs.length) show(tabs[tabs.length - 1]);
273
+ else {
274
+ active = null;
275
+ panesEl.replaceChildren();
276
+ renderTabs();
277
+ }
278
+ }
279
+
280
+ let agentTab = null;
281
+ /** Shows what an agent runs (approved in Projects): read-only, nothing is typed into a shell. */
282
+ function runVisible(cmd) {
283
+ if (!agentTab || !tabs.includes(agentTab)) {
284
+ const pane = makePane(true);
285
+ agentTab = { title: t("term.agent"), panes: [pane], readonly: true };
286
+ tabs.push(agentTab);
287
+ }
288
+ show(agentTab);
289
+ const term = agentTab.panes[0].term;
290
+ term.write(`\x1b[2m$ ${String(cmd).replace(/[\x00-\x08\x0b-\x1f\x7f]/g, "")}\x1b[0m\r\n`);
291
+ return {
292
+ write: (text) => term.write(String(text)),
293
+ done: (code) => term.write(`\x1b[2m${ended(code)}\x1b[0m\r\n\r\n`),
294
+ };
295
+ }
296
+
297
+ function dispose() {
298
+ disposed = true;
299
+ try {
300
+ ws && ws.close();
301
+ } catch {
302
+ /* closed */
303
+ }
304
+ for (const tab of tabs) for (const p of tab.panes) p.term.dispose();
305
+ resize.disconnect();
306
+ window.removeEventListener("pagehide", dispose);
307
+ el.replaceChildren();
308
+ }
309
+
310
+ bar.append(tabsEl, button("term.new", "tip.term.new", () => newTab()), button("term.split", "tip.term.split", () => split()), button("term.close", "tip.term.close", () => close()));
311
+ const resize = new ResizeObserver(() => fitAll());
312
+ resize.observe(panesEl);
313
+ // Closing the page ends its shells: the server closes them with the connection too.
314
+ window.addEventListener("pagehide", dispose);
315
+
316
+ terminalStatus(token).then(
317
+ (s) => {
318
+ if (disposed) return;
319
+ if (!s.available) return message("term.unavailable", false);
320
+ if (!s.enabled) return message("term.off", true);
321
+ connect();
322
+ newTab();
323
+ },
324
+ () => message("term.failed", false),
325
+ );
326
+
327
+ return { newTab, split, close, runVisible, dispose, fit: fitAll };
328
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ *
5
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
6
+ * @license MIT
7
+ *
8
+ * Originally forked from (with the author's permission):
9
+ * Fabrice Bellard's javascript vt100 for jslinux:
10
+ * http://bellard.org/jslinux/
11
+ * Copyright (c) 2011 Fabrice Bellard
12
+ */
13
+ /*---------------------------------------------------------------------------------------------
14
+ * Copyright (c) Microsoft Corporation. All rights reserved.
15
+ * Licensed under the MIT License. See License.txt in the project root for license information.
16
+ *--------------------------------------------------------------------------------------------*/
17
+ var h=2,_=1,o=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let s=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),l=parseInt(r.getPropertyValue("height")),a=Math.max(0,parseInt(r.getPropertyValue("width"))),i=window.getComputedStyle(this._terminal.element),n={top:parseInt(i.getPropertyValue("padding-top")),bottom:parseInt(i.getPropertyValue("padding-bottom")),right:parseInt(i.getPropertyValue("padding-right")),left:parseInt(i.getPropertyValue("padding-left"))},m=n.top+n.bottom,d=n.right+n.left,c=l-m,p=a-d-s;return{cols:Math.max(h,Math.floor(p/t.css.cell.width)),rows:Math.max(_,Math.floor(c/t.css.cell.height))}}};export{o as FitAddon};
18
+ //# sourceMappingURL=addon-fit.mjs.map
@@ -0,0 +1,285 @@
1
+ /**
2
+ * Copyright (c) 2014 The xterm.js authors. All rights reserved.
3
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
4
+ * https://github.com/chjj/term.js
5
+ * @license MIT
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ * Originally forked from (with the author's permission):
26
+ * Fabrice Bellard's javascript vt100 for jslinux:
27
+ * http://bellard.org/jslinux/
28
+ * Copyright (c) 2011 Fabrice Bellard
29
+ * The original design remains. The terminal itself
30
+ * has been extended to include xterm CSI codes, among
31
+ * other features.
32
+ */
33
+
34
+ /**
35
+ * Default styles for xterm.js
36
+ */
37
+
38
+ .xterm {
39
+ cursor: text;
40
+ position: relative;
41
+ user-select: none;
42
+ -ms-user-select: none;
43
+ -webkit-user-select: none;
44
+ }
45
+
46
+ .xterm.focus,
47
+ .xterm:focus {
48
+ outline: none;
49
+ }
50
+
51
+ .xterm .xterm-helpers {
52
+ position: absolute;
53
+ top: 0;
54
+ /**
55
+ * The z-index of the helpers must be higher than the canvases in order for
56
+ * IMEs to appear on top.
57
+ */
58
+ z-index: 5;
59
+ }
60
+
61
+ .xterm .xterm-helper-textarea {
62
+ padding: 0;
63
+ border: 0;
64
+ margin: 0;
65
+ /* Move textarea out of the screen to the far left, so that the cursor is not visible */
66
+ position: absolute;
67
+ opacity: 0;
68
+ left: -9999em;
69
+ top: 0;
70
+ width: 0;
71
+ height: 0;
72
+ z-index: -5;
73
+ /** Prevent wrapping so the IME appears against the textarea at the correct position */
74
+ white-space: nowrap;
75
+ overflow: hidden;
76
+ resize: none;
77
+ }
78
+
79
+ .xterm .composition-view {
80
+ /* TODO: Composition position got messed up somewhere */
81
+ background: #000;
82
+ color: #FFF;
83
+ display: none;
84
+ position: absolute;
85
+ white-space: nowrap;
86
+ z-index: 1;
87
+ }
88
+
89
+ .xterm .composition-view.active {
90
+ display: block;
91
+ }
92
+
93
+ .xterm .xterm-viewport {
94
+ /* On OS X this is required in order for the scroll bar to appear fully opaque */
95
+ background-color: #000;
96
+ overflow-y: scroll;
97
+ cursor: default;
98
+ position: absolute;
99
+ right: 0;
100
+ left: 0;
101
+ top: 0;
102
+ bottom: 0;
103
+ }
104
+
105
+ .xterm .xterm-screen {
106
+ position: relative;
107
+ }
108
+
109
+ .xterm .xterm-screen canvas {
110
+ position: absolute;
111
+ left: 0;
112
+ top: 0;
113
+ }
114
+
115
+ .xterm-char-measure-element {
116
+ display: inline-block;
117
+ visibility: hidden;
118
+ position: absolute;
119
+ top: 0;
120
+ left: -9999em;
121
+ line-height: normal;
122
+ }
123
+
124
+ .xterm.enable-mouse-events {
125
+ /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
126
+ cursor: default;
127
+ }
128
+
129
+ .xterm.xterm-cursor-pointer,
130
+ .xterm .xterm-cursor-pointer {
131
+ cursor: pointer;
132
+ }
133
+
134
+ .xterm.column-select.focus {
135
+ /* Column selection mode */
136
+ cursor: crosshair;
137
+ }
138
+
139
+ .xterm .xterm-accessibility:not(.debug),
140
+ .xterm .xterm-message {
141
+ position: absolute;
142
+ left: 0;
143
+ top: 0;
144
+ bottom: 0;
145
+ right: 0;
146
+ z-index: 10;
147
+ color: transparent;
148
+ pointer-events: none;
149
+ }
150
+
151
+ .xterm .xterm-accessibility-tree:not(.debug) *::selection {
152
+ color: transparent;
153
+ }
154
+
155
+ .xterm .xterm-accessibility-tree {
156
+ font-family: monospace;
157
+ user-select: text;
158
+ white-space: pre;
159
+ }
160
+
161
+ .xterm .xterm-accessibility-tree > div {
162
+ transform-origin: left;
163
+ width: fit-content;
164
+ }
165
+
166
+ .xterm .live-region {
167
+ position: absolute;
168
+ left: -9999px;
169
+ width: 1px;
170
+ height: 1px;
171
+ overflow: hidden;
172
+ }
173
+
174
+ .xterm-dim {
175
+ /* Dim should not apply to background, so the opacity of the foreground color is applied
176
+ * explicitly in the generated class and reset to 1 here */
177
+ opacity: 1 !important;
178
+ }
179
+
180
+ .xterm-underline-1 { text-decoration: underline; }
181
+ .xterm-underline-2 { text-decoration: double underline; }
182
+ .xterm-underline-3 { text-decoration: wavy underline; }
183
+ .xterm-underline-4 { text-decoration: dotted underline; }
184
+ .xterm-underline-5 { text-decoration: dashed underline; }
185
+
186
+ .xterm-overline {
187
+ text-decoration: overline;
188
+ }
189
+
190
+ .xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
191
+ .xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
192
+ .xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
193
+ .xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
194
+ .xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }
195
+
196
+ .xterm-strikethrough {
197
+ text-decoration: line-through;
198
+ }
199
+
200
+ .xterm-screen .xterm-decoration-container .xterm-decoration {
201
+ z-index: 6;
202
+ position: absolute;
203
+ }
204
+
205
+ .xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer {
206
+ z-index: 7;
207
+ }
208
+
209
+ .xterm-decoration-overview-ruler {
210
+ z-index: 8;
211
+ position: absolute;
212
+ top: 0;
213
+ right: 0;
214
+ pointer-events: none;
215
+ }
216
+
217
+ .xterm-decoration-top {
218
+ z-index: 2;
219
+ position: relative;
220
+ }
221
+
222
+
223
+
224
+ /* Derived from vs/base/browser/ui/scrollbar/media/scrollbar.css */
225
+
226
+ /* xterm.js customization: Override xterm's cursor style */
227
+ .xterm .xterm-scrollable-element > .scrollbar {
228
+ cursor: default;
229
+ }
230
+
231
+ /* Arrows */
232
+ .xterm .xterm-scrollable-element > .scrollbar > .scra {
233
+ cursor: pointer;
234
+ font-size: 11px !important;
235
+ }
236
+
237
+ .xterm .xterm-scrollable-element > .visible {
238
+ opacity: 1;
239
+
240
+ /* Background rule added for IE9 - to allow clicks on dom node */
241
+ background:rgba(0,0,0,0);
242
+
243
+ transition: opacity 100ms linear;
244
+ /* In front of peek view */
245
+ z-index: 11;
246
+ }
247
+ .xterm .xterm-scrollable-element > .invisible {
248
+ opacity: 0;
249
+ pointer-events: none;
250
+ }
251
+ .xterm .xterm-scrollable-element > .invisible.fade {
252
+ transition: opacity 800ms linear;
253
+ }
254
+
255
+ /* Scrollable Content Inset Shadow */
256
+ .xterm .xterm-scrollable-element > .shadow {
257
+ position: absolute;
258
+ display: none;
259
+ }
260
+ .xterm .xterm-scrollable-element > .shadow.top {
261
+ display: block;
262
+ top: 0;
263
+ left: 3px;
264
+ height: 3px;
265
+ width: 100%;
266
+ box-shadow: var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset;
267
+ }
268
+ .xterm .xterm-scrollable-element > .shadow.left {
269
+ display: block;
270
+ top: 3px;
271
+ left: 0;
272
+ height: 100%;
273
+ width: 3px;
274
+ box-shadow: var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset;
275
+ }
276
+ .xterm .xterm-scrollable-element > .shadow.top-left-corner {
277
+ display: block;
278
+ top: 0;
279
+ left: 0;
280
+ height: 3px;
281
+ width: 3px;
282
+ }
283
+ .xterm .xterm-scrollable-element > .shadow.top.left {
284
+ box-shadow: var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset;
285
+ }