@pixelatlarge/peanut-gallery-core 0.1.0 → 0.1.1

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/dist/index.cjs CHANGED
@@ -24,6 +24,7 @@ __export(index_exports, {
24
24
  DEFAULT_THEME: () => DEFAULT_THEME,
25
25
  ISSUE_BLOCK_LANG: () => ISSUE_BLOCK_LANG,
26
26
  LABELS: () => LABELS,
27
+ MAX_STEPS: () => MAX_STEPS,
27
28
  PALETTE: () => PALETTE,
28
29
  buildSelector: () => buildSelector,
29
30
  createAnchor: () => createAnchor,
@@ -33,12 +34,19 @@ __export(index_exports, {
33
34
  resolveAnchor: () => resolveAnchor,
34
35
  resolveTheme: () => resolveTheme,
35
36
  sessionToIssue: () => sessionToIssue,
37
+ stepLabel: () => stepLabel,
36
38
  themeToCssVars: () => themeToCssVars,
37
39
  uid: () => uid
38
40
  });
39
41
  module.exports = __toCommonJS(index_exports);
40
42
 
41
43
  // src/types.ts
44
+ var MAX_STEPS = 5;
45
+ function stepLabel(step) {
46
+ const t = (step.textFingerprint ?? "").trim();
47
+ if (t) return `\u201C${t.length > 40 ? t.slice(0, 39) + "\u2026" : t}\u201D`;
48
+ return step.selector.length > 60 ? step.tag : step.selector;
49
+ }
42
50
  var LABELS = {
43
51
  root: "peanut-gallery",
44
52
  feedback: "peanut-gallery:feedback",
@@ -177,6 +185,7 @@ function sessionToIssue(session) {
177
185
  lines.push(`- **Element:** \`${a.anchor.tag ?? "?"}\` \u2192 \`${a.anchor.selector}\``);
178
186
  if (a.anchor.textFingerprint) lines.push(`- **Text:** \u201C${a.anchor.textFingerprint}\u201D`);
179
187
  if (a.anchor.context) lines.push(`- **Near:** ${a.anchor.context}`);
188
+ if (a.steps?.length) lines.push(`- **Reached by clicking:** ${a.steps.map(stepLabel).join(" \u2192 ")}`);
180
189
  if (a.viewport && Number.isFinite(a.viewport.width) && Number.isFinite(a.viewport.height)) lines.push(`- **Viewport:** ${a.viewport.width}\xD7${a.viewport.height}`);
181
190
  lines.push("");
182
191
  });
@@ -221,7 +230,8 @@ function newIssueUrl(repo, session, labels = [], maxLen = 7500) {
221
230
  context: void 0,
222
231
  textFingerprint: a.anchor.textFingerprint.slice(0, 40),
223
232
  rect: roundRect(a.anchor.rect)
224
- }
233
+ },
234
+ steps: a.steps?.map((st) => ({ ...st, context: void 0, textFingerprint: st.textFingerprint.slice(0, 40), rect: roundRect(st.rect) }))
225
235
  }))
226
236
  };
227
237
  url = build(slim);
@@ -327,6 +337,7 @@ function themeToCssVars(theme) {
327
337
  DEFAULT_THEME,
328
338
  ISSUE_BLOCK_LANG,
329
339
  LABELS,
340
+ MAX_STEPS,
330
341
  PALETTE,
331
342
  buildSelector,
332
343
  createAnchor,
@@ -336,6 +347,7 @@ function themeToCssVars(theme) {
336
347
  resolveAnchor,
337
348
  resolveTheme,
338
349
  sessionToIssue,
350
+ stepLabel,
339
351
  themeToCssVars,
340
352
  uid
341
353
  });
package/dist/index.d.cts CHANGED
@@ -39,7 +39,17 @@ interface Annotation {
39
39
  author?: string;
40
40
  /** Optional free-form tag chosen by the reviewer, e.g. "bug", "copy", "layout". */
41
41
  kind?: AnnotationKind;
42
+ /**
43
+ * Clicks the reviewer made on this page before leaving the note, oldest first (at most 5,
44
+ * reset on navigation). Screenshots replay them when the element isn't on the freshly
45
+ * loaded page, e.g. a note inside a modal. Element identities only, never typed values.
46
+ */
47
+ steps?: ElementAnchor[];
42
48
  }
49
+ /** Most clicks kept per note. */
50
+ declare const MAX_STEPS = 5;
51
+ /** Short human label for a recorded click, e.g. `“Remove”` or `button#save`. */
52
+ declare function stepLabel(step: Pick<ElementAnchor, 'tag' | 'textFingerprint' | 'selector'>): string;
43
53
  type AnnotationKind = 'bug' | 'copy' | 'layout' | 'visual' | 'flow' | 'question' | 'praise';
44
54
  interface ReviewSession {
45
55
  id: string;
@@ -220,4 +230,4 @@ declare function resolveTheme(overrides?: Partial<Theme>): Theme;
220
230
  /** `--pg-primary: #0F7B52; …` for every role. */
221
231
  declare function themeToCssVars(theme: Theme): string;
222
232
 
223
- export { type Annotation, type AnnotationKind, DEFAULT_FONTS_URL, DEFAULT_THEME, type ElementAnchor, ISSUE_BLOCK_LANG, LABELS, PALETTE, type Proposal, type ProposalPosition, type ProposalRun, type ReviewSession, type Theme, buildSelector, createAnchor, issueToSession, newIssueUrl, normalizeText, resolveAnchor, resolveTheme, sessionToIssue, themeToCssVars, uid };
233
+ export { type Annotation, type AnnotationKind, DEFAULT_FONTS_URL, DEFAULT_THEME, type ElementAnchor, ISSUE_BLOCK_LANG, LABELS, MAX_STEPS, PALETTE, type Proposal, type ProposalPosition, type ProposalRun, type ReviewSession, type Theme, buildSelector, createAnchor, issueToSession, newIssueUrl, normalizeText, resolveAnchor, resolveTheme, sessionToIssue, stepLabel, themeToCssVars, uid };
package/dist/index.d.ts CHANGED
@@ -39,7 +39,17 @@ interface Annotation {
39
39
  author?: string;
40
40
  /** Optional free-form tag chosen by the reviewer, e.g. "bug", "copy", "layout". */
41
41
  kind?: AnnotationKind;
42
+ /**
43
+ * Clicks the reviewer made on this page before leaving the note, oldest first (at most 5,
44
+ * reset on navigation). Screenshots replay them when the element isn't on the freshly
45
+ * loaded page, e.g. a note inside a modal. Element identities only, never typed values.
46
+ */
47
+ steps?: ElementAnchor[];
42
48
  }
49
+ /** Most clicks kept per note. */
50
+ declare const MAX_STEPS = 5;
51
+ /** Short human label for a recorded click, e.g. `“Remove”` or `button#save`. */
52
+ declare function stepLabel(step: Pick<ElementAnchor, 'tag' | 'textFingerprint' | 'selector'>): string;
43
53
  type AnnotationKind = 'bug' | 'copy' | 'layout' | 'visual' | 'flow' | 'question' | 'praise';
44
54
  interface ReviewSession {
45
55
  id: string;
@@ -220,4 +230,4 @@ declare function resolveTheme(overrides?: Partial<Theme>): Theme;
220
230
  /** `--pg-primary: #0F7B52; …` for every role. */
221
231
  declare function themeToCssVars(theme: Theme): string;
222
232
 
223
- export { type Annotation, type AnnotationKind, DEFAULT_FONTS_URL, DEFAULT_THEME, type ElementAnchor, ISSUE_BLOCK_LANG, LABELS, PALETTE, type Proposal, type ProposalPosition, type ProposalRun, type ReviewSession, type Theme, buildSelector, createAnchor, issueToSession, newIssueUrl, normalizeText, resolveAnchor, resolveTheme, sessionToIssue, themeToCssVars, uid };
233
+ export { type Annotation, type AnnotationKind, DEFAULT_FONTS_URL, DEFAULT_THEME, type ElementAnchor, ISSUE_BLOCK_LANG, LABELS, MAX_STEPS, PALETTE, type Proposal, type ProposalPosition, type ProposalRun, type ReviewSession, type Theme, buildSelector, createAnchor, issueToSession, newIssueUrl, normalizeText, resolveAnchor, resolveTheme, sessionToIssue, stepLabel, themeToCssVars, uid };
package/dist/index.js CHANGED
@@ -1,4 +1,10 @@
1
1
  // src/types.ts
2
+ var MAX_STEPS = 5;
3
+ function stepLabel(step) {
4
+ const t = (step.textFingerprint ?? "").trim();
5
+ if (t) return `\u201C${t.length > 40 ? t.slice(0, 39) + "\u2026" : t}\u201D`;
6
+ return step.selector.length > 60 ? step.tag : step.selector;
7
+ }
2
8
  var LABELS = {
3
9
  root: "peanut-gallery",
4
10
  feedback: "peanut-gallery:feedback",
@@ -137,6 +143,7 @@ function sessionToIssue(session) {
137
143
  lines.push(`- **Element:** \`${a.anchor.tag ?? "?"}\` \u2192 \`${a.anchor.selector}\``);
138
144
  if (a.anchor.textFingerprint) lines.push(`- **Text:** \u201C${a.anchor.textFingerprint}\u201D`);
139
145
  if (a.anchor.context) lines.push(`- **Near:** ${a.anchor.context}`);
146
+ if (a.steps?.length) lines.push(`- **Reached by clicking:** ${a.steps.map(stepLabel).join(" \u2192 ")}`);
140
147
  if (a.viewport && Number.isFinite(a.viewport.width) && Number.isFinite(a.viewport.height)) lines.push(`- **Viewport:** ${a.viewport.width}\xD7${a.viewport.height}`);
141
148
  lines.push("");
142
149
  });
@@ -181,7 +188,8 @@ function newIssueUrl(repo, session, labels = [], maxLen = 7500) {
181
188
  context: void 0,
182
189
  textFingerprint: a.anchor.textFingerprint.slice(0, 40),
183
190
  rect: roundRect(a.anchor.rect)
184
- }
191
+ },
192
+ steps: a.steps?.map((st) => ({ ...st, context: void 0, textFingerprint: st.textFingerprint.slice(0, 40), rect: roundRect(st.rect) }))
185
193
  }))
186
194
  };
187
195
  url = build(slim);
@@ -286,6 +294,7 @@ export {
286
294
  DEFAULT_THEME,
287
295
  ISSUE_BLOCK_LANG,
288
296
  LABELS,
297
+ MAX_STEPS,
289
298
  PALETTE,
290
299
  buildSelector,
291
300
  createAnchor,
@@ -295,6 +304,7 @@ export {
295
304
  resolveAnchor,
296
305
  resolveTheme,
297
306
  sessionToIssue,
307
+ stepLabel,
298
308
  themeToCssVars,
299
309
  uid
300
310
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixelatlarge/peanut-gallery-core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Shared types, DOM anchoring, and GitHub issue serialization for peanut-gallery.",
5
5
  "keywords": [
6
6
  "prototype",