@kezh/my-custom-js-converter 0.0.17 → 0.0.19
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/core/encode.js +24 -7
- package/package.json +1 -1
package/core/encode.js
CHANGED
|
@@ -99,8 +99,11 @@ function getImportMethods(modPathByName, methodNamesByMod) {
|
|
|
99
99
|
return [];
|
|
100
100
|
}
|
|
101
101
|
const modMethodNames = modMethods.map((m) => m.key.name);
|
|
102
|
+
console.log(`mod methods => ${modMethodNames}`);
|
|
102
103
|
const useMethodNames = methodNamesByMod.get(name);
|
|
104
|
+
console.log(`use methods => ${useMethodNames}`);
|
|
103
105
|
const inlineMethodNames = getInlineThisMethodNames(modMethodNames, useMethodNames, modAst);
|
|
106
|
+
console.log(`inline methods => ${inlineMethodNames}`);
|
|
104
107
|
let mergeMethodNames = [
|
|
105
108
|
...new Set([...useMethodNames, ...inlineMethodNames])
|
|
106
109
|
];
|
|
@@ -241,13 +244,27 @@ function getSrcMethodNames(entry, srcAst) {
|
|
|
241
244
|
function getMethods(entry, ast) {
|
|
242
245
|
const methods = [];
|
|
243
246
|
(0, traverse_1.default)(ast, {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
247
|
+
Program(path) {
|
|
248
|
+
path.node.body.forEach((statement) => {
|
|
249
|
+
if (core_1.types.isVariableDeclaration(statement)) {
|
|
250
|
+
const variableDeclaration = statement;
|
|
251
|
+
variableDeclaration.declarations.filter((declaration) => {
|
|
252
|
+
if (core_1.types.isIdentifier(declaration.id)) {
|
|
253
|
+
const id = declaration.id;
|
|
254
|
+
if (id.name === entry) {
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return false;
|
|
259
|
+
}).forEach((declaration) => {
|
|
260
|
+
if (core_1.types.isObjectExpression(declaration.init)) {
|
|
261
|
+
const init = declaration.init;
|
|
262
|
+
const objectMethods = init.properties.filter(property => core_1.types.isObjectMethod(property));
|
|
263
|
+
methods.push(...objectMethods);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
});
|
|
251
268
|
}
|
|
252
269
|
});
|
|
253
270
|
return methods;
|