hotkey-router 0.2.0 → 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/dist/auto.min.js CHANGED
@@ -1,3 +1,3 @@
1
- // hotkey-router v0.2.0 | SEE LICENSE IN LICENSE
1
+ // hotkey-router v0.2.1 | SEE LICENSE IN LICENSE
2
2
 
3
3
  function R(t,e,r,a){return t.addEventListener(e,r,a),()=>t.removeEventListener(e,r,a)}var W=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform),H=new Set(["ctrl","shift","alt","meta"]),U=Object.freeze({Alt:"alt",AltGraph:"alt",Control:"ctrl",Shift:"shift",Meta:"meta",OS:"meta"}),V=new Map([["^","ctrl"],["!","alt"],["+","shift"],["#","meta"]]),A=Object.freeze({esc:"escape",escape:"escape",space:" ",spacebar:" ",enter:"enter",return:"enter",del:"delete",delete:"delete",backspace:"backspace",tab:"tab",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright",home:"home",end:"end",pageup:"pageup",pagedown:"pagedown",pgup:"pageup",pgdn:"pagedown",cmd:"meta",command:"meta",win:"meta",meta:"meta",control:"ctrl",ctrl:"ctrl",option:"alt",alt:"alt",shift:"shift","\u2318":"meta","\u2303":"ctrl","\u2325":"alt","\u21E7":"shift",mod:W?"meta":"ctrl",plus:"+"}),M=!0,C=typeof window<"u"?window:null,p=[],u=new Map,w=new Map,v=new Map,E=!1,q=1;function F(t){let e=String(t??"").trim(),r=e.toLowerCase();return A[r]??(e===" "?" ":r)}function S({ctrl:t,shift:e,alt:r,meta:a,key:i,code:o,bareModifier:n}){if(n)return`__bare__:${n}`;let s="";return t&&(s+="ctrl+"),e&&(s+="shift+"),r&&(s+="alt+"),a&&(s+="meta+"),o?s+"code:"+o:s?s+i:i}function G(t){let e=U[t.key];return e?`__bare__:${e}`:S({ctrl:t.ctrlKey,shift:t.shiftKey,alt:t.altKey,meta:t.metaKey,key:F(t.key)})}function X(t){if(!t.code)return null;let e="";return t.ctrlKey&&(e+="ctrl+"),t.shiftKey&&(e+="shift+"),t.altKey&&(e+="alt+"),t.metaKey&&(e+="meta+"),e+"code:"+t.code}function Z(t){let e=F(t);return H.has(e)}var Q=/(^|\+)code:([A-Za-z][A-Za-z0-9_]*)/;function P(t){let e=String(t||"").trim(),r=/\s+up$/i.test(e),a=r?e.replace(/\s+up$/i,"").trim():e,i={ctrl:!1,shift:!1,alt:!1,meta:!1,key:null,code:null,bareModifier:null},o=a;for(;o.length;){let c=V.get(o[0])??null;if(!c)break;i[c]=!0,o=o.slice(1).trimStart()}let n=o.match(/code:[A-Za-z][A-Za-z0-9_]*/g);if(n&&n.length>1)throw new Error(`Invalid hotkey "${t}": multiple code: tokens not supported (got ${n.length}).`);let s=null,d=o.replace(Q,(c,y,j)=>(s=j,y+"__code__")).toLowerCase(),h=d.split("+").map(c=>c.trim()),m=h.filter(Boolean),f=h.some(c=>c==="")&&d.includes("++");if(!f){let c=!1;for(let y of m)if(Z(y)){if(c)throw new Error(`Invalid hotkey "${t}": modifiers must come before the base key (e.g. "ctrl+k", not "k+ctrl")`)}else c||(c=!0)}for(let c of m){if(c==="__code__"){i.code=s;continue}let y=A[c]??c;y==="ctrl"?i.ctrl=!0:y==="shift"?i.shift=!0:y==="alt"?i.alt=!0:y==="meta"?i.meta=!0:i.key=F(y)}if(!i.key&&!i.code&&f&&(i.key="+"),!i.key&&!i.code){let c=(i.ctrl?1:0)+(i.shift?1:0)+(i.alt?1:0)+(i.meta?1:0);if(c===1)i.bareModifier=i.ctrl?"ctrl":i.shift?"shift":i.alt?"alt":"meta";else throw c>1?new Error(`Invalid hotkey "${t}": multi-modifier bare bindings not supported. Add a base key (e.g. "ctrl+alt+x").`):new Error(`Invalid hotkey "${t}" (missing base key)`)}return{combo:i,type:r?"keyup":"keydown",raw:t}}function Y(t){let e=t?.target;if(!e)return!1;let r=String(e.tagName||"").toUpperCase();return e.isContentEditable||r==="INPUT"||r==="TEXTAREA"||r==="SELECT"||e.getAttribute?.("role")==="textbox"}function J(t,e){let r=e?{...e}:{};return t==="keydown"&&r.repeat==null&&(r.repeat=!1),r.priority==null&&(r.priority=0),r}function tt(t,e){let r=u.get(t);r||(r=new Map,u.set(t,r));let a=r.get(e);return a||(a=[],r.set(e,a)),a}function x(t){let e=v.get(t);if(!e)return!1;let{comboStr:r,type:a}=e,i=u.get(r),o=i?.get(a);if(!o?.length)return v.delete(t),!1;let n=o.filter(s=>s.id!==t);return n.length?i.set(a,n):i.delete(a),i.size||u.delete(r),v.delete(t),!0}function D(t,e,r=null,a={}){let{combo:i,type:o,raw:n}=P(t),s=S(i),l=J(o,a),d={id:q++,comboStr:s,type:o,combo:i,handler:e,plugin:r,raw:n,options:l};if(tt(s,o).push(d),v.set(d.id,{comboStr:s,type:o}),p.length)for(let m of p)try{m({combo:i,raw:n,options:l,plugin:r,id:d.id})}catch(f){console.error("[hotkey-router] onBind hook threw:",f)}let h=()=>x(d.id);return h.id=d.id,h.hotkey=n,h}function et(t){if(typeof t!="function")throw new TypeError("hotkeys.onBind(hook) expects a function");return p.push(t),()=>{p=p.filter(e=>e!==t)}}function rt(t,e){let{combo:r,type:a}=P(t),i=S(r),o=u.get(i);if(!o)return;let n=o.get(a);if(n?.length){if(e){let s=[];for(let l of n)l.handler===e?v.delete(l.id):s.push(l);s.length?o.set(a,s):o.delete(a)}else{for(let s of n)v.delete(s.id);o.delete(a)}o.size||u.delete(i)}}function it(t,e){if(w.has(t))throw new Error(`Plugin "${t}" already registered`);let r=[];for(let[a,i]of Object.entries(e)){let[o,n]=Array.isArray(i)?i:[i,{}],s=D(a,o,t,n);r.push(s.id)}return w.set(t,r),()=>I(t)}function I(t){let e=w.get(t);if(e){for(let r of e)x(r);w.delete(t)}}function at(){E=!0}function ot(){E=!1}function st(t=!0){M=!!t}function nt(t){C=t}function B(t){let e=null;for(let r of t)e?(r.options.priority>e.options.priority||r.options.priority===e.options.priority&&r.id>e.id)&&(e=r):e=r;return e}function T(t){return e=>{if(E)return;let r=M&&Y(e),a=G(e),i=X(e),o=new Set,n=[];for(let d of[a,i]){if(!d||o.has(d))continue;o.add(d);let h=u.get(d)?.get(t);if(h?.length)for(let m of h){let f=m.options;r&&!f.allowIn?.(e)||t==="keydown"&&f.repeat===!1&&e.repeat||f.when&&f.when(e)===!1||n.push(m)}}if(!n.length)return;let s=B(n),l=s.options;l.preventDefault&&e.preventDefault(),l.stopImmediatePropagation?e.stopImmediatePropagation():l.stopPropagation&&e.stopPropagation(),s.handler(e),l.once&&x(s.id)}}var b=null,k=null;function _({target:t=C,capture:e=!1}={}){if(!t)throw new Error("hotkeys.init() requires a target (e.g. window)");(b||k)&&z(),b=R(t,"keydown",T("keydown"),{capture:e}),k=R(t,"keyup",T("keyup"),{capture:e})}function z(){b?.(),k?.(),b=null,k=null,u.clear(),w.clear(),v.clear()}var ct={ctrl:"Control",shift:"Shift",alt:"Alt",meta:"Meta"};function lt(t,{type:e}={}){let{combo:r,type:a}=P(t),i=S(r),o=e||a,n=u.get(i)?.get(o);if(!n?.length)return!1;let s=r.bareModifier?ct[r.bareModifier]:r.key,l=!!r.alt,d=!!r.ctrl,h=!!r.shift,m=!!r.meta;r.bareModifier&&o==="keyup"&&(r.bareModifier==="alt"?l=!1:r.bareModifier==="ctrl"?d=!1:r.bareModifier==="shift"?h=!1:r.bareModifier==="meta"&&(m=!1));let f={type:o,key:s,code:r.code||null,ctrlKey:d,shiftKey:h,altKey:l,metaKey:m,repeat:!1,preventDefault(){},stopPropagation(){},stopImmediatePropagation(){},target:null},c=B(n.filter(y=>y.options.when?y.options.when(f)!==!1:!0));return c?(c.handler(f),c.options.once&&x(c.id),!0):!1}C&&_();var O={init:_,destroy:z,setTarget:nt,bind:D,unbind:rt,registerPlugin:it,unregisterPlugin:I,onBind:et,pause:at,resume:ot,ignoreInput:st,trigger:lt};var g={$comment:"Machine-readable companion to docs/browser-hotkeys.md. Each combo entry describes who claims the binding and how strongly. Intended for runtime conflict warnings in keyboard-routing libraries (e.g. hotkey-router) and dev-time validation in apps like WebRadar. Update both this file and the markdown together \u2014 the markdown is the human source of truth, this file is the machine projection.",version:{generated:"2026-05-17",schema:"1.0",sources:["https://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-quickly","https://firefox-source-docs.mozilla.org/devtools-user/keyboard_shortcuts/index.html","https://support.google.com/chrome/answer/157179","https://developer.chrome.com/docs/devtools/shortcuts","https://support.apple.com/guide/safari/keyboard-shortcuts-and-gestures-cpsh003/mac","https://developer.apple.com/documentation/safari-developer-tools/web-inspector","https://support.microsoft.com/en-us/microsoft-edge/keyboard-shortcuts-in-microsoft-edge-50d3edab-30d9-c7e4-21ce-37fe2713cfad","https://support.apple.com/en-us/102650","https://support.microsoft.com/en-us/windows/keyboard-shortcuts-in-windows-dcc61a57-8ff0-cffe-9796-cb9706c75eec","https://help.gnome.org/gnome-help/shell-keyboard-shortcuts.html"]},severityLevels:{hard:"Browser or OS intercepts before page-world keydown fires. preventDefault() can't recover it.","find-bar-only":"Reserved only when the browser's find bar has focus. Fires in page world during normal browsing.","menu-activation":"Win/Linux Alt+letter activates the browser menu bar. Hard to suppress reliably.","system-text":"Only reserved while a text input has focus (terminal-style cursor controls on macOS).",compose:"macOS Option+letter types a special character in text inputs. Outside inputs, free for page world.",os:"Operating system intercepts globally, before any application sees it.","devtools-open":"Only relevant when DevTools is already open; outside DevTools it fires normally."},$keyFormat:"Each combo key uses hotkey-router-compatible syntax: modifiers in canonical order (ctrl|meta|alt|shift) joined by '+', then the key (lowercased letter, or symbolic name). Per-platform tables use the platform's native modifier name \u2014 `meta` on macOS = Cmd, `meta` on Windows = Win, `ctrl` on Linux/Windows = the primary modifier.",platforms:{mac:{browsers:{firefox:{"meta+a":{action:"Select all",severity:"hard"},"meta+b":{action:"Bookmarks sidebar",severity:"hard"},"meta+c":{action:"Copy",severity:"hard"},"meta+d":{action:"Bookmark this page",severity:"hard"},"meta+e":{action:"Search from page",severity:"hard"},"meta+f":{action:"Find in page",severity:"hard"},"meta+g":{action:"Find next",severity:"hard"},"meta+j":{action:"Downloads",severity:"hard"},"meta+l":{action:"Focus address bar",severity:"hard"},"meta+n":{action:"New window",severity:"hard"},"meta+o":{action:"Open file",severity:"hard"},"meta+p":{action:"Print",severity:"hard"},"meta+r":{action:"Reload",severity:"hard"},"meta+s":{action:"Save page",severity:"hard"},"meta+t":{action:"New tab",severity:"hard"},"meta+u":{action:"View source",severity:"hard"},"meta+v":{action:"Paste",severity:"hard"},"meta+w":{action:"Close tab",severity:"hard"},"meta+x":{action:"Cut",severity:"hard"},"meta+y":{action:"Redo",severity:"hard"},"meta+z":{action:"Undo",severity:"hard"},"meta+shift+a":{action:"Add-ons manager",severity:"hard"},"meta+shift+b":{action:"Bookmarks toolbar",severity:"hard"},"meta+shift+c":{action:"Inspector (element picker)",severity:"hard"},"meta+shift+d":{action:"Bookmark all tabs",severity:"hard"},"meta+shift+e":{action:"Network Monitor",severity:"hard"},"meta+shift+f":{action:"Toggle fullscreen",severity:"hard"},"meta+shift+g":{action:"Find previous",severity:"find-bar-only"},"meta+shift+j":{action:"Browser Console",severity:"hard"},"meta+shift+n":{action:"New private window",severity:"hard"},"meta+shift+o":{action:"Bookmarks library",severity:"hard"},"meta+shift+p":{action:"New private window (alt)",severity:"hard"},"meta+shift+q":{action:"Quit (with confirm)",severity:"hard"},"meta+shift+s":{action:"Firefox Screenshot",severity:"hard"},"meta+shift+t":{action:"Reopen closed tab",severity:"hard"},"meta+shift+v":{action:"Paste as plain text",severity:"hard"},"meta+shift+w":{action:"Close window",severity:"hard"},"meta+shift+z":{action:"Redo",severity:"hard"},"meta+alt+c":{action:"Inspector",severity:"hard"},"meta+alt+e":{action:"Network Monitor",severity:"hard"},"meta+alt+i":{action:"DevTools Toolbox",severity:"hard"},"meta+alt+j":{action:"Browser Console",severity:"hard"},"meta+alt+k":{action:"Web Console",severity:"hard"},"meta+alt+m":{action:"Responsive Design Mode",severity:"hard"},"meta+alt+z":{action:"Debugger",severity:"hard"}},chrome:{"meta+a":{action:"Select all",severity:"hard"},"meta+c":{action:"Copy",severity:"hard"},"meta+d":{action:"Bookmark this page",severity:"hard"},"meta+e":{action:"Search selected text",severity:"find-bar-only"},"meta+f":{action:"Find in page",severity:"hard"},"meta+g":{action:"Find next",severity:"hard"},"meta+l":{action:"Focus address bar",severity:"hard"},"meta+n":{action:"New window",severity:"hard"},"meta+o":{action:"Open file",severity:"hard"},"meta+p":{action:"Print",severity:"hard"},"meta+r":{action:"Reload",severity:"hard"},"meta+s":{action:"Save page",severity:"hard"},"meta+t":{action:"New tab",severity:"hard"},"meta+v":{action:"Paste",severity:"hard"},"meta+w":{action:"Close tab",severity:"hard"},"meta+x":{action:"Cut",severity:"hard"},"meta+y":{action:"History page",severity:"hard"},"meta+z":{action:"Undo",severity:"hard"},"meta+shift+b":{action:"Bookmarks bar toggle",severity:"hard"},"meta+shift+c":{action:"DevTools Inspector",severity:"hard"},"meta+shift+d":{action:"Bookmark all tabs",severity:"hard"},"meta+shift+g":{action:"Find previous",severity:"find-bar-only"},"meta+shift+j":{action:"Downloads page",severity:"hard"},"meta+shift+m":{action:"Switch user / guest",severity:"hard"},"meta+shift+n":{action:"New incognito window",severity:"hard"},"meta+shift+r":{action:"Hard reload",severity:"hard"},"meta+shift+t":{action:"Reopen closed tab",severity:"hard"},"meta+shift+v":{action:"Paste as plain text",severity:"hard"},"meta+shift+w":{action:"Close window",severity:"hard"},"meta+shift+z":{action:"Redo",severity:"hard"},"meta+alt+i":{action:"DevTools",severity:"hard"},"meta+alt+j":{action:"DevTools (console)",severity:"hard"},"meta+alt+u":{action:"View source",severity:"hard"}},safari:{"meta+a":{action:"Select all",severity:"hard"},"meta+c":{action:"Copy",severity:"hard"},"meta+d":{action:"Add to Reading List",severity:"hard"},"meta+f":{action:"Find in page",severity:"hard"},"meta+g":{action:"Find next",severity:"hard"},"meta+j":{action:"Downloads",severity:"hard"},"meta+l":{action:"Focus Smart Search",severity:"hard"},"meta+n":{action:"New window",severity:"hard"},"meta+p":{action:"Print",severity:"hard"},"meta+r":{action:"Reload",severity:"hard"},"meta+s":{action:"Save page",severity:"hard"},"meta+t":{action:"New tab",severity:"hard"},"meta+v":{action:"Paste",severity:"hard"},"meta+w":{action:"Close tab",severity:"hard"},"meta+x":{action:"Cut",severity:"hard"},"meta+z":{action:"Undo",severity:"hard"},"meta+shift+c":{action:"Inspector pick element",severity:"hard"},"meta+shift+d":{action:"Add Reading List item",severity:"hard"},"meta+shift+g":{action:"Find previous",severity:"find-bar-only"},"meta+shift+h":{action:"Go to homepage",severity:"hard"},"meta+shift+n":{action:"New private window",severity:"hard"},"meta+shift+r":{action:"Reader mode",severity:"hard"},"meta+shift+t":{action:"Reopen last closed tab",severity:"hard"},"meta+shift+v":{action:"Paste as plain text",severity:"hard"},"meta+shift+w":{action:"Close window",severity:"hard"},"meta+shift+z":{action:"Redo",severity:"hard"},"meta+alt+c":{action:"Web Inspector pick",severity:"hard"},"meta+alt+i":{action:"Web Inspector",severity:"hard"}}},system:{"meta+space":{action:"Spotlight",severity:"os"},"meta+tab":{action:"App switcher",severity:"os"},"meta+h":{action:"Hide app",severity:"os"},"meta+m":{action:"Minimize window",severity:"os"},"meta+q":{action:"Quit app",severity:"os"},"meta+shift+3":{action:"Screenshot full screen",severity:"os"},"meta+shift+4":{action:"Screenshot selection",severity:"os"},"meta+shift+5":{action:"Screen recording tool",severity:"os"},"meta+shift+q":{action:"Log out",severity:"os"},"meta+ctrl+q":{action:"Lock screen",severity:"os"},"meta+ctrl+space":{action:"Character Viewer",severity:"os"},"meta+alt+esc":{action:"Force-quit dialog",severity:"os"}},noteForLetterCombos:{"alt+a..z":{behavior:"compose",note:"Option+letter types special characters in text inputs (Option+E\u2192\xB4, Option+A\u2192\xE5, Option+F\u2192\u0192). Outside inputs, free for page world."},"ctrl+a..z":{behavior:"system-text",note:"Mac uses Ctrl+letter as terminal-style cursor controls inside text inputs (Ctrl+A=line start, Ctrl+E=line end, Ctrl+K=delete-to-end, etc.). Outside inputs, free for page world."}}},windows:{browsers:{firefox:{"ctrl+a":{action:"Select all",severity:"hard"},"ctrl+b":{action:"Bookmarks sidebar",severity:"hard"},"ctrl+c":{action:"Copy",severity:"hard"},"ctrl+d":{action:"Bookmark this page",severity:"hard"},"ctrl+f":{action:"Find in page",severity:"hard"},"ctrl+g":{action:"Find next",severity:"hard"},"ctrl+h":{action:"History sidebar",severity:"hard"},"ctrl+j":{action:"Downloads",severity:"hard"},"ctrl+l":{action:"Focus address bar",severity:"hard"},"ctrl+n":{action:"New window",severity:"hard"},"ctrl+o":{action:"Open file",severity:"hard"},"ctrl+p":{action:"Print",severity:"hard"},"ctrl+r":{action:"Reload",severity:"hard"},"ctrl+s":{action:"Save page",severity:"hard"},"ctrl+t":{action:"New tab",severity:"hard"},"ctrl+u":{action:"View source",severity:"hard"},"ctrl+v":{action:"Paste",severity:"hard"},"ctrl+w":{action:"Close tab",severity:"hard"},"ctrl+x":{action:"Cut",severity:"hard"},"ctrl+y":{action:"Redo",severity:"hard"},"ctrl+z":{action:"Undo",severity:"hard"},"ctrl+shift+a":{action:"Add-ons manager",severity:"hard"},"ctrl+shift+b":{action:"Bookmarks toolbar",severity:"hard"},"ctrl+shift+c":{action:"Inspector (element picker)",severity:"hard"},"ctrl+shift+d":{action:"Bookmark all tabs",severity:"hard"},"ctrl+shift+e":{action:"Network Monitor",severity:"hard"},"ctrl+shift+g":{action:"Find previous",severity:"find-bar-only"},"ctrl+shift+i":{action:"Developer Tools",severity:"hard"},"ctrl+shift+j":{action:"Browser Console",severity:"hard"},"ctrl+shift+k":{action:"Web Console",severity:"hard"},"ctrl+shift+m":{action:"Responsive Design Mode",severity:"hard"},"ctrl+shift+n":{action:"New private window",severity:"hard"},"ctrl+shift+o":{action:"Bookmarks library",severity:"hard"},"ctrl+shift+p":{action:"New private window (alt)",severity:"hard"},"ctrl+shift+s":{action:"Firefox Screenshot",severity:"hard"},"ctrl+shift+t":{action:"Reopen closed tab",severity:"hard"},"ctrl+shift+v":{action:"Paste as plain text",severity:"hard"},"ctrl+shift+w":{action:"Close window",severity:"hard"},"ctrl+shift+y":{action:"Downloads (alt)",severity:"hard"},"ctrl+shift+z":{action:"Debugger",severity:"hard"},"alt+f":{action:"File menu",severity:"menu-activation"},"alt+e":{action:"Edit menu",severity:"menu-activation"},"alt+v":{action:"View menu",severity:"menu-activation"},"alt+b":{action:"Bookmarks menu",severity:"menu-activation"},"alt+t":{action:"Tools menu",severity:"menu-activation"},"alt+h":{action:"Help menu",severity:"menu-activation"},"alt+d":{action:"Focus address bar",severity:"hard"}},chrome:{"ctrl+a":{action:"Select all",severity:"hard"},"ctrl+c":{action:"Copy",severity:"hard"},"ctrl+d":{action:"Bookmark this page",severity:"hard"},"ctrl+e":{action:"Search from page",severity:"hard"},"ctrl+f":{action:"Find in page",severity:"hard"},"ctrl+g":{action:"Find next",severity:"hard"},"ctrl+h":{action:"History page",severity:"hard"},"ctrl+j":{action:"Downloads",severity:"hard"},"ctrl+k":{action:"Search from page",severity:"hard"},"ctrl+l":{action:"Focus address bar",severity:"hard"},"ctrl+n":{action:"New window",severity:"hard"},"ctrl+o":{action:"Open file",severity:"hard"},"ctrl+p":{action:"Print",severity:"hard"},"ctrl+r":{action:"Reload",severity:"hard"},"ctrl+s":{action:"Save page",severity:"hard"},"ctrl+t":{action:"New tab",severity:"hard"},"ctrl+u":{action:"View source",severity:"hard"},"ctrl+v":{action:"Paste",severity:"hard"},"ctrl+w":{action:"Close tab",severity:"hard"},"ctrl+x":{action:"Cut",severity:"hard"},"ctrl+z":{action:"Undo",severity:"hard"},"ctrl+shift+b":{action:"Bookmarks bar toggle",severity:"hard"},"ctrl+shift+d":{action:"Bookmark all tabs",severity:"hard"},"ctrl+shift+g":{action:"Find previous",severity:"find-bar-only"},"ctrl+shift+i":{action:"DevTools",severity:"hard"},"ctrl+shift+j":{action:"DevTools (console)",severity:"hard"},"ctrl+shift+m":{action:"Switch user / guest",severity:"hard"},"ctrl+shift+n":{action:"Incognito window",severity:"hard"},"ctrl+shift+r":{action:"Hard reload",severity:"hard"},"ctrl+shift+t":{action:"Reopen closed tab",severity:"hard"},"ctrl+shift+v":{action:"Paste as plain text",severity:"hard"},"ctrl+shift+w":{action:"Close window",severity:"hard"},"alt+d":{action:"Focus address bar",severity:"hard"},"alt+e":{action:"Customize menu",severity:"menu-activation"},"alt+f":{action:"Customize menu (alt)",severity:"menu-activation"}},edge:{"ctrl+a":{action:"Select all",severity:"hard"},"ctrl+c":{action:"Copy",severity:"hard"},"ctrl+d":{action:"Favorite this page",severity:"hard"},"ctrl+e":{action:"Search from page",severity:"hard"},"ctrl+f":{action:"Find in page",severity:"hard"},"ctrl+g":{action:"Find next",severity:"hard"},"ctrl+h":{action:"History",severity:"hard"},"ctrl+j":{action:"Downloads",severity:"hard"},"ctrl+k":{action:"Search from page",severity:"hard"},"ctrl+l":{action:"Focus address bar",severity:"hard"},"ctrl+m":{action:"Mute current tab",severity:"hard"},"ctrl+n":{action:"New window",severity:"hard"},"ctrl+o":{action:"Open file",severity:"hard"},"ctrl+p":{action:"Print",severity:"hard"},"ctrl+r":{action:"Reload",severity:"hard"},"ctrl+s":{action:"Save page",severity:"hard"},"ctrl+t":{action:"New tab",severity:"hard"},"ctrl+u":{action:"View source",severity:"hard"},"ctrl+v":{action:"Paste",severity:"hard"},"ctrl+w":{action:"Close tab",severity:"hard"},"ctrl+x":{action:"Cut",severity:"hard"},"ctrl+z":{action:"Undo",severity:"hard"},"ctrl+shift+b":{action:"Favorites bar toggle",severity:"hard"},"ctrl+shift+d":{action:"Bookmark all tabs in folder",severity:"hard"},"ctrl+shift+e":{action:"Search in sidebar",severity:"hard"},"ctrl+shift+g":{action:"Find previous",severity:"find-bar-only"},"ctrl+shift+i":{action:"DevTools",severity:"hard"},"ctrl+shift+j":{action:"DevTools (console)",severity:"hard"},"ctrl+shift+k":{action:"Duplicate tab",severity:"hard"},"ctrl+shift+l":{action:"Paste and search",severity:"hard"},"ctrl+shift+m":{action:"Switch user / guest",severity:"hard"},"ctrl+shift+n":{action:"InPrivate window",severity:"hard"},"ctrl+shift+o":{action:"Open favorites",severity:"hard"},"ctrl+shift+p":{action:"Print (system dialog)",severity:"hard"},"ctrl+shift+r":{action:"Hard reload",severity:"hard"},"ctrl+shift+t":{action:"Reopen closed tab",severity:"hard"},"ctrl+shift+u":{action:"Read Aloud toggle",severity:"hard"},"ctrl+shift+v":{action:"Paste without formatting",severity:"hard"},"ctrl+shift+w":{action:"Close window",severity:"hard"},"ctrl+shift+y":{action:"Collections",severity:"hard"},"alt+d":{action:"Focus address bar",severity:"hard"},"alt+e":{action:"Settings menu",severity:"menu-activation"},"alt+f":{action:"Settings menu (alt)",severity:"menu-activation"},"alt+shift+b":{action:"Focus favorites bar",severity:"hard"},"alt+shift+i":{action:"Send feedback dialog",severity:"hard"},"alt+shift+t":{action:"Focus app bar toolbar",severity:"hard"}}},system:{"meta+a":{action:"Action Center",severity:"os"},"meta+c":{action:"Windows search",severity:"os"},"meta+d":{action:"Show desktop",severity:"os"},"meta+e":{action:"File Explorer",severity:"os"},"meta+g":{action:"Game bar",severity:"os"},"meta+h":{action:"Voice dictation",severity:"os"},"meta+i":{action:"Settings",severity:"os"},"meta+l":{action:"Lock",severity:"os"},"meta+n":{action:"Notification center",severity:"os"},"meta+p":{action:"Project / display mode",severity:"os"},"meta+r":{action:"Run dialog",severity:"os"},"meta+s":{action:"Search",severity:"os"},"meta+v":{action:"Clipboard history",severity:"os"},"meta+w":{action:"Widgets",severity:"os"},"meta+x":{action:"Quick Link menu",severity:"os"},"meta+z":{action:"Snap layouts",severity:"os"},"meta+tab":{action:"Task View",severity:"os"},"meta+shift+s":{action:"Screenshot region",severity:"os"},"ctrl+shift+esc":{action:"Task Manager",severity:"os"},"ctrl+alt+del":{action:"Security screen",severity:"os"},"alt+tab":{action:"Switch windows",severity:"os"},"alt+f4":{action:"Close active window",severity:"os"}}},linux:{browsers:{firefox:"$ref:platforms.windows.browsers.firefox",chrome:"$ref:platforms.windows.browsers.chrome",edge:"$ref:platforms.windows.browsers.edge"},system:{$comment:"GNOME defaults. KDE and other DEs have similar-shaped reservations but vary; this is a conservative baseline.","meta+tab":{action:"Switch windows",severity:"os"},"meta+a":{action:"Show applications",severity:"os"},"meta+l":{action:"Lock screen",severity:"os"},"meta+v":{action:"Notification list",severity:"os"},"alt+tab":{action:"Switch applications",severity:"os"},"alt+esc":{action:"Cycle windows",severity:"os"},"alt+f2":{action:"Run command",severity:"os"},"alt+f4":{action:"Close window",severity:"os"},"ctrl+alt+tab":{action:"Top-bar accessibility switcher",severity:"os"},"ctrl+alt+del":{action:"Power-off dialog",severity:"os"},"ctrl+shift+alt+r":{action:"Toggle screencast recording",severity:"os"}},noteForCtrlAlt:"Some Linux setups map right-Alt (AltGr) to 'compose' for typing accented characters, in which case AltGr+letter is reported as ctrl+alt+letter and types a special character. Avoid the ctrl+alt+letter namespace on Linux."}}};var ht="1.0",ft=new Set(["hard","os","menu-activation"]);function yt(t=typeof navigator<"u"?navigator:null){if(!t)return null;let e=t.platform||"";if(/Mac|iPhone|iPad|iPod/.test(e))return"mac";if(/Win/i.test(e))return"windows";if(/Linux|X11/i.test(e))return"linux";let r=t.userAgent||"";return/Mac OS X/i.test(r)?"mac":/Windows/i.test(r)?"windows":/Linux|X11/i.test(r)?"linux":null}function mt(t=typeof navigator<"u"?navigator:null){if(!t)return null;let e=t.userAgent||"";return/Edg\//.test(e)?"edge":/Firefox/.test(e)?"firefox":/Chrome/.test(e)?"chrome":/Safari/.test(e)?"safari":null}function ut(t){let e=String(t).toLowerCase().split("+").map(o=>o.trim()).filter(Boolean);if(!e.length)return"";let r=e[e.length-1],a=new Set(e.slice(0,-1)),i=[];return a.has("ctrl")&&i.push("ctrl"),a.has("meta")&&i.push("meta"),a.has("alt")&&i.push("alt"),a.has("shift")&&i.push("shift"),i.push(r),i.join("+")}function vt(t,e){if(typeof t!="string"||!t.startsWith("$ref:"))return t;let r=t.slice(5).split("."),a=e;for(let i of r)a=a?.[i];return a}function K(t){if(!t||typeof t!="object")return null;let e=Object.create(null);for(let[r,a]of Object.entries(t))!a||typeof a!="object"||!("severity"in a)||(e[ut(r)]=a);return e}function pt(t){let e={platforms:{}},r=t?.platforms||{};for(let[a,i]of Object.entries(r)){let o={};for(let[n,s]of Object.entries(i.browsers||{}))o[n]=K(vt(s,t));e.platforms[a]={browsers:o,system:K(i.system)}}return e}var N=g?.version?.schema===ht,wt=N?pt(g):{platforms:{}};function gt(t){if(!t)return null;let e=/^Key([A-Za-z])$/.exec(t);if(e)return e[1].toLowerCase();let r=/^Digit(\d)$/.exec(t);return r?r[1]:t.toLowerCase()}function bt(t){if(!t||t.bareModifier)return null;let e=t.code?gt(t.code):t.key;if(!e)return null;let r=[];return t.ctrl&&r.push("ctrl"),t.meta&&r.push("meta"),t.alt&&r.push("alt"),t.shift&&r.push("shift"),r.push(e),r.join("+")}function kt(t,{platform:e,browser:r}={}){if(!N)return null;let a=bt(t);if(!a)return null;let i=e&&wt.platforms[e];if(!i)return null;let n=(r?i.browsers?.[r]:null)?.[a];if(n)return{source:"browser",platform:e,browser:r,lookupKey:a,action:n.action,severity:n.severity};let s=i.system?.[a];return s?{source:"system",platform:e,browser:r,lookupKey:a,action:s.action,severity:s.severity}:null}var St={mac:"macOS",windows:"Windows",linux:"Linux"};function L(t){return ft.has(t)}function xt(t,e){let r=St[t.platform]||t.platform,a=t.source==="browser"?`${t.browser} on ${r}`:`${r}`,i=L(t.severity)?"will not fire":"fires in normal browsing";return`[hotkey-router] "${e}" (${t.lookupKey}) reserved by ${a}: "${t.action}" [${t.severity}] \u2014 ${i}.`}function Ct(t,e,r=console){let a=xt(t,e);(L(t.severity)?r.warn:r.info).call(r,a)}function $(t,e={}){if(!t||typeof t.onBind!="function")throw new TypeError("installReservationWarnings(hotkeys) requires a hotkey-router instance with onBind() (>= v0.2.0)");let r=e.platform!==void 0?e.platform:yt(),a=e.browser!==void 0?e.browser:mt(),i=e.console||console;return t.onBind(({combo:o,raw:n,options:s})=>{if(s?.warnOnReserved===!1||!r||!a)return;let l=kt(o,{platform:r,browser:a});l&&Ct(l,n,i)})}var Ot=g?.version?.schema,Rt=g?.version?.generated;$(O);var Dt=O;export{Dt as default};
@@ -1,4 +1,4 @@
1
- // hotkey-router v0.2.0 | SEE LICENSE IN LICENSE
1
+ // hotkey-router v0.2.1 | SEE LICENSE IN LICENSE
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,4 +1,4 @@
1
- // hotkey-router v0.2.0 | SEE LICENSE IN LICENSE
1
+ // hotkey-router v0.2.1 | SEE LICENSE IN LICENSE
2
2
 
3
3
 
4
4
  // hotkey-router.js
@@ -1,3 +1,3 @@
1
- // hotkey-router v0.2.0 | SEE LICENSE IN LICENSE
1
+ // hotkey-router v0.2.1 | SEE LICENSE IN LICENSE
2
2
 
3
3
  function P(e,t,n,s){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n,s)}var D=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform),F=new Set(["ctrl","shift","alt","meta"]),L=Object.freeze({Alt:"alt",AltGraph:"alt",Control:"ctrl",Shift:"shift",Meta:"meta",OS:"meta"}),R=new Map([["^","ctrl"],["!","alt"],["+","shift"],["#","meta"]]),T=Object.freeze({esc:"escape",escape:"escape",space:" ",spacebar:" ",enter:"enter",return:"enter",del:"delete",delete:"delete",backspace:"backspace",tab:"tab",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright",home:"home",end:"end",pageup:"pageup",pagedown:"pagedown",pgup:"pageup",pgdn:"pagedown",cmd:"meta",command:"meta",win:"meta",meta:"meta",control:"ctrl",ctrl:"ctrl",option:"alt",alt:"alt",shift:"shift","\u2318":"meta","\u2303":"ctrl","\u2325":"alt","\u21E7":"shift",mod:D?"meta":"ctrl",plus:"+"}),S=!0,_=typeof window<"u"?window:null,y=[],g=new Map,w=new Map,m=new Map,K=!1,N=1;function v(e){let t=String(e??"").trim(),n=t.toLowerCase();return T[n]??(t===" "?" ":n)}function E({ctrl:e,shift:t,alt:n,meta:s,key:o,code:r,bareModifier:l}){if(l)return`__bare__:${l}`;let i="";return e&&(i+="ctrl+"),t&&(i+="shift+"),n&&(i+="alt+"),s&&(i+="meta+"),r?i+"code:"+r:i?i+o:o}function U(e){let t=L[e.key];return t?`__bare__:${t}`:E({ctrl:e.ctrlKey,shift:e.shiftKey,alt:e.altKey,meta:e.metaKey,key:v(e.key)})}function Z(e){if(!e.code)return null;let t="";return e.ctrlKey&&(t+="ctrl+"),e.shiftKey&&(t+="shift+"),e.altKey&&(t+="alt+"),e.metaKey&&(t+="meta+"),t+"code:"+e.code}function j(e){let t=v(e);return F.has(t)}var H=/(^|\+)code:([A-Za-z][A-Za-z0-9_]*)/;function I(e){let t=String(e||"").trim(),n=/\s+up$/i.test(t),s=n?t.replace(/\s+up$/i,"").trim():t,o={ctrl:!1,shift:!1,alt:!1,meta:!1,key:null,code:null,bareModifier:null},r=s;for(;r.length;){let a=R.get(r[0])??null;if(!a)break;o[a]=!0,r=r.slice(1).trimStart()}let l=r.match(/code:[A-Za-z][A-Za-z0-9_]*/g);if(l&&l.length>1)throw new Error(`Invalid hotkey "${e}": multiple code: tokens not supported (got ${l.length}).`);let i=null,f=r.replace(H,(a,p,B)=>(i=B,p+"__code__")).toLowerCase(),u=f.split("+").map(a=>a.trim()),h=u.filter(Boolean),d=u.some(a=>a==="")&&f.includes("++");if(!d){let a=!1;for(let p of h)if(j(p)){if(a)throw new Error(`Invalid hotkey "${e}": modifiers must come before the base key (e.g. "ctrl+k", not "k+ctrl")`)}else a||(a=!0)}for(let a of h){if(a==="__code__"){o.code=i;continue}let p=T[a]??a;p==="ctrl"?o.ctrl=!0:p==="shift"?o.shift=!0:p==="alt"?o.alt=!0:p==="meta"?o.meta=!0:o.key=v(p)}if(!o.key&&!o.code&&d&&(o.key="+"),!o.key&&!o.code){let a=(o.ctrl?1:0)+(o.shift?1:0)+(o.alt?1:0)+(o.meta?1:0);if(a===1)o.bareModifier=o.ctrl?"ctrl":o.shift?"shift":o.alt?"alt":"meta";else throw a>1?new Error(`Invalid hotkey "${e}": multi-modifier bare bindings not supported. Add a base key (e.g. "ctrl+alt+x").`):new Error(`Invalid hotkey "${e}" (missing base key)`)}return{combo:o,type:n?"keyup":"keydown",raw:e}}function Y(e){let t=e?.target;if(!t)return!1;let n=String(t.tagName||"").toUpperCase();return t.isContentEditable||n==="INPUT"||n==="TEXTAREA"||n==="SELECT"||t.getAttribute?.("role")==="textbox"}function q(e,t){let n=t?{...t}:{};return e==="keydown"&&n.repeat==null&&(n.repeat=!1),n.priority==null&&(n.priority=0),n}function G(e,t){let n=g.get(e);n||(n=new Map,g.set(e,n));let s=n.get(t);return s||(s=[],n.set(t,s)),s}function M(e){let t=m.get(e);if(!t)return!1;let{comboStr:n,type:s}=t,o=g.get(n),r=o?.get(s);if(!r?.length)return m.delete(e),!1;let l=r.filter(i=>i.id!==e);return l.length?o.set(s,l):o.delete(s),o.size||g.delete(n),m.delete(e),!0}function O(e,t,n=null,s={}){let{combo:o,type:r,raw:l}=I(e),i=E(o),c=q(r,s),f={id:N++,comboStr:i,type:r,combo:o,handler:t,plugin:n,raw:l,options:c};if(G(i,r).push(f),m.set(f.id,{comboStr:i,type:r}),y.length)for(let h of y)try{h({combo:o,raw:l,options:c,plugin:n,id:f.id})}catch(d){console.error("[hotkey-router] onBind hook threw:",d)}let u=()=>M(f.id);return u.id=f.id,u.hotkey=l,u}function V(e){if(typeof e!="function")throw new TypeError("hotkeys.onBind(hook) expects a function");return y.push(e),()=>{y=y.filter(t=>t!==e)}}function W(e,t){let{combo:n,type:s}=I(e),o=E(n),r=g.get(o);if(!r)return;let l=r.get(s);if(l?.length){if(t){let i=[];for(let c of l)c.handler===t?m.delete(c.id):i.push(c);i.length?r.set(s,i):r.delete(s)}else{for(let i of l)m.delete(i.id);r.delete(s)}r.size||g.delete(o)}}function X(e,t){if(w.has(e))throw new Error(`Plugin "${e}" already registered`);let n=[];for(let[s,o]of Object.entries(t)){let[r,l]=Array.isArray(o)?o:[o,{}],i=O(s,r,e,l);n.push(i.id)}return w.set(e,n),()=>x(e)}function x(e){let t=w.get(e);if(t){for(let n of t)M(n);w.delete(e)}}function J(){K=!0}function Q(){K=!1}function ee(e=!0){S=!!e}function te(e){_=e}function z(e){let t=null;for(let n of e)t?(n.options.priority>t.options.priority||n.options.priority===t.options.priority&&n.id>t.id)&&(t=n):t=n;return t}function A(e){return t=>{if(K)return;let n=S&&Y(t),s=U(t),o=Z(t),r=new Set,l=[];for(let f of[s,o]){if(!f||r.has(f))continue;r.add(f);let u=g.get(f)?.get(e);if(u?.length)for(let h of u){let d=h.options;n&&!d.allowIn?.(t)||e==="keydown"&&d.repeat===!1&&t.repeat||d.when&&d.when(t)===!1||l.push(h)}}if(!l.length)return;let i=z(l),c=i.options;c.preventDefault&&t.preventDefault(),c.stopImmediatePropagation?t.stopImmediatePropagation():c.stopPropagation&&t.stopPropagation(),i.handler(t),c.once&&M(i.id)}}var b=null,k=null;function $({target:e=_,capture:t=!1}={}){if(!e)throw new Error("hotkeys.init() requires a target (e.g. window)");(b||k)&&C(),b=P(e,"keydown",A("keydown"),{capture:t}),k=P(e,"keyup",A("keyup"),{capture:t})}function C(){b?.(),k?.(),b=null,k=null,g.clear(),w.clear(),m.clear()}var ne={ctrl:"Control",shift:"Shift",alt:"Alt",meta:"Meta"};function oe(e,{type:t}={}){let{combo:n,type:s}=I(e),o=E(n),r=t||s,l=g.get(o)?.get(r);if(!l?.length)return!1;let i=n.bareModifier?ne[n.bareModifier]:n.key,c=!!n.alt,f=!!n.ctrl,u=!!n.shift,h=!!n.meta;n.bareModifier&&r==="keyup"&&(n.bareModifier==="alt"?c=!1:n.bareModifier==="ctrl"?f=!1:n.bareModifier==="shift"?u=!1:n.bareModifier==="meta"&&(h=!1));let d={type:r,key:i,code:n.code||null,ctrlKey:f,shiftKey:u,altKey:c,metaKey:h,repeat:!1,preventDefault(){},stopPropagation(){},stopImmediatePropagation(){},target:null},a=z(l.filter(p=>p.options.when?p.options.when(d)!==!1:!0));return a?(a.handler(d),a.options.once&&M(a.id),!0):!1}_&&$();var re={init:$,destroy:C,setTarget:te,bind:O,unbind:W,registerPlugin:X,unregisterPlugin:x,onBind:V,pause:J,resume:Q,ignoreInput:ee,trigger:oe};export{re as default};
@@ -1,4 +1,4 @@
1
- // hotkey-router v0.2.0 | SEE LICENSE IN LICENSE
1
+ // hotkey-router v0.2.1 | SEE LICENSE IN LICENSE
2
2
 
3
3
 
4
4
  // data/browser-hotkeys.json
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "hotkey-router",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A tiny, deterministic keyboard routing engine for modern web apps.",
5
5
  "type": "module",
6
- "author": "DR.WATT",
6
+ "author": "WATT3D <WATT3D@protonmail.com>",
7
7
  "license": "SEE LICENSE IN LICENSE",
8
8
  "keywords": [
9
9
  "hotkeys",
@@ -32,7 +32,9 @@
32
32
  "dist",
33
33
  "data",
34
34
  "README.md",
35
- "LICENSE"
35
+ "LICENSE",
36
+ "ADDITIONAL_TERMS.md",
37
+ "robots.txt"
36
38
  ],
37
39
  "scripts": {
38
40
  "build": "node build.js",
package/robots.txt ADDED
@@ -0,0 +1,79 @@
1
+ # WATT3D — AI scraping policy
2
+ #
3
+ # This file enumerates known AI / LLM training and inference crawlers
4
+ # that the WATT3D AI Training Rider does not consent to. See
5
+ # ./ADDITIONAL_TERMS.md for the legal scope and definitions.
6
+ #
7
+ # Honoring robots.txt is voluntary. The rider applies whether or not
8
+ # a bot respects this file. The enumeration is non-exhaustive — bots
9
+ # not listed here are still bound by the rider if they perform
10
+ # Training Use as defined in ADDITIONAL_TERMS.md §1.
11
+
12
+ User-agent: GPTBot
13
+ Disallow: /
14
+
15
+ User-agent: ChatGPT-User
16
+ Disallow: /
17
+
18
+ User-agent: OAI-SearchBot
19
+ Disallow: /
20
+
21
+ User-agent: anthropic-ai
22
+ Disallow: /
23
+
24
+ User-agent: ClaudeBot
25
+ Disallow: /
26
+
27
+ User-agent: Claude-Web
28
+ Disallow: /
29
+
30
+ User-agent: Claude-SearchBot
31
+ Disallow: /
32
+
33
+ User-agent: Google-Extended
34
+ Disallow: /
35
+
36
+ User-agent: Applebot-Extended
37
+ Disallow: /
38
+
39
+ User-agent: Meta-ExternalAgent
40
+ Disallow: /
41
+
42
+ User-agent: Meta-ExternalFetcher
43
+ Disallow: /
44
+
45
+ User-agent: FacebookBot
46
+ Disallow: /
47
+
48
+ User-agent: CCBot
49
+ Disallow: /
50
+
51
+ User-agent: PerplexityBot
52
+ Disallow: /
53
+
54
+ User-agent: Perplexity-User
55
+ Disallow: /
56
+
57
+ User-agent: cohere-ai
58
+ Disallow: /
59
+
60
+ User-agent: Bytespider
61
+ Disallow: /
62
+
63
+ User-agent: Amazonbot
64
+ Disallow: /
65
+
66
+ User-agent: Omgilibot
67
+ Disallow: /
68
+
69
+ User-agent: AI2Bot
70
+ Disallow: /
71
+
72
+ User-agent: Diffbot
73
+ Disallow: /
74
+
75
+ # Everyone else: full access. Search engines and human-driven crawlers
76
+ # remain welcome.
77
+
78
+ User-agent: *
79
+ Allow: /