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.
Files changed (114) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/LICENSE +1 -1
  3. package/README.md +11 -11
  4. package/bin/reslop.js +3 -8
  5. package/lib/ansi.js +72 -19
  6. package/lib/api.js +1 -1
  7. package/lib/capabilities.js +8 -8
  8. package/lib/cli.js +61 -75
  9. package/lib/clipboard.js +39 -47
  10. package/lib/dashboard/git.js +128 -0
  11. package/lib/dashboard/model.js +357 -0
  12. package/lib/dashboard/npm.js +290 -0
  13. package/lib/dashboard/tree.js +278 -0
  14. package/lib/deps-diff.js +197 -402
  15. package/lib/deps.js +113 -240
  16. package/lib/detect.js +8 -18
  17. package/lib/diff/align.js +41 -113
  18. package/lib/diff/diff.js +12 -43
  19. package/lib/diff/display.js +25 -36
  20. package/lib/diff/edit.js +6 -20
  21. package/lib/diff/inline.js +76 -144
  22. package/lib/diff/items.js +33 -47
  23. package/lib/diff/parse.js +28 -56
  24. package/lib/diff/patch.js +12 -33
  25. package/lib/diff/unit.js +79 -178
  26. package/lib/editor.js +52 -69
  27. package/lib/files.js +79 -91
  28. package/lib/find.js +61 -0
  29. package/lib/git-branches.js +254 -416
  30. package/lib/git-deps.js +148 -272
  31. package/lib/git-reword-todo.js +5 -13
  32. package/lib/git-worktree.js +161 -214
  33. package/lib/git.js +21 -49
  34. package/lib/github.js +67 -181
  35. package/lib/gitlab.js +40 -90
  36. package/lib/highlight/bash.js +55 -177
  37. package/lib/highlight/core.js +155 -141
  38. package/lib/highlight/css.js +25 -58
  39. package/lib/highlight/csv.js +19 -37
  40. package/lib/highlight/dart.js +72 -213
  41. package/lib/highlight/dot.js +14 -14
  42. package/lib/highlight/html.js +42 -63
  43. package/lib/highlight/js.js +177 -506
  44. package/lib/highlight/json.js +17 -37
  45. package/lib/highlight/log.js +19 -25
  46. package/lib/highlight/txt.js +7 -10
  47. package/lib/highlight.js +17 -46
  48. package/lib/keys.js +75 -83
  49. package/lib/manifest.js +67 -126
  50. package/lib/npm-commands.js +120 -169
  51. package/lib/remote.js +140 -190
  52. package/lib/render/branches.js +63 -61
  53. package/lib/render/chrome.js +412 -347
  54. package/lib/render/commits.js +160 -361
  55. package/lib/render/dash-activity.js +212 -0
  56. package/lib/render/dash-blocks.js +496 -0
  57. package/lib/render/dash-table.js +295 -0
  58. package/lib/render/dashboard.js +62 -0
  59. package/lib/render/diff.js +123 -258
  60. package/lib/render/files.js +60 -86
  61. package/lib/render/frame.js +82 -117
  62. package/lib/render/notes.js +150 -210
  63. package/lib/render/npm.js +213 -177
  64. package/lib/render/packages.js +93 -0
  65. package/lib/render/present.js +4 -11
  66. package/lib/render/primitives.js +77 -172
  67. package/lib/render/render.js +5 -14
  68. package/lib/render/report.js +43 -0
  69. package/lib/render/repos.js +226 -0
  70. package/lib/render/search.js +25 -0
  71. package/lib/render/tiles.js +355 -0
  72. package/lib/render/unit.js +15 -31
  73. package/lib/report-model.js +110 -33
  74. package/lib/report-parse.js +56 -37
  75. package/lib/report-render.js +102 -59
  76. package/lib/report-run.js +87 -77
  77. package/lib/report-test.js +221 -99
  78. package/lib/report-tools.js +96 -154
  79. package/lib/review-merge.js +33 -41
  80. package/lib/review.js +69 -129
  81. package/lib/runs.js +225 -0
  82. package/lib/select.js +53 -91
  83. package/lib/session/accessors.js +14 -21
  84. package/lib/session/actions.js +189 -65
  85. package/lib/session/branches.js +164 -222
  86. package/lib/session/change-actions.js +49 -119
  87. package/lib/session/commit.js +298 -352
  88. package/lib/session/compose.js +572 -715
  89. package/lib/session/dashboard.js +530 -0
  90. package/lib/session/dispatch.js +197 -171
  91. package/lib/session/files-pane.js +92 -45
  92. package/lib/session/find.js +94 -0
  93. package/lib/session/items.js +6 -17
  94. package/lib/session/lifecycle.js +420 -466
  95. package/lib/session/load.js +1 -14
  96. package/lib/session/navigation.js +4 -2
  97. package/lib/session/npm.js +403 -420
  98. package/lib/session/ops.js +5 -13
  99. package/lib/session/packages.js +143 -0
  100. package/lib/session/pointer.js +30 -14
  101. package/lib/session/progress.js +39 -30
  102. package/lib/session/review.js +1 -3
  103. package/lib/session/tasks.js +277 -236
  104. package/lib/session/templates.js +51 -59
  105. package/lib/session/terminal.js +85 -132
  106. package/lib/session/view.js +59 -80
  107. package/lib/session/watch.js +201 -212
  108. package/lib/session/workspace.js +455 -0
  109. package/lib/session.js +95 -161
  110. package/lib/update.js +44 -111
  111. package/lib/utilities.js +46 -88
  112. package/lib/workspace.js +166 -0
  113. package/lib/wrap.js +29 -55
  114. package/package.json +1 -1
@@ -0,0 +1,94 @@
1
+ 'use strict';
2
+
3
+ const files = require('../files.js');
4
+ const { isTasksEntry, TASKS_FILE } = files;
5
+ const find = require('../find.js');
6
+ const { fileMatches } = find;
7
+
8
+ const FIND_PANES = ['files', 'diff'];
9
+
10
+ const isTypeKey = (key) =>
11
+ Boolean(key) && key.length === 1 && key.charCodeAt(0) >= 32;
12
+
13
+ const startFind = (ui) => {
14
+ if (ui.mode !== 'review') return;
15
+ if (!FIND_PANES.includes(ui.pane)) return;
16
+ ui.mode = 'find';
17
+ ui.nav.find = { query: '', at: 0 };
18
+ ui.status = '';
19
+ };
20
+
21
+ const stopFind = (ui) => {
22
+ ui.mode = 'review';
23
+ ui.nav.find = null;
24
+ ui.status = '';
25
+ };
26
+
27
+ const focusMatch = (ui, hit, jump) => {
28
+ const entry = ui.fileList()[hit.index];
29
+ if (!entry) return;
30
+ const moved = ui.nav.fileCursor !== hit.index;
31
+ ui.nav.fileCursor = hit.index;
32
+ if (isTasksEntry(entry)) {
33
+ ui.nav.reviewPath = TASKS_FILE;
34
+ return;
35
+ }
36
+ ui.nav.reviewPath = entry.path;
37
+ if (ui.nav.pane !== 'diff') {
38
+ ui.nav.index = entry.firstIndex;
39
+ return;
40
+ }
41
+ if (!moved && !jump) return;
42
+ ui.nav.index = entry.openIndex ?? entry.firstIndex;
43
+ ui.nav.scroll = 0;
44
+ ui.nav.clearSelection();
45
+ };
46
+
47
+ const showHit = (ui, jump) => {
48
+ const state = ui.nav.find;
49
+ if (!state) return;
50
+ const hits = fileMatches(ui.fileList(), state.query);
51
+ if (!hits.length) return;
52
+ const count = hits.length;
53
+ let at = state.at % count;
54
+ if (at < 0) at += count;
55
+ state.at = at;
56
+ focusMatch(ui, hits[at], jump);
57
+ };
58
+
59
+ const typeFind = (ui, key) => {
60
+ const state = ui.nav.find;
61
+ state.query += key;
62
+ state.at = 0;
63
+ showHit(ui, true);
64
+ };
65
+
66
+ const eraseFind = (ui) => {
67
+ const state = ui.nav.find;
68
+ if (!state.query) return void stopFind(ui);
69
+ state.query = state.query.slice(0, -1);
70
+ state.at = 0;
71
+ showHit(ui, true);
72
+ };
73
+
74
+ const moveFind = (ui, delta) => {
75
+ const state = ui.nav.find;
76
+ if (!state.query) return;
77
+ state.at += delta;
78
+ showHit(ui, false);
79
+ };
80
+
81
+ const onFindKey = (ui, key) => {
82
+ if (!ui.nav.find) {
83
+ ui.mode = 'review';
84
+ return;
85
+ }
86
+ if (key === 'ctrl-c') return void ui.onQuit();
87
+ if (key === 'escape' || key === 'enter') return void stopFind(ui);
88
+ if (key === 'backspace') return void eraseFind(ui);
89
+ if (key === 'up' || key === 'left') return void moveFind(ui, -1);
90
+ if (key === 'down' || key === 'right') return void moveFind(ui, 1);
91
+ if (isTypeKey(key)) typeFind(ui, key);
92
+ };
93
+
94
+ module.exports = { FIND_PANES, startFind, stopFind, onFindKey };
@@ -29,13 +29,9 @@ const blockKey = (item) => {
29
29
  if (isTaskItem(item)) return `todo:${TASKS_FILE}`;
30
30
  const depId = depChangeKey(item);
31
31
  if (depId) return `${rel}:dep:${depId}`;
32
- if (!item.hunk) {
33
- const block = item.blockId ?? '-';
34
- return `${rel}:file:${block}`;
35
- }
36
- const oldStart = item.hunk.oldStart;
37
- const newStart = item.hunk.newStart;
38
32
  const block = item.blockId ?? '-';
33
+ if (!item.hunk) return `${rel}:file:${block}`;
34
+ const { oldStart, newStart } = item.hunk;
39
35
  return `${rel}:${oldStart}:${newStart}:${block}`;
40
36
  };
41
37
 
@@ -119,12 +115,10 @@ const alignLoadedItems = (prev, next) => {
119
115
  const ordered = [];
120
116
  for (const [rel, list] of groupByPath(prev)) {
121
117
  seen.add(rel);
122
- const aligned = alignGroup(list, nextGroups.get(rel) ?? []);
123
- for (const item of aligned) ordered.push(item);
118
+ ordered.push(...alignGroup(list, nextGroups.get(rel) ?? []));
124
119
  }
125
120
  for (const [rel, list] of nextGroups) {
126
- if (seen.has(rel)) continue;
127
- for (const item of list) ordered.push(item);
121
+ if (!seen.has(rel)) ordered.push(...list);
128
122
  }
129
123
  return ordered;
130
124
  };
@@ -195,8 +189,7 @@ const sameBlock = (left, right) => {
195
189
  const canEditCode = (item) => {
196
190
  if (!item || isTaskItem(item)) return false;
197
191
  if (!item.hunk || !item.file) return false;
198
- if (item.file.isBinary) return false;
199
- return true;
192
+ return !item.file.isBinary;
200
193
  };
201
194
 
202
195
  class ItemCollection {
@@ -237,11 +230,7 @@ class ItemCollection {
237
230
  const replaced = this.items.map((entry) =>
238
231
  sameBlock(entry, item) ? next : entry,
239
232
  );
240
- if (next.dep) {
241
- this.items = replaced;
242
- return;
243
- }
244
- this.items = refreshIndexPatches(replaced, next);
233
+ this.items = next.dep ? replaced : refreshIndexPatches(replaced, next);
245
234
  }
246
235
  }
247
236