ripple 0.3.128 → 0.4.0

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 (192) hide show
  1. package/CHANGELOG.md +267 -0
  2. package/package.json +10 -4
  3. package/src/runtime/element.js +23 -6
  4. package/src/runtime/index-client.js +81 -41
  5. package/src/runtime/index-server.js +1 -0
  6. package/src/runtime/internal/client/blocks.js +173 -91
  7. package/src/runtime/internal/client/component.js +4 -30
  8. package/src/runtime/internal/client/composite.js +12 -13
  9. package/src/runtime/internal/client/constants.js +9 -0
  10. package/src/runtime/internal/client/context.js +12 -19
  11. package/src/runtime/internal/client/css.js +7 -9
  12. package/src/runtime/internal/client/events.js +178 -90
  13. package/src/runtime/internal/client/expression.js +45 -25
  14. package/src/runtime/internal/client/for.js +409 -129
  15. package/src/runtime/internal/client/head.js +10 -5
  16. package/src/runtime/internal/client/html.js +1 -0
  17. package/src/runtime/internal/client/hydration.js +152 -10
  18. package/src/runtime/internal/client/if.js +239 -50
  19. package/src/runtime/internal/client/index.js +4 -12
  20. package/src/runtime/internal/client/operations.js +40 -61
  21. package/src/runtime/internal/client/portal.js +163 -85
  22. package/src/runtime/internal/client/render.js +39 -39
  23. package/src/runtime/internal/client/rpc.js +3 -3
  24. package/src/runtime/internal/client/runtime.js +592 -433
  25. package/src/runtime/internal/client/selector.js +5 -2
  26. package/src/runtime/internal/client/template.js +133 -158
  27. package/src/runtime/internal/client/transport.js +38 -0
  28. package/src/runtime/internal/client/try.js +465 -426
  29. package/src/runtime/internal/client/types.d.ts +56 -23
  30. package/src/runtime/internal/client/utils.js +1 -3
  31. package/src/runtime/internal/server/dynamic.js +20 -21
  32. package/src/runtime/internal/server/index.js +325 -275
  33. package/src/runtime/internal/server/rpc.js +3 -2
  34. package/src/runtime/internal/server/transport.js +16 -0
  35. package/src/runtime/transport.js +21 -0
  36. package/tests/client/__snapshots__/for.test.tsrx.snap +0 -5
  37. package/tests/client/array/array.copy-within.test.tsrx +12 -12
  38. package/tests/client/array/array.derived.test.tsrx +46 -46
  39. package/tests/client/array/array.iteration.test.tsrx +10 -10
  40. package/tests/client/array/array.mutations.test.tsrx +20 -20
  41. package/tests/client/array/array.static.test.tsrx +11 -11
  42. package/tests/client/array/array.to-methods.test.tsrx +6 -6
  43. package/tests/client/async-suspend.test.tsrx +74 -75
  44. package/tests/client/basic/basic.attributes.test.tsrx +86 -83
  45. package/tests/client/basic/basic.collections.test.tsrx +12 -12
  46. package/tests/client/basic/basic.components.test.tsrx +99 -25
  47. package/tests/client/basic/basic.errors.test.tsrx +18 -18
  48. package/tests/client/basic/basic.events.test.tsrx +42 -42
  49. package/tests/client/basic/basic.get-set.test.tsrx +8 -8
  50. package/tests/client/basic/basic.reactivity.test.tsrx +73 -38
  51. package/tests/client/basic/basic.rendering.test.tsrx +25 -25
  52. package/tests/client/basic/basic.utilities.test.tsrx +3 -3
  53. package/tests/client/boundaries.test.tsrx +8 -8
  54. package/tests/client/boxed-locals.test.tsrx +452 -0
  55. package/tests/client/compiler/__snapshots__/compiler.assignments.test.tsrx.snap +6 -6
  56. package/tests/client/compiler/compiler.assignments.test.tsrx +9 -73
  57. package/tests/client/compiler/compiler.attributes.test.tsrx +23 -23
  58. package/tests/client/compiler/compiler.basic.test.tsrx +15 -60
  59. package/tests/client/compiler/compiler.tracked-access.test.tsrx +18 -43
  60. package/tests/client/compiler/compiler.try-in-function.test.tsrx +2 -2
  61. package/tests/client/composite/__snapshots__/composite.render.test.tsrx.snap +0 -1
  62. package/tests/client/composite/composite.dynamic-components.test.tsrx +77 -6
  63. package/tests/client/composite/composite.props.test.tsrx +149 -12
  64. package/tests/client/composite/composite.reactivity.test.tsrx +51 -52
  65. package/tests/client/composite/composite.render.test.tsrx +26 -9
  66. package/tests/client/css/scoped-styles.test.tsrx +8 -8
  67. package/tests/client/date.test.tsrx +42 -42
  68. package/tests/client/derived-release.test.tsrx +370 -0
  69. package/tests/client/dynamic-elements.test.tsrx +45 -45
  70. package/tests/client/events.test.tsrx +97 -71
  71. package/tests/client/for-selector.test.tsrx +14 -14
  72. package/tests/client/for-single-root-items.test.tsrx +118 -3
  73. package/tests/client/for.test.tsrx +332 -31
  74. package/tests/client/head.test.tsrx +19 -19
  75. package/tests/client/html.test.tsrx +11 -9
  76. package/tests/client/if-block.test.tsrx +80 -0
  77. package/tests/client/map.test.tsrx +16 -16
  78. package/tests/client/media-query.test.tsrx +7 -7
  79. package/tests/client/portal.test.tsrx +224 -26
  80. package/tests/client/primitive-text.test.tsrx +50 -0
  81. package/tests/client/prop-kind-switch.test.tsrx +141 -0
  82. package/tests/client/ref.test.tsrx +17 -17
  83. package/tests/client/return.test.tsrx +26 -3
  84. package/tests/client/root-boundary.test.tsrx +42 -0
  85. package/tests/client/scoped-flush.test.tsrx +8 -8
  86. package/tests/client/set.test.tsrx +6 -6
  87. package/tests/client/svg.test.tsrx +11 -11
  88. package/tests/client/switch.test.tsrx +44 -44
  89. package/tests/client/track-async-hydration.test.tsrx +4 -4
  90. package/tests/client/try.test.tsrx +151 -83
  91. package/tests/client/tsx.test.tsrx +43 -40
  92. package/tests/client/url/url.derived.test.tsrx +6 -6
  93. package/tests/client/url-search-params/url-search-params.derived.test.tsrx +8 -8
  94. package/tests/client/url-search-params/url-search-params.iteration.test.tsrx +10 -10
  95. package/tests/client/url-search-params/url-search-params.mutation.test.tsrx +10 -10
  96. package/tests/client/url-search-params/url-search-params.retrieval.test.tsrx +18 -18
  97. package/tests/client/url-search-params/url-search-params.serialization.test.tsrx +2 -2
  98. package/tests/hydration/basic.test.js +74 -1
  99. package/tests/hydration/build-components.js +22 -1
  100. package/tests/hydration/compiled/client/basic.js +1142 -713
  101. package/tests/hydration/compiled/client/composite.js +151 -100
  102. package/tests/hydration/compiled/client/events.js +184 -171
  103. package/tests/hydration/compiled/client/for.js +1472 -1132
  104. package/tests/hydration/compiled/client/fragment-cursor.js +2341 -0
  105. package/tests/hydration/compiled/client/head.js +254 -201
  106. package/tests/hydration/compiled/client/hmr.js +54 -41
  107. package/tests/hydration/compiled/client/html-in-template.js +54 -39
  108. package/tests/hydration/compiled/client/html.js +1633 -1263
  109. package/tests/hydration/compiled/client/if-children.js +420 -270
  110. package/tests/hydration/compiled/client/if-fragment-controlflow.js +363 -317
  111. package/tests/hydration/compiled/client/if.js +229 -219
  112. package/tests/hydration/compiled/client/mixed-control-flow.js +420 -404
  113. package/tests/hydration/compiled/client/nested-control-flow.js +1326 -1277
  114. package/tests/hydration/compiled/client/portal.js +87 -95
  115. package/tests/hydration/compiled/client/reactivity.js +135 -101
  116. package/tests/hydration/compiled/client/return.js +28 -19
  117. package/tests/hydration/compiled/client/streaming.js +390 -306
  118. package/tests/hydration/compiled/client/switch.js +258 -266
  119. package/tests/hydration/compiled/client/track-async-serialization.js +448 -280
  120. package/tests/hydration/compiled/client/try.js +173 -129
  121. package/tests/hydration/compiled/client/typed-text.js +71 -0
  122. package/tests/hydration/compiled/fixtures/money.js +10 -0
  123. package/tests/hydration/compiled/server/basic.js +123 -6
  124. package/tests/hydration/compiled/server/composite.js +16 -30
  125. package/tests/hydration/compiled/server/events.js +66 -18
  126. package/tests/hydration/compiled/server/for.js +117 -41
  127. package/tests/hydration/compiled/server/fragment-cursor.js +1687 -0
  128. package/tests/hydration/compiled/server/head.js +20 -20
  129. package/tests/hydration/compiled/server/hmr.js +2 -2
  130. package/tests/hydration/compiled/server/html.js +70 -238
  131. package/tests/hydration/compiled/server/if-children.js +107 -15
  132. package/tests/hydration/compiled/server/if.js +11 -15
  133. package/tests/hydration/compiled/server/mixed-control-flow.js +8 -8
  134. package/tests/hydration/compiled/server/portal.js +14 -22
  135. package/tests/hydration/compiled/server/reactivity.js +14 -14
  136. package/tests/hydration/compiled/server/streaming.js +19 -19
  137. package/tests/hydration/compiled/server/switch.js +8 -8
  138. package/tests/hydration/compiled/server/track-async-serialization.js +150 -23
  139. package/tests/hydration/compiled/server/try.js +8 -8
  140. package/tests/hydration/compiled/server/typed-text.js +17 -0
  141. package/tests/hydration/components/basic.tsrx +44 -8
  142. package/tests/hydration/components/composite.tsrx +2 -2
  143. package/tests/hydration/components/events.tsrx +25 -25
  144. package/tests/hydration/components/for.tsrx +115 -67
  145. package/tests/hydration/components/fragment-cursor.tsrx +650 -0
  146. package/tests/hydration/components/head.tsrx +16 -16
  147. package/tests/hydration/components/hmr.tsrx +2 -2
  148. package/tests/hydration/components/html.tsrx +7 -7
  149. package/tests/hydration/components/if-children.tsrx +72 -25
  150. package/tests/hydration/components/if.tsrx +18 -18
  151. package/tests/hydration/components/mixed-control-flow.tsrx +11 -11
  152. package/tests/hydration/components/portal.tsrx +3 -3
  153. package/tests/hydration/components/reactivity.tsrx +16 -16
  154. package/tests/hydration/components/streaming.tsrx +20 -20
  155. package/tests/hydration/components/switch.tsrx +20 -20
  156. package/tests/hydration/components/text-types.ts +4 -0
  157. package/tests/hydration/components/track-async-serialization.tsrx +80 -26
  158. package/tests/hydration/components/try.tsrx +8 -8
  159. package/tests/hydration/components/typed-text.tsrx +22 -0
  160. package/tests/hydration/fixtures/money.js +10 -0
  161. package/tests/hydration/for.test.js +36 -0
  162. package/tests/hydration/fragment-cursor.test.js +111 -0
  163. package/tests/hydration/if-children.test.js +24 -0
  164. package/tests/hydration/streaming.test.js +19 -0
  165. package/tests/hydration/track-async-serialization.test.js +87 -2
  166. package/tests/hydration/tsconfig.text-types.json +10 -0
  167. package/tests/hydration/typed-text.test.js +34 -0
  168. package/tests/server/await.test.tsrx +3 -3
  169. package/tests/server/basic.attributes.test.tsrx +42 -42
  170. package/tests/server/basic.components.test.tsrx +64 -8
  171. package/tests/server/basic.test.tsrx +34 -32
  172. package/tests/server/compiler.test.tsrx +1 -70
  173. package/tests/server/composite.props.test.tsrx +6 -6
  174. package/tests/server/dynamic-elements.test.tsrx +31 -8
  175. package/tests/server/for.test.tsrx +94 -0
  176. package/tests/server/head.test.tsrx +11 -11
  177. package/tests/server/scoped-styles.test.tsrx +2 -2
  178. package/tests/server/streaming-ssr.test.tsrx +48 -43
  179. package/tests/server/track-async-serialization.test.tsrx +204 -21
  180. package/tests/server/try.test.tsrx +48 -48
  181. package/tests/types/transport.ts +40 -0
  182. package/tests/utils/vite-plugin-config.test.js +23 -0
  183. package/types/index.d.ts +48 -7
  184. package/types/server.d.ts +3 -0
  185. package/types/transport.d.ts +15 -0
  186. package/src/runtime/internal/client/switch.js +0 -113
  187. package/src/utils/errors.js +0 -13
  188. package/tests/client/lazy-array.test.tsrx +0 -31
  189. package/tests/client/lazy-destructuring.test.tsrx +0 -438
  190. package/tests/client/tracked-index-access.test.tsrx +0 -113
  191. package/tests/server/lazy-destructuring.test.tsrx +0 -595
  192. package/tests/server/tracked-index-access.test.tsrx +0 -76
@@ -1,4 +1,5 @@
1
1
  import * as devalue from 'devalue';
2
+ import { transport } from './transport.js';
2
3
 
3
4
  /**
4
5
  * @template {any[]} T
@@ -7,7 +8,7 @@ import * as devalue from 'devalue';
7
8
  * @param {string} rpc_arguments_string
8
9
  */
9
10
  export async function executeServerFunction(fn, rpc_arguments_string) {
10
- const rpc_arguments = devalue.parse(rpc_arguments_string);
11
+ const rpc_arguments = devalue.parse(rpc_arguments_string, transport?.revivers);
11
12
  const result = await fn.apply(null, rpc_arguments);
12
- return devalue.stringify({ value: result });
13
+ return devalue.stringify({ value: result }, transport?.reducers);
13
14
  }
@@ -0,0 +1,16 @@
1
+ import { create_transport } from '../../transport.js';
2
+ import { set_track_async_transport } from './index.js';
3
+
4
+ export { set_transport as setTransport };
5
+
6
+ /** @type {ReturnType<typeof create_transport>} */
7
+ export let transport;
8
+
9
+ /**
10
+ * Register the application's transport before rendering or serving RPC.
11
+ * @param {import('#public').Transport} [value]
12
+ */
13
+ export function set_transport(value) {
14
+ transport = create_transport(value);
15
+ set_track_async_transport(transport?.reducers);
16
+ }
@@ -0,0 +1,21 @@
1
+ /** @import { Transport } from '#public' */
2
+
3
+ /**
4
+ * Build the devalue tables once at registration. An empty transport retains
5
+ * the default serialization path, including raw JSON hydration envelopes.
6
+ * @param {Transport | undefined} transport
7
+ */
8
+ export function create_transport(transport) {
9
+ const entries = Object.entries(transport ?? {});
10
+ if (entries.length === 0) return undefined;
11
+
12
+ /** @type {Record<string, (value: any) => any>} */
13
+ const reducers = Object.create(null);
14
+ /** @type {Record<string, (value: any) => any>} */
15
+ const revivers = Object.create(null);
16
+ for (const [name, { encode, decode }] of entries) {
17
+ reducers[name] = encode;
18
+ revivers[name] = decode;
19
+ }
20
+ return { reducers, revivers };
21
+ }
@@ -28,7 +28,6 @@ exports[`for statements > correctly handles intermediate statements in for block
28
28
  3
29
29
  </div>
30
30
  </div>
31
-
32
31
  </div>
33
32
  <button>
34
33
  Add Item
@@ -74,7 +73,6 @@ exports[`for statements > correctly handles intermediate statements in for block
74
73
  4
75
74
  </div>
76
75
  </div>
77
-
78
76
  </div>
79
77
  <button>
80
78
  Add Item
@@ -141,7 +139,6 @@ exports[`for statements > correctly handles the index in a for...of loop 1`] = `
141
139
  <div>
142
140
  2 : c
143
141
  </div>
144
-
145
142
  </div>
146
143
  <button>
147
144
  Add Item
@@ -170,7 +167,6 @@ exports[`for statements > correctly handles the index in a for...of loop 2`] = `
170
167
  <div>
171
168
  3 : d
172
169
  </div>
173
-
174
170
  </div>
175
171
  <button>
176
172
  Add Item
@@ -199,7 +195,6 @@ exports[`for statements > correctly handles the index in a for...of loop 3`] = `
199
195
  <div>
200
196
  3 : a
201
197
  </div>
202
-
203
198
  </div>
204
199
  <button>
205
200
  Add Item
@@ -4,16 +4,16 @@ describe('RippleArray copyWithin', () => {
4
4
  it('handles copyWithin operation with reactivity', () => {
5
5
  function ArrayTest() @{
6
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]);
7
+ const firstItem = track(() => items[0]);
8
+ const thirdItem = track(() => items[2]);
9
+ const fourthItem = track(() => items[3]);
10
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
- <pre>{firstItem}</pre>
15
- <pre>{thirdItem}</pre>
16
- <pre>{fourthItem}</pre>
14
+ <pre>{firstItem.value}</pre>
15
+ <pre>{thirdItem.value}</pre>
16
+ <pre>{fourthItem.value}</pre>
17
17
  </>
18
18
  }
19
19
 
@@ -50,13 +50,13 @@ describe('RippleArray copyWithin', () => {
50
50
  it('handles copyWithin with negative indexes and reactivity', () => {
51
51
  function ArrayTest() @{
52
52
  let items = new RippleArray(1, 2, 3, 4, 5);
53
- let &[secondItem] = track(() => items[1]);
54
- let &[thirdItem] = track(() => items[2]);
53
+ const secondItem = track(() => items[1]);
54
+ const thirdItem = track(() => items[2]);
55
55
  <>
56
56
  <button onClick={() => items.copyWithin(-4, -2)}>{'copy with negative indexes'}</button>
57
57
  <pre>{JSON.stringify(items)}</pre>
58
- <pre>{secondItem}</pre>
59
- <pre>{thirdItem}</pre>
58
+ <pre>{secondItem.value}</pre>
59
+ <pre>{thirdItem.value}</pre>
60
60
  </>
61
61
  }
62
62
 
@@ -82,11 +82,11 @@ describe('RippleArray copyWithin', () => {
82
82
  it('handles copyWithin with overlapping ranges', () => {
83
83
  function ArrayTest() @{
84
84
  let items = new RippleArray(1, 2, 3, 4, 5);
85
- let &[entries] = track(() => Array.from(items.entries()));
85
+ const entries = track(() => Array.from(items.entries()));
86
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.value) {
90
90
  <pre>{`items[${i}]: ${value}`}</pre>
91
91
  }
92
92
  </>
@@ -4,16 +4,16 @@ describe('RippleArray > derived', () => {
4
4
  it('handles array methods that return values (map, filter, etc.)', () => {
5
5
  function ArrayTest() @{
6
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));
7
+ const doubled = track(() => items.map((x) => x * 2));
8
+ const filtered = track(() => items.filter((x) => x % 2 === 0));
9
+ const reduced = track(() => items.reduce((acc, val) => acc + val, 0));
10
+ const includes = track(() => items.includes(3));
11
11
  <>
12
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>
13
+ <pre>{JSON.stringify(doubled.value)}</pre>
14
+ <pre>{JSON.stringify(filtered.value)}</pre>
15
+ <pre>{reduced.value}</pre>
16
+ <pre>{includes.value.toString()}</pre>
17
17
  </>
18
18
  }
19
19
 
@@ -40,11 +40,11 @@ describe('RippleArray > derived', () => {
40
40
  it('handles concat method with reactivity', () => {
41
41
  function ArrayTest() @{
42
42
  let items = new RippleArray(1, 2, 3);
43
- let &[concatenated] = track(() => items.concat([4, 5], 6, [7, 8]));
43
+ const concatenated = track(() => items.concat([4, 5], 6, [7, 8]));
44
44
  <>
45
45
  <button onClick={() => items.push(3.5)}>{'add to original'}</button>
46
46
  <pre>{JSON.stringify(items)}</pre>
47
- <pre>{JSON.stringify(concatenated)}</pre>
47
+ <pre>{JSON.stringify(concatenated.value)}</pre>
48
48
  </>
49
49
  }
50
50
 
@@ -67,11 +67,11 @@ describe('RippleArray > derived', () => {
67
67
  it('handles array slice method with reactivity', () => {
68
68
  function ArrayTest() @{
69
69
  let items = new RippleArray(1, 2, 3, 4, 5);
70
- let &[sliced] = track(() => items.slice(1, 4));
70
+ const sliced = track(() => items.slice(1, 4));
71
71
  <>
72
72
  <button onClick={() => (items[2] = 30)}>{'change middle'}</button>
73
73
  <pre>{JSON.stringify(items)}</pre>
74
- <pre>{JSON.stringify(sliced)}</pre>
74
+ <pre>{JSON.stringify(sliced.value)}</pre>
75
75
  </>
76
76
  }
77
77
 
@@ -94,8 +94,8 @@ describe('RippleArray > derived', () => {
94
94
  it('handles find and findIndex methods with reactivity', () => {
95
95
  function ArrayTest() @{
96
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));
97
+ const found = track(() => items.find((x) => x > 12));
98
+ const foundIndex = track(() => items.findIndex((x) => x > 12));
99
99
  <>
100
100
  <button
101
101
  onClick={() => {
@@ -103,8 +103,8 @@ describe('RippleArray > derived', () => {
103
103
  items[0] = 6;
104
104
  }}
105
105
  >{'update values'}</button>
106
- <pre>{found}</pre>
107
- <pre>{foundIndex}</pre>
106
+ <pre>{found.value}</pre>
107
+ <pre>{foundIndex.value}</pre>
108
108
  </>
109
109
  }
110
110
 
@@ -127,8 +127,8 @@ describe('RippleArray > derived', () => {
127
127
  it('handles findLast and findLastIndex methods with reactivity', () => {
128
128
  function ArrayTest() @{
129
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));
130
+ const foundLast = track(() => items.findLast((x) => x === 15));
131
+ const foundLastIndex = track(() => items.findLastIndex((x) => x === 15));
132
132
  <>
133
133
  <button
134
134
  onClick={() => {
@@ -136,8 +136,8 @@ describe('RippleArray > derived', () => {
136
136
  items[4] = 15;
137
137
  }}
138
138
  >{'update values'}</button>
139
- <pre>{foundLast}</pre>
140
- <pre>{foundLastIndex}</pre>
139
+ <pre>{foundLast.value}</pre>
140
+ <pre>{foundLastIndex.value}</pre>
141
141
  </>
142
142
  }
143
143
 
@@ -160,7 +160,7 @@ describe('RippleArray > derived', () => {
160
160
  it('handles every method with reactivity', () => {
161
161
  function ArrayTest() @{
162
162
  let items = new RippleArray(2, 4, 6, 8);
163
- let &[allEven] = track(() => items.every((x) => x % 2 === 0));
163
+ const allEven = track(() => items.every((x) => x % 2 === 0));
164
164
  <>
165
165
  <button onClick={() => items.push(3)}>{'add odd'}</button>
166
166
  <button
@@ -169,7 +169,7 @@ describe('RippleArray > derived', () => {
169
169
  items.push(10);
170
170
  }}
171
171
  >{'ensure all even'}</button>
172
- <pre>{allEven.toString()}</pre>
172
+ <pre>{allEven.value.toString()}</pre>
173
173
  </>
174
174
  }
175
175
 
@@ -195,11 +195,11 @@ describe('RippleArray > derived', () => {
195
195
  it('handles flat method with reactivity', () => {
196
196
  function ArrayTest() @{
197
197
  let items = new RippleArray<number | number[]>([1, 2], [3, 4], 5);
198
- let &[flattened] = track(() => items.flat());
198
+ const flattened = track(() => items.flat());
199
199
  <>
200
200
  <button onClick={() => (items[0] = [6, 7, 8])}>{'change nested'}</button>
201
201
  <pre>{JSON.stringify(items)}</pre>
202
- <pre>{JSON.stringify(flattened)}</pre>
202
+ <pre>{JSON.stringify(flattened.value)}</pre>
203
203
  </>
204
204
  }
205
205
 
@@ -222,11 +222,11 @@ describe('RippleArray > derived', () => {
222
222
  it('handles flatMap method with reactivity', () => {
223
223
  function ArrayTest() @{
224
224
  let items = new RippleArray(1, 2, 3);
225
- let &[flatMapped] = track(() => items.flatMap((x) => [x, x * 2]));
225
+ const flatMapped = track(() => items.flatMap((x) => [x, x * 2]));
226
226
  <>
227
227
  <button onClick={() => items.push(4)}>{'add item'}</button>
228
228
  <pre>{JSON.stringify(items)}</pre>
229
- <pre>{JSON.stringify(flatMapped)}</pre>
229
+ <pre>{JSON.stringify(flatMapped.value)}</pre>
230
230
  </>
231
231
  }
232
232
 
@@ -249,11 +249,11 @@ describe('RippleArray > derived', () => {
249
249
  it('handles join method with reactivity', () => {
250
250
  function ArrayTest() @{
251
251
  let items = new RippleArray('apple', 'banana', 'cherry');
252
- let &[joined] = track(() => items.join(', '));
252
+ const joined = track(() => items.join(', '));
253
253
  <>
254
254
  <button onClick={() => items.push('date')}>{'add item'}</button>
255
255
  <pre>{JSON.stringify(items)}</pre>
256
- <pre>{joined}</pre>
256
+ <pre>{joined.value}</pre>
257
257
  </>
258
258
  }
259
259
 
@@ -278,7 +278,7 @@ describe('RippleArray > derived', () => {
278
278
  it('handles lastIndexOf method with reactivity', () => {
279
279
  function ArrayTest() @{
280
280
  let items = new RippleArray(1, 2, 3, 2, 1);
281
- let &[lastIndex] = track(() => items.lastIndexOf(2));
281
+ const lastIndex = track(() => items.lastIndexOf(2));
282
282
  <>
283
283
  <button
284
284
  onClick={() => {
@@ -286,7 +286,7 @@ describe('RippleArray > derived', () => {
286
286
  }}
287
287
  >{'add duplicate'}</button>
288
288
  <pre>{JSON.stringify(items)}</pre>
289
- <pre>{lastIndex}</pre>
289
+ <pre>{lastIndex.value}</pre>
290
290
  </>
291
291
  }
292
292
 
@@ -309,11 +309,11 @@ describe('RippleArray > derived', () => {
309
309
  it('handles reduceRight method with reactivity', () => {
310
310
  function ArrayTest() @{
311
311
  let items = new RippleArray('a', 'b', 'c');
312
- let &[reduced] = track(() => items.reduceRight((acc, val) => acc + val, ''));
312
+ const reduced = track(() => items.reduceRight((acc, val) => acc + val, ''));
313
313
  <>
314
314
  <button onClick={() => items.push('d')}>{'add item'}</button>
315
315
  <pre>{JSON.stringify(items)}</pre>
316
- <pre>{reduced}</pre>
316
+ <pre>{reduced.value}</pre>
317
317
  </>
318
318
  }
319
319
 
@@ -336,7 +336,7 @@ describe('RippleArray > derived', () => {
336
336
  it('handles some method with reactivity', () => {
337
337
  function ArrayTest() @{
338
338
  let items = new RippleArray(1, 3, 5, 7);
339
- let &[hasEven] = track(() => items.some((x) => x % 2 === 0));
339
+ const hasEven = track(() => items.some((x) => x % 2 === 0));
340
340
  <>
341
341
  <button onClick={() => items.push(2)}>{'add even'}</button>
342
342
  <button
@@ -345,7 +345,7 @@ describe('RippleArray > derived', () => {
345
345
  items.push(9);
346
346
  }}
347
347
  >{'ensure all odd'}</button>
348
- <pre>{hasEven.toString()}</pre>
348
+ <pre>{hasEven.value.toString()}</pre>
349
349
  </>
350
350
  }
351
351
 
@@ -371,7 +371,7 @@ describe('RippleArray > derived', () => {
371
371
  it('handles toLocaleString method with reactivity', () => {
372
372
  function ArrayTest() @{
373
373
  let items = new RippleArray(1000, 2000, 3000);
374
- let &[localized] = track(() => items.toLocaleString('en-US'));
374
+ const localized = track(() => items.toLocaleString('en-US'));
375
375
  <>
376
376
  <button
377
377
  onClick={() => {
@@ -379,7 +379,7 @@ describe('RippleArray > derived', () => {
379
379
  }}
380
380
  >{'add item'}</button>
381
381
  <pre>{JSON.stringify(items)}</pre>
382
- <pre>{localized}</pre>
382
+ <pre>{localized.value}</pre>
383
383
  </>
384
384
  }
385
385
 
@@ -402,11 +402,11 @@ describe('RippleArray > derived', () => {
402
402
  it('handles toString method with reactivity', () => {
403
403
  function ArrayTest() @{
404
404
  let items = new RippleArray(1, 2, 3);
405
- let &[string] = track(() => items.toString());
405
+ const string = track(() => items.toString());
406
406
  <>
407
407
  <button onClick={() => items.push(4)}>{'add item'}</button>
408
408
  <pre>{JSON.stringify(items)}</pre>
409
- <pre>{string}</pre>
409
+ <pre>{string.value}</pre>
410
410
  </>
411
411
  }
412
412
 
@@ -433,11 +433,11 @@ describe('RippleArray > derived', () => {
433
433
 
434
434
  function ArrayTest() @{
435
435
  let items = new RippleArray(1, 2, 3, 4);
436
- let &[withReplaced] = track(() => items.with(2, 30));
436
+ const withReplaced = track(() => items.with(2, 30));
437
437
  <>
438
438
  <button onClick={() => (items[2] = 50)}>{'change original'}</button>
439
439
  <pre>{JSON.stringify(items)}</pre>
440
- <pre>{JSON.stringify(withReplaced)}</pre>
440
+ <pre>{JSON.stringify(withReplaced.value)}</pre>
441
441
  </>
442
442
  }
443
443
 
@@ -483,16 +483,16 @@ describe('RippleArray > derived', () => {
483
483
  it('handles at method with reactivity', () => {
484
484
  function ArrayTest() @{
485
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));
486
+ const atIndex2 = track(() => items.at(2));
487
+ const atNegative1 = track(() => items.at(-1));
488
+ const atNegative2 = track(() => items.at(-2));
489
489
  <>
490
490
  <button onClick={() => (items[2] = 300)}>{'change index 2'}</button>
491
491
  <button onClick={() => (items[items.length - 1] = 500)}>{'change last'}</button>
492
492
  <pre>{JSON.stringify(items)}</pre>
493
- <pre>{atIndex2}</pre>
494
- <pre>{atNegative1}</pre>
495
- <pre>{atNegative2}</pre>
493
+ <pre>{atIndex2.value}</pre>
494
+ <pre>{atNegative1.value}</pre>
495
+ <pre>{atNegative2.value}</pre>
496
496
  </>
497
497
  }
498
498
 
@@ -4,11 +4,11 @@ describe('RippleArray > iteration', () => {
4
4
  it('handles entries method with reactivity', () => {
5
5
  function ArrayTest() @{
6
6
  let items = new RippleArray('a', 'b', 'c');
7
- let &[entries] = track(() => Array.from(items.entries()));
7
+ const entries = track(() => Array.from(items.entries()));
8
8
  <>
9
9
  <button onClick={() => items.push('d')}>{'add item'}</button>
10
10
  <pre>{JSON.stringify(items)}</pre>
11
- <pre>{JSON.stringify(entries)}</pre>
11
+ <pre>{JSON.stringify(entries.value)}</pre>
12
12
  </>
13
13
  }
14
14
 
@@ -33,11 +33,11 @@ describe('RippleArray > iteration', () => {
33
33
  it('handles keys method with reactivity', () => {
34
34
  function ArrayTest() @{
35
35
  let items = new RippleArray('a', 'b', 'c');
36
- let &[keys] = track(() => Array.from(items.keys()));
36
+ const keys = track(() => Array.from(items.keys()));
37
37
  <>
38
38
  <button onClick={() => items.push('d')}>{'add item'}</button>
39
39
  <pre>{JSON.stringify(items)}</pre>
40
- <pre>{JSON.stringify(keys)}</pre>
40
+ <pre>{JSON.stringify(keys.value)}</pre>
41
41
  </>
42
42
  }
43
43
 
@@ -60,11 +60,11 @@ describe('RippleArray > iteration', () => {
60
60
  it('handles values method with reactivity', () => {
61
61
  function ArrayTest() @{
62
62
  let items = new RippleArray('a', 'b', 'c');
63
- let &[values] = track(() => Array.from(items.values()));
63
+ const values = track(() => Array.from(items.values()));
64
64
  <>
65
65
  <button onClick={() => items.push('d')}>{'add item'}</button>
66
66
  <pre>{JSON.stringify(items)}</pre>
67
- <pre>{JSON.stringify(values)}</pre>
67
+ <pre>{JSON.stringify(values.value)}</pre>
68
68
  </>
69
69
  }
70
70
 
@@ -87,19 +87,19 @@ describe('RippleArray > iteration', () => {
87
87
  it('handles Symbol.iterator with reactivity', () => {
88
88
  function ArrayTest() @{
89
89
  let items = new RippleArray(1, 2, 3);
90
- let &[sum] = track(0);
90
+ const sum = track(0);
91
91
  effect(() => {
92
- sum = 0;
92
+ sum.value = 0;
93
93
  for (const item of items) {
94
94
  untrack(() => {
95
- sum += item;
95
+ sum.value += item;
96
96
  });
97
97
  }
98
98
  });
99
99
  <>
100
100
  <button onClick={() => items.push(4)}>{'add item'}</button>
101
101
  <pre>{JSON.stringify(items)}</pre>
102
- <pre>{sum}</pre>
102
+ <pre>{sum.value}</pre>
103
103
  </>
104
104
  }
105
105
 
@@ -37,13 +37,13 @@ describe('RippleArray > mutations', () => {
37
37
  it('handles push and pop operations with reactivity', () => {
38
38
  function ArrayTest() @{
39
39
  let items = new RippleArray(1, 2, 3);
40
- let &[lastItem] = track(() => items[items.length - 1]);
40
+ const lastItem = track(() => items[items.length - 1]);
41
41
  <>
42
42
  <button onClick={() => items.push(4)}>{'push'}</button>
43
43
  <button onClick={() => items.pop()}>{'pop'}</button>
44
44
  <pre>{JSON.stringify(items)}</pre>
45
45
  <pre>{items.length}</pre>
46
- <pre>{lastItem}</pre>
46
+ <pre>{lastItem.value}</pre>
47
47
  </>
48
48
  }
49
49
 
@@ -77,13 +77,13 @@ describe('RippleArray > mutations', () => {
77
77
  it('handles shift and unshift operations with reactivity', () => {
78
78
  function ArrayTest() @{
79
79
  let items = new RippleArray(2, 3, 4);
80
- let &[firstItem] = track(() => items[0]);
80
+ const firstItem = track(() => items[0]);
81
81
  <>
82
82
  <button onClick={() => items.unshift(1)}>{'unshift'}</button>
83
83
  <button onClick={() => items.shift()}>{'shift'}</button>
84
84
  <pre>{JSON.stringify(items)}</pre>
85
85
  <pre>{items.length}</pre>
86
- <pre>{firstItem}</pre>
86
+ <pre>{firstItem.value}</pre>
87
87
  </>
88
88
  }
89
89
 
@@ -117,12 +117,12 @@ describe('RippleArray > mutations', () => {
117
117
  it('handles splice operation with reactivity', () => {
118
118
  function ArrayTest() @{
119
119
  let items: RippleArray<number | string> = new RippleArray(1, 2, 3, 4, 5);
120
- let &[middleItem] = track(() => items[2]);
120
+ const middleItem = track(() => items[2]);
121
121
  <>
122
122
  <button onClick={() => items.splice(1, 2, 'a', 'b')}>{'splice'}</button>
123
123
  <pre>{JSON.stringify(items)}</pre>
124
124
  <pre>{items.length}</pre>
125
- <pre>{middleItem}</pre>
125
+ <pre>{middleItem.value}</pre>
126
126
  </>
127
127
  }
128
128
 
@@ -147,11 +147,11 @@ describe('RippleArray > mutations', () => {
147
147
  it('handles fill operation with reactivity', () => {
148
148
  function ArrayTest() @{
149
149
  let items = new RippleArray(1, 2, 3, 4, 5);
150
- let &[secondItem] = track(() => items[1]);
150
+ const secondItem = track(() => items[1]);
151
151
  <>
152
152
  <button onClick={() => items.fill(0, 1, 4)}>{'fill'}</button>
153
153
  <pre>{JSON.stringify(items)}</pre>
154
- <pre>{secondItem}</pre>
154
+ <pre>{secondItem.value}</pre>
155
155
  </>
156
156
  }
157
157
 
@@ -174,13 +174,13 @@ describe('RippleArray > mutations', () => {
174
174
  it('handles reverse operation with reactivity', () => {
175
175
  function ArrayTest() @{
176
176
  let items = new RippleArray(1, 2, 3, 4, 5);
177
- let &[firstItem] = track(() => items[0]);
178
- let &[lastItem] = track(() => items[4]);
177
+ const firstItem = track(() => items[0]);
178
+ const lastItem = track(() => items[4]);
179
179
  <>
180
180
  <button onClick={() => items.reverse()}>{'reverse'}</button>
181
181
  <pre>{JSON.stringify(items)}</pre>
182
- <pre>{firstItem}</pre>
183
- <pre>{lastItem}</pre>
182
+ <pre>{firstItem.value}</pre>
183
+ <pre>{lastItem.value}</pre>
184
184
  </>
185
185
  }
186
186
 
@@ -205,12 +205,12 @@ describe('RippleArray > mutations', () => {
205
205
  it('handles sort operation with reactivity', () => {
206
206
  function ArrayTest() @{
207
207
  let items = new RippleArray(5, 3, 1, 4, 2);
208
- let &[secondItem] = track(() => items[1]);
208
+ const secondItem = track(() => items[1]);
209
209
  <>
210
210
  <button onClick={() => items.sort()}>{'sort ascending'}</button>
211
211
  <button onClick={() => items.sort((a, b) => b - a)}>{'sort descending'}</button>
212
212
  <pre>{JSON.stringify(items)}</pre>
213
- <pre>{secondItem}</pre>
213
+ <pre>{secondItem.value}</pre>
214
214
  </>
215
215
  }
216
216
 
@@ -297,12 +297,12 @@ describe('RippleArray > mutations', () => {
297
297
  it('handles array index access with reactivity', () => {
298
298
  function ArrayTest() @{
299
299
  let items = new RippleArray(10, 20, 30);
300
- let &[firstItem] = track(() => items[0]);
301
- let &[secondItem] = track(() => items[1]);
300
+ const firstItem = track(() => items[0]);
301
+ const secondItem = track(() => items[1]);
302
302
  <>
303
303
  <button onClick={() => (items[0] = 100)}>{'change first'}</button>
304
- <pre>{firstItem}</pre>
305
- <pre>{secondItem}</pre>
304
+ <pre>{firstItem.value}</pre>
305
+ <pre>{secondItem.value}</pre>
306
306
  <pre>{items[0]}</pre>
307
307
  <pre>{items[1]}</pre>
308
308
  </>
@@ -331,12 +331,12 @@ describe('RippleArray > mutations', () => {
331
331
  it('handles length property for reactivity', () => {
332
332
  function ArrayTest() @{
333
333
  let items = new RippleArray(1, 2, 3);
334
- let &[length] = track(() => items.length);
334
+ const length = track(() => items.length);
335
335
  <>
336
336
  <button onClick={() => (items.length = 5)}>{'expand'}</button>
337
337
  <button onClick={() => (items.length = 2)}>{'shrink'}</button>
338
338
  <pre>{JSON.stringify(items)}</pre>
339
- <pre>{length}</pre>
339
+ <pre>{length.value}</pre>
340
340
  </>
341
341
  }
342
342