vercel 58.9.5 → 58.10.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.
@@ -10659,6 +10659,94 @@ var getSubcommand3 = {
10659
10659
  ],
10660
10660
  examples: []
10661
10661
  };
10662
+ var putImageSubcommand = {
10663
+ name: "put-image",
10664
+ aliases: [],
10665
+ description: "Optimize an image with Vercel Image Optimization and store the result in the Blob store (requires OIDC credentials)",
10666
+ arguments: [
10667
+ {
10668
+ name: "pathToFileOrUrl",
10669
+ required: true
10670
+ }
10671
+ ],
10672
+ options: [
10673
+ accessOption,
10674
+ {
10675
+ name: "width",
10676
+ shorthand: "w",
10677
+ type: Number,
10678
+ deprecated: false,
10679
+ description: "Width of the optimized image in pixels, between 1 and 8192 (required)",
10680
+ argument: "NUMBER"
10681
+ },
10682
+ {
10683
+ name: "quality",
10684
+ shorthand: "q",
10685
+ type: Number,
10686
+ deprecated: false,
10687
+ description: "Quality of the optimized image, between 1 and 100 (default: 75)",
10688
+ argument: "NUMBER"
10689
+ },
10690
+ {
10691
+ name: "format",
10692
+ shorthand: "F",
10693
+ type: String,
10694
+ deprecated: false,
10695
+ description: "Output format: jpeg, png, webp, or avif. Keeps the original format when omitted",
10696
+ argument: "FORMAT",
10697
+ choices: ["jpeg", "png", "webp", "avif"]
10698
+ },
10699
+ {
10700
+ name: "pathname",
10701
+ shorthand: "p",
10702
+ type: String,
10703
+ deprecated: false,
10704
+ description: "Pathname to store the optimized image at in the Blob store (required)",
10705
+ argument: "String"
10706
+ },
10707
+ {
10708
+ name: "add-random-suffix",
10709
+ shorthand: "r",
10710
+ type: Boolean,
10711
+ deprecated: false,
10712
+ description: "Add a random suffix to the file name (default: false)",
10713
+ argument: "Boolean"
10714
+ },
10715
+ {
10716
+ name: "cache-control-max-age",
10717
+ shorthand: "c",
10718
+ type: Number,
10719
+ deprecated: false,
10720
+ description: "Max-age of the cache-control header directive (default: 2592000 = 30 days)",
10721
+ argument: "Number"
10722
+ },
10723
+ {
10724
+ name: "allow-overwrite",
10725
+ shorthand: null,
10726
+ type: Boolean,
10727
+ deprecated: false,
10728
+ description: "Overwrite the file if it already exists (default: false)",
10729
+ argument: "Boolean"
10730
+ },
10731
+ {
10732
+ name: "json",
10733
+ shorthand: null,
10734
+ type: Boolean,
10735
+ deprecated: false,
10736
+ description: "Output the stored blob as JSON"
10737
+ }
10738
+ ],
10739
+ examples: [
10740
+ {
10741
+ name: "Optimize a local image and upload it",
10742
+ value: "vercel blob put-image photo.png --pathname images/photo.png --width 1200 --access public"
10743
+ },
10744
+ {
10745
+ name: "Optimize an image from a public URL and convert it to WebP",
10746
+ value: "vercel blob put-image https://example.com/hero.png --pathname images/hero.webp --width 800 --quality 60 --format webp --access public"
10747
+ }
10748
+ ]
10749
+ };
10662
10750
  var signedTokenSubcommand = {
10663
10751
  name: "signed-token",
10664
10752
  aliases: [],
@@ -10974,6 +11062,7 @@ var blobCommand = {
10974
11062
  subcommands: [
10975
11063
  listSubcommand20,
10976
11064
  putSubcommand,
11065
+ putImageSubcommand,
10977
11066
  getSubcommand3,
10978
11067
  delSubcommand,
10979
11068
  copySubcommand,
@@ -11507,6 +11596,7 @@ export {
11507
11596
  delSubcommand,
11508
11597
  copySubcommand,
11509
11598
  getSubcommand3,
11599
+ putImageSubcommand,
11510
11600
  signedTokenSubcommand,
11511
11601
  presignSubcommand,
11512
11602
  createStoreSubcommand,
@@ -24,7 +24,7 @@ import {
24
24
  apiCommand,
25
25
  listSubcommand4 as listSubcommand,
26
26
  loginCommand
27
- } from "./chunk-GBXTATOJ.js";
27
+ } from "./chunk-CLUCO4RD.js";
28
28
  import {
29
29
  require_semver
30
30
  } from "./chunk-IB5L4LKZ.js";
@@ -21,7 +21,7 @@ import {
21
21
  } from "./chunk-XBN2O34P.js";
22
22
  import {
23
23
  CommandTimeout
24
- } from "./chunk-GBXTATOJ.js";
24
+ } from "./chunk-CLUCO4RD.js";
25
25
  import {
26
26
  showPluginTipIfNeeded
27
27
  } from "./chunk-HT2XWSAJ.js";
@@ -13,7 +13,7 @@ import {
13
13
  purchaseDomainIfAvailable,
14
14
  require_cjs,
15
15
  setupDomain
16
- } from "../../chunks/chunk-3MELKK7A.js";
16
+ } from "../../chunks/chunk-L6BFCLXF.js";
17
17
  import "../../chunks/chunk-PRWJUY5U.js";
18
18
  import "../../chunks/chunk-I2XE3GMB.js";
19
19
  import {
@@ -38,7 +38,7 @@ import {
38
38
  deprecatedArchiveSplitTgz,
39
39
  getCommandAliases,
40
40
  initSubcommand
41
- } from "../../chunks/chunk-GBXTATOJ.js";
41
+ } from "../../chunks/chunk-CLUCO4RD.js";
42
42
  import "../../chunks/chunk-ELA5VN3A.js";
43
43
  import "../../chunks/chunk-B3JTF4CF.js";
44
44
  import "../../chunks/chunk-A5KP5HAI.js";
@@ -19557,6 +19557,30 @@ function nodeHeadersToFetchHeaders(nodeHeaders) {
19557
19557
  }
19558
19558
  return headers;
19559
19559
  }
19560
+ var NEVER_COMBINE_RESPONSE_HEADERS = /* @__PURE__ */ new Set([
19561
+ "set-cookie",
19562
+ "www-authenticate",
19563
+ "proxy-authenticate"
19564
+ ]);
19565
+ var COMMA_JOIN_RESPONSE_HEADERS = /* @__PURE__ */ new Set(["vary"]);
19566
+ function applyChainResponseHeader(res, name, value) {
19567
+ if (NEVER_COMBINE_RESPONSE_HEADERS.has(name)) {
19568
+ const existing = res.getHeader(name);
19569
+ const values = Array.isArray(existing) ? existing.map(String) : existing !== void 0 ? [String(existing)] : [];
19570
+ values.push(value);
19571
+ res.setHeader(name, values);
19572
+ return;
19573
+ }
19574
+ if (COMMA_JOIN_RESPONSE_HEADERS.has(name)) {
19575
+ const existing = res.getHeader(name);
19576
+ res.setHeader(
19577
+ name,
19578
+ existing !== void 0 ? `${existing}, ${value}` : value
19579
+ );
19580
+ return;
19581
+ }
19582
+ res.setHeader(name, value);
19583
+ }
19560
19584
  var NONOVERRIDABLE_HEADERS = /* @__PURE__ */ new Set([
19561
19585
  "host",
19562
19586
  "connection",
@@ -20005,14 +20029,14 @@ ${partHeaders}\r
20005
20029
  let statusCode;
20006
20030
  let prevUrl = req.url;
20007
20031
  let prevHeaders = {};
20008
- let middlewarePid;
20009
20032
  const requestTransforms = [];
20010
20033
  let responseTransforms;
20011
- const middleware = [...this.buildMatches.values()].find(
20034
+ const middlewares = [...this.buildMatches.values()].filter(
20012
20035
  (m) => m.config?.middleware === true
20013
20036
  );
20014
- if (middleware) {
20037
+ for (const middleware of middlewares) {
20015
20038
  let startMiddlewareResult;
20039
+ let middlewarePid;
20016
20040
  const { envConfigs, files, devCacheDir, cwd: workPath } = this;
20017
20041
  try {
20018
20042
  const { builder: builder2 } = middleware.builderWithPkg;
@@ -20036,13 +20060,15 @@ ${partHeaders}\r
20036
20060
  const { port, pid, shutdown } = startMiddlewareResult;
20037
20061
  middlewarePid = pid;
20038
20062
  this.shutdownCallbacks.set(pid, shutdown);
20063
+ debug(`Invoking middleware "${middleware.src}" (port=${port})`);
20039
20064
  const middlewareReqHeaders = nodeHeadersToFetchHeaders(req.headers);
20040
20065
  const proxyHeaders = this.getProxyHeaders(req, requestId, true);
20041
20066
  for (const [name, value] of nodeHeadersToFetchHeaders(proxyHeaders)) {
20042
20067
  middlewareReqHeaders.set(name, value);
20043
20068
  }
20069
+ const middlewareReqPath = url3.parse(req.url || "/").path || "/";
20044
20070
  const middlewareRes = await directFetch(
20045
- `http://127.0.0.1:${port}${parsed.path}`,
20071
+ `http://127.0.0.1:${port}${middlewareReqPath}`,
20046
20072
  {
20047
20073
  headers: middlewareReqHeaders,
20048
20074
  method: req.method,
@@ -20083,7 +20109,7 @@ ${partHeaders}\r
20083
20109
  } else if (name === "content-type") {
20084
20110
  contentType2 = value;
20085
20111
  } else if (!skipMiddlewareHeaders.has(name)) {
20086
- res.setHeader(name, value);
20112
+ applyChainResponseHeader(res, name, value);
20087
20113
  req.headers[name] = value;
20088
20114
  }
20089
20115
  }
@@ -33,7 +33,7 @@ import {
33
33
  } from "../../chunks/chunk-YPQSDAEW.js";
34
34
  import {
35
35
  getCommandAliases
36
- } from "../../chunks/chunk-GBXTATOJ.js";
36
+ } from "../../chunks/chunk-CLUCO4RD.js";
37
37
  import "../../chunks/chunk-ELA5VN3A.js";
38
38
  import "../../chunks/chunk-B3JTF4CF.js";
39
39
  import "../../chunks/chunk-A5KP5HAI.js";
@@ -11,7 +11,7 @@ import {
11
11
  addSubcommand7 as addSubcommand,
12
12
  getCommandAliases,
13
13
  linkCommand
14
- } from "../../chunks/chunk-GBXTATOJ.js";
14
+ } from "../../chunks/chunk-CLUCO4RD.js";
15
15
  import "../../chunks/chunk-ELA5VN3A.js";
16
16
  import "../../chunks/chunk-B3JTF4CF.js";
17
17
  import "../../chunks/chunk-A5KP5HAI.js";