ripple 0.3.72 → 0.3.74
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 +66 -0
- package/package.json +3 -3
- package/src/jsx-runtime.d.ts +2 -8
- package/src/runtime/index-client.js +3 -13
- package/src/runtime/internal/client/blocks.js +3 -25
- package/src/runtime/internal/client/for.js +80 -5
- package/src/runtime/internal/client/index.js +0 -2
- package/src/runtime/internal/client/types.d.ts +0 -10
- package/tests/client/__snapshots__/computed-properties.test.tsrx.snap +8 -0
- package/tests/client/__snapshots__/for.test.tsrx.snap +22 -0
- package/tests/client/__snapshots__/html.test.tsrx.snap +4 -0
- package/tests/client/array/array.copy-within.test.tsrx +19 -19
- package/tests/client/array/array.derived.test.tsrx +97 -109
- package/tests/client/array/array.iteration.test.tsrx +28 -28
- package/tests/client/array/array.mutations.test.tsrx +68 -68
- package/tests/client/array/array.static.test.tsrx +82 -92
- package/tests/client/array/array.to-methods.test.tsrx +15 -15
- package/tests/client/async-suspend.test.tsrx +180 -179
- package/tests/client/basic/__snapshots__/basic.attributes.test.tsrx.snap +2 -0
- package/tests/client/basic/__snapshots__/basic.rendering.test.tsrx.snap +4 -0
- package/tests/client/basic/basic.attributes.test.tsrx +273 -317
- package/tests/client/basic/basic.collections.test.tsrx +55 -61
- package/tests/client/basic/basic.components.test.tsrx +196 -218
- package/tests/client/basic/basic.errors.test.tsrx +70 -76
- package/tests/client/basic/basic.events.test.tsrx +80 -85
- package/tests/client/basic/basic.get-set.test.tsrx +54 -64
- package/tests/client/basic/basic.hmr.test.tsrx +15 -19
- package/tests/client/basic/basic.reactivity.test.tsrx +121 -135
- package/tests/client/basic/basic.rendering.test.tsrx +273 -178
- package/tests/client/basic/basic.utilities.test.tsrx +8 -10
- package/tests/client/boundaries.test.tsrx +18 -18
- package/tests/client/compiler/compiler.assignments.test.tsrx +77 -76
- package/tests/client/compiler/compiler.attributes.test.tsrx +18 -14
- package/tests/client/compiler/compiler.basic.test.tsrx +357 -288
- package/tests/client/compiler/compiler.regex.test.tsrx +40 -44
- package/tests/client/compiler/compiler.tracked-access.test.tsrx +57 -38
- package/tests/client/compiler/compiler.try-in-function.test.tsrx +16 -16
- package/tests/client/compiler/compiler.typescript.test.tsrx +4 -3
- package/tests/client/composite/composite.dynamic-components.test.tsrx +41 -44
- package/tests/client/composite/composite.generics.test.tsrx +165 -167
- package/tests/client/composite/composite.props.test.tsrx +66 -74
- package/tests/client/composite/composite.reactivity.test.tsrx +132 -166
- package/tests/client/composite/composite.render.test.tsrx +92 -101
- package/tests/client/computed-properties.test.tsrx +14 -18
- package/tests/client/context.test.tsrx +14 -18
- package/tests/client/css/global-additional-cases.test.tsrx +491 -437
- package/tests/client/css/global-advanced-selectors.test.tsrx +169 -153
- package/tests/client/css/global-at-rules.test.tsrx +71 -66
- package/tests/client/css/global-basic.test.tsrx +105 -98
- package/tests/client/css/global-classes-ids.test.tsrx +128 -114
- package/tests/client/css/global-combinators.test.tsrx +83 -78
- package/tests/client/css/global-complex-nesting.test.tsrx +134 -120
- package/tests/client/css/global-edge-cases.test.tsrx +138 -120
- package/tests/client/css/global-keyframes.test.tsrx +108 -96
- package/tests/client/css/global-nested.test.tsrx +88 -78
- package/tests/client/css/global-pseudo.test.tsrx +104 -98
- package/tests/client/css/global-scoping.test.tsrx +145 -125
- package/tests/client/css/style-identifier.test.tsrx +62 -69
- package/tests/client/date.test.tsrx +83 -83
- package/tests/client/dynamic-elements.test.tsrx +227 -283
- package/tests/client/events.test.tsrx +252 -266
- package/tests/client/for.test.tsrx +120 -127
- package/tests/client/head.test.tsrx +40 -48
- package/tests/client/html.test.tsrx +37 -49
- package/tests/client/input-value.test.tsrx +1125 -1354
- package/tests/client/lazy-array.test.tsrx +10 -16
- package/tests/client/lazy-destructuring.test.tsrx +169 -221
- package/tests/client/map.test.tsrx +39 -41
- package/tests/client/media-query.test.tsrx +15 -19
- package/tests/client/object.test.tsrx +46 -56
- package/tests/client/portal.test.tsrx +31 -37
- package/tests/client/ref.test.tsrx +173 -193
- package/tests/client/return.test.tsrx +62 -37
- package/tests/client/set.test.tsrx +33 -33
- package/tests/client/svg.test.tsrx +195 -215
- package/tests/client/switch.test.tsrx +201 -191
- package/tests/client/track-async-hydration.test.tsrx +14 -18
- package/tests/client/tracked-index-access.test.tsrx +18 -28
- package/tests/client/try.test.tsrx +494 -619
- package/tests/client/tsx.test.tsrx +286 -292
- package/tests/client/typescript-generics.test.tsrx +121 -129
- package/tests/client/url/url.derived.test.tsrx +21 -25
- package/tests/client/url/url.parsing.test.tsrx +35 -35
- package/tests/client/url/url.partial-removal.test.tsrx +32 -32
- package/tests/client/url/url.reactivity.test.tsrx +68 -72
- package/tests/client/url/url.serialization.test.tsrx +8 -8
- package/tests/client/url-search-params/url-search-params.derived.test.tsrx +21 -27
- package/tests/client/url-search-params/url-search-params.initialization.test.tsrx +16 -16
- package/tests/client/url-search-params/url-search-params.iteration.test.tsrx +37 -37
- package/tests/client/url-search-params/url-search-params.mutation.test.tsrx +56 -60
- package/tests/client/url-search-params/url-search-params.retrieval.test.tsrx +32 -34
- package/tests/client/url-search-params/url-search-params.serialization.test.tsrx +9 -9
- package/tests/client/url-search-params/url-search-params.tracked-url.test.tsrx +10 -10
- package/tests/hydration/compiled/client/basic.js +390 -319
- package/tests/hydration/compiled/client/composite.js +52 -44
- package/tests/hydration/compiled/client/for.js +734 -604
- package/tests/hydration/compiled/client/head.js +183 -103
- package/tests/hydration/compiled/client/html.js +93 -86
- package/tests/hydration/compiled/client/if-children.js +95 -71
- package/tests/hydration/compiled/client/if.js +113 -89
- package/tests/hydration/compiled/client/mixed-control-flow.js +225 -209
- package/tests/hydration/compiled/client/nested-control-flow.js +94 -98
- package/tests/hydration/compiled/client/reactivity.js +26 -24
- package/tests/hydration/compiled/client/return.js +8 -42
- package/tests/hydration/compiled/client/switch.js +208 -173
- package/tests/hydration/compiled/client/track-async-serialization.js +176 -128
- package/tests/hydration/compiled/client/try.js +29 -21
- package/tests/hydration/compiled/server/basic.js +210 -221
- package/tests/hydration/compiled/server/composite.js +13 -14
- package/tests/hydration/compiled/server/for.js +427 -444
- package/tests/hydration/compiled/server/head.js +199 -189
- package/tests/hydration/compiled/server/html.js +33 -41
- package/tests/hydration/compiled/server/if-children.js +114 -117
- package/tests/hydration/compiled/server/if.js +77 -83
- package/tests/hydration/compiled/server/mixed-control-flow.js +145 -150
- package/tests/hydration/compiled/server/nested-control-flow.js +10 -0
- package/tests/hydration/compiled/server/reactivity.js +24 -22
- package/tests/hydration/compiled/server/return.js +6 -18
- package/tests/hydration/compiled/server/switch.js +179 -176
- package/tests/hydration/compiled/server/track-async-serialization.js +88 -70
- package/tests/hydration/compiled/server/try.js +31 -35
- package/tests/hydration/components/basic.tsrx +216 -258
- package/tests/hydration/components/composite.tsrx +32 -42
- package/tests/hydration/components/events.tsrx +81 -101
- package/tests/hydration/components/for.tsrx +270 -336
- package/tests/hydration/components/head.tsrx +43 -39
- package/tests/hydration/components/hmr.tsrx +16 -22
- package/tests/hydration/components/html-in-template.tsrx +15 -21
- package/tests/hydration/components/html.tsrx +442 -526
- package/tests/hydration/components/if-children.tsrx +107 -125
- package/tests/hydration/components/if.tsrx +68 -90
- package/tests/hydration/components/mixed-control-flow.tsrx +65 -72
- package/tests/hydration/components/nested-control-flow.tsrx +202 -216
- package/tests/hydration/components/portal.tsrx +33 -41
- package/tests/hydration/components/reactivity.tsrx +26 -34
- package/tests/hydration/components/return.tsrx +4 -6
- package/tests/hydration/components/switch.tsrx +73 -78
- package/tests/hydration/components/track-async-serialization.tsrx +83 -93
- package/tests/hydration/components/try.tsrx +37 -51
- package/tests/hydration/switch.test.js +8 -8
- package/tests/server/await.test.tsrx +3 -3
- package/tests/server/basic.attributes.test.tsrx +117 -162
- package/tests/server/basic.components.test.tsrx +163 -193
- package/tests/server/basic.test.tsrx +298 -198
- package/tests/server/compiler.test.tsrx +142 -72
- package/tests/server/composite.props.test.tsrx +54 -58
- package/tests/server/composite.test.tsrx +165 -167
- package/tests/server/context.test.tsrx +13 -17
- package/tests/server/dynamic-elements.test.tsrx +103 -135
- package/tests/server/for.test.tsrx +115 -84
- package/tests/server/head.test.tsrx +31 -31
- package/tests/server/html-nesting-validation.test.tsrx +16 -8
- package/tests/server/if.test.tsrx +49 -59
- package/tests/server/lazy-destructuring.test.tsrx +288 -366
- package/tests/server/return.test.tsrx +58 -36
- package/tests/server/streaming-ssr.test.tsrx +4 -4
- package/tests/server/style-identifier.test.tsrx +58 -66
- package/tests/server/switch.test.tsrx +89 -97
- package/tests/server/track-async-serialization.test.tsrx +85 -103
- package/tests/server/try.test.tsrx +275 -360
- package/tests/utils/ref-types.test.js +72 -0
- package/tests/utils/vite-plugin-config.test.js +41 -74
- package/types/index.d.ts +1 -0
- package/src/runtime/internal/client/compat.js +0 -40
- package/tests/utils/compiler-compat-config.test.js +0 -38
|
@@ -18,15 +18,15 @@ describe('try block with catch and pending', () => {
|
|
|
18
18
|
resolve_value = resolve;
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
function App() {
|
|
22
|
-
|
|
21
|
+
function App() @{
|
|
22
|
+
<>
|
|
23
23
|
<span class="before">{'before'}</span>
|
|
24
|
-
try {
|
|
24
|
+
@try {
|
|
25
25
|
let &[data] = trackAsync(() => promise);
|
|
26
26
|
<p class="resolved">{data}</p>
|
|
27
|
-
} pending {}
|
|
27
|
+
} @pending {}
|
|
28
28
|
<span class="after">{'after'}</span>
|
|
29
|
-
|
|
29
|
+
</>
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
render(App);
|
|
@@ -49,22 +49,18 @@ describe('try block with catch and pending', () => {
|
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
it('catch block works when a child throws synchronously', async () => {
|
|
52
|
-
function App() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
</>;
|
|
52
|
+
function App() @{
|
|
53
|
+
@try {
|
|
54
|
+
<ThrowingChild />
|
|
55
|
+
} @pending {
|
|
56
|
+
<p>{'loading...'}</p>
|
|
57
|
+
} @catch (err) {
|
|
58
|
+
<p>{'caught error'}</p>
|
|
59
|
+
}
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
function ThrowingChild() {
|
|
65
|
-
|
|
66
|
-
throw new Error('sync error');
|
|
67
|
-
</>;
|
|
63
|
+
throw new Error('sync error');
|
|
68
64
|
}
|
|
69
65
|
|
|
70
66
|
render(App);
|
|
@@ -76,24 +72,20 @@ describe('try block with catch and pending', () => {
|
|
|
76
72
|
});
|
|
77
73
|
|
|
78
74
|
it('catch block works when component throws after trackAsync with pending block', async () => {
|
|
79
|
-
function App() {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
</>;
|
|
75
|
+
function App() @{
|
|
76
|
+
@try {
|
|
77
|
+
<ThrowingAfterAsync />
|
|
78
|
+
} @pending {
|
|
79
|
+
<p>{'loading...'}</p>
|
|
80
|
+
} @catch (err) {
|
|
81
|
+
<p>{'caught error'}</p>
|
|
82
|
+
}
|
|
89
83
|
}
|
|
90
84
|
|
|
91
|
-
function ThrowingAfterAsync() {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<p>{data}</p>
|
|
96
|
-
</>;
|
|
85
|
+
function ThrowingAfterAsync() @{
|
|
86
|
+
let &[data] = trackAsync(() => Promise.resolve('hello'));
|
|
87
|
+
throw new Error('error after await');
|
|
88
|
+
<p>{data}</p>
|
|
97
89
|
}
|
|
98
90
|
|
|
99
91
|
render(App);
|
|
@@ -106,17 +98,15 @@ describe('try block with catch and pending', () => {
|
|
|
106
98
|
});
|
|
107
99
|
|
|
108
100
|
it('catch block works when trackAsync rejects', async () => {
|
|
109
|
-
function App() {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
</>;
|
|
101
|
+
function App() @{
|
|
102
|
+
@try {
|
|
103
|
+
let &[data] = trackAsync(() => Promise.reject(new Error('rejected')));
|
|
104
|
+
<p>{data}</p>
|
|
105
|
+
} @pending {
|
|
106
|
+
<p>{'loading...'}</p>
|
|
107
|
+
} @catch (err) {
|
|
108
|
+
<p>{'caught rejection'}</p>
|
|
109
|
+
}
|
|
120
110
|
}
|
|
121
111
|
|
|
122
112
|
render(App);
|
|
@@ -147,19 +137,19 @@ describe('try block with catch and pending', () => {
|
|
|
147
137
|
return promise;
|
|
148
138
|
}
|
|
149
139
|
|
|
150
|
-
function App() {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
try {
|
|
140
|
+
function App() @{
|
|
141
|
+
let &[version] = track(0);
|
|
142
|
+
<>
|
|
143
|
+
@try {
|
|
154
144
|
let &[data] = trackAsync(() => createRequest(version));
|
|
155
145
|
<p class="resolved">{data}</p>
|
|
156
|
-
} pending {
|
|
146
|
+
} @pending {
|
|
157
147
|
<p class="pending">{'loading...'}</p>
|
|
158
|
-
} catch (err) {
|
|
148
|
+
} @catch (err) {
|
|
159
149
|
<p class="caught">{(err as Error).message}</p>
|
|
160
150
|
}
|
|
161
151
|
<button class="retry" onClick={() => version++}>{'Retry'}</button>
|
|
162
|
-
|
|
152
|
+
</>
|
|
163
153
|
}
|
|
164
154
|
|
|
165
155
|
render(App);
|
|
@@ -211,18 +201,18 @@ describe('try block with catch and pending', () => {
|
|
|
211
201
|
return promise;
|
|
212
202
|
}
|
|
213
203
|
|
|
214
|
-
function App() {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
204
|
+
function App() @{
|
|
205
|
+
let &[version] = track(0);
|
|
206
|
+
@try {
|
|
207
|
+
let &[data] = trackAsync(() => {
|
|
208
|
+
version;
|
|
209
|
+
return createRequest(version);
|
|
210
|
+
});
|
|
211
|
+
<p class="resolved">{data}</p>
|
|
212
|
+
} @pending {
|
|
213
|
+
<p class="pending">{'loading...'}</p>
|
|
214
|
+
} @catch (err, reset) {
|
|
215
|
+
<>
|
|
226
216
|
<p class="caught">{(err as Error).message}</p>
|
|
227
217
|
<button
|
|
228
218
|
class="retry"
|
|
@@ -230,11 +220,9 @@ describe('try block with catch and pending', () => {
|
|
|
230
220
|
version++;
|
|
231
221
|
reset();
|
|
232
222
|
}}
|
|
233
|
-
>
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
</>;
|
|
223
|
+
>{'Retry'}</button>
|
|
224
|
+
</>
|
|
225
|
+
}
|
|
238
226
|
}
|
|
239
227
|
|
|
240
228
|
render(App);
|
|
@@ -274,17 +262,17 @@ describe('try block', () => {
|
|
|
274
262
|
it(
|
|
275
263
|
'does not compile ref binds as async callbacks inside try/pending trackAsync branches',
|
|
276
264
|
async () => {
|
|
277
|
-
function App() {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
265
|
+
function App() @{
|
|
266
|
+
let &[value, valueTracked] = track(1);
|
|
267
|
+
@try {
|
|
268
|
+
let &[loaded] = trackAsync(() => Promise.resolve(value + 1));
|
|
269
|
+
<>
|
|
282
270
|
<input type="number" ref={bindValue(valueTracked)} />
|
|
283
271
|
<span>{loaded}</span>
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
|
|
272
|
+
</>
|
|
273
|
+
} @pending {
|
|
274
|
+
<p>{'loading...'}</p>
|
|
275
|
+
}
|
|
288
276
|
}
|
|
289
277
|
|
|
290
278
|
render(App);
|
|
@@ -300,25 +288,21 @@ describe('try block', () => {
|
|
|
300
288
|
);
|
|
301
289
|
|
|
302
290
|
it('does not crash when trackAsync is used to render a list inside try/pending', async () => {
|
|
303
|
-
function App() {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
</>;
|
|
291
|
+
function App() @{
|
|
292
|
+
@try {
|
|
293
|
+
<AsyncChild />
|
|
294
|
+
} @pending {
|
|
295
|
+
<p>{'loading...'}</p>
|
|
296
|
+
}
|
|
311
297
|
}
|
|
312
298
|
|
|
313
|
-
function AsyncChild() {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
</ul>
|
|
321
|
-
</>;
|
|
299
|
+
function AsyncChild() @{
|
|
300
|
+
let &[data] = trackAsync(() => Promise.resolve(['a', 'b', 'c']));
|
|
301
|
+
<ul>
|
|
302
|
+
@for (let item of data) {
|
|
303
|
+
<li>{item}</li>
|
|
304
|
+
}
|
|
305
|
+
</ul>
|
|
322
306
|
}
|
|
323
307
|
|
|
324
308
|
render(App);
|
|
@@ -335,29 +319,25 @@ describe('try block', () => {
|
|
|
335
319
|
it(
|
|
336
320
|
'does not crash when async component with tracked state is used inside try/pending',
|
|
337
321
|
async () => {
|
|
338
|
-
function App() {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
</>;
|
|
322
|
+
function App() @{
|
|
323
|
+
let &[query, queryTracked] = track('');
|
|
324
|
+
@try {
|
|
325
|
+
<FilteredList {queryTracked} />
|
|
326
|
+
} @pending {
|
|
327
|
+
<p>{'loading...'}</p>
|
|
328
|
+
}
|
|
347
329
|
}
|
|
348
330
|
|
|
349
|
-
function FilteredList({ queryTracked }: { queryTracked: Tracked<string> }) {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
</ul>
|
|
360
|
-
</>;
|
|
331
|
+
function FilteredList({ queryTracked }: { queryTracked: Tracked<string> }) @{
|
|
332
|
+
let &[items] = trackAsync(() => Promise.resolve(['apple', 'banana', 'cherry']));
|
|
333
|
+
let &[filtered] = track(
|
|
334
|
+
() => items.filter((item: string) => item.includes(queryTracked.value)),
|
|
335
|
+
);
|
|
336
|
+
<ul>
|
|
337
|
+
@for (let item of filtered) {
|
|
338
|
+
<li>{item}</li>
|
|
339
|
+
}
|
|
340
|
+
</ul>
|
|
361
341
|
}
|
|
362
342
|
|
|
363
343
|
render(App);
|
|
@@ -371,20 +351,18 @@ describe('try block', () => {
|
|
|
371
351
|
);
|
|
372
352
|
|
|
373
353
|
it('if test condition stays synchronous once trackAsync has resolved', async () => {
|
|
374
|
-
function App() {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
<p>{'not-in-list is not in the list.'}</p>
|
|
383
|
-
}
|
|
384
|
-
} pending {
|
|
385
|
-
<p>{'loading...'}</p>
|
|
354
|
+
function App() @{
|
|
355
|
+
@try {
|
|
356
|
+
let &[items] = trackAsync(() => Promise.resolve(['apple', 'banana', 'cherry']));
|
|
357
|
+
|
|
358
|
+
@if (items.includes('not-in-list')) {
|
|
359
|
+
<p>{'not-in-list is in the list!'}</p>
|
|
360
|
+
} @else {
|
|
361
|
+
<p>{'not-in-list is not in the list.'}</p>
|
|
386
362
|
}
|
|
387
|
-
|
|
363
|
+
} @pending {
|
|
364
|
+
<p>{'loading...'}</p>
|
|
365
|
+
}
|
|
388
366
|
}
|
|
389
367
|
|
|
390
368
|
render(App);
|
|
@@ -398,30 +376,28 @@ describe('try block', () => {
|
|
|
398
376
|
it('destroying try block while in pending state cleans up pending branch', async () => {
|
|
399
377
|
let pending_effect_teardown_count = 0;
|
|
400
378
|
|
|
401
|
-
function PendingChild() {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
<p class="pending">{'loading...'}</p>
|
|
409
|
-
</>;
|
|
379
|
+
function PendingChild() @{
|
|
380
|
+
effect(() => {
|
|
381
|
+
return () => {
|
|
382
|
+
pending_effect_teardown_count++;
|
|
383
|
+
};
|
|
384
|
+
});
|
|
385
|
+
<p class="pending">{'loading...'}</p>
|
|
410
386
|
}
|
|
411
387
|
|
|
412
|
-
function App() {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
if (show) {
|
|
416
|
-
try {
|
|
388
|
+
function App() @{
|
|
389
|
+
let &[show] = track(true);
|
|
390
|
+
<>
|
|
391
|
+
@if (show) {
|
|
392
|
+
@try {
|
|
417
393
|
let &[data] = trackAsync(() => new Promise(() => {}));
|
|
418
394
|
<p class="resolved">{data}</p>
|
|
419
|
-
} pending {
|
|
395
|
+
} @pending {
|
|
420
396
|
<PendingChild />
|
|
421
397
|
}
|
|
422
398
|
}
|
|
423
399
|
<button class="toggle" onClick={() => (show = !show)}>{'toggle'}</button>
|
|
424
|
-
|
|
400
|
+
</>
|
|
425
401
|
}
|
|
426
402
|
|
|
427
403
|
render(App);
|
|
@@ -446,32 +422,30 @@ describe('try block', () => {
|
|
|
446
422
|
it('destroying try block while in resolved state cleans up resolved branch', async () => {
|
|
447
423
|
let resolved_effect_teardown_count = 0;
|
|
448
424
|
|
|
449
|
-
function ResolvedChild(&{ data }: { data: string }) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
<p class="resolved">{data}</p>
|
|
457
|
-
</>;
|
|
425
|
+
function ResolvedChild(&{ data }: { data: string }) @{
|
|
426
|
+
effect(() => {
|
|
427
|
+
return () => {
|
|
428
|
+
resolved_effect_teardown_count++;
|
|
429
|
+
};
|
|
430
|
+
});
|
|
431
|
+
<p class="resolved">{data}</p>
|
|
458
432
|
}
|
|
459
433
|
|
|
460
|
-
function App() {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
if (show) {
|
|
464
|
-
try {
|
|
434
|
+
function App() @{
|
|
435
|
+
let &[show] = track(true);
|
|
436
|
+
<>
|
|
437
|
+
@if (show) {
|
|
438
|
+
@try {
|
|
465
439
|
let &[data] = trackAsync(() => Promise.resolve('hello'));
|
|
466
440
|
<ResolvedChild {data} />
|
|
467
|
-
} pending {
|
|
441
|
+
} @pending {
|
|
468
442
|
<p class="pending">{'loading...'}</p>
|
|
469
|
-
} catch (err) {
|
|
443
|
+
} @catch (err) {
|
|
470
444
|
<p class="caught">{(err as Error).message}</p>
|
|
471
445
|
}
|
|
472
446
|
}
|
|
473
447
|
<button class="toggle" onClick={() => (show = !show)}>{'toggle'}</button>
|
|
474
|
-
|
|
448
|
+
</>
|
|
475
449
|
}
|
|
476
450
|
|
|
477
451
|
render(App);
|
|
@@ -497,32 +471,30 @@ describe('try block', () => {
|
|
|
497
471
|
it('destroying try block while in catch state cleans up catch branch', async () => {
|
|
498
472
|
let catch_effect_teardown_count = 0;
|
|
499
473
|
|
|
500
|
-
function CatchChild({ error }: { error: Error }) {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
<p class="caught">{error.message}</p>
|
|
508
|
-
</>;
|
|
474
|
+
function CatchChild({ error }: { error: Error }) @{
|
|
475
|
+
effect(() => {
|
|
476
|
+
return () => {
|
|
477
|
+
catch_effect_teardown_count++;
|
|
478
|
+
};
|
|
479
|
+
});
|
|
480
|
+
<p class="caught">{error.message}</p>
|
|
509
481
|
}
|
|
510
482
|
|
|
511
|
-
function App() {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
if (show) {
|
|
515
|
-
try {
|
|
483
|
+
function App() @{
|
|
484
|
+
let &[show] = track(true);
|
|
485
|
+
<>
|
|
486
|
+
@if (show) {
|
|
487
|
+
@try {
|
|
516
488
|
let &[data] = trackAsync(() => Promise.reject(new Error('fail')));
|
|
517
489
|
<p class="resolved">{data}</p>
|
|
518
|
-
} pending {
|
|
490
|
+
} @pending {
|
|
519
491
|
<p class="pending">{'loading...'}</p>
|
|
520
|
-
} catch (err) {
|
|
492
|
+
} @catch (err) {
|
|
521
493
|
<CatchChild error={err as Error} />
|
|
522
494
|
}
|
|
523
495
|
}
|
|
524
496
|
<button class="toggle" onClick={() => (show = !show)}>{'toggle'}</button>
|
|
525
|
-
|
|
497
|
+
</>
|
|
526
498
|
}
|
|
527
499
|
|
|
528
500
|
render(App);
|
|
@@ -544,23 +516,18 @@ describe('try block', () => {
|
|
|
544
516
|
|
|
545
517
|
it('pending block throwing renders catch block from the same try block', async () => {
|
|
546
518
|
function ThrowingPending() {
|
|
547
|
-
|
|
548
|
-
throw new Error('pending exploded');
|
|
549
|
-
<p>{'should not render'}</p>
|
|
550
|
-
</>;
|
|
519
|
+
throw new Error('pending exploded');
|
|
551
520
|
}
|
|
552
521
|
|
|
553
|
-
function App() {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
}
|
|
563
|
-
</>;
|
|
522
|
+
function App() @{
|
|
523
|
+
@try {
|
|
524
|
+
let &[data] = trackAsync(() => new Promise(() => {}));
|
|
525
|
+
<p class="resolved">{data}</p>
|
|
526
|
+
} @pending {
|
|
527
|
+
<ThrowingPending />
|
|
528
|
+
} @catch (err) {
|
|
529
|
+
<p class="caught">{(err as Error).message}</p>
|
|
530
|
+
}
|
|
564
531
|
}
|
|
565
532
|
|
|
566
533
|
render(App);
|
|
@@ -577,31 +544,24 @@ describe('try block', () => {
|
|
|
577
544
|
|
|
578
545
|
it('pending block throwing without catch bubbles to parent try/catch', async () => {
|
|
579
546
|
function ThrowingPending() {
|
|
580
|
-
|
|
581
|
-
throw new Error('pending exploded');
|
|
582
|
-
<p>{'should not render'}</p>
|
|
583
|
-
</>;
|
|
547
|
+
throw new Error('pending exploded');
|
|
584
548
|
}
|
|
585
549
|
|
|
586
|
-
function App() {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
}
|
|
593
|
-
</>;
|
|
550
|
+
function App() @{
|
|
551
|
+
@try {
|
|
552
|
+
<Inner />
|
|
553
|
+
} @catch (err) {
|
|
554
|
+
<p class="parent-caught">{(err as Error).message}</p>
|
|
555
|
+
}
|
|
594
556
|
}
|
|
595
557
|
|
|
596
|
-
function Inner() {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
}
|
|
604
|
-
</>;
|
|
558
|
+
function Inner() @{
|
|
559
|
+
@try {
|
|
560
|
+
let &[data] = trackAsync(() => new Promise(() => {}));
|
|
561
|
+
<p class="resolved">{data}</p>
|
|
562
|
+
} @pending {
|
|
563
|
+
<ThrowingPending />
|
|
564
|
+
}
|
|
605
565
|
}
|
|
606
566
|
|
|
607
567
|
render(App);
|
|
@@ -623,27 +583,25 @@ describe('try block', () => {
|
|
|
623
583
|
first_resolve = resolve;
|
|
624
584
|
});
|
|
625
585
|
|
|
626
|
-
function App() {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
}
|
|
646
|
-
</>;
|
|
586
|
+
function App() @{
|
|
587
|
+
@try {
|
|
588
|
+
let &[name] = trackAsync(() => first_promise);
|
|
589
|
+
let &[length] = trackAsync(() => {
|
|
590
|
+
// Read name synchronously — throws ASYNC_DERIVED_READ_THROWN
|
|
591
|
+
// while name is still pending, triggering the deferred mechanism.
|
|
592
|
+
const n = name;
|
|
593
|
+
return new Promise<number>((resolve) => {
|
|
594
|
+
second_resolve = resolve;
|
|
595
|
+
}).then((val) => n.length + val);
|
|
596
|
+
});
|
|
597
|
+
<p class="resolved">
|
|
598
|
+
{name}
|
|
599
|
+
{' has length '}
|
|
600
|
+
{length}
|
|
601
|
+
</p>
|
|
602
|
+
} @pending {
|
|
603
|
+
<p class="pending">{'loading...'}</p>
|
|
604
|
+
}
|
|
647
605
|
}
|
|
648
606
|
|
|
649
607
|
render(App);
|
|
@@ -686,32 +644,28 @@ describe('try block', () => {
|
|
|
686
644
|
first_resolve = resolve;
|
|
687
645
|
});
|
|
688
646
|
|
|
689
|
-
function PendingTracker() {
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
<p class="pending">{'loading...'}</p>
|
|
693
|
-
</>;
|
|
647
|
+
function PendingTracker() @{
|
|
648
|
+
pending_render_count++;
|
|
649
|
+
<p class="pending">{'loading...'}</p>
|
|
694
650
|
}
|
|
695
651
|
|
|
696
|
-
function App() {
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
}
|
|
714
|
-
</>;
|
|
652
|
+
function App() @{
|
|
653
|
+
@try {
|
|
654
|
+
let &[name] = trackAsync(() => first_promise);
|
|
655
|
+
let &[length] = trackAsync(() => {
|
|
656
|
+
const n = name;
|
|
657
|
+
return new Promise<number>((resolve) => {
|
|
658
|
+
second_resolve = resolve;
|
|
659
|
+
}).then((val) => n.length + val);
|
|
660
|
+
});
|
|
661
|
+
<p class="resolved">
|
|
662
|
+
{name}
|
|
663
|
+
{' has length '}
|
|
664
|
+
{length}
|
|
665
|
+
</p>
|
|
666
|
+
} @pending {
|
|
667
|
+
<PendingTracker />
|
|
668
|
+
}
|
|
715
669
|
}
|
|
716
670
|
|
|
717
671
|
render(App);
|
|
@@ -753,27 +707,25 @@ describe('try block', () => {
|
|
|
753
707
|
first_reject = reject;
|
|
754
708
|
});
|
|
755
709
|
|
|
756
|
-
function App() {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
}
|
|
776
|
-
</>;
|
|
710
|
+
function App() @{
|
|
711
|
+
@try {
|
|
712
|
+
let &[name] = trackAsync(() => first_promise);
|
|
713
|
+
let &[length] = trackAsync(() => {
|
|
714
|
+
const n = name;
|
|
715
|
+
return new Promise<number>((resolve) => {
|
|
716
|
+
second_resolve = resolve;
|
|
717
|
+
}).then((val) => n.length + val);
|
|
718
|
+
});
|
|
719
|
+
<p class="resolved">
|
|
720
|
+
{name}
|
|
721
|
+
{' has length '}
|
|
722
|
+
{length}
|
|
723
|
+
</p>
|
|
724
|
+
} @pending {
|
|
725
|
+
<p class="pending">{'loading...'}</p>
|
|
726
|
+
} @catch (err) {
|
|
727
|
+
<p class="caught">{(err as Error).message}</p>
|
|
728
|
+
}
|
|
777
729
|
}
|
|
778
730
|
|
|
779
731
|
render(App);
|
|
@@ -810,27 +762,25 @@ describe('try block', () => {
|
|
|
810
762
|
first_resolve = resolve;
|
|
811
763
|
});
|
|
812
764
|
|
|
813
|
-
function App() {
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
second_reject = reject;
|
|
821
|
-
});
|
|
765
|
+
function App() @{
|
|
766
|
+
@try {
|
|
767
|
+
let &[name] = trackAsync(() => first_promise);
|
|
768
|
+
let &[length] = trackAsync(() => {
|
|
769
|
+
const n = name;
|
|
770
|
+
return new Promise<number>((_, reject) => {
|
|
771
|
+
second_reject = reject;
|
|
822
772
|
});
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
}
|
|
833
|
-
|
|
773
|
+
});
|
|
774
|
+
<p class="resolved">
|
|
775
|
+
{name}
|
|
776
|
+
{' has length '}
|
|
777
|
+
{length}
|
|
778
|
+
</p>
|
|
779
|
+
} @pending {
|
|
780
|
+
<p class="pending">{'loading...'}</p>
|
|
781
|
+
} @catch (err) {
|
|
782
|
+
<p class="caught">{(err as Error).message}</p>
|
|
783
|
+
}
|
|
834
784
|
}
|
|
835
785
|
|
|
836
786
|
render(App);
|
|
@@ -864,31 +814,25 @@ describe('try block', () => {
|
|
|
864
814
|
);
|
|
865
815
|
|
|
866
816
|
it('resolved try block without catch bubbles error to parent try/catch', async () => {
|
|
867
|
-
function ThrowingChild() {
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
<p class="resolved">{data}</p>
|
|
871
|
-
</>;
|
|
817
|
+
function ThrowingChild() @{
|
|
818
|
+
let &[data] = trackAsync(() => Promise.reject(new Error('async failed')));
|
|
819
|
+
<p class="resolved">{data}</p>
|
|
872
820
|
}
|
|
873
821
|
|
|
874
|
-
function App() {
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
}
|
|
881
|
-
</>;
|
|
822
|
+
function App() @{
|
|
823
|
+
@try {
|
|
824
|
+
<Inner />
|
|
825
|
+
} @catch (err) {
|
|
826
|
+
<p class="parent-caught">{(err as Error).message}</p>
|
|
827
|
+
}
|
|
882
828
|
}
|
|
883
829
|
|
|
884
|
-
function Inner() {
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
}
|
|
891
|
-
</>;
|
|
830
|
+
function Inner() @{
|
|
831
|
+
@try {
|
|
832
|
+
<ThrowingChild />
|
|
833
|
+
} @pending {
|
|
834
|
+
<p class="pending">{'loading...'}</p>
|
|
835
|
+
}
|
|
892
836
|
}
|
|
893
837
|
|
|
894
838
|
render(App);
|
|
@@ -922,17 +866,15 @@ describe('try block', () => {
|
|
|
922
866
|
|
|
923
867
|
let data: any;
|
|
924
868
|
|
|
925
|
-
function App() {
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
}
|
|
935
|
-
</>;
|
|
869
|
+
function App() @{
|
|
870
|
+
@try {
|
|
871
|
+
data = trackAsync(() => user_promise);
|
|
872
|
+
<p class="resolved">{data.value}</p>
|
|
873
|
+
} @pending {
|
|
874
|
+
<p class="pending">{'loading...'}</p>
|
|
875
|
+
} @catch (err) {
|
|
876
|
+
<p class="caught">{(err as Error).message}</p>
|
|
877
|
+
}
|
|
936
878
|
}
|
|
937
879
|
|
|
938
880
|
render(App);
|
|
@@ -977,27 +919,25 @@ describe('try block', () => {
|
|
|
977
919
|
let name: any;
|
|
978
920
|
let length: any;
|
|
979
921
|
|
|
980
|
-
function App() {
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
resolve(n.length);
|
|
988
|
-
});
|
|
922
|
+
function App() @{
|
|
923
|
+
@try {
|
|
924
|
+
name = trackAsync(() => first_promise);
|
|
925
|
+
length = trackAsync(() => {
|
|
926
|
+
const n = name.value;
|
|
927
|
+
return new Promise<number>((resolve) => {
|
|
928
|
+
resolve(n.length);
|
|
989
929
|
});
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
}
|
|
1000
|
-
|
|
930
|
+
});
|
|
931
|
+
<p class="resolved">
|
|
932
|
+
{name.value}
|
|
933
|
+
{' has length '}
|
|
934
|
+
{length.value}
|
|
935
|
+
</p>
|
|
936
|
+
} @pending {
|
|
937
|
+
<p class="pending">{'loading...'}</p>
|
|
938
|
+
} @catch (err) {
|
|
939
|
+
<p class="caught">{(err as Error).message}</p>
|
|
940
|
+
}
|
|
1001
941
|
}
|
|
1002
942
|
|
|
1003
943
|
render(App);
|
|
@@ -1047,31 +987,29 @@ describe('try block', () => {
|
|
|
1047
987
|
let a: any;
|
|
1048
988
|
let b: any;
|
|
1049
989
|
let c: any;
|
|
1050
|
-
function App() {
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
}
|
|
1074
|
-
</>;
|
|
990
|
+
function App() @{
|
|
991
|
+
@try {
|
|
992
|
+
a = trackAsync(() => a_promise);
|
|
993
|
+
b = trackAsync(() => {
|
|
994
|
+
const val = a.value;
|
|
995
|
+
return Promise.resolve(val.toUpperCase());
|
|
996
|
+
});
|
|
997
|
+
c = trackAsync(() => {
|
|
998
|
+
const val = b.value;
|
|
999
|
+
return Promise.resolve(val.length);
|
|
1000
|
+
});
|
|
1001
|
+
<p class="resolved">
|
|
1002
|
+
{a.value}
|
|
1003
|
+
{' → '}
|
|
1004
|
+
{b.value}
|
|
1005
|
+
{' → '}
|
|
1006
|
+
{c.value}
|
|
1007
|
+
</p>
|
|
1008
|
+
} @pending {
|
|
1009
|
+
<p class="pending">{'loading...'}</p>
|
|
1010
|
+
} @catch (err) {
|
|
1011
|
+
<p class="caught">{(err as Error).message}</p>
|
|
1012
|
+
}
|
|
1075
1013
|
}
|
|
1076
1014
|
|
|
1077
1015
|
render(App);
|
|
@@ -1133,22 +1071,20 @@ describe('try block', () => {
|
|
|
1133
1071
|
|
|
1134
1072
|
let name: any;
|
|
1135
1073
|
let count: any;
|
|
1136
|
-
function App() {
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
}
|
|
1151
|
-
</>;
|
|
1074
|
+
function App() @{
|
|
1075
|
+
@try {
|
|
1076
|
+
name = trackAsync(() => first_promise);
|
|
1077
|
+
count = trackAsync(() => second_promise);
|
|
1078
|
+
<p class="resolved">
|
|
1079
|
+
{name.value}
|
|
1080
|
+
{' count: '}
|
|
1081
|
+
{count.value}
|
|
1082
|
+
</p>
|
|
1083
|
+
} @pending {
|
|
1084
|
+
<p class="pending">{'loading...'}</p>
|
|
1085
|
+
} @catch (err) {
|
|
1086
|
+
<p class="caught">{(err as Error).message}</p>
|
|
1087
|
+
}
|
|
1152
1088
|
}
|
|
1153
1089
|
|
|
1154
1090
|
render(App);
|
|
@@ -1201,31 +1137,27 @@ describe('sync error while async deriveds are pending', () => {
|
|
|
1201
1137
|
(e) => (promise_settled = { type: 'rejected', value: e }),
|
|
1202
1138
|
);
|
|
1203
1139
|
|
|
1204
|
-
function App() {
|
|
1205
|
-
|
|
1206
|
-
|
|
1140
|
+
function App() @{
|
|
1141
|
+
@try {
|
|
1142
|
+
<>
|
|
1207
1143
|
<AsyncChild />
|
|
1208
1144
|
<ThrowingChild />
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1145
|
+
</>
|
|
1146
|
+
} @pending {
|
|
1147
|
+
<p class="pending">{'loading...'}</p>
|
|
1148
|
+
} @catch (err: Error) {
|
|
1149
|
+
<p class="caught">{err.message}</p>
|
|
1150
|
+
}
|
|
1215
1151
|
}
|
|
1216
1152
|
|
|
1217
1153
|
let data: any;
|
|
1218
|
-
function AsyncChild() {
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
<p class="async-resolved">{data.value}</p>
|
|
1222
|
-
</>;
|
|
1154
|
+
function AsyncChild() @{
|
|
1155
|
+
data = trackAsync(() => user_promise);
|
|
1156
|
+
<p class="async-resolved">{data.value}</p>
|
|
1223
1157
|
}
|
|
1224
1158
|
|
|
1225
1159
|
function ThrowingChild() {
|
|
1226
|
-
|
|
1227
|
-
throw new Error('sync boom');
|
|
1228
|
-
</>;
|
|
1160
|
+
throw new Error('sync boom');
|
|
1229
1161
|
}
|
|
1230
1162
|
|
|
1231
1163
|
render(App);
|
|
@@ -1272,31 +1204,27 @@ describe('sync error while async deriveds are pending', () => {
|
|
|
1272
1204
|
(e) => (promise_settled = { type: 'rejected', value: e }),
|
|
1273
1205
|
);
|
|
1274
1206
|
|
|
1275
|
-
function App() {
|
|
1276
|
-
|
|
1277
|
-
|
|
1207
|
+
function App() @{
|
|
1208
|
+
@try {
|
|
1209
|
+
<>
|
|
1278
1210
|
<AsyncChild />
|
|
1279
1211
|
<ThrowingChild />
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1212
|
+
</>
|
|
1213
|
+
} @pending {
|
|
1214
|
+
<p class="pending">{'loading...'}</p>
|
|
1215
|
+
} @catch (err: Error) {
|
|
1216
|
+
<p class="caught">{err.message}</p>
|
|
1217
|
+
}
|
|
1286
1218
|
}
|
|
1287
1219
|
|
|
1288
1220
|
let data: any;
|
|
1289
|
-
function AsyncChild() {
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
<p class="async-resolved">{data.value}</p>
|
|
1293
|
-
</>;
|
|
1221
|
+
function AsyncChild() @{
|
|
1222
|
+
data = trackAsync(() => user_promise);
|
|
1223
|
+
<p class="async-resolved">{data.value}</p>
|
|
1294
1224
|
}
|
|
1295
1225
|
|
|
1296
1226
|
function ThrowingChild() {
|
|
1297
|
-
|
|
1298
|
-
throw new Error('sync boom');
|
|
1299
|
-
</>;
|
|
1227
|
+
throw new Error('sync boom');
|
|
1300
1228
|
}
|
|
1301
1229
|
|
|
1302
1230
|
render(App);
|
|
@@ -1350,40 +1278,34 @@ describe('sync error while async deriveds are pending', () => {
|
|
|
1350
1278
|
(e) => (settled_b = { type: 'rejected', value: e }),
|
|
1351
1279
|
);
|
|
1352
1280
|
|
|
1353
|
-
function App() {
|
|
1354
|
-
|
|
1355
|
-
|
|
1281
|
+
function App() @{
|
|
1282
|
+
@try {
|
|
1283
|
+
<>
|
|
1356
1284
|
<ChildA />
|
|
1357
1285
|
<ChildB />
|
|
1358
1286
|
<ThrowingChild />
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1287
|
+
</>
|
|
1288
|
+
} @pending {
|
|
1289
|
+
<p class="pending">{'loading...'}</p>
|
|
1290
|
+
} @catch (err: Error) {
|
|
1291
|
+
<p class="caught">{err.message}</p>
|
|
1292
|
+
}
|
|
1365
1293
|
}
|
|
1366
1294
|
|
|
1367
1295
|
let dataA: any;
|
|
1368
|
-
function ChildA() {
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
<p class="a">{dataA.value}</p>
|
|
1372
|
-
</>;
|
|
1296
|
+
function ChildA() @{
|
|
1297
|
+
dataA = trackAsync(() => promise_a);
|
|
1298
|
+
<p class="a">{dataA.value}</p>
|
|
1373
1299
|
}
|
|
1374
1300
|
|
|
1375
1301
|
let dataB: any;
|
|
1376
|
-
function ChildB() {
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
<p class="b">{dataB.value}</p>
|
|
1380
|
-
</>;
|
|
1302
|
+
function ChildB() @{
|
|
1303
|
+
dataB = trackAsync(() => promise_b);
|
|
1304
|
+
<p class="b">{dataB.value}</p>
|
|
1381
1305
|
}
|
|
1382
1306
|
|
|
1383
1307
|
function ThrowingChild() {
|
|
1384
|
-
|
|
1385
|
-
throw new Error('sync boom');
|
|
1386
|
-
</>;
|
|
1308
|
+
throw new Error('sync boom');
|
|
1387
1309
|
}
|
|
1388
1310
|
|
|
1389
1311
|
render(App);
|
|
@@ -1443,40 +1365,34 @@ describe('sync error while async deriveds are pending', () => {
|
|
|
1443
1365
|
(e) => (settled_b = { type: 'rejected', value: e }),
|
|
1444
1366
|
);
|
|
1445
1367
|
|
|
1446
|
-
function App() {
|
|
1447
|
-
|
|
1448
|
-
|
|
1368
|
+
function App() @{
|
|
1369
|
+
@try {
|
|
1370
|
+
<>
|
|
1449
1371
|
<ChildA />
|
|
1450
1372
|
<ChildB />
|
|
1451
1373
|
<ThrowingChild />
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1374
|
+
</>
|
|
1375
|
+
} @pending {
|
|
1376
|
+
<p class="pending">{'loading...'}</p>
|
|
1377
|
+
} @catch (err: Error) {
|
|
1378
|
+
<p class="caught">{err.message}</p>
|
|
1379
|
+
}
|
|
1458
1380
|
}
|
|
1459
1381
|
|
|
1460
1382
|
let dataA: any;
|
|
1461
|
-
function ChildA() {
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
<p class="a">{dataA.value}</p>
|
|
1465
|
-
</>;
|
|
1383
|
+
function ChildA() @{
|
|
1384
|
+
dataA = trackAsync(() => promise_a);
|
|
1385
|
+
<p class="a">{dataA.value}</p>
|
|
1466
1386
|
}
|
|
1467
1387
|
|
|
1468
1388
|
let dataB: any;
|
|
1469
|
-
function ChildB() {
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
<p class="b">{dataB.value}</p>
|
|
1473
|
-
</>;
|
|
1389
|
+
function ChildB() @{
|
|
1390
|
+
dataB = trackAsync(() => promise_b);
|
|
1391
|
+
<p class="b">{dataB.value}</p>
|
|
1474
1392
|
}
|
|
1475
1393
|
|
|
1476
1394
|
function ThrowingChild() {
|
|
1477
|
-
|
|
1478
|
-
throw new Error('sync boom');
|
|
1479
|
-
</>;
|
|
1395
|
+
throw new Error('sync boom');
|
|
1480
1396
|
}
|
|
1481
1397
|
|
|
1482
1398
|
render(App);
|
|
@@ -1515,30 +1431,23 @@ describe('sync error while async deriveds are pending', () => {
|
|
|
1515
1431
|
|
|
1516
1432
|
it('try block without catch propagates sync error to upstream boundary', async () => {
|
|
1517
1433
|
function ThrowingChild() {
|
|
1518
|
-
|
|
1519
|
-
throw new Error('no catch here');
|
|
1520
|
-
<p>{'should not render'}</p>
|
|
1521
|
-
</>;
|
|
1434
|
+
throw new Error('no catch here');
|
|
1522
1435
|
}
|
|
1523
1436
|
|
|
1524
|
-
function App() {
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
}
|
|
1531
|
-
</>;
|
|
1437
|
+
function App() @{
|
|
1438
|
+
@try {
|
|
1439
|
+
<Inner />
|
|
1440
|
+
} @catch (err) {
|
|
1441
|
+
<p class="upstream-caught">{(err as Error).message}</p>
|
|
1442
|
+
}
|
|
1532
1443
|
}
|
|
1533
1444
|
|
|
1534
|
-
function Inner() {
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
}
|
|
1541
|
-
</>;
|
|
1445
|
+
function Inner() @{
|
|
1446
|
+
@try {
|
|
1447
|
+
<ThrowingChild />
|
|
1448
|
+
} @pending {
|
|
1449
|
+
<p class="inner-pending">{'loading...'}</p>
|
|
1450
|
+
}
|
|
1542
1451
|
}
|
|
1543
1452
|
|
|
1544
1453
|
render(App);
|
|
@@ -1549,25 +1458,21 @@ describe('sync error while async deriveds are pending', () => {
|
|
|
1549
1458
|
});
|
|
1550
1459
|
|
|
1551
1460
|
it('try block without catch propagates async rejection to upstream boundary', async () => {
|
|
1552
|
-
function App() {
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
}
|
|
1559
|
-
</>;
|
|
1461
|
+
function App() @{
|
|
1462
|
+
@try {
|
|
1463
|
+
<Inner />
|
|
1464
|
+
} @catch (err) {
|
|
1465
|
+
<p class="upstream-caught">{(err as Error).message}</p>
|
|
1466
|
+
}
|
|
1560
1467
|
}
|
|
1561
1468
|
|
|
1562
|
-
function Inner() {
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
}
|
|
1570
|
-
</>;
|
|
1469
|
+
function Inner() @{
|
|
1470
|
+
@try {
|
|
1471
|
+
let &[data] = trackAsync(() => Promise.reject(new Error('async no catch')));
|
|
1472
|
+
<p class="resolved">{data}</p>
|
|
1473
|
+
} @pending {
|
|
1474
|
+
<p class="inner-pending">{'loading...'}</p>
|
|
1475
|
+
}
|
|
1571
1476
|
}
|
|
1572
1477
|
|
|
1573
1478
|
render(App);
|
|
@@ -1586,25 +1491,21 @@ describe('sync error while async deriveds are pending', () => {
|
|
|
1586
1491
|
reject_fn = reject;
|
|
1587
1492
|
});
|
|
1588
1493
|
|
|
1589
|
-
function App() {
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
}
|
|
1596
|
-
</>;
|
|
1494
|
+
function App() @{
|
|
1495
|
+
@try {
|
|
1496
|
+
<Inner />
|
|
1497
|
+
} @catch (err) {
|
|
1498
|
+
<p class="upstream-caught">{(err as Error).message}</p>
|
|
1499
|
+
}
|
|
1597
1500
|
}
|
|
1598
1501
|
|
|
1599
|
-
function Inner() {
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
}
|
|
1607
|
-
</>;
|
|
1502
|
+
function Inner() @{
|
|
1503
|
+
@try {
|
|
1504
|
+
let &[data] = trackAsync(() => user_promise);
|
|
1505
|
+
<p class="resolved">{data}</p>
|
|
1506
|
+
} @pending {
|
|
1507
|
+
<p class="inner-pending">{'loading...'}</p>
|
|
1508
|
+
}
|
|
1608
1509
|
}
|
|
1609
1510
|
|
|
1610
1511
|
render(App);
|
|
@@ -1626,40 +1527,31 @@ describe('sync error while async deriveds are pending', () => {
|
|
|
1626
1527
|
|
|
1627
1528
|
it('nested try blocks without catch propagate error through multiple levels', async () => {
|
|
1628
1529
|
function ThrowingChild() {
|
|
1629
|
-
|
|
1630
|
-
throw new Error('deep error');
|
|
1631
|
-
<p>{'should not render'}</p>
|
|
1632
|
-
</>;
|
|
1530
|
+
throw new Error('deep error');
|
|
1633
1531
|
}
|
|
1634
1532
|
|
|
1635
|
-
function App() {
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
}
|
|
1642
|
-
</>;
|
|
1533
|
+
function App() @{
|
|
1534
|
+
@try {
|
|
1535
|
+
<Middle />
|
|
1536
|
+
} @catch (err) {
|
|
1537
|
+
<p class="top-caught">{(err as Error).message}</p>
|
|
1538
|
+
}
|
|
1643
1539
|
}
|
|
1644
1540
|
|
|
1645
|
-
function Middle() {
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
}
|
|
1652
|
-
</>;
|
|
1541
|
+
function Middle() @{
|
|
1542
|
+
@try {
|
|
1543
|
+
<Inner />
|
|
1544
|
+
} @pending {
|
|
1545
|
+
<p class="mid-pending">{'loading...'}</p>
|
|
1546
|
+
}
|
|
1653
1547
|
}
|
|
1654
1548
|
|
|
1655
|
-
function Inner() {
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
}
|
|
1662
|
-
</>;
|
|
1549
|
+
function Inner() @{
|
|
1550
|
+
@try {
|
|
1551
|
+
<ThrowingChild />
|
|
1552
|
+
} @pending {
|
|
1553
|
+
<p class="inner-pending">{'loading...'}</p>
|
|
1554
|
+
}
|
|
1663
1555
|
}
|
|
1664
1556
|
|
|
1665
1557
|
render(App);
|
|
@@ -1671,20 +1563,15 @@ describe('sync error while async deriveds are pending', () => {
|
|
|
1671
1563
|
|
|
1672
1564
|
it('try block without catch throws to global when no upstream boundary exists', async () => {
|
|
1673
1565
|
function ThrowingChild() {
|
|
1674
|
-
|
|
1675
|
-
throw new Error('unhandled error');
|
|
1676
|
-
<p>{'should not render'}</p>
|
|
1677
|
-
</>;
|
|
1566
|
+
throw new Error('unhandled error');
|
|
1678
1567
|
}
|
|
1679
1568
|
|
|
1680
|
-
function App() {
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
}
|
|
1687
|
-
</>;
|
|
1569
|
+
function App() @{
|
|
1570
|
+
@try {
|
|
1571
|
+
<ThrowingChild />
|
|
1572
|
+
} @pending {
|
|
1573
|
+
<p class="pending">{'loading...'}</p>
|
|
1574
|
+
}
|
|
1688
1575
|
}
|
|
1689
1576
|
|
|
1690
1577
|
expect(() => {
|
|
@@ -1700,25 +1587,21 @@ describe('sync error while async deriveds are pending', () => {
|
|
|
1700
1587
|
reject_fn = reject;
|
|
1701
1588
|
});
|
|
1702
1589
|
|
|
1703
|
-
function Inner() {
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
}
|
|
1711
|
-
</>;
|
|
1590
|
+
function Inner() @{
|
|
1591
|
+
@try {
|
|
1592
|
+
let &[data] = trackAsync(() => user_promise);
|
|
1593
|
+
<p class="resolved">{data}</p>
|
|
1594
|
+
} @catch (err) {
|
|
1595
|
+
<p class="downstream-caught">{(err as Error).message}</p>
|
|
1596
|
+
}
|
|
1712
1597
|
}
|
|
1713
1598
|
|
|
1714
|
-
function App() {
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
}
|
|
1721
|
-
</>;
|
|
1599
|
+
function App() @{
|
|
1600
|
+
@try {
|
|
1601
|
+
<Inner />
|
|
1602
|
+
} @pending {
|
|
1603
|
+
<p class="outer-pending">{'loading...'}</p>
|
|
1604
|
+
}
|
|
1722
1605
|
}
|
|
1723
1606
|
|
|
1724
1607
|
render(App);
|
|
@@ -1757,26 +1640,22 @@ describe('sync error while async deriveds are pending', () => {
|
|
|
1757
1640
|
(e) => (user_settled = { type: 'rejected', value: e }),
|
|
1758
1641
|
);
|
|
1759
1642
|
|
|
1760
|
-
function Inner() {
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
}
|
|
1769
|
-
</>;
|
|
1643
|
+
function Inner() @{
|
|
1644
|
+
@try {
|
|
1645
|
+
let &[data] = trackAsync(() => user_promise);
|
|
1646
|
+
throw new Error('synchronous error');
|
|
1647
|
+
<p class="resolved">{data}</p>
|
|
1648
|
+
} @catch (err) {
|
|
1649
|
+
<p class="downstream-caught">{(err as Error).message}</p>
|
|
1650
|
+
}
|
|
1770
1651
|
}
|
|
1771
1652
|
|
|
1772
|
-
function App() {
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
}
|
|
1779
|
-
</>;
|
|
1653
|
+
function App() @{
|
|
1654
|
+
@try {
|
|
1655
|
+
<Inner />
|
|
1656
|
+
} @pending {
|
|
1657
|
+
<p class="outer-pending">{'loading...'}</p>
|
|
1658
|
+
}
|
|
1780
1659
|
}
|
|
1781
1660
|
|
|
1782
1661
|
render(App);
|
|
@@ -1816,26 +1695,22 @@ describe('sync error while async deriveds are pending', () => {
|
|
|
1816
1695
|
(e) => (user_settled = { type: 'rejected', value: e }),
|
|
1817
1696
|
);
|
|
1818
1697
|
|
|
1819
|
-
function Inner() {
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
}
|
|
1828
|
-
</>;
|
|
1698
|
+
function Inner() @{
|
|
1699
|
+
@try {
|
|
1700
|
+
let &[data] = trackAsync(() => user_promise);
|
|
1701
|
+
throw new Error('synchronous error');
|
|
1702
|
+
<p class="resolved">{data}</p>
|
|
1703
|
+
} @catch (err) {
|
|
1704
|
+
<p class="downstream-caught">{(err as Error).message}</p>
|
|
1705
|
+
}
|
|
1829
1706
|
}
|
|
1830
1707
|
|
|
1831
|
-
function App() {
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
}
|
|
1838
|
-
</>;
|
|
1708
|
+
function App() @{
|
|
1709
|
+
@try {
|
|
1710
|
+
<Inner />
|
|
1711
|
+
} @pending {
|
|
1712
|
+
<p class="outer-pending">{'loading...'}</p>
|
|
1713
|
+
}
|
|
1839
1714
|
}
|
|
1840
1715
|
|
|
1841
1716
|
render(App);
|