unpeek 4.0.1 → 4.2.0
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/README.md +21 -13
- package/README.tr.md +21 -13
- package/dist/adapters/esbuild.cjs +5 -5
- package/dist/adapters/esbuild.d.cts +1 -1
- package/dist/adapters/esbuild.d.ts +1 -1
- package/dist/adapters/esbuild.js +3 -3
- package/dist/adapters/next/adapter.cjs +6 -6
- package/dist/adapters/next/adapter.d.cts +1 -1
- package/dist/adapters/next/adapter.d.ts +1 -1
- package/dist/adapters/next/adapter.js +5 -5
- package/dist/adapters/next/index.cjs +6 -6
- package/dist/adapters/next/index.js +5 -5
- package/dist/adapters/rollup.cjs +5 -5
- package/dist/adapters/rollup.d.cts +1 -1
- package/dist/adapters/rollup.d.ts +1 -1
- package/dist/adapters/rollup.js +3 -3
- package/dist/adapters/rspack.cjs +5 -5
- package/dist/adapters/rspack.d.cts +1 -1
- package/dist/adapters/rspack.d.ts +1 -1
- package/dist/adapters/rspack.js +3 -3
- package/dist/adapters/vite.cjs +5 -5
- package/dist/adapters/vite.d.cts +1 -1
- package/dist/adapters/vite.d.ts +1 -1
- package/dist/adapters/vite.js +3 -3
- package/dist/adapters/webpack.cjs +5 -5
- package/dist/adapters/webpack.d.cts +1 -1
- package/dist/adapters/webpack.d.ts +1 -1
- package/dist/adapters/webpack.js +3 -3
- package/dist/browser.cjs +2 -2
- package/dist/browser.d.cts +7 -6
- package/dist/browser.d.ts +7 -6
- package/dist/browser.js +1 -1
- package/dist/{chunk-TYL32LUK.js → chunk-32GLSJAW.js} +91 -569
- package/dist/{chunk-W77DAC3H.js → chunk-6EWFL4LQ.js} +16 -0
- package/dist/{chunk-3GDHYBVH.cjs → chunk-AD6UFBPA.cjs} +96 -574
- package/dist/{chunk-XYN5NYSD.js → chunk-APQOBFRO.js} +21 -15
- package/dist/{chunk-LGTXAAZH.js → chunk-BL2UXZGD.js} +3155 -481
- package/dist/{chunk-X6EETCO6.cjs → chunk-BQ2O6HM5.cjs} +16 -0
- package/dist/{chunk-4G2HCME5.js → chunk-GCWXTWTN.js} +30 -13
- package/dist/{chunk-4SOS3LRV.js → chunk-K77WRITN.js} +6 -6
- package/dist/{chunk-7ZEVJ4OR.cjs → chunk-KIAYVIC5.cjs} +40 -34
- package/dist/{chunk-M46SFJE7.cjs → chunk-MSECP2P4.cjs} +3351 -677
- package/dist/{chunk-NNAAPDUS.cjs → chunk-SJK45WAU.cjs} +8 -8
- package/dist/{chunk-OTA75YI6.cjs → chunk-UUJLTW7O.cjs} +53 -36
- package/dist/cli/index.js +2808 -528
- package/dist/{config-Y6JwVGwX.d.cts → config-BFAZrfjQ.d.cts} +2 -0
- package/dist/{config-Y6JwVGwX.d.ts → config-BFAZrfjQ.d.ts} +2 -0
- package/dist/config.cjs +2 -2
- package/dist/config.d.cts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/{index-COVHErnx.d.cts → index-Bo4S_VVM.d.cts} +1 -1
- package/dist/{index-0O1WSfVP.d.ts → index-CKdYVt_L.d.ts} +1 -1
- package/dist/index.cjs +171 -31
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +156 -16
- package/dist/plugins/unplugin.cjs +4 -4
- package/dist/plugins/unplugin.js +3 -3
- package/dist/{types-CMtZnV8C.d.ts → types-BDpFfokR.d.ts} +6 -3
- package/dist/{types-D93PuOOl.d.cts → types-WIoud53X.d.cts} +6 -3
- package/package.json +1 -1
|
@@ -95,11 +95,24 @@ function toRegExpArray(val) {
|
|
|
95
95
|
function clonePatterns(patterns) {
|
|
96
96
|
return patterns ? [...patterns] : void 0;
|
|
97
97
|
}
|
|
98
|
+
function validateSeed(val) {
|
|
99
|
+
if (val === void 0) return void 0;
|
|
100
|
+
if (typeof val !== "number" || !Number.isFinite(val)) {
|
|
101
|
+
throw new (0, _chunkL6BOM5VScjs.UnpeekError)(
|
|
102
|
+
"ERR_CONFIG_INVALID",
|
|
103
|
+
'Configuration "seed" must be a finite number.'
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
return val;
|
|
107
|
+
}
|
|
98
108
|
function normalizeConfig(raw) {
|
|
99
109
|
if (!isRecord(raw)) {
|
|
100
110
|
return {};
|
|
101
111
|
}
|
|
102
112
|
const result = { ...raw };
|
|
113
|
+
if ("seed" in raw && raw.seed !== void 0) {
|
|
114
|
+
result.seed = validateSeed(raw.seed);
|
|
115
|
+
}
|
|
103
116
|
if (isRecord(raw.hotPath)) {
|
|
104
117
|
result.hotPath = {
|
|
105
118
|
...raw.hotPath,
|
|
@@ -137,6 +150,7 @@ function mergeTwoConfigs(base, override) {
|
|
|
137
150
|
target: _nullishCoalesce(override.target, () => ( base.target)),
|
|
138
151
|
profile: _nullishCoalesce(override.profile, () => ( base.profile)),
|
|
139
152
|
tier: _nullishCoalesce(override.tier, () => ( base.tier)),
|
|
153
|
+
seed: _nullishCoalesce(override.seed, () => ( base.seed)),
|
|
140
154
|
coldFlow: _nullishCoalesce(override.coldFlow, () => ( base.coldFlow)),
|
|
141
155
|
outDir: _nullishCoalesce(override.outDir, () => ( base.outDir)),
|
|
142
156
|
scrubPaths: _nullishCoalesce(override.scrubPaths, () => ( base.scrubPaths)),
|
|
@@ -230,9 +244,11 @@ function mergeTwoConfigs(base, override) {
|
|
|
230
244
|
};
|
|
231
245
|
}
|
|
232
246
|
function mergeUnpeekConfig(base, override) {
|
|
247
|
+
validateSeed(base.seed);
|
|
233
248
|
if (!override) {
|
|
234
249
|
return { ...base };
|
|
235
250
|
}
|
|
251
|
+
validateSeed(override.seed);
|
|
236
252
|
const effectiveBase = override.profile ? mergeTwoConfigs(base, _chunkURPPSTHZcjs.PRESETS[override.profile]) : base;
|
|
237
253
|
return mergeTwoConfigs(effectiveBase, override);
|
|
238
254
|
}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
-
chainSourceMaps,
|
|
3
|
-
computeDeterministicDebugId,
|
|
4
2
|
extractDebugId,
|
|
5
|
-
|
|
3
|
+
matchesGlobPattern,
|
|
6
4
|
replaceOrAppendDebugId,
|
|
7
|
-
shiftSourceMapLines,
|
|
8
5
|
stripDebugIdComments,
|
|
9
6
|
stripSourceMapComments
|
|
10
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-32GLSJAW.js";
|
|
11
8
|
import {
|
|
9
|
+
chainSourceMaps,
|
|
10
|
+
computeDeterministicDebugId,
|
|
12
11
|
computeFnv1aHash,
|
|
13
12
|
deriveWindowKeySymbol,
|
|
13
|
+
flattenSourceMapSections,
|
|
14
14
|
generateRuntimeShield,
|
|
15
|
+
shiftSourceMapLines,
|
|
15
16
|
transformJavaScript
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-BL2UXZGD.js";
|
|
17
18
|
|
|
18
19
|
// src/plugins/unplugin.ts
|
|
19
20
|
import fs from "fs";
|
|
@@ -33,6 +34,17 @@ function isExcludedClientAsset(fileName, config) {
|
|
|
33
34
|
if (config?.target !== "worker" && SW_OR_WORKBOX_PATTERN.test(norm)) {
|
|
34
35
|
return true;
|
|
35
36
|
}
|
|
37
|
+
const cleanRel = norm.replace(/^\/+/, "");
|
|
38
|
+
if (config?.filter?.include && config.filter.include.length > 0) {
|
|
39
|
+
if (!config.filter.include.some((pattern) => matchesGlobPattern(cleanRel, pattern))) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (config?.filter?.exclude && config.filter.exclude.length > 0) {
|
|
44
|
+
if (config.filter.exclude.some((pattern) => matchesGlobPattern(cleanRel, pattern))) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
36
48
|
return false;
|
|
37
49
|
}
|
|
38
50
|
function createWebpackRawSource(sources, content) {
|
|
@@ -52,7 +64,7 @@ function createWebpackRawSource(sources, content) {
|
|
|
52
64
|
}
|
|
53
65
|
var unpeekPlugin = createUnplugin((options = {}) => {
|
|
54
66
|
const config = options.config;
|
|
55
|
-
const baseSeed = typeof options.seed === "number" ? options.seed : Math.floor(Math.random() * 2147483647) || 322420463;
|
|
67
|
+
const baseSeed = typeof options.seed === "number" && Number.isFinite(options.seed) ? options.seed : typeof config?.seed === "number" && Number.isFinite(config.seed) ? config.seed : Math.floor(Math.random() * 2147483647) || 322420463;
|
|
56
68
|
const deterrentMode = options.deterrentMode ?? config?.shield?.deterrentMode ?? "passive";
|
|
57
69
|
const detectHeadless = options.detectHeadless ?? config?.shield?.detectHeadless ?? false;
|
|
58
70
|
const injectRuntimeShield = options.injectRuntimeShield ?? true;
|
|
@@ -77,6 +89,7 @@ var unpeekPlugin = createUnplugin((options = {}) => {
|
|
|
77
89
|
codeToTransform = stripSourceMapComments(rawCode).code;
|
|
78
90
|
}
|
|
79
91
|
const shouldInjectShield = injectRuntimeShield && isEntry;
|
|
92
|
+
const shouldGenerateMap = requestMap || Boolean(inputMap);
|
|
80
93
|
const chunkSeed = computeFnv1aHash(fileName, baseSeed);
|
|
81
94
|
const transformOptions = {
|
|
82
95
|
seed: chunkSeed,
|
|
@@ -87,13 +100,15 @@ var unpeekPlugin = createUnplugin((options = {}) => {
|
|
|
87
100
|
shieldCoupled: injectRuntimeShield,
|
|
88
101
|
windowKeySymbol: masterSym,
|
|
89
102
|
expectedDelta: masterShield?.expectedDelta,
|
|
103
|
+
expectedStateHash: masterShield?.expectedStateHash,
|
|
104
|
+
originalSourceMap: inputMap,
|
|
90
105
|
deterrentMode,
|
|
91
106
|
detectHeadless,
|
|
92
107
|
aggressive,
|
|
93
|
-
config
|
|
108
|
+
config,
|
|
109
|
+
generateMap: shouldGenerateMap,
|
|
110
|
+
rootDir: process.cwd()
|
|
94
111
|
};
|
|
95
|
-
transformOptions.generateMap = requestMap || Boolean(inputMap);
|
|
96
|
-
transformOptions.rootDir = process.cwd();
|
|
97
112
|
const result = transformJavaScript(codeToTransform, transformOptions);
|
|
98
113
|
let finalCode = result.code;
|
|
99
114
|
let preambleLineOffset = 0;
|
|
@@ -116,7 +131,8 @@ var unpeekPlugin = createUnplugin((options = {}) => {
|
|
|
116
131
|
}
|
|
117
132
|
const inputMapDebugId = inputMap?.debugId ?? inputMap?.debug_id;
|
|
118
133
|
const hadDebugId = Boolean(fileDebugId || inputMapDebugId || result.debugId);
|
|
119
|
-
|
|
134
|
+
const shouldMintDebugId = hadDebugId || shouldGenerateMap && !result.skippedReason && Boolean(composedMap || inputMap);
|
|
135
|
+
if (shouldMintDebugId) {
|
|
120
136
|
const codeWithoutDebugId = stripDebugIdComments(finalCode);
|
|
121
137
|
const mintedDebugId = computeDeterministicDebugId(
|
|
122
138
|
codeWithoutDebugId,
|
|
@@ -336,7 +352,9 @@ var unpeekPlugin = createUnplugin((options = {}) => {
|
|
|
336
352
|
const jsOutCount = result.outputFiles.filter((f) => isSupportedJsAsset(f.path)).length;
|
|
337
353
|
for (const outFile of result.outputFiles) {
|
|
338
354
|
const normPath = outFile.path.replace(/\\/g, "/");
|
|
339
|
-
|
|
355
|
+
const relFromWork = path.relative(workDir, outFile.path).replace(/\\/g, "/");
|
|
356
|
+
const filterPath = relFromWork && !relFromWork.startsWith("..") && !path.isAbsolute(relFromWork) ? relFromWork : normPath;
|
|
357
|
+
if (!isSupportedJsAsset(normPath) || isExcludedClientAsset(filterPath, config)) {
|
|
340
358
|
continue;
|
|
341
359
|
}
|
|
342
360
|
const mapFile = mapFilesByPath.get(`${outFile.path}.map`);
|
|
@@ -347,7 +365,6 @@ var unpeekPlugin = createUnplugin((options = {}) => {
|
|
|
347
365
|
} catch {
|
|
348
366
|
}
|
|
349
367
|
}
|
|
350
|
-
const relFromWork = path.relative(workDir, outFile.path).replace(/\\/g, "/");
|
|
351
368
|
const isEntry = entryOutputs.size > 0 ? entryOutputs.has(outFile.path) || entryOutputs.has(relFromWork) || ENTRY_CHUNK_PATTERN.test(relFromWork) : ENTRY_CHUNK_PATTERN.test(relFromWork) || jsOutCount === 1;
|
|
352
369
|
const res = transformChunk(
|
|
353
370
|
outFile.text,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
protectProject,
|
|
3
3
|
serializeNextOptions
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-APQOBFRO.js";
|
|
5
5
|
import {
|
|
6
|
-
hasJsBundleFiles
|
|
7
|
-
|
|
8
|
-
} from "./chunk-TYL32LUK.js";
|
|
6
|
+
hasJsBundleFiles
|
|
7
|
+
} from "./chunk-32GLSJAW.js";
|
|
9
8
|
import {
|
|
10
|
-
computeFnv1aHash
|
|
11
|
-
|
|
9
|
+
computeFnv1aHash,
|
|
10
|
+
safeDecodeURIComponent
|
|
11
|
+
} from "./chunk-BL2UXZGD.js";
|
|
12
12
|
import {
|
|
13
13
|
UnpeekError,
|
|
14
14
|
__dirname,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkBQ2O6HM5cjs = require('./chunk-BQ2O6HM5.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -10,18 +10,18 @@ var _chunkX6EETCO6cjs = require('./chunk-X6EETCO6.cjs');
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
var _chunkAD6UFBPAcjs = require('./chunk-AD6UFBPA.cjs');
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
|
|
18
|
-
var _chunk3GDHYBVHcjs = require('./chunk-3GDHYBVH.cjs');
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _chunkMSECP2P4cjs = require('./chunk-MSECP2P4.cjs');
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
var _chunkL6BOM5VScjs = require('./chunk-L6BOM5VS.cjs');
|
|
@@ -199,7 +199,7 @@ function matchesManifestEntry(relPath, manifestEntries) {
|
|
|
199
199
|
function isEntryChunk(relPath, index, allRelPaths, manifestEntries, isWorkerTarget) {
|
|
200
200
|
const norm = relPath.replace(/\\/g, "/");
|
|
201
201
|
const base = _path2.default.basename(norm);
|
|
202
|
-
if (isWorkerTarget &&
|
|
202
|
+
if (isWorkerTarget && _chunkAD6UFBPAcjs.isWorkerOrServiceWorkerFile.call(void 0, norm)) {
|
|
203
203
|
return true;
|
|
204
204
|
}
|
|
205
205
|
if (matchesManifestEntry(norm, manifestEntries)) {
|
|
@@ -223,7 +223,7 @@ function readOriginalSourceMapForFile(filePath, relPath, vaultDir, deferVaultWri
|
|
|
223
223
|
candidates.push(`${filePath}.map`);
|
|
224
224
|
}
|
|
225
225
|
candidates.push(_path2.default.join(vaultDir, `${relPath}.map`));
|
|
226
|
-
const decodedRel =
|
|
226
|
+
const decodedRel = _chunkMSECP2P4cjs.safeDecodeURIComponent.call(void 0, relPath);
|
|
227
227
|
if (decodedRel !== relPath) {
|
|
228
228
|
candidates.push(_path2.default.join(vaultDir, `${decodedRel}.map`));
|
|
229
229
|
}
|
|
@@ -281,10 +281,10 @@ async function protectProject(options = {}) {
|
|
|
281
281
|
const startTime = performance.now();
|
|
282
282
|
const cwd = _path2.default.resolve(_nullishCoalesce(options.cwd, () => ( process.cwd())));
|
|
283
283
|
const effectiveConfigInput = options.profile ? { ..._nullishCoalesce(options.config, () => ( {})), profile: options.profile } : options.config;
|
|
284
|
-
const config = await
|
|
284
|
+
const config = await _chunkBQ2O6HM5cjs.loadUnpeekConfig.call(void 0, cwd, effectiveConfigInput);
|
|
285
285
|
const effectiveProfile = _nullishCoalesce(_nullishCoalesce(options.profile, () => ( config.profile)), () => ( "recommended"));
|
|
286
|
-
const { framework, outDir } =
|
|
287
|
-
const seed = typeof options.seed === "number" ? options.seed : Math.floor(Math.random() * 2147483647) || 1597463007;
|
|
286
|
+
const { framework, outDir } = _chunkAD6UFBPAcjs.detectTargetFramework.call(void 0, cwd, options.outDir, config);
|
|
287
|
+
const seed = typeof options.seed === "number" && Number.isFinite(options.seed) ? options.seed : typeof config.seed === "number" && Number.isFinite(config.seed) ? config.seed : Math.floor(Math.random() * 2147483647) || 1597463007;
|
|
288
288
|
const dryRun = Boolean(options.dryRun);
|
|
289
289
|
const keepPrivateMaps = _nullishCoalesce(_nullishCoalesce(options.keepPrivateMaps, () => ( _optionalChain([config, 'access', _7 => _7.sourcemaps, 'optionalAccess', _8 => _8.keepPrivate]))), () => ( true));
|
|
290
290
|
const privateMapsDir = _nullishCoalesce(_nullishCoalesce(options.privateMapsDir, () => ( _optionalChain([config, 'access', _9 => _9.sourcemaps, 'optionalAccess', _10 => _10.vaultDir]))), () => ( ".unpeek-maps"));
|
|
@@ -294,18 +294,18 @@ async function protectProject(options = {}) {
|
|
|
294
294
|
const minStringLength = _nullishCoalesce(_nullishCoalesce(options.minStringLength, () => ( _optionalChain([config, 'access', _15 => _15.vault, 'optionalAccess', _16 => _16.minStringLength]))), () => ( 4));
|
|
295
295
|
const aggressive = _nullishCoalesce(options.aggressive, () => ( (effectiveProfile === "strict" ? true : false)));
|
|
296
296
|
const scrubPaths = _nullishCoalesce(_nullishCoalesce(options.scrubPaths, () => ( config.scrubPaths)), () => ( (effectiveProfile === "strict" ? true : false)));
|
|
297
|
-
const masterSym =
|
|
298
|
-
const masterShield = injectRuntimeShield ?
|
|
297
|
+
const masterSym = _chunkMSECP2P4cjs.deriveWindowKeySymbol.call(void 0, seed);
|
|
298
|
+
const masterShield = injectRuntimeShield ? _chunkMSECP2P4cjs.generateRuntimeShield.call(void 0, {
|
|
299
299
|
seed,
|
|
300
300
|
deterrentMode,
|
|
301
301
|
detectHeadless,
|
|
302
302
|
windowKeySymbol: masterSym
|
|
303
303
|
}) : void 0;
|
|
304
304
|
const deferVaultWrites = dryRun || typeof options.maxGzipDelta === "number";
|
|
305
|
-
const vaultResult =
|
|
305
|
+
const vaultResult = _chunkAD6UFBPAcjs.relocateSourceMaps.call(void 0, outDir, cwd, keepPrivateMaps, privateMapsDir, false, config, {
|
|
306
306
|
dryRun: deferVaultWrites
|
|
307
307
|
});
|
|
308
|
-
const clientFiles =
|
|
308
|
+
const clientFiles = _chunkAD6UFBPAcjs.scanClientBundles.call(void 0, outDir, config);
|
|
309
309
|
const allRelPaths = clientFiles.map((f) => _path2.default.relative(outDir, f).replace(/\\/g, "/"));
|
|
310
310
|
const manifestEntries = collectManifestEntryFiles(outDir, cwd, config);
|
|
311
311
|
const isWorkerTarget = config.target === "worker";
|
|
@@ -350,9 +350,9 @@ async function protectProject(options = {}) {
|
|
|
350
350
|
for (let i = 0; i < clientFiles.length; i++) {
|
|
351
351
|
const filePath = clientFiles[i];
|
|
352
352
|
let codeToTransform = _fs2.default.readFileSync(filePath, "utf8");
|
|
353
|
-
const fileDebugId =
|
|
353
|
+
const fileDebugId = _chunkAD6UFBPAcjs.extractDebugId.call(void 0, codeToTransform);
|
|
354
354
|
if (codeToTransform.includes("sourceMappingURL=")) {
|
|
355
|
-
const strippedRes =
|
|
355
|
+
const strippedRes = _chunkAD6UFBPAcjs.stripSourceMapComments.call(void 0, codeToTransform);
|
|
356
356
|
codeToTransform = strippedRes.code;
|
|
357
357
|
if (strippedRes.stripped) {
|
|
358
358
|
vaultResult.strippedFilesCount++;
|
|
@@ -362,10 +362,11 @@ async function protectProject(options = {}) {
|
|
|
362
362
|
originalBytes += origBuf.byteLength;
|
|
363
363
|
allOrigBufs.push(origBuf);
|
|
364
364
|
const relPath = allRelPaths[i];
|
|
365
|
+
const originalMap = keepPrivateMaps ? readOriginalSourceMapForFile(filePath, relPath, vaultResult.vaultDir, deferVaultWrites) : void 0;
|
|
365
366
|
const preExistingHits = countPreExistingEvalCalls(codeToTransform);
|
|
366
367
|
const isEntry = isEntryChunk(relPath, i, allRelPaths, manifestEntries, isWorkerTarget);
|
|
367
368
|
const shouldInjectShield = injectRuntimeShield && isEntry;
|
|
368
|
-
const fileSeed =
|
|
369
|
+
const fileSeed = _chunkMSECP2P4cjs.computeFnv1aHash.call(void 0, `${relPath}:${i}`, seed);
|
|
369
370
|
const transformOptions = {
|
|
370
371
|
seed: fileSeed,
|
|
371
372
|
minStringLength,
|
|
@@ -375,15 +376,17 @@ async function protectProject(options = {}) {
|
|
|
375
376
|
shieldCoupled: injectRuntimeShield,
|
|
376
377
|
windowKeySymbol: masterSym,
|
|
377
378
|
expectedDelta: _optionalChain([masterShield, 'optionalAccess', _17 => _17.expectedDelta]),
|
|
379
|
+
expectedStateHash: _optionalChain([masterShield, 'optionalAccess', _18 => _18.expectedStateHash]),
|
|
380
|
+
originalSourceMap: originalMap,
|
|
378
381
|
deterrentMode,
|
|
379
382
|
detectHeadless,
|
|
380
383
|
aggressive,
|
|
381
384
|
scrubPaths,
|
|
382
|
-
config
|
|
385
|
+
config,
|
|
386
|
+
generateMap: keepPrivateMaps,
|
|
387
|
+
rootDir: cwd
|
|
383
388
|
};
|
|
384
|
-
|
|
385
|
-
transformOptions.rootDir = cwd;
|
|
386
|
-
const result = _chunkM46SFJE7cjs.transformJavaScript.call(void 0, codeToTransform, transformOptions);
|
|
389
|
+
const result = _chunkMSECP2P4cjs.transformJavaScript.call(void 0, codeToTransform, transformOptions);
|
|
387
390
|
if (result.skippedReason === "parse-error") {
|
|
388
391
|
diagnostics.push({
|
|
389
392
|
code: "PARSE_FALLBACK",
|
|
@@ -393,7 +396,7 @@ async function protectProject(options = {}) {
|
|
|
393
396
|
});
|
|
394
397
|
} else if (result.skippedReason === "already-protected") {
|
|
395
398
|
alreadyProtectedCount++;
|
|
396
|
-
const prevHits = _optionalChain([existingManifest, 'optionalAccess',
|
|
399
|
+
const prevHits = _optionalChain([existingManifest, 'optionalAccess', _19 => _19.preExistingEvalFiles, 'optionalAccess', _20 => _20[relPath]]);
|
|
397
400
|
if (Array.isArray(prevHits) && prevHits.length > 0) {
|
|
398
401
|
preExistingEvalFiles[relPath] = prevHits;
|
|
399
402
|
} else if (preExistingHits.length > 0) {
|
|
@@ -417,33 +420,33 @@ async function protectProject(options = {}) {
|
|
|
417
420
|
}
|
|
418
421
|
let finalCode = result.code;
|
|
419
422
|
let preambleLineOffset = 0;
|
|
420
|
-
if (shouldInjectShield && _optionalChain([masterShield, 'optionalAccess',
|
|
423
|
+
if (shouldInjectShield && _optionalChain([masterShield, 'optionalAccess', _21 => _21.preambleCode]) && !finalCode.includes(masterShield.integrityCheckFnName) && !finalCode.startsWith(masterShield.preambleCode)) {
|
|
421
424
|
const prefix = `${masterShield.preambleCode}
|
|
422
425
|
`;
|
|
423
426
|
preambleLineOffset = (_nullishCoalesce(prefix.match(/\n/g), () => ( []))).length;
|
|
424
427
|
finalCode = `${prefix}${finalCode}`;
|
|
425
428
|
}
|
|
426
|
-
const originalMap = keepPrivateMaps ? readOriginalSourceMapForFile(filePath, relPath, vaultResult.vaultDir, deferVaultWrites) : void 0;
|
|
427
429
|
const rawTransformMap = result.sourceMap;
|
|
428
|
-
const shiftedTransformMap = rawTransformMap ?
|
|
430
|
+
const shiftedTransformMap = rawTransformMap ? _chunkMSECP2P4cjs.shiftSourceMapLines.call(void 0, rawTransformMap, preambleLineOffset) : void 0;
|
|
429
431
|
let composedMap;
|
|
430
432
|
if (shiftedTransformMap && originalMap) {
|
|
431
|
-
composedMap =
|
|
433
|
+
composedMap = _chunkMSECP2P4cjs.chainSourceMaps.call(void 0, shiftedTransformMap, originalMap);
|
|
432
434
|
} else if (originalMap) {
|
|
433
|
-
composedMap =
|
|
435
|
+
composedMap = _chunkMSECP2P4cjs.flattenSourceMapSections.call(void 0, originalMap);
|
|
434
436
|
} else if (shiftedTransformMap) {
|
|
435
437
|
composedMap = shiftedTransformMap;
|
|
436
438
|
}
|
|
437
|
-
const originalMapDebugId = _nullishCoalesce(_optionalChain([originalMap, 'optionalAccess',
|
|
439
|
+
const originalMapDebugId = _nullishCoalesce(_optionalChain([originalMap, 'optionalAccess', _22 => _22.debugId]), () => ( _optionalChain([originalMap, 'optionalAccess', _23 => _23.debug_id])));
|
|
438
440
|
const hadDebugId = Boolean(fileDebugId || originalMapDebugId || result.debugId);
|
|
441
|
+
const shouldMintDebugId = hadDebugId || keepPrivateMaps && !result.skippedReason && Boolean(composedMap || originalMap);
|
|
439
442
|
let mintedDebugId;
|
|
440
|
-
if (
|
|
441
|
-
const codeWithoutDebugId =
|
|
442
|
-
mintedDebugId =
|
|
443
|
+
if (shouldMintDebugId) {
|
|
444
|
+
const codeWithoutDebugId = _chunkAD6UFBPAcjs.stripDebugIdComments.call(void 0, finalCode);
|
|
445
|
+
mintedDebugId = _chunkMSECP2P4cjs.computeDeterministicDebugId.call(void 0,
|
|
443
446
|
codeWithoutDebugId,
|
|
444
|
-
_nullishCoalesce(_optionalChain([composedMap, 'optionalAccess',
|
|
447
|
+
_nullishCoalesce(_optionalChain([composedMap, 'optionalAccess', _24 => _24.mappings]), () => ( ""))
|
|
445
448
|
);
|
|
446
|
-
finalCode =
|
|
449
|
+
finalCode = _chunkAD6UFBPAcjs.replaceOrAppendDebugId.call(void 0, codeWithoutDebugId, mintedDebugId);
|
|
447
450
|
if (composedMap) {
|
|
448
451
|
composedMap.debugId = mintedDebugId;
|
|
449
452
|
delete composedMap.debug_id;
|
|
@@ -479,7 +482,7 @@ async function protectProject(options = {}) {
|
|
|
479
482
|
}
|
|
480
483
|
if (!dryRun) {
|
|
481
484
|
if (deferVaultWrites) {
|
|
482
|
-
const finalVaultResult =
|
|
485
|
+
const finalVaultResult = _chunkAD6UFBPAcjs.relocateSourceMaps.call(void 0,
|
|
483
486
|
outDir,
|
|
484
487
|
cwd,
|
|
485
488
|
keepPrivateMaps,
|
|
@@ -497,11 +500,12 @@ async function protectProject(options = {}) {
|
|
|
497
500
|
const vaultedMapPath = _path2.default.join(vaultResult.vaultDir, `${relPath}.map`);
|
|
498
501
|
const decodedMapPath = _path2.default.join(
|
|
499
502
|
vaultResult.vaultDir,
|
|
500
|
-
`${
|
|
503
|
+
`${_chunkMSECP2P4cjs.safeDecodeURIComponent.call(void 0, relPath)}.map`
|
|
501
504
|
);
|
|
502
505
|
const targetMapPath = _fs2.default.existsSync(vaultedMapPath) ? vaultedMapPath : _fs2.default.existsSync(decodedMapPath) ? decodedMapPath : vaultedMapPath;
|
|
503
|
-
if (map
|
|
506
|
+
if (map) {
|
|
504
507
|
try {
|
|
508
|
+
_fs2.default.mkdirSync(_path2.default.dirname(targetMapPath), { recursive: true });
|
|
505
509
|
_fs2.default.writeFileSync(targetMapPath, JSON.stringify(map), "utf8");
|
|
506
510
|
} catch (e9) {
|
|
507
511
|
}
|
|
@@ -578,6 +582,8 @@ async function protectProject(options = {}) {
|
|
|
578
582
|
seed,
|
|
579
583
|
tier: resolvedTier,
|
|
580
584
|
aggressive,
|
|
585
|
+
deterrentMode,
|
|
586
|
+
detectHeadless,
|
|
581
587
|
dockerIgnoreMissing: vaultResult.dockerIgnoreMissing,
|
|
582
588
|
dryRun,
|
|
583
589
|
profile: effectiveProfile,
|