@visulima/dev-toolbar 1.0.0-alpha.1 → 1.0.0-alpha.10
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/CHANGELOG.md +218 -0
- package/LICENSE.md +116 -5
- package/README.md +70 -43
- package/bin/mcp.js +29 -0
- package/dist/apps/a11y/a11y-app.d.ts +0 -1
- package/dist/apps/a11y/a11y-store.d.ts +12 -16
- package/dist/apps/a11y/a11y-tooltip.d.ts +1 -2
- package/dist/apps/a11y/index.js +3 -3
- package/dist/apps/annotations/annotations-app.d.ts +4 -0
- package/dist/apps/annotations/index.d.ts +3 -0
- package/dist/apps/annotations/index.js +18 -0
- package/dist/apps/assets/assets-app.d.ts +4 -0
- package/dist/apps/assets/index.d.ts +3 -0
- package/dist/apps/assets/index.js +16 -0
- package/dist/apps/inspector/a11y-capture.d.ts +12 -0
- package/dist/apps/inspector/annotation-overlay.d.ts +55 -0
- package/dist/apps/inspector/annotation-settings.d.ts +33 -0
- package/dist/apps/inspector/element-utils.d.ts +115 -0
- package/dist/apps/inspector/freeze-animations.d.ts +22 -0
- package/dist/apps/inspector/index.d.ts +3 -0
- package/dist/apps/inspector/index.js +30 -0
- package/dist/apps/inspector/inspector-app.d.ts +14 -0
- package/dist/apps/inspector/rulers.d.ts +14 -0
- package/dist/apps/inspector/theme-palette.d.ts +34 -0
- package/dist/apps/module-graph/index.js +2 -2
- package/dist/apps/module-graph/module-graph-app.d.ts +0 -1
- package/dist/apps/performance/index.js +2 -2
- package/dist/apps/performance/performance-app.d.ts +0 -1
- package/dist/apps/performance/performance-tooltip.d.ts +0 -1
- package/dist/apps/seo/index.js +2 -2
- package/dist/apps/seo/seo-app.d.ts +0 -1
- package/dist/apps/settings/index.js +2 -2
- package/dist/apps/settings/settings-app.d.ts +0 -1
- package/dist/apps/tailwind/index.d.ts +3 -0
- package/dist/apps/tailwind/index.js +7 -0
- package/dist/apps/tailwind/tailwind-app.d.ts +4 -0
- package/dist/apps/timeline/index.js +2 -2
- package/dist/apps/timeline/timeline-app.d.ts +0 -1
- package/dist/apps/vite-config/index.js +2 -2
- package/dist/apps/vite-config/vite-config-app.d.ts +0 -1
- package/dist/client/overlay.js +1 -1
- package/dist/hooks/create-hook.d.ts +7 -5
- package/dist/hooks/events.d.ts +4 -2
- package/dist/hooks/global-hook.d.ts +6 -6
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -1
- package/dist/mcp/server.d.ts +12 -0
- package/dist/mcp/server.js +1 -0
- package/dist/packem_chunks/inject-source.js +9 -0
- package/dist/packem_shared/Alert-D2CvX4fw.js +1 -0
- package/dist/packem_shared/Badge-BEgU04nl.js +1 -0
- package/dist/packem_shared/Button-Bkx66Co7.js +1 -0
- package/dist/packem_shared/Card-CJa4vHVc.js +1 -0
- package/dist/packem_shared/Icon-B6UHkC0o.js +1 -0
- package/dist/packem_shared/Input-Cs6aduTi.js +1 -0
- package/dist/packem_shared/Label-DyCng4Cp.js +1 -0
- package/dist/packem_shared/Popover-BtFVaZYg.js +1 -0
- package/dist/packem_shared/Progress-DN6zn-0l.js +1 -0
- package/dist/packem_shared/Select-DgQ4ss-s.js +1 -0
- package/dist/packem_shared/Separator-D38mKeZv.js +1 -0
- package/dist/packem_shared/Skeleton-Dv-tcA1P.js +1 -0
- package/dist/packem_shared/Switch-C3NTpeoR.js +1 -0
- package/dist/packem_shared/Tabs-DKWMiawt.js +1 -0
- package/dist/packem_shared/Textarea-Yfg3dLZi.js +1 -0
- package/dist/packem_shared/Tooltip-CioncSXj.js +1 -0
- package/dist/packem_shared/annotation-settings-Bv0TH4WI.js +1 -0
- package/dist/packem_shared/annotation-store-bLQRYMaI.js +1 -0
- package/dist/packem_shared/clsx-wGlvpUfw.js +1 -0
- package/dist/packem_shared/createClientRPCContext-DgRxrllw.js +1 -0
- package/dist/packem_shared/createDevToolbarHook-4bZZiHPI.js +1 -0
- package/dist/packem_shared/createServerRPCContext-D-yZrEjs.js +1 -0
- package/dist/packem_shared/getTimelineStore-B1cfjWV8.js +1 -0
- package/dist/packem_shared/{setupGlobalHook-CFuxsCyl.js → setupGlobalHook-CCf9Logv.js} +1 -1
- package/dist/packem_shared/sharedToolbarStylesheet-CaTdYhVe.js +2 -0
- package/dist/packem_shared/store-DaUtLjf3.js +1 -0
- package/dist/packem_shared/use-frame-state-CxrlPUM5.js +1 -0
- package/dist/packem_shared/use-theme-zpm4zmqP.js +1 -0
- package/dist/performance/monitor.d.ts +27 -26
- package/dist/rpc/client.d.ts +6 -4
- package/dist/rpc/functions/annotations.d.ts +28 -0
- package/dist/rpc/functions/assets.d.ts +16 -0
- package/dist/rpc/functions/module-graph.d.ts +2 -2
- package/dist/rpc/functions/open-in-editor.d.ts +13 -6
- package/dist/rpc/functions/tailwind-config.d.ts +15 -0
- package/dist/rpc/functions/vite-config.d.ts +80 -4
- package/dist/rpc/server.d.ts +11 -5
- package/dist/store/annotation-store.d.ts +41 -0
- package/dist/timeline/capture.d.ts +8 -0
- package/dist/timeline/index.d.ts +3 -1
- package/dist/timeline/store.d.ts +12 -22
- package/dist/toolbar/app-manager.d.ts +49 -40
- package/dist/toolbar/components/app-button.d.ts +2 -3
- package/dist/toolbar/components/app-canvas.d.ts +1 -2
- package/dist/toolbar/components/app-tooltip-overlay.d.ts +0 -1
- package/dist/toolbar/components/first-visit-hint.d.ts +3 -4
- package/dist/toolbar/components/pinned-tooltip-card.d.ts +0 -1
- package/dist/toolbar/components/toolbar-bar.d.ts +1 -7
- package/dist/toolbar/components/toolbar-container.d.ts +2 -8
- package/dist/toolbar/components/vite-overlay-button.d.ts +2 -3
- package/dist/toolbar/context/index.d.ts +1 -1
- package/dist/toolbar/context/toolbar-context.d.ts +43 -42
- package/dist/toolbar/global-api.d.ts +4 -3
- package/dist/toolbar/helpers.d.ts +5 -3
- package/dist/toolbar/hooks/index.d.ts +4 -4
- package/dist/toolbar/hooks/use-apps.d.ts +5 -3
- package/dist/toolbar/hooks/use-frame-state.d.ts +32 -16
- package/dist/toolbar/hooks/use-panel-visible.d.ts +9 -7
- package/dist/toolbar/hooks/use-position.d.ts +7 -5
- package/dist/toolbar/hooks/use-theme.d.ts +6 -4
- package/dist/toolbar/hooks/use-toolbar.d.ts +4 -2
- package/dist/toolbar/index.d.ts +9 -17
- package/dist/toolbar/index.js +3 -4
- package/dist/toolbar/settings.d.ts +7 -7
- package/dist/toolbar/stylesheet.d.ts +3 -1
- package/dist/toolbar/utils/index.d.ts +3 -3
- package/dist/types/annotations.d.ts +156 -0
- package/dist/types/app.d.ts +26 -14
- package/dist/types/global-api.d.ts +27 -31
- package/dist/types/hooks.d.ts +32 -34
- package/dist/types/index.d.ts +1 -0
- package/dist/types/messaging.d.ts +2 -2
- package/dist/types/rpc.d.ts +49 -7
- package/dist/types/timeline.d.ts +3 -3
- package/dist/types/toolbar.d.ts +1 -1
- package/dist/ui/components/alert.d.ts +19 -0
- package/dist/ui/components/badge.d.ts +9 -0
- package/dist/ui/components/button.d.ts +11 -0
- package/dist/ui/components/card.d.ts +16 -0
- package/dist/ui/components/icon.d.ts +5 -7
- package/dist/ui/components/input.d.ts +7 -0
- package/dist/ui/components/label.d.ts +7 -0
- package/dist/ui/components/popover.d.ts +27 -0
- package/dist/ui/components/progress.d.ts +7 -0
- package/dist/ui/components/select.d.ts +54 -0
- package/dist/ui/components/separator.d.ts +8 -0
- package/dist/ui/components/skeleton.d.ts +6 -0
- package/dist/ui/components/switch.d.ts +11 -0
- package/dist/ui/components/tabs.d.ts +28 -0
- package/dist/ui/components/textarea.d.ts +7 -0
- package/dist/ui/components/tooltip.d.ts +19 -0
- package/dist/ui/index.d.ts +18 -0
- package/dist/ui/index.js +1 -0
- package/dist/vite/inject-source.d.ts +24 -0
- package/dist/vite/matcher.d.ts +6 -0
- package/dist/vite-plugin.d.ts +49 -6
- package/dist/vite-plugin.js +5 -2
- package/package.json +51 -12
- package/dist/apps/more/index.d.ts +0 -3
- package/dist/apps/more/index.js +0 -19
- package/dist/apps/more/more-app.d.ts +0 -5
- package/dist/packem_shared/TimelineStore-BgBrirKd.js +0 -1
- package/dist/packem_shared/cn-BEsR6GkP.js +0 -1
- package/dist/packem_shared/createClientRPCContext-DzKQpKTk.js +0 -1
- package/dist/packem_shared/createDevToolbarHook-DGNxqk8N.js +0 -1
- package/dist/packem_shared/createServerRPCContext-BVSesPXu.js +0 -1
- package/dist/packem_shared/icon-BUQ92HaT.js +0 -1
- package/dist/packem_shared/store-BxE0w51s.js +0 -1
- package/dist/rpc/index.d.ts +0 -8
- package/dist/utils/cn.d.ts +0 -8
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
type Severity = "critical" | "minor" | "moderate" | "serious";
|
|
2
|
+
type Standard = "best-practice" | "wcag21aa" | "wcag22aa" | "wcag2a";
|
|
3
|
+
interface A11yNode {
|
|
4
4
|
html: string;
|
|
5
5
|
selector: string;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
interface A11yIssue {
|
|
8
8
|
helpUrl: string;
|
|
9
9
|
id: string;
|
|
10
10
|
impact: Severity;
|
|
@@ -12,35 +12,31 @@ export interface A11yIssue {
|
|
|
12
12
|
nodes: A11yNode[];
|
|
13
13
|
wcagTags: string[];
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
interface A11yStoreState {
|
|
16
16
|
isScanning: boolean;
|
|
17
17
|
issues: A11yIssue[];
|
|
18
|
-
lastScan:
|
|
19
|
-
scanError:
|
|
18
|
+
lastScan: string | undefined;
|
|
19
|
+
scanError: string | undefined;
|
|
20
20
|
showOverlays: boolean;
|
|
21
21
|
standard: Standard;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
declare const SEVERITY_ORDER: Severity[];
|
|
24
24
|
type Listener = () => void;
|
|
25
25
|
declare class A11yStore {
|
|
26
26
|
private listeners;
|
|
27
27
|
private state;
|
|
28
28
|
constructor();
|
|
29
|
-
/** Remove all outline highlights from the page */
|
|
30
29
|
clearHighlights(): void;
|
|
31
30
|
getState(): Readonly<A11yStoreState>;
|
|
32
|
-
/** Scroll to and outline a single issue's elements */
|
|
33
31
|
highlightIssue(issue: A11yIssue): void;
|
|
34
|
-
/** Run an axe-core scan and persist results */
|
|
35
32
|
scan(disabledRules?: string[]): Promise<void>;
|
|
36
|
-
/** Toggle overlay highlights on all affected elements */
|
|
37
33
|
setShowOverlays(show: boolean): void;
|
|
38
|
-
/** Change the WCAG standard used for future scans */
|
|
39
34
|
setStandard(standard: Standard): void;
|
|
40
|
-
subscribe(
|
|
35
|
+
subscribe(listener: Listener): () => void;
|
|
41
36
|
private notify;
|
|
42
37
|
private persist;
|
|
43
38
|
private update;
|
|
44
39
|
}
|
|
45
|
-
|
|
46
|
-
export {};
|
|
40
|
+
declare const a11yStore: A11yStore;
|
|
41
|
+
export type { A11yIssue, A11yNode, A11yStoreState, Severity, Standard };
|
|
42
|
+
export { a11yStore, SEVERITY_ORDER };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
/** @jsxImportSource preact */
|
|
2
1
|
import type { ComponentChildren } from "preact";
|
|
3
2
|
import type { AppTooltipProps } from "../../types/app.d.ts";
|
|
4
3
|
/**
|
|
5
4
|
* Hover tooltip for the Accessibility app button.
|
|
6
5
|
* Shows a summary of scan results and quick action buttons.
|
|
7
|
-
* @param _props
|
|
6
|
+
* @param _props Tooltip props (unused; reads from a11yStore directly)
|
|
8
7
|
* @returns Rendered tooltip component
|
|
9
8
|
*/
|
|
10
9
|
declare const A11yTooltip: (_props: AppTooltipProps) => ComponentChildren;
|
package/dist/apps/a11y/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var X=Object.defineProperty;var O=(a,e)=>X(a,"name",{value:e,configurable:!0});import{addHookName as k}from"preact/devtools";import{clsx as d}from"../../packem_shared/clsx-wGlvpUfw.js";import{useState as C,useEffect as L}from"preact/hooks";import{jsxs as i,jsx as t,Fragment as W}from"preact/jsx-runtime";import w from"../../packem_shared/Button-Bkx66Co7.js";import{Alert as Y,AlertDescription as Z}from"../../packem_shared/Alert-D2CvX4fw.js";const ee=`<!-- @license lucide-static v1.8.0 - ISC -->
|
|
2
2
|
<svg
|
|
3
3
|
class="lucide lucide-accessibility"
|
|
4
4
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -17,5 +17,5 @@ var K=Object.defineProperty;var C=(s,e)=>K(s,"name",{value:e,configurable:!0});i
|
|
|
17
17
|
<path d="M4.24 14.5a5 5 0 0 0 6.88 6" />
|
|
18
18
|
<path d="M13.76 17.5a5 5 0 0 0-6.88-6" />
|
|
19
19
|
</svg>
|
|
20
|
-
`;var
|
|
21
|
-
`)],{type:"text/csv"}),
|
|
20
|
+
`;var te=Object.defineProperty,x=O((a,e)=>te(a,"name",{value:e,configurable:!0}),"i$3");const E=["critical","serious","moderate","minor"],re={critical:"rgb(239,68,68)",minor:"rgb(100,116,139)",moderate:"rgb(249,115,22)",serious:"rgb(234,179,8)"},se={"best-practice":["best-practice"],wcag2a:["wcag2a"],wcag21aa:["wcag2a","wcag2aa","wcag21a","wcag21aa"],wcag22aa:["wcag2a","wcag2aa","wcag21a","wcag21aa","wcag22a","wcag22aa"]},_="__vdt_a11y__",ne=x(()=>{try{const a=sessionStorage.getItem(_);if(a){const e=JSON.parse(a);if(Array.isArray(e.issues))return{issues:e.issues,lastScan:e.lastScan??void 0}}}catch{}return{issues:[],lastScan:void 0}},"loadFromSession"),z=x((a,e)=>{const n=a;n.dataset.vdtA11y=e,n.style.setProperty("outline",`2px solid ${re[e]}`,"important"),n.style.setProperty("outline-offset","2px","important")},"setHighlight"),I=x(()=>{for(const a of document.querySelectorAll("[data-vdt-a11y]")){const e=a;delete e.dataset.vdtA11y,e.style.removeProperty("outline"),e.style.removeProperty("outline-offset")}},"clearHighlightsDOM"),H=x(a=>{I();for(const e of a)for(const n of e.nodes)try{const r=document.querySelector(n.selector);r&&z(r,e.impact)}catch{}},"applyOverlaysDOM"),ae=x(a=>{const e=a.at(-1);return Array.isArray(e)?e.join(" "):String(e??"")},"nodeSelector"),ie=x((a,e)=>{const n=[];for(const r of a)e.includes(r.id)||n.push({helpUrl:r.helpUrl,id:r.id,impact:r.impact??"minor",message:r.help,nodes:r.nodes.map(o=>({html:o.html,selector:ae(o.target)})),wcagTags:r.tags.filter(o=>o.startsWith("wcag")||o==="best-practice")});return n},"convertViolations"),oe=x(async a=>{const e=await import("axe-core"),n=typeof e.default?.run=="function"?e.default:e;if(typeof n.run!="function")throw new TypeError("axe-core could not be loaded — .run is not available");return n.run(document,{exclude:[["dev-toolbar"]],runOnly:{type:"tag",values:se[a]}})},"runAxeScan");class ce{static{O(this,"v")}static{x(this,"A11yStore")}listeners=new Set;state;constructor(){const{issues:e,lastScan:n}=ne();this.state={isScanning:!1,issues:e,lastScan:n,scanError:void 0,showOverlays:!1,standard:"wcag21aa"}}clearHighlights(){I()}getState(){return this.state}highlightIssue(e){I();let n=!1;for(const r of e.nodes)try{const o=document.querySelector(r.selector);o&&(z(o,e.impact),n||(o.scrollIntoView({behavior:"smooth",block:"center"}),n=!0))}catch{}}async scan(e=[]){if(!this.state.isScanning){this.update({isScanning:!0,scanError:void 0});try{const n=await oe(this.state.standard),r=ie(n.violations,e);this.update({isScanning:!1,issues:r,lastScan:new Date().toISOString()}),this.persist(),this.state.showOverlays&&H(r)}catch(n){this.update({isScanning:!1,scanError:n instanceof Error?n.message:String(n)})}}}setShowOverlays(e){this.update({showOverlays:e}),e?H(this.state.issues):I()}setStandard(e){this.update({standard:e})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notify(){for(const e of this.listeners)e()}persist(){try{sessionStorage.setItem(_,JSON.stringify({issues:this.state.issues,lastScan:this.state.lastScan}))}catch{}}update(e){this.state={...this.state,...e},this.notify()}}const l=new ce;var le=Object.defineProperty,c=O((a,e)=>le(a,"name",{value:e,configurable:!0}),"i$2");const N={critical:"Critical",minor:"Minor",moderate:"Moderate",serious:"Serious"},J={critical:"text-destructive",minor:"text-muted-foreground",moderate:"text-warning-foreground",serious:"text-warning-foreground"},de={critical:"bg-destructive/10 border-destructive/30",minor:"bg-foreground/4 border-border",moderate:"bg-warning/10 border-warning/30",serious:"bg-warning/10 border-warning/30"},ue={critical:"bg-destructive",minor:"bg-muted-foreground/50",moderate:"bg-warning",serious:"bg-warning"},ge=c(({count:a,isActive:e,onClick:n,severity:r})=>i("button",{class:d("flex flex-col items-center gap-1 px-3 py-2.5 border cursor-pointer transition-colors",e?"ring-1 ring-inset ring-primary/40":"hover:bg-foreground/6",de[r]),onClick:n,title:`${e?"Clear":"Filter by"} ${N[r]}`,type:"button",children:[t("span",{class:d("text-xl font-bold tabular-nums leading-none",J[r]),children:a}),t("span",{class:"text-[0.6rem] font-semibold uppercase tracking-wider text-muted-foreground",children:N[r]})]}),"SeverityBucket"),pe=c(({isSelected:a,issue:e,onClick:n,onDisable:r})=>i("div",{class:d("p-3 border cursor-pointer transition-colors",a?"bg-foreground/6 border-primary/30":"border-border hover:bg-foreground/3"),onClick:n,children:[i("div",{class:"flex items-start gap-2 mb-1.5",children:[t("span",{class:d("mt-1 size-2 rounded-full shrink-0",ue[e.impact])}),t("span",{class:"text-[0.75rem] font-semibold text-foreground flex-1 leading-snug",children:e.id}),t("span",{class:d("text-[0.6rem] font-bold uppercase tracking-wide shrink-0",J[e.impact]),children:N[e.impact]})]}),t("p",{class:"text-[0.7rem] text-muted-foreground leading-relaxed mb-2 ml-4",children:e.message}),e.nodes.length>0&&i("div",{class:"mb-2 ml-4 space-y-0.5",children:[e.nodes.slice(0,3).map((o,p)=>t("code",{class:"block text-[0.65rem] text-foreground/70 font-mono bg-foreground/5 px-2 py-1 truncate",children:o.selector},p)),e.nodes.length>3&&i("span",{class:"text-[0.62rem] text-muted-foreground/60",children:["+",e.nodes.length-3," more element",e.nodes.length>4?"s":""]})]}),i("div",{class:"flex items-center gap-2 flex-wrap ml-4",children:[e.wcagTags.slice(0,3).map(o=>t("span",{class:"text-[0.58rem] font-mono uppercase bg-primary/8 text-primary/70 border border-primary/20 px-1.5 py-0.5",children:o},o)),t("span",{class:"flex-1"}),t("a",{class:"text-[0.62rem] text-primary/70 hover:text-primary transition-colors",href:e.helpUrl,onClick:c(o=>o.stopPropagation(),"onClick"),rel:"noopener noreferrer",target:"_blank",children:"Learn more ↗"}),t("button",{class:"text-[0.62rem] text-muted-foreground/60 hover:text-muted-foreground transition-colors cursor-pointer bg-transparent border-0 p-0",onClick:c(o=>{o.stopPropagation(),r(e.id)},"onClick"),title:"Disable this rule for current session",type:"button",children:"Disable"})]})]}),"IssueCard"),me=c(a=>{const[e,n]=k(C(()=>l.getState()),"storeState"),[r,o]=k(C([]),"disabledRules"),[p,M]=k(C(void 0),"minSeverity"),[S,v]=k(C(void 0),"activeIssueId"),[m,f]=k(C(void 0),"filterSeverity");L(()=>l.subscribe(()=>n(l.getState())),[]),L(()=>l.clearHighlights.bind(l),[]);const{isScanning:b,issues:h,lastScan:u,scanError:$,showOverlays:T,standard:q}=e,U=u!==void 0||$!==void 0,P=c(()=>{f(void 0),v(void 0),l.scan(r).catch(()=>{})},"handleScan"),V=c(s=>{S===s.id?(v(void 0),l.clearHighlights(),T&&l.setShowOverlays(!0)):(v(s.id),l.highlightIssue(s))},"handleIssueClick"),F=c(s=>{o(g=>[...g,s])},"handleDisableRule"),R=h.filter(s=>!(r.includes(s.id)||m&&s.impact!==m||p&&E.indexOf(s.impact)>E.indexOf(p))),K=c(s=>h.filter(g=>!r.includes(g.id)&&g.impact===s).length,"countBy");return i("div",{class:"flex flex-col h-full",children:[i("div",{class:"shrink-0 flex items-center gap-2 px-4 py-2.5 border-b border-border bg-foreground/2 flex-wrap",children:[t(w,{class:d(b?"border-primary/30 text-primary/50 bg-primary/5":""),disabled:b,onClick:P,size:"sm",variant:"outline",children:b?"Scanning…":"Scan page"}),i("label",{class:"flex items-center gap-1.5 text-[0.7rem] text-muted-foreground",children:["Standard",i("select",{class:"bg-card border border-border text-foreground text-[0.7rem] px-1.5 py-1 cursor-pointer",onChange:c(s=>l.setStandard(s.target.value),"onChange"),style:"color-scheme: dark",value:q,children:[t("option",{value:"wcag21aa",children:"WCAG 2.1 AA"}),t("option",{value:"wcag22aa",children:"WCAG 2.2 AA"}),t("option",{value:"wcag2a",children:"WCAG 2.0 A"}),t("option",{value:"best-practice",children:"Best Practice"})]})]}),i("label",{class:"flex items-center gap-1.5 text-[0.7rem] text-muted-foreground",children:["Min",i("select",{class:"bg-card border border-border text-foreground text-[0.7rem] px-1.5 py-1 cursor-pointer",onChange:c(s=>{const{value:g}=s.target;M(g||void 0)},"onChange"),style:"color-scheme: dark",value:p??"",children:[t("option",{value:"",children:"All"}),t("option",{value:"critical",children:"Critical only"}),t("option",{value:"serious",children:"Serious+"}),t("option",{value:"moderate",children:"Moderate+"})]})]}),t(w,{class:d(T?"border-primary/30 text-primary bg-primary/8":""),onClick:c(()=>l.setShowOverlays(!T),"onClick"),size:"sm",title:"Toggle visual highlights on affected elements",variant:"outline",children:"Overlays"}),U&&h.length>0&&i(W,{children:[t(w,{class:"ml-auto",onClick:c(()=>{const s=new Blob([JSON.stringify(h,void 0,2)],{type:"application/json"}),g=URL.createObjectURL(s),A=document.createElement("a");A.href=g,A.download="a11y-audit.json",A.click(),URL.revokeObjectURL(g)},"onClick"),size:"sm",title:"Export audit results as JSON",variant:"outline",children:"JSON"}),t(w,{onClick:c(()=>{const s=c(y=>`"${y.replaceAll('"','""')}"`,"q"),g=["Rule ID","Severity","Message","Selector","HTML","WCAG Tags"].join(","),A=h.flatMap(y=>y.nodes.map(G=>[s(y.id),s(y.impact),s(y.message),s(G.selector),s(G.html),s(y.wcagTags.join("; "))].join(","))),Q=new Blob([[g,...A].join(`
|
|
21
|
+
`)],{type:"text/csv"}),B=URL.createObjectURL(Q),D=document.createElement("a");D.href=B,D.download="a11y-audit.csv",D.click(),URL.revokeObjectURL(B)},"onClick"),size:"sm",title:"Export audit results as CSV",variant:"outline",children:"CSV"})]})]}),i("div",{class:"flex-1 overflow-y-auto devtools-content-scroll",children:[$&&t(Y,{class:"rounded-none border-x-0 border-t-0",variant:"destructive",children:i(Z,{children:["Scan failed: ",$]})}),!U&&!b&&i("div",{class:"flex flex-col items-center justify-center gap-4 p-8 min-h-48 text-center",children:[t("p",{class:"text-[0.8125rem] text-muted-foreground max-w-sm",children:"Run an accessibility audit using axe-core to detect WCAG violations on this page."}),t(w,{onClick:P,variant:"outline",children:"Start scan"})]}),b&&t("div",{class:"flex items-center justify-center gap-3 p-8 min-h-48",children:t("span",{class:"text-[0.8rem] text-muted-foreground",children:"Scanning for accessibility issues…"})}),U&&!b&&!$&&i("div",{class:"p-5 space-y-4",children:[t("div",{class:"grid grid-cols-4 gap-2",children:E.map(s=>t(ge,{count:K(s),isActive:m===s,onClick:c(()=>f(m===s?void 0:s),"onClick"),severity:s},s))}),R.length===0?i("div",{class:"p-6 text-center border border-border",children:[t("p",{class:"text-[0.8125rem] font-medium text-foreground/70",children:h.length===0?"No violations found!":"No issues match the current filters."}),h.length===0&&t("p",{class:"mt-1 text-[0.7rem] text-muted-foreground",children:"Great — the page passes all rules for the selected standard."})]}):i("section",{children:[i("div",{class:"flex items-center gap-2 mb-2",children:[i("span",{class:"text-[0.65rem] font-bold uppercase tracking-[0.1em] text-muted-foreground",children:[t("span",{"aria-hidden":"true",class:"text-primary/50",children:"//"})," ",R.length," issue",R.length===1?"":"s",m?` · ${N[m]} only`:""]}),m&&t(w,{class:"h-auto p-0 text-[0.62rem]",onClick:c(()=>f(void 0),"onClick"),variant:"link",children:"Clear ×"})]}),t("div",{class:"space-y-2",children:R.map(s=>t(pe,{isSelected:S===s.id,issue:s,onClick:c(()=>V(s),"onClick"),onDisable:F},s.id))})]}),r.length>0&&i("div",{class:"flex items-center gap-2 text-[0.65rem] text-muted-foreground/60",children:[i("span",{children:[r.length," rule",r.length===1?"":"s"," disabled this session."]}),t(w,{class:"h-auto p-0 text-[0.62rem]",onClick:c(()=>o([]),"onClick"),variant:"link",children:"Reset"})]})]})]})]})},"A11yApp");var he=Object.defineProperty,j=O((a,e)=>he(a,"name",{value:e,configurable:!0}),"i$1");const fe={critical:"text-destructive",minor:"text-muted-foreground",moderate:"text-warning-foreground",serious:"text-warning-foreground"},be={critical:"Crit",minor:"Min",moderate:"Mod",serious:"Ser"},xe=j(a=>{const e=new Date(a).getTime();if(Number.isNaN(e))return"unknown";const n=Math.max(0,Math.floor((Date.now()-e)/1e3));if(n<10)return"just now";if(n<60)return`${n}s ago`;const r=Math.floor(n/60);return r<60?`${r} min ago`:`${Math.floor(r/60)} hr ago`},"formatElapsed"),ve=j(a=>{const[e,n]=k(C(()=>l.getState()),"state");L(()=>l.subscribe(()=>n(l.getState())),[]);const{isScanning:r,issues:o,lastScan:p,showOverlays:M}=e,S=o.length,v={critical:0,minor:0,moderate:0,serious:0};for(const u of o)v[u.impact]=(v[u.impact]??0)+1;const m=j(u=>v[u],"countBy");let f;r?f="Scanning…":p?f="Re-scan":f="Scan";const b=M?"border-primary/30 text-primary bg-primary/8":"border-border text-muted-foreground bg-transparent hover:text-foreground",h=o.length===0?"border-border/50 text-muted-foreground/40 bg-transparent cursor-not-allowed":d("cursor-pointer",b);return i("div",{class:"space-y-3 min-w-[200px]",children:[p?i(W,{children:[i("div",{class:"flex items-baseline gap-2",children:[t("span",{class:d("text-2xl font-bold tabular-nums leading-none",S>0?"text-destructive":"text-success-foreground"),children:S}),i("span",{class:"text-[0.65rem] text-muted-foreground",children:["violation",S===1?"":"s"]})]}),t("div",{class:"grid grid-cols-4 gap-1.5",children:E.map(u=>i("div",{class:"flex flex-col items-center gap-0.5",children:[t("span",{class:d("text-[0.85rem] font-bold tabular-nums leading-none",fe[u]),children:m(u)}),t("span",{class:"text-[0.55rem] uppercase tracking-wide text-muted-foreground/70",children:be[u]})]},u))}),i("p",{class:"text-[0.62rem] text-muted-foreground/50",children:["Scanned ",xe(p)]})]}):i("div",{children:[t("p",{class:"text-[0.72rem] text-muted-foreground",children:"No scan run yet."}),t("p",{class:"text-[0.65rem] text-muted-foreground/50 mt-0.5",children:"Scan this page to detect WCAG violations."})]}),i("div",{class:"flex items-center gap-2 pt-2 border-t border-border/50",children:[t("button",{class:d("flex-1 px-2.5 py-1.5 text-[0.7rem] font-medium border transition-colors cursor-pointer",r?"border-primary/30 text-primary/50 bg-primary/5 cursor-not-allowed":"border-border text-foreground bg-transparent hover:bg-foreground/5"),disabled:r,onClick:j(()=>{l.scan().catch(()=>{})},"onClick"),type:"button",children:f}),t("button",{class:d("px-2.5 py-1.5 text-[0.7rem] border transition-colors",h),disabled:o.length===0,onClick:j(()=>l.setShowOverlays(!M),"onClick"),title:"Toggle visual highlights on affected elements",type:"button",children:"Overlays"})]})]})},"A11yTooltip"),je={component:me,icon:ee,id:"dev-toolbar:a11y",name:"Accessibility",tooltip:ve};export{je as default};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var j=Object.defineProperty;var z=(t,s)=>j(t,"name",{value:s,configurable:!0});import{addHookName as c}from"preact/devtools";import{clsx as h}from"../../packem_shared/clsx-wGlvpUfw.js";import{useState as p,useCallback as S,useEffect as q}from"preact/hooks";import{s as Q,M as H,l as K}from"../../packem_shared/annotation-settings-Bv0TH4WI.js";import{jsx as e,jsxs as r}from"preact/jsx-runtime";import g from"../../packem_shared/Button-Bkx66Co7.js";import U from"../../packem_shared/Textarea-Yfg3dLZi.js";const V=`<!-- @license lucide-static v1.8.0 - ISC -->
|
|
2
|
+
<svg
|
|
3
|
+
class="lucide lucide-message-square-plus"
|
|
4
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
+
width="24"
|
|
6
|
+
height="24"
|
|
7
|
+
viewBox="0 0 24 24"
|
|
8
|
+
fill="none"
|
|
9
|
+
stroke="currentColor"
|
|
10
|
+
stroke-width="2"
|
|
11
|
+
stroke-linecap="round"
|
|
12
|
+
stroke-linejoin="round"
|
|
13
|
+
>
|
|
14
|
+
<path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" />
|
|
15
|
+
<path d="M12 8v6" />
|
|
16
|
+
<path d="M9 11h6" />
|
|
17
|
+
</svg>
|
|
18
|
+
`;var G=Object.defineProperty,a=z((t,s)=>G(t,"name",{value:s,configurable:!0}),"o");const I={approve:"Approve",change:"Change",fix:"Fix",question:"Question"},M={approve:"bg-green-500/20 text-green-400 border-green-500/30",change:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",fix:"bg-destructive/20 text-destructive border-destructive/30",question:"bg-blue-500/20 text-blue-400 border-blue-500/30"},F={blocking:"Blocking",important:"Important",suggestion:"Suggestion"},$={blocking:"text-destructive",important:"text-warning-foreground",suggestion:"text-muted-foreground"},A={acknowledged:"Acknowledged",dismissed:"Dismissed",pending:"Pending",resolved:"Resolved"},Y=a(({active:t,counts:s,onFilter:i})=>e("div",{class:"flex gap-1.5",children:["all","pending","acknowledged","resolved","dismissed"].map(n=>r("button",{class:h("px-2.5 py-1 text-[0.65rem] font-medium border cursor-pointer transition-colors",t===n?"bg-primary/10 border-primary/30 text-primary":"bg-foreground/3 border-border text-muted-foreground hover:bg-foreground/6"),onClick:a(()=>i(n),"onClick"),type:"button",children:[n==="all"?"All":A[n]," (",s[n],")"]},n))}),"StatusFilters"),_=a(({annotation:t,isSelected:s,onClick:i,onDelete:n,onDismiss:d,onResolve:m})=>r("div",{class:h("p-3 border cursor-pointer transition-colors",s?"bg-foreground/6 border-primary/30":"border-border hover:bg-foreground/3"),onClick:i,children:[r("div",{class:"flex items-start gap-2 mb-1.5",children:[e("span",{class:h("text-[0.6rem] font-bold uppercase px-1.5 py-0.5 border shrink-0",M[t.intent]),children:I[t.intent]}),e("span",{class:h("text-[0.6rem] font-semibold uppercase tracking-wide shrink-0",$[t.severity]),children:F[t.severity]}),e("span",{class:"flex-1"}),t.resolvedBy&&r("span",{class:"text-[0.58rem] text-muted-foreground/60",children:["by ",t.resolvedBy]}),e("span",{class:"text-[0.58rem] text-muted-foreground/60",children:A[t.status]})]}),e("p",{class:"text-[0.7rem] text-foreground leading-relaxed mb-1.5 line-clamp-2",children:t.comment}),e("div",{class:"flex items-center gap-2 mb-1.5",children:r("code",{class:"text-[0.62rem] text-foreground/60 font-mono bg-foreground/5 px-1.5 py-0.5 truncate",children:[t.elementTag,t.elementPath?` · ${t.elementPath}`:""]})}),t.source&&e("div",{class:"mb-1.5",children:e("code",{class:"text-[0.6rem] text-primary/60 font-mono",children:t.source})}),e("div",{class:"text-[0.58rem] text-muted-foreground/50 truncate mb-2",children:t.url}),t.thread&&t.thread.length>0&&r("div",{class:"text-[0.6rem] text-muted-foreground/60 mb-2",children:[t.thread.length," message",t.thread.length===1?"":"s"," in thread"]}),t.status==="pending"&&r("div",{class:"flex items-center gap-1.5",onClick:a(u=>u.stopPropagation(),"onClick"),children:[e(g,{class:"h-auto py-0.5 px-2 text-[0.6rem]",onClick:m,size:"sm",variant:"outline",children:"Resolve"}),e(g,{class:"h-auto py-0.5 px-2 text-[0.6rem]",onClick:d,size:"sm",variant:"outline",children:"Dismiss"}),e("span",{class:"flex-1"}),e(g,{class:"h-auto py-0.5 px-2 text-[0.6rem] text-destructive hover:text-destructive",onClick:n,size:"sm",variant:"ghost",children:"Delete"})]})]}),"AnnotationCard"),J=a(({annotation:t,helpers:s,onBack:i,onRefresh:n})=>{const[d,m]=c(p(""),"message"),u=S(async()=>{const l=d.trim();l&&(await s.rpc.updateAnnotation?.(t.id,{threadMessage:{content:l,role:"human",timestamp:new Date().toISOString()}}),m(""),n())},[t.id,s,d,n]);return r("div",{class:"p-4 space-y-3",children:[e(g,{class:"h-auto py-0.5 px-2 text-[0.65rem]",onClick:i,size:"sm",variant:"ghost",children:"← Back"}),r("div",{class:"flex items-center gap-2 flex-wrap",children:[e("span",{class:h("text-[0.65rem] font-bold uppercase px-2 py-0.5 border",M[t.intent]),children:I[t.intent]}),e("span",{class:h("text-[0.65rem] font-semibold",$[t.severity]),children:F[t.severity]}),e("span",{class:"text-[0.6rem] text-muted-foreground ml-auto",children:A[t.status]})]}),e("div",{class:"text-[0.75rem] text-foreground leading-relaxed border border-border p-3",children:t.comment}),r("div",{class:"space-y-1 text-[0.65rem]",children:[r("div",{class:"flex gap-2",children:[e("span",{class:"text-muted-foreground w-16 shrink-0",children:"Element"}),r("code",{class:"text-foreground/70 font-mono",children:[t.elementTag,t.cssClasses?` .${t.cssClasses}`:""]})]}),t.source&&r("div",{class:"flex gap-2",children:[e("span",{class:"text-muted-foreground w-16 shrink-0",children:"Source"}),e("code",{class:"text-primary/70 font-mono",children:t.source})]}),r("div",{class:"flex gap-2",children:[e("span",{class:"text-muted-foreground w-16 shrink-0",children:"URL"}),e("span",{class:"text-foreground/60 truncate",children:t.url})]}),r("div",{class:"flex gap-2",children:[e("span",{class:"text-muted-foreground w-16 shrink-0",children:"Created"}),e("span",{class:"text-foreground/60",children:new Date(t.createdAt).toLocaleString()})]})]}),r("div",{children:[r("div",{class:"text-[0.65rem] font-bold uppercase tracking-[0.1em] text-muted-foreground mb-2",children:[e("span",{"aria-hidden":"true",class:"text-primary/50",children:"// "}),"Thread (",t.thread?.length??0,")"]}),t.thread&&t.thread.length>0&&e("div",{class:"space-y-2 mb-3",children:t.thread.map(l=>r("div",{class:"border border-border p-2",children:[r("div",{class:"flex items-center gap-2 mb-1",children:[e("span",{class:"text-[0.62rem] font-semibold text-primary/70",children:l.role}),e("span",{class:"text-[0.55rem] text-muted-foreground/50",children:new Date(l.timestamp).toLocaleString()})]}),e("p",{class:"text-[0.68rem] text-foreground/80 leading-relaxed whitespace-pre-wrap",children:l.content})]},`${l.role}-${l.timestamp}`))}),r("div",{class:"space-y-2",children:[e(U,{class:"text-[0.7rem] min-h-[60px]",onChange:a(l=>m(l.target.value),"onChange"),placeholder:"Add a message to the thread...",value:d}),e(g,{class:"text-[0.65rem]",disabled:!d.trim(),onClick:u,size:"sm",variant:"outline",children:"Send"})]})]})]})},"AnnotationDetail"),W=a(({onChange:t,settings:s})=>{const i=a(n=>{const d={...s,...n};Q(d),t(d)},"update");return r("div",{class:"space-y-3 p-4 border-t border-border",children:[r("div",{class:"text-[0.65rem] font-bold uppercase tracking-[0.1em] text-muted-foreground",children:[e("span",{"aria-hidden":"true",class:"text-primary/50",children:"// "}),"Settings"]}),r("label",{class:"flex items-center gap-2 text-[0.7rem] text-foreground",children:[e("span",{class:"text-muted-foreground w-24 shrink-0",children:"Output Detail"}),r("select",{class:"flex-1 bg-card border border-border text-foreground text-[0.65rem] px-1.5 py-1 cursor-pointer",onChange:a(n=>i({outputDetail:n.target.value}),"onChange"),style:"color-scheme: dark",value:s.outputDetail,children:[e("option",{value:"compact",children:"Compact"}),e("option",{value:"standard",children:"Standard"}),e("option",{value:"detailed",children:"Detailed"}),e("option",{value:"forensic",children:"Forensic"})]})]}),r("div",{class:"flex items-center gap-2 text-[0.7rem]",children:[e("span",{class:"text-muted-foreground w-24 shrink-0",children:"Marker Color"}),e("div",{class:"flex gap-1.5",children:H.map(n=>e("button",{class:h("w-5 h-5 rounded-full border-2 cursor-pointer p-0 transition-all",n.name===s.markerColorName?"border-foreground scale-110":"border-transparent hover:scale-110"),onClick:a(()=>i({markerColorName:n.name}),"onClick"),style:{background:n.bg},title:n.label,type:"button"},n.name))})]}),r("label",{class:"flex items-center gap-2 text-[0.7rem] text-foreground",children:[e("span",{class:"text-muted-foreground w-24 shrink-0",children:"Marker Click"}),r("select",{class:"flex-1 bg-card border border-border text-foreground text-[0.65rem] px-1.5 py-1 cursor-pointer",onChange:a(n=>i({markerClickBehavior:n.target.value}),"onChange"),style:"color-scheme: dark",value:s.markerClickBehavior,children:[e("option",{value:"detail",children:"Show Detail"}),e("option",{value:"edit",children:"Edit"}),e("option",{value:"delete",children:"Delete"})]})]}),r("label",{class:"flex items-center gap-2 text-[0.7rem] text-foreground cursor-pointer",children:[e("input",{checked:s.blockInteractions,class:"cursor-pointer",onChange:a(n=>i({blockInteractions:n.target.checked}),"onChange"),type:"checkbox"}),e("span",{children:"Block page interactions while inspecting"})]})]})},"AnnotationSettingsPanel"),X=a(({helpers:t})=>{const[s,i]=c(p([]),"annotations"),[n,d]=c(p(!1),"loading"),[m,u]=c(p(),"error"),[l,E]=c(p("pending"),"filterStatus"),[b,P]=c(p("all"),"filterIntent"),[k,D]=c(p(),"selectedId"),[y,L]=c(p(!1),"showSettings"),[N,O]=c(p(()=>K()),"settings"),x=S(async()=>{d(!0),u(void 0);try{const o=await t.rpc.getAnnotations?.();i(o??[])}catch(o){u(o instanceof Error?o.message:String(o))}finally{d(!1)}},[t]);q(()=>{x().catch(()=>{})},[x]);const R=s.filter(o=>!(l!=="all"&&o.status!==l||b!=="all"&&o.intent!==b)),f=a(o=>s.filter(v=>v.status===o).length,"countByStatus"),T={acknowledged:f("acknowledged"),all:s.length,dismissed:f("dismissed"),pending:f("pending"),resolved:f("resolved")},B=k?s.find(o=>o.id===k):void 0,C=S(async(o,v)=>{try{await(v==="delete"?t.rpc.deleteAnnotation?.(o):t.rpc.updateAnnotation?.(o,{status:v==="resolve"?"resolved":"dismissed"})),await x()}catch(w){console.error(`[annotations] ${v} failed for ${o}:`,w),u(w instanceof Error?w.message:`Failed to ${v} annotation`)}},[t,x]);return B?e(J,{annotation:B,helpers:t,onBack:a(()=>D(void 0),"onBack"),onRefresh:a(()=>x().catch(()=>{}),"onRefresh")}):r("div",{class:"flex flex-col h-full",children:[r("div",{class:"shrink-0 flex items-center gap-2 px-4 py-2.5 border-b border-border bg-foreground/2 flex-wrap",children:[e(g,{disabled:n,onClick:a(()=>x().catch(()=>{}),"onClick"),size:"sm",variant:"outline",children:n?"Loading…":"Refresh"}),e(g,{class:h("text-[0.65rem]",y&&"bg-primary/10 text-primary"),onClick:a(()=>L(!y),"onClick"),size:"sm",variant:"ghost",children:"Settings"}),e("span",{class:"flex-1"}),r("select",{class:"bg-card border border-border text-foreground text-[0.65rem] px-1.5 py-1 cursor-pointer",onChange:a(o=>P(o.target.value),"onChange"),style:"color-scheme: dark",value:b,children:[e("option",{value:"all",children:"All intents"}),e("option",{value:"fix",children:"Fix"}),e("option",{value:"change",children:"Change"}),e("option",{value:"question",children:"Question"}),e("option",{value:"approve",children:"Approve"})]})]}),r("div",{class:"flex-1 overflow-y-auto devtools-content-scroll",children:[m&&e("div",{class:"p-3 text-[0.7rem] text-destructive bg-destructive/10 border-b border-destructive/20",children:m}),r("div",{class:"p-4 space-y-3",children:[e(Y,{active:l,counts:T,onFilter:E}),R.length===0?r("div",{class:"p-6 text-center border border-border",children:[e("p",{class:"text-[0.8125rem] font-medium text-foreground/70",children:s.length===0?"No annotations yet":"No annotations match filters"}),e("p",{class:"mt-1 text-[0.7rem] text-muted-foreground",children:s.length===0?'Use the Inspector to click an element and select "Annotate".':"Try changing the status or intent filter."})]}):e("div",{class:"space-y-2",children:R.map(o=>e(_,{annotation:o,isSelected:k===o.id,onClick:a(()=>D(o.id),"onClick"),onDelete:a(()=>C(o.id,"delete").catch(()=>{}),"onDelete"),onDismiss:a(()=>C(o.id,"dismiss").catch(()=>{}),"onDismiss"),onResolve:a(()=>C(o.id,"resolve").catch(()=>{}),"onResolve")},o.id))})]})]}),y&&e(W,{onChange:O,settings:N})]})},"AnnotationsApp"),le={component:X,icon:V,id:"dev-toolbar:annotations",name:"Annotations"};export{le as default};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var B=Object.defineProperty;var P=(t,i)=>B(t,"name",{value:i,configurable:!0});import{addHookName as a}from"preact/devtools";import{clsx as u}from"../../packem_shared/clsx-wGlvpUfw.js";import{useState as s,useRef as N,useEffect as C}from"preact/hooks";import{jsx as e,jsxs as l}from"preact/jsx-runtime";import c from"../../packem_shared/Button-Bkx66Co7.js";import E from"../../packem_shared/Input-Cs6aduTi.js";const H=`<!-- @license lucide-static v1.8.0 - ISC -->
|
|
2
|
+
<svg
|
|
3
|
+
class="lucide lucide-folder-open"
|
|
4
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
+
width="24"
|
|
6
|
+
height="24"
|
|
7
|
+
viewBox="0 0 24 24"
|
|
8
|
+
fill="none"
|
|
9
|
+
stroke="currentColor"
|
|
10
|
+
stroke-width="2"
|
|
11
|
+
stroke-linecap="round"
|
|
12
|
+
stroke-linejoin="round"
|
|
13
|
+
>
|
|
14
|
+
<path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2" />
|
|
15
|
+
</svg>
|
|
16
|
+
`;var O=Object.defineProperty,o=P((t,i)=>O(t,"name",{value:i,configurable:!0}),"o");const j=o(t=>!Number.isFinite(t)||t<0?"–":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,"formatSize"),A=o(t=>t.startsWith("/")&&!t.includes(":")?t:"#","safePublicPath"),M=[{label:"All",value:"all"},{label:"Images",value:"image"},{label:"Videos",value:"video"},{label:"Audio",value:"audio"},{label:"Fonts",value:"font"},{label:"Text",value:"text"},{label:"Other",value:"other"}],D={audio:"bg-yellow-500/15 text-yellow-400 border-yellow-500/30",font:"bg-orange-500/15 text-orange-400 border-orange-500/30",image:"bg-blue-500/15 text-blue-400 border-blue-500/30",other:"bg-foreground/6 text-muted-foreground border-border",text:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",video:"bg-purple-500/15 text-purple-400 border-purple-500/30"},z=o(({type:t})=>e("span",{class:u("inline-flex px-1.5 py-0.5 text-[0.6rem] font-mono font-bold uppercase border",D[t]),children:t}),"TypeBadge"),V=o(({asset:t})=>{const i=A(t.publicPath);if(i!=="#"){if(t.type==="image")return e("div",{class:"flex items-center justify-center bg-foreground/4 border border-border h-32 overflow-hidden",children:e("img",{alt:t.publicPath,class:"max-w-full max-h-full object-contain",onError:o(p=>{p.target.style.display="none"},"onError"),src:i})});if(t.type==="video")return e("div",{class:"flex items-center justify-center bg-foreground/4 border border-border h-32 overflow-hidden",children:e("video",{class:"max-w-full max-h-full",preload:"metadata",src:i})});if(t.type==="audio")return e("div",{class:"flex items-center justify-center bg-foreground/4 border border-border h-14 px-2",children:e("audio",{class:"w-full",controls:!0,preload:"none",src:i})})}},"AssetPreview"),K=o(({helpers:t})=>{const[i,p]=a(s([]),"assets"),[F,f]=a(s(!0),"loading"),[g,v]=a(s(void 0),"error"),[y,T]=a(s(""),"search"),[d,S]=a(s("all"),"typeFilter"),[n,b]=a(s(void 0),"selected"),[I,w]=a(s(!1),"copied"),m=a(N(void 0),"copyTimerRef");C(()=>()=>{clearTimeout(m.current)},[]);const h=o(()=>{f(!0),v(void 0),b(void 0),t.rpc.getStaticAssets().then(r=>{p(r),f(!1)}).catch(r=>{v(r.message??"Failed to load assets"),f(!1)})},"load");C(()=>{h()},[]);const x=i.filter(r=>{const k=y.toLowerCase(),R=!k||r.publicPath.toLowerCase().includes(k),$=d==="all"||r.type===d;return R&&$}),L=o(r=>{navigator.clipboard.writeText(r.publicPath).then(()=>{clearTimeout(m.current),w(!0),m.current=setTimeout(w,1500,!1)}).catch(()=>{})},"copyPath");return F?l("div",{class:"flex flex-col items-center justify-center h-full gap-3 p-8 select-none",children:[e("div",{"aria-hidden":"true",class:"flex gap-1.5 items-center",children:[0,160,320].map(r=>e("span",{class:"size-1.5 bg-primary/50 rounded-full animate-pulse",style:{animationDelay:`${r}ms`}},r))}),e("span",{class:"text-[0.75rem] text-muted-foreground",children:"Scanning assets…"})]}):g?l("div",{class:"flex flex-col items-center justify-center h-full gap-3 p-8 text-center",children:[e("p",{class:"text-[0.8rem] text-destructive",children:g}),e(c,{onClick:h,size:"sm",variant:"outline",children:"Retry"})]}):l("div",{class:"flex flex-col h-full",children:[l("div",{class:"flex items-center gap-2 px-4 py-2.5 border-b border-border shrink-0 flex-wrap",children:[e(E,{class:"flex-1 min-w-32 bg-foreground/4 font-mono text-[0.8rem] placeholder:text-muted-foreground/50 focus-visible:border-primary/50 border-border",onInput:o(r=>{T(r.target.value)},"onInput"),placeholder:"Filter assets…",type:"text",value:y}),l("span",{class:"text-[0.7rem] text-muted-foreground shrink-0",children:[x.length," / ",i.length]}),e(c,{onClick:h,size:"sm",variant:"outline",children:"Refresh"})]}),e("div",{"aria-label":"Filter by type",class:"flex items-center gap-1.5 px-4 py-2 border-b border-border shrink-0 flex-wrap",role:"group",children:M.map(r=>e("button",{"aria-pressed":d===r.value,class:u("px-2.5 py-0.5 text-[0.7rem] font-medium border cursor-pointer transition-colors duration-100",d===r.value?"bg-primary/15 text-primary border-primary/30":"bg-foreground/4 text-muted-foreground border-border hover:bg-foreground/8 hover:text-foreground"),onClick:o(()=>{S(r.value)},"onClick"),type:"button",children:r.label},r.value))}),l("div",{class:"flex flex-1 min-h-0 overflow-hidden",children:[e("div",{class:"flex-1 overflow-auto divide-y divide-border/30",role:"list",children:x.length===0?e("div",{class:"flex items-center justify-center p-8 text-[0.8rem] text-muted-foreground",children:i.length===0?"No assets found in public directory.":"No assets match the current filter."}):x.map(r=>l("button",{"aria-label":r.publicPath,"aria-selected":n?.publicPath===r.publicPath,class:u("w-full flex items-center gap-3 px-4 py-2.5 text-left border-0 bg-transparent cursor-pointer","hover:bg-foreground/4 transition-colors duration-100",n?.publicPath===r.publicPath&&"bg-primary/6"),onClick:o(()=>{b(n?.publicPath===r.publicPath?void 0:r)},"onClick"),role:"option",type:"button",children:[e(z,{type:r.type}),e("span",{class:"flex-1 text-[0.775rem] font-mono text-foreground/80 truncate min-w-0",children:r.publicPath}),e("span",{class:"shrink-0 text-[0.65rem] text-muted-foreground",children:j(r.size)})]},r.publicPath))}),n&&l("div",{class:"border-l border-border bg-background w-72 shrink-0 flex flex-col overflow-hidden",children:[l("div",{class:"flex items-center justify-between gap-2 px-4 py-3 border-b border-border shrink-0",children:[e("span",{class:"text-[0.7rem] font-semibold text-foreground uppercase tracking-wide",children:"Asset Info"}),e(c,{"aria-label":"Close",class:"h-6 w-6 text-xs",onClick:o(()=>{b(void 0)},"onClick"),size:"icon",variant:"ghost",children:"✕"})]}),l("div",{class:"flex-1 overflow-auto p-4 space-y-4",children:[e(V,{asset:n}),l("div",{children:[e("div",{class:"text-[0.6rem] uppercase tracking-wider text-muted-foreground mb-1",children:"Path"}),e("code",{class:"text-[0.7rem] font-mono text-foreground/80 break-all",children:n.publicPath})]}),l("div",{children:[e("div",{class:"text-[0.6rem] uppercase tracking-wider text-muted-foreground mb-1",children:"Type"}),e(z,{type:n.type})]}),l("div",{children:[e("div",{class:"text-[0.6rem] uppercase tracking-wider text-muted-foreground mb-1",children:"Size"}),e("span",{class:"text-[0.8rem] font-mono text-foreground",children:j(n.size)})]}),l("div",{children:[e("div",{class:"text-[0.6rem] uppercase tracking-wider text-muted-foreground mb-1",children:"Last Modified"}),e("span",{class:"text-[0.75rem] text-foreground/80",children:new Date(n.mtime).toLocaleString()})]}),l("div",{class:"flex flex-col gap-2 pt-1",children:[e(c,{class:"w-full text-[0.75rem]",onClick:o(()=>{L(n)},"onClick"),size:"sm",variant:"outline",children:I?"Copied!":"Copy URL"}),e("a",{class:u("w-full text-[0.75rem] inline-flex items-center justify-center","px-3 py-1.5 border border-border bg-transparent","text-foreground hover:bg-foreground/6 transition-colors duration-100"),href:A(n.publicPath),rel:"noopener noreferrer",target:"_blank",children:"Open in browser"})]})]})]})]})]})},"AssetsApp"),X={component:K,icon:H,id:"dev-toolbar:assets",name:"Assets"};export{X as default};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface A11yInfo {
|
|
2
|
+
ariaAttributes: Record<string, string>;
|
|
3
|
+
focusable: boolean;
|
|
4
|
+
role: string | null;
|
|
5
|
+
tabindex: number | null;
|
|
6
|
+
}
|
|
7
|
+
/** Collect accessibility-relevant attributes from an element. */
|
|
8
|
+
declare const captureA11yInfo: (element: Element) => A11yInfo;
|
|
9
|
+
/** Format A11yInfo as a plain-text summary for clipboard. */
|
|
10
|
+
declare const formatA11yText: (info: A11yInfo) => string;
|
|
11
|
+
export { captureA11yInfo, formatA11yText };
|
|
12
|
+
export type { A11yInfo };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Annotation overlay — renders annotation markers on the page canvas,
|
|
3
|
+
* provides inline annotation form, detail popup, edit mode, screenshot capture,
|
|
4
|
+
* freeze mode, markdown export, and SPA navigation persistence.
|
|
5
|
+
*
|
|
6
|
+
* All DOM elements are injected into document.body (outside Shadow DOM)
|
|
7
|
+
* to match the inspector's rendering approach.
|
|
8
|
+
*/
|
|
9
|
+
import type { Annotation, BoundingBox } from "../../types/annotations.d.ts";
|
|
10
|
+
/**
|
|
11
|
+
* Returns true when the Annotations panel app is registered in the toolbar.
|
|
12
|
+
*/
|
|
13
|
+
export declare const isAnnotationsAppEnabled: () => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Convert viewport click coords to page-absolute coords for storage.
|
|
16
|
+
* x = percentage of viewport width, y = absolute page Y (scrollY + clientY).
|
|
17
|
+
* For fixed elements, y stays as viewport-relative (no scrollY offset).
|
|
18
|
+
*/
|
|
19
|
+
export declare const toPageCoords: (clientX: number, clientY: number, fixed?: boolean) => {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
};
|
|
23
|
+
/** Load annotations from server and render markers. */
|
|
24
|
+
export declare const loadAndShowMarkers: () => Promise<void>;
|
|
25
|
+
/** Remove all annotation markers and detach listeners. */
|
|
26
|
+
export declare const removeAllMarkers: () => void;
|
|
27
|
+
/** Close all annotation popups (form, detail) and area outline, but keep markers. */
|
|
28
|
+
export declare const closeAnnotationPopups: () => void;
|
|
29
|
+
/** Whether the annotation form popup is currently open. */
|
|
30
|
+
export declare const isAnnotationFormOpen: () => boolean;
|
|
31
|
+
/** Shake the annotation form to draw attention. */
|
|
32
|
+
export declare const shakeAnnotationForm: () => void;
|
|
33
|
+
/**
|
|
34
|
+
* Show annotation form popup. Captures selectedText, nearbyText, framework context,
|
|
35
|
+
* and generates a smart CSS selector.
|
|
36
|
+
*/
|
|
37
|
+
export declare const showAnnotationForm: (element: Element, rect: DOMRect, source: string | undefined, editAnnotation?: Annotation, clickPoint?: {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
}) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Show annotation form for a multi-select (drag) region.
|
|
43
|
+
* Creates a single annotation covering multiple elements.
|
|
44
|
+
*/
|
|
45
|
+
export declare const showMultiSelectForm: (elements: Element[], selectionRect: DOMRect, boundingBoxes: BoundingBox[]) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Show annotation form for an empty area selection (no elements found in drag region).
|
|
48
|
+
* Like agentation: creates an "Area selection" annotation with the region as bounding box.
|
|
49
|
+
* Shows a green dashed outline around the selected region.
|
|
50
|
+
*/
|
|
51
|
+
export declare const showAreaSelectionForm: (selectionRect: DOMRect) => void;
|
|
52
|
+
export declare const attachMarkdownShortcut: () => void;
|
|
53
|
+
export declare const detachMarkdownShortcut: () => void;
|
|
54
|
+
/** Check if a target is over an annotation overlay element. */
|
|
55
|
+
export declare const isOverAnnotationOverlay: (target: Element | undefined) => boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Annotation-specific settings — output detail level, marker appearance,
|
|
3
|
+
* interaction behavior. Persisted in localStorage.
|
|
4
|
+
*/
|
|
5
|
+
export type OutputDetailLevel = "compact" | "detailed" | "forensic" | "standard";
|
|
6
|
+
export type MarkerClickBehavior = "delete" | "detail" | "edit";
|
|
7
|
+
export interface MarkerColor {
|
|
8
|
+
/** Solid background for the marker */
|
|
9
|
+
bg: string;
|
|
10
|
+
/** Slightly darker ring / shadow tint */
|
|
11
|
+
border: string;
|
|
12
|
+
/** Text color inside the marker (white or dark for contrast) */
|
|
13
|
+
fg: string;
|
|
14
|
+
/** Translucent version for hover highlight overlay on elements */
|
|
15
|
+
highlightBg: string;
|
|
16
|
+
label: string;
|
|
17
|
+
name: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const MARKER_COLORS: MarkerColor[];
|
|
20
|
+
export interface AnnotationSettings {
|
|
21
|
+
/** Block clicks on interactive elements (buttons, links, inputs) while active */
|
|
22
|
+
blockInteractions: boolean;
|
|
23
|
+
/** What happens when you click a marker */
|
|
24
|
+
markerClickBehavior: MarkerClickBehavior;
|
|
25
|
+
/** Marker color name (from MARKER_COLORS) */
|
|
26
|
+
markerColorName: string;
|
|
27
|
+
/** Output detail level for markdown export */
|
|
28
|
+
outputDetail: OutputDetailLevel;
|
|
29
|
+
}
|
|
30
|
+
export declare const DEFAULT_SETTINGS: AnnotationSettings;
|
|
31
|
+
export declare const loadSettings: () => AnnotationSettings;
|
|
32
|
+
export declare const saveSettings: (settings: AnnotationSettings) => void;
|
|
33
|
+
export declare const getMarkerColor: (settings?: AnnotationSettings) => MarkerColor;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Element utility functions for annotation — shadow DOM piercing, CSS selector
|
|
3
|
+
* generation, smart naming, text extraction, a11y capture, computed styles,
|
|
4
|
+
* framework detection, screenshot, freeze, markdown export.
|
|
5
|
+
*/
|
|
6
|
+
import type { AccessibilityInfo, BoundingBox, FrameworkContext } from "../../types/annotations.d.ts";
|
|
7
|
+
export declare const deepElementFromPoint: (x: number, y: number) => Element | null;
|
|
8
|
+
/**
|
|
9
|
+
* Get the viewport-relative bounding rect for an element, accounting for
|
|
10
|
+
* it potentially being inside nested iframes.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getViewportRect: (element: Element) => DOMRect;
|
|
13
|
+
/**
|
|
14
|
+
* Pierce mode: Cmd+hover to find the actual element underneath invisible
|
|
15
|
+
* overlays, animation wrappers, and empty container divs.
|
|
16
|
+
*
|
|
17
|
+
* Two-pass approach:
|
|
18
|
+
* 1. Find elements with direct text content (skips empty wrappers)
|
|
19
|
+
* 2. If no text found, return the smallest visible element (catches
|
|
20
|
+
* visual-only elements like timeline bars, chart segments, swatches)
|
|
21
|
+
*/
|
|
22
|
+
export declare const pierceElementFromPoint: (x: number, y: number) => Element | null;
|
|
23
|
+
export declare const getParentElement: (element: Element) => Element | null;
|
|
24
|
+
/**
|
|
25
|
+
* Check if element or any ancestor has fixed or sticky positioning.
|
|
26
|
+
*/
|
|
27
|
+
export declare const isElementFixed: (element: Element) => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Generate a human-readable element label like agentation:
|
|
30
|
+
* button "Submit", link to /page, image "alt text", input[type=email]
|
|
31
|
+
*/
|
|
32
|
+
export declare const getElementLabel: (element: Element) => string;
|
|
33
|
+
/**
|
|
34
|
+
* Generate a unique CSS selector for an element.
|
|
35
|
+
* Strategy: ID → unique class combo → nth-of-type fallback.
|
|
36
|
+
*/
|
|
37
|
+
export declare const generateSelector: (element: Element) => string;
|
|
38
|
+
/**
|
|
39
|
+
* Clean CSS classes by stripping module hash suffixes.
|
|
40
|
+
*/
|
|
41
|
+
export declare const cleanCssClasses: (classes: DOMTokenList) => string;
|
|
42
|
+
/**
|
|
43
|
+
* Build full DOM ancestry path (body > main > article > section > p).
|
|
44
|
+
* Marks shadow DOM boundary crossings with ⟨shadow⟩.
|
|
45
|
+
*/
|
|
46
|
+
export declare const getFullDomPath: (element: Element) => string;
|
|
47
|
+
/**
|
|
48
|
+
* Get sibling elements as context (up to 5 siblings).
|
|
49
|
+
*/
|
|
50
|
+
export declare const getNearbyElements: (element: Element) => string;
|
|
51
|
+
/**
|
|
52
|
+
* Extract nearby text content from an element (up to maxLength chars).
|
|
53
|
+
*/
|
|
54
|
+
export declare const getNearbyText: (element: Element, maxLength?: number) => string;
|
|
55
|
+
/**
|
|
56
|
+
* Capture currently selected text (up to maxLength chars).
|
|
57
|
+
*/
|
|
58
|
+
export declare const getSelectedText: (maxLength?: number) => string;
|
|
59
|
+
/**
|
|
60
|
+
* Capture accessibility attributes from an element.
|
|
61
|
+
*/
|
|
62
|
+
export declare const captureAccessibility: (element: Element) => AccessibilityInfo;
|
|
63
|
+
/**
|
|
64
|
+
* Capture key computed styles for forensic context.
|
|
65
|
+
*/
|
|
66
|
+
export declare const captureComputedStyles: (element: Element) => string;
|
|
67
|
+
/**
|
|
68
|
+
* Detect framework component for an element.
|
|
69
|
+
*/
|
|
70
|
+
export declare const detectFrameworkComponent: (element: Element) => FrameworkContext | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Capture a screenshot of an element's bounding area.
|
|
73
|
+
*
|
|
74
|
+
* Uses the Screen Capture API (getDisplayMedia) to capture a frame from the
|
|
75
|
+
* screen, then crops to the element's bounding rect. This is the most reliable
|
|
76
|
+
* approach — works with external CSS, images, shadow DOM, and canvas content.
|
|
77
|
+
*
|
|
78
|
+
* Falls back to null if the user denies permission or the API is unavailable.
|
|
79
|
+
*/
|
|
80
|
+
export declare const captureElementScreenshot: (element: Element) => Promise<string | null>;
|
|
81
|
+
/**
|
|
82
|
+
* Get all elements within a rectangular region.
|
|
83
|
+
* Searches across shadow DOM and same-origin iframes.
|
|
84
|
+
*/
|
|
85
|
+
export declare const getElementsInRect: (rect: DOMRect) => Element[];
|
|
86
|
+
/**
|
|
87
|
+
* Get bounding boxes from a list of elements (iframe-aware).
|
|
88
|
+
*/
|
|
89
|
+
export declare const getElementBoundingBoxes: (elements: Element[]) => BoundingBox[];
|
|
90
|
+
/**
|
|
91
|
+
* Output detail levels:
|
|
92
|
+
* - compact: "Element: comment (re: "selected text...")"
|
|
93
|
+
* - standard: Element + location + component + feedback
|
|
94
|
+
* - detailed: + classes, position, context text
|
|
95
|
+
* - forensic: + full DOM path, styles, accessibility, nearby elements
|
|
96
|
+
*/
|
|
97
|
+
export declare const annotationsToMarkdown: (annotations: {
|
|
98
|
+
accessibility?: AccessibilityInfo;
|
|
99
|
+
comment: string;
|
|
100
|
+
computedStyles?: string;
|
|
101
|
+
cssClasses?: string;
|
|
102
|
+
elementLabel?: string;
|
|
103
|
+
elementPath?: string;
|
|
104
|
+
elementTag: string;
|
|
105
|
+
frameworkContext?: FrameworkContext;
|
|
106
|
+
fullPath?: string;
|
|
107
|
+
intent: string;
|
|
108
|
+
nearbyElements?: string;
|
|
109
|
+
nearbyText?: string;
|
|
110
|
+
selectedText?: string;
|
|
111
|
+
severity: string;
|
|
112
|
+
source?: string;
|
|
113
|
+
status: string;
|
|
114
|
+
url: string;
|
|
115
|
+
}[], detail?: "compact" | "detailed" | "forensic" | "standard") => string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Freeze Animations — comprehensive animation/timer freeze system.
|
|
3
|
+
*
|
|
4
|
+
* Monkey-patches setTimeout, setInterval, and requestAnimationFrame so that
|
|
5
|
+
* callbacks are silently queued while frozen. Also injects CSS to pause
|
|
6
|
+
* CSS animations/transitions, pauses WAAPI animations, and pauses videos.
|
|
7
|
+
*
|
|
8
|
+
* Patches are installed as a side effect of importing this module.
|
|
9
|
+
* Toolbar/popup code must import `originalSetTimeout` to bypass the patch.
|
|
10
|
+
*
|
|
11
|
+
* Based on agentation's freeze-animations.ts pattern.
|
|
12
|
+
*/
|
|
13
|
+
/** Original (unpatched) setTimeout — use for toolbar/popup animations */
|
|
14
|
+
export declare const originalSetTimeout: typeof setTimeout;
|
|
15
|
+
/** Whether animations are currently frozen */
|
|
16
|
+
export declare const isFrozen: () => boolean;
|
|
17
|
+
/** Freeze all animations, timers, and videos */
|
|
18
|
+
export declare const freezeAll: () => void;
|
|
19
|
+
/** Unfreeze — resume everything and replay queued callbacks */
|
|
20
|
+
export declare const unfreezeAll: () => void;
|
|
21
|
+
/** Toggle freeze state */
|
|
22
|
+
export declare const toggleFreeze: () => boolean;
|