ripple 0.3.72 → 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 +66 -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 +55 -61
  23. package/tests/client/basic/basic.components.test.tsrx +196 -218
  24. package/tests/client/basic/basic.errors.test.tsrx +70 -76
  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 +357 -288
  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 +286 -292
  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 +390 -319
  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 -258
  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 +117 -162
  143. package/tests/server/basic.components.test.tsrx +163 -193
  144. package/tests/server/basic.test.tsrx +298 -198
  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
@@ -3,15 +3,17 @@ import { compile } from '@tsrx/ripple';
3
3
  describe('CSS :global scoping verification', () => {
4
4
  it('verifies scoped styles are isolated', () => {
5
5
  const source = `
6
- export function Test() { return <>
7
- <div class="scoped">{'content'}</div>
6
+ export function Test() @{
7
+ <>
8
+ <div class="scoped">{'content'}</div>
8
9
 
9
- <style>
10
- .scoped {
11
- color: red;
12
- }
13
- </style>
14
- </>; }`;
10
+ <style>
11
+ .scoped {
12
+ color: red;
13
+ }
14
+ </style>
15
+ </>
16
+ }`;
15
17
  const { css } = compile(source, 'test.tsrx');
16
18
 
17
19
  expect(css).toMatch(/\.scoped\.tsrx-[a-z0-9]+/);
@@ -20,15 +22,17 @@ export function Test() { return <>
20
22
 
21
23
  it('verifies :global styles bypass scoping', () => {
22
24
  const source = `
23
- export function Test() { return <>
24
- <div class="global">{'content'}</div>
25
+ export function Test() @{
26
+ <>
27
+ <div class="global">{'content'}</div>
25
28
 
26
- <style>
27
- :global(.global) {
28
- color: red;
29
- }
30
- </style>
31
- </>; }`;
29
+ <style>
30
+ :global(.global) {
31
+ color: red;
32
+ }
33
+ </style>
34
+ </>
35
+ }`;
32
36
  const { css } = compile(source, 'test.tsrx');
33
37
 
34
38
  expect(css).toContain('.global {');
@@ -37,33 +41,35 @@ export function Test() { return <>
37
41
 
38
42
  it('verifies mixed local and global maintain proper scoping', () => {
39
43
  const source = `
40
- export function Test() { return <>
41
- <div class="outer">
42
- <span class="inner">{'content'}</span>
43
- </div>
44
-
45
- <style>
46
- .outer {
47
- color: red;
48
- }
44
+ export function Test() @{
45
+ <>
46
+ <div class="outer">
47
+ <span class="inner">{'content'}</span>
48
+ </div>
49
+
50
+ <style>
51
+ .outer {
52
+ color: red;
53
+ }
49
54
 
50
- :global(.outer) {
51
- color: blue;
52
- }
55
+ :global(.outer) {
56
+ color: blue;
57
+ }
53
58
 
54
- .outer .inner {
55
- color: green;
56
- }
59
+ .outer .inner {
60
+ color: green;
61
+ }
57
62
 
58
- :global(.outer) .inner {
59
- color: yellow;
60
- }
63
+ :global(.outer) .inner {
64
+ color: yellow;
65
+ }
61
66
 
62
- .outer :global(.inner) {
63
- color: purple;
64
- }
65
- </style>
66
- </>; }`;
67
+ .outer :global(.inner) {
68
+ color: purple;
69
+ }
70
+ </style>
71
+ </>
72
+ }`;
67
73
  const { css } = compile(source, 'test.tsrx');
68
74
 
69
75
  expect(css).toMatch(/\.outer\.tsrx-[a-z0-9]+ {/);
@@ -75,29 +81,31 @@ export function Test() { return <>
75
81
 
76
82
  it('verifies :global blocks scope all nested selectors globally', () => {
77
83
  const source = `
78
- export function Test() { return <>
79
- <div>
80
- <span>
81
- <button>{'click'}</button>
82
- </span>
83
- </div>
84
-
85
- <style>
86
- :global {
87
- div {
88
- color: red;
89
- }
90
-
91
- span {
92
- color: blue;
93
- }
94
-
95
- button {
96
- color: green;
84
+ export function Test() @{
85
+ <>
86
+ <div>
87
+ <span>
88
+ <button>{'click'}</button>
89
+ </span>
90
+ </div>
91
+
92
+ <style>
93
+ :global {
94
+ div {
95
+ color: red;
96
+ }
97
+
98
+ span {
99
+ color: blue;
100
+ }
101
+
102
+ button {
103
+ color: green;
104
+ }
97
105
  }
98
- }
99
- </style>
100
- </>; }`;
106
+ </style>
107
+ </>
108
+ }`;
101
109
  const { css } = compile(source, 'test.tsrx');
102
110
 
103
111
  expect(css).toContain('div {');
@@ -110,27 +118,29 @@ export function Test() { return <>
110
118
 
111
119
  it('verifies element selectors are scoped by default', () => {
112
120
  const source = `
113
- export function Test() { return <>
114
- <div>
115
- <span>
116
- <button>{'click'}</button>
117
- </span>
118
- </div>
119
-
120
- <style>
121
- div {
122
- color: red;
123
- }
121
+ export function Test() @{
122
+ <>
123
+ <div>
124
+ <span>
125
+ <button>{'click'}</button>
126
+ </span>
127
+ </div>
128
+
129
+ <style>
130
+ div {
131
+ color: red;
132
+ }
124
133
 
125
- span {
126
- color: blue;
127
- }
134
+ span {
135
+ color: blue;
136
+ }
128
137
 
129
- button {
130
- color: green;
131
- }
132
- </style>
133
- </>; }`;
138
+ button {
139
+ color: green;
140
+ }
141
+ </style>
142
+ </>
143
+ }`;
134
144
  const { css } = compile(source, 'test.tsrx');
135
145
 
136
146
  expect(css).toMatch(/div\.tsrx-[a-z0-9]+/);
@@ -140,19 +150,21 @@ export function Test() { return <>
140
150
 
141
151
  it('verifies :global() escapes only the wrapped selector', () => {
142
152
  const source = `
143
- export function Test() { return <>
144
- <div class="local">
145
- <span class="global">
146
- <button class="local">{'click'}</button>
147
- </span>
148
- </div>
149
-
150
- <style>
151
- .local :global(.global .local) {
152
- color: red;
153
- }
154
- </style>
155
- </>; }`;
153
+ export function Test() @{
154
+ <>
155
+ <div class="local">
156
+ <span class="global">
157
+ <button class="local">{'click'}</button>
158
+ </span>
159
+ </div>
160
+
161
+ <style>
162
+ .local :global(.global .local) {
163
+ color: red;
164
+ }
165
+ </style>
166
+ </>
167
+ }`;
156
168
  const { css } = compile(source, 'test.tsrx');
157
169
 
158
170
  expect(css).toMatch(/\.local\.tsrx-[a-z0-9]+ \.global \.local {/);
@@ -161,25 +173,29 @@ export function Test() { return <>
161
173
 
162
174
  it('verifies multiple components have different scope hashes', () => {
163
175
  const source1 = `
164
- export function Test1() { return <>
165
- <div class="test">{'one'}</div>
176
+ export function Test1() @{
177
+ <>
178
+ <div class="test">{'one'}</div>
166
179
 
167
- <style>
168
- .test {
169
- color: red;
170
- }
171
- </style>
172
- </>; }`;
180
+ <style>
181
+ .test {
182
+ color: red;
183
+ }
184
+ </style>
185
+ </>
186
+ }`;
173
187
  const source2 = `
174
- export function Test2() { return <>
175
- <div class="test">{'two'}</div>
188
+ export function Test2() @{
189
+ <>
190
+ <div class="test">{'two'}</div>
176
191
 
177
- <style>
178
- .test {
179
- color: blue;
180
- }
181
- </style>
182
- </>; }`;
192
+ <style>
193
+ .test {
194
+ color: blue;
195
+ }
196
+ </style>
197
+ </>
198
+ }`;
183
199
  const { css: css1 } = compile(source1, 'test1.tsrx');
184
200
  const { css: css2 } = compile(source2, 'test2.tsrx');
185
201
 
@@ -199,25 +215,29 @@ export function Test2() { return <>
199
215
 
200
216
  it('verifies :global styles are consistent across components', () => {
201
217
  const source1 = `
202
- export function Test1() { return <>
203
- <div class="global">{'one'}</div>
218
+ export function Test1() @{
219
+ <>
220
+ <div class="global">{'one'}</div>
204
221
 
205
- <style>
206
- :global(.global) {
207
- color: red;
208
- }
209
- </style>
210
- </>; }`;
222
+ <style>
223
+ :global(.global) {
224
+ color: red;
225
+ }
226
+ </style>
227
+ </>
228
+ }`;
211
229
  const source2 = `
212
- export function Test2() { return <>
213
- <div class="global">{'two'}</div>
230
+ export function Test2() @{
231
+ <>
232
+ <div class="global">{'two'}</div>
214
233
 
215
- <style>
216
- :global(.global) {
217
- color: blue;
218
- }
219
- </style>
220
- </>; }`;
234
+ <style>
235
+ :global(.global) {
236
+ color: blue;
237
+ }
238
+ </style>
239
+ </>
240
+ }`;
221
241
  const { css: css1 } = compile(source1, 'test1.tsrx');
222
242
  const { css: css2 } = compile(source2, 'test2.tsrx');
223
243
 
@@ -10,18 +10,18 @@ const external_styles = <style>
10
10
  describe('style class maps', () => {
11
11
  describe('basic usage with components', () => {
12
12
  it('passes scoped classes to a child component via a style expression', () => {
13
- function Child({ className }: { className: string }) {
14
- return <><div class={className}>{'styled child'}</div></>;
13
+ function Child({ className }: { className: string }) @{
14
+ <div class={className}>{'styled child'}</div>
15
15
  }
16
16
 
17
- function Parent() {
17
+ function Parent() @{
18
18
  const styles = <style>
19
19
  .highlight {
20
20
  color: red;
21
21
  }
22
22
  </style>;
23
23
 
24
- return <><Child className={styles.highlight} /></>;
24
+ <Child className={styles.highlight} />
25
25
  }
26
26
 
27
27
  render(Parent);
@@ -35,14 +35,14 @@ describe('style class maps', () => {
35
35
  });
36
36
 
37
37
  it('passes multiple style expression classes to a child component', () => {
38
- function Child({ primary, secondary }: { primary: string; secondary: string }) {
39
- return <>
38
+ function Child({ primary, secondary }: { primary: string; secondary: string }) @{
39
+ <>
40
40
  <div class={primary}>{'primary'}</div>
41
41
  <span class={secondary}>{'secondary'}</span>
42
- </>;
42
+ </>
43
43
  }
44
44
 
45
- function Parent() {
45
+ function Parent() @{
46
46
  const styles = <style>
47
47
  .primary {
48
48
  color: blue;
@@ -52,7 +52,7 @@ describe('style class maps', () => {
52
52
  }
53
53
  </style>;
54
54
 
55
- return <><Child primary={styles.primary} secondary={styles.secondary} /></>;
55
+ <Child primary={styles.primary} secondary={styles.secondary} />
56
56
  }
57
57
 
58
58
  render(Parent);
@@ -74,42 +74,38 @@ describe('style class maps', () => {
74
74
 
75
75
  it('allows style expression classes on child components with children', () => {
76
76
  const source = `
77
- function Child({ className }) { return <>
77
+ function Child({ className }) @{
78
78
  <div class={className}>"hello world"</div>
79
- </>; }
80
- function App() {
79
+ }
80
+ function App() @{
81
81
  const styles = <style>
82
82
  .container {
83
83
  color: red;
84
84
  }
85
85
  </style>;
86
86
 
87
- return <>
88
87
  <Child className={styles.container}>"hello world"</Child>
89
- </>;
90
88
  }`;
91
89
 
92
90
  expect(() => compile(source, 'test.tsrx')).not.toThrow();
93
91
  });
94
92
 
95
93
  it('passes scoped classes to a dynamic child component via a style expression', () => {
96
- function Child({ cls }: { cls: string }) {
97
- return <><span class={cls}>{'text'}</span></>;
94
+ function Child({ cls }: { cls: string }) @{
95
+ <span class={cls}>{'text'}</span>
98
96
  }
99
97
 
100
- function Parent() {
98
+ function Parent() @{
101
99
  const styles = <style>
102
100
  .text {
103
101
  color: red;
104
102
  }
105
103
  </style>;
106
104
 
107
- return <>
108
- let dynamic = track(() => Child);
109
- <div class="wrapper">
110
- <@dynamic cls={styles.text} />
111
- </div>
112
- </>;
105
+ let dynamic = track(() => Child);
106
+ <div class="wrapper">
107
+ <@dynamic cls={styles.text} />
108
+ </div>
113
109
  }
114
110
 
115
111
  render(Parent);
@@ -122,12 +118,12 @@ function App() {
122
118
  });
123
119
 
124
120
  it('passes style expression classes declared outside the component', () => {
125
- function Child({ cls }: { cls: string }) {
126
- return <><span class={cls}>{'text'}</span></>;
121
+ function Child({ cls }: { cls: string }) @{
122
+ <span class={cls}>{'text'}</span>
127
123
  }
128
124
 
129
- function Parent() {
130
- return <Child cls={external_styles.external} />;
125
+ function Parent() @{
126
+ <Child cls={external_styles.external} />
131
127
  }
132
128
 
133
129
  render(Parent);
@@ -140,25 +136,25 @@ function App() {
140
136
  });
141
137
 
142
138
  it('child can combine its own classes with a parent style expression class', () => {
143
- function Card({ className }: { className?: string }) {
144
- return <>
139
+ function Card({ className }: { className?: string }) @{
140
+ <>
145
141
  <div class={['card-base', className ?? '']}>{'card content'}</div>
146
142
  <style>
147
143
  .card-base {
148
144
  border: 1px solid black;
149
145
  }
150
146
  </style>
151
- </>;
147
+ </>
152
148
  }
153
149
 
154
- function App() {
150
+ function App() @{
155
151
  const styles = <style>
156
152
  .themed {
157
153
  background: purple;
158
154
  }
159
155
  </style>;
160
156
 
161
- return <><Card className={styles.themed} /></>;
157
+ <Card className={styles.themed} />
162
158
  }
163
159
 
164
160
  render(App);
@@ -171,11 +167,11 @@ function App() {
171
167
  });
172
168
 
173
169
  it('passes a standalone class even when it also appears in descendant context', () => {
174
- function Child({ cls }: { cls: string }) {
175
- return <><span class={cls}>{'text'}</span></>;
170
+ function Child({ cls }: { cls: string }) @{
171
+ <span class={cls}>{'text'}</span>
176
172
  }
177
173
 
178
- function App() {
174
+ function App() @{
179
175
  const styles = <style>
180
176
  .dual {
181
177
  color: blue;
@@ -185,11 +181,9 @@ function App() {
185
181
  }
186
182
  </style>;
187
183
 
188
- return <>
189
- <div class="parent">
190
- <Child cls={styles.dual} />
191
- </div>
192
- </>;
184
+ <div class="parent">
185
+ <Child cls={styles.dual} />
186
+ </div>
193
187
  }
194
188
 
195
189
  render(App);
@@ -205,30 +199,33 @@ function App() {
205
199
  describe('removed syntax', () => {
206
200
  it('does not parse the old style directive in attributes', () => {
207
201
  const source = `
208
- function Child({ cls }) { return <>
202
+ function Child({ cls }) @{
209
203
  <div class={cls}>{'text'}</div>
210
- </>; }
211
- function App() { return <>
212
- <Child cls={style 'highlight'} />
213
-
214
- <style>
215
- .highlight {
216
- color: red;
217
- }
218
- </style>
219
- </>; }`;
204
+ }
205
+ function App() @{
206
+ <>
207
+ <Child cls={style 'highlight'} />
208
+ <style>
209
+ .highlight {
210
+ color: red;
211
+ }
212
+ </style>
213
+ </>
214
+ }`;
220
215
  expect(() => compile(source, 'test.tsrx')).toThrow();
221
216
  });
222
217
 
223
218
  it('does not parse the old style directive as a child expression', () => {
224
- const source = `function App() { return <>
225
- <div>{style 'foo'}</div>
226
- <style>
227
- .foo {
228
- color: red;
229
- }
230
- </style>
231
- </>; }`;
219
+ const source = `function App() @{
220
+ <>
221
+ <div>{style 'foo'}</div>
222
+ <style>
223
+ .foo {
224
+ color: red;
225
+ }
226
+ </style>
227
+ </>
228
+ }`;
232
229
  expect(() => compile(source, 'test.tsrx')).toThrow();
233
230
  });
234
231
  });
@@ -236,19 +233,17 @@ function App() { return <>
236
233
  describe('compiler output', () => {
237
234
  it('emits style class maps for client mode', () => {
238
235
  const source = `
239
- function Child({ cls }) { return <>
236
+ function Child({ cls }) @{
240
237
  <div class={cls}>{'text'}</div>
241
- </>; }
242
- export function App() {
238
+ }
239
+ export function App() @{
243
240
  const styles = <style>
244
241
  .highlight {
245
242
  color: red;
246
243
  }
247
244
  </style>;
248
245
 
249
- return <>
250
246
  <Child cls={styles.highlight} />
251
- </>;
252
247
  }`;
253
248
  const { code } = compile(source, 'test.tsrx');
254
249
 
@@ -258,19 +253,17 @@ export function App() {
258
253
 
259
254
  it('emits style class maps for server mode', () => {
260
255
  const source = `
261
- function Child({ cls }) { return <>
256
+ function Child({ cls }) @{
262
257
  <div class={cls}>{'text'}</div>
263
- </>; }
264
- export function App() {
258
+ }
259
+ export function App() @{
265
260
  const styles = <style>
266
261
  .highlight {
267
262
  color: red;
268
263
  }
269
264
  </style>;
270
265
 
271
- return <>
272
266
  <Child cls={styles.highlight} />
273
- </>;
274
267
  }`;
275
268
  const { code } = compile(source, 'test.tsrx', { mode: 'server' });
276
269