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,397 +2,327 @@
2
2
  import { track } from 'ripple';
3
3
  import type { Children } from 'ripple';
4
4
 
5
- export function StaticText() {
6
- return <><div>{'Hello World'}</div></>;
5
+ export function StaticText() @{
6
+ <div>{'Hello World'}</div>
7
7
  }
8
8
 
9
- export function MultipleElements() {
10
- return <>
9
+ export function MultipleElements() @{
10
+ <>
11
11
  <h1>{'Title'}</h1>
12
12
  <p>{'Paragraph text'}</p>
13
13
  <span>{'Span text'}</span>
14
- </>;
14
+ </>
15
15
  }
16
16
 
17
- export function NestedElements() {
18
- return <>
19
- <div class="outer">
20
- <div class="inner">
21
- <span>{'Nested content'}</span>
22
- </div>
17
+ export function NestedElements() @{
18
+ <div class="outer">
19
+ <div class="inner">
20
+ <span>{'Nested content'}</span>
23
21
  </div>
24
- </>;
22
+ </div>
25
23
  }
26
24
 
27
- export function WithAttributes() {
28
- return <>
25
+ export function WithAttributes() @{
26
+ <>
29
27
  <input type="text" placeholder="Enter text" disabled />
30
28
  <a href="/link" target="_blank">{'Link'}</a>
31
- </>;
29
+ </>
32
30
  }
33
31
 
34
- export function ChildComponent() {
35
- return <><span class="child">{'Child content'}</span></>;
32
+ export function ChildComponent() @{
33
+ <span class="child">{'Child content'}</span>
36
34
  }
37
35
 
38
- export function ParentWithChild() {
39
- return <>
40
- <div class="parent">
41
- <ChildComponent />
42
- </div>
43
- </>;
36
+ export function ParentWithChild() @{
37
+ <div class="parent">
38
+ <ChildComponent />
39
+ </div>
44
40
  }
45
41
 
46
- export function FirstSibling() {
47
- return <><div class="first">{'First'}</div></>;
42
+ export function FirstSibling() @{
43
+ <div class="first">{'First'}</div>
48
44
  }
49
45
 
50
- export function SecondSibling() {
51
- return <><div class="second">{'Second'}</div></>;
46
+ export function SecondSibling() @{
47
+ <div class="second">{'Second'}</div>
52
48
  }
53
49
 
54
- export function SiblingComponents() {
55
- return <>
50
+ export function SiblingComponents() @{
51
+ <>
56
52
  <FirstSibling />
57
53
  <SecondSibling />
58
- </>;
54
+ </>
59
55
  }
60
56
 
61
- export function Greeting(props: { name: string }) {
62
- return <>
63
- <div>
64
- {'Hello '}
65
- {props.name}
66
- </div>
67
- </>;
57
+ export function Greeting(props: { name: string }) @{
58
+ <div>
59
+ {'Hello '}
60
+ {props.name}
61
+ </div>
68
62
  }
69
63
 
70
- export function WithGreeting() {
71
- return <><Greeting name="World" /></>;
64
+ export function WithGreeting() @{
65
+ <Greeting name="World" />
72
66
  }
73
67
 
74
- export function ExpressionContent() {
75
- return <>
76
- const value = 42;
77
- const label = 'computed';
68
+ export function ExpressionContent() @{
69
+ const value = 42;
70
+ const label = 'computed';
71
+ <>
78
72
  <div>{value}</div>
79
73
  <span>{label.toUpperCase()}</span>
80
- </>;
74
+ </>
81
75
  }
82
76
 
83
- function NestedHelperItem({ item }: { item: number }) {
84
- return <><div class="helper-item">{item}</div></>;
77
+ function NestedHelperItem({ item }: { item: number }) @{
78
+ <div class="helper-item">{item}</div>
85
79
  }
86
80
 
87
- function NestedTsxTsrxFragment({ label }: { label: string }) {
88
- return <>
81
+ function NestedTsxTsrxFragment({ label }: { label: string }) @{
82
+ <>
89
83
  <span class="label">{label}</span>
90
- for (const item of [1, 2, 3, 4]) {
84
+ @for (const item of [1, 2, 3, 4]) {
91
85
  <NestedHelperItem {item} />
92
86
  }
93
- </>;
87
+ </>
94
88
  }
95
89
 
96
- export function NestedTsxTsrxExpressionValues() {
97
- return <>
98
- for (const item of [1, 2, 3]) {
90
+ export function NestedTsxTsrxExpressionValues() @{
91
+ <div class="nested-expression-values">
92
+ @for (const item of [1, 2, 3]) {
99
93
  <div class="app-item">{item}</div>
100
94
  }
101
95
  <NestedTsxTsrxFragment label="from helper" />
102
- </>;
103
- }
104
-
105
- export function MixedTsrxCollectionText() {
106
- return <>
107
- const content = <tsx>
108
- {[
109
- 'alpha ',
110
- <strong class="middle">
111
- {'beta'}
112
- </strong>,
113
- ' gamma ',
114
- [
115
- 'delta ',
116
- <em class="tail">
117
- {'epsilon'}
118
- </em>,
119
- ' zeta',
120
- ],
121
- ]}
122
- </tsx>;
123
- <div class="mixed-collection">{content}</div>
124
- </>;
125
- }
126
-
127
- export function MixedTsrxCollectionSplitServerText() {
128
- return <>
129
- const content = <tsx>
130
- {[
131
- 'alpha ',
132
- <strong class="middle">
133
- {'beta'}
134
- </strong>,
135
- ' gamma ',
136
- [
137
- 'delta ',
138
- <em class="tail">
139
- {'epsilon'}
140
- </em>,
141
- ' zeta',
142
- ],
143
- ]}
144
- </tsx>;
145
- <div class="mixed-collection-split">{content}</div>
146
- </>;
147
- }
148
-
149
- export function MixedTsrxCollectionSplitClientText() {
150
- return <>
151
- const content = <tsx>
152
- {[
153
- 'alpha ',
154
- <strong class="middle">
155
- {'beta'}
156
- </strong>,
157
- ' gamma ',
158
- [
159
- 'changed ',
160
- <em class="tail">
161
- {'epsilon'}
162
- </em>,
163
- ' zeta',
164
- ],
165
- ]}
166
- </tsx>;
167
- <div class="mixed-collection-split">{content}</div>
168
- </>;
169
- }
170
-
171
- export function MixedTsrxCollectionPrimitiveServerText() {
172
- return <>
173
- const content = <tsx>
174
- {[
175
- 'count: ',
176
- 1,
177
- ' / ',
178
- true,
179
- <span class="primitive-tail">
180
- {' ok'}
181
- </span>,
182
- ]}
183
- </tsx>;
184
- <div class="mixed-collection-primitive">{content}</div>
185
- </>;
186
- }
187
-
188
- export function MixedTsrxCollectionPrimitiveClientText() {
189
- return <>
190
- const content = <tsx>
191
- {[
192
- 'count: ',
193
- 2,
194
- ' / ',
195
- false,
196
- <span class="primitive-tail">
197
- {' ok'}
198
- </span>,
199
- ]}
200
- </tsx>;
201
- <div class="mixed-collection-primitive">{content}</div>
202
- </>;
96
+ </div>
97
+ }
98
+
99
+ export function MixedTsrxCollectionText() @{
100
+ const content = <>
101
+ {[
102
+ 'alpha ',
103
+ <strong class="middle">{'beta'}</strong>,
104
+ ' gamma ',
105
+ [
106
+ 'delta ',
107
+ <em class="tail">{'epsilon'}</em>,
108
+ ' zeta',
109
+ ],
110
+ ]}
111
+ </>;
112
+ <div class="mixed-collection">{content}</div>
113
+ }
114
+
115
+ export function MixedTsrxCollectionSplitServerText() @{
116
+ const content = <>
117
+ {[
118
+ 'alpha ',
119
+ <strong class="middle">{'beta'}</strong>,
120
+ ' gamma ',
121
+ [
122
+ 'delta ',
123
+ <em class="tail">{'epsilon'}</em>,
124
+ ' zeta',
125
+ ],
126
+ ]}
127
+ </>;
128
+ <div class="mixed-collection-split">{content}</div>
129
+ }
130
+
131
+ export function MixedTsrxCollectionSplitClientText() @{
132
+ const content = <>
133
+ {[
134
+ 'alpha ',
135
+ <strong class="middle">{'beta'}</strong>,
136
+ ' gamma ',
137
+ [
138
+ 'changed ',
139
+ <em class="tail">{'epsilon'}</em>,
140
+ ' zeta',
141
+ ],
142
+ ]}
143
+ </>;
144
+ <div class="mixed-collection-split">{content}</div>
145
+ }
146
+
147
+ export function MixedTsrxCollectionPrimitiveServerText() @{
148
+ const content = <>
149
+ {[
150
+ 'count: ',
151
+ 1,
152
+ ' / ',
153
+ true,
154
+ <span class="primitive-tail">{' ok'}</span>,
155
+ ]}
156
+ </>;
157
+ <div class="mixed-collection-primitive">{content}</div>
158
+ }
159
+
160
+ export function MixedTsrxCollectionPrimitiveClientText() @{
161
+ const content = <>
162
+ {[
163
+ 'count: ',
164
+ 2,
165
+ ' / ',
166
+ false,
167
+ <span class="primitive-tail">{' ok'}</span>,
168
+ ]}
169
+ </>;
170
+ <div class="mixed-collection-primitive">{content}</div>
203
171
  }
204
172
 
205
173
  function createPrimitiveItems() {
206
174
  return ['start:', ['one', 2], true, null, false, ':end'];
207
175
  }
208
176
 
209
- export function DynamicArrayFromCall() {
210
- return <>
211
- const items = createPrimitiveItems();
212
- <div class="dynamic-array-call">{items}</div>
213
- </>;
177
+ export function DynamicArrayFromCall() @{
178
+ const items = createPrimitiveItems();
179
+ <div class="dynamic-array-call">{items}</div>
214
180
  }
215
181
 
216
- export function DynamicArrayFromTrack() {
217
- return <>
218
- let &[items] = track(['start:', ['one', 2], true, null, false, ':end']);
219
- <div class="dynamic-array-track">{items}</div>
220
- </>;
182
+ export function DynamicArrayFromTrack() @{
183
+ let &[items] = track(['start:', ['one', 2], true, null, false, ':end']);
184
+ <div class="dynamic-array-track">{items}</div>
221
185
  }
222
186
 
223
- export function DynamicArrayFromConditional() {
224
- return <>
225
- const condition = true;
226
- const items = condition ? ['start:', ['one', 2], true, null, false, ':end'] : ['fallback'];
227
- <div class="dynamic-array-conditional">{items}</div>
228
- </>;
187
+ export function DynamicArrayFromConditional() @{
188
+ const condition = true;
189
+ const items = condition ? ['start:', ['one', 2], true, null, false, ':end'] : ['fallback'];
190
+ <div class="dynamic-array-conditional">{items}</div>
229
191
  }
230
192
 
231
- export function DynamicArrayFromLogical() {
232
- return <>
233
- const condition = true;
234
- const items = condition && ['start:', ['one', 2], true, null, false, ':end'];
235
- <div class="dynamic-array-logical">{items}</div>
236
- </>;
193
+ export function DynamicArrayFromLogical() @{
194
+ const condition = true;
195
+ const items = condition && ['start:', ['one', 2], true, null, false, ':end'];
196
+ <div class="dynamic-array-logical">{items}</div>
237
197
  }
238
198
 
239
- export function NestedTsrxInsideTopLevelTsxExpression() {
240
- return <>
241
- const content = <tsx>
242
- <section class="outer">
243
- {<>
244
- <div class="inner">
245
- {'from tsrx'}
246
- </div>
247
- </>}
248
- </section>
249
- </tsx>;
250
- {content}
199
+ export function NestedTsrxInsideTopLevelTsxExpression() @{
200
+ const content = <>
201
+ <section class="outer">
202
+ <div class="inner">{'from tsrx'}</div>
203
+ </section>
251
204
  </>;
205
+ <>
206
+ {content}
207
+ </>
252
208
  }
253
209
 
254
- export function NestedTsrxElementsInsideTopLevelTsxValue() {
255
- return <>
256
- const content = <tsx>
257
- <div class="wrapper">
258
- {<>
259
- <section class="native">
260
- <span class="nested-tsrx">
261
- {'inside nested tsrx'}
262
- </span>
263
- </section>
264
- </>}
265
- </div>
266
- </tsx>;
267
- {content}
210
+ export function NestedTsrxElementsInsideTopLevelTsxValue() @{
211
+ const content = <>
212
+ <div class="wrapper">
213
+ <section class="native">
214
+ <span class="nested-tsrx">{'inside nested tsrx'}</span>
215
+ </section>
216
+ </div>
268
217
  </>;
218
+ <>
219
+ {content}
220
+ </>
269
221
  }
270
222
 
271
- export function TsxDeclaredBeforeTopLevelTsx() {
272
- return <>
273
- const nested = <tsx>
274
- <span class="nested-tsx">
275
- {'inside nested tsx'}
276
- </span>
277
- </tsx>;
278
- const content = <tsx>
279
- <div class="native">{nested}</div>
280
- </tsx>;
223
+ export function TsxDeclaredBeforeTopLevelTsx() @{
224
+ const nested = <span class="nested-tsx">inside nested tsx</span>;
225
+ const content = <><div class="native">{nested}</div></>;
226
+ <>
281
227
  {content}
282
- </>;
228
+ </>
283
229
  }
284
230
 
285
- function TextProp(&{ children }: { children: string }) {
286
- return <><div class="text-prop">{children}</div></>;
231
+ function TextProp(&{ children }: { children: string }) @{
232
+ <div class="text-prop">{children}</div>
287
233
  }
288
234
 
289
- export function TextPropWithToggle() {
290
- return <>
291
- let &[show] = track(false);
235
+ export function TextPropWithToggle() @{
236
+ let &[show] = track(false);
237
+ <>
292
238
  <TextProp children={show ? 'hello' : ''} />
293
239
  <button class="show-text" onClick={() => (show = true)}>{'Show'}</button>
294
- </>;
240
+ </>
295
241
  }
296
242
 
297
243
  // Test for static content in child component followed by sibling content
298
- function StaticHeader() {
299
- return <>
244
+ function StaticHeader() @{
245
+ <>
300
246
  <h1 class="sr-only">{'heading'}</h1>
301
247
  <p class="subtitle">{'first paragraph'}</p>
302
248
  <p class="subtitle">{'second paragraph'}</p>
303
- </>;
249
+ </>
304
250
  }
305
251
 
306
- export function StaticChildWithSiblings() {
307
- return <>
308
- const foo = 'bar';
252
+ export function StaticChildWithSiblings() @{
253
+ const foo = 'bar';
254
+ <>
309
255
  <StaticHeader />
310
256
  <span class="sibling1">{foo}</span>
311
257
  <span class="sibling2">{foo}</span>
312
- </>;
258
+ </>
313
259
  }
314
260
 
315
261
  // Website-like components for testing complex hydration scenarios
316
262
 
317
- function Header() {
318
- return <>
263
+ function Header() @{
264
+ <>
319
265
  <h1 class="sr-only">{'Ripple'}</h1>
320
266
  <img src="/images/logo.png" alt="Logo" class="logo" />
321
267
  <p class="subtitle">{'the elegant TypeScript UI framework'}</p>
322
- </>;
268
+ </>
323
269
  }
324
270
 
325
- function Actions({ playgroundVisible = false }: { playgroundVisible: boolean }) {
326
- return <>
327
- <div class="social-links">
328
- <a href="https://github.com" class="github-link">{'GitHub'}</a>
329
- <a href="https://discord.com" class="discord-link">{'Discord'}</a>
330
- if (playgroundVisible) {
331
- <a href="/playground" class="playground-link">{'Playground'}</a>
332
- }
333
- </div>
334
- </>;
271
+ function Actions({ playgroundVisible = false }: { playgroundVisible: boolean }) @{
272
+ <div class="social-links">
273
+ <a href="https://github.com" class="github-link">{'GitHub'}</a>
274
+ <a href="https://discord.com" class="discord-link">{'Discord'}</a>
275
+ {playgroundVisible ? <a href="/playground" class="playground-link">{'Playground'}</a> : null}
276
+ </div>
335
277
  }
336
278
 
337
- function Layout({ children }: { children: Children }) {
338
- return <>
339
- <main>
340
- <div class="container">{children}</div>
341
- </main>
342
- </>;
279
+ function Layout({ children }: { children: Children }) @{
280
+ <main>
281
+ <div class="container">{children}</div>
282
+ </main>
343
283
  }
344
284
 
345
- function Content() {
346
- return <>
347
- <div class="content">
348
- <p>{'Some content here'}</p>
349
- </div>
350
- </>;
285
+ function Content() @{
286
+ <div class="content">
287
+ <p>{'Some content here'}</p>
288
+ </div>
351
289
  }
352
290
 
353
- export function WebsiteIndex() {
354
- return <>
355
- <Layout>
356
- <Header />
357
- <Actions playgroundVisible={true} />
358
- <Content />
359
- <Actions playgroundVisible={false} />
360
- </Layout>
361
- </>;
291
+ export function WebsiteIndex() @{
292
+ <Layout>
293
+ <Header />
294
+ <Actions playgroundVisible={true} />
295
+ <Content />
296
+ <Actions playgroundVisible={false} />
297
+ </Layout>
362
298
  }
363
299
 
364
300
  // Test case for component as last element with no following siblings.
365
301
  // This exercises hydrate_advance() in append() - at the end of content,
366
302
  // there's no next sibling and that should be handled gracefully.
367
- function LastChild() {
368
- return <><footer class="last-child">{'I am the last child'}</footer></>;
303
+ function LastChild() @{
304
+ <footer class="last-child">{'I am the last child'}</footer>
369
305
  }
370
306
 
371
- export function ComponentAsLastSibling() {
372
- return <>
373
- <div class="wrapper">
374
- <h1>{'Header'}</h1>
375
- <p>{'Some content'}</p>
376
- <LastChild />
377
- </div>
378
- </>;
307
+ export function ComponentAsLastSibling() @{
308
+ <div class="wrapper">
309
+ <h1>{'Header'}</h1>
310
+ <p>{'Some content'}</p>
311
+ <LastChild />
312
+ </div>
379
313
  }
380
314
 
381
315
  // Nested version - component is last child inside another component
382
- function InnerContent() {
383
- return <>
384
- <div class="inner">
385
- <span>{'Inner text'}</span>
386
- <LastChild />
387
- </div>
388
- </>;
389
- }
390
-
391
- export function NestedComponentAsLastSibling() {
392
- return <>
393
- <section class="outer">
394
- <h2>{'Section title'}</h2>
395
- <InnerContent />
396
- </section>
397
- </>;
316
+ function InnerContent() @{
317
+ <div class="inner">
318
+ <span>{'Inner text'}</span>
319
+ <LastChild />
320
+ </div>
321
+ }
322
+
323
+ export function NestedComponentAsLastSibling() @{
324
+ <section class="outer">
325
+ <h2>{'Section title'}</h2>
326
+ <InnerContent />
327
+ </section>
398
328
  }