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.
- package/LICENSE +21 -21
- package/README.md +2 -0
- package/cli/args.js +33 -33
- package/cli/commands/build-api.js +443 -442
- package/cli/commands/build.js +254 -247
- package/cli/commands/bundle.js +1228 -1224
- package/cli/commands/create.js +137 -121
- package/cli/commands/dev/devtools/index.js +56 -56
- package/cli/commands/dev/devtools/js/components.js +49 -49
- package/cli/commands/dev/devtools/js/core.js +423 -423
- package/cli/commands/dev/devtools/js/elements.js +421 -421
- package/cli/commands/dev/devtools/js/network.js +166 -166
- package/cli/commands/dev/devtools/js/performance.js +73 -73
- package/cli/commands/dev/devtools/js/router.js +105 -105
- package/cli/commands/dev/devtools/js/source.js +132 -132
- package/cli/commands/dev/devtools/js/stats.js +35 -35
- package/cli/commands/dev/devtools/js/tabs.js +79 -79
- package/cli/commands/dev/devtools/panel.html +95 -95
- package/cli/commands/dev/devtools/styles.css +244 -244
- package/cli/commands/dev/index.js +107 -107
- package/cli/commands/dev/logger.js +75 -75
- package/cli/commands/dev/overlay.js +858 -858
- package/cli/commands/dev/server.js +220 -220
- package/cli/commands/dev/validator.js +94 -94
- package/cli/commands/dev/watcher.js +172 -172
- package/cli/help.js +114 -112
- package/cli/index.js +52 -52
- package/cli/scaffold/default/LICENSE +21 -21
- package/cli/scaffold/default/app/app.js +207 -207
- package/cli/scaffold/default/app/components/about.js +201 -201
- package/cli/scaffold/default/app/components/api-demo.js +143 -143
- package/cli/scaffold/default/app/components/contact-card.js +231 -231
- package/cli/scaffold/default/app/components/contacts/contacts.css +706 -706
- package/cli/scaffold/default/app/components/contacts/contacts.html +200 -200
- package/cli/scaffold/default/app/components/contacts/contacts.js +196 -196
- package/cli/scaffold/default/app/components/counter.js +127 -127
- package/cli/scaffold/default/app/components/home.js +249 -249
- package/cli/scaffold/default/app/components/not-found.js +16 -16
- package/cli/scaffold/default/app/components/playground/playground.css +115 -115
- package/cli/scaffold/default/app/components/playground/playground.html +161 -161
- package/cli/scaffold/default/app/components/playground/playground.js +116 -116
- package/cli/scaffold/default/app/components/todos.js +225 -225
- package/cli/scaffold/default/app/components/toolkit/toolkit.css +97 -97
- package/cli/scaffold/default/app/components/toolkit/toolkit.html +146 -146
- package/cli/scaffold/default/app/components/toolkit/toolkit.js +280 -280
- package/cli/scaffold/default/app/routes.js +15 -15
- package/cli/scaffold/default/app/store.js +101 -101
- package/cli/scaffold/default/global.css +552 -552
- package/cli/scaffold/default/index.html +99 -99
- package/cli/scaffold/minimal/app/app.js +85 -85
- package/cli/scaffold/minimal/app/components/about.js +68 -68
- package/cli/scaffold/minimal/app/components/counter.js +122 -122
- package/cli/scaffold/minimal/app/components/home.js +68 -68
- package/cli/scaffold/minimal/app/components/not-found.js +16 -16
- package/cli/scaffold/minimal/app/routes.js +9 -9
- package/cli/scaffold/minimal/app/store.js +36 -36
- package/cli/scaffold/minimal/global.css +300 -300
- package/cli/scaffold/minimal/index.html +44 -44
- package/cli/scaffold/ssr/app/app.js +41 -41
- package/cli/scaffold/ssr/app/components/about.js +55 -55
- package/cli/scaffold/ssr/app/components/blog/index.js +65 -65
- package/cli/scaffold/ssr/app/components/blog/post.js +86 -86
- package/cli/scaffold/ssr/app/components/home.js +37 -37
- package/cli/scaffold/ssr/app/components/not-found.js +15 -15
- package/cli/scaffold/ssr/app/routes.js +8 -8
- package/cli/scaffold/ssr/global.css +228 -228
- package/cli/scaffold/ssr/index.html +37 -37
- package/cli/scaffold/ssr/package.json +8 -8
- package/cli/scaffold/ssr/server/data/posts.js +144 -144
- package/cli/scaffold/ssr/server/index.js +213 -213
- package/cli/scaffold/webrtc/app/app.js +11 -0
- package/cli/scaffold/webrtc/app/components/video-room.js +295 -0
- package/cli/scaffold/webrtc/app/lib/room.js +252 -0
- package/cli/scaffold/webrtc/assets/.gitkeep +0 -0
- package/cli/scaffold/webrtc/global.css +250 -0
- package/cli/scaffold/webrtc/index.html +21 -0
- package/cli/utils.js +305 -287
- package/dist/API.md +661 -0
- package/dist/zquery.dist.zip +0 -0
- package/dist/zquery.js +10313 -6614
- package/dist/zquery.min.js +8 -631
- package/index.d.ts +570 -371
- package/index.js +311 -240
- package/package.json +76 -70
- package/src/component.js +1709 -1691
- package/src/core.js +921 -921
- package/src/diff.js +497 -497
- package/src/errors.js +209 -209
- package/src/expression.js +922 -922
- package/src/http.js +242 -242
- package/src/package.json +1 -1
- package/src/reactive.js +255 -255
- package/src/router.js +843 -843
- package/src/ssr.js +418 -418
- package/src/store.js +318 -318
- package/src/utils.js +515 -515
- package/src/webrtc/e2ee.js +351 -0
- package/src/webrtc/errors.js +116 -0
- package/src/webrtc/ice.js +301 -0
- package/src/webrtc/index.js +131 -0
- package/src/webrtc/joinToken.js +119 -0
- package/src/webrtc/observe.js +172 -0
- package/src/webrtc/peer.js +351 -0
- package/src/webrtc/reactive.js +268 -0
- package/src/webrtc/room.js +625 -0
- package/src/webrtc/sdp.js +302 -0
- package/src/webrtc/sfu/index.js +43 -0
- package/src/webrtc/sfu/livekit.js +131 -0
- package/src/webrtc/sfu/mediasoup.js +150 -0
- package/src/webrtc/signaling.js +373 -0
- package/src/webrtc/turn.js +237 -0
- package/tests/_helpers/webrtcFakes.js +289 -0
- package/tests/audit.test.js +4158 -4158
- package/tests/cli.test.js +1136 -1103
- package/tests/compare.test.js +497 -486
- package/tests/component.test.js +3969 -3938
- package/tests/core.test.js +1910 -1910
- package/tests/dev-server.test.js +489 -489
- package/tests/diff.test.js +1416 -1416
- package/tests/docs.test.js +1664 -1650
- package/tests/electron-features.test.js +864 -864
- package/tests/errors.test.js +619 -619
- package/tests/expression.test.js +1056 -1056
- package/tests/http.test.js +648 -648
- package/tests/reactive.test.js +819 -819
- package/tests/router.test.js +2327 -2327
- package/tests/ssr.test.js +870 -870
- package/tests/store.test.js +830 -830
- package/tests/test-minifier.js +153 -153
- package/tests/test-ssr.js +27 -27
- package/tests/utils.test.js +1377 -1377
- package/tests/webrtc/e2ee.test.js +283 -0
- package/tests/webrtc/ice.test.js +202 -0
- package/tests/webrtc/joinToken.test.js +89 -0
- package/tests/webrtc/observe.test.js +111 -0
- package/tests/webrtc/peer.test.js +373 -0
- package/tests/webrtc/reactive.test.js +235 -0
- package/tests/webrtc/room.test.js +406 -0
- package/tests/webrtc/sdp.test.js +151 -0
- package/tests/webrtc/sfu-livekit.test.js +119 -0
- package/tests/webrtc/sfu.test.js +160 -0
- package/tests/webrtc/signaling.test.js +251 -0
- package/tests/webrtc/turn.test.js +256 -0
- package/types/collection.d.ts +383 -383
- package/types/component.d.ts +186 -186
- package/types/errors.d.ts +135 -135
- package/types/http.d.ts +92 -92
- package/types/misc.d.ts +201 -201
- package/types/reactive.d.ts +98 -98
- package/types/router.d.ts +190 -190
- package/types/ssr.d.ts +102 -102
- package/types/store.d.ts +146 -146
- package/types/utils.d.ts +245 -245
- package/types/webrtc.d.ts +653 -0
package/tests/compare.test.js
CHANGED
|
@@ -1,486 +1,497 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compare page validation test suite.
|
|
3
|
-
*
|
|
4
|
-
* Validates the comparison data and code examples on the compare page
|
|
5
|
-
* against the actual framework implementation.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
it('
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
expect($.
|
|
105
|
-
expect($.
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('
|
|
109
|
-
expect($.
|
|
110
|
-
expect($.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
expect($.
|
|
122
|
-
expect($.
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
expect($.
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('
|
|
132
|
-
|
|
133
|
-
expect(
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
expect(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
expect(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
expect(
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it('
|
|
179
|
-
document.body.innerHTML = '<
|
|
180
|
-
const col =
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
document.body.innerHTML = '
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
inst.
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
})
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
expect(
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
expect(
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
expect(
|
|
340
|
-
expect(
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
expect(
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
expect(
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
expect(
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
expect(
|
|
371
|
-
expect(
|
|
372
|
-
expect(
|
|
373
|
-
expect(
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
expect(
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
expect(
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Compare page validation test suite.
|
|
3
|
+
*
|
|
4
|
+
* Validates the comparison data and code examples on the compare page
|
|
5
|
+
* against the actual framework implementation.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
9
|
+
import { existsSync } from 'node:fs';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
import { dirname, resolve } from 'node:path';
|
|
12
|
+
|
|
13
|
+
// Website sources are gitignored; on CI / fresh checkouts the compare page
|
|
14
|
+
// component isn't available — skip those specific tests gracefully.
|
|
15
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const COMPARE_FILE = resolve(__dirname, '../zquery-website/app/components/compare.js');
|
|
17
|
+
const COMPARE_AVAILABLE = existsSync(COMPARE_FILE);
|
|
18
|
+
|
|
19
|
+
// Framework imports
|
|
20
|
+
import {
|
|
21
|
+
signal, computed, effect, batch, untracked, reactive, Signal,
|
|
22
|
+
} from '../src/reactive.js';
|
|
23
|
+
import { component, mount, destroy, getInstance, getRegistry, style } from '../src/component.js';
|
|
24
|
+
import { createRouter, getRouter, matchRoute } from '../src/router.js';
|
|
25
|
+
import { createStore, getStore } from '../src/store.js';
|
|
26
|
+
import { http } from '../src/http.js';
|
|
27
|
+
import { morph, morphElement } from '../src/diff.js';
|
|
28
|
+
import { safeEval } from '../src/expression.js';
|
|
29
|
+
import {
|
|
30
|
+
debounce, throttle, pipe, once, sleep,
|
|
31
|
+
escapeHtml, stripHtml, html, trust, TrustedHTML, uuid,
|
|
32
|
+
deepClone, deepMerge, isEqual,
|
|
33
|
+
param, parseQuery,
|
|
34
|
+
storage, session, EventBus, bus,
|
|
35
|
+
range, unique, chunk, groupBy, pick, omit, getPath, setPath, isEmpty,
|
|
36
|
+
capitalize, truncate, clamp, memoize, retry, timeout,
|
|
37
|
+
camelCase, kebabCase,
|
|
38
|
+
} from '../src/utils.js';
|
|
39
|
+
import { ZQueryError, ErrorCode, onError, guardCallback, guardAsync, validate, formatError } from '../src/errors.js';
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
// ===========================================================================
|
|
43
|
+
// 1. COMPARE PAGE STRUCTURE
|
|
44
|
+
// ===========================================================================
|
|
45
|
+
describe('Compare page component structure', () => {
|
|
46
|
+
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
49
|
+
});
|
|
50
|
+
afterEach(() => vi.restoreAllMocks());
|
|
51
|
+
|
|
52
|
+
it.skipIf(!COMPARE_AVAILABLE)('compare-page component registers successfully', async () => {
|
|
53
|
+
// Importing compare.js registers the component via $.component
|
|
54
|
+
// We need $ to be available globally for comparisons
|
|
55
|
+
const mod = await import('../index.js');
|
|
56
|
+
const $ = mod.$;
|
|
57
|
+
// The compare page uses $.component which requires $ on the global scope
|
|
58
|
+
globalThis.$ = $;
|
|
59
|
+
globalThis.BUNDLE_SIZE = '~85.5 KB';
|
|
60
|
+
globalThis.BUNDLE_SIZE_NUM = 85.5;
|
|
61
|
+
|
|
62
|
+
// Import compare to register the component (dynamic path hides it from
|
|
63
|
+
// Vite's static import analysis, since the file may not exist on CI).
|
|
64
|
+
const comparePath = '../zquery-website/app/components/compare.js';
|
|
65
|
+
try {
|
|
66
|
+
await import(/* @vite-ignore */ comparePath);
|
|
67
|
+
} catch (e) {
|
|
68
|
+
// May fail due to store import; that's fine for structure tests
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
// ===========================================================================
|
|
75
|
+
// 2. FEATURE MATRIX CLAIMS — Verify each claimed capability exists
|
|
76
|
+
// ===========================================================================
|
|
77
|
+
describe('Compare page feature claims validation', () => {
|
|
78
|
+
|
|
79
|
+
let $;
|
|
80
|
+
beforeEach(async () => {
|
|
81
|
+
vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
82
|
+
const mod = await import('../index.js');
|
|
83
|
+
$ = mod.$;
|
|
84
|
+
});
|
|
85
|
+
afterEach(() => vi.restoreAllMocks());
|
|
86
|
+
|
|
87
|
+
describe('Overview panel claims', () => {
|
|
88
|
+
it('zQuery has zero dependencies', () => {
|
|
89
|
+
// Verified by package.json having no dependencies
|
|
90
|
+
// This is a data claim, verified structurally
|
|
91
|
+
expect(true).toBe(true);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('Component model exists', () => {
|
|
95
|
+
expect($.component).toBeTypeOf('function');
|
|
96
|
+
expect($.mount).toBeTypeOf('function');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('Scoped styles are supported', () => {
|
|
100
|
+
expect($.style).toBeTypeOf('function');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('Router is built-in', () => {
|
|
104
|
+
expect($.router).toBeTypeOf('function');
|
|
105
|
+
expect($.getRouter).toBeTypeOf('function');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('State management is built-in ($.store)', () => {
|
|
109
|
+
expect($.store).toBeTypeOf('function');
|
|
110
|
+
expect($.getStore).toBeTypeOf('function');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('Signals / fine-grained reactivity ($.signal)', () => {
|
|
114
|
+
expect($.signal).toBeTypeOf('function');
|
|
115
|
+
expect($.computed).toBeTypeOf('function');
|
|
116
|
+
expect($.effect).toBeTypeOf('function');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('HTTP client ($.http)', () => {
|
|
120
|
+
expect($.http).toBeDefined();
|
|
121
|
+
expect($.get).toBeTypeOf('function');
|
|
122
|
+
expect($.post).toBeTypeOf('function');
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('Two-way binding (z-model) is a component feature', () => {
|
|
126
|
+
// z-model is processed in the component system's template engine
|
|
127
|
+
// We verify the component system exists
|
|
128
|
+
expect($.component).toBeTypeOf('function');
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('DOM reconciliation uses real-DOM morph', () => {
|
|
132
|
+
expect($.morph).toBeTypeOf('function');
|
|
133
|
+
expect($.morphElement).toBeTypeOf('function');
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('Event bus is built-in ($.bus)', () => {
|
|
137
|
+
expect($.bus).toBeDefined();
|
|
138
|
+
expect($.bus.on).toBeTypeOf('function');
|
|
139
|
+
expect($.bus.emit).toBeTypeOf('function');
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('TypeScript types are bundled (d.ts)', () => {
|
|
143
|
+
// Verified by the existence of index.d.ts and types/ folder
|
|
144
|
+
expect(true).toBe(true);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
describe('Selector panel claims', () => {
|
|
149
|
+
it('$ returns ZQueryCollection with chaining', () => {
|
|
150
|
+
document.body.innerHTML = '<div class="test-el">hello</div>';
|
|
151
|
+
const col = $('div.test-el');
|
|
152
|
+
expect(col.length).toBeGreaterThanOrEqual(0);
|
|
153
|
+
// Should have chainable methods
|
|
154
|
+
expect(col.addClass).toBeTypeOf('function');
|
|
155
|
+
expect(col.css).toBeTypeOf('function');
|
|
156
|
+
expect(col.find).toBeTypeOf('function');
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('$.id returns raw Element', () => {
|
|
160
|
+
document.body.innerHTML = '<div id="compare-test">hi</div>';
|
|
161
|
+
const el = $.id('compare-test');
|
|
162
|
+
expect(el).toBeInstanceOf(Element);
|
|
163
|
+
expect(el.textContent).toBe('hi');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('$.class returns raw Element', () => {
|
|
167
|
+
document.body.innerHTML = '<div class="cmp-test">world</div>';
|
|
168
|
+
const el = $.class('cmp-test');
|
|
169
|
+
expect(el).toBeInstanceOf(Element);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('$.classes returns ZQueryCollection', () => {
|
|
173
|
+
document.body.innerHTML = '<div class="multi">a</div><div class="multi">b</div>';
|
|
174
|
+
const col = $.classes('multi');
|
|
175
|
+
expect(col.length).toBe(2);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('$.tag returns ZQueryCollection', () => {
|
|
179
|
+
document.body.innerHTML = '<span>a</span><span>b</span>';
|
|
180
|
+
const col = $.tag('span');
|
|
181
|
+
expect(col.length).toBeGreaterThanOrEqual(2);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('$.create creates DOM element', () => {
|
|
185
|
+
const btn = $.create('button', { class: 'primary', id: 'save' }, 'Save');
|
|
186
|
+
expect(btn).toBeDefined();
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('Collection has 90+ chainable methods', () => {
|
|
190
|
+
document.body.innerHTML = '<div></div>';
|
|
191
|
+
const col = $('div');
|
|
192
|
+
// Check a sampling of categories from the compare page table
|
|
193
|
+
const expectedMethods = [
|
|
194
|
+
// Traversal
|
|
195
|
+
'find', 'parent', 'parents', 'closest', 'children', 'siblings', 'next', 'prev',
|
|
196
|
+
// Filtering
|
|
197
|
+
'filter', 'not', 'has', 'is', 'first', 'last', 'eq', 'slice',
|
|
198
|
+
// Classes
|
|
199
|
+
'addClass', 'removeClass', 'toggleClass', 'hasClass',
|
|
200
|
+
// Attributes
|
|
201
|
+
'attr', 'removeAttr', 'prop', 'data',
|
|
202
|
+
// Content
|
|
203
|
+
'html', 'text', 'val',
|
|
204
|
+
// DOM Insert
|
|
205
|
+
'append', 'prepend', 'after', 'before',
|
|
206
|
+
// DOM Mutate
|
|
207
|
+
'wrap', 'unwrap', 'remove', 'empty', 'clone', 'replaceWith',
|
|
208
|
+
// CSS
|
|
209
|
+
'css', 'width', 'height', 'offset', 'position',
|
|
210
|
+
// Display
|
|
211
|
+
'show', 'hide', 'toggle',
|
|
212
|
+
// Events
|
|
213
|
+
'on', 'off', 'one', 'trigger',
|
|
214
|
+
// Animation
|
|
215
|
+
'animate', 'fadeIn', 'fadeOut', 'slideDown', 'slideUp',
|
|
216
|
+
// Forms
|
|
217
|
+
'serialize',
|
|
218
|
+
// Iteration
|
|
219
|
+
'each', 'map', 'toArray', 'get',
|
|
220
|
+
];
|
|
221
|
+
for (const method of expectedMethods) {
|
|
222
|
+
expect(col[method], `Missing method: ${method}`).toBeTypeOf('function');
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
describe('Component panel claims', () => {
|
|
228
|
+
beforeEach(() => {
|
|
229
|
+
document.body.innerHTML = '';
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it('component with state/render/methods works', () => {
|
|
233
|
+
component('cmp-counter-test', {
|
|
234
|
+
state: { count: 0 },
|
|
235
|
+
render() {
|
|
236
|
+
return `<p>${this.state.count}</p><button @click="inc">+</button>`;
|
|
237
|
+
},
|
|
238
|
+
inc() { this.state.count++; }
|
|
239
|
+
});
|
|
240
|
+
document.body.innerHTML = '<div id="cmp-ctr-root"></div>';
|
|
241
|
+
const inst = mount('#cmp-ctr-root', 'cmp-counter-test');
|
|
242
|
+
expect(inst).toBeDefined();
|
|
243
|
+
expect(inst.state.count).toBe(0);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('lifecycle hooks are recognized: init, mounted, updated, destroyed', () => {
|
|
247
|
+
const hooks = [];
|
|
248
|
+
component('cmp-lifecycle-test', {
|
|
249
|
+
state: { x: 0 },
|
|
250
|
+
init() { hooks.push('init'); },
|
|
251
|
+
mounted() { hooks.push('mounted'); },
|
|
252
|
+
destroyed() { hooks.push('destroyed'); },
|
|
253
|
+
render() { return '<p>test</p>'; }
|
|
254
|
+
});
|
|
255
|
+
document.body.innerHTML = '<div id="lc-root"></div>';
|
|
256
|
+
mount('#lc-root', 'cmp-lifecycle-test');
|
|
257
|
+
expect(hooks).toContain('init');
|
|
258
|
+
expect(hooks).toContain('mounted');
|
|
259
|
+
destroy('#lc-root');
|
|
260
|
+
expect(hooks).toContain('destroyed');
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it('scoped styles via styles property', () => {
|
|
264
|
+
component('cmp-scoped-test', {
|
|
265
|
+
styles: '.card { color: red; }',
|
|
266
|
+
render() { return '<div class="card">styled</div>'; }
|
|
267
|
+
});
|
|
268
|
+
document.body.innerHTML = '<div id="scoped-root"></div>';
|
|
269
|
+
const inst = mount('#scoped-root', 'cmp-scoped-test');
|
|
270
|
+
expect(inst).toBeDefined();
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it('this.emit dispatches custom events', () => {
|
|
274
|
+
component('cmp-emit-test', {
|
|
275
|
+
fire() { this.emit('custom-event', { value: 42 }); },
|
|
276
|
+
render() { return '<button @click="fire">go</button>'; }
|
|
277
|
+
});
|
|
278
|
+
document.body.innerHTML = '<div id="emit-root2"></div>';
|
|
279
|
+
const inst = mount('#emit-root2', 'cmp-emit-test');
|
|
280
|
+
let received = null;
|
|
281
|
+
document.querySelector('#emit-root2').addEventListener('custom-event', e => {
|
|
282
|
+
received = e.detail;
|
|
283
|
+
});
|
|
284
|
+
inst.fire();
|
|
285
|
+
expect(received).toEqual({ value: 42 });
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it('this.setState({}) triggers re-render', async () => {
|
|
289
|
+
component('cmp-ss-test', {
|
|
290
|
+
state: { v: 0 },
|
|
291
|
+
render() { return `<p>${this.state.v}</p>`; }
|
|
292
|
+
});
|
|
293
|
+
document.body.innerHTML = '<div id="ss-root2"></div>';
|
|
294
|
+
const inst = mount('#ss-root2', 'cmp-ss-test');
|
|
295
|
+
inst.setState({});
|
|
296
|
+
await sleep(50);
|
|
297
|
+
// Just verify it doesn't throw
|
|
298
|
+
expect(true).toBe(true);
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
describe('Reactivity panel claims', () => {
|
|
303
|
+
it('ES Proxy reactivity - mutations detected', () => {
|
|
304
|
+
const changes = [];
|
|
305
|
+
const data = reactive({ x: 0 }, (key, value) => changes.push({ key, value }));
|
|
306
|
+
data.x = 42;
|
|
307
|
+
expect(changes.length).toBe(1);
|
|
308
|
+
expect(changes[0].key).toBe('x');
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it('microtask-batched signal updates', () => {
|
|
312
|
+
const a = signal(1);
|
|
313
|
+
const b = signal(2);
|
|
314
|
+
const results = [];
|
|
315
|
+
effect(() => results.push(a.value + b.value));
|
|
316
|
+
expect(results).toEqual([3]);
|
|
317
|
+
batch(() => {
|
|
318
|
+
a.value = 10;
|
|
319
|
+
b.value = 20;
|
|
320
|
+
});
|
|
321
|
+
// Single result for both changes
|
|
322
|
+
expect(results[results.length - 1]).toBe(30);
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it('DOM morph engine exists (LIS-keyed reconciliation)', () => {
|
|
326
|
+
expect(morph).toBeTypeOf('function');
|
|
327
|
+
expect(morphElement).toBeTypeOf('function');
|
|
328
|
+
const root = document.createElement('div');
|
|
329
|
+
root.innerHTML = '<p>old</p>';
|
|
330
|
+
morph(root, '<p>new</p>');
|
|
331
|
+
expect(root.querySelector('p').textContent).toBe('new');
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
it('store with dispatch, subscribe, middleware, batch', () => {
|
|
335
|
+
const store = createStore('cmp-react-test', {
|
|
336
|
+
state: { count: 0 },
|
|
337
|
+
actions: { inc(s) { s.count++; } }
|
|
338
|
+
});
|
|
339
|
+
expect(store.dispatch).toBeTypeOf('function');
|
|
340
|
+
expect(store.subscribe).toBeTypeOf('function');
|
|
341
|
+
expect(store.use).toBeTypeOf('function');
|
|
342
|
+
expect(store.batch).toBeTypeOf('function');
|
|
343
|
+
store.dispatch('inc');
|
|
344
|
+
expect(store.state.count).toBe(1);
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it('event bus ($.bus) exists', () => {
|
|
348
|
+
expect(bus.on).toBeTypeOf('function');
|
|
349
|
+
expect(bus.emit).toBeTypeOf('function');
|
|
350
|
+
expect(bus.off).toBeTypeOf('function');
|
|
351
|
+
expect(bus.once).toBeTypeOf('function');
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
describe('Native & Size panel claims', () => {
|
|
356
|
+
it('CSP-safe expression evaluation (no eval/new Function)', () => {
|
|
357
|
+
// safeEval uses a recursive descent parser, not eval
|
|
358
|
+
expect(safeEval).toBeTypeOf('function');
|
|
359
|
+
const result = safeEval('1 + 2', [{}]);
|
|
360
|
+
expect(result).toBe(3);
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
it('native fetch for HTTP', () => {
|
|
364
|
+
// http uses native fetch internally
|
|
365
|
+
expect(http.get).toBeTypeOf('function');
|
|
366
|
+
expect(http.raw).toBeTypeOf('function');
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it('storage wrappers use native localStorage/sessionStorage', () => {
|
|
370
|
+
expect(storage.set).toBeTypeOf('function');
|
|
371
|
+
expect(storage.get).toBeTypeOf('function');
|
|
372
|
+
expect(session.set).toBeTypeOf('function');
|
|
373
|
+
expect(session.get).toBeTypeOf('function');
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
it('utility toolkit claims are real', () => {
|
|
377
|
+
expect(debounce).toBeTypeOf('function');
|
|
378
|
+
expect(throttle).toBeTypeOf('function');
|
|
379
|
+
expect(pipe).toBeTypeOf('function');
|
|
380
|
+
expect(once).toBeTypeOf('function');
|
|
381
|
+
expect(sleep).toBeTypeOf('function');
|
|
382
|
+
expect(deepClone).toBeTypeOf('function');
|
|
383
|
+
expect(deepMerge).toBeTypeOf('function');
|
|
384
|
+
expect(isEqual).toBeTypeOf('function');
|
|
385
|
+
expect(escapeHtml).toBeTypeOf('function');
|
|
386
|
+
expect(param).toBeTypeOf('function');
|
|
387
|
+
expect(parseQuery).toBeTypeOf('function');
|
|
388
|
+
expect(uuid).toBeTypeOf('function');
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
// ===========================================================================
|
|
395
|
+
// 3. CODE EXAMPLE VALIDATION — Test examples from compare page
|
|
396
|
+
// ===========================================================================
|
|
397
|
+
describe('Compare page code examples', () => {
|
|
398
|
+
|
|
399
|
+
beforeEach(() => {
|
|
400
|
+
vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
401
|
+
document.body.innerHTML = '';
|
|
402
|
+
});
|
|
403
|
+
afterEach(() => vi.restoreAllMocks());
|
|
404
|
+
|
|
405
|
+
it('counter component example', () => {
|
|
406
|
+
component('cmp-ex-counter', {
|
|
407
|
+
state: { count: 0 },
|
|
408
|
+
render() {
|
|
409
|
+
return `<p>${this.state.count}</p><button @click="inc">+</button>`;
|
|
410
|
+
},
|
|
411
|
+
inc() { this.state.count++; }
|
|
412
|
+
});
|
|
413
|
+
document.body.innerHTML = '<div id="ex-ctr"></div>';
|
|
414
|
+
const inst = mount('#ex-ctr', 'cmp-ex-counter');
|
|
415
|
+
inst.inc();
|
|
416
|
+
expect(inst.state.count).toBe(1);
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
it('signal example from reactivity panel', () => {
|
|
420
|
+
const count = signal(0);
|
|
421
|
+
const doubled = computed(() => count.value * 2);
|
|
422
|
+
|
|
423
|
+
expect(doubled.value).toBe(0);
|
|
424
|
+
count.value = 5;
|
|
425
|
+
expect(doubled.value).toBe(10);
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
it('store example from reactivity panel', () => {
|
|
429
|
+
const store = createStore('cmp-ex-store', {
|
|
430
|
+
state: { count: 0 },
|
|
431
|
+
actions: {
|
|
432
|
+
increment(state) { state.count++; },
|
|
433
|
+
},
|
|
434
|
+
getters: {
|
|
435
|
+
doubleCount: (state) => state.count * 2,
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
store.dispatch('increment');
|
|
439
|
+
expect(store.state.count).toBe(1);
|
|
440
|
+
expect(store.getters.doubleCount).toBe(2);
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
it('$.id and $.class examples from selectors panel', () => {
|
|
444
|
+
document.body.innerHTML = `
|
|
445
|
+
<div id="sidebar" class="sidebar">Sidebar</div>
|
|
446
|
+
<div id="cart-count">0</div>
|
|
447
|
+
<img class="avatar" src="" alt="">
|
|
448
|
+
`;
|
|
449
|
+
|
|
450
|
+
let $ = {};
|
|
451
|
+
import('../index.js').then(m => $ = m.$);
|
|
452
|
+
|
|
453
|
+
// These are raw Element operations as documented
|
|
454
|
+
const sidebar = document.getElementById('sidebar');
|
|
455
|
+
expect(sidebar).not.toBeNull();
|
|
456
|
+
sidebar.classList.toggle('collapsed');
|
|
457
|
+
expect(sidebar.classList.contains('collapsed')).toBe(true);
|
|
458
|
+
|
|
459
|
+
const cartCount = document.getElementById('cart-count');
|
|
460
|
+
cartCount.textContent = '3';
|
|
461
|
+
expect(cartCount.textContent).toBe('3');
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
it('morph/DOM diffing example from selectors panel', () => {
|
|
465
|
+
const root = document.createElement('div');
|
|
466
|
+
root.innerHTML = '<p>old content</p>';
|
|
467
|
+
morph(root, '<p>new content</p>');
|
|
468
|
+
expect(root.querySelector('p').textContent).toBe('new content');
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
it('debounce from utility toolkit example', () => {
|
|
472
|
+
const fn = debounce((x) => x, 300);
|
|
473
|
+
expect(fn).toBeTypeOf('function');
|
|
474
|
+
expect(fn.cancel).toBeTypeOf('function');
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
it('storage example from utility toolkit', () => {
|
|
478
|
+
storage.set('key', { nested: true });
|
|
479
|
+
const val = storage.get('key');
|
|
480
|
+
expect(val).toEqual({ nested: true });
|
|
481
|
+
storage.remove('key');
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
it('$.param and $.parseQuery from utility toolkit', () => {
|
|
485
|
+
const qs = param({ a: 1, b: 2 });
|
|
486
|
+
expect(qs).toContain('a=1');
|
|
487
|
+
expect(qs).toContain('b=2');
|
|
488
|
+
|
|
489
|
+
const parsed = parseQuery('a=1');
|
|
490
|
+
expect(parsed.a).toBe('1');
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
it('escapeHtml example from utility toolkit', () => {
|
|
494
|
+
const result = escapeHtml('<script>');
|
|
495
|
+
expect(result).toBe('<script>');
|
|
496
|
+
});
|
|
497
|
+
});
|