@tsrx/vue 0.3.1 → 0.3.3

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.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Vue compiler built on @tsrx/core",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.3.1",
6
+ "version": "0.3.3",
7
7
  "type": "module",
8
8
  "publishConfig": {
9
9
  "access": "public"
@@ -38,8 +38,8 @@
38
38
  "esrap": "^2.3.2",
39
39
  "is-reference": "^3.0.3",
40
40
  "zimmerframe": "^1.1.2",
41
- "@tsrx/core": "0.5.1",
42
- "@tsrx/vue-runtime": "0.1.12"
41
+ "@tsrx/core": "0.5.3",
42
+ "@tsrx/vue-runtime": "0.1.13"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "vue": ">=3.5",
package/src/index.js CHANGED
@@ -100,7 +100,6 @@ export function compile_to_volar_mappings(source, filename, options) {
100
100
  ...options,
101
101
  collect: true,
102
102
  loose: !!options?.loose,
103
- moduleScopedHookComponents: false,
104
103
  typeOnly: true,
105
104
  errors,
106
105
  comments,
package/src/transform.js CHANGED
@@ -66,20 +66,10 @@ const vue_platform = {
66
66
  scanUseServerDirectiveForAwaitWithCustomValidator: false,
67
67
  },
68
68
  hooks: {
69
- // Hoist to module scope
70
- // in the regular client transform — one
71
- // definition per helper keeps bundles small and source mappings 1:1
72
- // for editor IntelliSense. The `compile_to_volar_mappings` entry point
73
- // opts back out so Volar's type-only output keeps helpers inline,
74
- // matching how it generates virtual TSX today.
75
- moduleScopedHookComponents: true,
76
69
  initialState: () => ({
77
70
  needs_define_vapor_component: false,
78
71
  needs_vapor_for: false,
79
72
  }),
80
- isTopLevelSetupCall(call_expression) {
81
- return is_vue_setup_call(call_expression);
82
- },
83
73
  wrapHelperComponent(helper_fn, helper_id, ctx, source_node) {
84
74
  ctx.needs_define_vapor_component = true;
85
75
  return wrap_helper_component(helper_fn, helper_id, source_node);
@@ -102,7 +92,9 @@ const vue_platform = {
102
92
  return create_vapor_pending_boundary(try_content, fallback_content);
103
93
  },
104
94
  createErrorFallbackComponent(catch_body_nodes, catch_params, ctx, node) {
105
- if (ctx.typeOnly) return null;
95
+ // Only the runtime `@pending` boundary renders the component (see
96
+ // `createErrorBoundary`); anything else would be dead module code.
97
+ if (ctx.typeOnly || !node.pending) return null;
106
98
  return create_module_scoped_error_fallback_component(
107
99
  catch_body_nodes,
108
100
  catch_params,
@@ -119,9 +111,6 @@ const vue_platform = {
119
111
  return create_vapor_error_boundary(try_content, fallback_fn);
120
112
  }
121
113
  const fallback_component = info?.fallbackComponent ?? null;
122
- const fallback_renderer = fallback_component
123
- ? create_fallback_component_renderer(fallback_component, fallback_fn)
124
- : fallback_fn;
125
114
  const default_slot = ctx.typeOnly
126
115
  ? b.arrow([], jsx_child_to_expression(raw_try_content))
127
116
  : create_sync_error_boundary_slot(
@@ -135,7 +124,7 @@ const vue_platform = {
135
124
  default_slot,
136
125
  fallback_content,
137
126
  );
138
- const boundary = create_vapor_error_boundary(suspense, fallback_renderer);
127
+ const boundary = create_vapor_error_boundary(suspense, fallback_fn);
139
128
  for (const statement of fallback_component?.setup_statements ?? []) {
140
129
  addJsxSetupDeclaration(boundary, statement);
141
130
  }
@@ -214,21 +203,10 @@ function create_vapor_pending_boundary_from_default_slot(default_slot, fallback_
214
203
  * @returns {JsxHelperComponent}
215
204
  */
216
205
  function create_module_scoped_error_fallback_component(catch_body_nodes, catch_params, ctx, node) {
217
- const saved_module_scoped = ctx.module_scoped_hook_components;
218
- ctx.module_scoped_hook_components = true;
219
- try {
220
- const source = node.handler ?? node;
221
- return createHookSafeHelper(
222
- catch_body_nodes,
223
- undefined,
224
- has_location(source) ? source : undefined,
225
- ctx,
226
- undefined,
227
- { transientBindings: get_pattern_names(catch_params) },
228
- );
229
- } finally {
230
- ctx.module_scoped_hook_components = saved_module_scoped;
231
- }
206
+ const source = node.handler ?? node;
207
+ return createHookSafeHelper(catch_body_nodes, has_location(source) ? source : undefined, ctx, {
208
+ transientBindings: get_pattern_names(catch_params),
209
+ });
232
210
  }
233
211
 
234
212
  /**
@@ -276,18 +254,6 @@ function create_sync_error_boundary_slot(
276
254
  return b.arrow([], b.block([try_statement]));
277
255
  }
278
256
 
279
- /**
280
- * @param {JsxHelperComponent} fallback_component
281
- * @param {AST.ArrowFunctionExpression} fallback_fn
282
- * @returns {AST.ArrowFunctionExpression}
283
- */
284
- function create_fallback_component_renderer(fallback_component, fallback_fn) {
285
- return b.arrow(
286
- fallback_fn.params.map((param) => clone_ast_node(param, false)),
287
- b.block([b.return(create_fallback_component_element(fallback_component, fallback_fn))]),
288
- );
289
- }
290
-
291
257
  /**
292
258
  * @param {JsxHelperComponent} fallback_component
293
259
  * @param {AST.ArrowFunctionExpression} fallback_fn
@@ -1107,41 +1073,6 @@ function function_declaration_to_expression(fn) {
1107
1073
  return expression;
1108
1074
  }
1109
1075
 
1110
- const VUE_SETUP_CALLS = new Set([
1111
- 'ref',
1112
- 'shallowRef',
1113
- 'computed',
1114
- 'reactive',
1115
- 'shallowReactive',
1116
- 'customRef',
1117
- 'toRef',
1118
- 'toRefs',
1119
- 'useTemplateRef',
1120
- ]);
1121
-
1122
- /**
1123
- * @param {AST.CallExpression} call_expression
1124
- * @returns {boolean}
1125
- */
1126
- function is_vue_setup_call(call_expression) {
1127
- const callee = call_expression?.callee;
1128
- if (!callee) return false;
1129
-
1130
- if (callee.type === 'Identifier') {
1131
- return VUE_SETUP_CALLS.has(callee.name);
1132
- }
1133
-
1134
- if (
1135
- callee.type === 'MemberExpression' &&
1136
- callee.computed === false &&
1137
- callee.property?.type === 'Identifier'
1138
- ) {
1139
- return VUE_SETUP_CALLS.has(callee.property.name);
1140
- }
1141
-
1142
- return false;
1143
- }
1144
-
1145
1076
  /**
1146
1077
  * Vue's JSX transform treats some prop names ending in `ref` as template-ref
1147
1078
  * sugar on components. Keep those as ordinary runtime props by hiding the