jscrambler-metro-plugin 8.4.2 → 8.4.3
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/lib/index.js +13 -1
- package/lib/sourceMaps.js +23 -5
- package/package.json +1 -1
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];
|