ripple 0.3.68 → 0.3.69

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.
Files changed (182) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/package.json +3 -3
  3. package/src/jsx-runtime.d.ts +2 -2
  4. package/src/runtime/element.js +1 -1
  5. package/src/runtime/index-client.js +11 -11
  6. package/src/runtime/index-server.js +7 -4
  7. package/src/runtime/internal/client/bindings.js +1 -1
  8. package/src/runtime/internal/client/blocks.js +13 -4
  9. package/src/runtime/internal/client/component.js +55 -0
  10. package/src/runtime/internal/client/composite.js +4 -2
  11. package/src/runtime/internal/client/expression.js +65 -7
  12. package/src/runtime/internal/client/hmr.js +54 -43
  13. package/src/runtime/internal/client/index.js +5 -1
  14. package/src/runtime/internal/client/portal.js +70 -69
  15. package/src/runtime/internal/client/render.js +3 -0
  16. package/src/runtime/internal/server/index.js +92 -8
  17. package/tests/client/__snapshots__/html.test.tsrx.snap +3 -3
  18. package/tests/client/array/array.copy-within.test.tsrx +33 -31
  19. package/tests/client/array/array.derived.test.tsrx +186 -169
  20. package/tests/client/array/array.iteration.test.tsrx +40 -37
  21. package/tests/client/array/array.mutations.test.tsrx +113 -101
  22. package/tests/client/array/array.static.test.tsrx +119 -101
  23. package/tests/client/array/array.to-methods.test.tsrx +24 -21
  24. package/tests/client/async-suspend.test.tsrx +247 -246
  25. package/tests/client/basic/__snapshots__/basic.rendering.test.tsrx.snap +0 -1
  26. package/tests/client/basic/basic.attributes.test.tsrx +428 -423
  27. package/tests/client/basic/basic.collections.test.tsrx +109 -102
  28. package/tests/client/basic/basic.components.test.tsrx +323 -205
  29. package/tests/client/basic/basic.errors.test.tsrx +91 -91
  30. package/tests/client/basic/basic.events.test.tsrx +114 -115
  31. package/tests/client/basic/basic.get-set.test.tsrx +97 -87
  32. package/tests/client/basic/basic.hmr.test.tsrx +19 -16
  33. package/tests/client/basic/basic.reactivity.test.tsrx +199 -191
  34. package/tests/client/basic/basic.rendering.test.tsrx +272 -182
  35. package/tests/client/basic/basic.styling.test.tsrx +23 -22
  36. package/tests/client/basic/basic.utilities.test.tsrx +10 -8
  37. package/tests/client/boundaries.test.tsrx +26 -26
  38. package/tests/client/compiler/__snapshots__/compiler.assignments.test.rsrx.snap +5 -5
  39. package/tests/client/compiler/__snapshots__/compiler.assignments.test.tsrx.snap +5 -5
  40. package/tests/client/compiler/compiler.assignments.test.tsrx +77 -81
  41. package/tests/client/compiler/compiler.attributes.test.tsrx +15 -15
  42. package/tests/client/compiler/compiler.basic.test.tsrx +322 -314
  43. package/tests/client/compiler/compiler.regex.test.tsrx +44 -47
  44. package/tests/client/compiler/compiler.tracked-access.test.tsrx +38 -38
  45. package/tests/client/compiler/compiler.try-in-function.test.tsrx +16 -16
  46. package/tests/client/compiler/compiler.typescript.test.tsrx +2 -2
  47. package/tests/client/composite/composite.dynamic-components.test.tsrx +47 -48
  48. package/tests/client/composite/composite.generics.test.tsrx +168 -192
  49. package/tests/client/composite/composite.props.test.tsrx +97 -81
  50. package/tests/client/composite/composite.reactivity.test.tsrx +177 -147
  51. package/tests/client/composite/composite.render.test.tsrx +122 -105
  52. package/tests/client/computed-properties.test.tsrx +28 -28
  53. package/tests/client/context.test.tsrx +21 -21
  54. package/tests/client/css/global-additional-cases.test.tsrx +58 -58
  55. package/tests/client/css/global-advanced-selectors.test.tsrx +16 -16
  56. package/tests/client/css/global-at-rules.test.tsrx +10 -10
  57. package/tests/client/css/global-basic.test.tsrx +14 -14
  58. package/tests/client/css/global-classes-ids.test.tsrx +14 -14
  59. package/tests/client/css/global-combinators.test.tsrx +10 -10
  60. package/tests/client/css/global-complex-nesting.test.tsrx +14 -14
  61. package/tests/client/css/global-edge-cases.test.tsrx +18 -18
  62. package/tests/client/css/global-keyframes.test.tsrx +12 -12
  63. package/tests/client/css/global-nested.test.tsrx +10 -10
  64. package/tests/client/css/global-pseudo.test.tsrx +12 -12
  65. package/tests/client/css/global-scoping.test.tsrx +20 -20
  66. package/tests/client/css/style-identifier.test.tsrx +143 -291
  67. package/tests/client/date.test.tsrx +146 -133
  68. package/tests/client/dynamic-elements.test.tsrx +398 -365
  69. package/tests/client/events.test.tsrx +292 -290
  70. package/tests/client/for.test.tsrx +156 -153
  71. package/tests/client/head.test.tsrx +105 -96
  72. package/tests/client/html.test.tsrx +122 -26
  73. package/tests/client/input-value.test.tsrx +1361 -1314
  74. package/tests/client/lazy-array.test.tsrx +16 -13
  75. package/tests/client/lazy-destructuring.test.tsrx +257 -213
  76. package/tests/client/map.test.tsrx +65 -60
  77. package/tests/client/media-query.test.tsrx +22 -20
  78. package/tests/client/object.test.tsrx +87 -81
  79. package/tests/client/portal.test.tsrx +57 -51
  80. package/tests/client/ref.test.tsrx +233 -202
  81. package/tests/client/return.test.tsrx +71 -2560
  82. package/tests/client/set.test.tsrx +54 -45
  83. package/tests/client/svg.test.tsrx +216 -186
  84. package/tests/client/switch.test.tsrx +194 -193
  85. package/tests/client/track-async-hydration.test.tsrx +18 -14
  86. package/tests/client/tracked-index-access.test.tsrx +28 -18
  87. package/tests/client/try.test.tsrx +675 -548
  88. package/tests/client/tsx.test.tsrx +373 -311
  89. package/tests/client/typescript-generics.test.tsrx +145 -145
  90. package/tests/client/url/url.derived.test.tsrx +33 -28
  91. package/tests/client/url/url.parsing.test.tsrx +61 -51
  92. package/tests/client/url/url.partial-removal.test.tsrx +56 -48
  93. package/tests/client/url/url.reactivity.test.tsrx +142 -125
  94. package/tests/client/url/url.serialization.test.tsrx +13 -11
  95. package/tests/client/url-search-params/url-search-params.derived.test.tsrx +34 -29
  96. package/tests/client/url-search-params/url-search-params.initialization.test.tsrx +25 -21
  97. package/tests/client/url-search-params/url-search-params.iteration.test.tsrx +50 -45
  98. package/tests/client/url-search-params/url-search-params.mutation.test.tsrx +111 -99
  99. package/tests/client/url-search-params/url-search-params.retrieval.test.tsrx +49 -43
  100. package/tests/client/url-search-params/url-search-params.serialization.test.tsrx +14 -12
  101. package/tests/client/url-search-params/url-search-params.tracked-url.test.tsrx +16 -14
  102. package/tests/hydration/basic.test.js +3 -3
  103. package/tests/hydration/compiled/client/basic.js +586 -651
  104. package/tests/hydration/compiled/client/composite.js +79 -104
  105. package/tests/hydration/compiled/client/events.js +140 -148
  106. package/tests/hydration/compiled/client/for.js +1005 -1018
  107. package/tests/hydration/compiled/client/head.js +124 -134
  108. package/tests/hydration/compiled/client/hmr.js +41 -48
  109. package/tests/hydration/compiled/client/html-in-template.js +38 -41
  110. package/tests/hydration/compiled/client/html.js +970 -1314
  111. package/tests/hydration/compiled/client/if-children.js +234 -249
  112. package/tests/hydration/compiled/client/if.js +182 -189
  113. package/tests/hydration/compiled/client/mixed-control-flow.js +347 -303
  114. package/tests/hydration/compiled/client/nested-control-flow.js +1084 -832
  115. package/tests/hydration/compiled/client/portal.js +65 -85
  116. package/tests/hydration/compiled/client/reactivity.js +84 -90
  117. package/tests/hydration/compiled/client/return.js +38 -1939
  118. package/tests/hydration/compiled/client/switch.js +218 -224
  119. package/tests/hydration/compiled/client/track-async-serialization.js +250 -259
  120. package/tests/hydration/compiled/client/try.js +123 -132
  121. package/tests/hydration/compiled/server/basic.js +773 -831
  122. package/tests/hydration/compiled/server/composite.js +166 -191
  123. package/tests/hydration/compiled/server/events.js +170 -184
  124. package/tests/hydration/compiled/server/for.js +851 -909
  125. package/tests/hydration/compiled/server/head.js +206 -216
  126. package/tests/hydration/compiled/server/hmr.js +64 -72
  127. package/tests/hydration/compiled/server/html-in-template.js +42 -76
  128. package/tests/hydration/compiled/server/html.js +1362 -1667
  129. package/tests/hydration/compiled/server/if-children.js +419 -445
  130. package/tests/hydration/compiled/server/if.js +194 -208
  131. package/tests/hydration/compiled/server/mixed-control-flow.js +249 -257
  132. package/tests/hydration/compiled/server/nested-control-flow.js +491 -515
  133. package/tests/hydration/compiled/server/portal.js +152 -160
  134. package/tests/hydration/compiled/server/reactivity.js +94 -106
  135. package/tests/hydration/compiled/server/return.js +28 -2172
  136. package/tests/hydration/compiled/server/switch.js +274 -286
  137. package/tests/hydration/compiled/server/track-async-serialization.js +340 -358
  138. package/tests/hydration/compiled/server/try.js +167 -185
  139. package/tests/hydration/components/basic.tsrx +320 -272
  140. package/tests/hydration/components/composite.tsrx +44 -32
  141. package/tests/hydration/components/events.tsrx +101 -91
  142. package/tests/hydration/components/for.tsrx +510 -452
  143. package/tests/hydration/components/head.tsrx +87 -80
  144. package/tests/hydration/components/hmr.tsrx +22 -17
  145. package/tests/hydration/components/html-in-template.tsrx +22 -17
  146. package/tests/hydration/components/html.tsrx +525 -443
  147. package/tests/hydration/components/if-children.tsrx +158 -148
  148. package/tests/hydration/components/if.tsrx +109 -95
  149. package/tests/hydration/components/mixed-control-flow.tsrx +100 -96
  150. package/tests/hydration/components/nested-control-flow.tsrx +215 -203
  151. package/tests/hydration/components/portal.tsrx +41 -34
  152. package/tests/hydration/components/reactivity.tsrx +37 -27
  153. package/tests/hydration/components/return.tsrx +12 -556
  154. package/tests/hydration/components/switch.tsrx +120 -114
  155. package/tests/hydration/components/track-async-serialization.tsrx +107 -91
  156. package/tests/hydration/components/try.tsrx +55 -40
  157. package/tests/hydration/html.test.js +4 -4
  158. package/tests/hydration/return.test.js +13 -532
  159. package/tests/server/await.test.tsrx +3 -3
  160. package/tests/server/basic.attributes.test.tsrx +264 -195
  161. package/tests/server/basic.components.test.tsrx +296 -169
  162. package/tests/server/basic.test.tsrx +300 -198
  163. package/tests/server/compiler.test.tsrx +62 -60
  164. package/tests/server/composite.props.test.tsrx +77 -63
  165. package/tests/server/composite.test.tsrx +168 -192
  166. package/tests/server/context.test.tsrx +18 -12
  167. package/tests/server/dynamic-elements.test.tsrx +197 -180
  168. package/tests/server/for.test.tsrx +85 -78
  169. package/tests/server/head.test.tsrx +50 -43
  170. package/tests/server/html-nesting-validation.test.tsrx +8 -8
  171. package/tests/server/if.test.tsrx +57 -51
  172. package/tests/server/lazy-destructuring.test.tsrx +366 -294
  173. package/tests/server/return.test.tsrx +76 -1355
  174. package/tests/server/streaming-ssr.test.tsrx +4 -75
  175. package/tests/server/style-identifier.test.tsrx +169 -148
  176. package/tests/server/switch.test.tsrx +91 -85
  177. package/tests/server/track-async-serialization.test.tsrx +105 -85
  178. package/tests/server/try.test.tsrx +374 -280
  179. package/tests/utils/compiler-compat-config.test.js +2 -2
  180. package/tests/utils/runtime-imports.test.js +10 -0
  181. package/types/index.d.ts +8 -0
  182. package/tests/client/__snapshots__/html.test.rsrx.snap +0 -40
@@ -1,21 +1,22 @@
1
1
  describe('SSR: switch statements', () => {
2
2
  it('renders simple switch with literal cases', async () => {
3
- component App() {
4
- let value = 'b';
5
-
6
- switch (value) {
7
- case 'a':
8
- <div>{'Case A'}</div>
9
- break;
10
- case 'b':
11
- <div>{'Case B'}</div>
12
- break;
13
- case 'c':
14
- <div>{'Case C'}</div>
15
- break;
16
- default:
17
- <div>{'Default Case'}</div>
18
- }
3
+ function App() {
4
+ return <>
5
+ let value = 'b';
6
+ switch (value) {
7
+ case 'a':
8
+ <div>{'Case A'}</div>
9
+ break;
10
+ case 'b':
11
+ <div>{'Case B'}</div>
12
+ break;
13
+ case 'c':
14
+ <div>{'Case C'}</div>
15
+ break;
16
+ default:
17
+ <div>{'Default Case'}</div>
18
+ }
19
+ </>;
19
20
  }
20
21
 
21
22
  const { body } = await render(App);
@@ -23,20 +24,21 @@ describe('SSR: switch statements', () => {
23
24
  });
24
25
 
25
26
  it('renders a fall-through with an empty switch case', async () => {
26
- component App() {
27
- let value = 'b';
28
-
29
- switch (value) {
30
- case 'a':
31
- <div>{'Case A'}</div>
32
- break;
33
- case 'b':
34
- case 'c':
35
- <div>{'Case B or C'}</div>
36
- break;
37
- default:
38
- <div>{'Default Case'}</div>
39
- }
27
+ function App() {
28
+ return <>
29
+ let value = 'b';
30
+ switch (value) {
31
+ case 'a':
32
+ <div>{'Case A'}</div>
33
+ break;
34
+ case 'b':
35
+ case 'c':
36
+ <div>{'Case B or C'}</div>
37
+ break;
38
+ default:
39
+ <div>{'Default Case'}</div>
40
+ }
41
+ </>;
40
42
  }
41
43
 
42
44
  const { body } = await render(App);
@@ -44,20 +46,21 @@ describe('SSR: switch statements', () => {
44
46
  });
45
47
 
46
48
  it('renders a fall-through with a case that has elements', async () => {
47
- component App() {
48
- let value = 'a';
49
-
50
- switch (value) {
51
- case 'a':
52
- <div>{'Case A'}</div>
53
- case 'b':
54
- <div>{'Case B'}</div>
55
- case 'c':
56
- <div>{'Case C'}</div>
57
- break;
58
- default:
59
- <div>{'Default Case'}</div>
60
- }
49
+ function App() {
50
+ return <>
51
+ let value = 'a';
52
+ switch (value) {
53
+ case 'a':
54
+ <div>{'Case A'}</div>
55
+ case 'b':
56
+ <div>{'Case B'}</div>
57
+ case 'c':
58
+ <div>{'Case C'}</div>
59
+ break;
60
+ default:
61
+ <div>{'Default Case'}</div>
62
+ }
63
+ </>;
61
64
  }
62
65
 
63
66
  const { body } = await render(App);
@@ -65,21 +68,22 @@ describe('SSR: switch statements', () => {
65
68
  });
66
69
 
67
70
  it('renders a fall-through with a default case in the middle', async () => {
68
- component App() {
69
- let value = 'x';
70
-
71
- switch (value) {
72
- case 'a':
73
- <div>{'Case A'}</div>
74
- default:
75
- <div>{'Default Case'}</div>
76
- case 'b':
77
- <div>{'Case B'}</div>
78
- break;
79
- case 'c':
80
- <div>{'Case C'}</div>
81
- break;
82
- }
71
+ function App() {
72
+ return <>
73
+ let value = 'x';
74
+ switch (value) {
75
+ case 'a':
76
+ <div>{'Case A'}</div>
77
+ default:
78
+ <div>{'Default Case'}</div>
79
+ case 'b':
80
+ <div>{'Case B'}</div>
81
+ break;
82
+ case 'c':
83
+ <div>{'Case C'}</div>
84
+ break;
85
+ }
86
+ </>;
83
87
  }
84
88
 
85
89
  const { body } = await render(App);
@@ -87,18 +91,19 @@ describe('SSR: switch statements', () => {
87
91
  });
88
92
 
89
93
  it('renders bare text nodes in switch fall-through cases without element wrappers', async () => {
90
- component App() {
91
- let value = 'a';
92
-
93
- <div>
94
- <span>{'before'}</span>
95
- switch (value) {
96
- case 'a':
97
- {'Case A'}
98
- case 'b':
99
- {'Case B'}
100
- }
101
- </div>
94
+ function App() {
95
+ return <>
96
+ let value = 'a';
97
+ <div>
98
+ <span>{'before'}</span>
99
+ switch (value) {
100
+ case 'a':
101
+ {'Case A'}
102
+ case 'b':
103
+ {'Case B'}
104
+ }
105
+ </div>
106
+ </>;
102
107
  }
103
108
 
104
109
  const { body } = await render(App);
@@ -106,20 +111,21 @@ describe('SSR: switch statements', () => {
106
111
  });
107
112
 
108
113
  it('renders bare text nodes in switch cases without element wrappers', async () => {
109
- component App() {
110
- let value = 'a';
111
-
112
- <div>
113
- <span>{'before'}</span>
114
- switch (value) {
115
- case 'a':
116
- {'Case A'}
117
- break;
118
- case 'b':
119
- {'Case B'}
120
- break;
121
- }
122
- </div>
114
+ function App() {
115
+ return <>
116
+ let value = 'a';
117
+ <div>
118
+ <span>{'before'}</span>
119
+ switch (value) {
120
+ case 'a':
121
+ {'Case A'}
122
+ break;
123
+ case 'b':
124
+ {'Case B'}
125
+ break;
126
+ }
127
+ </div>
128
+ </>;
123
129
  }
124
130
 
125
131
  const { body } = await render(App);
@@ -5,13 +5,15 @@ const TRACK_ASYNC_PUBLIC_ERROR_MESSAGE = 'An error occurred during async renderi
5
5
 
6
6
  describe('trackAsync serialization (server)', () => {
7
7
  it('serializes resolved trackAsync data as a script tag in SSR output', async () => {
8
- component App() {
9
- try {
10
- let &[data] = trackAsync(() => Promise.resolve('hello world'));
11
- <p class="result">{data}</p>
12
- } pending {
13
- <p class="loading">{'loading...'}</p>
14
- }
8
+ function App() {
9
+ return <>
10
+ try {
11
+ let &[data] = trackAsync(() => Promise.resolve('hello world'));
12
+ <p class="result">{data}</p>
13
+ } pending {
14
+ <p class="loading">{'loading...'}</p>
15
+ }
16
+ </>;
15
17
  }
16
18
 
17
19
  const { body } = await render(App);
@@ -22,13 +24,15 @@ describe('trackAsync serialization (server)', () => {
22
24
  });
23
25
 
24
26
  it('serializes numeric trackAsync data correctly', async () => {
25
- component App() {
26
- try {
27
- let &[count] = trackAsync(() => Promise.resolve(42));
28
- <span class="count">{count}</span>
29
- } pending {
30
- <span>{'...'}</span>
31
- }
27
+ function App() {
28
+ return <>
29
+ try {
30
+ let &[count] = trackAsync(() => Promise.resolve(42));
31
+ <span class="count">{count}</span>
32
+ } pending {
33
+ <span>{'...'}</span>
34
+ }
35
+ </>;
32
36
  }
33
37
 
34
38
  const { body } = await render(App);
@@ -37,13 +41,15 @@ describe('trackAsync serialization (server)', () => {
37
41
  });
38
42
 
39
43
  it('serializes object trackAsync data correctly', async () => {
40
- component App() {
41
- try {
42
- let &[data] = trackAsync(() => Promise.resolve({ name: 'Alice', age: 30 }));
43
- <p>{data.name}</p>
44
- } pending {
45
- <p>{'...'}</p>
46
- }
44
+ function App() {
45
+ return <>
46
+ try {
47
+ let &[data] = trackAsync(() => Promise.resolve({ name: 'Alice', age: 30 }));
48
+ <p>{data.name}</p>
49
+ } pending {
50
+ <p>{'...'}</p>
51
+ }
52
+ </>;
47
53
  }
48
54
 
49
55
  const { body } = await render(App);
@@ -52,17 +58,19 @@ describe('trackAsync serialization (server)', () => {
52
58
  });
53
59
 
54
60
  it('serializes array trackAsync data correctly', async () => {
55
- component App() {
56
- try {
57
- let &[items] = trackAsync(() => Promise.resolve(['a', 'b', 'c']));
58
- <ul>
59
- for (let item of items) {
60
- <li>{item}</li>
61
- }
62
- </ul>
63
- } pending {
64
- <p>{'...'}</p>
65
- }
61
+ function App() {
62
+ return <>
63
+ try {
64
+ let &[items] = trackAsync(() => Promise.resolve(['a', 'b', 'c']));
65
+ <ul>
66
+ for (let item of items) {
67
+ <li>{item}</li>
68
+ }
69
+ </ul>
70
+ } pending {
71
+ <p>{'...'}</p>
72
+ }
73
+ </>;
66
74
  }
67
75
 
68
76
  const { body } = await render(App);
@@ -71,15 +79,17 @@ describe('trackAsync serialization (server)', () => {
71
79
  });
72
80
 
73
81
  it('serializes rejected trackAsync as error envelope', async () => {
74
- component App() {
75
- try {
76
- let &[data] = trackAsync(() => Promise.reject(new Error('fetch failed')));
77
- <p class="result">{data}</p>
78
- } pending {
79
- <p class="loading">{'loading...'}</p>
80
- } catch (e) {
81
- <p class="error">{(e as Error).message}</p>
82
- }
82
+ function App() {
83
+ return <>
84
+ try {
85
+ let &[data] = trackAsync(() => Promise.reject(new Error('fetch failed')));
86
+ <p class="result">{data}</p>
87
+ } pending {
88
+ <p class="loading">{'loading...'}</p>
89
+ } catch (e) {
90
+ <p class="error">{(e as Error).message}</p>
91
+ }
92
+ </>;
83
93
  }
84
94
 
85
95
  const { body } = await render(App);
@@ -91,21 +101,25 @@ describe('trackAsync serialization (server)', () => {
91
101
  });
92
102
 
93
103
  it('serializes error when child component error bubbles to parent catch', async () => {
94
- component Child() {
95
- try {
96
- let &[data] = trackAsync(() => Promise.reject(new Error('child error')));
97
- <p class="result">{data}</p>
98
- } pending {
99
- <p class="pending">{'loading...'}</p>
100
- }
104
+ function Child() {
105
+ return <>
106
+ try {
107
+ let &[data] = trackAsync(() => Promise.reject(new Error('child error')));
108
+ <p class="result">{data}</p>
109
+ } pending {
110
+ <p class="pending">{'loading...'}</p>
111
+ }
112
+ </>;
101
113
  }
102
114
 
103
- component Parent() {
104
- try {
105
- <Child />
106
- } catch (e) {
107
- <p class="parent-error">{(e as Error).message}</p>
108
- }
115
+ function Parent() {
116
+ return <>
117
+ try {
118
+ <Child />
119
+ } catch (e) {
120
+ <p class="parent-error">{(e as Error).message}</p>
121
+ }
122
+ </>;
109
123
  }
110
124
 
111
125
  const { body } = await render(Parent);
@@ -117,17 +131,19 @@ describe('trackAsync serialization (server)', () => {
117
131
  });
118
132
 
119
133
  it('serializes sync trackAsync throw using original cause message', async () => {
120
- component App() {
121
- try {
122
- let &[data] = trackAsync(() => {
123
- throw new Error('sync failure');
124
- });
125
- <p class="result">{data}</p>
126
- } pending {
127
- <p class="loading">{'loading...'}</p>
128
- } catch (e) {
129
- <p class="error">{(e as Error).message}</p>
130
- }
134
+ function App() {
135
+ return <>
136
+ try {
137
+ let &[data] = trackAsync(() => {
138
+ throw new Error('sync failure');
139
+ });
140
+ <p class="result">{data}</p>
141
+ } pending {
142
+ <p class="loading">{'loading...'}</p>
143
+ } catch (e) {
144
+ <p class="error">{(e as Error).message}</p>
145
+ }
146
+ </>;
131
147
  }
132
148
 
133
149
  const { body } = await render(App);
@@ -140,17 +156,19 @@ describe('trackAsync serialization (server)', () => {
140
156
  });
141
157
 
142
158
  it('escapes serialized error payload to keep script tag safe', async () => {
143
- component App() {
144
- try {
145
- let &[data] = trackAsync(
146
- () => Promise.reject(new Error('</script><div data-injected="1">boom</div>')),
147
- );
148
- <p class="result">{data}</p>
149
- } pending {
150
- <p class="loading">{'loading...'}</p>
151
- } catch (e) {
152
- <p class="error">{(e as Error).message}</p>
153
- }
159
+ function App() {
160
+ return <>
161
+ try {
162
+ let &[data] = trackAsync(
163
+ () => Promise.reject(new Error('</script><div data-injected="1">boom</div>')),
164
+ );
165
+ <p class="result">{data}</p>
166
+ } pending {
167
+ <p class="loading">{'loading...'}</p>
168
+ } catch (e) {
169
+ <p class="error">{(e as Error).message}</p>
170
+ }
171
+ </>;
154
172
  }
155
173
 
156
174
  const { body } = await render(App);
@@ -164,15 +182,17 @@ describe('trackAsync serialization (server)', () => {
164
182
  });
165
183
 
166
184
  it('generates unique hashes for multiple trackAsync calls', async () => {
167
- component App() {
168
- try {
169
- let &[a] = trackAsync(() => Promise.resolve('first'));
170
- let &[b] = trackAsync(() => Promise.resolve('second'));
171
- <p>{a}</p>
172
- <p>{b}</p>
173
- } pending {
174
- <p>{'...'}</p>
175
- }
185
+ function App() {
186
+ return <>
187
+ try {
188
+ let &[a] = trackAsync(() => Promise.resolve('first'));
189
+ let &[b] = trackAsync(() => Promise.resolve('second'));
190
+ <p>{a}</p>
191
+ <p>{b}</p>
192
+ } pending {
193
+ <p>{'...'}</p>
194
+ }
195
+ </>;
176
196
  }
177
197
 
178
198
  const { body } = await render(App);