@heypointerhq/sdk 0.0.0-stage → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +131 -2
- package/dist/author/capture.d.ts +53 -0
- package/dist/author/draft.d.ts +81 -0
- package/dist/author/flow.d.ts +31 -0
- package/dist/author/global.d.ts +1 -0
- package/dist/author/index.d.ts +49 -0
- package/dist/author/labels.d.ts +73 -0
- package/dist/author/panel.d.ts +61 -0
- package/dist/author/policy.d.ts +21 -0
- package/dist/author-import.d.ts +1 -0
- package/dist/author-import.iife.d.ts +1 -0
- package/dist/author-loader.d.ts +17 -0
- package/dist/author.js +750 -0
- package/dist/chunk-element.js +896 -0
- package/dist/chunk-theme.js +319 -0
- package/dist/client.d.ts +32 -0
- package/dist/contrast.d.ts +5 -0
- package/dist/element.d.ts +43 -0
- package/dist/element.js +1 -0
- package/dist/global.d.ts +2 -0
- package/dist/heypointer.author.js +2 -0
- package/dist/heypointer.global.js +2 -0
- package/dist/highlight.d.ts +21 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +3 -0
- package/dist/labels.d.ts +81 -0
- package/dist/player.d.ts +193 -0
- package/dist/recorder.d.ts +12 -0
- package/dist/spotlight.d.ts +28 -0
- package/dist/targeting/index.d.ts +26 -0
- package/dist/targeting/watch.d.ts +6 -0
- package/dist/theme.d.ts +32 -0
- package/dist/types.d.ts +5 -0
- package/dist/validate.d.ts +6 -0
- package/package.json +58 -4
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var HeyPointerGlobal=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t={launcher:`Guide me`,dialogName:`HeyPointer assistant`,heading:`HeyPointer`,closeLabel:`Close guide`,goalQuestion:`What do you want to do?`,goalAria:`Your goal`,goalPlaceholder:`e.g. invite a teammate`,submit:`Show me`,speak:`Speak`,stop:`Stop`,changeGoal:`Change goal or use voice`,assistToggle:`Assist: do safe clicks for me when I press Next`,assistHint:`You need to do this one yourself.`,assistClicked:`Clicked "{label}" for you.`,assistFailed:`I couldn't click "{label}" for you. Do this step yourself, then press Next.`,releasedNote:`It looks like you did that. Press Next to continue.`,next:`Next`,finish:`Finish`,back:`Back`,skip:`Skip`,stepProgress:`Step {current} of {total}`,tourCount:`{current} / {total}`,stepAnnounce:`Step {current} of {total}: {title}. {instruction}`,suggestedValue:`Suggested value: {value}`,gateWarning:`This changes data. Confirm before continuing.`,gateCheckbox:`I understand and want to do this myself.`,gateWhy:`Tick the confirmation box to continue.`,evidenceSummary:`Source ({count})`,loading:`Finding the steps…`,tryAgain:`Try again`,skipStep:`Skip step`,done:`Done. You finished: {goal}`,startAnother:`Start another`,suggestLabel:`Did you mean:`,suggestAnnounce:`Did you mean: {list}?`,notFound:`I can't find "{label}" on this page. The screen may differ from the docs.`,ambiguous:`I found more than one match for this step, so I won't guess. Look for: {label}.`,notFoundAnnounce:`Cannot find the target for: {title}. You can try again or skip this step.`,ambiguousAnnounce:`Several matches for: {title}. You can try again or skip this step.`,emptyGoal:`Type what you want to do first.`,recording:`Recording… press Stop when done.`,transcribing:`Transcribing…`,voiceUnavailable:`Voice isn't available. Type your goal instead.`,noSpeech:`I didn't hear anything. Try again or type your goal.`,audioFailed:`Could not process audio. Type your goal instead.`,insufficient:`I don't have enough documented steps to guide this safely.`,genericError:`Something went wrong.`,clientRequired:`HeyPointer needs a client ID. Run heypointer init or pass data-client-id.`,clientInvalid:`HeyPointer does not recognise this client ID. Check that it matches the one heypointer init gave you.`,clientOrigin:`This site's address is not allowed for this HeyPointer client ID. Ask the HeyPointer admin to add it to the client's allowed origins.`,clientMalformed:`The HeyPointer client ID looks wrong (it should start with hpc_). Check data-client-id against what heypointer init printed.`,rateLimited:`HeyPointer is getting too many requests right now. Wait a moment and try again.`,serverUnreachable:`Cannot reach the HeyPointer server at {host}. Check that it is running and the address is right.`,requestFailed:`Walkthrough request failed ({status})`},n=/\{(\w+)\}/g,r={done:[`goal`],stepAnnounce:[`instruction`]},i=e=>[...e.matchAll(n)].map(e=>e[1]),a=e=>[...new Set(i(t[e]))].filter(t=>!r[e]?.includes(t));function o(e,t={}){return e.replace(n,(e,n)=>Object.prototype.hasOwnProperty.call(t,n)?String(t[n]):e)}function s(e){let n={...t},r=[];if(typeof e!=`object`||!e||Array.isArray(e))return{labels:n,problems:r};for(let[r,o]of Object.entries(e)){if(r.startsWith(`author`)||!Object.prototype.hasOwnProperty.call(t,r))continue;let e=r;if(typeof o!=`string`||!o.trim()||o.length>300)continue;let s=i(o);a(e).filter(e=>!s.includes(e)).length||(n[e]=o)}return{labels:n,problems:r}}function c(e,t){if(t!=null&&t.trim())try{return JSON.parse(t)}catch{return}}var l=[`click`,`type`,`select`,`navigate`,`observe`],u=e=>typeof e==`object`&&!!e,d=e=>typeof e==`string`;function f(e,t){if(!u(e))throw Error(`step ${t} is not an object`);let{id:n,title:r,instruction:i,target:a,action:o,requiresConfirmation:s,evidence:c}=e;if(!d(n)||!d(r)||!d(i))throw Error(`step ${t} missing id/title/instruction`);if(!d(o)||!l.includes(o))throw Error(`step ${t} has invalid action`);if(!u(a)||!Array.isArray(a.selectors)||!a.selectors.every(d))throw Error(`step ${t} has invalid target`);if(typeof s!=`boolean`)throw Error(`step ${t} missing requiresConfirmation`);if(!Array.isArray(c)||c.length===0)throw Error(`step ${t} has no evidence`);return e}function ee(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e){if(!u(r)||!d(r.workflowId)||!d(r.title))continue;let e=r.title.trim();if(!(!r.workflowId||!e||e.length>200||t.has(e))&&(t.add(e),n.push({workflowId:r.workflowId,title:e}),n.length===5))break}return n}function te(e){if(!u(e))throw Error(`walkthrough is not an object`);if(e.status!==`ok`&&e.status!==`insufficient_evidence`)throw Error(`invalid walkthrough status`);if(!d(e.id)||!d(e.goal)||!Array.isArray(e.steps))throw Error(`walkthrough missing id/goal/steps`);let t=e.steps.map(f);if(e.status===`ok`&&t.length===0)throw Error(`ok walkthrough has no steps`);if(e.status===`insufficient_evidence`&&t.length>0)throw Error(`insufficient_evidence walkthrough must have no steps`);let n={...e,steps:t},r=e.status===`insufficient_evidence`?ee(e.suggestions):[];return r.length?n.suggestions=r:delete n.suggestions,n}function p(e){"@babel/helpers - typeof";return p=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},p(e)}function ne(e,t){if(p(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(p(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function m(e){var t=ne(e,`string`);return p(t)==`symbol`?t:t+``}function h(e,t,n){return(t=m(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var re=/^(?:hpc|gfc)_[0-9a-f]{24}$/,ie=`X-HeyPointer-Client`;t.clientRequired;async function ae(e,t){let n;try{n=(await e.json()).error}catch{}return e.status===401&&n===`client_required`?t(`clientRequired`):e.status===401&&n===`client_invalid`?t(`clientInvalid`):e.status===403&&n===`client_origin_not_allowed`?t(`clientOrigin`):e.status===429?t(`rateLimited`):t(`requestFailed`,{status:e.status})}var g=class extends Error{},_=class extends Error{},oe=class{constructor(e){h(this,`base`,void 0),h(this,`fetchImpl`,void 0),h(this,`clientId`,void 0),h(this,`t`,void 0),this.base=e.baseUrl.replace(/\/$/,``),this.clientId=e.clientId?.trim()||void 0,this.fetchImpl=e.fetch??((...e)=>globalThis.fetch(...e)),this.t=e.text??((e,n)=>o(t[e],n))}async send(e,t){try{return await this.fetchImpl(`${this.base}${e}`,t)}catch{let e=this.base;try{e=new URL(this.base).host}catch{}throw Error(this.t(`serverUnreachable`,{host:e}))}}async requestWalkthrough(e,t){if(this.clientId!==void 0&&!re.test(this.clientId))throw Error(this.t(`clientMalformed`));let n=await this.send(`/api/walkthrough`,{method:`POST`,headers:{"content-type":`application/json`,...this.clientId?{[ie]:this.clientId}:{}},body:JSON.stringify({goal:e,context:t})});if(!n.ok)throw Error(await ae(n,this.t));return te(await n.json())}async transcribe(e){let t=await this.send(`/api/transcribe`,{method:`POST`,headers:{"content-type":e.type||`audio/webm`},body:e});if(t.status===400)throw new _(`No speech detected`);if(!t.ok)throw new g(`Transcription unavailable (${t.status})`);let n=await t.json();if(typeof n.text!=`string`||!n.text.trim())throw new _(`Empty transcript`);return n.text.trim()}};function v(e){let t=0,n=0,r=e.ownerDocument?.defaultView??null;for(;r&&r!==r.top;){let e=r.frameElement;if(!e)break;let i=e.getBoundingClientRect();t+=i.left,n+=i.top,r=r.parent}return{x:t,y:n}}var y=class{constructor(e){h(this,`host`,void 0),h(this,`box`,void 0),h(this,`target`,null),h(this,`offset`,{x:0,y:0}),h(this,`onMove`,()=>this.position()),h(this,`frame`,0),h(this,`observer`,void 0),this.host=e,this.box=document.createElement(`div`),this.box.className=`hp-highlight`,this.box.setAttribute(`part`,`highlight`),this.box.setAttribute(`aria-hidden`,`true`),this.box.hidden=!0,e.appendChild(this.box)}show(e){this.target=e,this.offset=v(e);let t=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;e.scrollIntoView?.({block:`center`,behavior:t?`auto`:`smooth`}),this.box.hidden=!1,cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(()=>this.position()),this.position(),addEventListener(`scroll`,this.onMove,!0),addEventListener(`resize`,this.onMove),this.observer?.disconnect(),typeof ResizeObserver<`u`&&(this.observer=new ResizeObserver(this.onMove),this.observer.observe(document.documentElement),this.observer.observe(e))}hide(){this.target=null,cancelAnimationFrame(this.frame),this.box.hidden=!0,this.observer?.disconnect(),removeEventListener(`scroll`,this.onMove,!0),removeEventListener(`resize`,this.onMove)}current(){return this.target}position(){if(this.target){if(!this.target.isConnected)return this.hide();cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(()=>this.place()),this.place()}}place(){if(!this.target?.isConnected)return;let e=this.target.getBoundingClientRect();Object.assign(this.box.style,{top:`${e.top+this.offset.y-4}px`,left:`${e.left+this.offset.x-4}px`,width:`${e.width+8}px`,height:`${e.height+8}px`})}};function b(){return typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<`u`}var se=class{constructor(){h(this,`rec`,null),h(this,`chunks`,[]),h(this,`stream`,null)}async start(){this.stream=await navigator.mediaDevices.getUserMedia({audio:!0}),this.chunks=[],this.rec=new MediaRecorder(this.stream),this.rec.ondataavailable=e=>e.data.size&&this.chunks.push(e.data),this.rec.start()}stop(){return new Promise((e,t)=>{let n=this.rec;if(!n)return t(Error(`not recording`));n.onstop=()=>{this.stream?.getTracks().forEach(e=>e.stop()),e(new Blob(this.chunks,{type:n.mimeType||`audio/webm`}))},n.stop()})}},ce={button:`button, [role="button"], input[type="button"], input[type="submit"]`,link:`a[href], [role="link"]`,textbox:`input:not([type]), input[type="text"], input[type="email"], input[type="search"], textarea, [role="textbox"]`,combobox:`select, [role="combobox"]`,checkbox:`input[type="checkbox"], [role="checkbox"]`};function le(e){for(let t=e;t;t=t.parentElement){if(t.hidden||t.getAttribute(`aria-hidden`)===`true`||t.hasAttribute(`inert`))return!1;let e=getComputedStyle(t);if(e.display===`none`||e.visibility===`hidden`)return!1}return!0}function x(e){if(!e.isConnected||!le(e))return!1;if(typeof e.checkVisibility!=`function`)return!0;if(!e.checkVisibility({checkVisibilityCSS:!0,contentVisibilityAuto:!0})||!e.getClientRects().length)return!1;let t=e.getBoundingClientRect();return t.width>0||t.height>0}function S(e){let t=e.getAttribute(`aria-label`);if(t)return t;let n=e.labels;return n&&n.length?Array.from(n).map(e=>e.textContent??``).join(` `):e.textContent??``}var C=e=>e.replace(/\s+/g,` `).trim().toLowerCase(),w=`a[href], button, input, select, textarea, summary, [role="button"], [role="link"], [role="checkbox"], [role="radio"], [role="switch"], [role="tab"], [role="menuitem"], [role="option"], [role="combobox"], [role="textbox"]`;function ue(e){if(e.length<2)return e;let t=(e,t)=>{let n=e.matches(w);return n===t.matches(w)?t.contains(e):n};return e.filter(n=>!e.some(e=>e!==n&&(n.contains(e)||e.contains(n))&&t(e,n)))}function T(e,t){try{return Array.from(e.querySelectorAll(t))}catch{return[]}}function de(e){try{let t=e.contentDocument;return!!t&&!!t.defaultView}catch{return!1}}function fe(e){let t=[],n=e=>{e instanceof HTMLElement&&e.shadowRoot&&!e.hasAttribute(`data-heypointer-author`)&&(t.push(e.shadowRoot),n(e.shadowRoot));for(let t of Array.from(e.childNodes))n(t)};return n(e),t}function pe(e){let t=[],n=Array.from(e.querySelectorAll(`iframe`));for(let e of n)de(e)&&e.contentDocument&&t.push(e.contentDocument);return t}function me(e){let t=[e];return t.push(...fe(e)),t.push(...pe(e)),t}function E(e,t){let n=[];for(let r of e)n.push(...t(r));return{hits:n}}function D(e,t=document){let n=me(t),r=0,i=(e,t)=>e.length===1?{status:`found`,element:e[0],strategy:t}:(e.length>1&&(r=Math.max(r,e.length)),null);for(let t of e.selectors){let{hits:e}=E(n,e=>T(e,t).filter(x)),r=i(e,`selector`);if(r)return r}let a=e.text?C(e.text):``;if(e.role&&a){let t=ce[e.role]??`[role="${CSS.escape(e.role)}"]`,{hits:r}=E(n,e=>T(e,t).filter(e=>x(e)&&C(S(e))===a)),o=i(r,`role-text`);if(o)return o}let o=e.label?C(e.label):``;if(o){let{hits:e}=E(n,e=>T(e,`input, select, textarea, [role="textbox"], [role="combobox"]`).filter(e=>x(e)&&C(S(e))===o)),t=i(e,`label`);if(t)return t}if(a){let{hits:e}=E(n,e=>T(e,`button, a, label, [role], input, select, textarea, h1, h2, h3, li, p, span`).filter(e=>x(e)&&C(S(e))===a)),t=i(ue(e.filter(t=>!(t instanceof HTMLLabelElement&&t.control instanceof HTMLElement&&e.includes(t.control)))),`text`);if(t)return t}return r?{status:`ambiguous`,count:r}:{status:`missing`}}function O(e,t=1500,n=document){let r=D(e,n);return r.status===`found`||t<=0?Promise.resolve(r):new Promise(r=>{let i=e=>{a.disconnect(),clearTimeout(o),r(e)},a=new MutationObserver(()=>{let t=D(e,n);t.status===`found`&&i(t)});a.observe(n,{childList:!0,subtree:!0,attributes:!0});let o=setTimeout(()=>i(D(e,n)),t)})}var k=[`style`,`class`,`hidden`,`open`,`inert`,`aria-hidden`],A=[`transitionend`,`transitioncancel`,`animationend`,`animationcancel`],j=[`transitionrun`,`animationstart`],M=1e3;function N(e,t){let n=!0,r=!1,i=0,a=0,o=()=>{if(i=0,r)return;let o=x(e);o!==n&&(n=o,t(o)),!r&&performance.now()<a&&s()},s=()=>{!i&&!r&&(i=requestAnimationFrame(o))},c=t=>{t.target instanceof Node&&t.target.contains(e)&&s()},l=t=>{t.target instanceof Node&&t.target.contains(e)&&(a=performance.now()+M,s())},u=new MutationObserver(s);u.observe(document,{subtree:!0,childList:!0,attributes:!0,attributeFilter:k});for(let e of A)document.addEventListener(e,c,!0);for(let e of j)document.addEventListener(e,l,!0);return s(),()=>{r=!0,cancelAnimationFrame(i),u.disconnect();for(let e of A)document.removeEventListener(e,c,!0);for(let e of j)document.removeEventListener(e,l,!0)}}function P(e,t,n,r=n.width<=600,i=!1){if(r)return{left:12,top:e.bottom+16+t.height<=n.height-12?e.bottom+16:e.top-t.height-16>=12?e.top-t.height-16:16,placement:`floating`,arrowLeft:0};let a=(e,r)=>e>=12&&r>=12&&e+t.width<=n.width-12&&r+t.height<=n.height-12,o=e.left+(e.right-e.left-t.width)/2,s=e.top+(e.bottom-e.top-t.height)/2,c=[{placement:`below`,left:o,top:e.bottom+16},{placement:`above`,left:o,top:e.top-t.height-16},{placement:`right`,left:e.right+16,top:s},{placement:`left`,left:e.left-t.width-16,top:s}];i&&([c[2],c[3]]=[c[3],c[2]]);let l=c.find(e=>a(e.left,e.top))??c.map(e=>({...e,left:Math.max(12,Math.min(e.left,n.width-t.width-12)),top:Math.max(12,Math.min(e.top,n.height-t.height-12))})).sort((n,r)=>{let i=n=>Math.max(0,Math.min(e.right,n.left+t.width)-Math.max(e.left,n.left))*Math.max(0,Math.min(e.bottom,n.top+t.height)-Math.max(e.top,n.top));return i(n)-i(r)})[0],u=Math.max(24,Math.min((e.left+e.right)/2-l.left,t.width-24));return{...l,arrowLeft:u}}var F=class{constructor(e){h(this,`overlay`,void 0),h(this,`target`,null),h(this,`offset`,{x:0,y:0}),h(this,`enabled`,!1),h(this,`onReposition`,void 0),h(this,`frame`,0),h(this,`observer`,void 0),h(this,`onMove`,()=>this.position()),this.overlay=document.createElement(`div`),this.overlay.className=`hp-spotlight`,this.overlay.setAttribute(`part`,`spotlight`),this.overlay.setAttribute(`aria-hidden`,`true`),this.overlay.hidden=!0,e.appendChild(this.overlay)}show(e,t){this.hide(),this.target=e,this.onReposition=t,this.enabled=!0,this.overlay.hidden=!1,e&&(this.offset=v(e)),this.position(),cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(()=>this.position()),addEventListener(`scroll`,this.onMove,!0),addEventListener(`resize`,this.onMove),typeof ResizeObserver<`u`&&(this.observer=new ResizeObserver(this.onMove),this.observer.observe(document.documentElement),this.observer.observe(this.overlay),e&&this.observer.observe(e))}hide(){this.target=null,this.enabled=!1,cancelAnimationFrame(this.frame),this.overlay.hidden=!0,this.overlay.style.clipPath=``,this.observer?.disconnect(),removeEventListener(`scroll`,this.onMove,!0),removeEventListener(`resize`,this.onMove)}position(){this.enabled&&(!this.target||this.target.isConnected)&&(cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(()=>{this.enabled&&this.update()}),this.update())}update(){if(!this.enabled)return;let e=this.target?.getBoundingClientRect()??{top:0,left:0,width:0,height:0},t=e.left+this.offset.x-5,n=e.top+this.offset.y-5,r=e.width+10,i=e.height+10;this.overlay.style.clipPath=this.target?`polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, ${t}px ${n}px, ${t}px ${n+i}px, ${t+r}px ${n+i}px, ${t+r}px ${n}px, ${t}px ${n}px)`:``,this.onReposition?.()}},I=async()=>null,L=`heypointer:author:active:v1`,R=``,z=e=>{R=e};function he(e){if(e.author)return!0;if(!e.allowAuthorParam)return!1;try{return new URLSearchParams(location.search).has(`heypointer-author`)||sessionStorage.getItem(L)===`1`}catch{return!1}}async function ge(){let e=window;return e.HeyPointerAuthor?e.HeyPointerAuthor:await I()||(R?(await new Promise((e,t)=>{let n=document.createElement(`script`);n.src=R.replace(/[^/?#]*([?#].*)?$/,`heypointer.author.js`),n.onload=()=>e(),n.onerror=()=>t(Error(`heypointer.author.js did not load`)),document.head.appendChild(n)}),e.HeyPointerAuthor??null):null)}var B=[`auto`,`light`,`dark`],V=[`accent`,`accentFg`,`bg`,`fg`,`muted`,`border`,`warnBg`,`warnBorder`,`errBg`,`errBorder`,`focus`,`halo`,`ring`,`dim`],H=e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),_e=/[;{}@\\<>"'`\u0000-\u001f]|url\(|expression\(|\/\*|javascript:|image\(|image-set\(/i,ve=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,ye=/^[a-z]{3,30}$/i,be=/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix)\([0-9a-z%.,/\s+-]{1,120}\)$/i,xe=/^var\(--[a-z0-9_-]{1,60}\)$/i,Se=/^\d{1,3}(?:\.\d{1,3})?(?:px|rem|em)$/,Ce=/^[A-Za-z0-9 ,_'"-]{1,200}$/;function we(e){if(typeof e!=`string`)return!1;let t=e.trim();return!t||t.length>140||_e.test(t)?!1:ve.test(t)||ye.test(t)||be.test(t)||xe.test(t)}var U=e=>typeof e==`string`&&Se.test(e.trim()),Te=e=>typeof e==`string`&&Ce.test(e.trim())&&!/url|expression/i.test(e);function W(e,t,n){let r={};if(e===void 0||!e||typeof e!=`object`||Array.isArray(e))return r;for(let[t,n]of Object.entries(e))t!==`dark`&&t!==`radius`&&t!==`font`&&t!==`fontSize`&&V.includes(t)&&we(n)&&(r[t]=n.trim());return r}function Ee(e){let t=[];if(e==null)return{theme:{},problems:t};if(typeof e!=`object`||Array.isArray(e))return{theme:{},problems:[]};let n=e,r=W(n,`theme`,t);if(n.radius!==void 0&&U(n.radius)&&(r.radius=n.radius.trim()),n.fontSize!==void 0&&U(n.fontSize)&&(r.fontSize=n.fontSize.trim()),n.font!==void 0&&Te(n.font)&&(r.font=n.font.trim()),n.dark!==void 0){let e=W(n.dark,`theme.dark`,t);Object.keys(e).length&&(r.dark=e)}return{theme:r,problems:t}}function De(e){let t={};for(let n of V)e[n]&&(t[`--hp-${H(n)}`]=e[n]),e.dark?.[n]&&(t[`--hp-dark-${H(n)}`]=e.dark[n]);return e.radius&&(t[`--hp-radius`]=e.radius),e.font&&(t[`--hp-font`]=e.font),e.fontSize&&(t[`--hp-font-size`]=e.fontSize),t}var Oe=`/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
|
|
2
|
+
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-leading:initial;--tw-font-weight:initial}}}@layer theme{:root,:host{--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-semibold:600;--leading-snug:1.375;--radius-lg:.5rem;--color-hp-accent:var(--hp-accent,#087ea4);--color-hp-accent-fg:var(--hp-accent-fg,#fff);--color-hp-bg:var(--hp-bg,#fff);--color-hp-fg:var(--hp-fg,#172b3a);--color-hp-muted:var(--hp-muted,#334155);--color-hp-border:var(--hp-border,#64748b);--color-hp-warn-bg:var(--hp-warn-bg,#fef3c7);--color-hp-warn-bd:var(--hp-warn-border,#92400e);--color-hp-err-bg:var(--hp-err-bg,#fee2e2);--color-hp-err-bd:var(--hp-err-border,#b91c1c);--color-hp-focus:var(--hp-focus,#1e3a8a);--color-hp-halo:var(--hp-halo,#fff);--color-hp-ring:var(--hp-ring,#f59e0b);--color-hp-dim:var(--hp-dim,#09141e8c);--radius-hp:var(--hp-radius,12px)}}@layer utilities;:host{all:revert;pointer-events:none;font-family:var(--hp-font,system-ui, sans-serif);font-size:var(--hp-font-size,14px);color:var(--color-hp-fg);--tw-border-style:solid;--tw-outline-style:solid;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-inset-shadow:0 0 #0000;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;line-height:1.45}@media (prefers-color-scheme:dark){:host(:not([data-scheme=light])){--color-hp-accent:var(--hp-dark-accent,var(--hp-accent,#38bdf8));--color-hp-accent-fg:var(--hp-dark-accent-fg,var(--hp-accent-fg,#082f49));--color-hp-bg:var(--hp-dark-bg,#0f172a);--color-hp-fg:var(--hp-dark-fg,#f1f5f9);--color-hp-muted:var(--hp-dark-muted,#cbd5e1);--color-hp-border:var(--hp-dark-border,#94a3b8);--color-hp-warn-bg:var(--hp-dark-warn-bg,#422006);--color-hp-warn-bd:var(--hp-dark-warn-border,#fbbf24);--color-hp-err-bg:var(--hp-dark-err-bg,#450a0a);--color-hp-err-bd:var(--hp-dark-err-border,#f87171);--color-hp-focus:var(--hp-dark-focus,#fff);--color-hp-halo:var(--hp-dark-halo,#1e3a8a);--color-hp-ring:var(--hp-dark-ring,var(--hp-ring,#f59e0b));--color-hp-dim:var(--hp-dark-dim,var(--hp-dim,#09141e8c))}}:host([data-scheme=dark]){--color-hp-accent:var(--hp-dark-accent,var(--hp-accent,#38bdf8));--color-hp-accent-fg:var(--hp-dark-accent-fg,var(--hp-accent-fg,#082f49));--color-hp-bg:var(--hp-dark-bg,#0f172a);--color-hp-fg:var(--hp-dark-fg,#f1f5f9);--color-hp-muted:var(--hp-dark-muted,#cbd5e1);--color-hp-border:var(--hp-dark-border,#94a3b8);--color-hp-warn-bg:var(--hp-dark-warn-bg,#422006);--color-hp-warn-bd:var(--hp-dark-warn-border,#fbbf24);--color-hp-err-bg:var(--hp-dark-err-bg,#450a0a);--color-hp-err-bd:var(--hp-dark-err-border,#f87171);--color-hp-focus:var(--hp-dark-focus,#fff);--color-hp-halo:var(--hp-dark-halo,#1e3a8a);--color-hp-ring:var(--hp-dark-ring,var(--hp-ring,#f59e0b));--color-hp-dim:var(--hp-dark-dim,var(--hp-dim,#09141e8c))}@layer base{*,:before,:after{box-sizing:border-box}}@layer components{.hp-launcher{z-index:2147483646;bottom:calc(var(--spacing) * 4);min-height:calc(var(--spacing) * 10);cursor:pointer;border-style:var(--tw-border-style);background-color:var(--color-hp-accent);padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 2.5);color:var(--color-hp-accent-fg);--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);pointer-events:auto;font:inherit;border-width:0;border-radius:2147483647px;position:fixed;inset-inline-end:16px}.hp-launcher[hidden]{display:none}.hp-panel{z-index:2147483646;bottom:calc(var(--spacing) * 18);border-radius:var(--radius-hp);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-hp-border);background-color:var(--color-hp-bg);padding:calc(var(--spacing) * 4);color:var(--color-hp-fg);text-align:start;pointer-events:auto;width:min(360px,100vw - 32px);max-height:min(70dvh,32rem);position:fixed;inset-inline-end:16px;overflow:auto;box-shadow:0 8px 30px #0004}.hp-panel[hidden],.hp-spotlight[hidden],.hp-tour-arrow[hidden]{display:none}:host([data-launcher-side=start]) .hp-launcher{inset-inline:16px auto}@media (min-width:601px){:host([data-launcher-side=start]) .hp-panel:not(.hp-tour){inset-inline:16px auto}}.hp-spotlight{z-index:2147483644;background-color:var(--color-hp-dim);pointer-events:none;width:100vw;height:100dvh;position:fixed;top:0;left:0}.hp-highlight{z-index:2147483645;border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:3px;border-color:var(--color-hp-ring);outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-hp-focus);pointer-events:none;transition:all .2s;position:fixed}.hp-panel.hp-tour{border-style:var(--tw-border-style);width:auto;padding:calc(var(--spacing) * 5);inset-inline-end:auto;border-width:0;border-radius:14px;width:min(400px,100vw - 24px);max-height:calc(100dvh - 24px);bottom:auto;box-shadow:0 10px 36px #0005}.hp-tour-head{justify-content:space-between;align-items:flex-start;gap:calc(var(--spacing) * 3);display:flex}.hp-tour h2{margin:0;margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height));--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.hp-tour p{margin:0;margin-bottom:calc(var(--spacing) * 4.5);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.hp-tour .hp-progress,.hp-tour-count{margin:0;margin-bottom:calc(var(--spacing) * 1.75);white-space:nowrap;font-size:13px}.hp-tour .hp-close{margin-top:calc(var(--spacing) * -2);min-height:calc(var(--spacing) * 9);min-width:calc(var(--spacing) * 9);font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height));margin-inline-end:-8px}.hp-tour .hp-row{margin-top:calc(var(--spacing) * 4);flex-wrap:nowrap;justify-content:space-between;align-items:center}.hp-tour .hp-primary{min-height:calc(var(--spacing) * 10);padding-inline:calc(var(--spacing) * 5);padding-block:calc(var(--spacing) * 2);--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);border-radius:2147483647px}.hp-tour .hp-skip{cursor:pointer;border-style:var(--tw-border-style);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-hp-accent);background-color:#0000;border-width:0}.hp-tour .hp-back{cursor:pointer;border-style:var(--tw-border-style);padding-inline:0;padding-block:calc(var(--spacing) * 2);color:var(--color-hp-fg);background-color:#0000;border-width:0}.hp-tour .hp-evidence{margin-top:calc(var(--spacing) * 3)}.hp-tour .hp-warn{margin-block:calc(var(--spacing) * 3);font-size:13px}.hp-released h2,.hp-released>p:not(.hp-released-note){color:var(--color-hp-muted)}.hp-released .hp-released-note{margin:0;margin-bottom:calc(var(--spacing) * 3);--tw-font-weight:var(--font-weight-semibold);font-size:13px;font-weight:var(--font-weight-semibold);color:var(--color-hp-fg)}.hp-tour-tools{margin-bottom:calc(var(--spacing) * 3);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-hp-muted)}.hp-tour-tools summary{cursor:pointer;padding-block:var(--spacing)}.hp-goal-compact{margin-top:calc(var(--spacing) * 2);margin-bottom:0}.hp-goal-compact .hp-row{flex-wrap:nowrap;margin-top:0}.hp-goal-compact input[type=text]{height:calc(var(--spacing) * 8);min-height:calc(var(--spacing) * 8);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.hp-goal-compact button{min-height:calc(var(--spacing) * 8);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.hp-tour.hp-floating{width:auto;inset:auto 12px 12px!important}.hp-tour-arrow{z-index:2147483645;width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4);background-color:var(--color-hp-bg);pointer-events:none;position:fixed;rotate:45deg}.hp-tour[data-placement=below]+.hp-tour-arrow{clip-path:polygon(0 0,100% 0,0 100%)}.hp-tour[data-placement=above]+.hp-tour-arrow{clip-path:polygon(100% 0,100% 100%,0 100%)}.hp-tour[data-placement=left]+.hp-tour-arrow,.hp-tour[data-placement=right]+.hp-tour-arrow{display:none}.hp-row{margin-top:calc(var(--spacing) * 2);gap:calc(var(--spacing) * 2);flex-wrap:wrap;display:flex}.hp-row>input[type=text]{flex:1;min-width:0}button,input[type=text]{min-height:calc(var(--spacing) * 9);border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-hp-border);background-color:var(--color-hp-bg);padding-inline:calc(var(--spacing) * 2.5);padding-block:calc(var(--spacing) * 1.5);color:var(--color-hp-fg);font:inherit}button.hp-primary{border-color:var(--color-hp-accent);background-color:var(--color-hp-accent);color:var(--color-hp-accent-fg)}button[aria-disabled=true],button:disabled{cursor:not-allowed;opacity:.55}button:focus-visible,input:focus-visible,.hp-launcher:focus-visible,h2:focus-visible,summary:focus-visible{outline-style:var(--tw-outline-style);outline-offset:2px;outline-width:2px;outline-color:var(--color-hp-focus);box-shadow:0 0 0 4px var(--color-hp-halo)}h2:focus{outline:none}h2{margin:0;margin-bottom:var(--spacing);font-size:15px}.hp-assist{margin-top:calc(var(--spacing) * 2);cursor:pointer;align-items:center;gap:calc(var(--spacing) * 2.5);color:var(--color-hp-fg);min-height:44px;font-size:13px;display:flex}.hp-assist input{width:calc(var(--spacing) * 5);height:calc(var(--spacing) * 5);cursor:pointer;accent-color:var(--color-hp-accent);flex-shrink:0;min-height:0;margin:0}.hp-assist-note{margin:0;margin-bottom:calc(var(--spacing) * 2);color:var(--color-hp-muted);font-size:13px}.hp-assist-note.hp-alert{color:var(--color-hp-fg)}.hp-assist-hint{margin:0;margin-bottom:calc(var(--spacing) * 3);color:var(--color-hp-muted);font-size:13px}.hp-assist-hint[hidden]{display:none}.hp-warn{margin-top:calc(var(--spacing) * 2);border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-hp-warn-bd);background-color:var(--color-hp-warn-bg);padding:calc(var(--spacing) * 2)}.hp-alert{margin-top:calc(var(--spacing) * 2);border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-hp-err-bd);background-color:var(--color-hp-err-bg);padding:calc(var(--spacing) * 2)}.hp-suggest{margin-top:calc(var(--spacing) * 3);align-items:stretch;gap:calc(var(--spacing) * 2);flex-direction:column;display:flex}.hp-suggest-label{--tw-font-weight:var(--font-weight-semibold);font-size:13px;font-weight:var(--font-weight-semibold);color:var(--color-hp-muted);margin:0}.hp-suggestion{cursor:pointer;text-align:start;overflow-wrap:anywhere}.hp-evidence{margin-top:calc(var(--spacing) * 2);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-hp-muted)}.hp-evidence summary{cursor:pointer}.hp-head{justify-content:space-between;align-items:center;gap:calc(var(--spacing) * 2);display:flex}.hp-close{cursor:pointer;border-style:var(--tw-border-style);padding-inline:calc(var(--spacing) * 2.5);padding-block:var(--spacing);--tw-leading:1;color:var(--color-hp-fg);background-color:#0000;border-width:0;font-size:22px;line-height:1}.hp-progress{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-hp-muted)}.hp-sr-only{white-space:nowrap;clip:rect(0 0 0 0);width:1px;height:1px;position:absolute;overflow:hidden}@media (pointer:coarse){button,input[type=text],.hp-launcher{min-height:44px}}@media (max-width:600px){.hp-panel:not(.hp-tour){border-radius:var(--radius-hp) var(--radius-hp) 0 0;width:100%;max-height:75dvh;bottom:0;left:0;right:0}.hp-tour h2{font-size:15px}.hp-tour{padding:calc(var(--spacing) * 4)}}@media (prefers-reduced-motion:reduce){.hp-highlight{transition:none}}}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}`,ke=/\b(send|submit|delete|remove|pay|purchase|buy|transfer|publish|revoke|deploy)\b/i,G=e=>e.requiresConfirmation||e.action===`click`&&[e.target.text,e.target.label,e.title,e.instruction].some(e=>ke.test(e??``)),Ae=`button, a, label, summary, [role="button"], [role="link"], [role="checkbox"], [role="menuitem"], [role="tab"]`,je=`heypointer:assist`,Me=`heypointer:open`,Ne=`heypointer:close`;function Pe(e=80,t=600){return new Promise(n=>{let r,i=()=>{a.disconnect(),clearTimeout(r),clearTimeout(o),n()},a=new MutationObserver(()=>{clearTimeout(r),r=setTimeout(i,e)});a.observe(document,{childList:!0,subtree:!0}),r=setTimeout(i,e);let o=setTimeout(i,t)})}var K=(e,t)=>(e.setAttribute(`part`,t),e),q=class{constructor(e){h(this,`opts`,void 0),h(this,`host`,void 0),h(this,`root`,void 0),h(this,`client`,void 0),h(this,`hl`,void 0),h(this,`spotlight`,void 0),h(this,`arrow`,void 0),h(this,`panel`,void 0),h(this,`launcher`,void 0),h(this,`live`,void 0),h(this,`view`,{kind:`idle`}),h(this,`wt`,null),h(this,`index`,0),h(this,`confirmed`,new Set),h(this,`missing`,!1),h(this,`ambiguous`,!1),h(this,`recorder`,null),h(this,`recording`,!1),h(this,`notice`,``),h(this,`noticeAlert`,!1),h(this,`goalToolsOpen`,!1),h(this,`lastGoal`,``),h(this,`focusTitle`,!1),h(this,`target`,null),h(this,`targetOffset`,{x:0,y:0}),h(this,`renderToken`,0),h(this,`micOk`,void 0),h(this,`assist`,void 0),h(this,`userActed`,!1),h(this,`assisting`,!1),h(this,`assisted`,new Set),h(this,`assistNote`,null),h(this,`hintEl`,null),h(this,`released`,!1),h(this,`stopWatch`,void 0),h(this,`anchor`,null),h(this,`onDocClick`,e=>this.noteClick(e)),h(this,`L`,void 0),h(this,`theme`,{}),h(this,`themeProps`,[]),h(this,`cfg`,void 0),h(this,`opener`,null),this.opts=e;let t=s(e.labels);t.problems,this.L=t.labels,this.cfg={dir:e.dir===`ltr`||e.dir===`rtl`?e.dir:`auto`,lang:typeof e.lang==`string`?e.lang.trim().slice(0,35):``,scheme:B.includes(e.colorScheme)?e.colorScheme:`auto`,launcher:e.launcher===`none`?`none`:`default`,side:e.launcherSide===`start`?`start`:`end`},this.client=new oe({baseUrl:e.baseUrl,clientId:e.clientId,fetch:e.fetch,text:(e,t)=>this.t(e,t)}),this.micOk=e.speechSupported??b(),this.assist=!!e.assist,document.addEventListener(`click`,this.onDocClick,!0),this.host=document.createElement(`div`),this.host.setAttribute(`data-heypointer-root`,``),this.host.style.pointerEvents=`none`,this.root=this.host.attachShadow({mode:`open`});let n=document.createElement(`style`);n.textContent=Oe,this.root.appendChild(n),this.hl=new y(this.root),this.spotlight=new F(this.root),this.arrow=document.createElement(`div`),this.arrow.className=`hp-tour-arrow`,this.arrow.setAttribute(`part`,`arrow`),this.arrow.hidden=!0,this.arrow.setAttribute(`aria-hidden`,`true`),this.launcher=document.createElement(`button`),this.launcher.className=`hp-launcher`,this.launcher.textContent=this.t(`launcher`),this.launcher.setAttribute(`part`,`launcher`),this.launcher.setAttribute(`aria-expanded`,`false`),this.launcher.addEventListener(`click`,()=>this.panel.hidden?this.open():this.close()),this.panel=document.createElement(`section`),this.panel.className=`hp-panel`,this.panel.setAttribute(`role`,`dialog`),this.panel.setAttribute(`aria-label`,this.t(`dialogName`)),this.panel.setAttribute(`part`,`panel`),this.panel.hidden=!0,this.panel.addEventListener(`keydown`,e=>{e.key===`Escape`&&this.close()}),this.live=document.createElement(`div`),this.live.setAttribute(`aria-live`,`polite`),this.live.setAttribute(`role`,`status`),Object.assign(this.live.style,{position:`absolute`,width:`1px`,height:`1px`,overflow:`hidden`,clip:`rect(0 0 0 0)`}),this.root.append(this.launcher,this.panel,this.arrow,this.live),this.applyLayout(),e.theme!==void 0&&this.setTheme(e.theme),(e.mountTo??document.body).appendChild(this.host),this.render(),he(e)&&this.startAuthor()}async startAuthor(){try{(await ge())?.startAuthoring({labels:this.opts.labels,theme:this.opts.theme,colorScheme:this.cfg.scheme,dir:this.cfg.dir,lang:this.cfg.lang})}catch{}}t(e,t){return o(this.L[e],t)}setLabels(e){let t=s(e);t.problems,this.L=t.labels,this.launcher.textContent=this.t(`launcher`),this.panel.setAttribute(`aria-label`,this.t(`dialogName`)),this.render()}setTheme(e){let t=Ee(e);this.theme=t.theme;for(let e of this.themeProps)this.host.style.removeProperty(e);let n=De(t.theme);for(let[e,t]of Object.entries(n))this.host.style.setProperty(e,t);this.themeProps=Object.keys(n)}setColorScheme(e){this.cfg.scheme=B.includes(e)?e:`auto`,this.applyLayout(),this.setTheme(this.theme)}setLayout(e){e.dir!==void 0&&(this.cfg.dir=e.dir===`ltr`||e.dir===`rtl`?e.dir:`auto`),e.lang!==void 0&&(this.cfg.lang=e.lang.trim().slice(0,35)),e.launcher!==void 0&&(this.cfg.launcher=e.launcher===`none`?`none`:`default`),e.launcherSide!==void 0&&(this.cfg.side=e.launcherSide===`start`?`start`:`end`),this.applyLayout(),this.syncTour()}applyLayout(){let e=(e,t)=>t===null?this.host.removeAttribute(e):this.host.setAttribute(e,t);e(`dir`,this.cfg.dir===`auto`?null:this.cfg.dir),e(`lang`,this.cfg.lang||null),e(`data-scheme`,this.cfg.scheme===`auto`?null:this.cfg.scheme),e(`data-launcher`,this.cfg.launcher===`none`?`none`:null),e(`data-launcher-side`,this.cfg.side===`start`?`start`:null),this.launcher.hidden=this.cfg.launcher===`none`}isRtl(){try{return getComputedStyle(this.host).direction===`rtl`}catch{return!1}}emit(e){this.host.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0}))}currentOpener(){let e=document.activeElement;return e instanceof HTMLElement&&e!==document.body&&e!==this.host&&!this.host.contains(e)?e:null}open(){let e=!this.panel.hidden;e||(this.opener=this.currentOpener()),this.panel.hidden=!1,this.launcher.setAttribute(`aria-expanded`,`true`),this.syncTour(),this.focusFirst(),e||this.emit(Me)}close(){let e=!this.panel.hidden;this.panel.hidden=!0,this.launcher.setAttribute(`aria-expanded`,`false`),this.hl.hide(),this.spotlight.hide(),this.arrow.hidden=!0,this.stopWatching();let t=this.opener?.isConnected?this.opener:null;this.opener=null,t?t.focus():this.launcher.hidden||this.launcher.focus(),e&&this.emit(Ne)}destroy(){document.removeEventListener(`click`,this.onDocClick,!0),this.stopWatching(),this.hl.hide(),this.spotlight.hide(),this.host.remove()}async ask(e){let t=e.trim();if(!t)return this.notice=this.t(`emptyGoal`),this.render();this.notice=``,this.noticeAlert=!1,this.lastGoal=t,this.focusTitle=!0,this.hl.hide(),this.view={kind:`loading`},this.render();try{let e=await this.client.requestWalkthrough(t,{url:location.href});this.wt=e,this.index=0,this.confirmed.clear(),this.assisted.clear(),this.userActed=!1,this.assistNote=null,this.view=e.status===`ok`?{kind:`step`}:{kind:`insufficient`,wt:e}}catch(e){this.view={kind:`error`,message:e instanceof Error?e.message:this.t(`genericError`)}}await this.render()}async next(){let e=this.step();if(!this.wt||!e||G(e)&&!this.confirmed.has(e.id))return;let t=this.attemptAssist(e);this.assistNote=null,t&&`failed`in t?(this.assistNote={text:this.t(`assistFailed`,{label:t.failed}),alert:!0},await this.render()):(t&&await Pe(),this.index>=this.wt.steps.length-1?(this.hl.hide(),this.view={kind:`done`}):this.index++,this.userActed=!1,t&&(this.assistNote={text:this.t(`assistClicked`,{label:t.label}),alert:!1}),this.focusTitle=!0,await this.render())}async prev(){this.index>0&&(this.index--,this.userActed=!1,this.assistNote=null,this.view={kind:`step`},this.focusTitle=!0,await this.render())}async skip(){this.wt&&this.step()&&(this.userActed=!1,this.assistNote=null,this.index>=this.wt.steps.length-1?(this.hl.hide(),this.view={kind:`done`}):this.index++,this.focusTitle=!0,await this.render())}async confirm(){let e=this.step();e&&this.confirmed.add(e.id),await this.render()}async retry(){await this.render()}state(){return{view:this.view.kind,index:this.index,missing:this.missing,ambiguous:this.ambiguous,wt:this.wt}}assistBlock(e){if(this.host.contains(e)||e.getRootNode()===this.root)return`guide`;if(e.closest(`[inert]`))return`inert`;if(e.getAttribute(`aria-disabled`)===`true`||e.closest(`[aria-disabled="true"]`))return`disabled`;try{if(e.matches(`:disabled`))return`disabled`}catch{}if(e instanceof HTMLInputElement&&e.type===`file`)return`file`;let t=e.closest(`a`);if(t){if(t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return`link`;let e=t.getAttribute(`href`);if(e!==null)try{let t=new URL(e,location.href);if(t.protocol!==`http:`&&t.protocol!==`https:`||t.origin!==location.origin)return`link`}catch{return`link`}}return null}attemptAssist(e){if(!this.assist||this.released||this.userActed||this.assisted.has(this.index)||e.action!==`click`||G(e))return null;let t=e.target;if(!t.selectors.length&&!t.text&&!t.label)return null;let n=D(t,document);if(n.status!==`found`)return null;let r=n.element;if(this.target?.isConnected&&r!==this.target||this.assistBlock(r))return null;let i=(S(r).replace(/\s+/g,` `).trim()||t.text||t.label||e.title).slice(0,80);this.assisted.add(this.index),this.assisting=!0;try{r.click()}catch{return{failed:i}}finally{this.assisting=!1}let a={stepIndex:this.index,action:`click`,label:i};try{this.opts.onAssist?.(a)}catch{}return this.host.dispatchEvent(new CustomEvent(je,{detail:a,bubbles:!0,composed:!0})),{label:i}}noteClick(e){if(this.assisting||!this.target||this.view.kind!==`step`)return;let t=e.composedPath();if(t.includes(this.host))return;if(t.includes(this.target)){this.userActed=!0;return}let n=t[0];n instanceof Element&&n.contains(this.target)&&n.matches(Ae)&&(this.userActed=!0)}step(){return this.view.kind===`step`?this.wt?.steps[this.index]:void 0}async toggleRecording(){if(!this.recording){try{this.recorder??(this.recorder=(this.opts.recorderFactory??(()=>new se))()),await this.recorder.start(),this.recording=!0,this.notice=this.t(`recording`)}catch{this.recorder=null,this.notice=this.t(`voiceUnavailable`)}return this.render()}this.recording=!1,this.noticeAlert=!1;try{let e=await this.recorder.stop();this.notice=this.t(`transcribing`),await this.render();let t=await this.client.transcribe(e);this.notice=``,await this.ask(t)}catch(e){if(e instanceof _){this.notice=this.t(`noSpeech`),this.noticeAlert=!0,await this.render(),this.panel.querySelector(`[data-autofocus]`)?.focus();return}this.notice=e instanceof g?this.t(`voiceUnavailable`):this.t(`audioFailed`),await this.render()}}focusFirst(){(this.panel.querySelector(`[data-autofocus]`)??this.panel.querySelector(`button, input`))?.focus()}el(e,t={},n){let r=document.createElement(e);return Object.assign(r,t),n!==void 0&&(r.textContent=n),r}async render(){let e=++this.renderToken;this.stopWatching(),this.released=!1;let t=this.root.activeElement?.getAttribute(`data-key`),n=this.panel,r=this.view.kind===`step`;this.spotlight.hide(),n.className=r?`hp-panel hp-tour`:`hp-panel`,n.setAttribute(`part`,r?`panel card`:`panel`),n.removeAttribute(`data-placement`),n.style.left=``,n.style.top=``,n.replaceChildren(),this.target=null,this.arrow.hidden=!0,this.missing=!1,this.ambiguous=!1;let i=this.el(`div`,{className:r?`hp-tour-head`:`hp-head`});r||i.append(K(this.el(`h2`,{},this.t(`heading`)),`title`)),r&&i.append(K(this.el(`div`,{className:`hp-tour-count`},this.t(`tourCount`,{current:this.index+1,total:this.wt.steps.length})),`progress`));let a=K(this.el(`button`,{type:`button`,className:`hp-close`},`×`),`button close`);if(a.setAttribute(`aria-label`,this.t(`closeLabel`)),a.setAttribute(`data-key`,`close`),a.addEventListener(`click`,()=>this.close()),i.append(a),n.append(i),n.append(this.goalForm(r)),r){let e=this.el(`details`,{className:`hp-tour-tools`,open:this.goalToolsOpen||this.recording||!!this.notice});K(e,`tools`),e.append(this.el(`summary`,{},this.t(`changeGoal`))),e.addEventListener(`toggle`,()=>{this.goalToolsOpen=e.open}),e.append(n.querySelector(`form`)),n.append(e)}this.notice&&n.append(K(this.el(`p`,{role:this.noticeAlert?`alert`:`status`},this.notice),this.noticeAlert?`alert`:`text`)),this.assistNote&&n.append(this.assistNote.alert?K(this.el(`p`,{className:`hp-assist-note hp-alert`,role:`alert`},this.assistNote.text),`alert`):K(this.el(`p`,{className:`hp-assist-note`},this.assistNote.text),`hint`));let o=this.view;if(o.kind===`loading`&&n.append(K(this.el(`p`,{},this.t(`loading`)),`text`)),o.kind===`error`){let e=this.alert(o.message),t=K(this.el(`button`,{type:`button`},this.t(`tryAgain`)),`button button-secondary`);t.addEventListener(`click`,()=>void this.ask(this.lastGoal)),e.append(t),n.append(e)}if(o.kind===`insufficient`&&this.renderInsufficient(o.wt),o.kind===`done`){let e=this.wt?.goal??this.lastGoal,t=K(this.el(`p`,{},this.t(`done`,{goal:e})),`text`);t.tabIndex=-1;let r=K(this.el(`button`,{type:`button`},this.t(`startAnother`)),`button button-secondary`);r.addEventListener(`click`,()=>{this.view={kind:`idle`},this.wt=null,this.render().then(()=>this.focusFirst())}),n.append(t,r),this.announce(this.t(`done`,{goal:e})),this.focusTitle&&t.focus(),this.focusTitle=!1}if(o.kind===`step`){let t=this.step();this.renderStep(t),await this.locate(t,e)}r&&!this.panel.hidden?this.spotlight.show(this.target,()=>this.positionTour()):this.spotlight.hide(),o.kind===`step`&&this.watch(),t&&this.panel.querySelector(`[data-key="${t}"]`)?.focus({preventScroll:!0})}syncTour(){if(this.view.kind!==`step`)return this.spotlight.hide();this.released?this.reengage():this.spotlight.show(this.target,()=>this.positionTour()),this.watch()}stopWatching(){this.stopWatch?.(),this.stopWatch=void 0}watch(){this.stopWatching();let e=this.target;e&&this.view.kind===`step`&&(this.stopWatch=N(e,e=>e?this.reengage():this.release()))}release(){let e=this.step(),t=this.target;if(!e||!t||this.released)return;let n=D(e.target,document);if(n.status===`found`&&n.element!==t&&this.anchor?.isConnected&&this.anchor.contains(n.element))return this.rebind(n.element);this.released=!0,this.hl.hide(),this.spotlight.hide(),this.arrow.hidden=!0,this.panel.classList.add(`hp-released`,`hp-floating`),this.panel.removeAttribute(`data-placement`);let r=K(this.el(`p`,{className:`hp-released-note`},this.t(`releasedNote`)),`hint`);this.hintEl?this.hintEl.after(r):this.panel.append(r),this.announce(this.t(`releasedNote`))}reengage(){if(!this.released||!this.target)return;this.released=!1,this.panel.classList.remove(`hp-released`),this.panel.querySelector(`.hp-released-note`)?.remove();let e=this.step();e&&(!G(e)||this.confirmed.has(e.id))&&this.hl.show(this.target),this.spotlight.show(this.target,()=>this.positionTour())}rebind(e){this.target=e,this.targetOffset=v(e),this.anchor=e.parentElement;let t=this.step();t&&(!G(t)||this.confirmed.has(t.id))&&this.hl.show(e),this.spotlight.show(e,()=>this.positionTour()),this.watch()}positionTour(){if(this.panel.hidden||this.view.kind!==`step`)return;if(!this.target){this.panel.classList.add(`hp-floating`),this.panel.removeAttribute(`data-placement`),this.arrow.hidden=!0;return}let e=this.target.getBoundingClientRect(),t={left:e.left+this.targetOffset.x,top:e.top+this.targetOffset.y,right:e.right+this.targetOffset.x,bottom:e.bottom+this.targetOffset.y};this.panel.classList.remove(`hp-floating`),this.panel.style.left=`12px`,this.panel.style.top=`12px`;let n=this.panel.getBoundingClientRect(),r=P(t,n,{width:innerWidth,height:innerHeight},void 0,this.isRtl());this.panel.style.left=`${r.left}px`,this.panel.style.top=`${r.top}px`,this.panel.dataset.placement=r.placement,this.arrow.hidden=r.placement===`floating`||r.placement===`left`||r.placement===`right`,this.arrow.hidden||(this.arrow.style.left=`${r.left+r.arrowLeft-8}px`,this.arrow.style.top=`${r.placement===`below`?r.top-8:r.top+n.height-8}px`)}goalForm(e=!1){let t=this.el(`form`);e&&(t.className=`hp-goal-compact`);let n=this.el(`label`,{className:e?`hp-sr-only`:``},this.t(`goalQuestion`)),r=this.el(`input`,{type:`text`,name:`goal`,autocomplete:`off`});r.setAttribute(`data-autofocus`,``),r.setAttribute(`data-key`,`goal`),r.setAttribute(`aria-label`,this.t(`goalAria`)),r.setAttribute(`part`,`goal-input`),r.placeholder=this.t(`goalPlaceholder`),(this.view.kind===`step`||this.view.kind===`done`)&&(r.value=this.wt?.goal??``);let i=K(this.el(`button`,{type:`submit`,className:`hp-primary`},this.t(`submit`)),`button button-primary`),a=this.el(`div`,{className:`hp-row`});if(a.append(r,i),this.micOk){let e=K(this.el(`button`,{type:`button`},this.recording?this.t(`stop`):this.t(`speak`)),`button button-secondary`);e.setAttribute(`aria-pressed`,String(this.recording)),e.setAttribute(`data-key`,`mic`),e.addEventListener(`click`,()=>void this.toggleRecording()),a.append(e)}let o=K(this.el(`label`,{className:`hp-assist`}),`toggle`),s=this.el(`input`,{type:`checkbox`,checked:this.assist});return s.setAttribute(`data-key`,`assist`),s.addEventListener(`change`,()=>{this.assist=s.checked,this.render()}),o.append(s,this.el(`span`,{},this.t(`assistToggle`))),t.append(n,a,o),t.addEventListener(`submit`,e=>{e.preventDefault(),this.ask(r.value)}),t}alert(e){return K(this.el(`div`,{className:`hp-alert`,role:`alert`},e),`alert`)}renderInsufficient(e){let t=this.alert(e.message??this.t(`insufficient`));if(e.missingEvidence?.length){let n=this.el(`ul`);e.missingEvidence.forEach(e=>n.append(this.el(`li`,{},e))),t.append(n)}this.panel.append(t);let n=e.suggestions??[];if(!n.length)return;let r=K(this.el(`div`,{className:`hp-suggest`}),`suggestions`);r.setAttribute(`role`,`group`),r.setAttribute(`aria-labelledby`,`hp-suggest-label`),r.append(this.el(`p`,{id:`hp-suggest-label`,className:`hp-suggest-label`},this.t(`suggestLabel`))),n.forEach((e,t)=>{let n=K(this.el(`button`,{type:`button`,className:`hp-suggestion`},e.title),`button button-secondary suggestion`);n.setAttribute(`data-key`,`suggest-${t}`),n.addEventListener(`click`,()=>void this.ask(e.title)),r.append(n)}),this.panel.append(r),this.announce(this.t(`suggestAnnounce`,{list:n.map(e=>e.title).join(`; `)}))}renderStep(e){let t=this.wt.steps.length,n=this.panel;n.append(K(this.el(`span`,{className:`hp-progress hp-sr-only`},this.t(`stepProgress`,{current:this.index+1,total:t})),`progress`));let r=K(this.el(`h2`,{},e.title),`title`);r.setAttribute(`data-key`,`title`),r.tabIndex=-1,this.focusTitle&&queueMicrotask(()=>r.focus({preventScroll:!0})),this.focusTitle=!1,n.append(r,K(this.el(`p`,{},e.instruction),`text`)),e.value&&n.append(K(this.el(`p`,{},this.t(`suggestedValue`,{value:e.value})),`text`)),this.hintEl=K(this.el(`p`,{className:`hp-assist-hint`},this.t(`assistHint`)),`hint`),this.hintEl.hidden=!this.assist||!!G(e)||e.action!==`type`&&e.action!==`select`&&e.action!==`navigate`,n.append(this.hintEl);let i=G(e),a=this.confirmed.has(e.id);if(i){let e=K(this.el(`div`,{className:`hp-warn`}),`warning`);e.append(this.el(`strong`,{},this.t(`gateWarning`)));let t=this.el(`label`),r=this.el(`input`,{type:`checkbox`,checked:a});r.setAttribute(`data-key`,`confirm`),r.addEventListener(`change`,()=>void this.confirm()),t.append(r,` ${this.t(`gateCheckbox`)}`),e.append(this.el(`br`),t),n.append(e)}let o=this.el(`div`,{className:`hp-row`}),s=K(this.el(`button`,{type:`button`,className:`hp-back`,disabled:this.index===0},this.t(`back`)),`button button-secondary`);s.addEventListener(`click`,()=>void this.prev());let c=K(this.el(`button`,{type:`button`,className:`hp-skip`},this.t(`skip`)),`button button-secondary`);c.setAttribute(`data-key`,`skip`),c.addEventListener(`click`,()=>void this.skip());let l=this.index===t-1,u=i&&!a,d=K(this.el(`button`,{type:`button`,className:`hp-primary`},l?this.t(`finish`):this.t(`next`)),`button button-primary`);d.setAttribute(`data-key`,`next`),u&&(d.setAttribute(`aria-disabled`,`true`),d.setAttribute(`aria-describedby`,`hp-why`),o.append(this.el(`span`,{id:`hp-why`,hidden:!0},this.t(`gateWhy`)))),d.addEventListener(`click`,()=>void this.next());let f=K(this.el(`div`,{className:`hp-row`}),`actions`);if(f.append(c,d),o.append(s,f),n.append(o),e.evidence.length){let t=K(this.el(`details`,{className:`hp-evidence`}),`evidence`);t.append(this.el(`summary`,{},this.t(`evidenceSummary`,{count:e.evidence.length}))),e.evidence.forEach(e=>t.append(this.el(`div`,{},`${e.sourceType} · ${e.path}:${e.lineStart}${e.lineEnd===e.lineStart?``:`-`+e.lineEnd} — ${e.excerpt}`))),n.append(t)}this.announce(this.t(`stepAnnounce`,{current:this.index+1,total:t,title:e.title,instruction:e.instruction}))}async locate(e,t){this.hl.hide();let n=e.target;if(!(n.selectors.length>0||n.text||n.label))return;let r=await O(n,this.opts.targetTimeoutMs??1500,document);if(t!==this.renderToken)return;if(r.status===`found`){this.target=r.element,this.anchor=r.element.parentElement,this.targetOffset=v(r.element),(!G(e)||this.confirmed.has(e.id))&&this.hl.show(r.element),this.assist&&e.action===`click`&&!G(e)&&this.hintEl&&this.assistBlock(r.element)&&(this.hintEl.hidden=!1);return}this.missing=!0;let i=n.text??n.label??n.selectors[0],a=r.status===`ambiguous`;this.ambiguous=a;let o=this.alert(a?this.t(`ambiguous`,{label:i}):this.t(`notFound`,{label:i})),s=this.el(`div`,{className:`hp-row`}),c=K(this.el(`button`,{type:`button`},this.t(`tryAgain`)),`button button-secondary`);c.setAttribute(`data-key`,`retry`),c.addEventListener(`click`,()=>void this.retry());let l=K(this.el(`button`,{type:`button`},this.t(`skipStep`)),`button button-secondary`);l.setAttribute(`data-key`,`skip`),l.addEventListener(`click`,()=>void this.skip()),s.append(c,l),o.append(s),this.panel.append(o),this.announce(this.t(a?`ambiguousAnnounce`:`notFoundAnnounce`,{title:e.title}))}announce(e){let t=this.assistNote&&!this.assistNote.alert?`${this.assistNote.text} ${e}`:e;this.live.textContent=``,queueMicrotask(()=>this.live.textContent=t)}},J=`heypointer-assistant`,Y=typeof HTMLElement>`u`?class{}:HTMLElement,X=[`base-url`,`client-id`,`target-timeout-ms`,`assist`,`author`,`allow-author-param`],Fe=[`labels`,`theme`,`color-scheme`,`dir`,`lang`,`launcher`,`launcher-side`],Z=class extends Y{constructor(...e){super(...e),h(this,`gf`,null),h(this,`labelsProp`,void 0),h(this,`themeProp`,void 0)}get player(){return this.gf}get labels(){return this.labelsProp}set labels(e){this.labelsProp=typeof e==`string`?c(`labels`,e):e,this.gf?.setLabels(this.currentLabels())}get theme(){return this.themeProp}set theme(e){this.themeProp=typeof e==`string`?c(`theme`,e):e,this.gf?.setTheme(this.currentTheme())}setLabels(e){this.labels=e}open(){this.gf?.open()}close(){this.gf?.close()}ask(e){return this.gf?this.gf.ask(e):Promise.resolve()}connectedCallback(){this.style.display=`contents`,this.mount()}disconnectedCallback(){this.gf?.destroy(),this.gf=null}attributeChangedCallback(e,t,n){if(this.isConnected&&t!==n){if(X.includes(e)||!this.gf)return void this.mount();switch(e){case`labels`:this.gf.setLabels(this.currentLabels());break;case`theme`:this.gf.setTheme(this.currentTheme());break;case`color-scheme`:this.gf.setColorScheme(this.scheme());break;default:this.gf.setLayout(this.layout())}}}currentLabels(){return this.labelsProp??c(`labels`,this.getAttribute(`labels`))}currentTheme(){return this.themeProp??c(`theme`,this.getAttribute(`theme`))}scheme(){return this.getAttribute(`color-scheme`)??void 0}layout(){return{dir:this.getAttribute(`dir`)??`auto`,lang:this.getAttribute(`lang`)??``,launcher:this.getAttribute(`launcher`)===`none`?`none`:`default`,launcherSide:this.getAttribute(`launcher-side`)===`start`?`start`:`end`}}mount(){let e=this.getAttribute(`base-url`);if(this.gf?.destroy(),this.gf=null,!e)return;let t=Number(this.getAttribute(`target-timeout-ms`)),n=this.getAttribute(`client-id`)?.trim(),r=this.hasAttribute(`assist`)&&this.getAttribute(`assist`)!==`false`,i=e=>this.hasAttribute(e)&&this.getAttribute(e)!==`false`,a=this.layout(),o=this.currentLabels(),s=this.currentTheme(),c={baseUrl:e,...r?{assist:r}:{},...i(`author`)?{author:!0}:{},...i(`allow-author-param`)?{allowAuthorParam:!0}:{},...n?{clientId:n}:{},mountTo:this,...Number.isFinite(t)&&t>0?{targetTimeoutMs:t}:{},...o===void 0?{}:{labels:o},...s===void 0?{}:{theme:s},colorScheme:this.scheme(),dir:a.dir,lang:a.lang,launcher:a.launcher,launcherSide:a.launcherSide};this.gf=new q(c)}};h(Z,`observedAttributes`,[...X,...Fe]);function Ie(e=J){typeof customElements<`u`&&!customElements.get(e)&&customElements.define(e,Z)}Ie();var Q=document.currentScript;Q?.src&&z(Q.src);var $=Q?.dataset.baseUrl;if($&&!document.querySelector(`heypointer-assistant`)){let e=()=>{let e=document.createElement(J);e.setAttribute(`base-url`,$),Q?.dataset.clientId&&e.setAttribute(`client-id`,Q.dataset.clientId),Q?.dataset.assist!==void 0&&Q.dataset.assist!==`false`&&e.setAttribute(`assist`,``),Q?.dataset.author!==void 0&&Q.dataset.author!==`false`&&e.setAttribute(`author`,``),Q?.dataset.allowAuthorParam!==void 0&&Q.dataset.allowAuthorParam!==`false`&&e.setAttribute(`allow-author-param`,``),Q?.dataset.targetTimeoutMs&&e.setAttribute(`target-timeout-ms`,Q.dataset.targetTimeoutMs);let t=[[`labels`,Q?.dataset.labels],[`theme`,Q?.dataset.theme],[`color-scheme`,Q?.dataset.colorScheme],[`dir`,Q?.dataset.dir],[`lang`,Q?.dataset.lang],[`launcher`,Q?.dataset.launcher],[`launcher-side`,Q?.dataset.launcherSide]];for(let[n,r]of t)r&&e.setAttribute(n,r);document.body.appendChild(e)};document.body?e():document.addEventListener(`DOMContentLoaded`,e,{once:!0})}return e.HeyPointer=q,e})({});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Visual-only spotlight. Never intercepts pointer events, so the user performs the action themselves. */
|
|
2
|
+
/** Sum of frame-element offsets from the element's own document up to the top window. */
|
|
3
|
+
export declare function frameOffset(el: HTMLElement): {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
};
|
|
7
|
+
export declare class Highlighter {
|
|
8
|
+
private readonly host;
|
|
9
|
+
private box;
|
|
10
|
+
private target;
|
|
11
|
+
private offset;
|
|
12
|
+
private readonly onMove;
|
|
13
|
+
private frame;
|
|
14
|
+
private observer?;
|
|
15
|
+
constructor(host: ParentNode & Node);
|
|
16
|
+
show(el: HTMLElement): void;
|
|
17
|
+
hide(): void;
|
|
18
|
+
current(): HTMLElement | null;
|
|
19
|
+
private position;
|
|
20
|
+
private place;
|
|
21
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { HeyPointer, ASSIST_EVENT, OPEN_EVENT, CLOSE_EVENT, type HeyPointerOptions, type AssistEvent } from './player';
|
|
2
|
+
export { DEFAULT_LABELS, resolveLabels, type HeyPointerLabels, type LabelKey } from './labels';
|
|
3
|
+
export { sanitizeTheme, type HeyPointerTheme, type ColorScheme } from './theme';
|
|
4
|
+
export { HeyPointerElement, HEYPOINTER_TAG, defineHeyPointerElement } from './element';
|
|
5
|
+
export { HeyPointerClient, NoSpeechError, SpeechUnavailableError, CLIENT_ID_PATTERN } from './client';
|
|
6
|
+
export { resolveTarget, resolveDetailed, waitForTarget, waitForResolution } from './targeting/index';
|
|
7
|
+
export { parseWalkthrough } from './validate';
|
|
8
|
+
export type * from './types';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "./chunk-element.js";
|
|
2
|
+
import { c as f, d as p, l as m, m as h, n as g, o as _, s as v } from "./chunk-theme.js";
|
|
3
|
+
export { i as ASSIST_EVENT, t as CLIENT_ID_PATTERN, e as CLOSE_EVENT, p as DEFAULT_LABELS, u as HEYPOINTER_TAG, s as HeyPointer, a as HeyPointerClient, o as HeyPointerElement, d as NoSpeechError, l as OPEN_EVENT, n as SpeechUnavailableError, c as defineHeyPointerElement, r as parseWalkthrough, _ as resolveDetailed, h as resolveLabels, v as resolveTarget, g as sanitizeTheme, f as waitForResolution, m as waitForTarget };
|
package/dist/labels.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every string the guide shows or announces that does not come from the server.
|
|
3
|
+
* Hosts override any subset: `labels: { next: 'Continue' }`. Values are plain text with `{placeholder}`
|
|
4
|
+
* substitution and are only ever applied with textContent / setAttribute, never as HTML.
|
|
5
|
+
* Step titles, instructions and suggestions come from the knowledge base and are not translated here.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_LABELS: {
|
|
8
|
+
readonly launcher: "Guide me";
|
|
9
|
+
readonly dialogName: "HeyPointer assistant";
|
|
10
|
+
readonly heading: "HeyPointer";
|
|
11
|
+
readonly closeLabel: "Close guide";
|
|
12
|
+
readonly goalQuestion: "What do you want to do?";
|
|
13
|
+
readonly goalAria: "Your goal";
|
|
14
|
+
readonly goalPlaceholder: "e.g. invite a teammate";
|
|
15
|
+
readonly submit: "Show me";
|
|
16
|
+
readonly speak: "Speak";
|
|
17
|
+
readonly stop: "Stop";
|
|
18
|
+
readonly changeGoal: "Change goal or use voice";
|
|
19
|
+
readonly assistToggle: "Assist: do safe clicks for me when I press Next";
|
|
20
|
+
readonly assistHint: "You need to do this one yourself.";
|
|
21
|
+
readonly assistClicked: "Clicked \"{label}\" for you.";
|
|
22
|
+
readonly assistFailed: "I couldn't click \"{label}\" for you. Do this step yourself, then press Next.";
|
|
23
|
+
readonly releasedNote: "It looks like you did that. Press Next to continue.";
|
|
24
|
+
readonly next: "Next";
|
|
25
|
+
readonly finish: "Finish";
|
|
26
|
+
readonly back: "Back";
|
|
27
|
+
readonly skip: "Skip";
|
|
28
|
+
readonly stepProgress: "Step {current} of {total}";
|
|
29
|
+
readonly tourCount: "{current} / {total}";
|
|
30
|
+
readonly stepAnnounce: "Step {current} of {total}: {title}. {instruction}";
|
|
31
|
+
readonly suggestedValue: "Suggested value: {value}";
|
|
32
|
+
readonly gateWarning: "This changes data. Confirm before continuing.";
|
|
33
|
+
readonly gateCheckbox: "I understand and want to do this myself.";
|
|
34
|
+
readonly gateWhy: "Tick the confirmation box to continue.";
|
|
35
|
+
readonly evidenceSummary: "Source ({count})";
|
|
36
|
+
readonly loading: "Finding the steps…";
|
|
37
|
+
readonly tryAgain: "Try again";
|
|
38
|
+
readonly skipStep: "Skip step";
|
|
39
|
+
readonly done: "Done. You finished: {goal}";
|
|
40
|
+
readonly startAnother: "Start another";
|
|
41
|
+
readonly suggestLabel: "Did you mean:";
|
|
42
|
+
readonly suggestAnnounce: "Did you mean: {list}?";
|
|
43
|
+
readonly notFound: "I can't find \"{label}\" on this page. The screen may differ from the docs.";
|
|
44
|
+
readonly ambiguous: "I found more than one match for this step, so I won't guess. Look for: {label}.";
|
|
45
|
+
readonly notFoundAnnounce: "Cannot find the target for: {title}. You can try again or skip this step.";
|
|
46
|
+
readonly ambiguousAnnounce: "Several matches for: {title}. You can try again or skip this step.";
|
|
47
|
+
readonly emptyGoal: "Type what you want to do first.";
|
|
48
|
+
readonly recording: "Recording… press Stop when done.";
|
|
49
|
+
readonly transcribing: "Transcribing…";
|
|
50
|
+
readonly voiceUnavailable: "Voice isn't available. Type your goal instead.";
|
|
51
|
+
readonly noSpeech: "I didn't hear anything. Try again or type your goal.";
|
|
52
|
+
readonly audioFailed: "Could not process audio. Type your goal instead.";
|
|
53
|
+
readonly insufficient: "I don't have enough documented steps to guide this safely.";
|
|
54
|
+
readonly genericError: "Something went wrong.";
|
|
55
|
+
readonly clientRequired: "HeyPointer needs a client ID. Run heypointer init or pass data-client-id.";
|
|
56
|
+
readonly clientInvalid: "HeyPointer does not recognise this client ID. Check that it matches the one heypointer init gave you.";
|
|
57
|
+
readonly clientOrigin: "This site's address is not allowed for this HeyPointer client ID. Ask the HeyPointer admin to add it to the client's allowed origins.";
|
|
58
|
+
readonly clientMalformed: "The HeyPointer client ID looks wrong (it should start with hpc_). Check data-client-id against what heypointer init printed.";
|
|
59
|
+
readonly rateLimited: "HeyPointer is getting too many requests right now. Wait a moment and try again.";
|
|
60
|
+
readonly serverUnreachable: "Cannot reach the HeyPointer server at {host}. Check that it is running and the address is right.";
|
|
61
|
+
readonly requestFailed: "Walkthrough request failed ({status})";
|
|
62
|
+
};
|
|
63
|
+
export type LabelKey = keyof typeof DEFAULT_LABELS;
|
|
64
|
+
export type HeyPointerLabels = {
|
|
65
|
+
[K in LabelKey]?: string;
|
|
66
|
+
};
|
|
67
|
+
export type ResolvedLabels = Record<LabelKey, string>;
|
|
68
|
+
export declare const MAX_LABEL_LENGTH = 300;
|
|
69
|
+
/** Single-pass substitution: a value that itself contains `{x}` is never expanded again. */
|
|
70
|
+
export declare function fmt(template: string, vars?: Record<string, string | number>): string;
|
|
71
|
+
/** True in tests and source builds; the shipped bundles define it false, which removes everything behind it. */
|
|
72
|
+
export declare const DEV: boolean;
|
|
73
|
+
/** Development builds only: one console.warn per distinct set of problems. */
|
|
74
|
+
export declare function warnOnce(scope: string, problems: string[]): void;
|
|
75
|
+
/** Merge host overrides over the defaults. Anything invalid is ignored (and, in development builds, reported), never thrown. */
|
|
76
|
+
export declare function resolveLabels(input: unknown): {
|
|
77
|
+
labels: ResolvedLabels;
|
|
78
|
+
problems: string[];
|
|
79
|
+
};
|
|
80
|
+
/** Parse a JSON attribute value (`labels`, `data-labels`). Bad JSON is reported and ignored. */
|
|
81
|
+
export declare function parseJsonAttribute(name: string, raw: string | null | undefined): unknown;
|
package/dist/player.d.ts
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { type AudioRecorder } from './recorder';
|
|
2
|
+
import { type HeyPointerLabels } from './labels';
|
|
3
|
+
import { type ColorScheme, type HeyPointerTheme } from './theme';
|
|
4
|
+
import type { WalkthroughStep } from './types';
|
|
5
|
+
export interface HeyPointerOptions {
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
/** Publishable client id from `heypointer init` (`hpc_` + 24 hex). */
|
|
8
|
+
clientId?: string;
|
|
9
|
+
fetch?: typeof fetch;
|
|
10
|
+
recorderFactory?: () => AudioRecorder;
|
|
11
|
+
/** Override mic detection (tests). */
|
|
12
|
+
speechSupported?: boolean;
|
|
13
|
+
targetTimeoutMs?: number;
|
|
14
|
+
mountTo?: HTMLElement;
|
|
15
|
+
/** Start with assist mode on. The user can still toggle it in the card; it is never remembered between sessions. */
|
|
16
|
+
assist?: boolean;
|
|
17
|
+
/** Called once each time the guide clicks a control for the user (assist mode). Also fired as the `heypointer:assist` DOM event. */
|
|
18
|
+
onAssist?: (e: AssistEvent) => void;
|
|
19
|
+
/** Override any user-visible string (translations, tone). See HeyPointerLabels. Plain text with {placeholders}. */
|
|
20
|
+
labels?: HeyPointerLabels;
|
|
21
|
+
/** Colors, radius and font. Same names as the `--hp-*` CSS custom properties. Values are validated; invalid ones are ignored. */
|
|
22
|
+
theme?: HeyPointerTheme;
|
|
23
|
+
/** `auto` follows prefers-color-scheme (default); `light` or `dark` force one token set. */
|
|
24
|
+
colorScheme?: ColorScheme;
|
|
25
|
+
/** `auto` (default) inherits the page direction; `ltr`/`rtl` force it for the guide only. */
|
|
26
|
+
dir?: 'auto' | 'ltr' | 'rtl';
|
|
27
|
+
/** BCP 47 language tag set on the guide (screen readers, hyphenation). */
|
|
28
|
+
lang?: string;
|
|
29
|
+
/** `none` hides the built-in "Guide me" button; drive the guide with open(), close() and ask(). */
|
|
30
|
+
launcher?: 'default' | 'none';
|
|
31
|
+
/** Which edge the built-in button and the goal card sit on. Follows the text direction (`end` is the right in LTR). */
|
|
32
|
+
launcherSide?: 'start' | 'end';
|
|
33
|
+
/** Turn on author mode (record steps into a flow draft). Opt-in; loads its own bundle. For dev and staging builds. */
|
|
34
|
+
author?: boolean;
|
|
35
|
+
/** Also turn it on when the page URL has `?heypointer-author=1`. Off by default, so a production page can never be switched on from a URL. */
|
|
36
|
+
allowAuthorParam?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface AssistEvent {
|
|
39
|
+
stepIndex: number;
|
|
40
|
+
action: 'click';
|
|
41
|
+
label: string;
|
|
42
|
+
}
|
|
43
|
+
export declare const needsGate: (s: WalkthroughStep) => boolean;
|
|
44
|
+
export declare const ASSIST_EVENT = "heypointer:assist";
|
|
45
|
+
export declare const OPEN_EVENT = "heypointer:open";
|
|
46
|
+
export declare const CLOSE_EVENT = "heypointer:close";
|
|
47
|
+
export declare class HeyPointer {
|
|
48
|
+
private readonly opts;
|
|
49
|
+
readonly host: HTMLElement;
|
|
50
|
+
readonly root: ShadowRoot;
|
|
51
|
+
private readonly client;
|
|
52
|
+
private readonly hl;
|
|
53
|
+
private readonly spotlight;
|
|
54
|
+
private readonly arrow;
|
|
55
|
+
private readonly panel;
|
|
56
|
+
private readonly launcher;
|
|
57
|
+
private readonly live;
|
|
58
|
+
private view;
|
|
59
|
+
private wt;
|
|
60
|
+
private index;
|
|
61
|
+
private confirmed;
|
|
62
|
+
private missing;
|
|
63
|
+
private ambiguous;
|
|
64
|
+
private recorder;
|
|
65
|
+
private recording;
|
|
66
|
+
private notice;
|
|
67
|
+
private noticeAlert;
|
|
68
|
+
private goalToolsOpen;
|
|
69
|
+
private lastGoal;
|
|
70
|
+
private focusTitle;
|
|
71
|
+
private target;
|
|
72
|
+
private targetOffset;
|
|
73
|
+
private renderToken;
|
|
74
|
+
private readonly micOk;
|
|
75
|
+
private assist;
|
|
76
|
+
/** A click by the user (or the host app) reached the highlighted control since this step was shown. */
|
|
77
|
+
private userActed;
|
|
78
|
+
private assisting;
|
|
79
|
+
/** Steps the guide has already clicked once. It never clicks the same step twice, so it cannot undo a toggle. */
|
|
80
|
+
private assisted;
|
|
81
|
+
private assistNote;
|
|
82
|
+
private hintEl;
|
|
83
|
+
/** The control left the screen (the user closed the modal, say), so the guide stopped pointing at it and waits for Next. */
|
|
84
|
+
private released;
|
|
85
|
+
private stopWatch?;
|
|
86
|
+
private anchor;
|
|
87
|
+
private readonly onDocClick;
|
|
88
|
+
private L;
|
|
89
|
+
private theme;
|
|
90
|
+
private themeProps;
|
|
91
|
+
private cfg;
|
|
92
|
+
/** The host's own control that called open(), so Close can give focus back to it. */
|
|
93
|
+
private opener;
|
|
94
|
+
constructor(opts: HeyPointerOptions);
|
|
95
|
+
private startAuthor;
|
|
96
|
+
private t;
|
|
97
|
+
/** Replace the label overrides at runtime (a language switch, say). Unset keys go back to the English defaults. */
|
|
98
|
+
setLabels(labels: HeyPointerLabels | undefined): void;
|
|
99
|
+
/** Replace the theme at runtime. Invalid values are ignored; contrast problems are only warned about. */
|
|
100
|
+
setTheme(theme: HeyPointerTheme | undefined): void;
|
|
101
|
+
setColorScheme(scheme: ColorScheme | undefined): void;
|
|
102
|
+
/** Change direction, language, launcher visibility or side at runtime. */
|
|
103
|
+
setLayout(layout: {
|
|
104
|
+
dir?: 'auto' | 'ltr' | 'rtl';
|
|
105
|
+
lang?: string;
|
|
106
|
+
launcher?: 'default' | 'none';
|
|
107
|
+
launcherSide?: 'start' | 'end';
|
|
108
|
+
}): void;
|
|
109
|
+
private applyLayout;
|
|
110
|
+
private isRtl;
|
|
111
|
+
private emit;
|
|
112
|
+
private currentOpener;
|
|
113
|
+
open(): void;
|
|
114
|
+
close(): void;
|
|
115
|
+
destroy(): void;
|
|
116
|
+
/** Request a walkthrough for a typed (or transcribed) goal. */
|
|
117
|
+
ask(goal: string): Promise<void>;
|
|
118
|
+
next(): Promise<void>;
|
|
119
|
+
prev(): Promise<void>;
|
|
120
|
+
/** Skip a step without acting on it (e.g. target missing). Skipping performs no host action, so it needs no confirmation. */
|
|
121
|
+
skip(): Promise<void>;
|
|
122
|
+
confirm(): Promise<void>;
|
|
123
|
+
retry(): Promise<void>;
|
|
124
|
+
state(): {
|
|
125
|
+
view: "error" | "loading" | "done" | "insufficient" | "step" | "idle";
|
|
126
|
+
index: number;
|
|
127
|
+
missing: boolean;
|
|
128
|
+
ambiguous: boolean;
|
|
129
|
+
wt: {
|
|
130
|
+
id: string;
|
|
131
|
+
goal: string;
|
|
132
|
+
status: "ok" | "insufficient_evidence";
|
|
133
|
+
steps: {
|
|
134
|
+
id: string;
|
|
135
|
+
title: string;
|
|
136
|
+
instruction: string;
|
|
137
|
+
target: {
|
|
138
|
+
selectors: string[];
|
|
139
|
+
role?: string | undefined;
|
|
140
|
+
text?: string | undefined;
|
|
141
|
+
label?: string | undefined;
|
|
142
|
+
};
|
|
143
|
+
action: "type" | "click" | "select" | "navigate" | "observe";
|
|
144
|
+
requiresConfirmation: boolean;
|
|
145
|
+
evidence: {
|
|
146
|
+
nodeId: string;
|
|
147
|
+
sourceType: "prd" | "e2e" | "mermaid" | "code";
|
|
148
|
+
path: string;
|
|
149
|
+
lineStart: number;
|
|
150
|
+
lineEnd: number;
|
|
151
|
+
excerpt: string;
|
|
152
|
+
}[];
|
|
153
|
+
value?: string | undefined;
|
|
154
|
+
}[];
|
|
155
|
+
kbVersion: string;
|
|
156
|
+
confidence: number;
|
|
157
|
+
planner: "llm" | "deterministic" | "fallback";
|
|
158
|
+
workflowId?: string | undefined;
|
|
159
|
+
message?: string | undefined;
|
|
160
|
+
missingEvidence?: string[] | undefined;
|
|
161
|
+
suggestions?: {
|
|
162
|
+
workflowId: string;
|
|
163
|
+
title: string;
|
|
164
|
+
}[] | undefined;
|
|
165
|
+
} | null;
|
|
166
|
+
};
|
|
167
|
+
/** Why the guide must not click this control for the user, or null when it may. Never guesses: callers pass the single resolved element. */
|
|
168
|
+
private assistBlock;
|
|
169
|
+
/** In assist mode, click the step's control once for the user when that is provably safe. Null means "do nothing, just advance". */
|
|
170
|
+
private attemptAssist;
|
|
171
|
+
/** Capture-phase: remember that someone already used the highlighted control, so assist never repeats it. */
|
|
172
|
+
private noteClick;
|
|
173
|
+
private step;
|
|
174
|
+
private toggleRecording;
|
|
175
|
+
private focusFirst;
|
|
176
|
+
private el;
|
|
177
|
+
private render;
|
|
178
|
+
private syncTour;
|
|
179
|
+
private stopWatching;
|
|
180
|
+
/** Keep an eye on the highlighted control: closed, hidden or removed means the user acted, and it may come back. */
|
|
181
|
+
private watch;
|
|
182
|
+
private release;
|
|
183
|
+
private reengage;
|
|
184
|
+
private rebind;
|
|
185
|
+
private positionTour;
|
|
186
|
+
private goalForm;
|
|
187
|
+
private alert;
|
|
188
|
+
private renderInsufficient;
|
|
189
|
+
private renderStep;
|
|
190
|
+
/** Resolve the live DOM target; a gated step stays un-highlighted until confirmed. */
|
|
191
|
+
private locate;
|
|
192
|
+
private announce;
|
|
193
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface AudioRecorder {
|
|
2
|
+
start(): Promise<void>;
|
|
3
|
+
stop(): Promise<Blob>;
|
|
4
|
+
}
|
|
5
|
+
export declare function speechSupported(): boolean;
|
|
6
|
+
export declare class BrowserRecorder implements AudioRecorder {
|
|
7
|
+
private rec;
|
|
8
|
+
private chunks;
|
|
9
|
+
private stream;
|
|
10
|
+
start(): Promise<void>;
|
|
11
|
+
stop(): Promise<Blob>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type Placement = 'below' | 'above' | 'left' | 'right' | 'floating';
|
|
2
|
+
/** Position a coachmark near its real target without covering the target or viewport edges. */
|
|
3
|
+
export declare function coachmarkPosition(target: Pick<DOMRect, 'top' | 'left' | 'right' | 'bottom'>, card: Pick<DOMRect, 'width' | 'height'>, viewport: {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}, mobile?: boolean, rtl?: boolean): {
|
|
7
|
+
left: number;
|
|
8
|
+
top: number;
|
|
9
|
+
placement: Placement;
|
|
10
|
+
arrowLeft: number;
|
|
11
|
+
};
|
|
12
|
+
/** Visual dimmer plus a real, click-through cutout around the active control. */
|
|
13
|
+
export declare class Spotlight {
|
|
14
|
+
readonly overlay: HTMLDivElement;
|
|
15
|
+
private target;
|
|
16
|
+
private offset;
|
|
17
|
+
private enabled;
|
|
18
|
+
private onReposition?;
|
|
19
|
+
private frame;
|
|
20
|
+
private observer?;
|
|
21
|
+
private readonly onMove;
|
|
22
|
+
constructor(host: ParentNode & Node);
|
|
23
|
+
show(el: HTMLElement | null, onReposition: () => void): void;
|
|
24
|
+
hide(): void;
|
|
25
|
+
private position;
|
|
26
|
+
private update;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { StepTarget } from '../types';
|
|
2
|
+
export type Strategy = 'selector' | 'role-text' | 'label' | 'text';
|
|
3
|
+
export interface Resolved {
|
|
4
|
+
element: HTMLElement;
|
|
5
|
+
strategy: Strategy;
|
|
6
|
+
}
|
|
7
|
+
export type Resolution = ({
|
|
8
|
+
status: 'found';
|
|
9
|
+
} & Resolved) | {
|
|
10
|
+
status: 'ambiguous';
|
|
11
|
+
count: number;
|
|
12
|
+
} | {
|
|
13
|
+
status: 'missing';
|
|
14
|
+
};
|
|
15
|
+
export declare function isVisible(el: HTMLElement): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Can a person see and reach this element right now? The one definition shared by target resolution
|
|
18
|
+
* and the highlight watcher. On top of `isVisible` it asks the layout engine (content-visibility,
|
|
19
|
+
* no boxes, zero size) when the browser can answer; jsdom cannot, so there it stops at `isVisible`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isUsable(el: HTMLElement): boolean;
|
|
22
|
+
export declare function accessibleName(el: HTMLElement): string;
|
|
23
|
+
export declare function resolveDetailed(target: StepTarget, root?: ParentNode): Resolution;
|
|
24
|
+
export declare function resolveTarget(target: StepTarget, root?: ParentNode): Resolved | null;
|
|
25
|
+
export declare function waitForResolution(target: StepTarget, timeoutMs?: number, root?: Document): Promise<Resolution>;
|
|
26
|
+
export declare function waitForTarget(target: StepTarget, timeoutMs?: number, root?: Document): Promise<Resolved | null>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calls `onChange(false)` when `el` stops being usable (removed, hidden, closed) and `onChange(true)` when it
|
|
3
|
+
* comes back. Idle pages cost nothing: work happens at most once per frame after a relevant DOM change, and a
|
|
4
|
+
* short follow-up only while a transition or animation that contains `el` is running. Returns the stop function.
|
|
5
|
+
*/
|
|
6
|
+
export declare function watchUsable(el: HTMLElement, onChange: (usable: boolean) => void): () => void;
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme tokens. A host can set them in plain CSS (`heypointer-assistant { --hp-accent: #7c3aed }`) or pass a
|
|
3
|
+
* `theme` object, which this module validates and turns into the same custom properties.
|
|
4
|
+
* Values reach the page only through style.setProperty, and are additionally restricted to CSS color,
|
|
5
|
+
* length and font-family syntax, so a theme or attribute can never inject other CSS.
|
|
6
|
+
*/
|
|
7
|
+
export type ThemeColorKey = 'accent' | 'accentFg' | 'bg' | 'fg' | 'muted' | 'border' | 'warnBg' | 'warnBorder' | 'errBg' | 'errBorder' | 'focus' | 'halo' | 'ring' | 'dim';
|
|
8
|
+
export type ThemeColors = {
|
|
9
|
+
[K in ThemeColorKey]?: string;
|
|
10
|
+
};
|
|
11
|
+
export interface HeyPointerTheme extends ThemeColors {
|
|
12
|
+
/** Corner radius of the cards and controls, e.g. `12px`. */
|
|
13
|
+
radius?: string;
|
|
14
|
+
/** Font family list, e.g. `Inter, system-ui, sans-serif`. */
|
|
15
|
+
font?: string;
|
|
16
|
+
/** Base font size, e.g. `14px`. */
|
|
17
|
+
fontSize?: string;
|
|
18
|
+
/** Colors used instead when the dark scheme is active (falls back to the light value for accent and ring). */
|
|
19
|
+
dark?: ThemeColors;
|
|
20
|
+
}
|
|
21
|
+
export type ColorScheme = 'auto' | 'light' | 'dark';
|
|
22
|
+
export declare const COLOR_SCHEMES: readonly ColorScheme[];
|
|
23
|
+
export declare function isCssColor(v: unknown): v is string;
|
|
24
|
+
export declare const isCssLength: (v: unknown) => v is string;
|
|
25
|
+
export declare const isFontFamily: (v: unknown) => v is string;
|
|
26
|
+
/** Keep only valid entries; report the rest. Never throws. */
|
|
27
|
+
export declare function sanitizeTheme(input: unknown): {
|
|
28
|
+
theme: HeyPointerTheme;
|
|
29
|
+
problems: string[];
|
|
30
|
+
};
|
|
31
|
+
/** The custom properties a theme sets on the host element (`--hp-*`, and `--hp-dark-*` for the dark scheme). */
|
|
32
|
+
export declare function themeVars(theme: HeyPointerTheme): Record<string, string>;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Evidence, FlowSuggestion, StepAction, Target, Walkthrough, WalkthroughStep } from '@heypointerhq/contracts';
|
|
2
|
+
export type { Evidence, FlowSuggestion, StepAction, Target, Walkthrough, WalkthroughStep };
|
|
3
|
+
export type { HealthResponse, ErrorResponse, TranscribeResponse } from '@heypointerhq/contracts';
|
|
4
|
+
/** SDK-local alias: the target shape a step carries. */
|
|
5
|
+
export type StepTarget = Target;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Walkthrough } from './types';
|
|
2
|
+
/** Same limits as the contract: at most 5 suggestions, titles up to 200 characters. */
|
|
3
|
+
export declare const MAX_SUGGESTIONS = 5;
|
|
4
|
+
export declare const MAX_SUGGESTION_TITLE = 200;
|
|
5
|
+
/** Defensive client-side check: a step without evidence is never rendered. */
|
|
6
|
+
export declare function parseWalkthrough(raw: unknown): Walkthrough;
|
package/package.json
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heypointerhq/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "HeyPointer in-app guide: turns a goal into a spotlight-and-tooltip walkthrough of the real page. ESM, custom element and script-tag bundle; styles are compiled in.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"heypointer",
|
|
8
|
+
"walkthrough",
|
|
9
|
+
"onboarding",
|
|
10
|
+
"product-tour",
|
|
11
|
+
"spotlight",
|
|
12
|
+
"coachmark",
|
|
13
|
+
"web-component",
|
|
14
|
+
"custom-element"
|
|
15
|
+
],
|
|
16
|
+
"license": "Apache-2.0",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/heypointer/heypointer.git",
|
|
20
|
+
"directory": "packages/sdk"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./element": {
|
|
36
|
+
"types": "./dist/element.d.ts",
|
|
37
|
+
"import": "./dist/element.js"
|
|
38
|
+
},
|
|
39
|
+
"./author": {
|
|
40
|
+
"types": "./dist/author/index.d.ts",
|
|
41
|
+
"import": "./dist/author.js"
|
|
42
|
+
},
|
|
43
|
+
"./author/global": "./dist/heypointer.author.js",
|
|
44
|
+
"./global": "./dist/heypointer.global.js",
|
|
45
|
+
"./package.json": "./package.json"
|
|
46
|
+
},
|
|
47
|
+
"sideEffects": [
|
|
48
|
+
"./dist/heypointer.global.js",
|
|
49
|
+
"./dist/heypointer.author.js"
|
|
50
|
+
],
|
|
51
|
+
"files": [
|
|
52
|
+
"dist",
|
|
53
|
+
"LICENSE",
|
|
54
|
+
"NOTICE"
|
|
55
|
+
],
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@heypointerhq/contracts": "^0.2.1"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://heypointer.com/docs/"
|
|
60
|
+
}
|