ripple 0.3.68 → 0.3.70

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 (182) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/package.json +3 -3
  3. package/src/jsx-runtime.d.ts +2 -2
  4. package/src/runtime/element.js +1 -1
  5. package/src/runtime/index-client.js +11 -11
  6. package/src/runtime/index-server.js +7 -4
  7. package/src/runtime/internal/client/bindings.js +1 -1
  8. package/src/runtime/internal/client/blocks.js +13 -4
  9. package/src/runtime/internal/client/component.js +55 -0
  10. package/src/runtime/internal/client/composite.js +4 -2
  11. package/src/runtime/internal/client/expression.js +65 -7
  12. package/src/runtime/internal/client/hmr.js +54 -43
  13. package/src/runtime/internal/client/index.js +5 -1
  14. package/src/runtime/internal/client/portal.js +70 -69
  15. package/src/runtime/internal/client/render.js +3 -0
  16. package/src/runtime/internal/server/index.js +92 -8
  17. package/tests/client/__snapshots__/html.test.tsrx.snap +3 -3
  18. package/tests/client/array/array.copy-within.test.tsrx +33 -31
  19. package/tests/client/array/array.derived.test.tsrx +186 -169
  20. package/tests/client/array/array.iteration.test.tsrx +40 -37
  21. package/tests/client/array/array.mutations.test.tsrx +113 -101
  22. package/tests/client/array/array.static.test.tsrx +119 -101
  23. package/tests/client/array/array.to-methods.test.tsrx +24 -21
  24. package/tests/client/async-suspend.test.tsrx +247 -246
  25. package/tests/client/basic/__snapshots__/basic.rendering.test.tsrx.snap +0 -1
  26. package/tests/client/basic/basic.attributes.test.tsrx +428 -423
  27. package/tests/client/basic/basic.collections.test.tsrx +109 -102
  28. package/tests/client/basic/basic.components.test.tsrx +323 -205
  29. package/tests/client/basic/basic.errors.test.tsrx +91 -91
  30. package/tests/client/basic/basic.events.test.tsrx +114 -115
  31. package/tests/client/basic/basic.get-set.test.tsrx +97 -87
  32. package/tests/client/basic/basic.hmr.test.tsrx +19 -16
  33. package/tests/client/basic/basic.reactivity.test.tsrx +199 -191
  34. package/tests/client/basic/basic.rendering.test.tsrx +272 -182
  35. package/tests/client/basic/basic.styling.test.tsrx +23 -22
  36. package/tests/client/basic/basic.utilities.test.tsrx +10 -8
  37. package/tests/client/boundaries.test.tsrx +26 -26
  38. package/tests/client/compiler/__snapshots__/compiler.assignments.test.rsrx.snap +5 -5
  39. package/tests/client/compiler/__snapshots__/compiler.assignments.test.tsrx.snap +5 -5
  40. package/tests/client/compiler/compiler.assignments.test.tsrx +77 -81
  41. package/tests/client/compiler/compiler.attributes.test.tsrx +15 -15
  42. package/tests/client/compiler/compiler.basic.test.tsrx +322 -314
  43. package/tests/client/compiler/compiler.regex.test.tsrx +44 -47
  44. package/tests/client/compiler/compiler.tracked-access.test.tsrx +38 -38
  45. package/tests/client/compiler/compiler.try-in-function.test.tsrx +16 -16
  46. package/tests/client/compiler/compiler.typescript.test.tsrx +2 -2
  47. package/tests/client/composite/composite.dynamic-components.test.tsrx +47 -48
  48. package/tests/client/composite/composite.generics.test.tsrx +168 -192
  49. package/tests/client/composite/composite.props.test.tsrx +97 -81
  50. package/tests/client/composite/composite.reactivity.test.tsrx +177 -147
  51. package/tests/client/composite/composite.render.test.tsrx +122 -105
  52. package/tests/client/computed-properties.test.tsrx +28 -28
  53. package/tests/client/context.test.tsrx +21 -21
  54. package/tests/client/css/global-additional-cases.test.tsrx +58 -58
  55. package/tests/client/css/global-advanced-selectors.test.tsrx +16 -16
  56. package/tests/client/css/global-at-rules.test.tsrx +10 -10
  57. package/tests/client/css/global-basic.test.tsrx +14 -14
  58. package/tests/client/css/global-classes-ids.test.tsrx +14 -14
  59. package/tests/client/css/global-combinators.test.tsrx +10 -10
  60. package/tests/client/css/global-complex-nesting.test.tsrx +14 -14
  61. package/tests/client/css/global-edge-cases.test.tsrx +18 -18
  62. package/tests/client/css/global-keyframes.test.tsrx +12 -12
  63. package/tests/client/css/global-nested.test.tsrx +10 -10
  64. package/tests/client/css/global-pseudo.test.tsrx +12 -12
  65. package/tests/client/css/global-scoping.test.tsrx +20 -20
  66. package/tests/client/css/style-identifier.test.tsrx +126 -259
  67. package/tests/client/date.test.tsrx +146 -133
  68. package/tests/client/dynamic-elements.test.tsrx +398 -365
  69. package/tests/client/events.test.tsrx +292 -290
  70. package/tests/client/for.test.tsrx +156 -153
  71. package/tests/client/head.test.tsrx +105 -96
  72. package/tests/client/html.test.tsrx +122 -26
  73. package/tests/client/input-value.test.tsrx +1361 -1314
  74. package/tests/client/lazy-array.test.tsrx +16 -13
  75. package/tests/client/lazy-destructuring.test.tsrx +257 -213
  76. package/tests/client/map.test.tsrx +65 -60
  77. package/tests/client/media-query.test.tsrx +22 -20
  78. package/tests/client/object.test.tsrx +87 -81
  79. package/tests/client/portal.test.tsrx +57 -51
  80. package/tests/client/ref.test.tsrx +233 -202
  81. package/tests/client/return.test.tsrx +71 -2560
  82. package/tests/client/set.test.tsrx +54 -45
  83. package/tests/client/svg.test.tsrx +216 -186
  84. package/tests/client/switch.test.tsrx +194 -193
  85. package/tests/client/track-async-hydration.test.tsrx +18 -14
  86. package/tests/client/tracked-index-access.test.tsrx +28 -18
  87. package/tests/client/try.test.tsrx +675 -548
  88. package/tests/client/tsx.test.tsrx +373 -311
  89. package/tests/client/typescript-generics.test.tsrx +145 -145
  90. package/tests/client/url/url.derived.test.tsrx +33 -28
  91. package/tests/client/url/url.parsing.test.tsrx +61 -51
  92. package/tests/client/url/url.partial-removal.test.tsrx +56 -48
  93. package/tests/client/url/url.reactivity.test.tsrx +142 -125
  94. package/tests/client/url/url.serialization.test.tsrx +13 -11
  95. package/tests/client/url-search-params/url-search-params.derived.test.tsrx +34 -29
  96. package/tests/client/url-search-params/url-search-params.initialization.test.tsrx +25 -21
  97. package/tests/client/url-search-params/url-search-params.iteration.test.tsrx +50 -45
  98. package/tests/client/url-search-params/url-search-params.mutation.test.tsrx +111 -99
  99. package/tests/client/url-search-params/url-search-params.retrieval.test.tsrx +49 -43
  100. package/tests/client/url-search-params/url-search-params.serialization.test.tsrx +14 -12
  101. package/tests/client/url-search-params/url-search-params.tracked-url.test.tsrx +16 -14
  102. package/tests/hydration/basic.test.js +3 -3
  103. package/tests/hydration/compiled/client/basic.js +586 -651
  104. package/tests/hydration/compiled/client/composite.js +79 -104
  105. package/tests/hydration/compiled/client/events.js +140 -148
  106. package/tests/hydration/compiled/client/for.js +1005 -1018
  107. package/tests/hydration/compiled/client/head.js +124 -134
  108. package/tests/hydration/compiled/client/hmr.js +41 -48
  109. package/tests/hydration/compiled/client/html-in-template.js +38 -41
  110. package/tests/hydration/compiled/client/html.js +970 -1314
  111. package/tests/hydration/compiled/client/if-children.js +234 -249
  112. package/tests/hydration/compiled/client/if.js +182 -189
  113. package/tests/hydration/compiled/client/mixed-control-flow.js +347 -303
  114. package/tests/hydration/compiled/client/nested-control-flow.js +1084 -832
  115. package/tests/hydration/compiled/client/portal.js +65 -85
  116. package/tests/hydration/compiled/client/reactivity.js +84 -90
  117. package/tests/hydration/compiled/client/return.js +38 -1939
  118. package/tests/hydration/compiled/client/switch.js +218 -224
  119. package/tests/hydration/compiled/client/track-async-serialization.js +250 -259
  120. package/tests/hydration/compiled/client/try.js +123 -132
  121. package/tests/hydration/compiled/server/basic.js +773 -831
  122. package/tests/hydration/compiled/server/composite.js +166 -191
  123. package/tests/hydration/compiled/server/events.js +170 -184
  124. package/tests/hydration/compiled/server/for.js +851 -909
  125. package/tests/hydration/compiled/server/head.js +206 -216
  126. package/tests/hydration/compiled/server/hmr.js +64 -72
  127. package/tests/hydration/compiled/server/html-in-template.js +42 -76
  128. package/tests/hydration/compiled/server/html.js +1362 -1667
  129. package/tests/hydration/compiled/server/if-children.js +419 -445
  130. package/tests/hydration/compiled/server/if.js +194 -208
  131. package/tests/hydration/compiled/server/mixed-control-flow.js +249 -257
  132. package/tests/hydration/compiled/server/nested-control-flow.js +491 -515
  133. package/tests/hydration/compiled/server/portal.js +152 -160
  134. package/tests/hydration/compiled/server/reactivity.js +94 -106
  135. package/tests/hydration/compiled/server/return.js +28 -2172
  136. package/tests/hydration/compiled/server/switch.js +274 -286
  137. package/tests/hydration/compiled/server/track-async-serialization.js +340 -358
  138. package/tests/hydration/compiled/server/try.js +167 -185
  139. package/tests/hydration/components/basic.tsrx +320 -272
  140. package/tests/hydration/components/composite.tsrx +44 -32
  141. package/tests/hydration/components/events.tsrx +101 -91
  142. package/tests/hydration/components/for.tsrx +510 -452
  143. package/tests/hydration/components/head.tsrx +87 -80
  144. package/tests/hydration/components/hmr.tsrx +22 -17
  145. package/tests/hydration/components/html-in-template.tsrx +22 -17
  146. package/tests/hydration/components/html.tsrx +525 -443
  147. package/tests/hydration/components/if-children.tsrx +158 -148
  148. package/tests/hydration/components/if.tsrx +109 -95
  149. package/tests/hydration/components/mixed-control-flow.tsrx +100 -96
  150. package/tests/hydration/components/nested-control-flow.tsrx +215 -203
  151. package/tests/hydration/components/portal.tsrx +41 -34
  152. package/tests/hydration/components/reactivity.tsrx +37 -27
  153. package/tests/hydration/components/return.tsrx +12 -556
  154. package/tests/hydration/components/switch.tsrx +120 -114
  155. package/tests/hydration/components/track-async-serialization.tsrx +107 -91
  156. package/tests/hydration/components/try.tsrx +55 -40
  157. package/tests/hydration/html.test.js +4 -4
  158. package/tests/hydration/return.test.js +13 -532
  159. package/tests/server/await.test.tsrx +3 -3
  160. package/tests/server/basic.attributes.test.tsrx +264 -195
  161. package/tests/server/basic.components.test.tsrx +296 -169
  162. package/tests/server/basic.test.tsrx +300 -198
  163. package/tests/server/compiler.test.tsrx +62 -60
  164. package/tests/server/composite.props.test.tsrx +77 -63
  165. package/tests/server/composite.test.tsrx +168 -192
  166. package/tests/server/context.test.tsrx +18 -12
  167. package/tests/server/dynamic-elements.test.tsrx +197 -180
  168. package/tests/server/for.test.tsrx +85 -78
  169. package/tests/server/head.test.tsrx +50 -43
  170. package/tests/server/html-nesting-validation.test.tsrx +8 -8
  171. package/tests/server/if.test.tsrx +57 -51
  172. package/tests/server/lazy-destructuring.test.tsrx +366 -294
  173. package/tests/server/return.test.tsrx +76 -1355
  174. package/tests/server/streaming-ssr.test.tsrx +4 -75
  175. package/tests/server/style-identifier.test.tsrx +169 -131
  176. package/tests/server/switch.test.tsrx +91 -85
  177. package/tests/server/track-async-serialization.test.tsrx +105 -85
  178. package/tests/server/try.test.tsrx +374 -280
  179. package/tests/utils/compiler-compat-config.test.js +2 -2
  180. package/tests/utils/runtime-imports.test.js +10 -0
  181. package/types/index.d.ts +8 -0
  182. package/tests/client/__snapshots__/html.test.rsrx.snap +0 -40
@@ -1,11 +1,12 @@
1
1
  describe('for statements in SSR', () => {
2
2
  it('renders a simple static array', async () => {
3
- component App() {
4
- const items = ['Item 1', 'Item 2', 'Item 3'];
5
-
6
- for (const item of items) {
7
- <div class={item}>{item}</div>
8
- }
3
+ function App() {
4
+ return <>
5
+ const items = ['Item 1', 'Item 2', 'Item 3'];
6
+ for (const item of items) {
7
+ <div class={item}>{item}</div>
8
+ }
9
+ </>;
9
10
  }
10
11
 
11
12
  const { body } = await render(App);
@@ -15,26 +16,27 @@ describe('for statements in SSR', () => {
15
16
  });
16
17
 
17
18
  it('renders nested for...of loops', async () => {
18
- component App() {
19
- const groups = [
20
- {
21
- name: 'Group 1',
22
- items: ['Item 1.1', 'Item 1.2'],
23
- },
24
- {
25
- name: 'Group 2',
26
- items: ['Item 2.1', 'Item 2.2'],
27
- },
28
- ];
29
-
30
- for (const group of groups) {
31
- <h1>{group.name}</h1>
32
- <ul>
33
- for (const item of group.items) {
34
- <li>{item}</li>
35
- }
36
- </ul>
37
- }
19
+ function App() {
20
+ return <>
21
+ const groups = [
22
+ {
23
+ name: 'Group 1',
24
+ items: ['Item 1.1', 'Item 1.2'],
25
+ },
26
+ {
27
+ name: 'Group 2',
28
+ items: ['Item 2.1', 'Item 2.2'],
29
+ },
30
+ ];
31
+ for (const group of groups) {
32
+ <h1>{group.name}</h1>
33
+ <ul>
34
+ for (const item of group.items) {
35
+ <li>{item}</li>
36
+ }
37
+ </ul>
38
+ }
39
+ </>;
38
40
  }
39
41
 
40
42
  const { body } = await render(App);
@@ -44,12 +46,13 @@ describe('for statements in SSR', () => {
44
46
  });
45
47
 
46
48
  it('renders an array with index', async () => {
47
- component App() {
48
- const items = ['Item 1', 'Item 2', 'Item 3'];
49
-
50
- for (const item of items; index i) {
51
- <div class={`${item} ${i}`}>{`${item} ${i}`}</div>
52
- }
49
+ function App() {
50
+ return <>
51
+ const items = ['Item 1', 'Item 2', 'Item 3'];
52
+ for (const item of items; index i) {
53
+ <div class={`${item} ${i}`}>{`${item} ${i}`}</div>
54
+ }
55
+ </>;
53
56
  }
54
57
 
55
58
  const { body } = await render(App);
@@ -59,16 +62,17 @@ describe('for statements in SSR', () => {
59
62
  });
60
63
 
61
64
  it('renders an array with key', async () => {
62
- component App() {
63
- const items = [
64
- { id: 1, name: 'Item' },
65
- { id: 2, name: 'Item' },
66
- { id: 3, name: 'Item' },
67
- ];
68
-
69
- for (const item of items; key item.id) {
70
- <div class={`${item.name} ${item.id}`}>{`${item.name} ${item.id}`}</div>
71
- }
65
+ function App() {
66
+ return <>
67
+ const items = [
68
+ { id: 1, name: 'Item' },
69
+ { id: 2, name: 'Item' },
70
+ { id: 3, name: 'Item' },
71
+ ];
72
+ for (const item of items; key item.id) {
73
+ <div class={`${item.name} ${item.id}`}>{`${item.name} ${item.id}`}</div>
74
+ }
75
+ </>;
72
76
  }
73
77
 
74
78
  const { body } = await render(App);
@@ -78,16 +82,17 @@ describe('for statements in SSR', () => {
78
82
  });
79
83
 
80
84
  it('renders an array with index and key', async () => {
81
- component App() {
82
- const items = [
83
- { id: 1, name: 'Item' },
84
- { id: 2, name: 'Item' },
85
- { id: 3, name: 'Item' },
86
- ];
87
-
88
- for (const item of items; index i; key item.id) {
89
- <div class={`${item.name} ${item.id} ${i}`}>{`${item.name} ${item.id} ${i}`}</div>
90
- }
85
+ function App() {
86
+ return <>
87
+ const items = [
88
+ { id: 1, name: 'Item' },
89
+ { id: 2, name: 'Item' },
90
+ { id: 3, name: 'Item' },
91
+ ];
92
+ for (const item of items; index i; key item.id) {
93
+ <div class={`${item.name} ${item.id} ${i}`}>{`${item.name} ${item.id} ${i}`}</div>
94
+ }
95
+ </>;
91
96
  }
92
97
 
93
98
  const { body } = await render(App);
@@ -97,13 +102,14 @@ describe('for statements in SSR', () => {
97
102
  });
98
103
 
99
104
  it('allows continue to skip a for...of iteration', async () => {
100
- component App() {
101
- const items = ['Item 1', '', 'Item 3'];
102
-
103
- for (const item of items) {
104
- if (!item) continue;
105
- <div>{item}</div>
106
- }
105
+ function App() {
106
+ return <>
107
+ const items = ['Item 1', '', 'Item 3'];
108
+ for (const item of items) {
109
+ if (!item) continue;
110
+ <div>{item}</div>
111
+ }
112
+ </>;
107
113
  }
108
114
 
109
115
  const { body } = await render(App);
@@ -111,22 +117,23 @@ describe('for statements in SSR', () => {
111
117
  });
112
118
 
113
119
  it('allows ordinary function control flow inside for...of loops', async () => {
114
- component App() {
115
- const items = ['Item 1', '', 'Item 3'];
116
-
117
- for (const item of items) {
118
- function label(value) {
119
- for (let i = 0; i < 1; i++) {
120
- while (i < 0) {
121
- break;
120
+ function App() {
121
+ return <>
122
+ const items = ['Item 1', '', 'Item 3'];
123
+ for (const item of items) {
124
+ function label(value) {
125
+ for (let i = 0; i < 1; i++) {
126
+ while (i < 0) {
127
+ break;
128
+ }
129
+ if (!value) return 'missing';
122
130
  }
123
- if (!value) return 'missing';
131
+ return value;
124
132
  }
125
- return value;
126
- }
127
133
 
128
- <div>{label(item)}</div>
129
- }
134
+ <div>{label(item)}</div>
135
+ }
136
+ </>;
130
137
  }
131
138
 
132
139
  const { body } = await render(App);
@@ -136,30 +143,30 @@ describe('for statements in SSR', () => {
136
143
  it('throws for return statements inside for...of loops', () => {
137
144
  expect(
138
145
  () => compile(
139
- `component App(items) {
146
+ `function App(items) { return <>
140
147
  for (const item of items) {
141
148
  if (!item) return
142
149
  <div>{item}</div>
143
150
  }
144
- }`,
151
+ </>; }`,
145
152
  'App.tsrx',
146
153
  { mode: 'server' },
147
154
  ),
148
- ).toThrow('Return statements are not allowed inside component for...of loops');
155
+ ).toThrow('Return statements are not allowed inside TSRX templates.');
149
156
  });
150
157
 
151
158
  it('throws for break statements targeting for...of loops', () => {
152
159
  expect(
153
160
  () => compile(
154
- `component App(items) {
161
+ `function App(items) { return <>
155
162
  for (const item of items) {
156
163
  if (!item) break
157
164
  <div>{item}</div>
158
165
  }
159
- }`,
166
+ </>; }`,
160
167
  'App.tsrx',
161
168
  { mode: 'server' },
162
169
  ),
163
- ).toThrow('Break statements are not allowed inside component for...of loops');
170
+ ).toThrow('Break statements are not allowed inside TSRX template for...of loops');
164
171
  });
165
172
  });
@@ -2,12 +2,13 @@ import { track } from 'ripple';
2
2
 
3
3
  describe('head elements', () => {
4
4
  it('renders static title element', async () => {
5
- component App() {
6
- <head>
7
- <title>{'Static Test Title'}</title>
8
- </head>
9
-
10
- <div>{'Content'}</div>
5
+ function App() {
6
+ return <>
7
+ <head>
8
+ <title>{'Static Test Title'}</title>
9
+ </head>
10
+ <div>{'Content'}</div>
11
+ </>;
11
12
  }
12
13
 
13
14
  const { head, body } = await render(App);
@@ -18,15 +19,16 @@ describe('head elements', () => {
18
19
  });
19
20
 
20
21
  it('renders reactive title element', async () => {
21
- component App() {
22
- let &[title] = track('Initial Title');
23
-
24
- <head>
25
- <title>{title}</title>
26
- </head>
27
- <div>
28
- <span>{title}</span>
29
- </div>
22
+ function App() {
23
+ return <>
24
+ let &[title] = track('Initial Title');
25
+ <head>
26
+ <title>{title}</title>
27
+ </head>
28
+ <div>
29
+ <span>{title}</span>
30
+ </div>
31
+ </>;
30
32
  }
31
33
 
32
34
  const { head, body } = await render(App);
@@ -37,12 +39,13 @@ describe('head elements', () => {
37
39
  });
38
40
 
39
41
  it('renders title with template literal', async () => {
40
- component App() {
41
- let &[name] = track('World');
42
-
43
- <head>
44
- <title>{`Hello ${name}!`}</title>
45
- </head>
42
+ function App() {
43
+ return <>
44
+ let &[name] = track('World');
45
+ <head>
46
+ <title>{`Hello ${name}!`}</title>
47
+ </head>
48
+ </>;
46
49
  }
47
50
 
48
51
  const { head, body } = await render(App);
@@ -52,16 +55,17 @@ describe('head elements', () => {
52
55
  });
53
56
 
54
57
  it('renders title with computed value', async () => {
55
- component App() {
56
- let &[count] = track(0);
57
- let prefix = 'Count: ';
58
-
59
- <head>
60
- <title>{prefix + count}</title>
61
- </head>
62
- <div>
63
- <span>{count}</span>
64
- </div>
58
+ function App() {
59
+ return <>
60
+ let &[count] = track(0);
61
+ let prefix = 'Count: ';
62
+ <head>
63
+ <title>{prefix + count}</title>
64
+ </head>
65
+ <div>
66
+ <span>{count}</span>
67
+ </div>
68
+ </>;
65
69
  }
66
70
 
67
71
  const { head, body } = await render(App);
@@ -71,11 +75,13 @@ describe('head elements', () => {
71
75
  });
72
76
 
73
77
  it('renders empty title', async () => {
74
- component App() {
75
- <head>
76
- <title>{''}</title>
77
- </head>
78
- <div>{'Empty title test'}</div>
78
+ function App() {
79
+ return <>
80
+ <head>
81
+ <title>{''}</title>
82
+ </head>
83
+ <div>{'Empty title test'}</div>
84
+ </>;
79
85
  }
80
86
 
81
87
  const { head, body } = await render(App);
@@ -85,13 +91,14 @@ describe('head elements', () => {
85
91
  });
86
92
 
87
93
  it('renders title with conditional content', async () => {
88
- component App() {
89
- let &[showPrefix] = track(true);
90
- let &[title] = track('Main Page');
91
-
92
- <head>
93
- <title>{showPrefix ? 'App - ' + title : title}</title>
94
- </head>
94
+ function App() {
95
+ return <>
96
+ let &[showPrefix] = track(true);
97
+ let &[title] = track('Main Page');
98
+ <head>
99
+ <title>{showPrefix ? 'App - ' + title : title}</title>
100
+ </head>
101
+ </>;
95
102
  }
96
103
 
97
104
  const { head, body } = await render(App);
@@ -180,11 +180,11 @@ describe('HTML nesting validation', () => {
180
180
  describe('compiler dev mode output', () => {
181
181
  it('emits push_element and pop_element calls in dev mode', () => {
182
182
  const lines = [];
183
- lines.push('component App() {');
183
+ lines.push('function App() { return <>');
184
184
  lines.push(' <div>');
185
185
  lines.push(' <span>{"Hello"}</span>');
186
186
  lines.push(' </div>');
187
- lines.push('}');
187
+ lines.push('</>; }');
188
188
  const source = lines.join('\n');
189
189
 
190
190
  const result = compile(source, 'test.tsrx', { mode: 'server', dev: true });
@@ -195,11 +195,11 @@ describe('HTML nesting validation', () => {
195
195
 
196
196
  it('does not emit push_element or pop_element in non-dev mode', () => {
197
197
  const lines = [];
198
- lines.push('component App() {');
198
+ lines.push('function App() { return <>');
199
199
  lines.push(' <div>');
200
200
  lines.push(' <span>{"Hello"}</span>');
201
201
  lines.push(' </div>');
202
- lines.push('}');
202
+ lines.push('</>; }');
203
203
  const source = lines.join('\n');
204
204
 
205
205
  const result = compile(source, 'test.tsrx', { mode: 'server', dev: false });
@@ -210,9 +210,9 @@ describe('HTML nesting validation', () => {
210
210
 
211
211
  it('emits push_element with correct tag name', () => {
212
212
  const lines = [];
213
- lines.push('component App() {');
213
+ lines.push('function App() { return <>');
214
214
  lines.push(' <button>{"Click"}</button>');
215
- lines.push('}');
215
+ lines.push('</>; }');
216
216
  const source = lines.join('\n');
217
217
 
218
218
  const result = compile(source, 'test.tsrx', { mode: 'server', dev: true });
@@ -222,9 +222,9 @@ describe('HTML nesting validation', () => {
222
222
 
223
223
  it('does not emit push_element for client mode', () => {
224
224
  const lines = [];
225
- lines.push('component App() {');
225
+ lines.push('function App() { return <>');
226
226
  lines.push(' <div>{"Hello"}</div>');
227
- lines.push('}');
227
+ lines.push('</>; }');
228
228
  const source = lines.join('\n');
229
229
 
230
230
  const result = compile(source, 'test.tsrx', { mode: 'client', dev: true });
@@ -1,11 +1,12 @@
1
1
  describe('if statements in SSR', () => {
2
2
  it('renders if block when condition is true', async () => {
3
- component App() {
4
- let condition = true;
5
-
6
- if (condition) {
7
- <div>{'If block'}</div>
8
- }
3
+ function App() {
4
+ return <>
5
+ let condition = true;
6
+ if (condition) {
7
+ <div>{'If block'}</div>
8
+ }
9
+ </>;
9
10
  }
10
11
 
11
12
  const { body } = await render(App);
@@ -13,14 +14,15 @@ describe('if statements in SSR', () => {
13
14
  });
14
15
 
15
16
  it('renders else block when condition is false', async () => {
16
- component App() {
17
- let condition = false;
18
-
19
- if (condition) {
20
- <div>{'If block'}</div>
21
- } else {
22
- <div>{'Else block'}</div>
23
- }
17
+ function App() {
18
+ return <>
19
+ let condition = false;
20
+ if (condition) {
21
+ <div>{'If block'}</div>
22
+ } else {
23
+ <div>{'Else block'}</div>
24
+ }
25
+ </>;
24
26
  }
25
27
 
26
28
  const { body } = await render(App);
@@ -28,12 +30,13 @@ describe('if statements in SSR', () => {
28
30
  });
29
31
 
30
32
  it('renders bare double-quoted text in if-else branches', async () => {
31
- component App() {
32
- let condition = false;
33
-
34
- if (condition) {
35
- "Hello Ripple"
36
- } else "Hello React"
33
+ function App() {
34
+ return <>
35
+ let condition = false;
36
+ if (condition) {
37
+ "Hello Ripple"
38
+ } else "Hello React"
39
+ </>;
37
40
  }
38
41
 
39
42
  const { body } = await render(App);
@@ -41,16 +44,17 @@ describe('if statements in SSR', () => {
41
44
  });
42
45
 
43
46
  it('renders else if block when condition is true', async () => {
44
- component App() {
45
- let value = 'b';
46
-
47
- if (value === 'a') {
48
- <div>{'Case A'}</div>
49
- } else if (value === 'b') {
50
- <div>{'Case B'}</div>
51
- } else {
52
- <div>{'Default Case'}</div>
53
- }
47
+ function App() {
48
+ return <>
49
+ let value = 'b';
50
+ if (value === 'a') {
51
+ <div>{'Case A'}</div>
52
+ } else if (value === 'b') {
53
+ <div>{'Case B'}</div>
54
+ } else {
55
+ <div>{'Default Case'}</div>
56
+ }
57
+ </>;
54
58
  }
55
59
 
56
60
  const { body } = await render(App);
@@ -58,16 +62,17 @@ describe('if statements in SSR', () => {
58
62
  });
59
63
 
60
64
  it('renders final else block in an if-else if-else chain', async () => {
61
- component App() {
62
- let value = 'c';
63
-
64
- if (value === 'a') {
65
- <div>{'Case A'}</div>
66
- } else if (value === 'b') {
67
- <div>{'Case B'}</div>
68
- } else {
69
- <div>{'Default Case'}</div>
70
- }
65
+ function App() {
66
+ return <>
67
+ let value = 'c';
68
+ if (value === 'a') {
69
+ <div>{'Case A'}</div>
70
+ } else if (value === 'b') {
71
+ <div>{'Case B'}</div>
72
+ } else {
73
+ <div>{'Default Case'}</div>
74
+ }
75
+ </>;
71
76
  }
72
77
 
73
78
  const { body } = await render(App);
@@ -75,19 +80,20 @@ describe('if statements in SSR', () => {
75
80
  });
76
81
 
77
82
  it('renders nested if-else blocks correctly', async () => {
78
- component App() {
79
- let outer = true;
80
- let inner = false;
81
-
82
- if (outer) {
83
- if (inner) {
84
- <div>{'Outer true, Inner true'}</div>
83
+ function App() {
84
+ return <>
85
+ let outer = true;
86
+ let inner = false;
87
+ if (outer) {
88
+ if (inner) {
89
+ <div>{'Outer true, Inner true'}</div>
90
+ } else {
91
+ <div>{'Outer true, Inner false'}</div>
92
+ }
85
93
  } else {
86
- <div>{'Outer true, Inner false'}</div>
94
+ <div>{'Outer false'}</div>
87
95
  }
88
- } else {
89
- <div>{'Outer false'}</div>
90
- }
96
+ </>;
91
97
  }
92
98
 
93
99
  const { body } = await render(App);