web-remarq 0.2.6 → 0.3.0
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/core/index.cjs +149 -1
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +54 -1
- package/dist/core/index.d.ts +54 -1
- package/dist/core/index.js +146 -1
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +164 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -3
- package/dist/index.d.ts +40 -3
- package/dist/index.js +164 -4
- package/dist/index.js.map +1 -1
- package/dist/web-remarq.global.global.js +164 -4
- package/dist/web-remarq.global.global.js.map +1 -1
- package/package.json +1 -1
package/dist/core/index.cjs
CHANGED
|
@@ -51,6 +51,9 @@ var core_exports = {};
|
|
|
51
51
|
__export(core_exports, {
|
|
52
52
|
AnnotationStorage: () => AnnotationStorage,
|
|
53
53
|
createFingerprint: () => createFingerprint,
|
|
54
|
+
detectRemarqPlugin: () => detectRemarqPlugin,
|
|
55
|
+
detectSource: () => detectSource,
|
|
56
|
+
generateAgentExport: () => generateAgentExport,
|
|
54
57
|
matchElement: () => matchElement
|
|
55
58
|
});
|
|
56
59
|
module.exports = __toCommonJS(core_exports);
|
|
@@ -103,12 +106,54 @@ function decomposeCSSModules(classes) {
|
|
|
103
106
|
return result;
|
|
104
107
|
}
|
|
105
108
|
|
|
109
|
+
// src/core/source-detect.ts
|
|
110
|
+
function detectRemarqPlugin(el) {
|
|
111
|
+
const source = el.getAttribute("data-remarq-source");
|
|
112
|
+
if (!source) return { source: null, component: null };
|
|
113
|
+
return {
|
|
114
|
+
source,
|
|
115
|
+
component: el.getAttribute("data-remarq-component")
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function detectExternalSource(el) {
|
|
119
|
+
var _a;
|
|
120
|
+
const source = (_a = el.dataset.source) != null ? _a : el.getAttribute("data-locator");
|
|
121
|
+
if (!source) return { source: null, component: null };
|
|
122
|
+
return { source, component: null };
|
|
123
|
+
}
|
|
124
|
+
function detectReactFiber(el) {
|
|
125
|
+
var _a, _b, _c, _d;
|
|
126
|
+
const key = Object.keys(el).find((k) => k.startsWith("__reactFiber$"));
|
|
127
|
+
if (!key) return { source: null, component: null };
|
|
128
|
+
let current = el[key];
|
|
129
|
+
let depth = 0;
|
|
130
|
+
while (current && depth < 15) {
|
|
131
|
+
const debugSource = current._debugSource;
|
|
132
|
+
if (debugSource == null ? void 0 : debugSource.fileName) {
|
|
133
|
+
const source = `${debugSource.fileName}:${(_a = debugSource.lineNumber) != null ? _a : 0}:${(_b = debugSource.columnNumber) != null ? _b : 0}`;
|
|
134
|
+
const fiberType = current.type;
|
|
135
|
+
const component = typeof fiberType === "object" && fiberType ? (_d = (_c = fiberType.displayName) != null ? _c : fiberType.name) != null ? _d : null : null;
|
|
136
|
+
return { source, component };
|
|
137
|
+
}
|
|
138
|
+
current = current.return;
|
|
139
|
+
depth++;
|
|
140
|
+
}
|
|
141
|
+
return { source: null, component: null };
|
|
142
|
+
}
|
|
143
|
+
function detectSource(el) {
|
|
144
|
+
const external = detectExternalSource(el);
|
|
145
|
+
if (external.source) return external;
|
|
146
|
+
const fiber = detectReactFiber(el);
|
|
147
|
+
if (fiber.source) return fiber;
|
|
148
|
+
return { source: null, component: null };
|
|
149
|
+
}
|
|
150
|
+
|
|
106
151
|
// src/core/fingerprint.ts
|
|
107
152
|
var TEXT_MAX_LENGTH = 50;
|
|
108
153
|
function createFingerprint(el, options) {
|
|
109
154
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
110
155
|
const dataAttr = (_a = options == null ? void 0 : options.dataAttribute) != null ? _a : "data-annotate";
|
|
111
|
-
return {
|
|
156
|
+
return __spreadValues({
|
|
112
157
|
dataAnnotate: (_b = el.getAttribute(dataAttr)) != null ? _b : null,
|
|
113
158
|
dataTestId: (_e = (_d = (_c = el.getAttribute("data-testid")) != null ? _c : el.getAttribute("data-test")) != null ? _d : el.getAttribute("data-cy")) != null ? _e : null,
|
|
114
159
|
id: getStableId(el),
|
|
@@ -125,6 +170,24 @@ function createFingerprint(el, options) {
|
|
|
125
170
|
parentAnchor: findParentAnchor(el, dataAttr),
|
|
126
171
|
rawClasses: Array.from(el.classList),
|
|
127
172
|
cssModules: decomposeCSSModules(Array.from(el.classList))
|
|
173
|
+
}, resolveSourceFields(el));
|
|
174
|
+
}
|
|
175
|
+
function resolveSourceFields(el) {
|
|
176
|
+
const plugin = detectRemarqPlugin(el);
|
|
177
|
+
if (plugin.source) {
|
|
178
|
+
return {
|
|
179
|
+
sourceLocation: plugin.source,
|
|
180
|
+
componentName: plugin.component,
|
|
181
|
+
detectedSource: null,
|
|
182
|
+
detectedComponent: null
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
const detected = detectSource(el);
|
|
186
|
+
return {
|
|
187
|
+
sourceLocation: null,
|
|
188
|
+
componentName: null,
|
|
189
|
+
detectedSource: detected.source,
|
|
190
|
+
detectedComponent: detected.component
|
|
128
191
|
};
|
|
129
192
|
}
|
|
130
193
|
function getStableId(el) {
|
|
@@ -396,10 +459,95 @@ var AnnotationStorage = class {
|
|
|
396
459
|
}
|
|
397
460
|
}
|
|
398
461
|
};
|
|
462
|
+
|
|
463
|
+
// src/core/agent-export.ts
|
|
464
|
+
function parseSourceLocation(raw) {
|
|
465
|
+
const parts = raw.split(":");
|
|
466
|
+
if (parts.length < 2) return null;
|
|
467
|
+
const column = parseInt(parts.pop(), 10);
|
|
468
|
+
const line = parseInt(parts.pop(), 10);
|
|
469
|
+
const file = parts.join(":");
|
|
470
|
+
if (!file || isNaN(line)) return null;
|
|
471
|
+
return { file, line, column: isNaN(column) ? 0 : column };
|
|
472
|
+
}
|
|
473
|
+
function resolveSource(fp) {
|
|
474
|
+
var _a, _b;
|
|
475
|
+
if (fp.sourceLocation) {
|
|
476
|
+
const parsed = parseSourceLocation(fp.sourceLocation);
|
|
477
|
+
if (parsed) return __spreadProps(__spreadValues({}, parsed), { component: (_a = fp.componentName) != null ? _a : null });
|
|
478
|
+
}
|
|
479
|
+
if (fp.detectedSource) {
|
|
480
|
+
const parsed = parseSourceLocation(fp.detectedSource);
|
|
481
|
+
if (parsed) return __spreadProps(__spreadValues({}, parsed), { component: (_b = fp.detectedComponent) != null ? _b : null });
|
|
482
|
+
}
|
|
483
|
+
return null;
|
|
484
|
+
}
|
|
485
|
+
var TEMPLATE_GLOB = "*.{tsx,jsx,vue,svelte,html}";
|
|
486
|
+
var CSS_MODULE_GLOB = "*.module.{css,scss,less}";
|
|
487
|
+
var COMPONENT_GLOB = "*.{tsx,jsx,vue,ts,js}";
|
|
488
|
+
function buildSearchHints(fp) {
|
|
489
|
+
var _a, _b;
|
|
490
|
+
const grepQueries = [];
|
|
491
|
+
if (fp.dataAnnotate) {
|
|
492
|
+
grepQueries.push({ query: `data-annotate="${fp.dataAnnotate}"`, glob: TEMPLATE_GLOB, confidence: "high" });
|
|
493
|
+
}
|
|
494
|
+
if (fp.dataTestId) {
|
|
495
|
+
grepQueries.push({ query: `data-testid="${fp.dataTestId}"`, glob: TEMPLATE_GLOB, confidence: "high" });
|
|
496
|
+
}
|
|
497
|
+
if (fp.id) {
|
|
498
|
+
grepQueries.push({ query: `id="${fp.id}"`, glob: TEMPLATE_GLOB, confidence: "high" });
|
|
499
|
+
}
|
|
500
|
+
if (fp.ariaLabel) {
|
|
501
|
+
grepQueries.push({ query: `aria-label="${fp.ariaLabel}"`, glob: TEMPLATE_GLOB, confidence: "high" });
|
|
502
|
+
}
|
|
503
|
+
if (fp.textContent) {
|
|
504
|
+
grepQueries.push({ query: `"${fp.textContent}"`, glob: TEMPLATE_GLOB, confidence: "medium" });
|
|
505
|
+
}
|
|
506
|
+
if (fp.role) {
|
|
507
|
+
grepQueries.push({ query: `role="${fp.role}"`, glob: TEMPLATE_GLOB, confidence: "medium" });
|
|
508
|
+
}
|
|
509
|
+
if ((_a = fp.cssModules) == null ? void 0 : _a.length) {
|
|
510
|
+
for (const mod of fp.cssModules) {
|
|
511
|
+
grepQueries.push({ query: `.${mod.localName}`, glob: CSS_MODULE_GLOB, confidence: "medium" });
|
|
512
|
+
grepQueries.push({ query: `styles.${mod.localName}`, glob: COMPONENT_GLOB, confidence: "medium" });
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
if (fp.stableClasses.length) {
|
|
516
|
+
for (const cls of fp.stableClasses.slice(0, 3)) {
|
|
517
|
+
grepQueries.push({ query: `"${cls}"`, glob: TEMPLATE_GLOB, confidence: "low" });
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
return {
|
|
521
|
+
grepQueries,
|
|
522
|
+
domContext: fp.domPath,
|
|
523
|
+
tagName: fp.tagName,
|
|
524
|
+
classes: (_b = fp.rawClasses) != null ? _b : fp.stableClasses
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
function generateAgentExport(annotations, viewportBucket) {
|
|
528
|
+
const agentAnnotations = annotations.map((ann) => ({
|
|
529
|
+
id: ann.id,
|
|
530
|
+
route: ann.route,
|
|
531
|
+
comment: ann.comment,
|
|
532
|
+
status: ann.status,
|
|
533
|
+
timestamp: ann.timestamp,
|
|
534
|
+
source: resolveSource(ann.fingerprint),
|
|
535
|
+
searchHints: buildSearchHints(ann.fingerprint)
|
|
536
|
+
}));
|
|
537
|
+
return {
|
|
538
|
+
version: 1,
|
|
539
|
+
format: "agent",
|
|
540
|
+
viewportBucket,
|
|
541
|
+
annotations: agentAnnotations
|
|
542
|
+
};
|
|
543
|
+
}
|
|
399
544
|
// Annotate the CommonJS export names for ESM import in node:
|
|
400
545
|
0 && (module.exports = {
|
|
401
546
|
AnnotationStorage,
|
|
402
547
|
createFingerprint,
|
|
548
|
+
detectRemarqPlugin,
|
|
549
|
+
detectSource,
|
|
550
|
+
generateAgentExport,
|
|
403
551
|
matchElement
|
|
404
552
|
});
|
|
405
553
|
//# sourceMappingURL=index.cjs.map
|
package/dist/core/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/index.ts","../../src/core/hash-detect.ts","../../src/core/fingerprint.ts","../../src/core/matcher.ts","../../src/core/viewport.ts","../../src/core/storage.ts"],"sourcesContent":["export type { Annotation, AnnotationStore, ElementFingerprint, CSSModuleClass } from './types'\nexport { createFingerprint } from './fingerprint'\nexport { matchElement } from './matcher'\nexport { AnnotationStorage } from './storage'\n","import type { CSSModuleClass } from './types'\n\nconst CSS_MODULES_RE = /^(.+)__([a-zA-Z0-9]{3,})$/\nconst CSS_MODULES_3SEG_RE = /^([^_]+(?:[_-][^_]+)*)__([a-zA-Z][a-zA-Z0-9]*)__([a-zA-Z0-9]{3,})$/\nconst STYLED_COMPONENTS_RE = /^sc-/\nconst EMOTION_RE = /^css-[a-zA-Z0-9]+$/\nconst PURE_HASH_RE = /^(?=.*[a-zA-Z])(?=.*\\d)[a-zA-Z0-9]{8,}$/\n\nexport function isHashedClass(className: string): boolean {\n if (STYLED_COMPONENTS_RE.test(className)) return true\n if (EMOTION_RE.test(className)) return true\n if (CSS_MODULES_RE.test(className)) return true\n if (PURE_HASH_RE.test(className)) return true\n return false\n}\n\nexport function stripHash(className: string): string {\n const match = className.match(CSS_MODULES_RE)\n if (match) {\n const prefix = className.slice(0, className.lastIndexOf('__'))\n return prefix\n }\n return className\n}\n\nexport function filterClasses(\n classes: string[],\n classFilter?: (className: string) => boolean,\n): string[] {\n const result: string[] = []\n\n for (const cls of classes) {\n if (STYLED_COMPONENTS_RE.test(cls)) continue\n if (EMOTION_RE.test(cls)) continue\n if (PURE_HASH_RE.test(cls)) continue\n\n let stable = stripHash(cls)\n\n if (classFilter && !classFilter(stable)) continue\n\n result.push(stable)\n }\n\n return result\n}\n\nexport function decomposeCSSModules(classes: string[]): CSSModuleClass[] {\n const result: CSSModuleClass[] = []\n for (const cls of classes) {\n const match = cls.match(CSS_MODULES_3SEG_RE)\n if (match) {\n result.push({\n raw: cls,\n moduleHint: match[1],\n localName: match[2],\n })\n }\n }\n return result\n}\n","import type { ElementFingerprint, WebRemarqOptions } from './types'\nimport { filterClasses, isHashedClass, decomposeCSSModules } from './hash-detect'\n\nconst TEXT_MAX_LENGTH = 50\n\nexport function createFingerprint(\n el: HTMLElement,\n options?: Pick<WebRemarqOptions, 'classFilter' | 'dataAttribute'>,\n): ElementFingerprint {\n const dataAttr = options?.dataAttribute ?? 'data-annotate'\n\n return {\n dataAnnotate: el.getAttribute(dataAttr) ?? null,\n dataTestId: el.getAttribute('data-testid')\n ?? el.getAttribute('data-test')\n ?? el.getAttribute('data-cy')\n ?? null,\n id: getStableId(el),\n tagName: el.tagName.toLowerCase(),\n textContent: getTextContent(el),\n role: el.getAttribute('role') ?? null,\n ariaLabel: el.getAttribute('aria-label') ?? null,\n stableClasses: filterClasses(\n Array.from(el.classList),\n options?.classFilter,\n ),\n domPath: buildDomPath(el),\n siblingIndex: getSiblingIndex(el),\n parentAnchor: findParentAnchor(el, dataAttr),\n rawClasses: Array.from(el.classList),\n cssModules: decomposeCSSModules(Array.from(el.classList)),\n }\n}\n\nfunction getStableId(el: HTMLElement): string | null {\n const id = el.id\n if (!id) return null\n if (isHashedClass(id)) return null\n return id\n}\n\nfunction getTextContent(el: HTMLElement): string | null {\n // Use only direct text nodes, not nested children's text\n let text = ''\n for (const node of Array.from(el.childNodes)) {\n if (node.nodeType === Node.TEXT_NODE) {\n text += node.textContent ?? ''\n }\n }\n text = text.trim()\n\n // If no direct text, try first meaningful child's text (for wrappers like <span><b>Text</b></span>)\n if (!text && el.children.length <= 3) {\n text = el.textContent?.trim() ?? ''\n }\n\n if (!text) return null\n return text.length > TEXT_MAX_LENGTH ? text.slice(0, TEXT_MAX_LENGTH) : text\n}\n\nfunction buildDomPath(el: HTMLElement): string {\n const parts: string[] = []\n let current: HTMLElement | null = el\n\n while (current && current !== document.body && parts.length < 5) {\n let segment = current.tagName.toLowerCase()\n const stable = filterClasses(Array.from(current.classList))\n if (stable.length > 0) {\n segment += '.' + stable.slice(0, 2).join('.')\n }\n parts.unshift(segment)\n current = current.parentElement\n }\n\n return parts.join(' > ')\n}\n\nfunction getSiblingIndex(el: HTMLElement): number {\n const parent = el.parentElement\n if (!parent) return 0\n const children = Array.from(parent.children)\n return children.indexOf(el)\n}\n\nfunction findParentAnchor(el: HTMLElement, dataAttr: string): string | null {\n let current = el.parentElement\n while (current && current !== document.body) {\n const value = current.getAttribute(dataAttr)\n if (value) return value\n current = current.parentElement\n }\n return null\n}\n","import type { ElementFingerprint, WebRemarqOptions } from './types'\nimport { filterClasses } from './hash-detect'\n\nconst MATCH_THRESHOLD = 50\n\nexport function levenshteinSimilarity(a: string, b: string): number {\n if (a === b) return 1\n if (!a.length || !b.length) return 0\n\n const matrix: number[][] = []\n for (let i = 0; i <= a.length; i++) {\n matrix[i] = [i]\n }\n for (let j = 0; j <= b.length; j++) {\n matrix[0][j] = j\n }\n\n for (let i = 1; i <= a.length; i++) {\n for (let j = 1; j <= b.length; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1\n matrix[i][j] = Math.min(\n matrix[i - 1][j] + 1,\n matrix[i][j - 1] + 1,\n matrix[i - 1][j - 1] + cost,\n )\n }\n }\n\n const distance = matrix[a.length][b.length]\n return 1 - distance / Math.max(a.length, b.length)\n}\n\nfunction textSimilarity(a: string | null, b: string | null): number {\n if (!a || !b) return 0\n const na = a.trim().toLowerCase()\n const nb = b.trim().toLowerCase()\n if (na === nb) return 1\n if (na.includes(nb) || nb.includes(na)) return 1\n return levenshteinSimilarity(na, nb)\n}\n\nfunction jaccardSimilarity(a: string[], b: string[]): number {\n if (!a.length && !b.length) return 0\n const setA = new Set(a)\n const setB = new Set(b)\n let intersection = 0\n for (const item of setA) {\n if (setB.has(item)) intersection++\n }\n const union = new Set([...a, ...b]).size\n return union === 0 ? 0 : intersection / union\n}\n\nfunction scoreCandidate(el: HTMLElement, fp: ElementFingerprint, dataAttr: string): number {\n let score = 0\n\n // dataAnnotate match (+100)\n const elAnnotate = el.getAttribute(dataAttr)\n if (fp.dataAnnotate && elAnnotate === fp.dataAnnotate) {\n score += 100\n }\n\n // textContent match (+35 scaled)\n const elText = el.textContent?.trim().slice(0, 50) ?? null\n const textSim = textSimilarity(fp.textContent, elText)\n if (textSim > 0.7) {\n score += textSim * 35\n }\n\n // role + ariaLabel match (+30)\n if (fp.role && el.getAttribute('role') === fp.role &&\n fp.ariaLabel && el.getAttribute('aria-label') === fp.ariaLabel) {\n score += 30\n }\n\n // parentAnchor match (+15)\n if (fp.parentAnchor) {\n let parent = el.parentElement\n while (parent && parent !== document.body) {\n if (parent.getAttribute(dataAttr) === fp.parentAnchor) {\n score += 15\n break\n }\n parent = parent.parentElement\n }\n }\n\n // stableClasses overlap (+30 scaled)\n if (fp.stableClasses.length > 0) {\n const elClasses = filterClasses(Array.from(el.classList))\n const jaccard = jaccardSimilarity(fp.stableClasses, elClasses)\n score += jaccard * 30\n }\n\n // domPath match (+20 scaled)\n if (fp.domPath) {\n const elPath = buildDomPath(el)\n const pathSim = levenshteinSimilarity(fp.domPath, elPath)\n score += pathSim * 20\n }\n\n // siblingIndex match (+5)\n const parent = el.parentElement\n if (parent) {\n const idx = Array.from(parent.children).indexOf(el)\n if (idx === fp.siblingIndex) {\n score += 5\n }\n }\n\n return score\n}\n\nfunction buildDomPath(el: HTMLElement): string {\n const parts: string[] = []\n let current: HTMLElement | null = el\n while (current && current !== document.body && parts.length < 5) {\n let segment = current.tagName.toLowerCase()\n const stable = filterClasses(Array.from(current.classList))\n if (stable.length > 0) {\n segment += '.' + stable.slice(0, 2).join('.')\n }\n parts.unshift(segment)\n current = current.parentElement\n }\n return parts.join(' > ')\n}\n\nexport function matchElement(\n fp: ElementFingerprint,\n options?: Pick<WebRemarqOptions, 'dataAttribute'>,\n): HTMLElement | null {\n const dataAttr = options?.dataAttribute ?? 'data-annotate'\n\n // 1. Exact match by data-annotate\n if (fp.dataAnnotate) {\n const el = document.querySelector<HTMLElement>(`[${dataAttr}=\"${fp.dataAnnotate}\"]`)\n if (el) return el\n }\n\n // 2. Exact match by data-testid\n if (fp.dataTestId) {\n const el = document.querySelector<HTMLElement>(\n `[data-testid=\"${fp.dataTestId}\"], [data-test=\"${fp.dataTestId}\"], [data-cy=\"${fp.dataTestId}\"]`,\n )\n if (el) return el\n }\n\n // 3. Exact match by id\n if (fp.id) {\n const el = document.getElementById(fp.id) as HTMLElement | null\n if (el) return el\n }\n\n // 4. Fuzzy match by tagName + weighted scoring\n const candidates = document.querySelectorAll<HTMLElement>(fp.tagName)\n let bestEl: HTMLElement | null = null\n let bestScore = 0\n\n for (const candidate of candidates) {\n const score = scoreCandidate(candidate, fp, dataAttr)\n if (score > bestScore) {\n bestScore = score\n bestEl = candidate\n }\n }\n\n return bestScore >= MATCH_THRESHOLD ? bestEl : null\n}\n","type BucketChangeCallback = () => void\n\nlet currentBucket: number = 0\nlet onBucketChange: BucketChangeCallback | null = null\nlet resizeHandler: (() => void) | null = null\n\nexport function toBucket(width: number): number {\n return Math.floor(width / 100) * 100\n}\n\nfunction debounce(fn: () => void, ms: number): () => void {\n let timer: ReturnType<typeof setTimeout>\n return () => {\n clearTimeout(timer)\n timer = setTimeout(fn, ms)\n }\n}\n\nexport function initViewportListener(callback: BucketChangeCallback): void {\n currentBucket = toBucket(window.innerWidth)\n onBucketChange = callback\n\n resizeHandler = debounce(() => {\n const newBucket = toBucket(window.innerWidth)\n if (newBucket !== currentBucket) {\n currentBucket = newBucket\n onBucketChange?.()\n }\n }, 300)\n\n window.addEventListener('resize', resizeHandler)\n}\n\nexport function destroyViewportListener(): void {\n if (resizeHandler) {\n window.removeEventListener('resize', resizeHandler)\n resizeHandler = null\n }\n onBucketChange = null\n}\n","import type { Annotation, AnnotationStore } from './types'\nimport { toBucket } from './viewport'\n\nconst STORAGE_KEY = 'remarq:annotations'\n\nexport class AnnotationStorage {\n private annotations: Annotation[] = []\n private extraFields: Record<string, unknown> = {}\n isMemoryOnly = false\n\n constructor() {\n this.load()\n }\n\n getAll(): Annotation[] {\n return [...this.annotations]\n }\n\n getByRoute(route: string): Annotation[] {\n return this.annotations.filter((a) => a.route === route)\n }\n\n add(annotation: Annotation): void {\n this.annotations.push(annotation)\n this.save()\n }\n\n remove(id: string): void {\n this.annotations = this.annotations.filter((a) => a.id !== id)\n this.save()\n }\n\n update(id: string, changes: Partial<Annotation>): void {\n const idx = this.annotations.findIndex((a) => a.id === id)\n if (idx !== -1) {\n this.annotations[idx] = { ...this.annotations[idx], ...changes }\n this.save()\n }\n }\n\n clearAll(): void {\n this.annotations = []\n this.save()\n }\n\n exportJSON(): AnnotationStore {\n return {\n version: 1,\n annotations: [...this.annotations],\n }\n }\n\n importJSON(data: AnnotationStore): void {\n this.annotations = [...data.annotations]\n this.migrateViewportBuckets()\n this.save()\n }\n\n private migrateViewportBuckets(): void {\n for (const ann of this.annotations) {\n if (ann.viewportBucket == null && ann.viewport) {\n const width = parseInt(ann.viewport.split('x')[0], 10)\n ann.viewportBucket = toBucket(width)\n }\n }\n }\n\n private load(): void {\n try {\n const raw = localStorage.getItem(STORAGE_KEY)\n if (raw) {\n const parsed = JSON.parse(raw)\n const { version, annotations, ...rest } = parsed\n this.annotations = annotations ?? []\n this.extraFields = rest\n this.migrateViewportBuckets()\n }\n } catch {\n this.isMemoryOnly = true\n }\n }\n\n private save(): void {\n if (this.isMemoryOnly) return\n try {\n const data = {\n version: 1,\n ...this.extraFields,\n annotations: this.annotations,\n }\n localStorage.setItem(STORAGE_KEY, JSON.stringify(data))\n } catch {\n this.isMemoryOnly = true\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAM,iBAAiB;AACvB,IAAM,sBAAsB;AAC5B,IAAM,uBAAuB;AAC7B,IAAM,aAAa;AACnB,IAAM,eAAe;AAEd,SAAS,cAAc,WAA4B;AACxD,MAAI,qBAAqB,KAAK,SAAS,EAAG,QAAO;AACjD,MAAI,WAAW,KAAK,SAAS,E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,EACF;AAAA,EAEQ,OAAa;AACnB,QAAI,KAAK,aAAc;AACvB,QAAI;AACF,YAAM,OAAO;AAAA,QACX,SAAS;AAAA,SACN,KAAK,cAFG;AAAA,QAGX,aAAa,KAAK;AAAA,MACpB;AACA,mBAAa,QAAQ,aAAa,KAAK,UAAU,IAAI,CAAC;AAAA,IACxD,SAAQ;AACN,WAAK,eAAe;AAAA,IACtB;AAAA,EACF;AACF;","names":["parent","buildDomPath"]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/index.ts","../../src/core/hash-detect.ts","../../src/core/source-detect.ts","../../src/core/fingerprint.ts","../../src/core/matcher.ts","../../src/core/viewport.ts","../../src/core/storage.ts","../../src/core/agent-export.ts"],"sourcesContent":["export type { Annotation, AnnotationStore, ElementFingerprint, CSSModuleClass, SourceDetectionResult, SearchConfidence, GrepQuery, AgentSearchHints, AgentAnnotationSource, AgentAnnotation, AgentExport } from './types'\nexport { createFingerprint } from './fingerprint'\nexport { matchElement } from './matcher'\nexport { AnnotationStorage } from './storage'\nexport { detectRemarqPlugin, detectSource } from './source-detect'\nexport { generateAgentExport } from './agent-export'\n","import type { CSSModuleClass } from './types'\n\nconst CSS_MODULES_RE = /^(.+)__([a-zA-Z0-9]{3,})$/\nconst CSS_MODULES_3SEG_RE = /^([^_]+(?:[_-][^_]+)*)__([a-zA-Z][a-zA-Z0-9]*)__([a-zA-Z0-9]{3,})$/\nconst STYLED_COMPONENTS_RE = /^sc-/\nconst EMOTION_RE = /^css-[a-zA-Z0-9]+$/\nconst PURE_HASH_RE = /^(?=.*[a-zA-Z])(?=.*\\d)[a-zA-Z0-9]{8,}$/\n\nexport function isHashedClass(className: string): boolean {\n if (STYLED_COMPONENTS_RE.test(className)) return true\n if (EMOTION_RE.test(className)) return true\n if (CSS_MODULES_RE.test(className)) return true\n if (PURE_HASH_RE.test(className)) return true\n return false\n}\n\nexport function stripHash(className: string): string {\n const match = className.match(CSS_MODULES_RE)\n if (match) {\n const prefix = className.slice(0, className.lastIndexOf('__'))\n return prefix\n }\n return className\n}\n\nexport function filterClasses(\n classes: string[],\n classFilter?: (className: string) => boolean,\n): string[] {\n const result: string[] = []\n\n for (const cls of classes) {\n if (STYLED_COMPONENTS_RE.test(cls)) continue\n if (EMOTION_RE.test(cls)) continue\n if (PURE_HASH_RE.test(cls)) continue\n\n let stable = stripHash(cls)\n\n if (classFilter && !classFilter(stable)) continue\n\n result.push(stable)\n }\n\n return result\n}\n\nexport function decomposeCSSModules(classes: string[]): CSSModuleClass[] {\n const result: CSSModuleClass[] = []\n for (const cls of classes) {\n const match = cls.match(CSS_MODULES_3SEG_RE)\n if (match) {\n result.push({\n raw: cls,\n moduleHint: match[1],\n localName: match[2],\n })\n }\n }\n return result\n}\n","import type { SourceDetectionResult } from './types'\n\n/**\n * Level 1: Read data-remarq-source/data-remarq-component attrs\n * injected by @web-remarq/babel-plugin or @web-remarq/unplugin.\n */\nexport function detectRemarqPlugin(el: HTMLElement): SourceDetectionResult {\n const source = el.getAttribute('data-remarq-source')\n if (!source) return { source: null, component: null }\n return {\n source,\n component: el.getAttribute('data-remarq-component'),\n }\n}\n\n/**\n * Level 2a: Read data-source or data-locator attrs\n * from locator.js or similar external tools.\n */\nexport function detectExternalSource(el: HTMLElement): SourceDetectionResult {\n const source = el.dataset.source ?? el.getAttribute('data-locator')\n if (!source) return { source: null, component: null }\n return { source, component: null }\n}\n\n/**\n * Level 2b: Read React fiber _debugSource (dev mode only).\n * Unstable/best-effort — React internals are not public API.\n * Walks up the fiber tree because _debugSource lives on component fibers,\n * not on host (DOM element) fibers.\n */\nexport function detectReactFiber(el: HTMLElement): SourceDetectionResult {\n const key = Object.keys(el).find(k => k.startsWith('__reactFiber$'))\n if (!key) return { source: null, component: null }\n\n let current = (el as unknown as Record<string, unknown>)[key] as Record<string, unknown> | null\n // Walk up fiber tree to find nearest fiber with _debugSource (max 15 levels)\n let depth = 0\n while (current && depth < 15) {\n const debugSource = current._debugSource as { fileName?: string; lineNumber?: number; columnNumber?: number } | undefined\n if (debugSource?.fileName) {\n const source = `${debugSource.fileName}:${debugSource.lineNumber ?? 0}:${debugSource.columnNumber ?? 0}`\n\n // Try to get component name from fiber.type\n const fiberType = current.type as { displayName?: string; name?: string } | string | undefined\n const component = typeof fiberType === 'object' && fiberType\n ? (fiberType.displayName ?? fiberType.name ?? null)\n : null\n\n return { source, component }\n }\n current = current.return as Record<string, unknown> | null\n depth++\n }\n\n return { source: null, component: null }\n}\n\n/**\n * Runs Level 2 detectors in order. Returns first non-null result.\n */\nexport function detectSource(el: HTMLElement): SourceDetectionResult {\n const external = detectExternalSource(el)\n if (external.source) return external\n\n const fiber = detectReactFiber(el)\n if (fiber.source) return fiber\n\n return { source: null, component: null }\n}\n","import type { ElementFingerprint, WebRemarqOptions } from './types'\nimport { filterClasses, isHashedClass, decomposeCSSModules } from './hash-detect'\nimport { detectRemarqPlugin, detectSource } from './source-detect'\n\nconst TEXT_MAX_LENGTH = 50\n\nexport function createFingerprint(\n el: HTMLElement,\n options?: Pick<WebRemarqOptions, 'classFilter' | 'dataAttribute'>,\n): ElementFingerprint {\n const dataAttr = options?.dataAttribute ?? 'data-annotate'\n\n return {\n dataAnnotate: el.getAttribute(dataAttr) ?? null,\n dataTestId: el.getAttribute('data-testid')\n ?? el.getAttribute('data-test')\n ?? el.getAttribute('data-cy')\n ?? null,\n id: getStableId(el),\n tagName: el.tagName.toLowerCase(),\n textContent: getTextContent(el),\n role: el.getAttribute('role') ?? null,\n ariaLabel: el.getAttribute('aria-label') ?? null,\n stableClasses: filterClasses(\n Array.from(el.classList),\n options?.classFilter,\n ),\n domPath: buildDomPath(el),\n siblingIndex: getSiblingIndex(el),\n parentAnchor: findParentAnchor(el, dataAttr),\n rawClasses: Array.from(el.classList),\n cssModules: decomposeCSSModules(Array.from(el.classList)),\n ...resolveSourceFields(el),\n }\n}\n\nfunction resolveSourceFields(el: HTMLElement): {\n sourceLocation: string | null\n componentName: string | null\n detectedSource: string | null\n detectedComponent: string | null\n} {\n const plugin = detectRemarqPlugin(el)\n if (plugin.source) {\n return {\n sourceLocation: plugin.source,\n componentName: plugin.component,\n detectedSource: null,\n detectedComponent: null,\n }\n }\n\n const detected = detectSource(el)\n return {\n sourceLocation: null,\n componentName: null,\n detectedSource: detected.source,\n detectedComponent: detected.component,\n }\n}\n\nfunction getStableId(el: HTMLElement): string | null {\n const id = el.id\n if (!id) return null\n if (isHashedClass(id)) return null\n return id\n}\n\nfunction getTextContent(el: HTMLElement): string | null {\n // Use only direct text nodes, not nested children's text\n let text = ''\n for (const node of Array.from(el.childNodes)) {\n if (node.nodeType === Node.TEXT_NODE) {\n text += node.textContent ?? ''\n }\n }\n text = text.trim()\n\n // If no direct text, try first meaningful child's text (for wrappers like <span><b>Text</b></span>)\n if (!text && el.children.length <= 3) {\n text = el.textContent?.trim() ?? ''\n }\n\n if (!text) return null\n return text.length > TEXT_MAX_LENGTH ? text.slice(0, TEXT_MAX_LENGTH) : text\n}\n\nfunction buildDomPath(el: HTMLElement): string {\n const parts: string[] = []\n let current: HTMLElement | null = el\n\n while (current && current !== document.body && parts.length < 5) {\n let segment = current.tagName.toLowerCase()\n const stable = filterClasses(Array.from(current.classList))\n if (stable.length > 0) {\n segment += '.' + stable.slice(0, 2).join('.')\n }\n parts.unshift(segment)\n current = current.parentElement\n }\n\n return parts.join(' > ')\n}\n\nfunction getSiblingIndex(el: HTMLElement): number {\n const parent = el.parentElement\n if (!parent) return 0\n const children = Array.from(parent.children)\n return children.indexOf(el)\n}\n\nfunction findParentAnchor(el: HTMLElement, dataAttr: string): string | null {\n let current = el.parentElement\n while (current && current !== document.body) {\n const value = current.getAttribute(dataAttr)\n if (value) return value\n current = current.parentElement\n }\n return null\n}\n","import type { ElementFingerprint, WebRemarqOptions } from './types'\nimport { filterClasses } from './hash-detect'\n\nconst MATCH_THRESHOLD = 50\n\nexport function levenshteinSimilarity(a: string, b: string): number {\n if (a === b) return 1\n if (!a.length || !b.length) return 0\n\n const matrix: number[][] = []\n for (let i = 0; i <= a.length; i++) {\n matrix[i] = [i]\n }\n for (let j = 0; j <= b.length; j++) {\n matrix[0][j] = j\n }\n\n for (let i = 1; i <= a.length; i++) {\n for (let j = 1; j <= b.length; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1\n matrix[i][j] = Math.min(\n matrix[i - 1][j] + 1,\n matrix[i][j - 1] + 1,\n matrix[i - 1][j - 1] + cost,\n )\n }\n }\n\n const distance = matrix[a.length][b.length]\n return 1 - distance / Math.max(a.length, b.length)\n}\n\nfunction textSimilarity(a: string | null, b: string | null): number {\n if (!a || !b) return 0\n const na = a.trim().toLowerCase()\n const nb = b.trim().toLowerCase()\n if (na === nb) return 1\n if (na.includes(nb) || nb.includes(na)) return 1\n return levenshteinSimilarity(na, nb)\n}\n\nfunction jaccardSimilarity(a: string[], b: string[]): number {\n if (!a.length && !b.length) return 0\n const setA = new Set(a)\n const setB = new Set(b)\n let intersection = 0\n for (const item of setA) {\n if (setB.has(item)) intersection++\n }\n const union = new Set([...a, ...b]).size\n return union === 0 ? 0 : intersection / union\n}\n\nfunction scoreCandidate(el: HTMLElement, fp: ElementFingerprint, dataAttr: string): number {\n let score = 0\n\n // dataAnnotate match (+100)\n const elAnnotate = el.getAttribute(dataAttr)\n if (fp.dataAnnotate && elAnnotate === fp.dataAnnotate) {\n score += 100\n }\n\n // textContent match (+35 scaled)\n const elText = el.textContent?.trim().slice(0, 50) ?? null\n const textSim = textSimilarity(fp.textContent, elText)\n if (textSim > 0.7) {\n score += textSim * 35\n }\n\n // role + ariaLabel match (+30)\n if (fp.role && el.getAttribute('role') === fp.role &&\n fp.ariaLabel && el.getAttribute('aria-label') === fp.ariaLabel) {\n score += 30\n }\n\n // parentAnchor match (+15)\n if (fp.parentAnchor) {\n let parent = el.parentElement\n while (parent && parent !== document.body) {\n if (parent.getAttribute(dataAttr) === fp.parentAnchor) {\n score += 15\n break\n }\n parent = parent.parentElement\n }\n }\n\n // stableClasses overlap (+30 scaled)\n if (fp.stableClasses.length > 0) {\n const elClasses = filterClasses(Array.from(el.classList))\n const jaccard = jaccardSimilarity(fp.stableClasses, elClasses)\n score += jaccard * 30\n }\n\n // domPath match (+20 scaled)\n if (fp.domPath) {\n const elPath = buildDomPath(el)\n const pathSim = levenshteinSimilarity(fp.domPath, elPath)\n score += pathSim * 20\n }\n\n // siblingIndex match (+5)\n const parent = el.parentElement\n if (parent) {\n const idx = Array.from(parent.children).indexOf(el)\n if (idx === fp.siblingIndex) {\n score += 5\n }\n }\n\n return score\n}\n\nfunction buildDomPath(el: HTMLElement): string {\n const parts: string[] = []\n let current: HTMLElement | null = el\n while (current && current !== document.body && parts.length < 5) {\n let segment = current.tagName.toLowerCase()\n const stable = filterClasses(Array.from(current.classList))\n if (stable.length > 0) {\n segment += '.' + stable.slice(0, 2).join('.')\n }\n parts.unshift(segment)\n current = current.parentElement\n }\n return parts.join(' > ')\n}\n\nexport function matchElement(\n fp: ElementFingerprint,\n options?: Pick<WebRemarqOptions, 'dataAttribute'>,\n): HTMLElement | null {\n const dataAttr = options?.dataAttribute ?? 'data-annotate'\n\n // 1. Exact match by data-annotate\n if (fp.dataAnnotate) {\n const el = document.querySelector<HTMLElement>(`[${dataAttr}=\"${fp.dataAnnotate}\"]`)\n if (el) return el\n }\n\n // 2. Exact match by data-testid\n if (fp.dataTestId) {\n const el = document.querySelector<HTMLElement>(\n `[data-testid=\"${fp.dataTestId}\"], [data-test=\"${fp.dataTestId}\"], [data-cy=\"${fp.dataTestId}\"]`,\n )\n if (el) return el\n }\n\n // 3. Exact match by id\n if (fp.id) {\n const el = document.getElementById(fp.id) as HTMLElement | null\n if (el) return el\n }\n\n // 4. Fuzzy match by tagName + weighted scoring\n const candidates = document.querySelectorAll<HTMLElement>(fp.tagName)\n let bestEl: HTMLElement | null = null\n let bestScore = 0\n\n for (const candidate of candidates) {\n const score = scoreCandidate(candidate, fp, dataAttr)\n if (score > bestScore) {\n bestScore = score\n bestEl = candidate\n }\n }\n\n return bestScore >= MATCH_THRESHOLD ? bestEl : null\n}\n","type BucketChangeCallback = () => void\n\nlet currentBucket: number = 0\nlet onBucketChange: BucketChangeCallback | null = null\nlet resizeHandler: (() => void) | null = null\n\nexport function toBucket(width: number): number {\n return Math.floor(width / 100) * 100\n}\n\nfunction debounce(fn: () => void, ms: number): () => void {\n let timer: ReturnType<typeof setTimeout>\n return () => {\n clearTimeout(timer)\n timer = setTimeout(fn, ms)\n }\n}\n\nexport function initViewportListener(callback: BucketChangeCallback): void {\n currentBucket = toBucket(window.innerWidth)\n onBucketChange = callback\n\n resizeHandler = debounce(() => {\n const newBucket = toBucket(window.innerWidth)\n if (newBucket !== currentBucket) {\n currentBucket = newBucket\n onBucketChange?.()\n }\n }, 300)\n\n window.addEventListener('resize', resizeHandler)\n}\n\nexport function destroyViewportListener(): void {\n if (resizeHandler) {\n window.removeEventListener('resize', resizeHandler)\n resizeHandler = null\n }\n onBucketChange = null\n}\n","import type { Annotation, AnnotationStore } from './types'\nimport { toBucket } from './viewport'\n\nconst STORAGE_KEY = 'remarq:annotations'\n\nexport class AnnotationStorage {\n private annotations: Annotation[] = []\n private extraFields: Record<string, unknown> = {}\n isMemoryOnly = false\n\n constructor() {\n this.load()\n }\n\n getAll(): Annotation[] {\n return [...this.annotations]\n }\n\n getByRoute(route: string): Annotation[] {\n return this.annotations.filter((a) => a.route === route)\n }\n\n add(annotation: Annotation): void {\n this.annotations.push(annotation)\n this.save()\n }\n\n remove(id: string): void {\n this.annotations = this.annotations.filter((a) => a.id !== id)\n this.save()\n }\n\n update(id: string, changes: Partial<Annotation>): void {\n const idx = this.annotations.findIndex((a) => a.id === id)\n if (idx !== -1) {\n this.annotations[idx] = { ...this.annotations[idx], ...changes }\n this.save()\n }\n }\n\n clearAll(): void {\n this.annotations = []\n this.save()\n }\n\n exportJSON(): AnnotationStore {\n return {\n version: 1,\n annotations: [...this.annotations],\n }\n }\n\n importJSON(data: AnnotationStore): void {\n this.annotations = [...data.annotations]\n this.migrateViewportBuckets()\n this.save()\n }\n\n private migrateViewportBuckets(): void {\n for (const ann of this.annotations) {\n if (ann.viewportBucket == null && ann.viewport) {\n const width = parseInt(ann.viewport.split('x')[0], 10)\n ann.viewportBucket = toBucket(width)\n }\n }\n }\n\n private load(): void {\n try {\n const raw = localStorage.getItem(STORAGE_KEY)\n if (raw) {\n const parsed = JSON.parse(raw)\n const { version, annotations, ...rest } = parsed\n this.annotations = annotations ?? []\n this.extraFields = rest\n this.migrateViewportBuckets()\n }\n } catch {\n this.isMemoryOnly = true\n }\n }\n\n private save(): void {\n if (this.isMemoryOnly) return\n try {\n const data = {\n version: 1,\n ...this.extraFields,\n annotations: this.annotations,\n }\n localStorage.setItem(STORAGE_KEY, JSON.stringify(data))\n } catch {\n this.isMemoryOnly = true\n }\n }\n}\n","import type {\n Annotation,\n AgentExport,\n AgentAnnotation,\n AgentAnnotationSource,\n AgentSearchHints,\n GrepQuery,\n ElementFingerprint,\n} from './types'\n\nfunction parseSourceLocation(raw: string): { file: string; line: number; column: number } | null {\n const parts = raw.split(':')\n if (parts.length < 2) return null\n // file path may contain \":\" on Windows (C:\\...), so rejoin all but last 2\n const column = parseInt(parts.pop()!, 10)\n const line = parseInt(parts.pop()!, 10)\n const file = parts.join(':')\n if (!file || isNaN(line)) return null\n return { file, line, column: isNaN(column) ? 0 : column }\n}\n\nfunction resolveSource(fp: ElementFingerprint): AgentAnnotationSource | null {\n // Level 1: plugin source\n if (fp.sourceLocation) {\n const parsed = parseSourceLocation(fp.sourceLocation)\n if (parsed) return { ...parsed, component: fp.componentName ?? null }\n }\n\n // Level 2: detected source\n if (fp.detectedSource) {\n const parsed = parseSourceLocation(fp.detectedSource)\n if (parsed) return { ...parsed, component: fp.detectedComponent ?? null }\n }\n\n return null\n}\n\nconst TEMPLATE_GLOB = '*.{tsx,jsx,vue,svelte,html}'\nconst CSS_MODULE_GLOB = '*.module.{css,scss,less}'\nconst COMPONENT_GLOB = '*.{tsx,jsx,vue,ts,js}'\n\nfunction buildSearchHints(fp: ElementFingerprint): AgentSearchHints {\n const grepQueries: GrepQuery[] = []\n\n // High confidence — unique selectors\n if (fp.dataAnnotate) {\n grepQueries.push({ query: `data-annotate=\"${fp.dataAnnotate}\"`, glob: TEMPLATE_GLOB, confidence: 'high' })\n }\n if (fp.dataTestId) {\n grepQueries.push({ query: `data-testid=\"${fp.dataTestId}\"`, glob: TEMPLATE_GLOB, confidence: 'high' })\n }\n if (fp.id) {\n grepQueries.push({ query: `id=\"${fp.id}\"`, glob: TEMPLATE_GLOB, confidence: 'high' })\n }\n if (fp.ariaLabel) {\n grepQueries.push({ query: `aria-label=\"${fp.ariaLabel}\"`, glob: TEMPLATE_GLOB, confidence: 'high' })\n }\n\n // Medium confidence — text, CSS modules, role\n if (fp.textContent) {\n grepQueries.push({ query: `\"${fp.textContent}\"`, glob: TEMPLATE_GLOB, confidence: 'medium' })\n }\n if (fp.role) {\n grepQueries.push({ query: `role=\"${fp.role}\"`, glob: TEMPLATE_GLOB, confidence: 'medium' })\n }\n if (fp.cssModules?.length) {\n for (const mod of fp.cssModules) {\n grepQueries.push({ query: `.${mod.localName}`, glob: CSS_MODULE_GLOB, confidence: 'medium' })\n grepQueries.push({ query: `styles.${mod.localName}`, glob: COMPONENT_GLOB, confidence: 'medium' })\n }\n }\n\n // Low confidence — classes, domPath\n if (fp.stableClasses.length) {\n for (const cls of fp.stableClasses.slice(0, 3)) {\n grepQueries.push({ query: `\"${cls}\"`, glob: TEMPLATE_GLOB, confidence: 'low' })\n }\n }\n\n return {\n grepQueries,\n domContext: fp.domPath,\n tagName: fp.tagName,\n classes: fp.rawClasses ?? fp.stableClasses,\n }\n}\n\nexport function generateAgentExport(annotations: Annotation[], viewportBucket: number): AgentExport {\n const agentAnnotations: AgentAnnotation[] = annotations.map(ann => ({\n id: ann.id,\n route: ann.route,\n comment: ann.comment,\n status: ann.status,\n timestamp: ann.timestamp,\n source: resolveSource(ann.fingerprint),\n searchHints: buildSearchHints(ann.fingerprint),\n }))\n\n return {\n version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@@ interface CSSModuleClass {
|
|
|
3
3
|
moduleHint: string;
|
|
4
4
|
localName: string;
|
|
5
5
|
}
|
|
6
|
+
interface SourceDetectionResult {
|
|
7
|
+
source: string | null;
|
|
8
|
+
component: string | null;
|
|
9
|
+
}
|
|
6
10
|
interface ElementFingerprint {
|
|
7
11
|
dataAnnotate: string | null;
|
|
8
12
|
dataTestId: string | null;
|
|
@@ -17,6 +21,10 @@ interface ElementFingerprint {
|
|
|
17
21
|
parentAnchor: string | null;
|
|
18
22
|
rawClasses?: string[];
|
|
19
23
|
cssModules?: CSSModuleClass[];
|
|
24
|
+
sourceLocation: string | null;
|
|
25
|
+
componentName: string | null;
|
|
26
|
+
detectedSource: string | null;
|
|
27
|
+
detectedComponent: string | null;
|
|
20
28
|
}
|
|
21
29
|
interface Annotation {
|
|
22
30
|
id: string;
|
|
@@ -37,6 +45,39 @@ interface WebRemarqOptions {
|
|
|
37
45
|
classFilter?: (className: string) => boolean;
|
|
38
46
|
dataAttribute?: string;
|
|
39
47
|
}
|
|
48
|
+
type SearchConfidence = 'high' | 'medium' | 'low';
|
|
49
|
+
interface GrepQuery {
|
|
50
|
+
query: string;
|
|
51
|
+
glob: string;
|
|
52
|
+
confidence: SearchConfidence;
|
|
53
|
+
}
|
|
54
|
+
interface AgentSearchHints {
|
|
55
|
+
grepQueries: GrepQuery[];
|
|
56
|
+
domContext: string;
|
|
57
|
+
tagName: string;
|
|
58
|
+
classes: string[];
|
|
59
|
+
}
|
|
60
|
+
interface AgentAnnotationSource {
|
|
61
|
+
file: string;
|
|
62
|
+
line: number;
|
|
63
|
+
column: number;
|
|
64
|
+
component: string | null;
|
|
65
|
+
}
|
|
66
|
+
interface AgentAnnotation {
|
|
67
|
+
id: string;
|
|
68
|
+
route: string;
|
|
69
|
+
comment: string;
|
|
70
|
+
status: 'pending' | 'resolved';
|
|
71
|
+
timestamp: number;
|
|
72
|
+
source: AgentAnnotationSource | null;
|
|
73
|
+
searchHints: AgentSearchHints;
|
|
74
|
+
}
|
|
75
|
+
interface AgentExport {
|
|
76
|
+
version: 1;
|
|
77
|
+
format: 'agent';
|
|
78
|
+
viewportBucket: number;
|
|
79
|
+
annotations: AgentAnnotation[];
|
|
80
|
+
}
|
|
40
81
|
|
|
41
82
|
declare function createFingerprint(el: HTMLElement, options?: Pick<WebRemarqOptions, 'classFilter' | 'dataAttribute'>): ElementFingerprint;
|
|
42
83
|
|
|
@@ -60,4 +101,16 @@ declare class AnnotationStorage {
|
|
|
60
101
|
private save;
|
|
61
102
|
}
|
|
62
103
|
|
|
63
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Level 1: Read data-remarq-source/data-remarq-component attrs
|
|
106
|
+
* injected by @web-remarq/babel-plugin or @web-remarq/unplugin.
|
|
107
|
+
*/
|
|
108
|
+
declare function detectRemarqPlugin(el: HTMLElement): SourceDetectionResult;
|
|
109
|
+
/**
|
|
110
|
+
* Runs Level 2 detectors in order. Returns first non-null result.
|
|
111
|
+
*/
|
|
112
|
+
declare function detectSource(el: HTMLElement): SourceDetectionResult;
|
|
113
|
+
|
|
114
|
+
declare function generateAgentExport(annotations: Annotation[], viewportBucket: number): AgentExport;
|
|
115
|
+
|
|
116
|
+
export { type AgentAnnotation, type AgentAnnotationSource, type AgentExport, type AgentSearchHints, type Annotation, AnnotationStorage, type AnnotationStore, type CSSModuleClass, type ElementFingerprint, type GrepQuery, type SearchConfidence, type SourceDetectionResult, createFingerprint, detectRemarqPlugin, detectSource, generateAgentExport, matchElement };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ interface CSSModuleClass {
|
|
|
3
3
|
moduleHint: string;
|
|
4
4
|
localName: string;
|
|
5
5
|
}
|
|
6
|
+
interface SourceDetectionResult {
|
|
7
|
+
source: string | null;
|
|
8
|
+
component: string | null;
|
|
9
|
+
}
|
|
6
10
|
interface ElementFingerprint {
|
|
7
11
|
dataAnnotate: string | null;
|
|
8
12
|
dataTestId: string | null;
|
|
@@ -17,6 +21,10 @@ interface ElementFingerprint {
|
|
|
17
21
|
parentAnchor: string | null;
|
|
18
22
|
rawClasses?: string[];
|
|
19
23
|
cssModules?: CSSModuleClass[];
|
|
24
|
+
sourceLocation: string | null;
|
|
25
|
+
componentName: string | null;
|
|
26
|
+
detectedSource: string | null;
|
|
27
|
+
detectedComponent: string | null;
|
|
20
28
|
}
|
|
21
29
|
interface Annotation {
|
|
22
30
|
id: string;
|
|
@@ -37,6 +45,39 @@ interface WebRemarqOptions {
|
|
|
37
45
|
classFilter?: (className: string) => boolean;
|
|
38
46
|
dataAttribute?: string;
|
|
39
47
|
}
|
|
48
|
+
type SearchConfidence = 'high' | 'medium' | 'low';
|
|
49
|
+
interface GrepQuery {
|
|
50
|
+
query: string;
|
|
51
|
+
glob: string;
|
|
52
|
+
confidence: SearchConfidence;
|
|
53
|
+
}
|
|
54
|
+
interface AgentSearchHints {
|
|
55
|
+
grepQueries: GrepQuery[];
|
|
56
|
+
domContext: string;
|
|
57
|
+
tagName: string;
|
|
58
|
+
classes: string[];
|
|
59
|
+
}
|
|
60
|
+
interface AgentAnnotationSource {
|
|
61
|
+
file: string;
|
|
62
|
+
line: number;
|
|
63
|
+
column: number;
|
|
64
|
+
component: string | null;
|
|
65
|
+
}
|
|
66
|
+
interface AgentAnnotation {
|
|
67
|
+
id: string;
|
|
68
|
+
route: string;
|
|
69
|
+
comment: string;
|
|
70
|
+
status: 'pending' | 'resolved';
|
|
71
|
+
timestamp: number;
|
|
72
|
+
source: AgentAnnotationSource | null;
|
|
73
|
+
searchHints: AgentSearchHints;
|
|
74
|
+
}
|
|
75
|
+
interface AgentExport {
|
|
76
|
+
version: 1;
|
|
77
|
+
format: 'agent';
|
|
78
|
+
viewportBucket: number;
|
|
79
|
+
annotations: AgentAnnotation[];
|
|
80
|
+
}
|
|
40
81
|
|
|
41
82
|
declare function createFingerprint(el: HTMLElement, options?: Pick<WebRemarqOptions, 'classFilter' | 'dataAttribute'>): ElementFingerprint;
|
|
42
83
|
|
|
@@ -60,4 +101,16 @@ declare class AnnotationStorage {
|
|
|
60
101
|
private save;
|
|
61
102
|
}
|
|
62
103
|
|
|
63
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Level 1: Read data-remarq-source/data-remarq-component attrs
|
|
106
|
+
* injected by @web-remarq/babel-plugin or @web-remarq/unplugin.
|
|
107
|
+
*/
|
|
108
|
+
declare function detectRemarqPlugin(el: HTMLElement): SourceDetectionResult;
|
|
109
|
+
/**
|
|
110
|
+
* Runs Level 2 detectors in order. Returns first non-null result.
|
|
111
|
+
*/
|
|
112
|
+
declare function detectSource(el: HTMLElement): SourceDetectionResult;
|
|
113
|
+
|
|
114
|
+
declare function generateAgentExport(annotations: Annotation[], viewportBucket: number): AgentExport;
|
|
115
|
+
|
|
116
|
+
export { type AgentAnnotation, type AgentAnnotationSource, type AgentExport, type AgentSearchHints, type Annotation, AnnotationStorage, type AnnotationStore, type CSSModuleClass, type ElementFingerprint, type GrepQuery, type SearchConfidence, type SourceDetectionResult, createFingerprint, detectRemarqPlugin, detectSource, generateAgentExport, matchElement };
|
package/dist/core/index.js
CHANGED
|
@@ -78,12 +78,54 @@ function decomposeCSSModules(classes) {
|
|
|
78
78
|
return result;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
// src/core/source-detect.ts
|
|
82
|
+
function detectRemarqPlugin(el) {
|
|
83
|
+
const source = el.getAttribute("data-remarq-source");
|
|
84
|
+
if (!source) return { source: null, component: null };
|
|
85
|
+
return {
|
|
86
|
+
source,
|
|
87
|
+
component: el.getAttribute("data-remarq-component")
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function detectExternalSource(el) {
|
|
91
|
+
var _a;
|
|
92
|
+
const source = (_a = el.dataset.source) != null ? _a : el.getAttribute("data-locator");
|
|
93
|
+
if (!source) return { source: null, component: null };
|
|
94
|
+
return { source, component: null };
|
|
95
|
+
}
|
|
96
|
+
function detectReactFiber(el) {
|
|
97
|
+
var _a, _b, _c, _d;
|
|
98
|
+
const key = Object.keys(el).find((k) => k.startsWith("__reactFiber$"));
|
|
99
|
+
if (!key) return { source: null, component: null };
|
|
100
|
+
let current = el[key];
|
|
101
|
+
let depth = 0;
|
|
102
|
+
while (current && depth < 15) {
|
|
103
|
+
const debugSource = current._debugSource;
|
|
104
|
+
if (debugSource == null ? void 0 : debugSource.fileName) {
|
|
105
|
+
const source = `${debugSource.fileName}:${(_a = debugSource.lineNumber) != null ? _a : 0}:${(_b = debugSource.columnNumber) != null ? _b : 0}`;
|
|
106
|
+
const fiberType = current.type;
|
|
107
|
+
const component = typeof fiberType === "object" && fiberType ? (_d = (_c = fiberType.displayName) != null ? _c : fiberType.name) != null ? _d : null : null;
|
|
108
|
+
return { source, component };
|
|
109
|
+
}
|
|
110
|
+
current = current.return;
|
|
111
|
+
depth++;
|
|
112
|
+
}
|
|
113
|
+
return { source: null, component: null };
|
|
114
|
+
}
|
|
115
|
+
function detectSource(el) {
|
|
116
|
+
const external = detectExternalSource(el);
|
|
117
|
+
if (external.source) return external;
|
|
118
|
+
const fiber = detectReactFiber(el);
|
|
119
|
+
if (fiber.source) return fiber;
|
|
120
|
+
return { source: null, component: null };
|
|
121
|
+
}
|
|
122
|
+
|
|
81
123
|
// src/core/fingerprint.ts
|
|
82
124
|
var TEXT_MAX_LENGTH = 50;
|
|
83
125
|
function createFingerprint(el, options) {
|
|
84
126
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
85
127
|
const dataAttr = (_a = options == null ? void 0 : options.dataAttribute) != null ? _a : "data-annotate";
|
|
86
|
-
return {
|
|
128
|
+
return __spreadValues({
|
|
87
129
|
dataAnnotate: (_b = el.getAttribute(dataAttr)) != null ? _b : null,
|
|
88
130
|
dataTestId: (_e = (_d = (_c = el.getAttribute("data-testid")) != null ? _c : el.getAttribute("data-test")) != null ? _d : el.getAttribute("data-cy")) != null ? _e : null,
|
|
89
131
|
id: getStableId(el),
|
|
@@ -100,6 +142,24 @@ function createFingerprint(el, options) {
|
|
|
100
142
|
parentAnchor: findParentAnchor(el, dataAttr),
|
|
101
143
|
rawClasses: Array.from(el.classList),
|
|
102
144
|
cssModules: decomposeCSSModules(Array.from(el.classList))
|
|
145
|
+
}, resolveSourceFields(el));
|
|
146
|
+
}
|
|
147
|
+
function resolveSourceFields(el) {
|
|
148
|
+
const plugin = detectRemarqPlugin(el);
|
|
149
|
+
if (plugin.source) {
|
|
150
|
+
return {
|
|
151
|
+
sourceLocation: plugin.source,
|
|
152
|
+
componentName: plugin.component,
|
|
153
|
+
detectedSource: null,
|
|
154
|
+
detectedComponent: null
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const detected = detectSource(el);
|
|
158
|
+
return {
|
|
159
|
+
sourceLocation: null,
|
|
160
|
+
componentName: null,
|
|
161
|
+
detectedSource: detected.source,
|
|
162
|
+
detectedComponent: detected.component
|
|
103
163
|
};
|
|
104
164
|
}
|
|
105
165
|
function getStableId(el) {
|
|
@@ -371,9 +431,94 @@ var AnnotationStorage = class {
|
|
|
371
431
|
}
|
|
372
432
|
}
|
|
373
433
|
};
|
|
434
|
+
|
|
435
|
+
// src/core/agent-export.ts
|
|
436
|
+
function parseSourceLocation(raw) {
|
|
437
|
+
const parts = raw.split(":");
|
|
438
|
+
if (parts.length < 2) return null;
|
|
439
|
+
const column = parseInt(parts.pop(), 10);
|
|
440
|
+
const line = parseInt(parts.pop(), 10);
|
|
441
|
+
const file = parts.join(":");
|
|
442
|
+
if (!file || isNaN(line)) return null;
|
|
443
|
+
return { file, line, column: isNaN(column) ? 0 : column };
|
|
444
|
+
}
|
|
445
|
+
function resolveSource(fp) {
|
|
446
|
+
var _a, _b;
|
|
447
|
+
if (fp.sourceLocation) {
|
|
448
|
+
const parsed = parseSourceLocation(fp.sourceLocation);
|
|
449
|
+
if (parsed) return __spreadProps(__spreadValues({}, parsed), { component: (_a = fp.componentName) != null ? _a : null });
|
|
450
|
+
}
|
|
451
|
+
if (fp.detectedSource) {
|
|
452
|
+
const parsed = parseSourceLocation(fp.detectedSource);
|
|
453
|
+
if (parsed) return __spreadProps(__spreadValues({}, parsed), { component: (_b = fp.detectedComponent) != null ? _b : null });
|
|
454
|
+
}
|
|
455
|
+
return null;
|
|
456
|
+
}
|
|
457
|
+
var TEMPLATE_GLOB = "*.{tsx,jsx,vue,svelte,html}";
|
|
458
|
+
var CSS_MODULE_GLOB = "*.module.{css,scss,less}";
|
|
459
|
+
var COMPONENT_GLOB = "*.{tsx,jsx,vue,ts,js}";
|
|
460
|
+
function buildSearchHints(fp) {
|
|
461
|
+
var _a, _b;
|
|
462
|
+
const grepQueries = [];
|
|
463
|
+
if (fp.dataAnnotate) {
|
|
464
|
+
grepQueries.push({ query: `data-annotate="${fp.dataAnnotate}"`, glob: TEMPLATE_GLOB, confidence: "high" });
|
|
465
|
+
}
|
|
466
|
+
if (fp.dataTestId) {
|
|
467
|
+
grepQueries.push({ query: `data-testid="${fp.dataTestId}"`, glob: TEMPLATE_GLOB, confidence: "high" });
|
|
468
|
+
}
|
|
469
|
+
if (fp.id) {
|
|
470
|
+
grepQueries.push({ query: `id="${fp.id}"`, glob: TEMPLATE_GLOB, confidence: "high" });
|
|
471
|
+
}
|
|
472
|
+
if (fp.ariaLabel) {
|
|
473
|
+
grepQueries.push({ query: `aria-label="${fp.ariaLabel}"`, glob: TEMPLATE_GLOB, confidence: "high" });
|
|
474
|
+
}
|
|
475
|
+
if (fp.textContent) {
|
|
476
|
+
grepQueries.push({ query: `"${fp.textContent}"`, glob: TEMPLATE_GLOB, confidence: "medium" });
|
|
477
|
+
}
|
|
478
|
+
if (fp.role) {
|
|
479
|
+
grepQueries.push({ query: `role="${fp.role}"`, glob: TEMPLATE_GLOB, confidence: "medium" });
|
|
480
|
+
}
|
|
481
|
+
if ((_a = fp.cssModules) == null ? void 0 : _a.length) {
|
|
482
|
+
for (const mod of fp.cssModules) {
|
|
483
|
+
grepQueries.push({ query: `.${mod.localName}`, glob: CSS_MODULE_GLOB, confidence: "medium" });
|
|
484
|
+
grepQueries.push({ query: `styles.${mod.localName}`, glob: COMPONENT_GLOB, confidence: "medium" });
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
if (fp.stableClasses.length) {
|
|
488
|
+
for (const cls of fp.stableClasses.slice(0, 3)) {
|
|
489
|
+
grepQueries.push({ query: `"${cls}"`, glob: TEMPLATE_GLOB, confidence: "low" });
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return {
|
|
493
|
+
grepQueries,
|
|
494
|
+
domContext: fp.domPath,
|
|
495
|
+
tagName: fp.tagName,
|
|
496
|
+
classes: (_b = fp.rawClasses) != null ? _b : fp.stableClasses
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
function generateAgentExport(annotations, viewportBucket) {
|
|
500
|
+
const agentAnnotations = annotations.map((ann) => ({
|
|
501
|
+
id: ann.id,
|
|
502
|
+
route: ann.route,
|
|
503
|
+
comment: ann.comment,
|
|
504
|
+
status: ann.status,
|
|
505
|
+
timestamp: ann.timestamp,
|
|
506
|
+
source: resolveSource(ann.fingerprint),
|
|
507
|
+
searchHints: buildSearchHints(ann.fingerprint)
|
|
508
|
+
}));
|
|
509
|
+
return {
|
|
510
|
+
version: 1,
|
|
511
|
+
format: "agent",
|
|
512
|
+
viewportBucket,
|
|
513
|
+
annotations: agentAnnotations
|
|
514
|
+
};
|
|
515
|
+
}
|
|
374
516
|
export {
|
|
375
517
|
AnnotationStorage,
|
|
376
518
|
createFingerprint,
|
|
519
|
+
detectRemarqPlugin,
|
|
520
|
+
detectSource,
|
|
521
|
+
generateAgentExport,
|
|
377
522
|
matchElement
|
|
378
523
|
};
|
|
379
524
|
//# sourceMappingURL=index.js.map
|