@vercel/node 2.9.10 → 2.9.13

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.
package/dist/babel.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.compile = void 0;
4
- const babel = require('@babel/core'); // eslint-disable-line @typescript-eslint/no-var-requires
4
+ const babel = require('@babel/core'); // eslint-disable-line @typescript-eslint/no-var-requires
5
5
  // eslint-disable-next-line @typescript-eslint/no-var-requires
6
6
  const pluginTransformModulesCommonJs = require('@babel/plugin-transform-modules-commonjs');
7
7
  function compile(filename, source) {
@@ -1,73 +1,103 @@
1
1
  // provided by the edge runtime:
2
- /* global addEventListener Request Response */
3
-
4
- // provided by our edge handler logic:
5
- /* global IS_MIDDLEWARE ENTRYPOINT_LABEL */
2
+ /* global addEventListener */
6
3
 
7
4
  function buildUrl(requestDetails) {
8
- let proto = requestDetails.headers['x-forwarded-proto'];
5
+ let proto = requestDetails.headers['x-forwarded-proto'].split(/\b/).shift(); // handling multi-protocol like https,http://...
9
6
  let host = requestDetails.headers['x-forwarded-host'];
10
7
  let path = requestDetails.url;
11
8
  return `${proto}://${host}${path}`;
12
9
  }
13
10
 
14
- addEventListener('fetch', async event => {
15
- try {
16
- let serializedRequest = await event.request.text();
17
- let requestDetails = JSON.parse(serializedRequest);
11
+ async function respond(
12
+ userEdgeHandler,
13
+ requestDetails,
14
+ event,
15
+ options,
16
+ dependencies
17
+ ) {
18
+ const { Request, Response } = dependencies;
19
+ const { isMiddleware, entrypointLabel } = options;
18
20
 
19
- let body;
21
+ let body;
20
22
 
21
- if (requestDetails.method !== 'GET' && requestDetails.method !== 'HEAD') {
23
+ if (requestDetails.method !== 'GET' && requestDetails.method !== 'HEAD') {
24
+ if (requestDetails.body) {
22
25
  body = Uint8Array.from(atob(requestDetails.body), c => c.charCodeAt(0));
23
26
  }
27
+ }
24
28
 
25
- let request = new Request(buildUrl(requestDetails), {
26
- headers: requestDetails.headers,
27
- method: requestDetails.method,
28
- body: body,
29
- });
29
+ let request = new Request(buildUrl(requestDetails), {
30
+ headers: requestDetails.headers,
31
+ method: requestDetails.method,
32
+ body: body,
33
+ });
30
34
 
31
- event.request = request;
35
+ event.request = request;
32
36
 
33
- let edgeHandler = module.exports.default;
34
- if (!edgeHandler) {
37
+ let response = await userEdgeHandler(event.request, event);
38
+
39
+ if (!response) {
40
+ if (isMiddleware) {
41
+ // allow empty responses to pass through
42
+ response = new Response(null, {
43
+ headers: {
44
+ 'x-middleware-next': '1',
45
+ },
46
+ });
47
+ } else {
35
48
  throw new Error(
36
- 'No default export was found. Add a default export to handle requests. Learn more: https://vercel.link/creating-edge-middleware'
49
+ `Edge Function "${entrypointLabel}" did not return a response.`
37
50
  );
38
51
  }
52
+ }
53
+ return response;
54
+ }
39
55
 
40
- let response = await edgeHandler(event.request, event);
56
+ function toResponseError(error, Response) {
57
+ // we can't easily show a meaningful stack trace
58
+ // so, stick to just the error message for now
59
+ const msg = error.cause
60
+ ? error.message + ': ' + (error.cause.message || error.cause)
61
+ : error.message;
62
+ return new Response(msg, {
63
+ status: 500,
64
+ headers: {
65
+ 'x-vercel-failed': 'edge-wrapper',
66
+ },
67
+ });
68
+ }
41
69
 
42
- if (!response) {
43
- if (IS_MIDDLEWARE) {
44
- // allow empty responses to pass through
45
- response = new Response(null, {
46
- headers: {
47
- 'x-middleware-next': '1',
48
- },
49
- });
50
- } else {
51
- throw new Error(
52
- `Edge Function "${ENTRYPOINT_LABEL}" did not return a response.`
53
- );
54
- }
70
+ async function parseRequestEvent(event) {
71
+ let serializedRequest = await event.request.text();
72
+ let requestDetails = JSON.parse(serializedRequest);
73
+ return requestDetails;
74
+ }
75
+
76
+ // This will be invoked by logic using this template
77
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
78
+ function registerFetchListener(userEdgeHandler, options, dependencies) {
79
+ addEventListener('fetch', async event => {
80
+ try {
81
+ let requestDetails = await parseRequestEvent(event);
82
+ let response = await respond(
83
+ userEdgeHandler,
84
+ requestDetails,
85
+ event,
86
+ options,
87
+ dependencies
88
+ );
89
+ return event.respondWith(response);
90
+ } catch (error) {
91
+ event.respondWith(toResponseError(error, dependencies.Response));
55
92
  }
93
+ });
94
+ }
56
95
 
57
- return event.respondWith(response);
58
- } catch (error) {
59
- // we can't easily show a meaningful stack trace
60
- // so, stick to just the error message for now
61
- const msg = error.cause
62
- ? error.message + ': ' + (error.cause.message || error.cause)
63
- : error.message;
64
- event.respondWith(
65
- new Response(msg, {
66
- status: 500,
67
- headers: {
68
- 'x-vercel-failed': 'edge-wrapper',
69
- },
70
- })
71
- );
72
- }
73
- });
96
+ // for testing:
97
+ module.exports = {
98
+ buildUrl,
99
+ respond,
100
+ toResponseError,
101
+ parseRequestEvent,
102
+ registerFetchListener,
103
+ };
@@ -56,13 +56,28 @@ async function compileUserCode(entrypointFullPath, entrypointRelativePath, isMid
56
56
 
57
57
  // user code
58
58
  ${compiledFile.text};
59
+ const userEdgeHandler = module.exports.default;
60
+ if (!userEdgeHandler) {
61
+ throw new Error(
62
+ 'No default export was found. Add a default export to handle requests. Learn more: https://vercel.link/creating-edge-middleware'
63
+ );
64
+ }
59
65
 
60
66
  // request metadata
61
- const IS_MIDDLEWARE = ${isMiddleware};
62
- const ENTRYPOINT_LABEL = '${entrypointRelativePath}';
67
+ const isMiddleware = ${isMiddleware};
68
+ const entrypointLabel = '${entrypointRelativePath}';
63
69
 
64
70
  // edge handler
65
- ${edgeHandlerTemplate}
71
+ ${edgeHandlerTemplate};
72
+ const dependencies = {
73
+ Request,
74
+ Response
75
+ };
76
+ const options = {
77
+ isMiddleware,
78
+ entrypointLabel
79
+ };
80
+ registerFetchListener(userEdgeHandler, options, dependencies);
66
81
  `;
67
82
  return { userCode, wasmAssets };
68
83
  }
package/dist/index.js CHANGED
@@ -55731,7 +55731,7 @@ exports.libFiles = libFiles;
55731
55731
  Object.defineProperty(exports, "__esModule", ({ value: true }));
55732
55732
 
55733
55733
  var ts = __webpack_require__(11);
55734
- var minimatch = __webpack_require__(47345);
55734
+ var minimatch = __webpack_require__(97767);
55735
55735
  var fastGlob = __webpack_require__(94910);
55736
55736
  var fs$1 = __webpack_require__(35747);
55737
55737
  var mkdirp = __webpack_require__(57981);
@@ -255821,6 +255821,936 @@ micromatch.braceExpand = (pattern, options) => {
255821
255821
  module.exports = micromatch;
255822
255822
 
255823
255823
 
255824
+ /***/ }),
255825
+
255826
+ /***/ 97767:
255827
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
255828
+
255829
+ module.exports = minimatch
255830
+ minimatch.Minimatch = Minimatch
255831
+
255832
+ var path = { sep: '/' }
255833
+ try {
255834
+ path = __webpack_require__(85622)
255835
+ } catch (er) {}
255836
+
255837
+ var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
255838
+ var expand = __webpack_require__(90490)
255839
+
255840
+ var plTypes = {
255841
+ '!': { open: '(?:(?!(?:', close: '))[^/]*?)'},
255842
+ '?': { open: '(?:', close: ')?' },
255843
+ '+': { open: '(?:', close: ')+' },
255844
+ '*': { open: '(?:', close: ')*' },
255845
+ '@': { open: '(?:', close: ')' }
255846
+ }
255847
+
255848
+ // any single thing other than /
255849
+ // don't need to escape / when using new RegExp()
255850
+ var qmark = '[^/]'
255851
+
255852
+ // * => any number of characters
255853
+ var star = qmark + '*?'
255854
+
255855
+ // ** when dots are allowed. Anything goes, except .. and .
255856
+ // not (^ or / followed by one or two dots followed by $ or /),
255857
+ // followed by anything, any number of times.
255858
+ var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'
255859
+
255860
+ // not a ^ or / followed by a dot,
255861
+ // followed by anything, any number of times.
255862
+ var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'
255863
+
255864
+ // characters that need to be escaped in RegExp.
255865
+ var reSpecials = charSet('().*{}+?[]^$\\!')
255866
+
255867
+ // "abc" -> { a:true, b:true, c:true }
255868
+ function charSet (s) {
255869
+ return s.split('').reduce(function (set, c) {
255870
+ set[c] = true
255871
+ return set
255872
+ }, {})
255873
+ }
255874
+
255875
+ // normalizes slashes.
255876
+ var slashSplit = /\/+/
255877
+
255878
+ minimatch.filter = filter
255879
+ function filter (pattern, options) {
255880
+ options = options || {}
255881
+ return function (p, i, list) {
255882
+ return minimatch(p, pattern, options)
255883
+ }
255884
+ }
255885
+
255886
+ function ext (a, b) {
255887
+ a = a || {}
255888
+ b = b || {}
255889
+ var t = {}
255890
+ Object.keys(b).forEach(function (k) {
255891
+ t[k] = b[k]
255892
+ })
255893
+ Object.keys(a).forEach(function (k) {
255894
+ t[k] = a[k]
255895
+ })
255896
+ return t
255897
+ }
255898
+
255899
+ minimatch.defaults = function (def) {
255900
+ if (!def || !Object.keys(def).length) return minimatch
255901
+
255902
+ var orig = minimatch
255903
+
255904
+ var m = function minimatch (p, pattern, options) {
255905
+ return orig.minimatch(p, pattern, ext(def, options))
255906
+ }
255907
+
255908
+ m.Minimatch = function Minimatch (pattern, options) {
255909
+ return new orig.Minimatch(pattern, ext(def, options))
255910
+ }
255911
+
255912
+ return m
255913
+ }
255914
+
255915
+ Minimatch.defaults = function (def) {
255916
+ if (!def || !Object.keys(def).length) return Minimatch
255917
+ return minimatch.defaults(def).Minimatch
255918
+ }
255919
+
255920
+ function minimatch (p, pattern, options) {
255921
+ if (typeof pattern !== 'string') {
255922
+ throw new TypeError('glob pattern string required')
255923
+ }
255924
+
255925
+ if (!options) options = {}
255926
+
255927
+ // shortcut: comments match nothing.
255928
+ if (!options.nocomment && pattern.charAt(0) === '#') {
255929
+ return false
255930
+ }
255931
+
255932
+ // "" only matches ""
255933
+ if (pattern.trim() === '') return p === ''
255934
+
255935
+ return new Minimatch(pattern, options).match(p)
255936
+ }
255937
+
255938
+ function Minimatch (pattern, options) {
255939
+ if (!(this instanceof Minimatch)) {
255940
+ return new Minimatch(pattern, options)
255941
+ }
255942
+
255943
+ if (typeof pattern !== 'string') {
255944
+ throw new TypeError('glob pattern string required')
255945
+ }
255946
+
255947
+ if (!options) options = {}
255948
+ pattern = pattern.trim()
255949
+
255950
+ // windows support: need to use /, not \
255951
+ if (path.sep !== '/') {
255952
+ pattern = pattern.split(path.sep).join('/')
255953
+ }
255954
+
255955
+ this.options = options
255956
+ this.set = []
255957
+ this.pattern = pattern
255958
+ this.regexp = null
255959
+ this.negate = false
255960
+ this.comment = false
255961
+ this.empty = false
255962
+
255963
+ // make the set of regexps etc.
255964
+ this.make()
255965
+ }
255966
+
255967
+ Minimatch.prototype.debug = function () {}
255968
+
255969
+ Minimatch.prototype.make = make
255970
+ function make () {
255971
+ // don't do it more than once.
255972
+ if (this._made) return
255973
+
255974
+ var pattern = this.pattern
255975
+ var options = this.options
255976
+
255977
+ // empty patterns and comments match nothing.
255978
+ if (!options.nocomment && pattern.charAt(0) === '#') {
255979
+ this.comment = true
255980
+ return
255981
+ }
255982
+ if (!pattern) {
255983
+ this.empty = true
255984
+ return
255985
+ }
255986
+
255987
+ // step 1: figure out negation, etc.
255988
+ this.parseNegate()
255989
+
255990
+ // step 2: expand braces
255991
+ var set = this.globSet = this.braceExpand()
255992
+
255993
+ if (options.debug) this.debug = console.error
255994
+
255995
+ this.debug(this.pattern, set)
255996
+
255997
+ // step 3: now we have a set, so turn each one into a series of path-portion
255998
+ // matching patterns.
255999
+ // These will be regexps, except in the case of "**", which is
256000
+ // set to the GLOBSTAR object for globstar behavior,
256001
+ // and will not contain any / characters
256002
+ set = this.globParts = set.map(function (s) {
256003
+ return s.split(slashSplit)
256004
+ })
256005
+
256006
+ this.debug(this.pattern, set)
256007
+
256008
+ // glob --> regexps
256009
+ set = set.map(function (s, si, set) {
256010
+ return s.map(this.parse, this)
256011
+ }, this)
256012
+
256013
+ this.debug(this.pattern, set)
256014
+
256015
+ // filter out everything that didn't compile properly.
256016
+ set = set.filter(function (s) {
256017
+ return s.indexOf(false) === -1
256018
+ })
256019
+
256020
+ this.debug(this.pattern, set)
256021
+
256022
+ this.set = set
256023
+ }
256024
+
256025
+ Minimatch.prototype.parseNegate = parseNegate
256026
+ function parseNegate () {
256027
+ var pattern = this.pattern
256028
+ var negate = false
256029
+ var options = this.options
256030
+ var negateOffset = 0
256031
+
256032
+ if (options.nonegate) return
256033
+
256034
+ for (var i = 0, l = pattern.length
256035
+ ; i < l && pattern.charAt(i) === '!'
256036
+ ; i++) {
256037
+ negate = !negate
256038
+ negateOffset++
256039
+ }
256040
+
256041
+ if (negateOffset) this.pattern = pattern.substr(negateOffset)
256042
+ this.negate = negate
256043
+ }
256044
+
256045
+ // Brace expansion:
256046
+ // a{b,c}d -> abd acd
256047
+ // a{b,}c -> abc ac
256048
+ // a{0..3}d -> a0d a1d a2d a3d
256049
+ // a{b,c{d,e}f}g -> abg acdfg acefg
256050
+ // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
256051
+ //
256052
+ // Invalid sets are not expanded.
256053
+ // a{2..}b -> a{2..}b
256054
+ // a{b}c -> a{b}c
256055
+ minimatch.braceExpand = function (pattern, options) {
256056
+ return braceExpand(pattern, options)
256057
+ }
256058
+
256059
+ Minimatch.prototype.braceExpand = braceExpand
256060
+
256061
+ function braceExpand (pattern, options) {
256062
+ if (!options) {
256063
+ if (this instanceof Minimatch) {
256064
+ options = this.options
256065
+ } else {
256066
+ options = {}
256067
+ }
256068
+ }
256069
+
256070
+ pattern = typeof pattern === 'undefined'
256071
+ ? this.pattern : pattern
256072
+
256073
+ if (typeof pattern === 'undefined') {
256074
+ throw new TypeError('undefined pattern')
256075
+ }
256076
+
256077
+ if (options.nobrace ||
256078
+ !pattern.match(/\{.*\}/)) {
256079
+ // shortcut. no need to expand.
256080
+ return [pattern]
256081
+ }
256082
+
256083
+ return expand(pattern)
256084
+ }
256085
+
256086
+ // parse a component of the expanded set.
256087
+ // At this point, no pattern may contain "/" in it
256088
+ // so we're going to return a 2d array, where each entry is the full
256089
+ // pattern, split on '/', and then turned into a regular expression.
256090
+ // A regexp is made at the end which joins each array with an
256091
+ // escaped /, and another full one which joins each regexp with |.
256092
+ //
256093
+ // Following the lead of Bash 4.1, note that "**" only has special meaning
256094
+ // when it is the *only* thing in a path portion. Otherwise, any series
256095
+ // of * is equivalent to a single *. Globstar behavior is enabled by
256096
+ // default, and can be disabled by setting options.noglobstar.
256097
+ Minimatch.prototype.parse = parse
256098
+ var SUBPARSE = {}
256099
+ function parse (pattern, isSub) {
256100
+ if (pattern.length > 1024 * 64) {
256101
+ throw new TypeError('pattern is too long')
256102
+ }
256103
+
256104
+ var options = this.options
256105
+
256106
+ // shortcuts
256107
+ if (!options.noglobstar && pattern === '**') return GLOBSTAR
256108
+ if (pattern === '') return ''
256109
+
256110
+ var re = ''
256111
+ var hasMagic = !!options.nocase
256112
+ var escaping = false
256113
+ // ? => one single character
256114
+ var patternListStack = []
256115
+ var negativeLists = []
256116
+ var stateChar
256117
+ var inClass = false
256118
+ var reClassStart = -1
256119
+ var classStart = -1
256120
+ // . and .. never match anything that doesn't start with .,
256121
+ // even when options.dot is set.
256122
+ var patternStart = pattern.charAt(0) === '.' ? '' // anything
256123
+ // not (start or / followed by . or .. followed by / or end)
256124
+ : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))'
256125
+ : '(?!\\.)'
256126
+ var self = this
256127
+
256128
+ function clearStateChar () {
256129
+ if (stateChar) {
256130
+ // we had some state-tracking character
256131
+ // that wasn't consumed by this pass.
256132
+ switch (stateChar) {
256133
+ case '*':
256134
+ re += star
256135
+ hasMagic = true
256136
+ break
256137
+ case '?':
256138
+ re += qmark
256139
+ hasMagic = true
256140
+ break
256141
+ default:
256142
+ re += '\\' + stateChar
256143
+ break
256144
+ }
256145
+ self.debug('clearStateChar %j %j', stateChar, re)
256146
+ stateChar = false
256147
+ }
256148
+ }
256149
+
256150
+ for (var i = 0, len = pattern.length, c
256151
+ ; (i < len) && (c = pattern.charAt(i))
256152
+ ; i++) {
256153
+ this.debug('%s\t%s %s %j', pattern, i, re, c)
256154
+
256155
+ // skip over any that are escaped.
256156
+ if (escaping && reSpecials[c]) {
256157
+ re += '\\' + c
256158
+ escaping = false
256159
+ continue
256160
+ }
256161
+
256162
+ switch (c) {
256163
+ case '/':
256164
+ // completely not allowed, even escaped.
256165
+ // Should already be path-split by now.
256166
+ return false
256167
+
256168
+ case '\\':
256169
+ clearStateChar()
256170
+ escaping = true
256171
+ continue
256172
+
256173
+ // the various stateChar values
256174
+ // for the "extglob" stuff.
256175
+ case '?':
256176
+ case '*':
256177
+ case '+':
256178
+ case '@':
256179
+ case '!':
256180
+ this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c)
256181
+
256182
+ // all of those are literals inside a class, except that
256183
+ // the glob [!a] means [^a] in regexp
256184
+ if (inClass) {
256185
+ this.debug(' in class')
256186
+ if (c === '!' && i === classStart + 1) c = '^'
256187
+ re += c
256188
+ continue
256189
+ }
256190
+
256191
+ // if we already have a stateChar, then it means
256192
+ // that there was something like ** or +? in there.
256193
+ // Handle the stateChar, then proceed with this one.
256194
+ self.debug('call clearStateChar %j', stateChar)
256195
+ clearStateChar()
256196
+ stateChar = c
256197
+ // if extglob is disabled, then +(asdf|foo) isn't a thing.
256198
+ // just clear the statechar *now*, rather than even diving into
256199
+ // the patternList stuff.
256200
+ if (options.noext) clearStateChar()
256201
+ continue
256202
+
256203
+ case '(':
256204
+ if (inClass) {
256205
+ re += '('
256206
+ continue
256207
+ }
256208
+
256209
+ if (!stateChar) {
256210
+ re += '\\('
256211
+ continue
256212
+ }
256213
+
256214
+ patternListStack.push({
256215
+ type: stateChar,
256216
+ start: i - 1,
256217
+ reStart: re.length,
256218
+ open: plTypes[stateChar].open,
256219
+ close: plTypes[stateChar].close
256220
+ })
256221
+ // negation is (?:(?!js)[^/]*)
256222
+ re += stateChar === '!' ? '(?:(?!(?:' : '(?:'
256223
+ this.debug('plType %j %j', stateChar, re)
256224
+ stateChar = false
256225
+ continue
256226
+
256227
+ case ')':
256228
+ if (inClass || !patternListStack.length) {
256229
+ re += '\\)'
256230
+ continue
256231
+ }
256232
+
256233
+ clearStateChar()
256234
+ hasMagic = true
256235
+ var pl = patternListStack.pop()
256236
+ // negation is (?:(?!js)[^/]*)
256237
+ // The others are (?:<pattern>)<type>
256238
+ re += pl.close
256239
+ if (pl.type === '!') {
256240
+ negativeLists.push(pl)
256241
+ }
256242
+ pl.reEnd = re.length
256243
+ continue
256244
+
256245
+ case '|':
256246
+ if (inClass || !patternListStack.length || escaping) {
256247
+ re += '\\|'
256248
+ escaping = false
256249
+ continue
256250
+ }
256251
+
256252
+ clearStateChar()
256253
+ re += '|'
256254
+ continue
256255
+
256256
+ // these are mostly the same in regexp and glob
256257
+ case '[':
256258
+ // swallow any state-tracking char before the [
256259
+ clearStateChar()
256260
+
256261
+ if (inClass) {
256262
+ re += '\\' + c
256263
+ continue
256264
+ }
256265
+
256266
+ inClass = true
256267
+ classStart = i
256268
+ reClassStart = re.length
256269
+ re += c
256270
+ continue
256271
+
256272
+ case ']':
256273
+ // a right bracket shall lose its special
256274
+ // meaning and represent itself in
256275
+ // a bracket expression if it occurs
256276
+ // first in the list. -- POSIX.2 2.8.3.2
256277
+ if (i === classStart + 1 || !inClass) {
256278
+ re += '\\' + c
256279
+ escaping = false
256280
+ continue
256281
+ }
256282
+
256283
+ // handle the case where we left a class open.
256284
+ // "[z-a]" is valid, equivalent to "\[z-a\]"
256285
+ if (inClass) {
256286
+ // split where the last [ was, make sure we don't have
256287
+ // an invalid re. if so, re-walk the contents of the
256288
+ // would-be class to re-translate any characters that
256289
+ // were passed through as-is
256290
+ // TODO: It would probably be faster to determine this
256291
+ // without a try/catch and a new RegExp, but it's tricky
256292
+ // to do safely. For now, this is safe and works.
256293
+ var cs = pattern.substring(classStart + 1, i)
256294
+ try {
256295
+ RegExp('[' + cs + ']')
256296
+ } catch (er) {
256297
+ // not a valid class!
256298
+ var sp = this.parse(cs, SUBPARSE)
256299
+ re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
256300
+ hasMagic = hasMagic || sp[1]
256301
+ inClass = false
256302
+ continue
256303
+ }
256304
+ }
256305
+
256306
+ // finish up the class.
256307
+ hasMagic = true
256308
+ inClass = false
256309
+ re += c
256310
+ continue
256311
+
256312
+ default:
256313
+ // swallow any state char that wasn't consumed
256314
+ clearStateChar()
256315
+
256316
+ if (escaping) {
256317
+ // no need
256318
+ escaping = false
256319
+ } else if (reSpecials[c]
256320
+ && !(c === '^' && inClass)) {
256321
+ re += '\\'
256322
+ }
256323
+
256324
+ re += c
256325
+
256326
+ } // switch
256327
+ } // for
256328
+
256329
+ // handle the case where we left a class open.
256330
+ // "[abc" is valid, equivalent to "\[abc"
256331
+ if (inClass) {
256332
+ // split where the last [ was, and escape it
256333
+ // this is a huge pita. We now have to re-walk
256334
+ // the contents of the would-be class to re-translate
256335
+ // any characters that were passed through as-is
256336
+ cs = pattern.substr(classStart + 1)
256337
+ sp = this.parse(cs, SUBPARSE)
256338
+ re = re.substr(0, reClassStart) + '\\[' + sp[0]
256339
+ hasMagic = hasMagic || sp[1]
256340
+ }
256341
+
256342
+ // handle the case where we had a +( thing at the *end*
256343
+ // of the pattern.
256344
+ // each pattern list stack adds 3 chars, and we need to go through
256345
+ // and escape any | chars that were passed through as-is for the regexp.
256346
+ // Go through and escape them, taking care not to double-escape any
256347
+ // | chars that were already escaped.
256348
+ for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
256349
+ var tail = re.slice(pl.reStart + pl.open.length)
256350
+ this.debug('setting tail', re, pl)
256351
+ // maybe some even number of \, then maybe 1 \, followed by a |
256352
+ tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
256353
+ if (!$2) {
256354
+ // the | isn't already escaped, so escape it.
256355
+ $2 = '\\'
256356
+ }
256357
+
256358
+ // need to escape all those slashes *again*, without escaping the
256359
+ // one that we need for escaping the | character. As it works out,
256360
+ // escaping an even number of slashes can be done by simply repeating
256361
+ // it exactly after itself. That's why this trick works.
256362
+ //
256363
+ // I am sorry that you have to see this.
256364
+ return $1 + $1 + $2 + '|'
256365
+ })
256366
+
256367
+ this.debug('tail=%j\n %s', tail, tail, pl, re)
256368
+ var t = pl.type === '*' ? star
256369
+ : pl.type === '?' ? qmark
256370
+ : '\\' + pl.type
256371
+
256372
+ hasMagic = true
256373
+ re = re.slice(0, pl.reStart) + t + '\\(' + tail
256374
+ }
256375
+
256376
+ // handle trailing things that only matter at the very end.
256377
+ clearStateChar()
256378
+ if (escaping) {
256379
+ // trailing \\
256380
+ re += '\\\\'
256381
+ }
256382
+
256383
+ // only need to apply the nodot start if the re starts with
256384
+ // something that could conceivably capture a dot
256385
+ var addPatternStart = false
256386
+ switch (re.charAt(0)) {
256387
+ case '.':
256388
+ case '[':
256389
+ case '(': addPatternStart = true
256390
+ }
256391
+
256392
+ // Hack to work around lack of negative lookbehind in JS
256393
+ // A pattern like: *.!(x).!(y|z) needs to ensure that a name
256394
+ // like 'a.xyz.yz' doesn't match. So, the first negative
256395
+ // lookahead, has to look ALL the way ahead, to the end of
256396
+ // the pattern.
256397
+ for (var n = negativeLists.length - 1; n > -1; n--) {
256398
+ var nl = negativeLists[n]
256399
+
256400
+ var nlBefore = re.slice(0, nl.reStart)
256401
+ var nlFirst = re.slice(nl.reStart, nl.reEnd - 8)
256402
+ var nlLast = re.slice(nl.reEnd - 8, nl.reEnd)
256403
+ var nlAfter = re.slice(nl.reEnd)
256404
+
256405
+ nlLast += nlAfter
256406
+
256407
+ // Handle nested stuff like *(*.js|!(*.json)), where open parens
256408
+ // mean that we should *not* include the ) in the bit that is considered
256409
+ // "after" the negated section.
256410
+ var openParensBefore = nlBefore.split('(').length - 1
256411
+ var cleanAfter = nlAfter
256412
+ for (i = 0; i < openParensBefore; i++) {
256413
+ cleanAfter = cleanAfter.replace(/\)[+*?]?/, '')
256414
+ }
256415
+ nlAfter = cleanAfter
256416
+
256417
+ var dollar = ''
256418
+ if (nlAfter === '' && isSub !== SUBPARSE) {
256419
+ dollar = '$'
256420
+ }
256421
+ var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast
256422
+ re = newRe
256423
+ }
256424
+
256425
+ // if the re is not "" at this point, then we need to make sure
256426
+ // it doesn't match against an empty path part.
256427
+ // Otherwise a/* will match a/, which it should not.
256428
+ if (re !== '' && hasMagic) {
256429
+ re = '(?=.)' + re
256430
+ }
256431
+
256432
+ if (addPatternStart) {
256433
+ re = patternStart + re
256434
+ }
256435
+
256436
+ // parsing just a piece of a larger pattern.
256437
+ if (isSub === SUBPARSE) {
256438
+ return [re, hasMagic]
256439
+ }
256440
+
256441
+ // skip the regexp for non-magical patterns
256442
+ // unescape anything in it, though, so that it'll be
256443
+ // an exact match against a file etc.
256444
+ if (!hasMagic) {
256445
+ return globUnescape(pattern)
256446
+ }
256447
+
256448
+ var flags = options.nocase ? 'i' : ''
256449
+ try {
256450
+ var regExp = new RegExp('^' + re + '$', flags)
256451
+ } catch (er) {
256452
+ // If it was an invalid regular expression, then it can't match
256453
+ // anything. This trick looks for a character after the end of
256454
+ // the string, which is of course impossible, except in multi-line
256455
+ // mode, but it's not a /m regex.
256456
+ return new RegExp('$.')
256457
+ }
256458
+
256459
+ regExp._glob = pattern
256460
+ regExp._src = re
256461
+
256462
+ return regExp
256463
+ }
256464
+
256465
+ minimatch.makeRe = function (pattern, options) {
256466
+ return new Minimatch(pattern, options || {}).makeRe()
256467
+ }
256468
+
256469
+ Minimatch.prototype.makeRe = makeRe
256470
+ function makeRe () {
256471
+ if (this.regexp || this.regexp === false) return this.regexp
256472
+
256473
+ // at this point, this.set is a 2d array of partial
256474
+ // pattern strings, or "**".
256475
+ //
256476
+ // It's better to use .match(). This function shouldn't
256477
+ // be used, really, but it's pretty convenient sometimes,
256478
+ // when you just want to work with a regex.
256479
+ var set = this.set
256480
+
256481
+ if (!set.length) {
256482
+ this.regexp = false
256483
+ return this.regexp
256484
+ }
256485
+ var options = this.options
256486
+
256487
+ var twoStar = options.noglobstar ? star
256488
+ : options.dot ? twoStarDot
256489
+ : twoStarNoDot
256490
+ var flags = options.nocase ? 'i' : ''
256491
+
256492
+ var re = set.map(function (pattern) {
256493
+ return pattern.map(function (p) {
256494
+ return (p === GLOBSTAR) ? twoStar
256495
+ : (typeof p === 'string') ? regExpEscape(p)
256496
+ : p._src
256497
+ }).join('\\\/')
256498
+ }).join('|')
256499
+
256500
+ // must match entire pattern
256501
+ // ending in a * or ** will make it less strict.
256502
+ re = '^(?:' + re + ')$'
256503
+
256504
+ // can match anything, as long as it's not this.
256505
+ if (this.negate) re = '^(?!' + re + ').*$'
256506
+
256507
+ try {
256508
+ this.regexp = new RegExp(re, flags)
256509
+ } catch (ex) {
256510
+ this.regexp = false
256511
+ }
256512
+ return this.regexp
256513
+ }
256514
+
256515
+ minimatch.match = function (list, pattern, options) {
256516
+ options = options || {}
256517
+ var mm = new Minimatch(pattern, options)
256518
+ list = list.filter(function (f) {
256519
+ return mm.match(f)
256520
+ })
256521
+ if (mm.options.nonull && !list.length) {
256522
+ list.push(pattern)
256523
+ }
256524
+ return list
256525
+ }
256526
+
256527
+ Minimatch.prototype.match = match
256528
+ function match (f, partial) {
256529
+ this.debug('match', f, this.pattern)
256530
+ // short-circuit in the case of busted things.
256531
+ // comments, etc.
256532
+ if (this.comment) return false
256533
+ if (this.empty) return f === ''
256534
+
256535
+ if (f === '/' && partial) return true
256536
+
256537
+ var options = this.options
256538
+
256539
+ // windows: need to use /, not \
256540
+ if (path.sep !== '/') {
256541
+ f = f.split(path.sep).join('/')
256542
+ }
256543
+
256544
+ // treat the test path as a set of pathparts.
256545
+ f = f.split(slashSplit)
256546
+ this.debug(this.pattern, 'split', f)
256547
+
256548
+ // just ONE of the pattern sets in this.set needs to match
256549
+ // in order for it to be valid. If negating, then just one
256550
+ // match means that we have failed.
256551
+ // Either way, return on the first hit.
256552
+
256553
+ var set = this.set
256554
+ this.debug(this.pattern, 'set', set)
256555
+
256556
+ // Find the basename of the path by looking for the last non-empty segment
256557
+ var filename
256558
+ var i
256559
+ for (i = f.length - 1; i >= 0; i--) {
256560
+ filename = f[i]
256561
+ if (filename) break
256562
+ }
256563
+
256564
+ for (i = 0; i < set.length; i++) {
256565
+ var pattern = set[i]
256566
+ var file = f
256567
+ if (options.matchBase && pattern.length === 1) {
256568
+ file = [filename]
256569
+ }
256570
+ var hit = this.matchOne(file, pattern, partial)
256571
+ if (hit) {
256572
+ if (options.flipNegate) return true
256573
+ return !this.negate
256574
+ }
256575
+ }
256576
+
256577
+ // didn't get any hits. this is success if it's a negative
256578
+ // pattern, failure otherwise.
256579
+ if (options.flipNegate) return false
256580
+ return this.negate
256581
+ }
256582
+
256583
+ // set partial to true to test if, for example,
256584
+ // "/a/b" matches the start of "/*/b/*/d"
256585
+ // Partial means, if you run out of file before you run
256586
+ // out of pattern, then that's fine, as long as all
256587
+ // the parts match.
256588
+ Minimatch.prototype.matchOne = function (file, pattern, partial) {
256589
+ var options = this.options
256590
+
256591
+ this.debug('matchOne',
256592
+ { 'this': this, file: file, pattern: pattern })
256593
+
256594
+ this.debug('matchOne', file.length, pattern.length)
256595
+
256596
+ for (var fi = 0,
256597
+ pi = 0,
256598
+ fl = file.length,
256599
+ pl = pattern.length
256600
+ ; (fi < fl) && (pi < pl)
256601
+ ; fi++, pi++) {
256602
+ this.debug('matchOne loop')
256603
+ var p = pattern[pi]
256604
+ var f = file[fi]
256605
+
256606
+ this.debug(pattern, p, f)
256607
+
256608
+ // should be impossible.
256609
+ // some invalid regexp stuff in the set.
256610
+ if (p === false) return false
256611
+
256612
+ if (p === GLOBSTAR) {
256613
+ this.debug('GLOBSTAR', [pattern, p, f])
256614
+
256615
+ // "**"
256616
+ // a/**/b/**/c would match the following:
256617
+ // a/b/x/y/z/c
256618
+ // a/x/y/z/b/c
256619
+ // a/b/x/b/x/c
256620
+ // a/b/c
256621
+ // To do this, take the rest of the pattern after
256622
+ // the **, and see if it would match the file remainder.
256623
+ // If so, return success.
256624
+ // If not, the ** "swallows" a segment, and try again.
256625
+ // This is recursively awful.
256626
+ //
256627
+ // a/**/b/**/c matching a/b/x/y/z/c
256628
+ // - a matches a
256629
+ // - doublestar
256630
+ // - matchOne(b/x/y/z/c, b/**/c)
256631
+ // - b matches b
256632
+ // - doublestar
256633
+ // - matchOne(x/y/z/c, c) -> no
256634
+ // - matchOne(y/z/c, c) -> no
256635
+ // - matchOne(z/c, c) -> no
256636
+ // - matchOne(c, c) yes, hit
256637
+ var fr = fi
256638
+ var pr = pi + 1
256639
+ if (pr === pl) {
256640
+ this.debug('** at the end')
256641
+ // a ** at the end will just swallow the rest.
256642
+ // We have found a match.
256643
+ // however, it will not swallow /.x, unless
256644
+ // options.dot is set.
256645
+ // . and .. are *never* matched by **, for explosively
256646
+ // exponential reasons.
256647
+ for (; fi < fl; fi++) {
256648
+ if (file[fi] === '.' || file[fi] === '..' ||
256649
+ (!options.dot && file[fi].charAt(0) === '.')) return false
256650
+ }
256651
+ return true
256652
+ }
256653
+
256654
+ // ok, let's see if we can swallow whatever we can.
256655
+ while (fr < fl) {
256656
+ var swallowee = file[fr]
256657
+
256658
+ this.debug('\nglobstar while', file, fr, pattern, pr, swallowee)
256659
+
256660
+ // XXX remove this slice. Just pass the start index.
256661
+ if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
256662
+ this.debug('globstar found match!', fr, fl, swallowee)
256663
+ // found a match.
256664
+ return true
256665
+ } else {
256666
+ // can't swallow "." or ".." ever.
256667
+ // can only swallow ".foo" when explicitly asked.
256668
+ if (swallowee === '.' || swallowee === '..' ||
256669
+ (!options.dot && swallowee.charAt(0) === '.')) {
256670
+ this.debug('dot detected!', file, fr, pattern, pr)
256671
+ break
256672
+ }
256673
+
256674
+ // ** swallows a segment, and continue.
256675
+ this.debug('globstar swallow a segment, and continue')
256676
+ fr++
256677
+ }
256678
+ }
256679
+
256680
+ // no match was found.
256681
+ // However, in partial mode, we can't say this is necessarily over.
256682
+ // If there's more *pattern* left, then
256683
+ if (partial) {
256684
+ // ran out of file
256685
+ this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
256686
+ if (fr === fl) return true
256687
+ }
256688
+ return false
256689
+ }
256690
+
256691
+ // something other than **
256692
+ // non-magic patterns just have to match exactly
256693
+ // patterns with magic have been turned into regexps.
256694
+ var hit
256695
+ if (typeof p === 'string') {
256696
+ if (options.nocase) {
256697
+ hit = f.toLowerCase() === p.toLowerCase()
256698
+ } else {
256699
+ hit = f === p
256700
+ }
256701
+ this.debug('string match', p, f, hit)
256702
+ } else {
256703
+ hit = f.match(p)
256704
+ this.debug('pattern match', p, f, hit)
256705
+ }
256706
+
256707
+ if (!hit) return false
256708
+ }
256709
+
256710
+ // Note: ending in / means that we'll get a final ""
256711
+ // at the end of the pattern. This can only match a
256712
+ // corresponding "" at the end of the file.
256713
+ // If the file ends in /, then it can only match a
256714
+ // a pattern that ends in /, unless the pattern just
256715
+ // doesn't have any more for it. But, a/b/ should *not*
256716
+ // match "a/b/*", even though "" matches against the
256717
+ // [^/]*? pattern, except in partial mode, where it might
256718
+ // simply not be reached yet.
256719
+ // However, a/b/ should still satisfy a/*
256720
+
256721
+ // now either we fell off the end of the pattern, or we're done.
256722
+ if (fi === fl && pi === pl) {
256723
+ // ran out of pattern and filename at the same time.
256724
+ // an exact hit!
256725
+ return true
256726
+ } else if (fi === fl) {
256727
+ // ran out of file, but still had pattern left.
256728
+ // this is ok if we're doing the match as part of
256729
+ // a glob fs traversal.
256730
+ return partial
256731
+ } else if (pi === pl) {
256732
+ // ran out of pattern, still have file left.
256733
+ // this is only acceptable if we're on the very last
256734
+ // empty segment of a file with a trailing slash.
256735
+ // a/* should match a/b/
256736
+ var emptyFileEnd = (fi === fl - 1) && (file[fi] === '')
256737
+ return emptyFileEnd
256738
+ }
256739
+
256740
+ // should be unreachable.
256741
+ throw new Error('wtf?')
256742
+ }
256743
+
256744
+ // replace stuff like \* with *
256745
+ function globUnescape (s) {
256746
+ return s.replace(/\\(.)/g, '$1')
256747
+ }
256748
+
256749
+ function regExpEscape (s) {
256750
+ return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
256751
+ }
256752
+
256753
+
255824
256754
  /***/ }),
255825
256755
 
255826
256756
  /***/ 47345:
@@ -300924,7 +301854,7 @@ var __webpack_unused_export__;
300924
301854
 
300925
301855
  __webpack_unused_export__ = ({ value: true });
300926
301856
  exports.M = void 0;
300927
- const babel = __webpack_require__(60861); // eslint-disable-line @typescript-eslint/no-var-requires
301857
+ const babel = __webpack_require__(60861); // eslint-disable-line @typescript-eslint/no-var-requires
300928
301858
  // eslint-disable-next-line @typescript-eslint/no-var-requires
300929
301859
  const pluginTransformModulesCommonJs = __webpack_require__(16846);
300930
301860
  function compile(filename, source) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/node",
3
- "version": "2.9.10",
3
+ "version": "2.9.13",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
@@ -31,9 +31,9 @@
31
31
  "dependencies": {
32
32
  "@edge-runtime/vm": "2.0.0",
33
33
  "@types/node": "14.18.33",
34
- "@vercel/build-utils": "6.3.2",
34
+ "@vercel/build-utils": "6.4.0",
35
35
  "@vercel/node-bridge": "3.1.14",
36
- "@vercel/static-config": "2.0.13",
36
+ "@vercel/static-config": "2.0.14",
37
37
  "edge-runtime": "2.0.0",
38
38
  "esbuild": "0.14.47",
39
39
  "exit-hook": "2.2.1",
@@ -64,5 +64,5 @@
64
64
  "test-listen": "1.1.0",
65
65
  "ts-morph": "12.0.0"
66
66
  },
67
- "gitHead": "803a9363f93c3f2be0f0ea2bce3ba64eefa78e04"
67
+ "gitHead": "b2c68f1301b6a5eb41b6261b7faac6a8fa4c53eb"
68
68
  }