vercel 54.14.0 → 54.14.2
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/chunks/{add-PVEKZBHH.js → add-PKT6ULVJ.js} +9 -9
- package/dist/chunks/{chunk-Y76J3TGD.js → chunk-2HN6DLIY.js} +1 -1
- package/dist/chunks/{chunk-FPRA7U2P.js → chunk-2XEEOHHH.js} +1 -1
- package/dist/chunks/{chunk-TH555JND.js → chunk-2ZSXQQXI.js} +15 -42
- package/dist/chunks/{chunk-6D6CSOSK.js → chunk-372SHB43.js} +86 -62
- package/dist/chunks/{chunk-4KAFHBYE.js → chunk-3BR246Y6.js} +1 -1
- package/dist/chunks/{chunk-V2WFM23D.js → chunk-4BFK3C7V.js} +2 -2
- package/dist/chunks/{chunk-FMN3NXRC.js → chunk-56AJHIQC.js} +1 -1
- package/dist/chunks/chunk-64IF634X.js +18 -0
- package/dist/chunks/{chunk-VNUNCNPE.js → chunk-AWD3IGXU.js} +3 -3
- package/dist/chunks/{chunk-5SYDEK2N.js → chunk-D7MGZH35.js} +1 -1
- package/dist/chunks/{chunk-IQQJHYW4.js → chunk-DPS62LHL.js} +2 -2
- package/dist/chunks/{chunk-RWJORLQP.js → chunk-FEYVO2US.js} +59 -17
- package/dist/chunks/{chunk-ABOX5TXU.js → chunk-FLW73SZ3.js} +3 -3
- package/dist/chunks/{chunk-Z7KOKD2G.js → chunk-G3NXHUFT.js} +1 -1
- package/dist/chunks/{chunk-CO5D46AG.js → chunk-GGP5R3FU.js} +18 -38
- package/dist/chunks/{chunk-J5273CSE.js → chunk-HIYWSGI7.js} +19 -10
- package/dist/chunks/{chunk-WFRHKZFI.js → chunk-IB56QKCM.js} +1 -1
- package/dist/chunks/{chunk-ZTPOJE63.js → chunk-IJJOI63T.js} +1 -1
- package/dist/chunks/{chunk-DAASB6YQ.js → chunk-ILJH44MK.js} +23 -3
- package/dist/chunks/{chunk-V4GROAUJ.js → chunk-IPWWE7PB.js} +4 -7
- package/dist/chunks/{chunk-G7QWUIGS.js → chunk-J7BMPRCU.js} +3 -3
- package/dist/chunks/{chunk-7OZWGXPA.js → chunk-JISJDGJF.js} +2 -2
- package/dist/chunks/{chunk-5UCWXYNH.js → chunk-LQR3CHMH.js} +88 -46
- package/dist/chunks/{chunk-4NDOMD3E.js → chunk-LYCSVJIX.js} +1 -1
- package/dist/chunks/{chunk-6IQZVQV6.js → chunk-MYWLF3BZ.js} +18 -0
- package/dist/chunks/{chunk-6K3WJDFA.js → chunk-O4V7CMVO.js} +10 -10
- package/dist/chunks/{chunk-KJ5O7JQQ.js → chunk-O7RJHL34.js} +81 -86
- package/dist/chunks/{chunk-C3VH3X5Y.js → chunk-OHIZ4SVU.js} +4 -4
- package/dist/chunks/{chunk-JFWE5ORG.js → chunk-P4KQ3FJ4.js} +1 -0
- package/dist/chunks/{chunk-PV533MBH.js → chunk-PMUUPCDL.js} +1 -1
- package/dist/chunks/{chunk-OEM7RB3X.js → chunk-SDZ5ICZL.js} +2 -2
- package/dist/chunks/{chunk-NGRSQRSN.js → chunk-SGPBULVT.js} +1 -1
- package/dist/chunks/{chunk-RM4XGGZO.js → chunk-TSENBD7C.js} +2 -2
- package/dist/chunks/{chunk-O4C4A7HM.js → chunk-VKRW77HH.js} +1 -1
- package/dist/chunks/chunk-VXYGCOKL.js +28 -0
- package/dist/chunks/{chunk-7CJZCFLW.js → chunk-YLGMXYFG.js} +2 -2
- package/dist/chunks/{chunk-B6C7NMT3.js → chunk-Z2MBXYZZ.js} +1 -1
- package/dist/chunks/{chunk-S4VHXL2Y.js → chunk-Z3X747P6.js} +1 -1
- package/dist/chunks/{compile-vercel-config-MD37D2F7.js → compile-vercel-config-3LV7J3IZ.js} +4 -4
- package/dist/chunks/{delete-6EMDCXSA.js → delete-GFW6Y6TZ.js} +10 -8
- package/dist/chunks/{disable-FLJ27NHG.js → disable-PGRAS2ZL.js} +10 -8
- package/dist/chunks/{discard-KEIII6RM.js → discard-S6N5Q4G5.js} +10 -8
- package/dist/chunks/{edit-DOL2ZJPG.js → edit-TICKX4ZV.js} +12 -10
- package/dist/chunks/{enable-PZWZIETT.js → enable-L3BYWN6S.js} +10 -8
- package/dist/chunks/{export-2PFHAELC.js → export-NXS33U5T.js} +6 -6
- package/dist/chunks/{inspect-WPWOZJ2K.js → inspect-OOI5JN3Y.js} +9 -9
- package/dist/chunks/{list-4R5DCLTB.js → list-6EHRL2D4.js} +7 -7
- package/dist/chunks/{list-ZT7QK2H7.js → list-77WL6463.js} +11 -11
- package/dist/chunks/{ls-4JTXQXMQ.js → ls-PBSOEXFG.js} +9 -9
- package/dist/chunks/{publish-JV4J3SOA.js → publish-CU2THVYW.js} +10 -8
- package/dist/chunks/{query-N22EYSZZ.js → query-HEATRYAK.js} +99 -43
- package/dist/chunks/{reorder-TG53BKW4.js → reorder-IQVKSM3H.js} +10 -8
- package/dist/chunks/{restore-U7O4VESA.js → restore-RDEOBGAS.js} +10 -8
- package/dist/chunks/{rm-XA4LYZXI.js → rm-MCSGTU4J.js} +9 -9
- package/dist/chunks/{routes-EAMQVFU2.js → routes-YEU33SON.js} +2 -2
- package/dist/chunks/{rule-inspect-HC745CYT.js → rule-inspect-3YK2XSL3.js} +9 -9
- package/dist/chunks/{rules-RMN72YHN.js → rules-F4MRDDHM.js} +6 -6
- package/dist/chunks/{schema-CZVKUXM6.js → schema-65C5EBJ7.js} +9 -9
- package/dist/chunks/{stamp-ENIXDCRO.js → stamp-AA7R3MZS.js} +3 -1
- package/dist/chunks/{types-P6JKZFEY.js → types-3R7HKP57.js} +3 -3
- package/dist/chunks/{update-PU3WLIA7.js → update-XB4WSRGY.js} +9 -9
- package/dist/commands/build/index.js +18 -16
- package/dist/commands/deploy/index.js +30 -171
- package/dist/commands/dev/index.js +187 -133
- package/dist/commands/dev/next-dev-websocket-shim-preload.cjs +190 -0
- package/dist/commands/env/index.js +162 -101
- package/dist/commands/link/index.js +19 -19
- package/dist/commands/list/index.js +13 -11
- package/dist/commands-bulk.js +258 -104
- package/dist/help.js +1 -1
- package/dist/index.js +27 -27
- package/dist/version.mjs +1 -1
- package/package.json +11 -11
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const http = require('node:http');
|
|
4
|
+
const { AsyncLocalStorage } = require('node:async_hooks');
|
|
5
|
+
|
|
6
|
+
const REQUEST_CONTEXT_SYMBOL = Symbol.for('@vercel/request-context');
|
|
7
|
+
const PATCHED_SYMBOL = Symbol.for('@vercel/next-dev-websocket-shim/patched');
|
|
8
|
+
const UPGRADE_LISTENER_SYMBOL = Symbol.for(
|
|
9
|
+
'@vercel/next-dev-websocket-shim/upgrade-listener'
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
if (!globalThis[PATCHED_SYMBOL]) {
|
|
13
|
+
globalThis[PATCHED_SYMBOL] = true;
|
|
14
|
+
|
|
15
|
+
const requestContext = new AsyncLocalStorage();
|
|
16
|
+
const previousRequestContext = globalThis[REQUEST_CONTEXT_SYMBOL];
|
|
17
|
+
|
|
18
|
+
Object.defineProperty(globalThis, REQUEST_CONTEXT_SYMBOL, {
|
|
19
|
+
enumerable: false,
|
|
20
|
+
configurable: true,
|
|
21
|
+
value: {
|
|
22
|
+
get: () => requestContext.getStore() ?? previousRequestContext?.get?.(),
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const originalEmit = http.Server.prototype.emit;
|
|
27
|
+
const originalListen = http.Server.prototype.listen;
|
|
28
|
+
|
|
29
|
+
http.Server.prototype.listen = function listen(...args) {
|
|
30
|
+
if (!this[UPGRADE_LISTENER_SYMBOL]) {
|
|
31
|
+
this[UPGRADE_LISTENER_SYMBOL] = true;
|
|
32
|
+
this.on('upgrade', noop);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return originalListen.apply(this, args);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
http.Server.prototype.emit = function emit(
|
|
39
|
+
event,
|
|
40
|
+
req,
|
|
41
|
+
socket,
|
|
42
|
+
head,
|
|
43
|
+
...args
|
|
44
|
+
) {
|
|
45
|
+
if (
|
|
46
|
+
event !== 'upgrade' ||
|
|
47
|
+
!isWebSocketUpgrade(req) ||
|
|
48
|
+
isNextInternalUpgrade(req)
|
|
49
|
+
) {
|
|
50
|
+
return originalEmit.call(this, event, req, socket, head, ...args);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const requestListeners = this.listeners('request');
|
|
54
|
+
if (requestListeners.length === 0) {
|
|
55
|
+
return originalEmit.call(this, event, req, socket, head, ...args);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const response = new http.ServerResponse(req);
|
|
59
|
+
|
|
60
|
+
return emitWebSocketRequest({
|
|
61
|
+
server: this,
|
|
62
|
+
req,
|
|
63
|
+
response,
|
|
64
|
+
socket,
|
|
65
|
+
head: head || Buffer.alloc(0),
|
|
66
|
+
requestContext,
|
|
67
|
+
originalEmit,
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function emitWebSocketRequest({
|
|
73
|
+
server,
|
|
74
|
+
req,
|
|
75
|
+
response,
|
|
76
|
+
socket,
|
|
77
|
+
head,
|
|
78
|
+
requestContext,
|
|
79
|
+
originalEmit,
|
|
80
|
+
}) {
|
|
81
|
+
socket.setTimeout(0);
|
|
82
|
+
socket.setNoDelay(true);
|
|
83
|
+
|
|
84
|
+
if (typeof response.assignSocket === 'function' && !response.socket) {
|
|
85
|
+
response.assignSocket(socket);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const abortController = new AbortController();
|
|
89
|
+
let consumed = false;
|
|
90
|
+
const context = {
|
|
91
|
+
waitUntil: promiseOrFunc => {
|
|
92
|
+
const promise =
|
|
93
|
+
typeof promiseOrFunc === 'function' ? promiseOrFunc() : promiseOrFunc;
|
|
94
|
+
Promise.resolve(promise).catch(() => {});
|
|
95
|
+
},
|
|
96
|
+
headers: Object.fromEntries(
|
|
97
|
+
Object.entries(req.headers).map(([key, value]) => [
|
|
98
|
+
key,
|
|
99
|
+
Array.isArray(value) ? value.join(',') : value,
|
|
100
|
+
])
|
|
101
|
+
),
|
|
102
|
+
method: req.method || 'GET',
|
|
103
|
+
url: new URL(req.url || '/', getRequestOrigin(req)).toString(),
|
|
104
|
+
signal: abortController.signal,
|
|
105
|
+
upgradeWebSocket: () => {
|
|
106
|
+
if (consumed) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
'ctx.upgradeWebSocket() can only be called once per request'
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
consumed = true;
|
|
112
|
+
|
|
113
|
+
if (typeof response.detachSocket === 'function') {
|
|
114
|
+
response.detachSocket(socket);
|
|
115
|
+
}
|
|
116
|
+
suppressFrameworkResponse(response);
|
|
117
|
+
preserveAsyncContextOnSocket(socket, requestContext);
|
|
118
|
+
|
|
119
|
+
socket.once('close', () => {
|
|
120
|
+
requestContext.run(context, () => {
|
|
121
|
+
req.emit('aborted');
|
|
122
|
+
abortController.abort();
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
socket.once('error', noop);
|
|
126
|
+
|
|
127
|
+
return { req, socket, head };
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
requestContext.run(context, () => {
|
|
132
|
+
try {
|
|
133
|
+
originalEmit.call(server, 'request', req, response);
|
|
134
|
+
} catch (error) {
|
|
135
|
+
socket.destroy(error);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function isWebSocketUpgrade(req) {
|
|
143
|
+
const connection = req?.headers?.connection;
|
|
144
|
+
const upgrade = req?.headers?.upgrade;
|
|
145
|
+
return (
|
|
146
|
+
typeof connection === 'string' &&
|
|
147
|
+
connection
|
|
148
|
+
.split(',')
|
|
149
|
+
.some(token => token.trim().toLowerCase() === 'upgrade') &&
|
|
150
|
+
typeof upgrade === 'string' &&
|
|
151
|
+
upgrade.split(',').some(token => token.trim().toLowerCase() === 'websocket')
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function isNextInternalUpgrade(req) {
|
|
156
|
+
const pathname = new URL(req?.url || '/', 'http://localhost').pathname;
|
|
157
|
+
return pathname.includes('/_next/') || pathname.startsWith('/__nextjs');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function suppressFrameworkResponse(response) {
|
|
161
|
+
response.writeHead = function writeHead() {
|
|
162
|
+
return this;
|
|
163
|
+
};
|
|
164
|
+
response.write = function write() {
|
|
165
|
+
return true;
|
|
166
|
+
};
|
|
167
|
+
response.end = function end() {
|
|
168
|
+
return this;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function preserveAsyncContextOnSocket(socket, requestContext) {
|
|
173
|
+
const store = requestContext.getStore();
|
|
174
|
+
const runInSnapshot =
|
|
175
|
+
typeof AsyncLocalStorage.snapshot === 'function'
|
|
176
|
+
? AsyncLocalStorage.snapshot()
|
|
177
|
+
: callback => requestContext.run(store, callback);
|
|
178
|
+
const originalEmit = socket.emit;
|
|
179
|
+
socket.emit = function emit(...args) {
|
|
180
|
+
return runInSnapshot(() => originalEmit.apply(this, args));
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function getRequestOrigin(req) {
|
|
185
|
+
const host = req.headers.host || 'localhost';
|
|
186
|
+
const proto = req.socket?.encrypted ? 'https' : 'http';
|
|
187
|
+
return `${proto}://${host}`;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function noop() {}
|