ripple 0.3.127 → 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 +293 -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 +192 -114
- 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 +14 -5
- 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 +185 -124
- package/src/runtime/internal/client/for.js +616 -264
- 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 +9 -13
- package/src/runtime/internal/client/operations.js +44 -51
- package/src/runtime/internal/client/portal.js +163 -85
- package/src/runtime/internal/client/render.js +44 -25
- package/src/runtime/internal/client/rpc.js +3 -3
- package/src/runtime/internal/client/runtime.js +799 -576
- package/src/runtime/internal/client/selector.js +77 -0
- 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 +65 -21
- 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 +327 -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 +97 -29
- 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 +221 -0
- 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 +190 -150
- package/tests/hydration/compiled/client/for.js +1472 -1126
- package/tests/hydration/compiled/client/fragment-cursor.js +2341 -0
- package/tests/hydration/compiled/client/head.js +255 -199
- 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 -400
- package/tests/hydration/compiled/client/nested-control-flow.js +1326 -1255
- package/tests/hydration/compiled/client/portal.js +87 -95
- package/tests/hydration/compiled/client/reactivity.js +140 -83
- 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 +19 -19
- package/tests/hydration/compiled/server/for.js +109 -49
- package/tests/hydration/compiled/server/fragment-cursor.js +1687 -0
- package/tests/hydration/compiled/server/head.js +20 -28
- package/tests/hydration/compiled/server/hmr.js +2 -2
- package/tests/hydration/compiled/server/html.js +71 -247
- 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 -46
- 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,7 +5,7 @@ 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 = '';
|
|
@@ -15,7 +15,7 @@ export function ClickCounter() {
|
|
|
15
15
|
{
|
|
16
16
|
_$_.output_push(__out);
|
|
17
17
|
__out = '';
|
|
18
|
-
_$_.render_expression(
|
|
18
|
+
_$_.render_expression(count.value);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
__out += '</span></div>';
|
|
@@ -26,7 +26,7 @@ export function ClickCounter() {
|
|
|
26
26
|
|
|
27
27
|
export function IncrementDecrement() {
|
|
28
28
|
return _$_.tsrx_element(() => {
|
|
29
|
-
|
|
29
|
+
const count = _$_.track(0, '87fcabdd');
|
|
30
30
|
|
|
31
31
|
_$_.regular_block(() => {
|
|
32
32
|
let __out = '';
|
|
@@ -36,7 +36,7 @@ export function IncrementDecrement() {
|
|
|
36
36
|
{
|
|
37
37
|
_$_.output_push(__out);
|
|
38
38
|
__out = '';
|
|
39
|
-
_$_.render_expression(
|
|
39
|
+
_$_.render_expression(count.value);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
__out += '</span><button class="increment">+</button></div>';
|
|
@@ -47,8 +47,8 @@ export function IncrementDecrement() {
|
|
|
47
47
|
|
|
48
48
|
export function MultipleEvents() {
|
|
49
49
|
return _$_.tsrx_element(() => {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
const clicks = _$_.track(0, '41b9f0b0');
|
|
51
|
+
const hovers = _$_.track(0, '72789f75');
|
|
52
52
|
|
|
53
53
|
_$_.regular_block(() => {
|
|
54
54
|
let __out = '';
|
|
@@ -58,7 +58,7 @@ export function MultipleEvents() {
|
|
|
58
58
|
{
|
|
59
59
|
_$_.output_push(__out);
|
|
60
60
|
__out = '';
|
|
61
|
-
_$_.render_expression(
|
|
61
|
+
_$_.render_expression(clicks.value);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
__out += '</span><span class="hovers">';
|
|
@@ -66,7 +66,7 @@ export function MultipleEvents() {
|
|
|
66
66
|
{
|
|
67
67
|
_$_.output_push(__out);
|
|
68
68
|
__out = '';
|
|
69
|
-
_$_.render_expression(
|
|
69
|
+
_$_.render_expression(hovers.value);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
__out += '</span></div>';
|
|
@@ -77,12 +77,12 @@ export function MultipleEvents() {
|
|
|
77
77
|
|
|
78
78
|
export function MultiStateUpdate() {
|
|
79
79
|
return _$_.tsrx_element(() => {
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
const count = _$_.track(0, '5a375160');
|
|
81
|
+
const lastAction = _$_.track('none', '3ceeb88c');
|
|
82
82
|
|
|
83
83
|
const handleClick = () => {
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
count.value++;
|
|
85
|
+
lastAction.value = 'increment';
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
_$_.regular_block(() => {
|
|
@@ -93,7 +93,7 @@ export function MultiStateUpdate() {
|
|
|
93
93
|
{
|
|
94
94
|
_$_.output_push(__out);
|
|
95
95
|
__out = '';
|
|
96
|
-
_$_.render_expression(
|
|
96
|
+
_$_.render_expression(count.value);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
__out += '</span><span class="action">';
|
|
@@ -101,7 +101,7 @@ export function MultiStateUpdate() {
|
|
|
101
101
|
{
|
|
102
102
|
_$_.output_push(__out);
|
|
103
103
|
__out = '';
|
|
104
|
-
_$_.render_expression(
|
|
104
|
+
_$_.render_expression(lastAction.value);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
__out += '</span></div>';
|
|
@@ -112,12 +112,12 @@ export function MultiStateUpdate() {
|
|
|
112
112
|
|
|
113
113
|
export function ToggleButton() {
|
|
114
114
|
return _$_.tsrx_element(() => {
|
|
115
|
-
|
|
115
|
+
const isOn = _$_.track(false, 'be823ec7');
|
|
116
116
|
|
|
117
117
|
_$_.regular_block(() => {
|
|
118
118
|
let __out = '';
|
|
119
119
|
|
|
120
|
-
__out += '<div><button class="toggle">' + _$_.escape(
|
|
120
|
+
__out += '<div><button class="toggle">' + _$_.escape(isOn.value ? 'ON' : 'OFF') + '</button></div>';
|
|
121
121
|
_$_.output_push(__out);
|
|
122
122
|
});
|
|
123
123
|
});
|
|
@@ -136,7 +136,7 @@ export function ChildButton(props) {
|
|
|
136
136
|
|
|
137
137
|
export function ParentWithChildButton() {
|
|
138
138
|
return _$_.tsrx_element(() => {
|
|
139
|
-
|
|
139
|
+
const count = _$_.track(0, 'dcc2e0f9');
|
|
140
140
|
|
|
141
141
|
_$_.regular_block(() => {
|
|
142
142
|
let __out = '';
|
|
@@ -149,7 +149,7 @@ export function ParentWithChildButton() {
|
|
|
149
149
|
const args = [
|
|
150
150
|
{
|
|
151
151
|
onClick: () => {
|
|
152
|
-
|
|
152
|
+
count.value++;
|
|
153
153
|
},
|
|
154
154
|
label: "Click me"
|
|
155
155
|
}
|
|
@@ -165,7 +165,7 @@ export function ParentWithChildButton() {
|
|
|
165
165
|
{
|
|
166
166
|
_$_.output_push(__out);
|
|
167
167
|
__out = '';
|
|
168
|
-
_$_.render_expression(
|
|
168
|
+
_$_.render_expression(count.value);
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
__out += '</span></div>';
|
|
@@ -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
|
{
|
|
@@ -240,15 +240,7 @@ export function EmptyForLoop() {
|
|
|
240
240
|
__out += '<div class="container"><!--[-->';
|
|
241
241
|
|
|
242
242
|
for (const item of items) {
|
|
243
|
-
__out += '<span>';
|
|
244
|
-
|
|
245
|
-
{
|
|
246
|
-
_$_.output_push(__out);
|
|
247
|
-
__out = '';
|
|
248
|
-
_$_.render_expression(item);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
__out += '</span>';
|
|
243
|
+
__out += '<span>' + _$_.escape(item) + '</span>';
|
|
252
244
|
}
|
|
253
245
|
|
|
254
246
|
__out += '<!--]--></div>';
|
|
@@ -297,7 +289,7 @@ export function ForLoopComplexObjects() {
|
|
|
297
289
|
|
|
298
290
|
export function KeyedForLoopReorder() {
|
|
299
291
|
return _$_.tsrx_element(() => {
|
|
300
|
-
|
|
292
|
+
const items = _$_.track(
|
|
301
293
|
[
|
|
302
294
|
{ id: 1, name: 'First' },
|
|
303
295
|
{ id: 2, name: 'Second' },
|
|
@@ -311,7 +303,7 @@ export function KeyedForLoopReorder() {
|
|
|
311
303
|
|
|
312
304
|
__out += '<button class="reorder">Reorder</button><ul><!--[-->';
|
|
313
305
|
|
|
314
|
-
for (const item of
|
|
306
|
+
for (const item of items.value) {
|
|
315
307
|
__out += '<li' + _$_.attr('class', `item-${item.id}`) + '>';
|
|
316
308
|
|
|
317
309
|
{
|
|
@@ -331,14 +323,14 @@ export function KeyedForLoopReorder() {
|
|
|
331
323
|
|
|
332
324
|
export function KeyedForLoopUpdate() {
|
|
333
325
|
return _$_.tsrx_element(() => {
|
|
334
|
-
|
|
326
|
+
const items = _$_.track([{ id: 1, name: 'Item 1' }, { id: 2, name: 'Item 2' }], '7a2c2ada');
|
|
335
327
|
|
|
336
328
|
_$_.regular_block(() => {
|
|
337
329
|
let __out = '';
|
|
338
330
|
|
|
339
331
|
__out += '<button class="update">Update</button><ul><!--[-->';
|
|
340
332
|
|
|
341
|
-
for (const item of
|
|
333
|
+
for (const item of items.value) {
|
|
342
334
|
__out += '<li' + _$_.attr('class', `item-${item.id}`) + '>';
|
|
343
335
|
|
|
344
336
|
{
|
|
@@ -358,14 +350,14 @@ export function KeyedForLoopUpdate() {
|
|
|
358
350
|
|
|
359
351
|
export function ForLoopMixedOperations() {
|
|
360
352
|
return _$_.tsrx_element(() => {
|
|
361
|
-
|
|
353
|
+
const items = _$_.track(['A', 'B', 'C', 'D'], '3dd7c7b6');
|
|
362
354
|
|
|
363
355
|
_$_.regular_block(() => {
|
|
364
356
|
let __out = '';
|
|
365
357
|
|
|
366
358
|
__out += '<button class="shuffle">Shuffle</button><ul><!--[-->';
|
|
367
359
|
|
|
368
|
-
for (const item of
|
|
360
|
+
for (const item of items.value) {
|
|
369
361
|
__out += '<li' + _$_.attr('class', `item-${item}`) + '>';
|
|
370
362
|
|
|
371
363
|
{
|
|
@@ -385,18 +377,18 @@ export function ForLoopMixedOperations() {
|
|
|
385
377
|
|
|
386
378
|
export function ForLoopInsideIf() {
|
|
387
379
|
return _$_.tsrx_element(() => {
|
|
388
|
-
|
|
389
|
-
|
|
380
|
+
const showList = _$_.track(true, '0528df30');
|
|
381
|
+
const items = _$_.track(['X', 'Y', 'Z'], 'bf375103');
|
|
390
382
|
|
|
391
383
|
_$_.regular_block(() => {
|
|
392
384
|
let __out = '';
|
|
393
385
|
|
|
394
386
|
__out += '<button class="toggle">Toggle List</button><button class="add">Add Item</button><!--[-->';
|
|
395
387
|
|
|
396
|
-
if (
|
|
388
|
+
if (showList.value) {
|
|
397
389
|
__out += '<ul class="list"><!--[-->';
|
|
398
390
|
|
|
399
|
-
for (const item of
|
|
391
|
+
for (const item of items.value) {
|
|
400
392
|
__out += '<li>';
|
|
401
393
|
|
|
402
394
|
{
|
|
@@ -419,14 +411,14 @@ export function ForLoopInsideIf() {
|
|
|
419
411
|
|
|
420
412
|
export function ForLoopEmptyToPopulated() {
|
|
421
413
|
return _$_.tsrx_element(() => {
|
|
422
|
-
|
|
414
|
+
const items = _$_.track([], '525c5dbc');
|
|
423
415
|
|
|
424
416
|
_$_.regular_block(() => {
|
|
425
417
|
let __out = '';
|
|
426
418
|
|
|
427
419
|
__out += '<button class="populate">Populate</button><ul class="list"><!--[-->';
|
|
428
420
|
|
|
429
|
-
for (const item of
|
|
421
|
+
for (const item of items.value) {
|
|
430
422
|
__out += '<li>';
|
|
431
423
|
|
|
432
424
|
{
|
|
@@ -446,14 +438,14 @@ export function ForLoopEmptyToPopulated() {
|
|
|
446
438
|
|
|
447
439
|
export function ForLoopPopulatedToEmpty() {
|
|
448
440
|
return _$_.tsrx_element(() => {
|
|
449
|
-
|
|
441
|
+
const items = _$_.track(['One', 'Two', 'Three'], 'ee47f078');
|
|
450
442
|
|
|
451
443
|
_$_.regular_block(() => {
|
|
452
444
|
let __out = '';
|
|
453
445
|
|
|
454
446
|
__out += '<button class="clear">Clear</button><ul class="list"><!--[-->';
|
|
455
447
|
|
|
456
|
-
for (const item of
|
|
448
|
+
for (const item of items.value) {
|
|
457
449
|
__out += '<li>';
|
|
458
450
|
|
|
459
451
|
{
|
|
@@ -473,7 +465,7 @@ export function ForLoopPopulatedToEmpty() {
|
|
|
473
465
|
|
|
474
466
|
export function NestedForLoopReactive() {
|
|
475
467
|
return _$_.tsrx_element(() => {
|
|
476
|
-
|
|
468
|
+
const grid = _$_.track([[1, 2], [3, 4]], 'a2f41fb3');
|
|
477
469
|
|
|
478
470
|
_$_.regular_block(() => {
|
|
479
471
|
let __out = '';
|
|
@@ -485,7 +477,7 @@ export function NestedForLoopReactive() {
|
|
|
485
477
|
|
|
486
478
|
var rowIndex = 0;
|
|
487
479
|
|
|
488
|
-
for (const row of
|
|
480
|
+
for (const row of grid.value) {
|
|
489
481
|
__out += '<div' + _$_.attr('class', `row-${rowIndex}`) + '>';
|
|
490
482
|
|
|
491
483
|
{
|
|
@@ -594,7 +586,7 @@ export function ForLoopDeeplyNested() {
|
|
|
594
586
|
|
|
595
587
|
export function ForLoopIndexUpdate() {
|
|
596
588
|
return _$_.tsrx_element(() => {
|
|
597
|
-
|
|
589
|
+
const items = _$_.track(['First', 'Second', 'Third'], 'f61e31e6');
|
|
598
590
|
|
|
599
591
|
_$_.regular_block(() => {
|
|
600
592
|
let __out = '';
|
|
@@ -606,7 +598,7 @@ export function ForLoopIndexUpdate() {
|
|
|
606
598
|
|
|
607
599
|
var i = 0;
|
|
608
600
|
|
|
609
|
-
for (const item of
|
|
601
|
+
for (const item of items.value) {
|
|
610
602
|
__out += '<li' + _$_.attr('class', `item-${i}`) + '>' + _$_.escape(`[${i}] ${item}`) + '</li>';
|
|
611
603
|
i++;
|
|
612
604
|
}
|
|
@@ -622,7 +614,7 @@ export function ForLoopIndexUpdate() {
|
|
|
622
614
|
|
|
623
615
|
export function KeyedForLoopWithIndex() {
|
|
624
616
|
return _$_.tsrx_element(() => {
|
|
625
|
-
|
|
617
|
+
const items = _$_.track(
|
|
626
618
|
[
|
|
627
619
|
{ id: 'a', value: 'Alpha' },
|
|
628
620
|
{ id: 'b', value: 'Beta' },
|
|
@@ -641,7 +633,7 @@ export function KeyedForLoopWithIndex() {
|
|
|
641
633
|
|
|
642
634
|
var i = 0;
|
|
643
635
|
|
|
644
|
-
for (const item of
|
|
636
|
+
for (const item of items.value) {
|
|
645
637
|
__out += '<li' + _$_.attr('data-index', i, false) + _$_.attr('class', `item-${item.id}`) + '>' + _$_.escape(`[${i}] ${item.id}: ${item.value}`) + '</li>';
|
|
646
638
|
i++;
|
|
647
639
|
}
|
|
@@ -657,14 +649,14 @@ export function KeyedForLoopWithIndex() {
|
|
|
657
649
|
|
|
658
650
|
export function ForLoopWithSiblings() {
|
|
659
651
|
return _$_.tsrx_element(() => {
|
|
660
|
-
|
|
652
|
+
const items = _$_.track(['A', 'B'], '3c7e8152');
|
|
661
653
|
|
|
662
654
|
_$_.regular_block(() => {
|
|
663
655
|
let __out = '';
|
|
664
656
|
|
|
665
657
|
__out += '<div class="wrapper"><header class="before">Before</header><!--[-->';
|
|
666
658
|
|
|
667
|
-
for (const item of
|
|
659
|
+
for (const item of items.value) {
|
|
668
660
|
__out += '<div' + _$_.attr('class', `item-${item}`) + '>';
|
|
669
661
|
|
|
670
662
|
{
|
|
@@ -714,12 +706,12 @@ export function ForLoopItemState() {
|
|
|
714
706
|
|
|
715
707
|
function TodoItem(props) {
|
|
716
708
|
return _$_.tsrx_element(() => {
|
|
717
|
-
|
|
709
|
+
const done = _$_.track(false, '4f2402a4');
|
|
718
710
|
|
|
719
711
|
_$_.regular_block(() => {
|
|
720
712
|
let __out = '';
|
|
721
713
|
|
|
722
|
-
__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>';
|
|
723
715
|
_$_.output_push(__out);
|
|
724
716
|
});
|
|
725
717
|
});
|
|
@@ -754,14 +746,14 @@ export function ForLoopSingleItem() {
|
|
|
754
746
|
|
|
755
747
|
export function ForLoopAddAtBeginning() {
|
|
756
748
|
return _$_.tsrx_element(() => {
|
|
757
|
-
|
|
749
|
+
const items = _$_.track(['B', 'C'], '1561403a');
|
|
758
750
|
|
|
759
751
|
_$_.regular_block(() => {
|
|
760
752
|
let __out = '';
|
|
761
753
|
|
|
762
754
|
__out += '<button class="prepend">Prepend A</button><ul><!--[-->';
|
|
763
755
|
|
|
764
|
-
for (const item of
|
|
756
|
+
for (const item of items.value) {
|
|
765
757
|
__out += '<li' + _$_.attr('class', `item-${item}`) + '>';
|
|
766
758
|
|
|
767
759
|
{
|
|
@@ -781,14 +773,14 @@ export function ForLoopAddAtBeginning() {
|
|
|
781
773
|
|
|
782
774
|
export function ForLoopAddInMiddle() {
|
|
783
775
|
return _$_.tsrx_element(() => {
|
|
784
|
-
|
|
776
|
+
const items = _$_.track(['A', 'C'], '1bc60b46');
|
|
785
777
|
|
|
786
778
|
_$_.regular_block(() => {
|
|
787
779
|
let __out = '';
|
|
788
780
|
|
|
789
781
|
__out += '<button class="insert">Insert B</button><ul><!--[-->';
|
|
790
782
|
|
|
791
|
-
for (const item of
|
|
783
|
+
for (const item of items.value) {
|
|
792
784
|
__out += '<li' + _$_.attr('class', `item-${item}`) + '>';
|
|
793
785
|
|
|
794
786
|
{
|
|
@@ -808,14 +800,14 @@ export function ForLoopAddInMiddle() {
|
|
|
808
800
|
|
|
809
801
|
export function ForLoopRemoveFromMiddle() {
|
|
810
802
|
return _$_.tsrx_element(() => {
|
|
811
|
-
|
|
803
|
+
const items = _$_.track(['A', 'B', 'C'], '1c87f95f');
|
|
812
804
|
|
|
813
805
|
_$_.regular_block(() => {
|
|
814
806
|
let __out = '';
|
|
815
807
|
|
|
816
808
|
__out += '<button class="remove-middle">Remove B</button><ul><!--[-->';
|
|
817
809
|
|
|
818
|
-
for (const item of
|
|
810
|
+
for (const item of items.value) {
|
|
819
811
|
__out += '<li' + _$_.attr('class', `item-${item}`) + '>';
|
|
820
812
|
|
|
821
813
|
{
|
|
@@ -871,14 +863,14 @@ export function ForLoopLargeList() {
|
|
|
871
863
|
|
|
872
864
|
export function ForLoopSwap() {
|
|
873
865
|
return _$_.tsrx_element(() => {
|
|
874
|
-
|
|
866
|
+
const items = _$_.track(['A', 'B', 'C', 'D'], '5f8d152f');
|
|
875
867
|
|
|
876
868
|
_$_.regular_block(() => {
|
|
877
869
|
let __out = '';
|
|
878
870
|
|
|
879
871
|
__out += '<button class="swap">Swap First and Last</button><ul><!--[-->';
|
|
880
872
|
|
|
881
|
-
for (const item of
|
|
873
|
+
for (const item of items.value) {
|
|
882
874
|
__out += '<li' + _$_.attr('class', `item-${item}`) + '>';
|
|
883
875
|
|
|
884
876
|
{
|
|
@@ -898,14 +890,14 @@ export function ForLoopSwap() {
|
|
|
898
890
|
|
|
899
891
|
export function ForLoopReverse() {
|
|
900
892
|
return _$_.tsrx_element(() => {
|
|
901
|
-
|
|
893
|
+
const items = _$_.track(['A', 'B', 'C', 'D'], '24602e64');
|
|
902
894
|
|
|
903
895
|
_$_.regular_block(() => {
|
|
904
896
|
let __out = '';
|
|
905
897
|
|
|
906
898
|
__out += '<button class="reverse">Reverse</button><ul><!--[-->';
|
|
907
899
|
|
|
908
|
-
for (const item of
|
|
900
|
+
for (const item of items.value) {
|
|
909
901
|
__out += '<li' + _$_.attr('class', `item-${item}`) + '>';
|
|
910
902
|
|
|
911
903
|
{
|
|
@@ -921,4 +913,72 @@ export function ForLoopReverse() {
|
|
|
921
913
|
_$_.output_push(__out);
|
|
922
914
|
});
|
|
923
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
|
+
});
|
|
924
984
|
}
|