ripple 0.3.72 → 0.3.76

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 (172) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/package.json +3 -3
  3. package/src/jsx-runtime.d.ts +4 -10
  4. package/src/runtime/dynamic-client.js +33 -0
  5. package/src/runtime/dynamic-server.js +80 -0
  6. package/src/runtime/index-client.js +5 -13
  7. package/src/runtime/index-server.js +2 -0
  8. package/src/runtime/internal/client/blocks.js +6 -27
  9. package/src/runtime/internal/client/composite.js +11 -6
  10. package/src/runtime/internal/client/for.js +80 -5
  11. package/src/runtime/internal/client/index.js +0 -2
  12. package/src/runtime/internal/client/render.js +5 -2
  13. package/src/runtime/internal/client/types.d.ts +0 -10
  14. package/src/runtime/internal/server/index.js +8 -1
  15. package/tests/client/__snapshots__/computed-properties.test.tsrx.snap +8 -0
  16. package/tests/client/__snapshots__/for.test.tsrx.snap +22 -0
  17. package/tests/client/__snapshots__/html.test.tsrx.snap +4 -0
  18. package/tests/client/array/array.copy-within.test.tsrx +19 -19
  19. package/tests/client/array/array.derived.test.tsrx +97 -109
  20. package/tests/client/array/array.iteration.test.tsrx +28 -28
  21. package/tests/client/array/array.mutations.test.tsrx +68 -68
  22. package/tests/client/array/array.static.test.tsrx +82 -92
  23. package/tests/client/array/array.to-methods.test.tsrx +15 -15
  24. package/tests/client/async-suspend.test.tsrx +180 -179
  25. package/tests/client/basic/__snapshots__/basic.attributes.test.tsrx.snap +2 -0
  26. package/tests/client/basic/__snapshots__/basic.rendering.test.tsrx.snap +4 -0
  27. package/tests/client/basic/basic.attributes.test.tsrx +273 -317
  28. package/tests/client/basic/basic.collections.test.tsrx +55 -61
  29. package/tests/client/basic/basic.components.test.tsrx +198 -220
  30. package/tests/client/basic/basic.errors.test.tsrx +70 -76
  31. package/tests/client/basic/basic.events.test.tsrx +80 -85
  32. package/tests/client/basic/basic.get-set.test.tsrx +54 -64
  33. package/tests/client/basic/basic.hmr.test.tsrx +15 -19
  34. package/tests/client/basic/basic.reactivity.test.tsrx +121 -135
  35. package/tests/client/basic/basic.rendering.test.tsrx +273 -178
  36. package/tests/client/basic/basic.styling.test.tsrx +16 -14
  37. package/tests/client/basic/basic.utilities.test.tsrx +8 -10
  38. package/tests/client/boundaries.test.tsrx +18 -18
  39. package/tests/client/compiler/compiler.assignments.test.tsrx +77 -76
  40. package/tests/client/compiler/compiler.attributes.test.tsrx +18 -14
  41. package/tests/client/compiler/compiler.basic.test.tsrx +357 -288
  42. package/tests/client/compiler/compiler.regex.test.tsrx +40 -44
  43. package/tests/client/compiler/compiler.tracked-access.test.tsrx +57 -38
  44. package/tests/client/compiler/compiler.try-in-function.test.tsrx +16 -16
  45. package/tests/client/compiler/compiler.typescript.test.tsrx +4 -3
  46. package/tests/client/composite/composite.dynamic-components.test.tsrx +62 -47
  47. package/tests/client/composite/composite.generics.test.tsrx +165 -167
  48. package/tests/client/composite/composite.props.test.tsrx +66 -74
  49. package/tests/client/composite/composite.reactivity.test.tsrx +132 -166
  50. package/tests/client/composite/composite.render.test.tsrx +92 -101
  51. package/tests/client/computed-properties.test.tsrx +14 -18
  52. package/tests/client/context.test.tsrx +14 -18
  53. package/tests/client/css/global-additional-cases.test.tsrx +493 -439
  54. package/tests/client/css/global-advanced-selectors.test.tsrx +169 -153
  55. package/tests/client/css/global-at-rules.test.tsrx +71 -66
  56. package/tests/client/css/global-basic.test.tsrx +105 -98
  57. package/tests/client/css/global-classes-ids.test.tsrx +128 -114
  58. package/tests/client/css/global-combinators.test.tsrx +83 -78
  59. package/tests/client/css/global-complex-nesting.test.tsrx +134 -120
  60. package/tests/client/css/global-edge-cases.test.tsrx +138 -120
  61. package/tests/client/css/global-keyframes.test.tsrx +108 -96
  62. package/tests/client/css/global-nested.test.tsrx +88 -78
  63. package/tests/client/css/global-pseudo.test.tsrx +104 -98
  64. package/tests/client/css/global-scoping.test.tsrx +145 -125
  65. package/tests/client/css/style-identifier.test.tsrx +65 -72
  66. package/tests/client/date.test.tsrx +83 -83
  67. package/tests/client/dynamic-elements.test.tsrx +318 -299
  68. package/tests/client/events.test.tsrx +252 -266
  69. package/tests/client/for.test.tsrx +120 -127
  70. package/tests/client/head.test.tsrx +74 -48
  71. package/tests/client/html.test.tsrx +37 -49
  72. package/tests/client/input-value.test.tsrx +1125 -1354
  73. package/tests/client/lazy-array.test.tsrx +10 -16
  74. package/tests/client/lazy-destructuring.test.tsrx +169 -221
  75. package/tests/client/map.test.tsrx +39 -41
  76. package/tests/client/media-query.test.tsrx +15 -19
  77. package/tests/client/object.test.tsrx +46 -56
  78. package/tests/client/portal.test.tsrx +31 -37
  79. package/tests/client/ref.test.tsrx +173 -193
  80. package/tests/client/return.test.tsrx +62 -37
  81. package/tests/client/set.test.tsrx +33 -33
  82. package/tests/client/svg.test.tsrx +197 -216
  83. package/tests/client/switch.test.tsrx +201 -191
  84. package/tests/client/track-async-hydration.test.tsrx +14 -18
  85. package/tests/client/tracked-index-access.test.tsrx +18 -28
  86. package/tests/client/try.test.tsrx +494 -619
  87. package/tests/client/tsx.test.tsrx +286 -292
  88. package/tests/client/typescript-generics.test.tsrx +121 -129
  89. package/tests/client/url/url.derived.test.tsrx +21 -25
  90. package/tests/client/url/url.parsing.test.tsrx +35 -35
  91. package/tests/client/url/url.partial-removal.test.tsrx +32 -32
  92. package/tests/client/url/url.reactivity.test.tsrx +68 -72
  93. package/tests/client/url/url.serialization.test.tsrx +8 -8
  94. package/tests/client/url-search-params/url-search-params.derived.test.tsrx +21 -27
  95. package/tests/client/url-search-params/url-search-params.initialization.test.tsrx +16 -16
  96. package/tests/client/url-search-params/url-search-params.iteration.test.tsrx +37 -37
  97. package/tests/client/url-search-params/url-search-params.mutation.test.tsrx +56 -60
  98. package/tests/client/url-search-params/url-search-params.retrieval.test.tsrx +32 -34
  99. package/tests/client/url-search-params/url-search-params.serialization.test.tsrx +9 -9
  100. package/tests/client/url-search-params/url-search-params.tracked-url.test.tsrx +10 -10
  101. package/tests/hydration/compiled/client/basic.js +390 -319
  102. package/tests/hydration/compiled/client/composite.js +52 -44
  103. package/tests/hydration/compiled/client/for.js +734 -604
  104. package/tests/hydration/compiled/client/head.js +183 -103
  105. package/tests/hydration/compiled/client/html.js +93 -86
  106. package/tests/hydration/compiled/client/if-children.js +95 -71
  107. package/tests/hydration/compiled/client/if.js +113 -89
  108. package/tests/hydration/compiled/client/mixed-control-flow.js +225 -209
  109. package/tests/hydration/compiled/client/nested-control-flow.js +94 -98
  110. package/tests/hydration/compiled/client/reactivity.js +26 -24
  111. package/tests/hydration/compiled/client/return.js +8 -42
  112. package/tests/hydration/compiled/client/switch.js +208 -173
  113. package/tests/hydration/compiled/client/track-async-serialization.js +176 -128
  114. package/tests/hydration/compiled/client/try.js +29 -21
  115. package/tests/hydration/compiled/server/basic.js +210 -221
  116. package/tests/hydration/compiled/server/composite.js +13 -14
  117. package/tests/hydration/compiled/server/for.js +427 -444
  118. package/tests/hydration/compiled/server/head.js +199 -189
  119. package/tests/hydration/compiled/server/html.js +33 -41
  120. package/tests/hydration/compiled/server/if-children.js +114 -117
  121. package/tests/hydration/compiled/server/if.js +77 -83
  122. package/tests/hydration/compiled/server/mixed-control-flow.js +145 -150
  123. package/tests/hydration/compiled/server/nested-control-flow.js +10 -0
  124. package/tests/hydration/compiled/server/reactivity.js +24 -22
  125. package/tests/hydration/compiled/server/return.js +6 -18
  126. package/tests/hydration/compiled/server/switch.js +179 -176
  127. package/tests/hydration/compiled/server/track-async-serialization.js +88 -70
  128. package/tests/hydration/compiled/server/try.js +31 -35
  129. package/tests/hydration/components/basic.tsrx +216 -258
  130. package/tests/hydration/components/composite.tsrx +32 -42
  131. package/tests/hydration/components/events.tsrx +81 -101
  132. package/tests/hydration/components/for.tsrx +270 -336
  133. package/tests/hydration/components/head.tsrx +43 -39
  134. package/tests/hydration/components/hmr.tsrx +16 -22
  135. package/tests/hydration/components/html-in-template.tsrx +15 -21
  136. package/tests/hydration/components/html.tsrx +442 -526
  137. package/tests/hydration/components/if-children.tsrx +107 -125
  138. package/tests/hydration/components/if.tsrx +68 -90
  139. package/tests/hydration/components/mixed-control-flow.tsrx +65 -72
  140. package/tests/hydration/components/nested-control-flow.tsrx +202 -216
  141. package/tests/hydration/components/portal.tsrx +33 -41
  142. package/tests/hydration/components/reactivity.tsrx +26 -34
  143. package/tests/hydration/components/return.tsrx +4 -6
  144. package/tests/hydration/components/switch.tsrx +73 -78
  145. package/tests/hydration/components/track-async-serialization.tsrx +83 -93
  146. package/tests/hydration/components/try.tsrx +37 -51
  147. package/tests/hydration/switch.test.js +8 -8
  148. package/tests/server/await.test.tsrx +3 -3
  149. package/tests/server/basic.attributes.test.tsrx +117 -162
  150. package/tests/server/basic.components.test.tsrx +164 -194
  151. package/tests/server/basic.test.tsrx +299 -199
  152. package/tests/server/compiler.test.tsrx +142 -72
  153. package/tests/server/composite.props.test.tsrx +54 -58
  154. package/tests/server/composite.test.tsrx +165 -167
  155. package/tests/server/context.test.tsrx +13 -17
  156. package/tests/server/dynamic-elements.test.tsrx +147 -148
  157. package/tests/server/for.test.tsrx +115 -84
  158. package/tests/server/head.test.tsrx +54 -31
  159. package/tests/server/html-nesting-validation.test.tsrx +16 -8
  160. package/tests/server/if.test.tsrx +49 -59
  161. package/tests/server/lazy-destructuring.test.tsrx +288 -366
  162. package/tests/server/return.test.tsrx +58 -36
  163. package/tests/server/streaming-ssr.test.tsrx +4 -4
  164. package/tests/server/style-identifier.test.tsrx +61 -69
  165. package/tests/server/switch.test.tsrx +89 -97
  166. package/tests/server/track-async-serialization.test.tsrx +85 -103
  167. package/tests/server/try.test.tsrx +275 -360
  168. package/tests/utils/ref-types.test.js +72 -0
  169. package/tests/utils/vite-plugin-config.test.js +41 -74
  170. package/types/index.d.ts +29 -4
  171. package/src/runtime/internal/client/compat.js +0 -40
  172. package/tests/utils/compiler-compat-config.test.js +0 -38
@@ -2,18 +2,18 @@ import { RippleMap, flushSync, track } from 'ripple';
2
2
 
3
3
  describe('RippleMap', () => {
4
4
  it('handles set with update and delete operations with a reactive size var', () => {
5
- function MapTest() {
6
- return <>
7
- let map = RippleMap([['a', 1], ['b', 2], ['c', 3]]);
8
- let &[value] = track(() => map.get('a'));
9
- let &[size] = track(() => map.size);
5
+ function MapTest() @{
6
+ let map = new RippleMap([['a', 1], ['b', 2], ['c', 3]]);
7
+ let &[value] = track(() => map.get('a'));
8
+ let &[size] = track(() => map.size);
9
+ <>
10
10
  <button onClick={() => map.set('d', 4)}>{'set'}</button>
11
11
  <button onClick={() => map.delete('b')}>{'delete'}</button>
12
12
  <button onClick={() => map.set('a', 5)}>{'update'}</button>
13
13
  <pre>{map.get('d')}</pre>
14
14
  <pre>{size}</pre>
15
15
  <pre>{value}</pre>
16
- </>;
16
+ </>
17
17
  }
18
18
 
19
19
  render(MapTest);
@@ -41,12 +41,12 @@ describe('RippleMap', () => {
41
41
  });
42
42
 
43
43
  it('handles clear operation', () => {
44
- function MapTest() {
45
- return <>
46
- let map = RippleMap([['a', 1], ['b', 2], ['c', 3]]);
44
+ function MapTest() @{
45
+ let map = new RippleMap([['a', 1], ['b', 2], ['c', 3]]);
46
+ <>
47
47
  <button onClick={() => map.clear()}>{'clear'}</button>
48
48
  <pre>{map.size}</pre>
49
- </>;
49
+ </>
50
50
  }
51
51
 
52
52
  render(MapTest);
@@ -60,13 +60,13 @@ describe('RippleMap', () => {
60
60
  });
61
61
 
62
62
  it('handles has operation and tracks reactive $has', () => {
63
- function MapTest() {
64
- return <>
65
- let map = RippleMap([['a', 1], ['b', 2], ['c', 3]]);
66
- let &[has] = track(() => map.has('b'));
63
+ function MapTest() @{
64
+ let map = new RippleMap([['a', 1], ['b', 2], ['c', 3]]);
65
+ let &[has] = track(() => map.has('b'));
66
+ <>
67
67
  <button onClick={() => map.delete('b')}>{'delete'}</button>
68
68
  <pre>{has}</pre>
69
- </>;
69
+ </>
70
70
  }
71
71
 
72
72
  render(MapTest);
@@ -81,17 +81,17 @@ describe('RippleMap', () => {
81
81
  });
82
82
 
83
83
  it('handles reactivity of keys, values, and entries', () => {
84
- function MapTest() {
85
- return <>
86
- let map = RippleMap([['x', 10], ['y', 20]]);
87
- let &[keys] = track(() => Array.from(map.keys()));
88
- let &[values] = track(() => Array.from(map.values()));
89
- let &[entries] = track(() => Array.from(map.entries()));
84
+ function MapTest() @{
85
+ let map = new RippleMap([['x', 10], ['y', 20]]);
86
+ let &[keys] = track(() => Array.from(map.keys()));
87
+ let &[values] = track(() => Array.from(map.values()));
88
+ let &[entries] = track(() => Array.from(map.entries()));
89
+ <>
90
90
  <button onClick={() => map.delete('x')}>{'delete'}</button>
91
91
  <pre>{JSON.stringify(keys)}</pre>
92
92
  <pre>{JSON.stringify(values)}</pre>
93
93
  <pre>{JSON.stringify(entries)}</pre>
94
- </>;
94
+ </>
95
95
  }
96
96
 
97
97
  render(MapTest);
@@ -111,11 +111,9 @@ describe('RippleMap', () => {
111
111
  });
112
112
 
113
113
  it('toJSON returns correct object', () => {
114
- function MapTest() {
115
- return <>
116
- let map = RippleMap([['foo', 1], ['bar', 2]]);
117
- <pre>{JSON.stringify(map)}</pre>
118
- </>;
114
+ function MapTest() @{
115
+ let map = new RippleMap([['foo', 1], ['bar', 2]]);
116
+ <pre>{JSON.stringify(map)}</pre>
119
117
  }
120
118
 
121
119
  render(MapTest);
@@ -124,12 +122,12 @@ describe('RippleMap', () => {
124
122
  });
125
123
 
126
124
  it('creates empty RippleMap using RippleMap() shorthand syntax', () => {
127
- function MapTest() {
128
- return <>
129
- let map = RippleMap();
125
+ function MapTest() @{
126
+ let map = new RippleMap();
127
+ <>
130
128
  <button onClick={() => map.set('a', 1)}>{'add'}</button>
131
129
  <pre>{map.size}</pre>
132
- </>;
130
+ </>
133
131
  }
134
132
 
135
133
  render(MapTest);
@@ -144,14 +142,14 @@ describe('RippleMap', () => {
144
142
  });
145
143
 
146
144
  it('creates RippleMap with initial entries using RippleMap() shorthand syntax', () => {
147
- function MapTest() {
148
- return <>
149
- let map = RippleMap([['a', 1], ['b', 2], ['c', 3]]);
150
- let &[value] = track(() => map.get('b'));
145
+ function MapTest() @{
146
+ let map = new RippleMap([['a', 1], ['b', 2], ['c', 3]]);
147
+ let &[value] = track(() => map.get('b'));
148
+ <>
151
149
  <button onClick={() => map.set('b', 10)}>{'update'}</button>
152
150
  <pre>{map.size}</pre>
153
151
  <pre>{value}</pre>
154
- </>;
152
+ </>
155
153
  }
156
154
 
157
155
  render(MapTest);
@@ -167,16 +165,16 @@ describe('RippleMap', () => {
167
165
  });
168
166
 
169
167
  it('handles all operations with RippleMap() shorthand syntax', () => {
170
- function MapTest() {
171
- return <>
172
- let map = RippleMap([['x', 100], ['y', 200]]);
173
- let &[keys] = track(() => Array.from(map.keys()));
168
+ function MapTest() @{
169
+ let map = new RippleMap([['x', 100], ['y', 200]]);
170
+ let &[keys] = track(() => Array.from(map.keys()));
171
+ <>
174
172
  <button onClick={() => map.set('z', 300)}>{'add'}</button>
175
173
  <button onClick={() => map.delete('x')}>{'delete'}</button>
176
174
  <button onClick={() => map.clear()}>{'clear'}</button>
177
175
  <pre>{JSON.stringify(keys)}</pre>
178
176
  <pre>{map.size}</pre>
179
- </>;
177
+ </>
180
178
  }
181
179
 
182
180
  render(MapTest);
@@ -50,13 +50,11 @@ describe('MediaQuery', () => {
50
50
  it('should be reactive if matchMedia changes', () => {
51
51
  const media = '(min-width: 600px)';
52
52
 
53
- function App() {
54
- return <>
55
- let &[medium] = MediaQuery(media);
56
- <div>
57
- <p>{medium}</p>
58
- </div>
59
- </>;
53
+ function App() @{
54
+ let &[medium] = new MediaQuery(media);
55
+ <div>
56
+ <p>{medium}</p>
57
+ </div>
60
58
  }
61
59
 
62
60
  render(App);
@@ -86,23 +84,21 @@ describe('MediaQuery', () => {
86
84
  it('should have cleared event listeners after unmount', async () => {
87
85
  const media = '(min-width: 600px)';
88
86
 
89
- function App() {
90
- return <>
91
- let &[show] = track(true);
92
- if (show) {
87
+ function App() @{
88
+ let &[show] = track(true);
89
+ <>
90
+ @if (show) {
93
91
  <Child />
94
92
  }
95
93
  <button onClick={() => (show = !show)}>{'Toggle Child'}</button>
96
- </>;
94
+ </>
97
95
  }
98
96
 
99
- function Child() {
100
- return <>
101
- let &[medium] = MediaQuery(media);
102
- <div>
103
- <p>{medium}</p>
104
- </div>
105
- </>;
97
+ function Child() @{
98
+ let &[medium] = new MediaQuery(media);
99
+ <div>
100
+ <p>{medium}</p>
101
+ </div>
106
102
  }
107
103
 
108
104
  render(App);
@@ -3,19 +3,17 @@ import { TRACKED_OBJECT } from '../../src/runtime/internal/client/constants.js';
3
3
 
4
4
  describe('RippleObject', () => {
5
5
  it('makes new properties reactive', () => {
6
- function ObjectTest() {
7
- return <>
8
- const obj = new RippleObject({ a: -1 });
9
- obj.a = 0;
6
+ function ObjectTest() @{
7
+ const obj = new RippleObject({ a: -1 });
8
+ obj.a = 0;
9
+ <>
10
10
  <pre>{obj.a}</pre>
11
11
  <button
12
12
  onClick={() => {
13
13
  obj.a++;
14
14
  }}
15
- >
16
- {'Increment A'}
17
- </button>
18
- </>;
15
+ >{'Increment A'}</button>
16
+ </>
19
17
  }
20
18
 
21
19
  render(ObjectTest);
@@ -32,18 +30,16 @@ describe('RippleObject', () => {
32
30
  });
33
31
 
34
32
  it('makes existing object properties reactive', () => {
35
- function ObjectTest() {
36
- return <>
37
- const obj = new RippleObject({ a: 0 });
33
+ function ObjectTest() @{
34
+ const obj = new RippleObject({ a: 0 });
35
+ <>
38
36
  <pre>{obj.a}</pre>
39
37
  <button
40
38
  onClick={() => {
41
39
  obj.a++;
42
40
  }}
43
- >
44
- {'Increment A'}
45
- </button>
46
- </>;
41
+ >{'Increment A'}</button>
42
+ </>
47
43
  }
48
44
 
49
45
  render(ObjectTest);
@@ -60,12 +56,12 @@ describe('RippleObject', () => {
60
56
  });
61
57
 
62
58
  it('checks if property exists via the has trap', () => {
63
- function ObjectTest() {
64
- return <>
65
- const obj = new RippleObject({ a: -1, b: 1 });
66
- obj.a = 0;
67
- <pre>{'a' in obj && 'b' in obj}</pre>
68
- </>;
59
+ function ObjectTest() @{
60
+ const obj = new RippleObject({ a: -1, b: 1 });
61
+ obj.a = 0;
62
+ <pre>
63
+ {'a' in obj && 'b' in obj}
64
+ </pre>
69
65
  }
70
66
 
71
67
  render(ObjectTest);
@@ -76,18 +72,16 @@ describe('RippleObject', () => {
76
72
  });
77
73
 
78
74
  it('deletes properties via the delete trap', () => {
79
- function ObjectTest() {
80
- return <>
81
- const obj = new RippleObject<{ a?: number; b: number }>({ a: 0, b: 1 });
75
+ function ObjectTest() @{
76
+ const obj = new RippleObject<{ a?: number; b: number }>({ a: 0, b: 1 });
77
+ <>
82
78
  <pre>{String(obj.a)}</pre>
83
79
  <button
84
80
  onClick={() => {
85
81
  delete obj.a;
86
82
  }}
87
- >
88
- {'Delete A'}
89
- </button>
90
- </>;
83
+ >{'Delete A'}</button>
84
+ </>
91
85
  }
92
86
 
93
87
  render(ObjectTest);
@@ -104,18 +98,16 @@ describe('RippleObject', () => {
104
98
  });
105
99
 
106
100
  it('checks if non-existent property is reactive when added later', () => {
107
- function ObjectTest() {
108
- return <>
109
- const obj = new RippleObject<{ a?: number }>({});
101
+ function ObjectTest() @{
102
+ const obj = new RippleObject<{ a?: number }>({});
103
+ <>
110
104
  <pre>{String(obj.a)}</pre>
111
105
  <button
112
106
  onClick={() => {
113
107
  obj.a = 1;
114
108
  }}
115
- >
116
- {'Add A'}
117
- </button>
118
- </>;
109
+ >{'Add A'}</button>
110
+ </>
119
111
  }
120
112
 
121
113
  render(ObjectTest);
@@ -132,18 +124,16 @@ describe('RippleObject', () => {
132
124
  });
133
125
 
134
126
  it('checks that deeply nested objects are not proxied or reactive', () => {
135
- function ObjectTest() {
136
- return <>
137
- const obj = new RippleObject({ a: { b: 1 } });
127
+ function ObjectTest() @{
128
+ const obj = new RippleObject({ a: { b: 1 } });
129
+ <>
138
130
  <pre>{String(obj.a.b)}</pre>
139
131
  <button
140
132
  onClick={() => {
141
133
  obj.a.b++;
142
134
  }}
143
- >
144
- {'Increment B'}
145
- </button>
146
- </>;
135
+ >{'Increment B'}</button>
136
+ </>
147
137
  }
148
138
 
149
139
  render(ObjectTest);
@@ -161,30 +151,30 @@ describe('RippleObject', () => {
161
151
  });
162
152
 
163
153
  it('checks if TRACKED_OBJECT symbol is present on RippleObject instances', () => {
164
- function ObjectTest() {
165
- return <>
166
- const obj = new RippleObject({ a: 0 });
167
- // @ts-expect-error TRACKED_OBJECT is internal
168
- expect(obj[TRACKED_OBJECT]).toBe(true);
169
- </>;
154
+ function ObjectTest() @{
155
+ const obj = new RippleObject({ a: 0 });
156
+ expect(TRACKED_OBJECT in obj).toBe(true);
157
+ <pre>{'done'}</pre>
170
158
  }
159
+
160
+ render(ObjectTest);
171
161
  });
172
162
 
173
163
  it('uses the hash syntax for creating RippleObject', () => {
174
- function ObjectTest() {
175
- return <>
176
- const obj = new RippleObject({ a: 0, b: 1, c: { d: { e: 8 } } });
164
+ function ObjectTest() @{
165
+ const obj = new RippleObject({ a: 0, b: 1, c: { d: { e: 8 } } });
166
+ <>
177
167
  <pre>{obj.a}</pre>
178
- <pre>{TRACKED_OBJECT in obj}</pre>
168
+ <pre>
169
+ {TRACKED_OBJECT in obj}
170
+ </pre>
179
171
  <pre>{JSON.stringify(obj)}</pre>
180
172
  <button
181
173
  onClick={() => {
182
174
  obj.a++;
183
175
  }}
184
- >
185
- {'Increment A'}
186
- </button>
187
- </>;
176
+ >{'Increment A'}</button>
177
+ </>
188
178
  }
189
179
 
190
180
  render(ObjectTest);
@@ -11,12 +11,10 @@ describe('Portal', () => {
11
11
  const target = document.createElement('div');
12
12
  document.body.appendChild(target);
13
13
 
14
- function TestPortal() {
15
- return <>
16
- <Portal {target}>
17
- <div class="test-portal">{'Portal works!'}</div>
18
- </Portal>
19
- </>;
14
+ function TestPortal() @{
15
+ <Portal {target}>
16
+ <div class="test-portal">{'Portal works!'}</div>
17
+ </Portal>
20
18
  }
21
19
 
22
20
  render(TestPortal);
@@ -30,12 +28,10 @@ describe('Portal', () => {
30
28
  });
31
29
 
32
30
  it('renders portal content to document.body', () => {
33
- function TestPortal() {
34
- return <>
35
- <Portal target={document.body}>
36
- <div class="test-portal">{'In document.body!'}</div>
37
- </Portal>
38
- </>;
31
+ function TestPortal() @{
32
+ <Portal target={document.body}>
33
+ <div class="test-portal">{'In document.body!'}</div>
34
+ </Portal>
39
35
  }
40
36
 
41
37
  render(TestPortal);
@@ -49,16 +45,16 @@ describe('Portal', () => {
49
45
  });
50
46
 
51
47
  it('cleans up portal content when destroyed via conditional rendering', () => {
52
- function TestPortal() {
53
- return <>
54
- let &[open] = track(true);
55
- if (open) {
48
+ function TestPortal() @{
49
+ let &[open] = track(true);
50
+ <>
51
+ @if (open) {
56
52
  <Portal target={document.body}>
57
53
  <div class="test-portal">{'Conditional content'}</div>
58
54
  </Portal>
59
55
  }
60
56
  <button onClick={() => (open = false)}>{'Close'}</button>
61
- </>;
57
+ </>
62
58
  }
63
59
 
64
60
  render(TestPortal);
@@ -75,10 +71,10 @@ describe('Portal', () => {
75
71
  });
76
72
 
77
73
  it('opens and closes portal via conditional rendering', () => {
78
- function TestPortal() {
79
- return <>
80
- let &[open] = track(false);
81
- if (open) {
74
+ function TestPortal() @{
75
+ let &[open] = track(false);
76
+ <>
77
+ @if (open) {
82
78
  <Portal target={document.body}>
83
79
  <div class="test-portal">
84
80
  {'Content'}
@@ -86,10 +82,10 @@ describe('Portal', () => {
86
82
  </div>
87
83
  </Portal>
88
84
  }
89
- if (!open) {
85
+ @if (!open) {
90
86
  <button onClick={() => (open = true)}>{'Open'}</button>
91
87
  }
92
- </>;
88
+ </>
93
89
  }
94
90
 
95
91
  render(TestPortal);
@@ -117,15 +113,15 @@ describe('Portal', () => {
117
113
  document.body.appendChild(target1);
118
114
  document.body.appendChild(target2);
119
115
 
120
- function TestMultiPortal() {
121
- return <>
116
+ function TestMultiPortal() @{
117
+ <>
122
118
  <Portal target={target1}>
123
119
  <div class="test-portal">{'Portal 1 content'}</div>
124
120
  </Portal>
125
121
  <Portal target={target2}>
126
122
  <div class="test-portal">{'Portal 2 content'}</div>
127
123
  </Portal>
128
- </>;
124
+ </>
129
125
  }
130
126
 
131
127
  render(TestMultiPortal);
@@ -142,17 +138,15 @@ describe('Portal', () => {
142
138
  });
143
139
 
144
140
  it('handles portal with reactive content', () => {
145
- function TestReactivePortal() {
146
- return <>
147
- let &[count] = track(0);
148
- <Portal target={document.body}>
149
- <div class="test-portal">
150
- {'Count: '}
151
- {String(count)}
152
- <button onClick={() => count++}>{'Increment'}</button>
153
- </div>
154
- </Portal>
155
- </>;
141
+ function TestReactivePortal() @{
142
+ let &[count] = track(0);
143
+ <Portal target={document.body}>
144
+ <div class="test-portal">
145
+ {'Count: '}
146
+ {String(count)}
147
+ <button onClick={() => count++}>{'Increment'}</button>
148
+ </div>
149
+ </Portal>
156
150
  }
157
151
 
158
152
  render(TestReactivePortal);