glidercli 0.4.19 → 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 +378 -61
- package/docs/setup.json +6 -2
- package/docs/tab-identity.scorched.json +2042 -0
- package/lib/bwindow.js +8 -6
- package/lib/cookie-jar.js +233 -0
- package/lib/paths.js +25 -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-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",
|