@next-community/adapter-vercel 0.0.1-beta.20 → 0.0.1-beta.22

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 (2) hide show
  1. package/dist/index.js +127 -60
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -36,9 +36,9 @@ var require_interop_require_default = __commonJS({
36
36
  }
37
37
  });
38
38
 
39
- // ../../node_modules/.pnpm/next@16.2.1-canary.34_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/next/dist/shared/lib/modern-browserslist-target.js
39
+ // ../../node_modules/.pnpm/next@16.3.0-canary.24_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/next/dist/shared/lib/modern-browserslist-target.js
40
40
  var require_modern_browserslist_target = __commonJS({
41
- "../../node_modules/.pnpm/next@16.2.1-canary.34_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/next/dist/shared/lib/modern-browserslist-target.js"(exports2, module2) {
41
+ "../../node_modules/.pnpm/next@16.3.0-canary.24_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/next/dist/shared/lib/modern-browserslist-target.js"(exports2, module2) {
42
42
  "use strict";
43
43
  var MODERN_BROWSERSLIST_TARGET = [
44
44
  "chrome 111",
@@ -50,9 +50,9 @@ var require_modern_browserslist_target = __commonJS({
50
50
  }
51
51
  });
52
52
 
53
- // ../../node_modules/.pnpm/next@16.2.1-canary.34_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/next/dist/shared/lib/entry-constants.js
53
+ // ../../node_modules/.pnpm/next@16.3.0-canary.24_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/next/dist/shared/lib/entry-constants.js
54
54
  var require_entry_constants = __commonJS({
55
- "../../node_modules/.pnpm/next@16.2.1-canary.34_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/next/dist/shared/lib/entry-constants.js"(exports2) {
55
+ "../../node_modules/.pnpm/next@16.3.0-canary.24_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/next/dist/shared/lib/entry-constants.js"(exports2) {
56
56
  "use strict";
57
57
  Object.defineProperty(exports2, "__esModule", {
58
58
  value: true
@@ -84,9 +84,9 @@ var require_entry_constants = __commonJS({
84
84
  }
85
85
  });
86
86
 
87
- // ../../node_modules/.pnpm/next@16.2.1-canary.34_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/next/dist/shared/lib/constants.js
87
+ // ../../node_modules/.pnpm/next@16.3.0-canary.24_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/next/dist/shared/lib/constants.js
88
88
  var require_constants = __commonJS({
89
- "../../node_modules/.pnpm/next@16.2.1-canary.34_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/next/dist/shared/lib/constants.js"(exports2, module2) {
89
+ "../../node_modules/.pnpm/next@16.3.0-canary.24_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/next/dist/shared/lib/constants.js"(exports2, module2) {
90
90
  "use strict";
91
91
  Object.defineProperty(exports2, "__esModule", {
92
92
  value: true
@@ -447,9 +447,9 @@ var require_constants = __commonJS({
447
447
  }
448
448
  });
449
449
 
450
- // ../../node_modules/.pnpm/next@16.2.1-canary.34_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/next/constants.js
450
+ // ../../node_modules/.pnpm/next@16.3.0-canary.24_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/next/constants.js
451
451
  var require_constants2 = __commonJS({
452
- "../../node_modules/.pnpm/next@16.2.1-canary.34_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/next/constants.js"(exports2, module2) {
452
+ "../../node_modules/.pnpm/next@16.3.0-canary.24_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/next/constants.js"(exports2, module2) {
453
453
  module2.exports = require_constants();
454
454
  }
455
455
  });
@@ -9539,6 +9539,45 @@ function getWasmImportStatements(wasm) {
9539
9539
 
9540
9540
  // src/outputs.ts
9541
9541
  var import_node_handler = require("./node-handler");
9542
+
9543
+ // src/utils.ts
9544
+ var import_node_crypto = __toESM(require("node:crypto"));
9545
+ var import_picomatch = __toESM(require_picomatch2());
9546
+ function getImagesConfig(config) {
9547
+ const images = config.images || {};
9548
+ const remotePatterns = (images.remotePatterns || []).map((p) => ({
9549
+ protocol: p.protocol?.replace(/:$/, ""),
9550
+ hostname: (0, import_picomatch.makeRe)(p.hostname).source,
9551
+ port: p.port,
9552
+ pathname: (0, import_picomatch.makeRe)(p.pathname ?? "**", { dot: true }).source,
9553
+ search: p.search
9554
+ }));
9555
+ const localPatterns = images.localPatterns?.map((p) => ({
9556
+ pathname: (0, import_picomatch.makeRe)(p.pathname ?? "**", { dot: true }).source,
9557
+ search: p.search
9558
+ }));
9559
+ return {
9560
+ localPatterns,
9561
+ remotePatterns,
9562
+ sizes: [...images.imageSizes || [], ...images.deviceSizes || []],
9563
+ domains: images.domains || [],
9564
+ qualities: images.qualities,
9565
+ minimumCacheTTL: images.minimumCacheTTL,
9566
+ formats: images.formats,
9567
+ dangerouslyAllowSVG: images.dangerouslyAllowSVG,
9568
+ contentSecurityPolicy: images.contentSecurityPolicy,
9569
+ contentDispositionType: images.contentDispositionType
9570
+ };
9571
+ }
9572
+ var matchOperatorsRegex = /[|\\{}()[\]^$+*?.-]/g;
9573
+ function escapeStringRegexp(str) {
9574
+ return str.replace(matchOperatorsRegex, "\\$&");
9575
+ }
9576
+ function sha256(input) {
9577
+ return import_node_crypto.default.createHash("sha256").update(input).digest("hex");
9578
+ }
9579
+
9580
+ // src/outputs.ts
9542
9581
  function fallbackHasFilePath(fallback) {
9543
9582
  return fallback !== void 0 && "filePath" in fallback && typeof fallback.filePath === "string";
9544
9583
  }
@@ -9715,8 +9754,12 @@ async function writeDeterministicRoutesManifest(distDir) {
9715
9754
  distDir,
9716
9755
  "routes-manifest-deterministic.json"
9717
9756
  );
9718
- await import_promises.default.writeFile(outputManifestPath, JSON.stringify(manifest));
9719
- return outputManifestPath;
9757
+ const manifestJson = JSON.stringify(manifest);
9758
+ await import_promises.default.writeFile(outputManifestPath, manifestJson);
9759
+ return {
9760
+ routesManifestPath: outputManifestPath,
9761
+ routesManifestHash: sha256(manifestJson)
9762
+ };
9720
9763
  }
9721
9764
  async function getProjectEnvFiles(projectDir) {
9722
9765
  const envFiles = [];
@@ -9780,10 +9823,7 @@ async function handleNodeOutputs(nodeOutputs, {
9780
9823
  break;
9781
9824
  }
9782
9825
  }
9783
- const routesManifestDeterministicRelativePath = import_node_path.default.posix.relative(
9784
- repoRoot,
9785
- await writeDeterministicRoutesManifest(distDir)
9786
- );
9826
+ const { routesManifestPath, routesManifestHash } = await writeDeterministicRoutesManifest(distDir);
9787
9827
  const routesManifestRelativePath = import_node_path.default.posix.join(
9788
9828
  import_node_path.default.posix.relative(repoRoot, distDir),
9789
9829
  "routes-manifest.json"
@@ -9791,9 +9831,13 @@ async function handleNodeOutputs(nodeOutputs, {
9791
9831
  const envFiles = await getProjectEnvFiles(projectDir);
9792
9832
  const hasProjectEnvFiles = envFiles.length > 0;
9793
9833
  const envFilePathMap = {};
9834
+ const envFileHashes = {};
9794
9835
  let nextEnvLoaderPathRelativeToProjectDir;
9795
9836
  for (const envFile of envFiles) {
9796
9837
  envFilePathMap[import_node_path.default.posix.join(import_node_path.default.posix.relative(repoRoot, projectDir), envFile)] = import_node_path.default.posix.relative(repoRoot, import_node_path.default.join(projectDir, envFile));
9838
+ envFileHashes[envFile] = sha256(
9839
+ await import_promises.default.readFile(import_node_path.default.join(projectDir, envFile))
9840
+ );
9797
9841
  }
9798
9842
  if (hasProjectEnvFiles) {
9799
9843
  if (!hasWarnedAboutDotEnv) {
@@ -9804,6 +9848,9 @@ async function handleNodeOutputs(nodeOutputs, {
9804
9848
  }
9805
9849
  const nextEnvLoaderPath = resolveNextEnvLoaderPath(projectDir);
9806
9850
  envFilePathMap[import_node_path.default.posix.relative(repoRoot, nextEnvLoaderPath)] = import_node_path.default.posix.relative(repoRoot, nextEnvLoaderPath);
9851
+ envFileHashes[import_node_path.default.posix.relative(repoRoot, nextEnvLoaderPath)] = sha256(
9852
+ await import_promises.default.readFile(nextEnvLoaderPath)
9853
+ );
9807
9854
  nextEnvLoaderPathRelativeToProjectDir = import_node_path.default.posix.relative(
9808
9855
  projectDir,
9809
9856
  nextEnvLoaderPath
@@ -9818,12 +9865,16 @@ async function handleNodeOutputs(nodeOutputs, {
9818
9865
  );
9819
9866
  await import_promises.default.mkdir(functionDir, { recursive: true });
9820
9867
  const files = {};
9868
+ const filesHashes = output.assetsHashes;
9821
9869
  for (const [relPath, fsPath] of Object.entries(output.assets)) {
9822
9870
  files[relPath] = import_node_path.default.posix.relative(repoRoot, fsPath);
9823
9871
  }
9824
9872
  files[import_node_path.default.posix.relative(repoRoot, output.filePath)] = import_node_path.default.posix.relative(repoRoot, output.filePath);
9825
9873
  if (hasProjectEnvFiles) {
9826
9874
  Object.assign(files, envFilePathMap);
9875
+ if (filesHashes) {
9876
+ Object.assign(filesHashes, envFileHashes);
9877
+ }
9827
9878
  }
9828
9879
  if (output.type === import_constants.AdapterOutputType.PAGES) {
9829
9880
  const notFoundOutput = pages404Output || pagesErrorOutput;
@@ -9832,12 +9883,19 @@ async function handleNodeOutputs(nodeOutputs, {
9832
9883
  notFoundOutput.assets
9833
9884
  )) {
9834
9885
  files[relPath] = import_node_path.default.posix.relative(repoRoot, fsPath);
9886
+ if (filesHashes) {
9887
+ filesHashes[relPath] = notFoundOutput.assetsHashes?.[relPath];
9888
+ }
9835
9889
  }
9836
9890
  files[import_node_path.default.posix.relative(repoRoot, notFoundOutput.filePath)] = import_node_path.default.posix.relative(repoRoot, notFoundOutput.filePath);
9837
9891
  }
9838
9892
  }
9839
- if (files[routesManifestRelativePath]) {
9840
- files[routesManifestRelativePath] = routesManifestDeterministicRelativePath;
9893
+ files[routesManifestRelativePath] = import_node_path.default.posix.relative(
9894
+ repoRoot,
9895
+ routesManifestPath
9896
+ );
9897
+ if (filesHashes) {
9898
+ filesHashes[routesManifestRelativePath] = routesManifestHash;
9841
9899
  }
9842
9900
  const handlerFilePath = import_node_path.default.join(
9843
9901
  functionDir,
@@ -9845,16 +9903,17 @@ async function handleNodeOutputs(nodeOutputs, {
9845
9903
  "___next_launcher.cjs"
9846
9904
  );
9847
9905
  await import_promises.default.mkdir(import_node_path.default.dirname(handlerFilePath), { recursive: true });
9848
- await writeIfNotExists(
9849
- handlerFilePath,
9850
- (0, import_node_handler.getHandlerSource)({
9851
- projectRelativeDistDir: import_node_path.default.posix.relative(projectDir, distDir),
9852
- prerenderFallbackFalseMap,
9853
- isMiddleware,
9854
- nextConfig: config,
9855
- nextEnvLoaderPathRelativeToProjectDir
9856
- })
9857
- );
9906
+ const handlerSource = (0, import_node_handler.getHandlerSource)({
9907
+ projectRelativeDistDir: import_node_path.default.posix.relative(projectDir, distDir),
9908
+ prerenderFallbackFalseMap,
9909
+ isMiddleware,
9910
+ nextConfig: config,
9911
+ nextEnvLoaderPathRelativeToProjectDir
9912
+ });
9913
+ await writeIfNotExists(handlerFilePath, handlerSource);
9914
+ if (filesHashes) {
9915
+ filesHashes["___next_launcher.cjs"] = sha256(handlerSource);
9916
+ }
9858
9917
  const operationType = output.type === import_constants.AdapterOutputType.APP_PAGE || import_constants.AdapterOutputType.PAGES ? "PAGE" : "API";
9859
9918
  const sourceFile = await getSourceFilePathFromPage({
9860
9919
  workPath: projectDir,
@@ -9897,11 +9956,12 @@ async function handleNodeOutputs(nodeOutputs, {
9897
9956
  experimentalAllowBundling: true,
9898
9957
  // middleware handler always expects Request/Response interface
9899
9958
  useWebApi: isMiddleware,
9900
- launcherType: "Nodejs"
9959
+ launcherType: "Nodejs",
9960
+ fileHashes: filesHashes
9901
9961
  };
9902
9962
  await writeIfNotExists(
9903
9963
  import_node_path.default.join(functionDir, `.vc-config.json`),
9904
- JSON.stringify(nodeConfig)
9964
+ JSON.stringify(nodeConfig, null, 2)
9905
9965
  );
9906
9966
  fsSema.release();
9907
9967
  })
@@ -10540,49 +10600,56 @@ function denormalizeNextDataRoutes(config, buildId, shouldHandleMiddlewareDataRe
10540
10600
  ];
10541
10601
  }
10542
10602
 
10543
- // src/utils.ts
10544
- var import_picomatch = __toESM(require_picomatch2());
10545
- function getImagesConfig(config) {
10546
- const images = config.images || {};
10547
- const remotePatterns = (images.remotePatterns || []).map((p) => ({
10548
- protocol: p.protocol?.replace(/:$/, ""),
10549
- hostname: (0, import_picomatch.makeRe)(p.hostname).source,
10550
- port: p.port,
10551
- pathname: (0, import_picomatch.makeRe)(p.pathname ?? "**", { dot: true }).source,
10552
- search: p.search
10553
- }));
10554
- const localPatterns = images.localPatterns?.map((p) => ({
10555
- pathname: (0, import_picomatch.makeRe)(p.pathname ?? "**", { dot: true }).source,
10556
- search: p.search
10557
- }));
10558
- return {
10559
- localPatterns,
10560
- remotePatterns,
10561
- sizes: [...images.imageSizes || [], ...images.deviceSizes || []],
10562
- domains: images.domains || [],
10563
- qualities: images.qualities,
10564
- minimumCacheTTL: images.minimumCacheTTL,
10565
- formats: images.formats,
10566
- dangerouslyAllowSVG: images.dangerouslyAllowSVG,
10567
- contentSecurityPolicy: images.contentSecurityPolicy,
10568
- contentDispositionType: images.contentDispositionType
10569
- };
10570
- }
10571
- var matchOperatorsRegex = /[|\\{}()[\]^$+*?.-]/g;
10572
- function escapeStringRegexp(str) {
10573
- return str.replace(matchOperatorsRegex, "\\$&");
10603
+ // src/toolbar.ts
10604
+ function generateToolbarScript(isProduction, optIn, deploymentIdExpr) {
10605
+ let cookieCheck = "true";
10606
+ let applyOptInAttr = "";
10607
+ if (isProduction) {
10608
+ cookieCheck = "/(?:^|;\\s)__vercel_toolbar=1(?:;|$)/.test(document.cookie)";
10609
+ applyOptInAttr = 's.setAttribute("data-explicit-opt-in","true");s.setAttribute("data-cookie-opt-in","true");';
10610
+ } else if (optIn) {
10611
+ applyOptInAttr = 's.setAttribute("data-explicit-opt-in","true");';
10612
+ }
10613
+ applyOptInAttr += `s.setAttribute("data-deployment-id",${deploymentIdExpr});`;
10614
+ return `
10615
+ if(${cookieCheck}){
10616
+ var s=document.createElement('script');
10617
+ s.src='https://vercel.live/_next-live/feedback/feedback.js';
10618
+ ${applyOptInAttr}
10619
+ ((document.head||document.documentElement).appendChild(s))
10620
+ }`;
10574
10621
  }
10575
10622
 
10576
10623
  // src/index.ts
10577
10624
  var myAdapter = {
10578
10625
  name: "Vercel",
10579
- modifyConfig(config, ctx) {
10626
+ async modifyConfig(config, ctx) {
10580
10627
  if (ctx.phase === import_constants2.PHASE_PRODUCTION_BUILD && process.env.VERCEL_IMMUTABLE_STATIC_FILES_ENABLED === "1") {
10581
10628
  config.experimental.supportsImmutableAssets = true;
10582
10629
  }
10583
10630
  if (process.env.VERCEL_HASH_SALT != null) {
10584
10631
  config.experimental.outputHashSalt = (config.experimental.outputHashSalt ?? "") + process.env.VERCEL_HASH_SALT;
10585
10632
  }
10633
+ if (ctx.phase === import_constants2.PHASE_PRODUCTION_BUILD && process.env.VERCEL_PREVIEW_COMMENTS_ENABLED === "1" && // Only available in newer Next.js versions
10634
+ typeof ctx.projectDir !== "undefined") {
10635
+ const dir = import_node_path2.default.join(ctx.projectDir, ".vercel/");
10636
+ await import_promises2.default.mkdir(dir, { recursive: true });
10637
+ await import_promises2.default.writeFile(
10638
+ import_node_path2.default.join(dir, "adapter-toolbar-script.js"),
10639
+ generateToolbarScript(
10640
+ process.env.VERCEL_ENV === "production",
10641
+ process.env.VERCEL_PREVIEW_COMMENTS_OPT_IN === "1",
10642
+ process.env.VERCEL_SKEW_PROTECTION_ENABLED === "1" ? "process.env.NEXT_DEPLOYMENT_ID" : (
10643
+ // Fallback to burning in the deployment id if skew protection is disabled
10644
+ "process.env.NEXT_PUBLIC_VERCEL_DEPLOYMENT_ID"
10645
+ )
10646
+ )
10647
+ );
10648
+ config.instrumentationClientInject ??= [];
10649
+ config.instrumentationClientInject.push(
10650
+ `./.vercel/adapter-toolbar-script.js`
10651
+ );
10652
+ }
10586
10653
  return config;
10587
10654
  },
10588
10655
  async onBuildComplete({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-community/adapter-vercel",
3
- "version": "0.0.1-beta.20",
3
+ "version": "0.0.1-beta.22",
4
4
  "type": "commonjs",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -23,7 +23,7 @@
23
23
  "convert-source-map": "1.8.0",
24
24
  "esbuild": "0.25.10",
25
25
  "fs-extra": "11.2.0",
26
- "next": "16.2.1-canary.34",
26
+ "next": "16.3.0-canary.24",
27
27
  "picomatch": "4.0.1",
28
28
  "source-map": "0.7.4",
29
29
  "webpack-sources": "3.2.3"