ripple 0.3.84 → 0.3.86

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 (59) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/package.json +3 -3
  3. package/src/constants.js +4 -0
  4. package/src/runtime/internal/client/blocks.js +53 -0
  5. package/src/runtime/internal/client/component.js +3 -3
  6. package/src/runtime/internal/client/constants.js +4 -0
  7. package/src/runtime/internal/client/for.js +87 -14
  8. package/src/runtime/internal/client/if.js +18 -2
  9. package/src/runtime/internal/client/index.js +1 -0
  10. package/src/runtime/internal/client/operations.js +25 -0
  11. package/src/runtime/internal/client/runtime.js +62 -10
  12. package/src/runtime/internal/client/switch.js +33 -5
  13. package/src/runtime/internal/client/template.js +10 -2
  14. package/src/runtime/internal/client/try.js +12 -2
  15. package/src/runtime/internal/client/types.d.ts +4 -0
  16. package/tests/client/__snapshots__/for.test.tsrx.snap +0 -2
  17. package/tests/client/compiler/compiler.basic.test.tsrx +5 -2
  18. package/tests/client/composite/__snapshots__/composite.render.test.tsrx.snap +0 -4
  19. package/tests/client/for-single-root-items.test.tsrx +130 -0
  20. package/tests/client/scoped-flush.test.tsrx +105 -0
  21. package/tests/hydration/compiled/client/basic.js +198 -214
  22. package/tests/hydration/compiled/client/composite.js +23 -72
  23. package/tests/hydration/compiled/client/for.js +66 -72
  24. package/tests/hydration/compiled/client/hmr.js +2 -13
  25. package/tests/hydration/compiled/client/html.js +619 -479
  26. package/tests/hydration/compiled/client/if-children.js +72 -84
  27. package/tests/hydration/compiled/client/if-fragment-controlflow.js +463 -0
  28. package/tests/hydration/compiled/client/if.js +87 -92
  29. package/tests/hydration/compiled/client/mixed-control-flow.js +120 -160
  30. package/tests/hydration/compiled/client/nested-control-flow.js +288 -360
  31. package/tests/hydration/compiled/client/portal.js +15 -21
  32. package/tests/hydration/compiled/client/reactivity.js +7 -12
  33. package/tests/hydration/compiled/client/switch.js +113 -115
  34. package/tests/hydration/compiled/client/track-async-serialization.js +71 -122
  35. package/tests/hydration/compiled/client/try.js +26 -41
  36. package/tests/hydration/compiled/server/basic.js +295 -556
  37. package/tests/hydration/compiled/server/composite.js +31 -50
  38. package/tests/hydration/compiled/server/events.js +37 -173
  39. package/tests/hydration/compiled/server/for.js +236 -847
  40. package/tests/hydration/compiled/server/head.js +110 -241
  41. package/tests/hydration/compiled/server/hmr.js +14 -41
  42. package/tests/hydration/compiled/server/html-in-template.js +14 -38
  43. package/tests/hydration/compiled/server/html.js +951 -1176
  44. package/tests/hydration/compiled/server/if-children.js +59 -493
  45. package/tests/hydration/compiled/server/if-fragment-controlflow.js +227 -0
  46. package/tests/hydration/compiled/server/if.js +57 -209
  47. package/tests/hydration/compiled/server/mixed-control-flow.js +144 -250
  48. package/tests/hydration/compiled/server/nested-control-flow.js +309 -559
  49. package/tests/hydration/compiled/server/portal.js +94 -156
  50. package/tests/hydration/compiled/server/reactivity.js +23 -65
  51. package/tests/hydration/compiled/server/return.js +6 -16
  52. package/tests/hydration/compiled/server/switch.js +91 -219
  53. package/tests/hydration/compiled/server/track-async-serialization.js +211 -256
  54. package/tests/hydration/compiled/server/try.js +67 -126
  55. package/tests/hydration/components/html.tsrx +75 -0
  56. package/tests/hydration/components/if-fragment-controlflow.tsrx +145 -0
  57. package/tests/hydration/html.test.js +50 -0
  58. package/tests/hydration/if-fragment-controlflow.test.js +95 -0
  59. package/tests/server/compiler.test.tsrx +6 -2
@@ -8,39 +8,24 @@ export function IfWithChildren({ children }) {
8
8
  let lazy = _$_.track(true, 'c64714b1');
9
9
 
10
10
  _$_.regular_block(() => {
11
- _$_.output_push('<div');
12
- _$_.output_push(' class="container"');
13
- _$_.output_push('>');
11
+ let __out = '';
14
12
 
15
- {
16
- _$_.output_push('<div');
17
- _$_.output_push(' role="button"');
18
- _$_.output_push(' class="header"');
19
- _$_.output_push('>');
20
-
21
- {
22
- _$_.output_push('Toggle');
23
- }
24
-
25
- _$_.output_push('</div>');
26
- _$_.output_push('<!--[-->');
27
-
28
- if (lazy.value) {
29
- _$_.output_push('<div');
30
- _$_.output_push(' class="content"');
31
- _$_.output_push('>');
13
+ __out += '<div class="container"><div role="button" class="header">Toggle</div><!--[-->';
32
14
 
33
- {
34
- _$_.render_expression(children);
35
- }
15
+ if (lazy.value) {
16
+ __out += '<div class="content">';
36
17
 
37
- _$_.output_push('</div>');
18
+ {
19
+ _$_.output_push(__out);
20
+ __out = '';
21
+ _$_.render_expression(children);
38
22
  }
39
23
 
40
- _$_.output_push('<!--]-->');
24
+ __out += '</div>';
41
25
  }
42
26
 
43
- _$_.output_push('</div>');
27
+ __out += '<!--]--></div>';
28
+ _$_.output_push(__out);
44
29
  });
45
30
  });
46
31
  }
@@ -48,15 +33,10 @@ export function IfWithChildren({ children }) {
48
33
  export function ChildItem({ text: label }) {
49
34
  return _$_.tsrx_element(() => {
50
35
  _$_.regular_block(() => {
51
- _$_.output_push('<div');
52
- _$_.output_push(' class="item"');
53
- _$_.output_push('>');
54
-
55
- {
56
- _$_.output_push(_$_.escape(label));
57
- }
36
+ let __out = '';
58
37
 
59
- _$_.output_push('</div>');
38
+ __out += '<div class="item">' + _$_.escape(label) + '</div>';
39
+ _$_.output_push(__out);
60
40
  });
61
41
  });
62
42
  }
@@ -100,54 +80,16 @@ export function IfWithStaticChildren() {
100
80
  let lazy_1 = _$_.track(true, '3bba8f77');
101
81
 
102
82
  _$_.regular_block(() => {
103
- _$_.output_push('<div');
104
- _$_.output_push(' class="container"');
105
- _$_.output_push('>');
106
-
107
- {
108
- _$_.output_push('<div');
109
- _$_.output_push(' role="button"');
110
- _$_.output_push(' class="header"');
111
- _$_.output_push('>');
112
-
113
- {
114
- _$_.output_push('Toggle');
115
- }
116
-
117
- _$_.output_push('</div>');
118
- _$_.output_push('<!--[-->');
119
-
120
- if (lazy_1.value) {
121
- _$_.output_push('<div');
122
- _$_.output_push(' class="content"');
123
- _$_.output_push('>');
124
-
125
- {
126
- _$_.output_push('<span');
127
- _$_.output_push('>');
128
-
129
- {
130
- _$_.output_push('Static child 1');
131
- }
132
-
133
- _$_.output_push('</span>');
134
- _$_.output_push('<span');
135
- _$_.output_push('>');
83
+ let __out = '';
136
84
 
137
- {
138
- _$_.output_push('Static child 2');
139
- }
85
+ __out += '<div class="container"><div role="button" class="header">Toggle</div><!--[-->';
140
86
 
141
- _$_.output_push('</span>');
142
- }
143
-
144
- _$_.output_push('</div>');
145
- }
146
-
147
- _$_.output_push('<!--]-->');
87
+ if (lazy_1.value) {
88
+ __out += '<div class="content"><span>Static child 1</span><span>Static child 2</span></div>';
148
89
  }
149
90
 
150
- _$_.output_push('</div>');
91
+ __out += '<!--]--></div>';
92
+ _$_.output_push(__out);
151
93
  });
152
94
  });
153
95
  }
@@ -157,74 +99,24 @@ export function IfWithSiblingsAndChildren({ children }) {
157
99
  let lazy_2 = _$_.track(true, 'a1b8fb4c');
158
100
 
159
101
  _$_.regular_block(() => {
160
- _$_.output_push('<section');
161
- _$_.output_push(' class="group"');
162
- _$_.output_push('>');
163
-
164
- {
165
- _$_.output_push('<div');
166
- _$_.output_push(' role="button"');
167
- _$_.output_push(' class="item"');
168
- _$_.output_push('>');
102
+ let __out = '';
169
103
 
170
- {
171
- _$_.output_push('<div');
172
- _$_.output_push(' class="indicator"');
173
- _$_.output_push('>');
174
- _$_.output_push('</div>');
175
- _$_.output_push('<h2');
176
- _$_.output_push(' class="text"');
177
- _$_.output_push('>');
178
-
179
- {
180
- _$_.output_push('Title');
181
- }
104
+ __out += '<section class="group"><div role="button" class="item"><div class="indicator"></div><h2 class="text">Title</h2><div class="caret"><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"></path></svg></div></div><!--[-->';
182
105
 
183
- _$_.output_push('</h2>');
184
- _$_.output_push('<div');
185
- _$_.output_push(' class="caret"');
186
- _$_.output_push('>');
106
+ if (lazy_2.value) {
107
+ __out += '<div class="items">';
187
108
 
188
- {
189
- _$_.output_push('<svg');
190
- _$_.output_push(' xmlns="http://www.w3.org/2000/svg"');
191
- _$_.output_push(' width="18"');
192
- _$_.output_push(' height="18"');
193
- _$_.output_push(' viewBox="0 0 24 24"');
194
- _$_.output_push('>');
195
-
196
- {
197
- _$_.output_push('<path');
198
- _$_.output_push(' d="m9 18 6-6-6-6"');
199
- _$_.output_push('>');
200
- _$_.output_push('</path>');
201
- }
202
-
203
- _$_.output_push('</svg>');
204
- }
205
-
206
- _$_.output_push('</div>');
207
- }
208
-
209
- _$_.output_push('</div>');
210
- _$_.output_push('<!--[-->');
211
-
212
- if (lazy_2.value) {
213
- _$_.output_push('<div');
214
- _$_.output_push(' class="items"');
215
- _$_.output_push('>');
216
-
217
- {
218
- _$_.render_expression(children);
219
- }
220
-
221
- _$_.output_push('</div>');
109
+ {
110
+ _$_.output_push(__out);
111
+ __out = '';
112
+ _$_.render_expression(children);
222
113
  }
223
114
 
224
- _$_.output_push('<!--]-->');
115
+ __out += '</div>';
225
116
  }
226
117
 
227
- _$_.output_push('</section>');
118
+ __out += '<!--]--></section>';
119
+ _$_.output_push(__out);
228
120
  });
229
121
  });
230
122
  }
@@ -268,65 +160,16 @@ export function ElementWithChildrenThenIf() {
268
160
  let lazy_3 = _$_.track(true, '7cd4817b');
269
161
 
270
162
  _$_.regular_block(() => {
271
- {
272
- _$_.output_push('<div');
273
- _$_.output_push(' class="wrapper"');
274
- _$_.output_push('>');
163
+ let __out = '';
275
164
 
276
- {
277
- _$_.output_push('<div');
278
- _$_.output_push(' class="nested-parent"');
279
- _$_.output_push('>');
165
+ __out += '<div class="wrapper"><div class="nested-parent"><div class="nested-child"><span class="deep">Deep content</span></div></div><!--[-->';
280
166
 
281
- {
282
- _$_.output_push('<div');
283
- _$_.output_push(' class="nested-child"');
284
- _$_.output_push('>');
285
-
286
- {
287
- _$_.output_push('<span');
288
- _$_.output_push(' class="deep"');
289
- _$_.output_push('>');
290
-
291
- {
292
- _$_.output_push('Deep content');
293
- }
294
-
295
- _$_.output_push('</span>');
296
- }
297
-
298
- _$_.output_push('</div>');
299
- }
300
-
301
- _$_.output_push('</div>');
302
- _$_.output_push('<!--[-->');
303
-
304
- if (lazy_3.value) {
305
- _$_.output_push('<div');
306
- _$_.output_push(' class="conditional"');
307
- _$_.output_push('>');
308
-
309
- {
310
- _$_.output_push('Conditional content');
311
- }
312
-
313
- _$_.output_push('</div>');
314
- }
315
-
316
- _$_.output_push('<!--]-->');
317
- }
318
-
319
- _$_.output_push('</div>');
320
- _$_.output_push('<button');
321
- _$_.output_push(' class="toggle"');
322
- _$_.output_push('>');
323
-
324
- {
325
- _$_.output_push('Toggle');
326
- }
327
-
328
- _$_.output_push('</button>');
167
+ if (lazy_3.value) {
168
+ __out += '<div class="conditional">Conditional content</div>';
329
169
  }
170
+
171
+ __out += '<!--]--></div><button class="toggle">Toggle</button>';
172
+ _$_.output_push(__out);
330
173
  });
331
174
  });
332
175
  }
@@ -336,80 +179,16 @@ export function DeepNestingThenIf() {
336
179
  let lazy_4 = _$_.track(true, '923116be');
337
180
 
338
181
  _$_.regular_block(() => {
339
- {
340
- _$_.output_push('<section');
341
- _$_.output_push(' class="outer"');
342
- _$_.output_push('>');
182
+ let __out = '';
343
183
 
344
- {
345
- _$_.output_push('<article');
346
- _$_.output_push(' class="middle"');
347
- _$_.output_push('>');
348
-
349
- {
350
- _$_.output_push('<div');
351
- _$_.output_push(' class="inner"');
352
- _$_.output_push('>');
184
+ __out += '<section class="outer"><article class="middle"><div class="inner"><p class="leaf"><strong>Bold</strong><em>Italic</em></p></div></article><!--[-->';
353
185
 
354
- {
355
- _$_.output_push('<p');
356
- _$_.output_push(' class="leaf"');
357
- _$_.output_push('>');
358
-
359
- {
360
- _$_.output_push('<strong');
361
- _$_.output_push('>');
362
-
363
- {
364
- _$_.output_push('Bold');
365
- }
366
-
367
- _$_.output_push('</strong>');
368
- _$_.output_push('<em');
369
- _$_.output_push('>');
370
-
371
- {
372
- _$_.output_push('Italic');
373
- }
374
-
375
- _$_.output_push('</em>');
376
- }
377
-
378
- _$_.output_push('</p>');
379
- }
380
-
381
- _$_.output_push('</div>');
382
- }
383
-
384
- _$_.output_push('</article>');
385
- _$_.output_push('<!--[-->');
386
-
387
- if (lazy_4.value) {
388
- _$_.output_push('<footer');
389
- _$_.output_push(' class="footer"');
390
- _$_.output_push('>');
391
-
392
- {
393
- _$_.output_push('Footer');
394
- }
395
-
396
- _$_.output_push('</footer>');
397
- }
398
-
399
- _$_.output_push('<!--]-->');
400
- }
401
-
402
- _$_.output_push('</section>');
403
- _$_.output_push('<button');
404
- _$_.output_push(' class="btn"');
405
- _$_.output_push('>');
406
-
407
- {
408
- _$_.output_push('Toggle');
409
- }
410
-
411
- _$_.output_push('</button>');
186
+ if (lazy_4.value) {
187
+ __out += '<footer class="footer">Footer</footer>';
412
188
  }
189
+
190
+ __out += '<!--]--></section><button class="btn">Toggle</button>';
191
+ _$_.output_push(__out);
413
192
  });
414
193
  });
415
194
  }
@@ -419,75 +198,18 @@ export function DomElementChildrenThenSibling() {
419
198
  let lazy_5 = _$_.track('code', '33a1e97f');
420
199
 
421
200
  _$_.regular_block(() => {
422
- _$_.output_push('<div');
423
- _$_.output_push(' class="tabs"');
424
- _$_.output_push('>');
425
-
426
- {
427
- _$_.output_push('<div');
428
- _$_.output_push(' class="tab-list"');
429
- _$_.output_push('>');
430
-
431
- {
432
- _$_.output_push('<button');
433
- _$_.output_push(_$_.attr('aria-selected', lazy_5.value === 'code' ? 'true' : 'false', false));
434
- _$_.output_push(' class="tab"');
435
- _$_.output_push('>');
436
-
437
- {
438
- _$_.output_push('Code');
439
- }
201
+ let __out = '';
440
202
 
441
- _$_.output_push('</button>');
442
- _$_.output_push('<button');
443
- _$_.output_push(_$_.attr('aria-selected', lazy_5.value === 'preview' ? 'true' : 'false', false));
444
- _$_.output_push(' class="tab"');
445
- _$_.output_push('>');
203
+ __out += '<div class="tabs"><div class="tab-list"><button' + _$_.attr('aria-selected', lazy_5.value === 'code' ? 'true' : 'false', false) + ' class="tab">Code</button><button' + _$_.attr('aria-selected', lazy_5.value === 'preview' ? 'true' : 'false', false) + ' class="tab">Preview</button></div><div class="panel"><!--[-->';
446
204
 
447
- {
448
- _$_.output_push('Preview');
449
- }
450
-
451
- _$_.output_push('</button>');
452
- }
453
-
454
- _$_.output_push('</div>');
455
- _$_.output_push('<div');
456
- _$_.output_push(' class="panel"');
457
- _$_.output_push('>');
458
-
459
- {
460
- _$_.output_push('<!--[-->');
461
-
462
- if (lazy_5.value === 'code') {
463
- _$_.output_push('<pre');
464
- _$_.output_push(' class="code"');
465
- _$_.output_push('>');
466
-
467
- {
468
- _$_.output_push('const x = 1;');
469
- }
470
-
471
- _$_.output_push('</pre>');
472
- } else {
473
- _$_.output_push('<div');
474
- _$_.output_push(' class="preview"');
475
- _$_.output_push('>');
476
-
477
- {
478
- _$_.output_push('Preview content');
479
- }
480
-
481
- _$_.output_push('</div>');
482
- }
483
-
484
- _$_.output_push('<!--]-->');
485
- }
486
-
487
- _$_.output_push('</div>');
205
+ if (lazy_5.value === 'code') {
206
+ __out += '<pre class="code">const x = 1;</pre>';
207
+ } else {
208
+ __out += '<div class="preview">Preview content</div>';
488
209
  }
489
210
 
490
- _$_.output_push('</div>');
211
+ __out += '<!--]--></div></div>';
212
+ _$_.output_push(__out);
491
213
  });
492
214
  });
493
215
  }
@@ -497,69 +219,10 @@ export function DomChildrenThenStaticSiblings() {
497
219
  let lazy_6 = _$_.track(0, '0ea64305');
498
220
 
499
221
  _$_.regular_block(() => {
500
- {
501
- _$_.output_push('<div');
502
- _$_.output_push(' class="container"');
503
- _$_.output_push('>');
504
-
505
- {
506
- _$_.output_push('<ul');
507
- _$_.output_push(' class="list"');
508
- _$_.output_push('>');
509
-
510
- {
511
- _$_.output_push('<li');
512
- _$_.output_push(' class="item"');
513
- _$_.output_push('>');
514
-
515
- {
516
- _$_.output_push(_$_.escape('Item count: ' + String(lazy_6.value ?? '')));
517
- }
518
-
519
- _$_.output_push('</li>');
520
- _$_.output_push('<li');
521
- _$_.output_push(' class="item"');
522
- _$_.output_push('>');
523
-
524
- {
525
- _$_.output_push('Another item');
526
- }
527
-
528
- _$_.output_push('</li>');
529
- }
530
-
531
- _$_.output_push('</ul>');
532
- _$_.output_push('<h2');
533
- _$_.output_push(' class="heading"');
534
- _$_.output_push('>');
535
-
536
- {
537
- _$_.output_push('Static Heading');
538
- }
539
-
540
- _$_.output_push('</h2>');
541
- _$_.output_push('<p');
542
- _$_.output_push(' class="para"');
543
- _$_.output_push('>');
544
-
545
- {
546
- _$_.output_push('Static paragraph');
547
- }
548
-
549
- _$_.output_push('</p>');
550
- }
551
-
552
- _$_.output_push('</div>');
553
- _$_.output_push('<button');
554
- _$_.output_push(' class="inc"');
555
- _$_.output_push('>');
556
-
557
- {
558
- _$_.output_push('Increment');
559
- }
222
+ let __out = '';
560
223
 
561
- _$_.output_push('</button>');
562
- }
224
+ __out += '<div class="container"><ul class="list"><li class="item">' + _$_.escape('Item count: ' + String(lazy_6.value ?? '')) + '</li><li class="item">Another item</li></ul><h2 class="heading">Static Heading</h2><p class="para">Static paragraph</p></div><button class="inc">Increment</button>';
225
+ _$_.output_push(__out);
563
226
  });
564
227
  });
565
228
  }
@@ -567,107 +230,10 @@ export function DomChildrenThenStaticSiblings() {
567
230
  export function StaticListThenStaticSiblings() {
568
231
  return _$_.tsrx_element(() => {
569
232
  _$_.regular_block(() => {
570
- _$_.output_push('<div');
571
- _$_.output_push(' class="wrapper"');
572
- _$_.output_push('>');
573
-
574
- {
575
- _$_.output_push('<ul');
576
- _$_.output_push(' class="features"');
577
- _$_.output_push('>');
578
-
579
- {
580
- _$_.output_push('<li');
581
- _$_.output_push('>');
582
-
583
- {
584
- _$_.output_push('<strong');
585
- _$_.output_push('>');
586
-
587
- {
588
- _$_.output_push('Feature One');
589
- }
590
-
591
- _$_.output_push('</strong>');
592
- _$_.output_push(': Description of feature one with ');
593
- _$_.output_push('<code');
594
- _$_.output_push('>');
595
-
596
- {
597
- _$_.output_push('code');
598
- }
599
-
600
- _$_.output_push('</code>');
601
- _$_.output_push(' reference');
602
- }
603
-
604
- _$_.output_push('</li>');
605
- _$_.output_push('<li');
606
- _$_.output_push('>');
607
-
608
- {
609
- _$_.output_push('<strong');
610
- _$_.output_push('>');
611
-
612
- {
613
- _$_.output_push('Feature Two');
614
- }
615
-
616
- _$_.output_push('</strong>');
617
- _$_.output_push(': Another feature description');
618
- }
619
-
620
- _$_.output_push('</li>');
621
- _$_.output_push('<li');
622
- _$_.output_push('>');
623
-
624
- {
625
- _$_.output_push('<strong');
626
- _$_.output_push('>');
627
-
628
- {
629
- _$_.output_push('Feature Three');
630
- }
631
-
632
- _$_.output_push('</strong>');
633
- _$_.output_push(': Third feature');
634
- }
635
-
636
- _$_.output_push('</li>');
637
- }
638
-
639
- _$_.output_push('</ul>');
640
- _$_.output_push('<h2');
641
- _$_.output_push(' class="section-heading"');
642
- _$_.output_push('>');
643
-
644
- {
645
- _$_.output_push('Section Heading');
646
- }
647
-
648
- _$_.output_push('</h2>');
649
- _$_.output_push('<p');
650
- _$_.output_push(' class="section-content"');
651
- _$_.output_push('>');
652
-
653
- {
654
- _$_.output_push('Static paragraph with ');
655
- _$_.output_push('<a');
656
- _$_.output_push(' href="/link"');
657
- _$_.output_push('>');
658
-
659
- {
660
- _$_.output_push('a link');
661
- }
662
-
663
- _$_.output_push('</a>');
664
- _$_.output_push(' and more text.');
665
- }
666
-
667
- _$_.output_push('</p>');
668
- }
233
+ let __out = '';
669
234
 
670
- _$_.output_push('</div>');
235
+ __out += '<div class="wrapper"><ul class="features"><li><strong>Feature One</strong>: Description of feature one with <code>code</code> reference</li><li><strong>Feature Two</strong>: Another feature description</li><li><strong>Feature Three</strong>: Third feature</li></ul><h2 class="section-heading">Section Heading</h2><p class="section-content">Static paragraph with <a href="/link">a link</a> and more text.</p></div>';
236
+ _$_.output_push(__out);
671
237
  });
672
238
  });
673
239
  }