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
@@ -2,19 +2,19 @@ import { RippleArray, flushSync, track } from 'ripple';
2
2
 
3
3
  describe('RippleArray > mutations', () => {
4
4
  it('handles direct assignment and length tracking', () => {
5
- function ArrayTest() {
6
- return <>
7
- let items = new RippleArray(1, 2, 3);
5
+ function ArrayTest() @{
6
+ let items = new RippleArray(1, 2, 3);
7
+ <>
8
8
  <button onClick={() => (items[items.length] = items.length + 1)}>{'increment'}</button>
9
9
  <Child {items} />
10
- </>;
10
+ </>
11
11
  }
12
12
 
13
- function Child({ items }: { items: RippleArray<number> }) {
14
- return <>
13
+ function Child({ items }: { items: RippleArray<number> }) @{
14
+ <>
15
15
  <pre>{JSON.stringify(items)}</pre>
16
16
  <pre>{items.length}</pre>
17
- </>;
17
+ </>
18
18
  }
19
19
 
20
20
  render(ArrayTest);
@@ -35,16 +35,16 @@ describe('RippleArray > mutations', () => {
35
35
  });
36
36
 
37
37
  it('handles push and pop operations with reactivity', () => {
38
- function ArrayTest() {
39
- return <>
40
- let items = new RippleArray(1, 2, 3);
41
- let &[lastItem] = track(() => items[items.length - 1]);
38
+ function ArrayTest() @{
39
+ let items = new RippleArray(1, 2, 3);
40
+ let &[lastItem] = track(() => items[items.length - 1]);
41
+ <>
42
42
  <button onClick={() => items.push(4)}>{'push'}</button>
43
43
  <button onClick={() => items.pop()}>{'pop'}</button>
44
44
  <pre>{JSON.stringify(items)}</pre>
45
45
  <pre>{items.length}</pre>
46
46
  <pre>{lastItem}</pre>
47
- </>;
47
+ </>
48
48
  }
49
49
 
50
50
  render(ArrayTest);
@@ -75,16 +75,16 @@ describe('RippleArray > mutations', () => {
75
75
  });
76
76
 
77
77
  it('handles shift and unshift operations with reactivity', () => {
78
- function ArrayTest() {
79
- return <>
80
- let items = new RippleArray(2, 3, 4);
81
- let &[firstItem] = track(() => items[0]);
78
+ function ArrayTest() @{
79
+ let items = new RippleArray(2, 3, 4);
80
+ let &[firstItem] = track(() => items[0]);
81
+ <>
82
82
  <button onClick={() => items.unshift(1)}>{'unshift'}</button>
83
83
  <button onClick={() => items.shift()}>{'shift'}</button>
84
84
  <pre>{JSON.stringify(items)}</pre>
85
85
  <pre>{items.length}</pre>
86
86
  <pre>{firstItem}</pre>
87
- </>;
87
+ </>
88
88
  }
89
89
 
90
90
  render(ArrayTest);
@@ -115,15 +115,15 @@ describe('RippleArray > mutations', () => {
115
115
  });
116
116
 
117
117
  it('handles splice operation with reactivity', () => {
118
- function ArrayTest() {
119
- return <>
120
- let items: RippleArray<number | string> = new RippleArray(1, 2, 3, 4, 5);
121
- let &[middleItem] = track(() => items[2]);
118
+ function ArrayTest() @{
119
+ let items: RippleArray<number | string> = new RippleArray(1, 2, 3, 4, 5);
120
+ let &[middleItem] = track(() => items[2]);
121
+ <>
122
122
  <button onClick={() => items.splice(1, 2, 'a', 'b')}>{'splice'}</button>
123
123
  <pre>{JSON.stringify(items)}</pre>
124
124
  <pre>{items.length}</pre>
125
125
  <pre>{middleItem}</pre>
126
- </>;
126
+ </>
127
127
  }
128
128
 
129
129
  render(ArrayTest);
@@ -145,14 +145,14 @@ describe('RippleArray > mutations', () => {
145
145
  });
146
146
 
147
147
  it('handles fill operation with reactivity', () => {
148
- function ArrayTest() {
149
- return <>
150
- let items = new RippleArray(1, 2, 3, 4, 5);
151
- let &[secondItem] = track(() => items[1]);
148
+ function ArrayTest() @{
149
+ let items = new RippleArray(1, 2, 3, 4, 5);
150
+ let &[secondItem] = track(() => items[1]);
151
+ <>
152
152
  <button onClick={() => items.fill(0, 1, 4)}>{'fill'}</button>
153
153
  <pre>{JSON.stringify(items)}</pre>
154
154
  <pre>{secondItem}</pre>
155
- </>;
155
+ </>
156
156
  }
157
157
 
158
158
  render(ArrayTest);
@@ -172,16 +172,16 @@ describe('RippleArray > mutations', () => {
172
172
  });
173
173
 
174
174
  it('handles reverse operation with reactivity', () => {
175
- function ArrayTest() {
176
- return <>
177
- let items = new RippleArray(1, 2, 3, 4, 5);
178
- let &[firstItem] = track(() => items[0]);
179
- let &[lastItem] = track(() => items[4]);
175
+ function ArrayTest() @{
176
+ let items = new RippleArray(1, 2, 3, 4, 5);
177
+ let &[firstItem] = track(() => items[0]);
178
+ let &[lastItem] = track(() => items[4]);
179
+ <>
180
180
  <button onClick={() => items.reverse()}>{'reverse'}</button>
181
181
  <pre>{JSON.stringify(items)}</pre>
182
182
  <pre>{firstItem}</pre>
183
183
  <pre>{lastItem}</pre>
184
- </>;
184
+ </>
185
185
  }
186
186
 
187
187
  render(ArrayTest);
@@ -203,15 +203,15 @@ describe('RippleArray > mutations', () => {
203
203
  });
204
204
 
205
205
  it('handles sort operation with reactivity', () => {
206
- function ArrayTest() {
207
- return <>
208
- let items = new RippleArray(5, 3, 1, 4, 2);
209
- let &[secondItem] = track(() => items[1]);
206
+ function ArrayTest() @{
207
+ let items = new RippleArray(5, 3, 1, 4, 2);
208
+ let &[secondItem] = track(() => items[1]);
209
+ <>
210
210
  <button onClick={() => items.sort()}>{'sort ascending'}</button>
211
211
  <button onClick={() => items.sort((a, b) => b - a)}>{'sort descending'}</button>
212
212
  <pre>{JSON.stringify(items)}</pre>
213
213
  <pre>{secondItem}</pre>
214
- </>;
214
+ </>
215
215
  }
216
216
 
217
217
  render(ArrayTest);
@@ -239,14 +239,14 @@ describe('RippleArray > mutations', () => {
239
239
  });
240
240
 
241
241
  it('handles array modification through forEach()', () => {
242
- function ArrayTest() {
243
- return <>
244
- let items = new RippleArray(1, 2, 3);
245
- <button onClick={() => items.forEach((item, i) => (items[i] = item * 2))}>
246
- {'double all'}
247
- </button>
242
+ function ArrayTest() @{
243
+ let items = new RippleArray(1, 2, 3);
244
+ <>
245
+ <button
246
+ onClick={() => items.forEach((item, i) => (items[i] = item * 2))}
247
+ >{'double all'}</button>
248
248
  <pre>{JSON.stringify(items)}</pre>
249
- </>;
249
+ </>
250
250
  }
251
251
 
252
252
  render(ArrayTest);
@@ -264,16 +264,16 @@ describe('RippleArray > mutations', () => {
264
264
  });
265
265
 
266
266
  it('handles array modification through iterator', () => {
267
- function ArrayTest() {
268
- return <>
269
- let items = new RippleArray(1, 2, 3);
270
- <button onClick={() => items.forEach((item, i) => (items[i] = item * 2))}>
271
- {'double all'}
272
- </button>
273
- for (const item of items) {
267
+ function ArrayTest() @{
268
+ let items = new RippleArray(1, 2, 3);
269
+ <>
270
+ <button
271
+ onClick={() => items.forEach((item, i) => (items[i] = item * 2))}
272
+ >{'double all'}</button>
273
+ @for (const item of items) {
274
274
  <pre>{item}</pre>
275
275
  }
276
- </>;
276
+ </>
277
277
  }
278
278
 
279
279
  render(ArrayTest);
@@ -295,17 +295,17 @@ describe('RippleArray > mutations', () => {
295
295
  });
296
296
 
297
297
  it('handles array index access with reactivity', () => {
298
- function ArrayTest() {
299
- return <>
300
- let items = new RippleArray(10, 20, 30);
301
- let &[firstItem] = track(() => items[0]);
302
- let &[secondItem] = track(() => items[1]);
298
+ function ArrayTest() @{
299
+ let items = new RippleArray(10, 20, 30);
300
+ let &[firstItem] = track(() => items[0]);
301
+ let &[secondItem] = track(() => items[1]);
302
+ <>
303
303
  <button onClick={() => (items[0] = 100)}>{'change first'}</button>
304
304
  <pre>{firstItem}</pre>
305
305
  <pre>{secondItem}</pre>
306
306
  <pre>{items[0]}</pre>
307
307
  <pre>{items[1]}</pre>
308
- </>;
308
+ </>
309
309
  }
310
310
 
311
311
  render(ArrayTest);
@@ -329,15 +329,15 @@ describe('RippleArray > mutations', () => {
329
329
  });
330
330
 
331
331
  it('handles length property for reactivity', () => {
332
- function ArrayTest() {
333
- return <>
334
- let items = new RippleArray(1, 2, 3);
335
- let &[length] = track(() => items.length);
332
+ function ArrayTest() @{
333
+ let items = new RippleArray(1, 2, 3);
334
+ let &[length] = track(() => items.length);
335
+ <>
336
336
  <button onClick={() => (items.length = 5)}>{'expand'}</button>
337
337
  <button onClick={() => (items.length = 2)}>{'shrink'}</button>
338
338
  <pre>{JSON.stringify(items)}</pre>
339
339
  <pre>{length}</pre>
340
- </>;
340
+ </>
341
341
  }
342
342
 
343
343
  render(ArrayTest);
@@ -365,14 +365,14 @@ describe('RippleArray > mutations', () => {
365
365
  });
366
366
 
367
367
  it('handles setting length property and resizing the array', () => {
368
- function ArrayTest() {
369
- return <>
370
- let items = new RippleArray(1, 2, 3, 4, 5);
368
+ function ArrayTest() @{
369
+ let items = new RippleArray(1, 2, 3, 4, 5);
370
+ <>
371
371
  <button onClick={() => (items.length = 3)}>{'truncate'}</button>
372
372
  <button onClick={() => (items.length = 7)}>{'expand'}</button>
373
373
  <pre>{JSON.stringify(items)}</pre>
374
374
  <pre>{items.length}</pre>
375
- </>;
375
+ </>
376
376
  }
377
377
 
378
378
  render(ArrayTest);
@@ -3,15 +3,15 @@ import { MAX_ARRAY_LENGTH } from '../../../src/runtime/internal/client/constants
3
3
 
4
4
  describe('RippleArray > static', () => {
5
5
  it('handles static methods - from and of', () => {
6
- function ArrayTest() {
7
- return <>
8
- let itemsFrom = RippleArray.from([1, 2, 3], (x: number) => x * 2);
9
- let itemsOf = RippleArray.of(4, 5, 6);
6
+ function ArrayTest() @{
7
+ let itemsFrom = RippleArray.from([1, 2, 3], (x: number) => x * 2);
8
+ let itemsOf = RippleArray.of(4, 5, 6);
9
+ <>
10
10
  <button onClick={() => itemsFrom.push(8)}>{'add to from'}</button>
11
11
  <button onClick={() => itemsOf.push(7)}>{'add to of'}</button>
12
12
  <pre>{JSON.stringify(itemsFrom)}</pre>
13
13
  <pre>{JSON.stringify(itemsOf)}</pre>
14
- </>;
14
+ </>
15
15
  }
16
16
 
17
17
  render(ArrayTest);
@@ -38,28 +38,24 @@ describe('RippleArray > static', () => {
38
38
 
39
39
  ('fromAsync' in Array.prototype ? describe : describe.skip)('RippleArray fromAsync', async () => {
40
40
  it('handles static fromAsync method with reactivity', async () => {
41
- function Parent() {
42
- return <>
43
- try {
44
- <ArrayTest />
45
- } pending {
46
- <div>{'Loading placeholder...'}</div>
47
- }
48
- </>;
41
+ function Parent() @{
42
+ @try {
43
+ <ArrayTest />
44
+ } @pending {
45
+ <div>{'Loading placeholder...'}</div>
46
+ }
49
47
  }
50
48
 
51
- function ArrayTest() {
52
- return <>
53
- let &[items] = trackAsync(() => RippleArray.fromAsync([1, 2, 3]));
49
+ function ArrayTest() @{
50
+ let &[items] = trackAsync(() => RippleArray.fromAsync([1, 2, 3]));
51
+ <>
54
52
  <button
55
53
  onClick={() => {
56
54
  items.push(4);
57
55
  }}
58
- >
59
- {'add item'}
60
- </button>
56
+ >{'add item'}</button>
61
57
  <pre>{JSON.stringify(items)}</pre>
62
- </>;
58
+ </>
63
59
  }
64
60
 
65
61
  render(Parent);
@@ -79,28 +75,24 @@ describe('RippleArray > static', () => {
79
75
  });
80
76
 
81
77
  it('handles static fromAsync method with mapping function', async () => {
82
- function Parent() {
83
- return <>
84
- try {
85
- <ArrayTest />
86
- } pending {
87
- <div>{'Loading placeholder...'}</div>
88
- }
89
- </>;
78
+ function Parent() @{
79
+ @try {
80
+ <ArrayTest />
81
+ } @pending {
82
+ <div>{'Loading placeholder...'}</div>
83
+ }
90
84
  }
91
85
 
92
- function ArrayTest() {
93
- return <>
94
- let &[items] = trackAsync(() => RippleArray.fromAsync([1, 2, 3], (x: number) => x * 2));
86
+ function ArrayTest() @{
87
+ let &[items] = trackAsync(() => RippleArray.fromAsync([1, 2, 3], (x: number) => x * 2));
88
+ <>
95
89
  <button
96
90
  onClick={() => {
97
91
  items.push(8);
98
92
  }}
99
- >
100
- {'add item'}
101
- </button>
93
+ >{'add item'}</button>
102
94
  <pre>{JSON.stringify(items)}</pre>
103
- </>;
95
+ </>
104
96
  }
105
97
 
106
98
  render(Parent);
@@ -122,36 +114,36 @@ describe('RippleArray > static', () => {
122
114
  ('fromAsync' in Array.prototype ? it : it.skip)(
123
115
  'handles error in fromAsync method',
124
116
  async () => {
125
- function Parent() {
126
- return <>
127
- try {
128
- <ArrayTest />
129
- } pending {
130
- <div>{'Loading placeholder...'}</div>
131
- }
132
- </>;
117
+ function Parent() @{
118
+ @try {
119
+ <ArrayTest />
120
+ } @pending {
121
+ <div>{'Loading placeholder...'}</div>
122
+ }
133
123
  }
134
124
 
135
- function ArrayTest() {
136
- return <>
137
- async function* throwingIterable() {
138
- throw new Error('Async error');
139
- }
140
- try {
141
- let &[items] = trackAsync(() => RippleArray.fromAsync(throwingIterable()));
142
-
143
- <ul>
144
- for (const item of items) {
145
- <li>{item}</li>
146
- }
147
- </ul>
148
- } pending {
149
- <div>{'Loading...'}</div>
150
- } catch (e) {
151
- <pre>{'Error: ' + (e as Error).message}</pre>
125
+ function ArrayTest() @{
126
+ async function* throwingIterable() {
127
+ throw new Error('Async error');
128
+ }
129
+ @try {
130
+ let &[items] = trackAsync(() => RippleArray.fromAsync(throwingIterable()));
131
+
132
+ <ul>
133
+ @for (const item of items) {
134
+ <li>{item}</li>
135
+ }
136
+ </ul>
137
+ } @pending {
138
+ <div>{'Loading...'}</div>
139
+ } @catch (e) {
140
+ <>
141
+ <pre>
142
+ {'Error: ' + (e as Error).message}
143
+ </pre>
152
144
  <pre>{'No items'}</pre>
153
- }
154
- </>;
145
+ </>
146
+ }
155
147
  }
156
148
 
157
149
  render(Parent);
@@ -167,12 +159,12 @@ describe('RippleArray > static', () => {
167
159
 
168
160
  describe('Creates RippleArray with a single element', () => {
169
161
  it('specifies int', () => {
170
- function ArrayTest() {
171
- return <>
172
- let items = new RippleArray(3);
162
+ function ArrayTest() @{
163
+ let items = new RippleArray(3);
164
+ <>
173
165
  <pre>{JSON.stringify(items)}</pre>
174
166
  <pre>{items.length}</pre>
175
- </>;
167
+ </>
176
168
  }
177
169
 
178
170
  render(ArrayTest);
@@ -182,16 +174,16 @@ describe('RippleArray > static', () => {
182
174
  });
183
175
 
184
176
  it('errors on exceeding max array size', () => {
185
- function ArrayTest() {
186
- return <>
187
- let error = null;
177
+ function ArrayTest() @{
178
+ const error = (() => {
188
179
  try {
189
180
  new RippleArray(MAX_ARRAY_LENGTH + 1);
181
+ return null;
190
182
  } catch (e) {
191
- error = (e as Error).message;
183
+ return (e as Error).message;
192
184
  }
193
- <pre>{error}</pre>
194
- </>;
185
+ })();
186
+ <pre>{error}</pre>
195
187
  }
196
188
 
197
189
  render(ArrayTest);
@@ -200,12 +192,12 @@ describe('RippleArray > static', () => {
200
192
  });
201
193
 
202
194
  it('specifies int using static from method', () => {
203
- function ArrayTest() {
204
- return <>
205
- let items = RippleArray.from([4]);
195
+ function ArrayTest() @{
196
+ let items = RippleArray.from([4]);
197
+ <>
206
198
  <pre>{JSON.stringify(items)}</pre>
207
199
  <pre>{items.length}</pre>
208
- </>;
200
+ </>
209
201
  }
210
202
 
211
203
  render(ArrayTest);
@@ -215,12 +207,12 @@ describe('RippleArray > static', () => {
215
207
  });
216
208
 
217
209
  it('specifies int using static of method', () => {
218
- function ArrayTest() {
219
- return <>
220
- let items = RippleArray.of(5);
210
+ function ArrayTest() @{
211
+ let items = RippleArray.of(5);
212
+ <>
221
213
  <pre>{JSON.stringify(items)}</pre>
222
214
  <pre>{items.length}</pre>
223
- </>;
215
+ </>
224
216
  }
225
217
 
226
218
  render(ArrayTest);
@@ -232,22 +224,20 @@ describe('RippleArray > static', () => {
232
224
  ('fromAsync' in Array.prototype ? it : it.skip)(
233
225
  'specifies int using static fromAsync method',
234
226
  async () => {
235
- function Parent() {
236
- return <>
237
- try {
238
- <ArrayTest />
239
- } pending {
240
- <div>{'Loading placeholder...'}</div>
241
- }
242
- </>;
227
+ function Parent() @{
228
+ @try {
229
+ <ArrayTest />
230
+ } @pending {
231
+ <div>{'Loading placeholder...'}</div>
232
+ }
243
233
  }
244
234
 
245
- function ArrayTest() {
246
- return <>
247
- let &[items] = trackAsync(() => RippleArray.fromAsync([6]));
235
+ function ArrayTest() @{
236
+ let &[items] = trackAsync(() => RippleArray.fromAsync([6]));
237
+ <>
248
238
  <pre>{JSON.stringify(items)}</pre>
249
239
  <pre>{items.length}</pre>
250
- </>;
240
+ </>
251
241
  }
252
242
 
253
243
  render(Parent);
@@ -6,14 +6,14 @@ describe('RippleArray > to* methods', () => {
6
6
  context.skip();
7
7
  }
8
8
 
9
- function ArrayTest() {
10
- return <>
11
- let items = new RippleArray(1, 2, 3, 4);
12
- let &[reversed] = track(() => items.toReversed());
9
+ function ArrayTest() @{
10
+ let items = new RippleArray(1, 2, 3, 4);
11
+ let &[reversed] = track(() => items.toReversed());
12
+ <>
13
13
  <button onClick={() => items.push(5)}>{'add item'}</button>
14
14
  <pre>{JSON.stringify(items)}</pre>
15
15
  <pre>{JSON.stringify(reversed)}</pre>
16
- </>;
16
+ </>
17
17
  }
18
18
 
19
19
  render(ArrayTest);
@@ -37,14 +37,14 @@ describe('RippleArray > to* methods', () => {
37
37
  context.skip();
38
38
  }
39
39
 
40
- function ArrayTest() {
41
- return <>
42
- let items = new RippleArray(3, 1, 4, 2);
43
- let &[sorted] = track(() => items.toSorted());
40
+ function ArrayTest() @{
41
+ let items = new RippleArray(3, 1, 4, 2);
42
+ let &[sorted] = track(() => items.toSorted());
43
+ <>
44
44
  <button onClick={() => items.push(0)}>{'add item'}</button>
45
45
  <pre>{JSON.stringify(items)}</pre>
46
46
  <pre>{JSON.stringify(sorted)}</pre>
47
- </>;
47
+ </>
48
48
  }
49
49
 
50
50
  render(ArrayTest);
@@ -68,14 +68,14 @@ describe('RippleArray > to* methods', () => {
68
68
  context.skip();
69
69
  }
70
70
 
71
- function ArrayTest() {
72
- return <>
73
- let items = new RippleArray<string | number>(1, 2, 3, 4, 5);
74
- let &[spliced] = track(() => items.toSpliced(1, 2, 'a', 'b'));
71
+ function ArrayTest() @{
72
+ let items = new RippleArray<string | number>(1, 2, 3, 4, 5);
73
+ let &[spliced] = track(() => items.toSpliced(1, 2, 'a', 'b'));
74
+ <>
75
75
  <button onClick={() => (items[2] = 30)}>{'change item'}</button>
76
76
  <pre>{JSON.stringify(items)}</pre>
77
77
  <pre>{JSON.stringify(spliced)}</pre>
78
- </>;
78
+ </>
79
79
  }
80
80
 
81
81
  render(ArrayTest);