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