@celljs/ta-workspace 4.8.0 → 4.9.1
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 +2 -2
- package/README.zh-cn.md +2 -2
- package/package.json +13 -4
- package/web/index.js +916 -295
- package/web-src/browser-agent.ts +0 -440
- package/web-src/browser-common.tsx +0 -278
- package/web-src/browser-import.tsx +0 -126
- package/web-src/browser-webview.tsx +0 -270
- package/web-src/browser.tsx +0 -80
- package/web-src/common.tsx +0 -296
- package/web-src/editors.tsx +0 -471
- package/web-src/explorer.tsx +0 -717
- package/web-src/file-icon.tsx +0 -21
- package/web-src/host.ts +0 -121
- package/web-src/i18n.ts +0 -395
- package/web-src/index.tsx +0 -71
- package/web-src/open-files.tsx +0 -80
- package/web-src/preview.tsx +0 -132
- package/web-src/react.ts +0 -8
- package/web-src/scm.tsx +0 -388
- package/web-src/search.tsx +0 -485
- package/web-src/style.ts +0 -254
- package/web-src/terminal.tsx +0 -269
- package/web-src/util/browser-snapshot.spec.ts +0 -96
- package/web-src/util/browser-snapshot.ts +0 -225
- package/web-src/util/file-icon.spec.ts +0 -35
- package/web-src/util/file-icon.ts +0 -23
- package/web-src/util/git.ts +0 -203
- package/web-src/util/preview.spec.ts +0 -48
- package/web-src/util/preview.ts +0 -90
- package/web-src/util/search.spec.ts +0 -164
- package/web-src/util/search.ts +0 -274
- package/web-src/util/seti-font.ts +0 -6
- package/web-src/util/seti.ts +0 -761
- package/web-src/util/upload.spec.ts +0 -66
- package/web-src/util/upload.ts +0 -123
- package/web-src/util/workspace.spec.ts +0 -220
- package/web-src/util/workspace.ts +0 -396
- package/web-src/util/zip.spec.ts +0 -60
- package/web-src/util/zip.ts +0 -137
- package/web-src/workspace-client.ts +0 -221
package/web-src/style.ts
DELETED
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { SETI_FONT } from './util/seti-font';
|
|
2
|
-
|
|
3
|
-
/** The styles of the views; only the --ta-* variables of the page, so they follow its theme. */
|
|
4
|
-
export const STYLE = `
|
|
5
|
-
.taw-view { --taw-git-added: var(--ta-green); --taw-git-deleted: var(--ta-red); --taw-git-modified: var(--ta-yellow); --taw-git-conflict: #e4676b; position: relative; display: flex; flex-direction: column; height: 100%; min-height: 0; color: var(--ta-text); font-size: 13px; }
|
|
6
|
-
:root[data-theme='light'] .taw-view { --taw-git-modified: #b8860b; --taw-git-conflict: #ad0707; }
|
|
7
|
-
.taw-view-head { display: flex; align-items: center; gap: 4px; height: 30px; padding: 0 8px 0 12px; flex: none; }
|
|
8
|
-
.taw-view-title { flex: 1; min-width: 0; font-size: 12px; font-weight: 600; color: var(--ta-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
9
|
-
.taw-actions { display: flex; gap: 2px; }
|
|
10
|
-
.taw-action { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; flex: none; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--ta-muted); cursor: pointer; }
|
|
11
|
-
.taw-action:hover:not(:disabled) { background: var(--ta-hover); color: var(--ta-text); }
|
|
12
|
-
.taw-action:disabled { opacity: 0.4; cursor: default; }
|
|
13
|
-
.taw-action.taw-on { background: var(--ta-selected); color: var(--ta-text); }
|
|
14
|
-
.taw-action:focus-visible, .taw-row:focus-visible, .taw-row-main:focus-visible, .taw-button:focus-visible { outline: 1px solid var(--ta-border-focus); outline-offset: -1px; }
|
|
15
|
-
.taw-list { flex: 1; min-height: 0; overflow: auto; padding: 0 4px 12px; }
|
|
16
|
-
.taw-row { position: relative; display: flex; align-items: center; gap: 6px; width: 100%; height: 24px; padding: 0 6px 0 8px; border: 0; border-radius: 6px; background: none; color: var(--ta-body); font: inherit; text-align: left; cursor: pointer; user-select: none; outline: none; }
|
|
17
|
-
.taw-row:hover { background: var(--ta-hover); }
|
|
18
|
-
.taw-row.taw-selected { background: var(--ta-selected); color: var(--ta-text); }
|
|
19
|
-
.taw-row:focus-visible { box-shadow: inset 0 0 0 1px var(--ta-border-focus); }
|
|
20
|
-
.taw-row > svg { flex: none; color: var(--ta-muted); }
|
|
21
|
-
.taw-row-actions { display: none; align-items: center; gap: 0; flex: none; margin-left: auto; }
|
|
22
|
-
.taw-row-actions .taw-action { width: 22px; height: 22px; border-radius: 5px; }
|
|
23
|
-
.taw-row:hover .taw-row-actions, .taw-row:focus-within .taw-row-actions, .taw-section-head:hover .taw-row-actions, .taw-section-head:focus-within .taw-row-actions { display: flex; }
|
|
24
|
-
.taw-row-actions + .taw-letter, .taw-row-actions + .taw-badge { margin-left: 4px; }
|
|
25
|
-
.taw-row:not(:hover):not(:focus-within) .taw-row-actions + .taw-letter, .taw-row:not(:hover):not(:focus-within) .taw-row-actions + .taw-badge { margin-left: auto; }
|
|
26
|
-
.taw-row.taw-selected .taw-row-actions.taw-keep { display: flex; }
|
|
27
|
-
.taw-ignored { opacity: 0.5; }
|
|
28
|
-
.taw-deleted .taw-name { text-decoration: line-through; }
|
|
29
|
-
.taw-tree-row { padding-right: 10px; }
|
|
30
|
-
.taw-guides { position: absolute; inset: 0; pointer-events: none; }
|
|
31
|
-
.taw-guide { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--ta-border); opacity: 0; transition: opacity 120ms; }
|
|
32
|
-
.taw-tree:hover .taw-guide { opacity: 1; }
|
|
33
|
-
.taw-tree-row.taw-drop, .taw-tree-row.taw-drop:hover { background: color-mix(in srgb, var(--ta-border-focus) 16%, transparent); }
|
|
34
|
-
.taw-tree.taw-drop-root { box-shadow: inset 0 0 0 1px var(--ta-border-focus); background: color-mix(in srgb, var(--ta-border-focus) 8%, transparent); }
|
|
35
|
-
.taw-transfer { position: relative; flex: none; display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 12px; border-top: 1px solid var(--ta-border-muted); color: var(--ta-secondary); font-size: 12px; overflow: hidden; }
|
|
36
|
-
.taw-transfer > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
37
|
-
.taw-transfer .taw-detail { flex: none; }
|
|
38
|
-
.taw-transfer-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--ta-border-focus); transition: width 0.2s ease; }
|
|
39
|
-
.taw-editing { cursor: default; background: none !important; }
|
|
40
|
-
.taw-name-input { position: relative; flex: 1; min-width: 0; display: flex; }
|
|
41
|
-
.taw-input.taw-inline { height: 22px; padding: 0 4px; border-radius: 4px; font-size: 13px; }
|
|
42
|
-
.taw-input.taw-inline.taw-error { border-color: var(--ta-red); }
|
|
43
|
-
.taw-input.taw-inline.taw-warning { border-color: var(--ta-yellow); }
|
|
44
|
-
.taw-input-message { padding: 4px 6px; border-radius: 4px; font-size: 12px; line-height: 1.4; white-space: normal; }
|
|
45
|
-
.taw-name-input .taw-input-message { position: absolute; z-index: 5; top: 100%; left: 0; right: 0; margin-top: 1px; box-shadow: var(--ta-shadow-pop); }
|
|
46
|
-
.taw-input-message.taw-error { background: color-mix(in srgb, var(--ta-red) 16%, var(--ta-card)); border: 1px solid var(--ta-red); color: var(--ta-text); }
|
|
47
|
-
.taw-input-message.taw-warning { background: color-mix(in srgb, var(--ta-yellow) 16%, var(--ta-card)); border: 1px solid var(--ta-yellow); color: var(--ta-text); }
|
|
48
|
-
.taw-menu { position: fixed; z-index: 80; min-width: 210px; max-width: 320px; display: flex; flex-direction: column; gap: 1px; padding: 6px; border-radius: 12px; border: 1px solid var(--ta-border); background: var(--ta-side); box-shadow: var(--ta-shadow-pop); animation: taw-fade 100ms ease-out; }
|
|
49
|
-
.taw-menu-item { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex: none; height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: var(--ta-text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; outline: none; }
|
|
50
|
-
.taw-menu-item:hover:not(:disabled), .taw-menu-item:focus-visible { background: var(--ta-hover); }
|
|
51
|
-
.taw-menu-item:disabled { opacity: 0.45; cursor: default; }
|
|
52
|
-
.taw-menu-item kbd { font-family: inherit; font-size: 12px; color: var(--ta-muted); }
|
|
53
|
-
.taw-menu-line { flex: none; height: 1px; margin: 5px 8px; border: 0; background: var(--ta-border-muted); }
|
|
54
|
-
@keyframes taw-fade { from { opacity: 0; } }
|
|
55
|
-
.taw-section-head { display: flex; align-items: center; gap: 4px; height: 26px; margin-top: 6px; padding-right: 6px; border-radius: 6px; }
|
|
56
|
-
.taw-section-head:hover { background: var(--ta-hover); }
|
|
57
|
-
.taw-section-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; height: 100%; padding: 0 0 0 4px; border: 0; background: none; color: var(--ta-secondary); font: inherit; font-size: 12px; font-weight: 600; text-align: left; cursor: pointer; }
|
|
58
|
-
.taw-section-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
59
|
-
.taw-badge { flex: none; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--ta-chip); color: var(--ta-secondary); font-size: 11px; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
|
|
60
|
-
.taw-twisty { display: inline-flex; width: 14px; flex: none; color: var(--ta-muted); }
|
|
61
|
-
.taw-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
62
|
-
.taw-detail { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-muted); font-size: 12px; }
|
|
63
|
-
.taw-count { margin-left: auto; padding: 0 6px; border-radius: 8px; background: var(--ta-chip); color: var(--ta-secondary); font-size: 11px; line-height: 16px; }
|
|
64
|
-
.taw-letter { margin-left: auto; width: 14px; flex: none; text-align: center; font-size: 12px; font-weight: 600; }
|
|
65
|
-
.taw-group { display: flex; align-items: center; gap: 6px; margin: 8px 0 2px; padding: 0 8px; font-size: 11px; font-weight: 600; color: var(--ta-secondary); }
|
|
66
|
-
.taw-empty { padding: 12px; color: var(--ta-muted); font-size: 12px; line-height: 1.6; }
|
|
67
|
-
.taw-empty p { margin: 0 0 8px; }
|
|
68
|
-
.taw-error { color: var(--ta-red); }
|
|
69
|
-
.taw-note { color: var(--ta-muted); font-size: 12px; }
|
|
70
|
-
.taw-pad { padding: 8px; margin: 0; line-height: 1.6; }
|
|
71
|
-
.taw-button { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--ta-border); border-radius: 6px; background: var(--ta-card); color: var(--ta-text); font: inherit; cursor: pointer; }
|
|
72
|
-
.taw-button:hover { background: var(--ta-hover); }
|
|
73
|
-
.taw-search-form { display: flex; gap: 2px; padding: 4px 10px 6px 4px; flex: none; }
|
|
74
|
-
.taw-search-toggle { flex: none; width: 18px; display: flex; align-items: flex-start; justify-content: center; padding: 7px 0 0; border: 0; border-radius: 4px; background: none; color: var(--ta-muted); cursor: pointer; }
|
|
75
|
-
.taw-search-toggle:hover { background: var(--ta-hover); color: var(--ta-text); }
|
|
76
|
-
.taw-search-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
|
|
77
|
-
.taw-search-fields .taw-field { flex: none; align-items: flex-start; }
|
|
78
|
-
.taw-search-fields .taw-field .taw-action { margin-top: 3px; width: 22px; height: 22px; }
|
|
79
|
-
.taw-field .taw-input.taw-search-input { resize: none; height: auto; min-height: 28px; padding: 5px 4px 5px 8px; line-height: 18px; overflow: hidden; }
|
|
80
|
-
.taw-field.taw-invalid { border-color: var(--ta-red); }
|
|
81
|
-
.taw-replace-row { display: flex; align-items: center; gap: 2px; }
|
|
82
|
-
.taw-replace-row .taw-field { flex: 1; }
|
|
83
|
-
.taw-details-toggle { display: flex; justify-content: flex-end; margin: -4px 0 -6px; }
|
|
84
|
-
.taw-details-toggle .taw-action { width: 22px; height: 16px; }
|
|
85
|
-
.taw-search-details { display: flex; flex-direction: column; gap: 6px; }
|
|
86
|
-
.taw-search-label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--ta-secondary); }
|
|
87
|
-
.taw-search-label .taw-input { flex: none; height: 28px; font-size: 12.5px; }
|
|
88
|
-
.taw-results-head { display: flex; align-items: center; gap: 4px; min-height: 26px; padding: 0 8px 0 12px; flex: none; }
|
|
89
|
-
.taw-results-summary { flex: 1; min-width: 0; color: var(--ta-muted); font-size: 12px; }
|
|
90
|
-
.taw-results-summary .taw-summary { padding: 0; }
|
|
91
|
-
.taw-progress { display: block; width: 100%; height: 2px; border-radius: 1px; background: linear-gradient(90deg, transparent, var(--ta-accent), transparent) 0 0 / 40% 100% no-repeat; animation: taw-slide 1s linear infinite; }
|
|
92
|
-
.taw-progress-bar { position: absolute; left: 0; right: 0; top: 30px; height: 2px; background: linear-gradient(90deg, transparent, var(--ta-accent), transparent) 0 0 / 30% 100% no-repeat; animation: taw-slide 1.1s linear infinite; z-index: 2; }
|
|
93
|
-
@keyframes taw-slide { from { background-position: -40% 0; } to { background-position: 140% 0; } }
|
|
94
|
-
.taw-result-file { padding-right: 6px; }
|
|
95
|
-
.taw-commit { display: flex; flex-direction: column; gap: 8px; padding: 2px 10px 10px; flex: none; }
|
|
96
|
-
.taw-input.taw-commit-input { flex: none; resize: none; height: auto; min-height: 34px; max-height: 200px; padding: 7px 10px; border-radius: 8px; line-height: 18px; }
|
|
97
|
-
.taw-button.taw-commit-button { justify-content: center; height: 30px; border-radius: 8px; border-color: var(--ta-border); background: var(--ta-raised); color: var(--ta-secondary); font-weight: 500; transition: background 120ms, color 120ms, opacity 120ms; }
|
|
98
|
-
.taw-button.taw-commit-button:hover:not(:disabled) { background: var(--ta-hover-strong); color: var(--ta-text); }
|
|
99
|
-
/* With a message, it stands out a little, without a bright bar in the side panel. */
|
|
100
|
-
.taw-button.taw-commit-button.taw-ready { border-color: var(--ta-border-field); background: var(--ta-hover-strong); color: var(--ta-text); }
|
|
101
|
-
.taw-button.taw-commit-button.taw-ready:hover:not(:disabled) { background: var(--ta-hover-strong); opacity: 0.85; }
|
|
102
|
-
.taw-scm-title { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
|
|
103
|
-
.taw-scm-title > span:first-child { overflow: hidden; text-overflow: ellipsis; }
|
|
104
|
-
.taw-branch-title { display: inline-flex; align-items: center; gap: 4px; flex: none; padding: 0 6px; height: 18px; border-radius: 9px; background: var(--ta-chip); color: var(--ta-secondary); font-weight: 500; }
|
|
105
|
-
.taw-branch-title > svg { flex: none; color: var(--ta-muted); }
|
|
106
|
-
.taw-sync { color: var(--ta-muted); font-weight: 500; font-variant-numeric: tabular-nums; }
|
|
107
|
-
.taw-scm-row { padding-right: 6px; }
|
|
108
|
-
.taw-field { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1; padding-right: 2px; border: 1px solid var(--ta-border-field); border-radius: 6px; background: var(--ta-input); }
|
|
109
|
-
.taw-field:focus-within { border-color: var(--ta-border-focus); }
|
|
110
|
-
.taw-input { flex: 1; min-width: 0; height: 30px; padding: 0 8px; border: 1px solid var(--ta-border-field); border-radius: 6px; background: var(--ta-input); color: var(--ta-text); font: inherit; font-size: 13px; outline: none; }
|
|
111
|
-
.taw-input:focus { border-color: var(--ta-border-focus); }
|
|
112
|
-
.taw-field .taw-input { height: 28px; border: 0; background: none; }
|
|
113
|
-
.taw-summary { padding: 4px 8px 6px; color: var(--ta-muted); font-size: 12px; }
|
|
114
|
-
.taw-match { padding-left: 36px; padding-right: 6px; }
|
|
115
|
-
.taw-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: pre; color: var(--ta-body); font-size: 12.5px; }
|
|
116
|
-
.taw-preview mark { background: color-mix(in srgb, var(--ta-yellow) 32%, transparent); color: inherit; border-radius: 2px; }
|
|
117
|
-
.taw-preview del { background: color-mix(in srgb, var(--ta-red) 22%, transparent); color: inherit; text-decoration: line-through; }
|
|
118
|
-
.taw-preview ins { background: color-mix(in srgb, var(--ta-green) 24%, transparent); color: inherit; text-decoration: none; }
|
|
119
|
-
.taw-chip { padding: 0 6px; border-radius: 8px; background: var(--ta-chip); font-size: 11px; line-height: 18px; }
|
|
120
|
-
.taw-editor { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--ta-main); color: var(--ta-text); }
|
|
121
|
-
.taw-editor-head { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px; border-bottom: 1px solid var(--ta-border-muted); font-size: 12px; color: var(--ta-secondary); flex: none; }
|
|
122
|
-
.taw-editor-path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--ta-mono); }
|
|
123
|
-
.taw-view > .taw-editor { flex: 1; height: auto; }
|
|
124
|
-
.taw-browser { display: flex; flex-direction: column; height: 100%; min-height: 0; color: var(--ta-text); font-size: 13px; }
|
|
125
|
-
.taw-browser-bar { position: relative; display: flex; align-items: center; gap: 2px; height: 42px; padding: 0 8px; border-bottom: 1px solid var(--ta-border-muted); flex: none; }
|
|
126
|
-
.taw-browser-bar > .taw-action { width: 28px; height: 28px; border-radius: 7px; }
|
|
127
|
-
.taw-address { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; height: 30px; margin: 0 4px; padding: 0 3px 0 11px; border: 1px solid transparent; border-radius: 15px; background: var(--ta-chip); transition: background-color 120ms, border-color 120ms; }
|
|
128
|
-
.taw-address:hover { background: color-mix(in srgb, var(--ta-chip) 70%, var(--ta-text) 6%); }
|
|
129
|
-
.taw-address:focus-within { border-color: var(--ta-border-focus); background: var(--ta-input); }
|
|
130
|
-
.taw-address input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: none; color: var(--ta-text); font: inherit; font-size: 12.5px; outline: none; text-overflow: ellipsis; }
|
|
131
|
-
.taw-address input::placeholder { color: var(--ta-muted); }
|
|
132
|
-
.taw-address-icon { display: inline-flex; flex: none; color: var(--ta-muted); }
|
|
133
|
-
.taw-address-go { width: 24px; height: 24px; border-radius: 12px; }
|
|
134
|
-
.taw-spin { display: inline-flex; animation: taw-spin 0.9s linear infinite; }
|
|
135
|
-
@keyframes taw-spin { to { transform: rotate(360deg); } }
|
|
136
|
-
.taw-browser-loading { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: linear-gradient(90deg, transparent, var(--ta-accent), transparent) 0 0 / 30% 100% no-repeat; animation: taw-slide 1.1s linear infinite; pointer-events: none; }
|
|
137
|
-
.taw-browser-home { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; align-items: center; padding: 56px 20px 16px; }
|
|
138
|
-
.taw-browser-blank { padding-top: 16px; }
|
|
139
|
-
.taw-browser-blank .taw-browser-hero { margin: auto 0; }
|
|
140
|
-
.taw-browser-hero { display: flex; flex-direction: column; align-items: center; max-width: 380px; text-align: center; }
|
|
141
|
-
.taw-browser-mark { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; margin-bottom: 14px; border-radius: 14px; background: var(--ta-chip); color: var(--ta-secondary); }
|
|
142
|
-
.taw-browser-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--ta-text); }
|
|
143
|
-
.taw-browser-sub { margin: 6px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--ta-muted); }
|
|
144
|
-
.taw-browser-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 16px; }
|
|
145
|
-
.taw-browser-chip { height: 26px; padding: 0 10px; border: 1px solid var(--ta-border); border-radius: 13px; background: none; color: var(--ta-secondary); font-family: var(--ta-mono); font-size: 11px; cursor: pointer; transition: background-color 120ms, color 120ms; }
|
|
146
|
-
.taw-browser-chip:hover { background: var(--ta-hover); color: var(--ta-text); }
|
|
147
|
-
.taw-browser-recent { width: 100%; max-width: 480px; margin-top: 32px; }
|
|
148
|
-
.taw-browser-heading { margin: 0 0 4px; padding: 0 10px; font-size: 11px; font-weight: 600; color: var(--ta-secondary); }
|
|
149
|
-
.taw-browser-site { display: flex; align-items: center; border-radius: 8px; }
|
|
150
|
-
.taw-browser-site:hover { background: var(--ta-hover); }
|
|
151
|
-
.taw-browser-site-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 4px 0 8px; border: 0; background: none; color: var(--ta-body); font: inherit; text-align: left; cursor: pointer; outline: none; }
|
|
152
|
-
.taw-browser-letter { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 22px; height: 22px; border-radius: 6px; background: var(--ta-chip); color: var(--ta-secondary); font-size: 11px; font-weight: 600; }
|
|
153
|
-
.taw-browser-host { flex: none; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-text); }
|
|
154
|
-
.taw-browser-path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-muted); font-size: 12px; }
|
|
155
|
-
.taw-browser-remove { margin-right: 6px; opacity: 0; }
|
|
156
|
-
.taw-browser-site:hover .taw-browser-remove, .taw-browser-remove:focus-visible { opacity: 1; }
|
|
157
|
-
.taw-browser-site-main:focus-visible { box-shadow: inset 0 0 0 1px var(--ta-border-focus); border-radius: 8px; }
|
|
158
|
-
.taw-browser-foot { margin: auto 0 0; padding-top: 24px; max-width: 340px; text-align: center; font-size: 11.5px; line-height: 1.6; color: var(--ta-muted); opacity: 0.8; }
|
|
159
|
-
.taw-editor-tools { display: flex; align-items: center; gap: 8px; flex: none; min-width: 0; }
|
|
160
|
-
.taw-editor-tools .taw-note { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
161
|
-
.taw-warning { color: var(--ta-yellow); }
|
|
162
|
-
.taw-link { padding: 0; border: 0; background: none; color: var(--ta-link); font: inherit; cursor: pointer; }
|
|
163
|
-
.taw-link:hover { text-decoration: underline; }
|
|
164
|
-
.taw-button.taw-small { height: 24px; padding: 0 8px; font-size: 12px; flex: none; }
|
|
165
|
-
.taw-button:disabled { opacity: 0.6; cursor: default; }
|
|
166
|
-
.taw-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ta-text); }
|
|
167
|
-
.taw-segmented { display: inline-flex; flex: none; min-inline-size: 0; margin: 0; border: 0; padding: 2px; border-radius: 7px; background: var(--ta-chip); }
|
|
168
|
-
.taw-segmented > button { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border: 0; border-radius: 5px; background: none; color: var(--ta-secondary); font: inherit; font-size: 12px; cursor: pointer; }
|
|
169
|
-
.taw-segmented > button:hover { color: var(--ta-text); }
|
|
170
|
-
.taw-segmented > button.taw-on { background: var(--ta-main); color: var(--ta-text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
|
|
171
|
-
.taw-segmented > button:focus-visible { outline: 1px solid var(--ta-border-focus); outline-offset: -1px; }
|
|
172
|
-
.taw-preview-frame { flex: 1; width: 100%; min-height: 0; border: 0; background: var(--ta-main); }
|
|
173
|
-
.taw-preview-page { background: #fff; }
|
|
174
|
-
.taw-preview-media { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; background: var(--ta-code); }
|
|
175
|
-
.taw-preview-media video { max-width: 100%; max-height: 100%; border-radius: 8px; background: #000; outline: none; }
|
|
176
|
-
.taw-preview-media audio { width: min(480px, 100%); }
|
|
177
|
-
.taw-preview-image { background-color: var(--ta-code); background-image: linear-gradient(45deg, var(--ta-chip) 25%, transparent 25%, transparent 75%, var(--ta-chip) 75%), linear-gradient(45deg, var(--ta-chip) 25%, transparent 25%, transparent 75%, var(--ta-chip) 75%); background-size: 16px 16px; background-position: 0 0, 8px 8px; }
|
|
178
|
-
.taw-image-toggle { display: flex; align-items: center; justify-content: center; max-width: 100%; max-height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
|
|
179
|
-
.taw-image-toggle:focus-visible { outline: 1px solid var(--ta-border-focus); outline-offset: 2px; }
|
|
180
|
-
.taw-preview-image img { max-width: 100%; max-height: 100%; object-fit: contain; }
|
|
181
|
-
.taw-preview-image.taw-actual { align-items: flex-start; justify-content: flex-start; }
|
|
182
|
-
.taw-preview-image.taw-actual .taw-image-toggle { max-width: none; max-height: none; margin: auto; cursor: zoom-out; }
|
|
183
|
-
.taw-preview-image.taw-actual img { max-width: none; max-height: none; }
|
|
184
|
-
.taw-message { padding: 16px; color: var(--ta-muted); font-size: 13px; }
|
|
185
|
-
.taw-code { flex: 1; min-height: 0; overflow: auto; padding: 6px 0; background: var(--ta-code); font-family: var(--ta-mono); font-size: 12px; line-height: 20px; }
|
|
186
|
-
.taw-code-block { content-visibility: auto; }
|
|
187
|
-
.taw-code-line { display: flex; min-width: max-content; white-space: pre; }
|
|
188
|
-
.taw-code-line.taw-current { background: var(--ta-selected); }
|
|
189
|
-
.taw-gutter { position: sticky; left: 0; flex: none; width: var(--taw-gutter, 5ch); padding-right: 12px; background: var(--ta-code); color: var(--ta-muted); text-align: right; user-select: none; }
|
|
190
|
-
.taw-text { padding-right: 16px; }
|
|
191
|
-
.taw-hint { flex: none; padding: 4px 12px; border-bottom: 1px solid var(--ta-border-muted); background: var(--ta-raised); color: var(--ta-secondary); font-size: 12px; }
|
|
192
|
-
.taw-frame { flex: 1; width: 100%; min-height: 0; border: 0; background: #fff; }
|
|
193
|
-
.taw-browser-stage { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
|
|
194
|
-
.taw-webview { flex: 1; width: 100%; min-height: 0; border: 0; background: #fff; }
|
|
195
|
-
.taw-browser-driven { display: inline-flex; align-items: center; flex: none; gap: 6px; height: 22px; margin-right: 2px; padding: 0 9px 0 8px; border-radius: 11px; background: color-mix(in srgb, var(--ta-green) 14%, transparent); color: var(--ta-green); font-size: 11.5px; white-space: nowrap; }
|
|
196
|
-
.taw-browser-driven-dot { width: 6px; height: 6px; border-radius: 3px; background: currentColor; animation: taw-pulse 1.2s ease-in-out infinite; }
|
|
197
|
-
@keyframes taw-pulse { 50% { opacity: 0.35; } }
|
|
198
|
-
.taw-browser-import { display: inline-flex; align-items: center; gap: 6px; margin-top: 18px; padding: 0; border: 0; background: none; color: var(--ta-secondary); font: inherit; font-size: 12.5px; cursor: pointer; }
|
|
199
|
-
.taw-browser-import:hover { color: var(--ta-text); text-decoration: underline; text-underline-offset: 3px; }
|
|
200
|
-
.taw-import { display: flex; flex-direction: column; gap: 12px; width: min(420px, 80vw); font-size: 13px; color: var(--ta-text); }
|
|
201
|
-
.taw-import-hint { margin: 0; color: var(--ta-secondary); line-height: 1.6; }
|
|
202
|
-
.taw-import-error { margin: 0; color: var(--ta-red); line-height: 1.5; overflow-wrap: anywhere; }
|
|
203
|
-
.taw-import-profiles { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow: auto; }
|
|
204
|
-
.taw-import-profile { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; }
|
|
205
|
-
.taw-import-profile:hover { background: var(--ta-hover); }
|
|
206
|
-
.taw-import-profile.taw-on { border-color: var(--ta-border-focus); background: var(--ta-hover); }
|
|
207
|
-
.taw-import-profile input { position: absolute; opacity: 0; pointer-events: none; }
|
|
208
|
-
.taw-import-browser { flex: none; font-weight: 500; }
|
|
209
|
-
.taw-import-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-muted); }
|
|
210
|
-
.taw-import-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 4px; }
|
|
211
|
-
.taw-import-result { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 8px 0 0; }
|
|
212
|
-
.taw-import-result .taw-import-actions { justify-content: center; margin-top: 18px; }
|
|
213
|
-
.taw-button.taw-primary { border-color: var(--ta-brand); background: var(--ta-brand); color: var(--ta-brand-text); font-weight: 500; }
|
|
214
|
-
.taw-button.taw-primary:hover:not(:disabled) { background: var(--ta-brand); opacity: 0.88; }
|
|
215
|
-
.taw-button:disabled { opacity: 0.45; cursor: default; }
|
|
216
|
-
.taw-link { padding: 0; border: 0; background: none; color: var(--ta-muted); font: inherit; font-size: 12.5px; cursor: pointer; }
|
|
217
|
-
.taw-link:hover:not(:disabled) { color: var(--ta-text); text-decoration: underline; text-underline-offset: 3px; }
|
|
218
|
-
.taw-address-favicon { width: 14px; height: 14px; border-radius: 3px; object-fit: contain; }
|
|
219
|
-
.taw-browser-failure { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: var(--ta-main); text-align: center; }
|
|
220
|
-
.taw-browser-failure .taw-browser-sub { max-width: 380px; overflow-wrap: anywhere; }
|
|
221
|
-
.taw-terminal { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--ta-code); }
|
|
222
|
-
@media (pointer: coarse) {
|
|
223
|
-
.taw-row { height: 36px; }
|
|
224
|
-
.taw-action { width: 32px; height: 32px; }
|
|
225
|
-
.taw-row-actions { display: flex; }
|
|
226
|
-
.taw-guide { opacity: 1; }
|
|
227
|
-
.taw-input { height: 34px; font-size: 16px; }
|
|
228
|
-
.taw-field .taw-input, .taw-search-label .taw-input { height: 34px; font-size: 16px; }
|
|
229
|
-
.taw-field .taw-input.taw-search-input { min-height: 34px; padding-top: 7px; padding-bottom: 7px; line-height: 20px; }
|
|
230
|
-
.taw-search-fields .taw-field .taw-action { width: 30px; height: 30px; margin-top: 2px; }
|
|
231
|
-
.taw-search-toggle { width: 26px; padding-top: 10px; }
|
|
232
|
-
.taw-input.taw-commit-input { min-height: 40px; }
|
|
233
|
-
.taw-address input { font-size: 16px; }
|
|
234
|
-
.taw-browser-remove { opacity: 1; }
|
|
235
|
-
}
|
|
236
|
-
.taw-file-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; overflow: hidden; font-family: 'taw-seti'; font-style: normal; font-weight: normal; line-height: 1; color: var(--taw-icon); -webkit-font-smoothing: antialiased; speak: never; }
|
|
237
|
-
:root[data-theme='light'] .taw-file-icon { color: var(--taw-icon-light); }
|
|
238
|
-
.taw-terminal-tabs { display: flex; align-items: center; gap: 2px; min-height: 32px; padding: 0 6px; border-bottom: 1px solid var(--ta-border-muted); background: var(--ta-side); overflow-x: auto; scrollbar-width: none; flex: none; }
|
|
239
|
-
.taw-terminal-tab { display: flex; align-items: center; flex: none; max-width: 200px; border-radius: 6px; color: var(--ta-muted); }
|
|
240
|
-
.taw-terminal-tab:hover { background: var(--ta-hover); }
|
|
241
|
-
.taw-terminal-tab.taw-on { background: var(--ta-selected); color: var(--ta-text); }
|
|
242
|
-
.taw-terminal-tab > button:first-child { display: flex; align-items: center; gap: 6px; min-width: 0; height: 24px; padding: 0 2px 0 8px; border: 0; background: none; color: inherit; font: inherit; font-size: 12px; cursor: pointer; }
|
|
243
|
-
.taw-terminal-tab > button:first-child > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
244
|
-
.taw-terminal-tab > .taw-action { width: 20px; height: 20px; }
|
|
245
|
-
`;
|
|
246
|
-
|
|
247
|
-
/** Adds the styles to the page; the function returned takes them away. */
|
|
248
|
-
export function injectStyle(): () => void {
|
|
249
|
-
const element = document.createElement('style');
|
|
250
|
-
element.dataset.taPackage = 'ta-workspace';
|
|
251
|
-
element.textContent = `@font-face { font-family: 'taw-seti'; src: url('${SETI_FONT}') format('woff'); font-display: block; }\n${STYLE}`;
|
|
252
|
-
document.head.appendChild(element);
|
|
253
|
-
return () => element.remove();
|
|
254
|
-
}
|
package/web-src/terminal.tsx
DELETED
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
import type { TaTerminalInfo } from '@celljs/ta-protocol';
|
|
2
|
-
import type { WebTerminal } from '@celljs/ta-web/lib/browser/extension/web-extension-api';
|
|
3
|
-
import { Action, Empty, Glyph, type MenuItem, useContextMenu } from './common';
|
|
4
|
-
import { Host, pi } from './host';
|
|
5
|
-
import { t } from './i18n';
|
|
6
|
-
import { React } from './react';
|
|
7
|
-
import { WorkspaceUtil } from './util/workspace';
|
|
8
|
-
|
|
9
|
-
const RESIZE_MS = 120;
|
|
10
|
-
/** A shell opens at this size, and its screen with it, until its view fits it. */
|
|
11
|
-
const OPEN_COLS = 100;
|
|
12
|
-
const OPEN_ROWS = 30;
|
|
13
|
-
|
|
14
|
-
/** `pty` is false for a shell on pipes (the server has no `script`). */
|
|
15
|
-
type TerminalInfo = TaTerminalInfo;
|
|
16
|
-
|
|
17
|
-
interface Session {
|
|
18
|
-
info: TerminalInfo;
|
|
19
|
-
terminal: WebTerminal;
|
|
20
|
-
exitCode?: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** The terminals of this page and what they printed; they outlive the views that show them. */
|
|
24
|
-
export namespace Terminals {
|
|
25
|
-
const sessions = new Map<string, Session>();
|
|
26
|
-
/** Closed here: what the server still sends of them (their end) does not bring them back. */
|
|
27
|
-
const closed = new Set<string>();
|
|
28
|
-
const listeners = new Set<() => void>();
|
|
29
|
-
let list: Session[] = [];
|
|
30
|
-
let frame = 0;
|
|
31
|
-
|
|
32
|
-
export function all(): Session[] {
|
|
33
|
-
return list;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function get(id: string): Session | undefined {
|
|
37
|
-
return sessions.get(id);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function subscribe(listener: () => void): () => void {
|
|
41
|
-
listeners.add(listener);
|
|
42
|
-
return () => listeners.delete(listener);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** The list of terminals or how one ended changed: views read it again once a frame. */
|
|
46
|
-
function changed(): void {
|
|
47
|
-
list = [...sessions.values()];
|
|
48
|
-
if (!frame) {
|
|
49
|
-
frame = requestAnimationFrame(() => {
|
|
50
|
-
frame = 0;
|
|
51
|
-
for (const listener of listeners) {
|
|
52
|
-
listener();
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function add(info: TerminalInfo): Session {
|
|
59
|
-
let session = sessions.get(info.terminalId);
|
|
60
|
-
if (!session) {
|
|
61
|
-
const terminal = pi.ui.createTerminal({ cols: OPEN_COLS, rows: OPEN_ROWS, cwd: info.cwd || undefined });
|
|
62
|
-
const created: Session = { info, terminal };
|
|
63
|
-
const id = info.terminalId;
|
|
64
|
-
terminal.onData(data => {
|
|
65
|
-
if (created.exitCode === undefined) {
|
|
66
|
-
void pi.terminals.writeTerminal(id, data).catch(() => undefined);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
// The shell hears the last size, once the view stopped changing.
|
|
70
|
-
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
71
|
-
terminal.onResize(({ cols, rows }) => {
|
|
72
|
-
clearTimeout(timer);
|
|
73
|
-
timer = setTimeout(() => void pi.terminals.resizeTerminal(id, cols, rows).catch(() => undefined), RESIZE_MS);
|
|
74
|
-
});
|
|
75
|
-
session = created;
|
|
76
|
-
sessions.set(id, session);
|
|
77
|
-
changed();
|
|
78
|
-
}
|
|
79
|
-
return session;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function receive(terminalId: string, data: string, exitCode?: number): void {
|
|
83
|
-
if (closed.has(terminalId)) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const session = sessions.get(terminalId) ?? add({ terminalId, cwd: '', shell: '', pty: true });
|
|
87
|
-
session.terminal.write(data);
|
|
88
|
-
// JSON has no undefined: a terminal that goes on sends null.
|
|
89
|
-
if (exitCode !== undefined && exitCode !== null) {
|
|
90
|
-
session.exitCode = exitCode;
|
|
91
|
-
// Nothing more is typed there: the cursor goes.
|
|
92
|
-
session.terminal.write(`\r\n${t('terminalEnded', { code: exitCode })}\r\n\x1b[?25l`);
|
|
93
|
-
changed();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function remove(terminalId: string): void {
|
|
98
|
-
const session = sessions.get(terminalId);
|
|
99
|
-
if (session && sessions.delete(terminalId)) {
|
|
100
|
-
session.terminal.dispose();
|
|
101
|
-
closed.add(terminalId);
|
|
102
|
-
changed();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** Takes back the shells of this page after a reconnect. */
|
|
107
|
-
export async function sync(): Promise<void> {
|
|
108
|
-
for (const info of await pi.terminals.listTerminals()) {
|
|
109
|
-
add(info);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function useTerminals(): Session[] {
|
|
115
|
-
return React.useSyncExternalStore(Terminals.subscribe, Terminals.all);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function title(session: Session): string {
|
|
119
|
-
return `${WorkspaceUtil.basename(session.info.shell) || t('terminal')} · ${WorkspaceUtil.basename(session.info.cwd)}`;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
async function close(session: Session): Promise<void> {
|
|
123
|
-
Terminals.remove(session.info.terminalId);
|
|
124
|
-
if (session.exitCode === undefined) {
|
|
125
|
-
await pi.terminals.closeTerminal(session.info.terminalId).catch(() => undefined);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function closeEach(sessions: readonly Session[]): void {
|
|
130
|
-
for (const session of sessions) {
|
|
131
|
-
void close(session);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/** The terminals of the page in one tab of the workbench: a row of them, and the one shown. The first opens with the view. */
|
|
136
|
-
export function TerminalView() {
|
|
137
|
-
const cwd = pi.ui.useCwd();
|
|
138
|
-
const sessions = useTerminals();
|
|
139
|
-
const [shown, setShown] = React.useState<string>();
|
|
140
|
-
const [error, setError] = React.useState<string>();
|
|
141
|
-
const opening = React.useRef(false);
|
|
142
|
-
const create = React.useCallback(async () => {
|
|
143
|
-
if (opening.current) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
opening.current = true;
|
|
147
|
-
try {
|
|
148
|
-
setError(undefined);
|
|
149
|
-
setShown(Terminals.add(await pi.terminals.openTerminal({ cwd, cols: OPEN_COLS, rows: OPEN_ROWS })).info.terminalId);
|
|
150
|
-
} catch (failure) {
|
|
151
|
-
setError(Host.message(failure));
|
|
152
|
-
} finally {
|
|
153
|
-
opening.current = false;
|
|
154
|
-
}
|
|
155
|
-
}, [cwd]);
|
|
156
|
-
// Once, when the view opens.
|
|
157
|
-
React.useEffect(() => {
|
|
158
|
-
Terminals.sync().then(
|
|
159
|
-
async () => {
|
|
160
|
-
if (Terminals.all().length === 0) {
|
|
161
|
-
await create();
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
failure => setError(Host.message(failure)),
|
|
165
|
-
);
|
|
166
|
-
}, []);
|
|
167
|
-
const current = sessions.find(session => session.info.terminalId === shown) ?? sessions[sessions.length - 1];
|
|
168
|
-
const [menu, openMenu] = useContextMenu();
|
|
169
|
-
const menuFor = (session: Session): MenuItem[] => {
|
|
170
|
-
const at = sessions.indexOf(session);
|
|
171
|
-
const others = sessions.filter(other => other !== session);
|
|
172
|
-
const left = sessions.slice(0, at);
|
|
173
|
-
const right = sessions.slice(at + 1);
|
|
174
|
-
const ended = sessions.filter(other => other.exitCode !== undefined);
|
|
175
|
-
return [
|
|
176
|
-
{ label: t('close'), run: () => void close(session) },
|
|
177
|
-
{ label: t('closeOthers'), run: () => closeEach(others), disabled: others.length === 0 },
|
|
178
|
-
{ label: t('closeToTheLeft'), run: () => closeEach(left), disabled: left.length === 0 },
|
|
179
|
-
{ label: t('closeTabsToTheRight'), run: () => closeEach(right), disabled: right.length === 0 },
|
|
180
|
-
'-',
|
|
181
|
-
{ label: t('closeEnded'), run: () => closeEach(ended), disabled: ended.length === 0 },
|
|
182
|
-
{ label: t('closeAll'), run: () => closeEach(sessions) },
|
|
183
|
-
'-',
|
|
184
|
-
{ label: t('newTerminal'), run: () => void create() },
|
|
185
|
-
];
|
|
186
|
-
};
|
|
187
|
-
return (
|
|
188
|
-
<div className="taw-view">
|
|
189
|
-
<header className="taw-terminal-tabs" role="tablist" aria-label={t('terminal')}>
|
|
190
|
-
{sessions.map(session => (
|
|
191
|
-
<div key={session.info.terminalId} className={`taw-terminal-tab ${session === current ? 'taw-on' : ''}`} title={session.info.cwd}>
|
|
192
|
-
<button
|
|
193
|
-
type="button"
|
|
194
|
-
role="tab"
|
|
195
|
-
aria-selected={session === current}
|
|
196
|
-
onClick={() => setShown(session.info.terminalId)}
|
|
197
|
-
onContextMenu={event => openMenu(event, menuFor(session))}
|
|
198
|
-
>
|
|
199
|
-
<Glyph name="SquareTerminal" size={13} />
|
|
200
|
-
<span>{title(session)}</span>
|
|
201
|
-
{session.exitCode !== undefined && <span className="taw-detail">{session.exitCode}</span>}
|
|
202
|
-
</button>
|
|
203
|
-
<Action icon="X" label={t('close')} onClick={() => void close(session)} />
|
|
204
|
-
</div>
|
|
205
|
-
))}
|
|
206
|
-
<Action icon="Plus" label={t('newTerminal')} onClick={() => void create()} />
|
|
207
|
-
</header>
|
|
208
|
-
{menu}
|
|
209
|
-
{error && <Empty tone="error">{t('failed', { message: error })}</Empty>}
|
|
210
|
-
{!error && sessions.length === 0 && (
|
|
211
|
-
<Empty>
|
|
212
|
-
<p>{t('noTerminals')}</p>
|
|
213
|
-
<button type="button" className="taw-button" onClick={() => void create()}>
|
|
214
|
-
<Glyph name="Plus" size={14} />
|
|
215
|
-
{t('newTerminal')}
|
|
216
|
-
</button>
|
|
217
|
-
</Empty>
|
|
218
|
-
)}
|
|
219
|
-
{current && <TerminalEditor key={current.info.terminalId} terminalId={current.info.terminalId} />}
|
|
220
|
-
</div>
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/** The screen of a shell: its terminal, moved into this view while it shows. */
|
|
225
|
-
function TerminalEditor({ terminalId }: { terminalId: string }) {
|
|
226
|
-
useTerminals();
|
|
227
|
-
const session = Terminals.get(terminalId);
|
|
228
|
-
const box = React.useRef<HTMLDivElement>(null);
|
|
229
|
-
const terminal = session?.terminal;
|
|
230
|
-
React.useEffect(() => {
|
|
231
|
-
const element = box.current;
|
|
232
|
-
if (!element || !terminal) {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
const detach = terminal.attach(element);
|
|
236
|
-
terminal.focus();
|
|
237
|
-
return detach;
|
|
238
|
-
}, [terminal]);
|
|
239
|
-
if (!session) {
|
|
240
|
-
return <Empty>{t('noTerminals')}</Empty>;
|
|
241
|
-
}
|
|
242
|
-
return (
|
|
243
|
-
<div className="taw-editor">
|
|
244
|
-
{session.info.pty === false && <div className="taw-hint">{t('pipeMode')}</div>}
|
|
245
|
-
{/* biome-ignore lint/a11y/noStaticElementInteractions: dropping files types their paths, as they could be typed */}
|
|
246
|
-
<div
|
|
247
|
-
className="taw-terminal"
|
|
248
|
-
ref={box}
|
|
249
|
-
onDragOver={event => {
|
|
250
|
-
if (pi.ui.fileDrag.has(event.dataTransfer)) {
|
|
251
|
-
event.preventDefault();
|
|
252
|
-
event.dataTransfer.dropEffect = 'copy';
|
|
253
|
-
}
|
|
254
|
-
}}
|
|
255
|
-
onDrop={event => {
|
|
256
|
-
const files = pi.ui.fileDrag.get(event.dataTransfer);
|
|
257
|
-
if (!files || session.exitCode !== undefined) {
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
event.preventDefault();
|
|
261
|
-
const windows = /(^|[\\/])(cmd|powershell|pwsh)(\.exe)?$/i.test(session.info.shell);
|
|
262
|
-
const words = pi.ui.fileDrag.paths(files).map(path => WorkspaceUtil.shellQuote(path, windows));
|
|
263
|
-
void pi.terminals.writeTerminal(terminalId, `${words.join(' ')} `).catch(() => undefined);
|
|
264
|
-
terminal?.focus();
|
|
265
|
-
}}
|
|
266
|
-
/>
|
|
267
|
-
</div>
|
|
268
|
-
);
|
|
269
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test';
|
|
2
|
-
import { type AXNode, BrowserSnapshot } from './browser-snapshot';
|
|
3
|
-
|
|
4
|
-
const node = (nodeId: string, role: string, name: string, extra: Partial<AXNode> = {}): AXNode => ({
|
|
5
|
-
nodeId,
|
|
6
|
-
role: { value: role },
|
|
7
|
-
name: { value: name },
|
|
8
|
-
...extra,
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
describe('BrowserSnapshot', () => {
|
|
12
|
-
it('shows a page as indented lines, with refs on what one acts on', () => {
|
|
13
|
-
const nodes: AXNode[] = [
|
|
14
|
-
node('1', 'RootWebArea', 'Sign in', { childIds: ['2'] }),
|
|
15
|
-
node('2', 'generic', '', { parentId: '1', childIds: ['3', '4', '6', '7', '9'] }),
|
|
16
|
-
node('3', 'heading', 'Welcome back', { parentId: '2', childIds: ['3t'], properties: [{ name: 'level', value: { value: 1 } }] }),
|
|
17
|
-
node('3t', 'StaticText', 'Welcome back', { parentId: '3' }),
|
|
18
|
-
node('4', 'textbox', 'Email', {
|
|
19
|
-
parentId: '2',
|
|
20
|
-
backendDOMNodeId: 41,
|
|
21
|
-
childIds: ['5'],
|
|
22
|
-
value: { value: 'a@b.dev' },
|
|
23
|
-
properties: [
|
|
24
|
-
{ name: 'focused', value: { value: true } },
|
|
25
|
-
{ name: 'required', value: { value: true } },
|
|
26
|
-
],
|
|
27
|
-
}),
|
|
28
|
-
node('5', 'generic', '', { parentId: '4', backendDOMNodeId: 50, properties: [{ name: 'editable', value: { value: 'plaintext' } }] }),
|
|
29
|
-
node('6', 'checkbox', 'Remember me', { parentId: '2', backendDOMNodeId: 60, properties: [{ name: 'checked', value: { value: 'mixed' } }] }),
|
|
30
|
-
node('7', 'button', 'More', { parentId: '2', backendDOMNodeId: 70, properties: [{ name: 'expanded', value: { value: false } }] }),
|
|
31
|
-
node('9', 'paragraph', '', { parentId: '2', childIds: ['10', '11'] }),
|
|
32
|
-
node('10', 'StaticText', 'No account?', { parentId: '9' }),
|
|
33
|
-
node('11', 'link', 'Sign up', { parentId: '9', backendDOMNodeId: 110, ignored: false, childIds: ['12'] }),
|
|
34
|
-
node('12', 'StaticText', 'Sign up', { parentId: '11' }),
|
|
35
|
-
];
|
|
36
|
-
expect(BrowserSnapshot.render(nodes)).toBe(
|
|
37
|
-
[
|
|
38
|
-
'RootWebArea "Sign in"',
|
|
39
|
-
' heading "Welcome back" level=1',
|
|
40
|
-
' [41] textbox "Email" (focused, required) value="a@b.dev"',
|
|
41
|
-
' [60] checkbox "Remember me" (checked=mixed)',
|
|
42
|
-
' [70] button "More" (collapsed)',
|
|
43
|
-
' "No account?"',
|
|
44
|
-
' [110] link "Sign up"',
|
|
45
|
-
].join('\n'),
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('gives a ref to an editable element of its own, and leaves out labels without a name', () => {
|
|
50
|
-
const nodes: AXNode[] = [
|
|
51
|
-
node('1', 'LabelText', '', { childIds: ['2', '3'] }),
|
|
52
|
-
node('2', 'StaticText', 'Notes', { parentId: '1' }),
|
|
53
|
-
node('3', 'generic', '', { parentId: '1', backendDOMNodeId: 7, properties: [{ name: 'editable', value: { value: 'richtext' } }] }),
|
|
54
|
-
];
|
|
55
|
-
expect(BrowserSnapshot.render(nodes)).toBe('"Notes"\n[7] generic');
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('skips what is ignored and says how much it left out', () => {
|
|
59
|
-
const nodes: AXNode[] = [
|
|
60
|
-
node('1', 'generic', '', { childIds: ['2', '3', '4'] }),
|
|
61
|
-
node('2', 'none', '', { parentId: '1', childIds: ['5'] }),
|
|
62
|
-
node('3', 'button', 'Hidden', { parentId: '1', ignored: true, backendDOMNodeId: 3 }),
|
|
63
|
-
node('4', 'StaticText', 'one', { parentId: '1' }),
|
|
64
|
-
node('5', 'StaticText', 'two', { parentId: '2' }),
|
|
65
|
-
];
|
|
66
|
-
expect(BrowserSnapshot.render(nodes, 1)).toBe('"two"\n… 1 more lines: scroll, or evaluate to read a part of the page.');
|
|
67
|
-
expect(BrowserSnapshot.render([])).toBe('(the page shows nothing to read yet)');
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('cuts long names', () => {
|
|
71
|
-
const line = BrowserSnapshot.render([node('1', 'heading', 'x'.repeat(300))]);
|
|
72
|
-
expect(line.length).toBeLessThan(140);
|
|
73
|
-
expect(line.endsWith('…"')).toBe(true);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('finds the middle of a quad', () => {
|
|
77
|
-
expect(BrowserSnapshot.center([10, 20, 110, 20, 110, 60, 10, 60])).toEqual({ x: 60, y: 40 });
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('reads keys and shortcuts as key events', () => {
|
|
81
|
-
expect(BrowserSnapshot.key('Enter')).toEqual({ key: 'Enter', code: 'Enter', windowsVirtualKeyCode: 13, modifiers: 0, text: '\r' });
|
|
82
|
-
expect(BrowserSnapshot.key('a')).toEqual({ key: 'a', code: 'KeyA', windowsVirtualKeyCode: 65, modifiers: 0, text: 'a' });
|
|
83
|
-
expect(BrowserSnapshot.key('Shift+a')).toEqual({ key: 'A', code: 'KeyA', windowsVirtualKeyCode: 65, modifiers: 8, text: 'A' });
|
|
84
|
-
expect(BrowserSnapshot.key('Control+A')).toEqual({ key: 'a', code: 'KeyA', windowsVirtualKeyCode: 65, modifiers: 2 });
|
|
85
|
-
expect(BrowserSnapshot.key('Meta+Shift+ArrowLeft')).toEqual({ key: 'ArrowLeft', code: 'ArrowLeft', windowsVirtualKeyCode: 37, modifiers: 12 });
|
|
86
|
-
expect(BrowserSnapshot.key('cmd+enter')).toEqual({ key: 'Enter', code: 'Enter', windowsVirtualKeyCode: 13, modifiers: 4 });
|
|
87
|
-
expect(BrowserSnapshot.key('Space')).toMatchObject({ key: ' ', text: ' ' });
|
|
88
|
-
expect(BrowserSnapshot.key('F5')).toEqual({ key: 'F5', code: 'F5', windowsVirtualKeyCode: 116, modifiers: 0 });
|
|
89
|
-
expect(BrowserSnapshot.key('7')).toMatchObject({ code: 'Digit7', windowsVirtualKeyCode: 55, text: '7' });
|
|
90
|
-
expect(BrowserSnapshot.key('+')).toMatchObject({ key: '+', text: '+' });
|
|
91
|
-
expect(BrowserSnapshot.key('Control++')).toMatchObject({ key: '+', modifiers: 2 });
|
|
92
|
-
expect(BrowserSnapshot.key('Hyper+a')).toBeUndefined();
|
|
93
|
-
expect(BrowserSnapshot.key('Hello')).toBeUndefined();
|
|
94
|
-
expect(BrowserSnapshot.key('')).toBeUndefined();
|
|
95
|
-
});
|
|
96
|
-
});
|