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.
- package/CHANGELOG.md +81 -0
- package/package.json +3 -3
- package/src/constants.js +4 -0
- package/src/runtime/internal/client/blocks.js +53 -0
- package/src/runtime/internal/client/component.js +3 -3
- package/src/runtime/internal/client/constants.js +4 -0
- package/src/runtime/internal/client/for.js +87 -14
- package/src/runtime/internal/client/if.js +18 -2
- package/src/runtime/internal/client/index.js +1 -0
- package/src/runtime/internal/client/operations.js +25 -0
- package/src/runtime/internal/client/runtime.js +62 -10
- package/src/runtime/internal/client/switch.js +33 -5
- package/src/runtime/internal/client/template.js +10 -2
- package/src/runtime/internal/client/try.js +12 -2
- package/src/runtime/internal/client/types.d.ts +4 -0
- package/tests/client/__snapshots__/for.test.tsrx.snap +0 -2
- package/tests/client/compiler/compiler.basic.test.tsrx +5 -2
- package/tests/client/composite/__snapshots__/composite.render.test.tsrx.snap +0 -4
- package/tests/client/for-single-root-items.test.tsrx +130 -0
- package/tests/client/scoped-flush.test.tsrx +105 -0
- package/tests/hydration/compiled/client/basic.js +198 -214
- package/tests/hydration/compiled/client/composite.js +23 -72
- package/tests/hydration/compiled/client/for.js +66 -72
- package/tests/hydration/compiled/client/hmr.js +2 -13
- package/tests/hydration/compiled/client/html.js +619 -479
- package/tests/hydration/compiled/client/if-children.js +72 -84
- package/tests/hydration/compiled/client/if-fragment-controlflow.js +463 -0
- package/tests/hydration/compiled/client/if.js +87 -92
- package/tests/hydration/compiled/client/mixed-control-flow.js +120 -160
- package/tests/hydration/compiled/client/nested-control-flow.js +288 -360
- package/tests/hydration/compiled/client/portal.js +15 -21
- package/tests/hydration/compiled/client/reactivity.js +7 -12
- package/tests/hydration/compiled/client/switch.js +113 -115
- package/tests/hydration/compiled/client/track-async-serialization.js +71 -122
- package/tests/hydration/compiled/client/try.js +26 -41
- package/tests/hydration/compiled/server/basic.js +295 -556
- package/tests/hydration/compiled/server/composite.js +31 -50
- package/tests/hydration/compiled/server/events.js +37 -173
- package/tests/hydration/compiled/server/for.js +236 -847
- package/tests/hydration/compiled/server/head.js +110 -241
- package/tests/hydration/compiled/server/hmr.js +14 -41
- package/tests/hydration/compiled/server/html-in-template.js +14 -38
- package/tests/hydration/compiled/server/html.js +951 -1176
- package/tests/hydration/compiled/server/if-children.js +59 -493
- package/tests/hydration/compiled/server/if-fragment-controlflow.js +227 -0
- package/tests/hydration/compiled/server/if.js +57 -209
- package/tests/hydration/compiled/server/mixed-control-flow.js +144 -250
- package/tests/hydration/compiled/server/nested-control-flow.js +309 -559
- package/tests/hydration/compiled/server/portal.js +94 -156
- package/tests/hydration/compiled/server/reactivity.js +23 -65
- package/tests/hydration/compiled/server/return.js +6 -16
- package/tests/hydration/compiled/server/switch.js +91 -219
- package/tests/hydration/compiled/server/track-async-serialization.js +211 -256
- package/tests/hydration/compiled/server/try.js +67 -126
- package/tests/hydration/components/html.tsrx +75 -0
- package/tests/hydration/components/if-fragment-controlflow.tsrx +145 -0
- package/tests/hydration/html.test.js +50 -0
- package/tests/hydration/if-fragment-controlflow.test.js +95 -0
- package/tests/server/compiler.test.tsrx +6 -2
|
@@ -4,26 +4,24 @@ import * as _$_ from 'ripple/internal/client';
|
|
|
4
4
|
var root_1 = _$_.template(`<div class="content"><!></div>`, 0);
|
|
5
5
|
var root = _$_.template(`<div class="container"><div role="button" class="header">Toggle</div><!></div>`, 0);
|
|
6
6
|
var root_2 = _$_.template(`<div class="item"> </div>`, 0);
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
7
|
+
var root_3 = _$_.template(`<!><!>`, 1, 2);
|
|
8
|
+
var root_5 = _$_.template(`<div class="content"><span>Static child 1</span><span>Static child 2</span></div>`, 0);
|
|
9
|
+
var root_4 = _$_.template(`<div class="container"><div role="button" class="header">Toggle</div><!></div>`, 0);
|
|
10
|
+
var root_7 = _$_.template(`<div class="items"><!></div>`, 0);
|
|
11
|
+
var root_6 = _$_.template(`<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><!></section>`, 0);
|
|
12
|
+
var root_8 = _$_.template(`<!><!>`, 1, 2);
|
|
13
|
+
var root_11 = _$_.template(`<div class="conditional">Conditional content</div>`, 0);
|
|
14
|
+
var root_10 = _$_.template(`<div class="wrapper"><div class="nested-parent"><div class="nested-child"><span class="deep">Deep content</span></div></div><!></div><button class="toggle">Toggle</button>`, 1, 2);
|
|
14
15
|
var root_9 = _$_.template(`<!>`, 1, 1);
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var root_16 = _$_.template(`<
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var root_21 = _$_.template(`<div class="container"><ul class="list"><li class="item"> </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>`, 1, 2);
|
|
25
|
-
var root_20 = _$_.template(`<!>`, 1, 1);
|
|
26
|
-
var root_22 = _$_.template(`<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>`, 0);
|
|
16
|
+
var root_14 = _$_.template(`<footer class="footer">Footer</footer>`, 0);
|
|
17
|
+
var root_13 = _$_.template(`<section class="outer"><article class="middle"><div class="inner"><p class="leaf"><strong>Bold</strong><em>Italic</em></p></div></article><!></section><button class="btn">Toggle</button>`, 1, 2);
|
|
18
|
+
var root_12 = _$_.template(`<!>`, 1, 1);
|
|
19
|
+
var root_16 = _$_.template(`<pre class="code">const x = 1;</pre>`, 0);
|
|
20
|
+
var root_17 = _$_.template(`<div class="preview">Preview content</div>`, 0);
|
|
21
|
+
var root_15 = _$_.template(`<div class="tabs"><div class="tab-list"><button class="tab">Code</button><button class="tab">Preview</button></div><div class="panel"><!></div></div>`, 0);
|
|
22
|
+
var root_19 = _$_.template(`<div class="container"><ul class="list"><li class="item"> </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>`, 1, 2);
|
|
23
|
+
var root_18 = _$_.template(`<!>`, 1, 1);
|
|
24
|
+
var root_20 = _$_.template(`<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>`, 0);
|
|
27
25
|
|
|
28
26
|
import { track } from 'ripple';
|
|
29
27
|
|
|
@@ -82,47 +80,42 @@ export function ChildItem({ text: label }) {
|
|
|
82
80
|
|
|
83
81
|
export function TestIfWithChildren() {
|
|
84
82
|
return _$_.tsrx_element((__anchor, __block) => {
|
|
85
|
-
|
|
86
|
-
var node_1 = _$_.first_child_frag(fragment);
|
|
87
|
-
|
|
88
|
-
_$_.render_component(IfWithChildren, node_1, {
|
|
83
|
+
_$_.render_component(IfWithChildren, __anchor, {
|
|
89
84
|
children: _$_.tsrx_element((__anchor, __block) => {
|
|
90
|
-
var
|
|
91
|
-
var
|
|
85
|
+
var fragment = root_3();
|
|
86
|
+
var node_1 = _$_.first_child_frag(fragment);
|
|
92
87
|
|
|
93
|
-
_$_.render_component(ChildItem,
|
|
88
|
+
_$_.render_component(ChildItem, node_1, { text: "Item 1" });
|
|
94
89
|
|
|
95
|
-
var
|
|
90
|
+
var node_2 = _$_.sibling(node_1);
|
|
96
91
|
|
|
97
|
-
_$_.render_component(ChildItem,
|
|
98
|
-
_$_.append(__anchor,
|
|
92
|
+
_$_.render_component(ChildItem, node_2, { text: "Item 2" });
|
|
93
|
+
_$_.append(__anchor, fragment);
|
|
99
94
|
})
|
|
100
95
|
});
|
|
101
|
-
|
|
102
|
-
_$_.append(__anchor, fragment);
|
|
103
96
|
});
|
|
104
97
|
}
|
|
105
98
|
|
|
106
99
|
export function IfWithStaticChildren() {
|
|
107
100
|
return _$_.tsrx_element((__anchor, __block) => {
|
|
108
101
|
let lazy_1 = _$_.track(true, __block, '3bba8f77');
|
|
109
|
-
var div_5 =
|
|
102
|
+
var div_5 = root_4();
|
|
110
103
|
|
|
111
104
|
{
|
|
112
105
|
var div_6 = _$_.child(div_5);
|
|
113
106
|
|
|
114
107
|
div_6.__click = () => _$_.set(lazy_1, !lazy_1.value);
|
|
115
108
|
|
|
116
|
-
var
|
|
109
|
+
var node_3 = _$_.sibling(div_6);
|
|
117
110
|
|
|
118
111
|
{
|
|
119
112
|
var consequent_1 = (__anchor) => {
|
|
120
|
-
var div_7 =
|
|
113
|
+
var div_7 = root_5();
|
|
121
114
|
|
|
122
115
|
_$_.append(__anchor, div_7);
|
|
123
116
|
};
|
|
124
117
|
|
|
125
|
-
_$_.if(
|
|
118
|
+
_$_.if(node_3, (__render) => {
|
|
126
119
|
if (lazy_1.value) __render(consequent_1);
|
|
127
120
|
});
|
|
128
121
|
}
|
|
@@ -137,7 +130,7 @@ export function IfWithStaticChildren() {
|
|
|
137
130
|
export function IfWithSiblingsAndChildren({ children }) {
|
|
138
131
|
return _$_.tsrx_element((__anchor, __block) => {
|
|
139
132
|
let lazy_2 = _$_.track(true, __block, 'a1b8fb4c');
|
|
140
|
-
var section_1 =
|
|
133
|
+
var section_1 = root_6();
|
|
141
134
|
|
|
142
135
|
{
|
|
143
136
|
var div_8 = _$_.child(section_1);
|
|
@@ -145,11 +138,11 @@ export function IfWithSiblingsAndChildren({ children }) {
|
|
|
145
138
|
div_8.__click = () => _$_.set(lazy_2, !lazy_2.value);
|
|
146
139
|
_$_.pop(div_8);
|
|
147
140
|
|
|
148
|
-
var
|
|
141
|
+
var node_4 = _$_.sibling(div_8);
|
|
149
142
|
|
|
150
143
|
{
|
|
151
144
|
var consequent_2 = (__anchor) => {
|
|
152
|
-
var div_9 =
|
|
145
|
+
var div_9 = root_7();
|
|
153
146
|
|
|
154
147
|
{
|
|
155
148
|
var expression_2 = _$_.child(div_9);
|
|
@@ -161,7 +154,7 @@ export function IfWithSiblingsAndChildren({ children }) {
|
|
|
161
154
|
_$_.append(__anchor, div_9);
|
|
162
155
|
};
|
|
163
156
|
|
|
164
|
-
_$_.if(
|
|
157
|
+
_$_.if(node_4, (__render) => {
|
|
165
158
|
if (lazy_2.value) __render(consequent_2);
|
|
166
159
|
});
|
|
167
160
|
}
|
|
@@ -175,52 +168,47 @@ export function IfWithSiblingsAndChildren({ children }) {
|
|
|
175
168
|
|
|
176
169
|
export function TestIfWithSiblingsAndChildren() {
|
|
177
170
|
return _$_.tsrx_element((__anchor, __block) => {
|
|
178
|
-
|
|
179
|
-
var node_6 = _$_.first_child_frag(fragment_2);
|
|
180
|
-
|
|
181
|
-
_$_.render_component(IfWithSiblingsAndChildren, node_6, {
|
|
171
|
+
_$_.render_component(IfWithSiblingsAndChildren, __anchor, {
|
|
182
172
|
children: _$_.tsrx_element((__anchor, __block) => {
|
|
183
|
-
var
|
|
184
|
-
var
|
|
173
|
+
var fragment_1 = root_8();
|
|
174
|
+
var node_5 = _$_.first_child_frag(fragment_1);
|
|
185
175
|
|
|
186
|
-
_$_.render_component(ChildItem,
|
|
176
|
+
_$_.render_component(ChildItem, node_5, { text: "Item A" });
|
|
187
177
|
|
|
188
|
-
var
|
|
178
|
+
var node_6 = _$_.sibling(node_5);
|
|
189
179
|
|
|
190
|
-
_$_.render_component(ChildItem,
|
|
191
|
-
_$_.append(__anchor,
|
|
180
|
+
_$_.render_component(ChildItem, node_6, { text: "Item B" });
|
|
181
|
+
_$_.append(__anchor, fragment_1);
|
|
192
182
|
})
|
|
193
183
|
});
|
|
194
|
-
|
|
195
|
-
_$_.append(__anchor, fragment_2);
|
|
196
184
|
});
|
|
197
185
|
}
|
|
198
186
|
|
|
199
187
|
export function ElementWithChildrenThenIf() {
|
|
200
188
|
return _$_.tsrx_element((__anchor, __block) => {
|
|
201
189
|
let lazy_3 = _$_.track(true, __block, '7cd4817b');
|
|
202
|
-
var
|
|
203
|
-
var
|
|
190
|
+
var fragment_2 = root_9();
|
|
191
|
+
var node_8 = _$_.first_child_frag(fragment_2);
|
|
204
192
|
|
|
205
|
-
_$_.expression(
|
|
206
|
-
var
|
|
207
|
-
var div_11 = _$_.first_child_frag(
|
|
193
|
+
_$_.expression(node_8, () => _$_.tsrx_element((__anchor, __block) => {
|
|
194
|
+
var fragment_3 = root_10();
|
|
195
|
+
var div_11 = _$_.first_child_frag(fragment_3);
|
|
208
196
|
|
|
209
197
|
{
|
|
210
198
|
var div_10 = _$_.child(div_11);
|
|
211
199
|
|
|
212
200
|
_$_.pop(div_10);
|
|
213
201
|
|
|
214
|
-
var
|
|
202
|
+
var node_7 = _$_.sibling(div_10);
|
|
215
203
|
|
|
216
204
|
{
|
|
217
205
|
var consequent_3 = (__anchor) => {
|
|
218
|
-
var div_12 =
|
|
206
|
+
var div_12 = root_11();
|
|
219
207
|
|
|
220
208
|
_$_.append(__anchor, div_12);
|
|
221
209
|
};
|
|
222
210
|
|
|
223
|
-
_$_.if(
|
|
211
|
+
_$_.if(node_7, (__render) => {
|
|
224
212
|
if (lazy_3.value) __render(consequent_3);
|
|
225
213
|
});
|
|
226
214
|
}
|
|
@@ -232,38 +220,38 @@ export function ElementWithChildrenThenIf() {
|
|
|
232
220
|
|
|
233
221
|
button_1.__click = () => _$_.set(lazy_3, !lazy_3.value);
|
|
234
222
|
_$_.next();
|
|
235
|
-
_$_.append(__anchor,
|
|
223
|
+
_$_.append(__anchor, fragment_3, true);
|
|
236
224
|
}));
|
|
237
225
|
|
|
238
|
-
_$_.append(__anchor,
|
|
226
|
+
_$_.append(__anchor, fragment_2);
|
|
239
227
|
});
|
|
240
228
|
}
|
|
241
229
|
|
|
242
230
|
export function DeepNestingThenIf() {
|
|
243
231
|
return _$_.tsrx_element((__anchor, __block) => {
|
|
244
232
|
let lazy_4 = _$_.track(true, __block, '923116be');
|
|
245
|
-
var
|
|
246
|
-
var
|
|
233
|
+
var fragment_4 = root_12();
|
|
234
|
+
var node_10 = _$_.first_child_frag(fragment_4);
|
|
247
235
|
|
|
248
|
-
_$_.expression(
|
|
249
|
-
var
|
|
250
|
-
var section_2 = _$_.first_child_frag(
|
|
236
|
+
_$_.expression(node_10, () => _$_.tsrx_element((__anchor, __block) => {
|
|
237
|
+
var fragment_5 = root_13();
|
|
238
|
+
var section_2 = _$_.first_child_frag(fragment_5);
|
|
251
239
|
|
|
252
240
|
{
|
|
253
241
|
var article_1 = _$_.child(section_2);
|
|
254
242
|
|
|
255
243
|
_$_.pop(article_1);
|
|
256
244
|
|
|
257
|
-
var
|
|
245
|
+
var node_9 = _$_.sibling(article_1);
|
|
258
246
|
|
|
259
247
|
{
|
|
260
248
|
var consequent_4 = (__anchor) => {
|
|
261
|
-
var footer_1 =
|
|
249
|
+
var footer_1 = root_14();
|
|
262
250
|
|
|
263
251
|
_$_.append(__anchor, footer_1);
|
|
264
252
|
};
|
|
265
253
|
|
|
266
|
-
_$_.if(
|
|
254
|
+
_$_.if(node_9, (__render) => {
|
|
267
255
|
if (lazy_4.value) __render(consequent_4);
|
|
268
256
|
});
|
|
269
257
|
}
|
|
@@ -275,17 +263,17 @@ export function DeepNestingThenIf() {
|
|
|
275
263
|
|
|
276
264
|
button_2.__click = () => _$_.set(lazy_4, !lazy_4.value);
|
|
277
265
|
_$_.next();
|
|
278
|
-
_$_.append(__anchor,
|
|
266
|
+
_$_.append(__anchor, fragment_5, true);
|
|
279
267
|
}));
|
|
280
268
|
|
|
281
|
-
_$_.append(__anchor,
|
|
269
|
+
_$_.append(__anchor, fragment_4);
|
|
282
270
|
});
|
|
283
271
|
}
|
|
284
272
|
|
|
285
273
|
export function DomElementChildrenThenSibling() {
|
|
286
274
|
return _$_.tsrx_element((__anchor, __block) => {
|
|
287
275
|
let lazy_5 = _$_.track('code', __block, '33a1e97f');
|
|
288
|
-
var div_13 =
|
|
276
|
+
var div_13 = root_15();
|
|
289
277
|
|
|
290
278
|
{
|
|
291
279
|
var div_14 = _$_.child(div_13);
|
|
@@ -305,22 +293,22 @@ export function DomElementChildrenThenSibling() {
|
|
|
305
293
|
var div_15 = _$_.sibling(div_14);
|
|
306
294
|
|
|
307
295
|
{
|
|
308
|
-
var
|
|
296
|
+
var node_11 = _$_.child(div_15);
|
|
309
297
|
|
|
310
298
|
{
|
|
311
299
|
var consequent_5 = (__anchor) => {
|
|
312
|
-
var pre_1 =
|
|
300
|
+
var pre_1 = root_16();
|
|
313
301
|
|
|
314
302
|
_$_.append(__anchor, pre_1);
|
|
315
303
|
};
|
|
316
304
|
|
|
317
305
|
var alternate = (__anchor) => {
|
|
318
|
-
var div_16 =
|
|
306
|
+
var div_16 = root_17();
|
|
319
307
|
|
|
320
308
|
_$_.append(__anchor, div_16);
|
|
321
309
|
};
|
|
322
310
|
|
|
323
|
-
_$_.if(
|
|
311
|
+
_$_.if(node_11, (__render) => {
|
|
324
312
|
if (lazy_5.value === 'code') __render(consequent_5); else __render(alternate, false);
|
|
325
313
|
});
|
|
326
314
|
}
|
|
@@ -353,12 +341,12 @@ export function DomElementChildrenThenSibling() {
|
|
|
353
341
|
export function DomChildrenThenStaticSiblings() {
|
|
354
342
|
return _$_.tsrx_element((__anchor, __block) => {
|
|
355
343
|
let lazy_6 = _$_.track(0, __block, '0ea64305');
|
|
356
|
-
var
|
|
357
|
-
var
|
|
344
|
+
var fragment_6 = root_18();
|
|
345
|
+
var node_12 = _$_.first_child_frag(fragment_6);
|
|
358
346
|
|
|
359
|
-
_$_.expression(
|
|
360
|
-
var
|
|
361
|
-
var div_17 = _$_.first_child_frag(
|
|
347
|
+
_$_.expression(node_12, () => _$_.tsrx_element((__anchor, __block) => {
|
|
348
|
+
var fragment_7 = root_19();
|
|
349
|
+
var div_17 = _$_.first_child_frag(fragment_7);
|
|
362
350
|
|
|
363
351
|
{
|
|
364
352
|
var ul_1 = _$_.child(div_17);
|
|
@@ -387,16 +375,16 @@ export function DomChildrenThenStaticSiblings() {
|
|
|
387
375
|
_$_.set_text(expression_3, 'Item count: ' + _$_.with_scope(__block, () => String(lazy_6.value ?? '')));
|
|
388
376
|
});
|
|
389
377
|
|
|
390
|
-
_$_.append(__anchor,
|
|
378
|
+
_$_.append(__anchor, fragment_7, true);
|
|
391
379
|
}));
|
|
392
380
|
|
|
393
|
-
_$_.append(__anchor,
|
|
381
|
+
_$_.append(__anchor, fragment_6);
|
|
394
382
|
});
|
|
395
383
|
}
|
|
396
384
|
|
|
397
385
|
export function StaticListThenStaticSiblings() {
|
|
398
386
|
return _$_.tsrx_element((__anchor, __block) => {
|
|
399
|
-
var div_18 =
|
|
387
|
+
var div_18 = root_20();
|
|
400
388
|
|
|
401
389
|
{
|
|
402
390
|
var ul_2 = _$_.child(div_18);
|