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
|
@@ -34,14 +34,14 @@ export function SwitchStatic() {
|
|
|
34
34
|
|
|
35
35
|
export function SwitchReactive() {
|
|
36
36
|
return _$_.tsrx_element(() => {
|
|
37
|
-
|
|
37
|
+
const status = _$_.track('a', '9b34d955');
|
|
38
38
|
|
|
39
39
|
_$_.regular_block(() => {
|
|
40
40
|
let __out = '';
|
|
41
41
|
|
|
42
42
|
__out += '<button class="toggle">Toggle</button><!--[-->';
|
|
43
43
|
|
|
44
|
-
switch (
|
|
44
|
+
switch (status.value) {
|
|
45
45
|
case 'a':
|
|
46
46
|
__out += '<div class="case-a">Case A</div>';
|
|
47
47
|
break;
|
|
@@ -91,14 +91,14 @@ export function SwitchFallthrough() {
|
|
|
91
91
|
|
|
92
92
|
export function SwitchNumericLevels() {
|
|
93
93
|
return _$_.tsrx_element(() => {
|
|
94
|
-
|
|
94
|
+
const level = _$_.track(1, '7581a7ab');
|
|
95
95
|
|
|
96
96
|
_$_.regular_block(() => {
|
|
97
97
|
let __out = '';
|
|
98
98
|
|
|
99
99
|
__out += '<button class="level-toggle">Toggle Level</button><!--[-->';
|
|
100
100
|
|
|
101
|
-
switch (
|
|
101
|
+
switch (level.value) {
|
|
102
102
|
case 1:
|
|
103
103
|
__out += '<div class="level-1">Level 1</div>';
|
|
104
104
|
break;
|
|
@@ -120,14 +120,14 @@ export function SwitchNumericLevels() {
|
|
|
120
120
|
|
|
121
121
|
export function SwitchBlockScoped() {
|
|
122
122
|
return _$_.tsrx_element(() => {
|
|
123
|
-
|
|
123
|
+
const level = _$_.track(1, 'ca9f9852');
|
|
124
124
|
|
|
125
125
|
_$_.regular_block(() => {
|
|
126
126
|
let __out = '';
|
|
127
127
|
|
|
128
128
|
__out += '<button class="block-toggle">Toggle</button><!--[-->';
|
|
129
129
|
|
|
130
|
-
switch (
|
|
130
|
+
switch (level.value) {
|
|
131
131
|
case 1:
|
|
132
132
|
__out += '<div class="block-1">Block 1</div>';
|
|
133
133
|
break;
|
|
@@ -149,14 +149,14 @@ export function SwitchBlockScoped() {
|
|
|
149
149
|
|
|
150
150
|
export function SwitchNoBreak() {
|
|
151
151
|
return _$_.tsrx_element(() => {
|
|
152
|
-
|
|
152
|
+
const level = _$_.track(1, '6b7cb0ea');
|
|
153
153
|
|
|
154
154
|
_$_.regular_block(() => {
|
|
155
155
|
let __out = '';
|
|
156
156
|
|
|
157
157
|
__out += '<button class="nobreak-toggle">Toggle</button><!--[-->';
|
|
158
158
|
|
|
159
|
-
switch (
|
|
159
|
+
switch (level.value) {
|
|
160
160
|
case 1:
|
|
161
161
|
__out += '<div class="nobreak-1">NoBreak 1</div>';
|
|
162
162
|
break;
|
|
@@ -1,25 +1,109 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import * as _$_ from 'ripple/internal/server';
|
|
3
3
|
|
|
4
|
+
import { Money as _$_Money__ } from '../fixtures/money.js';
|
|
4
5
|
import { track, trackAsync } from 'ripple/server';
|
|
6
|
+
import { Money } from '../fixtures/money.js';
|
|
7
|
+
|
|
8
|
+
export const transport = {
|
|
9
|
+
Money: {
|
|
10
|
+
encode: (value) => value instanceof Money && [value.amount, value.currency],
|
|
11
|
+
decode: ([amount, currency]) => new Money(amount, currency)
|
|
12
|
+
}
|
|
13
|
+
};
|
|
5
14
|
|
|
6
15
|
export const _$_server_$_ = (() => {
|
|
7
16
|
var _$_server_$_ = {};
|
|
17
|
+
const Money = _$_Money__;
|
|
8
18
|
|
|
9
19
|
_$_server_$_.formatValue = async function formatValue(n) {
|
|
10
20
|
return `server-${n}`;
|
|
11
21
|
};
|
|
12
22
|
|
|
23
|
+
_$_server_$_.doubleMoney = async function doubleMoney(value) {
|
|
24
|
+
if (!(value instanceof Money)) throw new Error('RPC argument was not revived');
|
|
25
|
+
|
|
26
|
+
return new Money(value.amount * 2, value.currency);
|
|
27
|
+
};
|
|
28
|
+
|
|
13
29
|
return _$_server_$_;
|
|
14
30
|
})();
|
|
15
31
|
|
|
32
|
+
const doubleMoney = function (...args) {
|
|
33
|
+
return _$_server_$_.doubleMoney(...args);
|
|
34
|
+
};
|
|
35
|
+
|
|
16
36
|
const formatValue = function (...args) {
|
|
17
37
|
return _$_server_$_.formatValue(...args);
|
|
18
38
|
};
|
|
19
39
|
|
|
40
|
+
function MoneyResult({ count }) {
|
|
41
|
+
return _$_.tsrx_element(() => {
|
|
42
|
+
const money = _$_.track_async(() => doubleMoney(new Money(count.value, 'USD')), '2e21cbe9');
|
|
43
|
+
|
|
44
|
+
_$_.regular_block(() => {
|
|
45
|
+
let __out = '';
|
|
46
|
+
|
|
47
|
+
__out += '<p class="result">';
|
|
48
|
+
|
|
49
|
+
{
|
|
50
|
+
_$_.output_push(__out);
|
|
51
|
+
__out = '';
|
|
52
|
+
_$_.render_expression(money.value.format());
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
__out += '</p>';
|
|
56
|
+
_$_.output_push(__out);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function AsyncCustomType() {
|
|
62
|
+
return _$_.tsrx_element(() => {
|
|
63
|
+
const count = _$_.track(6, 'f0c2b41e');
|
|
64
|
+
|
|
65
|
+
_$_.regular_block(() => {
|
|
66
|
+
let __out = '';
|
|
67
|
+
|
|
68
|
+
__out += '<button class="increment">increment</button>';
|
|
69
|
+
_$_.output_push(__out);
|
|
70
|
+
__out = '';
|
|
71
|
+
|
|
72
|
+
_$_.try_block(
|
|
73
|
+
() => {
|
|
74
|
+
let __out = '';
|
|
75
|
+
|
|
76
|
+
__out += '<!--[-->';
|
|
77
|
+
|
|
78
|
+
{
|
|
79
|
+
const comp = MoneyResult;
|
|
80
|
+
const args = [{ count }];
|
|
81
|
+
|
|
82
|
+
_$_.output_push(__out);
|
|
83
|
+
__out = '';
|
|
84
|
+
_$_.render_component(comp, ...args);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
__out += '<!--]-->';
|
|
88
|
+
_$_.output_push(__out);
|
|
89
|
+
},
|
|
90
|
+
null,
|
|
91
|
+
() => {
|
|
92
|
+
let __out = '';
|
|
93
|
+
|
|
94
|
+
__out += '<!--[--><p class="loading">loading...</p><!--]-->';
|
|
95
|
+
_$_.output_push(__out);
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
_$_.output_push(__out);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
20
104
|
function ServerCallResult({ count }) {
|
|
21
105
|
return _$_.tsrx_element(() => {
|
|
22
|
-
|
|
106
|
+
const data = _$_.track_async(() => formatValue(count.value), '4e502c38');
|
|
23
107
|
|
|
24
108
|
_$_.regular_block(() => {
|
|
25
109
|
let __out = '';
|
|
@@ -29,7 +113,7 @@ function ServerCallResult({ count }) {
|
|
|
29
113
|
{
|
|
30
114
|
_$_.output_push(__out);
|
|
31
115
|
__out = '';
|
|
32
|
-
_$_.render_expression(
|
|
116
|
+
_$_.render_expression(data.value);
|
|
33
117
|
}
|
|
34
118
|
|
|
35
119
|
__out += '</p>';
|
|
@@ -40,7 +124,7 @@ function ServerCallResult({ count }) {
|
|
|
40
124
|
|
|
41
125
|
export function AsyncWithServerCall() {
|
|
42
126
|
return _$_.tsrx_element(() => {
|
|
43
|
-
|
|
127
|
+
const count = _$_.track(0, '14891754');
|
|
44
128
|
|
|
45
129
|
_$_.regular_block(() => {
|
|
46
130
|
let __out = '';
|
|
@@ -57,7 +141,7 @@ export function AsyncWithServerCall() {
|
|
|
57
141
|
|
|
58
142
|
{
|
|
59
143
|
const comp = ServerCallResult;
|
|
60
|
-
const args = [{ count
|
|
144
|
+
const args = [{ count }];
|
|
61
145
|
|
|
62
146
|
_$_.output_push(__out);
|
|
63
147
|
__out = '';
|
|
@@ -89,7 +173,7 @@ export function AsyncSimpleValue() {
|
|
|
89
173
|
|
|
90
174
|
__out += '<!--[-->';
|
|
91
175
|
|
|
92
|
-
|
|
176
|
+
const data = _$_.track_async(() => Promise.resolve('hydrated value'), 'f325448a');
|
|
93
177
|
|
|
94
178
|
_$_.output_push(__out);
|
|
95
179
|
__out = '';
|
|
@@ -102,7 +186,7 @@ export function AsyncSimpleValue() {
|
|
|
102
186
|
{
|
|
103
187
|
_$_.output_push(__out);
|
|
104
188
|
__out = '';
|
|
105
|
-
_$_.render_expression(
|
|
189
|
+
_$_.render_expression(data.value);
|
|
106
190
|
}
|
|
107
191
|
|
|
108
192
|
__out += '</p>';
|
|
@@ -142,7 +226,7 @@ export function AsyncNumericValue() {
|
|
|
142
226
|
|
|
143
227
|
__out += '<!--[-->';
|
|
144
228
|
|
|
145
|
-
|
|
229
|
+
const count = _$_.track_async(() => Promise.resolve(42), 'ab8199a0');
|
|
146
230
|
|
|
147
231
|
_$_.output_push(__out);
|
|
148
232
|
__out = '';
|
|
@@ -155,7 +239,7 @@ export function AsyncNumericValue() {
|
|
|
155
239
|
{
|
|
156
240
|
_$_.output_push(__out);
|
|
157
241
|
__out = '';
|
|
158
|
-
_$_.render_expression(
|
|
242
|
+
_$_.render_expression(count.value);
|
|
159
243
|
}
|
|
160
244
|
|
|
161
245
|
__out += '</span>';
|
|
@@ -195,7 +279,7 @@ export function AsyncObjectValue() {
|
|
|
195
279
|
|
|
196
280
|
__out += '<!--[-->';
|
|
197
281
|
|
|
198
|
-
|
|
282
|
+
const user = _$_.track_async(() => Promise.resolve({ name: 'Alice', age: 30 }), 'fb7ad40b');
|
|
199
283
|
|
|
200
284
|
_$_.output_push(__out);
|
|
201
285
|
__out = '';
|
|
@@ -208,7 +292,7 @@ export function AsyncObjectValue() {
|
|
|
208
292
|
{
|
|
209
293
|
_$_.output_push(__out);
|
|
210
294
|
__out = '';
|
|
211
|
-
_$_.render_expression(
|
|
295
|
+
_$_.render_expression(user.value.name);
|
|
212
296
|
}
|
|
213
297
|
|
|
214
298
|
__out += '</span><span class="age">';
|
|
@@ -216,7 +300,7 @@ export function AsyncObjectValue() {
|
|
|
216
300
|
{
|
|
217
301
|
_$_.output_push(__out);
|
|
218
302
|
__out = '';
|
|
219
|
-
_$_.render_expression(
|
|
303
|
+
_$_.render_expression(user.value.age);
|
|
220
304
|
}
|
|
221
305
|
|
|
222
306
|
__out += '</span></div>';
|
|
@@ -256,8 +340,8 @@ export function AsyncMultipleValues() {
|
|
|
256
340
|
|
|
257
341
|
__out += '<!--[-->';
|
|
258
342
|
|
|
259
|
-
|
|
260
|
-
|
|
343
|
+
const first = _$_.track_async(() => Promise.resolve('alpha'), '99982de5');
|
|
344
|
+
const second = _$_.track_async(() => Promise.resolve('beta'), '1dea4c85');
|
|
261
345
|
|
|
262
346
|
_$_.output_push(__out);
|
|
263
347
|
__out = '';
|
|
@@ -270,7 +354,7 @@ export function AsyncMultipleValues() {
|
|
|
270
354
|
{
|
|
271
355
|
_$_.output_push(__out);
|
|
272
356
|
__out = '';
|
|
273
|
-
_$_.render_expression(
|
|
357
|
+
_$_.render_expression(first.value);
|
|
274
358
|
}
|
|
275
359
|
|
|
276
360
|
__out += '</span><span class="second">';
|
|
@@ -278,7 +362,7 @@ export function AsyncMultipleValues() {
|
|
|
278
362
|
{
|
|
279
363
|
_$_.output_push(__out);
|
|
280
364
|
__out = '';
|
|
281
|
-
_$_.render_expression(
|
|
365
|
+
_$_.render_expression(second.value);
|
|
282
366
|
}
|
|
283
367
|
|
|
284
368
|
__out += '</span></div>';
|
|
@@ -318,7 +402,7 @@ export function AsyncWithCatch() {
|
|
|
318
402
|
|
|
319
403
|
__out += '<!--[-->';
|
|
320
404
|
|
|
321
|
-
|
|
405
|
+
const data = _$_.track_async(() => Promise.reject(new Error('fetch failed')), 'c9d12acf');
|
|
322
406
|
|
|
323
407
|
_$_.output_push(__out);
|
|
324
408
|
__out = '';
|
|
@@ -331,7 +415,7 @@ export function AsyncWithCatch() {
|
|
|
331
415
|
{
|
|
332
416
|
_$_.output_push(__out);
|
|
333
417
|
__out = '';
|
|
334
|
-
_$_.render_expression(
|
|
418
|
+
_$_.render_expression(data.value);
|
|
335
419
|
}
|
|
336
420
|
|
|
337
421
|
__out += '</p>';
|
|
@@ -395,7 +479,7 @@ export function ChildWithError() {
|
|
|
395
479
|
|
|
396
480
|
__out += '<!--[-->';
|
|
397
481
|
|
|
398
|
-
|
|
482
|
+
const data = _$_.track_async(() => Promise.reject(new Error('child error')), 'cdd1adb8');
|
|
399
483
|
|
|
400
484
|
_$_.output_push(__out);
|
|
401
485
|
__out = '';
|
|
@@ -408,7 +492,7 @@ export function ChildWithError() {
|
|
|
408
492
|
{
|
|
409
493
|
_$_.output_push(__out);
|
|
410
494
|
__out = '';
|
|
411
|
-
_$_.render_expression(
|
|
495
|
+
_$_.render_expression(data.value);
|
|
412
496
|
}
|
|
413
497
|
|
|
414
498
|
__out += '</p>';
|
|
@@ -494,7 +578,7 @@ export function ParentWithCatch() {
|
|
|
494
578
|
|
|
495
579
|
function ReactiveDependencyResult({ count }) {
|
|
496
580
|
return _$_.tsrx_element(() => {
|
|
497
|
-
|
|
581
|
+
const data = _$_.track_async(() => Promise.resolve(`count-${count.value}`), '18c43c3a');
|
|
498
582
|
|
|
499
583
|
_$_.regular_block(() => {
|
|
500
584
|
let __out = '';
|
|
@@ -504,7 +588,7 @@ function ReactiveDependencyResult({ count }) {
|
|
|
504
588
|
{
|
|
505
589
|
_$_.output_push(__out);
|
|
506
590
|
__out = '';
|
|
507
|
-
_$_.render_expression(
|
|
591
|
+
_$_.render_expression(data.value);
|
|
508
592
|
}
|
|
509
593
|
|
|
510
594
|
__out += '</p>';
|
|
@@ -515,7 +599,50 @@ function ReactiveDependencyResult({ count }) {
|
|
|
515
599
|
|
|
516
600
|
export function AsyncWithReactiveDependency() {
|
|
517
601
|
return _$_.tsrx_element(() => {
|
|
518
|
-
|
|
602
|
+
const count = _$_.track(0, 'd5dcc1d3');
|
|
603
|
+
|
|
604
|
+
_$_.regular_block(() => {
|
|
605
|
+
let __out = '';
|
|
606
|
+
|
|
607
|
+
__out += '<button class="increment">increment</button>';
|
|
608
|
+
_$_.output_push(__out);
|
|
609
|
+
__out = '';
|
|
610
|
+
|
|
611
|
+
_$_.try_block(
|
|
612
|
+
() => {
|
|
613
|
+
let __out = '';
|
|
614
|
+
|
|
615
|
+
__out += '<!--[-->';
|
|
616
|
+
|
|
617
|
+
{
|
|
618
|
+
const comp = ReactiveDependencyResult;
|
|
619
|
+
const args = [{ count }];
|
|
620
|
+
|
|
621
|
+
_$_.output_push(__out);
|
|
622
|
+
__out = '';
|
|
623
|
+
_$_.render_component(comp, ...args);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
__out += '<!--]-->';
|
|
627
|
+
_$_.output_push(__out);
|
|
628
|
+
},
|
|
629
|
+
null,
|
|
630
|
+
() => {
|
|
631
|
+
let __out = '';
|
|
632
|
+
|
|
633
|
+
__out += '<!--[--><p class="loading">loading...</p><!--]-->';
|
|
634
|
+
_$_.output_push(__out);
|
|
635
|
+
}
|
|
636
|
+
);
|
|
637
|
+
|
|
638
|
+
_$_.output_push(__out);
|
|
639
|
+
});
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
export function AsyncWithReadOnlyDependency() {
|
|
644
|
+
return _$_.tsrx_element(() => {
|
|
645
|
+
const count = _$_.track(0, '75a97b64');
|
|
519
646
|
|
|
520
647
|
_$_.regular_block(() => {
|
|
521
648
|
let __out = '';
|
|
@@ -532,7 +659,7 @@ export function AsyncWithReactiveDependency() {
|
|
|
532
659
|
|
|
533
660
|
{
|
|
534
661
|
const comp = ReactiveDependencyResult;
|
|
535
|
-
const args = [{ count:
|
|
662
|
+
const args = [{ count: count.readOnly() }];
|
|
536
663
|
|
|
537
664
|
_$_.output_push(__out);
|
|
538
665
|
__out = '';
|
|
@@ -48,7 +48,7 @@ export function RootThrows() {
|
|
|
48
48
|
|
|
49
49
|
export function RootAsyncDirect() {
|
|
50
50
|
return _$_.tsrx_element(() => {
|
|
51
|
-
|
|
51
|
+
const value = _$_.track_async(() => Promise.resolve('root async value'), 'd6bf9e33');
|
|
52
52
|
|
|
53
53
|
_$_.regular_block(() => {
|
|
54
54
|
let __out = '';
|
|
@@ -58,7 +58,7 @@ export function RootAsyncDirect() {
|
|
|
58
58
|
{
|
|
59
59
|
_$_.output_push(__out);
|
|
60
60
|
__out = '';
|
|
61
|
-
_$_.render_expression(
|
|
61
|
+
_$_.render_expression(value.value);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
__out += '</p>';
|
|
@@ -69,7 +69,7 @@ export function RootAsyncDirect() {
|
|
|
69
69
|
|
|
70
70
|
export function RootAsyncRejects() {
|
|
71
71
|
return _$_.tsrx_element(() => {
|
|
72
|
-
|
|
72
|
+
const value = _$_.track_async(() => Promise.reject(new Error('root async failed')), 'd2fe7b64');
|
|
73
73
|
|
|
74
74
|
_$_.regular_block(() => {
|
|
75
75
|
let __out = '';
|
|
@@ -79,7 +79,7 @@ export function RootAsyncRejects() {
|
|
|
79
79
|
{
|
|
80
80
|
_$_.output_push(__out);
|
|
81
81
|
__out = '';
|
|
82
|
-
_$_.render_expression(
|
|
82
|
+
_$_.render_expression(value.value);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
__out += '</p>';
|
|
@@ -134,14 +134,14 @@ export function AsyncListInTryPending() {
|
|
|
134
134
|
|
|
135
135
|
function AsyncList() {
|
|
136
136
|
return _$_.tsrx_element(() => {
|
|
137
|
-
|
|
137
|
+
const items = _$_.track_async(() => Promise.resolve(['alpha', 'beta', 'gamma']), 'b3d31627');
|
|
138
138
|
|
|
139
139
|
_$_.regular_block(() => {
|
|
140
140
|
let __out = '';
|
|
141
141
|
|
|
142
142
|
__out += '<ul class="items"><!--[-->';
|
|
143
143
|
|
|
144
|
-
for (let item of
|
|
144
|
+
for (let item of items.value) {
|
|
145
145
|
__out += '<li>';
|
|
146
146
|
|
|
147
147
|
{
|
|
@@ -202,7 +202,7 @@ export function AsyncTryWithLeadingSibling() {
|
|
|
202
202
|
|
|
203
203
|
function AsyncContent() {
|
|
204
204
|
return _$_.tsrx_element(() => {
|
|
205
|
-
|
|
205
|
+
const value = _$_.track_async(() => Promise.resolve('ready'), '15ea8758');
|
|
206
206
|
|
|
207
207
|
_$_.regular_block(() => {
|
|
208
208
|
let __out = '';
|
|
@@ -212,7 +212,7 @@ function AsyncContent() {
|
|
|
212
212
|
{
|
|
213
213
|
_$_.output_push(__out);
|
|
214
214
|
__out = '';
|
|
215
|
-
_$_.render_expression(
|
|
215
|
+
_$_.render_expression(value.value);
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
__out += '</div>';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import * as _$_ from 'ripple/internal/server';
|
|
3
|
+
|
|
4
|
+
import { track } from 'ripple/server';
|
|
5
|
+
|
|
6
|
+
export function TypedText() {
|
|
7
|
+
return _$_.tsrx_element(() => {
|
|
8
|
+
const row = _$_.track({ label: '<first>', count: 2 }, '9bf2304a');
|
|
9
|
+
|
|
10
|
+
_$_.regular_block(() => {
|
|
11
|
+
let __out = '';
|
|
12
|
+
|
|
13
|
+
__out += '<div class="typed-run">' + _$_.escape('value: ' + (row.value.label + String(row.value.count ?? ''))) + '<span>tail</span></div><p class="typed-number">' + _$_.escape((0, row.value.count)) + '</p><button>update</button>';
|
|
14
|
+
_$_.output_push(__out);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Basic static components for hydration testing
|
|
2
2
|
import { track } from 'ripple';
|
|
3
|
-
import type { Children } from 'ripple';
|
|
3
|
+
import type { Children, Derived } from 'ripple';
|
|
4
4
|
|
|
5
5
|
export function StaticText() @{
|
|
6
6
|
<div>{'Hello World'}</div>
|
|
@@ -180,8 +180,8 @@ export function DynamicArrayFromCall() @{
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
export function DynamicArrayFromTrack() @{
|
|
183
|
-
|
|
184
|
-
<div class="dynamic-array-track">{items}</div>
|
|
183
|
+
const items = track(['start:', ['one', 2], true, null, false, ':end']);
|
|
184
|
+
<div class="dynamic-array-track">{items.value}</div>
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
export function DynamicArrayFromConditional() @{
|
|
@@ -228,15 +228,29 @@ export function TsxDeclaredBeforeTopLevelTsx() @{
|
|
|
228
228
|
</>
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
|
|
232
|
-
|
|
231
|
+
// Untyped children render through the generic expression path (hydration
|
|
232
|
+
// markers); typed string children hydrate a text node directly.
|
|
233
|
+
function TextProp({ children }: { children: Derived<unknown> }) @{
|
|
234
|
+
<div class="text-prop">{children.value}</div>
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function TypedTextProp({ children }: { children: Derived<string> }) @{
|
|
238
|
+
<div class="text-prop">{children.value}</div>
|
|
233
239
|
}
|
|
234
240
|
|
|
235
241
|
export function TextPropWithToggle() @{
|
|
236
|
-
|
|
242
|
+
const show = track(false);
|
|
237
243
|
<>
|
|
238
|
-
<TextProp children={show ? 'hello' : ''} />
|
|
239
|
-
<button class="show-text" onClick={() => (show = true)}>{'Show'}</button>
|
|
244
|
+
<TextProp children={track(() => (show.value ? 'hello' : ''))} />
|
|
245
|
+
<button class="show-text" onClick={() => (show.value = true)}>{'Show'}</button>
|
|
246
|
+
</>
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export function TypedTextPropWithToggle() @{
|
|
250
|
+
const show = track(false);
|
|
251
|
+
<>
|
|
252
|
+
<TypedTextProp children={track(() => (show.value ? 'hello' : ''))} />
|
|
253
|
+
<button class="show-text" onClick={() => (show.value = true)}>{'Show'}</button>
|
|
240
254
|
</>
|
|
241
255
|
}
|
|
242
256
|
|
|
@@ -369,3 +383,25 @@ export function FragmentLeadsWithPrimitiveCall() @{
|
|
|
369
383
|
// prettier-ignore
|
|
370
384
|
<div><PrimitiveCallLead /></div>
|
|
371
385
|
}
|
|
386
|
+
|
|
387
|
+
export function PrimitiveTextCalls() @{
|
|
388
|
+
const count = track(2);
|
|
389
|
+
<>
|
|
390
|
+
// prettier-ignore
|
|
391
|
+
<div class="primitive-calls">sum: {Number(count.value) + Number(count.value)}; big: {BigInt(count.value)}</div>
|
|
392
|
+
<button onClick={() => count.value++}>update</button>
|
|
393
|
+
</>
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export function ShadowedTextCalls() @{
|
|
397
|
+
const String = () => <b>string</b>;
|
|
398
|
+
const Number = () => <b>number</b>;
|
|
399
|
+
const BigInt = () => <b>bigint</b>;
|
|
400
|
+
const Date = () => <b>date</b>;
|
|
401
|
+
<>
|
|
402
|
+
<p>before{String()}after</p>
|
|
403
|
+
<p>before{Number()}after</p>
|
|
404
|
+
<p>before{BigInt()}after</p>
|
|
405
|
+
<p>before{Date()}after</p>
|
|
406
|
+
</>
|
|
407
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Children } from 'ripple';
|
|
2
2
|
|
|
3
|
-
export function Layout(
|
|
3
|
+
export function Layout({ children }: { children?: Children }) @{
|
|
4
4
|
<div class="layout">{children}</div>
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export function TextWrappedLayout(
|
|
7
|
+
export function TextWrappedLayout({ children }: { children?: Children }) @{
|
|
8
8
|
<div class="layout">
|
|
9
9
|
{'before'}
|
|
10
10
|
{children}
|