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
@@ -2,18 +2,19 @@ import { RippleArray, flushSync, track } from 'ripple';
2
2
 
3
3
  describe('RippleArray > derived', () => {
4
4
  it('handles array methods that return values (map, filter, etc.)', () => {
5
- component ArrayTest() {
6
- let items = new RippleArray(1, 2, 3, 4, 5);
7
- let &[doubled] = track(() => items.map((x) => x * 2));
8
- let &[filtered] = track(() => items.filter((x) => x % 2 === 0));
9
- let &[reduced] = track(() => items.reduce((acc, val) => acc + val, 0));
10
- let &[includes] = track(() => items.includes(3));
11
-
12
- <button onClick={() => items.push(6)}>{'add item'}</button>
13
- <pre>{JSON.stringify(doubled)}</pre>
14
- <pre>{JSON.stringify(filtered)}</pre>
15
- <pre>{reduced}</pre>
16
- <pre>{includes.toString()}</pre>
5
+ function ArrayTest() {
6
+ return <>
7
+ let items = new RippleArray(1, 2, 3, 4, 5);
8
+ let &[doubled] = track(() => items.map((x) => x * 2));
9
+ let &[filtered] = track(() => items.filter((x) => x % 2 === 0));
10
+ let &[reduced] = track(() => items.reduce((acc, val) => acc + val, 0));
11
+ let &[includes] = track(() => items.includes(3));
12
+ <button onClick={() => items.push(6)}>{'add item'}</button>
13
+ <pre>{JSON.stringify(doubled)}</pre>
14
+ <pre>{JSON.stringify(filtered)}</pre>
15
+ <pre>{reduced}</pre>
16
+ <pre>{includes.toString()}</pre>
17
+ </>;
17
18
  }
18
19
 
19
20
  render(ArrayTest);
@@ -37,13 +38,14 @@ describe('RippleArray > derived', () => {
37
38
  });
38
39
 
39
40
  it('handles concat method with reactivity', () => {
40
- component ArrayTest() {
41
- let items = new RippleArray(1, 2, 3);
42
- let &[concatenated] = track(() => items.concat([4, 5], 6, [7, 8]));
43
-
44
- <button onClick={() => items.push(3.5)}>{'add to original'}</button>
45
- <pre>{JSON.stringify(items)}</pre>
46
- <pre>{JSON.stringify(concatenated)}</pre>
41
+ function ArrayTest() {
42
+ return <>
43
+ let items = new RippleArray(1, 2, 3);
44
+ let &[concatenated] = track(() => items.concat([4, 5], 6, [7, 8]));
45
+ <button onClick={() => items.push(3.5)}>{'add to original'}</button>
46
+ <pre>{JSON.stringify(items)}</pre>
47
+ <pre>{JSON.stringify(concatenated)}</pre>
48
+ </>;
47
49
  }
48
50
 
49
51
  render(ArrayTest);
@@ -63,13 +65,14 @@ describe('RippleArray > derived', () => {
63
65
  });
64
66
 
65
67
  it('handles array slice method with reactivity', () => {
66
- component ArrayTest() {
67
- let items = new RippleArray(1, 2, 3, 4, 5);
68
- let &[sliced] = track(() => items.slice(1, 4));
69
-
70
- <button onClick={() => (items[2] = 30)}>{'change middle'}</button>
71
- <pre>{JSON.stringify(items)}</pre>
72
- <pre>{JSON.stringify(sliced)}</pre>
68
+ function ArrayTest() {
69
+ return <>
70
+ let items = new RippleArray(1, 2, 3, 4, 5);
71
+ let &[sliced] = track(() => items.slice(1, 4));
72
+ <button onClick={() => (items[2] = 30)}>{'change middle'}</button>
73
+ <pre>{JSON.stringify(items)}</pre>
74
+ <pre>{JSON.stringify(sliced)}</pre>
75
+ </>;
73
76
  }
74
77
 
75
78
  render(ArrayTest);
@@ -89,21 +92,22 @@ describe('RippleArray > derived', () => {
89
92
  });
90
93
 
91
94
  it('handles find and findIndex methods with reactivity', () => {
92
- component ArrayTest() {
93
- let items = new RippleArray(5, 10, 15, 20, 25);
94
- let &[found] = track(() => items.find((x) => x > 12));
95
- let &[foundIndex] = track(() => items.findIndex((x) => x > 12));
96
-
97
- <button
98
- onClick={() => {
99
- items[1] = 13;
100
- items[0] = 6;
101
- }}
102
- >
103
- {'update values'}
104
- </button>
105
- <pre>{found}</pre>
106
- <pre>{foundIndex}</pre>
95
+ function ArrayTest() {
96
+ return <>
97
+ let items = new RippleArray(5, 10, 15, 20, 25);
98
+ let &[found] = track(() => items.find((x) => x > 12));
99
+ let &[foundIndex] = track(() => items.findIndex((x) => x > 12));
100
+ <button
101
+ onClick={() => {
102
+ items[1] = 13;
103
+ items[0] = 6;
104
+ }}
105
+ >
106
+ {'update values'}
107
+ </button>
108
+ <pre>{found}</pre>
109
+ <pre>{foundIndex}</pre>
110
+ </>;
107
111
  }
108
112
 
109
113
  render(ArrayTest);
@@ -123,21 +127,22 @@ describe('RippleArray > derived', () => {
123
127
  });
124
128
 
125
129
  it('handles findLast and findLastIndex methods with reactivity', () => {
126
- component ArrayTest() {
127
- let items = new RippleArray(5, 15, 10, 20, 15);
128
- let &[foundLast] = track(() => items.findLast((x) => x === 15));
129
- let &[foundLastIndex] = track(() => items.findLastIndex((x) => x === 15));
130
-
131
- <button
132
- onClick={() => {
133
- items[1] = 25;
134
- items[4] = 15;
135
- }}
136
- >
137
- {'update values'}
138
- </button>
139
- <pre>{foundLast}</pre>
140
- <pre>{foundLastIndex}</pre>
130
+ function ArrayTest() {
131
+ return <>
132
+ let items = new RippleArray(5, 15, 10, 20, 15);
133
+ let &[foundLast] = track(() => items.findLast((x) => x === 15));
134
+ let &[foundLastIndex] = track(() => items.findLastIndex((x) => x === 15));
135
+ <button
136
+ onClick={() => {
137
+ items[1] = 25;
138
+ items[4] = 15;
139
+ }}
140
+ >
141
+ {'update values'}
142
+ </button>
143
+ <pre>{foundLast}</pre>
144
+ <pre>{foundLastIndex}</pre>
145
+ </>;
141
146
  }
142
147
 
143
148
  render(ArrayTest);
@@ -157,20 +162,21 @@ describe('RippleArray > derived', () => {
157
162
  });
158
163
 
159
164
  it('handles every method with reactivity', () => {
160
- component ArrayTest() {
161
- let items = new RippleArray(2, 4, 6, 8);
162
- let &[allEven] = track(() => items.every((x) => x % 2 === 0));
163
-
164
- <button onClick={() => items.push(3)}>{'add odd'}</button>
165
- <button
166
- onClick={() => {
167
- items.pop();
168
- items.push(10);
169
- }}
170
- >
171
- {'ensure all even'}
172
- </button>
173
- <pre>{allEven.toString()}</pre>
165
+ function ArrayTest() {
166
+ return <>
167
+ let items = new RippleArray(2, 4, 6, 8);
168
+ let &[allEven] = track(() => items.every((x) => x % 2 === 0));
169
+ <button onClick={() => items.push(3)}>{'add odd'}</button>
170
+ <button
171
+ onClick={() => {
172
+ items.pop();
173
+ items.push(10);
174
+ }}
175
+ >
176
+ {'ensure all even'}
177
+ </button>
178
+ <pre>{allEven.toString()}</pre>
179
+ </>;
174
180
  }
175
181
 
176
182
  render(ArrayTest);
@@ -193,13 +199,14 @@ describe('RippleArray > derived', () => {
193
199
  });
194
200
 
195
201
  it('handles flat method with reactivity', () => {
196
- component ArrayTest() {
197
- let items = new RippleArray<number | number[]>([1, 2], [3, 4], 5);
198
- let &[flattened] = track(() => items.flat());
199
-
200
- <button onClick={() => (items[0] = [6, 7, 8])}>{'change nested'}</button>
201
- <pre>{JSON.stringify(items)}</pre>
202
- <pre>{JSON.stringify(flattened)}</pre>
202
+ function ArrayTest() {
203
+ return <>
204
+ let items = new RippleArray<number | number[]>([1, 2], [3, 4], 5);
205
+ let &[flattened] = track(() => items.flat());
206
+ <button onClick={() => (items[0] = [6, 7, 8])}>{'change nested'}</button>
207
+ <pre>{JSON.stringify(items)}</pre>
208
+ <pre>{JSON.stringify(flattened)}</pre>
209
+ </>;
203
210
  }
204
211
 
205
212
  render(ArrayTest);
@@ -219,13 +226,14 @@ describe('RippleArray > derived', () => {
219
226
  });
220
227
 
221
228
  it('handles flatMap method with reactivity', () => {
222
- component ArrayTest() {
223
- let items = new RippleArray(1, 2, 3);
224
- let &[flatMapped] = track(() => items.flatMap((x) => [x, x * 2]));
225
-
226
- <button onClick={() => items.push(4)}>{'add item'}</button>
227
- <pre>{JSON.stringify(items)}</pre>
228
- <pre>{JSON.stringify(flatMapped)}</pre>
229
+ function ArrayTest() {
230
+ return <>
231
+ let items = new RippleArray(1, 2, 3);
232
+ let &[flatMapped] = track(() => items.flatMap((x) => [x, x * 2]));
233
+ <button onClick={() => items.push(4)}>{'add item'}</button>
234
+ <pre>{JSON.stringify(items)}</pre>
235
+ <pre>{JSON.stringify(flatMapped)}</pre>
236
+ </>;
229
237
  }
230
238
 
231
239
  render(ArrayTest);
@@ -245,13 +253,14 @@ describe('RippleArray > derived', () => {
245
253
  });
246
254
 
247
255
  it('handles join method with reactivity', () => {
248
- component ArrayTest() {
249
- let items = new RippleArray('apple', 'banana', 'cherry');
250
- let &[joined] = track(() => items.join(', '));
251
-
252
- <button onClick={() => items.push('date')}>{'add item'}</button>
253
- <pre>{JSON.stringify(items)}</pre>
254
- <pre>{joined}</pre>
256
+ function ArrayTest() {
257
+ return <>
258
+ let items = new RippleArray('apple', 'banana', 'cherry');
259
+ let &[joined] = track(() => items.join(', '));
260
+ <button onClick={() => items.push('date')}>{'add item'}</button>
261
+ <pre>{JSON.stringify(items)}</pre>
262
+ <pre>{joined}</pre>
263
+ </>;
255
264
  }
256
265
 
257
266
  render(ArrayTest);
@@ -273,19 +282,20 @@ describe('RippleArray > derived', () => {
273
282
  });
274
283
 
275
284
  it('handles lastIndexOf method with reactivity', () => {
276
- component ArrayTest() {
277
- let items = new RippleArray(1, 2, 3, 2, 1);
278
- let &[lastIndex] = track(() => items.lastIndexOf(2));
279
-
280
- <button
281
- onClick={() => {
282
- items.push(2);
283
- }}
284
- >
285
- {'add duplicate'}
286
- </button>
287
- <pre>{JSON.stringify(items)}</pre>
288
- <pre>{lastIndex}</pre>
285
+ function ArrayTest() {
286
+ return <>
287
+ let items = new RippleArray(1, 2, 3, 2, 1);
288
+ let &[lastIndex] = track(() => items.lastIndexOf(2));
289
+ <button
290
+ onClick={() => {
291
+ items.push(2);
292
+ }}
293
+ >
294
+ {'add duplicate'}
295
+ </button>
296
+ <pre>{JSON.stringify(items)}</pre>
297
+ <pre>{lastIndex}</pre>
298
+ </>;
289
299
  }
290
300
 
291
301
  render(ArrayTest);
@@ -305,13 +315,14 @@ describe('RippleArray > derived', () => {
305
315
  });
306
316
 
307
317
  it('handles reduceRight method with reactivity', () => {
308
- component ArrayTest() {
309
- let items = new RippleArray('a', 'b', 'c');
310
- let &[reduced] = track(() => items.reduceRight((acc, val) => acc + val, ''));
311
-
312
- <button onClick={() => items.push('d')}>{'add item'}</button>
313
- <pre>{JSON.stringify(items)}</pre>
314
- <pre>{reduced}</pre>
318
+ function ArrayTest() {
319
+ return <>
320
+ let items = new RippleArray('a', 'b', 'c');
321
+ let &[reduced] = track(() => items.reduceRight((acc, val) => acc + val, ''));
322
+ <button onClick={() => items.push('d')}>{'add item'}</button>
323
+ <pre>{JSON.stringify(items)}</pre>
324
+ <pre>{reduced}</pre>
325
+ </>;
315
326
  }
316
327
 
317
328
  render(ArrayTest);
@@ -331,20 +342,21 @@ describe('RippleArray > derived', () => {
331
342
  });
332
343
 
333
344
  it('handles some method with reactivity', () => {
334
- component ArrayTest() {
335
- let items = new RippleArray(1, 3, 5, 7);
336
- let &[hasEven] = track(() => items.some((x) => x % 2 === 0));
337
-
338
- <button onClick={() => items.push(2)}>{'add even'}</button>
339
- <button
340
- onClick={() => {
341
- items.pop();
342
- items.push(9);
343
- }}
344
- >
345
- {'ensure all odd'}
346
- </button>
347
- <pre>{hasEven.toString()}</pre>
345
+ function ArrayTest() {
346
+ return <>
347
+ let items = new RippleArray(1, 3, 5, 7);
348
+ let &[hasEven] = track(() => items.some((x) => x % 2 === 0));
349
+ <button onClick={() => items.push(2)}>{'add even'}</button>
350
+ <button
351
+ onClick={() => {
352
+ items.pop();
353
+ items.push(9);
354
+ }}
355
+ >
356
+ {'ensure all odd'}
357
+ </button>
358
+ <pre>{hasEven.toString()}</pre>
359
+ </>;
348
360
  }
349
361
 
350
362
  render(ArrayTest);
@@ -367,19 +379,20 @@ describe('RippleArray > derived', () => {
367
379
  });
368
380
 
369
381
  it('handles toLocaleString method with reactivity', () => {
370
- component ArrayTest() {
371
- let items = new RippleArray(1000, 2000, 3000);
372
- let &[localized] = track(() => items.toLocaleString('en-US'));
373
-
374
- <button
375
- onClick={() => {
376
- items[2] = 4000;
377
- }}
378
- >
379
- {'add item'}
380
- </button>
381
- <pre>{JSON.stringify(items)}</pre>
382
- <pre>{localized}</pre>
382
+ function ArrayTest() {
383
+ return <>
384
+ let items = new RippleArray(1000, 2000, 3000);
385
+ let &[localized] = track(() => items.toLocaleString('en-US'));
386
+ <button
387
+ onClick={() => {
388
+ items[2] = 4000;
389
+ }}
390
+ >
391
+ {'add item'}
392
+ </button>
393
+ <pre>{JSON.stringify(items)}</pre>
394
+ <pre>{localized}</pre>
395
+ </>;
383
396
  }
384
397
 
385
398
  render(ArrayTest);
@@ -399,13 +412,14 @@ describe('RippleArray > derived', () => {
399
412
  });
400
413
 
401
414
  it('handles toString method with reactivity', () => {
402
- component ArrayTest() {
403
- let items = new RippleArray(1, 2, 3);
404
- let &[string] = track(() => items.toString());
405
-
406
- <button onClick={() => items.push(4)}>{'add item'}</button>
407
- <pre>{JSON.stringify(items)}</pre>
408
- <pre>{string}</pre>
415
+ function ArrayTest() {
416
+ return <>
417
+ let items = new RippleArray(1, 2, 3);
418
+ let &[string] = track(() => items.toString());
419
+ <button onClick={() => items.push(4)}>{'add item'}</button>
420
+ <pre>{JSON.stringify(items)}</pre>
421
+ <pre>{string}</pre>
422
+ </>;
409
423
  }
410
424
 
411
425
  render(ArrayTest);
@@ -429,13 +443,14 @@ describe('RippleArray > derived', () => {
429
443
  context.skip();
430
444
  }
431
445
 
432
- component ArrayTest() {
433
- let items = new RippleArray(1, 2, 3, 4);
434
- let &[withReplaced] = track(() => items.with(2, 30));
435
-
436
- <button onClick={() => (items[2] = 50)}>{'change original'}</button>
437
- <pre>{JSON.stringify(items)}</pre>
438
- <pre>{JSON.stringify(withReplaced)}</pre>
446
+ function ArrayTest() {
447
+ return <>
448
+ let items = new RippleArray(1, 2, 3, 4);
449
+ let &[withReplaced] = track(() => items.with(2, 30));
450
+ <button onClick={() => (items[2] = 50)}>{'change original'}</button>
451
+ <pre>{JSON.stringify(items)}</pre>
452
+ <pre>{JSON.stringify(withReplaced)}</pre>
453
+ </>;
439
454
  }
440
455
 
441
456
  render(ArrayTest);
@@ -455,11 +470,12 @@ describe('RippleArray > derived', () => {
455
470
  });
456
471
 
457
472
  it('handles toJSON method', () => {
458
- component ArrayTest() {
459
- let items = new RippleArray(1, 2, 3);
460
-
461
- <button onClick={() => items.push(4)}>{'add'}</button>
462
- <pre>{JSON.stringify(items)}</pre>
473
+ function ArrayTest() {
474
+ return <>
475
+ let items = new RippleArray(1, 2, 3);
476
+ <button onClick={() => items.push(4)}>{'add'}</button>
477
+ <pre>{JSON.stringify(items)}</pre>
478
+ </>;
463
479
  }
464
480
 
465
481
  render(ArrayTest);
@@ -477,18 +493,19 @@ describe('RippleArray > derived', () => {
477
493
  });
478
494
 
479
495
  it('handles at method with reactivity', () => {
480
- component ArrayTest() {
481
- let items = new RippleArray(10, 20, 30, 40, 50);
482
- let &[atIndex2] = track(() => items.at(2));
483
- let &[atNegative1] = track(() => items.at(-1));
484
- let &[atNegative2] = track(() => items.at(-2));
485
-
486
- <button onClick={() => (items[2] = 300)}>{'change index 2'}</button>
487
- <button onClick={() => (items[items.length - 1] = 500)}>{'change last'}</button>
488
- <pre>{JSON.stringify(items)}</pre>
489
- <pre>{atIndex2}</pre>
490
- <pre>{atNegative1}</pre>
491
- <pre>{atNegative2}</pre>
496
+ function ArrayTest() {
497
+ return <>
498
+ let items = new RippleArray(10, 20, 30, 40, 50);
499
+ let &[atIndex2] = track(() => items.at(2));
500
+ let &[atNegative1] = track(() => items.at(-1));
501
+ let &[atNegative2] = track(() => items.at(-2));
502
+ <button onClick={() => (items[2] = 300)}>{'change index 2'}</button>
503
+ <button onClick={() => (items[items.length - 1] = 500)}>{'change last'}</button>
504
+ <pre>{JSON.stringify(items)}</pre>
505
+ <pre>{atIndex2}</pre>
506
+ <pre>{atNegative1}</pre>
507
+ <pre>{atNegative2}</pre>
508
+ </>;
492
509
  }
493
510
 
494
511
  render(ArrayTest);
@@ -2,13 +2,14 @@ import { RippleArray, effect, flushSync, track, untrack } from 'ripple';
2
2
 
3
3
  describe('RippleArray > iteration', () => {
4
4
  it('handles entries method with reactivity', () => {
5
- component ArrayTest() {
6
- let items = new RippleArray('a', 'b', 'c');
7
- let &[entries] = track(() => Array.from(items.entries()));
8
-
9
- <button onClick={() => items.push('d')}>{'add item'}</button>
10
- <pre>{JSON.stringify(items)}</pre>
11
- <pre>{JSON.stringify(entries)}</pre>
5
+ function ArrayTest() {
6
+ return <>
7
+ let items = new RippleArray('a', 'b', 'c');
8
+ let &[entries] = track(() => Array.from(items.entries()));
9
+ <button onClick={() => items.push('d')}>{'add item'}</button>
10
+ <pre>{JSON.stringify(items)}</pre>
11
+ <pre>{JSON.stringify(entries)}</pre>
12
+ </>;
12
13
  }
13
14
 
14
15
  render(ArrayTest);
@@ -30,13 +31,14 @@ describe('RippleArray > iteration', () => {
30
31
  });
31
32
 
32
33
  it('handles keys method with reactivity', () => {
33
- component ArrayTest() {
34
- let items = new RippleArray('a', 'b', 'c');
35
- let &[keys] = track(() => Array.from(items.keys()));
36
-
37
- <button onClick={() => items.push('d')}>{'add item'}</button>
38
- <pre>{JSON.stringify(items)}</pre>
39
- <pre>{JSON.stringify(keys)}</pre>
34
+ function ArrayTest() {
35
+ return <>
36
+ let items = new RippleArray('a', 'b', 'c');
37
+ let &[keys] = track(() => Array.from(items.keys()));
38
+ <button onClick={() => items.push('d')}>{'add item'}</button>
39
+ <pre>{JSON.stringify(items)}</pre>
40
+ <pre>{JSON.stringify(keys)}</pre>
41
+ </>;
40
42
  }
41
43
 
42
44
  render(ArrayTest);
@@ -56,13 +58,14 @@ describe('RippleArray > iteration', () => {
56
58
  });
57
59
 
58
60
  it('handles values method with reactivity', () => {
59
- component ArrayTest() {
60
- let items = new RippleArray('a', 'b', 'c');
61
- let &[values] = track(() => Array.from(items.values()));
62
-
63
- <button onClick={() => items.push('d')}>{'add item'}</button>
64
- <pre>{JSON.stringify(items)}</pre>
65
- <pre>{JSON.stringify(values)}</pre>
61
+ function ArrayTest() {
62
+ return <>
63
+ let items = new RippleArray('a', 'b', 'c');
64
+ let &[values] = track(() => Array.from(items.values()));
65
+ <button onClick={() => items.push('d')}>{'add item'}</button>
66
+ <pre>{JSON.stringify(items)}</pre>
67
+ <pre>{JSON.stringify(values)}</pre>
68
+ </>;
66
69
  }
67
70
 
68
71
  render(ArrayTest);
@@ -82,22 +85,22 @@ describe('RippleArray > iteration', () => {
82
85
  });
83
86
 
84
87
  it('handles Symbol.iterator with reactivity', () => {
85
- component ArrayTest() {
86
- let items = new RippleArray(1, 2, 3);
87
- let &[sum] = track(0);
88
-
89
- effect(() => {
90
- sum = 0;
91
- for (const item of items) {
92
- untrack(() => {
93
- sum += item;
94
- });
95
- }
96
- });
97
-
98
- <button onClick={() => items.push(4)}>{'add item'}</button>
99
- <pre>{JSON.stringify(items)}</pre>
100
- <pre>{sum}</pre>
88
+ function ArrayTest() {
89
+ return <>
90
+ let items = new RippleArray(1, 2, 3);
91
+ let &[sum] = track(0);
92
+ effect(() => {
93
+ sum = 0;
94
+ for (const item of items) {
95
+ untrack(() => {
96
+ sum += item;
97
+ });
98
+ }
99
+ });
100
+ <button onClick={() => items.push(4)}>{'add item'}</button>
101
+ <pre>{JSON.stringify(items)}</pre>
102
+ <pre>{sum}</pre>
103
+ </>;
101
104
  }
102
105
 
103
106
  render(ArrayTest);