ripple 0.2.213 → 0.2.214

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # ripple
2
2
 
3
+ ## 0.2.214
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - ripple@0.2.214
9
+
3
10
  ## 0.2.213
4
11
 
5
12
  ### Patch Changes
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ripple is an elegant TypeScript UI framework",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.2.213",
6
+ "version": "0.2.214",
7
7
  "type": "module",
8
8
  "module": "src/runtime/index-client.js",
9
9
  "main": "src/runtime/index-client.js",
@@ -15,7 +15,7 @@
15
15
  "bugs": {
16
16
  "url": "https://github.com/Ripple-TS/ripple/issues"
17
17
  },
18
- "homepage": "https://ripplejs.com",
18
+ "homepage": "https://ripple-ts.com",
19
19
  "keywords": [
20
20
  "ripple",
21
21
  "UI",
@@ -96,6 +96,6 @@
96
96
  "vscode-languageserver-types": "^3.17.5"
97
97
  },
98
98
  "peerDependencies": {
99
- "ripple": "0.2.213"
99
+ "ripple": "0.2.214"
100
100
  }
101
101
  }
@@ -3129,7 +3129,11 @@ function transform_children(children, context) {
3129
3129
  (node.id.type !== 'Identifier' || !is_element_dom_element(node))),
3130
3130
  ) ||
3131
3131
  normalized.filter(
3132
- (node) => node.type !== 'VariableDeclaration' && node.type !== 'EmptyStatement',
3132
+ (node) =>
3133
+ node.type !== 'VariableDeclaration' &&
3134
+ node.type !== 'EmptyStatement' &&
3135
+ node.type !== 'BreakStatement' &&
3136
+ node.type !== 'ContinueStatement',
3133
3137
  ).length > 1;
3134
3138
  /** @type {AST.Identifier | null} */
3135
3139
  let initial = null;
@@ -0,0 +1 @@
1
+ // TODO
@@ -20,7 +20,7 @@ export function html(node, get_html, svg = false, mathml = false) {
20
20
 
21
21
  render(() => {
22
22
  var block = /** @type {Block} */ (active_block);
23
- var new_html = get_html() + '';
23
+ var new_html = (get_html() ?? '') + '';
24
24
 
25
25
  // If the HTML hasn't changed, skip the update (but still hydrate on first run)
26
26
  if (html === new_html) {
@@ -63,11 +63,11 @@ export function create_fragment_from_html(
63
63
  export function template(content, flags) {
64
64
  var is_fragment = (flags & TEMPLATE_FRAGMENT) !== 0;
65
65
  var use_import_node = (flags & TEMPLATE_USE_IMPORT_NODE) !== 0;
66
- var use_svg_namespace = (flags & TEMPLATE_SVG_NAMESPACE) !== 0;
67
- var use_mathml_namespace = (flags & TEMPLATE_MATHML_NAMESPACE) !== 0;
66
+ var is_comment = content === '<!>';
67
+ var use_svg_namespace = !is_comment && (flags & TEMPLATE_SVG_NAMESPACE) !== 0;
68
+ var use_mathml_namespace = !is_comment && (flags & TEMPLATE_MATHML_NAMESPACE) !== 0;
68
69
  /** @type {Node | DocumentFragment | undefined} */
69
70
  var node;
70
- var is_comment = content === '<!>';
71
71
  var has_start = !is_comment && !content.startsWith('<!>');
72
72
 
73
73
  // For fragments, eagerly create the node so we can walk its children
@@ -147,8 +147,8 @@ export function template(content, flags) {
147
147
  return /** @type {Node} */ (hydrate_node);
148
148
  }
149
149
  // If using runtime namespace, check active_namespace
150
- var svg = !is_comment && (use_svg_namespace || active_namespace === 'svg');
151
- var mathml = !is_comment && (use_mathml_namespace || active_namespace === 'mathml');
150
+ var svg = use_svg_namespace || (!is_comment && active_namespace === 'svg');
151
+ var mathml = use_mathml_namespace || (!is_comment && active_namespace === 'mathml');
152
152
 
153
153
  if (node === undefined || use_svg_namespace !== svg || use_mathml_namespace !== mathml) {
154
154
  node = create_fragment_from_html(has_start ? content : '<!>' + content, svg, mathml);
@@ -438,4 +438,48 @@ describe('SVG namespace handling', () => {
438
438
  expect(path.tagName.toLowerCase()).toBe('path');
439
439
  });
440
440
  });
441
+
442
+ it('should render dynamic SVG elements dispatched via a switch inside a for loop', () => {
443
+ component App() {
444
+ const iconNodes: [string, Record<string, string>][] = [
445
+ ['path', { d: 'm14 12 4 4 4-4' }],
446
+ ['circle', { cx: '12', cy: '12', r: '4' }],
447
+ ['path', { d: 'M18 16V7' }],
448
+ ];
449
+
450
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24">
451
+ for (const [tag, attrs] of iconNodes) {
452
+ switch (tag) {
453
+ case 'path':
454
+ <path {...attrs} />
455
+ break;
456
+ case 'circle':
457
+ <circle {...attrs} />
458
+ break;
459
+ }
460
+ }
461
+ </svg>
462
+ }
463
+
464
+ render(App);
465
+
466
+ const svg = container.querySelector('svg');
467
+ expect(svg).toBeTruthy();
468
+ expect(svg.namespaceURI).toBe('http://www.w3.org/2000/svg');
469
+
470
+ const paths = svg.querySelectorAll('path');
471
+ const circles = svg.querySelectorAll('circle');
472
+
473
+ expect(paths.length).toBe(2);
474
+ expect(circles.length).toBe(1);
475
+
476
+ paths.forEach((path) => {
477
+ expect(path.namespaceURI).toBe('http://www.w3.org/2000/svg');
478
+ });
479
+ expect(circles[0].namespaceURI).toBe('http://www.w3.org/2000/svg');
480
+
481
+ expect(paths[0].getAttribute('d')).toBe('m14 12 4 4 4-4');
482
+ expect(circles[0].getAttribute('cx')).toBe('12');
483
+ expect(paths[1].getAttribute('d')).toBe('M18 16V7');
484
+ });
441
485
  });
@@ -7,6 +7,29 @@ var root_2 = _$_.template(`<div><!></div>`, 0);
7
7
  var root_3 = _$_.template(`<section><!></section>`, 0);
8
8
  var root_4 = _$_.template(`<div><!><!></div>`, 0);
9
9
  var root_5 = _$_.template(`<div><!><button>Increment</button></div>`, 0);
10
+ var root_6 = _$_.template(`<div class="wrapper"><div class="inner"><!></div></div>`, 0);
11
+ var root_8 = _$_.template(`<div class="vp-doc"><!></div>`, 0);
12
+ var root_7 = _$_.template(`<!>`, 1);
13
+ var root_10 = _$_.template(`<h1>Title</h1><div class="content"><!></div>`, 1);
14
+ var root_9 = _$_.template(`<!>`, 1);
15
+ var root_12 = _$_.template(`<div class="doc"><!><!></div>`, 0);
16
+ var root_11 = _$_.template(`<!>`, 1);
17
+ var root_13 = _$_.template(`<div><!></div>`, 0);
18
+ var root_14 = _$_.template(`<div><!></div>`, 0);
19
+ var root_16 = _$_.template(`<div class="vp-doc"><!></div>`, 0);
20
+ var root_15 = _$_.template(`<!>`, 1);
21
+ var root_17 = _$_.template(`<footer class="doc-footer">Footer content</footer>`, 0);
22
+ var root_19 = _$_.template(`<div class="edit-link"><a>Edit</a></div>`, 0);
23
+ var root_20 = _$_.template(`<nav class="prev-next"><a> </a></nav>`, 0);
24
+ var root_22 = _$_.template(`<li><a> </a></li>`, 0);
25
+ var root_21 = _$_.template(`<div class="toc"><ul></ul></div>`, 0);
26
+ var root_18 = _$_.template(`<div class="layout"><div class="content-container"><article><div><!></div></article><!><!><!></div><aside><!></aside></div>`, 0);
27
+ var root_24 = _$_.template(`<div class="vp-doc"><!></div>`, 0);
28
+ var root_23 = _$_.template(`<!>`, 1);
29
+ var root_26 = _$_.template(`<div class="vp-doc"><!></div>`, 0);
30
+ var root_25 = _$_.template(`<!>`, 1);
31
+ var root_28 = _$_.template(`<div class="vp-doc"><!></div>`, 0);
32
+ var root_27 = _$_.template(`<!>`, 1);
10
33
 
11
34
  import { track } from 'ripple';
12
35
 
@@ -133,4 +156,507 @@ export function HtmlWithReactivity(__anchor, _, __block) {
133
156
 
134
157
  _$_.append(__anchor, div_5);
135
158
  _$_.pop_component();
159
+ }
160
+
161
+ export function HtmlWrapper(__anchor, __props, __block) {
162
+ _$_.push_component();
163
+
164
+ var div_6 = root_6();
165
+
166
+ {
167
+ var div_7 = _$_.child(div_6);
168
+
169
+ {
170
+ var node_7 = _$_.child(div_7);
171
+
172
+ _$_.composite(() => __props.children, node_7, {});
173
+ _$_.pop(div_7);
174
+ }
175
+ }
176
+
177
+ _$_.append(__anchor, div_6);
178
+ _$_.pop_component();
179
+ }
180
+
181
+ export function HtmlInChildren(__anchor, _, __block) {
182
+ _$_.push_component();
183
+
184
+ const content = '<p><strong>Bold</strong> text</p>';
185
+ var fragment = root_7();
186
+ var node_8 = _$_.first_child_frag(fragment);
187
+
188
+ HtmlWrapper(
189
+ node_8,
190
+ {
191
+ children(__anchor, _, __block) {
192
+ _$_.push_component();
193
+
194
+ var div_8 = root_8();
195
+
196
+ {
197
+ var node_9 = _$_.child(div_8);
198
+
199
+ _$_.pop(div_8);
200
+ }
201
+
202
+ _$_.render(() => {
203
+ _$_.html(node_9, () => content);
204
+ });
205
+
206
+ _$_.append(__anchor, div_8);
207
+ _$_.pop_component();
208
+ }
209
+ },
210
+ _$_.active_block
211
+ );
212
+
213
+ _$_.append(__anchor, fragment);
214
+ _$_.pop_component();
215
+ }
216
+
217
+ export function HtmlInChildrenWithSiblings(__anchor, _, __block) {
218
+ _$_.push_component();
219
+
220
+ const content = '<p>Dynamic content</p>';
221
+ var fragment_1 = root_9();
222
+ var node_10 = _$_.first_child_frag(fragment_1);
223
+
224
+ HtmlWrapper(
225
+ node_10,
226
+ {
227
+ children(__anchor, _, __block) {
228
+ _$_.push_component();
229
+
230
+ var fragment_2 = root_10();
231
+ var h1_1 = _$_.first_child_frag(fragment_2);
232
+ var div_9 = _$_.sibling(h1_1);
233
+
234
+ {
235
+ var node_11 = _$_.child(div_9);
236
+
237
+ _$_.pop(div_9);
238
+ }
239
+
240
+ _$_.next();
241
+
242
+ _$_.render(() => {
243
+ _$_.html(node_11, () => content);
244
+ });
245
+
246
+ _$_.append(__anchor, fragment_2, true);
247
+ _$_.pop_component();
248
+ }
249
+ },
250
+ _$_.active_block
251
+ );
252
+
253
+ _$_.append(__anchor, fragment_1);
254
+ _$_.pop_component();
255
+ }
256
+
257
+ export function MultipleHtmlInChildren(__anchor, _, __block) {
258
+ _$_.push_component();
259
+
260
+ const html1 = '<p>First</p>';
261
+ const html2 = '<p>Second</p>';
262
+ var fragment_3 = root_11();
263
+ var node_12 = _$_.first_child_frag(fragment_3);
264
+
265
+ HtmlWrapper(
266
+ node_12,
267
+ {
268
+ children(__anchor, _, __block) {
269
+ _$_.push_component();
270
+
271
+ var div_10 = root_12();
272
+
273
+ {
274
+ var node_13 = _$_.child(div_10);
275
+ var node_14 = _$_.sibling(node_13);
276
+
277
+ _$_.pop(div_10);
278
+ }
279
+
280
+ _$_.render(
281
+ (__prev) => {
282
+ _$_.html(node_13, () => html1);
283
+ _$_.html(node_14, () => html2);
284
+ },
285
+ {}
286
+ );
287
+
288
+ _$_.append(__anchor, div_10);
289
+ _$_.pop_component();
290
+ }
291
+ },
292
+ _$_.active_block
293
+ );
294
+
295
+ _$_.append(__anchor, fragment_3);
296
+ _$_.pop_component();
297
+ }
298
+
299
+ export function HtmlWithComments(__anchor, _, __block) {
300
+ _$_.push_component();
301
+
302
+ const content = '<p>Before comment</p><!-- TODO: Elaborate --><p>After comment</p>';
303
+ var div_11 = root_13();
304
+
305
+ {
306
+ var node_15 = _$_.child(div_11);
307
+
308
+ _$_.pop(div_11);
309
+ }
310
+
311
+ _$_.render(() => {
312
+ _$_.html(node_15, () => content);
313
+ });
314
+
315
+ _$_.append(__anchor, div_11);
316
+ _$_.pop_component();
317
+ }
318
+
319
+ export function HtmlWithEmptyComment(__anchor, _, __block) {
320
+ _$_.push_component();
321
+
322
+ const content = '<p>Before</p><!----><p>After</p>';
323
+ var div_12 = root_14();
324
+
325
+ {
326
+ var node_16 = _$_.child(div_12);
327
+
328
+ _$_.pop(div_12);
329
+ }
330
+
331
+ _$_.render(() => {
332
+ _$_.html(node_16, () => content);
333
+ });
334
+
335
+ _$_.append(__anchor, div_12);
336
+ _$_.pop_component();
337
+ }
338
+
339
+ export function HtmlWithCommentsInChildren(__anchor, _, __block) {
340
+ _$_.push_component();
341
+
342
+ const content = '<h2 id="intro">Introduction</h2><p>Some text</p><!-- TODO --><p>More text</p>';
343
+ var fragment_4 = root_15();
344
+ var node_17 = _$_.first_child_frag(fragment_4);
345
+
346
+ HtmlWrapper(
347
+ node_17,
348
+ {
349
+ children(__anchor, _, __block) {
350
+ _$_.push_component();
351
+
352
+ var div_13 = root_16();
353
+
354
+ {
355
+ var node_18 = _$_.child(div_13);
356
+
357
+ _$_.pop(div_13);
358
+ }
359
+
360
+ _$_.render(() => {
361
+ _$_.html(node_18, () => content);
362
+ });
363
+
364
+ _$_.append(__anchor, div_13);
365
+ _$_.pop_component();
366
+ }
367
+ },
368
+ _$_.active_block
369
+ );
370
+
371
+ _$_.append(__anchor, fragment_4);
372
+ _$_.pop_component();
373
+ }
374
+
375
+ function DocFooter(__anchor, _, __block) {
376
+ _$_.push_component();
377
+
378
+ var footer_1 = root_17();
379
+
380
+ _$_.append(__anchor, footer_1);
381
+ _$_.pop_component();
382
+ }
383
+
384
+ export function DocLayout(__anchor, __props, __block) {
385
+ _$_.push_component();
386
+
387
+ var div_14 = root_18();
388
+
389
+ {
390
+ var div_16 = _$_.child(div_14);
391
+
392
+ {
393
+ var article_1 = _$_.child(div_16);
394
+
395
+ {
396
+ var div_15 = _$_.child(article_1);
397
+
398
+ {
399
+ var node_19 = _$_.child(div_15);
400
+
401
+ _$_.composite(() => __props.children, node_19, {});
402
+ _$_.pop(div_15);
403
+ }
404
+ }
405
+
406
+ _$_.pop(article_1);
407
+
408
+ var node_20 = _$_.sibling(article_1);
409
+
410
+ {
411
+ var consequent = (__anchor) => {
412
+ var div_17 = root_19();
413
+
414
+ {
415
+ var a_1 = _$_.child(div_17);
416
+ }
417
+
418
+ _$_.render(() => {
419
+ _$_.set_attribute(a_1, 'href', `https://github.com/edit/${_$_.fallback(__props.editPath, '')}`);
420
+ });
421
+
422
+ _$_.append(__anchor, div_17);
423
+ };
424
+
425
+ _$_.if(node_20, (__render) => {
426
+ if (_$_.fallback(__props.editPath, '')) __render(consequent);
427
+ });
428
+ }
429
+
430
+ var node_21 = _$_.sibling(node_20);
431
+
432
+ {
433
+ var consequent_1 = (__anchor) => {
434
+ var nav_1 = root_20();
435
+
436
+ {
437
+ var a_2 = _$_.child(nav_1);
438
+
439
+ {
440
+ var text = _$_.child(a_2, true);
441
+
442
+ _$_.pop(a_2);
443
+ }
444
+ }
445
+
446
+ _$_.render(
447
+ (__prev) => {
448
+ var __a = _$_.fallback(__props.nextLink, null).text;
449
+
450
+ if (__prev.a !== __a) {
451
+ _$_.set_text(text, __prev.a = __a);
452
+ }
453
+
454
+ var __b = _$_.fallback(__props.nextLink, null).href;
455
+
456
+ if (__prev.b !== __b) {
457
+ _$_.set_attribute(a_2, 'href', __prev.b = __b);
458
+ }
459
+ },
460
+ { a: ' ', b: void 0 }
461
+ );
462
+
463
+ _$_.append(__anchor, nav_1);
464
+ };
465
+
466
+ _$_.if(node_21, (__render) => {
467
+ if (_$_.fallback(__props.nextLink, null)) __render(consequent_1);
468
+ });
469
+ }
470
+
471
+ var node_22 = _$_.sibling(node_21);
472
+
473
+ DocFooter(node_22, {}, _$_.active_block);
474
+ _$_.pop(div_16);
475
+ }
476
+
477
+ var aside_1 = _$_.sibling(div_16);
478
+
479
+ {
480
+ var node_23 = _$_.child(aside_1);
481
+
482
+ {
483
+ var consequent_2 = (__anchor) => {
484
+ var div_18 = root_21();
485
+
486
+ {
487
+ var ul_1 = _$_.child(div_18);
488
+
489
+ {
490
+ _$_.for(
491
+ ul_1,
492
+ () => _$_.fallback(__props.toc, []),
493
+ (__anchor, item) => {
494
+ var li_1 = root_22();
495
+
496
+ {
497
+ var a_3 = _$_.child(li_1);
498
+
499
+ {
500
+ var text_1 = _$_.child(a_3, true);
501
+
502
+ _$_.pop(a_3);
503
+ }
504
+ }
505
+
506
+ _$_.render(
507
+ (__prev) => {
508
+ var __a = item.text;
509
+
510
+ if (__prev.a !== __a) {
511
+ _$_.set_text(text_1, __prev.a = __a);
512
+ }
513
+
514
+ var __b = item.href;
515
+
516
+ if (__prev.b !== __b) {
517
+ _$_.set_attribute(a_3, 'href', __prev.b = __b);
518
+ }
519
+ },
520
+ { a: ' ', b: void 0 }
521
+ );
522
+
523
+ _$_.append(__anchor, li_1);
524
+ },
525
+ 4
526
+ );
527
+
528
+ _$_.pop(ul_1);
529
+ }
530
+ }
531
+
532
+ _$_.append(__anchor, div_18);
533
+ };
534
+
535
+ _$_.if(node_23, (__render) => {
536
+ if (_$_.fallback(__props.toc, []).length > 0) __render(consequent_2);
537
+ });
538
+ }
539
+
540
+ _$_.pop(aside_1);
541
+ }
542
+ }
543
+
544
+ _$_.append(__anchor, div_14);
545
+ _$_.pop_component();
546
+ }
547
+
548
+ export function HtmlWithServerData(__anchor, _, __block) {
549
+ _$_.push_component();
550
+
551
+ const content = '<h1 id="intro" class="doc-h1">Introduction</h1><p>Ripple is a framework.</p>';
552
+ var fragment_5 = root_23();
553
+ var node_24 = _$_.first_child_frag(fragment_5);
554
+
555
+ DocLayout(
556
+ node_24,
557
+ {
558
+ editPath: "docs/introduction.md",
559
+ nextLink: { href: '/docs/quick-start', text: 'Quick Start' },
560
+
561
+ toc: [
562
+ { href: '#intro', text: 'Introduction' },
563
+ { href: '#features', text: 'Features' }
564
+ ],
565
+
566
+ children(__anchor, _, __block) {
567
+ _$_.push_component();
568
+
569
+ var div_19 = root_24();
570
+
571
+ {
572
+ var node_25 = _$_.child(div_19);
573
+
574
+ _$_.pop(div_19);
575
+ }
576
+
577
+ _$_.render(() => {
578
+ _$_.html(node_25, () => content);
579
+ });
580
+
581
+ _$_.append(__anchor, div_19);
582
+ _$_.pop_component();
583
+ }
584
+ },
585
+ _$_.active_block
586
+ );
587
+
588
+ _$_.append(__anchor, fragment_5);
589
+ _$_.pop_component();
590
+ }
591
+
592
+ export function HtmlWithClientDefaults(__anchor, _, __block) {
593
+ _$_.push_component();
594
+
595
+ const content = '<h1 id="intro" class="doc-h1">Introduction</h1><p>Ripple is a framework.</p>';
596
+ var fragment_6 = root_25();
597
+ var node_26 = _$_.first_child_frag(fragment_6);
598
+
599
+ DocLayout(
600
+ node_26,
601
+ {
602
+ children(__anchor, _, __block) {
603
+ _$_.push_component();
604
+
605
+ var div_20 = root_26();
606
+
607
+ {
608
+ var node_27 = _$_.child(div_20);
609
+
610
+ _$_.pop(div_20);
611
+ }
612
+
613
+ _$_.render(() => {
614
+ _$_.html(node_27, () => content);
615
+ });
616
+
617
+ _$_.append(__anchor, div_20);
618
+ _$_.pop_component();
619
+ }
620
+ },
621
+ _$_.active_block
622
+ );
623
+
624
+ _$_.append(__anchor, fragment_6);
625
+ _$_.pop_component();
626
+ }
627
+
628
+ export function HtmlWithUndefinedContent(__anchor, _, __block) {
629
+ _$_.push_component();
630
+
631
+ const content = undefined;
632
+ var fragment_7 = root_27();
633
+ var node_28 = _$_.first_child_frag(fragment_7);
634
+
635
+ DocLayout(
636
+ node_28,
637
+ {
638
+ children(__anchor, _, __block) {
639
+ _$_.push_component();
640
+
641
+ var div_21 = root_28();
642
+
643
+ {
644
+ var node_29 = _$_.child(div_21);
645
+
646
+ _$_.pop(div_21);
647
+ }
648
+
649
+ _$_.render(() => {
650
+ _$_.html(node_29, () => content);
651
+ });
652
+
653
+ _$_.append(__anchor, div_21);
654
+ _$_.pop_component();
655
+ }
656
+ },
657
+ _$_.active_block
658
+ );
659
+
660
+ _$_.append(__anchor, fragment_7);
661
+ _$_.pop_component();
136
662
  }