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