@qaiddev/thumbs-embed 1.12.1 → 1.13.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.
Files changed (50) hide show
  1. package/README.md +67 -13
  2. package/dist/bootstrap.d.ts +29 -4
  3. package/dist/chunks/annotate-1zompTEi.js +2 -0
  4. package/dist/chunks/annotate-1zompTEi.js.map +1 -0
  5. package/dist/chunks/core-vu1EieDc.js +26 -0
  6. package/dist/chunks/core-vu1EieDc.js.map +1 -0
  7. package/dist/chunks/dom-kdwHduNo.js +2 -0
  8. package/dist/chunks/dom-kdwHduNo.js.map +1 -0
  9. package/dist/chunks/html2canvas.esm-Csbr1w14.js +6 -0
  10. package/dist/chunks/html2canvas.esm-Csbr1w14.js.map +1 -0
  11. package/dist/chunks/modal-5G2DhiUE.js +2 -0
  12. package/dist/chunks/modal-5G2DhiUE.js.map +1 -0
  13. package/dist/chunks/{recording-BUw5-5Rf.js → recording-CVwPTtB0.js} +2 -2
  14. package/dist/chunks/{recording-BUw5-5Rf.js.map → recording-CVwPTtB0.js.map} +1 -1
  15. package/dist/chunks/screenshot-dom-DO-0UlOz.js +2 -0
  16. package/dist/chunks/screenshot-dom-DO-0UlOz.js.map +1 -0
  17. package/dist/chunks/send-C3IvslZA.js +2 -0
  18. package/dist/chunks/send-C3IvslZA.js.map +1 -0
  19. package/dist/chunks/{targeting-CMUEe-7C.js → targeting-Bpbt68Pp.js} +2 -6
  20. package/dist/chunks/{targeting-CMUEe-7C.js.map → targeting-Bpbt68Pp.js.map} +1 -1
  21. package/dist/dom.d.ts +0 -2
  22. package/dist/embed-loader.d.ts +7 -0
  23. package/dist/embed.js +1 -1
  24. package/dist/embed.js.map +1 -1
  25. package/dist/icons.d.ts +2 -0
  26. package/dist/index.js +6628 -1530
  27. package/dist/index.js.map +1 -1
  28. package/dist/loader.js +1 -1
  29. package/dist/loader.js.map +1 -1
  30. package/dist/origin-key.d.ts +7 -0
  31. package/dist/qaid.umd.cjs +17 -17
  32. package/dist/qaid.umd.cjs.map +1 -1
  33. package/dist/quest-config.d.ts +27 -2
  34. package/dist/quest-launcher.d.ts +12 -0
  35. package/dist/screenshot-dom.d.ts +7 -5
  36. package/dist/svg-sanitize.d.ts +35 -0
  37. package/dist/trusted-types.d.ts +29 -0
  38. package/package.json +4 -2
  39. package/dist/chunks/annotate-DGyRcgPt.js +0 -2
  40. package/dist/chunks/annotate-DGyRcgPt.js.map +0 -1
  41. package/dist/chunks/core-BsR7oV99.js +0 -26
  42. package/dist/chunks/core-BsR7oV99.js.map +0 -1
  43. package/dist/chunks/dom-scpOS8nl.js +0 -2
  44. package/dist/chunks/dom-scpOS8nl.js.map +0 -1
  45. package/dist/chunks/modal-DYxcs1Gm.js +0 -2
  46. package/dist/chunks/modal-DYxcs1Gm.js.map +0 -1
  47. package/dist/chunks/screenshot-dom-ZYP2w2h0.js +0 -2
  48. package/dist/chunks/screenshot-dom-ZYP2w2h0.js.map +0 -1
  49. package/dist/chunks/send-C26DRoYc.js +0 -2
  50. package/dist/chunks/send-C26DRoYc.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"targeting-CMUEe-7C.js","sources":["../../src/element-selector.ts","../../src/targeting.ts"],"sourcesContent":["/**\n * Element selector generation utilities\n */\n\n/** Data attributes to look for (in priority order) */\nexport const DATA_ATTRS = [\"data-comp\", \"data-qa\", \"data-testid\", \"data-id\"];\n\nexport interface ElementInfo {\n selector: string;\n text: string;\n dataAttr: string | null;\n}\n\n/**\n * Find the first matching data attribute on an element or its ancestors\n */\nexport function findDataAttribute(\n element: Element,\n stopAt: Element = document.body\n): string | null {\n let current: Element | null = element;\n\n while (current && current !== stopAt) {\n for (const attr of DATA_ATTRS) {\n const value = current.getAttribute(attr);\n if (value) {\n return `${attr}=\"${value}\"`;\n }\n }\n current = current.parentElement;\n }\n\n return null;\n}\n\n/**\n * Get truncated text content from an element\n */\nexport function getTruncatedText(element: Element, maxLength = 100): string {\n const textContent = element.textContent?.trim().slice(0, maxLength) || \"\";\n return textContent.length === maxLength ? textContent + \"...\" : textContent;\n}\n\n/**\n * Get the nth-child index of an element among its siblings\n */\nfunction getNthChildIndex(element: Element): number {\n let index = 1;\n let sibling = element.previousElementSibling;\n while (sibling) {\n index++;\n sibling = sibling.previousElementSibling;\n }\n return index;\n}\n\n/**\n * Generate an nth-child path from body to the element\n * This is always a valid CSS selector and uniquely identifies the element\n * Exported for testing\n */\nexport function generateNthChildPath(element: Element): string {\n const path: string[] = [];\n let current: Element | null = element;\n\n while (current && current !== document.body && current !== document.documentElement) {\n const tag = current.tagName.toLowerCase();\n const index = getNthChildIndex(current);\n path.unshift(`${tag}:nth-child(${index})`);\n current = current.parentElement;\n }\n\n return path.length > 0 ? `body > ${path.join(\" > \")}` : \"body\";\n}\n\n/**\n * Escape special CSS characters in a string (for IDs with special chars)\n */\nfunction escapeCSSIdentifier(str: string): string {\n return str.replace(/([!\"#$%&'()*+,./:;<=>?@[\\\\\\]^`{|}~])/g, \"\\\\$1\");\n}\n\n/**\n * Generate a selector string for an element\n * Priority: data attribute > ID > nth-child path\n */\nexport function generateSelector(element: Element): string {\n // Try data attribute first (on element or ancestors) - most stable\n const dataAttr = findDataAttribute(element);\n if (dataAttr) {\n return `[${dataAttr}]`;\n }\n\n // Try ID (escaped for special characters)\n if (element.id) {\n return `#${escapeCSSIdentifier(element.id)}`;\n }\n\n // Fall back to nth-child path - always valid and unique\n return generateNthChildPath(element);\n}\n\n/**\n * Generate complete element info for feedback\n */\nexport function generateElementInfo(element: Element): ElementInfo {\n const text = getTruncatedText(element);\n const dataAttr = findDataAttribute(element);\n const selector = generateSelector(element);\n\n return { selector, text, dataAttr };\n}\n\n/* -------------------------------------------------------------------------- */\n/* Keyboard element targeting */\n/* */\n/* The mouse targeting path in embed.ts resolves the target with */\n/* elementFromPoint(clientX, clientY). A keyboard-activated thumb produces a */\n/* synthetic click at (0, 0), so a keyboard-only user can never point at a */\n/* real element. This controller provides a coordinate-free alternative: */\n/* Tab / arrow keys move a highlight between candidate elements (seeded from */\n/* document.activeElement), Enter / Space selects, Escape cancels. It never */\n/* hides the cursor — it drives the *native* focus ring instead, so both */\n/* sighted keyboard users and screen readers can follow the highlight. */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Default set of \"targetable\" elements for keyboard navigation: focusable\n * controls, ARIA-role'd nodes, common semantic content, and anything already\n * carrying one of the stable data attributes we key selectors off of.\n */\nexport const TARGETABLE_SELECTOR: string = [\n \"a[href]\",\n \"button\",\n \"input:not([type=hidden])\",\n \"select\",\n \"textarea\",\n \"summary\",\n \"[tabindex]\",\n \"[role]\",\n \"img\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"p\",\n \"li\",\n \"label\",\n ...DATA_ATTRS.map((attr) => `[${attr}]`),\n].join(\",\");\n\n/** Tag names that already take keyboard focus without an added tabindex. */\nconst NATIVELY_FOCUSABLE = /^(?:A|BUTTON|INPUT|SELECT|TEXTAREA|SUMMARY)$/;\n\n/**\n * Best-effort visibility test used to keep invisible nodes out of the keyboard\n * candidate list. Deliberately layout-free (no getBoundingClientRect) so it is\n * stable in headless/test environments: it only rejects nodes that are\n * explicitly hidden via the `hidden` attribute, `aria-hidden`, or a computed\n * `display:none` / `visibility:hidden`.\n */\nexport function isElementVisible(element: Element): boolean {\n if (element.hasAttribute(\"hidden\")) return false;\n if (element.getAttribute(\"aria-hidden\") === \"true\") return false;\n const view = element.ownerDocument?.defaultView;\n if (view && typeof view.getComputedStyle === \"function\") {\n const style = view.getComputedStyle(element);\n if (style.display === \"none\" || style.visibility === \"hidden\") return false;\n }\n return true;\n}\n\nexport interface CollectTargetableOptions {\n /** Where to search for candidates (default `document.body`). */\n root?: ParentNode;\n /** CSS selector for candidate elements (default {@link TARGETABLE_SELECTOR}). */\n selector?: string;\n /** Return true to drop an element (e.g. the embed's own shadow hosts). */\n isExcluded?: (element: Element) => boolean;\n /** Visibility predicate (default {@link isElementVisible}). */\n isVisible?: (element: Element) => boolean;\n}\n\n/**\n * Collect the ordered list of elements a keyboard user can target. Document\n * order matches the natural Tab order closely enough for feedback targeting.\n */\nexport function collectTargetableElements(\n options: CollectTargetableOptions = {}\n): Element[] {\n const root = options.root ?? document.body;\n const selector = options.selector ?? TARGETABLE_SELECTOR;\n const isExcluded = options.isExcluded ?? (() => false);\n const isVisible = options.isVisible ?? isElementVisible;\n\n return Array.from(root.querySelectorAll(selector)).filter(\n (element) => !isExcluded(element) && isVisible(element)\n );\n}\n\nexport interface KeyboardTargetingOptions {\n /**\n * Explicit candidate list. When omitted, candidates are collected via\n * {@link collectTargetableElements} using `root` / `selector` / `isExcluded`\n * / `isVisible`.\n */\n candidates?: Element[];\n /** Passed through to {@link collectTargetableElements} when `candidates` is omitted. */\n root?: ParentNode;\n /** Passed through to {@link collectTargetableElements} when `candidates` is omitted. */\n selector?: string;\n /** Passed through to {@link collectTargetableElements} when `candidates` is omitted. */\n isExcluded?: (element: Element) => boolean;\n /** Passed through to {@link collectTargetableElements} when `candidates` is omitted. */\n isVisible?: (element: Element) => boolean;\n /**\n * Element to start the highlight on. Defaults to `document.activeElement`\n * when it is one of the candidates, otherwise the first candidate.\n */\n initial?: Element | null;\n /**\n * Move native focus to the highlighted element (default true). This is what\n * keeps a screen reader / focus ring on the highlight; non-focusable nodes\n * get a temporary `tabindex=\"-1\"` that is removed on {@link stop}. The cursor\n * is never hidden.\n */\n moveFocus?: boolean;\n /** Where the keydown listener is attached (default `document`). */\n eventTarget?: Document | HTMLElement;\n /** Fired whenever the highlighted candidate changes (and once on start). */\n onHighlight?: (element: Element, index: number) => void;\n /** Fired when the user commits a selection (Enter / Space). Auto-stops first. */\n onSelect: (element: Element) => void;\n /** Fired when the user cancels (Escape). Auto-stops first. */\n onCancel?: () => void;\n}\n\nexport interface KeyboardTargetingController {\n /** The (frozen) candidate list being navigated. */\n readonly candidates: readonly Element[];\n /** Index of the highlighted candidate, or -1 when there are none. */\n getIndex(): number;\n /** The highlighted candidate, or null when there are none. */\n getCurrent(): Element | null;\n /** Highlight the next candidate (wraps to the first). */\n next(): void;\n /** Highlight the previous candidate (wraps to the last). */\n prev(): void;\n /** Highlight a specific index (wraps out-of-range values). */\n moveTo(index: number): void;\n /** Commit the current candidate (fires onSelect) and stop. */\n select(): void;\n /** Cancel (fires onCancel) and stop. */\n cancel(): void;\n /**\n * Handle a keydown. Wired automatically to `eventTarget`; exposed so a host\n * can forward events from another surface (e.g. the embed's shadow root).\n */\n handleKey(event: KeyboardEvent): void;\n /** Remove the listener and restore any temporary tabindex. Idempotent. */\n stop(): void;\n}\n\n/**\n * Start a keyboard element-targeting session. The returned controller wires its\n * own capture-phase keydown listener on `eventTarget` and emits the initial\n * highlight synchronously before returning.\n */\nexport function startKeyboardTargeting(\n options: KeyboardTargetingOptions\n): KeyboardTargetingController {\n const candidates =\n options.candidates ??\n collectTargetableElements({\n root: options.root,\n selector: options.selector,\n isExcluded: options.isExcluded,\n isVisible: options.isVisible,\n });\n\n const moveFocus = options.moveFocus ?? true;\n const target: EventTarget = options.eventTarget ?? document;\n const addedTabindex = new Set<Element>();\n\n let index = -1;\n let stopped = false;\n\n // Seed the highlight from the currently focused element when it is a\n // candidate; this makes \"Tab to a control, then hit the thumb\" land on that\n // control rather than the top of the page.\n const seed =\n options.initial !== undefined\n ? options.initial\n : typeof document !== \"undefined\"\n ? document.activeElement\n : null;\n if (seed) {\n const seedIndex = candidates.indexOf(seed);\n if (seedIndex >= 0) index = seedIndex;\n }\n if (index < 0 && candidates.length > 0) index = 0;\n\n function focusCurrent(element: Element): void {\n if (!moveFocus) return;\n const focusable = element as HTMLElement;\n if (typeof focusable.focus !== \"function\") return;\n // Make non-focusable content (p, img, li, …) programmatically focusable so\n // the native focus ring and AT follow the highlight. Never hide the cursor.\n if (\n element.getAttribute(\"tabindex\") === null &&\n !NATIVELY_FOCUSABLE.test(element.tagName)\n ) {\n element.setAttribute(\"tabindex\", \"-1\");\n addedTabindex.add(element);\n }\n try {\n focusable.focus();\n } catch {\n /* focus can throw in detached/headless cases — highlight still works */\n }\n }\n\n function emitHighlight(): void {\n const element = candidates[index];\n if (!element) return;\n focusCurrent(element);\n options.onHighlight?.(element, index);\n }\n\n function moveTo(nextIndex: number): void {\n if (stopped || candidates.length === 0) return;\n const len = candidates.length;\n index = ((nextIndex % len) + len) % len; // wrap in both directions\n emitHighlight();\n }\n\n function next(): void {\n moveTo(index + 1);\n }\n\n function prev(): void {\n moveTo(index - 1);\n }\n\n function getCurrent(): Element | null {\n return candidates[index] ?? null;\n }\n\n function stop(): void {\n if (stopped) return;\n stopped = true;\n target.removeEventListener(\"keydown\", handleKey as EventListener, true);\n addedTabindex.forEach((element) => element.removeAttribute(\"tabindex\"));\n addedTabindex.clear();\n }\n\n function select(): void {\n if (stopped) return;\n const element = getCurrent();\n stop();\n if (element) options.onSelect(element);\n }\n\n function cancel(): void {\n if (stopped) return;\n stop();\n options.onCancel?.();\n }\n\n function handleKey(event: KeyboardEvent): void {\n if (stopped) return;\n switch (event.key) {\n case \"Tab\":\n event.preventDefault();\n event.stopPropagation();\n if (event.shiftKey) prev();\n else next();\n break;\n case \"ArrowDown\":\n case \"ArrowRight\":\n event.preventDefault();\n event.stopPropagation();\n next();\n break;\n case \"ArrowUp\":\n case \"ArrowLeft\":\n event.preventDefault();\n event.stopPropagation();\n prev();\n break;\n case \"Enter\":\n case \" \":\n case \"Spacebar\": // legacy key value\n event.preventDefault();\n event.stopPropagation();\n select();\n break;\n case \"Escape\":\n case \"Esc\": // legacy key value\n event.preventDefault();\n event.stopPropagation();\n cancel();\n break;\n default:\n break;\n }\n }\n\n target.addEventListener(\"keydown\", handleKey as EventListener, true);\n\n // Emit the initial highlight so the caller can position its highlight box.\n if (index >= 0) emitHighlight();\n\n return {\n candidates,\n getIndex: () => index,\n getCurrent,\n next,\n prev,\n moveTo,\n select,\n cancel,\n handleKey,\n stop,\n };\n}\n","/**\n * Element-targeting subsystem — extracted from embed.ts into its own lazily\n * loaded chunk (it also carries `element-selector`, ~14 KB). It's fetched the\n * first time the user starts targeting (and pre-warmed on thumb-button hover,\n * so the reticle appears without a perceptible wait).\n *\n * The controller owns the reticle/overlay, the mouse/touch/keyboard targeting\n * flows, and the selected-element marker; it talks back to the embed through\n * the narrow `TargetingHost` interface.\n */\n\nimport {\n generateElementInfo,\n startKeyboardTargeting,\n type KeyboardTargetingController,\n} from \"./element-selector\";\nimport {\n getElementAtPointUnderOverlay,\n isEmbedElement,\n getElementBounds,\n} from \"./dom-utils\";\nimport type {\n ResolvedFeedbackConfig,\n EmbedState,\n FeedbackData,\n FeedbackType,\n SelectedBounds,\n} from \"./types\";\nimport featureStyles from \"./styles-targeting.css?inline\";\n\n/** A touch that moves more than this (px) is a scroll, not a tap-to-select. */\nconst TOUCH_TAP_SLOP = 12;\n\n/** The slice of the embed the targeting subsystem needs. */\nexport interface TargetingHost {\n readonly config: ResolvedFeedbackConfig;\n readonly cssVars: Record<string, string>;\n readonly state: EmbedState;\n readonly shadowHost: HTMLDivElement | null;\n readonly overlayShadowHost: HTMLDivElement | null;\n readonly boundKeyDown: (e: KeyboardEvent) => void;\n /** Live references, mutated in place. */\n readonly feedbackData: FeedbackData;\n readonly selectedBounds: SelectedBounds;\n setState(state: EmbedState): void;\n ensureOverlayHost(): ShadowRoot;\n applyVars(el: HTMLElement): void;\n announceMsg(message: string, assertive?: boolean): void;\n clearActiveThumb(): void;\n submitFeedback(): Promise<void>;\n}\n\nexport class TargetingController {\n private mousePos = { x: 0, y: 0 };\n private touchStartPos: { x: number; y: number } | null = null;\n private overlayContainer: HTMLDivElement | null = null;\n private captureLayer: HTMLDivElement | null = null;\n private crosshairH: HTMLDivElement | null = null;\n private crosshairV: HTMLDivElement | null = null;\n private scope: HTMLDivElement | null = null;\n private highlightBox: HTMLDivElement | null = null;\n private marker: HTMLDivElement | null = null;\n private keyboardController: KeyboardTargetingController | null = null;\n\n private boundMouseMove = (e: MouseEvent): void => this.handleMouseMove(e);\n private boundClick = (e: MouseEvent): void => this.handleClick(e);\n private boundTouchStart = (e: TouchEvent): void => this.handleTouchStart(e);\n private boundTouchEnd = (e: TouchEvent): void => this.handleTouchEnd(e);\n\n constructor(private host: TargetingHost) {}\n\n startPointer(type: FeedbackType, e: MouseEvent): void {\n this.host.setState(\"TARGETING\");\n this.host.feedbackData.feedbackType = type;\n this.host.feedbackData.elementSelector = null;\n this.host.feedbackData.elementText = null;\n this.host.selectedBounds.visible = false;\n\n // Track initial mouse position from the click event\n this.mousePos.x = e.clientX;\n this.mousePos.y = e.clientY;\n\n // Add class to body (light DOM — for cursor override)\n document.body.classList.add(\"qaid-targeting\");\n if (type === \"up\") {\n document.body.classList.add(\"qaid-type-up\");\n } else {\n document.body.classList.remove(\"qaid-type-up\");\n }\n\n // Set targeting colors on body so .qaid-highlight rules can resolve them\n document.body.style.setProperty(\"--qaid-positive\", this.host.cssVars[\"--qaid-positive\"]);\n document.body.style.setProperty(\"--qaid-negative\", this.host.cssVars[\"--qaid-negative\"]);\n\n this.createTargetingOverlay();\n\n // Add event listeners on document — overlay is pointer-events:none so scroll works naturally\n document.addEventListener(\"keydown\", this.host.boundKeyDown);\n document.addEventListener(\"mousemove\", this.boundMouseMove);\n document.addEventListener(\"click\", this.boundClick, true);\n // Touch: tap to select (scrolling stays enabled). touchstart is passive\n // (we only read the point); touchend is non-passive so a tap can\n // preventDefault the synthesised click that would otherwise activate the\n // targeted element.\n document.addEventListener(\"touchstart\", this.boundTouchStart, { passive: true });\n document.addEventListener(\"touchend\", this.boundTouchEnd, { passive: false });\n }\n\n /**\n * Keyboard-driven targeting. Mirrors startPointer minus the mouse plumbing:\n * no `qaid-targeting` body class (keeps the cursor visible for keyboard\n * users), no mouse reticle, and no document mouse/click listeners. The\n * KeyboardTargetingController owns Tab/Arrow/Enter/Space/Escape.\n */\n startKeyboard(type: FeedbackType): void {\n this.host.setState(\"TARGETING\");\n this.host.feedbackData.feedbackType = type;\n this.host.feedbackData.elementSelector = null;\n this.host.feedbackData.elementText = null;\n this.host.selectedBounds.visible = false;\n\n document.body.style.setProperty(\"--qaid-positive\", this.host.cssVars[\"--qaid-positive\"]);\n document.body.style.setProperty(\"--qaid-negative\", this.host.cssVars[\"--qaid-negative\"]);\n\n // Build the highlight box, then hide the mouse reticle (meaningless here)\n this.createTargetingOverlay();\n if (this.crosshairH) this.crosshairH.style.display = \"none\";\n if (this.crosshairV) this.crosshairV.style.display = \"none\";\n if (this.scope) this.scope.style.display = \"none\";\n\n this.keyboardController = startKeyboardTargeting({\n isExcluded: (el) => isEmbedElement(el),\n onHighlight: (el) => {\n const rect = el.getBoundingClientRect();\n const b = this.highlightBox;\n if (b) {\n b.style.transform = `translate(${rect.left}px, ${rect.top}px)`;\n b.style.width = `${rect.width}px`;\n b.style.height = `${rect.height}px`;\n b.style.display = \"block\";\n }\n const { text } = generateElementInfo(el);\n this.host.announceMsg(`Targeting ${text || el.tagName.toLowerCase()}`);\n },\n onSelect: (el) => this.selectKeyboardTarget(el),\n onCancel: () => this.cancel(),\n });\n }\n\n private selectKeyboardTarget(el: Element): void {\n const bounds = getElementBounds(el, 8);\n Object.assign(this.host.selectedBounds, bounds, {\n clickX: bounds.x + bounds.width / 2,\n clickY: bounds.y + bounds.height / 2,\n visible: true,\n });\n\n const { selector, text } = generateElementInfo(el);\n this.host.feedbackData.elementSelector = selector;\n this.host.feedbackData.elementText = text;\n\n // Teardown (controller has already auto-stopped before onSelect fired)\n this.removeTargetingOverlay();\n document.body.classList.remove(\"qaid-targeting\", \"qaid-type-up\");\n document.body.style.removeProperty(\"--qaid-positive\");\n document.body.style.removeProperty(\"--qaid-negative\");\n this.keyboardController = null;\n this.host.clearActiveThumb();\n\n this.host.setState(\"SELECTED\");\n this.showSelectedMarker();\n void this.host.submitFeedback();\n }\n\n private createTargetingOverlay(): void {\n const root = this.host.ensureOverlayHost();\n\n this.overlayContainer = document.createElement(\"div\");\n this.overlayContainer.className = `qaid-targeting-overlay qaid-type-${this.host.feedbackData.feedbackType}`;\n\n // Capture layer (pointer-events:none — scroll passes through naturally)\n this.captureLayer = document.createElement(\"div\");\n this.captureLayer.className = \"qaid-capture-layer\";\n\n // Vignette\n const vignette = document.createElement(\"div\");\n vignette.className = \"qaid-vignette\";\n\n // Crosshairs\n this.crosshairH = document.createElement(\"div\");\n this.crosshairH.className = \"qaid-crosshair-h\";\n\n this.crosshairV = document.createElement(\"div\");\n this.crosshairV.className = \"qaid-crosshair-v\";\n\n // Scope\n this.scope = document.createElement(\"div\");\n this.scope.className = \"qaid-scope\";\n this.scope.innerHTML = `\n <div class=\"qaid-scope-ring\"></div>\n <div class=\"qaid-scope-ring-inner\"></div>\n <div class=\"qaid-scope-dot\"></div>\n `;\n\n // Highlight box overlay (positioned over hovered elements)\n this.highlightBox = document.createElement(\"div\");\n this.highlightBox.className = \"qaid-highlight-box\";\n\n this.overlayContainer.appendChild(this.captureLayer);\n this.overlayContainer.appendChild(vignette);\n this.overlayContainer.appendChild(this.highlightBox);\n this.overlayContainer.appendChild(this.crosshairH);\n this.overlayContainer.appendChild(this.crosshairV);\n this.overlayContainer.appendChild(this.scope);\n\n // Position crosshairs immediately at current mouse position\n this.crosshairH.style.top = `${this.mousePos.y}px`;\n this.crosshairV.style.left = `${this.mousePos.x}px`;\n this.scope.style.left = `${this.mousePos.x}px`;\n this.scope.style.top = `${this.mousePos.y}px`;\n\n this.host.applyVars(this.overlayContainer);\n root.appendChild(this.overlayContainer);\n }\n\n private handleMouseMove(e: MouseEvent): void {\n this.updateReticleAt(e.clientX, e.clientY);\n }\n\n /** Move the crosshair/scope reticle and highlight the element under (x, y). */\n private updateReticleAt(x: number, y: number): void {\n this.mousePos.x = x;\n this.mousePos.y = y;\n\n if (this.crosshairH) this.crosshairH.style.top = `${y}px`;\n if (this.crosshairV) this.crosshairV.style.left = `${x}px`;\n if (this.scope) {\n this.scope.style.left = `${x}px`;\n this.scope.style.top = `${y}px`;\n }\n\n // Find element underneath — hide both shadow hosts\n if (this.captureLayer && this.host.shadowHost) {\n const hosts = [this.host.shadowHost, this.host.overlayShadowHost].filter(Boolean) as HTMLElement[];\n const elementUnder = getElementAtPointUnderOverlay(x, y, hosts);\n\n if (elementUnder && !isEmbedElement(elementUnder)) {\n if (this.highlightBox) {\n const rect = elementUnder.getBoundingClientRect();\n this.highlightBox.style.transform = `translate(${rect.left}px, ${rect.top}px)`;\n this.highlightBox.style.width = `${rect.width}px`;\n this.highlightBox.style.height = `${rect.height}px`;\n this.highlightBox.style.display = \"block\";\n }\n } else if (this.highlightBox) {\n this.highlightBox.style.display = \"none\";\n }\n }\n }\n\n private handleClick(e: MouseEvent): void {\n e.preventDefault();\n e.stopPropagation();\n this.selectAt(e.clientX, e.clientY);\n }\n\n // ---- Touch targeting (iOS/iPadOS) ----\n private handleTouchStart(e: TouchEvent): void {\n const t = e.touches[0];\n if (!t) return;\n this.touchStartPos = { x: t.clientX, y: t.clientY };\n // Preview what's under the finger; don't preventDefault so scrolling works.\n this.updateReticleAt(t.clientX, t.clientY);\n }\n\n private handleTouchEnd(e: TouchEvent): void {\n // touches is empty on touchend; the lifted point is in changedTouches.\n const t = e.changedTouches[0];\n const start = this.touchStartPos;\n this.touchStartPos = null;\n if (!t || !start) return;\n // A drag beyond the slop threshold is a scroll, not a selection — ignore it.\n const moved = Math.hypot(t.clientX - start.x, t.clientY - start.y);\n if (moved > TOUCH_TAP_SLOP) return;\n e.preventDefault(); // suppress the tap's synthesised click\n this.selectAt(t.clientX, t.clientY);\n }\n\n /** Select the element under (x, y) and tear down targeting. */\n private selectAt(x: number, y: number): void {\n const hosts = [this.host.shadowHost, this.host.overlayShadowHost].filter(Boolean) as HTMLElement[];\n const target = getElementAtPointUnderOverlay(x, y, hosts);\n\n if (!target || isEmbedElement(target)) {\n return;\n }\n\n const bounds = getElementBounds(target, 8);\n Object.assign(this.host.selectedBounds, bounds, { clickX: x, clickY: y, visible: true });\n\n const { selector, text } = generateElementInfo(target);\n this.host.feedbackData.elementSelector = selector;\n this.host.feedbackData.elementText = text;\n\n // Remove targeting overlay and document listeners\n this.stopTargetingListeners();\n document.body.classList.remove(\"qaid-targeting\", \"qaid-type-up\");\n document.body.style.removeProperty(\"--qaid-positive\");\n document.body.style.removeProperty(\"--qaid-negative\");\n\n this.host.setState(\"SELECTED\");\n this.host.clearActiveThumb();\n\n this.showSelectedMarker();\n void this.host.submitFeedback();\n }\n\n private stopTargetingListeners(): void {\n this.removeTargetingOverlay();\n this.touchStartPos = null;\n document.removeEventListener(\"mousemove\", this.boundMouseMove);\n document.removeEventListener(\"click\", this.boundClick, true);\n document.removeEventListener(\"touchstart\", this.boundTouchStart);\n document.removeEventListener(\"touchend\", this.boundTouchEnd);\n document.removeEventListener(\"keydown\", this.host.boundKeyDown);\n }\n\n cancel(): void {\n this.keyboardController?.stop();\n this.keyboardController = null;\n this.stopTargetingListeners();\n document.body.classList.remove(\"qaid-targeting\", \"qaid-type-up\");\n document.body.style.removeProperty(\"--qaid-positive\");\n document.body.style.removeProperty(\"--qaid-negative\");\n this.host.clearActiveThumb();\n\n this.host.setState(\"IDLE\");\n this.host.feedbackData.feedbackType = null;\n this.host.feedbackData.elementSelector = null;\n this.host.feedbackData.elementText = null;\n this.host.selectedBounds.visible = false;\n }\n\n private removeTargetingOverlay(): void {\n if (this.overlayContainer) {\n this.overlayContainer.remove();\n this.overlayContainer = null;\n }\n this.captureLayer = null;\n this.crosshairH = null;\n this.crosshairV = null;\n this.scope = null;\n }\n\n private showSelectedMarker(): void {\n const root = this.host.ensureOverlayHost();\n\n this.marker = document.createElement(\"div\");\n this.marker.className = \"qaid-selected-marker\";\n this.marker.style.left = `${this.host.selectedBounds.x}px`;\n this.marker.style.top = `${this.host.selectedBounds.y}px`;\n this.marker.style.width = `${this.host.selectedBounds.width}px`;\n this.marker.style.height = `${this.host.selectedBounds.height}px`;\n this.marker.style.zIndex = String(this.host.config.zIndex + 1);\n\n this.host.applyVars(this.marker);\n root.appendChild(this.marker);\n }\n\n hideMarker(): void {\n if (this.marker) {\n this.marker.remove();\n this.marker = null;\n }\n }\n\n /** Full teardown for embed.destroy(). */\n destroy(): void {\n this.keyboardController?.stop();\n this.keyboardController = null;\n this.stopTargetingListeners();\n this.hideMarker();\n }\n}\n\n/** This feature's shadow-DOM styles; the embed adds them when it loads the chunk. */\nexport const styles = featureStyles;\n"],"names":["DATA_ATTRS","findDataAttribute","element","stopAt","current","attr","value","getTruncatedText","maxLength","textContent","getNthChildIndex","index","sibling","generateNthChildPath","path","tag","escapeCSSIdentifier","str","generateSelector","dataAttr","generateElementInfo","text","TARGETABLE_SELECTOR","NATIVELY_FOCUSABLE","isElementVisible","view","style","collectTargetableElements","options","root","selector","isExcluded","isVisible","startKeyboardTargeting","candidates","moveFocus","target","addedTabindex","stopped","seed","seedIndex","focusCurrent","focusable","emitHighlight","moveTo","nextIndex","len","next","prev","getCurrent","stop","handleKey","select","cancel","event","TOUCH_TAP_SLOP","TargetingController","host","e","type","el","isEmbedElement","rect","b","bounds","getElementBounds","vignette","x","y","hosts","elementUnder","getElementAtPointUnderOverlay","t","start","styles","featureStyles"],"mappings":"qDAKO,MAAMA,EAAa,CAAC,YAAa,UAAW,cAAe,SAAS,EAWpE,SAASC,EACdC,EACAC,EAAkB,SAAS,KACZ,CACf,IAAIC,EAA0BF,EAE9B,KAAOE,GAAWA,IAAYD,GAAQ,CACpC,UAAWE,KAAQL,EAAY,CAC7B,MAAMM,EAAQF,EAAQ,aAAaC,CAAI,EACvC,GAAIC,EACF,MAAO,GAAGD,CAAI,KAAKC,CAAK,GAE5B,CACAF,EAAUA,EAAQ,aACpB,CAEA,OAAO,IACT,CAKO,SAASG,EAAiBL,EAAkBM,EAAY,IAAa,CAC1E,MAAMC,EAAcP,EAAQ,aAAa,KAAA,EAAO,MAAM,EAAGM,CAAS,GAAK,GACvE,OAAOC,EAAY,SAAWD,EAAYC,EAAc,MAAQA,CAClE,CAKA,SAASC,EAAiBR,EAA0B,CAClD,IAAIS,EAAQ,EACRC,EAAUV,EAAQ,uBACtB,KAAOU,GACLD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,OAAO,MAAM,KAAO,GAAG,KAAK,KAAK,eAAe,CAAC,KACtD,KAAK,OAAO,MAAM,IAAM,GAAG,KAAK,KAAK,eAAe,CAAC,KACrD,KAAK,OAAO,MAAM,MAAQ,GAAG,KAAK,KAAK,eAAe,KAAK,KAC3D,KAAK,OAAO,MAAM,OAAS,GAAG,KAAK,KAAK,eAAe,MAAM,KAC7D,KAAK,OAAO,MAAM,OAAS,OAAO,KAAK,KAAK,OAAO,OAAS,CAAC,EAE7D,KAAK,KAAK,UAAU,KAAK,MAAM,EAC/BA,EAAK,YAAY,KAAK,MAAM,CAC9B,CAEA,YAAmB,CACb,KAAK,SACP,KAAK,OAAO,OAAA,EACZ,KAAK,OAAS,KAElB,CAGA,SAAgB,CACd,KAAK,oBAAoB,KAAA,EACzB,KAAK,mBAAqB,KAC1B,KAAK,uBAAA,EACL,KAAK,WAAA,CACP,CACF,CAGO,MAAM6C,EAASC"}
1
+ {"version":3,"file":"targeting-Bpbt68Pp.js","sources":["../../src/element-selector.ts","../../src/targeting.ts"],"sourcesContent":["/**\n * Element selector generation utilities\n */\n\n/** Data attributes to look for (in priority order) */\nexport const DATA_ATTRS = [\"data-comp\", \"data-qa\", \"data-testid\", \"data-id\"];\n\nexport interface ElementInfo {\n selector: string;\n text: string;\n dataAttr: string | null;\n}\n\n/**\n * Find the first matching data attribute on an element or its ancestors\n */\nexport function findDataAttribute(\n element: Element,\n stopAt: Element = document.body\n): string | null {\n let current: Element | null = element;\n\n while (current && current !== stopAt) {\n for (const attr of DATA_ATTRS) {\n const value = current.getAttribute(attr);\n if (value) {\n return `${attr}=\"${value}\"`;\n }\n }\n current = current.parentElement;\n }\n\n return null;\n}\n\n/**\n * Get truncated text content from an element\n */\nexport function getTruncatedText(element: Element, maxLength = 100): string {\n const textContent = element.textContent?.trim().slice(0, maxLength) || \"\";\n return textContent.length === maxLength ? textContent + \"...\" : textContent;\n}\n\n/**\n * Get the nth-child index of an element among its siblings\n */\nfunction getNthChildIndex(element: Element): number {\n let index = 1;\n let sibling = element.previousElementSibling;\n while (sibling) {\n index++;\n sibling = sibling.previousElementSibling;\n }\n return index;\n}\n\n/**\n * Generate an nth-child path from body to the element\n * This is always a valid CSS selector and uniquely identifies the element\n * Exported for testing\n */\nexport function generateNthChildPath(element: Element): string {\n const path: string[] = [];\n let current: Element | null = element;\n\n while (current && current !== document.body && current !== document.documentElement) {\n const tag = current.tagName.toLowerCase();\n const index = getNthChildIndex(current);\n path.unshift(`${tag}:nth-child(${index})`);\n current = current.parentElement;\n }\n\n return path.length > 0 ? `body > ${path.join(\" > \")}` : \"body\";\n}\n\n/**\n * Escape special CSS characters in a string (for IDs with special chars)\n */\nfunction escapeCSSIdentifier(str: string): string {\n return str.replace(/([!\"#$%&'()*+,./:;<=>?@[\\\\\\]^`{|}~])/g, \"\\\\$1\");\n}\n\n/**\n * Generate a selector string for an element\n * Priority: data attribute > ID > nth-child path\n */\nexport function generateSelector(element: Element): string {\n // Try data attribute first (on element or ancestors) - most stable\n const dataAttr = findDataAttribute(element);\n if (dataAttr) {\n return `[${dataAttr}]`;\n }\n\n // Try ID (escaped for special characters)\n if (element.id) {\n return `#${escapeCSSIdentifier(element.id)}`;\n }\n\n // Fall back to nth-child path - always valid and unique\n return generateNthChildPath(element);\n}\n\n/**\n * Generate complete element info for feedback\n */\nexport function generateElementInfo(element: Element): ElementInfo {\n const text = getTruncatedText(element);\n const dataAttr = findDataAttribute(element);\n const selector = generateSelector(element);\n\n return { selector, text, dataAttr };\n}\n\n/* -------------------------------------------------------------------------- */\n/* Keyboard element targeting */\n/* */\n/* The mouse targeting path in embed.ts resolves the target with */\n/* elementFromPoint(clientX, clientY). A keyboard-activated thumb produces a */\n/* synthetic click at (0, 0), so a keyboard-only user can never point at a */\n/* real element. This controller provides a coordinate-free alternative: */\n/* Tab / arrow keys move a highlight between candidate elements (seeded from */\n/* document.activeElement), Enter / Space selects, Escape cancels. It never */\n/* hides the cursor — it drives the *native* focus ring instead, so both */\n/* sighted keyboard users and screen readers can follow the highlight. */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Default set of \"targetable\" elements for keyboard navigation: focusable\n * controls, ARIA-role'd nodes, common semantic content, and anything already\n * carrying one of the stable data attributes we key selectors off of.\n */\nexport const TARGETABLE_SELECTOR: string = [\n \"a[href]\",\n \"button\",\n \"input:not([type=hidden])\",\n \"select\",\n \"textarea\",\n \"summary\",\n \"[tabindex]\",\n \"[role]\",\n \"img\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"p\",\n \"li\",\n \"label\",\n ...DATA_ATTRS.map((attr) => `[${attr}]`),\n].join(\",\");\n\n/** Tag names that already take keyboard focus without an added tabindex. */\nconst NATIVELY_FOCUSABLE = /^(?:A|BUTTON|INPUT|SELECT|TEXTAREA|SUMMARY)$/;\n\n/**\n * Best-effort visibility test used to keep invisible nodes out of the keyboard\n * candidate list. Deliberately layout-free (no getBoundingClientRect) so it is\n * stable in headless/test environments: it only rejects nodes that are\n * explicitly hidden via the `hidden` attribute, `aria-hidden`, or a computed\n * `display:none` / `visibility:hidden`.\n */\nexport function isElementVisible(element: Element): boolean {\n if (element.hasAttribute(\"hidden\")) return false;\n if (element.getAttribute(\"aria-hidden\") === \"true\") return false;\n const view = element.ownerDocument?.defaultView;\n if (view && typeof view.getComputedStyle === \"function\") {\n const style = view.getComputedStyle(element);\n if (style.display === \"none\" || style.visibility === \"hidden\") return false;\n }\n return true;\n}\n\nexport interface CollectTargetableOptions {\n /** Where to search for candidates (default `document.body`). */\n root?: ParentNode;\n /** CSS selector for candidate elements (default {@link TARGETABLE_SELECTOR}). */\n selector?: string;\n /** Return true to drop an element (e.g. the embed's own shadow hosts). */\n isExcluded?: (element: Element) => boolean;\n /** Visibility predicate (default {@link isElementVisible}). */\n isVisible?: (element: Element) => boolean;\n}\n\n/**\n * Collect the ordered list of elements a keyboard user can target. Document\n * order matches the natural Tab order closely enough for feedback targeting.\n */\nexport function collectTargetableElements(\n options: CollectTargetableOptions = {}\n): Element[] {\n const root = options.root ?? document.body;\n const selector = options.selector ?? TARGETABLE_SELECTOR;\n const isExcluded = options.isExcluded ?? (() => false);\n const isVisible = options.isVisible ?? isElementVisible;\n\n return Array.from(root.querySelectorAll(selector)).filter(\n (element) => !isExcluded(element) && isVisible(element)\n );\n}\n\nexport interface KeyboardTargetingOptions {\n /**\n * Explicit candidate list. When omitted, candidates are collected via\n * {@link collectTargetableElements} using `root` / `selector` / `isExcluded`\n * / `isVisible`.\n */\n candidates?: Element[];\n /** Passed through to {@link collectTargetableElements} when `candidates` is omitted. */\n root?: ParentNode;\n /** Passed through to {@link collectTargetableElements} when `candidates` is omitted. */\n selector?: string;\n /** Passed through to {@link collectTargetableElements} when `candidates` is omitted. */\n isExcluded?: (element: Element) => boolean;\n /** Passed through to {@link collectTargetableElements} when `candidates` is omitted. */\n isVisible?: (element: Element) => boolean;\n /**\n * Element to start the highlight on. Defaults to `document.activeElement`\n * when it is one of the candidates, otherwise the first candidate.\n */\n initial?: Element | null;\n /**\n * Move native focus to the highlighted element (default true). This is what\n * keeps a screen reader / focus ring on the highlight; non-focusable nodes\n * get a temporary `tabindex=\"-1\"` that is removed on {@link stop}. The cursor\n * is never hidden.\n */\n moveFocus?: boolean;\n /** Where the keydown listener is attached (default `document`). */\n eventTarget?: Document | HTMLElement;\n /** Fired whenever the highlighted candidate changes (and once on start). */\n onHighlight?: (element: Element, index: number) => void;\n /** Fired when the user commits a selection (Enter / Space). Auto-stops first. */\n onSelect: (element: Element) => void;\n /** Fired when the user cancels (Escape). Auto-stops first. */\n onCancel?: () => void;\n}\n\nexport interface KeyboardTargetingController {\n /** The (frozen) candidate list being navigated. */\n readonly candidates: readonly Element[];\n /** Index of the highlighted candidate, or -1 when there are none. */\n getIndex(): number;\n /** The highlighted candidate, or null when there are none. */\n getCurrent(): Element | null;\n /** Highlight the next candidate (wraps to the first). */\n next(): void;\n /** Highlight the previous candidate (wraps to the last). */\n prev(): void;\n /** Highlight a specific index (wraps out-of-range values). */\n moveTo(index: number): void;\n /** Commit the current candidate (fires onSelect) and stop. */\n select(): void;\n /** Cancel (fires onCancel) and stop. */\n cancel(): void;\n /**\n * Handle a keydown. Wired automatically to `eventTarget`; exposed so a host\n * can forward events from another surface (e.g. the embed's shadow root).\n */\n handleKey(event: KeyboardEvent): void;\n /** Remove the listener and restore any temporary tabindex. Idempotent. */\n stop(): void;\n}\n\n/**\n * Start a keyboard element-targeting session. The returned controller wires its\n * own capture-phase keydown listener on `eventTarget` and emits the initial\n * highlight synchronously before returning.\n */\nexport function startKeyboardTargeting(\n options: KeyboardTargetingOptions\n): KeyboardTargetingController {\n const candidates =\n options.candidates ??\n collectTargetableElements({\n root: options.root,\n selector: options.selector,\n isExcluded: options.isExcluded,\n isVisible: options.isVisible,\n });\n\n const moveFocus = options.moveFocus ?? true;\n const target: EventTarget = options.eventTarget ?? document;\n const addedTabindex = new Set<Element>();\n\n let index = -1;\n let stopped = false;\n\n // Seed the highlight from the currently focused element when it is a\n // candidate; this makes \"Tab to a control, then hit the thumb\" land on that\n // control rather than the top of the page.\n const seed =\n options.initial !== undefined\n ? options.initial\n : typeof document !== \"undefined\"\n ? document.activeElement\n : null;\n if (seed) {\n const seedIndex = candidates.indexOf(seed);\n if (seedIndex >= 0) index = seedIndex;\n }\n if (index < 0 && candidates.length > 0) index = 0;\n\n function focusCurrent(element: Element): void {\n if (!moveFocus) return;\n const focusable = element as HTMLElement;\n if (typeof focusable.focus !== \"function\") return;\n // Make non-focusable content (p, img, li, …) programmatically focusable so\n // the native focus ring and AT follow the highlight. Never hide the cursor.\n if (\n element.getAttribute(\"tabindex\") === null &&\n !NATIVELY_FOCUSABLE.test(element.tagName)\n ) {\n element.setAttribute(\"tabindex\", \"-1\");\n addedTabindex.add(element);\n }\n try {\n focusable.focus();\n } catch {\n /* focus can throw in detached/headless cases — highlight still works */\n }\n }\n\n function emitHighlight(): void {\n const element = candidates[index];\n if (!element) return;\n focusCurrent(element);\n options.onHighlight?.(element, index);\n }\n\n function moveTo(nextIndex: number): void {\n if (stopped || candidates.length === 0) return;\n const len = candidates.length;\n index = ((nextIndex % len) + len) % len; // wrap in both directions\n emitHighlight();\n }\n\n function next(): void {\n moveTo(index + 1);\n }\n\n function prev(): void {\n moveTo(index - 1);\n }\n\n function getCurrent(): Element | null {\n return candidates[index] ?? null;\n }\n\n function stop(): void {\n if (stopped) return;\n stopped = true;\n target.removeEventListener(\"keydown\", handleKey as EventListener, true);\n addedTabindex.forEach((element) => element.removeAttribute(\"tabindex\"));\n addedTabindex.clear();\n }\n\n function select(): void {\n if (stopped) return;\n const element = getCurrent();\n stop();\n if (element) options.onSelect(element);\n }\n\n function cancel(): void {\n if (stopped) return;\n stop();\n options.onCancel?.();\n }\n\n function handleKey(event: KeyboardEvent): void {\n if (stopped) return;\n switch (event.key) {\n case \"Tab\":\n event.preventDefault();\n event.stopPropagation();\n if (event.shiftKey) prev();\n else next();\n break;\n case \"ArrowDown\":\n case \"ArrowRight\":\n event.preventDefault();\n event.stopPropagation();\n next();\n break;\n case \"ArrowUp\":\n case \"ArrowLeft\":\n event.preventDefault();\n event.stopPropagation();\n prev();\n break;\n case \"Enter\":\n case \" \":\n case \"Spacebar\": // legacy key value\n event.preventDefault();\n event.stopPropagation();\n select();\n break;\n case \"Escape\":\n case \"Esc\": // legacy key value\n event.preventDefault();\n event.stopPropagation();\n cancel();\n break;\n default:\n break;\n }\n }\n\n target.addEventListener(\"keydown\", handleKey as EventListener, true);\n\n // Emit the initial highlight so the caller can position its highlight box.\n if (index >= 0) emitHighlight();\n\n return {\n candidates,\n getIndex: () => index,\n getCurrent,\n next,\n prev,\n moveTo,\n select,\n cancel,\n handleKey,\n stop,\n };\n}\n","/**\n * Element-targeting subsystem — extracted from embed.ts into its own lazily\n * loaded chunk (it also carries `element-selector`, ~14 KB). It's fetched the\n * first time the user starts targeting (and pre-warmed on thumb-button hover,\n * so the reticle appears without a perceptible wait).\n *\n * The controller owns the reticle/overlay, the mouse/touch/keyboard targeting\n * flows, and the selected-element marker; it talks back to the embed through\n * the narrow `TargetingHost` interface.\n */\n\nimport {\n generateElementInfo,\n startKeyboardTargeting,\n type KeyboardTargetingController,\n} from \"./element-selector\";\nimport {\n getElementAtPointUnderOverlay,\n isEmbedElement,\n getElementBounds,\n} from \"./dom-utils\";\nimport type {\n ResolvedFeedbackConfig,\n EmbedState,\n FeedbackData,\n FeedbackType,\n SelectedBounds,\n} from \"./types\";\nimport featureStyles from \"./styles-targeting.css?inline\";\n\n/** A touch that moves more than this (px) is a scroll, not a tap-to-select. */\nconst TOUCH_TAP_SLOP = 12;\n\n/** The slice of the embed the targeting subsystem needs. */\nexport interface TargetingHost {\n readonly config: ResolvedFeedbackConfig;\n readonly cssVars: Record<string, string>;\n readonly state: EmbedState;\n readonly shadowHost: HTMLDivElement | null;\n readonly overlayShadowHost: HTMLDivElement | null;\n readonly boundKeyDown: (e: KeyboardEvent) => void;\n /** Live references, mutated in place. */\n readonly feedbackData: FeedbackData;\n readonly selectedBounds: SelectedBounds;\n setState(state: EmbedState): void;\n ensureOverlayHost(): ShadowRoot;\n applyVars(el: HTMLElement): void;\n announceMsg(message: string, assertive?: boolean): void;\n clearActiveThumb(): void;\n submitFeedback(): Promise<void>;\n}\n\nexport class TargetingController {\n private mousePos = { x: 0, y: 0 };\n private touchStartPos: { x: number; y: number } | null = null;\n private overlayContainer: HTMLDivElement | null = null;\n private captureLayer: HTMLDivElement | null = null;\n private crosshairH: HTMLDivElement | null = null;\n private crosshairV: HTMLDivElement | null = null;\n private scope: HTMLDivElement | null = null;\n private highlightBox: HTMLDivElement | null = null;\n private marker: HTMLDivElement | null = null;\n private keyboardController: KeyboardTargetingController | null = null;\n\n private boundMouseMove = (e: MouseEvent): void => this.handleMouseMove(e);\n private boundClick = (e: MouseEvent): void => this.handleClick(e);\n private boundTouchStart = (e: TouchEvent): void => this.handleTouchStart(e);\n private boundTouchEnd = (e: TouchEvent): void => this.handleTouchEnd(e);\n\n constructor(private host: TargetingHost) {}\n\n startPointer(type: FeedbackType, e: MouseEvent): void {\n this.host.setState(\"TARGETING\");\n this.host.feedbackData.feedbackType = type;\n this.host.feedbackData.elementSelector = null;\n this.host.feedbackData.elementText = null;\n this.host.selectedBounds.visible = false;\n\n // Track initial mouse position from the click event\n this.mousePos.x = e.clientX;\n this.mousePos.y = e.clientY;\n\n // Add class to body (light DOM — for cursor override)\n document.body.classList.add(\"qaid-targeting\");\n if (type === \"up\") {\n document.body.classList.add(\"qaid-type-up\");\n } else {\n document.body.classList.remove(\"qaid-type-up\");\n }\n\n // Set targeting colors on body so .qaid-highlight rules can resolve them\n document.body.style.setProperty(\"--qaid-positive\", this.host.cssVars[\"--qaid-positive\"]);\n document.body.style.setProperty(\"--qaid-negative\", this.host.cssVars[\"--qaid-negative\"]);\n\n this.createTargetingOverlay();\n\n // Add event listeners on document — overlay is pointer-events:none so scroll works naturally\n document.addEventListener(\"keydown\", this.host.boundKeyDown);\n document.addEventListener(\"mousemove\", this.boundMouseMove);\n document.addEventListener(\"click\", this.boundClick, true);\n // Touch: tap to select (scrolling stays enabled). touchstart is passive\n // (we only read the point); touchend is non-passive so a tap can\n // preventDefault the synthesised click that would otherwise activate the\n // targeted element.\n document.addEventListener(\"touchstart\", this.boundTouchStart, { passive: true });\n document.addEventListener(\"touchend\", this.boundTouchEnd, { passive: false });\n }\n\n /**\n * Keyboard-driven targeting. Mirrors startPointer minus the mouse plumbing:\n * no `qaid-targeting` body class (keeps the cursor visible for keyboard\n * users), no mouse reticle, and no document mouse/click listeners. The\n * KeyboardTargetingController owns Tab/Arrow/Enter/Space/Escape.\n */\n startKeyboard(type: FeedbackType): void {\n this.host.setState(\"TARGETING\");\n this.host.feedbackData.feedbackType = type;\n this.host.feedbackData.elementSelector = null;\n this.host.feedbackData.elementText = null;\n this.host.selectedBounds.visible = false;\n\n document.body.style.setProperty(\"--qaid-positive\", this.host.cssVars[\"--qaid-positive\"]);\n document.body.style.setProperty(\"--qaid-negative\", this.host.cssVars[\"--qaid-negative\"]);\n\n // Build the highlight box, then hide the mouse reticle (meaningless here)\n this.createTargetingOverlay();\n if (this.crosshairH) this.crosshairH.style.display = \"none\";\n if (this.crosshairV) this.crosshairV.style.display = \"none\";\n if (this.scope) this.scope.style.display = \"none\";\n\n this.keyboardController = startKeyboardTargeting({\n isExcluded: (el) => isEmbedElement(el),\n onHighlight: (el) => {\n const rect = el.getBoundingClientRect();\n const b = this.highlightBox;\n if (b) {\n b.style.transform = `translate(${rect.left}px, ${rect.top}px)`;\n b.style.width = `${rect.width}px`;\n b.style.height = `${rect.height}px`;\n b.style.display = \"block\";\n }\n const { text } = generateElementInfo(el);\n this.host.announceMsg(`Targeting ${text || el.tagName.toLowerCase()}`);\n },\n onSelect: (el) => this.selectKeyboardTarget(el),\n onCancel: () => this.cancel(),\n });\n }\n\n private selectKeyboardTarget(el: Element): void {\n const bounds = getElementBounds(el, 8);\n Object.assign(this.host.selectedBounds, bounds, {\n clickX: bounds.x + bounds.width / 2,\n clickY: bounds.y + bounds.height / 2,\n visible: true,\n });\n\n const { selector, text } = generateElementInfo(el);\n this.host.feedbackData.elementSelector = selector;\n this.host.feedbackData.elementText = text;\n\n // Teardown (controller has already auto-stopped before onSelect fired)\n this.removeTargetingOverlay();\n document.body.classList.remove(\"qaid-targeting\", \"qaid-type-up\");\n document.body.style.removeProperty(\"--qaid-positive\");\n document.body.style.removeProperty(\"--qaid-negative\");\n this.keyboardController = null;\n this.host.clearActiveThumb();\n\n this.host.setState(\"SELECTED\");\n this.showSelectedMarker();\n void this.host.submitFeedback();\n }\n\n private createTargetingOverlay(): void {\n const root = this.host.ensureOverlayHost();\n\n this.overlayContainer = document.createElement(\"div\");\n this.overlayContainer.className = `qaid-targeting-overlay qaid-type-${this.host.feedbackData.feedbackType}`;\n\n // Capture layer (pointer-events:none — scroll passes through naturally)\n this.captureLayer = document.createElement(\"div\");\n this.captureLayer.className = \"qaid-capture-layer\";\n\n // Vignette\n const vignette = document.createElement(\"div\");\n vignette.className = \"qaid-vignette\";\n\n // Crosshairs\n this.crosshairH = document.createElement(\"div\");\n this.crosshairH.className = \"qaid-crosshair-h\";\n\n this.crosshairV = document.createElement(\"div\");\n this.crosshairV.className = \"qaid-crosshair-v\";\n\n // Scope\n this.scope = document.createElement(\"div\");\n this.scope.className = \"qaid-scope\";\n for (const part of [\"qaid-scope-ring\", \"qaid-scope-ring-inner\", \"qaid-scope-dot\"]) {\n const div = document.createElement(\"div\");\n div.className = part;\n this.scope.appendChild(div);\n }\n\n // Highlight box overlay (positioned over hovered elements)\n this.highlightBox = document.createElement(\"div\");\n this.highlightBox.className = \"qaid-highlight-box\";\n\n this.overlayContainer.appendChild(this.captureLayer);\n this.overlayContainer.appendChild(vignette);\n this.overlayContainer.appendChild(this.highlightBox);\n this.overlayContainer.appendChild(this.crosshairH);\n this.overlayContainer.appendChild(this.crosshairV);\n this.overlayContainer.appendChild(this.scope);\n\n // Position crosshairs immediately at current mouse position\n this.crosshairH.style.top = `${this.mousePos.y}px`;\n this.crosshairV.style.left = `${this.mousePos.x}px`;\n this.scope.style.left = `${this.mousePos.x}px`;\n this.scope.style.top = `${this.mousePos.y}px`;\n\n this.host.applyVars(this.overlayContainer);\n root.appendChild(this.overlayContainer);\n }\n\n private handleMouseMove(e: MouseEvent): void {\n this.updateReticleAt(e.clientX, e.clientY);\n }\n\n /** Move the crosshair/scope reticle and highlight the element under (x, y). */\n private updateReticleAt(x: number, y: number): void {\n this.mousePos.x = x;\n this.mousePos.y = y;\n\n if (this.crosshairH) this.crosshairH.style.top = `${y}px`;\n if (this.crosshairV) this.crosshairV.style.left = `${x}px`;\n if (this.scope) {\n this.scope.style.left = `${x}px`;\n this.scope.style.top = `${y}px`;\n }\n\n // Find element underneath — hide both shadow hosts\n if (this.captureLayer && this.host.shadowHost) {\n const hosts = [this.host.shadowHost, this.host.overlayShadowHost].filter(Boolean) as HTMLElement[];\n const elementUnder = getElementAtPointUnderOverlay(x, y, hosts);\n\n if (elementUnder && !isEmbedElement(elementUnder)) {\n if (this.highlightBox) {\n const rect = elementUnder.getBoundingClientRect();\n this.highlightBox.style.transform = `translate(${rect.left}px, ${rect.top}px)`;\n this.highlightBox.style.width = `${rect.width}px`;\n this.highlightBox.style.height = `${rect.height}px`;\n this.highlightBox.style.display = \"block\";\n }\n } else if (this.highlightBox) {\n this.highlightBox.style.display = \"none\";\n }\n }\n }\n\n private handleClick(e: MouseEvent): void {\n e.preventDefault();\n e.stopPropagation();\n this.selectAt(e.clientX, e.clientY);\n }\n\n // ---- Touch targeting (iOS/iPadOS) ----\n private handleTouchStart(e: TouchEvent): void {\n const t = e.touches[0];\n if (!t) return;\n this.touchStartPos = { x: t.clientX, y: t.clientY };\n // Preview what's under the finger; don't preventDefault so scrolling works.\n this.updateReticleAt(t.clientX, t.clientY);\n }\n\n private handleTouchEnd(e: TouchEvent): void {\n // touches is empty on touchend; the lifted point is in changedTouches.\n const t = e.changedTouches[0];\n const start = this.touchStartPos;\n this.touchStartPos = null;\n if (!t || !start) return;\n // A drag beyond the slop threshold is a scroll, not a selection — ignore it.\n const moved = Math.hypot(t.clientX - start.x, t.clientY - start.y);\n if (moved > TOUCH_TAP_SLOP) return;\n e.preventDefault(); // suppress the tap's synthesised click\n this.selectAt(t.clientX, t.clientY);\n }\n\n /** Select the element under (x, y) and tear down targeting. */\n private selectAt(x: number, y: number): void {\n const hosts = [this.host.shadowHost, this.host.overlayShadowHost].filter(Boolean) as HTMLElement[];\n const target = getElementAtPointUnderOverlay(x, y, hosts);\n\n if (!target || isEmbedElement(target)) {\n return;\n }\n\n const bounds = getElementBounds(target, 8);\n Object.assign(this.host.selectedBounds, bounds, { clickX: x, clickY: y, visible: true });\n\n const { selector, text } = generateElementInfo(target);\n this.host.feedbackData.elementSelector = selector;\n this.host.feedbackData.elementText = text;\n\n // Remove targeting overlay and document listeners\n this.stopTargetingListeners();\n document.body.classList.remove(\"qaid-targeting\", \"qaid-type-up\");\n document.body.style.removeProperty(\"--qaid-positive\");\n document.body.style.removeProperty(\"--qaid-negative\");\n\n this.host.setState(\"SELECTED\");\n this.host.clearActiveThumb();\n\n this.showSelectedMarker();\n void this.host.submitFeedback();\n }\n\n private stopTargetingListeners(): void {\n this.removeTargetingOverlay();\n this.touchStartPos = null;\n document.removeEventListener(\"mousemove\", this.boundMouseMove);\n document.removeEventListener(\"click\", this.boundClick, true);\n document.removeEventListener(\"touchstart\", this.boundTouchStart);\n document.removeEventListener(\"touchend\", this.boundTouchEnd);\n document.removeEventListener(\"keydown\", this.host.boundKeyDown);\n }\n\n cancel(): void {\n this.keyboardController?.stop();\n this.keyboardController = null;\n this.stopTargetingListeners();\n document.body.classList.remove(\"qaid-targeting\", \"qaid-type-up\");\n document.body.style.removeProperty(\"--qaid-positive\");\n document.body.style.removeProperty(\"--qaid-negative\");\n this.host.clearActiveThumb();\n\n this.host.setState(\"IDLE\");\n this.host.feedbackData.feedbackType = null;\n this.host.feedbackData.elementSelector = null;\n this.host.feedbackData.elementText = null;\n this.host.selectedBounds.visible = false;\n }\n\n private removeTargetingOverlay(): void {\n if (this.overlayContainer) {\n this.overlayContainer.remove();\n this.overlayContainer = null;\n }\n this.captureLayer = null;\n this.crosshairH = null;\n this.crosshairV = null;\n this.scope = null;\n }\n\n private showSelectedMarker(): void {\n const root = this.host.ensureOverlayHost();\n\n this.marker = document.createElement(\"div\");\n this.marker.className = \"qaid-selected-marker\";\n this.marker.style.left = `${this.host.selectedBounds.x}px`;\n this.marker.style.top = `${this.host.selectedBounds.y}px`;\n this.marker.style.width = `${this.host.selectedBounds.width}px`;\n this.marker.style.height = `${this.host.selectedBounds.height}px`;\n this.marker.style.zIndex = String(this.host.config.zIndex + 1);\n\n this.host.applyVars(this.marker);\n root.appendChild(this.marker);\n }\n\n hideMarker(): void {\n if (this.marker) {\n this.marker.remove();\n this.marker = null;\n }\n }\n\n /** Full teardown for embed.destroy(). */\n destroy(): void {\n this.keyboardController?.stop();\n this.keyboardController = null;\n this.stopTargetingListeners();\n this.hideMarker();\n }\n}\n\n/** This feature's shadow-DOM styles; the embed adds them when it loads the chunk. */\nexport const styles = featureStyles;\n"],"names":["DATA_ATTRS","findDataAttribute","element","stopAt","current","attr","value","getTruncatedText","maxLength","textContent","getNthChildIndex","index","sibling","generateNthChildPath","path","tag","escapeCSSIdentifier","str","generateSelector","dataAttr","generateElementInfo","text","TARGETABLE_SELECTOR","NATIVELY_FOCUSABLE","isElementVisible","view","style","collectTargetableElements","options","root","selector","isExcluded","isVisible","startKeyboardTargeting","candidates","moveFocus","target","addedTabindex","stopped","seed","seedIndex","focusCurrent","focusable","emitHighlight","moveTo","nextIndex","len","next","prev","getCurrent","stop","handleKey","select","cancel","event","TOUCH_TAP_SLOP","TargetingController","host","e","type","el","isEmbedElement","rect","b","bounds","getElementBounds","vignette","part","div","x","y","hosts","elementUnder","getElementAtPointUnderOverlay","t","start","styles","featureStyles"],"mappings":"qDAKO,MAAMA,EAAa,CAAC,YAAa,UAAW,cAAe,SAAS,EAWpE,SAASC,EACdC,EACAC,EAAkB,SAAS,KACZ,CACf,IAAIC,EAA0BF,EAE9B,KAAOE,GAAWA,IAAYD,GAAQ,CACpC,UAAWE,KAAQL,EAAY,CAC7B,MAAMM,EAAQF,EAAQ,aAAaC,CAAI,EACvC,GAAIC,EACF,MAAO,GAAGD,CAAI,KAAKC,CAAK,GAE5B,CACAF,EAAUA,EAAQ,aACpB,CAEA,OAAO,IACT,CAKO,SAASG,EAAiBL,EAAkBM,EAAY,IAAa,CAC1E,MAAMC,EAAcP,EAAQ,aAAa,KAAA,EAAO,MAAM,EAAGM,CAAS,GAAK,GACvE,OAAOC,EAAY,SAAWD,EAAYC,EAAc,MAAQA,CAClE,CAKA,SAASC,EAAiBR,EAA0B,CAClD,IAAIS,EAAQ,EACRC,EAAUV,EAAQ,uBACtB,KAAOU,GACLD,IACAC,EAAUA,EAAQ,uBAEpB,OAAOD,CACT,CAOO,SAASE,EAAqBX,EAA0B,CAC7D,MAAMY,EAAiB,CAAA,EACv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Y,uBACxB,KAAK,OAAO,MAAM,KAAO,GAAG,KAAK,KAAK,eAAe,CAAC,KACtD,KAAK,OAAO,MAAM,IAAM,GAAG,KAAK,KAAK,eAAe,CAAC,KACrD,KAAK,OAAO,MAAM,MAAQ,GAAG,KAAK,KAAK,eAAe,KAAK,KAC3D,KAAK,OAAO,MAAM,OAAS,GAAG,KAAK,KAAK,eAAe,MAAM,KAC7D,KAAK,OAAO,MAAM,OAAS,OAAO,KAAK,KAAK,OAAO,OAAS,CAAC,EAE7D,KAAK,KAAK,UAAU,KAAK,MAAM,EAC/BA,EAAK,YAAY,KAAK,MAAM,CAC9B,CAEA,YAAmB,CACb,KAAK,SACP,KAAK,OAAO,OAAA,EACZ,KAAK,OAAS,KAElB,CAGA,SAAgB,CACd,KAAK,oBAAoB,KAAA,EACzB,KAAK,mBAAqB,KAC1B,KAAK,uBAAA,EACL,KAAK,WAAA,CACP,CACF,CAGO,MAAM+C,EAASC"}
package/dist/dom.d.ts CHANGED
@@ -18,8 +18,6 @@ export interface ElProps {
18
18
  class?: string;
19
19
  /** Inline styles as a cssText string. */
20
20
  style?: string;
21
- /** innerHTML — for icons / trusted SVG markup. */
22
- html?: string;
23
21
  /** textContent. */
24
22
  text?: string;
25
23
  /** Attributes set via setAttribute (aria-*, data-*, type, role, …). */
@@ -20,8 +20,15 @@
20
20
  * (Distinct from `loader.ts`/`loader.js`, the ESM-only progressive entry this
21
21
  * one delegates to on modern browsers.)
22
22
  *
23
+ * Pinned with Subresource Integrity (`integrity="sha384-…"` on this tag), it
24
+ * loads the single-file UMD bundle instead, with that file's own sha384 baked
25
+ * in at build time (vite.config.embed.ts). `import()` can't carry a hash, so
26
+ * the code-split ESM build's lazy chunks could not be checked; the one-file
27
+ * bundle can, so every byte of the embed's JavaScript is verified.
28
+ *
23
29
  * IMPORTANT: this file must stay ES5-clean and dependency-free. It is the one
24
30
  * script that also runs on the legacy browsers we fall back for, so it can't
25
31
  * use syntax (arrow fns, const/let, template literals) they'd choke on before
26
32
  * the fallback ever loads. Written with var/function on purpose.
27
33
  */
34
+ export {};
package/dist/embed.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(){"use strict";(function(){if(typeof document=="undefined")return;function o(){var s=document.currentScript;if(s&&s.src)return s;for(var c=document.getElementsByTagName("script"),r=c.length-1;r>=0;r--){var i=c[r].src||"";if(i.indexOf("thumbs-embed")!==-1&&/\/embed(\.min)?\.js(\?|#|$)/.test(i))return c[r]}return null}var t=o();if(!(!t||!t.src)){for(var d=t.src.substring(0,t.src.lastIndexOf("/")+1),f=("noModule"in HTMLScriptElement.prototype),e=document.createElement("script"),a=t.attributes,n=0;n<a.length;n++){var u=a[n];u.name.indexOf("data-")===0&&e.setAttribute(u.name,u.value)}f?(e.type="module",e.src=d+"loader.js"):(e.defer=!0,e.src=d+"qaid.umd.cjs"),(document.head||document.documentElement).appendChild(e)}})()})();
1
+ (function(){"use strict";var v="qaid-embed",f="__qaidEmbedTrustedTypes";function y(){if(typeof window=="undefined")return null;var r=window,e=r.trustedTypes;if(!e||typeof e.createPolicy!="function")return null;var i=r[f];if(i)return i;var a=Object.create(null),t=null;try{t=e.createPolicy(v,{createScriptURL:function(n){if(a[n]===!0)return n;throw new TypeError("qaid-embed: refused script URL "+n)}})}catch(n){t=null}var u={policy:t,allowed:a};try{Object.defineProperty(r,f,{value:u,configurable:!0})}catch(n){}return u}function b(r){var e=y();return!e||!e.policy?r:(e.allowed[r]=!0,e.policy.createScriptURL(r))}var h="__qaidThumbsOrigin";(function(){if(typeof document=="undefined")return;function r(){var c=document.currentScript;if(c&&c.src)return c;for(var l=document.getElementsByTagName("script"),s=l.length-1;s>=0;s--){var m=l[s].src||"";if(m.indexOf("thumbs-embed")!==-1&&/\/embed(\.min)?\.js(\?|#|$)/.test(m))return l[s]}return null}var e=r();if(!(!e||!e.src)){for(var i=e.src.substring(0,e.src.lastIndexOf("/")+1),a=("noModule"in HTMLScriptElement.prototype),t=document.createElement("script"),u=e.attributes,n=0;n<u.length;n++){var o=u[n];o.name.indexOf("data-")===0&&t.setAttribute(o.name,o.value)}t[h]=e;var g="sha384-dvYrFdNJc4RgJa2keZAWIhtUM2OuLw6x42BhJx0ROKwuXj552zn+YPCxCHqJ4qru",p=!!e.getAttribute("integrity")&&!0,d;a&&!p?(t.type="module",d=i+"loader.js"):(t.defer=!0,d=i+"qaid.umd.cjs",p&&(t.integrity=g,t.crossOrigin="anonymous"));try{t.src=b(d)}catch(c){typeof console!="undefined"&&console.warn("[thumbs-embed] Trusted Types blocked "+d+". Add `trusted-types qaid-embed` to the page's CSP.");return}(document.head||document.documentElement).appendChild(t)}})()})();
2
2
  //# sourceMappingURL=embed.js.map
package/dist/embed.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"embed.js","sources":["../src/embed-loader.ts"],"sourcesContent":["/**\n * Single-tag embed loader (`dist/embed.js`).\n *\n * A drop-in classic `<script>` that works in every browser. It feature-detects\n * ES-module support and injects the right build, so the page author never has\n * to think about compatibility:\n *\n * - modern browsers → the progressive ESM loader (`loader.js`): a small core,\n * with screenshot / video / annotation / targeting loading on demand.\n * - older browsers → the all-in-one UMD bundle (`qaid.umd.cjs`).\n *\n * The injected build initializes itself from the `data-*` attributes copied\n * across from this tag (or from a `<script type=\"application/json\">` config\n * block already on the page), so exactly one embed is created either way.\n *\n * Usage:\n * <script src=\"https://unpkg.com/@qaiddev/thumbs-embed/dist/embed.js\"\n * data-endpoint=\"/api/feedback\"></script>\n *\n * (Distinct from `loader.ts`/`loader.js`, the ESM-only progressive entry this\n * one delegates to on modern browsers.)\n *\n * IMPORTANT: this file must stay ES5-clean and dependency-free. It is the one\n * script that also runs on the legacy browsers we fall back for, so it can't\n * use syntax (arrow fns, const/let, template literals) they'd choke on before\n * the fallback ever loads. Written with var/function on purpose.\n */\n\n(function () {\n if (typeof document === \"undefined\") return;\n\n // Locate this script tag: prefer document.currentScript (valid for a plain\n // classic script), else find the last <script> whose src looks like embed.js.\n function findSelf(): HTMLScriptElement | null {\n var cur = document.currentScript as HTMLScriptElement | null;\n if (cur && cur.src) return cur;\n var scripts = document.getElementsByTagName(\"script\");\n for (var i = scripts.length - 1; i >= 0; i--) {\n var src = scripts[i].src || \"\";\n if (src.indexOf(\"thumbs-embed\") !== -1 && /\\/embed(\\.min)?\\.js(\\?|#|$)/.test(src)) {\n return scripts[i];\n }\n }\n return null;\n }\n\n var self = findSelf();\n if (!self || !self.src) return;\n\n // Base = the directory that holds embed.js, e.g.\n // \"https://unpkg.com/@qaiddev/thumbs-embed/dist/\". loader.js's own relative\n // chunk imports then resolve against the same (CDN-versioned) base.\n var base = self.src.substring(0, self.src.lastIndexOf(\"/\") + 1);\n\n var supportsModules = \"noModule\" in HTMLScriptElement.prototype;\n\n var entry = document.createElement(\"script\");\n\n // Carry the config across so the injected build's auto-init sees it.\n var attrs = self.attributes;\n for (var j = 0; j < attrs.length; j++) {\n var a = attrs[j];\n if (a.name.indexOf(\"data-\") === 0) entry.setAttribute(a.name, a.value);\n }\n\n if (supportsModules) {\n entry.type = \"module\";\n entry.src = base + \"loader.js\";\n } else {\n // Classic bundle: defer so it runs after the document is parsed, matching\n // the module entry's deferred timing.\n entry.defer = true;\n entry.src = base + \"qaid.umd.cjs\";\n }\n\n (document.head || document.documentElement).appendChild(entry);\n})();\n"],"names":["findSelf","cur","scripts","i","src","self","base","supportsModules","entry","attrs","j","a"],"mappings":"0BA4BC,UAAY,CACX,GAAI,OAAO,UAAa,YAAa,OAIrC,SAASA,GAAqC,CAC5C,IAAIC,EAAM,SAAS,cACnB,GAAIA,GAAOA,EAAI,IAAK,OAAOA,EAE3B,QADIC,EAAU,SAAS,qBAAqB,QAAQ,EAC3CC,EAAID,EAAQ,OAAS,EAAGC,GAAK,EAAGA,IAAK,CAC5C,IAAIC,EAAMF,EAAQC,CAAC,EAAE,KAAO,GAC5B,GAAIC,EAAI,QAAQ,cAAc,IAAM,IAAM,8BAA8B,KAAKA,CAAG,EAC9E,OAAOF,EAAQC,CAAC,CAEpB,CACA,OAAO,IACT,CAEA,IAAIE,EAAOL,EAAA,EACX,GAAI,GAACK,GAAQ,CAACA,EAAK,KAanB,SARIC,EAAOD,EAAK,IAAI,UAAU,EAAGA,EAAK,IAAI,YAAY,GAAG,EAAI,CAAC,EAE1DE,GAAkB,aAAc,kBAAkB,WAElDC,EAAQ,SAAS,cAAc,QAAQ,EAGvCC,EAAQJ,EAAK,WACRK,EAAI,EAAGA,EAAID,EAAM,OAAQC,IAAK,CACrC,IAAIC,EAAIF,EAAMC,CAAC,EACXC,EAAE,KAAK,QAAQ,OAAO,IAAM,GAAGH,EAAM,aAAaG,EAAE,KAAMA,EAAE,KAAK,CACvE,CAEIJ,GACFC,EAAM,KAAO,SACbA,EAAM,IAAMF,EAAO,cAInBE,EAAM,MAAQ,GACdA,EAAM,IAAMF,EAAO,iBAGpB,SAAS,MAAQ,SAAS,iBAAiB,YAAYE,CAAK,EAC/D,GAAA"}
1
+ {"version":3,"file":"embed.js","sources":["../src/trusted-types.ts","../src/origin-key.ts","../src/embed-loader.ts"],"sourcesContent":["/**\n * The embed's one Trusted Types policy, `qaid-embed`.\n *\n * On a page that sets `require-trusted-types-for 'script'`, assigning a plain\n * string to `script.src` throws. The embed computes every script URL it sets\n * itself (its own stage-two file, the quests module), so it passes each one\n * through this policy, which only signs URLs the embed registered a moment\n * before. A partner allows it with `trusted-types qaid-embed`.\n *\n * The policy is created once per page and kept on `window`, because embed.js,\n * the bundle it loads, and quests-embed (which keeps its own copy of this\n * file) all want the same name, and a page's `trusted-types` directive\n * refuses a second policy of one name unless it says `'allow-duplicates'`.\n *\n * When the browser has no Trusted Types, or the page's directive does not\n * list `qaid-embed`, the URL comes back as a plain string. The assignment\n * then works or throws exactly as it would have; callers catch it.\n *\n * ES5-clean on purpose: embed.js, which runs on the oldest browsers we\n * support, bundles this file too.\n */\n\ninterface ScriptUrlPolicy {\n createScriptURL(url: string): unknown;\n}\n\ninterface SharedPolicy {\n policy: ScriptUrlPolicy | null;\n allowed: Record<string, boolean>;\n}\n\ninterface TrustedTypesFactory {\n createPolicy(\n name: string,\n rules: { createScriptURL: (url: string) => string }\n ): ScriptUrlPolicy;\n}\n\nexport var POLICY_NAME = \"qaid-embed\";\nvar KEY = \"__qaidEmbedTrustedTypes\";\n\nfunction shared(): SharedPolicy | null {\n if (typeof window === \"undefined\") return null;\n var w = window as unknown as Record<string, unknown>;\n var tt = w.trustedTypes as TrustedTypesFactory | undefined;\n if (!tt || typeof tt.createPolicy !== \"function\") return null;\n var existing = w[KEY] as SharedPolicy | undefined;\n if (existing) return existing;\n\n var allowed: Record<string, boolean> = Object.create(null);\n var policy: ScriptUrlPolicy | null = null;\n try {\n policy = tt.createPolicy(POLICY_NAME, {\n createScriptURL: function (url: string): string {\n if (allowed[url] === true) return url;\n throw new TypeError(\"qaid-embed: refused script URL \" + url);\n },\n });\n } catch (e) {\n // The page's trusted-types directive does not list qaid-embed.\n policy = null;\n }\n var state: SharedPolicy = { policy: policy, allowed: allowed };\n try {\n Object.defineProperty(w, KEY, { value: state, configurable: true });\n } catch (e) {\n /* frozen window: keep it local */\n }\n return state;\n}\n\n/**\n * A value for `script.src`: a TrustedScriptURL from the `qaid-embed` policy\n * when one exists, else the string itself.\n */\nexport function trustedScriptUrl(url: string): string {\n var s = shared();\n if (!s || !s.policy) return url;\n s.allowed[url] = true;\n return s.policy.createScriptURL(url) as string;\n}\n\n/** @internal Test seam: forget the page's policy. */\nexport function _resetTrustedTypes(): void {\n if (typeof window === \"undefined\") return;\n try {\n delete (window as unknown as Record<string, unknown>)[KEY];\n } catch (e) {\n /* nothing to forget */\n }\n}\n","/**\n * The property embed.js sets on the tag it injects, pointing back at the\n * customer's own `<script src=\".../embed.js\">`. An expando, not an attribute:\n * markup injected into the page can't forge it. Its own module so embed.js\n * (ES5, tiny) can share it with the bootstrap without pulling the bootstrap in.\n */\nexport var ORIGIN_KEY_NAME = \"__qaidThumbsOrigin\";\n","/**\n * Single-tag embed loader (`dist/embed.js`).\n *\n * A drop-in classic `<script>` that works in every browser. It feature-detects\n * ES-module support and injects the right build, so the page author never has\n * to think about compatibility:\n *\n * - modern browsers → the progressive ESM loader (`loader.js`): a small core,\n * with screenshot / video / annotation / targeting loading on demand.\n * - older browsers → the all-in-one UMD bundle (`qaid.umd.cjs`).\n *\n * The injected build initializes itself from the `data-*` attributes copied\n * across from this tag (or from a `<script type=\"application/json\">` config\n * block already on the page), so exactly one embed is created either way.\n *\n * Usage:\n * <script src=\"https://unpkg.com/@qaiddev/thumbs-embed/dist/embed.js\"\n * data-endpoint=\"/api/feedback\"></script>\n *\n * (Distinct from `loader.ts`/`loader.js`, the ESM-only progressive entry this\n * one delegates to on modern browsers.)\n *\n * Pinned with Subresource Integrity (`integrity=\"sha384-…\"` on this tag), it\n * loads the single-file UMD bundle instead, with that file's own sha384 baked\n * in at build time (vite.config.embed.ts). `import()` can't carry a hash, so\n * the code-split ESM build's lazy chunks could not be checked; the one-file\n * bundle can, so every byte of the embed's JavaScript is verified.\n *\n * IMPORTANT: this file must stay ES5-clean and dependency-free. It is the one\n * script that also runs on the legacy browsers we fall back for, so it can't\n * use syntax (arrow fns, const/let, template literals) they'd choke on before\n * the fallback ever loads. Written with var/function on purpose.\n */\n\nimport { trustedScriptUrl } from \"./trusted-types\";\nimport { ORIGIN_KEY_NAME } from \"./origin-key\";\n\n/** sha384 of qaid.umd.cjs, set by vite.config.embed.ts. Empty in tests. */\ndeclare const __QAID_UMD_INTEGRITY__: string | undefined;\n\n(function () {\n if (typeof document === \"undefined\") return;\n\n // Locate this script tag: prefer document.currentScript (valid for a plain\n // classic script), else find the last <script> whose src looks like embed.js.\n function findSelf(): HTMLScriptElement | null {\n var cur = document.currentScript as HTMLScriptElement | null;\n if (cur && cur.src) return cur;\n var scripts = document.getElementsByTagName(\"script\");\n for (var i = scripts.length - 1; i >= 0; i--) {\n var src = scripts[i].src || \"\";\n if (src.indexOf(\"thumbs-embed\") !== -1 && /\\/embed(\\.min)?\\.js(\\?|#|$)/.test(src)) {\n return scripts[i];\n }\n }\n return null;\n }\n\n var self = findSelf();\n if (!self || !self.src) return;\n\n // Base = the directory that holds embed.js, e.g.\n // \"https://unpkg.com/@qaiddev/thumbs-embed/dist/\". loader.js's own relative\n // chunk imports then resolve against the same (CDN-versioned) base.\n var base = self.src.substring(0, self.src.lastIndexOf(\"/\") + 1);\n\n var supportsModules = \"noModule\" in HTMLScriptElement.prototype;\n\n var entry = document.createElement(\"script\");\n\n // Carry the config across so the injected build's auto-init sees it.\n var attrs = self.attributes;\n for (var j = 0; j < attrs.length; j++) {\n var a = attrs[j];\n if (a.name.indexOf(\"data-\") === 0) entry.setAttribute(a.name, a.value);\n }\n\n // Lets the injected build find this tag, for the JSON config block beside\n // it. A property, not an attribute, so page markup can't fake it.\n (entry as unknown as Record<string, unknown>)[ORIGIN_KEY_NAME] = self;\n\n var umdIntegrity = typeof __QAID_UMD_INTEGRITY__ === \"string\" ? __QAID_UMD_INTEGRITY__ : \"\";\n var pinned = !!self.getAttribute(\"integrity\") && !!umdIntegrity;\n\n var url: string;\n if (supportsModules && !pinned) {\n entry.type = \"module\";\n url = base + \"loader.js\";\n } else {\n // Classic bundle: defer so it runs after the document is parsed, matching\n // the module entry's deferred timing.\n entry.defer = true;\n url = base + \"qaid.umd.cjs\";\n if (pinned) {\n entry.integrity = umdIntegrity;\n entry.crossOrigin = \"anonymous\";\n }\n }\n\n try {\n entry.src = trustedScriptUrl(url);\n } catch (e) {\n // A Trusted Types page that doesn't allow the qaid-embed policy.\n if (typeof console !== \"undefined\") {\n console.warn(\"[thumbs-embed] Trusted Types blocked \" + url + \". Add `trusted-types qaid-embed` to the page's CSP.\");\n }\n return;\n }\n\n (document.head || document.documentElement).appendChild(entry);\n})();\n"],"names":["POLICY_NAME","KEY","shared","w","tt","existing","allowed","policy","url","e","state","trustedScriptUrl","s","ORIGIN_KEY_NAME","findSelf","cur","scripts","i","src","self","base","supportsModules","entry","attrs","j","a","umdIntegrity","pinned"],"mappings":"yBAsCO,IAAI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CAEpB,CACA,OAAO,IACT,CAEA,IAAIE,EAAOL,EAAA,EACX,GAAI,GAACK,GAAQ,CAACA,EAAK,KAanB,SARIC,EAAOD,EAAK,IAAI,UAAU,EAAGA,EAAK,IAAI,YAAY,GAAG,EAAI,CAAC,EAE1DE,GAAkB,aAAc,kBAAkB,WAElDC,EAAQ,SAAS,cAAc,QAAQ,EAGvCC,EAAQJ,EAAK,WACRK,EAAI,EAAGA,EAAID,EAAM,OAAQC,IAAK,CACrC,IAAIC,EAAIF,EAAMC,CAAC,EACXC,EAAE,KAAK,QAAQ,OAAO,IAAM,GAAGH,EAAM,aAAaG,EAAE,KAAMA,EAAE,KAAK,CACvE,CAICH,EAA6CT,CAAe,EAAIM,EAEjE,IAAIO,EAA4D,0EAC5DC,EAAS,CAAC,CAACR,EAAK,aAAa,WAAW,GAAK,GAE7CX,EACAa,GAAmB,CAACM,GACtBL,EAAM,KAAO,SACbd,EAAMY,EAAO,cAIbE,EAAM,MAAQ,GACdd,EAAMY,EAAO,eACTO,IACFL,EAAM,UAAYI,EAClBJ,EAAM,YAAc,cAIxB,GAAI,CACFA,EAAM,IAAMX,EAAiBH,CAAG,CAClC,OAASC,EAAG,CAEN,OAAO,SAAY,aACrB,QAAQ,KAAK,wCAA0CD,EAAM,qDAAqD,EAEpH,MACF,EAEC,SAAS,MAAQ,SAAS,iBAAiB,YAAYc,CAAK,EAC/D,GAAA"}
package/dist/icons.d.ts CHANGED
@@ -6,6 +6,8 @@ export declare const THUMBS_DOWN_ICON = "<svg xmlns=\"http://www.w3.org/2000/svg
6
6
  export declare const RECORD_ICON = "<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"qaid-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M15.75 10.5l4.72-4.72a.75.75 0 011.28.53v11.38a.75.75 0 01-1.28.53l-4.72-4.72M4.5 18.75h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25h-9A2.25 2.25 0 002.25 7.5v9a2.25 2.25 0 002.25 2.25z\"/>\n</svg>";
7
7
  /** Chat-bubble icon for the single, sentiment-free "Feedback" button. */
8
8
  export declare const FEEDBACK_ICON = "<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"qaid-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M8 10h8M8 14h5m-9 6l3.5-3.5H18a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v14z\"/>\n</svg>";
9
+ /** The small X that hides the buttons. */
10
+ export declare const DISMISS_ICON = "<svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M2 2l8 8M10 2l-8 8\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"/></svg>";
9
11
  export declare const RECTANGLE_ICON = "<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"qaid-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\">\n <rect x=\"4\" y=\"6\" width=\"16\" height=\"12\" rx=\"1\" stroke-linejoin=\"round\"/>\n</svg>";
10
12
  export declare const ARROW_ICON = "<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"qaid-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M5 19L19 5m0 0h-8m8 0v8\"/>\n</svg>";
11
13
  export declare const PENCIL_ICON = "<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"qaid-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M12 20h9M16.5 3.5a2.121 2.121 0 013 3L7 19l-4 1 1-4L16.5 3.5z\"/>\n</svg>";