ripple 0.2.95 → 0.2.97

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": "Ripple is an elegant TypeScript UI framework",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.2.95",
6
+ "version": "0.2.97",
7
7
  "type": "module",
8
8
  "module": "src/runtime/index-client.js",
9
9
  "main": "src/runtime/index-client.js",
@@ -140,6 +140,12 @@ const visitors = {
140
140
  },
141
141
 
142
142
  CallExpression(node, context) {
143
+ // bug in our acorn pasrer: it uses typeParameters instead of typeArguments
144
+ if (node.typeParameters) {
145
+ node.typeArguments = node.typeParameters;
146
+ delete node.typeParameters;
147
+ }
148
+
143
149
  const callee = node.callee;
144
150
 
145
151
  if (context.state.function_depth === 0 && is_ripple_track_call(callee, context)) {
@@ -497,9 +503,9 @@ const visitors = {
497
503
  if (attr.name.type === 'Identifier') {
498
504
  attribute_names.add(attr.name);
499
505
  }
500
- if (attr.value !== null) {
501
- visit(attr.value, state);
502
- }
506
+ if (attr.value !== null) {
507
+ visit(attr.value, state);
508
+ }
503
509
  } else if (attr.type === 'SpreadAttribute') {
504
510
  visit(attr.argument, state);
505
511
  } else if (attr.type === 'RefAttribute') {
@@ -1,3 +1,5 @@
1
+ /** @import {Expression, FunctionExpression} from 'estree' */
2
+
1
3
  import { walk } from 'zimmerframe';
2
4
  import path from 'node:path';
3
5
  import { print } from 'esrap';
@@ -195,6 +197,9 @@ const visitors = {
195
197
  },
196
198
 
197
199
  CallExpression(node, context) {
200
+ if (!context.state.to_ts) {
201
+ delete node.typeArguments;
202
+ }
198
203
  const callee = node.callee;
199
204
  const parent = context.path.at(-1);
200
205
 
@@ -407,29 +412,13 @@ const visitors = {
407
412
  },
408
413
 
409
414
  VariableDeclaration(node, context) {
410
- const declarations = [];
411
-
412
415
  for (const declarator of node.declarations) {
413
- const metadata = declarator.metadata;
414
-
415
- if (declarator.id.type === 'Identifier') {
416
- const binding = context.state.scope.get(declarator.id.name);
417
-
418
- if (!context.state.to_ts) {
419
- delete declarator.id.typeAnnotation;
420
- }
421
-
422
- declarations.push(context.visit(declarator));
423
- } else {
424
- if (!context.state.to_ts) {
425
- delete declarator.id.typeAnnotation;
426
- }
427
-
428
- declarations.push(context.visit(declarator));
416
+ if (!context.state.to_ts) {
417
+ delete declarator.id.typeAnnotation;
429
418
  }
430
419
  }
431
420
 
432
- return { ...node, declarations };
421
+ return context.next();
433
422
  },
434
423
 
435
424
  FunctionDeclaration(node, context) {
@@ -106,6 +106,45 @@ const visitors = {
106
106
  );
107
107
  },
108
108
 
109
+ CallExpression(node, context) {
110
+ if (!context.state.to_ts) {
111
+ delete node.typeArguments;
112
+ }
113
+ return context.next();
114
+ },
115
+
116
+ PropertyDefinition(node, context) {
117
+ if (!context.state.to_ts) {
118
+ delete node.typeAnnotation;
119
+ }
120
+ return context.next();
121
+ },
122
+
123
+ TSAsExpression(node, context) {
124
+ if (!context.state.to_ts) {
125
+ return context.visit(node.expression);
126
+ }
127
+ return context.next();
128
+ },
129
+
130
+ ExportNamedDeclaration(node, context) {
131
+ if (!context.state.to_ts && node.exportKind === 'type') {
132
+ return b.empty;
133
+ }
134
+
135
+ return context.next();
136
+ },
137
+
138
+ VariableDeclaration(node, context) {
139
+ for (const declarator of node.declarations) {
140
+ if (!context.state.to_ts) {
141
+ delete declarator.id.typeAnnotation;
142
+ }
143
+ }
144
+
145
+ return context.next();
146
+ },
147
+
109
148
  Element(node, context) {
110
149
  const { state, visit } = context;
111
150