ripple 0.3.128 → 0.4.0
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 +267 -0
- package/package.json +10 -4
- package/src/runtime/element.js +23 -6
- package/src/runtime/index-client.js +81 -41
- package/src/runtime/index-server.js +1 -0
- package/src/runtime/internal/client/blocks.js +173 -91
- package/src/runtime/internal/client/component.js +4 -30
- package/src/runtime/internal/client/composite.js +12 -13
- package/src/runtime/internal/client/constants.js +9 -0
- package/src/runtime/internal/client/context.js +12 -19
- package/src/runtime/internal/client/css.js +7 -9
- package/src/runtime/internal/client/events.js +178 -90
- package/src/runtime/internal/client/expression.js +45 -25
- package/src/runtime/internal/client/for.js +409 -129
- package/src/runtime/internal/client/head.js +10 -5
- package/src/runtime/internal/client/html.js +1 -0
- package/src/runtime/internal/client/hydration.js +152 -10
- package/src/runtime/internal/client/if.js +239 -50
- package/src/runtime/internal/client/index.js +4 -12
- package/src/runtime/internal/client/operations.js +40 -61
- package/src/runtime/internal/client/portal.js +163 -85
- package/src/runtime/internal/client/render.js +39 -39
- package/src/runtime/internal/client/rpc.js +3 -3
- package/src/runtime/internal/client/runtime.js +592 -433
- package/src/runtime/internal/client/selector.js +5 -2
- package/src/runtime/internal/client/template.js +133 -158
- package/src/runtime/internal/client/transport.js +38 -0
- package/src/runtime/internal/client/try.js +465 -426
- package/src/runtime/internal/client/types.d.ts +56 -23
- package/src/runtime/internal/client/utils.js +1 -3
- package/src/runtime/internal/server/dynamic.js +20 -21
- package/src/runtime/internal/server/index.js +325 -275
- package/src/runtime/internal/server/rpc.js +3 -2
- package/src/runtime/internal/server/transport.js +16 -0
- package/src/runtime/transport.js +21 -0
- package/tests/client/__snapshots__/for.test.tsrx.snap +0 -5
- package/tests/client/array/array.copy-within.test.tsrx +12 -12
- package/tests/client/array/array.derived.test.tsrx +46 -46
- package/tests/client/array/array.iteration.test.tsrx +10 -10
- package/tests/client/array/array.mutations.test.tsrx +20 -20
- package/tests/client/array/array.static.test.tsrx +11 -11
- package/tests/client/array/array.to-methods.test.tsrx +6 -6
- package/tests/client/async-suspend.test.tsrx +74 -75
- package/tests/client/basic/basic.attributes.test.tsrx +86 -83
- package/tests/client/basic/basic.collections.test.tsrx +12 -12
- package/tests/client/basic/basic.components.test.tsrx +99 -25
- package/tests/client/basic/basic.errors.test.tsrx +18 -18
- package/tests/client/basic/basic.events.test.tsrx +42 -42
- package/tests/client/basic/basic.get-set.test.tsrx +8 -8
- package/tests/client/basic/basic.reactivity.test.tsrx +73 -38
- package/tests/client/basic/basic.rendering.test.tsrx +25 -25
- package/tests/client/basic/basic.utilities.test.tsrx +3 -3
- package/tests/client/boundaries.test.tsrx +8 -8
- package/tests/client/boxed-locals.test.tsrx +452 -0
- package/tests/client/compiler/__snapshots__/compiler.assignments.test.tsrx.snap +6 -6
- package/tests/client/compiler/compiler.assignments.test.tsrx +9 -73
- package/tests/client/compiler/compiler.attributes.test.tsrx +23 -23
- package/tests/client/compiler/compiler.basic.test.tsrx +15 -60
- package/tests/client/compiler/compiler.tracked-access.test.tsrx +18 -43
- package/tests/client/compiler/compiler.try-in-function.test.tsrx +2 -2
- package/tests/client/composite/__snapshots__/composite.render.test.tsrx.snap +0 -1
- package/tests/client/composite/composite.dynamic-components.test.tsrx +77 -6
- package/tests/client/composite/composite.props.test.tsrx +149 -12
- package/tests/client/composite/composite.reactivity.test.tsrx +51 -52
- package/tests/client/composite/composite.render.test.tsrx +26 -9
- package/tests/client/css/scoped-styles.test.tsrx +8 -8
- package/tests/client/date.test.tsrx +42 -42
- package/tests/client/derived-release.test.tsrx +370 -0
- package/tests/client/dynamic-elements.test.tsrx +45 -45
- package/tests/client/events.test.tsrx +97 -71
- package/tests/client/for-selector.test.tsrx +14 -14
- package/tests/client/for-single-root-items.test.tsrx +118 -3
- package/tests/client/for.test.tsrx +332 -31
- package/tests/client/head.test.tsrx +19 -19
- package/tests/client/html.test.tsrx +11 -9
- package/tests/client/if-block.test.tsrx +80 -0
- package/tests/client/map.test.tsrx +16 -16
- package/tests/client/media-query.test.tsrx +7 -7
- package/tests/client/portal.test.tsrx +224 -26
- package/tests/client/primitive-text.test.tsrx +50 -0
- package/tests/client/prop-kind-switch.test.tsrx +141 -0
- package/tests/client/ref.test.tsrx +17 -17
- package/tests/client/return.test.tsrx +26 -3
- package/tests/client/root-boundary.test.tsrx +42 -0
- package/tests/client/scoped-flush.test.tsrx +8 -8
- package/tests/client/set.test.tsrx +6 -6
- package/tests/client/svg.test.tsrx +11 -11
- package/tests/client/switch.test.tsrx +44 -44
- package/tests/client/track-async-hydration.test.tsrx +4 -4
- package/tests/client/try.test.tsrx +151 -83
- package/tests/client/tsx.test.tsrx +43 -40
- package/tests/client/url/url.derived.test.tsrx +6 -6
- package/tests/client/url-search-params/url-search-params.derived.test.tsrx +8 -8
- package/tests/client/url-search-params/url-search-params.iteration.test.tsrx +10 -10
- package/tests/client/url-search-params/url-search-params.mutation.test.tsrx +10 -10
- package/tests/client/url-search-params/url-search-params.retrieval.test.tsrx +18 -18
- package/tests/client/url-search-params/url-search-params.serialization.test.tsrx +2 -2
- package/tests/hydration/basic.test.js +74 -1
- package/tests/hydration/build-components.js +22 -1
- package/tests/hydration/compiled/client/basic.js +1142 -713
- package/tests/hydration/compiled/client/composite.js +151 -100
- package/tests/hydration/compiled/client/events.js +184 -171
- package/tests/hydration/compiled/client/for.js +1472 -1132
- package/tests/hydration/compiled/client/fragment-cursor.js +2341 -0
- package/tests/hydration/compiled/client/head.js +254 -201
- package/tests/hydration/compiled/client/hmr.js +54 -41
- package/tests/hydration/compiled/client/html-in-template.js +54 -39
- package/tests/hydration/compiled/client/html.js +1633 -1263
- package/tests/hydration/compiled/client/if-children.js +420 -270
- package/tests/hydration/compiled/client/if-fragment-controlflow.js +363 -317
- package/tests/hydration/compiled/client/if.js +229 -219
- package/tests/hydration/compiled/client/mixed-control-flow.js +420 -404
- package/tests/hydration/compiled/client/nested-control-flow.js +1326 -1277
- package/tests/hydration/compiled/client/portal.js +87 -95
- package/tests/hydration/compiled/client/reactivity.js +135 -101
- package/tests/hydration/compiled/client/return.js +28 -19
- package/tests/hydration/compiled/client/streaming.js +390 -306
- package/tests/hydration/compiled/client/switch.js +258 -266
- package/tests/hydration/compiled/client/track-async-serialization.js +448 -280
- package/tests/hydration/compiled/client/try.js +173 -129
- package/tests/hydration/compiled/client/typed-text.js +71 -0
- package/tests/hydration/compiled/fixtures/money.js +10 -0
- package/tests/hydration/compiled/server/basic.js +123 -6
- package/tests/hydration/compiled/server/composite.js +16 -30
- package/tests/hydration/compiled/server/events.js +66 -18
- package/tests/hydration/compiled/server/for.js +117 -41
- package/tests/hydration/compiled/server/fragment-cursor.js +1687 -0
- package/tests/hydration/compiled/server/head.js +20 -20
- package/tests/hydration/compiled/server/hmr.js +2 -2
- package/tests/hydration/compiled/server/html.js +70 -238
- package/tests/hydration/compiled/server/if-children.js +107 -15
- package/tests/hydration/compiled/server/if.js +11 -15
- package/tests/hydration/compiled/server/mixed-control-flow.js +8 -8
- package/tests/hydration/compiled/server/portal.js +14 -22
- package/tests/hydration/compiled/server/reactivity.js +14 -14
- package/tests/hydration/compiled/server/streaming.js +19 -19
- package/tests/hydration/compiled/server/switch.js +8 -8
- package/tests/hydration/compiled/server/track-async-serialization.js +150 -23
- package/tests/hydration/compiled/server/try.js +8 -8
- package/tests/hydration/compiled/server/typed-text.js +17 -0
- package/tests/hydration/components/basic.tsrx +44 -8
- package/tests/hydration/components/composite.tsrx +2 -2
- package/tests/hydration/components/events.tsrx +25 -25
- package/tests/hydration/components/for.tsrx +115 -67
- package/tests/hydration/components/fragment-cursor.tsrx +650 -0
- package/tests/hydration/components/head.tsrx +16 -16
- package/tests/hydration/components/hmr.tsrx +2 -2
- package/tests/hydration/components/html.tsrx +7 -7
- package/tests/hydration/components/if-children.tsrx +72 -25
- package/tests/hydration/components/if.tsrx +18 -18
- package/tests/hydration/components/mixed-control-flow.tsrx +11 -11
- package/tests/hydration/components/portal.tsrx +3 -3
- package/tests/hydration/components/reactivity.tsrx +16 -16
- package/tests/hydration/components/streaming.tsrx +20 -20
- package/tests/hydration/components/switch.tsrx +20 -20
- package/tests/hydration/components/text-types.ts +4 -0
- package/tests/hydration/components/track-async-serialization.tsrx +80 -26
- package/tests/hydration/components/try.tsrx +8 -8
- package/tests/hydration/components/typed-text.tsrx +22 -0
- package/tests/hydration/fixtures/money.js +10 -0
- package/tests/hydration/for.test.js +36 -0
- package/tests/hydration/fragment-cursor.test.js +111 -0
- package/tests/hydration/if-children.test.js +24 -0
- package/tests/hydration/streaming.test.js +19 -0
- package/tests/hydration/track-async-serialization.test.js +87 -2
- package/tests/hydration/tsconfig.text-types.json +10 -0
- package/tests/hydration/typed-text.test.js +34 -0
- package/tests/server/await.test.tsrx +3 -3
- package/tests/server/basic.attributes.test.tsrx +42 -42
- package/tests/server/basic.components.test.tsrx +64 -8
- package/tests/server/basic.test.tsrx +34 -32
- package/tests/server/compiler.test.tsrx +1 -70
- package/tests/server/composite.props.test.tsrx +6 -6
- package/tests/server/dynamic-elements.test.tsrx +31 -8
- package/tests/server/for.test.tsrx +94 -0
- package/tests/server/head.test.tsrx +11 -11
- package/tests/server/scoped-styles.test.tsrx +2 -2
- package/tests/server/streaming-ssr.test.tsrx +48 -43
- package/tests/server/track-async-serialization.test.tsrx +204 -21
- package/tests/server/try.test.tsrx +48 -48
- package/tests/types/transport.ts +40 -0
- package/tests/utils/vite-plugin-config.test.js +23 -0
- package/types/index.d.ts +48 -7
- package/types/server.d.ts +3 -0
- package/types/transport.d.ts +15 -0
- package/src/runtime/internal/client/switch.js +0 -113
- package/src/utils/errors.js +0 -13
- package/tests/client/lazy-array.test.tsrx +0 -31
- package/tests/client/lazy-destructuring.test.tsrx +0 -438
- package/tests/client/tracked-index-access.test.tsrx +0 -113
- package/tests/server/lazy-destructuring.test.tsrx +0 -595
- package/tests/server/tracked-index-access.test.tsrx +0 -76
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import * as _$_ from 'ripple/internal/server';
|
|
3
3
|
|
|
4
|
-
export function Layout(
|
|
4
|
+
export function Layout({ children }) {
|
|
5
5
|
return _$_.tsrx_element(() => {
|
|
6
6
|
_$_.regular_block(() => {
|
|
7
7
|
let __out = '';
|
|
@@ -11,7 +11,7 @@ export function Layout(__props) {
|
|
|
11
11
|
{
|
|
12
12
|
_$_.output_push(__out);
|
|
13
13
|
__out = '';
|
|
14
|
-
_$_.render_expression(
|
|
14
|
+
_$_.render_expression(children);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
__out += '</div>';
|
|
@@ -20,7 +20,7 @@ export function Layout(__props) {
|
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export function TextWrappedLayout(
|
|
23
|
+
export function TextWrappedLayout({ children }) {
|
|
24
24
|
return _$_.tsrx_element(() => {
|
|
25
25
|
_$_.regular_block(() => {
|
|
26
26
|
let __out = '';
|
|
@@ -28,7 +28,7 @@ export function TextWrappedLayout(__props) {
|
|
|
28
28
|
__out += '<div class="layout">before';
|
|
29
29
|
_$_.output_push(__out);
|
|
30
30
|
__out = '';
|
|
31
|
-
_$_.render_expression(
|
|
31
|
+
_$_.render_expression(children);
|
|
32
32
|
__out += 'after</div>';
|
|
33
33
|
_$_.output_push(__out);
|
|
34
34
|
});
|
|
@@ -190,26 +190,17 @@ export function DynamicTagElement() {
|
|
|
190
190
|
const Tag = 'section';
|
|
191
191
|
|
|
192
192
|
_$_.regular_block(() => {
|
|
193
|
-
{
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
__out += 'hello';
|
|
205
|
-
_$_.output_push(__out);
|
|
206
|
-
});
|
|
207
|
-
})
|
|
208
|
-
}
|
|
209
|
-
];
|
|
210
|
-
|
|
211
|
-
_$_.render_component(comp, ...args);
|
|
212
|
-
}
|
|
193
|
+
_$_.dynamic_element(Tag, {
|
|
194
|
+
class: "host",
|
|
195
|
+
children: _$_.tsrx_element(() => {
|
|
196
|
+
return _$_.tsrx_element(() => {
|
|
197
|
+
let __out = '';
|
|
198
|
+
|
|
199
|
+
__out += 'hello';
|
|
200
|
+
_$_.output_push(__out);
|
|
201
|
+
});
|
|
202
|
+
})
|
|
203
|
+
});
|
|
213
204
|
});
|
|
214
205
|
});
|
|
215
206
|
}
|
|
@@ -226,12 +217,7 @@ export function DynamicTagComponent() {
|
|
|
226
217
|
{
|
|
227
218
|
children: _$_.tsrx_element(() => {
|
|
228
219
|
return _$_.tsrx_element(() => {
|
|
229
|
-
{
|
|
230
|
-
const comp = _$_.dynamic_element;
|
|
231
|
-
const args = [{ is: Comp }];
|
|
232
|
-
|
|
233
|
-
_$_.render_component(comp, ...args);
|
|
234
|
-
}
|
|
220
|
+
_$_.dynamic_element(Comp, {});
|
|
235
221
|
});
|
|
236
222
|
})
|
|
237
223
|
}
|
|
@@ -5,12 +5,20 @@ import { track } from 'ripple/server';
|
|
|
5
5
|
|
|
6
6
|
export function ClickCounter() {
|
|
7
7
|
return _$_.tsrx_element(() => {
|
|
8
|
-
|
|
8
|
+
const count = _$_.track(0, 'a070e3a7');
|
|
9
9
|
|
|
10
10
|
_$_.regular_block(() => {
|
|
11
11
|
let __out = '';
|
|
12
12
|
|
|
13
|
-
__out += '<div><button class="increment">Increment</button><span class="count">'
|
|
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>';
|
|
14
22
|
_$_.output_push(__out);
|
|
15
23
|
});
|
|
16
24
|
});
|
|
@@ -18,12 +26,20 @@ export function ClickCounter() {
|
|
|
18
26
|
|
|
19
27
|
export function IncrementDecrement() {
|
|
20
28
|
return _$_.tsrx_element(() => {
|
|
21
|
-
|
|
29
|
+
const count = _$_.track(0, '87fcabdd');
|
|
22
30
|
|
|
23
31
|
_$_.regular_block(() => {
|
|
24
32
|
let __out = '';
|
|
25
33
|
|
|
26
|
-
__out += '<div><button class="decrement">-</button><span class="count">'
|
|
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>';
|
|
27
43
|
_$_.output_push(__out);
|
|
28
44
|
});
|
|
29
45
|
});
|
|
@@ -31,13 +47,29 @@ export function IncrementDecrement() {
|
|
|
31
47
|
|
|
32
48
|
export function MultipleEvents() {
|
|
33
49
|
return _$_.tsrx_element(() => {
|
|
34
|
-
|
|
35
|
-
|
|
50
|
+
const clicks = _$_.track(0, '41b9f0b0');
|
|
51
|
+
const hovers = _$_.track(0, '72789f75');
|
|
36
52
|
|
|
37
53
|
_$_.regular_block(() => {
|
|
38
54
|
let __out = '';
|
|
39
55
|
|
|
40
|
-
__out += '<div><button class="target">Target</button><span class="clicks">'
|
|
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>';
|
|
41
73
|
_$_.output_push(__out);
|
|
42
74
|
});
|
|
43
75
|
});
|
|
@@ -45,23 +77,31 @@ export function MultipleEvents() {
|
|
|
45
77
|
|
|
46
78
|
export function MultiStateUpdate() {
|
|
47
79
|
return _$_.tsrx_element(() => {
|
|
48
|
-
|
|
49
|
-
|
|
80
|
+
const count = _$_.track(0, '5a375160');
|
|
81
|
+
const lastAction = _$_.track('none', '3ceeb88c');
|
|
50
82
|
|
|
51
83
|
const handleClick = () => {
|
|
52
|
-
|
|
53
|
-
|
|
84
|
+
count.value++;
|
|
85
|
+
lastAction.value = 'increment';
|
|
54
86
|
};
|
|
55
87
|
|
|
56
88
|
_$_.regular_block(() => {
|
|
57
89
|
let __out = '';
|
|
58
90
|
|
|
59
|
-
__out += '<div><button class="btn">Click</button><span class="count">'
|
|
91
|
+
__out += '<div><button class="btn">Click</button><span class="count">';
|
|
60
92
|
|
|
61
93
|
{
|
|
62
94
|
_$_.output_push(__out);
|
|
63
95
|
__out = '';
|
|
64
|
-
_$_.render_expression(
|
|
96
|
+
_$_.render_expression(count.value);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
__out += '</span><span class="action">';
|
|
100
|
+
|
|
101
|
+
{
|
|
102
|
+
_$_.output_push(__out);
|
|
103
|
+
__out = '';
|
|
104
|
+
_$_.render_expression(lastAction.value);
|
|
65
105
|
}
|
|
66
106
|
|
|
67
107
|
__out += '</span></div>';
|
|
@@ -72,12 +112,12 @@ export function MultiStateUpdate() {
|
|
|
72
112
|
|
|
73
113
|
export function ToggleButton() {
|
|
74
114
|
return _$_.tsrx_element(() => {
|
|
75
|
-
|
|
115
|
+
const isOn = _$_.track(false, 'be823ec7');
|
|
76
116
|
|
|
77
117
|
_$_.regular_block(() => {
|
|
78
118
|
let __out = '';
|
|
79
119
|
|
|
80
|
-
__out += '<div><button class="toggle">' + _$_.escape(
|
|
120
|
+
__out += '<div><button class="toggle">' + _$_.escape(isOn.value ? 'ON' : 'OFF') + '</button></div>';
|
|
81
121
|
_$_.output_push(__out);
|
|
82
122
|
});
|
|
83
123
|
});
|
|
@@ -96,7 +136,7 @@ export function ChildButton(props) {
|
|
|
96
136
|
|
|
97
137
|
export function ParentWithChildButton() {
|
|
98
138
|
return _$_.tsrx_element(() => {
|
|
99
|
-
|
|
139
|
+
const count = _$_.track(0, 'dcc2e0f9');
|
|
100
140
|
|
|
101
141
|
_$_.regular_block(() => {
|
|
102
142
|
let __out = '';
|
|
@@ -109,7 +149,7 @@ export function ParentWithChildButton() {
|
|
|
109
149
|
const args = [
|
|
110
150
|
{
|
|
111
151
|
onClick: () => {
|
|
112
|
-
|
|
152
|
+
count.value++;
|
|
113
153
|
},
|
|
114
154
|
label: "Click me"
|
|
115
155
|
}
|
|
@@ -120,7 +160,15 @@ export function ParentWithChildButton() {
|
|
|
120
160
|
_$_.render_component(comp, ...args);
|
|
121
161
|
}
|
|
122
162
|
|
|
123
|
-
__out += '<span class="count">'
|
|
163
|
+
__out += '<span class="count">';
|
|
164
|
+
|
|
165
|
+
{
|
|
166
|
+
_$_.output_push(__out);
|
|
167
|
+
__out = '';
|
|
168
|
+
_$_.render_expression(count.value);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
__out += '</span></div>';
|
|
124
172
|
_$_.output_push(__out);
|
|
125
173
|
});
|
|
126
174
|
});
|
|
@@ -91,14 +91,14 @@ export function KeyedForLoop() {
|
|
|
91
91
|
|
|
92
92
|
export function ReactiveForLoopAdd() {
|
|
93
93
|
return _$_.tsrx_element(() => {
|
|
94
|
-
|
|
94
|
+
const items = _$_.track(['A', 'B'], 'e145678a');
|
|
95
95
|
|
|
96
96
|
_$_.regular_block(() => {
|
|
97
97
|
let __out = '';
|
|
98
98
|
|
|
99
99
|
__out += '<button class="add">Add</button><ul><!--[-->';
|
|
100
100
|
|
|
101
|
-
for (const item of
|
|
101
|
+
for (const item of items.value) {
|
|
102
102
|
__out += '<li>';
|
|
103
103
|
|
|
104
104
|
{
|
|
@@ -118,14 +118,14 @@ export function ReactiveForLoopAdd() {
|
|
|
118
118
|
|
|
119
119
|
export function ReactiveForLoopRemove() {
|
|
120
120
|
return _$_.tsrx_element(() => {
|
|
121
|
-
|
|
121
|
+
const items = _$_.track(['A', 'B', 'C'], 'b4e9bd54');
|
|
122
122
|
|
|
123
123
|
_$_.regular_block(() => {
|
|
124
124
|
let __out = '';
|
|
125
125
|
|
|
126
126
|
__out += '<button class="remove">Remove</button><ul><!--[-->';
|
|
127
127
|
|
|
128
|
-
for (const item of
|
|
128
|
+
for (const item of items.value) {
|
|
129
129
|
__out += '<li>';
|
|
130
130
|
|
|
131
131
|
{
|
|
@@ -145,7 +145,7 @@ export function ReactiveForLoopRemove() {
|
|
|
145
145
|
|
|
146
146
|
export function ForLoopInteractive() {
|
|
147
147
|
return _$_.tsrx_element(() => {
|
|
148
|
-
|
|
148
|
+
const counts = _$_.track([0, 0, 0], '36f563df');
|
|
149
149
|
|
|
150
150
|
_$_.regular_block(() => {
|
|
151
151
|
let __out = '';
|
|
@@ -157,7 +157,7 @@ export function ForLoopInteractive() {
|
|
|
157
157
|
|
|
158
158
|
var i = 0;
|
|
159
159
|
|
|
160
|
-
for (const count of
|
|
160
|
+
for (const count of counts.value) {
|
|
161
161
|
__out += '<div' + _$_.attr('class', `item-${i}`) + '><span class="value">';
|
|
162
162
|
|
|
163
163
|
{
|
|
@@ -289,7 +289,7 @@ export function ForLoopComplexObjects() {
|
|
|
289
289
|
|
|
290
290
|
export function KeyedForLoopReorder() {
|
|
291
291
|
return _$_.tsrx_element(() => {
|
|
292
|
-
|
|
292
|
+
const items = _$_.track(
|
|
293
293
|
[
|
|
294
294
|
{ id: 1, name: 'First' },
|
|
295
295
|
{ id: 2, name: 'Second' },
|
|
@@ -303,7 +303,7 @@ export function KeyedForLoopReorder() {
|
|
|
303
303
|
|
|
304
304
|
__out += '<button class="reorder">Reorder</button><ul><!--[-->';
|
|
305
305
|
|
|
306
|
-
for (const item of
|
|
306
|
+
for (const item of items.value) {
|
|
307
307
|
__out += '<li' + _$_.attr('class', `item-${item.id}`) + '>';
|
|
308
308
|
|
|
309
309
|
{
|
|
@@ -323,14 +323,14 @@ export function KeyedForLoopReorder() {
|
|
|
323
323
|
|
|
324
324
|
export function KeyedForLoopUpdate() {
|
|
325
325
|
return _$_.tsrx_element(() => {
|
|
326
|
-
|
|
326
|
+
const items = _$_.track([{ id: 1, name: 'Item 1' }, { id: 2, name: 'Item 2' }], '7a2c2ada');
|
|
327
327
|
|
|
328
328
|
_$_.regular_block(() => {
|
|
329
329
|
let __out = '';
|
|
330
330
|
|
|
331
331
|
__out += '<button class="update">Update</button><ul><!--[-->';
|
|
332
332
|
|
|
333
|
-
for (const item of
|
|
333
|
+
for (const item of items.value) {
|
|
334
334
|
__out += '<li' + _$_.attr('class', `item-${item.id}`) + '>';
|
|
335
335
|
|
|
336
336
|
{
|
|
@@ -350,14 +350,14 @@ export function KeyedForLoopUpdate() {
|
|
|
350
350
|
|
|
351
351
|
export function ForLoopMixedOperations() {
|
|
352
352
|
return _$_.tsrx_element(() => {
|
|
353
|
-
|
|
353
|
+
const items = _$_.track(['A', 'B', 'C', 'D'], '3dd7c7b6');
|
|
354
354
|
|
|
355
355
|
_$_.regular_block(() => {
|
|
356
356
|
let __out = '';
|
|
357
357
|
|
|
358
358
|
__out += '<button class="shuffle">Shuffle</button><ul><!--[-->';
|
|
359
359
|
|
|
360
|
-
for (const item of
|
|
360
|
+
for (const item of items.value) {
|
|
361
361
|
__out += '<li' + _$_.attr('class', `item-${item}`) + '>';
|
|
362
362
|
|
|
363
363
|
{
|
|
@@ -377,18 +377,18 @@ export function ForLoopMixedOperations() {
|
|
|
377
377
|
|
|
378
378
|
export function ForLoopInsideIf() {
|
|
379
379
|
return _$_.tsrx_element(() => {
|
|
380
|
-
|
|
381
|
-
|
|
380
|
+
const showList = _$_.track(true, '0528df30');
|
|
381
|
+
const items = _$_.track(['X', 'Y', 'Z'], 'bf375103');
|
|
382
382
|
|
|
383
383
|
_$_.regular_block(() => {
|
|
384
384
|
let __out = '';
|
|
385
385
|
|
|
386
386
|
__out += '<button class="toggle">Toggle List</button><button class="add">Add Item</button><!--[-->';
|
|
387
387
|
|
|
388
|
-
if (
|
|
388
|
+
if (showList.value) {
|
|
389
389
|
__out += '<ul class="list"><!--[-->';
|
|
390
390
|
|
|
391
|
-
for (const item of
|
|
391
|
+
for (const item of items.value) {
|
|
392
392
|
__out += '<li>';
|
|
393
393
|
|
|
394
394
|
{
|
|
@@ -411,15 +411,23 @@ export function ForLoopInsideIf() {
|
|
|
411
411
|
|
|
412
412
|
export function ForLoopEmptyToPopulated() {
|
|
413
413
|
return _$_.tsrx_element(() => {
|
|
414
|
-
|
|
414
|
+
const items = _$_.track([], '525c5dbc');
|
|
415
415
|
|
|
416
416
|
_$_.regular_block(() => {
|
|
417
417
|
let __out = '';
|
|
418
418
|
|
|
419
419
|
__out += '<button class="populate">Populate</button><ul class="list"><!--[-->';
|
|
420
420
|
|
|
421
|
-
for (const item of
|
|
422
|
-
__out += '<li>'
|
|
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>';
|
|
423
431
|
}
|
|
424
432
|
|
|
425
433
|
__out += '<!--]--></ul>';
|
|
@@ -430,14 +438,14 @@ export function ForLoopEmptyToPopulated() {
|
|
|
430
438
|
|
|
431
439
|
export function ForLoopPopulatedToEmpty() {
|
|
432
440
|
return _$_.tsrx_element(() => {
|
|
433
|
-
|
|
441
|
+
const items = _$_.track(['One', 'Two', 'Three'], 'ee47f078');
|
|
434
442
|
|
|
435
443
|
_$_.regular_block(() => {
|
|
436
444
|
let __out = '';
|
|
437
445
|
|
|
438
446
|
__out += '<button class="clear">Clear</button><ul class="list"><!--[-->';
|
|
439
447
|
|
|
440
|
-
for (const item of
|
|
448
|
+
for (const item of items.value) {
|
|
441
449
|
__out += '<li>';
|
|
442
450
|
|
|
443
451
|
{
|
|
@@ -457,7 +465,7 @@ export function ForLoopPopulatedToEmpty() {
|
|
|
457
465
|
|
|
458
466
|
export function NestedForLoopReactive() {
|
|
459
467
|
return _$_.tsrx_element(() => {
|
|
460
|
-
|
|
468
|
+
const grid = _$_.track([[1, 2], [3, 4]], 'a2f41fb3');
|
|
461
469
|
|
|
462
470
|
_$_.regular_block(() => {
|
|
463
471
|
let __out = '';
|
|
@@ -469,7 +477,7 @@ export function NestedForLoopReactive() {
|
|
|
469
477
|
|
|
470
478
|
var rowIndex = 0;
|
|
471
479
|
|
|
472
|
-
for (const row of
|
|
480
|
+
for (const row of grid.value) {
|
|
473
481
|
__out += '<div' + _$_.attr('class', `row-${rowIndex}`) + '>';
|
|
474
482
|
|
|
475
483
|
{
|
|
@@ -578,7 +586,7 @@ export function ForLoopDeeplyNested() {
|
|
|
578
586
|
|
|
579
587
|
export function ForLoopIndexUpdate() {
|
|
580
588
|
return _$_.tsrx_element(() => {
|
|
581
|
-
|
|
589
|
+
const items = _$_.track(['First', 'Second', 'Third'], 'f61e31e6');
|
|
582
590
|
|
|
583
591
|
_$_.regular_block(() => {
|
|
584
592
|
let __out = '';
|
|
@@ -590,7 +598,7 @@ export function ForLoopIndexUpdate() {
|
|
|
590
598
|
|
|
591
599
|
var i = 0;
|
|
592
600
|
|
|
593
|
-
for (const item of
|
|
601
|
+
for (const item of items.value) {
|
|
594
602
|
__out += '<li' + _$_.attr('class', `item-${i}`) + '>' + _$_.escape(`[${i}] ${item}`) + '</li>';
|
|
595
603
|
i++;
|
|
596
604
|
}
|
|
@@ -606,7 +614,7 @@ export function ForLoopIndexUpdate() {
|
|
|
606
614
|
|
|
607
615
|
export function KeyedForLoopWithIndex() {
|
|
608
616
|
return _$_.tsrx_element(() => {
|
|
609
|
-
|
|
617
|
+
const items = _$_.track(
|
|
610
618
|
[
|
|
611
619
|
{ id: 'a', value: 'Alpha' },
|
|
612
620
|
{ id: 'b', value: 'Beta' },
|
|
@@ -625,7 +633,7 @@ export function KeyedForLoopWithIndex() {
|
|
|
625
633
|
|
|
626
634
|
var i = 0;
|
|
627
635
|
|
|
628
|
-
for (const item of
|
|
636
|
+
for (const item of items.value) {
|
|
629
637
|
__out += '<li' + _$_.attr('data-index', i, false) + _$_.attr('class', `item-${item.id}`) + '>' + _$_.escape(`[${i}] ${item.id}: ${item.value}`) + '</li>';
|
|
630
638
|
i++;
|
|
631
639
|
}
|
|
@@ -641,14 +649,14 @@ export function KeyedForLoopWithIndex() {
|
|
|
641
649
|
|
|
642
650
|
export function ForLoopWithSiblings() {
|
|
643
651
|
return _$_.tsrx_element(() => {
|
|
644
|
-
|
|
652
|
+
const items = _$_.track(['A', 'B'], '3c7e8152');
|
|
645
653
|
|
|
646
654
|
_$_.regular_block(() => {
|
|
647
655
|
let __out = '';
|
|
648
656
|
|
|
649
657
|
__out += '<div class="wrapper"><header class="before">Before</header><!--[-->';
|
|
650
658
|
|
|
651
|
-
for (const item of
|
|
659
|
+
for (const item of items.value) {
|
|
652
660
|
__out += '<div' + _$_.attr('class', `item-${item}`) + '>';
|
|
653
661
|
|
|
654
662
|
{
|
|
@@ -698,12 +706,12 @@ export function ForLoopItemState() {
|
|
|
698
706
|
|
|
699
707
|
function TodoItem(props) {
|
|
700
708
|
return _$_.tsrx_element(() => {
|
|
701
|
-
|
|
709
|
+
const done = _$_.track(false, '4f2402a4');
|
|
702
710
|
|
|
703
711
|
_$_.regular_block(() => {
|
|
704
712
|
let __out = '';
|
|
705
713
|
|
|
706
|
-
__out += '<div' + _$_.attr('class', `todo-${props.id}`) + '><input type="checkbox"' + _$_.attr('checked',
|
|
714
|
+
__out += '<div' + _$_.attr('class', `todo-${props.id}`) + '><input type="checkbox"' + _$_.attr('checked', done.value, true) + ' class="checkbox" /><span' + _$_.attr('class', done.value ? 'completed' : 'pending') + '>' + _$_.escape(props.text) + '</span></div>';
|
|
707
715
|
_$_.output_push(__out);
|
|
708
716
|
});
|
|
709
717
|
});
|
|
@@ -738,14 +746,14 @@ export function ForLoopSingleItem() {
|
|
|
738
746
|
|
|
739
747
|
export function ForLoopAddAtBeginning() {
|
|
740
748
|
return _$_.tsrx_element(() => {
|
|
741
|
-
|
|
749
|
+
const items = _$_.track(['B', 'C'], '1561403a');
|
|
742
750
|
|
|
743
751
|
_$_.regular_block(() => {
|
|
744
752
|
let __out = '';
|
|
745
753
|
|
|
746
754
|
__out += '<button class="prepend">Prepend A</button><ul><!--[-->';
|
|
747
755
|
|
|
748
|
-
for (const item of
|
|
756
|
+
for (const item of items.value) {
|
|
749
757
|
__out += '<li' + _$_.attr('class', `item-${item}`) + '>';
|
|
750
758
|
|
|
751
759
|
{
|
|
@@ -765,14 +773,14 @@ export function ForLoopAddAtBeginning() {
|
|
|
765
773
|
|
|
766
774
|
export function ForLoopAddInMiddle() {
|
|
767
775
|
return _$_.tsrx_element(() => {
|
|
768
|
-
|
|
776
|
+
const items = _$_.track(['A', 'C'], '1bc60b46');
|
|
769
777
|
|
|
770
778
|
_$_.regular_block(() => {
|
|
771
779
|
let __out = '';
|
|
772
780
|
|
|
773
781
|
__out += '<button class="insert">Insert B</button><ul><!--[-->';
|
|
774
782
|
|
|
775
|
-
for (const item of
|
|
783
|
+
for (const item of items.value) {
|
|
776
784
|
__out += '<li' + _$_.attr('class', `item-${item}`) + '>';
|
|
777
785
|
|
|
778
786
|
{
|
|
@@ -792,14 +800,14 @@ export function ForLoopAddInMiddle() {
|
|
|
792
800
|
|
|
793
801
|
export function ForLoopRemoveFromMiddle() {
|
|
794
802
|
return _$_.tsrx_element(() => {
|
|
795
|
-
|
|
803
|
+
const items = _$_.track(['A', 'B', 'C'], '1c87f95f');
|
|
796
804
|
|
|
797
805
|
_$_.regular_block(() => {
|
|
798
806
|
let __out = '';
|
|
799
807
|
|
|
800
808
|
__out += '<button class="remove-middle">Remove B</button><ul><!--[-->';
|
|
801
809
|
|
|
802
|
-
for (const item of
|
|
810
|
+
for (const item of items.value) {
|
|
803
811
|
__out += '<li' + _$_.attr('class', `item-${item}`) + '>';
|
|
804
812
|
|
|
805
813
|
{
|
|
@@ -855,14 +863,14 @@ export function ForLoopLargeList() {
|
|
|
855
863
|
|
|
856
864
|
export function ForLoopSwap() {
|
|
857
865
|
return _$_.tsrx_element(() => {
|
|
858
|
-
|
|
866
|
+
const items = _$_.track(['A', 'B', 'C', 'D'], '5f8d152f');
|
|
859
867
|
|
|
860
868
|
_$_.regular_block(() => {
|
|
861
869
|
let __out = '';
|
|
862
870
|
|
|
863
871
|
__out += '<button class="swap">Swap First and Last</button><ul><!--[-->';
|
|
864
872
|
|
|
865
|
-
for (const item of
|
|
873
|
+
for (const item of items.value) {
|
|
866
874
|
__out += '<li' + _$_.attr('class', `item-${item}`) + '>';
|
|
867
875
|
|
|
868
876
|
{
|
|
@@ -882,14 +890,14 @@ export function ForLoopSwap() {
|
|
|
882
890
|
|
|
883
891
|
export function ForLoopReverse() {
|
|
884
892
|
return _$_.tsrx_element(() => {
|
|
885
|
-
|
|
893
|
+
const items = _$_.track(['A', 'B', 'C', 'D'], '24602e64');
|
|
886
894
|
|
|
887
895
|
_$_.regular_block(() => {
|
|
888
896
|
let __out = '';
|
|
889
897
|
|
|
890
898
|
__out += '<button class="reverse">Reverse</button><ul><!--[-->';
|
|
891
899
|
|
|
892
|
-
for (const item of
|
|
900
|
+
for (const item of items.value) {
|
|
893
901
|
__out += '<li' + _$_.attr('class', `item-${item}`) + '>';
|
|
894
902
|
|
|
895
903
|
{
|
|
@@ -905,4 +913,72 @@ export function ForLoopReverse() {
|
|
|
905
913
|
_$_.output_push(__out);
|
|
906
914
|
});
|
|
907
915
|
});
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
export function KeyedForLoopAppendAndRotate() {
|
|
919
|
+
return _$_.tsrx_element(() => {
|
|
920
|
+
const items = _$_.track([1, 2, 3], 'a8b41504');
|
|
921
|
+
|
|
922
|
+
_$_.regular_block(() => {
|
|
923
|
+
let __out = '';
|
|
924
|
+
|
|
925
|
+
__out += '<div class="wrapper"><div class="host"><!--[-->';
|
|
926
|
+
|
|
927
|
+
for (const item of items.value) {
|
|
928
|
+
__out += '<span class="item">';
|
|
929
|
+
|
|
930
|
+
{
|
|
931
|
+
_$_.output_push(__out);
|
|
932
|
+
__out = '';
|
|
933
|
+
_$_.render_expression(item);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
__out += '</span>';
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
__out += '<!--]--><p class="tail">p</p></div><button class="push">Push</button><button class="rotate">Rotate</button></div>';
|
|
940
|
+
_$_.output_push(__out);
|
|
941
|
+
});
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
function RootKeyedList(props) {
|
|
946
|
+
return _$_.tsrx_element(() => {
|
|
947
|
+
_$_.regular_block(() => {
|
|
948
|
+
let __out = '';
|
|
949
|
+
|
|
950
|
+
__out += '<!--[-->';
|
|
951
|
+
|
|
952
|
+
for (const item of props.items.value) {
|
|
953
|
+
__out += '<span class="item">' + _$_.escape(item) + '</span>';
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
__out += '<!--]-->';
|
|
957
|
+
_$_.output_push(__out);
|
|
958
|
+
});
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
export function RootKeyedForLoopAppendAndRotate() {
|
|
963
|
+
return _$_.tsrx_element(() => {
|
|
964
|
+
const items = _$_.track([1, 2, 3], '50a91d60');
|
|
965
|
+
|
|
966
|
+
_$_.regular_block(() => {
|
|
967
|
+
let __out = '';
|
|
968
|
+
|
|
969
|
+
__out += '<div class="wrapper"><div class="host">';
|
|
970
|
+
|
|
971
|
+
{
|
|
972
|
+
const comp = RootKeyedList;
|
|
973
|
+
const args = [{ items }];
|
|
974
|
+
|
|
975
|
+
_$_.output_push(__out);
|
|
976
|
+
__out = '';
|
|
977
|
+
_$_.render_component(comp, ...args);
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
__out += '<p class="tail">p</p></div><button class="push">Push</button><button class="rotate">Rotate</button></div>';
|
|
981
|
+
_$_.output_push(__out);
|
|
982
|
+
});
|
|
983
|
+
});
|
|
908
984
|
}
|