glidercli 0.4.18 → 0.4.31
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 +18 -6
- package/bin/glider.js +388 -71
- package/docs/setup.json +6 -2
- package/docs/tab-identity.scorched.json +2042 -0
- package/lib/bexplore.js +6 -5
- package/lib/bfavicon.js +3 -2
- package/lib/bwindow.js +8 -6
- package/lib/cdp-direct.js +1 -1
- package/lib/cookie-jar.js +233 -0
- package/lib/paths.js +48 -0
- package/lib/tab-catalog.js +67 -10
- package/lib/tab-map.js +282 -0
- package/lib/tab-tui.js +179 -0
- package/package.json +3 -3
package/lib/tab-map.js
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { stateDir } = require('./paths.js');
|
|
6
|
+
|
|
7
|
+
function mapPath() {
|
|
8
|
+
return path.join(stateDir(), 'tab-map.json');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function rowHandle(t, handle) {
|
|
12
|
+
return {
|
|
13
|
+
handle: String(handle),
|
|
14
|
+
kind: t.kind || 'tab',
|
|
15
|
+
tabId: t.tabId == null ? 0 : t.tabId,
|
|
16
|
+
sessionId: t.sessionId || '',
|
|
17
|
+
targetId: t.targetId || '',
|
|
18
|
+
windowId: t.windowId == null ? 0 : t.windowId,
|
|
19
|
+
index: t.index == null ? 0 : t.index,
|
|
20
|
+
title: t.title || '',
|
|
21
|
+
url: t.url || '',
|
|
22
|
+
attached: !!t.attached,
|
|
23
|
+
active: !!t.active,
|
|
24
|
+
discarded: !!t.discarded,
|
|
25
|
+
highlighted: !!t.highlighted,
|
|
26
|
+
pinned: !!t.pinned,
|
|
27
|
+
load: t.load || '',
|
|
28
|
+
incognito: !!t.incognito,
|
|
29
|
+
current: !!t.current,
|
|
30
|
+
audible: !!t.audible,
|
|
31
|
+
muted: !!t.muted,
|
|
32
|
+
autoDiscardable: t.autoDiscardable !== false,
|
|
33
|
+
groupId: t.groupId == null ? '' : t.groupId,
|
|
34
|
+
openerTabId: t.openerTabId == null ? '' : t.openerTabId,
|
|
35
|
+
pendingUrl: t.pendingUrl || '',
|
|
36
|
+
favIconUrl: t.favIconUrl || '',
|
|
37
|
+
frozen: !!t.frozen,
|
|
38
|
+
lastAccessed: t.lastAccessed == null ? '' : t.lastAccessed,
|
|
39
|
+
width: t.width == null ? '' : t.width,
|
|
40
|
+
height: t.height == null ? '' : t.height,
|
|
41
|
+
chromeSessionId: t.chromeSessionId || '',
|
|
42
|
+
successorTabId: t.successorTabId == null ? '' : t.successorTabId,
|
|
43
|
+
splitViewId: t.splitViewId == null ? '' : t.splitViewId,
|
|
44
|
+
selected: !!t.selected,
|
|
45
|
+
mutedReason: t.mutedReason || '',
|
|
46
|
+
mutedExtensionId: t.mutedExtensionId || '',
|
|
47
|
+
targetType: t.targetType || t.type || '',
|
|
48
|
+
subtype: t.subtype || '',
|
|
49
|
+
openerId: t.openerId || '',
|
|
50
|
+
openerFrameId: t.openerFrameId || '',
|
|
51
|
+
parentFrameId: t.parentFrameId || '',
|
|
52
|
+
canAccessOpener: !!t.canAccessOpener,
|
|
53
|
+
cdpAttached: t.cdpAttached,
|
|
54
|
+
browserContextId: t.browserContextId || '',
|
|
55
|
+
cookieStoreId: t.cookieStoreId == null ? '' : String(t.cookieStoreId),
|
|
56
|
+
parent_sessionId: t.parent_sessionId || '',
|
|
57
|
+
parent_targetId: t.parent_targetId || '',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function buildMap(catalog) {
|
|
62
|
+
const handles = {};
|
|
63
|
+
let n = 0;
|
|
64
|
+
for (const w of catalog.windows || []) {
|
|
65
|
+
for (const t of w.tabs || []) {
|
|
66
|
+
n += 1;
|
|
67
|
+
handles[String(n)] = rowHandle({
|
|
68
|
+
...t,
|
|
69
|
+
kind: 'tab',
|
|
70
|
+
windowId: t.windowId || w.windowId,
|
|
71
|
+
current: !!w.current,
|
|
72
|
+
incognito: t.incognito || w.incognito,
|
|
73
|
+
}, n);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
(catalog.attached || []).forEach((t, i) => {
|
|
77
|
+
const h = `A${i + 1}`;
|
|
78
|
+
handles[h] = rowHandle({ ...t, kind: 'attached' }, h);
|
|
79
|
+
});
|
|
80
|
+
(catalog.stale || []).forEach((t, i) => {
|
|
81
|
+
const h = `S${i + 1}`;
|
|
82
|
+
handles[h] = rowHandle({ ...t, kind: 'stale' }, h);
|
|
83
|
+
});
|
|
84
|
+
(catalog.iframes || []).forEach((t, i) => {
|
|
85
|
+
const h = `I${i + 1}`;
|
|
86
|
+
handles[h] = rowHandle({ ...t, kind: 'iframe', attached: true }, h);
|
|
87
|
+
});
|
|
88
|
+
(catalog.other || []).forEach((t, i) => {
|
|
89
|
+
const h = `O${i + 1}`;
|
|
90
|
+
handles[h] = rowHandle({ ...t, kind: 'other', attached: true }, h);
|
|
91
|
+
});
|
|
92
|
+
return { handles };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function writeMap(catalog) {
|
|
96
|
+
const payload = { ...buildMap(catalog), writtenAt: Date.now() };
|
|
97
|
+
fs.writeFileSync(mapPath(), `${JSON.stringify(payload, null, 2)}\n`);
|
|
98
|
+
return payload;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function readMap() {
|
|
102
|
+
const p = mapPath();
|
|
103
|
+
if (!fs.existsSync(p)) return { handles: {} };
|
|
104
|
+
try {
|
|
105
|
+
const data = JSON.parse(fs.readFileSync(p, 'utf8'));
|
|
106
|
+
return data && data.handles ? data : { handles: {} };
|
|
107
|
+
} catch {
|
|
108
|
+
return { handles: {} };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function resolveRef(opts) {
|
|
113
|
+
return resolveChain(opts);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function resolveChain({
|
|
117
|
+
current, incognito, windowId, index, handle, tabId, targetId, sessionId, browserContextId, iframe,
|
|
118
|
+
active, attached, discarded, highlighted, pinned, status, title, focusedWindowId, openerTabId, groupId,
|
|
119
|
+
cookieStoreId, map,
|
|
120
|
+
} = {}) {
|
|
121
|
+
const src = map && map.handles ? map : readMap();
|
|
122
|
+
let rows = Object.values(src.handles || {});
|
|
123
|
+
const via = [];
|
|
124
|
+
const fail = (err) => ({ row: null, via: via.join('>'), error: err });
|
|
125
|
+
if (current) {
|
|
126
|
+
rows = rows.filter((r) => r.current);
|
|
127
|
+
via.push('current');
|
|
128
|
+
if (!rows.length) return fail('current');
|
|
129
|
+
}
|
|
130
|
+
if (incognito) {
|
|
131
|
+
rows = rows.filter((r) => r.incognito);
|
|
132
|
+
via.push('incognito');
|
|
133
|
+
if (!rows.length) return fail('incognito');
|
|
134
|
+
}
|
|
135
|
+
if (windowId != null && windowId !== '') {
|
|
136
|
+
const id = Number(windowId);
|
|
137
|
+
rows = rows.filter((r) => Number(r.windowId) === id);
|
|
138
|
+
via.push('window');
|
|
139
|
+
if (!rows.length) return fail('window');
|
|
140
|
+
}
|
|
141
|
+
if (focusedWindowId != null && focusedWindowId !== '') {
|
|
142
|
+
const id = Number(focusedWindowId);
|
|
143
|
+
rows = rows.filter((r) => Number(r.windowId) === id);
|
|
144
|
+
via.push('focusedWindowId');
|
|
145
|
+
if (!rows.length) return fail('focusedWindowId');
|
|
146
|
+
}
|
|
147
|
+
if (active) {
|
|
148
|
+
rows = rows.filter((r) => r.active);
|
|
149
|
+
via.push('active');
|
|
150
|
+
if (!rows.length) return fail('active');
|
|
151
|
+
}
|
|
152
|
+
if (attached) {
|
|
153
|
+
rows = rows.filter((r) => r.attached);
|
|
154
|
+
via.push('attached');
|
|
155
|
+
if (!rows.length) return fail('attached');
|
|
156
|
+
}
|
|
157
|
+
if (discarded) {
|
|
158
|
+
rows = rows.filter((r) => r.discarded);
|
|
159
|
+
via.push('discarded');
|
|
160
|
+
if (!rows.length) return fail('discarded');
|
|
161
|
+
}
|
|
162
|
+
if (highlighted) {
|
|
163
|
+
rows = rows.filter((r) => r.highlighted);
|
|
164
|
+
via.push('highlighted');
|
|
165
|
+
if (!rows.length) return fail('highlighted');
|
|
166
|
+
}
|
|
167
|
+
if (pinned) {
|
|
168
|
+
rows = rows.filter((r) => r.pinned);
|
|
169
|
+
via.push('pinned');
|
|
170
|
+
if (!rows.length) return fail('pinned');
|
|
171
|
+
}
|
|
172
|
+
if (status != null && status !== '') {
|
|
173
|
+
const want = String(status).toLowerCase();
|
|
174
|
+
rows = rows.filter((r) => String(r.load || '').toLowerCase() === want);
|
|
175
|
+
via.push('status');
|
|
176
|
+
if (!rows.length) return fail('status');
|
|
177
|
+
}
|
|
178
|
+
if (title != null && title !== '') {
|
|
179
|
+
const needle = String(title).toLowerCase();
|
|
180
|
+
rows = rows.filter((r) => String(r.title || '').toLowerCase().includes(needle));
|
|
181
|
+
via.push('title');
|
|
182
|
+
if (!rows.length) return fail('title');
|
|
183
|
+
}
|
|
184
|
+
if (openerTabId != null && openerTabId !== '') {
|
|
185
|
+
const id = Number(openerTabId);
|
|
186
|
+
rows = rows.filter((r) => Number(r.openerTabId) === id);
|
|
187
|
+
via.push('openerTabId');
|
|
188
|
+
if (!rows.length) return fail('openerTabId');
|
|
189
|
+
}
|
|
190
|
+
if (groupId != null && groupId !== '') {
|
|
191
|
+
const id = String(groupId);
|
|
192
|
+
rows = rows.filter((r) => String(r.groupId) === id);
|
|
193
|
+
via.push('groupId');
|
|
194
|
+
if (!rows.length) return fail('groupId');
|
|
195
|
+
}
|
|
196
|
+
if (cookieStoreId != null && cookieStoreId !== '') {
|
|
197
|
+
const id = String(cookieStoreId);
|
|
198
|
+
rows = rows.filter((r) => String(r.cookieStoreId || '') === id);
|
|
199
|
+
via.push('cookieStoreId');
|
|
200
|
+
if (!rows.length) return fail('cookieStoreId');
|
|
201
|
+
}
|
|
202
|
+
if (index != null && index !== '') {
|
|
203
|
+
const n = Number(index);
|
|
204
|
+
rows = rows.filter((r) => Number(r.index) === n);
|
|
205
|
+
via.push('index');
|
|
206
|
+
if (!rows.length) return fail('index');
|
|
207
|
+
}
|
|
208
|
+
if (iframe) {
|
|
209
|
+
rows = rows.filter((r) => r.kind === 'iframe');
|
|
210
|
+
via.push('iframe');
|
|
211
|
+
if (!rows.length) return fail('iframe');
|
|
212
|
+
}
|
|
213
|
+
if (handle != null && handle !== '') {
|
|
214
|
+
const hit = src.handles[String(handle)];
|
|
215
|
+
if (!hit) return fail('handle');
|
|
216
|
+
if (rows.length && !rows.some((r) => r.handle === hit.handle)) {
|
|
217
|
+
via.push('handle');
|
|
218
|
+
return fail('handle_not_in_window');
|
|
219
|
+
}
|
|
220
|
+
rows = [hit];
|
|
221
|
+
via.push('handle');
|
|
222
|
+
}
|
|
223
|
+
if (tabId != null && tabId !== '') {
|
|
224
|
+
const id = Number(tabId);
|
|
225
|
+
const hit = rows.find((r) => Number(r.tabId) === id);
|
|
226
|
+
if (!hit) {
|
|
227
|
+
via.push('tab');
|
|
228
|
+
return fail('tab');
|
|
229
|
+
}
|
|
230
|
+
rows = [hit];
|
|
231
|
+
via.push('tab');
|
|
232
|
+
}
|
|
233
|
+
if (targetId) {
|
|
234
|
+
const hit = rows.find((r) => r.targetId === targetId);
|
|
235
|
+
if (!hit) {
|
|
236
|
+
via.push('target');
|
|
237
|
+
return fail('target');
|
|
238
|
+
}
|
|
239
|
+
rows = [hit];
|
|
240
|
+
via.push('target');
|
|
241
|
+
}
|
|
242
|
+
if (sessionId) {
|
|
243
|
+
const hit = rows.find((r) => r.sessionId === sessionId);
|
|
244
|
+
if (!hit) {
|
|
245
|
+
via.push('session');
|
|
246
|
+
return fail('session');
|
|
247
|
+
}
|
|
248
|
+
rows = [hit];
|
|
249
|
+
via.push('session');
|
|
250
|
+
}
|
|
251
|
+
if (browserContextId) {
|
|
252
|
+
const hit = rows.find((r) => r.browserContextId === browserContextId);
|
|
253
|
+
if (!hit) {
|
|
254
|
+
via.push('context');
|
|
255
|
+
return fail('context');
|
|
256
|
+
}
|
|
257
|
+
rows = [hit];
|
|
258
|
+
via.push('context');
|
|
259
|
+
}
|
|
260
|
+
if (rows.length === 1) return { row: rows[0], via: via.join('>') || 'unique' };
|
|
261
|
+
const coarse = via.includes('window') || via.includes('focusedWindowId') || via.includes('current') || via.includes('incognito');
|
|
262
|
+
if (rows.length > 1 && coarse && !handle && (tabId == null || tabId === '') && !sessionId && !targetId && (index == null || index === '')) {
|
|
263
|
+
const active = rows.find((r) => r.active && r.sessionId && r.kind !== 'iframe');
|
|
264
|
+
if (active) return { row: active, via: via.concat('active').join('>') };
|
|
265
|
+
}
|
|
266
|
+
if (rows.length > 1) return { row: null, via: via.join('>'), error: 'ambiguous' };
|
|
267
|
+
return { row: null, via: via.join('>'), error: 'empty' };
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function lookslikeHandle(token) {
|
|
271
|
+
return typeof token === 'string' && /^(?:\d+|[ASI]\d+)$/i.test(token);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
module.exports = {
|
|
275
|
+
mapPath,
|
|
276
|
+
buildMap,
|
|
277
|
+
writeMap,
|
|
278
|
+
readMap,
|
|
279
|
+
resolveRef,
|
|
280
|
+
resolveChain,
|
|
281
|
+
lookslikeHandle,
|
|
282
|
+
};
|
package/lib/tab-tui.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// 16-color SGR only (see docs/tab-identity.scorched.json for tab TUI roles).
|
|
4
|
+
// one field per line; labels dim; ids 96; url 94; no 38;5 / 38;2
|
|
5
|
+
const NC = '\x1b[0m';
|
|
6
|
+
const DIM = '\x1b[2m';
|
|
7
|
+
const GREEN = '\x1b[32m';
|
|
8
|
+
const YELLOW = '\x1b[33m';
|
|
9
|
+
const CYAN = '\x1b[96m';
|
|
10
|
+
const LIME = '\x1b[92m';
|
|
11
|
+
const WHITE = '\x1b[97m';
|
|
12
|
+
const VALUE = YELLOW;
|
|
13
|
+
const GREY = VALUE;
|
|
14
|
+
const OTHER = '\x1b[90m';
|
|
15
|
+
const CURRENT = '\x1b[93m';
|
|
16
|
+
const MAGENTA = '\x1b[95m';
|
|
17
|
+
const BLUE = '\x1b[94m';
|
|
18
|
+
|
|
19
|
+
const WIN = ' ';
|
|
20
|
+
const TAB = ' ';
|
|
21
|
+
|
|
22
|
+
function lab(s) {
|
|
23
|
+
return `${DIM}${s}${NC}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function val(sgr, s) {
|
|
27
|
+
return `${sgr}${s}${NC}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function dash(v) {
|
|
31
|
+
if (v == null || v === '') return '-';
|
|
32
|
+
return String(v);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function kv(indent, label, value, sgr) {
|
|
36
|
+
return `${indent}${lab(`${label}:`)} ${val(sgr, dash(value))}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function kvBool(indent, label, b, onSgr, offSgr) {
|
|
40
|
+
return kv(indent, label, b ? 'true' : 'false', b ? (onSgr || LIME) : (offSgr || VALUE));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function attachStatus(kind) {
|
|
44
|
+
if (kind === 'attached') return ['attached', LIME];
|
|
45
|
+
if (kind === 'stale') return ['stale', YELLOW];
|
|
46
|
+
return ['not attached', VALUE];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function printWindow(lines, w) {
|
|
50
|
+
lines.push(lab('window'));
|
|
51
|
+
lines.push(kv(WIN, 'windowId', w.windowId, CYAN));
|
|
52
|
+
lines.push(kvBool(WIN, 'current', !!w.current, CURRENT, VALUE));
|
|
53
|
+
lines.push(kvBool(WIN, 'focused', !!w.focused, LIME, VALUE));
|
|
54
|
+
lines.push(kvBool(WIN, 'incognito', !!w.incognito, MAGENTA, VALUE));
|
|
55
|
+
lines.push(kv(WIN, 'incognitoSource', w.incognitoSource || '', VALUE));
|
|
56
|
+
lines.push(kv(WIN, 'type', w.type || '', VALUE));
|
|
57
|
+
lines.push(kv(WIN, 'state', w.state || '', VALUE));
|
|
58
|
+
lines.push(kvBool(WIN, 'alwaysOnTop', !!w.alwaysOnTop));
|
|
59
|
+
lines.push(kv(WIN, 'width', w.width, CYAN));
|
|
60
|
+
lines.push(kv(WIN, 'height', w.height, CYAN));
|
|
61
|
+
lines.push(kv(WIN, 'left', w.left, CYAN));
|
|
62
|
+
lines.push(kv(WIN, 'top', w.top, CYAN));
|
|
63
|
+
lines.push(kv(WIN, 'chromeSessionId', w.chromeSessionId || '', CYAN));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function printTab(lines, t, handle, activeSessionId, kind) {
|
|
67
|
+
const pin = t.sessionId && t.sessionId === activeSessionId;
|
|
68
|
+
const mark = pin ? `${val(GREEN, '*')} ` : ' ';
|
|
69
|
+
const [st, stSgr] = attachStatus(kind);
|
|
70
|
+
const head = t.title ? val(WHITE, t.title) : val(BLUE, t.url || '-');
|
|
71
|
+
lines.push(`${mark}${val(CYAN, `[${handle}]`)} ${head}`);
|
|
72
|
+
lines.push(kv(TAB, 'handle', handle, CYAN));
|
|
73
|
+
lines.push(kv(TAB, 'kind', t.kind || 'tab', VALUE));
|
|
74
|
+
lines.push(kv(TAB, 'index', t.index, CYAN));
|
|
75
|
+
lines.push(kv(TAB, 'tabId', t.tabId, CYAN));
|
|
76
|
+
lines.push(kv(TAB, 'windowId', t.windowId, CYAN));
|
|
77
|
+
lines.push(kv(TAB, 'title', t.title || '', WHITE));
|
|
78
|
+
lines.push(kv(TAB, 'url', t.url || '', BLUE));
|
|
79
|
+
lines.push(kv(TAB, 'status', st, stSgr));
|
|
80
|
+
lines.push(kv(TAB, 'load', t.load || '', t.load === 'loading' ? YELLOW : VALUE));
|
|
81
|
+
lines.push(kvBool(TAB, 'active', !!t.active));
|
|
82
|
+
lines.push(kvBool(TAB, 'highlighted', !!t.highlighted));
|
|
83
|
+
lines.push(kvBool(TAB, 'pinned', !!t.pinned));
|
|
84
|
+
lines.push(kvBool(TAB, 'discarded', !!t.discarded));
|
|
85
|
+
lines.push(kvBool(TAB, 'attached', !!t.attached || kind === 'attached'));
|
|
86
|
+
lines.push(kvBool(TAB, 'incognito', !!t.incognito, MAGENTA, VALUE));
|
|
87
|
+
lines.push(kv(TAB, 'incognitoSource', t.incognitoSource || '', VALUE));
|
|
88
|
+
lines.push(kvBool(TAB, 'audible', !!t.audible));
|
|
89
|
+
lines.push(kvBool(TAB, 'muted', !!t.muted));
|
|
90
|
+
lines.push(kv(TAB, 'mutedReason', t.mutedReason || '', VALUE));
|
|
91
|
+
lines.push(kv(TAB, 'mutedExtensionId', t.mutedExtensionId || '', CYAN));
|
|
92
|
+
lines.push(kvBool(TAB, 'autoDiscardable', t.autoDiscardable !== false));
|
|
93
|
+
lines.push(kv(TAB, 'groupId', t.groupId, CYAN));
|
|
94
|
+
lines.push(kv(TAB, 'openerTabId', t.openerTabId, CYAN));
|
|
95
|
+
lines.push(kv(TAB, 'pendingUrl', t.pendingUrl || '', BLUE));
|
|
96
|
+
lines.push(kv(TAB, 'favIconUrl', t.favIconUrl || '', BLUE));
|
|
97
|
+
lines.push(kvBool(TAB, 'frozen', !!t.frozen));
|
|
98
|
+
lines.push(kv(TAB, 'lastAccessed', t.lastAccessed, CYAN));
|
|
99
|
+
lines.push(kv(TAB, 'width', t.width, CYAN));
|
|
100
|
+
lines.push(kv(TAB, 'height', t.height, CYAN));
|
|
101
|
+
lines.push(kv(TAB, 'chromeSessionId', t.chromeSessionId || '', CYAN));
|
|
102
|
+
lines.push(kv(TAB, 'successorTabId', t.successorTabId, CYAN));
|
|
103
|
+
lines.push(kv(TAB, 'splitViewId', t.splitViewId, CYAN));
|
|
104
|
+
lines.push(kvBool(TAB, 'selected', !!t.selected));
|
|
105
|
+
lines.push(kv(TAB, 'sessionId', t.sessionId || '', CYAN));
|
|
106
|
+
lines.push(kv(TAB, 'targetId', t.targetId || '', CYAN));
|
|
107
|
+
lines.push(kv(TAB, 'targetType', t.targetType || t.type || '', VALUE));
|
|
108
|
+
lines.push(kv(TAB, 'subtype', t.subtype || '', VALUE));
|
|
109
|
+
lines.push(kv(TAB, 'browserContextId', t.browserContextId || '', CYAN));
|
|
110
|
+
lines.push(kv(TAB, 'openerId', t.openerId || '', CYAN));
|
|
111
|
+
lines.push(kv(TAB, 'openerFrameId', t.openerFrameId || '', CYAN));
|
|
112
|
+
lines.push(kv(TAB, 'parentFrameId', t.parentFrameId || '', CYAN));
|
|
113
|
+
lines.push(kvBool(TAB, 'canAccessOpener', !!t.canAccessOpener));
|
|
114
|
+
lines.push(kv(TAB, 'cdpAttached', t.cdpAttached == null ? '' : t.cdpAttached, t.cdpAttached ? LIME : VALUE));
|
|
115
|
+
lines.push(kv(TAB, 'parent_sessionId', t.parent_sessionId || '', CYAN));
|
|
116
|
+
lines.push(kv(TAB, 'parent_targetId', t.parent_targetId || '', CYAN));
|
|
117
|
+
if (t.reason) lines.push(kv(TAB, 'reason', t.reason, VALUE));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function formatCatalogTui(catalog, activeSessionId) {
|
|
121
|
+
const lines = [];
|
|
122
|
+
const winCount = catalog.windows.reduce((n, w) => n + (w.tabs || []).length, 0);
|
|
123
|
+
lines.push(`${val(GREEN, String(winCount))} tab(s) in ${catalog.windows.length} window(s)`);
|
|
124
|
+
lines.push('');
|
|
125
|
+
let n = 0;
|
|
126
|
+
for (const w of catalog.windows) {
|
|
127
|
+
printWindow(lines, w);
|
|
128
|
+
for (const t of w.tabs || []) {
|
|
129
|
+
n += 1;
|
|
130
|
+
printTab(lines, { ...t, kind: t.kind || 'tab' }, String(n), activeSessionId, t.attached ? 'attached' : 'not_attached');
|
|
131
|
+
}
|
|
132
|
+
lines.push('');
|
|
133
|
+
}
|
|
134
|
+
if ((catalog.attached || []).length) {
|
|
135
|
+
lines.push(`${DIM}attached (debugger, not in chrome.tabs)${NC}`);
|
|
136
|
+
catalog.attached.forEach((t, i) => {
|
|
137
|
+
printTab(lines, { ...t, kind: t.kind || 'attached' }, `A${i + 1}`, activeSessionId, 'attached');
|
|
138
|
+
});
|
|
139
|
+
lines.push('');
|
|
140
|
+
}
|
|
141
|
+
if ((catalog.stale || []).length) {
|
|
142
|
+
lines.push(`${val(YELLOW, 'stale')} ${lab('(dropped from map)')}`);
|
|
143
|
+
catalog.stale.forEach((t, i) => {
|
|
144
|
+
printTab(lines, { ...t, kind: t.kind || 'stale' }, `S${i + 1}`, activeSessionId, 'stale');
|
|
145
|
+
});
|
|
146
|
+
lines.push('');
|
|
147
|
+
}
|
|
148
|
+
if ((catalog.iframes || []).length) {
|
|
149
|
+
lines.push(`${DIM}iframes (OOPIF)${NC}`);
|
|
150
|
+
catalog.iframes.forEach((t, i) => {
|
|
151
|
+
printTab(lines, { ...t, kind: t.kind || 'iframe' }, `I${i + 1}`, activeSessionId, 'attached');
|
|
152
|
+
});
|
|
153
|
+
lines.push('');
|
|
154
|
+
}
|
|
155
|
+
if ((catalog.other || []).length) {
|
|
156
|
+
lines.push(`${DIM}other (cdp non-page)${NC}`);
|
|
157
|
+
catalog.other.forEach((t, i) => {
|
|
158
|
+
printTab(lines, { ...t, kind: t.kind || t.targetType || 'other' }, `O${i + 1}`, activeSessionId, 'attached');
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return lines.join('\n');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
module.exports = {
|
|
165
|
+
formatCatalogTui,
|
|
166
|
+
LIME,
|
|
167
|
+
GREY,
|
|
168
|
+
WHITE,
|
|
169
|
+
VALUE,
|
|
170
|
+
OTHER,
|
|
171
|
+
DIM,
|
|
172
|
+
GREEN,
|
|
173
|
+
CYAN,
|
|
174
|
+
YELLOW,
|
|
175
|
+
CURRENT,
|
|
176
|
+
MAGENTA,
|
|
177
|
+
BLUE,
|
|
178
|
+
NC,
|
|
179
|
+
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glidercli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.31",
|
|
4
4
|
"description": "Browser automation CLI. Control a configured Chromium browser through an extension CDP relay, run YAML tasks, and execute bounded autonomous loops.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"glider": "bin/glider.js"
|
|
7
7
|
},
|
|
8
8
|
"scripts": {
|
|
9
9
|
"test": "node --test tests/*.test.js",
|
|
10
|
-
"test:syntax": "node --check bin/glider.js && node --check lib/bserve.js && node --check lib/bexplore.js && node --check lib/tab-catalog.js && node --check lib/pin-machine.js && node --check lib/relay-heal.js && node --check lib/pkg-update.js",
|
|
11
|
-
"test:regression": "node --test tests/browser-config.test.js tests/core.test.js tests/cli-regression.test.js tests/relay-integration.test.js",
|
|
10
|
+
"test:syntax": "node --check bin/glider.js && node --check lib/bserve.js && node --check lib/bexplore.js && node --check lib/tab-catalog.js && node --check lib/tab-tui.js && node --check lib/tab-map.js && node --check lib/pin-machine.js && node --check lib/relay-heal.js && node --check lib/pkg-update.js && node --check lib/cookie-jar.js",
|
|
11
|
+
"test:regression": "node --test tests/browser-config.test.js tests/core.test.js tests/cli-regression.test.js tests/relay-integration.test.js tests/tab-tui-color-regression.test.js tests/tab-map.test.js tests/tab-catalog.test.js",
|
|
12
12
|
"test:integration": "node --test tests/relay-integration.test.js tests/daemon-lifecycle.test.js",
|
|
13
13
|
"test:pack": "node --test tests/npm-tarball.test.js",
|
|
14
14
|
"test:smoke": "node tests/live-browser.smoke.js",
|