zero-query 1.1.1 → 1.2.0

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.
Files changed (154) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +2 -0
  3. package/cli/args.js +33 -33
  4. package/cli/commands/build-api.js +443 -442
  5. package/cli/commands/build.js +254 -247
  6. package/cli/commands/bundle.js +1228 -1224
  7. package/cli/commands/create.js +137 -121
  8. package/cli/commands/dev/devtools/index.js +56 -56
  9. package/cli/commands/dev/devtools/js/components.js +49 -49
  10. package/cli/commands/dev/devtools/js/core.js +423 -423
  11. package/cli/commands/dev/devtools/js/elements.js +421 -421
  12. package/cli/commands/dev/devtools/js/network.js +166 -166
  13. package/cli/commands/dev/devtools/js/performance.js +73 -73
  14. package/cli/commands/dev/devtools/js/router.js +105 -105
  15. package/cli/commands/dev/devtools/js/source.js +132 -132
  16. package/cli/commands/dev/devtools/js/stats.js +35 -35
  17. package/cli/commands/dev/devtools/js/tabs.js +79 -79
  18. package/cli/commands/dev/devtools/panel.html +95 -95
  19. package/cli/commands/dev/devtools/styles.css +244 -244
  20. package/cli/commands/dev/index.js +107 -107
  21. package/cli/commands/dev/logger.js +75 -75
  22. package/cli/commands/dev/overlay.js +858 -858
  23. package/cli/commands/dev/server.js +220 -220
  24. package/cli/commands/dev/validator.js +94 -94
  25. package/cli/commands/dev/watcher.js +172 -172
  26. package/cli/help.js +114 -112
  27. package/cli/index.js +52 -52
  28. package/cli/scaffold/default/LICENSE +21 -21
  29. package/cli/scaffold/default/app/app.js +207 -207
  30. package/cli/scaffold/default/app/components/about.js +201 -201
  31. package/cli/scaffold/default/app/components/api-demo.js +143 -143
  32. package/cli/scaffold/default/app/components/contact-card.js +231 -231
  33. package/cli/scaffold/default/app/components/contacts/contacts.css +706 -706
  34. package/cli/scaffold/default/app/components/contacts/contacts.html +200 -200
  35. package/cli/scaffold/default/app/components/contacts/contacts.js +196 -196
  36. package/cli/scaffold/default/app/components/counter.js +127 -127
  37. package/cli/scaffold/default/app/components/home.js +249 -249
  38. package/cli/scaffold/default/app/components/not-found.js +16 -16
  39. package/cli/scaffold/default/app/components/playground/playground.css +115 -115
  40. package/cli/scaffold/default/app/components/playground/playground.html +161 -161
  41. package/cli/scaffold/default/app/components/playground/playground.js +116 -116
  42. package/cli/scaffold/default/app/components/todos.js +225 -225
  43. package/cli/scaffold/default/app/components/toolkit/toolkit.css +97 -97
  44. package/cli/scaffold/default/app/components/toolkit/toolkit.html +146 -146
  45. package/cli/scaffold/default/app/components/toolkit/toolkit.js +280 -280
  46. package/cli/scaffold/default/app/routes.js +15 -15
  47. package/cli/scaffold/default/app/store.js +101 -101
  48. package/cli/scaffold/default/global.css +552 -552
  49. package/cli/scaffold/default/index.html +99 -99
  50. package/cli/scaffold/minimal/app/app.js +85 -85
  51. package/cli/scaffold/minimal/app/components/about.js +68 -68
  52. package/cli/scaffold/minimal/app/components/counter.js +122 -122
  53. package/cli/scaffold/minimal/app/components/home.js +68 -68
  54. package/cli/scaffold/minimal/app/components/not-found.js +16 -16
  55. package/cli/scaffold/minimal/app/routes.js +9 -9
  56. package/cli/scaffold/minimal/app/store.js +36 -36
  57. package/cli/scaffold/minimal/global.css +300 -300
  58. package/cli/scaffold/minimal/index.html +44 -44
  59. package/cli/scaffold/ssr/app/app.js +41 -41
  60. package/cli/scaffold/ssr/app/components/about.js +55 -55
  61. package/cli/scaffold/ssr/app/components/blog/index.js +65 -65
  62. package/cli/scaffold/ssr/app/components/blog/post.js +86 -86
  63. package/cli/scaffold/ssr/app/components/home.js +37 -37
  64. package/cli/scaffold/ssr/app/components/not-found.js +15 -15
  65. package/cli/scaffold/ssr/app/routes.js +8 -8
  66. package/cli/scaffold/ssr/global.css +228 -228
  67. package/cli/scaffold/ssr/index.html +37 -37
  68. package/cli/scaffold/ssr/package.json +8 -8
  69. package/cli/scaffold/ssr/server/data/posts.js +144 -144
  70. package/cli/scaffold/ssr/server/index.js +213 -213
  71. package/cli/scaffold/webrtc/app/app.js +11 -0
  72. package/cli/scaffold/webrtc/app/components/video-room.js +295 -0
  73. package/cli/scaffold/webrtc/app/lib/room.js +252 -0
  74. package/cli/scaffold/webrtc/assets/.gitkeep +0 -0
  75. package/cli/scaffold/webrtc/global.css +250 -0
  76. package/cli/scaffold/webrtc/index.html +21 -0
  77. package/cli/utils.js +305 -287
  78. package/dist/API.md +661 -0
  79. package/dist/zquery.dist.zip +0 -0
  80. package/dist/zquery.js +10313 -6614
  81. package/dist/zquery.min.js +8 -631
  82. package/index.d.ts +570 -371
  83. package/index.js +311 -240
  84. package/package.json +76 -70
  85. package/src/component.js +1709 -1691
  86. package/src/core.js +921 -921
  87. package/src/diff.js +497 -497
  88. package/src/errors.js +209 -209
  89. package/src/expression.js +922 -922
  90. package/src/http.js +242 -242
  91. package/src/package.json +1 -1
  92. package/src/reactive.js +255 -255
  93. package/src/router.js +843 -843
  94. package/src/ssr.js +418 -418
  95. package/src/store.js +318 -318
  96. package/src/utils.js +515 -515
  97. package/src/webrtc/e2ee.js +351 -0
  98. package/src/webrtc/errors.js +116 -0
  99. package/src/webrtc/ice.js +301 -0
  100. package/src/webrtc/index.js +131 -0
  101. package/src/webrtc/joinToken.js +119 -0
  102. package/src/webrtc/observe.js +172 -0
  103. package/src/webrtc/peer.js +351 -0
  104. package/src/webrtc/reactive.js +268 -0
  105. package/src/webrtc/room.js +625 -0
  106. package/src/webrtc/sdp.js +302 -0
  107. package/src/webrtc/sfu/index.js +43 -0
  108. package/src/webrtc/sfu/livekit.js +131 -0
  109. package/src/webrtc/sfu/mediasoup.js +150 -0
  110. package/src/webrtc/signaling.js +373 -0
  111. package/src/webrtc/turn.js +237 -0
  112. package/tests/_helpers/webrtcFakes.js +289 -0
  113. package/tests/audit.test.js +4158 -4158
  114. package/tests/cli.test.js +1136 -1103
  115. package/tests/compare.test.js +497 -486
  116. package/tests/component.test.js +3969 -3938
  117. package/tests/core.test.js +1910 -1910
  118. package/tests/dev-server.test.js +489 -489
  119. package/tests/diff.test.js +1416 -1416
  120. package/tests/docs.test.js +1664 -1650
  121. package/tests/electron-features.test.js +864 -864
  122. package/tests/errors.test.js +619 -619
  123. package/tests/expression.test.js +1056 -1056
  124. package/tests/http.test.js +648 -648
  125. package/tests/reactive.test.js +819 -819
  126. package/tests/router.test.js +2327 -2327
  127. package/tests/ssr.test.js +870 -870
  128. package/tests/store.test.js +830 -830
  129. package/tests/test-minifier.js +153 -153
  130. package/tests/test-ssr.js +27 -27
  131. package/tests/utils.test.js +1377 -1377
  132. package/tests/webrtc/e2ee.test.js +283 -0
  133. package/tests/webrtc/ice.test.js +202 -0
  134. package/tests/webrtc/joinToken.test.js +89 -0
  135. package/tests/webrtc/observe.test.js +111 -0
  136. package/tests/webrtc/peer.test.js +373 -0
  137. package/tests/webrtc/reactive.test.js +235 -0
  138. package/tests/webrtc/room.test.js +406 -0
  139. package/tests/webrtc/sdp.test.js +151 -0
  140. package/tests/webrtc/sfu-livekit.test.js +119 -0
  141. package/tests/webrtc/sfu.test.js +160 -0
  142. package/tests/webrtc/signaling.test.js +251 -0
  143. package/tests/webrtc/turn.test.js +256 -0
  144. package/types/collection.d.ts +383 -383
  145. package/types/component.d.ts +186 -186
  146. package/types/errors.d.ts +135 -135
  147. package/types/http.d.ts +92 -92
  148. package/types/misc.d.ts +201 -201
  149. package/types/reactive.d.ts +98 -98
  150. package/types/router.d.ts +190 -190
  151. package/types/ssr.d.ts +102 -102
  152. package/types/store.d.ts +146 -146
  153. package/types/utils.d.ts +245 -245
  154. package/types/webrtc.d.ts +653 -0
package/index.d.ts CHANGED
@@ -1,371 +1,570 @@
1
- /**
2
- * zQuery (zeroQuery) - TypeScript Declarations
3
- *
4
- * Lightweight modern frontend library - jQuery-like selectors, reactive
5
- * components, SPA router, state management, HTTP client & utilities.
6
- *
7
- * @version 1.1.0
8
- * @license MIT
9
- * @see https://z-query.com/docs
10
- */
11
-
12
- // ---------------------------------------------------------------------------
13
- // Re-export every public type from the modular type files
14
- // ---------------------------------------------------------------------------
15
-
16
- export { ZQueryCollection } from './types/collection';
17
-
18
- export {
19
- ReactiveProxy,
20
- reactive,
21
- Signal,
22
- signal,
23
- computed,
24
- effect,
25
- batch,
26
- untracked,
27
- } from './types/reactive';
28
-
29
- export {
30
- ComponentDefinition,
31
- ComponentInstance,
32
- component,
33
- mount,
34
- mountAll,
35
- getInstance,
36
- destroy,
37
- getRegistry,
38
- prefetch,
39
- StyleHandle,
40
- StyleOptions,
41
- style,
42
- } from './types/component';
43
-
44
- export {
45
- RouteDefinition,
46
- NavigationContext,
47
- RouterConfig,
48
- RouterInstance,
49
- RouteMatch,
50
- createRouter,
51
- getRouter,
52
- matchRoute,
53
- } from './types/router';
54
-
55
- export {
56
- StoreConfig,
57
- StoreHistoryEntry,
58
- StoreInstance,
59
- createStore,
60
- getStore,
61
- } from './types/store';
62
-
63
- export {
64
- HttpResponse,
65
- HttpRequestOptions,
66
- HttpConfigureOptions,
67
- HttpRequestInterceptor,
68
- HttpResponseInterceptor,
69
- HttpClient,
70
- http,
71
- } from './types/http';
72
-
73
- export {
74
- DebouncedFunction,
75
- debounce,
76
- throttle,
77
- pipe,
78
- once,
79
- sleep,
80
- escapeHtml,
81
- stripHtml,
82
- html,
83
- TrustedHTML,
84
- trust,
85
- uuid,
86
- camelCase,
87
- kebabCase,
88
- deepClone,
89
- deepMerge,
90
- isEqual,
91
- param,
92
- parseQuery,
93
- StorageWrapper,
94
- storage,
95
- session,
96
- EventBus,
97
- bus,
98
- range,
99
- unique,
100
- chunk,
101
- groupBy,
102
- pick,
103
- omit,
104
- getPath,
105
- setPath,
106
- isEmpty,
107
- capitalize,
108
- truncate,
109
- clamp,
110
- MemoizedFunction,
111
- memoize,
112
- RetryOptions,
113
- retry,
114
- timeout,
115
- } from './types/utils';
116
-
117
- export {
118
- ErrorCode,
119
- ErrorCodeValue,
120
- ZQueryError,
121
- ZQueryErrorHandler,
122
- FormattedError,
123
- onError,
124
- reportError,
125
- guardCallback,
126
- guardAsync,
127
- validate,
128
- formatError,
129
- } from './types/errors';
130
-
131
- export {
132
- morph,
133
- morphElement,
134
- safeEval,
135
- EventModifier,
136
- } from './types/misc';
137
-
138
- export {
139
- SSRApp,
140
- createSSRApp,
141
- renderToString,
142
- } from './types/ssr';
143
-
144
- // ---------------------------------------------------------------------------
145
- // $ - Main function & namespace
146
- // ---------------------------------------------------------------------------
147
-
148
- import type { ZQueryCollection } from './types/collection';
149
- import type { reactive, Signal, signal, computed, effect, batch, untracked } from './types/reactive';
150
- import type { component, mount, mountAll, getInstance, destroy, getRegistry, prefetch, style } from './types/component';
151
- import type { createRouter, getRouter, matchRoute } from './types/router';
152
- import type { createStore, getStore } from './types/store';
153
- import type { HttpClient } from './types/http';
154
- import type {
155
- debounce, throttle, pipe, once, sleep,
156
- escapeHtml, stripHtml, html, trust, TrustedHTML, uuid, camelCase, kebabCase,
157
- deepClone, deepMerge, isEqual, param, parseQuery,
158
- StorageWrapper, EventBus,
159
- range, unique, chunk, groupBy,
160
- pick, omit, getPath, setPath, isEmpty,
161
- capitalize, truncate, clamp,
162
- MemoizedFunction, memoize, RetryOptions, retry, timeout,
163
- } from './types/utils';
164
- import type { onError, ZQueryError, ErrorCode, guardCallback, guardAsync, validate, formatError } from './types/errors';
165
- import type { morph, morphElement, safeEval } from './types/misc';
166
-
167
- /**
168
- * Main selector / DOM-ready function - always returns a `ZQueryCollection` (like jQuery).
169
- *
170
- * - `$('selector')` → ZQueryCollection via `querySelectorAll`
171
- * - `$('<div>…</div>')` → ZQueryCollection from created elements
172
- * - `$(element)` → ZQueryCollection wrapping the element
173
- * - `$(fn)` → DOMContentLoaded shorthand
174
- */
175
- interface ZQueryStatic {
176
- (selector: string, context?: string | Element): ZQueryCollection;
177
- (element: Element | Window): ZQueryCollection;
178
- (nodeList: NodeList | HTMLCollection | Element[]): ZQueryCollection;
179
- (fn: () => void): void;
180
-
181
- // -- Collection selector -------------------------------------------------
182
- /**
183
- * Collection selector - returns a `ZQueryCollection`.
184
- *
185
- * - `$.all('.card')` → all matching elements
186
- * - `$.all('<div>…</div>')` → create elements as collection
187
- * - `$.all(element)` → wrap single element
188
- * - `$.all(nodeList)` → wrap NodeList
189
- */
190
- all(selector: string, context?: string | Element): ZQueryCollection;
191
- all(element: Element | Window): ZQueryCollection;
192
- all(nodeList: NodeList | HTMLCollection | Element[]): ZQueryCollection;
193
-
194
- // -- Quick-ref shortcuts -------------------------------------------------
195
- /** `document.getElementById(id)` */
196
- id(id: string): Element | null;
197
- /** `document.querySelector('.name')` */
198
- class(name: string): Element | null;
199
- /** `document.getElementsByClassName(name)` as `ZQueryCollection`. */
200
- classes(name: string): ZQueryCollection;
201
- /** `document.getElementsByTagName(name)` as `ZQueryCollection`. */
202
- tag(name: string): ZQueryCollection;
203
- /** `document.getElementsByName(name)` as `ZQueryCollection`. */
204
- name(name: string): ZQueryCollection;
205
- /** Children of `#parentId` as `ZQueryCollection`. */
206
- children(parentId: string): ZQueryCollection;
207
- /** `document.querySelector(selector)` - raw Element or null. */
208
- qs(selector: string, context?: Element | Document): Element | null;
209
- /** `document.querySelectorAll(selector)` - as a real `Array<Element>`. */
210
- qsa(selector: string, context?: Element | Document): Element[];
211
-
212
- // -- Static helpers ------------------------------------------------------
213
- /**
214
- * Create a DOM element.
215
- * Special `attrs` keys: `class`, `style` (object), `on*` (handler), `data` (object).
216
- */
217
- create(
218
- tag: string,
219
- attrs?: Record<string, any>,
220
- ...children: Array<string | Node>
221
- ): ZQueryCollection;
222
-
223
- /** Register a DOMContentLoaded callback (fires immediately if already loaded). */
224
- ready(fn: () => void): void;
225
-
226
- /** Global event delegation on `document`. */
227
- on(event: string, selector: string, handler: (this: Element, e: Event) => void): void;
228
-
229
- /** Direct event listener on a specific target (e.g. `window`). */
230
- on(event: string, target: EventTarget, handler: (e: Event) => void): void;
231
-
232
- /** Direct event listener on `document` (for keydown, resize, etc.). */
233
- on(event: string, handler: (e: Event) => void): void;
234
-
235
- /** Remove a direct global event listener previously attached with `$.on(event, handler)`. */
236
- off(event: string, handler: (e: Event) => void): void;
237
-
238
- /** Alias for `ZQueryCollection.prototype` - extend to add custom collection methods. */
239
- fn: typeof ZQueryCollection.prototype;
240
-
241
- // -- Reactive ------------------------------------------------------------
242
- reactive: typeof reactive;
243
- Signal: typeof Signal;
244
- signal: typeof signal;
245
- computed: typeof computed;
246
- effect: typeof effect;
247
- batch: typeof batch;
248
- untracked: typeof untracked;
249
-
250
- // -- Components ----------------------------------------------------------
251
- component: typeof component;
252
- mount: typeof mount;
253
- mountAll: typeof mountAll;
254
- getInstance: typeof getInstance;
255
- destroy: typeof destroy;
256
- /** Returns all registered component definitions. */
257
- components: typeof getRegistry;
258
- /** Pre-load external templates and styles for a component. */
259
- prefetch: typeof prefetch;
260
- style: typeof style;
261
- morph: typeof morph;
262
- /** Morph a single element in place - preserves identity when tag name matches. */
263
- morphElement: typeof morphElement;
264
- safeEval: typeof safeEval;
265
-
266
- // -- Router --------------------------------------------------------------
267
- router: typeof createRouter;
268
- getRouter: typeof getRouter;
269
- matchRoute: typeof matchRoute;
270
-
271
- // -- Store ---------------------------------------------------------------
272
- store: typeof createStore;
273
- getStore: typeof getStore;
274
-
275
- // -- HTTP ----------------------------------------------------------------
276
- http: HttpClient;
277
- get: HttpClient['get'];
278
- post: HttpClient['post'];
279
- put: HttpClient['put'];
280
- patch: HttpClient['patch'];
281
- delete: HttpClient['delete'];
282
- head: HttpClient['head'];
283
-
284
- // -- Error Handling ------------------------------------------------------
285
- /** Register a global error handler (or pass `null` to remove). */
286
- onError: typeof onError;
287
- /** Structured error class. */
288
- ZQueryError: typeof ZQueryError;
289
- /** Frozen map of all error code constants. */
290
- ErrorCode: typeof ErrorCode;
291
- /** Wrap a callback so thrown errors are caught and reported via the global handler. */
292
- guardCallback: typeof guardCallback;
293
- /** Wrap an async function so thrown errors are caught and reported via the global handler. */
294
- guardAsync: typeof guardAsync;
295
- /** Validate a required value is defined and of the expected type. */
296
- validate: typeof validate;
297
- /** Format a ZQueryError into a structured plain object. */
298
- formatError: typeof formatError;
299
-
300
- // -- Utilities -----------------------------------------------------------
301
- debounce: typeof debounce;
302
- throttle: typeof throttle;
303
- pipe: typeof pipe;
304
- once: typeof once;
305
- sleep: typeof sleep;
306
-
307
- escapeHtml: typeof escapeHtml;
308
- stripHtml: typeof stripHtml;
309
- html: typeof html;
310
- trust: typeof trust;
311
- TrustedHTML: typeof TrustedHTML;
312
- uuid: typeof uuid;
313
- camelCase: typeof camelCase;
314
- kebabCase: typeof kebabCase;
315
-
316
- deepClone: typeof deepClone;
317
- deepMerge: typeof deepMerge;
318
- isEqual: typeof isEqual;
319
-
320
- param: typeof param;
321
- parseQuery: typeof parseQuery;
322
-
323
- storage: StorageWrapper;
324
- session: StorageWrapper;
325
- EventBus: typeof EventBus;
326
- bus: EventBus;
327
-
328
- range: typeof range;
329
- unique: typeof unique;
330
- chunk: typeof chunk;
331
- groupBy: typeof groupBy;
332
- pick: typeof pick;
333
- omit: typeof omit;
334
- getPath: typeof getPath;
335
- setPath: typeof setPath;
336
- isEmpty: typeof isEmpty;
337
- capitalize: typeof capitalize;
338
- truncate: typeof truncate;
339
- clamp: typeof clamp;
340
- memoize: typeof memoize;
341
- retry: typeof retry;
342
- timeout: typeof timeout;
343
-
344
- // -- Meta ----------------------------------------------------------------
345
- /** Library version string. */
346
- version: string;
347
- /** Minified library size string (e.g. `"~85.5 KB"`), injected at build time. */
348
- libSize: string;
349
- /** Unit test results captured at build time. */
350
- unitTests: {
351
- passed: number;
352
- failed: number;
353
- total: number;
354
- suites: number;
355
- duration: number;
356
- ok: boolean;
357
- };
358
- /** Populated at build time by the CLI bundler. */
359
- meta: Record<string, any>;
360
- /** Remove `$` from `window` and return the library object. */
361
- noConflict(): ZQueryStatic;
362
- }
363
-
364
- /** The main `$` / `zQuery` function + namespace. */
365
- export const $: ZQueryStatic;
366
- export { $ as zQuery };
367
-
368
- /** Collection selector function - same as `$.all()`. */
369
- export function queryAll(selector: string, context?: string | Element): ZQueryCollection;
370
- export function queryAll(element: Element): ZQueryCollection;
371
- export function queryAll(nodeList: NodeList | HTMLCollection | Element[]): ZQueryCollection;
1
+ /**
2
+ * zQuery (zeroQuery) - TypeScript Declarations
3
+ *
4
+ * Lightweight modern frontend library - jQuery-like selectors, reactive
5
+ * components, SPA router, state management, HTTP client & utilities.
6
+ *
7
+ * @version 1.1.0
8
+ * @license MIT
9
+ * @see https://z-query.com/docs
10
+ */
11
+
12
+ // ---------------------------------------------------------------------------
13
+ // Re-export every public type from the modular type files
14
+ // ---------------------------------------------------------------------------
15
+
16
+ export { ZQueryCollection } from './types/collection';
17
+
18
+ export {
19
+ ReactiveProxy,
20
+ reactive,
21
+ Signal,
22
+ signal,
23
+ computed,
24
+ effect,
25
+ batch,
26
+ untracked,
27
+ } from './types/reactive';
28
+
29
+ export {
30
+ ComponentDefinition,
31
+ ComponentInstance,
32
+ component,
33
+ mount,
34
+ mountAll,
35
+ getInstance,
36
+ destroy,
37
+ getRegistry,
38
+ prefetch,
39
+ StyleHandle,
40
+ StyleOptions,
41
+ style,
42
+ } from './types/component';
43
+
44
+ export {
45
+ RouteDefinition,
46
+ NavigationContext,
47
+ RouterConfig,
48
+ RouterInstance,
49
+ RouteMatch,
50
+ createRouter,
51
+ getRouter,
52
+ matchRoute,
53
+ } from './types/router';
54
+
55
+ export {
56
+ StoreConfig,
57
+ StoreHistoryEntry,
58
+ StoreInstance,
59
+ createStore,
60
+ getStore,
61
+ } from './types/store';
62
+
63
+ export {
64
+ HttpResponse,
65
+ HttpRequestOptions,
66
+ HttpConfigureOptions,
67
+ HttpRequestInterceptor,
68
+ HttpResponseInterceptor,
69
+ HttpClient,
70
+ http,
71
+ } from './types/http';
72
+
73
+ export {
74
+ DebouncedFunction,
75
+ debounce,
76
+ throttle,
77
+ pipe,
78
+ once,
79
+ sleep,
80
+ escapeHtml,
81
+ stripHtml,
82
+ html,
83
+ TrustedHTML,
84
+ trust,
85
+ uuid,
86
+ camelCase,
87
+ kebabCase,
88
+ deepClone,
89
+ deepMerge,
90
+ isEqual,
91
+ param,
92
+ parseQuery,
93
+ StorageWrapper,
94
+ storage,
95
+ session,
96
+ EventBus,
97
+ bus,
98
+ range,
99
+ unique,
100
+ chunk,
101
+ groupBy,
102
+ pick,
103
+ omit,
104
+ getPath,
105
+ setPath,
106
+ isEmpty,
107
+ capitalize,
108
+ truncate,
109
+ clamp,
110
+ MemoizedFunction,
111
+ memoize,
112
+ RetryOptions,
113
+ retry,
114
+ timeout,
115
+ } from './types/utils';
116
+
117
+ export {
118
+ ErrorCode,
119
+ ErrorCodeValue,
120
+ ZQueryError,
121
+ ZQueryErrorHandler,
122
+ FormattedError,
123
+ onError,
124
+ reportError,
125
+ guardCallback,
126
+ guardAsync,
127
+ validate,
128
+ formatError,
129
+ } from './types/errors';
130
+
131
+ export {
132
+ morph,
133
+ morphElement,
134
+ safeEval,
135
+ EventModifier,
136
+ } from './types/misc';
137
+
138
+ export {
139
+ SSRApp,
140
+ createSSRApp,
141
+ renderToString,
142
+ } from './types/ssr';
143
+
144
+ export {
145
+ WebRtcError,
146
+ SignalingError,
147
+ IceError,
148
+ SdpError,
149
+ TurnError,
150
+ E2eeError,
151
+ SfuError,
152
+ WebRtcErrorOptions,
153
+ SignalingClient,
154
+ SignalingClientOptions,
155
+ SignalingReconnectOptions,
156
+ Peer,
157
+ PeerOptions,
158
+ PeerEvent,
159
+ JoinOptions,
160
+ PeerInfo,
161
+ Room,
162
+ RoomDataChannel,
163
+ ReactiveHandle,
164
+ DataChannelMessage,
165
+ join,
166
+ useRoom,
167
+ usePeer,
168
+ useTracks,
169
+ useDataChannel,
170
+ useConnectionQuality,
171
+ fetchTurnCredentials,
172
+ mergeIceServers,
173
+ createTurnRefresher,
174
+ deriveSFrameKey,
175
+ generateSFrameKey,
176
+ SFrameContext,
177
+ encryptFrame,
178
+ decryptFrame,
179
+ attachE2ee,
180
+ loadSfuAdapter,
181
+ decodeJoinToken,
182
+ isJoinTokenExpired,
183
+ DecodedJoinToken,
184
+ samplePeerStats,
185
+ createStatsSampler,
186
+ classifyStats,
187
+ PeerStatsSample,
188
+ FetchTurnOptions,
189
+ TurnRefresher,
190
+ TurnRefresherOptions,
191
+ TurnCredentials,
192
+ SfuAdapter,
193
+ WebRtcNamespace,
194
+ webrtc,
195
+ parseSdp,
196
+ validateSdp,
197
+ SDP_DIRECTIONS,
198
+ ParsedSdp,
199
+ SdpMedia,
200
+ SdpAttribute,
201
+ SdpFingerprint,
202
+ SdpRtpMap,
203
+ ParseSdpOptions,
204
+ parseCandidate,
205
+ stringifyCandidate,
206
+ filterCandidates,
207
+ isPrivateIp,
208
+ isLoopbackIp,
209
+ isLinkLocalIp,
210
+ isMdnsHostname,
211
+ IceCandidate,
212
+ CandidateFilterPolicy,
213
+ CANDIDATE_TYPES,
214
+ TCP_TYPES,
215
+ } from './types/webrtc';
216
+
217
+ // ---------------------------------------------------------------------------
218
+ // $ - Main function & namespace
219
+ // ---------------------------------------------------------------------------
220
+
221
+ import type { ZQueryCollection } from './types/collection';
222
+ import type { reactive, Signal, signal, computed, effect, batch, untracked } from './types/reactive';
223
+ import type { component, mount, mountAll, getInstance, destroy, getRegistry, prefetch, style } from './types/component';
224
+ import type { createRouter, getRouter, matchRoute } from './types/router';
225
+ import type { createStore, getStore } from './types/store';
226
+ import type { HttpClient } from './types/http';
227
+ import type {
228
+ debounce, throttle, pipe, once, sleep,
229
+ escapeHtml, stripHtml, html, trust, TrustedHTML, uuid, camelCase, kebabCase,
230
+ deepClone, deepMerge, isEqual, param, parseQuery,
231
+ StorageWrapper, EventBus,
232
+ range, unique, chunk, groupBy,
233
+ pick, omit, getPath, setPath, isEmpty,
234
+ capitalize, truncate, clamp,
235
+ MemoizedFunction, memoize, RetryOptions, retry, timeout,
236
+ } from './types/utils';
237
+ import type { onError, ZQueryError, ErrorCode, guardCallback, guardAsync, validate, formatError } from './types/errors';
238
+ import type { morph, morphElement, safeEval } from './types/misc';
239
+ import type {
240
+ WebRtcNamespace,
241
+ SignalingClient,
242
+ Peer,
243
+ Room,
244
+ join as webrtcJoin,
245
+ useRoom,
246
+ usePeer,
247
+ useTracks,
248
+ useDataChannel,
249
+ useConnectionQuality,
250
+ fetchTurnCredentials,
251
+ mergeIceServers,
252
+ createTurnRefresher,
253
+ deriveSFrameKey,
254
+ generateSFrameKey,
255
+ SFrameContext,
256
+ encryptFrame,
257
+ decryptFrame,
258
+ attachE2ee,
259
+ loadSfuAdapter,
260
+ decodeJoinToken,
261
+ isJoinTokenExpired,
262
+ samplePeerStats,
263
+ createStatsSampler,
264
+ classifyStats,
265
+ WebRtcError,
266
+ SignalingError,
267
+ IceError,
268
+ SdpError,
269
+ TurnError,
270
+ E2eeError,
271
+ SfuError,
272
+ parseSdp,
273
+ validateSdp,
274
+ parseCandidate,
275
+ stringifyCandidate,
276
+ filterCandidates,
277
+ isPrivateIp,
278
+ isLoopbackIp,
279
+ isLinkLocalIp,
280
+ isMdnsHostname,
281
+ } from './types/webrtc';
282
+
283
+ /**
284
+ * Main selector / DOM-ready function - always returns a `ZQueryCollection` (like jQuery).
285
+ *
286
+ * - `$('selector')` → ZQueryCollection via `querySelectorAll`
287
+ * - `$('<div>…</div>')` → ZQueryCollection from created elements
288
+ * - `$(element)` → ZQueryCollection wrapping the element
289
+ * - `$(fn)` DOMContentLoaded shorthand
290
+ */
291
+ interface ZQueryStatic {
292
+ (selector: string, context?: string | Element): ZQueryCollection;
293
+ (element: Element | Window): ZQueryCollection;
294
+ (nodeList: NodeList | HTMLCollection | Element[]): ZQueryCollection;
295
+ (fn: () => void): void;
296
+
297
+ // -- Collection selector -------------------------------------------------
298
+ /**
299
+ * Collection selector - returns a `ZQueryCollection`.
300
+ *
301
+ * - `$.all('.card')` → all matching elements
302
+ * - `$.all('<div>…</div>')` → create elements as collection
303
+ * - `$.all(element)` → wrap single element
304
+ * - `$.all(nodeList)` → wrap NodeList
305
+ */
306
+ all(selector: string, context?: string | Element): ZQueryCollection;
307
+ all(element: Element | Window): ZQueryCollection;
308
+ all(nodeList: NodeList | HTMLCollection | Element[]): ZQueryCollection;
309
+
310
+ // -- Quick-ref shortcuts -------------------------------------------------
311
+ /** `document.getElementById(id)` */
312
+ id(id: string): Element | null;
313
+ /** `document.querySelector('.name')` */
314
+ class(name: string): Element | null;
315
+ /** `document.getElementsByClassName(name)` as `ZQueryCollection`. */
316
+ classes(name: string): ZQueryCollection;
317
+ /** `document.getElementsByTagName(name)` as `ZQueryCollection`. */
318
+ tag(name: string): ZQueryCollection;
319
+ /** `document.getElementsByName(name)` as `ZQueryCollection`. */
320
+ name(name: string): ZQueryCollection;
321
+ /** Children of `#parentId` as `ZQueryCollection`. */
322
+ children(parentId: string): ZQueryCollection;
323
+ /** `document.querySelector(selector)` - raw Element or null. */
324
+ qs(selector: string, context?: Element | Document): Element | null;
325
+ /** `document.querySelectorAll(selector)` - as a real `Array<Element>`. */
326
+ qsa(selector: string, context?: Element | Document): Element[];
327
+
328
+ // -- Static helpers ------------------------------------------------------
329
+ /**
330
+ * Create a DOM element.
331
+ * Special `attrs` keys: `class`, `style` (object), `on*` (handler), `data` (object).
332
+ */
333
+ create(
334
+ tag: string,
335
+ attrs?: Record<string, any>,
336
+ ...children: Array<string | Node>
337
+ ): ZQueryCollection;
338
+
339
+ /** Register a DOMContentLoaded callback (fires immediately if already loaded). */
340
+ ready(fn: () => void): void;
341
+
342
+ /** Global event delegation on `document`. */
343
+ on(event: string, selector: string, handler: (this: Element, e: Event) => void): void;
344
+
345
+ /** Direct event listener on a specific target (e.g. `window`). */
346
+ on(event: string, target: EventTarget, handler: (e: Event) => void): void;
347
+
348
+ /** Direct event listener on `document` (for keydown, resize, etc.). */
349
+ on(event: string, handler: (e: Event) => void): void;
350
+
351
+ /** Remove a direct global event listener previously attached with `$.on(event, handler)`. */
352
+ off(event: string, handler: (e: Event) => void): void;
353
+
354
+ /** Alias for `ZQueryCollection.prototype` - extend to add custom collection methods. */
355
+ fn: typeof ZQueryCollection.prototype;
356
+
357
+ // -- Reactive ------------------------------------------------------------
358
+ reactive: typeof reactive;
359
+ Signal: typeof Signal;
360
+ signal: typeof signal;
361
+ computed: typeof computed;
362
+ effect: typeof effect;
363
+ batch: typeof batch;
364
+ untracked: typeof untracked;
365
+
366
+ // -- Components ----------------------------------------------------------
367
+ component: typeof component;
368
+ mount: typeof mount;
369
+ mountAll: typeof mountAll;
370
+ getInstance: typeof getInstance;
371
+ destroy: typeof destroy;
372
+ /** Returns all registered component definitions. */
373
+ components: typeof getRegistry;
374
+ /** Pre-load external templates and styles for a component. */
375
+ prefetch: typeof prefetch;
376
+ style: typeof style;
377
+ morph: typeof morph;
378
+ /** Morph a single element in place - preserves identity when tag name matches. */
379
+ morphElement: typeof morphElement;
380
+ safeEval: typeof safeEval;
381
+
382
+ // -- Router --------------------------------------------------------------
383
+ router: typeof createRouter;
384
+ getRouter: typeof getRouter;
385
+ matchRoute: typeof matchRoute;
386
+
387
+ // -- Store ---------------------------------------------------------------
388
+ store: typeof createStore;
389
+ getStore: typeof getStore;
390
+
391
+ // -- HTTP ----------------------------------------------------------------
392
+ http: HttpClient;
393
+ get: HttpClient['get'];
394
+ post: HttpClient['post'];
395
+ put: HttpClient['put'];
396
+ patch: HttpClient['patch'];
397
+ delete: HttpClient['delete'];
398
+ head: HttpClient['head'];
399
+
400
+ // -- Error Handling ------------------------------------------------------
401
+ /** Register a global error handler (or pass `null` to remove). */
402
+ onError: typeof onError;
403
+ /** Structured error class. */
404
+ ZQueryError: typeof ZQueryError;
405
+ /** Frozen map of all error code constants. */
406
+ ErrorCode: typeof ErrorCode;
407
+ /** Wrap a callback so thrown errors are caught and reported via the global handler. */
408
+ guardCallback: typeof guardCallback;
409
+ /** Wrap an async function so thrown errors are caught and reported via the global handler. */
410
+ guardAsync: typeof guardAsync;
411
+ /** Validate a required value is defined and of the expected type. */
412
+ validate: typeof validate;
413
+ /** Format a ZQueryError into a structured plain object. */
414
+ formatError: typeof formatError;
415
+
416
+ // -- Utilities -----------------------------------------------------------
417
+ debounce: typeof debounce;
418
+ throttle: typeof throttle;
419
+ pipe: typeof pipe;
420
+ once: typeof once;
421
+ sleep: typeof sleep;
422
+
423
+ escapeHtml: typeof escapeHtml;
424
+ stripHtml: typeof stripHtml;
425
+ html: typeof html;
426
+ trust: typeof trust;
427
+ TrustedHTML: typeof TrustedHTML;
428
+ uuid: typeof uuid;
429
+ camelCase: typeof camelCase;
430
+ kebabCase: typeof kebabCase;
431
+
432
+ deepClone: typeof deepClone;
433
+ deepMerge: typeof deepMerge;
434
+ isEqual: typeof isEqual;
435
+
436
+ param: typeof param;
437
+ parseQuery: typeof parseQuery;
438
+
439
+ storage: StorageWrapper;
440
+ session: StorageWrapper;
441
+ EventBus: typeof EventBus;
442
+ bus: EventBus;
443
+
444
+ range: typeof range;
445
+ unique: typeof unique;
446
+ chunk: typeof chunk;
447
+ groupBy: typeof groupBy;
448
+ pick: typeof pick;
449
+ omit: typeof omit;
450
+ getPath: typeof getPath;
451
+ setPath: typeof setPath;
452
+ isEmpty: typeof isEmpty;
453
+ capitalize: typeof capitalize;
454
+ truncate: typeof truncate;
455
+ clamp: typeof clamp;
456
+ memoize: typeof memoize;
457
+ retry: typeof retry;
458
+ timeout: typeof timeout;
459
+
460
+ // -- WebRTC --------------------------------------------------------------
461
+ /** WebRTC namespace - low-level `SignalingClient`, error family, and (future) high-level helpers. */
462
+ webrtc: WebRtcNamespace;
463
+ /** Low-level WebSocket signaling client (speaks `@zero-server/webrtc` wire). */
464
+ SignalingClient: typeof SignalingClient;
465
+ /** Per-remote-peer `RTCPeerConnection` wrapper with perfect negotiation. */
466
+ Peer: typeof Peer;
467
+ /** High-level multi-peer room handle. */
468
+ Room: typeof Room;
469
+ /** Join a room over the given signaling URL. */
470
+ webrtcJoin: typeof webrtcJoin;
471
+ /** Resolve a `Room` from a URL or pass-through an existing one. */
472
+ useRoom: typeof useRoom;
473
+ /** Reactive handle that tracks a remote peer by id. */
474
+ usePeer: typeof usePeer;
475
+ /** Reactive handle exposing the live track list for a peer. */
476
+ useTracks: typeof useTracks;
477
+ /** Reactive multiplexed data channel keyed by `label`. */
478
+ useDataChannel: typeof useDataChannel;
479
+ /** Reactive connection-quality bucket from periodic `getStats()`. */
480
+ useConnectionQuality: typeof useConnectionQuality;
481
+ /** Fetch TURN credentials from the app's HTTP endpoint. */
482
+ fetchTurnCredentials: typeof fetchTurnCredentials;
483
+ /** Merge TURN credentials with a base `iceServers[]`. */
484
+ mergeIceServers: typeof mergeIceServers;
485
+ /** Schedule automatic TURN-credential refresh ahead of expiry. */
486
+ createTurnRefresher: typeof createTurnRefresher;
487
+ /** Derive an AES-GCM-128 SFrame key from a shared passphrase + salt. */
488
+ deriveSFrameKey: typeof deriveSFrameKey;
489
+ /** Generate a random AES-GCM-128 SFrame key. */
490
+ generateSFrameKey: typeof generateSFrameKey;
491
+ /** SFrame epoch / key holder. */
492
+ SFrameContext: typeof SFrameContext;
493
+ /** Encrypt a single frame with the current SFrame epoch's key. */
494
+ encryptFrame: typeof encryptFrame;
495
+ /** Decrypt a frame previously produced by `encryptFrame()`. */
496
+ decryptFrame: typeof decryptFrame;
497
+ /** Install SFrame encrypt/decrypt transforms on a peer connection. */
498
+ attachE2ee: typeof attachE2ee;
499
+ /** Load an optional SFU adapter (peer-dep). */
500
+ loadSfuAdapter: typeof loadSfuAdapter;
501
+ /** UX-only decode of a server-issued join token. */
502
+ decodeJoinToken: typeof decodeJoinToken;
503
+ /** Returns `true` if a decoded token's `exp` is in the past. */
504
+ isJoinTokenExpired: typeof isJoinTokenExpired;
505
+ /** One-shot reduced `getStats()` snapshot. */
506
+ samplePeerStats: typeof samplePeerStats;
507
+ /** Periodic `getStats()` sampler. */
508
+ createStatsSampler: typeof createStatsSampler;
509
+ /** Bucket a reduced sample into a connection-quality label. */
510
+ classifyStats: typeof classifyStats;
511
+ /** Parse an SDP document into a structured `ParsedSdp`. */
512
+ parseSdp: typeof parseSdp;
513
+ /** Parse + enforce server-side SDP constraints. */
514
+ validateSdp: typeof validateSdp;
515
+ /** Parse a single `candidate:` line. */
516
+ parseCandidate: typeof parseCandidate;
517
+ /** Serialize a parsed candidate back to canonical line form. */
518
+ stringifyCandidate: typeof stringifyCandidate;
519
+ /** Filter candidates against a privacy / policy filter. */
520
+ filterCandidates: typeof filterCandidates;
521
+ /** True for RFC 1918 / 6598 / IPv6 ULA addresses. */
522
+ isPrivateIp: typeof isPrivateIp;
523
+ /** True for `127.0.0.0/8` and `::1`. */
524
+ isLoopbackIp: typeof isLoopbackIp;
525
+ /** True for `169.254/16` and `fe80::/10`. */
526
+ isLinkLocalIp: typeof isLinkLocalIp;
527
+ /** True for `.local` mDNS hostnames. */
528
+ isMdnsHostname: typeof isMdnsHostname;
529
+ /** Base WebRTC error. */
530
+ WebRtcError: typeof WebRtcError;
531
+ /** Signaling-channel error. */
532
+ SignalingError: typeof SignalingError;
533
+ /** ICE candidate / connectivity error. */
534
+ IceError: typeof IceError;
535
+ /** SDP parse / validate error. */
536
+ SdpError: typeof SdpError;
537
+ /** TURN credential error. */
538
+ TurnError: typeof TurnError;
539
+ /** End-to-end encryption error. */
540
+ E2eeError: typeof E2eeError;
541
+ SfuError: typeof SfuError;
542
+
543
+ // -- Meta ----------------------------------------------------------------
544
+ /** Library version string. */
545
+ version: string;
546
+ /** Minified library size string (e.g. `"~85.5 KB"`), injected at build time. */
547
+ libSize: string;
548
+ /** Unit test results captured at build time. */
549
+ unitTests: {
550
+ passed: number;
551
+ failed: number;
552
+ total: number;
553
+ suites: number;
554
+ duration: number;
555
+ ok: boolean;
556
+ };
557
+ /** Populated at build time by the CLI bundler. */
558
+ meta: Record<string, any>;
559
+ /** Remove `$` from `window` and return the library object. */
560
+ noConflict(): ZQueryStatic;
561
+ }
562
+
563
+ /** The main `$` / `zQuery` function + namespace. */
564
+ export const $: ZQueryStatic;
565
+ export { $ as zQuery };
566
+
567
+ /** Collection selector function - same as `$.all()`. */
568
+ export function queryAll(selector: string, context?: string | Element): ZQueryCollection;
569
+ export function queryAll(element: Element): ZQueryCollection;
570
+ export function queryAll(nodeList: NodeList | HTMLCollection | Element[]): ZQueryCollection;