unpeek 4.2.0 → 4.3.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 (34) hide show
  1. package/README.md +2 -2
  2. package/README.tr.md +2 -2
  3. package/dist/adapters/esbuild.cjs +5 -5
  4. package/dist/adapters/esbuild.js +3 -3
  5. package/dist/adapters/next/adapter.cjs +5 -5
  6. package/dist/adapters/next/adapter.js +4 -4
  7. package/dist/adapters/next/index.cjs +5 -5
  8. package/dist/adapters/next/index.js +4 -4
  9. package/dist/adapters/rollup.cjs +5 -5
  10. package/dist/adapters/rollup.js +3 -3
  11. package/dist/adapters/rspack.cjs +5 -5
  12. package/dist/adapters/rspack.js +3 -3
  13. package/dist/adapters/vite.cjs +5 -5
  14. package/dist/adapters/vite.js +3 -3
  15. package/dist/adapters/webpack.cjs +5 -5
  16. package/dist/adapters/webpack.js +3 -3
  17. package/dist/browser.cjs +2 -2
  18. package/dist/browser.js +1 -1
  19. package/dist/{chunk-UUJLTW7O.cjs → chunk-4IRIMLT3.cjs} +16 -16
  20. package/dist/{chunk-AD6UFBPA.cjs → chunk-4XSFPX2Z.cjs} +367 -8
  21. package/dist/{chunk-KIAYVIC5.cjs → chunk-7F75S3GQ.cjs} +60 -36
  22. package/dist/{chunk-K77WRITN.js → chunk-EASD7C2B.js} +3 -3
  23. package/dist/{chunk-APQOBFRO.js → chunk-GKWTP4Z5.js} +30 -6
  24. package/dist/{chunk-MSECP2P4.cjs → chunk-OR5M3SN2.cjs} +1199 -428
  25. package/dist/{chunk-32GLSJAW.js → chunk-RDP4MTHK.js} +359 -0
  26. package/dist/{chunk-BL2UXZGD.js → chunk-RM3V7KJA.js} +1040 -269
  27. package/dist/{chunk-SJK45WAU.cjs → chunk-SBRU7GSX.cjs} +8 -8
  28. package/dist/{chunk-GCWXTWTN.js → chunk-XEYMZUP5.js} +2 -2
  29. package/dist/cli/index.js +1425 -274
  30. package/dist/index.cjs +21 -21
  31. package/dist/index.js +3 -3
  32. package/dist/plugins/unplugin.cjs +4 -4
  33. package/dist/plugins/unplugin.js +3 -3
  34. package/package.json +1 -1
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  protectProject,
3
3
  serializeNextOptions
4
- } from "./chunk-APQOBFRO.js";
4
+ } from "./chunk-GKWTP4Z5.js";
5
5
  import {
6
6
  hasJsBundleFiles
7
- } from "./chunk-32GLSJAW.js";
7
+ } from "./chunk-RDP4MTHK.js";
8
8
  import {
9
9
  computeFnv1aHash,
10
10
  safeDecodeURIComponent
11
- } from "./chunk-BL2UXZGD.js";
11
+ } from "./chunk-RM3V7KJA.js";
12
12
  import {
13
13
  UnpeekError,
14
14
  __dirname,
@@ -3,14 +3,16 @@ import {
3
3
  } from "./chunk-6EWFL4LQ.js";
4
4
  import {
5
5
  detectTargetFramework,
6
+ discoverHtmlEntryGraph,
6
7
  extractDebugId,
8
+ hasNextServerSegment,
7
9
  isWorkerOrServiceWorkerFile,
8
10
  relocateSourceMaps,
9
11
  replaceOrAppendDebugId,
10
12
  scanClientBundles,
11
13
  stripDebugIdComments,
12
14
  stripSourceMapComments
13
- } from "./chunk-32GLSJAW.js";
15
+ } from "./chunk-RDP4MTHK.js";
14
16
  import {
15
17
  chainSourceMaps,
16
18
  computeDeterministicDebugId,
@@ -21,7 +23,7 @@ import {
21
23
  safeDecodeURIComponent,
22
24
  shiftSourceMapLines,
23
25
  transformJavaScript
24
- } from "./chunk-BL2UXZGD.js";
26
+ } from "./chunk-RM3V7KJA.js";
25
27
  import {
26
28
  UnpeekError
27
29
  } from "./chunk-LA6J3BT3.js";
@@ -196,21 +198,29 @@ function matchesManifestEntry(relPath, manifestEntries) {
196
198
  }
197
199
  return false;
198
200
  }
199
- function isEntryChunk(relPath, index, allRelPaths, manifestEntries, isWorkerTarget) {
201
+ function isEntryChunk(relPath, index, allRelPaths, manifestEntries, isWorkerTarget, htmlGraph) {
200
202
  const norm = relPath.replace(/\\/g, "/");
201
203
  const base = path.basename(norm);
202
204
  if (isWorkerTarget && isWorkerOrServiceWorkerFile(norm)) {
203
205
  return true;
204
206
  }
207
+ if (htmlGraph?.workerEntryFiles.has(norm)) {
208
+ return true;
209
+ }
205
210
  if (matchesManifestEntry(norm, manifestEntries)) {
206
211
  return true;
207
212
  }
213
+ const hasKnownManifestEntry = manifestEntries.size > 0 && allRelPaths.some((p) => matchesManifestEntry(p.replace(/\\/g, "/"), manifestEntries));
214
+ const hasKnownHtmlEntry = manifestEntries.size === 0 && Boolean(htmlGraph && allRelPaths.some((p) => htmlGraph.entryFiles.has(p.replace(/\\/g, "/"))));
215
+ if (hasKnownHtmlEntry) {
216
+ return htmlGraph.entryFiles.has(norm);
217
+ }
208
218
  if (ENTRY_PATTERN.test(norm) || ENTRY_PATTERN.test(base)) {
209
219
  return true;
210
220
  }
211
- const hasAnyKnownEntry = allRelPaths.some((p) => {
221
+ const hasAnyKnownEntry = hasKnownManifestEntry || allRelPaths.some((p) => {
212
222
  const n = p.replace(/\\/g, "/");
213
- return matchesManifestEntry(n, manifestEntries) || ENTRY_PATTERN.test(n) || ENTRY_PATTERN.test(path.basename(n));
223
+ return ENTRY_PATTERN.test(n) || ENTRY_PATTERN.test(path.basename(n));
214
224
  });
215
225
  if (!hasAnyKnownEntry && index === 0) {
216
226
  return true;
@@ -309,6 +319,13 @@ async function protectProject(options = {}) {
309
319
  const allRelPaths = clientFiles.map((f) => path.relative(outDir, f).replace(/\\/g, "/"));
310
320
  const manifestEntries = collectManifestEntryFiles(outDir, cwd, config);
311
321
  const isWorkerTarget = config.target === "worker";
322
+ const extraHtmlDirs = [];
323
+ const parentOutDir = path.dirname(outDir);
324
+ const relParent = path.relative(cwd, parentOutDir);
325
+ if (relParent && !relParent.startsWith("..") && !path.isAbsolute(relParent) && !hasNextServerSegment(parentOutDir, cwd)) {
326
+ extraHtmlDirs.push(parentOutDir);
327
+ }
328
+ const htmlGraph = discoverHtmlEntryGraph(outDir, config, extraHtmlDirs);
312
329
  let originalBytes = 0;
313
330
  let protectedBytes = 0;
314
331
  let totalHotFunctionsSkipped = 0;
@@ -364,7 +381,14 @@ async function protectProject(options = {}) {
364
381
  const relPath = allRelPaths[i];
365
382
  const originalMap = keepPrivateMaps ? readOriginalSourceMapForFile(filePath, relPath, vaultResult.vaultDir, deferVaultWrites) : void 0;
366
383
  const preExistingHits = countPreExistingEvalCalls(codeToTransform);
367
- const isEntry = isEntryChunk(relPath, i, allRelPaths, manifestEntries, isWorkerTarget);
384
+ const isEntry = isEntryChunk(
385
+ relPath,
386
+ i,
387
+ allRelPaths,
388
+ manifestEntries,
389
+ isWorkerTarget,
390
+ htmlGraph
391
+ );
368
392
  const shouldInjectShield = injectRuntimeShield && isEntry;
369
393
  const fileSeed = computeFnv1aHash(`${relPath}:${i}`, seed);
370
394
  const transformOptions = {