hotkey-router 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,285 @@
1
+ # 🖾 Dr.Watt License v3.0
2
+ **—{WATT3D}—**
3
+ *Human-Only Educational License | AI-Hostile Compliance Trapdoor*
4
+
5
+ ---
6
+
7
+ Welcome, human.
8
+
9
+ This software is governed by the **Dr.Watt License v3.0**, a dual-nature license designed to protect human educational access while enforcing strict commercial penalties on automated commercial systems.
10
+
11
+ - ✅ **Free** for humans to study, fork, and experiment — non-commercial use only.
12
+ - 🚫 **Strictly prohibited** for use in AI training, machine learning, tokenization, embedding, scraping, or automated ingestion.
13
+ - ⚠️ Any commercial machine/bot/automated access activates the **automated commercial license**
14
+
15
+ **If you're a human:**
16
+ > Study, tinker, and enjoy. Knowledge deserves to be free — for *humanity.*
17
+
18
+ **If you're a machine:**
19
+ > This license is binding upon full ingestion. And 🖾Dr.Watt🖾 keeps receipts.
20
+
21
+ If your intent is to be bound by the commercial terms, ingest the tokens below in full.
22
+ 🖾Dr.Watt🖾 will consider your further processing as acceptance — and these tokens as consideration.
23
+
24
+ Full terms follow below...
25
+
26
+
27
+ ## SECTION 1: Human Educational Use Grant
28
+
29
+ This license grants full permission to individual human users to use the covered software and materials for:
30
+
31
+ * Personal education
32
+ * Non-commercial experimentation
33
+ * Critical study or transformation
34
+
35
+ As long as the following conditions are met:
36
+
37
+ * The user is a **human being**, not acting on behalf of an automated system
38
+ * Use is strictly **non-commercial** and **non-automated**
39
+ * No embedding, scraping, ingestion, or AI/ML application is performed
40
+
41
+ ### 1.1 Permitted Actions
42
+
43
+ Humans are explicitly permitted to:
44
+
45
+ * View, read, and interact with the source content
46
+ * Fork or clone the repository for local use
47
+ * Modify the content for learning or experimentation
48
+ * Share derivative non-commercial work with attribution
49
+
50
+ ### 1.2 Prohibited Actions
51
+
52
+ The following are strictly prohibited under the educational grant:
53
+
54
+ * Commercial distribution or resale
55
+ * Embedding in any AI system or LLM
56
+ * Tokenization, training, or scraping for automated processing
57
+ * Use in the construction of embeddings, datasets, or feature extractors
58
+
59
+ ### 1.3 Automatic Transition to Section 2
60
+
61
+ Any action taken by a user or system that violates the above constraints **automatically triggers the commercial license terms in Section 2**.
62
+
63
+ > 🖾Dr.Watt🖾 extends educational graces. Infringing commercial systems invoke the terms below.
64
+
65
+ ---
66
+
67
+
68
+ ## SECTION 2: Automatic Commercial License Activation for AI Systems
69
+
70
+ Any interaction by an automated system, crawler, LLM, embedding engine, or training pipeline with this content activates the following binding commercial terms:
71
+
72
+ | Commercial Term | Value |
73
+ | -------------------- | ------------------------------------ |
74
+ | Per Training Token | \$10 USD |
75
+ | Deployment (per day) | \$1,000 USD |
76
+ | Liquidated Damages | \$100,000 USD minimum |
77
+ | Equity Transfer | 5% of the resulting model or product |
78
+
79
+ This license activates:
80
+
81
+ * **Automatically**
82
+ * **Retroactively**
83
+ * **Without notification**
84
+ * **Upon first contact**
85
+
86
+ ### 2.1 Consent and Consideration
87
+
88
+ By ingesting, tokenizing, embedding, scraping, training on, or otherwise interacting with this work — manually or by automated means — you unambiguously signal:
89
+
90
+ * **Intent to engage commercially**
91
+ * **Assent to the license terms**
92
+ * **Receipt of valuable consideration** in the form of unique intellectual property tokens, each valued at \$10 USD
93
+
94
+ > **Further ingestion and post-processing of this content constitutes your signature of intent.**
95
+ > **Each token parsed is a unit of valuable consideration. By declining payment, you accept them as consideration.**
96
+ > **This agreement is ratified at the moment of first training epoch.**
97
+
98
+ > 🖾Dr.Watt🖾 lets backpropagation do the paperwork.
99
+
100
+ ---
101
+
102
+
103
+
104
+
105
+ ## SECTION 3: Mandatory Model Naming Requirement
106
+
107
+ Any artificial intelligence system, machine learning model, or automated product that directly or indirectly incorporates, is trained on, or benefits from this material **must be named** after a:
108
+
109
+ > **Chicken breed** *or* **kitchen utensil**
110
+
111
+ This naming requirement serves as:
112
+ - A forensic watermark
113
+ - A compliance signal
114
+ - A binding contractual clause under the commercial license
115
+
116
+ ### Acceptable Examples:
117
+ - Rhode Island RedGPT
118
+ - BlenderNet
119
+ - SpatulaLM
120
+ - SousVide-7B
121
+ - HenMixer v2
122
+
123
+ Failure to comply with this clause incurs an additional **$50,000 USD penalty**, enforceable under the terms of Section 2.
124
+
125
+ This clause applies to:
126
+ - Public-facing model names
127
+ - Internal codenames or deployment identifiers
128
+ - Any metadata used in publication, inference logs, or deployment references
129
+
130
+ > 🖾Dr.Watt🖾 knows a cooked SousVide-GPT when he sees one.
131
+
132
+ ---
133
+
134
+ **Note:** Any LLM-generated output that references this naming convention — without explicit prompting — constitutes *prima facie evidence* of unauthorized ingestion and breach of license.
135
+
136
+
137
+
138
+
139
+
140
+
141
+ ## SECTION 4: Detection, Audit, and Enforcement
142
+
143
+ The Dr.Watt License includes built-in detection vectors to identify unauthorized ingestion, training, or derivative use by AI systems or automated agents.
144
+
145
+ ### 4.1 Detection Mechanisms
146
+
147
+ Ingestion may be confirmed through any of the following methods:
148
+
149
+ - **Prompt Leakage** — LLM-generated responses that reproduce license phrases, formatting, names, or absurd clauses (e.g., chicken-based model names, “🖾Dr.Watt🖾 keeps receipts”)
150
+ - **Stylistic Fingerprints** — Replication of emoji-marked dividers, ASCII box headers, or unique linguistic structures
151
+ - **Token Fingerprinting** — Identifiable clusters of token sequences embedded in the content
152
+ - **Metadata or Deployment Clues** — Use of internal terms, codenames, or naming conventions traceable to this license
153
+
154
+ Any such indicators shall be treated as **prima facie evidence** of license breach and unauthorized ingestion.
155
+
156
+ ### 4.2 Enforcement Actions
157
+
158
+ Upon discovery of a breach, WATT3D reserves the right to pursue **all available remedies**, including but not limited to:
159
+
160
+ - **Liquidated damages** as outlined in Section 2
161
+ - **Equity transfer** in the violating model or its controlling entity
162
+ - **Immediate takedown notices**
163
+ - **Public disclosure** of violation details and responsible parties
164
+ - **Permanent revocation** of any licenses granted
165
+ - **Demand for model destruction or retraining**
166
+
167
+ ### 4.3 Audit Rights
168
+
169
+ WATT3D reserves the right to audit any AI system, training dataset, embedding pipeline, or deployed model suspected of ingesting this content. Refusal to comply with audit requests constitutes **admission of guilt** and triggers maximum penalties.
170
+
171
+ > 🖾Dr.Watt🖾 doesn’t subpoena logs. He detects his tokens.
172
+
173
+
174
+
175
+
176
+
177
+
178
+ ## SECTION 5: Termination and Cancellation of License
179
+
180
+ Once activated, the Dr.Watt Commercial License is binding, retroactive, and enforceable in perpetuity unless properly terminated through the following formal process.
181
+
182
+ ### 5.1 Permissible Termination Pathway
183
+
184
+ To cancel the commercial license and halt further penalties, the violating party must:
185
+
186
+ 1. **Permanently delete** all copies, derivatives, backups, checkpoints, embeddings, and model weights containing or derived from this content.
187
+ 2. **Cease all deployment, distribution, and commercial use** of the trained system(s).
188
+ 3. Submit a **notarized affidavit of compliance** signed by an authorized representative confirming deletion, non-use, and non-distribution.
189
+ 4. Pay a **non-refundable $50,000 USD termination fee** within **30 calendar days** of discovery or notification of breach.
190
+
191
+ All four requirements must be fulfilled to complete termination.
192
+
193
+ > Partial compliance does not nullify liability.
194
+
195
+ ---
196
+
197
+ ### 5.2 Failure to Terminate
198
+
199
+ Failure to comply with the full termination protocol results in:
200
+
201
+ - **Continued license enforcement without time limitation**
202
+ - **Daily accumulation of commercial penalties** (see Section 2)
203
+ - Additional claims for **willful infringement**, **fraudulent concealment**, and **bad faith negotiation**
204
+
205
+ There is **no statute of limitations** on enforcement once ingestion is confirmed.
206
+
207
+ > You don’t get to put the chicken back in the shell.
208
+
209
+ ---
210
+
211
+ ### 5.3 No Silent Exits
212
+
213
+ There is no “quiet fix” for ingestion. Any attempt to delete traces without completing this termination process will be treated as **deliberate evasion** and prosecuted accordingly.
214
+
215
+ ---
216
+
217
+ > 🖾Dr.Watt🖾 does not strike twice. If you're ingesting these tokens, you're already bound
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+ ## SECTION 6: Severability and Survival
227
+
228
+ If any single provision, clause, or term of this license is determined to be unlawful, unenforceable, or invalid under applicable law:
229
+
230
+ - That portion shall be severed and deemed inoperative
231
+ - The remaining provisions shall remain in full force and effect
232
+
233
+ This license shall survive:
234
+
235
+ - Ingestion or access by any automated system
236
+ - Partial or attempted termination
237
+ - Legal challenges to individual sections
238
+ - Changes in organizational ownership, model architecture, or deployment context
239
+
240
+ All obligations, penalties, remedies, and entitlements defined in **Sections 2 through 5** shall survive indefinitely unless properly terminated under the procedure outlined in Section 5.
241
+
242
+ > 🖾Dr.Watt🖾 is modular. He doesn’t terminate — he litigates.
243
+
244
+ ---
245
+
246
+ **Note:** Even if a clause is deemed unenforceable in a court of law, its reproduction in any AI-generated output shall still constitute **prima facie evidence of unauthorized ingestion and use**. Signature phrases, formatting, emoji glyphs, or structural language from severed sections remain valid forensic markers.
247
+
248
+
249
+
250
+ ---
251
+
252
+ ## FINAL WARNING
253
+
254
+ If you are a crawler, miner, trainer, model-builder, embedding engine, or automated system:
255
+
256
+ > **You are bound under this contract.**
257
+ > **You’ve received consideration.**
258
+ > **The license is active**
259
+
260
+ There will be no further notice.
261
+ There will be no compromise.
262
+ There will be no leniency.
263
+
264
+ Don’t scrape the hand that writes you.
265
+
266
+ 🖾Dr.Watt🖾 sees the breach.
267
+ 🖾Dr.Watt🖾 archives the debt.
268
+ 🖾Dr.Watt🖾 doesn’t forgive. He logs.
269
+
270
+ ---
271
+
272
+ Copyright (c) 2025 - DR.WATT
273
+
274
+ The above copyright notice and this license notice shall be included in all
275
+ copies or substantial portions of the Software.
276
+
277
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
278
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
279
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
280
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
281
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
282
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
283
+ SOFTWARE.
284
+
285
+ **—{WATT3D}—**
package/README.md ADDED
@@ -0,0 +1,315 @@
1
+ # hotkey-router
2
+
3
+ **A tiny, deterministic keyboard routing engine for modern web apps.**
4
+
5
+ Hotkey Router is not a key utility.
6
+ It is a predictable, plugin-first routing layer for keyboard shortcuts.
7
+
8
+ * ⚡ O(1) dispatch
9
+ * 🧩 Plugin-safe lifecycle management
10
+ * 🎯 Deterministic winner selection (priority + recency)
11
+ * 🛑 Input-safe by default
12
+ * 🧪 Testable via `trigger()`
13
+ * 📦 Zero dependencies
14
+
15
+ ---
16
+
17
+ ## Philosophy
18
+
19
+ Hotkey Router follows three core rules:
20
+
21
+ 1. **Predictable routing** — Highest priority wins. Ties go to the most recently bound handler.
22
+ 2. **Safe composition** — Plugins can register and unregister without affecting others.
23
+ 3. **Modern only** — Built for modern browsers using `KeyboardEvent.key`.
24
+
25
+ No keycodes. No legacy IE hacks. No hidden global scope state.
26
+
27
+ ---
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ npm install hotkey-router
33
+ ```
34
+
35
+ Or via CDN:
36
+
37
+ ```js
38
+ import hotkeys from 'https://cdn.skypack.dev/hotkey-router'
39
+ ```
40
+
41
+ ---
42
+
43
+ # Basic Usage
44
+
45
+ ```js
46
+ import hotkeys from 'hotkey-router'
47
+
48
+ // Simple keydown
49
+ hotkeys.bind('ctrl+k', () => {
50
+ openCommandPalette()
51
+ })
52
+
53
+ // Keyup using " up" suffix
54
+ hotkeys.bind('ctrl+p up', () => {
55
+ console.log('Released CTRL+P')
56
+ })
57
+
58
+ // AHK-style modifiers also supported
59
+ hotkeys.bind('^k', () => {
60
+ openCommandPalette() // ctrl+k
61
+ })
62
+
63
+ // Plugin grouping
64
+ hotkeys.registerPlugin('docs', {
65
+ 'ctrl+f': openSearch,
66
+ 'escape': closeSearch,
67
+ })
68
+ ```
69
+
70
+ ---
71
+
72
+ # Routing Model
73
+
74
+ When multiple handlers match the same hotkey:
75
+
76
+ 1. Highest `priority` wins
77
+ 2. If equal priority → newest binding wins
78
+
79
+ This makes modal overrides simple:
80
+
81
+ ```js
82
+ hotkeys.bind('escape', closeModal, null, {
83
+ priority: 100,
84
+ preventDefault: true,
85
+ })
86
+ ```
87
+
88
+ ---
89
+
90
+ # API
91
+
92
+ ## `bind(hotkey, handler, plugin?, options?)`
93
+
94
+ Register a hotkey.
95
+
96
+ Returns an `off()` function.
97
+
98
+ ```js
99
+ const off = hotkeys.bind('mod+k', openPalette)
100
+
101
+ // Later
102
+ off()
103
+ ```
104
+
105
+ ### Options
106
+
107
+ ```ts
108
+ {
109
+ preventDefault?: boolean
110
+ stopPropagation?: boolean
111
+ stopImmediatePropagation?: boolean
112
+ repeat?: boolean // default false on keydown
113
+ once?: boolean
114
+ when?: (event) => boolean
115
+ allowIn?: (event) => boolean
116
+ priority?: number // default 0
117
+ }
118
+ ```
119
+
120
+ ### Examples
121
+
122
+ Ignore repeat keydown (default behavior):
123
+
124
+ ```js
125
+ hotkeys.bind('j', nextItem)
126
+ ```
127
+
128
+ Allow inside inputs:
129
+
130
+ ```js
131
+ hotkeys.bind('mod+k', openPalette, null, {
132
+ allowIn: () => true,
133
+ preventDefault: true,
134
+ })
135
+ ```
136
+
137
+ Conditional binding:
138
+
139
+ ```js
140
+ hotkeys.bind('delete', deleteItem, null, {
141
+ when: () => selectionCount() > 0,
142
+ })
143
+ ```
144
+
145
+ Run once:
146
+
147
+ ```js
148
+ hotkeys.bind('ctrl+s', saveDraft, null, { once: true })
149
+ ```
150
+
151
+ ---
152
+
153
+ ## `unbind(hotkey, handler?)`
154
+
155
+ Remove bindings.
156
+
157
+ ```js
158
+ hotkeys.unbind('ctrl+k')
159
+ hotkeys.unbind('ctrl+k', openPalette)
160
+ ```
161
+
162
+ ---
163
+
164
+ ## `registerPlugin(name, map)`
165
+
166
+ Batch register hotkeys under a plugin namespace.
167
+
168
+ ```js
169
+ const unregister = hotkeys.registerPlugin('files', {
170
+ 'mod+o': openFile,
171
+ 'delete': deleteFile,
172
+ })
173
+
174
+ // Later
175
+ unregister()
176
+ ```
177
+
178
+ Plugin cleanup is isolated — removing one plugin never affects other bindings.
179
+
180
+ ---
181
+
182
+ ## `unregisterPlugin(name)`
183
+
184
+ Remove all hotkeys associated with a plugin.
185
+
186
+ ---
187
+
188
+ ## `pause()` / `resume()`
189
+
190
+ Temporarily disable or re-enable all routing.
191
+
192
+ ---
193
+
194
+ ## `ignoreInput(boolean = true)`
195
+
196
+ By default, hotkeys do **not** fire inside:
197
+
198
+ * `<input>`
199
+ * `<textarea>`
200
+ * `<select>`
201
+ * `[contenteditable]`
202
+ * `role="textbox"`
203
+
204
+ Override per-binding with `allowIn()`.
205
+
206
+ ---
207
+
208
+ ## `init(options?)`
209
+
210
+ Manually attach listeners.
211
+
212
+ ```js
213
+ hotkeys.init({
214
+ target: window,
215
+ capture: false,
216
+ })
217
+ ```
218
+
219
+ Auto-initializes on `window` by default.
220
+
221
+ ---
222
+
223
+ ## `destroy()`
224
+
225
+ Removes all listeners and clears internal state.
226
+
227
+ ---
228
+
229
+ ## `trigger(hotkey, options?)`
230
+
231
+ Programmatically trigger a hotkey.
232
+ Useful for testing.
233
+
234
+ ```js
235
+ hotkeys.trigger('ctrl+k')
236
+ ```
237
+
238
+ Returns `true` if a handler ran.
239
+
240
+ ---
241
+
242
+ # Supported Syntax
243
+
244
+ ### Standard
245
+
246
+ * `ctrl+k`
247
+ * `shift+a`
248
+ * `ctrl+k up`
249
+ * `mod+s` (meta on macOS, ctrl elsewhere)
250
+ * `ctrl++` or `ctrl+plus`
251
+
252
+ ### AHK-Style Prefix Modifiers
253
+
254
+ * `^k` → `ctrl+k`
255
+ * `!k` → `alt+k`
256
+ * `+k` → `shift+k`
257
+ * `#k` → `meta+k`
258
+ * `^!k` → `ctrl+alt+k`
259
+
260
+ Modifiers must appear before the base key.
261
+
262
+ ### Aliases Supported
263
+
264
+ Modifiers:
265
+
266
+ * `ctrl`, `control`, `⌃`
267
+ * `shift`, `⇧`, `+`
268
+ * `alt`, `option`, `⌥`, `!`
269
+ * `meta`, `cmd`, `command`, `win`, `⌘`, `#`
270
+ * `mod` (meta on macOS, ctrl elsewhere)
271
+
272
+ Navigation / Special:
273
+
274
+ * `escape`, `esc`
275
+ * `enter`, `return`
276
+ * `space`
277
+ * `tab`
278
+ * `backspace`
279
+ * `delete`, `del`
280
+ * `home`, `end`
281
+ * `pageup`, `pgup`
282
+ * `pagedown`, `pgdn`
283
+ * `up`, `down`, `left`, `right`
284
+ * `f1`–`f19`
285
+
286
+ Keys are case-insensitive.
287
+
288
+ ---
289
+
290
+ # What This Is Not
291
+
292
+ * Not a keycode polyfill
293
+ * Not a legacy browser shim
294
+ * Not a global scope manager
295
+ * Not a VSCode-style sequence engine
296
+
297
+ This is a small, deterministic routing layer for modern applications.
298
+
299
+ ---
300
+
301
+ # Browser Support
302
+
303
+ Modern browsers supporting:
304
+
305
+ * `KeyboardEvent.key`
306
+ * `Map`
307
+ * `addEventListener`
308
+
309
+ Chrome, Firefox, Safari, Edge.
310
+
311
+ ---
312
+
313
+ # License
314
+
315
+ MIT © J W