zero-query 1.0.0 → 1.0.2

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.
@@ -7,7 +7,7 @@ export const notFound = {
7
7
  <h1>404</h1>
8
8
  <p class="subtitle">Page not found.</p>
9
9
  <p style="margin-top:1rem;">
10
- <a href="/" style="color:var(--accent);">← Home</a>
10
+ <a z-link="/" style="color:var(--accent);">← Home</a>
11
11
  </p>
12
12
  </div>
13
13
  `;
@@ -1,6 +1,8 @@
1
1
  // routes.js - Route definitions (shared between client and server)
2
2
 
3
3
  export const routes = [
4
- { path: '/', component: 'home-page' },
5
- { path: '/about', component: 'about-page' },
4
+ { path: '/', component: 'home-page' },
5
+ { path: '/blog', component: 'blog-list' },
6
+ { path: '/blog/:slug', component: 'blog-post' },
7
+ { path: '/about', component: 'about-page' },
6
8
  ];
@@ -49,6 +49,8 @@ body {
49
49
  padding: 0.4rem 0.8rem;
50
50
  border-radius: var(--radius);
51
51
  transition: color 0.2s, background 0.2s;
52
+ cursor: pointer;
53
+ user-select: none;
52
54
  }
53
55
  .nav-link:hover, .nav-link.active {
54
56
  color: var(--accent);
@@ -57,13 +59,12 @@ body {
57
59
 
58
60
  /* -- Main content -- */
59
61
  z-outlet {
60
- max-width: 800px;
62
+ display: block;
63
+ max-width: 1200px;
61
64
  margin: 2rem auto;
62
65
  padding: 0 1.5rem;
63
66
  }
64
67
 
65
- [z-cloak] { display: none !important; }
66
-
67
68
  .page-header {
68
69
  margin-bottom: var(--gap);
69
70
  }
@@ -92,6 +93,15 @@ z-outlet {
92
93
  border-radius: 4px;
93
94
  font-size: 0.9em;
94
95
  }
96
+ .card a {
97
+ color: var(--accent);
98
+ text-decoration: none;
99
+ transition: color 0.15s;
100
+ }
101
+ .card a:hover {
102
+ color: var(--accent-hover);
103
+ text-decoration: underline;
104
+ }
95
105
 
96
106
  .badge {
97
107
  display: inline-block;
@@ -103,6 +113,111 @@ z-outlet {
103
113
  .badge-ssr { background: rgba(0,212,255,0.15); color: var(--accent); }
104
114
  .badge-csr { background: rgba(255,165,0,0.15); color: #ffa500; }
105
115
 
116
+ /* -- Blog Grid -- */
117
+ .blog-grid {
118
+ display: grid;
119
+ grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
120
+ gap: var(--gap);
121
+ }
122
+
123
+ .blog-card {
124
+ display: block;
125
+ text-decoration: none;
126
+ color: inherit;
127
+ background: var(--surface);
128
+ border: 1px solid rgba(255,255,255,0.06);
129
+ border-radius: var(--radius);
130
+ padding: 1.5rem;
131
+ transition: border-color 0.2s, transform 0.2s;
132
+ cursor: pointer;
133
+ }
134
+ .blog-card:hover {
135
+ border-color: rgba(0, 212, 255, 0.25);
136
+ transform: translateY(-2px);
137
+ }
138
+
139
+ .blog-card-header {
140
+ display: flex;
141
+ align-items: center;
142
+ justify-content: space-between;
143
+ margin-bottom: 0.75rem;
144
+ }
145
+
146
+ .blog-date {
147
+ font-size: 0.8em;
148
+ color: var(--muted);
149
+ }
150
+
151
+ .blog-title {
152
+ font-size: 1.1rem;
153
+ margin-bottom: 0.5rem;
154
+ color: var(--text);
155
+ }
156
+
157
+ .blog-summary {
158
+ color: var(--muted);
159
+ font-size: 0.9rem;
160
+ line-height: 1.6;
161
+ }
162
+
163
+ /* -- Blog Post Detail -- */
164
+ .back-link {
165
+ display: inline-block;
166
+ color: var(--accent);
167
+ font-size: 0.9rem;
168
+ margin-bottom: 1rem;
169
+ transition: opacity 0.15s;
170
+ text-decoration: none;
171
+ cursor: pointer;
172
+ }
173
+ .back-link:hover { opacity: 0.75; }
174
+
175
+ .blog-post-meta {
176
+ display: flex;
177
+ align-items: center;
178
+ gap: 0.75rem;
179
+ margin-top: 0.5rem;
180
+ }
181
+
182
+ .blog-post-body {
183
+ background: var(--surface);
184
+ border: 1px solid rgba(255,255,255,0.06);
185
+ border-radius: var(--radius);
186
+ padding: 2rem;
187
+ line-height: 1.8;
188
+ font-size: 0.95rem;
189
+ }
190
+ .blog-post-body h4 {
191
+ color: var(--accent);
192
+ margin: 1.5rem 0 0.75rem;
193
+ font-size: 1.05rem;
194
+ }
195
+ .blog-post-body h4:first-child { margin-top: 0; }
196
+ .blog-post-body ul, .blog-post-body ol {
197
+ padding-left: 1.5rem;
198
+ margin: 0.5rem 0;
199
+ }
200
+ .blog-post-body li { margin-bottom: 0.4rem; }
201
+ .blog-post-body pre {
202
+ background: rgba(0,0,0,0.3);
203
+ border-radius: var(--radius);
204
+ padding: 1rem 1.25rem;
205
+ overflow-x: auto;
206
+ margin: 0.75rem 0;
207
+ font-size: 0.85rem;
208
+ line-height: 1.5;
209
+ }
210
+ .blog-post-body code {
211
+ background: rgba(255,255,255,0.06);
212
+ padding: 0.15em 0.4em;
213
+ border-radius: 4px;
214
+ font-size: 0.9em;
215
+ }
216
+ .blog-post-body pre code {
217
+ background: none;
218
+ padding: 0;
219
+ }
220
+
106
221
  /* -- Footer -- */
107
222
  .footer {
108
223
  text-align: center;
@@ -4,6 +4,11 @@
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>{{NAME}}</title>
7
+ <meta name="description" content="">
8
+ <meta property="og:title" content="{{NAME}}">
9
+ <meta property="og:description" content="">
10
+ <meta property="og:type" content="website">
11
+ <meta name="robots" content="index, follow">
7
12
  <base href="/">
8
13
  <link rel="stylesheet" href="global.css">
9
14
  <script src="zquery.min.js"></script>
@@ -15,13 +20,14 @@
15
20
  <nav class="navbar">
16
21
  <span class="brand">⚡ {{NAME}}</span>
17
22
  <div class="nav-links">
18
- <a z-link="/" class="nav-link">Home</a>
19
- <a z-link="/about" class="nav-link">About</a>
23
+ <a z-link="/" class="nav-link" z-active-route="/" z-active-exact>Home</a>
24
+ <a z-link="/blog" class="nav-link" z-active-route="/blog">Blog</a>
25
+ <a z-link="/about" class="nav-link" z-active-route="/about">About</a>
20
26
  </div>
21
27
  </nav>
22
28
 
23
29
  <!-- Main content - SSR output is injected here by the server -->
24
- <z-outlet z-cloak></z-outlet>
30
+ <z-outlet></z-outlet>
25
31
 
26
32
  <footer class="footer">
27
33
  <small>Built with zQuery · SSR Scaffold</small>
@@ -0,0 +1,144 @@
1
+ // server/data/posts.js - Blog post data
2
+ //
3
+ // Simulates a database or CMS. In a real app you'd fetch from a DB,
4
+ // headless CMS, or markdown files. The server imports this data and
5
+ // passes it as props to blog components during SSR.
6
+
7
+ export const posts = [
8
+ {
9
+ slug: 'why-ssr-matters',
10
+ title: 'Why Server-Side Rendering Matters',
11
+ date: '2025-12-15',
12
+ tag: 'SSR',
13
+ summary:
14
+ 'SSR delivers fully rendered HTML to the browser, improving first contentful paint, SEO indexability, and perceived performance on slower connections.',
15
+ body: `
16
+ <p>Server-Side Rendering (SSR) generates the full HTML for a page on the server
17
+ before sending it to the browser. Instead of shipping an empty shell and waiting
18
+ for JavaScript to populate it, the user sees content immediately.</p>
19
+
20
+ <h4>Key Benefits</h4>
21
+ <ul>
22
+ <li><strong>Faster First Paint</strong> — HTML arrives ready to display.
23
+ No waiting for JS bundles to download and execute.</li>
24
+ <li><strong>SEO Friendly</strong> — Search engine crawlers see complete
25
+ content without running JavaScript.</li>
26
+ <li><strong>Social Sharing</strong> — Open Graph meta tags are present in
27
+ the initial response, so link previews work everywhere.</li>
28
+ <li><strong>Accessibility</strong> — Content is available even if JS fails
29
+ to load or is disabled.</li>
30
+ </ul>
31
+
32
+ <h4>The Trade-Off</h4>
33
+ <p>SSR adds server-side compute cost per request. Strategies like render
34
+ caching, edge deployment, and stale-while-revalidate headers help keep
35
+ response times low while maintaining the benefits of dynamic rendering.</p>
36
+ `,
37
+ },
38
+ {
39
+ slug: 'hydration-explained',
40
+ title: 'Hydration: Picking Up Where the Server Left Off',
41
+ date: '2025-12-20',
42
+ tag: 'Architecture',
43
+ summary:
44
+ 'After the server sends HTML, the client "hydrates" the page — attaching event listeners and reactive state so the SPA takes over without a full re-render.',
45
+ body: `
46
+ <p>Hydration is the process where the client-side framework takes ownership
47
+ of server-rendered HTML. The DOM is already there — hydration wires up event
48
+ handlers, reactive state, and component lifecycles on top of it.</p>
49
+
50
+ <h4>How It Works in zQuery</h4>
51
+ <ol>
52
+ <li>The server renders a component to HTML with <code>app.renderToString()</code>,
53
+ adding a <code>data-zq-ssr</code> marker.</li>
54
+ <li>The HTML is injected into the page shell and sent to the browser.</li>
55
+ <li>The client loads the same component definitions and registers them
56
+ with <code>$.component()</code>.</li>
57
+ <li>The router detects the SSR marker and hydrates instead of re-rendering,
58
+ preserving the existing DOM while activating reactivity.</li>
59
+ </ol>
60
+
61
+ <h4>Why This Matters</h4>
62
+ <p>Without hydration, the client would discard the server HTML and re-render
63
+ from scratch — causing a flash of empty content. Hydration gives you the best
64
+ of both worlds: fast server-rendered first paint with full client interactivity.</p>
65
+ `,
66
+ },
67
+ {
68
+ slug: 'shared-components',
69
+ title: 'Shared Components Across Client and Server',
70
+ date: '2026-01-05',
71
+ tag: 'Components',
72
+ summary:
73
+ 'Write your component once and use it everywhere. The same definition object that powers client rendering can be imported by the SSR server to produce identical markup.',
74
+ body: `
75
+ <p>In zQuery, a component is a plain JavaScript object with <code>state</code>,
76
+ <code>render()</code>, and optional lifecycle hooks. This simple contract means
77
+ the same file works on both sides:</p>
78
+
79
+ <pre><code>// components/greeting.js
80
+ export const greeting = {
81
+ state: () => ({ name: 'World' }),
82
+ render() {
83
+ return \`&lt;h1&gt;Hello, \${this.state.name}!&lt;/h1&gt;\`;
84
+ }
85
+ };</code></pre>
86
+
87
+ <h4>Client</h4>
88
+ <pre><code>import { greeting } from './components/greeting.js';
89
+ $.component('greeting', greeting);</code></pre>
90
+
91
+ <h4>Server</h4>
92
+ <pre><code>import { greeting } from '../app/components/greeting.js';
93
+ app.component('greeting', greeting);
94
+ const html = await app.renderToString('greeting', { name: 'Tony' });</code></pre>
95
+
96
+ <p>No special file conventions, no build-time transforms. Just JavaScript
97
+ modules shared between environments.</p>
98
+ `,
99
+ },
100
+ {
101
+ slug: 'ssr-caching-strategies',
102
+ title: 'Caching Strategies for SSR Pages',
103
+ date: '2026-01-18',
104
+ tag: 'Performance',
105
+ summary:
106
+ 'Combine stale-while-revalidate headers, in-memory render caching, and CDN edge caching to serve SSR pages at static-site speed without sacrificing freshness.',
107
+ body: `
108
+ <p>SSR is powerful but adds per-request compute. Smart caching lets you keep
109
+ the dynamic benefits while serving at near-static speed.</p>
110
+
111
+ <h4>Layer 1: In-Memory Cache</h4>
112
+ <p>Cache rendered HTML in a <code>Map</code> keyed by route. Set a TTL
113
+ (e.g. 60 seconds) and serve cached responses until they expire. Simple and
114
+ effective for moderate traffic.</p>
115
+
116
+ <h4>Layer 2: HTTP Cache Headers</h4>
117
+ <pre><code>Cache-Control: public, s-maxage=60, stale-while-revalidate=300</code></pre>
118
+ <p>This tells CDNs to serve cached content for 60s, then revalidate in the
119
+ background for up to 5 minutes. Users always get a fast response.</p>
120
+
121
+ <h4>Layer 3: CDN Edge Caching</h4>
122
+ <p>Deploy behind a CDN (Cloudflare, Vercel Edge, Fastly) so cached pages are
123
+ served from the nearest edge node. Combine with geographic routing for
124
+ sub-100ms global TTFB.</p>
125
+
126
+ <h4>When to Skip Caching</h4>
127
+ <p>User-specific pages (dashboards, settings) shouldn't be edge-cached.
128
+ Use <code>Cache-Control: private</code> and rely on in-memory caching
129
+ or skip caching entirely for authenticated routes.</p>
130
+ `,
131
+ },
132
+ ];
133
+
134
+ /** Find a single post by slug. Returns undefined if not found. */
135
+ export function getPostBySlug(slug) {
136
+ return posts.find(p => p.slug === slug);
137
+ }
138
+
139
+ /** Return all posts (summary only — no body). */
140
+ export function getAllPosts() {
141
+ return posts.map(({ slug, title, date, tag, summary }) => ({
142
+ slug, title, date, tag, summary,
143
+ }));
144
+ }
@@ -17,9 +17,14 @@ import { createSSRApp } from 'zero-query/ssr';
17
17
  // Shared component definitions - same ones the client registers
18
18
  import { homePage } from '../app/components/home.js';
19
19
  import { aboutPage } from '../app/components/about.js';
20
+ import { blogList } from '../app/components/blog/index.js';
21
+ import { blogPost } from '../app/components/blog/post.js';
20
22
  import { notFound } from '../app/components/not-found.js';
21
23
  import { routes } from '../app/routes.js';
22
24
 
25
+ // Server-side data — simulates a database or CMS
26
+ import { getAllPosts, getPostBySlug } from './data/posts.js';
27
+
23
28
  const __dirname = fileURLToPath(new URL('.', import.meta.url));
24
29
  const ROOT = join(__dirname, '..');
25
30
  const PORT = parseInt(process.env.PORT || '3000', 10);
@@ -29,43 +34,160 @@ const PORT = parseInt(process.env.PORT || '3000', 10);
29
34
  const app = createSSRApp();
30
35
  app.component('home-page', homePage);
31
36
  app.component('about-page', aboutPage);
37
+ app.component('blog-list', blogList);
38
+ app.component('blog-post', blogPost);
32
39
  app.component('not-found', notFound);
33
40
 
34
41
  // --- Route matching ---------------------------------------------------------
35
42
 
43
+ /**
44
+ * Match a pathname to a route definition. Supports :param segments.
45
+ * Returns { component, params } or the not-found fallback.
46
+ */
36
47
  function matchRoute(pathname) {
37
- const route = routes.find(r => r.path === pathname);
38
- return route ? route.component : 'not-found';
48
+ for (const route of routes) {
49
+ const paramNames = [];
50
+ const pattern = route.path.replace(/:(\w+)/g, (_, name) => {
51
+ paramNames.push(name);
52
+ return '([^/]+)';
53
+ });
54
+ const match = new RegExp(`^${pattern}$`).exec(pathname);
55
+ if (match) {
56
+ const params = {};
57
+ paramNames.forEach((name, i) => { params[name] = match[i + 1]; });
58
+ return { component: route.component, params };
59
+ }
60
+ }
61
+ return { component: 'not-found', params: {} };
62
+ }
63
+
64
+ // --- Server-side data fetching ----------------------------------------------
65
+
66
+ /**
67
+ * Fetch data for a matched route. This is where you'd query a database,
68
+ * call an API, or read from the filesystem in a real application.
69
+ * The returned object is passed as props to the component during SSR.
70
+ */
71
+ function getPropsForRoute(component, params) {
72
+ switch (component) {
73
+ case 'blog-list':
74
+ return { posts: getAllPosts() };
75
+ case 'blog-post':
76
+ return { post: getPostBySlug(params.slug) || null };
77
+ default:
78
+ return {};
79
+ }
80
+ }
81
+
82
+ // --- SEO metadata per route -------------------------------------------------
83
+
84
+ /**
85
+ * Return page-specific metadata for SEO, social sharing, and browser tabs.
86
+ * The server injects these into the HTML shell's <head> before sending.
87
+ *
88
+ * In a real app you'd pull this from a CMS or database alongside the content.
89
+ * Open Graph tags ensure rich link previews on social media.
90
+ */
91
+ function getMetaForRoute(component, params, props) {
92
+ const base = {
93
+ title: '{{NAME}}',
94
+ description: 'A zQuery SSR application.',
95
+ ogType: 'website',
96
+ };
97
+
98
+ switch (component) {
99
+ case 'home-page':
100
+ return {
101
+ ...base,
102
+ title: '{{NAME}} — Home',
103
+ description: 'A server-rendered application built with zQuery. Fast first paint, SEO-friendly, zero dependencies.',
104
+ };
105
+
106
+ case 'blog-list':
107
+ return {
108
+ ...base,
109
+ title: 'Blog — {{NAME}}',
110
+ description: 'Articles on server-side rendering, hydration, shared components, and modern web architecture.',
111
+ };
112
+
113
+ case 'blog-post': {
114
+ const post = props.post;
115
+ if (!post) return { ...base, title: 'Post Not Found — {{NAME}}' };
116
+ return {
117
+ ...base,
118
+ title: `${post.title} — {{NAME}}`,
119
+ description: post.summary,
120
+ ogType: 'article',
121
+ };
122
+ }
123
+
124
+ case 'about-page':
125
+ return {
126
+ ...base,
127
+ title: 'About — {{NAME}}',
128
+ description: 'Learn about zQuery — a zero-dependency frontend micro-library for reactive components, routing, SSR, and state management.',
129
+ };
130
+
131
+ default:
132
+ return {
133
+ ...base,
134
+ title: 'Page Not Found — {{NAME}}',
135
+ description: 'The page you\'re looking for doesn\'t exist.',
136
+ };
137
+ }
39
138
  }
40
139
 
41
140
  // --- Render a full HTML page ------------------------------------------------
42
141
 
142
+ // Read the index.html shell once at startup — it already has z-link nav,
143
+ // client scripts (zquery.min.js + app/app.js), and the <z-outlet> tag.
144
+ // On each request we just inject the SSR body into <z-outlet>.
145
+ let shellCache = null;
146
+ async function getShell() {
147
+ if (!shellCache) shellCache = await readFile(join(ROOT, 'index.html'), 'utf-8');
148
+ return shellCache;
149
+ }
150
+
43
151
  async function render(pathname) {
44
- const component = matchRoute(pathname);
45
- const body = await app.renderToString(component);
46
-
47
- return `<!DOCTYPE html>
48
- <html lang="en">
49
- <head>
50
- <meta charset="UTF-8">
51
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
52
- <title>{{NAME}}</title>
53
- <link rel="stylesheet" href="/global.css">
54
- </head>
55
- <body>
56
- <nav class="navbar">
57
- <span class="brand">⚡ {{NAME}}</span>
58
- <div class="nav-links">
59
- ${routes.map(r =>
60
- ` <a href="${r.path}" class="nav-link${r.path === pathname ? ' active' : ''}">${
61
- r.path === '/' ? 'Home' : r.path.slice(1)[0].toUpperCase() + r.path.slice(2)
62
- }</a>`).join('\n')}
63
- </div>
64
- </nav>
65
- <z-outlet>${body}</z-outlet>
66
- <footer class="footer"><small>Built with zQuery · SSR</small></footer>
67
- </body>
68
- </html>`;
152
+ const { component, params } = matchRoute(pathname);
153
+ const props = getPropsForRoute(component, params);
154
+ const meta = getMetaForRoute(component, params, props);
155
+
156
+ // SSR render — pass server-fetched data as props to the component
157
+ const body = await app.renderToString(component, props);
158
+ const shell = await getShell();
159
+
160
+ // Inject SSR content into <z-outlet …>
161
+ let html = shell.replace(/(<z-outlet[^>]*>)(<\/z-outlet>)?/, `$1${body}</z-outlet>`);
162
+
163
+ // Inject page-specific <title> and meta tags for SEO / social sharing
164
+ html = html.replace(/<title>[^<]*<\/title>/, `<title>${meta.title}</title>`);
165
+ html = html.replace(
166
+ /<meta name="description" content="[^"]*">/,
167
+ `<meta name="description" content="${meta.description}">`
168
+ );
169
+ html = html.replace(
170
+ /<meta property="og:title" content="[^"]*">/,
171
+ `<meta property="og:title" content="${meta.title}">`
172
+ );
173
+ html = html.replace(
174
+ /<meta property="og:description" content="[^"]*">/,
175
+ `<meta property="og:description" content="${meta.description}">`
176
+ );
177
+ html = html.replace(
178
+ /<meta property="og:type" content="[^"]*">/,
179
+ `<meta property="og:type" content="${meta.ogType}">`
180
+ );
181
+
182
+ // Embed server data so the client can hydrate without re-fetching.
183
+ // Also include meta so client can update document.title on navigation.
184
+ const ssrData = JSON.stringify({ component, params, props, meta });
185
+ html = html.replace(
186
+ '</head>',
187
+ `<script>window.__SSR_DATA__=${ssrData};</script>\n</head>`
188
+ );
189
+
190
+ return html;
69
191
  }
70
192
 
71
193
  // --- Static files -----------------------------------------------------------
@@ -99,6 +221,25 @@ createServer(async (req, res) => {
99
221
  // Static assets (CSS, images, etc.)
100
222
  if (pathname !== '/' && await serveStatic(res, pathname)) return;
101
223
 
224
+ // --- JSON API for client-side navigation ----------------------------------
225
+ // The client fetches data here when navigating via SPA (after initial SSR).
226
+ // In a real app, these would query a database or external API.
227
+
228
+ if (pathname === '/api/posts') {
229
+ const json = JSON.stringify(getAllPosts());
230
+ res.writeHead(200, { 'Content-Type': 'application/json' });
231
+ res.end(json);
232
+ return;
233
+ }
234
+
235
+ const postMatch = /^\/api\/posts\/([^/]+)$/.exec(pathname);
236
+ if (postMatch) {
237
+ const post = getPostBySlug(postMatch[1]) || null;
238
+ res.writeHead(post ? 200 : 404, { 'Content-Type': 'application/json' });
239
+ res.end(JSON.stringify(post));
240
+ return;
241
+ }
242
+
102
243
  // SSR route
103
244
  try {
104
245
  const html = await render(pathname);
Binary file
package/dist/zquery.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * zQuery (zeroQuery) v1.0.0
2
+ * zQuery (zeroQuery) v1.0.2
3
3
  * Lightweight Frontend Library
4
4
  * https://github.com/tonywied17/zero-query
5
5
  * (c) 2026 Anthony Wiedman - MIT License
@@ -3498,13 +3498,28 @@ class Component {
3498
3498
  if (el.contains(e.target)) continue;
3499
3499
  }
3500
3500
 
3501
- // Key modifiers - filter keyboard events by key
3501
+ // Key modifiers - filter keyboard events by key.
3502
+ // Named shortcuts map common names to their e.key values.
3503
+ // Any modifier not recognised as a built-in behaviour, timing,
3504
+ // or system modifier is matched against e.key (case-insensitive)
3505
+ // so that arbitrary keys work: .a, .f1, .+, .0, .arrowup, etc.
3502
3506
  const _keyMap = { enter: 'Enter', escape: 'Escape', tab: 'Tab', space: ' ', delete: 'Delete|Backspace', up: 'ArrowUp', down: 'ArrowDown', left: 'ArrowLeft', right: 'ArrowRight' };
3507
+ const _nonKeyMods = new Set(['prevent','stop','self','once','outside','capture','passive','debounce','throttle','ctrl','shift','alt','meta']);
3503
3508
  let keyFiltered = false;
3504
- for (const mod of modifiers) {
3509
+ for (let mi = 0; mi < modifiers.length; mi++) {
3510
+ const mod = modifiers[mi];
3505
3511
  if (_keyMap[mod]) {
3506
3512
  const keys = _keyMap[mod].split('|');
3507
3513
  if (!e.key || !keys.includes(e.key)) { keyFiltered = true; break; }
3514
+ } else if (_nonKeyMods.has(mod)) {
3515
+ continue;
3516
+ } else if (/^\d+$/.test(mod) && mi > 0 && (modifiers[mi - 1] === 'debounce' || modifiers[mi - 1] === 'throttle')) {
3517
+ // Numeric value following debounce/throttle — skip (it's a ms parameter)
3518
+ continue;
3519
+ } else {
3520
+ // Dynamic key match — compare modifier against e.key
3521
+ // Case-insensitive: .a matches 'a' and 'A', .f1 matches 'F1'
3522
+ if (!e.key || e.key.toLowerCase() !== mod.toLowerCase()) { keyFiltered = true; break; }
3508
3523
  }
3509
3524
  }
3510
3525
  if (keyFiltered) continue;
@@ -6189,9 +6204,9 @@ $.validate = validate;
6189
6204
  $.formatError = formatError;
6190
6205
 
6191
6206
  // --- Meta ------------------------------------------------------------------
6192
- $.version = '1.0.0';
6193
- $.libSize = '~106 KB';
6194
- $.unitTests = {"passed":1882,"failed":0,"total":1882,"suites":508,"duration":3548,"ok":true};
6207
+ $.version = '1.0.2';
6208
+ $.libSize = '~107 KB';
6209
+ $.unitTests = {"passed":1906,"failed":0,"total":1906,"suites":521,"duration":3744,"ok":true};
6195
6210
  $.meta = {}; // populated at build time by CLI bundler
6196
6211
 
6197
6212
  $.noConflict = () => {