@netlify/plugin-nextjs 5.0.0-beta.4 → 5.0.0-beta.6

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.
@@ -7,7 +7,7 @@
7
7
  import {
8
8
  copyFetchContent,
9
9
  copyPrerenderedContent
10
- } from "../../esm-chunks/chunk-DZM5AUXX.js";
10
+ } from "../../esm-chunks/chunk-UDWVXRI2.js";
11
11
  import "../../esm-chunks/chunk-MFN4GH7U.js";
12
12
  import "../../esm-chunks/chunk-WELZ7LFO.js";
13
13
  export {
@@ -8,7 +8,7 @@ import {
8
8
  copyNextDependencies,
9
9
  copyNextServerCode,
10
10
  writeTagsManifest
11
- } from "../../esm-chunks/chunk-6HBXWNZS.js";
11
+ } from "../../esm-chunks/chunk-COJ526HO.js";
12
12
  import "../../esm-chunks/chunk-MFN4GH7U.js";
13
13
  import "../../esm-chunks/chunk-WELZ7LFO.js";
14
14
  export {
@@ -9,8 +9,9 @@ import {
9
9
  copyStaticContent,
10
10
  publishStaticDir,
11
11
  unpublishStaticDir
12
- } from "../../esm-chunks/chunk-KMPIVUVT.js";
12
+ } from "../../esm-chunks/chunk-AMJYZZKR.js";
13
13
  import "../../esm-chunks/chunk-MFN4GH7U.js";
14
+ import "../../esm-chunks/chunk-TYCYFZ22.js";
14
15
  import "../../esm-chunks/chunk-WELZ7LFO.js";
15
16
  export {
16
17
  copyStaticAssets,
@@ -6,9 +6,10 @@
6
6
 
7
7
  import {
8
8
  createEdgeHandlers
9
- } from "../../esm-chunks/chunk-XC7T747I.js";
9
+ } from "../../esm-chunks/chunk-PCJY2SS7.js";
10
10
  import "../../esm-chunks/chunk-MFN4GH7U.js";
11
- import "../../esm-chunks/chunk-IZY5TPZE.js";
11
+ import "../../esm-chunks/chunk-IZ2AVCVF.js";
12
+ import "../../esm-chunks/chunk-TYCYFZ22.js";
12
13
  import "../../esm-chunks/chunk-WELZ7LFO.js";
13
14
  export {
14
15
  createEdgeHandlers
@@ -6,10 +6,11 @@
6
6
 
7
7
  import {
8
8
  createServerHandler
9
- } from "../../esm-chunks/chunk-X4Q4MYBW.js";
10
- import "../../esm-chunks/chunk-6HBXWNZS.js";
9
+ } from "../../esm-chunks/chunk-KDRFBPAR.js";
10
+ import "../../esm-chunks/chunk-COJ526HO.js";
11
11
  import "../../esm-chunks/chunk-MFN4GH7U.js";
12
- import "../../esm-chunks/chunk-IZY5TPZE.js";
12
+ import "../../esm-chunks/chunk-IZ2AVCVF.js";
13
+ import "../../esm-chunks/chunk-TYCYFZ22.js";
13
14
  import "../../esm-chunks/chunk-WELZ7LFO.js";
14
15
  export {
15
16
  createServerHandler
@@ -8,7 +8,8 @@ import {
8
8
  EDGE_HANDLER_NAME,
9
9
  PluginContext,
10
10
  SERVER_HANDLER_NAME
11
- } from "../esm-chunks/chunk-IZY5TPZE.js";
11
+ } from "../esm-chunks/chunk-IZ2AVCVF.js";
12
+ import "../esm-chunks/chunk-TYCYFZ22.js";
12
13
  import "../esm-chunks/chunk-WELZ7LFO.js";
13
14
  export {
14
15
  EDGE_HANDLER_NAME,
@@ -7,13 +7,15 @@
7
7
  import {
8
8
  require_out
9
9
  } from "./chunk-MFN4GH7U.js";
10
+ import {
11
+ encodeBlobKey
12
+ } from "./chunk-TYCYFZ22.js";
10
13
  import {
11
14
  __toESM
12
15
  } from "./chunk-WELZ7LFO.js";
13
16
 
14
17
  // src/build/content/static.ts
15
18
  var import_fast_glob = __toESM(require_out(), 1);
16
- import { Buffer } from "node:buffer";
17
19
  import { existsSync } from "node:fs";
18
20
  import { cp, mkdir, rename, rm } from "node:fs/promises";
19
21
  import { join } from "node:path";
@@ -27,8 +29,7 @@ var copyStaticContent = async (ctx) => {
27
29
  try {
28
30
  await Promise.all(
29
31
  paths.filter((path) => !paths.includes(`${path.slice(0, -5)}.json`)).map(async (path) => {
30
- const key = Buffer.from(path).toString("base64");
31
- await cp(join(srcDir, path), join(destDir, key), { recursive: true });
32
+ await cp(join(srcDir, path), join(destDir, await encodeBlobKey(path)), { recursive: true });
32
33
  })
33
34
  );
34
35
  } catch (error) {
@@ -15,7 +15,8 @@ import {
15
15
  var import_fast_glob = __toESM(require_out(), 1);
16
16
  import { existsSync } from "node:fs";
17
17
  import { cp, mkdir, readFile, readdir, readlink, symlink, writeFile } from "node:fs/promises";
18
- import { dirname, join } from "node:path";
18
+ import { createRequire } from "node:module";
19
+ import { dirname, join, resolve } from "node:path";
19
20
  var copyNextServerCode = async (ctx) => {
20
21
  const srcDir = join(ctx.standaloneDir, ".next");
21
22
  const destDir = join(ctx.serverHandlerDir, ".next");
@@ -57,7 +58,7 @@ async function recreateNodeModuleSymlinks(src, dest, org) {
57
58
  if (org) {
58
59
  await mkdir(join(dest, org), { recursive: true });
59
60
  }
60
- await symlink(symlinkDest, symlinkSrc);
61
+ await symlink(symlinkTarget, symlinkSrc);
61
62
  }
62
63
  }
63
64
  })
@@ -71,7 +72,7 @@ var copyNextDependencies = async (ctx) => {
71
72
  }
72
73
  const src = join(ctx.standaloneDir, entry);
73
74
  const dest = join(ctx.serverHandlerDir, entry);
74
- await cp(src, dest, { recursive: true });
75
+ await cp(src, dest, { recursive: true, verbatimSymlinks: true });
75
76
  if (entry === "node_modules") {
76
77
  await recreateNodeModuleSymlinks(ctx.resolve("node_modules"), dest);
77
78
  }
@@ -80,12 +81,21 @@ var copyNextDependencies = async (ctx) => {
80
81
  const rootDestDir = join(ctx.serverHandlerRootDir, "node_modules");
81
82
  if (existsSync(rootSrcDir) && ctx.standaloneRootDir !== ctx.standaloneDir) {
82
83
  promises.push(
83
- cp(rootSrcDir, rootDestDir, { recursive: true }).then(
84
- () => recreateNodeModuleSymlinks(ctx.resolve("node_modules"), rootDestDir)
84
+ cp(rootSrcDir, rootDestDir, { recursive: true, verbatimSymlinks: true }).then(
85
+ () => recreateNodeModuleSymlinks(resolve("node_modules"), rootDestDir)
85
86
  )
86
87
  );
87
88
  }
88
89
  await Promise.all(promises);
90
+ const require2 = createRequire(ctx.serverHandlerDir);
91
+ try {
92
+ require2.resolve("styled-jsx");
93
+ require2.resolve("next");
94
+ } catch {
95
+ throw new Error(
96
+ "node_modules are not installed correctly, if you are using pnpm please set the public hoist pattern to: `public-hoist-pattern[]=*`.\nRefer to your docs for more details: https://docs.netlify.com/integrations/frameworks/next-js/overview/#pnpm-support"
97
+ );
98
+ }
89
99
  };
90
100
  var writeTagsManifest = async (ctx) => {
91
101
  const manifest = await ctx.getPrerenderManifest();
@@ -4,11 +4,13 @@
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
+ import {
8
+ encodeBlobKey
9
+ } from "./chunk-TYCYFZ22.js";
7
10
 
8
11
  // src/build/plugin-context.ts
9
- import { Buffer } from "node:buffer";
10
12
  import { readFileSync } from "node:fs";
11
- import { mkdir, readFile, writeFile } from "node:fs/promises";
13
+ import { mkdir, readFile, writeFile, stat } from "node:fs/promises";
12
14
  import { dirname, join, resolve } from "node:path";
13
15
  import { fileURLToPath } from "node:url";
14
16
  var MODULE_DIR = fileURLToPath(new URL(".", import.meta.url));
@@ -124,13 +126,13 @@ var PluginContext = class {
124
126
  return JSON.parse(await readFile(join(this.publishDir, "routes-manifest.json"), "utf-8"));
125
127
  }
126
128
  /**
127
- * Write a cache entry to the blob upload directory using
128
- * base64 keys to avoid collisions with directories
129
+ * Write a cache entry to the blob upload directory.
129
130
  */
130
- async writeCacheEntry(key, value) {
131
- const path = join(this.blobDir, Buffer.from(key).toString("base64"));
131
+ async writeCacheEntry(route, value, filePath) {
132
+ const { mtime } = await stat(filePath);
133
+ const path = join(this.blobDir, await encodeBlobKey(route));
132
134
  const entry = JSON.stringify({
133
- lastModified: Date.now(),
135
+ lastModified: mtime.getTime(),
134
136
  value
135
137
  });
136
138
  await mkdir(dirname(path), { recursive: true });
@@ -8,13 +8,13 @@ import {
8
8
  copyNextDependencies,
9
9
  copyNextServerCode,
10
10
  writeTagsManifest
11
- } from "./chunk-6HBXWNZS.js";
11
+ } from "./chunk-COJ526HO.js";
12
12
  import {
13
13
  require_out
14
14
  } from "./chunk-MFN4GH7U.js";
15
15
  import {
16
16
  SERVER_HANDLER_NAME
17
- } from "./chunk-IZY5TPZE.js";
17
+ } from "./chunk-IZ2AVCVF.js";
18
18
  import {
19
19
  __toESM
20
20
  } from "./chunk-WELZ7LFO.js";
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-MFN4GH7U.js";
10
10
  import {
11
11
  EDGE_HANDLER_NAME
12
- } from "./chunk-IZY5TPZE.js";
12
+ } from "./chunk-IZ2AVCVF.js";
13
13
  import {
14
14
  __toESM
15
15
  } from "./chunk-WELZ7LFO.js";
@@ -17,7 +17,7 @@ import {
17
17
  // src/build/functions/edge.ts
18
18
  var import_fast_glob = __toESM(require_out(), 1);
19
19
  import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
20
- import { dirname, join } from "node:path";
20
+ import { dirname, join, relative } from "node:path";
21
21
  var writeEdgeManifest = async (ctx, manifest) => {
22
22
  await mkdir(ctx.edgeFunctionsDir, { recursive: true });
23
23
  await writeFile(join(ctx.edgeFunctionsDir, "manifest.json"), JSON.stringify(manifest, null, 2));
@@ -59,24 +59,39 @@ var writeHandlerFile = async (ctx, { matchers, name }) => {
59
59
  `
60
60
  );
61
61
  };
62
- var copyHandlerDependencies = async (ctx, { name, files }) => {
63
- const edgeRuntimePath = join(ctx.pluginDir, "edge-runtime");
62
+ var copyHandlerDependencies = async (ctx, { name, files, wasm }) => {
64
63
  const srcDir = join(ctx.standaloneDir, ".next");
65
- const shimPath = join(edgeRuntimePath, "shim/index.js");
66
- const shim = await readFile(shimPath, "utf8");
67
- const imports = `import './edge-runtime-webpack.js';`;
68
- const exports = `export default _ENTRIES["middleware_${name}"].default;`;
64
+ const destDir = join(ctx.edgeFunctionsDir, getHandlerName({ name }));
69
65
  await Promise.all(
70
66
  files.map(async (file) => {
71
- const destDir = join(ctx.edgeFunctionsDir, getHandlerName({ name }));
72
67
  if (file === `server/${name}.js`) {
68
+ const edgeRuntimeDir = join(ctx.pluginDir, "edge-runtime");
69
+ const shimPath = join(edgeRuntimeDir, "shim/index.js");
70
+ const shim = await readFile(shimPath, "utf8");
71
+ const importsDir = relative(dirname(join(srcDir, file)), join(srcDir, "server"));
72
+ const importsSrc = `${importsDir || "."}/edge-runtime-webpack.js`;
73
+ const imports = `import '${importsSrc}';`;
74
+ const exports = `export default _ENTRIES["middleware_${name}"].default;`;
75
+ const parts = [shim, imports];
76
+ if (wasm?.length) {
77
+ parts.push(
78
+ `import { decode as _base64Decode } from "../edge-runtime/vendor/deno.land/std@0.175.0/encoding/base64.ts";`
79
+ );
80
+ for (const wasmChunk of wasm ?? []) {
81
+ const data = await readFile(join(srcDir, wasmChunk.filePath));
82
+ parts.push(
83
+ `const ${wasmChunk.name} = _base64Decode(${JSON.stringify(
84
+ data.toString("base64")
85
+ )}).buffer`
86
+ );
87
+ }
88
+ }
73
89
  const entrypoint = await readFile(join(srcDir, file), "utf8");
74
- const parts = [shim, imports, entrypoint, exports];
75
90
  await mkdir(dirname(join(destDir, file)), { recursive: true });
76
- await writeFile(join(destDir, file), parts.join("\n;"));
77
- return;
91
+ await writeFile(join(destDir, file), [...parts, entrypoint, exports].join("\n;"));
92
+ } else {
93
+ await cp(join(srcDir, file), join(destDir, file));
78
94
  }
79
- await cp(join(srcDir, file), join(destDir, file));
80
95
  })
81
96
  );
82
97
  };
@@ -87,8 +102,8 @@ var createEdgeHandler = async (ctx, definition) => {
87
102
  var getHandlerName = ({ name }) => `${EDGE_HANDLER_NAME}-${name.replace(/\W/g, "-")}`;
88
103
  var buildHandlerDefinition = (ctx, { name, matchers, page }) => {
89
104
  const fun = getHandlerName({ name });
90
- const funName = name === "middleware" ? "Next.js Middleware Handler" : `Next.js Edge Handler: ${page}`;
91
- const cache = name === "middleware" ? void 0 : "manual";
105
+ const funName = name.endsWith("middleware") ? "Next.js Middleware Handler" : `Next.js Edge Handler: ${page}`;
106
+ const cache = name.endsWith("middleware") ? void 0 : "manual";
92
107
  const generator = `${ctx.pluginName}@${ctx.pluginVersion}`;
93
108
  return matchers.map((matcher) => ({
94
109
  function: fun,
@@ -0,0 +1,25 @@
1
+
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
+ return createRequire(import.meta.url);
5
+ })();
6
+
7
+
8
+ // src/shared/blobkey.ts
9
+ import { Buffer } from "node:buffer";
10
+ import { webcrypto as crypto } from "node:crypto";
11
+ var maxLength = 180;
12
+ async function encodeBlobKey(key) {
13
+ const buffer = Buffer.from(key);
14
+ const base64 = buffer.toString("base64url");
15
+ if (base64.length <= maxLength) {
16
+ return base64;
17
+ }
18
+ const digest = await crypto.subtle.digest("SHA-256", buffer);
19
+ const hash = Buffer.from(digest).toString("base64url");
20
+ return `${base64.slice(0, maxLength - hash.length - 1)}-${hash}`;
21
+ }
22
+
23
+ export {
24
+ encodeBlobKey
25
+ };
@@ -16,7 +16,7 @@ var import_fast_glob = __toESM(require_out(), 1);
16
16
  import { existsSync } from "node:fs";
17
17
  import { readFile } from "node:fs/promises";
18
18
  import { join } from "node:path";
19
- var routeToFilePath = (path) => path.replace(/^\//, "") || "index";
19
+ var routeToFilePath = (path) => path === "/" ? "/index" : path;
20
20
  var buildPagesCacheValue = async (path) => ({
21
21
  kind: "PAGE",
22
22
  html: await readFile(`${path}.html`, "utf-8"),
@@ -44,28 +44,37 @@ var copyPrerenderedContent = async (ctx) => {
44
44
  Object.entries(manifest.routes).map(async ([route, meta]) => {
45
45
  const key = routeToFilePath(route);
46
46
  let value;
47
+ let path;
47
48
  switch (true) {
48
49
  case (meta.dataRoute?.endsWith("/default.rsc") && !existsSync(join(ctx.publishDir, "server/app", `${key}.html`))):
49
50
  return;
50
51
  case meta.dataRoute?.endsWith(".json"):
51
- value = await buildPagesCacheValue(join(ctx.publishDir, "server/pages", key));
52
+ path = join(ctx.publishDir, "server/pages", key);
53
+ value = await buildPagesCacheValue(path);
52
54
  break;
53
55
  case meta.dataRoute?.endsWith(".rsc"):
54
- value = await buildAppCacheValue(join(ctx.publishDir, "server/app", key));
56
+ path = join(ctx.publishDir, "server/app", key);
57
+ value = await buildAppCacheValue(path);
55
58
  break;
56
59
  case meta.dataRoute === null:
57
- value = await buildRouteCacheValue(join(ctx.publishDir, "server/app", key));
60
+ path = join(ctx.publishDir, "server/app", key);
61
+ value = await buildRouteCacheValue(path);
58
62
  break;
59
63
  default:
60
64
  throw new Error(`Unrecognized content: ${route}`);
61
65
  }
62
- await ctx.writeCacheEntry(key, value);
66
+ await ctx.writeCacheEntry(
67
+ key,
68
+ value,
69
+ meta.dataRoute === null ? `${path}.body` : `${path}.html`
70
+ );
63
71
  })
64
72
  );
65
73
  if (existsSync(join(ctx.publishDir, `server/app/_not-found.html`))) {
66
- const key = "404";
67
- const value = await buildAppCacheValue(join(ctx.publishDir, "server/app/_not-found"));
68
- await ctx.writeCacheEntry(key, value);
74
+ const key = "/404";
75
+ const path = join(ctx.publishDir, "server/app/_not-found");
76
+ const value = await buildAppCacheValue(path);
77
+ await ctx.writeCacheEntry(key, value, `${path}.html`);
69
78
  }
70
79
  } catch (error) {
71
80
  ctx.failBuild("Failed assembling prerendered content for upload", error);
@@ -79,8 +88,9 @@ var copyFetchContent = async (ctx) => {
79
88
  });
80
89
  await Promise.all(
81
90
  paths.map(async (key) => {
82
- const value = await buildFetchCacheValue(join(ctx.publishDir, "cache/fetch-cache", key));
83
- await ctx.writeCacheEntry(key, value);
91
+ const path = join(ctx.publishDir, "cache/fetch-cache", key);
92
+ const value = await buildFetchCacheValue(path);
93
+ await ctx.writeCacheEntry(key, value, path);
84
94
  })
85
95
  );
86
96
  } catch (error) {
@@ -4,9 +4,9 @@
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
-
8
- // src/run/headers.ts
9
- import { Buffer as Buffer4 } from "node:buffer";
7
+ import {
8
+ encodeBlobKey
9
+ } from "./chunk-TYCYFZ22.js";
10
10
 
11
11
  // node_modules/@netlify/blobs/dist/main.js
12
12
  import { Buffer } from "buffer";
@@ -520,15 +520,12 @@ var setVaryHeaders = (headers, request, { basePath, i18n }) => {
520
520
  }
521
521
  headers.set(`netlify-vary`, generateNetlifyVaryValues(netlifyVaryValues));
522
522
  };
523
- function encodeBlobKey(key) {
524
- return Buffer4.from(key.replace(/^\//, "")).toString("base64");
525
- }
526
523
  var adjustDateHeader = async (headers, request) => {
527
524
  if (headers.get("x-nextjs-cache") !== "HIT") {
528
525
  return;
529
526
  }
530
527
  const path = new URL(request.url).pathname;
531
- const key = encodeBlobKey(path);
528
+ const key = await encodeBlobKey(path);
532
529
  const blobStore = getDeployStore();
533
530
  const { lastModified } = await blobStore.get(key, { type: "json" }) ?? {};
534
531
  if (!lastModified) {
package/dist/index.js CHANGED
@@ -7,20 +7,20 @@
7
7
  import {
8
8
  copyFetchContent,
9
9
  copyPrerenderedContent
10
- } from "./esm-chunks/chunk-DZM5AUXX.js";
10
+ } from "./esm-chunks/chunk-UDWVXRI2.js";
11
11
  import {
12
12
  copyStaticAssets,
13
13
  copyStaticContent,
14
14
  publishStaticDir,
15
15
  unpublishStaticDir
16
- } from "./esm-chunks/chunk-KMPIVUVT.js";
16
+ } from "./esm-chunks/chunk-AMJYZZKR.js";
17
17
  import {
18
18
  createEdgeHandlers
19
- } from "./esm-chunks/chunk-XC7T747I.js";
19
+ } from "./esm-chunks/chunk-PCJY2SS7.js";
20
20
  import {
21
21
  createServerHandler
22
- } from "./esm-chunks/chunk-X4Q4MYBW.js";
23
- import "./esm-chunks/chunk-6HBXWNZS.js";
22
+ } from "./esm-chunks/chunk-KDRFBPAR.js";
23
+ import "./esm-chunks/chunk-COJ526HO.js";
24
24
  import "./esm-chunks/chunk-MFN4GH7U.js";
25
25
  import {
26
26
  restoreBuildCache,
@@ -31,7 +31,8 @@ import {
31
31
  } from "./esm-chunks/chunk-EPSI5TTB.js";
32
32
  import {
33
33
  PluginContext
34
- } from "./esm-chunks/chunk-IZY5TPZE.js";
34
+ } from "./esm-chunks/chunk-IZ2AVCVF.js";
35
+ import "./esm-chunks/chunk-TYCYFZ22.js";
35
36
  import "./esm-chunks/chunk-WELZ7LFO.js";
36
37
 
37
38
  // src/index.ts
@@ -45,7 +46,9 @@ var onPreBuild = async (options) => {
45
46
  var onBuild = async (options) => {
46
47
  const ctx = new PluginContext(options);
47
48
  if (!existsSync(ctx.publishDir)) {
48
- ctx.failBuild("Publish directory not found, please check your netlify.toml");
49
+ ctx.failBuild(
50
+ `Publish directory not found under: ${ctx.publishDir}, please check your netlify.toml`
51
+ );
49
52
  }
50
53
  await setImageConfig(ctx);
51
54
  if (!options.constants.IS_LOCAL) {
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
8
11
  var __commonJS = (cb, mod) => function __require() {
9
12
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
13
  };
@@ -245,6 +248,31 @@ var require_main = __commonJS({
245
248
  }
246
249
  });
247
250
 
251
+ // src/shared/blobkey.ts
252
+ var blobkey_exports = {};
253
+ __export(blobkey_exports, {
254
+ encodeBlobKey: () => encodeBlobKey
255
+ });
256
+ async function encodeBlobKey(key) {
257
+ const buffer = import_node_buffer.Buffer.from(key);
258
+ const base64 = buffer.toString("base64url");
259
+ if (base64.length <= maxLength) {
260
+ return base64;
261
+ }
262
+ const digest = await import_node_crypto.webcrypto.subtle.digest("SHA-256", buffer);
263
+ const hash = import_node_buffer.Buffer.from(digest).toString("base64url");
264
+ return `${base64.slice(0, maxLength - hash.length - 1)}-${hash}`;
265
+ }
266
+ var import_node_buffer, import_node_crypto, maxLength;
267
+ var init_blobkey = __esm({
268
+ "src/shared/blobkey.ts"() {
269
+ "use strict";
270
+ import_node_buffer = require("node:buffer");
271
+ import_node_crypto = require("node:crypto");
272
+ maxLength = 180;
273
+ }
274
+ });
275
+
248
276
  // src/run/handlers/cache.cts
249
277
  var cache_exports = {};
250
278
  __export(cache_exports, {
@@ -252,7 +280,7 @@ __export(cache_exports, {
252
280
  default: () => cache_default
253
281
  });
254
282
  module.exports = __toCommonJS(cache_exports);
255
- var import_node_buffer = require("node:buffer");
283
+ var import_node_buffer2 = require("node:buffer");
256
284
  var import_node_fs = require("node:fs");
257
285
  var import_posix = require("node:path/posix");
258
286
 
@@ -730,9 +758,6 @@ var prerenderManifest = JSON.parse(
730
758
  function toRoute(cacheKey) {
731
759
  return cacheKey.replace(/\/$/, "").replace(/\/index$/, "") || "/";
732
760
  }
733
- function encodeBlobKey(key) {
734
- return import_node_buffer.Buffer.from(key.replace(/^\//, "")).toString("base64");
735
- }
736
761
  var fetchBeforeNextPatchedIt = globalThis.fetch;
737
762
  var NetlifyCacheHandler = class {
738
763
  options;
@@ -743,10 +768,14 @@ var NetlifyCacheHandler = class {
743
768
  this.revalidatedTags = options.revalidatedTags;
744
769
  this.blobStore = getDeployStore({ fetch: fetchBeforeNextPatchedIt });
745
770
  }
771
+ async encodeBlobKey(key) {
772
+ const { encodeBlobKey: encodeBlobKey2 } = await Promise.resolve().then(() => (init_blobkey(), blobkey_exports));
773
+ return await encodeBlobKey2(key);
774
+ }
746
775
  async get(...args) {
747
776
  const [key, ctx = {}] = args;
748
777
  console.debug(`[NetlifyCacheHandler.get]: ${key}`);
749
- const blob = await this.blobStore.get(encodeBlobKey(key), {
778
+ const blob = await this.blobStore.get(await this.encodeBlobKey(key), {
750
779
  type: "json"
751
780
  });
752
781
  if (!blob) {
@@ -772,7 +801,7 @@ var NetlifyCacheHandler = class {
772
801
  return {
773
802
  lastModified: blob.lastModified,
774
803
  value: {
775
- body: import_node_buffer.Buffer.from(blob.value.body),
804
+ body: import_node_buffer2.Buffer.from(blob.value.body),
776
805
  kind: blob.value.kind,
777
806
  status: blob.value.status,
778
807
  headers: blob.value.headers
@@ -790,7 +819,7 @@ var NetlifyCacheHandler = class {
790
819
  async set(...args) {
791
820
  const [key, data] = args;
792
821
  console.debug(`[NetlifyCacheHandler.set]: ${key}`);
793
- await this.blobStore.setJSON(encodeBlobKey(key), {
822
+ await this.blobStore.setJSON(await this.encodeBlobKey(key), {
794
823
  lastModified: Date.now(),
795
824
  value: data
796
825
  });
@@ -802,7 +831,7 @@ var NetlifyCacheHandler = class {
802
831
  revalidatedAt: Date.now()
803
832
  };
804
833
  try {
805
- await this.blobStore.setJSON(encodeBlobKey(tag), data);
834
+ await this.blobStore.setJSON(await this.encodeBlobKey(tag), data);
806
835
  } catch (error) {
807
836
  console.warn(`Failed to update tag manifest for ${tag}`, error);
808
837
  }
@@ -818,7 +847,7 @@ var NetlifyCacheHandler = class {
818
847
  const cacheTags = [...tags, ...softTags];
819
848
  const allManifests = await Promise.all(
820
849
  cacheTags.map(async (tag) => {
821
- const res = await this.blobStore.get(encodeBlobKey(tag), { type: "json" }).then((value) => ({ [tag]: value })).catch(console.error);
850
+ const res = await this.blobStore.get(await this.encodeBlobKey(tag), { type: "json" }).then((value) => ({ [tag]: value })).catch(console.error);
822
851
  return res || { [tag]: null };
823
852
  })
824
853
  );
@@ -17,7 +17,8 @@ import {
17
17
  setCacheControlHeaders,
18
18
  setCacheTagsHeaders,
19
19
  setVaryHeaders
20
- } from "../../esm-chunks/chunk-YG3G7B2X.js";
20
+ } from "../../esm-chunks/chunk-W5TLWQMF.js";
21
+ import "../../esm-chunks/chunk-TYCYFZ22.js";
21
22
  import {
22
23
  nextResponseProxy
23
24
  } from "../../esm-chunks/chunk-NE4HYI2D.js";
@@ -10,7 +10,8 @@ import {
10
10
  setCacheControlHeaders,
11
11
  setCacheTagsHeaders,
12
12
  setVaryHeaders
13
- } from "../esm-chunks/chunk-YG3G7B2X.js";
13
+ } from "../esm-chunks/chunk-W5TLWQMF.js";
14
+ import "../esm-chunks/chunk-TYCYFZ22.js";
14
15
  import "../esm-chunks/chunk-WELZ7LFO.js";
15
16
  export {
16
17
  adjustDateHeader,
package/dist/run/next.cjs CHANGED
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
8
11
  var __commonJS = (cb, mod) => function __require() {
9
12
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
13
  };
@@ -549,6 +552,31 @@ var require_lib = __commonJS({
549
552
  }
550
553
  });
551
554
 
555
+ // src/shared/blobkey.ts
556
+ var blobkey_exports = {};
557
+ __export(blobkey_exports, {
558
+ encodeBlobKey: () => encodeBlobKey
559
+ });
560
+ async function encodeBlobKey(key) {
561
+ const buffer = import_node_buffer.Buffer.from(key);
562
+ const base64 = buffer.toString("base64url");
563
+ if (base64.length <= maxLength) {
564
+ return base64;
565
+ }
566
+ const digest = await import_node_crypto.webcrypto.subtle.digest("SHA-256", buffer);
567
+ const hash = import_node_buffer.Buffer.from(digest).toString("base64url");
568
+ return `${base64.slice(0, maxLength - hash.length - 1)}-${hash}`;
569
+ }
570
+ var import_node_buffer, import_node_crypto, maxLength;
571
+ var init_blobkey = __esm({
572
+ "src/shared/blobkey.ts"() {
573
+ "use strict";
574
+ import_node_buffer = require("node:buffer");
575
+ import_node_crypto = require("node:crypto");
576
+ maxLength = 180;
577
+ }
578
+ });
579
+
552
580
  // src/run/next.cts
553
581
  var next_exports = {};
554
582
  __export(next_exports, {
@@ -556,7 +584,6 @@ __export(next_exports, {
556
584
  });
557
585
  module.exports = __toCommonJS(next_exports);
558
586
  var import_promises = __toESM(require("fs/promises"));
559
- var import_node_buffer = require("node:buffer");
560
587
  var import_path = require("path");
561
588
 
562
589
  // node_modules/@netlify/blobs/dist/main.js
@@ -1029,6 +1056,7 @@ var import_fs_monkey = __toESM(require_lib());
1029
1056
  async function getMockedRequestHandlers(...args) {
1030
1057
  const store = getDeployStore();
1031
1058
  const ofs = { ...import_promises.default };
1059
+ const { encodeBlobKey: encodeBlobKey2 } = await Promise.resolve().then(() => (init_blobkey(), blobkey_exports));
1032
1060
  async function readFileFallbackBlobStore(...fsargs) {
1033
1061
  const [path, options] = fsargs;
1034
1062
  try {
@@ -1036,8 +1064,7 @@ async function getMockedRequestHandlers(...args) {
1036
1064
  } catch (error) {
1037
1065
  if (typeof path === "string" && path.endsWith(".html")) {
1038
1066
  const relPath = (0, import_path.relative)((0, import_path.resolve)(".next/server/pages"), path);
1039
- const blobKey = import_node_buffer.Buffer.from(relPath).toString("base64");
1040
- const file = await store.get(blobKey);
1067
+ const file = await store.get(await encodeBlobKey2(relPath));
1041
1068
  if (file !== null) {
1042
1069
  return file;
1043
1070
  }
@@ -0,0 +1,13 @@
1
+
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
+ return createRequire(import.meta.url);
5
+ })();
6
+
7
+ import {
8
+ encodeBlobKey
9
+ } from "../esm-chunks/chunk-TYCYFZ22.js";
10
+ import "../esm-chunks/chunk-WELZ7LFO.js";
11
+ export {
12
+ encodeBlobKey
13
+ };
@@ -2,13 +2,7 @@
2
2
  "imports": {
3
3
  "https://ghuc.cc/worker-tools/resolvable-promise/index.ts": "./raw.githubusercontent.com/worker-tools/resolvable-promise/master/index.ts",
4
4
  "https://deno.land/": "./deno.land/",
5
- "https://esm.sh/": "./esm.sh/",
6
5
  "https://raw.githubusercontent.com/": "./raw.githubusercontent.com/",
7
6
  "https://v1-7-0--edge-utils.netlify.app/": "./v1-7-0--edge-utils.netlify.app/"
8
- },
9
- "scopes": {
10
- "./esm.sh/": {
11
- "/v91/next@12.2.5/deno/dist/compiled/cookie.js": "./esm.sh/v91/next@12.2.5/deno/dist/compiled/cookie.js"
12
- }
13
7
  }
14
8
  }
@@ -14,7 +14,4 @@ import 'https://deno.land/std@0.175.0/path/mod.ts'
14
14
  import 'https://deno.land/x/path_to_regexp@v6.2.1/index.ts'
15
15
  import 'https://deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts'
16
16
 
17
- import 'https://esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js'
18
- import 'https://esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/response.js'
19
-
20
17
  import 'https://v1-7-0--edge-utils.netlify.app/logger/mod.ts'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/plugin-nextjs",
3
- "version": "5.0.0-beta.4",
3
+ "version": "5.0.0-beta.6",
4
4
  "description": "Run Next.js seamlessly on Netlify",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -1,13 +0,0 @@
1
- /* esm.sh - esbuild bundle(next@12.2.5/dist/compiled/cookie) deno production */
2
- var A=Object.create;var S=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var z=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),D=(i,e)=>{for(var a in e)S(i,a,{get:e[a],enumerable:!0})},y=(i,e,a,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of N(e))!q.call(i,s)&&s!==a&&S(i,s,{get:()=>e[s],enumerable:!(l=U(e,s))||l.enumerable});return i},u=(i,e,a)=>(y(i,e,"default"),a&&y(a,e,"default")),g=(i,e,a)=>(a=i!=null?A(O(i)):{},y(e||!i||!i.__esModule?S(a,"default",{value:i,enumerable:!0}):a,i));var _=z((F,T)=>{(()=>{"use strict";typeof __nccwpck_require__<"u"&&(__nccwpck_require__.ab="/_virtual/esm.sh/v91/next@12.2.5/deno/dist/compiled/");var i={};(()=>{var e=i;e.parse=b,e.serialize=k;var a=decodeURIComponent,l=encodeURIComponent,s=/; */,w=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function b(n,d){if(typeof n!="string")throw new TypeError("argument str must be a string");for(var f={},r=d||{},m=n.split(s),c=r.decode||a,t=0;t<m.length;t++){var o=m[t],v=o.indexOf("=");if(!(v<0)){var x=o.substr(0,v).trim(),h=o.substr(++v,o.length).trim();h[0]=='"'&&(h=h.slice(1,-1)),f[x]==null&&(f[x]=C(h,c))}}return f}function k(n,d,f){var r=f||{},m=r.encode||l;if(typeof m!="function")throw new TypeError("option encode is invalid");if(!w.test(n))throw new TypeError("argument name is invalid");var c=m(d);if(c&&!w.test(c))throw new TypeError("argument val is invalid");var t=n+"="+c;if(r.maxAge!=null){var o=r.maxAge-0;if(isNaN(o)||!isFinite(o))throw new TypeError("option maxAge is invalid");t+="; Max-Age="+Math.floor(o)}if(r.domain){if(!w.test(r.domain))throw new TypeError("option domain is invalid");t+="; Domain="+r.domain}if(r.path){if(!w.test(r.path))throw new TypeError("option path is invalid");t+="; Path="+r.path}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");t+="; Expires="+r.expires.toUTCString()}if(r.httpOnly&&(t+="; HttpOnly"),r.secure&&(t+="; Secure"),r.sameSite){var v=typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite;switch(v){case!0:t+="; SameSite=Strict";break;case"lax":t+="; SameSite=Lax";break;case"strict":t+="; SameSite=Strict";break;case"none":t+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return t}function C(n,d){try{return d(n)}catch{return n}}})(),T.exports=i})()});var p={};D(p,{default:()=>M});var I=g(_());u(p,g(_()));var{default:E,...L}=I,M=E!==void 0?E:L;export{M as default};
3
- /*! Bundled license information:
4
-
5
- next/dist/compiled/cookie/index.js:
6
- (*!
7
- * cookie
8
- * Copyright(c) 2012-2014 Roman Shtylman
9
- * Copyright(c) 2015 Douglas Christopher Wilson
10
- * MIT Licensed
11
- *)
12
- */
13
- //# sourceMappingURL=cookie.js.map
@@ -1,12 +0,0 @@
1
- /* esm.sh - esbuild bundle(next@12.2.5/dist/server/web/spec-extension/request) deno production */
2
- import * as __0$ from "/v91/next@12.2.5/deno/dist/compiled/cookie.js";
3
- var require=n=>{const e=m=>typeof m.default<"u"?m.default:m,c=m=>Object.assign({},m);switch(n){case"next/dist/compiled/cookie":return e(__0$);default:throw new Error("module \""+n+"\" not found");}};
4
- var xe=Object.create;var w=Object.defineProperty;var _e=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var ye=Object.getPrototypeOf,Le=Object.prototype.hasOwnProperty;var we=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var l=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),je=(t,e)=>{for(var r in e)w(t,r,{get:e[r],enumerable:!0})},L=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of be(e))!Le.call(t,i)&&i!==r&&w(t,i,{get:()=>e[i],enumerable:!(s=_e(e,i))||s.enumerable});return t},c=(t,e,r)=>(L(t,e,"default"),r&&L(r,e,"default")),G=(t,e,r)=>(r=t!=null?xe(ye(t)):{},L(e||!t||!t.__esModule?w(r,"default",{value:t,enumerable:!0}):r,t));var Q=l(j=>{"use strict";Object.defineProperty(j,"__esModule",{value:!0});j.detectDomainLocale=qe;function qe(t,e,r){let s;if(t){r&&(r=r.toLowerCase());for(let o of t){var i,n;let u=(i=o.domain)==null?void 0:i.split(":")[0].toLowerCase();if(e===u||r===o.defaultLocale.toLowerCase()||(n=o.locales)!=null&&n.some(h=>h.toLowerCase()===r)){s=o;break}}}return s}});var V=l(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});q.removeTrailingSlash=Ce;function Ce(t){return t.replace(/\/$/,"")||"/"}});var v=l(C=>{"use strict";Object.defineProperty(C,"__esModule",{value:!0});C.parsePath=Ie;function Ie(t){let e=t.indexOf("#"),r=t.indexOf("?"),s=r>-1&&(e<0||r<e);return s||e>-1?{pathname:t.substring(0,s?r:e),query:s?t.substring(r,e>-1?e:void 0):"",hash:e>-1?t.slice(e):""}:{pathname:t,query:"",hash:""}}});var S=l(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0});I.addPathPrefix=Ne;var Se=v();function Ne(t,e){if(!t.startsWith("/")||!e)return t;let{pathname:r,query:s,hash:i}=Se.parsePath(t);return`${e}${r}${s}${i}`}});var X=l(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.addPathSuffix=$e;var Re=v();function $e(t,e){if(!t.startsWith("/")||!e)return t;let{pathname:r,query:s,hash:i}=Re.parsePath(t);return`${r}${e}${s}${i}`}});var x=l(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.pathHasPrefix=ke;var Oe=v();function ke(t,e){if(typeof t!="string")return!1;let{pathname:r}=Oe.parsePath(t);return r===e||r.startsWith(e+"/")}});var K=l($=>{"use strict";Object.defineProperty($,"__esModule",{value:!0});$.addLocale=He;var Ae=S(),B=x();function He(t,e,r,s){return e&&e!==r&&(s||!B.pathHasPrefix(t.toLowerCase(),`/${e.toLowerCase()}`)&&!B.pathHasPrefix(t.toLowerCase(),"/api"))?Ae.addPathPrefix(t,`/${e}`):t}});var ee=l(O=>{"use strict";Object.defineProperty(O,"__esModule",{value:!0});O.formatNextPathnameInfo=Ee;var Ue=V(),Y=S(),Z=X(),Me=K();function Ee(t){let e=Me.addLocale(t.pathname,t.locale,t.buildId?void 0:t.defaultLocale,t.ignorePrefix);return t.buildId&&(e=Z.addPathSuffix(Y.addPathPrefix(e,`/_next/data/${t.buildId}`),t.pathname==="/"?"index.json":".json")),e=Y.addPathPrefix(e,t.basePath),t.trailingSlash?!t.buildId&&!e.endsWith("/")?Z.addPathSuffix(e,"/"):e:Ue.removeTrailingSlash(e)}});var te=l(k=>{"use strict";Object.defineProperty(k,"__esModule",{value:!0});k.getHostname=Te;function Te(t,e){var r;return(r=!Array.isArray(e?.host)&&e?.host||t.hostname)==null?void 0:r.split(":")[0].toLowerCase()}});var re=l(A=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0});A.normalizeLocalePath=ze;function ze(t,e){let r,s=t.split("/");return(e||[]).some(i=>s[1]&&s[1].toLowerCase()===i.toLowerCase()?(r=i,s.splice(1,1),t=s.join("/")||"/",!0):!1),{pathname:t,detectedLocale:r}}});var se=l(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.removePathPrefix=De;var We=x();function De(t,e){if(We.pathHasPrefix(t,e)){let r=t.slice(e.length);return r.startsWith("/")?r:`/${r}`}return t}});var ae=l(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.getNextPathnameInfo=Qe;var Je=re(),Fe=se(),Ge=x();function Qe(t,e){var r;let{basePath:s,i18n:i,trailingSlash:n}=(r=e.nextConfig)!=null?r:{},o={pathname:t,trailingSlash:t!=="/"?t.endsWith("/"):n};if(s&&Ge.pathHasPrefix(o.pathname,s)&&(o.pathname=Fe.removePathPrefix(o.pathname,s),o.basePath=s),e.parseData===!0&&o.pathname.startsWith("/_next/data/")&&o.pathname.endsWith(".json")){let u=o.pathname.replace(/^\/_next\/data\//,"").replace(/\.json$/,"").split("/"),h=u[0];o.pathname=u[1]!=="index"?`/${u.slice(1).join("/")}`:"/",o.buildId=h}if(i){let u=Je.normalizeLocalePath(o.pathname,i.locales);o.locale=u?.detectedLocale,o.pathname=u?.pathname||o.pathname}return o}});var ne=l(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});var Ve=Q(),Xe=ee(),Be=te(),Ke=ae(),a=Symbol("NextURLInternal"),M=class t{constructor(e,r,s){let i,n;typeof r=="object"&&"pathname"in r||typeof r=="string"?(i=r,n=s||{}):n=s||r||{},this[a]={url:oe(e,i??n.base),options:n,basePath:""},this.analyzeUrl()}analyzeUrl(){var e,r,s,i,n;let o=Ke.getNextPathnameInfo(this[a].url.pathname,{nextConfig:this[a].options.nextConfig,parseData:!0});this[a].domainLocale=Ve.detectDomainLocale((e=this[a].options.nextConfig)==null||(r=e.i18n)==null?void 0:r.domains,Be.getHostname(this[a].url,this[a].options.headers));let u=((s=this[a].domainLocale)==null?void 0:s.defaultLocale)||((i=this[a].options.nextConfig)==null||(n=i.i18n)==null?void 0:n.defaultLocale);this[a].url.pathname=o.pathname,this[a].defaultLocale=u;var h;this[a].basePath=(h=o.basePath)!=null?h:"",this[a].buildId=o.buildId;var P;this[a].locale=(P=o.locale)!=null?P:u,this[a].trailingSlash=o.trailingSlash}formatPathname(){return Xe.formatNextPathnameInfo({basePath:this[a].basePath,buildId:this[a].buildId,defaultLocale:this[a].options.forceLocale?void 0:this[a].defaultLocale,locale:this[a].locale,pathname:this[a].url.pathname,trailingSlash:this[a].trailingSlash})}get buildId(){return this[a].buildId}set buildId(e){this[a].buildId=e}get locale(){var e;return(e=this[a].locale)!=null?e:""}set locale(e){var r,s;if(!this[a].locale||!(!((r=this[a].options.nextConfig)==null||(s=r.i18n)==null)&&s.locales.includes(e)))throw new TypeError(`The NextURL configuration includes no locale "${e}"`);this[a].locale=e}get defaultLocale(){return this[a].defaultLocale}get domainLocale(){return this[a].domainLocale}get searchParams(){return this[a].url.searchParams}get host(){return this[a].url.host}set host(e){this[a].url.host=e}get hostname(){return this[a].url.hostname}set hostname(e){this[a].url.hostname=e}get port(){return this[a].url.port}set port(e){this[a].url.port=e}get protocol(){return this[a].url.protocol}set protocol(e){this[a].url.protocol=e}get href(){let e=this.formatPathname();return`${this.protocol}//${this.host}${e}${this[a].url.search}`}set href(e){this[a].url=oe(e),this.analyzeUrl()}get origin(){return this[a].url.origin}get pathname(){return this[a].url.pathname}set pathname(e){this[a].url.pathname=e}get hash(){return this[a].url.hash}set hash(e){this[a].url.hash=e}get search(){return this[a].url.search}set search(e){this[a].url.search=e}get password(){return this[a].url.password}set password(e){this[a].url.password=e}get username(){return this[a].url.username}set username(e){this[a].url.username=e}get basePath(){return this[a].basePath}set basePath(e){this[a].basePath=e.startsWith("/")?e:`/${e}`}toString(){return this.href}toJSON(){return this.href}[Symbol.for("edge-runtime.inspect.custom")](){return{href:this.href,origin:this.origin,protocol:this.protocol,username:this.username,password:this.password,host:this.host,hostname:this.hostname,port:this.port,pathname:this.pathname,search:this.search,searchParams:this.searchParams,hash:this.hash}}clone(){return new t(String(this),this[a].options)}};E.NextURL=M;var ie=/(?!^https?:\/\/)(127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}|::1|localhost)/;function oe(t,e){return new URL(String(t).replace(ie,"localhost"),e&&String(e).replace(ie,"localhost"))}});var le=l(p=>{"use strict";Object.defineProperty(p,"__esModule",{value:!0});p.fromNodeHeaders=Ye;p.toNodeHeaders=Ze;p.splitCookiesString=ue;p.validateURL=et;function Ye(t){let e=new Headers;for(let[r,s]of Object.entries(t)){let i=Array.isArray(s)?s:[s];for(let n of i)n!==void 0&&e.append(r,n)}return e}function Ze(t){let e={};if(t)for(let[r,s]of t.entries())e[r]=s,r.toLowerCase()==="set-cookie"&&(e[r]=ue(s));return e}function ue(t){var e=[],r=0,s,i,n,o,u;function h(){for(;r<t.length&&/\s/.test(t.charAt(r));)r+=1;return r<t.length}function P(){return i=t.charAt(r),i!=="="&&i!==";"&&i!==","}for(;r<t.length;){for(s=r,u=!1;h();)if(i=t.charAt(r),i===","){for(n=r,r+=1,h(),o=r;r<t.length&&P();)r+=1;r<t.length&&t.charAt(r)==="="?(u=!0,r=o,e.push(t.substring(s,n)),s=r):r=n+1}else r+=1;(!u||r>=t.length)&&e.push(t.substring(s,t.length))}return e}function et(t){try{return String(new URL(String(t)))}catch(e){throw new Error("URLs is malformed. Please use only absolute URLs - https://nextjs.org/docs/messages/middleware-relative-urls",{cause:e})}}});var he=l(m=>{"use strict";Object.defineProperty(m,"__esModule",{value:!0});var T=class extends Error{constructor({page:e}){super(`The middleware "${e}" accepts an async API directly with the form:
5
-
6
- export function middleware(request, event) {
7
- return NextResponse.redirect('/new-location')
8
- }
9
-
10
- Read more: https://nextjs.org/docs/messages/middleware-new-signature
11
- `)}};m.PageSignatureError=T;var z=class extends Error{constructor(){super("The request.page has been deprecated in favour of `URLPattern`.\n Read more: https://nextjs.org/docs/messages/middleware-request-page\n ")}};m.RemovedPageError=z;var W=class extends Error{constructor(){super("The request.ua has been removed in favour of `userAgent` function.\n Read more: https://nextjs.org/docs/messages/middleware-parse-user-agent\n ")}};m.RemovedUAError=W});var pe=l(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});var _=tt(we("next/dist/compiled/cookie"));function tt(t){return t&&t.__esModule?t:{default:t}}var rt=t=>(t=Object.assign({},t),t.maxAge&&(t.expires=new Date(Date.now()+t.maxAge*1e3)),t.path==null&&(t.path="/"),t),st=t=>typeof t=="object"?`j:${JSON.stringify(t)}`:String(t),de=(t,e={})=>_.default.serialize(t,"",{expires:new Date(0),path:"/",...e}),ce=t=>{let e=t.headers.get("set-cookie");return e!=null?e.split(", "):[]},fe=t=>t.join(", "),b=class extends Map{constructor(e){let r=typeof e=="string"?_.default.parse(e):{};super(Object.entries(r))}set(e,r,s={}){return super.set(e,_.default.serialize(e,st(r),rt(s)))}[Symbol.for("edge-runtime.inspect.custom")](){return Object.fromEntries(this.entries())}};y.Cookies=b;var D=class extends b{constructor(e){super(e.headers.get("cookie")),this.response=e}get=(...e)=>this.getWithOptions(...e).value;getWithOptions=(...e)=>{let r=super.get(...e);if(typeof r!="string")return{value:r,options:{}};let{[e[0]]:s,...i}=_.default.parse(r);return{value:s,options:i}};set=(...e)=>{let r=super.has(e[0]);super.set(...e);let s=super.get(e[0]);if(typeof s!="string")throw new Error(`Invariant: failed to generate cookie for ${JSON.stringify(e)}`);if(r){let i=fe(ce(this.response).filter(n=>!n.startsWith(`${e[0]}=`)));i?this.response.headers.set("set-cookie",[s,i].join(", ")):this.response.headers.set("set-cookie",s)}else this.response.headers.append("set-cookie",s);return this};delete=(e,r={})=>{let s=super.delete(e);if(s){let i=fe(ce(this.response).filter(o=>!o.startsWith(`${e}=`))),n=de(e,r);this.response.headers.set("set-cookie",[n,i].join(", "))}return s};clear=(e={})=>{let r=Array.from(super.keys()).map(s=>de(s,e)).join(", ");return r&&this.response.headers.set("set-cookie",r),super.clear()}};y.NextCookies=D});var F=l(g=>{"use strict";Object.defineProperty(g,"__esModule",{value:!0});g.INTERNALS=void 0;var at=ne(),me=le(),ge=he(),it=pe(),f=Symbol("internal request");g.INTERNALS=f;var J=class extends Request{constructor(e,r={}){let s=typeof e!="string"&&"url"in e?e.url:String(e);me.validateURL(s),super(s,r),this[f]={cookies:new it.NextCookies(this),geo:r.geo||{},ip:r.ip,url:new at.NextURL(s,{headers:me.toNodeHeaders(this.headers),nextConfig:r.nextConfig})}}[Symbol.for("edge-runtime.inspect.custom")](){return{cookies:this.cookies,geo:this.geo,ip:this.ip,nextUrl:this.nextUrl,url:this.url,bodyUsed:this.bodyUsed,cache:this.cache,credentials:this.credentials,destination:this.destination,headers:Object.fromEntries(this.headers),integrity:this.integrity,keepalive:this.keepalive,method:this.method,mode:this.mode,redirect:this.redirect,referrer:this.referrer,referrerPolicy:this.referrerPolicy,signal:this.signal}}get cookies(){return this[f].cookies}get geo(){return this[f].geo}get ip(){return this[f].ip}get nextUrl(){return this[f].url}get page(){throw new ge.RemovedPageError}get ua(){throw new ge.RemovedUAError}get url(){return this[f].url.toString()}};g.NextRequest=J});var d={};je(d,{INTERNALS:()=>nt,NextRequest:()=>ut,__esModule:()=>ot,default:()=>ht});var ve=G(F());c(d,G(F()));var{__esModule:ot,INTERNALS:nt,NextRequest:ut}=ve,{default:Pe,...lt}=ve,ht=Pe!==void 0?Pe:lt;export{nt as INTERNALS,ut as NextRequest,ot as __esModule,ht as default};
12
- //# sourceMappingURL=request.js.map
@@ -1,5 +0,0 @@
1
- /* esm.sh - esbuild bundle(next@12.2.5/dist/server/web/spec-extension/response) deno production */
2
- import * as __0$ from "/v91/next@12.2.5/deno/dist/compiled/cookie.js";
3
- var require=n=>{const e=m=>typeof m.default<"u"?m.default:m,c=m=>Object.assign({},m);switch(n){case"next/dist/compiled/cookie":return e(__0$);default:throw new Error("module \""+n+"\" not found");}};
4
- var fe=Object.create;var b=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var Pe=Object.getPrototypeOf,ve=Object.prototype.hasOwnProperty;var ge=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var u=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),xe=(t,e)=>{for(var r in e)b(t,r,{get:e[r],enumerable:!0})},_=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of me(e))!ve.call(t,o)&&o!==r&&b(t,o,{get:()=>e[o],enumerable:!(s=pe(e,o))||s.enumerable});return t},c=(t,e,r)=>(_(t,e,"default"),r&&_(r,e,"default")),D=(t,e,r)=>(r=t!=null?fe(Pe(t)):{},_(e||!t||!t.__esModule?b(r,"default",{value:t,enumerable:!0}):r,t));var T=u(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.detectDomainLocale=_e;function _e(t,e,r){let s;if(t){r&&(r=r.toLowerCase());for(let n of t){var o,i;let l=(o=n.domain)==null?void 0:o.split(":")[0].toLowerCase();if(e===l||r===n.defaultLocale.toLowerCase()||(i=n.locales)!=null&&i.some(h=>h.toLowerCase()===r)){s=n;break}}}return s}});var J=u(w=>{"use strict";Object.defineProperty(w,"__esModule",{value:!0});w.removeTrailingSlash=be;function be(t){return t.replace(/\/$/,"")||"/"}});var m=u(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.parsePath=ye;function ye(t){let e=t.indexOf("#"),r=t.indexOf("?"),s=r>-1&&(e<0||r<e);return s||e>-1?{pathname:t.substring(0,s?r:e),query:s?t.substring(r,e>-1?e:void 0):"",hash:e>-1?t.slice(e):""}:{pathname:t,query:"",hash:""}}});var C=u(j=>{"use strict";Object.defineProperty(j,"__esModule",{value:!0});j.addPathPrefix=Le;var we=m();function Le(t,e){if(!t.startsWith("/")||!e)return t;let{pathname:r,query:s,hash:o}=we.parsePath(t);return`${e}${r}${s}${o}`}});var F=u(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0});I.addPathSuffix=Ce;var je=m();function Ce(t,e){if(!t.startsWith("/")||!e)return t;let{pathname:r,query:s,hash:o}=je.parsePath(t);return`${r}${e}${s}${o}`}});var P=u(S=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0});S.pathHasPrefix=Se;var Ie=m();function Se(t,e){if(typeof t!="string")return!1;let{pathname:r}=Ie.parsePath(t);return r===e||r.startsWith(e+"/")}});var Q=u(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});q.addLocale=He;var qe=C(),G=P();function He(t,e,r,s){return e&&e!==r&&(s||!G.pathHasPrefix(t.toLowerCase(),`/${e.toLowerCase()}`)&&!G.pathHasPrefix(t.toLowerCase(),"/api"))?qe.addPathPrefix(t,`/${e}`):t}});var B=u(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.formatNextPathnameInfo=Ne;var Oe=J(),V=C(),X=F(),$e=Q();function Ne(t){let e=$e.addLocale(t.pathname,t.locale,t.buildId?void 0:t.defaultLocale,t.ignorePrefix);return t.buildId&&(e=X.addPathSuffix(V.addPathPrefix(e,`/_next/data/${t.buildId}`),t.pathname==="/"?"index.json":".json")),e=V.addPathPrefix(e,t.basePath),t.trailingSlash?!t.buildId&&!e.endsWith("/")?X.addPathSuffix(e,"/"):e:Oe.removeTrailingSlash(e)}});var K=u(O=>{"use strict";Object.defineProperty(O,"__esModule",{value:!0});O.getHostname=ke;function ke(t,e){var r;return(r=!Array.isArray(e?.host)&&e?.host||t.hostname)==null?void 0:r.split(":")[0].toLowerCase()}});var Y=u($=>{"use strict";Object.defineProperty($,"__esModule",{value:!0});$.normalizeLocalePath=Re;function Re(t,e){let r,s=t.split("/");return(e||[]).some(o=>s[1]&&s[1].toLowerCase()===o.toLowerCase()?(r=o,s.splice(1,1),t=s.join("/")||"/",!0):!1),{pathname:t,detectedLocale:r}}});var Z=u(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.removePathPrefix=Ue;var Me=P();function Ue(t,e){if(Me.pathHasPrefix(t,e)){let r=t.slice(e.length);return r.startsWith("/")?r:`/${r}`}return t}});var ee=u(k=>{"use strict";Object.defineProperty(k,"__esModule",{value:!0});k.getNextPathnameInfo=Ee;var Ae=Y(),ze=Z(),We=P();function Ee(t,e){var r;let{basePath:s,i18n:o,trailingSlash:i}=(r=e.nextConfig)!=null?r:{},n={pathname:t,trailingSlash:t!=="/"?t.endsWith("/"):i};if(s&&We.pathHasPrefix(n.pathname,s)&&(n.pathname=ze.removePathPrefix(n.pathname,s),n.basePath=s),e.parseData===!0&&n.pathname.startsWith("/_next/data/")&&n.pathname.endsWith(".json")){let l=n.pathname.replace(/^\/_next\/data\//,"").replace(/\.json$/,"").split("/"),h=l[0];n.pathname=l[1]!=="index"?`/${l.slice(1).join("/")}`:"/",n.buildId=h}if(o){let l=Ae.normalizeLocalePath(n.pathname,o.locales);n.locale=l?.detectedLocale,n.pathname=l?.pathname||n.pathname}return n}});var se=u(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});var De=T(),Te=B(),Je=K(),Fe=ee(),a=Symbol("NextURLInternal"),R=class t{constructor(e,r,s){let o,i;typeof r=="object"&&"pathname"in r||typeof r=="string"?(o=r,i=s||{}):i=s||r||{},this[a]={url:re(e,o??i.base),options:i,basePath:""},this.analyzeUrl()}analyzeUrl(){var e,r,s,o,i;let n=Fe.getNextPathnameInfo(this[a].url.pathname,{nextConfig:this[a].options.nextConfig,parseData:!0});this[a].domainLocale=De.detectDomainLocale((e=this[a].options.nextConfig)==null||(r=e.i18n)==null?void 0:r.domains,Je.getHostname(this[a].url,this[a].options.headers));let l=((s=this[a].domainLocale)==null?void 0:s.defaultLocale)||((o=this[a].options.nextConfig)==null||(i=o.i18n)==null?void 0:i.defaultLocale);this[a].url.pathname=n.pathname,this[a].defaultLocale=l;var h;this[a].basePath=(h=n.basePath)!=null?h:"",this[a].buildId=n.buildId;var p;this[a].locale=(p=n.locale)!=null?p:l,this[a].trailingSlash=n.trailingSlash}formatPathname(){return Te.formatNextPathnameInfo({basePath:this[a].basePath,buildId:this[a].buildId,defaultLocale:this[a].options.forceLocale?void 0:this[a].defaultLocale,locale:this[a].locale,pathname:this[a].url.pathname,trailingSlash:this[a].trailingSlash})}get buildId(){return this[a].buildId}set buildId(e){this[a].buildId=e}get locale(){var e;return(e=this[a].locale)!=null?e:""}set locale(e){var r,s;if(!this[a].locale||!(!((r=this[a].options.nextConfig)==null||(s=r.i18n)==null)&&s.locales.includes(e)))throw new TypeError(`The NextURL configuration includes no locale "${e}"`);this[a].locale=e}get defaultLocale(){return this[a].defaultLocale}get domainLocale(){return this[a].domainLocale}get searchParams(){return this[a].url.searchParams}get host(){return this[a].url.host}set host(e){this[a].url.host=e}get hostname(){return this[a].url.hostname}set hostname(e){this[a].url.hostname=e}get port(){return this[a].url.port}set port(e){this[a].url.port=e}get protocol(){return this[a].url.protocol}set protocol(e){this[a].url.protocol=e}get href(){let e=this.formatPathname();return`${this.protocol}//${this.host}${e}${this[a].url.search}`}set href(e){this[a].url=re(e),this.analyzeUrl()}get origin(){return this[a].url.origin}get pathname(){return this[a].url.pathname}set pathname(e){this[a].url.pathname=e}get hash(){return this[a].url.hash}set hash(e){this[a].url.hash=e}get search(){return this[a].url.search}set search(e){this[a].url.search=e}get password(){return this[a].url.password}set password(e){this[a].url.password=e}get username(){return this[a].url.username}set username(e){this[a].url.username=e}get basePath(){return this[a].basePath}set basePath(e){this[a].basePath=e.startsWith("/")?e:`/${e}`}toString(){return this.href}toJSON(){return this.href}[Symbol.for("edge-runtime.inspect.custom")](){return{href:this.href,origin:this.origin,protocol:this.protocol,username:this.username,password:this.password,host:this.host,hostname:this.hostname,port:this.port,pathname:this.pathname,search:this.search,searchParams:this.searchParams,hash:this.hash}}clone(){return new t(String(this),this[a].options)}};M.NextURL=R;var te=/(?!^https?:\/\/)(127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}|::1|localhost)/;function re(t,e){return new URL(String(t).replace(te,"localhost"),e&&String(e).replace(te,"localhost"))}});var oe=u(f=>{"use strict";Object.defineProperty(f,"__esModule",{value:!0});f.fromNodeHeaders=Ge;f.toNodeHeaders=Qe;f.splitCookiesString=ae;f.validateURL=Ve;function Ge(t){let e=new Headers;for(let[r,s]of Object.entries(t)){let o=Array.isArray(s)?s:[s];for(let i of o)i!==void 0&&e.append(r,i)}return e}function Qe(t){let e={};if(t)for(let[r,s]of t.entries())e[r]=s,r.toLowerCase()==="set-cookie"&&(e[r]=ae(s));return e}function ae(t){var e=[],r=0,s,o,i,n,l;function h(){for(;r<t.length&&/\s/.test(t.charAt(r));)r+=1;return r<t.length}function p(){return o=t.charAt(r),o!=="="&&o!==";"&&o!==","}for(;r<t.length;){for(s=r,l=!1;h();)if(o=t.charAt(r),o===","){for(i=r,r+=1,h(),n=r;r<t.length&&p();)r+=1;r<t.length&&t.charAt(r)==="="?(l=!0,r=n,e.push(t.substring(s,i)),s=r):r=i+1}else r+=1;(!l||r>=t.length)&&e.push(t.substring(s,t.length))}return e}function Ve(t){try{return String(new URL(String(t)))}catch(e){throw new Error("URLs is malformed. Please use only absolute URLs - https://nextjs.org/docs/messages/middleware-relative-urls",{cause:e})}}});var ue=u(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});var v=Xe(ge("next/dist/compiled/cookie"));function Xe(t){return t&&t.__esModule?t:{default:t}}var Be=t=>(t=Object.assign({},t),t.maxAge&&(t.expires=new Date(Date.now()+t.maxAge*1e3)),t.path==null&&(t.path="/"),t),Ke=t=>typeof t=="object"?`j:${JSON.stringify(t)}`:String(t),ne=(t,e={})=>v.default.serialize(t,"",{expires:new Date(0),path:"/",...e}),ie=t=>{let e=t.headers.get("set-cookie");return e!=null?e.split(", "):[]},le=t=>t.join(", "),g=class extends Map{constructor(e){let r=typeof e=="string"?v.default.parse(e):{};super(Object.entries(r))}set(e,r,s={}){return super.set(e,v.default.serialize(e,Ke(r),Be(s)))}[Symbol.for("edge-runtime.inspect.custom")](){return Object.fromEntries(this.entries())}};x.Cookies=g;var U=class extends g{constructor(e){super(e.headers.get("cookie")),this.response=e}get=(...e)=>this.getWithOptions(...e).value;getWithOptions=(...e)=>{let r=super.get(...e);if(typeof r!="string")return{value:r,options:{}};let{[e[0]]:s,...o}=v.default.parse(r);return{value:s,options:o}};set=(...e)=>{let r=super.has(e[0]);super.set(...e);let s=super.get(e[0]);if(typeof s!="string")throw new Error(`Invariant: failed to generate cookie for ${JSON.stringify(e)}`);if(r){let o=le(ie(this.response).filter(i=>!i.startsWith(`${e[0]}=`)));o?this.response.headers.set("set-cookie",[s,o].join(", ")):this.response.headers.set("set-cookie",s)}else this.response.headers.append("set-cookie",s);return this};delete=(e,r={})=>{let s=super.delete(e);if(s){let o=le(ie(this.response).filter(n=>!n.startsWith(`${e}=`))),i=ne(e,r);this.response.headers.set("set-cookie",[i,o].join(", "))}return s};clear=(e={})=>{let r=Array.from(super.keys()).map(s=>ne(s,e)).join(", ");return r&&this.response.headers.set("set-cookie",r),super.clear()}};x.NextCookies=U});var E=u(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});var Ye=se(),A=oe(),Ze=ue(),he=Symbol("internal response"),et=new Set([301,302,303,307,308]),z=class t extends Response{constructor(e,r={}){super(e,r),this[he]={cookies:new Ze.NextCookies(this),url:r.url?new Ye.NextURL(r.url,{headers:A.toNodeHeaders(this.headers),nextConfig:r.nextConfig}):void 0}}[Symbol.for("edge-runtime.inspect.custom")](){return{cookies:this.cookies,url:this.url,body:this.body,bodyUsed:this.bodyUsed,headers:Object.fromEntries(this.headers),ok:this.ok,redirected:this.redirected,status:this.status,statusText:this.statusText,type:this.type}}get cookies(){return this[he].cookies}static json(e,r){let s=Response.json(e,r);return new t(s.body,s)}static redirect(e,r){var s;let o=typeof r=="number"?r:(s=r?.status)!=null?s:307;if(!et.has(o))throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');let i=typeof r=="object"?r:{},n=new Headers(i?.headers);return n.set("Location",A.validateURL(e)),new t(null,{...i,headers:n,status:o})}static rewrite(e,r){let s=new Headers(r?.headers);return s.set("x-middleware-rewrite",A.validateURL(e)),new t(null,{...r,headers:s})}static next(e){let r=new Headers(e?.headers);return r.set("x-middleware-next","1"),new t(null,{...e,headers:r})}};W.NextResponse=z});var d={};xe(d,{NextResponse:()=>rt,__esModule:()=>tt,default:()=>at});var ce=D(E());c(d,D(E()));var{__esModule:tt,NextResponse:rt}=ce,{default:de,...st}=ce,at=de!==void 0?de:st;export{rt as NextResponse,tt as __esModule,at as default};
5
- //# sourceMappingURL=response.js.map