jscrambler-metro-plugin 8.4.1 → 8.4.3
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/index.js +13 -1
- package/lib/sourceMaps.js +23 -5
- package/package.json +2 -2
package/lib/index.js
CHANGED
@@ -192,12 +192,24 @@ async function obfuscateBundle(
|
|
192
192
|
return [`${chunks[0]}${globalThisPolyfill}`, ...chunks.slice(1)].join('\n');
|
193
193
|
}
|
194
194
|
|
195
|
+
let showSource = addShowSource;
|
196
|
+
let startAtFirstColumn = requireStartAtFirstColumn;
|
197
|
+
|
195
198
|
const obfuscatedCode = obfusctedUserFiles[i - 1];
|
199
|
+
const sourceFileIgnored = metroUserFilesOnly[i - 1] === obfuscatedCode;
|
200
|
+
|
201
|
+
if (sourceFileIgnored) {
|
202
|
+
// restore excluded files
|
203
|
+
showSource = false;
|
204
|
+
startAtFirstColumn = false;
|
205
|
+
debug && console.log(`debug Jscrambler File ${fileNames[i - 1]} was excluded`);
|
206
|
+
}
|
207
|
+
|
196
208
|
const tillCodeEnd = c.substr(
|
197
209
|
c.indexOf(JSCRAMBLER_END_ANNOTATION),
|
198
210
|
c.length
|
199
211
|
);
|
200
|
-
return `${acc}${JSCRAMBLER_BEG_ANNOTATION}${
|
212
|
+
return `${acc}${JSCRAMBLER_BEG_ANNOTATION}${showSource ? '"show source";' : ''}${startAtFirstColumn ? '\n' : ''}${obfuscatedCode}${tillCodeEnd}`;
|
201
213
|
}, '');
|
202
214
|
|
203
215
|
await writeFile(bundlePath, stripJscramblerTags(finalBundle));
|
package/lib/sourceMaps.js
CHANGED
@@ -36,9 +36,20 @@ module.exports = async function generateSourceMaps(payload) {
|
|
36
36
|
await jscrambler.downloadSourceMaps(Object.assign({protectionId}, config));
|
37
37
|
|
38
38
|
// read obfuscated source-map from filesystem
|
39
|
-
const obfuscatedSourceMaps = await Promise.all(
|
40
|
-
|
41
|
-
|
39
|
+
const obfuscatedSourceMaps = await Promise.all(
|
40
|
+
metroUserFilesOnly.map((c, i) =>
|
41
|
+
readFile(
|
42
|
+
`${JSCRAMBLER_SOURCE_MAPS_TEMP_FOLDER}/${fileNames[i]}.map`,
|
43
|
+
'utf8',
|
44
|
+
).catch((e) => {
|
45
|
+
if (e.code === 'ENOENT') {
|
46
|
+
// when a source file is excluded, the sourcemap is not produced
|
47
|
+
return null;
|
48
|
+
}
|
49
|
+
throw e;
|
50
|
+
}),
|
51
|
+
),
|
52
|
+
);
|
42
53
|
|
43
54
|
// read metro source-map
|
44
55
|
const metroSourceMap = await readFile(bundleSourceMapPath, 'utf8');
|
@@ -46,7 +57,10 @@ module.exports = async function generateSourceMaps(payload) {
|
|
46
57
|
|
47
58
|
const metroSourceMapConsumer = new sourceMap.SourceMapConsumer(metroSourceMap);
|
48
59
|
const finalSourceMapGenerator = new sourceMap.SourceMapGenerator({file: bundlePath});
|
49
|
-
const ofuscatedSourceMapConsumers = obfuscatedSourceMaps.map(map =>
|
60
|
+
const ofuscatedSourceMapConsumers = obfuscatedSourceMaps.map((map) =>
|
61
|
+
// when a source file is excluded, the sourcemap is not produced
|
62
|
+
map ? new sourceMap.SourceMapConsumer(map) : null,
|
63
|
+
);
|
50
64
|
|
51
65
|
// add all original sources and sourceContents
|
52
66
|
metroSourceMapConsumer.sources.forEach(function (sourceFile) {
|
@@ -80,7 +94,11 @@ module.exports = async function generateSourceMaps(payload) {
|
|
80
94
|
shiftLines = tmpShiftLine;
|
81
95
|
}
|
82
96
|
|
83
|
-
if (
|
97
|
+
if (
|
98
|
+
fileNamesIndex !== -1 &&
|
99
|
+
/* check if sourceMap was loaded */
|
100
|
+
ofuscatedSourceMapConsumers[fileNamesIndex]
|
101
|
+
) {
|
84
102
|
/* jscrambler obfuscated files */
|
85
103
|
const {lineStart, lineEnd, columnStart} = metroBundleLocs[fileNamesIndex];
|
86
104
|
const {lineStart: finalLineStart, lineEnd: finalLineEnd} = finalBundleLocs[fileNamesIndex];
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "jscrambler-metro-plugin",
|
3
|
-
"version": "8.4.
|
3
|
+
"version": "8.4.3",
|
4
4
|
"description": "A plugin to use metro with Jscrambler",
|
5
5
|
"exports": "./lib/index.js",
|
6
6
|
"peerDependencies": {
|
@@ -9,7 +9,7 @@
|
|
9
9
|
"dependencies": {
|
10
10
|
"commander": "^2.20.0",
|
11
11
|
"fs-extra": "^8.0.1",
|
12
|
-
"jscrambler": "8.4.
|
12
|
+
"jscrambler": "8.4.2"
|
13
13
|
},
|
14
14
|
"keywords": [
|
15
15
|
"jscrambler",
|