ripple 0.3.12 → 0.3.13

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 (190) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/package.json +8 -2
  3. package/src/compiler/phases/1-parse/index.js +73 -30
  4. package/src/compiler/phases/2-analyze/index.js +28 -58
  5. package/src/compiler/phases/3-transform/client/index.js +127 -164
  6. package/src/compiler/phases/3-transform/segments.js +4 -8
  7. package/src/compiler/phases/3-transform/server/index.js +210 -360
  8. package/src/compiler/types/import.d.ts +0 -12
  9. package/src/compiler/types/index.d.ts +12 -5
  10. package/src/compiler/types/parse.d.ts +2 -0
  11. package/src/compiler/utils.js +39 -44
  12. package/src/helpers.d.ts +2 -0
  13. package/src/runtime/index-client.js +15 -13
  14. package/src/runtime/index-server.js +18 -11
  15. package/src/runtime/internal/client/blocks.js +19 -23
  16. package/src/runtime/internal/client/constants.js +20 -9
  17. package/src/runtime/internal/client/index.js +14 -4
  18. package/src/runtime/internal/client/runtime.js +435 -173
  19. package/src/runtime/internal/client/try.js +334 -156
  20. package/src/runtime/internal/client/types.d.ts +26 -0
  21. package/src/runtime/internal/server/blocks.js +183 -0
  22. package/src/runtime/internal/server/constants.js +7 -0
  23. package/src/runtime/internal/server/index.js +780 -148
  24. package/src/runtime/internal/server/types.d.ts +35 -0
  25. package/src/server/index.js +1 -1
  26. package/src/utils/async.js +35 -0
  27. package/src/utils/builders.js +3 -1
  28. package/tests/client/__snapshots__/computed-properties.test.rsrx.snap +49 -0
  29. package/tests/client/__snapshots__/for.test.rsrx.snap +319 -0
  30. package/tests/client/__snapshots__/html.test.rsrx.snap +40 -0
  31. package/tests/client/_etc.test.rsrx +7 -0
  32. package/tests/client/array/{array.static.test.ripple → array.static.test.rsrx} +18 -20
  33. package/tests/client/async-suspend.test.rsrx +662 -0
  34. package/tests/client/basic/__snapshots__/basic.attributes.test.rsrx.snap +60 -0
  35. package/tests/client/basic/__snapshots__/basic.rendering.test.rsrx.snap +59 -0
  36. package/tests/client/basic/{basic.errors.test.ripple → basic.errors.test.rsrx} +2 -2
  37. package/tests/client/compiler/__snapshots__/compiler.assignments.test.rsrx.snap +12 -0
  38. package/tests/client/compiler/__snapshots__/compiler.typescript.test.rsrx.snap +46 -0
  39. package/tests/client/compiler/{compiler.try-in-function.test.ripple → compiler.try-in-function.test.rsrx} +8 -6
  40. package/tests/client/composite/__snapshots__/composite.render.test.rsrx.snap +37 -0
  41. package/tests/client/{function-overload.test.ripple → function-overload.test.rsrx} +1 -1
  42. package/tests/client/try.test.rsrx +1702 -0
  43. package/tests/hydration/build-components.js +5 -3
  44. package/tests/hydration/compiled/client/head.js +11 -11
  45. package/tests/hydration/compiled/client/mixed-control-flow.js +55 -70
  46. package/tests/hydration/compiled/client/nested-control-flow.js +72 -88
  47. package/tests/hydration/compiled/client/try.js +42 -54
  48. package/tests/hydration/compiled/server/basic.js +491 -369
  49. package/tests/hydration/compiled/server/composite.js +153 -128
  50. package/tests/hydration/compiled/server/events.js +166 -145
  51. package/tests/hydration/compiled/server/for.js +821 -677
  52. package/tests/hydration/compiled/server/head.js +200 -165
  53. package/tests/hydration/compiled/server/hmr.js +62 -54
  54. package/tests/hydration/compiled/server/html-in-template.js +64 -55
  55. package/tests/hydration/compiled/server/html.js +1477 -1360
  56. package/tests/hydration/compiled/server/if-children.js +448 -408
  57. package/tests/hydration/compiled/server/if.js +204 -171
  58. package/tests/hydration/compiled/server/mixed-control-flow.js +237 -195
  59. package/tests/hydration/compiled/server/nested-control-flow.js +533 -467
  60. package/tests/hydration/compiled/server/portal.js +94 -107
  61. package/tests/hydration/compiled/server/reactivity.js +87 -64
  62. package/tests/hydration/compiled/server/return.js +1424 -1174
  63. package/tests/hydration/compiled/server/switch.js +268 -238
  64. package/tests/hydration/compiled/server/try.js +98 -87
  65. package/tests/hydration/components/{mixed-control-flow.ripple → mixed-control-flow.rsrx} +2 -2
  66. package/tests/hydration/components/{try.ripple → try.rsrx} +4 -2
  67. package/tests/hydration/mixed-control-flow.test.js +14 -0
  68. package/tests/hydration/nested-control-flow.test.js +50 -48
  69. package/tests/hydration/try.test.js +25 -0
  70. package/tests/server/__snapshots__/compiler.test.ripple.snap +0 -32
  71. package/tests/server/__snapshots__/compiler.test.rsrx.snap +95 -0
  72. package/tests/server/{compiler.test.ripple → compiler.test.rsrx} +0 -17
  73. package/tests/server/{html-nesting-validation.test.ripple → html-nesting-validation.test.rsrx} +3 -3
  74. package/tests/server/streaming-ssr.test.rsrx +115 -0
  75. package/tests/server/try.test.rsrx +503 -0
  76. package/tests/utils/compiler-compat-config.test.js +3 -3
  77. package/tests/utils/vite-plugin-config.test.js +1 -1
  78. package/tests/utils/vite-plugin-hmr.test.js +5 -5
  79. package/tsconfig.json +2 -0
  80. package/types/index.d.ts +13 -23
  81. package/types/server.d.ts +43 -16
  82. package/tests/client/_etc.test.ripple +0 -5
  83. package/tests/client/async-suspend.test.ripple +0 -94
  84. package/tests/client/try.test.ripple +0 -196
  85. package/tests/server/streaming-ssr.test.ripple +0 -68
  86. package/tests/server/try.test.ripple +0 -82
  87. /package/tests/client/array/{array.copy-within.test.ripple → array.copy-within.test.rsrx} +0 -0
  88. /package/tests/client/array/{array.derived.test.ripple → array.derived.test.rsrx} +0 -0
  89. /package/tests/client/array/{array.iteration.test.ripple → array.iteration.test.rsrx} +0 -0
  90. /package/tests/client/array/{array.mutations.test.ripple → array.mutations.test.rsrx} +0 -0
  91. /package/tests/client/array/{array.to-methods.test.ripple → array.to-methods.test.rsrx} +0 -0
  92. /package/tests/client/basic/{basic.attributes.test.ripple → basic.attributes.test.rsrx} +0 -0
  93. /package/tests/client/basic/{basic.collections.test.ripple → basic.collections.test.rsrx} +0 -0
  94. /package/tests/client/basic/{basic.components.test.ripple → basic.components.test.rsrx} +0 -0
  95. /package/tests/client/basic/{basic.events.test.ripple → basic.events.test.rsrx} +0 -0
  96. /package/tests/client/basic/{basic.get-set.test.ripple → basic.get-set.test.rsrx} +0 -0
  97. /package/tests/client/basic/{basic.hmr.test.ripple → basic.hmr.test.rsrx} +0 -0
  98. /package/tests/client/basic/{basic.reactivity.test.ripple → basic.reactivity.test.rsrx} +0 -0
  99. /package/tests/client/basic/{basic.rendering.test.ripple → basic.rendering.test.rsrx} +0 -0
  100. /package/tests/client/basic/{basic.styling.test.ripple → basic.styling.test.rsrx} +0 -0
  101. /package/tests/client/basic/{basic.utilities.test.ripple → basic.utilities.test.rsrx} +0 -0
  102. /package/tests/client/{boundaries.test.ripple → boundaries.test.rsrx} +0 -0
  103. /package/tests/client/compiler/{compiler.assignments.test.ripple → compiler.assignments.test.rsrx} +0 -0
  104. /package/tests/client/compiler/{compiler.attributes.test.ripple → compiler.attributes.test.rsrx} +0 -0
  105. /package/tests/client/compiler/{compiler.basic.test.ripple → compiler.basic.test.rsrx} +0 -0
  106. /package/tests/client/compiler/{compiler.regex.test.ripple → compiler.regex.test.rsrx} +0 -0
  107. /package/tests/client/compiler/{compiler.tracked-access.test.ripple → compiler.tracked-access.test.rsrx} +0 -0
  108. /package/tests/client/compiler/{compiler.typescript.test.ripple → compiler.typescript.test.rsrx} +0 -0
  109. /package/tests/client/composite/{composite.dynamic-components.test.ripple → composite.dynamic-components.test.rsrx} +0 -0
  110. /package/tests/client/composite/{composite.generics.test.ripple → composite.generics.test.rsrx} +0 -0
  111. /package/tests/client/composite/{composite.props.test.ripple → composite.props.test.rsrx} +0 -0
  112. /package/tests/client/composite/{composite.reactivity.test.ripple → composite.reactivity.test.rsrx} +0 -0
  113. /package/tests/client/composite/{composite.render.test.ripple → composite.render.test.rsrx} +0 -0
  114. /package/tests/client/{computed-properties.test.ripple → computed-properties.test.rsrx} +0 -0
  115. /package/tests/client/{context.test.ripple → context.test.rsrx} +0 -0
  116. /package/tests/client/css/{global-additional-cases.test.ripple → global-additional-cases.test.rsrx} +0 -0
  117. /package/tests/client/css/{global-advanced-selectors.test.ripple → global-advanced-selectors.test.rsrx} +0 -0
  118. /package/tests/client/css/{global-at-rules.test.ripple → global-at-rules.test.rsrx} +0 -0
  119. /package/tests/client/css/{global-basic.test.ripple → global-basic.test.rsrx} +0 -0
  120. /package/tests/client/css/{global-classes-ids.test.ripple → global-classes-ids.test.rsrx} +0 -0
  121. /package/tests/client/css/{global-combinators.test.ripple → global-combinators.test.rsrx} +0 -0
  122. /package/tests/client/css/{global-complex-nesting.test.ripple → global-complex-nesting.test.rsrx} +0 -0
  123. /package/tests/client/css/{global-edge-cases.test.ripple → global-edge-cases.test.rsrx} +0 -0
  124. /package/tests/client/css/{global-keyframes.test.ripple → global-keyframes.test.rsrx} +0 -0
  125. /package/tests/client/css/{global-nested.test.ripple → global-nested.test.rsrx} +0 -0
  126. /package/tests/client/css/{global-pseudo.test.ripple → global-pseudo.test.rsrx} +0 -0
  127. /package/tests/client/css/{global-scoping.test.ripple → global-scoping.test.rsrx} +0 -0
  128. /package/tests/client/css/{style-identifier.test.ripple → style-identifier.test.rsrx} +0 -0
  129. /package/tests/client/{date.test.ripple → date.test.rsrx} +0 -0
  130. /package/tests/client/{dynamic-elements.test.ripple → dynamic-elements.test.rsrx} +0 -0
  131. /package/tests/client/{events.test.ripple → events.test.rsrx} +0 -0
  132. /package/tests/client/{for.test.ripple → for.test.rsrx} +0 -0
  133. /package/tests/client/{function-overload-import.ripple → function-overload-import.rsrx} +0 -0
  134. /package/tests/client/{head.test.ripple → head.test.rsrx} +0 -0
  135. /package/tests/client/{html.test.ripple → html.test.rsrx} +0 -0
  136. /package/tests/client/{input-value.test.ripple → input-value.test.rsrx} +0 -0
  137. /package/tests/client/{lazy-destructuring.test.ripple → lazy-destructuring.test.rsrx} +0 -0
  138. /package/tests/client/{map.test.ripple → map.test.rsrx} +0 -0
  139. /package/tests/client/{media-query.test.ripple → media-query.test.rsrx} +0 -0
  140. /package/tests/client/{object.test.ripple → object.test.rsrx} +0 -0
  141. /package/tests/client/{portal.test.ripple → portal.test.rsrx} +0 -0
  142. /package/tests/client/{ref.test.ripple → ref.test.rsrx} +0 -0
  143. /package/tests/client/{return.test.ripple → return.test.rsrx} +0 -0
  144. /package/tests/client/{set.test.ripple → set.test.rsrx} +0 -0
  145. /package/tests/client/{svg.test.ripple → svg.test.rsrx} +0 -0
  146. /package/tests/client/{switch.test.ripple → switch.test.rsrx} +0 -0
  147. /package/tests/client/{tsx.test.ripple → tsx.test.rsrx} +0 -0
  148. /package/tests/client/{typescript-generics.test.ripple → typescript-generics.test.rsrx} +0 -0
  149. /package/tests/client/url/{url.derived.test.ripple → url.derived.test.rsrx} +0 -0
  150. /package/tests/client/url/{url.parsing.test.ripple → url.parsing.test.rsrx} +0 -0
  151. /package/tests/client/url/{url.partial-removal.test.ripple → url.partial-removal.test.rsrx} +0 -0
  152. /package/tests/client/url/{url.reactivity.test.ripple → url.reactivity.test.rsrx} +0 -0
  153. /package/tests/client/url/{url.serialization.test.ripple → url.serialization.test.rsrx} +0 -0
  154. /package/tests/client/url-search-params/{url-search-params.derived.test.ripple → url-search-params.derived.test.rsrx} +0 -0
  155. /package/tests/client/url-search-params/{url-search-params.initialization.test.ripple → url-search-params.initialization.test.rsrx} +0 -0
  156. /package/tests/client/url-search-params/{url-search-params.iteration.test.ripple → url-search-params.iteration.test.rsrx} +0 -0
  157. /package/tests/client/url-search-params/{url-search-params.mutation.test.ripple → url-search-params.mutation.test.rsrx} +0 -0
  158. /package/tests/client/url-search-params/{url-search-params.retrieval.test.ripple → url-search-params.retrieval.test.rsrx} +0 -0
  159. /package/tests/client/url-search-params/{url-search-params.serialization.test.ripple → url-search-params.serialization.test.rsrx} +0 -0
  160. /package/tests/client/url-search-params/{url-search-params.tracked-url.test.ripple → url-search-params.tracked-url.test.rsrx} +0 -0
  161. /package/tests/hydration/components/{basic.ripple → basic.rsrx} +0 -0
  162. /package/tests/hydration/components/{composite.ripple → composite.rsrx} +0 -0
  163. /package/tests/hydration/components/{events.ripple → events.rsrx} +0 -0
  164. /package/tests/hydration/components/{for.ripple → for.rsrx} +0 -0
  165. /package/tests/hydration/components/{head.ripple → head.rsrx} +0 -0
  166. /package/tests/hydration/components/{hmr.ripple → hmr.rsrx} +0 -0
  167. /package/tests/hydration/components/{html-in-template.ripple → html-in-template.rsrx} +0 -0
  168. /package/tests/hydration/components/{html.ripple → html.rsrx} +0 -0
  169. /package/tests/hydration/components/{if-children.ripple → if-children.rsrx} +0 -0
  170. /package/tests/hydration/components/{if.ripple → if.rsrx} +0 -0
  171. /package/tests/hydration/components/{nested-control-flow.ripple → nested-control-flow.rsrx} +0 -0
  172. /package/tests/hydration/components/{portal.ripple → portal.rsrx} +0 -0
  173. /package/tests/hydration/components/{reactivity.ripple → reactivity.rsrx} +0 -0
  174. /package/tests/hydration/components/{return.ripple → return.rsrx} +0 -0
  175. /package/tests/hydration/components/{switch.ripple → switch.rsrx} +0 -0
  176. /package/tests/server/{await.test.ripple → await.test.rsrx} +0 -0
  177. /package/tests/server/{basic.attributes.test.ripple → basic.attributes.test.rsrx} +0 -0
  178. /package/tests/server/{basic.components.test.ripple → basic.components.test.rsrx} +0 -0
  179. /package/tests/server/{basic.test.ripple → basic.test.rsrx} +0 -0
  180. /package/tests/server/{composite.props.test.ripple → composite.props.test.rsrx} +0 -0
  181. /package/tests/server/{composite.test.ripple → composite.test.rsrx} +0 -0
  182. /package/tests/server/{context.test.ripple → context.test.rsrx} +0 -0
  183. /package/tests/server/{dynamic-elements.test.ripple → dynamic-elements.test.rsrx} +0 -0
  184. /package/tests/server/{for.test.ripple → for.test.rsrx} +0 -0
  185. /package/tests/server/{head.test.ripple → head.test.rsrx} +0 -0
  186. /package/tests/server/{if.test.ripple → if.test.rsrx} +0 -0
  187. /package/tests/server/{lazy-destructuring.test.ripple → lazy-destructuring.test.rsrx} +0 -0
  188. /package/tests/server/{return.test.ripple → return.test.rsrx} +0 -0
  189. /package/tests/server/{style-identifier.test.ripple → style-identifier.test.rsrx} +0 -0
  190. /package/tests/server/{switch.test.ripple → switch.test.rsrx} +0 -0
@@ -46,7 +46,6 @@ import {
46
46
  is_value_static,
47
47
  is_void_element,
48
48
  is_element_dom_element,
49
- is_top_level_await,
50
49
  is_ripple_track_call,
51
50
  normalize_children,
52
51
  build_getter,
@@ -61,6 +60,7 @@ import {
61
60
  is_ripple_import,
62
61
  replace_lazy_param_pattern,
63
62
  ripple_import_requires_block,
63
+ strip_class_typescript_syntax,
64
64
  jsx_to_ripple_node,
65
65
  } from '../../../utils.js';
66
66
  import {
@@ -147,23 +147,6 @@ function visit_function(node, context) {
147
147
  };
148
148
  }
149
149
 
150
- /**
151
- * @param {AST.ClassDeclaration | AST.ClassExpression} node
152
- * @param {TransformClientContext} context
153
- * @returns {void}
154
- */
155
- function strip_class_typescript_syntax(node, context) {
156
- delete node.typeParameters;
157
- delete node.superTypeParameters;
158
- delete node.implements;
159
-
160
- if (node.superClass?.type === 'TSInstantiationExpression') {
161
- node.superClass = /** @type {AST.Expression} */ (context.visit(node.superClass.expression));
162
- } else if (node.superClass && 'typeArguments' in node.superClass) {
163
- delete node.superClass.typeArguments;
164
- }
165
- }
166
-
167
150
  /**
168
151
  * @param {AST.Element} node
169
152
  * @param {number} index
@@ -235,7 +218,6 @@ function apply_updates(init, update, state) {
235
218
  return u.operation();
236
219
  }),
237
220
  ),
238
- !!update.async,
239
221
  ),
240
222
  ),
241
223
  ),
@@ -340,7 +322,7 @@ function apply_updates(init, update, state) {
340
322
  b.stmt(
341
323
  b.call(
342
324
  '_$_.render',
343
- b.arrow([b.id('__prev')], b.block(render_statements), !!update.async),
325
+ b.arrow([b.id('__prev')], b.block(render_statements)),
344
326
  b.object(initial),
345
327
  ),
346
328
  ),
@@ -356,7 +338,7 @@ function visit_title_element(node, context) {
356
338
  const normalized = normalize_children(node.children, context);
357
339
  const content = normalized[0];
358
340
 
359
- const metadata = { tracking: false, await: false };
341
+ const metadata = { tracking: false };
360
342
  const visited = context.visit(content, { ...context.state, metadata });
361
343
  const result = /** @type {AST.Expression} */ (
362
344
  /** @type {{expression?: AST.Expression}} */ (visited).expression
@@ -545,17 +527,9 @@ const visitors = {
545
527
  },
546
528
 
547
529
  StyleIdentifier(node, context) {
548
- if (context.state.to_ts) {
549
- const style_alias = set_hidden_import_from_ripple(STYLE_IDENTIFIER, context, true);
550
-
551
- // IMPORTANT! only add location to the identifier
552
- const style_id = b.id(style_alias, /** @type {AST.NodeWithLocation} */ (node));
553
- style_id.metadata.source_name = '#style';
554
-
555
- return b.ts_as(style_id, b.ts_type_reference(b.id('RippleStyle')));
556
- }
557
-
558
- return { ...node, ...b.id(STYLE_IDENTIFIER) };
530
+ const id = b.id(STYLE_IDENTIFIER);
531
+ id.metadata.source_name = '#style';
532
+ return { ...node, ...id };
559
533
  },
560
534
 
561
535
  ImportDeclaration(node, context) {
@@ -632,7 +606,7 @@ const visitors = {
632
606
 
633
607
  const matched_track_call = !context.state.to_ts ? is_ripple_track_call(callee, context) : null;
634
608
  if (matched_track_call) {
635
- const track_method_name = 'track';
609
+ const track_method_name = matched_track_call === 'trackAsync' ? 'track_async' : 'track';
636
610
 
637
611
  if (callee.type === 'Identifier' && callee.name === 'track') {
638
612
  if (node.arguments.length === 0) {
@@ -643,14 +617,26 @@ const visitors = {
643
617
  node.arguments.push(b.void0);
644
618
  }
645
619
  }
646
- return {
647
- ...node,
648
- callee: b.member(b.id('_$_'), b.id(track_method_name)),
649
- arguments: /** @type {(AST.Expression | AST.SpreadElement)[]} */ ([
620
+
621
+ /** @type {(AST.Expression | AST.SpreadElement)[]} */
622
+ let call_args;
623
+ if (track_method_name === 'track_async') {
624
+ call_args = [
625
+ /** @type {AST.Expression} */ (context.visit(node.arguments[0])),
626
+ b.id('__block'),
627
+ ];
628
+ } else {
629
+ call_args = /** @type {(AST.Expression | AST.SpreadElement)[]} */ ([
650
630
  ...node.arguments.map((arg) => context.visit(arg)),
651
631
  b.id('__block'),
652
- ]),
653
- };
632
+ ]);
633
+ }
634
+
635
+ return /** @type {AST.CallExpression} */ ({
636
+ ...node,
637
+ callee: b.member(b.id('_$_'), b.id(track_method_name)),
638
+ arguments: call_args,
639
+ });
654
640
  }
655
641
 
656
642
  // Handle member calls on ripple imports, like RippleArray.from()
@@ -718,16 +704,13 @@ const visitors = {
718
704
  return b.call(
719
705
  '_$_.with_scope',
720
706
  b.id('__block'),
721
- b.thunk(
722
- {
723
- ...node,
724
- callee: /** @type {AST.Expression} */ (context.visit(callee)),
725
- arguments: /** @type {(AST.Expression | AST.SpreadElement)[]} */ (
726
- node.arguments.map((arg) => context.visit(arg))
727
- ),
728
- },
729
- context.state.metadata?.await ?? false,
730
- ),
707
+ b.thunk({
708
+ ...node,
709
+ callee: /** @type {AST.Expression} */ (context.visit(callee)),
710
+ arguments: /** @type {(AST.Expression | AST.SpreadElement)[]} */ (
711
+ node.arguments.map((arg) => context.visit(arg))
712
+ ),
713
+ }),
731
714
  );
732
715
  },
733
716
 
@@ -808,7 +791,7 @@ const visitors = {
808
791
  }
809
792
 
810
793
  if (node.object.type === 'MemberExpression' && node.object.optional) {
811
- const metadata = { tracking: false, await: false };
794
+ const metadata = { tracking: false };
812
795
 
813
796
  const object = context.visit(node.object, { ...context.state, metadata });
814
797
 
@@ -824,11 +807,6 @@ const visitors = {
824
807
  property: /** @type {AST.Expression} */ (context.visit(node.property)),
825
808
  };
826
809
  }
827
- if (metadata.await) {
828
- if (context.state.metadata?.await === false) {
829
- context.state.metadata.await = true;
830
- }
831
- }
832
810
  } else {
833
811
  return context.next();
834
812
  }
@@ -1338,7 +1316,7 @@ const visitors = {
1338
1316
 
1339
1317
  if (name === 'value') {
1340
1318
  const id = state.flush_node?.();
1341
- const metadata = { tracking: false, await: false };
1319
+ const metadata = { tracking: false };
1342
1320
  const expression = /** @type {AST.Expression} */ (
1343
1321
  visit(attr.value, { ...state, metadata })
1344
1322
  );
@@ -1371,7 +1349,7 @@ const visitors = {
1371
1349
 
1372
1350
  if (name === 'checked') {
1373
1351
  const id = state.flush_node?.();
1374
- const metadata = { tracking: false, await: false };
1352
+ const metadata = { tracking: false };
1375
1353
  const expression = /** @type {AST.Expression} */ (
1376
1354
  visit(attr.value, { ...state, metadata })
1377
1355
  );
@@ -1391,7 +1369,7 @@ const visitors = {
1391
1369
 
1392
1370
  if (name === 'selected') {
1393
1371
  const id = state.flush_node?.();
1394
- const metadata = { tracking: false, await: false };
1372
+ const metadata = { tracking: false };
1395
1373
  const expression = /** @type {AST.Expression} */ (
1396
1374
  visit(attr.value, { ...state, metadata })
1397
1375
  );
@@ -1410,7 +1388,7 @@ const visitors = {
1410
1388
  }
1411
1389
 
1412
1390
  if (is_event_attribute(name)) {
1413
- const metadata = { tracking: false, await: false };
1391
+ const metadata = { tracking: false };
1414
1392
  let handler = /** @type {AST.Expression} */ (
1415
1393
  visit(attr.value, { ...state, metadata })
1416
1394
  );
@@ -1447,7 +1425,7 @@ const visitors = {
1447
1425
 
1448
1426
  continue;
1449
1427
  }
1450
- const metadata = { tracking: false, await: false };
1428
+ const metadata = { tracking: false };
1451
1429
  const expression = /** @type {AST.Expression} */ (
1452
1430
  visit(attr.value, { ...state, metadata })
1453
1431
  );
@@ -1502,7 +1480,7 @@ const visitors = {
1502
1480
  );
1503
1481
  } else if (attr.type === 'RefAttribute') {
1504
1482
  const id = state.flush_node?.();
1505
- const metadata = { tracking: false, await: false };
1483
+ const metadata = { tracking: false };
1506
1484
  state.init?.push(
1507
1485
  b.stmt(
1508
1486
  b.call(
@@ -1529,7 +1507,7 @@ const visitors = {
1529
1507
  handle_static_attr(class_attribute.name.name, value);
1530
1508
  } else {
1531
1509
  const id = state.flush_node?.();
1532
- const metadata = { tracking: false, await: false };
1510
+ const metadata = { tracking: false };
1533
1511
  const expression = /** @type {AST.Expression} */ (
1534
1512
  visit(attr_value, { ...state, metadata })
1535
1513
  );
@@ -1563,7 +1541,7 @@ const visitors = {
1563
1541
  handle_static_attr(style_attribute.name.name, attr_value.value);
1564
1542
  } else {
1565
1543
  const id = state.flush_node?.();
1566
- const metadata = { tracking: false, await: false };
1544
+ const metadata = { tracking: false };
1567
1545
  const expression = /** @type {AST.Expression} */ (
1568
1546
  visit(attr_value, { ...state, metadata })
1569
1547
  );
@@ -1685,7 +1663,7 @@ const visitors = {
1685
1663
  for (const attr of node.attributes) {
1686
1664
  if (attr.type === 'Attribute') {
1687
1665
  if (attr.name.type === 'Identifier') {
1688
- const metadata = { tracking: false, await: false };
1666
+ const metadata = { tracking: false };
1689
1667
  let property =
1690
1668
  attr.value === null
1691
1669
  ? b.literal(true)
@@ -1760,7 +1738,7 @@ const visitors = {
1760
1738
  );
1761
1739
  } else if (attr.type === 'RefAttribute') {
1762
1740
  const ref_id = state.scope.generate('ref');
1763
- const metadata = { tracking: false, await: false };
1741
+ const metadata = { tracking: false };
1764
1742
  state.init?.push(b.var(ref_id, b.call('_$_.ref_prop')));
1765
1743
  props.push(
1766
1744
  b.prop(
@@ -1848,7 +1826,7 @@ const visitors = {
1848
1826
  props.push(children_prop);
1849
1827
  }
1850
1828
 
1851
- const metadata = { tracking: false, await: false };
1829
+ const metadata = { tracking: false };
1852
1830
  // We visit, but only to gather metadata
1853
1831
  b.call(/** @type {AST.Expression} */ (visit(node.id, { ...state, metadata })));
1854
1832
 
@@ -1920,7 +1898,7 @@ const visitors = {
1920
1898
 
1921
1899
  Component(node, context) {
1922
1900
  let prop_statements;
1923
- const metadata = { await: false };
1901
+ const metadata = {};
1924
1902
 
1925
1903
  /** @type {AST.Statement[]} */
1926
1904
  const style_statements = [];
@@ -1954,24 +1932,7 @@ const visitors = {
1954
1932
  );
1955
1933
  }
1956
1934
  }
1957
- if (context.state.to_ts) {
1958
- // For to_ts mode, we create a type alias for RippleStyle
1959
- // that maps the scoped class names
1960
- const ripple_style_type_alias = b.ts_type_alias(
1961
- b.id('RippleStyle'),
1962
- b.ts_type_literal(
1963
- properties.map((prop) =>
1964
- b.ts_property_signature(
1965
- /** @type {AST.Expression} */ (prop.key),
1966
- b.ts_type_annotation(b.ts_keyword_type('string')),
1967
- ),
1968
- ),
1969
- ),
1970
- );
1971
- style_statements.push(
1972
- /** @type {AST.Statement} */ (/** @type {unknown} */ (ripple_style_type_alias)),
1973
- );
1974
- }
1935
+
1975
1936
  style_statements.push(b[var_method_type](b.id(STYLE_IDENTIFIER), b.object(properties)));
1976
1937
  }
1977
1938
 
@@ -2072,13 +2033,7 @@ const visitors = {
2072
2033
  const func = b.function(
2073
2034
  node.id,
2074
2035
  params,
2075
- b.block([
2076
- ...style_statements,
2077
- ...(prop_statements ?? []),
2078
- ...(metadata.await
2079
- ? [b.stmt(b.call('_$_.async', b.thunk(b.block(body_statements), true)))]
2080
- : body_statements),
2081
- ]),
2036
+ b.block([...style_statements, ...(prop_statements ?? []), ...body_statements]),
2082
2037
  );
2083
2038
 
2084
2039
  func.metadata = {
@@ -2308,7 +2263,7 @@ const visitors = {
2308
2263
  /** @type {AST.Expression} */ (
2309
2264
  context.visit(node.test, {
2310
2265
  ...context.state,
2311
- metadata: { ...context.state.metadata, await: false },
2266
+ metadata: { ...context.state.metadata },
2312
2267
  })
2313
2268
  ),
2314
2269
  b.stmt(b.call('_$_.set', b.id(info.name), b.true)),
@@ -2321,7 +2276,7 @@ const visitors = {
2321
2276
  /** @type {AST.Expression} */ (
2322
2277
  context.visit(node.test, {
2323
2278
  ...context.state,
2324
- metadata: { ...context.state.metadata, await: false },
2279
+ metadata: { ...context.state.metadata },
2325
2280
  })
2326
2281
  ),
2327
2282
  b.stmt(b.assignment('=', b.id(info.name), b.true)),
@@ -2398,7 +2353,7 @@ const visitors = {
2398
2353
  /** @type {AST.Expression} */ (
2399
2354
  context.visit(node.test, {
2400
2355
  ...context.state,
2401
- metadata: { ...context.state.metadata, await: false },
2356
+ metadata: { ...context.state.metadata },
2402
2357
  })
2403
2358
  ),
2404
2359
  b.stmt(b.call(b.id('__render'), b.id(consequent_id))),
@@ -2513,18 +2468,22 @@ const visitors = {
2513
2468
  context.state.template?.push('<!>');
2514
2469
 
2515
2470
  const id = context.state.flush_node?.();
2516
- const metadata = { await: false };
2471
+ const handler = /** @type {AST.CatchClause | null} */ (node.handler);
2472
+ const pending = /** @type {AST.BlockStatement | null} */ (node.pending);
2517
2473
  let body = transform_body(node.block.body, {
2518
2474
  ...context,
2519
- state: { ...context.state, metadata },
2475
+ state: {
2476
+ ...context.state,
2477
+ scope: /** @type {ScopeInterface} */ (context.state.scopes.get(node.block)),
2478
+ },
2520
2479
  });
2521
2480
 
2522
- if (node.pending) {
2523
- body = [b.stmt(b.call('_$_.async', b.thunk(b.block(body), true)))];
2481
+ if (handler?.param) {
2482
+ delete handler.param.typeAnnotation;
2483
+ }
2484
+ if (handler?.resetParam) {
2485
+ delete handler.resetParam.typeAnnotation;
2524
2486
  }
2525
-
2526
- const handler = /** @type {AST.CatchClause | null} */ (node.handler);
2527
- const pending = /** @type {AST.BlockStatement | null} */ (node.pending);
2528
2487
 
2529
2488
  context.state.init?.push(
2530
2489
  b.stmt(
@@ -2535,43 +2494,43 @@ const visitors = {
2535
2494
  handler === null
2536
2495
  ? b.literal(null)
2537
2496
  : b.arrow(
2538
- [b.id('__anchor'), ...(handler.param ? [handler.param] : [])],
2539
- b.block(transform_body(handler.body.body, context)),
2497
+ [
2498
+ b.id('__anchor'),
2499
+ ...(handler.param && handler.resetParam
2500
+ ? [handler.param, handler.resetParam]
2501
+ : handler.param
2502
+ ? [handler.param]
2503
+ : []),
2504
+ ],
2505
+ b.block(
2506
+ transform_body(handler.body.body, {
2507
+ ...context,
2508
+ state: {
2509
+ ...context.state,
2510
+ scope: /** @type {ScopeInterface} */ (context.state.scopes.get(handler.body)),
2511
+ },
2512
+ }),
2513
+ ),
2540
2514
  ),
2541
2515
  pending === null
2542
2516
  ? undefined
2543
- : b.arrow([b.id('__anchor')], b.block(transform_body(pending.body, context))),
2517
+ : b.arrow(
2518
+ [b.id('__anchor')],
2519
+ b.block(
2520
+ transform_body(pending.body, {
2521
+ ...context,
2522
+ state: {
2523
+ ...context.state,
2524
+ scope: /** @type {ScopeInterface} */ (context.state.scopes.get(pending)),
2525
+ },
2526
+ }),
2527
+ ),
2528
+ ),
2544
2529
  ),
2545
2530
  ),
2546
2531
  );
2547
2532
  },
2548
2533
 
2549
- AwaitExpression(node, context) {
2550
- const { state } = context;
2551
-
2552
- if (state.to_ts) {
2553
- if (is_inside_component(context)) {
2554
- node.metadata.inside_component_top_level = true;
2555
- }
2556
-
2557
- return context.next();
2558
- }
2559
-
2560
- if (!is_top_level_await(context)) {
2561
- return context.next();
2562
- }
2563
-
2564
- if (context.state.metadata?.await === false) {
2565
- context.state.metadata.await = true;
2566
- }
2567
-
2568
- return b.call(
2569
- b.await(
2570
- b.call('_$_.maybe_tracked', /** @type {AST.Expression} */ (context.visit(node.argument))),
2571
- ),
2572
- );
2573
- },
2574
-
2575
2534
  BinaryExpression(node, context) {
2576
2535
  return b.binary(
2577
2536
  node.operator,
@@ -2766,8 +2725,7 @@ function transform_ts_child(node, context) {
2766
2725
 
2767
2726
  const attributes = node.attributes.map((attr) => {
2768
2727
  if (attr.type === 'Attribute') {
2769
- const metadata = { await: false };
2770
- const name = visit(attr.name, { ...state, metadata });
2728
+ const name = visit(attr.name, state);
2771
2729
  const attr_value = /** @type { AST.Expression & AST.NodeWithLocation | null} */ (
2772
2730
  attr.value
2773
2731
  );
@@ -2777,7 +2735,7 @@ function transform_ts_child(node, context) {
2777
2735
  // will take care of the mapping JSXAttribute's JSXIdentifier
2778
2736
  b.literal(true)
2779
2737
  : // reset init, update, final to avoid adding attr value to the component body
2780
- visit(attr_value, SetStateForOutsideComponent(state, { metadata }));
2738
+ visit(attr_value, SetStateForOutsideComponent(state));
2781
2739
 
2782
2740
  // Handle both regular identifiers and tracked identifiers
2783
2741
  /** @type {string} */
@@ -2832,16 +2790,14 @@ function transform_ts_child(node, context) {
2832
2790
  );
2833
2791
  return jsx_attr;
2834
2792
  } else if (attr.type === 'SpreadAttribute') {
2835
- const metadata = { await: false };
2836
- const argument = visit(attr.argument, { ...state, metadata });
2793
+ const argument = visit(attr.argument, state);
2837
2794
  return b.jsx_spread_attribute(
2838
2795
  /** @type {AST.Expression} */ (argument),
2839
2796
  /** @type {AST.NodeWithLocation} */ (attr),
2840
2797
  );
2841
2798
  } else if (attr.type === 'RefAttribute') {
2842
2799
  const createRefKeyAlias = set_hidden_import_from_ripple('createRefKey', context);
2843
- const metadata = { await: false };
2844
- const argument = visit(attr.argument, { ...state, metadata });
2800
+ const argument = visit(attr.argument, state);
2845
2801
  const wrapper = b.object([
2846
2802
  b.prop('init', b.call(createRefKeyAlias), /** @type {AST.Expression} */ (argument), true),
2847
2803
  ]);
@@ -2867,7 +2823,6 @@ function transform_ts_child(node, context) {
2867
2823
  visit(child, {
2868
2824
  ...state,
2869
2825
  scope: component_scope,
2870
- metadata: { await: false },
2871
2826
  })
2872
2827
  );
2873
2828
  const func = b.arrow(
@@ -3108,6 +3063,7 @@ function transform_ts_child(node, context) {
3108
3063
  );
3109
3064
  catch_handler = b.catch_clause(
3110
3065
  node.handler.param || null,
3066
+ node.handler.resetParam || null,
3111
3067
  catch_body,
3112
3068
  /** @type {AST.NodeWithLocation} */ (node.handler),
3113
3069
  );
@@ -3362,7 +3318,7 @@ function transform_template_element(node, state, visit, child_namespace, init, u
3362
3318
  // Single {html} expression - set innerHTML reactively
3363
3319
  const html_node = /** @type {AST.Html} */ (node.children[0]);
3364
3320
  const id = state.flush_node?.();
3365
- const metadata = { tracking: false, await: false };
3321
+ const metadata = { tracking: false };
3366
3322
  const expression = /** @type {AST.Expression} */ (
3367
3323
  visit(html_node.expression, { ...state, metadata })
3368
3324
  );
@@ -3655,20 +3611,13 @@ function transform_children(children, context) {
3655
3611
  node.type === 'ReturnStatement' ||
3656
3612
  node.type === 'Component'
3657
3613
  ) {
3658
- const metadata = { await: false };
3659
- state.init?.push(
3660
- /** @type {AST.Statement} */ (visit(node, { ...state, return_flags, metadata })),
3661
- );
3662
- if (metadata.await) {
3663
- state.init?.push(b.if(b.call('_$_.aborted'), b.return(null)));
3664
- if (state.metadata?.await === false) {
3665
- state.metadata.await = true;
3666
- }
3667
- }
3668
- if (!state.to_ts && node.type === 'ReturnStatement') {
3669
- const info = return_flags.get(node);
3670
- if (info && !accumulated_return_flags.some((f) => f.name === info.name)) {
3671
- accumulated_return_flags.push(info);
3614
+ state.init?.push(/** @type {AST.Statement} */ (visit(node, { ...state, return_flags })));
3615
+ if (!state.to_ts) {
3616
+ if (node.type === 'ReturnStatement') {
3617
+ const info = return_flags.get(node);
3618
+ if (info && !accumulated_return_flags.some((f) => f.name === info.name)) {
3619
+ accumulated_return_flags.push(info);
3620
+ }
3672
3621
  }
3673
3622
  }
3674
3623
  } else if (state.to_ts) {
@@ -3679,7 +3628,7 @@ function transform_children(children, context) {
3679
3628
  let expression = undefined;
3680
3629
  let is_create_text_only = false;
3681
3630
  if (node.type === 'RippleExpression' || node.type === 'Text' || node.type === 'Html') {
3682
- metadata = { tracking: false, await: false };
3631
+ metadata = { tracking: false };
3683
3632
  expression = /** @type {AST.Expression} */ (visit(node.expression, { ...state, metadata }));
3684
3633
  is_create_text_only =
3685
3634
  node.type !== 'Html' && normalized.length === 1 && expression.type === 'Literal';
@@ -3898,9 +3847,6 @@ function transform_children(children, context) {
3898
3847
  identity: node.expression,
3899
3848
  initial: b.literal(' '),
3900
3849
  });
3901
- if (metadata.await) {
3902
- /** @type {NonNullable<TransformClientState['update']>} */ (state.update).async = true;
3903
- }
3904
3850
  } else if (normalized.length === 1) {
3905
3851
  skipped++;
3906
3852
  const expr = /** @type {AST.Expression} */ (expression);
@@ -3944,10 +3890,6 @@ function transform_children(children, context) {
3944
3890
  identity: node.expression,
3945
3891
  initial: b.literal(' '),
3946
3892
  });
3947
- if (metadata?.await) {
3948
- /** @type {NonNullable<TransformClientState['update']>} */ (state.update).async =
3949
- true;
3950
- }
3951
3893
  }
3952
3894
  }
3953
3895
  } else if (node.type === 'ForOfStatement') {
@@ -5036,13 +4978,34 @@ function create_tsx_with_typescript_support(comments) {
5036
4978
 
5037
4979
  if (node.handler) {
5038
4980
  context.write(' catch');
5039
- if (node.handler.param) {
4981
+ if (node.handler.param && !node.handler.resetParam) {
5040
4982
  context.write(' (');
5041
4983
  context.visit(node.handler.param);
5042
4984
  context.write(')');
5043
4985
  }
5044
4986
  context.write(' ');
5045
- context.visit(node.handler.body);
4987
+ if (node.handler.param && node.handler.resetParam) {
4988
+ // Emit as IIFE so both params are valid TS arrow function parameters
4989
+ context.write('{\n');
4990
+ context.indent();
4991
+ context.write('((');
4992
+ context.visit(node.handler.param);
4993
+ if (!node.handler.param.typeAnnotation) {
4994
+ context.write(': unknown');
4995
+ }
4996
+ context.write(', ');
4997
+ context.visit(node.handler.resetParam);
4998
+ if (!node.handler.resetParam.typeAnnotation) {
4999
+ context.write(': () => void');
5000
+ }
5001
+ context.write(') => ');
5002
+ context.visit(node.handler.body);
5003
+ context.write(')({}, () => {})\n');
5004
+ context.dedent();
5005
+ context.write('}');
5006
+ } else {
5007
+ context.visit(node.handler.body);
5008
+ }
5046
5009
  }
5047
5010
 
5048
5011
  if (node.finalizer) {
@@ -1076,10 +1076,13 @@ export function convert_source_map_to_mappings(
1076
1076
  }
1077
1077
  return;
1078
1078
  } else if (node.type === 'CatchClause') {
1079
- // Visit in source order: param, body
1079
+ // Visit in source order: param, resetParam, body
1080
1080
  if (node.param) {
1081
1081
  visit(node.param);
1082
1082
  }
1083
+ if (node.resetParam) {
1084
+ visit(node.resetParam);
1085
+ }
1083
1086
  if (node.body) {
1084
1087
  visit(node.body);
1085
1088
  }
@@ -1411,13 +1414,6 @@ export function convert_source_map_to_mappings(
1411
1414
  max_len,
1412
1415
  );
1413
1416
 
1414
- if (node.metadata?.inside_component_top_level) {
1415
- // Since we don't print component with async,
1416
- // we need to suppress the ts diagnostic on the 'await' keyword
1417
- // about being inside a non-async function
1418
- mapping.data.customData.suppressedDiagnostics = [1308];
1419
- }
1420
-
1421
1417
  mappings.push(mapping);
1422
1418
  }
1423
1419
  return;