ripple 0.2.211 → 0.2.213

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