@vercel/next 35.0.0-snapshot-12a52bb14e02 → 35.0.1-snapshot-e90c74f31ca1

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.
@@ -11217,15 +11217,29 @@ async function isFile(file) {
11217
11217
  }
11218
11218
 
11219
11219
  // src/index.ts
11220
- function getHtmlLimitedBotsPattern(config) {
11221
- const pattern = config.htmlLimitedBots;
11222
- return Buffer.byteLength(pattern, "utf8") <= 4096 ? pattern : void 0;
11220
+ var MAX_HTML_LIMITED_BOTS_REGEX_BYTES = 4096;
11221
+ function shouldEmitAfterCacheBypass(config, { warnOnByteLimitExceeded = false } = {}) {
11222
+ if (!config.cacheComponents) {
11223
+ return false;
11224
+ }
11225
+ const byteLength = Buffer.byteLength(config.htmlLimitedBots, "utf8");
11226
+ if (byteLength <= MAX_HTML_LIMITED_BOTS_REGEX_BYTES) {
11227
+ return true;
11228
+ }
11229
+ if (warnOnByteLimitExceeded) {
11230
+ console.warn(
11231
+ `The \`htmlLimitedBots\` regex in ${config.configFileName} is ${byteLength} UTF-8 bytes which exceeds the maximum of ${MAX_HTML_LIMITED_BOTS_REGEX_BYTES} bytes. Some link previews may be missing a title or description. Please reduce the size of htmlLimitedBots and try deploying again.`
11232
+ );
11233
+ }
11234
+ return false;
11223
11235
  }
11224
11236
  var myAdapter = {
11225
11237
  name: "Vercel",
11226
11238
  getCapabilities({ config }) {
11227
11239
  return {
11228
- supportsHtmlLimitedBotPrerenders: getHtmlLimitedBotsPattern(config) !== void 0,
11240
+ supportsHtmlLimitedBotPrerenders: shouldEmitAfterCacheBypass(config, {
11241
+ warnOnByteLimitExceeded: true
11242
+ }),
11229
11243
  supportsPrerenderMethodBypass: true
11230
11244
  };
11231
11245
  },
@@ -11289,17 +11303,16 @@ var myAdapter = {
11289
11303
  const hasPagesDir = outputs.pages.length > 0 || outputs.pagesApi.length > 0;
11290
11304
  const shouldHandleMiddlewareDataResolving = routing.shouldNormalizeNextData;
11291
11305
  const i18nConfig = config.i18n;
11292
- const htmlLimitedBotsRegex = getHtmlLimitedBotsPattern(config);
11293
11306
  const vercelConfig2 = {
11294
11307
  version: 3,
11295
- afterCacheBypass: config.cacheComponents && htmlLimitedBotsRegex !== void 0 ? [
11308
+ afterCacheBypass: shouldEmitAfterCacheBypass(config) ? [
11296
11309
  {
11297
11310
  name: "HTML Limited Bots",
11298
11311
  hasAll: [
11299
11312
  {
11300
11313
  type: "request.header",
11301
11314
  key: "user-agent",
11302
- value: { re: htmlLimitedBotsRegex }
11315
+ value: { re: config.htmlLimitedBots }
11303
11316
  },
11304
11317
  {
11305
11318
  type: "cache.response.header",
Binary file
package/dist/index.js CHANGED
@@ -3288,14 +3288,14 @@ var require_empty = __commonJS({
3288
3288
  var u2 = require_universalify().fromPromise;
3289
3289
  var fs7 = require_fs();
3290
3290
  var path7 = require("path");
3291
- var mkdir = require_mkdirs();
3291
+ var mkdir2 = require_mkdirs();
3292
3292
  var remove7 = require_remove();
3293
3293
  var emptyDir = u2(async function emptyDir2(dir) {
3294
3294
  let items;
3295
3295
  try {
3296
3296
  items = await fs7.readdir(dir);
3297
3297
  } catch {
3298
- return mkdir.mkdirs(dir);
3298
+ return mkdir2.mkdirs(dir);
3299
3299
  }
3300
3300
  return Promise.all(items.map((item) => remove7.remove(path7.join(dir, item))));
3301
3301
  });
@@ -3304,7 +3304,7 @@ var require_empty = __commonJS({
3304
3304
  try {
3305
3305
  items = fs7.readdirSync(dir);
3306
3306
  } catch {
3307
- return mkdir.mkdirsSync(dir);
3307
+ return mkdir2.mkdirsSync(dir);
3308
3308
  }
3309
3309
  items.forEach((item) => {
3310
3310
  item = path7.join(dir, item);
@@ -3327,7 +3327,7 @@ var require_file = __commonJS({
3327
3327
  var u2 = require_universalify().fromPromise;
3328
3328
  var path7 = require("path");
3329
3329
  var fs7 = require_fs();
3330
- var mkdir = require_mkdirs();
3330
+ var mkdir2 = require_mkdirs();
3331
3331
  async function createFile(file) {
3332
3332
  let stats;
3333
3333
  try {
@@ -3342,7 +3342,7 @@ var require_file = __commonJS({
3342
3342
  dirStats = await fs7.stat(dir);
3343
3343
  } catch (err) {
3344
3344
  if (err.code === "ENOENT") {
3345
- await mkdir.mkdirs(dir);
3345
+ await mkdir2.mkdirs(dir);
3346
3346
  await fs7.writeFile(file, "");
3347
3347
  return;
3348
3348
  } else {
@@ -3370,7 +3370,7 @@ var require_file = __commonJS({
3370
3370
  }
3371
3371
  } catch (err) {
3372
3372
  if (err && err.code === "ENOENT")
3373
- mkdir.mkdirsSync(dir);
3373
+ mkdir2.mkdirsSync(dir);
3374
3374
  else
3375
3375
  throw err;
3376
3376
  }
@@ -3390,7 +3390,7 @@ var require_link = __commonJS({
3390
3390
  var u2 = require_universalify().fromPromise;
3391
3391
  var path7 = require("path");
3392
3392
  var fs7 = require_fs();
3393
- var mkdir = require_mkdirs();
3393
+ var mkdir2 = require_mkdirs();
3394
3394
  var { pathExists: pathExists4 } = require_path_exists2();
3395
3395
  var { areIdentical } = require_stat();
3396
3396
  async function createLink(srcpath, dstpath) {
@@ -3411,7 +3411,7 @@ var require_link = __commonJS({
3411
3411
  const dir = path7.dirname(dstpath);
3412
3412
  const dirExists = await pathExists4(dir);
3413
3413
  if (!dirExists) {
3414
- await mkdir.mkdirs(dir);
3414
+ await mkdir2.mkdirs(dir);
3415
3415
  }
3416
3416
  await fs7.link(srcpath, dstpath);
3417
3417
  }
@@ -3433,7 +3433,7 @@ var require_link = __commonJS({
3433
3433
  const dirExists = fs7.existsSync(dir);
3434
3434
  if (dirExists)
3435
3435
  return fs7.linkSync(srcpath, dstpath);
3436
- mkdir.mkdirsSync(dir);
3436
+ mkdir2.mkdirsSync(dir);
3437
3437
  return fs7.linkSync(srcpath, dstpath);
3438
3438
  }
3439
3439
  module2.exports = {
@@ -3758,19 +3758,19 @@ var require_output_file = __commonJS({
3758
3758
  var u2 = require_universalify().fromPromise;
3759
3759
  var fs7 = require_fs();
3760
3760
  var path7 = require("path");
3761
- var mkdir = require_mkdirs();
3761
+ var mkdir2 = require_mkdirs();
3762
3762
  var pathExists4 = require_path_exists2().pathExists;
3763
3763
  async function outputFile(file, data, encoding = "utf-8") {
3764
3764
  const dir = path7.dirname(file);
3765
3765
  if (!await pathExists4(dir)) {
3766
- await mkdir.mkdirs(dir);
3766
+ await mkdir2.mkdirs(dir);
3767
3767
  }
3768
3768
  return fs7.writeFile(file, data, encoding);
3769
3769
  }
3770
3770
  function outputFileSync(file, ...args) {
3771
3771
  const dir = path7.dirname(file);
3772
3772
  if (!fs7.existsSync(dir)) {
3773
- mkdir.mkdirsSync(dir);
3773
+ mkdir2.mkdirsSync(dir);
3774
3774
  }
3775
3775
  fs7.writeFileSync(file, ...args);
3776
3776
  }
@@ -26424,9 +26424,32 @@ async function withGoCacheLock(workPath, kind, run) {
26424
26424
  }
26425
26425
  }
26426
26426
  }
26427
+ function goBuildCacheRoot() {
26428
+ const uid = process.getuid?.();
26429
+ return uid === void 0 ? (0, import_path12.join)((0, import_os2.tmpdir)(), "vercel-next-go-build") : (0, import_path12.join)((0, import_os2.tmpdir)(), `vercel-next-go-build-${uid}`);
26430
+ }
26427
26431
  function externalGoBuildCachePath(workPath) {
26428
26432
  const hash = (0, import_crypto2.createHash)("sha256").update((0, import_path12.resolve)(workPath)).digest("hex").slice(0, 16);
26429
- return (0, import_path12.join)((0, import_os2.tmpdir)(), `vercel-next-go-build-${hash}`);
26433
+ return (0, import_path12.join)(goBuildCacheRoot(), hash);
26434
+ }
26435
+ async function isPrivateDirectory(dir) {
26436
+ try {
26437
+ const stats = await (0, import_fs_extra9.lstat)(dir);
26438
+ if (!stats.isDirectory())
26439
+ return false;
26440
+ if (process.platform === "win32")
26441
+ return true;
26442
+ const uid = process.getuid?.();
26443
+ return (stats.mode & 63) === 0 && (uid === void 0 || stats.uid === uid);
26444
+ } catch {
26445
+ return false;
26446
+ }
26447
+ }
26448
+ async function ensurePrivateDirectory(dir) {
26449
+ await (0, import_promises2.mkdir)(dir, { recursive: true, mode: 448 });
26450
+ if (!await isPrivateDirectory(dir)) {
26451
+ throw new Error(`Go build cache directory is not private: ${dir}`);
26452
+ }
26430
26453
  }
26431
26454
  function isWithin(root, path7) {
26432
26455
  const pathFromRoot = (0, import_path12.relative)(root, path7);
@@ -26465,7 +26488,8 @@ async function prepareGoBuildCache(workPath) {
26465
26488
  const externalCache = externalGoBuildCachePath(workPath);
26466
26489
  const archive = (0, import_path12.join)(workPath, localCacheDir, GO_BUILD_CACHE_ARCHIVE);
26467
26490
  await withGoCacheLock(workPath, "hydrate", async () => {
26468
- await (0, import_fs_extra9.mkdirp)(externalCache);
26491
+ await ensurePrivateDirectory(goBuildCacheRoot());
26492
+ await ensurePrivateDirectory(externalCache);
26469
26493
  if (await (0, import_fs_extra9.pathExists)(archive)) {
26470
26494
  try {
26471
26495
  let invalidPath = false;
@@ -26536,7 +26560,7 @@ async function prepareGoCache({
26536
26560
  await materializeGoCacheDirectory(goCacheDir);
26537
26561
  if (externalBuildCache) {
26538
26562
  const externalCache = externalGoBuildCachePath(workPath);
26539
- if (await (0, import_fs_extra9.pathExists)(externalCache)) {
26563
+ if (await isPrivateDirectory(goBuildCacheRoot()) && await isPrivateDirectory(externalCache)) {
26540
26564
  await snapshotGoBuildCache(externalCache, goCacheDir);
26541
26565
  }
26542
26566
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "35.0.0-snapshot-12a52bb14e02",
3
+ "version": "35.0.1-snapshot-e90c74f31ca1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -14,13 +14,13 @@
14
14
  ],
15
15
  "dependencies": {
16
16
  "@vercel/nft": "1.10.0",
17
- "@vercel/container": "31.0.0-snapshot-12a52bb14e02"
17
+ "@vercel/container": "31.0.0"
18
18
  },
19
19
  "peerDependencies": {
20
- "@vercel/build-utils": "15.9.0-snapshot-12a52bb14e02"
20
+ "@vercel/build-utils": "15.9.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@next-community/adapter-vercel": "0.1.0-beta.42",
23
+ "@next-community/adapter-vercel": "0.1.0-beta.43",
24
24
  "@types/aws-lambda": "8.10.19",
25
25
  "@types/buffer-crc32": "0.2.0",
26
26
  "@types/bytes": "3.1.1",
@@ -61,8 +61,8 @@
61
61
  "vite": "6.4.3",
62
62
  "vitest": "4.1.10",
63
63
  "webpack-sources": "3.2.3",
64
- "@vercel/go": "34.0.0-snapshot-12a52bb14e02",
65
- "@vercel/build-utils": "15.9.0-snapshot-12a52bb14e02",
64
+ "@vercel/go": "34.0.0",
65
+ "@vercel/build-utils": "15.9.0",
66
66
  "@vercel-internals/ipc-proxy": "1.1.5",
67
67
  "@vercel/routing-utils": "6.6.1"
68
68
  },