@riebeckite/plugin-diff 0.0.5 → 0.0.6

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 CHANGED
@@ -87,4 +87,4 @@ When `cwd` is not inside a Git repository, API calls resolve to empty results
87
87
 
88
88
  ## See also
89
89
 
90
- - [Plugin guide](../../docs/plugins_en.md)
90
+ - [Plugin guide](../../../docs/en/plugin-system.md)
package/dist/index.js CHANGED
@@ -18,6 +18,27 @@ function escapeHtml(value) {
18
18
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
19
19
  }
20
20
 
21
+ // src/components/format-date.ts
22
+ var MONTHS = [
23
+ "Jan",
24
+ "Feb",
25
+ "Mar",
26
+ "Apr",
27
+ "May",
28
+ "Jun",
29
+ "Jul",
30
+ "Aug",
31
+ "Sep",
32
+ "Oct",
33
+ "Nov",
34
+ "Dec"
35
+ ];
36
+ function formatDiffDate(value) {
37
+ const date = new Date(value);
38
+ if (Number.isNaN(date.getTime())) return value;
39
+ return `${MONTHS[date.getUTCMonth()]} ${date.getUTCDate()}`;
40
+ }
41
+
21
42
  // src/components/diff-viewer.tsx
22
43
  function renderDiffViewer({
23
44
  history,
@@ -45,14 +66,9 @@ function renderDiffPanel(diff2) {
45
66
  function renderRevisionSelect(kind, history, value) {
46
67
  const emptyOption = kind === "from" ? `<option value="">Beginning</option>` : "";
47
68
  return `<select data-rr-diff-${kind}>${emptyOption}${history.map(
48
- (revision) => `<option value="${escapeHtml(revision.hash)}"${revision.hash === value ? " selected" : ""}>${escapeHtml(revision.shortHash)} · ${escapeHtml(formatDate(revision.date))}</option>`
69
+ (revision) => `<option value="${escapeHtml(revision.hash)}"${revision.hash === value ? " selected" : ""}>${escapeHtml(revision.shortHash)} · ${escapeHtml(formatDiffDate(revision.date))}</option>`
49
70
  ).join("")}</select>`;
50
71
  }
51
- function formatDate(value) {
52
- const date = new Date(value);
53
- if (Number.isNaN(date.getTime())) return value;
54
- return date.toLocaleDateString("en", { month: "short", day: "numeric" });
55
- }
56
72
 
57
73
  // src/components/diff-history.tsx
58
74
  function renderDiffHistory(input) {
@@ -81,17 +97,12 @@ function renderEmptyState() {
81
97
  function renderRevisionButton(revision, selected) {
82
98
  return `<li class="rr-diff-history__item">
83
99
  <button class="rr-diff-history__commit" type="button" data-rr-diff-select="${escapeHtml(revision.hash)}" aria-pressed="${selected}">
84
- <span class="rr-diff-history__date">${escapeHtml(formatDate2(revision.date))}</span>
100
+ <span class="rr-diff-history__date">${escapeHtml(formatDiffDate(revision.date))}</span>
85
101
  <span class="rr-diff-history__message">${escapeHtml(revision.message || "Untitled change")}</span>
86
102
  <span class="rr-diff-history__meta">${escapeHtml(revision.shortHash)} · ${escapeHtml(revision.author)}</span>
87
103
  </button>
88
104
  </li>`;
89
105
  }
90
- function formatDate2(value) {
91
- const date = new Date(value);
92
- if (Number.isNaN(date.getTime())) return value;
93
- return date.toLocaleDateString("en", { month: "short", day: "numeric" });
94
- }
95
106
 
96
107
  // src/diff/line_diff.ts
97
108
  function createLineDiff(fromMarkdown, toMarkdown) {
@@ -0,0 +1 @@
1
+ export declare function formatDiffDate(value: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-diff",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -21,10 +21,12 @@
21
21
  "./style.css": "./style.css"
22
22
  },
23
23
  "dependencies": {
24
- "@riebeckite/core": "0.0.5"
24
+ "@riebeckite/core": "0.0.6"
25
25
  },
26
26
  "devDependencies": {
27
- "@types/node": "^24.5.2"
27
+ "@types/node": "^24.5.2",
28
+ "tsx": "^4.22.4",
29
+ "@riebeckite/test": "0.0.6"
28
30
  },
29
31
  "publishConfig": {
30
32
  "access": "public"
@@ -59,6 +61,7 @@
59
61
  "./style.css"
60
62
  ],
61
63
  "scripts": {
62
- "build": "node ../../../scripts/build_package.mjs"
64
+ "build": "node ../../../scripts/build_package.mjs",
65
+ "test": "node --import tsx --test \"test/*.test.ts\""
63
66
  }
64
67
  }
package/style.css CHANGED
@@ -1,229 +1,229 @@
1
- .rr-diff-history {
2
- margin-block: 4rem 2rem;
3
- border-block-start: 1px solid
4
- var(--rb-color-border, color-mix(in srgb, currentColor 18%, transparent));
5
- padding-block-start: 1.5rem;
6
- color: var(--rb-color-ink, currentColor);
7
- }
8
-
9
- .rr-diff-history__header {
10
- display: flex;
11
- align-items: baseline;
12
- justify-content: space-between;
13
- gap: 1rem;
14
- margin-block-end: 1rem;
15
- }
16
-
17
- .rr-diff-history__title {
18
- margin: 0;
19
- font-size: 0.875rem;
20
- letter-spacing: 0.08em;
21
- text-transform: uppercase;
22
- }
23
-
24
- .rr-diff-history__count,
25
- .rr-diff-history__date,
26
- .rr-diff-history__meta {
27
- color: var(
28
- --rb-color-muted,
29
- color-mix(in srgb, currentColor 62%, transparent)
30
- );
31
- font-size: 0.8125rem;
32
- }
33
-
34
- .rr-diff-history__layout {
35
- display: grid;
36
- grid-template-columns: minmax(12rem, 0.36fr) minmax(0, 1fr);
37
- gap: 1.5rem;
38
- }
39
-
40
- .rr-diff-history__list {
41
- display: grid;
42
- gap: 0;
43
- margin: 0;
44
- padding: 0;
45
- list-style: none;
46
- }
47
-
48
- .rr-diff-history__item {
49
- position: relative;
50
- padding-inline-start: 1.25rem;
51
- }
52
-
53
- .rr-diff-history__item::before {
54
- position: absolute;
55
- inset-block-start: 0.7rem;
56
- inset-inline-start: 0;
57
- width: 0.5rem;
58
- height: 0.5rem;
59
- border: 1px solid var(--rb-color-ink, currentColor);
60
- border-radius: 999px;
61
- background: var(--rb-color-paper, Canvas);
62
- content: "";
63
- }
64
-
65
- .rr-diff-history__item:not(:last-child)::after {
66
- position: absolute;
67
- inset-block: 1.25rem -0.25rem;
68
- inset-inline-start: 0.25rem;
69
- width: 1px;
70
- background: var(
71
- --rb-color-border,
72
- color-mix(in srgb, currentColor 18%, transparent)
73
- );
74
- content: "";
75
- }
76
-
77
- .rr-diff-history__commit {
78
- display: grid;
79
- width: 100%;
80
- border: 0;
81
- padding: 0 0 1rem;
82
- background: transparent;
83
- color: inherit;
84
- font: inherit;
85
- text-align: start;
86
- cursor: pointer;
87
- }
88
-
89
- .rr-diff-history__message {
90
- overflow-wrap: anywhere;
91
- font-size: 0.9375rem;
92
- line-height: 1.45;
93
- }
94
-
95
- .rr-diff-history__commit:hover .rr-diff-history__message,
96
- .rr-diff-history__commit[aria-pressed="true"] .rr-diff-history__message {
97
- color: var(--rb-color-accent, #f66620);
98
- }
99
-
100
- .rr-diff-history__commit:focus-visible,
101
- .rr-diff-history__controls select:focus-visible {
102
- outline: 2px solid var(--rb-color-accent, #f66620);
103
- outline-offset: 2px;
104
- }
105
-
106
- .rr-diff-history__viewer {
107
- min-width: 0;
108
- }
109
-
110
- .rr-diff-history__controls {
111
- display: flex;
112
- flex-wrap: wrap;
113
- gap: 0.75rem;
114
- margin-block-end: 0.75rem;
115
- font-size: 0.8125rem;
116
- }
117
-
118
- .rr-diff-history__controls label {
119
- display: inline-flex;
120
- align-items: center;
121
- gap: 0.5rem;
122
- }
123
-
124
- .rr-diff-history__controls select {
125
- border: 1px solid
126
- var(--rb-color-border, color-mix(in srgb, currentColor 18%, transparent));
127
- border-radius: 0;
128
- padding: 0.25rem 0.5rem;
129
- background: var(--rb-color-paper, Canvas);
130
- color: inherit;
131
- font: inherit;
132
- }
133
-
134
- .rr-diff-history__diff {
135
- border: 1px solid
136
- var(--rb-color-border, color-mix(in srgb, currentColor 18%, transparent));
137
- }
138
-
139
- .rr-diff-history__diff-head {
140
- border-block-end: 1px solid
141
- var(--rb-color-border, color-mix(in srgb, currentColor 18%, transparent));
142
- padding: 0.625rem 0.75rem;
143
- font-family: var(
144
- --rb-font-mono,
145
- ui-monospace,
146
- SFMono-Regular,
147
- Consolas,
148
- monospace
149
- );
150
- font-size: 0.8125rem;
151
- }
152
-
153
- .rr-diff-history__table-wrap {
154
- overflow-x: auto;
155
- }
156
-
157
- .rr-diff-history__table {
158
- width: 100%;
159
- min-width: 42rem;
160
- border-collapse: collapse;
161
- font-family: var(
162
- --rb-font-mono,
163
- ui-monospace,
164
- SFMono-Regular,
165
- Consolas,
166
- monospace
167
- );
168
- font-size: 0.8125rem;
169
- line-height: 1.55;
170
- }
171
-
172
- .rr-diff-history__num {
173
- width: 3.25rem;
174
- border-inline-end: 1px solid
175
- var(--rb-color-border, color-mix(in srgb, currentColor 14%, transparent));
176
- color: var(
177
- --rb-color-muted,
178
- color-mix(in srgb, currentColor 58%, transparent)
179
- );
180
- text-align: end;
181
- user-select: none;
182
- }
183
-
184
- .rr-diff-history__num,
185
- .rr-diff-history__code {
186
- padding: 0.125rem 0.625rem;
187
- vertical-align: top;
188
- }
189
-
190
- .rr-diff-history__code code {
191
- white-space: pre;
192
- }
193
-
194
- .rr-diff-history__line--added {
195
- background: color-mix(in srgb, #2f9e44 16%, transparent);
196
- }
197
-
198
- .rr-diff-history__line--removed {
199
- background: color-mix(in srgb, #e03131 14%, transparent);
200
- }
201
-
202
- .rr-diff-history__line--context {
203
- background: color-mix(in srgb, currentColor 2%, transparent);
204
- }
205
-
206
- .rr-diff-history__empty {
207
- margin: 0;
208
- color: var(
209
- --rb-color-muted,
210
- color-mix(in srgb, currentColor 62%, transparent)
211
- );
212
- font-size: 0.9375rem;
213
- }
214
-
215
- @media (max-width: 720px) {
216
- .rr-diff-history__layout {
217
- grid-template-columns: 1fr;
218
- }
219
-
220
- .rr-diff-history__list {
221
- max-height: 18rem;
222
- overflow: auto;
223
- padding-inline-end: 0.25rem;
224
- }
225
-
226
- .rr-diff-history__header {
227
- align-items: flex-start;
228
- }
229
- }
1
+ .rr-diff-history {
2
+ margin-block: 4rem 2rem;
3
+ border-block-start: 1px solid
4
+ var(--rb-color-border, color-mix(in srgb, currentColor 18%, transparent));
5
+ padding-block-start: 1.5rem;
6
+ color: var(--rb-color-ink, currentColor);
7
+ }
8
+
9
+ .rr-diff-history__header {
10
+ display: flex;
11
+ align-items: baseline;
12
+ justify-content: space-between;
13
+ gap: 1rem;
14
+ margin-block-end: 1rem;
15
+ }
16
+
17
+ .rr-diff-history__title {
18
+ margin: 0;
19
+ font-size: 0.875rem;
20
+ letter-spacing: 0.08em;
21
+ text-transform: uppercase;
22
+ }
23
+
24
+ .rr-diff-history__count,
25
+ .rr-diff-history__date,
26
+ .rr-diff-history__meta {
27
+ color: var(
28
+ --rb-color-muted,
29
+ color-mix(in srgb, currentColor 62%, transparent)
30
+ );
31
+ font-size: 0.8125rem;
32
+ }
33
+
34
+ .rr-diff-history__layout {
35
+ display: grid;
36
+ grid-template-columns: minmax(12rem, 0.36fr) minmax(0, 1fr);
37
+ gap: 1.5rem;
38
+ }
39
+
40
+ .rr-diff-history__list {
41
+ display: grid;
42
+ gap: 0;
43
+ margin: 0;
44
+ padding: 0;
45
+ list-style: none;
46
+ }
47
+
48
+ .rr-diff-history__item {
49
+ position: relative;
50
+ padding-inline-start: 1.25rem;
51
+ }
52
+
53
+ .rr-diff-history__item::before {
54
+ position: absolute;
55
+ inset-block-start: 0.7rem;
56
+ inset-inline-start: 0;
57
+ width: 0.5rem;
58
+ height: 0.5rem;
59
+ border: 1px solid var(--rb-color-ink, currentColor);
60
+ border-radius: 999px;
61
+ background: var(--rb-color-paper, Canvas);
62
+ content: "";
63
+ }
64
+
65
+ .rr-diff-history__item:not(:last-child)::after {
66
+ position: absolute;
67
+ inset-block: 1.25rem -0.25rem;
68
+ inset-inline-start: 0.25rem;
69
+ width: 1px;
70
+ background: var(
71
+ --rb-color-border,
72
+ color-mix(in srgb, currentColor 18%, transparent)
73
+ );
74
+ content: "";
75
+ }
76
+
77
+ .rr-diff-history__commit {
78
+ display: grid;
79
+ width: 100%;
80
+ border: 0;
81
+ padding: 0 0 1rem;
82
+ background: transparent;
83
+ color: inherit;
84
+ font: inherit;
85
+ text-align: start;
86
+ cursor: pointer;
87
+ }
88
+
89
+ .rr-diff-history__message {
90
+ overflow-wrap: anywhere;
91
+ font-size: 0.9375rem;
92
+ line-height: 1.45;
93
+ }
94
+
95
+ .rr-diff-history__commit:hover .rr-diff-history__message,
96
+ .rr-diff-history__commit[aria-pressed="true"] .rr-diff-history__message {
97
+ color: var(--rb-color-accent, #f66620);
98
+ }
99
+
100
+ .rr-diff-history__commit:focus-visible,
101
+ .rr-diff-history__controls select:focus-visible {
102
+ outline: 2px solid var(--rb-color-accent, #f66620);
103
+ outline-offset: 2px;
104
+ }
105
+
106
+ .rr-diff-history__viewer {
107
+ min-width: 0;
108
+ }
109
+
110
+ .rr-diff-history__controls {
111
+ display: flex;
112
+ flex-wrap: wrap;
113
+ gap: 0.75rem;
114
+ margin-block-end: 0.75rem;
115
+ font-size: 0.8125rem;
116
+ }
117
+
118
+ .rr-diff-history__controls label {
119
+ display: inline-flex;
120
+ align-items: center;
121
+ gap: 0.5rem;
122
+ }
123
+
124
+ .rr-diff-history__controls select {
125
+ border: 1px solid
126
+ var(--rb-color-border, color-mix(in srgb, currentColor 18%, transparent));
127
+ border-radius: 0;
128
+ padding: 0.25rem 0.5rem;
129
+ background: var(--rb-color-paper, Canvas);
130
+ color: inherit;
131
+ font: inherit;
132
+ }
133
+
134
+ .rr-diff-history__diff {
135
+ border: 1px solid
136
+ var(--rb-color-border, color-mix(in srgb, currentColor 18%, transparent));
137
+ }
138
+
139
+ .rr-diff-history__diff-head {
140
+ border-block-end: 1px solid
141
+ var(--rb-color-border, color-mix(in srgb, currentColor 18%, transparent));
142
+ padding: 0.625rem 0.75rem;
143
+ font-family: var(
144
+ --rb-font-mono,
145
+ ui-monospace,
146
+ SFMono-Regular,
147
+ Consolas,
148
+ monospace
149
+ );
150
+ font-size: 0.8125rem;
151
+ }
152
+
153
+ .rr-diff-history__table-wrap {
154
+ overflow-x: auto;
155
+ }
156
+
157
+ .rr-diff-history__table {
158
+ width: 100%;
159
+ min-width: 42rem;
160
+ border-collapse: collapse;
161
+ font-family: var(
162
+ --rb-font-mono,
163
+ ui-monospace,
164
+ SFMono-Regular,
165
+ Consolas,
166
+ monospace
167
+ );
168
+ font-size: 0.8125rem;
169
+ line-height: 1.55;
170
+ }
171
+
172
+ .rr-diff-history__num {
173
+ width: 3.25rem;
174
+ border-inline-end: 1px solid
175
+ var(--rb-color-border, color-mix(in srgb, currentColor 14%, transparent));
176
+ color: var(
177
+ --rb-color-muted,
178
+ color-mix(in srgb, currentColor 58%, transparent)
179
+ );
180
+ text-align: end;
181
+ user-select: none;
182
+ }
183
+
184
+ .rr-diff-history__num,
185
+ .rr-diff-history__code {
186
+ padding: 0.125rem 0.625rem;
187
+ vertical-align: top;
188
+ }
189
+
190
+ .rr-diff-history__code code {
191
+ white-space: pre;
192
+ }
193
+
194
+ .rr-diff-history__line--added {
195
+ background: color-mix(in srgb, #2f9e44 16%, transparent);
196
+ }
197
+
198
+ .rr-diff-history__line--removed {
199
+ background: color-mix(in srgb, #e03131 14%, transparent);
200
+ }
201
+
202
+ .rr-diff-history__line--context {
203
+ background: color-mix(in srgb, currentColor 2%, transparent);
204
+ }
205
+
206
+ .rr-diff-history__empty {
207
+ margin: 0;
208
+ color: var(
209
+ --rb-color-muted,
210
+ color-mix(in srgb, currentColor 62%, transparent)
211
+ );
212
+ font-size: 0.9375rem;
213
+ }
214
+
215
+ @media (max-width: 720px) {
216
+ .rr-diff-history__layout {
217
+ grid-template-columns: 1fr;
218
+ }
219
+
220
+ .rr-diff-history__list {
221
+ max-height: 18rem;
222
+ overflow: auto;
223
+ padding-inline-end: 0.25rem;
224
+ }
225
+
226
+ .rr-diff-history__header {
227
+ align-items: flex-start;
228
+ }
229
+ }