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
|
@@ -5,14 +5,14 @@ import { track } from 'ripple/server';
|
|
|
5
5
|
|
|
6
6
|
export function IfWithChildren({ children }) {
|
|
7
7
|
return _$_.tsrx_element(() => {
|
|
8
|
-
|
|
8
|
+
const expanded = _$_.track(true, 'c64714b1');
|
|
9
9
|
|
|
10
10
|
_$_.regular_block(() => {
|
|
11
11
|
let __out = '';
|
|
12
12
|
|
|
13
13
|
__out += '<div class="container"><div role="button" class="header">Toggle</div><!--[-->';
|
|
14
14
|
|
|
15
|
-
if (
|
|
15
|
+
if (expanded.value) {
|
|
16
16
|
__out += '<div class="content">';
|
|
17
17
|
|
|
18
18
|
{
|
|
@@ -77,14 +77,14 @@ export function TestIfWithChildren() {
|
|
|
77
77
|
|
|
78
78
|
export function IfWithStaticChildren() {
|
|
79
79
|
return _$_.tsrx_element(() => {
|
|
80
|
-
|
|
80
|
+
const expanded = _$_.track(true, '3bba8f77');
|
|
81
81
|
|
|
82
82
|
_$_.regular_block(() => {
|
|
83
83
|
let __out = '';
|
|
84
84
|
|
|
85
85
|
__out += '<div class="container"><div role="button" class="header">Toggle</div><!--[-->';
|
|
86
86
|
|
|
87
|
-
if (
|
|
87
|
+
if (expanded.value) {
|
|
88
88
|
__out += '<div class="content"><span>Static child 1</span><span>Static child 2</span></div>';
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -96,14 +96,14 @@ export function IfWithStaticChildren() {
|
|
|
96
96
|
|
|
97
97
|
export function IfWithSiblingsAndChildren({ children }) {
|
|
98
98
|
return _$_.tsrx_element(() => {
|
|
99
|
-
|
|
99
|
+
const expanded = _$_.track(true, 'a1b8fb4c');
|
|
100
100
|
|
|
101
101
|
_$_.regular_block(() => {
|
|
102
102
|
let __out = '';
|
|
103
103
|
|
|
104
104
|
__out += '<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><!--[-->';
|
|
105
105
|
|
|
106
|
-
if (
|
|
106
|
+
if (expanded.value) {
|
|
107
107
|
__out += '<div class="items">';
|
|
108
108
|
|
|
109
109
|
{
|
|
@@ -157,14 +157,14 @@ export function TestIfWithSiblingsAndChildren() {
|
|
|
157
157
|
|
|
158
158
|
export function ElementWithChildrenThenIf() {
|
|
159
159
|
return _$_.tsrx_element(() => {
|
|
160
|
-
|
|
160
|
+
const show = _$_.track(true, '7cd4817b');
|
|
161
161
|
|
|
162
162
|
_$_.regular_block(() => {
|
|
163
163
|
let __out = '';
|
|
164
164
|
|
|
165
165
|
__out += '<div class="wrapper"><div class="nested-parent"><div class="nested-child"><span class="deep">Deep content</span></div></div><!--[-->';
|
|
166
166
|
|
|
167
|
-
if (
|
|
167
|
+
if (show.value) {
|
|
168
168
|
__out += '<div class="conditional">Conditional content</div>';
|
|
169
169
|
}
|
|
170
170
|
|
|
@@ -176,14 +176,14 @@ export function ElementWithChildrenThenIf() {
|
|
|
176
176
|
|
|
177
177
|
export function DeepNestingThenIf() {
|
|
178
178
|
return _$_.tsrx_element(() => {
|
|
179
|
-
|
|
179
|
+
const visible = _$_.track(true, '923116be');
|
|
180
180
|
|
|
181
181
|
_$_.regular_block(() => {
|
|
182
182
|
let __out = '';
|
|
183
183
|
|
|
184
184
|
__out += '<section class="outer"><article class="middle"><div class="inner"><p class="leaf"><strong>Bold</strong><em>Italic</em></p></div></article><!--[-->';
|
|
185
185
|
|
|
186
|
-
if (
|
|
186
|
+
if (visible.value) {
|
|
187
187
|
__out += '<footer class="footer">Footer</footer>';
|
|
188
188
|
}
|
|
189
189
|
|
|
@@ -195,14 +195,14 @@ export function DeepNestingThenIf() {
|
|
|
195
195
|
|
|
196
196
|
export function DomElementChildrenThenSibling() {
|
|
197
197
|
return _$_.tsrx_element(() => {
|
|
198
|
-
|
|
198
|
+
const activeTab = _$_.track('code', '33a1e97f');
|
|
199
199
|
|
|
200
200
|
_$_.regular_block(() => {
|
|
201
201
|
let __out = '';
|
|
202
202
|
|
|
203
|
-
__out += '<div class="tabs"><div class="tab-list"><button' + _$_.attr('aria-selected',
|
|
203
|
+
__out += '<div class="tabs"><div class="tab-list"><button' + _$_.attr('aria-selected', activeTab.value === 'code' ? 'true' : 'false', false) + ' class="tab">Code</button><button' + _$_.attr('aria-selected', activeTab.value === 'preview' ? 'true' : 'false', false) + ' class="tab">Preview</button></div><div class="panel"><!--[-->';
|
|
204
204
|
|
|
205
|
-
if (
|
|
205
|
+
if (activeTab.value === 'code') {
|
|
206
206
|
__out += '<pre class="code">const x = 1;</pre>';
|
|
207
207
|
} else {
|
|
208
208
|
__out += '<div class="preview">Preview content</div>';
|
|
@@ -216,12 +216,12 @@ export function DomElementChildrenThenSibling() {
|
|
|
216
216
|
|
|
217
217
|
export function DomChildrenThenStaticSiblings() {
|
|
218
218
|
return _$_.tsrx_element(() => {
|
|
219
|
-
|
|
219
|
+
const count = _$_.track(0, '0ea64305');
|
|
220
220
|
|
|
221
221
|
_$_.regular_block(() => {
|
|
222
222
|
let __out = '';
|
|
223
223
|
|
|
224
|
-
__out += '<div class="container"><ul class="list"><li class="item">' + _$_.escape('Item count: ' + String(
|
|
224
|
+
__out += '<div class="container"><ul class="list"><li class="item">' + _$_.escape('Item count: ' + String(count.value ?? '')) + '</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>';
|
|
225
225
|
_$_.output_push(__out);
|
|
226
226
|
});
|
|
227
227
|
});
|
|
@@ -236,4 +236,96 @@ export function StaticListThenStaticSiblings() {
|
|
|
236
236
|
_$_.output_push(__out);
|
|
237
237
|
});
|
|
238
238
|
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function RootIfChild(props) {
|
|
242
|
+
return _$_.tsrx_element(() => {
|
|
243
|
+
_$_.regular_block(() => {
|
|
244
|
+
let __out = '';
|
|
245
|
+
|
|
246
|
+
__out += '<!--[-->';
|
|
247
|
+
|
|
248
|
+
if (props.on.value) {
|
|
249
|
+
__out += '<span class="root-if">on</span>';
|
|
250
|
+
} else {
|
|
251
|
+
__out += '<span class="root-if">off</span>';
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
__out += '<!--]-->';
|
|
255
|
+
_$_.output_push(__out);
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function RootForChild(props) {
|
|
261
|
+
return _$_.tsrx_element(() => {
|
|
262
|
+
_$_.regular_block(() => {
|
|
263
|
+
let __out = '';
|
|
264
|
+
|
|
265
|
+
__out += '<!--[-->';
|
|
266
|
+
|
|
267
|
+
for (const item of props.items.value) {
|
|
268
|
+
__out += '<span class="root-for">' + _$_.escape(item) + '</span>';
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
__out += '<!--]-->';
|
|
272
|
+
_$_.output_push(__out);
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function TrailingChild() {
|
|
278
|
+
return _$_.tsrx_element(() => {
|
|
279
|
+
_$_.regular_block(() => {
|
|
280
|
+
let __out = '';
|
|
281
|
+
|
|
282
|
+
__out += '<span class="trailing">end</span>';
|
|
283
|
+
_$_.output_push(__out);
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export function ComponentChildrenWithControlFlowRoots() {
|
|
289
|
+
return _$_.tsrx_element(() => {
|
|
290
|
+
const on = _$_.track(true, 'f3e4c6ee');
|
|
291
|
+
const items = _$_.track([1, 2, 3], '2bbbeeb0');
|
|
292
|
+
|
|
293
|
+
_$_.regular_block(() => {
|
|
294
|
+
let __out = '';
|
|
295
|
+
|
|
296
|
+
__out += '<div class="wrapper"><div class="host">';
|
|
297
|
+
|
|
298
|
+
{
|
|
299
|
+
{
|
|
300
|
+
const comp = RootIfChild;
|
|
301
|
+
const args = [{ on }];
|
|
302
|
+
|
|
303
|
+
_$_.output_push(__out);
|
|
304
|
+
__out = '';
|
|
305
|
+
_$_.render_component(comp, ...args);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
{
|
|
309
|
+
const comp = RootForChild;
|
|
310
|
+
const args = [{ items }];
|
|
311
|
+
|
|
312
|
+
_$_.output_push(__out);
|
|
313
|
+
__out = '';
|
|
314
|
+
_$_.render_component(comp, ...args);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
{
|
|
318
|
+
const comp = TrailingChild;
|
|
319
|
+
const args = [{}];
|
|
320
|
+
|
|
321
|
+
_$_.output_push(__out);
|
|
322
|
+
__out = '';
|
|
323
|
+
_$_.render_component(comp, ...args);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
__out += '</div><button class="toggle">Toggle</button><button class="rotate">Rotate</button></div>';
|
|
328
|
+
_$_.output_push(__out);
|
|
329
|
+
});
|
|
330
|
+
});
|
|
239
331
|
}
|
|
@@ -64,14 +64,14 @@ export function IfElse() {
|
|
|
64
64
|
|
|
65
65
|
export function ReactiveIf() {
|
|
66
66
|
return _$_.tsrx_element(() => {
|
|
67
|
-
|
|
67
|
+
const show = _$_.track(true, '19a16ff0');
|
|
68
68
|
|
|
69
69
|
_$_.regular_block(() => {
|
|
70
70
|
let __out = '';
|
|
71
71
|
|
|
72
72
|
__out += '<button class="toggle">Toggle</button><!--[-->';
|
|
73
73
|
|
|
74
|
-
if (
|
|
74
|
+
if (show.value) {
|
|
75
75
|
__out += '<div class="content">Content visible</div>';
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -83,14 +83,14 @@ export function ReactiveIf() {
|
|
|
83
83
|
|
|
84
84
|
export function ReactiveIfElse() {
|
|
85
85
|
return _$_.tsrx_element(() => {
|
|
86
|
-
|
|
86
|
+
const isOn = _$_.track(false, '41177f39');
|
|
87
87
|
|
|
88
88
|
_$_.regular_block(() => {
|
|
89
89
|
let __out = '';
|
|
90
90
|
|
|
91
91
|
__out += '<button class="toggle">Toggle</button><!--[-->';
|
|
92
92
|
|
|
93
|
-
if (
|
|
93
|
+
if (isOn.value) {
|
|
94
94
|
__out += '<div class="on">ON</div>';
|
|
95
95
|
} else {
|
|
96
96
|
__out += '<div class="off">OFF</div>';
|
|
@@ -104,18 +104,18 @@ export function ReactiveIfElse() {
|
|
|
104
104
|
|
|
105
105
|
export function NestedIf() {
|
|
106
106
|
return _$_.tsrx_element(() => {
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
const outer = _$_.track(true, '7894e1df');
|
|
108
|
+
const inner = _$_.track(true, 'f21b8c26');
|
|
109
109
|
|
|
110
110
|
_$_.regular_block(() => {
|
|
111
111
|
let __out = '';
|
|
112
112
|
|
|
113
113
|
__out += '<button class="outer-toggle">Outer</button><button class="inner-toggle">Inner</button><!--[-->';
|
|
114
114
|
|
|
115
|
-
if (
|
|
115
|
+
if (outer.value) {
|
|
116
116
|
__out += '<div class="outer-content">Outer<!--[-->';
|
|
117
117
|
|
|
118
|
-
if (
|
|
118
|
+
if (inner.value) {
|
|
119
119
|
__out += '<span class="inner-content">Inner</span>';
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -130,25 +130,21 @@ export function NestedIf() {
|
|
|
130
130
|
|
|
131
131
|
export function IfElseIfChain() {
|
|
132
132
|
return _$_.tsrx_element(() => {
|
|
133
|
-
|
|
133
|
+
const status = _$_.track('loading', '4c69c94a');
|
|
134
134
|
|
|
135
135
|
_$_.regular_block(() => {
|
|
136
136
|
let __out = '';
|
|
137
137
|
|
|
138
138
|
__out += '<div><button class="success">Success</button><button class="error">Error</button><button class="loading">Loading</button><!--[-->';
|
|
139
139
|
|
|
140
|
-
if (
|
|
140
|
+
if (status.value === 'loading') {
|
|
141
141
|
__out += '<div class="state">Loading...</div>';
|
|
142
142
|
} else {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (lazy_4.value === 'success') {
|
|
143
|
+
if (status.value === 'success') {
|
|
146
144
|
__out += '<div class="state">Success!</div>';
|
|
147
145
|
} else {
|
|
148
146
|
__out += '<div class="state">Error occurred</div>';
|
|
149
147
|
}
|
|
150
|
-
|
|
151
|
-
__out += '<!--]-->';
|
|
152
148
|
}
|
|
153
149
|
|
|
154
150
|
__out += '<!--]--></div>';
|
|
@@ -78,22 +78,22 @@ export function MixedControlFlowStatic() {
|
|
|
78
78
|
|
|
79
79
|
export function MixedControlFlowReactive() {
|
|
80
80
|
return _$_.tsrx_element(() => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
const show = _$_.track(true, '5ae53d26');
|
|
82
|
+
const mode = _$_.track('a', '5b53eda2');
|
|
83
|
+
const items = _$_.track([{ id: 1, label: 'One' }, { id: 2, label: 'Two' }], '7890dad6');
|
|
84
84
|
|
|
85
85
|
_$_.regular_block(() => {
|
|
86
86
|
let __out = '';
|
|
87
87
|
|
|
88
88
|
__out += '<button class="toggle-show">Toggle Show</button><button class="toggle-mode">Toggle Mode</button><button class="add-item">Add Item</button><!--[-->';
|
|
89
89
|
|
|
90
|
-
if (
|
|
90
|
+
if (show.value) {
|
|
91
91
|
__out += '<div class="mixed-reactive-list"><!--[-->';
|
|
92
92
|
|
|
93
|
-
for (const item of
|
|
93
|
+
for (const item of items.value) {
|
|
94
94
|
__out += '<!--[-->';
|
|
95
95
|
|
|
96
|
-
switch (
|
|
96
|
+
switch (mode.value) {
|
|
97
97
|
case 'a':
|
|
98
98
|
_$_.output_push(__out);
|
|
99
99
|
__out = '';
|
|
@@ -214,7 +214,7 @@ export function MixedControlFlowAsyncPending() {
|
|
|
214
214
|
|
|
215
215
|
function AsyncRow({ label }) {
|
|
216
216
|
return _$_.tsrx_element(() => {
|
|
217
|
-
|
|
217
|
+
const value = _$_.track_async(() => Promise.resolve(label), '10cc79a0');
|
|
218
218
|
|
|
219
219
|
_$_.regular_block(() => {
|
|
220
220
|
let __out = '';
|
|
@@ -224,7 +224,7 @@ function AsyncRow({ label }) {
|
|
|
224
224
|
{
|
|
225
225
|
_$_.output_push(__out);
|
|
226
226
|
__out = '';
|
|
227
|
-
_$_.render_expression(
|
|
227
|
+
_$_.render_expression(value.value);
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
__out += '</div>';
|
|
@@ -30,11 +30,9 @@ export function SimplePortal() {
|
|
|
30
30
|
}
|
|
31
31
|
];
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
_$_.render_component(comp, ...args);
|
|
37
|
-
}
|
|
33
|
+
_$_.output_push(__out);
|
|
34
|
+
__out = '';
|
|
35
|
+
_$_.render_component(comp, ...args);
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
__out += '</div>';
|
|
@@ -45,14 +43,14 @@ export function SimplePortal() {
|
|
|
45
43
|
|
|
46
44
|
export function ConditionalPortal() {
|
|
47
45
|
return _$_.tsrx_element(() => {
|
|
48
|
-
|
|
46
|
+
const show = _$_.track(true, '4f6df174');
|
|
49
47
|
|
|
50
48
|
_$_.regular_block(() => {
|
|
51
49
|
let __out = '';
|
|
52
50
|
|
|
53
51
|
__out += '<div class="container"><button class="toggle">Toggle</button><!--[-->';
|
|
54
52
|
|
|
55
|
-
if (
|
|
53
|
+
if (show.value) {
|
|
56
54
|
{
|
|
57
55
|
const comp = Portal;
|
|
58
56
|
|
|
@@ -73,11 +71,9 @@ export function ConditionalPortal() {
|
|
|
73
71
|
}
|
|
74
72
|
];
|
|
75
73
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
_$_.render_component(comp, ...args);
|
|
80
|
-
}
|
|
74
|
+
_$_.output_push(__out);
|
|
75
|
+
__out = '';
|
|
76
|
+
_$_.render_component(comp, ...args);
|
|
81
77
|
}
|
|
82
78
|
}
|
|
83
79
|
|
|
@@ -114,11 +110,9 @@ export function PortalWithMainContent() {
|
|
|
114
110
|
}
|
|
115
111
|
];
|
|
116
112
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
_$_.render_component(comp, ...args);
|
|
121
|
-
}
|
|
113
|
+
_$_.output_push(__out);
|
|
114
|
+
__out = '';
|
|
115
|
+
_$_.render_component(comp, ...args);
|
|
122
116
|
}
|
|
123
117
|
|
|
124
118
|
__out += '<div class="footer">Footer</div></div>';
|
|
@@ -154,11 +148,9 @@ export function NestedContentWithPortal() {
|
|
|
154
148
|
}
|
|
155
149
|
];
|
|
156
150
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
_$_.render_component(comp, ...args);
|
|
161
|
-
}
|
|
151
|
+
_$_.output_push(__out);
|
|
152
|
+
__out = '';
|
|
153
|
+
_$_.render_component(comp, ...args);
|
|
162
154
|
}
|
|
163
155
|
|
|
164
156
|
__out += '</div>';
|
|
@@ -5,12 +5,12 @@ import { track } from 'ripple/server';
|
|
|
5
5
|
|
|
6
6
|
export function TrackedState() {
|
|
7
7
|
return _$_.tsrx_element(() => {
|
|
8
|
-
|
|
8
|
+
const count = _$_.track(0, 'c1818584');
|
|
9
9
|
|
|
10
10
|
_$_.regular_block(() => {
|
|
11
11
|
let __out = '';
|
|
12
12
|
|
|
13
|
-
__out += '<div class="count">' + _$_.escape(
|
|
13
|
+
__out += '<div class="count">' + _$_.escape(count.value) + '</div>';
|
|
14
14
|
_$_.output_push(__out);
|
|
15
15
|
});
|
|
16
16
|
});
|
|
@@ -18,7 +18,7 @@ export function TrackedState() {
|
|
|
18
18
|
|
|
19
19
|
export function CounterWithInitial(props) {
|
|
20
20
|
return _$_.tsrx_element(() => {
|
|
21
|
-
|
|
21
|
+
const count = _$_.track(props.initial, '03ea4348');
|
|
22
22
|
|
|
23
23
|
_$_.regular_block(() => {
|
|
24
24
|
let __out = '';
|
|
@@ -28,7 +28,7 @@ export function CounterWithInitial(props) {
|
|
|
28
28
|
{
|
|
29
29
|
_$_.output_push(__out);
|
|
30
30
|
__out = '';
|
|
31
|
-
_$_.render_expression(
|
|
31
|
+
_$_.render_expression(count.value);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
__out += '</span></div>';
|
|
@@ -52,9 +52,9 @@ export function CounterWrapper() {
|
|
|
52
52
|
|
|
53
53
|
export function ComputedValues() {
|
|
54
54
|
return _$_.tsrx_element(() => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const sum = () =>
|
|
55
|
+
const a = _$_.track(2, 'b78281db');
|
|
56
|
+
const b = _$_.track(3, 'a0cf6c6d');
|
|
57
|
+
const sum = () => a.value + b.value;
|
|
58
58
|
|
|
59
59
|
_$_.regular_block(() => {
|
|
60
60
|
let __out = '';
|
|
@@ -75,14 +75,14 @@ export function ComputedValues() {
|
|
|
75
75
|
|
|
76
76
|
export function MultipleTracked() {
|
|
77
77
|
return _$_.tsrx_element(() => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
const x = _$_.track(10, '843522de');
|
|
79
|
+
const y = _$_.track(20, '1308996d');
|
|
80
|
+
const z = _$_.track(30, '048c3fd0');
|
|
81
81
|
|
|
82
82
|
_$_.regular_block(() => {
|
|
83
83
|
let __out = '';
|
|
84
84
|
|
|
85
|
-
__out += '<div class="multiple-tracked"><div class="x">' + _$_.escape(
|
|
85
|
+
__out += '<div class="multiple-tracked"><div class="x">' + _$_.escape(x.value) + '</div><div class="y">' + _$_.escape(y.value) + '</div><div class="z">' + _$_.escape(z.value) + '</div></div>';
|
|
86
86
|
_$_.output_push(__out);
|
|
87
87
|
});
|
|
88
88
|
});
|
|
@@ -90,9 +90,9 @@ export function MultipleTracked() {
|
|
|
90
90
|
|
|
91
91
|
export function DerivedState() {
|
|
92
92
|
return _$_.tsrx_element(() => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const fullName = () => `${
|
|
93
|
+
const firstName = _$_.track('John', '6015eeca');
|
|
94
|
+
const lastName = _$_.track('Doe', '4fa9a20e');
|
|
95
|
+
const fullName = () => `${firstName.value} ${lastName.value}`;
|
|
96
96
|
|
|
97
97
|
_$_.regular_block(() => {
|
|
98
98
|
let __out = '';
|
|
@@ -32,13 +32,13 @@ resetControls();
|
|
|
32
32
|
|
|
33
33
|
function BasicContent() {
|
|
34
34
|
return _$_.tsrx_element(() => {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const data = _$_.track_async(() => controls.basic.promise, '703e438e');
|
|
36
|
+
const count = _$_.track(0, '928bce39');
|
|
37
37
|
|
|
38
38
|
_$_.regular_block(() => {
|
|
39
39
|
let __out = '';
|
|
40
40
|
|
|
41
|
-
__out += '<div class="resolved"><span class="value">' + _$_.escape(
|
|
41
|
+
__out += '<div class="resolved"><span class="value">' + _$_.escape(data.value + ':' + count.value) + '</span><button class="inc">inc</button></div>';
|
|
42
42
|
_$_.output_push(__out);
|
|
43
43
|
});
|
|
44
44
|
});
|
|
@@ -88,7 +88,7 @@ export function StreamPending() {
|
|
|
88
88
|
|
|
89
89
|
function CatchOnlyContent() {
|
|
90
90
|
return _$_.tsrx_element(() => {
|
|
91
|
-
|
|
91
|
+
const data = _$_.track_async(() => controls.catchOnly.promise, '50f939c6');
|
|
92
92
|
|
|
93
93
|
_$_.regular_block(() => {
|
|
94
94
|
let __out = '';
|
|
@@ -98,7 +98,7 @@ function CatchOnlyContent() {
|
|
|
98
98
|
{
|
|
99
99
|
_$_.output_push(__out);
|
|
100
100
|
__out = '';
|
|
101
|
-
_$_.render_expression(
|
|
101
|
+
_$_.render_expression(data.value);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
__out += '</p>';
|
|
@@ -158,7 +158,7 @@ export function StreamCatchOnly() {
|
|
|
158
158
|
|
|
159
159
|
function RejectContent() {
|
|
160
160
|
return _$_.tsrx_element(() => {
|
|
161
|
-
|
|
161
|
+
const data = _$_.track_async(() => controls.rejects.promise, '96452a54');
|
|
162
162
|
|
|
163
163
|
_$_.regular_block(() => {
|
|
164
164
|
let __out = '';
|
|
@@ -168,7 +168,7 @@ function RejectContent() {
|
|
|
168
168
|
{
|
|
169
169
|
_$_.output_push(__out);
|
|
170
170
|
__out = '';
|
|
171
|
-
_$_.render_expression(
|
|
171
|
+
_$_.render_expression(data.value);
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
__out += '</p>';
|
|
@@ -247,7 +247,7 @@ export function StreamRejects() {
|
|
|
247
247
|
|
|
248
248
|
function NoCatchContent() {
|
|
249
249
|
return _$_.tsrx_element(() => {
|
|
250
|
-
|
|
250
|
+
const data = _$_.track_async(() => controls.noCatch.promise, '6baa716b');
|
|
251
251
|
|
|
252
252
|
_$_.regular_block(() => {
|
|
253
253
|
let __out = '';
|
|
@@ -257,7 +257,7 @@ function NoCatchContent() {
|
|
|
257
257
|
{
|
|
258
258
|
_$_.output_push(__out);
|
|
259
259
|
__out = '';
|
|
260
|
-
_$_.render_expression(
|
|
260
|
+
_$_.render_expression(data.value);
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
__out += '</p>';
|
|
@@ -342,27 +342,27 @@ export function RootPending() {
|
|
|
342
342
|
|
|
343
343
|
function HeadContent() {
|
|
344
344
|
return _$_.tsrx_element(() => {
|
|
345
|
-
|
|
345
|
+
const data = _$_.track_async(() => controls.head.promise, '9cd3c3cd');
|
|
346
346
|
|
|
347
347
|
_$_.regular_block(() => {
|
|
348
348
|
let __out = '';
|
|
349
349
|
|
|
350
350
|
__out += '<!--[--><!--[-->';
|
|
351
351
|
|
|
352
|
-
if (
|
|
352
|
+
if (data.value) {
|
|
353
353
|
__out += '<p class="head-content">';
|
|
354
354
|
|
|
355
355
|
{
|
|
356
356
|
_$_.output_push(__out);
|
|
357
357
|
__out = '';
|
|
358
|
-
_$_.render_expression(
|
|
358
|
+
_$_.render_expression(data.value);
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
__out += '</p>';
|
|
362
362
|
_$_.output_push(__out);
|
|
363
363
|
__out = '';
|
|
364
364
|
_$_.set_output_target('head');
|
|
365
|
-
__out += '<!--
|
|
365
|
+
__out += '<!--1ad4258e--><title>' + _$_.escape('title:' + data.value) + '</title>';
|
|
366
366
|
_$_.output_push(__out);
|
|
367
367
|
__out = '';
|
|
368
368
|
_$_.set_output_target(null);
|
|
@@ -420,7 +420,7 @@ export function StreamHead() {
|
|
|
420
420
|
|
|
421
421
|
export function StreamRootDirect() {
|
|
422
422
|
return _$_.tsrx_element(() => {
|
|
423
|
-
|
|
423
|
+
const data = _$_.track_async(() => controls.rootDirect.promise, 'bc9e61da');
|
|
424
424
|
|
|
425
425
|
_$_.regular_block(() => {
|
|
426
426
|
let __out = '';
|
|
@@ -430,7 +430,7 @@ export function StreamRootDirect() {
|
|
|
430
430
|
{
|
|
431
431
|
_$_.output_push(__out);
|
|
432
432
|
__out = '';
|
|
433
|
-
_$_.render_expression(
|
|
433
|
+
_$_.render_expression(data.value);
|
|
434
434
|
}
|
|
435
435
|
|
|
436
436
|
__out += '</p>';
|
|
@@ -441,7 +441,7 @@ export function StreamRootDirect() {
|
|
|
441
441
|
|
|
442
442
|
function OuterContent() {
|
|
443
443
|
return _$_.tsrx_element(() => {
|
|
444
|
-
|
|
444
|
+
const data = _$_.track_async(() => controls.outer.promise, '35931cce');
|
|
445
445
|
|
|
446
446
|
_$_.regular_block(() => {
|
|
447
447
|
let __out = '';
|
|
@@ -451,7 +451,7 @@ function OuterContent() {
|
|
|
451
451
|
{
|
|
452
452
|
_$_.output_push(__out);
|
|
453
453
|
__out = '';
|
|
454
|
-
_$_.render_expression(
|
|
454
|
+
_$_.render_expression(data.value);
|
|
455
455
|
}
|
|
456
456
|
|
|
457
457
|
__out += '</p>';
|
|
@@ -462,7 +462,7 @@ function OuterContent() {
|
|
|
462
462
|
|
|
463
463
|
function InnerContent() {
|
|
464
464
|
return _$_.tsrx_element(() => {
|
|
465
|
-
|
|
465
|
+
const data = _$_.track_async(() => controls.inner.promise, '6c7d38ed');
|
|
466
466
|
|
|
467
467
|
_$_.regular_block(() => {
|
|
468
468
|
let __out = '';
|
|
@@ -472,7 +472,7 @@ function InnerContent() {
|
|
|
472
472
|
{
|
|
473
473
|
_$_.output_push(__out);
|
|
474
474
|
__out = '';
|
|
475
|
-
_$_.render_expression(
|
|
475
|
+
_$_.render_expression(data.value);
|
|
476
476
|
}
|
|
477
477
|
|
|
478
478
|
__out += '</p>';
|