zero-query 0.2.9 → 0.4.9

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/index.d.ts CHANGED
@@ -4,14 +4,14 @@
4
4
  * Lightweight modern frontend library — jQuery-like selectors, reactive
5
5
  * components, SPA router, state management, HTTP client & utilities.
6
6
  *
7
- * @version 0.2.5
7
+ * @version 0.4.9
8
8
  * @license MIT
9
9
  * @see https://z-query.com/docs
10
10
  */
11
11
 
12
- // ───────────────────────────────────────────────────────────────────────────
12
+ // ---------------------------------------------------------------------------
13
13
  // ZQueryCollection
14
- // ───────────────────────────────────────────────────────────────────────────
14
+ // ---------------------------------------------------------------------------
15
15
 
16
16
  /**
17
17
  * Chainable wrapper around an array of DOM elements, similar to a jQuery object.
@@ -26,7 +26,7 @@ export class ZQueryCollection {
26
26
 
27
27
  constructor(elements: Element | Element[]);
28
28
 
29
- // ── Iteration ───────────────────────────────────────────────────────────
29
+ // -- Iteration -----------------------------------------------------------
30
30
  /**
31
31
  * Iterate over each element. `this` inside the callback is the element.
32
32
  * @returns The collection (for chaining).
@@ -53,7 +53,7 @@ export class ZQueryCollection {
53
53
  /** Iterable protocol — works with `for...of` and spread. */
54
54
  [Symbol.iterator](): IterableIterator<Element>;
55
55
 
56
- // ── Traversal ───────────────────────────────────────────────────────────
56
+ // -- Traversal -----------------------------------------------------------
57
57
  /** Descendants matching `selector`. */
58
58
  find(selector: string): ZQueryCollection;
59
59
 
@@ -75,7 +75,7 @@ export class ZQueryCollection {
75
75
  /** Previous sibling of each element. */
76
76
  prev(): ZQueryCollection;
77
77
 
78
- // ── Filtering ───────────────────────────────────────────────────────────
78
+ // -- Filtering -----------------------------------------------------------
79
79
  /** Keep elements matching a CSS selector or predicate. */
80
80
  filter(selector: string): ZQueryCollection;
81
81
  filter(fn: (element: Element, index: number) => boolean): ZQueryCollection;
@@ -87,7 +87,7 @@ export class ZQueryCollection {
87
87
  /** Keep elements that have a descendant matching `selector`. */
88
88
  has(selector: string): ZQueryCollection;
89
89
 
90
- // ── Classes ─────────────────────────────────────────────────────────────
90
+ // -- Classes -------------------------------------------------------------
91
91
  /** Add one or more classes (space-separated strings accepted). */
92
92
  addClass(...names: string[]): this;
93
93
 
@@ -100,7 +100,7 @@ export class ZQueryCollection {
100
100
  /** Check whether the first element has the given class. */
101
101
  hasClass(name: string): boolean;
102
102
 
103
- // ── Attributes & Properties ─────────────────────────────────────────────
103
+ // -- Attributes & Properties ---------------------------------------------
104
104
  /** Get attribute value of the first element. */
105
105
  attr(name: string): string | null;
106
106
  /** Set attribute on all elements. */
@@ -120,9 +120,9 @@ export class ZQueryCollection {
120
120
  /** Set data attribute on all elements. Objects are JSON-stringified. */
121
121
  data(key: string, value: any): this;
122
122
 
123
- // ── CSS & Dimensions ────────────────────────────────────────────────────
124
- /** Get computed style property of the first element. */
125
- css(property: string): string;
123
+ // -- CSS & Dimensions ----------------------------------------------------
124
+ /** Get computed style property of the first element, or `undefined` if empty. */
125
+ css(property: string): string | undefined;
126
126
  /** Set inline styles on all elements. */
127
127
  css(props: Partial<CSSStyleDeclaration>): this;
128
128
 
@@ -138,23 +138,23 @@ export class ZQueryCollection {
138
138
  /** Position relative to the offset parent. */
139
139
  position(): { top: number; left: number } | null;
140
140
 
141
- // ── Content ─────────────────────────────────────────────────────────────
142
- /** Get `innerHTML` of the first element. */
143
- html(): string;
141
+ // -- Content -------------------------------------------------------------
142
+ /** Get `innerHTML` of the first element, or `undefined` if empty. */
143
+ html(): string | undefined;
144
144
  /** Set `innerHTML` on all elements. */
145
145
  html(content: string): this;
146
146
 
147
- /** Get `textContent` of the first element. */
148
- text(): string;
147
+ /** Get `textContent` of the first element, or `undefined` if empty. */
148
+ text(): string | undefined;
149
149
  /** Set `textContent` on all elements. */
150
150
  text(content: string): this;
151
151
 
152
- /** Get value of the first input/select/textarea. */
153
- val(): string;
152
+ /** Get value of the first input/select/textarea, or `undefined` if empty. */
153
+ val(): string | undefined;
154
154
  /** Set value on all inputs. */
155
155
  val(value: string): this;
156
156
 
157
- // ── DOM Manipulation ────────────────────────────────────────────────────
157
+ // -- DOM Manipulation ----------------------------------------------------
158
158
  /** Insert content at the end of each element. */
159
159
  append(content: string | Node | ZQueryCollection): this;
160
160
 
@@ -182,7 +182,7 @@ export class ZQueryCollection {
182
182
  /** Replace elements with new content. */
183
183
  replaceWith(content: string | Node): this;
184
184
 
185
- // ── Visibility ──────────────────────────────────────────────────────────
185
+ // -- Visibility ----------------------------------------------------------
186
186
  /** Show elements. Optional display value (default: `''`). */
187
187
  show(display?: string): this;
188
188
 
@@ -192,7 +192,7 @@ export class ZQueryCollection {
192
192
  /** Toggle visibility. */
193
193
  toggle(display?: string): this;
194
194
 
195
- // ── Events ──────────────────────────────────────────────────────────────
195
+ // -- Events --------------------------------------------------------------
196
196
  /** Attach event handler. Space-separated events accepted. */
197
197
  on(events: string, handler: (event: Event) => void): this;
198
198
  /** Delegated event handler. */
@@ -222,7 +222,7 @@ export class ZQueryCollection {
222
222
  /** Blur the first element. */
223
223
  blur(): this;
224
224
 
225
- // ── Animation ───────────────────────────────────────────────────────────
225
+ // -- Animation -----------------------------------------------------------
226
226
  /**
227
227
  * CSS transition animation.
228
228
  * @param props CSS properties to animate to.
@@ -244,7 +244,7 @@ export class ZQueryCollection {
244
244
  /** Toggle height with a slide animation. Default 300 ms. */
245
245
  slideToggle(duration?: number): this;
246
246
 
247
- // ── Form Helpers ────────────────────────────────────────────────────────
247
+ // -- Form Helpers --------------------------------------------------------
248
248
  /** URL-encoded form data string. */
249
249
  serialize(): string;
250
250
 
@@ -253,9 +253,9 @@ export class ZQueryCollection {
253
253
  }
254
254
 
255
255
 
256
- // ───────────────────────────────────────────────────────────────────────────
256
+ // ---------------------------------------------------------------------------
257
257
  // Reactive
258
- // ───────────────────────────────────────────────────────────────────────────
258
+ // ---------------------------------------------------------------------------
259
259
 
260
260
  /** Marker properties added to every reactive proxy. */
261
261
  interface ReactiveProxy<T extends object = object> {
@@ -308,14 +308,19 @@ export function computed<T>(fn: () => T): Signal<T>;
308
308
  export function effect(fn: () => void): () => void;
309
309
 
310
310
 
311
- // ───────────────────────────────────────────────────────────────────────────
311
+ // ---------------------------------------------------------------------------
312
312
  // Component System
313
- // ───────────────────────────────────────────────────────────────────────────
313
+ // ---------------------------------------------------------------------------
314
314
 
315
315
  /** Item in a `pages` config — either a string id or an `{ id, label }` object. */
316
316
  type PageItem = string | { id: string; label?: string };
317
317
 
318
- /** Declarative multi-page configuration for a component. */
318
+ /**
319
+ * Declarative multi-page configuration for a component.
320
+ *
321
+ * Pages are **lazy-loaded**: only the active page is fetched on first render.
322
+ * Remaining pages are prefetched in the background for instant navigation.
323
+ */
319
324
  interface PagesConfig {
320
325
  /** Directory containing the page HTML files (resolved relative to `base`). */
321
326
  dir?: string;
@@ -388,8 +393,14 @@ interface ComponentInstance {
388
393
  /** Reactive state proxy. Mutating triggers re-render. */
389
394
  state: Record<string, any> & ReactiveProxy;
390
395
 
391
- /** Frozen props passed from parent / router. */
392
- readonly props: Readonly<Record<string, any>>;
396
+ /** Frozen props passed from parent / router.
397
+ * When mounted by the router, includes `$route` (NavigationContext), `$query`, and `$params`.
398
+ */
399
+ readonly props: Readonly<Record<string, any> & {
400
+ $route?: NavigationContext;
401
+ $query?: Record<string, string>;
402
+ $params?: Record<string, string>;
403
+ }>;
393
404
 
394
405
  /** Map of `z-ref` name → DOM element. Populated after each render. */
395
406
  refs: Record<string, Element>;
@@ -412,7 +423,7 @@ interface ComponentInstance {
412
423
  /** Teardown: removes listeners, scoped styles, clears DOM. */
413
424
  destroy(): void;
414
425
 
415
- /** Manually queue a re-render (microtask-batched). */
426
+ /** Manually queue a re-render (microtask-batched). Safe to call from anywhere — state mutations during render are coalesced (no infinite loop risk). */
416
427
  _scheduleUpdate(): void;
417
428
 
418
429
  /** Any user-defined methods from the component definition. */
@@ -480,9 +491,124 @@ interface StyleOptions {
480
491
  export function style(urls: string | string[], opts?: StyleOptions): StyleHandle;
481
492
 
482
493
 
483
- // ───────────────────────────────────────────────────────────────────────────
494
+ // ---------------------------------------------------------------------------
495
+ // Directive System
496
+ // ---------------------------------------------------------------------------
497
+ //
498
+ // Directives are special attributes processed by zQuery's component renderer.
499
+ // They work in both `render()` template literals and external `templateUrl`
500
+ // HTML files. All expressions evaluate in the component's state context
501
+ // (bare names resolve to `this.state.*`; `props` and `refs` also available).
502
+ //
503
+ // ─── Structural Directives ──────────────────────────────────────────────
504
+ //
505
+ // z-if="expression" Conditional rendering — element removed when falsy.
506
+ // z-else-if="expression" Else-if branch (must be immediate sibling of z-if).
507
+ // z-else Default branch (must follow z-if or z-else-if).
508
+ //
509
+ // z-for="item in items" List rendering — repeats the element per item.
510
+ // {{item.prop}} Use double-brace interpolation for item data.
511
+ // (item, index) in items Destructured index support.
512
+ // n in 5 Number range → [1, 2, 3, 4, 5].
513
+ // (val, key) in object Object iteration → {key, value} entries.
514
+ //
515
+ // z-show="expression" Toggle `display: none` (element stays in DOM).
516
+ //
517
+ // ─── Attribute Directives ───────────────────────────────────────────────
518
+ //
519
+ // z-bind:attr="expression" Dynamic attribute binding.
520
+ // :attr="expression" Shorthand for z-bind:attr.
521
+ // false/null/undefined → removes the attribute.
522
+ // true → sets empty attribute (e.g. disabled="").
523
+ //
524
+ // z-class="expression" Dynamic class binding.
525
+ // String: space-separated class names.
526
+ // Array: list of class names (falsy filtered).
527
+ // Object: { className: condition } map.
528
+ //
529
+ // z-style="expression" Dynamic inline styles.
530
+ // String: appended to existing cssText.
531
+ // Object: { property: value } map (camelCase keys).
532
+ //
533
+ // z-html="expression" Set innerHTML from expression (use trusted content only).
534
+ // z-text="expression" Set textContent from expression (safe, no HTML).
535
+ //
536
+ // ─── Form & Reference Directives ────────────────────────────────────────
537
+ //
538
+ // z-model="stateKey" Two-way binding for form elements.
539
+ // Supports: input, textarea, select, select[multiple], contenteditable.
540
+ // Nested keys: z-model="user.name" → this.state.user.name.
541
+ // Modifiers (boolean attributes on same element):
542
+ // z-lazy — update on 'change' instead of 'input' (update on blur).
543
+ // z-trim — auto .trim() whitespace before writing to state.
544
+ // z-number — force Number() conversion regardless of input type.
545
+ //
546
+ // z-ref="name" Element reference → this.refs.name.
547
+ //
548
+ // ─── Event Directives ───────────────────────────────────────────────────
549
+ //
550
+ // @event="method" Event binding with delegation (shorthand).
551
+ // z-on:event="method" Event binding with delegation (full syntax).
552
+ // @event="method(args)" Pass arguments: strings, numbers, booleans,
553
+ // null, $event, state.key references.
554
+ //
555
+ // Event Modifiers (chainable with dots):
556
+ // .prevent event.preventDefault()
557
+ // .stop event.stopPropagation()
558
+ // .self Only fire if event.target === element itself.
559
+ // .once Handler fires at most once per element.
560
+ // .capture addEventListener with { capture: true }.
561
+ // .passive addEventListener with { passive: true }.
562
+ // .debounce.{ms} Debounce: delay until {ms}ms idle (default 250).
563
+ // .throttle.{ms} Throttle: invoke at most once per {ms}ms (default 250).
564
+ //
565
+ // ─── Special Directives ─────────────────────────────────────────────────
566
+ //
567
+ // z-cloak Hidden until rendered (auto-removed after mount).
568
+ // Global CSS: [z-cloak] { display: none !important }.
569
+ // Also injects: *, *::before, *::after { -webkit-tap-highlight-color: transparent }.
570
+ //
571
+ // z-pre Skip all directive processing for this element
572
+ // and its descendants.
573
+ //
574
+ // ─── Processing Order ───────────────────────────────────────────────────
575
+ //
576
+ // 1. z-for (pre-innerHTML expansion)
577
+ // 2. z-if chain (DOM removal)
578
+ // 3. z-show (display toggle)
579
+ // 4. z-bind / : (dynamic attributes)
580
+ // 5. z-class (dynamic classes)
581
+ // 6. z-style (dynamic styles)
582
+ // 7. z-html/text (content injection)
583
+ // 8. @/z-on (event binding)
584
+ // 9. z-ref (element references)
585
+ // 10. z-model (two-way binding)
586
+ // 11. z-cloak (attribute removal)
587
+ //
588
+ // ---------------------------------------------------------------------------
589
+
590
+ /**
591
+ * Supported event modifier strings for `@event` and `z-on:event` bindings.
592
+ * Modifiers are appended to the event name with dots, e.g. `@click.prevent.stop`.
593
+ */
594
+ type EventModifier =
595
+ | 'prevent'
596
+ | 'stop'
597
+ | 'self'
598
+ | 'once'
599
+ | 'capture'
600
+ | 'passive'
601
+ | `debounce`
602
+ | `debounce.${number}`
603
+ | `throttle`
604
+ | `throttle.${number}`;
605
+
606
+ export { EventModifier };
607
+
608
+
609
+ // ---------------------------------------------------------------------------
484
610
  // Router
485
- // ───────────────────────────────────────────────────────────────────────────
611
+ // ---------------------------------------------------------------------------
486
612
 
487
613
  /** A single route definition. */
488
614
  interface RouteDefinition {
@@ -581,7 +707,7 @@ interface RouterInstance {
581
707
  /** Resolve a path applying the base prefix. */
582
708
  resolve(path: string): string;
583
709
 
584
- // ── Properties ──────────────────────────────────────────────────────────
710
+ // -- Properties ----------------------------------------------------------
585
711
  /** Current navigation context. */
586
712
  readonly current: NavigationContext | null;
587
713
  /** Current path (base-stripped in history mode). */
@@ -599,9 +725,9 @@ export function createRouter(config: RouterConfig): RouterInstance;
599
725
  export function getRouter(): RouterInstance | null;
600
726
 
601
727
 
602
- // ───────────────────────────────────────────────────────────────────────────
728
+ // ---------------------------------------------------------------------------
603
729
  // Store
604
- // ───────────────────────────────────────────────────────────────────────────
730
+ // ---------------------------------------------------------------------------
605
731
 
606
732
  /** Store configuration. */
607
733
  interface StoreConfig<
@@ -700,9 +826,9 @@ export function getStore<
700
826
  >(name?: string): StoreInstance<S, A, G> | null;
701
827
 
702
828
 
703
- // ───────────────────────────────────────────────────────────────────────────
829
+ // ---------------------------------------------------------------------------
704
830
  // HTTP Client
705
- // ───────────────────────────────────────────────────────────────────────────
831
+ // ---------------------------------------------------------------------------
706
832
 
707
833
  /** The response object resolved by all HTTP request methods (except `raw`). */
708
834
  interface HttpResponse<T = any> {
@@ -781,9 +907,9 @@ interface HttpClient {
781
907
  export const http: HttpClient;
782
908
 
783
909
 
784
- // ───────────────────────────────────────────────────────────────────────────
910
+ // ---------------------------------------------------------------------------
785
911
  // Utilities — Functions
786
- // ───────────────────────────────────────────────────────────────────────────
912
+ // ---------------------------------------------------------------------------
787
913
 
788
914
  /** Debounced function with a `.cancel()` helper. */
789
915
  interface DebouncedFunction<T extends (...args: any[]) => any> {
@@ -805,7 +931,11 @@ export function debounce<T extends (...args: any[]) => any>(fn: T, ms?: number):
805
931
  export function throttle<T extends (...args: any[]) => any>(fn: T, ms?: number): (...args: Parameters<T>) => void;
806
932
 
807
933
  /** Left-to-right function composition. */
808
- export function pipe<T>(...fns: Array<(value: T) => T>): (input: T) => T;
934
+ export function pipe<A, B>(f1: (a: A) => B): (input: A) => B;
935
+ export function pipe<A, B, C>(f1: (a: A) => B, f2: (b: B) => C): (input: A) => C;
936
+ export function pipe<A, B, C, D>(f1: (a: A) => B, f2: (b: B) => C, f3: (c: C) => D): (input: A) => D;
937
+ export function pipe<A, B, C, D, E>(f1: (a: A) => B, f2: (b: B) => C, f3: (c: C) => D, f4: (d: D) => E): (input: A) => E;
938
+ export function pipe<T>(...fns: Array<(value: any) => any>): (input: T) => any;
809
939
 
810
940
  /**
811
941
  * Returns a function that only executes once, caching the result.
@@ -816,9 +946,9 @@ export function once<T extends (...args: any[]) => any>(fn: T): (...args: Parame
816
946
  export function sleep(ms: number): Promise<void>;
817
947
 
818
948
 
819
- // ───────────────────────────────────────────────────────────────────────────
949
+ // ---------------------------------------------------------------------------
820
950
  // Utilities — Strings
821
- // ───────────────────────────────────────────────────────────────────────────
951
+ // ---------------------------------------------------------------------------
822
952
 
823
953
  /** Escape HTML entities: `&`, `<`, `>`, `"`, `'`. */
824
954
  export function escapeHtml(str: string): string;
@@ -847,9 +977,9 @@ export function camelCase(str: string): string;
847
977
  export function kebabCase(str: string): string;
848
978
 
849
979
 
850
- // ───────────────────────────────────────────────────────────────────────────
980
+ // ---------------------------------------------------------------------------
851
981
  // Utilities — Objects
852
- // ───────────────────────────────────────────────────────────────────────────
982
+ // ---------------------------------------------------------------------------
853
983
 
854
984
  /** Deep clone using `structuredClone` (JSON fallback). */
855
985
  export function deepClone<T>(obj: T): T;
@@ -861,9 +991,9 @@ export function deepMerge<T extends object>(target: T, ...sources: Partial<T>[])
861
991
  export function isEqual(a: any, b: any): boolean;
862
992
 
863
993
 
864
- // ───────────────────────────────────────────────────────────────────────────
994
+ // ---------------------------------------------------------------------------
865
995
  // Utilities — URL
866
- // ───────────────────────────────────────────────────────────────────────────
996
+ // ---------------------------------------------------------------------------
867
997
 
868
998
  /** Serialize an object to a URL query string. */
869
999
  export function param(obj: Record<string, any>): string;
@@ -872,9 +1002,9 @@ export function param(obj: Record<string, any>): string;
872
1002
  export function parseQuery(str: string): Record<string, string>;
873
1003
 
874
1004
 
875
- // ───────────────────────────────────────────────────────────────────────────
1005
+ // ---------------------------------------------------------------------------
876
1006
  // Utilities — Storage
877
- // ───────────────────────────────────────────────────────────────────────────
1007
+ // ---------------------------------------------------------------------------
878
1008
 
879
1009
  /** JSON-aware `localStorage` wrapper. */
880
1010
  interface StorageWrapper {
@@ -895,9 +1025,9 @@ export const storage: StorageWrapper;
895
1025
  export const session: StorageWrapper;
896
1026
 
897
1027
 
898
- // ───────────────────────────────────────────────────────────────────────────
1028
+ // ---------------------------------------------------------------------------
899
1029
  // Utilities — Event Bus
900
- // ───────────────────────────────────────────────────────────────────────────
1030
+ // ---------------------------------------------------------------------------
901
1031
 
902
1032
  /** Singleton pub/sub event bus for cross-component communication. */
903
1033
  interface EventBus {
@@ -916,9 +1046,9 @@ interface EventBus {
916
1046
  export const bus: EventBus;
917
1047
 
918
1048
 
919
- // ───────────────────────────────────────────────────────────────────────────
1049
+ // ---------------------------------------------------------------------------
920
1050
  // $ — Main function & namespace
921
- // ───────────────────────────────────────────────────────────────────────────
1051
+ // ---------------------------------------------------------------------------
922
1052
 
923
1053
  /**
924
1054
  * Main selector / DOM-ready function.
@@ -934,7 +1064,7 @@ interface ZQueryStatic {
934
1064
  (nodeList: NodeList | HTMLCollection | Element[]): Element | null;
935
1065
  (fn: () => void): void;
936
1066
 
937
- // ── Collection selector ─────────────────────────────────────────────────
1067
+ // -- Collection selector -------------------------------------------------
938
1068
  /**
939
1069
  * Collection selector — returns a `ZQueryCollection`.
940
1070
  *
@@ -947,7 +1077,7 @@ interface ZQueryStatic {
947
1077
  all(element: Element): ZQueryCollection;
948
1078
  all(nodeList: NodeList | HTMLCollection | Element[]): ZQueryCollection;
949
1079
 
950
- // ── Quick-ref shortcuts ─────────────────────────────────────────────────
1080
+ // -- Quick-ref shortcuts -------------------------------------------------
951
1081
  /** `document.getElementById(id)` */
952
1082
  id(id: string): Element | null;
953
1083
  /** `document.querySelector('.name')` */
@@ -959,7 +1089,7 @@ interface ZQueryStatic {
959
1089
  /** Children of `#parentId` as array. */
960
1090
  children(parentId: string): Element[];
961
1091
 
962
- // ── Static helpers ──────────────────────────────────────────────────────
1092
+ // -- Static helpers ------------------------------------------------------
963
1093
  /**
964
1094
  * Create a DOM element.
965
1095
  * Special `attrs` keys: `class`, `style` (object), `on*` (handler), `data` (object).
@@ -976,16 +1106,22 @@ interface ZQueryStatic {
976
1106
  /** Global event delegation on `document`. */
977
1107
  on(event: string, selector: string, handler: (this: Element, e: Event) => void): void;
978
1108
 
1109
+ /** Direct event listener on `document` (for keydown, resize, etc.). */
1110
+ on(event: string, handler: (e: Event) => void): void;
1111
+
1112
+ /** Remove a direct global event listener previously attached with `$.on(event, handler)`. */
1113
+ off(event: string, handler: (e: Event) => void): void;
1114
+
979
1115
  /** Alias for `ZQueryCollection.prototype` — extend to add custom collection methods. */
980
1116
  fn: typeof ZQueryCollection.prototype;
981
1117
 
982
- // ── Reactive ────────────────────────────────────────────────────────────
1118
+ // -- Reactive ------------------------------------------------------------
983
1119
  reactive: typeof reactive;
984
1120
  signal: typeof signal;
985
1121
  computed: typeof computed;
986
1122
  effect: typeof effect;
987
1123
 
988
- // ── Components ──────────────────────────────────────────────────────────
1124
+ // -- Components ----------------------------------------------------------
989
1125
  component: typeof component;
990
1126
  mount: typeof mount;
991
1127
  mountAll: typeof mountAll;
@@ -995,15 +1131,15 @@ interface ZQueryStatic {
995
1131
  components: typeof getRegistry;
996
1132
  style: typeof style;
997
1133
 
998
- // ── Router ──────────────────────────────────────────────────────────────
1134
+ // -- Router --------------------------------------------------------------
999
1135
  router: typeof createRouter;
1000
1136
  getRouter: typeof getRouter;
1001
1137
 
1002
- // ── Store ───────────────────────────────────────────────────────────────
1138
+ // -- Store ---------------------------------------------------------------
1003
1139
  store: typeof createStore;
1004
1140
  getStore: typeof getStore;
1005
1141
 
1006
- // ── HTTP ────────────────────────────────────────────────────────────────
1142
+ // -- HTTP ----------------------------------------------------------------
1007
1143
  http: HttpClient;
1008
1144
  get: HttpClient['get'];
1009
1145
  post: HttpClient['post'];
@@ -1011,7 +1147,7 @@ interface ZQueryStatic {
1011
1147
  patch: HttpClient['patch'];
1012
1148
  delete: HttpClient['delete'];
1013
1149
 
1014
- // ── Utilities ───────────────────────────────────────────────────────────
1150
+ // -- Utilities -----------------------------------------------------------
1015
1151
  debounce: typeof debounce;
1016
1152
  throttle: typeof throttle;
1017
1153
  pipe: typeof pipe;
@@ -1036,7 +1172,7 @@ interface ZQueryStatic {
1036
1172
  session: StorageWrapper;
1037
1173
  bus: EventBus;
1038
1174
 
1039
- // ── Meta ────────────────────────────────────────────────────────────────
1175
+ // -- Meta ----------------------------------------------------------------
1040
1176
  /** Library version string. */
1041
1177
  version: string;
1042
1178
  /** Populated at build time by the CLI bundler. */
@@ -1048,14 +1184,18 @@ interface ZQueryStatic {
1048
1184
  /** The main `$` / `zQuery` function + namespace. */
1049
1185
  export const $: ZQueryStatic;
1050
1186
  export { $ as zQuery };
1051
- export const queryAll: typeof ZQueryCollection;
1187
+
1188
+ /** Collection selector function — same as `$.all()`. */
1189
+ export function queryAll(selector: string, context?: string | Element): ZQueryCollection;
1190
+ export function queryAll(element: Element): ZQueryCollection;
1191
+ export function queryAll(nodeList: NodeList | HTMLCollection | Element[]): ZQueryCollection;
1052
1192
 
1053
1193
  export default $;
1054
1194
 
1055
1195
 
1056
- // ───────────────────────────────────────────────────────────────────────────
1196
+ // ---------------------------------------------------------------------------
1057
1197
  // Global augmentation (browser)
1058
- // ───────────────────────────────────────────────────────────────────────────
1198
+ // ---------------------------------------------------------------------------
1059
1199
 
1060
1200
  declare global {
1061
1201
  interface Window {
package/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
- * ┌─────────────────────────────────────────────────────────┐
2
+ * ┌---------------------------------------------------------┐
3
3
  * │ zQuery (zeroQuery) — Lightweight Frontend Library │
4
4
  * │ │
5
5
  * │ jQuery-like selectors · Reactive components │
6
6
  * │ SPA router · State management · Zero dependencies │
7
7
  * │ │
8
8
  * │ https://github.com/tonywied17/zero-query │
9
- * └─────────────────────────────────────────────────────────┘
9
+ * └---------------------------------------------------------┘
10
10
  */
11
11
 
12
12
  import { query, queryAll, ZQueryCollection } from './src/core.js';
@@ -77,6 +77,7 @@ $.all = function(selector, context) {
77
77
  $.create = query.create;
78
78
  $.ready = query.ready;
79
79
  $.on = query.on;
80
+ $.off = query.off;
80
81
  $.fn = query.fn;
81
82
 
82
83
  // --- Reactive primitives ---------------------------------------------------
@@ -161,12 +162,12 @@ export {
161
162
  ZQueryCollection,
162
163
  queryAll,
163
164
  reactive, signal, computed, effect,
164
- component, mount, mountAll, getInstance, destroy, style,
165
+ component, mount, mountAll, getInstance, destroy, getRegistry, style,
165
166
  createRouter, getRouter,
166
167
  createStore, getStore,
167
168
  http,
168
169
  debounce, throttle, pipe, once, sleep,
169
- escapeHtml, html, trust, uuid,
170
+ escapeHtml, html, trust, uuid, camelCase, kebabCase,
170
171
  deepClone, deepMerge, isEqual, param, parseQuery,
171
172
  storage, session, bus,
172
173
  };
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
1
  {
2
2
  "name": "zero-query",
3
- "version": "0.2.9",
3
+ "version": "0.4.9",
4
4
  "description": "Lightweight modern frontend library — jQuery-like selectors, reactive components, SPA router, and state management with zero dependencies.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "bin": {
8
- "zquery": "./cli.js"
8
+ "zquery": "cli/index.js"
9
9
  },
10
10
  "files": [
11
11
  "src",
12
12
  "dist",
13
+ "cli",
13
14
  "index.js",
14
15
  "index.d.ts",
15
- "cli.js",
16
16
  "LICENSE",
17
17
  "README.md"
18
18
  ],
19
19
  "scripts": {
20
- "build": "node build.js",
21
- "dev": "node cli.js dev examples/starter-app",
22
- "dev-lib": "node build.js --watch",
23
- "bundle": "node cli.js bundle",
24
- "bundle:app": "node cli.js bundle examples/starter-app/scripts/app.js"
20
+ "build": "node cli/index.js build",
21
+ "dev": "node cli/index.js dev zquery-website",
22
+ "dev-lib": "node cli/index.js build --watch",
23
+ "bundle": "node cli/index.js bundle",
24
+ "bundle:app": "node cli/index.js bundle zquery-website"
25
25
  },
26
26
  "keywords": [
27
27
  "dom",