reslop 0.2.5 → 0.2.7
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/CHANGELOG.md +22 -1
- package/LICENSE +1 -1
- package/README.md +11 -11
- package/bin/reslop.js +3 -8
- package/lib/ansi.js +72 -19
- package/lib/api.js +1 -1
- package/lib/capabilities.js +8 -8
- package/lib/cli.js +61 -75
- package/lib/clipboard.js +39 -47
- package/lib/dashboard/git.js +128 -0
- package/lib/dashboard/model.js +357 -0
- package/lib/dashboard/npm.js +290 -0
- package/lib/dashboard/tree.js +278 -0
- package/lib/deps-diff.js +197 -402
- package/lib/deps.js +113 -240
- package/lib/detect.js +8 -18
- package/lib/diff/align.js +41 -113
- package/lib/diff/diff.js +12 -43
- package/lib/diff/display.js +25 -36
- package/lib/diff/edit.js +6 -20
- package/lib/diff/inline.js +76 -144
- package/lib/diff/items.js +33 -47
- package/lib/diff/parse.js +28 -56
- package/lib/diff/patch.js +12 -33
- package/lib/diff/unit.js +79 -178
- package/lib/editor.js +52 -69
- package/lib/files.js +79 -91
- package/lib/find.js +61 -0
- package/lib/git-branches.js +254 -416
- package/lib/git-deps.js +148 -272
- package/lib/git-reword-todo.js +5 -13
- package/lib/git-worktree.js +161 -214
- package/lib/git.js +21 -49
- package/lib/github.js +67 -181
- package/lib/gitlab.js +40 -90
- package/lib/highlight/bash.js +55 -177
- package/lib/highlight/core.js +155 -141
- package/lib/highlight/css.js +25 -58
- package/lib/highlight/csv.js +19 -37
- package/lib/highlight/dart.js +72 -213
- package/lib/highlight/dot.js +14 -14
- package/lib/highlight/html.js +42 -63
- package/lib/highlight/js.js +177 -506
- package/lib/highlight/json.js +17 -37
- package/lib/highlight/log.js +19 -25
- package/lib/highlight/txt.js +7 -10
- package/lib/highlight.js +17 -46
- package/lib/keys.js +75 -83
- package/lib/manifest.js +67 -126
- package/lib/npm-commands.js +120 -169
- package/lib/remote.js +140 -190
- package/lib/render/branches.js +63 -61
- package/lib/render/chrome.js +412 -347
- package/lib/render/commits.js +160 -361
- package/lib/render/dash-activity.js +212 -0
- package/lib/render/dash-blocks.js +496 -0
- package/lib/render/dash-table.js +295 -0
- package/lib/render/dashboard.js +62 -0
- package/lib/render/diff.js +123 -258
- package/lib/render/files.js +60 -86
- package/lib/render/frame.js +82 -117
- package/lib/render/notes.js +150 -210
- package/lib/render/npm.js +213 -177
- package/lib/render/packages.js +93 -0
- package/lib/render/present.js +4 -11
- package/lib/render/primitives.js +77 -172
- package/lib/render/render.js +5 -14
- package/lib/render/report.js +43 -0
- package/lib/render/repos.js +226 -0
- package/lib/render/search.js +25 -0
- package/lib/render/tiles.js +355 -0
- package/lib/render/unit.js +15 -31
- package/lib/report-model.js +110 -33
- package/lib/report-parse.js +56 -37
- package/lib/report-render.js +102 -59
- package/lib/report-run.js +87 -77
- package/lib/report-test.js +221 -99
- package/lib/report-tools.js +96 -154
- package/lib/review-merge.js +33 -41
- package/lib/review.js +69 -129
- package/lib/runs.js +225 -0
- package/lib/select.js +53 -91
- package/lib/session/accessors.js +14 -21
- package/lib/session/actions.js +189 -65
- package/lib/session/branches.js +164 -222
- package/lib/session/change-actions.js +49 -119
- package/lib/session/commit.js +298 -352
- package/lib/session/compose.js +572 -715
- package/lib/session/dashboard.js +530 -0
- package/lib/session/dispatch.js +197 -171
- package/lib/session/files-pane.js +92 -45
- package/lib/session/find.js +94 -0
- package/lib/session/items.js +6 -17
- package/lib/session/lifecycle.js +420 -466
- package/lib/session/load.js +1 -14
- package/lib/session/navigation.js +4 -2
- package/lib/session/npm.js +403 -420
- package/lib/session/ops.js +5 -13
- package/lib/session/packages.js +143 -0
- package/lib/session/pointer.js +30 -14
- package/lib/session/progress.js +39 -30
- package/lib/session/review.js +1 -3
- package/lib/session/tasks.js +277 -236
- package/lib/session/templates.js +51 -59
- package/lib/session/terminal.js +85 -132
- package/lib/session/view.js +59 -80
- package/lib/session/watch.js +201 -212
- package/lib/session/workspace.js +455 -0
- package/lib/session.js +95 -161
- package/lib/update.js +44 -111
- package/lib/utilities.js +46 -88
- package/lib/workspace.js +166 -0
- package/lib/wrap.js +29 -55
- package/package.json +1 -1
package/lib/select.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const ansi = require('./ansi.js');
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
const { visibleWidth } = ansi;
|
|
4
|
+
const { ESC, RESET, THEME, seq, fg, bg, stripAnsi, visibleWidth } = ansi;
|
|
5
|
+
const { graphemes, graphemeWidth, firstGrapheme } = ansi;
|
|
7
6
|
|
|
8
7
|
const CSI_FINAL = /[@-~]/;
|
|
8
|
+
const TRUECOLOR = 2;
|
|
9
9
|
|
|
10
10
|
const isRange = (sel) => {
|
|
11
11
|
if (!sel || !sel.start || !sel.end) return false;
|
|
@@ -13,21 +13,16 @@ const isRange = (sel) => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
const ordered = (sel) => {
|
|
16
|
-
const start = sel
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
if (start.y > end.y) return { first: end, last: start };
|
|
20
|
-
if (start.x <= end.x) return { first: start, last: end };
|
|
21
|
-
return { first: end, last: start };
|
|
16
|
+
const { start, end } = sel;
|
|
17
|
+
const forward = start.y < end.y || (start.y === end.y && start.x <= end.x);
|
|
18
|
+
return forward ? { first: start, last: end } : { first: end, last: start };
|
|
22
19
|
};
|
|
23
20
|
|
|
24
21
|
const slicePlain = (plain, fromCol, toCol) => {
|
|
25
|
-
const parts = graphemes(plain);
|
|
26
22
|
let col = 0;
|
|
27
23
|
let out = '';
|
|
28
|
-
for (const ch of
|
|
29
|
-
const
|
|
30
|
-
const next = col + w;
|
|
24
|
+
for (const ch of graphemes(plain)) {
|
|
25
|
+
const next = col + graphemeWidth(ch, col);
|
|
31
26
|
if (next > fromCol && col < toCol) out += ch;
|
|
32
27
|
col = next;
|
|
33
28
|
if (col >= toCol) break;
|
|
@@ -39,10 +34,8 @@ const lineRange = (rowIndex, sel) => {
|
|
|
39
34
|
const { first, last } = ordered(sel);
|
|
40
35
|
const y = rowIndex + 1;
|
|
41
36
|
if (y < first.y || y > last.y) return null;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (y === first.y) from = first.x - 1;
|
|
45
|
-
if (y === last.y) to = last.x;
|
|
37
|
+
const from = y === first.y ? first.x - 1 : 0;
|
|
38
|
+
const to = y === last.y ? last.x : Infinity;
|
|
46
39
|
if (to <= from) return null;
|
|
47
40
|
return { from, to };
|
|
48
41
|
};
|
|
@@ -61,11 +54,10 @@ const extractText = (rows, sel) => {
|
|
|
61
54
|
return lines.join('\n');
|
|
62
55
|
};
|
|
63
56
|
|
|
64
|
-
const
|
|
57
|
+
const csiEnd = (line, i) => {
|
|
65
58
|
let j = i + 2;
|
|
66
59
|
while (j < line.length && !CSI_FINAL.test(line[j])) j += 1;
|
|
67
|
-
|
|
68
|
-
return j;
|
|
60
|
+
return j < line.length ? j + 1 : j;
|
|
69
61
|
};
|
|
70
62
|
|
|
71
63
|
const parseParams = (body) => {
|
|
@@ -74,45 +66,30 @@ const parseParams = (body) => {
|
|
|
74
66
|
};
|
|
75
67
|
|
|
76
68
|
const applyRgb = (state, field, params, i) => {
|
|
77
|
-
const TRUECOLOR = 2;
|
|
78
69
|
const isTruecolor = params[i + 1] === TRUECOLOR;
|
|
79
|
-
|
|
80
|
-
if (!hasRgb) return 1;
|
|
70
|
+
if (!isTruecolor || i + 4 >= params.length) return 1;
|
|
81
71
|
state[field] = [params[i + 2], params[i + 3], params[i + 4]];
|
|
82
72
|
return 5;
|
|
83
73
|
};
|
|
84
74
|
|
|
85
|
-
const SGR = {
|
|
86
|
-
0: (state) => {
|
|
87
|
-
state.fg = null;
|
|
88
|
-
state.bg = null;
|
|
89
|
-
return 1;
|
|
90
|
-
},
|
|
91
|
-
38: (state, params, i) => applyRgb(state, 'fg', params, i),
|
|
92
|
-
48: (state, params, i) => applyRgb(state, 'bg', params, i),
|
|
93
|
-
39: (state) => {
|
|
94
|
-
state.fg = null;
|
|
95
|
-
return 1;
|
|
96
|
-
},
|
|
97
|
-
49: (state) => {
|
|
98
|
-
state.bg = null;
|
|
99
|
-
return 1;
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
|
|
103
75
|
const applySgr = (params, state) => {
|
|
104
76
|
let i = 0;
|
|
105
77
|
while (i < params.length) {
|
|
106
|
-
const
|
|
107
|
-
|
|
78
|
+
const code = params[i];
|
|
79
|
+
if (code === 38) {
|
|
80
|
+
i += applyRgb(state, 'fg', params, i);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (code === 48) {
|
|
84
|
+
i += applyRgb(state, 'bg', params, i);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (code === 0 || code === 39) state.fg = null;
|
|
88
|
+
if (code === 0 || code === 49) state.bg = null;
|
|
89
|
+
i += 1;
|
|
108
90
|
}
|
|
109
91
|
};
|
|
110
92
|
|
|
111
|
-
const nextGrapheme = (line, index) => {
|
|
112
|
-
const parts = graphemes(line.slice(index));
|
|
113
|
-
return parts[0] ?? '';
|
|
114
|
-
};
|
|
115
|
-
|
|
116
93
|
const parseCells = (line) => {
|
|
117
94
|
const cells = [];
|
|
118
95
|
const state = { fg: null, bg: null };
|
|
@@ -120,24 +97,21 @@ const parseCells = (line) => {
|
|
|
120
97
|
let i = 0;
|
|
121
98
|
while (i < line.length) {
|
|
122
99
|
if (line[i] === ESC && line[i + 1] === '[') {
|
|
123
|
-
const
|
|
124
|
-
if (line[
|
|
125
|
-
|
|
126
|
-
applySgr(parseParams(body), state);
|
|
100
|
+
const end = csiEnd(line, i);
|
|
101
|
+
if (line[end - 1] === 'm') {
|
|
102
|
+
applySgr(parseParams(line.slice(i + 2, end - 1)), state);
|
|
127
103
|
}
|
|
128
|
-
i =
|
|
104
|
+
i = end;
|
|
129
105
|
continue;
|
|
130
106
|
}
|
|
131
107
|
if (line[i] === ESC) {
|
|
132
108
|
i += 1;
|
|
133
109
|
continue;
|
|
134
110
|
}
|
|
135
|
-
const ch =
|
|
111
|
+
const ch = firstGrapheme(line.slice(i));
|
|
136
112
|
if (!ch) break;
|
|
137
113
|
const width = graphemeWidth(ch, col);
|
|
138
|
-
|
|
139
|
-
const bg = state.bg;
|
|
140
|
-
cells.push({ ch, fg, bg, col, width });
|
|
114
|
+
cells.push({ ch, fg: state.fg, bg: state.bg, col, width });
|
|
141
115
|
col += width;
|
|
142
116
|
i += ch.length;
|
|
143
117
|
}
|
|
@@ -146,10 +120,10 @@ const parseCells = (line) => {
|
|
|
146
120
|
|
|
147
121
|
const rgbKey = (rgb) => (rgb ? `${rgb[0]},${rgb[1]},${rgb[2]}` : '');
|
|
148
122
|
|
|
149
|
-
const styleSeq = (
|
|
150
|
-
if (
|
|
151
|
-
if (
|
|
152
|
-
if (
|
|
123
|
+
const styleSeq = (fgRgb, bgRgb) => {
|
|
124
|
+
if (fgRgb && bgRgb) return RESET + seq(fgRgb, bgRgb);
|
|
125
|
+
if (fgRgb) return RESET + fg(fgRgb);
|
|
126
|
+
if (bgRgb) return RESET + bg(bgRgb);
|
|
153
127
|
return RESET;
|
|
154
128
|
};
|
|
155
129
|
|
|
@@ -160,17 +134,15 @@ const overlayRange = (line, fromCol, toCol) => {
|
|
|
160
134
|
let out = '';
|
|
161
135
|
let last = null;
|
|
162
136
|
for (const cell of cells) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
fg = cell.bg ?? THEME.ctxBg;
|
|
169
|
-
bg = cell.fg ?? THEME.ctxFg;
|
|
137
|
+
let cellFg = cell.fg;
|
|
138
|
+
let cellBg = cell.bg;
|
|
139
|
+
if (cell.col + cell.width > fromCol && cell.col < toCol) {
|
|
140
|
+
cellFg = cell.bg ?? THEME.ctxBg;
|
|
141
|
+
cellBg = cell.fg ?? THEME.ctxFg;
|
|
170
142
|
}
|
|
171
|
-
const key = `${rgbKey(
|
|
143
|
+
const key = `${rgbKey(cellFg)}|${rgbKey(cellBg)}`;
|
|
172
144
|
if (key !== last) {
|
|
173
|
-
out += styleSeq(
|
|
145
|
+
out += styleSeq(cellFg, cellBg);
|
|
174
146
|
last = key;
|
|
175
147
|
}
|
|
176
148
|
out += cell.ch;
|
|
@@ -178,35 +150,29 @@ const overlayRange = (line, fromCol, toCol) => {
|
|
|
178
150
|
return out;
|
|
179
151
|
};
|
|
180
152
|
|
|
181
|
-
const
|
|
153
|
+
const editorSelection = (view) => {
|
|
154
|
+
const source = view?.compose || view?.codeOverlay;
|
|
182
155
|
if (!source || typeof source.anchor !== 'number') return null;
|
|
183
156
|
const cursor = source.cursor ?? 0;
|
|
184
157
|
if (source.anchor === cursor) return null;
|
|
185
158
|
return { anchor: source.anchor, cursor };
|
|
186
159
|
};
|
|
187
160
|
|
|
188
|
-
const editorSelection = (view) => {
|
|
189
|
-
if (!view) return null;
|
|
190
|
-
if (view.compose) return selectionOf(view.compose);
|
|
191
|
-
return selectionOf(view.codeOverlay);
|
|
192
|
-
};
|
|
193
|
-
|
|
194
161
|
const spanCols = (hit, lo, hi) => {
|
|
195
162
|
const start = hit.start ?? 0;
|
|
196
163
|
const from = Math.max(lo, start);
|
|
197
164
|
const to = Math.min(hi, hit.limit ?? start);
|
|
198
165
|
if (to <= from) return null;
|
|
199
166
|
const text = hit.text ?? '';
|
|
200
|
-
const
|
|
201
|
-
const
|
|
202
|
-
const c0 = visibleWidth(text.slice(0, head));
|
|
203
|
-
const c1 = visibleWidth(text.slice(0, tail));
|
|
167
|
+
const c0 = visibleWidth(text.slice(0, Math.max(0, from - start)));
|
|
168
|
+
const c1 = visibleWidth(text.slice(0, Math.max(0, to - start)));
|
|
204
169
|
const scroll = hit.scroll ?? 0;
|
|
205
|
-
const
|
|
170
|
+
const textX = hit.textX ?? 1;
|
|
171
|
+
const room = Math.max(0, (hit.x1 ?? textX) - textX);
|
|
206
172
|
const vis0 = Math.max(c0, scroll);
|
|
207
173
|
const vis1 = Math.min(c1, scroll + room);
|
|
208
174
|
if (vis1 <= vis0) return null;
|
|
209
|
-
const origin =
|
|
175
|
+
const origin = textX - 1;
|
|
210
176
|
return { from: origin + vis0 - scroll, to: origin + vis1 - scroll };
|
|
211
177
|
};
|
|
212
178
|
|
|
@@ -220,9 +186,8 @@ const markEditorSelection = (rows, view, hits, color) => {
|
|
|
220
186
|
for (const hit of hits) {
|
|
221
187
|
if (!hit.live || !hit.y) continue;
|
|
222
188
|
const range = spanCols(hit, lo, hi);
|
|
223
|
-
if (!range) continue;
|
|
224
189
|
const i = hit.y - 1;
|
|
225
|
-
if (i < 0 || i >= next.length) continue;
|
|
190
|
+
if (!range || i < 0 || i >= next.length) continue;
|
|
226
191
|
next[i] = overlayRange(next[i], range.from, range.to);
|
|
227
192
|
}
|
|
228
193
|
return next;
|
|
@@ -230,13 +195,10 @@ const markEditorSelection = (rows, view, hits, color) => {
|
|
|
230
195
|
|
|
231
196
|
const overlayRows = (rows, sel) => {
|
|
232
197
|
if (!isRange(sel)) return rows;
|
|
233
|
-
|
|
234
|
-
const next = new Array(length);
|
|
235
|
-
for (let i = 0; i < length; i++) {
|
|
198
|
+
return rows.map((row, i) => {
|
|
236
199
|
const range = lineRange(i, sel);
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
return next;
|
|
200
|
+
return range ? overlayRange(row, range.from, range.to) : row;
|
|
201
|
+
});
|
|
240
202
|
};
|
|
241
203
|
|
|
242
204
|
module.exports = {
|
package/lib/session/accessors.js
CHANGED
|
@@ -1,33 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const bindAlias = (target, name, get, set) => {
|
|
4
|
-
const desc = { configurable: true, enumerable: true, get };
|
|
5
|
-
if (set) desc.set = set;
|
|
6
|
-
Object.defineProperty(target, name, desc);
|
|
7
|
-
};
|
|
8
|
-
|
|
9
3
|
const bindAccessors = (target, owner, names) => {
|
|
10
4
|
for (const name of names) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
Object.defineProperty(target, name, {
|
|
6
|
+
configurable: true,
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: () => owner[name],
|
|
9
|
+
set: (value) => {
|
|
10
|
+
owner[name] = value;
|
|
11
|
+
},
|
|
12
|
+
});
|
|
16
13
|
}
|
|
17
14
|
};
|
|
18
15
|
|
|
19
16
|
const bindGetters = (target, owner, names) => {
|
|
20
17
|
for (const name of names) {
|
|
21
|
-
|
|
18
|
+
Object.defineProperty(target, name, {
|
|
19
|
+
configurable: true,
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: () => owner[name],
|
|
22
|
+
});
|
|
22
23
|
}
|
|
23
24
|
};
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
const descriptors = Object.getOwnPropertyDescriptors(methods);
|
|
27
|
-
const view = Object.defineProperties({}, descriptors);
|
|
28
|
-
bindAccessors(view, state, writable);
|
|
29
|
-
bindGetters(view, state, readonly);
|
|
30
|
-
return view;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
module.exports = { bindAccessors, bindGetters, bindAlias, stateView };
|
|
26
|
+
module.exports = { bindAccessors, bindGetters };
|