Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
One-time setup that gathers your project's design context and saves it to CLAUDE.md for future sessions.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
scripts/live-ui-core.mjs
1/**2* Framework-neutral Impeccable live chrome contract.3*4* The production browser bundle is intentionally plain DOM so Svelte, React,5* Vue, and static adapters can all mount the same chrome. This module is the6* testable contract/inventory for that bundle; live-browser.js mirrors these7* values at runtime because it is served as a standalone script.8*/910export const LIVE_CHROME_MOUNT_CONTRACT = Object.freeze([11'root',12'transport',13'state',14'actions',15]);1617export const LIVE_UI_SURFACES = Object.freeze([18{19key: 'global-bottom-bar',20ids: [21'impeccable-live-global-bar',22'impeccable-live-global-bar-brand',23'impeccable-live-pick-toggle',24'impeccable-live-insert-toggle',25'impeccable-live-detect-toggle',26'impeccable-live-detect-badge',27'impeccable-live-design-toggle',28'impeccable-live-page-chat',29'impeccable-live-page-chat-input',30'impeccable-live-page-chat-voice',31],32states: ['rest', 'hover', 'focus-visible', 'pressed', 'active', 'tooltip'],33},34{35key: 'pending-copy-edit-dock',36ids: ['impeccable-live-pending-dock'],37states: ['closed', 'open', 'hover', 'pressed', 'loading', 'rollback', 'keep-fixing'],38},39{40key: 'element-selection-chrome',41ids: [42'impeccable-live-highlight',43'impeccable-live-tooltip',44'impeccable-live-bar',45'impeccable-live-configure-input-wrap',46'impeccable-live-input',47'impeccable-live-configure-voice',48],49states: ['rest', 'hover', 'focus-visible', 'pressed', 'disabled'],50},51{52key: 'action-picker',53ids: ['impeccable-live-picker'],54states: ['closed', 'open', 'option-hover', 'option-focus'],55},56{57key: 'edit-chrome',58ids: ['impeccable-live-edit-badge'],59states: ['enabled', 'disabled', 'editing', 'cancel', 'save', 'edited-content'],60},61{62key: 'generating-row',63ids: ['impeccable-live-bar', 'impeccable-live-shader'],64states: ['action-label', 'animated-dots', 'generating', 'done'],65},66{67key: 'variant-cycling-row',68ids: ['impeccable-live-bar', 'impeccable-live-params-panel'],69states: ['variant-1', 'variant-2', 'variant-3', 'left-disabled', 'right-disabled', 'dot-click', 'accept', 'discard'],70},71{72key: 'variant-params-panel',73ids: ['impeccable-live-params-panel'],74states: ['closed', 'open-above', 'open-below', 'range', 'steps', 'toggle'],75},76{77key: 'saving-confirmed-rows',78ids: ['impeccable-live-bar'],79states: ['saving', 'applying-variant', 'confirmed'],80},81{82key: 'insert-mode-chrome',83ids: [84'impeccable-live-insert-line',85'impeccable-live-insert-placeholder',86'impeccable-live-placeholder-resize',87'impeccable-live-insert-input',88'impeccable-live-insert-voice',89'impeccable-live-insert-create',90'impeccable-live-insert-create-tooltip',91],92states: ['toggle-active', 'line', 'placeholder', 'resize', 'enabled', 'disabled', 'tooltip'],93},94{95key: 'annotation-chrome',96ids: [97'impeccable-live-annot',98'impeccable-live-annot-svg',99'impeccable-live-annot-pins',100'impeccable-live-annot-clear',101],102states: ['overlay', 'drawing', 'pin', 'pin-edit', 'clear'],103},104{105key: 'design-system-panel',106ids: ['impeccable-live-design-host'],107states: ['closed', 'open', 'tabs', 'token-tiles', 'copy'],108},109{110key: 'toasts-and-errors',111ids: ['impeccable-live-toast'],112states: ['normal', 'error', 'no-variants-mounted'],113},114{115key: 'css-isolation-boundary',116ids: ['impeccable-live-root'],117states: ['shadow-root', 'style-tags', 'hostile-css'],118},119]);120121export const LIVE_UI_COMPONENT_IDS = Object.freeze([122...new Set(LIVE_UI_SURFACES.flatMap((surface) => surface.ids)),123]);124125export function resolveLiveUiRoot(env = globalThis) {126const doc = env?.document;127const explicit = env?.__IMPECCABLE_LIVE_UI_ROOT__128|| env?.window?.__IMPECCABLE_LIVE_UI_ROOT__;129if (explicit && typeof explicit.appendChild === 'function') return explicit;130return doc?.body || null;131}132133export function getLiveUiElementById(id, env = globalThis) {134const doc = env?.document;135const root = resolveLiveUiRoot(env);136if (!id) return null;137if (root?.getElementById) {138const found = root.getElementById(id);139if (found) return found;140}141if (root?.querySelector) {142const found = root.querySelector('#' + escapeCssIdent(id));143if (found) return found;144}145return doc?.getElementById?.(id) || null;146}147148export function appendToLiveUiRoot(el, env = globalThis) {149const root = resolveLiveUiRoot(env);150if (!root) throw new Error('Impeccable live UI root is not available');151root.appendChild(el);152return el;153}154155export function appendStyleToLiveUiRoot(styleEl, env = globalThis) {156const doc = env?.document;157const root = resolveLiveUiRoot(env);158if (root && root !== doc?.body) {159root.appendChild(styleEl);160} else {161(doc?.head || doc?.body || root).appendChild(styleEl);162}163return styleEl;164}165166export function activeElementDeep(doc = globalThis.document) {167let active = doc?.activeElement || null;168while (active?.shadowRoot?.activeElement) {169active = active.shadowRoot.activeElement;170}171return active;172}173174function escapeCssIdent(value) {175if (typeof CSS !== 'undefined' && typeof CSS.escape === 'function') {176return CSS.escape(String(value));177}178return String(value).replace(/([ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g, '\\$1');179}180