@esportsplus/reactivity 0.24.4 → 0.24.5
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/build/transformer/transforms/array.js +3 -0
- package/build/transformer/transforms/object.js +1 -0
- package/build/transformer/transforms/primitives.js +11 -9
- package/package.json +1 -1
- package/src/transformer/transforms/array.ts +5 -0
- package/src/transformer/transforms/object.ts +3 -1
- package/src/transformer/transforms/primitives.ts +16 -13
|
@@ -34,6 +34,9 @@ function isAssignmentTarget(node) {
|
|
|
34
34
|
return false;
|
|
35
35
|
}
|
|
36
36
|
function visit(ctx, node) {
|
|
37
|
+
if (ts.isImportDeclaration(node)) {
|
|
38
|
+
return node;
|
|
39
|
+
}
|
|
37
40
|
if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer) {
|
|
38
41
|
if (ts.isIdentifier(node.initializer) && ctx.bindings.get(node.initializer.text) === 'array') {
|
|
39
42
|
ctx.bindings.set(node.name.text, 'array');
|
|
@@ -130,18 +130,20 @@ function isReactiveReassignment(node) {
|
|
|
130
130
|
return false;
|
|
131
131
|
}
|
|
132
132
|
function visit(ctx, node) {
|
|
133
|
-
if (ts.isImportDeclaration(node)
|
|
134
|
-
ts.isStringLiteral(node.moduleSpecifier) &&
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
133
|
+
if (ts.isImportDeclaration(node)) {
|
|
134
|
+
if (ts.isStringLiteral(node.moduleSpecifier) &&
|
|
135
|
+
node.moduleSpecifier.text.includes('@esportsplus/reactivity')) {
|
|
136
|
+
let clause = node.importClause;
|
|
137
|
+
if (clause?.namedBindings && ts.isNamedImports(clause.namedBindings)) {
|
|
138
|
+
for (let i = 0, n = clause.namedBindings.elements.length; i < n; i++) {
|
|
139
|
+
if (clause.namedBindings.elements[i].name.text === 'reactive') {
|
|
140
|
+
ctx.hasReactiveImport = true;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
145
|
}
|
|
146
|
+
return node;
|
|
145
147
|
}
|
|
146
148
|
if (ctx.hasReactiveImport &&
|
|
147
149
|
ts.isCallExpression(node) &&
|
package/package.json
CHANGED
|
@@ -58,6 +58,11 @@ function isAssignmentTarget(node: ts.Node): boolean {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
function visit(ctx: TransformContext, node: ts.Node): ts.Node {
|
|
61
|
+
// Skip import declarations - don't visit their children
|
|
62
|
+
if (ts.isImportDeclaration(node)) {
|
|
63
|
+
return node;
|
|
64
|
+
}
|
|
65
|
+
|
|
61
66
|
// Track array bindings from variable declarations
|
|
62
67
|
if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer) {
|
|
63
68
|
if (ts.isIdentifier(node.initializer) && ctx.bindings.get(node.initializer.text) === 'array') {
|
|
@@ -279,7 +279,7 @@ function buildReactiveClass(
|
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
function visit(ctx: TransformContext, node: ts.Node): ts.Node | ts.Node[] {
|
|
282
|
-
// Check for reactive import
|
|
282
|
+
// Check for reactive import - return early to avoid visiting import children
|
|
283
283
|
if (ts.isImportDeclaration(node)) {
|
|
284
284
|
if (
|
|
285
285
|
ts.isStringLiteral(node.moduleSpecifier) &&
|
|
@@ -298,6 +298,8 @@ function visit(ctx: TransformContext, node: ts.Node): ts.Node | ts.Node[] {
|
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
|
+
|
|
302
|
+
return node;
|
|
301
303
|
}
|
|
302
304
|
|
|
303
305
|
// Transform reactive({ ... }) or reactive([...]) calls
|
|
@@ -189,22 +189,25 @@ function isReactiveReassignment(node: ts.BinaryExpression): boolean {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
function visit(ctx: TransformContext, node: ts.Node): ts.Node {
|
|
192
|
-
// Check for reactive import
|
|
193
|
-
if (
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
192
|
+
// Check for reactive import - return early to avoid visiting import children
|
|
193
|
+
if (ts.isImportDeclaration(node)) {
|
|
194
|
+
if (
|
|
195
|
+
ts.isStringLiteral(node.moduleSpecifier) &&
|
|
196
|
+
node.moduleSpecifier.text.includes('@esportsplus/reactivity')
|
|
197
|
+
) {
|
|
198
|
+
let clause = node.importClause;
|
|
199
|
+
|
|
200
|
+
if (clause?.namedBindings && ts.isNamedImports(clause.namedBindings)) {
|
|
201
|
+
for (let i = 0, n = clause.namedBindings.elements.length; i < n; i++) {
|
|
202
|
+
if (clause.namedBindings.elements[i].name.text === 'reactive') {
|
|
203
|
+
ctx.hasReactiveImport = true;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
205
206
|
}
|
|
206
207
|
}
|
|
207
208
|
}
|
|
209
|
+
|
|
210
|
+
return node;
|
|
208
211
|
}
|
|
209
212
|
|
|
210
213
|
// Transform reactive() calls to signal() or computed()
|