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.
Files changed (165) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/package.json +3 -3
  3. package/src/jsx-runtime.d.ts +2 -8
  4. package/src/runtime/index-client.js +3 -13
  5. package/src/runtime/internal/client/blocks.js +3 -25
  6. package/src/runtime/internal/client/for.js +80 -5
  7. package/src/runtime/internal/client/index.js +0 -2
  8. package/src/runtime/internal/client/types.d.ts +0 -10
  9. package/tests/client/__snapshots__/computed-properties.test.tsrx.snap +8 -0
  10. package/tests/client/__snapshots__/for.test.tsrx.snap +22 -0
  11. package/tests/client/__snapshots__/html.test.tsrx.snap +4 -0
  12. package/tests/client/array/array.copy-within.test.tsrx +19 -19
  13. package/tests/client/array/array.derived.test.tsrx +97 -109
  14. package/tests/client/array/array.iteration.test.tsrx +28 -28
  15. package/tests/client/array/array.mutations.test.tsrx +68 -68
  16. package/tests/client/array/array.static.test.tsrx +82 -92
  17. package/tests/client/array/array.to-methods.test.tsrx +15 -15
  18. package/tests/client/async-suspend.test.tsrx +180 -179
  19. package/tests/client/basic/__snapshots__/basic.attributes.test.tsrx.snap +2 -0
  20. package/tests/client/basic/__snapshots__/basic.rendering.test.tsrx.snap +4 -0
  21. package/tests/client/basic/basic.attributes.test.tsrx +273 -317
  22. package/tests/client/basic/basic.collections.test.tsrx +55 -61
  23. package/tests/client/basic/basic.components.test.tsrx +196 -218
  24. package/tests/client/basic/basic.errors.test.tsrx +70 -76
  25. package/tests/client/basic/basic.events.test.tsrx +80 -85
  26. package/tests/client/basic/basic.get-set.test.tsrx +54 -64
  27. package/tests/client/basic/basic.hmr.test.tsrx +15 -19
  28. package/tests/client/basic/basic.reactivity.test.tsrx +121 -135
  29. package/tests/client/basic/basic.rendering.test.tsrx +273 -178
  30. package/tests/client/basic/basic.utilities.test.tsrx +8 -10
  31. package/tests/client/boundaries.test.tsrx +18 -18
  32. package/tests/client/compiler/compiler.assignments.test.tsrx +77 -76
  33. package/tests/client/compiler/compiler.attributes.test.tsrx +18 -14
  34. package/tests/client/compiler/compiler.basic.test.tsrx +357 -288
  35. package/tests/client/compiler/compiler.regex.test.tsrx +40 -44
  36. package/tests/client/compiler/compiler.tracked-access.test.tsrx +57 -38
  37. package/tests/client/compiler/compiler.try-in-function.test.tsrx +16 -16
  38. package/tests/client/compiler/compiler.typescript.test.tsrx +4 -3
  39. package/tests/client/composite/composite.dynamic-components.test.tsrx +41 -44
  40. package/tests/client/composite/composite.generics.test.tsrx +165 -167
  41. package/tests/client/composite/composite.props.test.tsrx +66 -74
  42. package/tests/client/composite/composite.reactivity.test.tsrx +132 -166
  43. package/tests/client/composite/composite.render.test.tsrx +92 -101
  44. package/tests/client/computed-properties.test.tsrx +14 -18
  45. package/tests/client/context.test.tsrx +14 -18
  46. package/tests/client/css/global-additional-cases.test.tsrx +491 -437
  47. package/tests/client/css/global-advanced-selectors.test.tsrx +169 -153
  48. package/tests/client/css/global-at-rules.test.tsrx +71 -66
  49. package/tests/client/css/global-basic.test.tsrx +105 -98
  50. package/tests/client/css/global-classes-ids.test.tsrx +128 -114
  51. package/tests/client/css/global-combinators.test.tsrx +83 -78
  52. package/tests/client/css/global-complex-nesting.test.tsrx +134 -120
  53. package/tests/client/css/global-edge-cases.test.tsrx +138 -120
  54. package/tests/client/css/global-keyframes.test.tsrx +108 -96
  55. package/tests/client/css/global-nested.test.tsrx +88 -78
  56. package/tests/client/css/global-pseudo.test.tsrx +104 -98
  57. package/tests/client/css/global-scoping.test.tsrx +145 -125
  58. package/tests/client/css/style-identifier.test.tsrx +62 -69
  59. package/tests/client/date.test.tsrx +83 -83
  60. package/tests/client/dynamic-elements.test.tsrx +227 -283
  61. package/tests/client/events.test.tsrx +252 -266
  62. package/tests/client/for.test.tsrx +120 -127
  63. package/tests/client/head.test.tsrx +40 -48
  64. package/tests/client/html.test.tsrx +37 -49
  65. package/tests/client/input-value.test.tsrx +1125 -1354
  66. package/tests/client/lazy-array.test.tsrx +10 -16
  67. package/tests/client/lazy-destructuring.test.tsrx +169 -221
  68. package/tests/client/map.test.tsrx +39 -41
  69. package/tests/client/media-query.test.tsrx +15 -19
  70. package/tests/client/object.test.tsrx +46 -56
  71. package/tests/client/portal.test.tsrx +31 -37
  72. package/tests/client/ref.test.tsrx +173 -193
  73. package/tests/client/return.test.tsrx +62 -37
  74. package/tests/client/set.test.tsrx +33 -33
  75. package/tests/client/svg.test.tsrx +195 -215
  76. package/tests/client/switch.test.tsrx +201 -191
  77. package/tests/client/track-async-hydration.test.tsrx +14 -18
  78. package/tests/client/tracked-index-access.test.tsrx +18 -28
  79. package/tests/client/try.test.tsrx +494 -619
  80. package/tests/client/tsx.test.tsrx +286 -292
  81. package/tests/client/typescript-generics.test.tsrx +121 -129
  82. package/tests/client/url/url.derived.test.tsrx +21 -25
  83. package/tests/client/url/url.parsing.test.tsrx +35 -35
  84. package/tests/client/url/url.partial-removal.test.tsrx +32 -32
  85. package/tests/client/url/url.reactivity.test.tsrx +68 -72
  86. package/tests/client/url/url.serialization.test.tsrx +8 -8
  87. package/tests/client/url-search-params/url-search-params.derived.test.tsrx +21 -27
  88. package/tests/client/url-search-params/url-search-params.initialization.test.tsrx +16 -16
  89. package/tests/client/url-search-params/url-search-params.iteration.test.tsrx +37 -37
  90. package/tests/client/url-search-params/url-search-params.mutation.test.tsrx +56 -60
  91. package/tests/client/url-search-params/url-search-params.retrieval.test.tsrx +32 -34
  92. package/tests/client/url-search-params/url-search-params.serialization.test.tsrx +9 -9
  93. package/tests/client/url-search-params/url-search-params.tracked-url.test.tsrx +10 -10
  94. package/tests/hydration/compiled/client/basic.js +390 -319
  95. package/tests/hydration/compiled/client/composite.js +52 -44
  96. package/tests/hydration/compiled/client/for.js +734 -604
  97. package/tests/hydration/compiled/client/head.js +183 -103
  98. package/tests/hydration/compiled/client/html.js +93 -86
  99. package/tests/hydration/compiled/client/if-children.js +95 -71
  100. package/tests/hydration/compiled/client/if.js +113 -89
  101. package/tests/hydration/compiled/client/mixed-control-flow.js +225 -209
  102. package/tests/hydration/compiled/client/nested-control-flow.js +94 -98
  103. package/tests/hydration/compiled/client/reactivity.js +26 -24
  104. package/tests/hydration/compiled/client/return.js +8 -42
  105. package/tests/hydration/compiled/client/switch.js +208 -173
  106. package/tests/hydration/compiled/client/track-async-serialization.js +176 -128
  107. package/tests/hydration/compiled/client/try.js +29 -21
  108. package/tests/hydration/compiled/server/basic.js +210 -221
  109. package/tests/hydration/compiled/server/composite.js +13 -14
  110. package/tests/hydration/compiled/server/for.js +427 -444
  111. package/tests/hydration/compiled/server/head.js +199 -189
  112. package/tests/hydration/compiled/server/html.js +33 -41
  113. package/tests/hydration/compiled/server/if-children.js +114 -117
  114. package/tests/hydration/compiled/server/if.js +77 -83
  115. package/tests/hydration/compiled/server/mixed-control-flow.js +145 -150
  116. package/tests/hydration/compiled/server/nested-control-flow.js +10 -0
  117. package/tests/hydration/compiled/server/reactivity.js +24 -22
  118. package/tests/hydration/compiled/server/return.js +6 -18
  119. package/tests/hydration/compiled/server/switch.js +179 -176
  120. package/tests/hydration/compiled/server/track-async-serialization.js +88 -70
  121. package/tests/hydration/compiled/server/try.js +31 -35
  122. package/tests/hydration/components/basic.tsrx +216 -258
  123. package/tests/hydration/components/composite.tsrx +32 -42
  124. package/tests/hydration/components/events.tsrx +81 -101
  125. package/tests/hydration/components/for.tsrx +270 -336
  126. package/tests/hydration/components/head.tsrx +43 -39
  127. package/tests/hydration/components/hmr.tsrx +16 -22
  128. package/tests/hydration/components/html-in-template.tsrx +15 -21
  129. package/tests/hydration/components/html.tsrx +442 -526
  130. package/tests/hydration/components/if-children.tsrx +107 -125
  131. package/tests/hydration/components/if.tsrx +68 -90
  132. package/tests/hydration/components/mixed-control-flow.tsrx +65 -72
  133. package/tests/hydration/components/nested-control-flow.tsrx +202 -216
  134. package/tests/hydration/components/portal.tsrx +33 -41
  135. package/tests/hydration/components/reactivity.tsrx +26 -34
  136. package/tests/hydration/components/return.tsrx +4 -6
  137. package/tests/hydration/components/switch.tsrx +73 -78
  138. package/tests/hydration/components/track-async-serialization.tsrx +83 -93
  139. package/tests/hydration/components/try.tsrx +37 -51
  140. package/tests/hydration/switch.test.js +8 -8
  141. package/tests/server/await.test.tsrx +3 -3
  142. package/tests/server/basic.attributes.test.tsrx +117 -162
  143. package/tests/server/basic.components.test.tsrx +163 -193
  144. package/tests/server/basic.test.tsrx +298 -198
  145. package/tests/server/compiler.test.tsrx +142 -72
  146. package/tests/server/composite.props.test.tsrx +54 -58
  147. package/tests/server/composite.test.tsrx +165 -167
  148. package/tests/server/context.test.tsrx +13 -17
  149. package/tests/server/dynamic-elements.test.tsrx +103 -135
  150. package/tests/server/for.test.tsrx +115 -84
  151. package/tests/server/head.test.tsrx +31 -31
  152. package/tests/server/html-nesting-validation.test.tsrx +16 -8
  153. package/tests/server/if.test.tsrx +49 -59
  154. package/tests/server/lazy-destructuring.test.tsrx +288 -366
  155. package/tests/server/return.test.tsrx +58 -36
  156. package/tests/server/streaming-ssr.test.tsrx +4 -4
  157. package/tests/server/style-identifier.test.tsrx +58 -66
  158. package/tests/server/switch.test.tsrx +89 -97
  159. package/tests/server/track-async-serialization.test.tsrx +85 -103
  160. package/tests/server/try.test.tsrx +275 -360
  161. package/tests/utils/ref-types.test.js +72 -0
  162. package/tests/utils/vite-plugin-config.test.js +41 -74
  163. package/types/index.d.ts +1 -0
  164. package/src/runtime/internal/client/compat.js +0 -40
  165. package/tests/utils/compiler-compat-config.test.js +0 -38
@@ -3,24 +3,18 @@ import { flushSync, track } from 'ripple';
3
3
 
4
4
  describe('lazy array destructuring', () => {
5
5
  it('updates unknown lazy array bindings through tracked values', () => {
6
- function Child({ tr: &[count, tr] }) {
7
- return <>
8
- <button
9
- onClick={() => {
10
- count++;
11
- tr[0]++;
12
- }}
13
- >
14
- {count}
15
- </button>
16
- </>;
6
+ function Child({ tr: &[count, tr] }) @{
7
+ <button
8
+ onClick={() => {
9
+ count++;
10
+ tr[0]++;
11
+ }}
12
+ >{count}</button>
17
13
  }
18
14
 
19
- function App() {
20
- return <>
21
- let tracked = track(0);
22
- <Child tr={tracked} />
23
- </>;
15
+ function App() @{
16
+ let tracked = track(0);
17
+ <Child tr={tracked} />
24
18
  }
25
19
 
26
20
  render(App);
@@ -3,19 +3,17 @@ import { flushSync, track } from 'ripple';
3
3
 
4
4
  describe('lazy destructuring', () => {
5
5
  it('supports tracked value getter and setter', () => {
6
- function Test() {
7
- return <>
8
- let count = track(1);
9
- let doubled = track(() => count.value * 2);
6
+ function Test() @{
7
+ let count = track(1);
8
+ let doubled = track(() => count.value * 2);
9
+ <>
10
10
  <div>{`${count.value}-${doubled.value}`}</div>
11
11
  <button
12
12
  onClick={() => {
13
13
  count.value = 5;
14
14
  }}
15
- >
16
- {'set'}
17
- </button>
18
- </>;
15
+ >{'set'}</button>
16
+ </>
19
17
  }
20
18
 
21
19
  render(Test);
@@ -26,24 +24,22 @@ describe('lazy destructuring', () => {
26
24
  });
27
25
 
28
26
  it('lazily accesses object properties with const', () => {
29
- function Inner(&{ a, b }: { a: number; b: string }) {
30
- return <><pre>{`${a}-${b}`}</pre></>;
27
+ function Inner(&{ a, b }: { a: number; b: string }) @{
28
+ <pre>{`${a}-${b}`}</pre>
31
29
  }
32
30
 
33
- function Test() {
34
- return <>
35
- let &[a] = track(1);
36
- let &[b] = track('hello');
31
+ function Test() @{
32
+ let &[a] = track(1);
33
+ let &[b] = track('hello');
34
+ <>
37
35
  <Inner {a} {b} />
38
36
  <button
39
37
  onClick={() => {
40
38
  a = 2;
41
39
  b = 'world';
42
40
  }}
43
- >
44
- {'update'}
45
- </button>
46
- </>;
41
+ >{'update'}</button>
42
+ </>
47
43
  }
48
44
 
49
45
  render(Test);
@@ -54,24 +50,22 @@ describe('lazy destructuring', () => {
54
50
  });
55
51
 
56
52
  it('lazily accesses array elements with const', () => {
57
- function Inner(&{ first, second }: { first: number; second: number }) {
58
- return <><pre>{`${first}-${second}`}</pre></>;
53
+ function Inner(&{ first, second }: { first: number; second: number }) @{
54
+ <pre>{`${first}-${second}`}</pre>
59
55
  }
60
56
 
61
- function Test() {
62
- return <>
63
- let &[first] = track(10);
64
- let &[second] = track(20);
57
+ function Test() @{
58
+ let &[first] = track(10);
59
+ let &[second] = track(20);
60
+ <>
65
61
  <Inner {first} {second} />
66
62
  <button
67
63
  onClick={() => {
68
64
  first = 30;
69
65
  second = 40;
70
66
  }}
71
- >
72
- {'update'}
73
- </button>
74
- </>;
67
+ >{'update'}</button>
68
+ </>
75
69
  }
76
70
 
77
71
  render(Test);
@@ -82,12 +76,12 @@ describe('lazy destructuring', () => {
82
76
  });
83
77
 
84
78
  it('preserves numeric member access on lazy array value bindings', () => {
85
- function Child({ pair: &[first] }: { pair: [{ 0: string }] }) {
86
- return <><pre>{first[0]}</pre></>;
79
+ function Child({ pair: &[first] }: { pair: [{ 0: string }] }) @{
80
+ <pre>{first[0]}</pre>
87
81
  }
88
82
 
89
- function Test() {
90
- return <><Child pair={[{ 0: 'x' }]} /></>;
83
+ function Test() @{
84
+ <Child pair={[{ 0: 'x' }]} />
91
85
  }
92
86
 
93
87
  render(Test);
@@ -95,12 +89,10 @@ describe('lazy destructuring', () => {
95
89
  });
96
90
 
97
91
  it('supports default values in lazy object destructuring', () => {
98
- function Test() {
99
- return <>
100
- const obj: { a: number; b?: number } = { a: 5 };
101
- const &{ a, b = 99 } = obj;
102
- <pre>{`${a}-${b}`}</pre>
103
- </>;
92
+ function Test() @{
93
+ const obj: { a: number; b?: number } = { a: 5 };
94
+ const &{ a, b = 99 } = obj;
95
+ <pre>{`${a}-${b}`}</pre>
104
96
  }
105
97
 
106
98
  render(Test);
@@ -108,12 +100,12 @@ describe('lazy destructuring', () => {
108
100
  });
109
101
 
110
102
  it('supports lazy destructuring in component params', () => {
111
- function Inner(&{ name, age }: { name: string; age: number }) {
112
- return <><pre>{`${name}-${age}`}</pre></>;
103
+ function Inner(&{ name, age }: { name: string; age: number }) @{
104
+ <pre>{`${name}-${age}`}</pre>
113
105
  }
114
106
 
115
- function Test() {
116
- return <><Inner name="Alice" age={30} /></>;
107
+ function Test() @{
108
+ <Inner name="Alice" age={30} />
117
109
  }
118
110
 
119
111
  render(Test);
@@ -121,22 +113,20 @@ describe('lazy destructuring', () => {
121
113
  });
122
114
 
123
115
  it('supports lazy destructuring in component params with reactivity', () => {
124
- function Inner(&{ count }: { count: number }) {
125
- return <><pre>{count}</pre></>;
116
+ function Inner(&{ count }: { count: number }) @{
117
+ <pre>{count}</pre>
126
118
  }
127
119
 
128
- function Test() {
129
- return <>
130
- let &[count] = track(0);
120
+ function Test() @{
121
+ let &[count] = track(0);
122
+ <>
131
123
  <Inner {count} />
132
124
  <button
133
125
  onClick={() => {
134
126
  count++;
135
127
  }}
136
- >
137
- {'increment'}
138
- </button>
139
- </>;
128
+ >{'increment'}</button>
129
+ </>
140
130
  }
141
131
 
142
132
  render(Test);
@@ -147,15 +137,13 @@ describe('lazy destructuring', () => {
147
137
  });
148
138
 
149
139
  it('supports nested lazy destructuring in non-lazy component params', () => {
150
- function Inner({ something: &[first, second] }: { something: Tracked<number> }) {
151
- return <>
152
- first = second.value + 1;
153
- <pre>{`${first}-${second.value}`}</pre>
154
- </>;
140
+ function Inner({ something: &[first, second] }: { something: Tracked<number> }) @{
141
+ first = second.value + 1;
142
+ <pre>{`${first}-${second.value}`}</pre>
155
143
  }
156
144
 
157
- function Test() {
158
- return <><Inner something={track(1)} /></>;
145
+ function Test() @{
146
+ <Inner something={track(1)} />
159
147
  }
160
148
 
161
149
  render(Test);
@@ -169,16 +157,14 @@ describe('lazy destructuring', () => {
169
157
  values: [head, ...&{ length: rest_length, 0: first_rest }],
170
158
  }: {
171
159
  values: [number, Tracked<number>, Tracked<number>];
172
- }) {
173
- return <>
174
- const before = `${first_rest?.value ?? 'nil'}-${rest_length}`;
175
- rest_length = 0;
176
- <pre>{`${head}-${before}-${first_rest?.value ?? 'nil'}-${rest_length}`}</pre>
177
- </>;
160
+ }) @{
161
+ const before = `${first_rest?.value ?? 'nil'}-${rest_length}`;
162
+ rest_length = 0;
163
+ <pre>{`${head}-${before}-${first_rest?.value ?? 'nil'}-${rest_length}`}</pre>
178
164
  }
179
165
 
180
- function Test() {
181
- return <><Inner values={[10, track(20), track(30)]} /></>;
166
+ function Test() @{
167
+ <Inner values={[10, track(20), track(30)]} />
182
168
  }
183
169
 
184
170
  render(Test);
@@ -187,14 +173,12 @@ describe('lazy destructuring', () => {
187
173
  );
188
174
 
189
175
  it('supports lazy destructuring in function params', () => {
190
- function Test() {
191
- return <>
192
- function getInfo(&{ x, y }: { x: number; y: number }) {
193
- return x + y;
194
- }
195
- const result = getInfo({ x: 3, y: 7 });
196
- <pre>{result}</pre>
197
- </>;
176
+ function Test() @{
177
+ function getInfo(&{ x, y }: { x: number; y: number }) {
178
+ return x + y;
179
+ }
180
+ const result = getInfo({ x: 3, y: 7 });
181
+ <pre>{result}</pre>
198
182
  }
199
183
 
200
184
  render(Test);
@@ -202,16 +186,14 @@ describe('lazy destructuring', () => {
202
186
  });
203
187
 
204
188
  it('supports nested lazy destructuring in non-lazy function params', () => {
205
- function Test() {
206
- return <>
207
- const something = track(1);
208
- function getInfo({ something: &[first, second] }: { something: Tracked<number> }) {
209
- first = second.value + 1;
210
- return `${first}-${second.value}`;
211
- }
212
- const result = getInfo({ something });
213
- <pre>{result}</pre>
214
- </>;
189
+ function Test() @{
190
+ const something = track(1);
191
+ function getInfo({ something: &[first, second] }: { something: Tracked<number> }) {
192
+ first = second.value + 1;
193
+ return `${first}-${second.value}`;
194
+ }
195
+ const result = getInfo({ something });
196
+ <pre>{result}</pre>
215
197
  }
216
198
 
217
199
  render(Test);
@@ -221,20 +203,18 @@ describe('lazy destructuring', () => {
221
203
  it(
222
204
  'preserves lazy getter/setter behavior for nested rest destructuring in non-lazy function params',
223
205
  () => {
224
- function Test() {
225
- return <>
226
- function summarize({
227
- values: [head, ...&{ length: rest_length, 0: first_rest }],
228
- }: {
229
- values: [number, Tracked<number>, Tracked<number>];
230
- }) {
231
- const before = `${first_rest?.value ?? 'nil'}-${rest_length}`;
232
- rest_length = 0;
233
- return `${head}-${before}-${first_rest?.value ?? 'nil'}-${rest_length}`;
234
- }
235
- const result = summarize({ values: [5, track(6), track(7)] });
236
- <pre>{result}</pre>
237
- </>;
206
+ function Test() @{
207
+ function summarize({
208
+ values: [head, ...&{ length: rest_length, 0: first_rest }],
209
+ }: {
210
+ values: [number, Tracked<number>, Tracked<number>];
211
+ }) {
212
+ const before = `${first_rest?.value ?? 'nil'}-${rest_length}`;
213
+ rest_length = 0;
214
+ return `${head}-${before}-${first_rest?.value ?? 'nil'}-${rest_length}`;
215
+ }
216
+ const result = summarize({ values: [5, track(6), track(7)] });
217
+ <pre>{result}</pre>
238
218
  }
239
219
 
240
220
  render(Test);
@@ -243,14 +223,12 @@ describe('lazy destructuring', () => {
243
223
  );
244
224
 
245
225
  it('supports let lazy destructuring with assignment writeback', () => {
246
- function Test() {
247
- return <>
248
- const obj = { a: 1, b: 2 };
249
- let &{ a, b } = obj;
250
- a = 10;
251
- b = 20;
252
- <pre>{`${obj.a}-${obj.b}`}</pre>
253
- </>;
226
+ function Test() @{
227
+ const obj = { a: 1, b: 2 };
228
+ let &{ a, b } = obj;
229
+ a = 10;
230
+ b = 20;
231
+ <pre>{`${obj.a}-${obj.b}`}</pre>
254
232
  }
255
233
 
256
234
  render(Test);
@@ -258,14 +236,12 @@ describe('lazy destructuring', () => {
258
236
  });
259
237
 
260
238
  it('supports compound assignment operators on lazy bindings', () => {
261
- function Test() {
262
- return <>
263
- const obj = { a: 5, b: 10 };
264
- let &{ a, b } = obj;
265
- a += 3;
266
- b *= 2;
267
- <pre>{`${obj.a}-${obj.b}`}</pre>
268
- </>;
239
+ function Test() @{
240
+ const obj = { a: 5, b: 10 };
241
+ let &{ a, b } = obj;
242
+ a += 3;
243
+ b *= 2;
244
+ <pre>{`${obj.a}-${obj.b}`}</pre>
269
245
  }
270
246
 
271
247
  render(Test);
@@ -273,15 +249,13 @@ describe('lazy destructuring', () => {
273
249
  });
274
250
 
275
251
  it('supports update expressions on lazy bindings', () => {
276
- function Test() {
277
- return <>
278
- const obj = { count: 0 };
279
- let &{ count } = obj;
280
- count++;
281
- count++;
282
- count--;
283
- <pre>{obj.count}</pre>
284
- </>;
252
+ function Test() @{
253
+ const obj = { count: 0 };
254
+ let &{ count } = obj;
255
+ count++;
256
+ count++;
257
+ count--;
258
+ <pre>{obj.count}</pre>
285
259
  }
286
260
 
287
261
  render(Test);
@@ -289,15 +263,13 @@ describe('lazy destructuring', () => {
289
263
  });
290
264
 
291
265
  it('supports function params with lazy destructuring and default values', () => {
292
- function Test() {
293
- return <>
294
- function calc(&{ x, y = 100 }: { x: number; y?: number }) {
295
- return x + y;
296
- }
297
- const a = calc({ x: 5, y: 10 });
298
- const b = calc({ x: 5 });
299
- <pre>{`${a}-${b}`}</pre>
300
- </>;
266
+ function Test() @{
267
+ function calc(&{ x, y = 100 }: { x: number; y?: number }) {
268
+ return x + y;
269
+ }
270
+ const a = calc({ x: 5, y: 10 });
271
+ const b = calc({ x: 5 });
272
+ <pre>{`${a}-${b}`}</pre>
301
273
  }
302
274
 
303
275
  render(Test);
@@ -305,13 +277,11 @@ describe('lazy destructuring', () => {
305
277
  });
306
278
 
307
279
  it('supports lazy destructuring with default value writeback', () => {
308
- function Test() {
309
- return <>
310
- const obj: { a: number; b?: number } = { a: 1 };
311
- let &{ a, b = 50 } = obj;
312
- b = 99;
313
- <pre>{`${a}-${obj.b}`}</pre>
314
- </>;
280
+ function Test() @{
281
+ const obj: { a: number; b?: number } = { a: 1 };
282
+ let &{ a, b = 50 } = obj;
283
+ b = 99;
284
+ <pre>{`${a}-${obj.b}`}</pre>
315
285
  }
316
286
 
317
287
  render(Test);
@@ -319,11 +289,9 @@ describe('lazy destructuring', () => {
319
289
  });
320
290
 
321
291
  it('supports rest destructuring from iterable array-like tracked values', () => {
322
- function Test() {
323
- return <>
324
- let &[value, ...rest] = track(0);
325
- <pre>{`${value}-${rest.length}-${(rest[0] as Tracked<number>).value === value}`}</pre>
326
- </>;
292
+ function Test() @{
293
+ let &[value, ...rest] = track(0);
294
+ <pre>{`${value}-${rest.length}-${(rest[0] as Tracked<number>).value === value}`}</pre>
327
295
  }
328
296
 
329
297
  render(Test);
@@ -331,12 +299,10 @@ describe('lazy destructuring', () => {
331
299
  });
332
300
 
333
301
  it('supports rest destructuring from length-only array-like sources', () => {
334
- function Test() {
335
- return <>
336
- const source = { 0: 'x', 1: 'y', 2: 'z', length: 3 };
337
- const &[first, ...rest] = source;
338
- <pre>{`${first}-${rest.join(',')}`}</pre>
339
- </>;
302
+ function Test() @{
303
+ const source = { 0: 'x', 1: 'y', 2: 'z', length: 3 };
304
+ const &[first, ...rest] = source;
305
+ <pre>{`${first}-${rest.join(',')}`}</pre>
340
306
  }
341
307
 
342
308
  render(Test);
@@ -344,18 +310,16 @@ describe('lazy destructuring', () => {
344
310
  });
345
311
 
346
312
  it('supports rest destructuring from iterable sources', () => {
347
- function Test() {
348
- return <>
349
- const source = {
350
- *[Symbol.iterator]() {
351
- yield 'x';
352
- yield 'y';
353
- yield 'z';
354
- },
355
- };
356
- const &[first, ...rest] = source;
357
- <pre>{`${first}-${rest.join(',')}`}</pre>
358
- </>;
313
+ function Test() @{
314
+ const source = {
315
+ *[Symbol.iterator]() {
316
+ yield 'x';
317
+ yield 'y';
318
+ yield 'z';
319
+ },
320
+ };
321
+ const &[first, ...rest] = source;
322
+ <pre>{`${first}-${rest.join(',')}`}</pre>
359
323
  }
360
324
 
361
325
  render(Test);
@@ -363,14 +327,12 @@ describe('lazy destructuring', () => {
363
327
  });
364
328
 
365
329
  it('supports update expressions on lazy bindings with default values', () => {
366
- function Test() {
367
- return <>
368
- const obj: { count?: number } = {};
369
- let &{ count = 0 } = obj;
370
- count++;
371
- count++;
372
- <pre>{obj.count}</pre>
373
- </>;
330
+ function Test() @{
331
+ const obj: { count?: number } = {};
332
+ let &{ count = 0 } = obj;
333
+ count++;
334
+ count++;
335
+ <pre>{obj.count}</pre>
374
336
  }
375
337
 
376
338
  render(Test);
@@ -378,12 +340,10 @@ describe('lazy destructuring', () => {
378
340
  });
379
341
 
380
342
  it('supports member access on lazy destructured objects', () => {
381
- function Test() {
382
- return <>
383
- const obj = { user: { name: 'Alice', age: 30 } };
384
- const &{ user } = obj;
385
- <pre>{`${user.name}-${user.age}`}</pre>
386
- </>;
343
+ function Test() @{
344
+ const obj = { user: { name: 'Alice', age: 30 } };
345
+ const &{ user } = obj;
346
+ <pre>{`${user.name}-${user.age}`}</pre>
387
347
  }
388
348
 
389
349
  render(Test);
@@ -391,19 +351,17 @@ describe('lazy destructuring', () => {
391
351
  });
392
352
 
393
353
  it('supports standalone lazy array destructuring with track()', () => {
394
- function Test() {
395
- return <>
396
- let count: number;
397
- &[count] = track(0);
354
+ function Test() @{
355
+ let count: number;
356
+ &[count] = track(0);
357
+ <>
398
358
  <div>{count}</div>
399
359
  <button
400
360
  onClick={() => {
401
361
  count++;
402
362
  }}
403
- >
404
- {'inc'}
405
- </button>
406
- </>;
363
+ >{'inc'}</button>
364
+ </>
407
365
  }
408
366
 
409
367
  render(Test);
@@ -414,20 +372,18 @@ describe('lazy destructuring', () => {
414
372
  });
415
373
 
416
374
  it('supports standalone lazy array destructuring with second element', () => {
417
- function Test() {
418
- return <>
419
- let value;
420
- let tracked;
421
- &[value, tracked] = track(42);
375
+ function Test() @{
376
+ let value;
377
+ let tracked;
378
+ &[value, tracked] = track(42);
379
+ <>
422
380
  <div>{value}</div>
423
381
  <button
424
382
  onClick={() => {
425
383
  value = 100;
426
384
  }}
427
- >
428
- {'set'}
429
- </button>
430
- </>;
385
+ >{'set'}</button>
386
+ </>
431
387
  }
432
388
 
433
389
  render(Test);
@@ -438,16 +394,14 @@ describe('lazy destructuring', () => {
438
394
  });
439
395
 
440
396
  it('supports direct value access on tracked values', () => {
441
- function Test() {
442
- return <>
443
- let tracked = track(0);
444
- ++tracked.value;
445
- tracked.value++;
446
- tracked.value = tracked.value + 1;
447
- let value = tracked.value;
448
- let ref = tracked;
449
- <pre>{`${value}-${ref === tracked}`}</pre>
450
- </>;
397
+ function Test() @{
398
+ let tracked = track(0);
399
+ ++tracked.value;
400
+ tracked.value++;
401
+ tracked.value = tracked.value + 1;
402
+ let value = tracked.value;
403
+ let ref = tracked;
404
+ <pre>{`${value}-${ref === tracked}`}</pre>
451
405
  }
452
406
 
453
407
  render(Test);
@@ -455,19 +409,15 @@ describe('lazy destructuring', () => {
455
409
  });
456
410
 
457
411
  it('supports lazy destructured tracked ref value access', () => {
458
- function Child({ pair: &[value, tracked_ref] }: { pair: Tracked<number> }) {
459
- return <>
460
- ++tracked_ref.value;
461
- tracked_ref.value++;
462
- <pre>{`${value}-${tracked_ref.value}`}</pre>
463
- </>;
412
+ function Child({ pair: &[value, tracked_ref] }: { pair: Tracked<number> }) @{
413
+ ++tracked_ref.value;
414
+ tracked_ref.value++;
415
+ <pre>{`${value}-${tracked_ref.value}`}</pre>
464
416
  }
465
417
 
466
- function Test() {
467
- return <>
468
- let tracked = track(0);
469
- <Child pair={tracked} />
470
- </>;
418
+ function Test() @{
419
+ let tracked = track(0);
420
+ <Child pair={tracked} />
471
421
  }
472
422
 
473
423
  render(Test);
@@ -475,13 +425,11 @@ describe('lazy destructuring', () => {
475
425
  });
476
426
 
477
427
  it('supports standalone lazy object destructuring', () => {
478
- function Test() {
479
- return <>
480
- let a;
481
- let b;
482
- &{ a, b } = { a: 10, b: 20 };
483
- <pre>{`${a}-${b}`}</pre>
484
- </>;
428
+ function Test() @{
429
+ let a;
430
+ let b;
431
+ &{ a, b } = { a: 10, b: 20 };
432
+ <pre>{`${a}-${b}`}</pre>
485
433
  }
486
434
 
487
435
  render(Test);