ripple 0.3.91 → 0.3.93
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 +32 -0
- package/package.json +1 -1
- package/src/constants.js +13 -0
- package/src/runtime/index-client.js +5 -1
- package/src/runtime/internal/client/hydration.js +4 -1
- package/src/runtime/internal/client/template.js +2 -1
- package/src/runtime/internal/client/try.js +199 -9
- package/src/runtime/internal/client/types.d.ts +25 -0
- package/src/runtime/internal/server/blocks.js +47 -9
- package/src/runtime/internal/server/css-registry.js +1 -1
- package/src/runtime/internal/server/index.js +546 -69
- package/src/runtime/internal/server/stream-runtime.js +173 -0
- package/src/server/index.js +2 -2
- package/src/utils/track-async-serialization.js +1 -1
- package/tests/hydration/compiled/client/streaming.js +448 -0
- package/tests/hydration/compiled/server/streaming.js +476 -0
- package/tests/hydration/components/streaming.tsrx +164 -0
- package/tests/hydration/streaming.test.js +342 -0
- package/tests/hydration/track-async-serialization.test.js +3 -3
- package/tests/hydration/try.test.js +4 -4
- package/tests/server/streaming-ssr.test.tsrx +714 -4
- package/tests/server/track-async-serialization.test.tsrx +9 -9
- package/types/server.d.ts +22 -1
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import * as _$_ from 'ripple/internal/server';
|
|
3
|
+
|
|
4
|
+
import { track, trackAsync } from 'ripple/server';
|
|
5
|
+
|
|
6
|
+
function make() {
|
|
7
|
+
let resolve = () => {};
|
|
8
|
+
let reject = () => {};
|
|
9
|
+
|
|
10
|
+
const promise = new Promise((res, rej) => {
|
|
11
|
+
resolve = res;
|
|
12
|
+
reject = rej;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return { promise, resolve, reject };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const controls = {};
|
|
19
|
+
|
|
20
|
+
export function resetControls() {
|
|
21
|
+
controls.basic = make();
|
|
22
|
+
controls.catchOnly = make();
|
|
23
|
+
controls.rejects = make();
|
|
24
|
+
controls.noCatch = make();
|
|
25
|
+
controls.outer = make();
|
|
26
|
+
controls.inner = make();
|
|
27
|
+
controls.rootDirect = make();
|
|
28
|
+
controls.head = make();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
resetControls();
|
|
32
|
+
|
|
33
|
+
function BasicContent() {
|
|
34
|
+
return _$_.tsrx_element(() => {
|
|
35
|
+
let lazy = _$_.track_async(() => controls.basic.promise, '703e438e');
|
|
36
|
+
let lazy_1 = _$_.track(0, '928bce39');
|
|
37
|
+
|
|
38
|
+
_$_.regular_block(() => {
|
|
39
|
+
let __out = '';
|
|
40
|
+
|
|
41
|
+
__out += '<div class="resolved"><span class="value">' + _$_.escape(lazy.value + ':' + lazy_1.value) + '</span><button class="inc">inc</button></div>';
|
|
42
|
+
_$_.output_push(__out);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function StreamPending() {
|
|
48
|
+
return _$_.tsrx_element(() => {
|
|
49
|
+
_$_.regular_block(() => {
|
|
50
|
+
let __out = '';
|
|
51
|
+
|
|
52
|
+
__out += '<span class="before">before</span>';
|
|
53
|
+
_$_.output_push(__out);
|
|
54
|
+
__out = '';
|
|
55
|
+
|
|
56
|
+
_$_.try_block(
|
|
57
|
+
() => {
|
|
58
|
+
let __out = '';
|
|
59
|
+
|
|
60
|
+
__out += '<!--[-->';
|
|
61
|
+
|
|
62
|
+
{
|
|
63
|
+
const comp = BasicContent;
|
|
64
|
+
const args = [{}];
|
|
65
|
+
|
|
66
|
+
_$_.output_push(__out);
|
|
67
|
+
__out = '';
|
|
68
|
+
_$_.render_component(comp, ...args);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
__out += '<footer class="after-async">after-async</footer><!--]-->';
|
|
72
|
+
_$_.output_push(__out);
|
|
73
|
+
},
|
|
74
|
+
null,
|
|
75
|
+
() => {
|
|
76
|
+
let __out = '';
|
|
77
|
+
|
|
78
|
+
__out += '<!--[--><p class="loading">loading...</p><!--]-->';
|
|
79
|
+
_$_.output_push(__out);
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
__out += '<span class="sibling-after">sibling-after</span>';
|
|
84
|
+
_$_.output_push(__out);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function CatchOnlyContent() {
|
|
90
|
+
return _$_.tsrx_element(() => {
|
|
91
|
+
let lazy_2 = _$_.track_async(() => controls.catchOnly.promise, '50f939c6');
|
|
92
|
+
|
|
93
|
+
_$_.regular_block(() => {
|
|
94
|
+
let __out = '';
|
|
95
|
+
|
|
96
|
+
__out += '<p class="resolved">' + _$_.escape(lazy_2.value) + '</p>';
|
|
97
|
+
_$_.output_push(__out);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function StreamCatchOnly() {
|
|
103
|
+
return _$_.tsrx_element(() => {
|
|
104
|
+
_$_.regular_block(() => {
|
|
105
|
+
let __out = '';
|
|
106
|
+
|
|
107
|
+
__out += '<span class="before">before</span>';
|
|
108
|
+
_$_.output_push(__out);
|
|
109
|
+
__out = '';
|
|
110
|
+
|
|
111
|
+
_$_.try_block(
|
|
112
|
+
() => {
|
|
113
|
+
let __out = '';
|
|
114
|
+
|
|
115
|
+
__out += '<!--[-->';
|
|
116
|
+
|
|
117
|
+
{
|
|
118
|
+
const comp = CatchOnlyContent;
|
|
119
|
+
const args = [{}];
|
|
120
|
+
|
|
121
|
+
_$_.output_push(__out);
|
|
122
|
+
__out = '';
|
|
123
|
+
_$_.render_component(comp, ...args);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
__out += '<!--]-->';
|
|
127
|
+
_$_.output_push(__out);
|
|
128
|
+
},
|
|
129
|
+
(e) => {
|
|
130
|
+
let __out = '';
|
|
131
|
+
|
|
132
|
+
__out += '<!--[--><em class="caught">' + _$_.escape(e.message) + '</em><!--]-->';
|
|
133
|
+
_$_.output_push(__out);
|
|
134
|
+
},
|
|
135
|
+
null
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
_$_.output_push(__out);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function RejectContent() {
|
|
144
|
+
return _$_.tsrx_element(() => {
|
|
145
|
+
let lazy_3 = _$_.track_async(() => controls.rejects.promise, '96452a54');
|
|
146
|
+
|
|
147
|
+
_$_.regular_block(() => {
|
|
148
|
+
let __out = '';
|
|
149
|
+
|
|
150
|
+
__out += '<p class="resolved">' + _$_.escape(lazy_3.value) + '</p>';
|
|
151
|
+
_$_.output_push(__out);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function StreamRejects() {
|
|
157
|
+
return _$_.tsrx_element(() => {
|
|
158
|
+
_$_.try_block(
|
|
159
|
+
() => {
|
|
160
|
+
let __out = '';
|
|
161
|
+
|
|
162
|
+
__out += '<!--[-->';
|
|
163
|
+
_$_.output_push(__out);
|
|
164
|
+
__out = '';
|
|
165
|
+
|
|
166
|
+
_$_.regular_block(() => {
|
|
167
|
+
{
|
|
168
|
+
const comp = RejectContent;
|
|
169
|
+
const args = [{}];
|
|
170
|
+
|
|
171
|
+
_$_.render_component(comp, ...args);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
__out += '<!--]-->';
|
|
176
|
+
_$_.output_push(__out);
|
|
177
|
+
},
|
|
178
|
+
(e) => {
|
|
179
|
+
let __out = '';
|
|
180
|
+
|
|
181
|
+
__out += '<!--[-->';
|
|
182
|
+
_$_.output_push(__out);
|
|
183
|
+
__out = '';
|
|
184
|
+
|
|
185
|
+
_$_.regular_block(() => {
|
|
186
|
+
let __out = '';
|
|
187
|
+
|
|
188
|
+
__out += '<em class="caught">' + _$_.escape(e.message) + '</em>';
|
|
189
|
+
_$_.output_push(__out);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
__out += '<!--]-->';
|
|
193
|
+
_$_.output_push(__out);
|
|
194
|
+
},
|
|
195
|
+
() => {
|
|
196
|
+
let __out = '';
|
|
197
|
+
|
|
198
|
+
__out += '<!--[-->';
|
|
199
|
+
_$_.output_push(__out);
|
|
200
|
+
__out = '';
|
|
201
|
+
|
|
202
|
+
_$_.regular_block(() => {
|
|
203
|
+
let __out = '';
|
|
204
|
+
|
|
205
|
+
__out += '<p class="loading">loading...</p>';
|
|
206
|
+
_$_.output_push(__out);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
__out += '<!--]-->';
|
|
210
|
+
_$_.output_push(__out);
|
|
211
|
+
}
|
|
212
|
+
);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function NoCatchContent() {
|
|
217
|
+
return _$_.tsrx_element(() => {
|
|
218
|
+
let lazy_4 = _$_.track_async(() => controls.noCatch.promise, '6baa716b');
|
|
219
|
+
|
|
220
|
+
_$_.regular_block(() => {
|
|
221
|
+
let __out = '';
|
|
222
|
+
|
|
223
|
+
__out += '<p class="resolved">' + _$_.escape(lazy_4.value) + '</p>';
|
|
224
|
+
_$_.output_push(__out);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export function StreamNoCatch() {
|
|
230
|
+
return _$_.tsrx_element(() => {
|
|
231
|
+
_$_.try_block(
|
|
232
|
+
() => {
|
|
233
|
+
let __out = '';
|
|
234
|
+
|
|
235
|
+
__out += '<!--[-->';
|
|
236
|
+
_$_.output_push(__out);
|
|
237
|
+
__out = '';
|
|
238
|
+
|
|
239
|
+
_$_.regular_block(() => {
|
|
240
|
+
{
|
|
241
|
+
const comp = NoCatchContent;
|
|
242
|
+
const args = [{}];
|
|
243
|
+
|
|
244
|
+
_$_.render_component(comp, ...args);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
__out += '<!--]-->';
|
|
249
|
+
_$_.output_push(__out);
|
|
250
|
+
},
|
|
251
|
+
null,
|
|
252
|
+
() => {
|
|
253
|
+
let __out = '';
|
|
254
|
+
|
|
255
|
+
__out += '<!--[-->';
|
|
256
|
+
_$_.output_push(__out);
|
|
257
|
+
__out = '';
|
|
258
|
+
|
|
259
|
+
_$_.regular_block(() => {
|
|
260
|
+
let __out = '';
|
|
261
|
+
|
|
262
|
+
__out += '<p class="loading">loading...</p>';
|
|
263
|
+
_$_.output_push(__out);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
__out += '<!--]-->';
|
|
267
|
+
_$_.output_push(__out);
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export function RootCatch({ error, reset }) {
|
|
274
|
+
return _$_.tsrx_element(() => {
|
|
275
|
+
_$_.regular_block(() => {
|
|
276
|
+
let __out = '';
|
|
277
|
+
|
|
278
|
+
__out += '<section class="root-catch">' + _$_.escape(error.message) + '</section>';
|
|
279
|
+
_$_.output_push(__out);
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export function RootPending() {
|
|
285
|
+
return _$_.tsrx_element(() => {
|
|
286
|
+
_$_.regular_block(() => {
|
|
287
|
+
let __out = '';
|
|
288
|
+
|
|
289
|
+
__out += '<p class="root-pending">root-loading</p>';
|
|
290
|
+
_$_.output_push(__out);
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function HeadContent() {
|
|
296
|
+
return _$_.tsrx_element(() => {
|
|
297
|
+
let lazy_5 = _$_.track_async(() => controls.head.promise, '9cd3c3cd');
|
|
298
|
+
|
|
299
|
+
_$_.regular_block(() => {
|
|
300
|
+
let __out = '';
|
|
301
|
+
|
|
302
|
+
__out += '<!--[--><!--[-->';
|
|
303
|
+
|
|
304
|
+
if (lazy_5.value) {
|
|
305
|
+
__out += '<!--[--><p class="head-content">' + _$_.escape(lazy_5.value) + '</p>';
|
|
306
|
+
_$_.output_push(__out);
|
|
307
|
+
__out = '';
|
|
308
|
+
_$_.set_output_target('head');
|
|
309
|
+
__out += '<!--e957a664--><title>' + _$_.escape('title:' + lazy_5.value) + '</title>';
|
|
310
|
+
_$_.output_push(__out);
|
|
311
|
+
__out = '';
|
|
312
|
+
_$_.set_output_target(null);
|
|
313
|
+
__out += '<!--]-->';
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
__out += '<!--]--><!--]-->';
|
|
317
|
+
_$_.output_push(__out);
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export function StreamHead() {
|
|
323
|
+
return _$_.tsrx_element(() => {
|
|
324
|
+
_$_.try_block(
|
|
325
|
+
() => {
|
|
326
|
+
let __out = '';
|
|
327
|
+
|
|
328
|
+
__out += '<!--[-->';
|
|
329
|
+
_$_.output_push(__out);
|
|
330
|
+
__out = '';
|
|
331
|
+
|
|
332
|
+
_$_.regular_block(() => {
|
|
333
|
+
{
|
|
334
|
+
const comp = HeadContent;
|
|
335
|
+
const args = [{}];
|
|
336
|
+
|
|
337
|
+
_$_.render_component(comp, ...args);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
__out += '<!--]-->';
|
|
342
|
+
_$_.output_push(__out);
|
|
343
|
+
},
|
|
344
|
+
null,
|
|
345
|
+
() => {
|
|
346
|
+
let __out = '';
|
|
347
|
+
|
|
348
|
+
__out += '<!--[-->';
|
|
349
|
+
_$_.output_push(__out);
|
|
350
|
+
__out = '';
|
|
351
|
+
|
|
352
|
+
_$_.regular_block(() => {
|
|
353
|
+
let __out = '';
|
|
354
|
+
|
|
355
|
+
__out += '<p class="loading">loading...</p>';
|
|
356
|
+
_$_.output_push(__out);
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
__out += '<!--]-->';
|
|
360
|
+
_$_.output_push(__out);
|
|
361
|
+
}
|
|
362
|
+
);
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export function StreamRootDirect() {
|
|
367
|
+
return _$_.tsrx_element(() => {
|
|
368
|
+
let lazy_6 = _$_.track_async(() => controls.rootDirect.promise, 'bc9e61da');
|
|
369
|
+
|
|
370
|
+
_$_.regular_block(() => {
|
|
371
|
+
let __out = '';
|
|
372
|
+
|
|
373
|
+
__out += '<p class="root-async">' + _$_.escape(lazy_6.value) + '</p>';
|
|
374
|
+
_$_.output_push(__out);
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function OuterContent() {
|
|
380
|
+
return _$_.tsrx_element(() => {
|
|
381
|
+
let lazy_7 = _$_.track_async(() => controls.outer.promise, '35931cce');
|
|
382
|
+
|
|
383
|
+
_$_.regular_block(() => {
|
|
384
|
+
let __out = '';
|
|
385
|
+
|
|
386
|
+
__out += '<p class="outer">' + _$_.escape(lazy_7.value) + '</p>';
|
|
387
|
+
_$_.output_push(__out);
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
function InnerContent() {
|
|
393
|
+
return _$_.tsrx_element(() => {
|
|
394
|
+
let lazy_8 = _$_.track_async(() => controls.inner.promise, '6c7d38ed');
|
|
395
|
+
|
|
396
|
+
_$_.regular_block(() => {
|
|
397
|
+
let __out = '';
|
|
398
|
+
|
|
399
|
+
__out += '<p class="inner">' + _$_.escape(lazy_8.value) + '</p>';
|
|
400
|
+
_$_.output_push(__out);
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
export function StreamNested() {
|
|
406
|
+
return _$_.tsrx_element(() => {
|
|
407
|
+
_$_.try_block(
|
|
408
|
+
() => {
|
|
409
|
+
let __out = '';
|
|
410
|
+
|
|
411
|
+
__out += '<!--[-->';
|
|
412
|
+
_$_.output_push(__out);
|
|
413
|
+
__out = '';
|
|
414
|
+
|
|
415
|
+
_$_.regular_block(() => {
|
|
416
|
+
{
|
|
417
|
+
{
|
|
418
|
+
const comp = OuterContent;
|
|
419
|
+
const args = [{}];
|
|
420
|
+
|
|
421
|
+
_$_.render_component(comp, ...args);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
_$_.try_block(
|
|
425
|
+
() => {
|
|
426
|
+
let __out = '';
|
|
427
|
+
|
|
428
|
+
__out += '<!--[-->';
|
|
429
|
+
|
|
430
|
+
{
|
|
431
|
+
const comp = InnerContent;
|
|
432
|
+
const args = [{}];
|
|
433
|
+
|
|
434
|
+
_$_.output_push(__out);
|
|
435
|
+
__out = '';
|
|
436
|
+
_$_.render_component(comp, ...args);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
__out += '<!--]-->';
|
|
440
|
+
_$_.output_push(__out);
|
|
441
|
+
},
|
|
442
|
+
null,
|
|
443
|
+
() => {
|
|
444
|
+
let __out = '';
|
|
445
|
+
|
|
446
|
+
__out += '<!--[--><p class="inner-loading">inner-loading</p><!--]-->';
|
|
447
|
+
_$_.output_push(__out);
|
|
448
|
+
}
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
__out += '<!--]-->';
|
|
454
|
+
_$_.output_push(__out);
|
|
455
|
+
},
|
|
456
|
+
null,
|
|
457
|
+
() => {
|
|
458
|
+
let __out = '';
|
|
459
|
+
|
|
460
|
+
__out += '<!--[-->';
|
|
461
|
+
_$_.output_push(__out);
|
|
462
|
+
__out = '';
|
|
463
|
+
|
|
464
|
+
_$_.regular_block(() => {
|
|
465
|
+
let __out = '';
|
|
466
|
+
|
|
467
|
+
__out += '<p class="outer-loading">outer-loading</p>';
|
|
468
|
+
_$_.output_push(__out);
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
__out += '<!--]-->';
|
|
472
|
+
_$_.output_push(__out);
|
|
473
|
+
}
|
|
474
|
+
);
|
|
475
|
+
});
|
|
476
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { track, trackAsync } from 'ripple';
|
|
2
|
+
|
|
3
|
+
interface Control {
|
|
4
|
+
promise: Promise<string>;
|
|
5
|
+
resolve: (value: string) => void;
|
|
6
|
+
reject: (reason?: unknown) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function make(): Control {
|
|
10
|
+
let resolve: (value: string) => void = () => {};
|
|
11
|
+
let reject: (reason?: unknown) => void = () => {};
|
|
12
|
+
const promise = new Promise<string>((res, rej) => {
|
|
13
|
+
resolve = res;
|
|
14
|
+
reject = rej;
|
|
15
|
+
});
|
|
16
|
+
return { promise, resolve, reject };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const controls: Record<string, Control> = {};
|
|
20
|
+
|
|
21
|
+
export function resetControls() {
|
|
22
|
+
controls.basic = make();
|
|
23
|
+
controls.catchOnly = make();
|
|
24
|
+
controls.rejects = make();
|
|
25
|
+
controls.noCatch = make();
|
|
26
|
+
controls.outer = make();
|
|
27
|
+
controls.inner = make();
|
|
28
|
+
controls.rootDirect = make();
|
|
29
|
+
controls.head = make();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
resetControls();
|
|
33
|
+
|
|
34
|
+
function BasicContent() @{
|
|
35
|
+
let &[data] = trackAsync(() => controls.basic.promise);
|
|
36
|
+
let &[count] = track(0);
|
|
37
|
+
<div class="resolved">
|
|
38
|
+
<span class="value">
|
|
39
|
+
{data + ':' + count}
|
|
40
|
+
</span>
|
|
41
|
+
<button class="inc" onClick={() => count++}>{'inc'}</button>
|
|
42
|
+
</div>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function StreamPending() @{
|
|
46
|
+
<>
|
|
47
|
+
<span class="before">{'before'}</span>
|
|
48
|
+
@try {
|
|
49
|
+
<>
|
|
50
|
+
<BasicContent />
|
|
51
|
+
<footer class="after-async">{'after-async'}</footer>
|
|
52
|
+
</>
|
|
53
|
+
} @pending {
|
|
54
|
+
<p class="loading">{'loading...'}</p>
|
|
55
|
+
}
|
|
56
|
+
<span class="sibling-after">{'sibling-after'}</span>
|
|
57
|
+
</>
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function CatchOnlyContent() @{
|
|
61
|
+
let &[data] = trackAsync(() => controls.catchOnly.promise);
|
|
62
|
+
<p class="resolved">{data}</p>
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function StreamCatchOnly() @{
|
|
66
|
+
<>
|
|
67
|
+
<span class="before">{'before'}</span>
|
|
68
|
+
@try {
|
|
69
|
+
<CatchOnlyContent />
|
|
70
|
+
} @catch (e: Error) {
|
|
71
|
+
<em class="caught">{e.message}</em>
|
|
72
|
+
}
|
|
73
|
+
</>
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function RejectContent() @{
|
|
77
|
+
let &[data] = trackAsync(() => controls.rejects.promise);
|
|
78
|
+
<p class="resolved">{data}</p>
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function StreamRejects() @{
|
|
82
|
+
@try {
|
|
83
|
+
<RejectContent />
|
|
84
|
+
} @pending {
|
|
85
|
+
<p class="loading">{'loading...'}</p>
|
|
86
|
+
} @catch (e: Error) {
|
|
87
|
+
<em class="caught">{e.message}</em>
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function NoCatchContent() @{
|
|
92
|
+
let &[data] = trackAsync(() => controls.noCatch.promise);
|
|
93
|
+
<p class="resolved">{data}</p>
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function StreamNoCatch() @{
|
|
97
|
+
@try {
|
|
98
|
+
<NoCatchContent />
|
|
99
|
+
} @pending {
|
|
100
|
+
<p class="loading">{'loading...'}</p>
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function RootCatch({ error, reset }: { error: Error; reset: () => void }) @{
|
|
105
|
+
<section class="root-catch" onClick={reset}>{error.message}</section>
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function RootPending() @{
|
|
109
|
+
<p class="root-pending">{'root-loading'}</p>
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function HeadContent() @{
|
|
113
|
+
let &[data] = trackAsync(() => controls.head.promise);
|
|
114
|
+
<>
|
|
115
|
+
@if (data) {
|
|
116
|
+
<>
|
|
117
|
+
<head>
|
|
118
|
+
<title>
|
|
119
|
+
{'title:' + data}
|
|
120
|
+
</title>
|
|
121
|
+
</head>
|
|
122
|
+
<p class="head-content">{data}</p>
|
|
123
|
+
</>
|
|
124
|
+
}
|
|
125
|
+
</>
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function StreamHead() @{
|
|
129
|
+
@try {
|
|
130
|
+
<HeadContent />
|
|
131
|
+
} @pending {
|
|
132
|
+
<p class="loading">{'loading...'}</p>
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function StreamRootDirect() @{
|
|
137
|
+
let &[data] = trackAsync(() => controls.rootDirect.promise);
|
|
138
|
+
<p class="root-async">{data}</p>
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function OuterContent() @{
|
|
142
|
+
let &[data] = trackAsync(() => controls.outer.promise);
|
|
143
|
+
<p class="outer">{data}</p>
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function InnerContent() @{
|
|
147
|
+
let &[data] = trackAsync(() => controls.inner.promise);
|
|
148
|
+
<p class="inner">{data}</p>
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function StreamNested() @{
|
|
152
|
+
@try {
|
|
153
|
+
<>
|
|
154
|
+
<OuterContent />
|
|
155
|
+
@try {
|
|
156
|
+
<InnerContent />
|
|
157
|
+
} @pending {
|
|
158
|
+
<p class="inner-loading">{'inner-loading'}</p>
|
|
159
|
+
}
|
|
160
|
+
</>
|
|
161
|
+
} @pending {
|
|
162
|
+
<p class="outer-loading">{'outer-loading'}</p>
|
|
163
|
+
}
|
|
164
|
+
}
|