@kezh/my-custom-js-converter 1.1.3 → 1.1.6
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/context/map_context.js +20 -10
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const ast_1 = require("../util/ast");
|
|
11
11
|
const parent_path_1 = require("../util/parent_path");
|
|
12
|
+
const os_1 = require("os");
|
|
12
13
|
class MapContext {
|
|
13
14
|
constructor(srcPath = "", entry = "", outDir = "", initMap = false) {
|
|
14
15
|
this.map = new map_config_1.MapConfig();
|
|
@@ -87,7 +88,7 @@ class MapContext {
|
|
|
87
88
|
catch (err) {
|
|
88
89
|
fs_1.default.mkdirSync(this.outDir);
|
|
89
90
|
}
|
|
90
|
-
fs_1.default.writeFileSync(outPath, json, "utf-8");
|
|
91
|
+
fs_1.default.writeFileSync(outPath, json.replace(/\n/gm, os_1.EOL), "utf-8");
|
|
91
92
|
}
|
|
92
93
|
buildMapContext(inPath, entry, root) {
|
|
93
94
|
const srcAst = (0, ast_1.parseSrcAst)(inPath);
|
|
@@ -153,16 +154,25 @@ class MapContext {
|
|
|
153
154
|
const inlineMethods = (0, ast_1.getInlineMethodsByMethodName)(astMap.get(method[0]), method[0], method[1], useMethodNameMap);
|
|
154
155
|
readyStack.push(...inlineMethods.map((m) => m.split("#")));
|
|
155
156
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
157
|
+
const filterMapConfig = new map_config_1.MapConfig();
|
|
158
|
+
this.getModNames()
|
|
159
|
+
.map((modName) => [modName, this.getMod(modName)])
|
|
160
|
+
.filter((modInfo) => modInfo[1])
|
|
161
|
+
.forEach((modInfo) => {
|
|
162
|
+
const filterDeps = new map_config_1.Dependencies();
|
|
163
|
+
const mod = modInfo[1];
|
|
164
|
+
const deps = mod.dependencies;
|
|
165
|
+
Object.keys(deps)
|
|
166
|
+
.filter((depName) => [...filterMethodMap.keys()].includes(depName))
|
|
167
|
+
.map((depName) => {
|
|
168
|
+
const filterMethods = deps[depName].methods.filter((method) => filterMethodMap.get(depName).has(method));
|
|
169
|
+
return [depName, new map_config_1.Dependency(filterMethods)];
|
|
170
|
+
})
|
|
171
|
+
.forEach((depInfo) => (filterDeps[depInfo[0]] = depInfo[1]));
|
|
172
|
+
const filterMod = new map_config_1.Mod(mod === null || mod === void 0 ? void 0 : mod.src, filterDeps);
|
|
173
|
+
filterMapConfig[modInfo[0]] = filterMod;
|
|
165
174
|
});
|
|
175
|
+
this.map = filterMapConfig;
|
|
166
176
|
}
|
|
167
177
|
}
|
|
168
178
|
exports.MapContext = MapContext;
|