ripple 0.4.0 → 0.4.2
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 +82 -0
- package/package.json +3 -2
- package/src/constants.js +4 -0
- package/src/jsx-runtime.d.ts +12 -2
- package/src/runtime/internal/client/constants.js +6 -0
- package/src/runtime/internal/client/for.js +224 -50
- package/src/runtime/internal/client/hydration.js +0 -16
- package/src/runtime/internal/client/index.js +2 -2
- package/src/runtime/internal/client/operations.js +1 -2
- package/src/runtime/internal/client/render.js +42 -4
- package/src/runtime/internal/client/runtime.js +45 -2
- package/src/runtime/internal/server/index.js +11 -6
- package/tests/client/basic/basic.attributes.test.tsrx +37 -0
- package/tests/client/compiler/compiler.basic.test.tsrx +2 -2
- package/tests/client/for-item.test.tsrx +404 -0
- package/tests/hydration/compiled/client/basic.js +29 -55
- package/tests/hydration/compiled/client/events.js +80 -67
- package/tests/hydration/compiled/client/for.js +95 -80
- package/tests/hydration/compiled/client/fragment-cursor.js +412 -344
- package/tests/hydration/compiled/client/head.js +4 -7
- package/tests/hydration/compiled/client/html.js +40 -64
- package/tests/hydration/compiled/client/if-children.js +30 -34
- package/tests/hydration/compiled/client/if-fragment-controlflow.js +7 -7
- package/tests/hydration/compiled/client/if.js +4 -4
- package/tests/hydration/compiled/client/mixed-control-flow.js +20 -50
- package/tests/hydration/compiled/client/nested-control-flow.js +97 -185
- package/tests/hydration/compiled/client/portal.js +2 -2
- package/tests/hydration/compiled/client/reactivity.js +17 -31
- package/tests/hydration/compiled/client/streaming.js +4 -8
- package/tests/hydration/compiled/client/typed-text.js +4 -15
- package/tests/hydration/compiled/server/events.js +5 -53
- package/tests/hydration/compiled/server/for.js +1 -9
- package/tests/hydration/compiled/server/fragment-cursor.js +36 -324
- package/tests/server/basic.attributes.test.tsrx +28 -0
- package/tests/server/basic.test.tsrx +23 -0
- package/tests/utils/jsx-runtime-types.test.js +67 -2
- package/tests/utils/tracked-types.test.js +117 -0
- package/types/index.d.ts +7 -8
- package/tests/client/compiler/__snapshots__/compiler.assignments.test.rsrx.snap +0 -12
- package/tests/client/compiler/__snapshots__/compiler.typescript.test.rsrx.snap +0 -46
|
@@ -39,7 +39,7 @@ function if_1(show) {
|
|
|
39
39
|
if (show.value) return consequent;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
var root_2 = _$_.template(`<div class="container"><button class="toggle">Toggle</button
|
|
42
|
+
var root_2 = _$_.template(`<div class="container"><button class="toggle">Toggle</button></div>`, 0);
|
|
43
43
|
|
|
44
44
|
function ConditionalPortal_render(__anchor, __block) {
|
|
45
45
|
const show = _$_.track(true, __block, '4f6df174');
|
|
@@ -50,7 +50,7 @@ function ConditionalPortal_render(__anchor, __block) {
|
|
|
50
50
|
|
|
51
51
|
button.__click = () => show.value = !show.value;
|
|
52
52
|
|
|
53
|
-
var node_1 = _$_.hydrating ? _$_.hydrate_sibling() :
|
|
53
|
+
var node_1 = _$_.hydrating ? _$_.hydrate_sibling() : _$_.append_into(div_2);
|
|
54
54
|
|
|
55
55
|
_$_.if(node_1, if_1, false, show);
|
|
56
56
|
_$_.hydrating && _$_.pop(div_2);
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import * as _$_ from 'ripple/internal/client';
|
|
3
3
|
|
|
4
|
-
var root = _$_.template(`<div class="count"
|
|
4
|
+
var root = _$_.template(`<div class="count"></div>`, 0);
|
|
5
5
|
|
|
6
6
|
function render(__prev) {
|
|
7
7
|
var __a = __prev._count.value;
|
|
8
8
|
|
|
9
9
|
if (__prev.a !== __a) {
|
|
10
|
-
_$_.
|
|
10
|
+
_$_.set_text_content(__prev._div, __a, __prev.a);
|
|
11
|
+
__prev.a = __a;
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
|
|
@@ -15,11 +16,7 @@ function TrackedState_render(__anchor, __block) {
|
|
|
15
16
|
const count = _$_.track(0, __block, 'c1818584');
|
|
16
17
|
var div = root();
|
|
17
18
|
|
|
18
|
-
{
|
|
19
|
-
var expression = _$_.hydrating ? _$_.hydrate_text() : div.firstChild;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
_$_.render(render, { a: ' ', _count: count, _expression: expression });
|
|
19
|
+
_$_.render(render, { a: '', _count: count, _div: div });
|
|
23
20
|
_$_.append(__anchor, div);
|
|
24
21
|
}
|
|
25
22
|
|
|
@@ -73,25 +70,28 @@ function ComputedValues_render(__anchor, __block) {
|
|
|
73
70
|
|
|
74
71
|
ComputedValues[_$_.$r] = ComputedValues_render;
|
|
75
72
|
|
|
76
|
-
var root_3 = _$_.template(`<div class="multiple-tracked"><div class="x"
|
|
73
|
+
var root_3 = _$_.template(`<div class="multiple-tracked"><div class="x"></div><div class="y"></div><div class="z"></div></div>`, 0);
|
|
77
74
|
|
|
78
75
|
function render_1(__prev) {
|
|
79
76
|
var __a = __prev._x.value;
|
|
80
77
|
|
|
81
78
|
if (__prev.a !== __a) {
|
|
82
|
-
_$_.
|
|
79
|
+
_$_.set_text_content(__prev._div_4, __a, __prev.a);
|
|
80
|
+
__prev.a = __a;
|
|
83
81
|
}
|
|
84
82
|
|
|
85
83
|
var __b = __prev._y.value;
|
|
86
84
|
|
|
87
85
|
if (__prev.b !== __b) {
|
|
88
|
-
_$_.
|
|
86
|
+
_$_.set_text_content(__prev._div_5, __b, __prev.b);
|
|
87
|
+
__prev.b = __b;
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
var __c = __prev._z.value;
|
|
92
91
|
|
|
93
92
|
if (__prev.c !== __c) {
|
|
94
|
-
_$_.
|
|
93
|
+
_$_.set_text_content(__prev._div_6, __c, __prev.c);
|
|
94
|
+
__prev.c = __c;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -103,34 +103,20 @@ function MultipleTracked_render(__anchor, __block) {
|
|
|
103
103
|
|
|
104
104
|
{
|
|
105
105
|
var div_4 = _$_.hydrating ? _$_.hydrate_child() : div_3.firstChild;
|
|
106
|
-
|
|
107
|
-
{
|
|
108
|
-
var expression_3 = _$_.hydrating ? _$_.hydrate_text() : div_4.firstChild;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
106
|
var div_5 = _$_.hydrating ? _$_.hydrate_sibling() : div_4.nextSibling;
|
|
112
|
-
|
|
113
|
-
{
|
|
114
|
-
var expression_4 = _$_.hydrating ? _$_.hydrate_text() : div_5.firstChild;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
107
|
var div_6 = _$_.hydrating ? _$_.hydrate_sibling() : div_5.nextSibling;
|
|
118
|
-
|
|
119
|
-
{
|
|
120
|
-
var expression_5 = _$_.hydrating ? _$_.hydrate_text() : div_6.firstChild;
|
|
121
|
-
}
|
|
122
108
|
}
|
|
123
109
|
|
|
124
110
|
_$_.render(render_1, {
|
|
125
|
-
a: '
|
|
126
|
-
b: '
|
|
127
|
-
c: '
|
|
111
|
+
a: '',
|
|
112
|
+
b: '',
|
|
113
|
+
c: '',
|
|
128
114
|
_x: x,
|
|
129
|
-
|
|
115
|
+
_div_4: div_4,
|
|
130
116
|
_y: y,
|
|
131
|
-
|
|
117
|
+
_div_5: div_5,
|
|
132
118
|
_z: z,
|
|
133
|
-
|
|
119
|
+
_div_6: div_6
|
|
134
120
|
});
|
|
135
121
|
|
|
136
122
|
_$_.append(__anchor, div_3);
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import * as _$_ from 'ripple/internal/client';
|
|
3
3
|
|
|
4
|
-
var root = _$_.template(`<div class="resolved"><span class="value"
|
|
4
|
+
var root = _$_.template(`<div class="resolved"><span class="value"></span><button class="inc">inc</button></div>`, 0);
|
|
5
5
|
|
|
6
6
|
function render(__prev) {
|
|
7
7
|
var __a = __prev._data.value + ':' + __prev._count.value;
|
|
8
8
|
|
|
9
9
|
if (__prev.a !== __a) {
|
|
10
|
-
_$_.
|
|
10
|
+
_$_.set_text_content(__prev._span, __a, __prev.a);
|
|
11
|
+
__prev.a = __a;
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
|
|
@@ -18,17 +19,12 @@ function BasicContent_render(__anchor, __block) {
|
|
|
18
19
|
|
|
19
20
|
{
|
|
20
21
|
var span = _$_.hydrating ? _$_.hydrate_child() : div.firstChild;
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
var expression = _$_.hydrating ? _$_.hydrate_text() : span.firstChild;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
22
|
var button = _$_.hydrating ? _$_.hydrate_sibling() : span.nextSibling;
|
|
27
23
|
|
|
28
24
|
button.__click = () => count.value++;
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
_$_.render(render, { a: '
|
|
27
|
+
_$_.render(render, { a: '', _data: data, _count: count, _span: span });
|
|
32
28
|
_$_.append(__anchor, div);
|
|
33
29
|
}
|
|
34
30
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import * as _$_ from 'ripple/internal/client';
|
|
3
3
|
|
|
4
|
-
var root_1 = _$_.template(`<div class="typed-run"> <span>tail</span></div><p class="typed-number"
|
|
4
|
+
var root_1 = _$_.template(`<div class="typed-run"> <span>tail</span></div><p class="typed-number"></p><button>update</button>`, 1, 3);
|
|
5
5
|
|
|
6
6
|
function render(__prev) {
|
|
7
7
|
var __a = 'value: ' + (__prev._row.value.label + String(__prev._row.value.count ?? ''));
|
|
@@ -13,7 +13,8 @@ function render(__prev) {
|
|
|
13
13
|
var __b = (0, __prev._row.value.count);
|
|
14
14
|
|
|
15
15
|
if (__prev.b !== __b) {
|
|
16
|
-
_$_.
|
|
16
|
+
_$_.set_text_content(__prev._p, __b, __prev.b);
|
|
17
|
+
__prev.b = __b;
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -35,25 +36,13 @@ function TypedText_render(__anchor, __block) {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
var p = _$_.hydrating ? _$_.hydrate_sibling() : div.nextSibling;
|
|
38
|
-
|
|
39
|
-
{
|
|
40
|
-
var expression_1 = _$_.hydrating ? _$_.hydrate_text() : p.firstChild;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
39
|
var button = _$_.hydrating ? _$_.hydrate_sibling() : p.nextSibling;
|
|
44
40
|
|
|
45
41
|
button.__click = () => {
|
|
46
42
|
row.value = { label: '&next', count: 3n };
|
|
47
43
|
};
|
|
48
44
|
|
|
49
|
-
_$_.render(render, {
|
|
50
|
-
a: ' ',
|
|
51
|
-
b: ' ',
|
|
52
|
-
_row: row,
|
|
53
|
-
_expression: expression,
|
|
54
|
-
_expression_1: expression_1
|
|
55
|
-
});
|
|
56
|
-
|
|
45
|
+
_$_.render(render, { a: ' ', b: '', _row: row, _expression: expression, _p: p });
|
|
57
46
|
_$_.append(__anchor, fragment_1);
|
|
58
47
|
}));
|
|
59
48
|
|
|
@@ -10,15 +10,7 @@ export function ClickCounter() {
|
|
|
10
10
|
_$_.regular_block(() => {
|
|
11
11
|
let __out = '';
|
|
12
12
|
|
|
13
|
-
__out += '<div><button class="increment">Increment</button><span class="count">';
|
|
14
|
-
|
|
15
|
-
{
|
|
16
|
-
_$_.output_push(__out);
|
|
17
|
-
__out = '';
|
|
18
|
-
_$_.render_expression(count.value);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
__out += '</span></div>';
|
|
13
|
+
__out += '<div><button class="increment">Increment</button><span class="count">' + _$_.escape(count.value) + '</span></div>';
|
|
22
14
|
_$_.output_push(__out);
|
|
23
15
|
});
|
|
24
16
|
});
|
|
@@ -31,15 +23,7 @@ export function IncrementDecrement() {
|
|
|
31
23
|
_$_.regular_block(() => {
|
|
32
24
|
let __out = '';
|
|
33
25
|
|
|
34
|
-
__out += '<div><button class="decrement">-</button><span class="count">';
|
|
35
|
-
|
|
36
|
-
{
|
|
37
|
-
_$_.output_push(__out);
|
|
38
|
-
__out = '';
|
|
39
|
-
_$_.render_expression(count.value);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
__out += '</span><button class="increment">+</button></div>';
|
|
26
|
+
__out += '<div><button class="decrement">-</button><span class="count">' + _$_.escape(count.value) + '</span><button class="increment">+</button></div>';
|
|
43
27
|
_$_.output_push(__out);
|
|
44
28
|
});
|
|
45
29
|
});
|
|
@@ -53,23 +37,7 @@ export function MultipleEvents() {
|
|
|
53
37
|
_$_.regular_block(() => {
|
|
54
38
|
let __out = '';
|
|
55
39
|
|
|
56
|
-
__out += '<div><button class="target">Target</button><span class="clicks">';
|
|
57
|
-
|
|
58
|
-
{
|
|
59
|
-
_$_.output_push(__out);
|
|
60
|
-
__out = '';
|
|
61
|
-
_$_.render_expression(clicks.value);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
__out += '</span><span class="hovers">';
|
|
65
|
-
|
|
66
|
-
{
|
|
67
|
-
_$_.output_push(__out);
|
|
68
|
-
__out = '';
|
|
69
|
-
_$_.render_expression(hovers.value);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
__out += '</span></div>';
|
|
40
|
+
__out += '<div><button class="target">Target</button><span class="clicks">' + _$_.escape(clicks.value) + '</span><span class="hovers">' + _$_.escape(hovers.value) + '</span></div>';
|
|
73
41
|
_$_.output_push(__out);
|
|
74
42
|
});
|
|
75
43
|
});
|
|
@@ -88,15 +56,7 @@ export function MultiStateUpdate() {
|
|
|
88
56
|
_$_.regular_block(() => {
|
|
89
57
|
let __out = '';
|
|
90
58
|
|
|
91
|
-
__out += '<div><button class="btn">Click</button><span class="count">';
|
|
92
|
-
|
|
93
|
-
{
|
|
94
|
-
_$_.output_push(__out);
|
|
95
|
-
__out = '';
|
|
96
|
-
_$_.render_expression(count.value);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
__out += '</span><span class="action">';
|
|
59
|
+
__out += '<div><button class="btn">Click</button><span class="count">' + _$_.escape(count.value) + '</span><span class="action">';
|
|
100
60
|
|
|
101
61
|
{
|
|
102
62
|
_$_.output_push(__out);
|
|
@@ -160,15 +120,7 @@ export function ParentWithChildButton() {
|
|
|
160
120
|
_$_.render_component(comp, ...args);
|
|
161
121
|
}
|
|
162
122
|
|
|
163
|
-
__out += '<span class="count">';
|
|
164
|
-
|
|
165
|
-
{
|
|
166
|
-
_$_.output_push(__out);
|
|
167
|
-
__out = '';
|
|
168
|
-
_$_.render_expression(count.value);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
__out += '</span></div>';
|
|
123
|
+
__out += '<span class="count">' + _$_.escape(count.value) + '</span></div>';
|
|
172
124
|
_$_.output_push(__out);
|
|
173
125
|
});
|
|
174
126
|
});
|
|
@@ -419,15 +419,7 @@ export function ForLoopEmptyToPopulated() {
|
|
|
419
419
|
__out += '<button class="populate">Populate</button><ul class="list"><!--[-->';
|
|
420
420
|
|
|
421
421
|
for (const item of items.value) {
|
|
422
|
-
__out += '<li>';
|
|
423
|
-
|
|
424
|
-
{
|
|
425
|
-
_$_.output_push(__out);
|
|
426
|
-
__out = '';
|
|
427
|
-
_$_.render_expression(item);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
__out += '</li>';
|
|
422
|
+
__out += '<li>' + _$_.escape(item) + '</li>';
|
|
431
423
|
}
|
|
432
424
|
|
|
433
425
|
__out += '<!--]--></ul>';
|