unpeek 4.0.0 → 4.1.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.
Files changed (64) hide show
  1. package/README.md +21 -12
  2. package/README.tr.md +20 -11
  3. package/dist/adapters/esbuild.cjs +5 -5
  4. package/dist/adapters/esbuild.d.cts +1 -1
  5. package/dist/adapters/esbuild.d.ts +1 -1
  6. package/dist/adapters/esbuild.js +3 -3
  7. package/dist/adapters/next/adapter.cjs +6 -6
  8. package/dist/adapters/next/adapter.d.cts +1 -1
  9. package/dist/adapters/next/adapter.d.ts +1 -1
  10. package/dist/adapters/next/adapter.js +5 -5
  11. package/dist/adapters/next/index.cjs +6 -6
  12. package/dist/adapters/next/index.js +5 -5
  13. package/dist/adapters/rollup.cjs +5 -5
  14. package/dist/adapters/rollup.d.cts +1 -1
  15. package/dist/adapters/rollup.d.ts +1 -1
  16. package/dist/adapters/rollup.js +3 -3
  17. package/dist/adapters/rspack.cjs +5 -5
  18. package/dist/adapters/rspack.d.cts +1 -1
  19. package/dist/adapters/rspack.d.ts +1 -1
  20. package/dist/adapters/rspack.js +3 -3
  21. package/dist/adapters/vite.cjs +5 -5
  22. package/dist/adapters/vite.d.cts +1 -1
  23. package/dist/adapters/vite.d.ts +1 -1
  24. package/dist/adapters/vite.js +3 -3
  25. package/dist/adapters/webpack.cjs +5 -5
  26. package/dist/adapters/webpack.d.cts +1 -1
  27. package/dist/adapters/webpack.d.ts +1 -1
  28. package/dist/adapters/webpack.js +3 -3
  29. package/dist/browser.cjs +2 -2
  30. package/dist/browser.d.cts +4 -4
  31. package/dist/browser.d.ts +4 -4
  32. package/dist/browser.js +1 -1
  33. package/dist/chunk-32GLSJAW.js +614 -0
  34. package/dist/{chunk-W77DAC3H.js → chunk-6EWFL4LQ.js} +16 -0
  35. package/dist/{chunk-4FNZNIBW.js → chunk-6KLUNEKE.js} +2538 -547
  36. package/dist/chunk-AD6UFBPA.cjs +614 -0
  37. package/dist/{chunk-X6EETCO6.cjs → chunk-BQ2O6HM5.cjs} +16 -0
  38. package/dist/{chunk-ZG7BIAUI.cjs → chunk-FLZ4FSP5.cjs} +58 -17
  39. package/dist/{chunk-2JU3V7HW.js → chunk-HV47WJIR.js} +52 -11
  40. package/dist/{chunk-VG4Y26ZN.cjs → chunk-Q4DFRMAV.cjs} +53 -36
  41. package/dist/{chunk-HHC7BUCK.js → chunk-STTUFUDC.js} +114 -16
  42. package/dist/{chunk-YCRMTXOE.js → chunk-TOUYQ4N5.js} +30 -13
  43. package/dist/{chunk-KLYFNMKS.cjs → chunk-VLL4THTG.cjs} +2727 -736
  44. package/dist/{chunk-7HXLHLLQ.cjs → chunk-WYW5UOBE.cjs} +136 -38
  45. package/dist/cli/index.js +2240 -572
  46. package/dist/{config-Y6JwVGwX.d.cts → config-BFAZrfjQ.d.cts} +2 -0
  47. package/dist/{config-Y6JwVGwX.d.ts → config-BFAZrfjQ.d.ts} +2 -0
  48. package/dist/config.cjs +2 -2
  49. package/dist/config.d.cts +1 -1
  50. package/dist/config.d.ts +1 -1
  51. package/dist/config.js +1 -1
  52. package/dist/{index-COVHErnx.d.cts → index-Bo4S_VVM.d.cts} +1 -1
  53. package/dist/{index-0O1WSfVP.d.ts → index-CKdYVt_L.d.ts} +1 -1
  54. package/dist/index.cjs +186 -47
  55. package/dist/index.d.cts +6 -6
  56. package/dist/index.d.ts +6 -6
  57. package/dist/index.js +174 -35
  58. package/dist/plugins/unplugin.cjs +4 -4
  59. package/dist/plugins/unplugin.js +3 -3
  60. package/dist/{types-CMtZnV8C.d.ts → types-BZqvBhBI.d.ts} +4 -2
  61. package/dist/{types-D93PuOOl.d.cts → types-E4ugA4Oz.d.cts} +4 -2
  62. package/package.json +1 -1
  63. package/dist/chunk-3LWXEJU6.cjs +0 -1054
  64. package/dist/chunk-ADKRENAP.js +0 -1054
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; }
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 _chunkX6EETCO6cjs = require('./chunk-X6EETCO6.cjs');
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 _chunk3LWXEJU6cjs = require('./chunk-3LWXEJU6.cjs');
19
19
 
20
20
 
21
21
 
22
22
 
23
23
 
24
- var _chunkKLYFNMKScjs = require('./chunk-KLYFNMKS.cjs');
24
+ var _chunkVLL4THTGcjs = require('./chunk-VLL4THTG.cjs');
25
25
 
26
26
 
27
27
  var _chunkL6BOM5VScjs = require('./chunk-L6BOM5VS.cjs');
@@ -86,6 +86,8 @@ function readUnpeekNextOptionsFromEnv() {
86
86
  var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
87
87
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
88
88
  var _zlib = require('zlib'); var _zlib2 = _interopRequireDefault(_zlib);
89
+ var _acorn = require('acorn'); var acorn = _interopRequireWildcard(_acorn);
90
+ var _acornwalk = require('acorn-walk');
89
91
  var ENTRY_PATTERN = /^(?:webpack|main|index|runtime|turbopack|pages\/_app|pages\/index)(?:[-._/]|$)/i;
90
92
  function normalizeManifestRel(fileRef) {
91
93
  const clean = fileRef.replace(/\\/g, "/").split("?")[0].split("#")[0].replace(/^\/+/, "");
@@ -197,7 +199,7 @@ function matchesManifestEntry(relPath, manifestEntries) {
197
199
  function isEntryChunk(relPath, index, allRelPaths, manifestEntries, isWorkerTarget) {
198
200
  const norm = relPath.replace(/\\/g, "/");
199
201
  const base = _path2.default.basename(norm);
200
- if (isWorkerTarget && _chunk3LWXEJU6cjs.isWorkerOrServiceWorkerFile.call(void 0, norm)) {
202
+ if (isWorkerTarget && _chunkAD6UFBPAcjs.isWorkerOrServiceWorkerFile.call(void 0, norm)) {
201
203
  return true;
202
204
  }
203
205
  if (matchesManifestEntry(norm, manifestEntries)) {
@@ -221,7 +223,7 @@ function readOriginalSourceMapForFile(filePath, relPath, vaultDir, deferVaultWri
221
223
  candidates.push(`${filePath}.map`);
222
224
  }
223
225
  candidates.push(_path2.default.join(vaultDir, `${relPath}.map`));
224
- const decodedRel = _chunk3LWXEJU6cjs.safeDecodeURIComponent.call(void 0, relPath);
226
+ const decodedRel = _chunkVLL4THTGcjs.safeDecodeURIComponent.call(void 0, relPath);
225
227
  if (decodedRel !== relPath) {
226
228
  candidates.push(_path2.default.join(vaultDir, `${decodedRel}.map`));
227
229
  }
@@ -237,14 +239,52 @@ function readOriginalSourceMapForFile(filePath, relPath, vaultDir, deferVaultWri
237
239
  }
238
240
  return void 0;
239
241
  }
242
+ function countPreExistingEvalCalls(code) {
243
+ const hits = [];
244
+ let ast;
245
+ try {
246
+ ast = acorn.parse(code, {
247
+ ecmaVersion: "latest",
248
+ sourceType: "module",
249
+ allowReturnOutsideFunction: true
250
+ });
251
+ } catch (e6) {
252
+ try {
253
+ ast = acorn.parse(code, {
254
+ ecmaVersion: "latest",
255
+ sourceType: "script",
256
+ allowReturnOutsideFunction: true
257
+ });
258
+ } catch (e7) {
259
+ return hits;
260
+ }
261
+ }
262
+ _acornwalk.simple.call(void 0, ast, {
263
+ CallExpression(node) {
264
+ if (node.callee.type === "Identifier") {
265
+ if (node.callee.name === "eval") {
266
+ hits.push("eval(...)");
267
+ } else if (node.callee.name === "Function") {
268
+ hits.push("Function(...)");
269
+ }
270
+ }
271
+ },
272
+ NewExpression(node) {
273
+ if (node.callee.type === "Identifier" && node.callee.name === "Function") {
274
+ hits.push("new Function(...)");
275
+ }
276
+ }
277
+ });
278
+ return hits;
279
+ }
240
280
  async function protectProject(options = {}) {
241
281
  const startTime = performance.now();
242
282
  const cwd = _path2.default.resolve(_nullishCoalesce(options.cwd, () => ( process.cwd())));
243
283
  const effectiveConfigInput = options.profile ? { ..._nullishCoalesce(options.config, () => ( {})), profile: options.profile } : options.config;
244
- const config = await _chunkX6EETCO6cjs.loadUnpeekConfig.call(void 0, cwd, effectiveConfigInput);
284
+ const config = await _chunkBQ2O6HM5cjs.loadUnpeekConfig.call(void 0, cwd, effectiveConfigInput);
245
285
  const effectiveProfile = _nullishCoalesce(_nullishCoalesce(options.profile, () => ( config.profile)), () => ( "recommended"));
246
- const { framework, outDir } = _chunk3LWXEJU6cjs.detectTargetFramework.call(void 0, cwd, options.outDir, config);
247
- 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;
248
288
  const dryRun = Boolean(options.dryRun);
249
289
  const keepPrivateMaps = _nullishCoalesce(_nullishCoalesce(options.keepPrivateMaps, () => ( _optionalChain([config, 'access', _7 => _7.sourcemaps, 'optionalAccess', _8 => _8.keepPrivate]))), () => ( true));
250
290
  const privateMapsDir = _nullishCoalesce(_nullishCoalesce(options.privateMapsDir, () => ( _optionalChain([config, 'access', _9 => _9.sourcemaps, 'optionalAccess', _10 => _10.vaultDir]))), () => ( ".unpeek-maps"));
@@ -254,18 +294,18 @@ async function protectProject(options = {}) {
254
294
  const minStringLength = _nullishCoalesce(_nullishCoalesce(options.minStringLength, () => ( _optionalChain([config, 'access', _15 => _15.vault, 'optionalAccess', _16 => _16.minStringLength]))), () => ( 4));
255
295
  const aggressive = _nullishCoalesce(options.aggressive, () => ( (effectiveProfile === "strict" ? true : false)));
256
296
  const scrubPaths = _nullishCoalesce(_nullishCoalesce(options.scrubPaths, () => ( config.scrubPaths)), () => ( (effectiveProfile === "strict" ? true : false)));
257
- const masterSym = _chunkKLYFNMKScjs.deriveWindowKeySymbol.call(void 0, seed);
258
- const masterShield = injectRuntimeShield ? _chunkKLYFNMKScjs.generateRuntimeShield.call(void 0, {
297
+ const masterSym = _chunkVLL4THTGcjs.deriveWindowKeySymbol.call(void 0, seed);
298
+ const masterShield = injectRuntimeShield ? _chunkVLL4THTGcjs.generateRuntimeShield.call(void 0, {
259
299
  seed,
260
300
  deterrentMode,
261
301
  detectHeadless,
262
302
  windowKeySymbol: masterSym
263
303
  }) : void 0;
264
304
  const deferVaultWrites = dryRun || typeof options.maxGzipDelta === "number";
265
- const vaultResult = _chunk3LWXEJU6cjs.relocateSourceMaps.call(void 0, outDir, cwd, keepPrivateMaps, privateMapsDir, false, config, {
305
+ const vaultResult = _chunkAD6UFBPAcjs.relocateSourceMaps.call(void 0, outDir, cwd, keepPrivateMaps, privateMapsDir, false, config, {
266
306
  dryRun: deferVaultWrites
267
307
  });
268
- const clientFiles = _chunk3LWXEJU6cjs.scanClientBundles.call(void 0, outDir, config);
308
+ const clientFiles = _chunkAD6UFBPAcjs.scanClientBundles.call(void 0, outDir, config);
269
309
  const allRelPaths = clientFiles.map((f) => _path2.default.relative(outDir, f).replace(/\\/g, "/"));
270
310
  const manifestEntries = collectManifestEntryFiles(outDir, cwd, config);
271
311
  const isWorkerTarget = config.target === "worker";
@@ -289,6 +329,19 @@ async function protectProject(options = {}) {
289
329
  const allProtBufs = [];
290
330
  const stagedFiles = [];
291
331
  const pendingVaultMaps = [];
332
+ const preExistingEvalFiles = {};
333
+ let alreadyProtectedCount = 0;
334
+ const manifestPath = _path2.default.join(vaultResult.vaultDir, "manifest.json");
335
+ let existingManifest;
336
+ if (!dryRun && _fs2.default.existsSync(manifestPath)) {
337
+ try {
338
+ const parsed = JSON.parse(_fs2.default.readFileSync(manifestPath, "utf8"));
339
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
340
+ existingManifest = parsed;
341
+ }
342
+ } catch (e8) {
343
+ }
344
+ }
292
345
  let originalGzipBytes = 0;
293
346
  let protectedGzipBytes = 0;
294
347
  let gzipDeltaPercent = 0;
@@ -297,9 +350,9 @@ async function protectProject(options = {}) {
297
350
  for (let i = 0; i < clientFiles.length; i++) {
298
351
  const filePath = clientFiles[i];
299
352
  let codeToTransform = _fs2.default.readFileSync(filePath, "utf8");
300
- const fileDebugId = _chunk3LWXEJU6cjs.extractDebugId.call(void 0, codeToTransform);
353
+ const fileDebugId = _chunkAD6UFBPAcjs.extractDebugId.call(void 0, codeToTransform);
301
354
  if (codeToTransform.includes("sourceMappingURL=")) {
302
- const strippedRes = _chunk3LWXEJU6cjs.stripSourceMapComments.call(void 0, codeToTransform);
355
+ const strippedRes = _chunkAD6UFBPAcjs.stripSourceMapComments.call(void 0, codeToTransform);
303
356
  codeToTransform = strippedRes.code;
304
357
  if (strippedRes.stripped) {
305
358
  vaultResult.strippedFilesCount++;
@@ -309,9 +362,11 @@ async function protectProject(options = {}) {
309
362
  originalBytes += origBuf.byteLength;
310
363
  allOrigBufs.push(origBuf);
311
364
  const relPath = allRelPaths[i];
365
+ const originalMap = keepPrivateMaps ? readOriginalSourceMapForFile(filePath, relPath, vaultResult.vaultDir, deferVaultWrites) : void 0;
366
+ const preExistingHits = countPreExistingEvalCalls(codeToTransform);
312
367
  const isEntry = isEntryChunk(relPath, i, allRelPaths, manifestEntries, isWorkerTarget);
313
368
  const shouldInjectShield = injectRuntimeShield && isEntry;
314
- const fileSeed = _chunkKLYFNMKScjs.computeFnv1aHash.call(void 0, `${relPath}:${i}`, seed);
369
+ const fileSeed = _chunkVLL4THTGcjs.computeFnv1aHash.call(void 0, `${relPath}:${i}`, seed);
315
370
  const transformOptions = {
316
371
  seed: fileSeed,
317
372
  minStringLength,
@@ -321,15 +376,17 @@ async function protectProject(options = {}) {
321
376
  shieldCoupled: injectRuntimeShield,
322
377
  windowKeySymbol: masterSym,
323
378
  expectedDelta: _optionalChain([masterShield, 'optionalAccess', _17 => _17.expectedDelta]),
379
+ expectedStateHash: _optionalChain([masterShield, 'optionalAccess', _18 => _18.expectedStateHash]),
380
+ originalSourceMap: originalMap,
324
381
  deterrentMode,
325
382
  detectHeadless,
326
383
  aggressive,
327
384
  scrubPaths,
328
- config
385
+ config,
386
+ generateMap: keepPrivateMaps,
387
+ rootDir: cwd
329
388
  };
330
- transformOptions.generateMap = keepPrivateMaps;
331
- transformOptions.rootDir = cwd;
332
- const result = _chunkKLYFNMKScjs.transformJavaScript.call(void 0, codeToTransform, transformOptions);
389
+ const result = _chunkVLL4THTGcjs.transformJavaScript.call(void 0, codeToTransform, transformOptions);
333
390
  if (result.skippedReason === "parse-error") {
334
391
  diagnostics.push({
335
392
  code: "PARSE_FALLBACK",
@@ -338,6 +395,13 @@ async function protectProject(options = {}) {
338
395
  file: relPath
339
396
  });
340
397
  } else if (result.skippedReason === "already-protected") {
398
+ alreadyProtectedCount++;
399
+ const prevHits = _optionalChain([existingManifest, 'optionalAccess', _19 => _19.preExistingEvalFiles, 'optionalAccess', _20 => _20[relPath]]);
400
+ if (Array.isArray(prevHits) && prevHits.length > 0) {
401
+ preExistingEvalFiles[relPath] = prevHits;
402
+ } else if (preExistingHits.length > 0) {
403
+ preExistingEvalFiles[relPath] = preExistingHits;
404
+ }
341
405
  diagnostics.push({
342
406
  code: "ALREADY_PROTECTED",
343
407
  severity: "info",
@@ -351,36 +415,38 @@ async function protectProject(options = {}) {
351
415
  message: `File "${relPath}" is empty.`,
352
416
  file: relPath
353
417
  });
418
+ } else if (preExistingHits.length > 0) {
419
+ preExistingEvalFiles[relPath] = preExistingHits;
354
420
  }
355
421
  let finalCode = result.code;
356
422
  let preambleLineOffset = 0;
357
- if (shouldInjectShield && _optionalChain([masterShield, 'optionalAccess', _18 => _18.preambleCode]) && !finalCode.includes(masterShield.integrityCheckFnName) && !finalCode.startsWith(masterShield.preambleCode)) {
423
+ if (shouldInjectShield && _optionalChain([masterShield, 'optionalAccess', _21 => _21.preambleCode]) && !finalCode.includes(masterShield.integrityCheckFnName) && !finalCode.startsWith(masterShield.preambleCode)) {
358
424
  const prefix = `${masterShield.preambleCode}
359
425
  `;
360
426
  preambleLineOffset = (_nullishCoalesce(prefix.match(/\n/g), () => ( []))).length;
361
427
  finalCode = `${prefix}${finalCode}`;
362
428
  }
363
- const originalMap = keepPrivateMaps ? readOriginalSourceMapForFile(filePath, relPath, vaultResult.vaultDir, deferVaultWrites) : void 0;
364
429
  const rawTransformMap = result.sourceMap;
365
- const shiftedTransformMap = rawTransformMap ? _chunk3LWXEJU6cjs.shiftSourceMapLines.call(void 0, rawTransformMap, preambleLineOffset) : void 0;
430
+ const shiftedTransformMap = rawTransformMap ? _chunkVLL4THTGcjs.shiftSourceMapLines.call(void 0, rawTransformMap, preambleLineOffset) : void 0;
366
431
  let composedMap;
367
432
  if (shiftedTransformMap && originalMap) {
368
- composedMap = _chunk3LWXEJU6cjs.chainSourceMaps.call(void 0, shiftedTransformMap, originalMap);
433
+ composedMap = _chunkVLL4THTGcjs.chainSourceMaps.call(void 0, shiftedTransformMap, originalMap);
369
434
  } else if (originalMap) {
370
- composedMap = _chunk3LWXEJU6cjs.flattenSourceMapSections.call(void 0, originalMap);
435
+ composedMap = _chunkVLL4THTGcjs.flattenSourceMapSections.call(void 0, originalMap);
371
436
  } else if (shiftedTransformMap) {
372
437
  composedMap = shiftedTransformMap;
373
438
  }
374
- const originalMapDebugId = _nullishCoalesce(_optionalChain([originalMap, 'optionalAccess', _19 => _19.debugId]), () => ( _optionalChain([originalMap, 'optionalAccess', _20 => _20.debug_id])));
439
+ const originalMapDebugId = _nullishCoalesce(_optionalChain([originalMap, 'optionalAccess', _22 => _22.debugId]), () => ( _optionalChain([originalMap, 'optionalAccess', _23 => _23.debug_id])));
375
440
  const hadDebugId = Boolean(fileDebugId || originalMapDebugId || result.debugId);
441
+ const shouldMintDebugId = hadDebugId || keepPrivateMaps && !result.skippedReason && Boolean(composedMap || originalMap);
376
442
  let mintedDebugId;
377
- if (hadDebugId) {
378
- const codeWithoutDebugId = _chunk3LWXEJU6cjs.stripDebugIdComments.call(void 0, finalCode);
379
- mintedDebugId = _chunk3LWXEJU6cjs.computeDeterministicDebugId.call(void 0,
443
+ if (shouldMintDebugId) {
444
+ const codeWithoutDebugId = _chunkAD6UFBPAcjs.stripDebugIdComments.call(void 0, finalCode);
445
+ mintedDebugId = _chunkVLL4THTGcjs.computeDeterministicDebugId.call(void 0,
380
446
  codeWithoutDebugId,
381
- _nullishCoalesce(_optionalChain([composedMap, 'optionalAccess', _21 => _21.mappings]), () => ( ""))
447
+ _nullishCoalesce(_optionalChain([composedMap, 'optionalAccess', _24 => _24.mappings]), () => ( ""))
382
448
  );
383
- finalCode = _chunk3LWXEJU6cjs.replaceOrAppendDebugId.call(void 0, codeWithoutDebugId, mintedDebugId);
449
+ finalCode = _chunkAD6UFBPAcjs.replaceOrAppendDebugId.call(void 0, codeWithoutDebugId, mintedDebugId);
384
450
  if (composedMap) {
385
451
  composedMap.debugId = mintedDebugId;
386
452
  delete composedMap.debug_id;
@@ -416,7 +482,7 @@ async function protectProject(options = {}) {
416
482
  }
417
483
  if (!dryRun) {
418
484
  if (deferVaultWrites) {
419
- const finalVaultResult = _chunk3LWXEJU6cjs.relocateSourceMaps.call(void 0,
485
+ const finalVaultResult = _chunkAD6UFBPAcjs.relocateSourceMaps.call(void 0,
420
486
  outDir,
421
487
  cwd,
422
488
  keepPrivateMaps,
@@ -434,13 +500,14 @@ async function protectProject(options = {}) {
434
500
  const vaultedMapPath = _path2.default.join(vaultResult.vaultDir, `${relPath}.map`);
435
501
  const decodedMapPath = _path2.default.join(
436
502
  vaultResult.vaultDir,
437
- `${_chunk3LWXEJU6cjs.safeDecodeURIComponent.call(void 0, relPath)}.map`
503
+ `${_chunkVLL4THTGcjs.safeDecodeURIComponent.call(void 0, relPath)}.map`
438
504
  );
439
505
  const targetMapPath = _fs2.default.existsSync(vaultedMapPath) ? vaultedMapPath : _fs2.default.existsSync(decodedMapPath) ? decodedMapPath : vaultedMapPath;
440
- if (map && _fs2.default.existsSync(targetMapPath)) {
506
+ if (map) {
441
507
  try {
508
+ _fs2.default.mkdirSync(_path2.default.dirname(targetMapPath), { recursive: true });
442
509
  _fs2.default.writeFileSync(targetMapPath, JSON.stringify(map), "utf8");
443
- } catch (e6) {
510
+ } catch (e9) {
444
511
  }
445
512
  } else if (debugId && _fs2.default.existsSync(targetMapPath)) {
446
513
  try {
@@ -448,26 +515,55 @@ async function protectProject(options = {}) {
448
515
  mapJson.debugId = debugId;
449
516
  delete mapJson.debug_id;
450
517
  _fs2.default.writeFileSync(targetMapPath, JSON.stringify(mapJson), "utf8");
451
- } catch (e7) {
518
+ } catch (e10) {
452
519
  }
453
520
  }
454
521
  }
455
522
  for (const { tmpPath, finalPath } of stagedFiles) {
456
523
  _fs2.default.renameSync(tmpPath, finalPath);
457
524
  }
525
+ const relVault = _path2.default.relative(cwd, vaultResult.vaultDir);
526
+ const isSafeVaultDir = relVault === "" || !relVault.startsWith("..") && !_path2.default.isAbsolute(relVault);
527
+ if (isSafeVaultDir) {
528
+ const relOutDir = _path2.default.relative(cwd, outDir).replace(/\\/g, "/") || ".";
529
+ const manifestPayload = processedFiles > 0 && alreadyProtectedCount === processedFiles && existingManifest ? {
530
+ version: 1,
531
+ outDir: _nullishCoalesce(existingManifest.outDir, () => ( relOutDir)),
532
+ originalGzipBytes: _nullishCoalesce(existingManifest.originalGzipBytes, () => ( originalGzipBytes)),
533
+ protectedGzipBytes: _nullishCoalesce(existingManifest.protectedGzipBytes, () => ( protectedGzipBytes)),
534
+ gzipDeltaPercent: _nullishCoalesce(existingManifest.gzipDeltaPercent, () => ( gzipDeltaPercent)),
535
+ preExistingEvalFiles: {
536
+ ..._nullishCoalesce(existingManifest.preExistingEvalFiles, () => ( {})),
537
+ ...preExistingEvalFiles
538
+ }
539
+ } : {
540
+ version: 1,
541
+ outDir: relOutDir,
542
+ originalGzipBytes,
543
+ protectedGzipBytes,
544
+ gzipDeltaPercent,
545
+ preExistingEvalFiles
546
+ };
547
+ try {
548
+ _fs2.default.mkdirSync(vaultResult.vaultDir, { recursive: true });
549
+ _fs2.default.writeFileSync(manifestPath, JSON.stringify(manifestPayload, null, 2), "utf8");
550
+ } catch (e11) {
551
+ }
552
+ }
458
553
  }
459
554
  } catch (error) {
460
555
  for (const { tmpPath } of stagedFiles) {
461
556
  if (_fs2.default.existsSync(tmpPath)) {
462
557
  try {
463
558
  _fs2.default.unlinkSync(tmpPath);
464
- } catch (e8) {
559
+ } catch (e12) {
465
560
  }
466
561
  }
467
562
  }
468
563
  throw error;
469
564
  }
470
565
  const elapsedMs = Math.max(1, Math.round(performance.now() - startTime));
566
+ const resolvedTier = _nullishCoalesce(options.tier, () => ( (effectiveProfile === "strict" || aggressive ? "Tier 3" : effectiveProfile === "minimal" ? "Tier 1" : _nullishCoalesce(config.tier, () => ( "Tier 2")))));
471
567
  return {
472
568
  framework,
473
569
  outDir,
@@ -484,8 +580,10 @@ async function protectProject(options = {}) {
484
580
  totalMangledSymbols,
485
581
  elapsedMs,
486
582
  seed,
487
- tier: aggressive ? "Tier 2" : "Tier 1",
583
+ tier: resolvedTier,
488
584
  aggressive,
585
+ deterrentMode,
586
+ detectHeadless,
489
587
  dockerIgnoreMissing: vaultResult.dockerIgnoreMissing,
490
588
  dryRun,
491
589
  profile: effectiveProfile,