@tanstack/devtools-vite 0.5.5 → 0.6.1
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/dist/esm/babel.js +7 -15
- package/dist/esm/babel.js.map +1 -1
- package/dist/esm/editor.js +18 -27
- package/dist/esm/editor.js.map +1 -1
- package/dist/esm/enhance-logs.js +48 -80
- package/dist/esm/enhance-logs.js.map +1 -1
- package/dist/esm/index.js +1 -5
- package/dist/esm/inject-plugin.js +160 -220
- package/dist/esm/inject-plugin.js.map +1 -1
- package/dist/esm/inject-source.js +108 -201
- package/dist/esm/inject-source.js.map +1 -1
- package/dist/esm/matcher.js +11 -16
- package/dist/esm/matcher.js.map +1 -1
- package/dist/esm/package-manager.js +90 -131
- package/dist/esm/package-manager.js.map +1 -1
- package/dist/esm/plugin.js +334 -448
- package/dist/esm/plugin.js.map +1 -1
- package/dist/esm/remove-devtools.js +97 -131
- package/dist/esm/remove-devtools.js.map +1 -1
- package/dist/esm/utils.js +149 -162
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/virtual-console.js +170 -14
- package/dist/esm/virtual-console.js.map +1 -1
- package/package.json +3 -3
- package/src/plugin.ts +9 -1
- package/src/virtual-console.test.ts +172 -1
- package/src/virtual-console.ts +146 -7
- package/dist/esm/index.js.map +0 -1
|
@@ -1,228 +1,168 @@
|
|
|
1
|
+
import { gen, parse, t, trav } from "./babel.js";
|
|
1
2
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
3
|
+
//#region src/inject-plugin.ts
|
|
4
|
+
/**
|
|
5
|
+
* Detects if a file imports TanStack devtools packages
|
|
6
|
+
* Handles: import X from '@tanstack/react-devtools'
|
|
7
|
+
* import * as X from '@tanstack/react-devtools'
|
|
8
|
+
* import { TanStackDevtools } from '@tanstack/react-devtools'
|
|
9
|
+
*/
|
|
10
|
+
var detectDevtoolsImport = (code) => {
|
|
11
|
+
const devtoolsPackages = [
|
|
12
|
+
"@tanstack/react-devtools",
|
|
13
|
+
"@tanstack/solid-devtools",
|
|
14
|
+
"@tanstack/vue-devtools",
|
|
15
|
+
"@tanstack/svelte-devtools",
|
|
16
|
+
"@tanstack/angular-devtools"
|
|
17
|
+
];
|
|
18
|
+
try {
|
|
19
|
+
const ast = parse(code, {
|
|
20
|
+
sourceType: "module",
|
|
21
|
+
plugins: ["jsx", "typescript"]
|
|
22
|
+
});
|
|
23
|
+
let hasDevtoolsImport = false;
|
|
24
|
+
trav(ast, { ImportDeclaration(path) {
|
|
25
|
+
const importSource = path.node.source.value;
|
|
26
|
+
if (devtoolsPackages.includes(importSource)) {
|
|
27
|
+
hasDevtoolsImport = true;
|
|
28
|
+
path.stop();
|
|
29
|
+
}
|
|
30
|
+
} });
|
|
31
|
+
return hasDevtoolsImport;
|
|
32
|
+
} catch (e) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
32
35
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
});
|
|
65
|
-
return componentName;
|
|
36
|
+
/**
|
|
37
|
+
* Finds the TanStackDevtools component name in the file
|
|
38
|
+
* Handles renamed imports and namespace imports
|
|
39
|
+
*/
|
|
40
|
+
var findDevtoolsComponentName = (ast) => {
|
|
41
|
+
let componentName = null;
|
|
42
|
+
const devtoolsPackages = [
|
|
43
|
+
"@tanstack/react-devtools",
|
|
44
|
+
"@tanstack/solid-devtools",
|
|
45
|
+
"@tanstack/vue-devtools",
|
|
46
|
+
"@tanstack/svelte-devtools",
|
|
47
|
+
"@tanstack/angular-devtools"
|
|
48
|
+
];
|
|
49
|
+
trav(ast, { ImportDeclaration(path) {
|
|
50
|
+
const importSource = path.node.source.value;
|
|
51
|
+
if (devtoolsPackages.includes(importSource)) {
|
|
52
|
+
const namedImport = path.node.specifiers.find((spec) => t.isImportSpecifier(spec) && t.isIdentifier(spec.imported) && spec.imported.name === "TanStackDevtools");
|
|
53
|
+
if (namedImport && t.isImportSpecifier(namedImport)) {
|
|
54
|
+
componentName = namedImport.local.name;
|
|
55
|
+
path.stop();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const namespaceImport = path.node.specifiers.find((spec) => t.isImportNamespaceSpecifier(spec));
|
|
59
|
+
if (namespaceImport && t.isImportNamespaceSpecifier(namespaceImport)) {
|
|
60
|
+
componentName = `${namespaceImport.local.name}.TanStackDevtools`;
|
|
61
|
+
path.stop();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
} });
|
|
66
|
+
return componentName;
|
|
66
67
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
t.stringLiteral(displayName)
|
|
126
|
-
),
|
|
127
|
-
t.objectProperty(t.identifier("render"), renderValue)
|
|
128
|
-
])
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
didTransform = true;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
} else {
|
|
136
|
-
let pluginElement;
|
|
137
|
-
if (pluginType === "function") {
|
|
138
|
-
pluginElement = t.callExpression(t.identifier(importName), []);
|
|
139
|
-
} else {
|
|
140
|
-
const renderValue = t.jsxElement(
|
|
141
|
-
t.jsxOpeningElement(t.jsxIdentifier(importName), [], true),
|
|
142
|
-
null,
|
|
143
|
-
[],
|
|
144
|
-
true
|
|
145
|
-
);
|
|
146
|
-
pluginElement = t.objectExpression([
|
|
147
|
-
t.objectProperty(
|
|
148
|
-
t.identifier("name"),
|
|
149
|
-
t.stringLiteral(displayName)
|
|
150
|
-
),
|
|
151
|
-
t.objectProperty(t.identifier("render"), renderValue)
|
|
152
|
-
]);
|
|
153
|
-
}
|
|
154
|
-
path.node.attributes.push(
|
|
155
|
-
t.jsxAttribute(
|
|
156
|
-
t.jsxIdentifier("plugins"),
|
|
157
|
-
t.jsxExpressionContainer(t.arrayExpression([pluginElement]))
|
|
158
|
-
)
|
|
159
|
-
);
|
|
160
|
-
didTransform = true;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
if (didTransform) {
|
|
166
|
-
const importDeclaration = t.importDeclaration(
|
|
167
|
-
[t.importSpecifier(t.identifier(importName), t.identifier(importName))],
|
|
168
|
-
t.stringLiteral(injection.packageName)
|
|
169
|
-
);
|
|
170
|
-
let lastImportIndex = -1;
|
|
171
|
-
ast.program.body.forEach((node, index) => {
|
|
172
|
-
if (t.isImportDeclaration(node)) {
|
|
173
|
-
lastImportIndex = index;
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
ast.program.body.splice(lastImportIndex + 1, 0, importDeclaration);
|
|
177
|
-
}
|
|
178
|
-
return didTransform;
|
|
68
|
+
var transformAndInject = (ast, injection, devtoolsComponentName) => {
|
|
69
|
+
let didTransform = false;
|
|
70
|
+
const importName = injection.pluginImport?.importName;
|
|
71
|
+
const pluginType = injection.pluginImport?.type || "jsx";
|
|
72
|
+
const displayName = injection.pluginName;
|
|
73
|
+
if (!importName) return false;
|
|
74
|
+
const isNamespaceImport = devtoolsComponentName.includes(".");
|
|
75
|
+
trav(ast, { JSXOpeningElement(path) {
|
|
76
|
+
const elementName = path.node.name;
|
|
77
|
+
let matches = false;
|
|
78
|
+
if (isNamespaceImport) {
|
|
79
|
+
if (t.isJSXMemberExpression(elementName)) matches = `${t.isJSXIdentifier(elementName.object) ? elementName.object.name : ""}.${t.isJSXIdentifier(elementName.property) ? elementName.property.name : ""}` === devtoolsComponentName;
|
|
80
|
+
} else matches = t.isJSXIdentifier(elementName) && elementName.name === devtoolsComponentName;
|
|
81
|
+
if (matches) {
|
|
82
|
+
const pluginsProp = path.node.attributes.find((attr) => t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name) && attr.name.name === "plugins");
|
|
83
|
+
if (pluginsProp && t.isJSXAttribute(pluginsProp)) {
|
|
84
|
+
if (pluginsProp.value && t.isJSXExpressionContainer(pluginsProp.value)) {
|
|
85
|
+
const expression = pluginsProp.value.expression;
|
|
86
|
+
if (t.isArrayExpression(expression)) {
|
|
87
|
+
if (!expression.elements.some((element) => {
|
|
88
|
+
if (!element) return false;
|
|
89
|
+
if (pluginType === "function") return t.isCallExpression(element) && t.isIdentifier(element.callee) && element.callee.name === importName;
|
|
90
|
+
if (!t.isObjectExpression(element)) return false;
|
|
91
|
+
return element.properties.some((prop) => {
|
|
92
|
+
if (!t.isObjectProperty(prop) || !t.isIdentifier(prop.key) || prop.key.name !== "name") return false;
|
|
93
|
+
return t.isStringLiteral(prop.value) && prop.value.value === displayName;
|
|
94
|
+
});
|
|
95
|
+
})) {
|
|
96
|
+
if (pluginType === "function") expression.elements.push(t.callExpression(t.identifier(importName), []));
|
|
97
|
+
else {
|
|
98
|
+
const renderValue = t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier(importName), [], true), null, [], true);
|
|
99
|
+
expression.elements.push(t.objectExpression([t.objectProperty(t.identifier("name"), t.stringLiteral(displayName)), t.objectProperty(t.identifier("render"), renderValue)]));
|
|
100
|
+
}
|
|
101
|
+
didTransform = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
let pluginElement;
|
|
107
|
+
if (pluginType === "function") pluginElement = t.callExpression(t.identifier(importName), []);
|
|
108
|
+
else {
|
|
109
|
+
const renderValue = t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier(importName), [], true), null, [], true);
|
|
110
|
+
pluginElement = t.objectExpression([t.objectProperty(t.identifier("name"), t.stringLiteral(displayName)), t.objectProperty(t.identifier("render"), renderValue)]);
|
|
111
|
+
}
|
|
112
|
+
path.node.attributes.push(t.jsxAttribute(t.jsxIdentifier("plugins"), t.jsxExpressionContainer(t.arrayExpression([pluginElement]))));
|
|
113
|
+
didTransform = true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
} });
|
|
117
|
+
if (didTransform) {
|
|
118
|
+
const importDeclaration = t.importDeclaration([t.importSpecifier(t.identifier(importName), t.identifier(importName))], t.stringLiteral(injection.packageName));
|
|
119
|
+
let lastImportIndex = -1;
|
|
120
|
+
ast.program.body.forEach((node, index) => {
|
|
121
|
+
if (t.isImportDeclaration(node)) lastImportIndex = index;
|
|
122
|
+
});
|
|
123
|
+
ast.program.body.splice(lastImportIndex + 1, 0, importDeclaration);
|
|
124
|
+
}
|
|
125
|
+
return didTransform;
|
|
179
126
|
};
|
|
127
|
+
/**
|
|
128
|
+
* Detects if a file contains TanStack devtools import
|
|
129
|
+
*/
|
|
180
130
|
function detectDevtoolsFile(code) {
|
|
181
|
-
|
|
131
|
+
return detectDevtoolsImport(code);
|
|
182
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Injects a plugin into the TanStackDevtools component in a file
|
|
135
|
+
* Reads the file, transforms it, and writes it back
|
|
136
|
+
*/
|
|
183
137
|
function injectPluginIntoFile(filePath, injection) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
retainLines: false
|
|
211
|
-
});
|
|
212
|
-
writeFileSync(filePath, result.code, "utf-8");
|
|
213
|
-
return { success: true };
|
|
214
|
-
} catch (e) {
|
|
215
|
-
console.error("Error injecting plugin:", e);
|
|
216
|
-
return {
|
|
217
|
-
success: false,
|
|
218
|
-
error: e instanceof Error ? e.message : "Unknown error"
|
|
219
|
-
};
|
|
220
|
-
}
|
|
138
|
+
try {
|
|
139
|
+
const ast = parse(readFileSync(filePath, "utf-8"), {
|
|
140
|
+
sourceType: "module",
|
|
141
|
+
plugins: ["jsx", "typescript"]
|
|
142
|
+
});
|
|
143
|
+
const devtoolsComponentName = findDevtoolsComponentName(ast);
|
|
144
|
+
if (!devtoolsComponentName) return {
|
|
145
|
+
success: false,
|
|
146
|
+
error: "Could not find TanStackDevtools import"
|
|
147
|
+
};
|
|
148
|
+
if (!transformAndInject(ast, injection, devtoolsComponentName)) return {
|
|
149
|
+
success: false,
|
|
150
|
+
error: "Plugin already exists or no TanStackDevtools component found"
|
|
151
|
+
};
|
|
152
|
+
writeFileSync(filePath, gen(ast, {
|
|
153
|
+
sourceMaps: false,
|
|
154
|
+
retainLines: false
|
|
155
|
+
}).code, "utf-8");
|
|
156
|
+
return { success: true };
|
|
157
|
+
} catch (e) {
|
|
158
|
+
console.error("Error injecting plugin:", e);
|
|
159
|
+
return {
|
|
160
|
+
success: false,
|
|
161
|
+
error: e instanceof Error ? e.message : "Unknown error"
|
|
162
|
+
};
|
|
163
|
+
}
|
|
221
164
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
transformAndInject
|
|
227
|
-
};
|
|
228
|
-
//# sourceMappingURL=inject-plugin.js.map
|
|
165
|
+
//#endregion
|
|
166
|
+
export { detectDevtoolsFile, injectPluginIntoFile };
|
|
167
|
+
|
|
168
|
+
//# sourceMappingURL=inject-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-plugin.js","sources":["../../src/inject-plugin.ts"],"sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs'\nimport { gen, parse, t, trav } from './babel'\nimport type { PluginInjection } from '@tanstack/devtools-client'\nimport type { types as Babel } from '@babel/core'\nimport type { ParseResult } from '@babel/parser'\n\n/**\n * Detects if a file imports TanStack devtools packages\n * Handles: import X from '@tanstack/react-devtools'\n * import * as X from '@tanstack/react-devtools'\n * import { TanStackDevtools } from '@tanstack/react-devtools'\n */\nconst detectDevtoolsImport = (code: string): boolean => {\n const devtoolsPackages = [\n '@tanstack/react-devtools',\n '@tanstack/solid-devtools',\n '@tanstack/vue-devtools',\n '@tanstack/svelte-devtools',\n '@tanstack/angular-devtools',\n ]\n\n try {\n const ast = parse(code, {\n sourceType: 'module',\n plugins: ['jsx', 'typescript'],\n })\n\n let hasDevtoolsImport = false\n\n trav(ast, {\n ImportDeclaration(path) {\n const importSource = path.node.source.value\n if (devtoolsPackages.includes(importSource)) {\n hasDevtoolsImport = true\n path.stop()\n }\n },\n })\n\n return hasDevtoolsImport\n } catch (e) {\n return false\n }\n}\n\n/**\n * Finds the TanStackDevtools component name in the file\n * Handles renamed imports and namespace imports\n */\nexport const findDevtoolsComponentName = (\n ast: ParseResult<Babel.File>,\n): string | null => {\n let componentName: string | null = null\n const devtoolsPackages = [\n '@tanstack/react-devtools',\n '@tanstack/solid-devtools',\n '@tanstack/vue-devtools',\n '@tanstack/svelte-devtools',\n '@tanstack/angular-devtools',\n ]\n\n trav(ast, {\n ImportDeclaration(path) {\n const importSource = path.node.source.value\n if (devtoolsPackages.includes(importSource)) {\n // Check for: import { TanStackDevtools } from '@tanstack/...'\n const namedImport = path.node.specifiers.find(\n (spec) =>\n t.isImportSpecifier(spec) &&\n t.isIdentifier(spec.imported) &&\n spec.imported.name === 'TanStackDevtools',\n )\n if (namedImport && t.isImportSpecifier(namedImport)) {\n componentName = namedImport.local.name\n path.stop()\n return\n }\n\n // Check for: import * as DevtoolsName from '@tanstack/...'\n const namespaceImport = path.node.specifiers.find((spec) =>\n t.isImportNamespaceSpecifier(spec),\n )\n if (namespaceImport && t.isImportNamespaceSpecifier(namespaceImport)) {\n // For namespace imports, we need to look for DevtoolsName.TanStackDevtools\n componentName = `${namespaceImport.local.name}.TanStackDevtools`\n path.stop()\n return\n }\n }\n },\n })\n\n return componentName\n}\n\nexport const transformAndInject = (\n ast: ParseResult<Babel.File>,\n injection: PluginInjection,\n devtoolsComponentName: string,\n) => {\n let didTransform = false\n\n // Use pluginImport if provided, otherwise generate from package name\n const importName = injection.pluginImport?.importName\n const pluginType = injection.pluginImport?.type || 'jsx'\n const displayName = injection.pluginName\n\n if (!importName) {\n return false\n }\n // Handle namespace imports like DevtoolsModule.TanStackDevtools\n const isNamespaceImport = devtoolsComponentName.includes('.')\n\n // Find and modify the TanStackDevtools JSX element\n trav(ast, {\n JSXOpeningElement(path) {\n const elementName = path.node.name\n let matches = false\n\n if (isNamespaceImport) {\n // Handle <DevtoolsModule.TanStackDevtools />\n if (t.isJSXMemberExpression(elementName)) {\n const fullName = `${t.isJSXIdentifier(elementName.object) ? elementName.object.name : ''}.${t.isJSXIdentifier(elementName.property) ? elementName.property.name : ''}`\n matches = fullName === devtoolsComponentName\n }\n } else {\n // Handle <TanStackDevtools /> or <RenamedDevtools />\n matches =\n t.isJSXIdentifier(elementName) &&\n elementName.name === devtoolsComponentName\n }\n\n if (matches) {\n // Find the plugins prop\n const pluginsProp = path.node.attributes.find(\n (attr) =>\n t.isJSXAttribute(attr) &&\n t.isJSXIdentifier(attr.name) &&\n attr.name.name === 'plugins',\n )\n // plugins found\n if (pluginsProp && t.isJSXAttribute(pluginsProp)) {\n // Check if plugins prop has a value\n if (\n pluginsProp.value &&\n t.isJSXExpressionContainer(pluginsProp.value)\n ) {\n const expression = pluginsProp.value.expression\n\n // If it's an array expression, add our plugin to it\n if (t.isArrayExpression(expression)) {\n // Check if plugin already exists\n const pluginExists = expression.elements.some((element) => {\n if (!element) return false\n\n // For function-based plugins, check if the function call exists\n if (pluginType === 'function') {\n return (\n t.isCallExpression(element) &&\n t.isIdentifier(element.callee) &&\n element.callee.name === importName\n )\n }\n\n // For JSX plugins, check object with name property\n if (!t.isObjectExpression(element)) return false\n\n return element.properties.some((prop) => {\n if (\n !t.isObjectProperty(prop) ||\n !t.isIdentifier(prop.key) ||\n prop.key.name !== 'name'\n ) {\n return false\n }\n\n return (\n t.isStringLiteral(prop.value) &&\n prop.value.value === displayName\n )\n })\n })\n\n if (!pluginExists) {\n // For function-based plugins, add them directly as function calls\n // For JSX plugins, wrap them in objects with name and render\n if (pluginType === 'function') {\n // Add directly: FormDevtoolsPlugin()\n expression.elements.push(\n t.callExpression(t.identifier(importName), []),\n )\n } else {\n // Add as object: { name: \"...\", render: <Component /> }\n const renderValue = t.jsxElement(\n t.jsxOpeningElement(t.jsxIdentifier(importName), [], true),\n null,\n [],\n true,\n )\n\n expression.elements.push(\n t.objectExpression([\n t.objectProperty(\n t.identifier('name'),\n t.stringLiteral(displayName),\n ),\n t.objectProperty(t.identifier('render'), renderValue),\n ]),\n )\n }\n\n didTransform = true\n }\n }\n }\n } else {\n // No plugins prop exists, create one with our plugin\n // For function-based plugins, add them directly as function calls\n // For JSX plugins, wrap them in objects with name and render\n let pluginElement\n if (pluginType === 'function') {\n // Add directly: plugins={[FormDevtoolsPlugin()]}\n pluginElement = t.callExpression(t.identifier(importName), [])\n } else {\n // Add as object: plugins={[{ name: \"...\", render: <Component /> }]}\n const renderValue = t.jsxElement(\n t.jsxOpeningElement(t.jsxIdentifier(importName), [], true),\n null,\n [],\n true,\n )\n\n pluginElement = t.objectExpression([\n t.objectProperty(\n t.identifier('name'),\n t.stringLiteral(displayName),\n ),\n t.objectProperty(t.identifier('render'), renderValue),\n ])\n }\n\n path.node.attributes.push(\n t.jsxAttribute(\n t.jsxIdentifier('plugins'),\n t.jsxExpressionContainer(t.arrayExpression([pluginElement])),\n ),\n )\n\n didTransform = true\n }\n }\n },\n })\n\n // Add import at the top of the file if transform happened\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (didTransform) {\n const importDeclaration = t.importDeclaration(\n [t.importSpecifier(t.identifier(importName), t.identifier(importName))],\n t.stringLiteral(injection.packageName),\n )\n\n // Find the last import declaration\n let lastImportIndex = -1\n ast.program.body.forEach((node, index) => {\n if (t.isImportDeclaration(node)) {\n lastImportIndex = index\n }\n })\n\n // Insert after the last import or at the beginning\n ast.program.body.splice(lastImportIndex + 1, 0, importDeclaration)\n }\n\n return didTransform\n}\n\n/**\n * Detects if a file contains TanStack devtools import\n */\nexport function detectDevtoolsFile(code: string): boolean {\n return detectDevtoolsImport(code)\n}\n\n/**\n * Injects a plugin into the TanStackDevtools component in a file\n * Reads the file, transforms it, and writes it back\n */\nexport function injectPluginIntoFile(\n filePath: string,\n injection: PluginInjection,\n): { success: boolean; error?: string } {\n try {\n // Read the file\n const code = readFileSync(filePath, 'utf-8')\n\n // Parse the code\n const ast = parse(code, {\n sourceType: 'module',\n plugins: ['jsx', 'typescript'],\n })\n\n // Find the devtools component name (handles renamed imports)\n const devtoolsComponentName = findDevtoolsComponentName(ast)\n if (!devtoolsComponentName) {\n return {\n success: false,\n error: 'Could not find TanStackDevtools import',\n }\n }\n\n // Transform and inject\n const didTransform = transformAndInject(\n ast,\n injection,\n devtoolsComponentName,\n )\n\n if (!didTransform) {\n return {\n success: false,\n error: 'Plugin already exists or no TanStackDevtools component found',\n }\n }\n\n // Generate the new code\n const result = gen(ast, {\n sourceMaps: false,\n retainLines: false,\n })\n\n // Write back to file\n writeFileSync(filePath, result.code, 'utf-8')\n\n return { success: true }\n } catch (e) {\n console.error('Error injecting plugin:', e)\n return {\n success: false,\n error: e instanceof Error ? e.message : 'Unknown error',\n }\n }\n}\n"],"names":[],"mappings":";;;;AAYA,MAAM,uBAAuB,CAAC,SAA0B;AACtD,QAAM,mBAAmB;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGF,MAAI;AACF,UAAM,MAAM,MAAM,MAAM;AAAA,MACtB,YAAY;AAAA,MACZ,SAAS,CAAC,OAAO,YAAY;AAAA,IAAA,CAC9B;AAED,QAAI,oBAAoB;AAExB,SAAK,KAAK;AAAA,MACR,kBAAkB,MAAM;AACtB,cAAM,eAAe,KAAK,KAAK,OAAO;AACtC,YAAI,iBAAiB,SAAS,YAAY,GAAG;AAC3C,8BAAoB;AACpB,eAAK,KAAA;AAAA,QACP;AAAA,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AAa,QAAQ,EAAE,UAAU;AAAA,IAAA;AAAA,EAE5C;AACF;"}
|
|
1
|
+
{"version":3,"file":"inject-plugin.js","names":[],"sources":["../../src/inject-plugin.ts"],"sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs'\nimport { gen, parse, t, trav } from './babel'\nimport type { PluginInjection } from '@tanstack/devtools-client'\nimport type { types as Babel } from '@babel/core'\nimport type { ParseResult } from '@babel/parser'\n\n/**\n * Detects if a file imports TanStack devtools packages\n * Handles: import X from '@tanstack/react-devtools'\n * import * as X from '@tanstack/react-devtools'\n * import { TanStackDevtools } from '@tanstack/react-devtools'\n */\nconst detectDevtoolsImport = (code: string): boolean => {\n const devtoolsPackages = [\n '@tanstack/react-devtools',\n '@tanstack/solid-devtools',\n '@tanstack/vue-devtools',\n '@tanstack/svelte-devtools',\n '@tanstack/angular-devtools',\n ]\n\n try {\n const ast = parse(code, {\n sourceType: 'module',\n plugins: ['jsx', 'typescript'],\n })\n\n let hasDevtoolsImport = false\n\n trav(ast, {\n ImportDeclaration(path) {\n const importSource = path.node.source.value\n if (devtoolsPackages.includes(importSource)) {\n hasDevtoolsImport = true\n path.stop()\n }\n },\n })\n\n return hasDevtoolsImport\n } catch (e) {\n return false\n }\n}\n\n/**\n * Finds the TanStackDevtools component name in the file\n * Handles renamed imports and namespace imports\n */\nexport const findDevtoolsComponentName = (\n ast: ParseResult<Babel.File>,\n): string | null => {\n let componentName: string | null = null\n const devtoolsPackages = [\n '@tanstack/react-devtools',\n '@tanstack/solid-devtools',\n '@tanstack/vue-devtools',\n '@tanstack/svelte-devtools',\n '@tanstack/angular-devtools',\n ]\n\n trav(ast, {\n ImportDeclaration(path) {\n const importSource = path.node.source.value\n if (devtoolsPackages.includes(importSource)) {\n // Check for: import { TanStackDevtools } from '@tanstack/...'\n const namedImport = path.node.specifiers.find(\n (spec) =>\n t.isImportSpecifier(spec) &&\n t.isIdentifier(spec.imported) &&\n spec.imported.name === 'TanStackDevtools',\n )\n if (namedImport && t.isImportSpecifier(namedImport)) {\n componentName = namedImport.local.name\n path.stop()\n return\n }\n\n // Check for: import * as DevtoolsName from '@tanstack/...'\n const namespaceImport = path.node.specifiers.find((spec) =>\n t.isImportNamespaceSpecifier(spec),\n )\n if (namespaceImport && t.isImportNamespaceSpecifier(namespaceImport)) {\n // For namespace imports, we need to look for DevtoolsName.TanStackDevtools\n componentName = `${namespaceImport.local.name}.TanStackDevtools`\n path.stop()\n return\n }\n }\n },\n })\n\n return componentName\n}\n\nexport const transformAndInject = (\n ast: ParseResult<Babel.File>,\n injection: PluginInjection,\n devtoolsComponentName: string,\n) => {\n let didTransform = false\n\n // Use pluginImport if provided, otherwise generate from package name\n const importName = injection.pluginImport?.importName\n const pluginType = injection.pluginImport?.type || 'jsx'\n const displayName = injection.pluginName\n\n if (!importName) {\n return false\n }\n // Handle namespace imports like DevtoolsModule.TanStackDevtools\n const isNamespaceImport = devtoolsComponentName.includes('.')\n\n // Find and modify the TanStackDevtools JSX element\n trav(ast, {\n JSXOpeningElement(path) {\n const elementName = path.node.name\n let matches = false\n\n if (isNamespaceImport) {\n // Handle <DevtoolsModule.TanStackDevtools />\n if (t.isJSXMemberExpression(elementName)) {\n const fullName = `${t.isJSXIdentifier(elementName.object) ? elementName.object.name : ''}.${t.isJSXIdentifier(elementName.property) ? elementName.property.name : ''}`\n matches = fullName === devtoolsComponentName\n }\n } else {\n // Handle <TanStackDevtools /> or <RenamedDevtools />\n matches =\n t.isJSXIdentifier(elementName) &&\n elementName.name === devtoolsComponentName\n }\n\n if (matches) {\n // Find the plugins prop\n const pluginsProp = path.node.attributes.find(\n (attr) =>\n t.isJSXAttribute(attr) &&\n t.isJSXIdentifier(attr.name) &&\n attr.name.name === 'plugins',\n )\n // plugins found\n if (pluginsProp && t.isJSXAttribute(pluginsProp)) {\n // Check if plugins prop has a value\n if (\n pluginsProp.value &&\n t.isJSXExpressionContainer(pluginsProp.value)\n ) {\n const expression = pluginsProp.value.expression\n\n // If it's an array expression, add our plugin to it\n if (t.isArrayExpression(expression)) {\n // Check if plugin already exists\n const pluginExists = expression.elements.some((element) => {\n if (!element) return false\n\n // For function-based plugins, check if the function call exists\n if (pluginType === 'function') {\n return (\n t.isCallExpression(element) &&\n t.isIdentifier(element.callee) &&\n element.callee.name === importName\n )\n }\n\n // For JSX plugins, check object with name property\n if (!t.isObjectExpression(element)) return false\n\n return element.properties.some((prop) => {\n if (\n !t.isObjectProperty(prop) ||\n !t.isIdentifier(prop.key) ||\n prop.key.name !== 'name'\n ) {\n return false\n }\n\n return (\n t.isStringLiteral(prop.value) &&\n prop.value.value === displayName\n )\n })\n })\n\n if (!pluginExists) {\n // For function-based plugins, add them directly as function calls\n // For JSX plugins, wrap them in objects with name and render\n if (pluginType === 'function') {\n // Add directly: FormDevtoolsPlugin()\n expression.elements.push(\n t.callExpression(t.identifier(importName), []),\n )\n } else {\n // Add as object: { name: \"...\", render: <Component /> }\n const renderValue = t.jsxElement(\n t.jsxOpeningElement(t.jsxIdentifier(importName), [], true),\n null,\n [],\n true,\n )\n\n expression.elements.push(\n t.objectExpression([\n t.objectProperty(\n t.identifier('name'),\n t.stringLiteral(displayName),\n ),\n t.objectProperty(t.identifier('render'), renderValue),\n ]),\n )\n }\n\n didTransform = true\n }\n }\n }\n } else {\n // No plugins prop exists, create one with our plugin\n // For function-based plugins, add them directly as function calls\n // For JSX plugins, wrap them in objects with name and render\n let pluginElement\n if (pluginType === 'function') {\n // Add directly: plugins={[FormDevtoolsPlugin()]}\n pluginElement = t.callExpression(t.identifier(importName), [])\n } else {\n // Add as object: plugins={[{ name: \"...\", render: <Component /> }]}\n const renderValue = t.jsxElement(\n t.jsxOpeningElement(t.jsxIdentifier(importName), [], true),\n null,\n [],\n true,\n )\n\n pluginElement = t.objectExpression([\n t.objectProperty(\n t.identifier('name'),\n t.stringLiteral(displayName),\n ),\n t.objectProperty(t.identifier('render'), renderValue),\n ])\n }\n\n path.node.attributes.push(\n t.jsxAttribute(\n t.jsxIdentifier('plugins'),\n t.jsxExpressionContainer(t.arrayExpression([pluginElement])),\n ),\n )\n\n didTransform = true\n }\n }\n },\n })\n\n // Add import at the top of the file if transform happened\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (didTransform) {\n const importDeclaration = t.importDeclaration(\n [t.importSpecifier(t.identifier(importName), t.identifier(importName))],\n t.stringLiteral(injection.packageName),\n )\n\n // Find the last import declaration\n let lastImportIndex = -1\n ast.program.body.forEach((node, index) => {\n if (t.isImportDeclaration(node)) {\n lastImportIndex = index\n }\n })\n\n // Insert after the last import or at the beginning\n ast.program.body.splice(lastImportIndex + 1, 0, importDeclaration)\n }\n\n return didTransform\n}\n\n/**\n * Detects if a file contains TanStack devtools import\n */\nexport function detectDevtoolsFile(code: string): boolean {\n return detectDevtoolsImport(code)\n}\n\n/**\n * Injects a plugin into the TanStackDevtools component in a file\n * Reads the file, transforms it, and writes it back\n */\nexport function injectPluginIntoFile(\n filePath: string,\n injection: PluginInjection,\n): { success: boolean; error?: string } {\n try {\n // Read the file\n const code = readFileSync(filePath, 'utf-8')\n\n // Parse the code\n const ast = parse(code, {\n sourceType: 'module',\n plugins: ['jsx', 'typescript'],\n })\n\n // Find the devtools component name (handles renamed imports)\n const devtoolsComponentName = findDevtoolsComponentName(ast)\n if (!devtoolsComponentName) {\n return {\n success: false,\n error: 'Could not find TanStackDevtools import',\n }\n }\n\n // Transform and inject\n const didTransform = transformAndInject(\n ast,\n injection,\n devtoolsComponentName,\n )\n\n if (!didTransform) {\n return {\n success: false,\n error: 'Plugin already exists or no TanStackDevtools component found',\n }\n }\n\n // Generate the new code\n const result = gen(ast, {\n sourceMaps: false,\n retainLines: false,\n })\n\n // Write back to file\n writeFileSync(filePath, result.code, 'utf-8')\n\n return { success: true }\n } catch (e) {\n console.error('Error injecting plugin:', e)\n return {\n success: false,\n error: e instanceof Error ? e.message : 'Unknown error',\n }\n }\n}\n"],"mappings":";;;;;;;;;AAYA,IAAM,wBAAwB,SAA0B;CACtD,MAAM,mB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