code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
run (callback) {
while (true) {
if (this.#state === parserStates.INFO) {
// If there aren't enough bytes to parse the payload length, etc.
if (this.#byteOffset < 2) {
return callback()
}
const buffer = this.consume(2)
this.#info.fin = (buffer[0] & 0x80) !== 0
this.#info.opcode = buffer[0] & 0x0F
// If we receive a fragmented message, we use the type of the first
// frame to parse the full message as binary/text, when it's terminated
this.#info.originalOpcode ??= this.#info.opcode
this.#info.fragmented = !this.#info.fin && this.#info.opcode !== opcodes.CONTINUATION
if (this.#info.fragmented && this.#info.opcode !== opcodes.BINARY && this.#info.opcode !== opcodes.TEXT) {
// Only text and binary frames can be fragmented
failWebsocketConnection(this.ws, 'Invalid frame type was fragmented.')
return
}
const payloadLength = buffer[1] & 0x7F
if (payloadLength <= 125) {
this.#info.payloadLength = payloadLength
this.#state = parserStates.READ_DATA
} else if (payloadLength === 126) {
this.#state = parserStates.PAYLOADLENGTH_16
} else if (payloadLength === 127) {
this.#state = parserStates.PAYLOADLENGTH_64
}
if (this.#info.fragmented && payloadLength > 125) {
// A fragmented frame can't be fragmented itself
failWebsocketConnection(this.ws, 'Fragmented frame exceeded 125 bytes.')
return
} else if (
(this.#info.opcode === opcodes.PING ||
this.#info.opcode === opcodes.PONG ||
this.#info.opcode === opcodes.CLOSE) &&
payloadLength > 125
) {
// Control frames can have a payload length of 125 bytes MAX
failWebsocketConnection(this.ws, 'Payload length for control frame exceeded 125 bytes.')
return
} else if (this.#info.opcode === opcodes.CLOSE) {
if (payloadLength === 1) {
failWebsocketConnection(this.ws, 'Received close frame with a 1-byte body.')
return
}
const body = this.consume(payloadLength)
this.#info.closeInfo = this.parseCloseBody(false, body)
if (!this.ws[kSentClose]) {
// If an endpoint receives a Close frame and did not previously send a
// Close frame, the endpoint MUST send a Close frame in response. (When
// sending a Close frame in response, the endpoint typically echos the
// status code it received.)
const body = Buffer.allocUnsafe(2)
body.writeUInt16BE(this.#info.closeInfo.code, 0)
const closeFrame = new WebsocketFrameSend(body)
this.ws[kResponse].socket.write(
closeFrame.createFrame(opcodes.CLOSE),
(err) => {
if (!err) {
this.ws[kSentClose] = true
}
}
)
}
// Upon either sending or receiving a Close control frame, it is said
// that _The WebSocket Closing Handshake is Started_ and that the
// WebSocket connection is in the CLOSING state.
this.ws[kReadyState] = states.CLOSING
this.ws[kReceivedClose] = true
this.end()
return
} else if (this.#info.opcode === opcodes.PING) {
// Upon receipt of a Ping frame, an endpoint MUST send a Pong frame in
// response, unless it already received a Close frame.
// A Pong frame sent in response to a Ping frame must have identical
// "Application data"
const body = this.consume(payloadLength)
if (!this.ws[kReceivedClose]) {
const frame = new WebsocketFrameSend(body)
this.ws[kResponse].socket.write(frame.createFrame(opcodes.PONG))
if (channels.ping.hasSubscribers) {
channels.ping.publish({
payload: body
})
}
}
this.#state = parserStates.INFO
if (this.#byteOffset > 0) {
continue
} else {
callback()
return
}
} else if (this.#info.opcode === opcodes.PONG) {
// A Pong frame MAY be sent unsolicited. This serves as a
// unidirectional heartbeat. A response to an unsolicited Pong frame is
// not expected.
const body = this.consume(payloadLength)
if (channels.pong.hasSubscribers) {
channels.pong.publish({
payload: body
})
}
if (this.#byteOffset > 0) {
continue
} else {
callback()
return
}
}
} else if (this.#state === parserStates.PAYLOADLENGTH_16) {
if (this.#byteOffset < 2) {
return callback()
}
const buffer = this.consume(2)
this.#info.payloadLength = buffer.readUInt16BE(0)
this.#state = parserStates.READ_DATA
} else if (this.#state === parserStates.PAYLOADLENGTH_64) {
if (this.#byteOffset < 8) {
return callback()
}
const buffer = this.consume(8)
const upper = buffer.readUInt32BE(0)
// 2^31 is the maxinimum bytes an arraybuffer can contain
// on 32-bit systems. Although, on 64-bit systems, this is
// 2^53-1 bytes.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_array_length
// https://source.chromium.org/chromium/chromium/src/+/main:v8/src/common/globals.h;drc=1946212ac0100668f14eb9e2843bdd846e510a1e;bpv=1;bpt=1;l=1275
// https://source.chromium.org/chromium/chromium/src/+/main:v8/src/objects/js-array-buffer.h;l=34;drc=1946212ac0100668f14eb9e2843bdd846e510a1e
if (upper > 2 ** 31 - 1) {
failWebsocketConnection(this.ws, 'Received payload length > 2^31 bytes.')
return
}
const lower = buffer.readUInt32BE(4)
this.#info.payloadLength = (upper << 8) + lower
this.#state = parserStates.READ_DATA
} else if (this.#state === parserStates.READ_DATA) {
if (this.#byteOffset < this.#info.payloadLength) {
// If there is still more data in this chunk that needs to be read
return callback()
} else if (this.#byteOffset >= this.#info.payloadLength) {
// If the server sent multiple frames in a single chunk
const body = this.consume(this.#info.payloadLength)
this.#fragments.push(body)
// If the frame is unfragmented, or a fragmented frame was terminated,
// a message was received
if (!this.#info.fragmented || (this.#info.fin && this.#info.opcode === opcodes.CONTINUATION)) {
const fullMessage = Buffer.concat(this.#fragments)
websocketMessageReceived(this.ws, this.#info.originalOpcode, fullMessage)
this.#info = {}
this.#fragments.length = 0
}
this.#state = parserStates.INFO
}
}
if (this.#byteOffset > 0) {
continue
} else {
callback()
break
}
}
}
|
Runs whenever a new chunk is received.
Callback is called whenever there are no more chunks buffering,
or not enough bytes are buffered to parse.
|
run
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
parseCloseBody (onlyCode, data) {
// https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.5
/** @type {number|undefined} */
let code
if (data.length >= 2) {
// _The WebSocket Connection Close Code_ is
// defined as the status code (Section 7.4) contained in the first Close
// control frame received by the application
code = data.readUInt16BE(0)
}
if (onlyCode) {
if (!isValidStatusCode(code)) {
return null
}
return { code }
}
// https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.6
/** @type {Buffer} */
let reason = data.subarray(2)
// Remove BOM
if (reason[0] === 0xEF && reason[1] === 0xBB && reason[2] === 0xBF) {
reason = reason.subarray(3)
}
if (code !== undefined && !isValidStatusCode(code)) {
return null
}
try {
// TODO: optimize this
reason = new TextDecoder('utf-8', { fatal: true }).decode(reason)
} catch {
return null
}
return { code, reason }
}
|
@see https://dom.spec.whatwg.org/#concept-event-fire
@param {string} e
@param {EventTarget} target
@param {EventInit | undefined} eventInitDict
|
parseCloseBody
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
get closingInfo () {
return this.#info.closeInfo
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
@param {import('./websocket').WebSocket} ws
@param {number} type Opcode
@param {Buffer} data application data
|
closingInfo
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
function isEstablished (ws) {
// If the server's response is validated as provided for above, it is
// said that _The WebSocket Connection is Established_ and that the
// WebSocket Connection is in the OPEN state.
return ws[kReadyState] === states.OPEN
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
@param {import('./websocket').WebSocket} ws
@param {number} type Opcode
@param {Buffer} data application data
|
isEstablished
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
function isClosing (ws) {
// Upon either sending or receiving a Close control frame, it is said
// that _The WebSocket Closing Handshake is Started_ and that the
// WebSocket connection is in the CLOSING state.
return ws[kReadyState] === states.CLOSING
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
@param {import('./websocket').WebSocket} ws
@param {number} type Opcode
@param {Buffer} data application data
|
isClosing
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
function isClosed (ws) {
return ws[kReadyState] === states.CLOSED
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
@param {import('./websocket').WebSocket} ws
@param {number} type Opcode
@param {Buffer} data application data
|
isClosed
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
function isValidStatusCode (code) {
if (code >= 1000 && code < 1015) {
return (
code !== 1004 && // reserved
code !== 1005 && // "MUST NOT be set as a status code"
code !== 1006 // "MUST NOT be set as a status code"
)
}
return code >= 3000 && code <= 4999
}
|
@param {string} url
@param {string|string[]} protocols
|
isValidStatusCode
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
function failWebsocketConnection (ws, reason) {
const { [kController]: controller, [kResponse]: response } = ws
controller.abort()
if (response?.socket && !response.socket.destroyed) {
response.socket.destroy()
}
if (reason) {
fireEvent('error', ws, ErrorEvent, {
error: new Error(reason)
})
}
}
|
@param {string} url
@param {string|string[]} protocols
|
failWebsocketConnection
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
close (code = undefined, reason = undefined) {
webidl.brandCheck(this, WebSocket)
if (code !== undefined) {
code = webidl.converters['unsigned short'](code, { clamp: true })
}
if (reason !== undefined) {
reason = webidl.converters.USVString(reason)
}
// 1. If code is present, but is neither an integer equal to 1000 nor an
// integer in the range 3000 to 4999, inclusive, throw an
// "InvalidAccessError" DOMException.
if (code !== undefined) {
if (code !== 1000 && (code < 3000 || code > 4999)) {
throw new DOMException('invalid code', 'InvalidAccessError')
}
}
let reasonByteLength = 0
// 2. If reason is present, then run these substeps:
if (reason !== undefined) {
// 1. Let reasonBytes be the result of encoding reason.
// 2. If reasonBytes is longer than 123 bytes, then throw a
// "SyntaxError" DOMException.
reasonByteLength = Buffer.byteLength(reason)
if (reasonByteLength > 123) {
throw new DOMException(
`Reason must be less than 123 bytes; received ${reasonByteLength}`,
'SyntaxError'
)
}
}
// 3. Run the first matching steps from the following list:
if (this[kReadyState] === WebSocket.CLOSING || this[kReadyState] === WebSocket.CLOSED) {
// If this's ready state is CLOSING (2) or CLOSED (3)
// Do nothing.
} else if (!isEstablished(this)) {
// If the WebSocket connection is not yet established
// Fail the WebSocket connection and set this's ready state
// to CLOSING (2).
failWebsocketConnection(this, 'Connection was closed before it was established.')
this[kReadyState] = WebSocket.CLOSING
} else if (!isClosing(this)) {
// If the WebSocket closing handshake has not yet been started
// Start the WebSocket closing handshake and set this's ready
// state to CLOSING (2).
// - If neither code nor reason is present, the WebSocket Close
// message must not have a body.
// - If code is present, then the status code to use in the
// WebSocket Close message must be the integer given by code.
// - If reason is also present, then reasonBytes must be
// provided in the Close message after the status code.
const frame = new WebsocketFrameSend()
// If neither code nor reason is present, the WebSocket Close
// message must not have a body.
// If code is present, then the status code to use in the
// WebSocket Close message must be the integer given by code.
if (code !== undefined && reason === undefined) {
frame.frameData = Buffer.allocUnsafe(2)
frame.frameData.writeUInt16BE(code, 0)
} else if (code !== undefined && reason !== undefined) {
// If reason is also present, then reasonBytes must be
// provided in the Close message after the status code.
frame.frameData = Buffer.allocUnsafe(2 + reasonByteLength)
frame.frameData.writeUInt16BE(code, 0)
// the body MAY contain UTF-8-encoded data with value /reason/
frame.frameData.write(reason, 2, 'utf-8')
} else {
frame.frameData = emptyBuffer
}
/** @type {import('stream').Duplex} */
const socket = this[kResponse].socket
socket.write(frame.createFrame(opcodes.CLOSE), (err) => {
if (!err) {
this[kSentClose] = true
}
})
// Upon either sending or receiving a Close control frame, it is said
// that _The WebSocket Closing Handshake is Started_ and that the
// WebSocket connection is in the CLOSING state.
this[kReadyState] = states.CLOSING
} else {
// Otherwise
// Set this's ready state to CLOSING (2).
this[kReadyState] = WebSocket.CLOSING
}
}
|
@see https://websockets.spec.whatwg.org/#dom-websocket-close
@param {number|undefined} code
@param {string|undefined} reason
|
close
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
get readyState () {
webidl.brandCheck(this, WebSocket)
// The readyState getter steps are to return this's ready state.
return this[kReadyState]
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
readyState
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
get bufferedAmount () {
webidl.brandCheck(this, WebSocket)
return this.#bufferedAmount
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
bufferedAmount
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
get url () {
webidl.brandCheck(this, WebSocket)
// The url getter steps are to return this's url, serialized.
return URLSerializer(this[kWebSocketURL])
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
url
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
get extensions () {
webidl.brandCheck(this, WebSocket)
return this.#extensions
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
extensions
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
get protocol () {
webidl.brandCheck(this, WebSocket)
return this.#protocol
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
protocol
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
get onopen () {
webidl.brandCheck(this, WebSocket)
return this.#events.open
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
onopen
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
set onopen (fn) {
webidl.brandCheck(this, WebSocket)
if (this.#events.open) {
this.removeEventListener('open', this.#events.open)
}
if (typeof fn === 'function') {
this.#events.open = fn
this.addEventListener('open', fn)
} else {
this.#events.open = null
}
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
onopen
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
get onerror () {
webidl.brandCheck(this, WebSocket)
return this.#events.error
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
onerror
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
set onerror (fn) {
webidl.brandCheck(this, WebSocket)
if (this.#events.error) {
this.removeEventListener('error', this.#events.error)
}
if (typeof fn === 'function') {
this.#events.error = fn
this.addEventListener('error', fn)
} else {
this.#events.error = null
}
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
onerror
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
get onclose () {
webidl.brandCheck(this, WebSocket)
return this.#events.close
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
onclose
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
set onclose (fn) {
webidl.brandCheck(this, WebSocket)
if (this.#events.close) {
this.removeEventListener('close', this.#events.close)
}
if (typeof fn === 'function') {
this.#events.close = fn
this.addEventListener('close', fn)
} else {
this.#events.close = null
}
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
onclose
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
get onmessage () {
webidl.brandCheck(this, WebSocket)
return this.#events.message
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
onmessage
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
set onmessage (fn) {
webidl.brandCheck(this, WebSocket)
if (this.#events.message) {
this.removeEventListener('message', this.#events.message)
}
if (typeof fn === 'function') {
this.#events.message = fn
this.addEventListener('message', fn)
} else {
this.#events.message = null
}
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
onmessage
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
get binaryType () {
webidl.brandCheck(this, WebSocket)
return this[kBinaryType]
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
binaryType
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
set binaryType (type) {
webidl.brandCheck(this, WebSocket)
if (type !== 'blob' && type !== 'arraybuffer') {
this[kBinaryType] = 'blob'
} else {
this[kBinaryType] = type
}
}
|
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
binaryType
|
javascript
|
vercel/next.js
|
.github/actions/next-integration-stat/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
|
MIT
|
async linkPackages({
repoDir,
nextSwcVersion: nextSwcVersionSpecified,
parentSpan,
}) {
if (!parentSpan) {
// Not all callers provide a parent span
parentSpan = mockSpan()
}
/** @type {Map<string, string>} */
const pkgPaths = new Map()
/** @type {Map<string, { packageJsonPath: string, packagePath: string, packageJson: any, packedPackageTarPath: string }>} */
const pkgDatas = new Map()
let packageFolders
try {
packageFolders = await parentSpan
.traceChild('read-packages-folder')
.traceAsyncFn(() =>
fs.promises.readdir(path.join(repoDir, 'packages'))
)
} catch (err) {
if (err.code === 'ENOENT') {
require('console').log('no packages to link')
return pkgPaths
}
throw err
}
parentSpan.traceChild('get-pkgdatas').traceFn(() => {
for (const packageFolder of packageFolders) {
const packagePath = path.join(repoDir, 'packages', packageFolder)
const packedPackageTarPath = path.join(
packagePath,
`${packageFolder}-packed.tgz`
)
const packageJsonPath = path.join(packagePath, 'package.json')
if (!existsSync(packageJsonPath)) {
require('console').log(`Skipping ${packageFolder}, no package.json`)
continue
}
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath))
const { name: packageName } = packageJson
pkgDatas.set(packageName, {
packageJsonPath,
packagePath,
packageJson,
packedPackageTarPath,
})
pkgPaths.set(packageName, packedPackageTarPath)
}
})
const nextSwcVersion =
nextSwcVersionSpecified ??
pkgDatas.get('@next/swc')?.packedPackageTarPath ??
null
await parentSpan
.traceChild('write-packagejson')
.traceAsyncFn(async () => {
for (const [
packageName,
{ packageJsonPath, packagePath, packageJson },
] of pkgDatas.entries()) {
// This loops through all items to get the packagedPkgPath of each item and add it to pkgData.dependencies
for (const [
packageName,
{ packedPackageTarPath },
] of pkgDatas.entries()) {
if (
!packageJson.dependencies ||
!packageJson.dependencies[packageName]
)
continue
// Edit the pkgData of the current item to point to the packed tgz
packageJson.dependencies[packageName] = packedPackageTarPath
}
// make sure native binaries are included in local linking
if (packageName === '@next/swc') {
packageJson.files ||= []
packageJson.files.push('native')
try {
const swcBinariesDirContents = (
await fs.promises.readdir(path.join(packagePath, 'native'))
).filter(
(file) => file !== '.gitignore' && file !== 'index.d.ts'
)
require('console').log(
'using swc binaries: ',
swcBinariesDirContents.join(', ')
)
} catch (err) {
if (err.code === 'ENOENT') {
require('console').log('swc binaries dir is missing!')
}
throw err
}
} else if (packageName === 'next') {
const nextSwcPkg = pkgDatas.get('@next/swc')
console.log('using swc dep', {
nextSwcVersion,
nextSwcPkg,
})
if (nextSwcVersion) {
Object.assign(packageJson.dependencies, {
// CI
'@next/swc-linux-x64-gnu': nextSwcVersion,
// Vercel issued laptops
'@next/swc-darwin-arm64': nextSwcVersion,
})
}
}
await fs.promises.writeFile(
packageJsonPath,
JSON.stringify(packageJson, null, 2),
'utf8'
)
}
})
await parentSpan
.traceChild('pnpm-packing')
.traceAsyncFn(async (packingSpan) => {
// wait to pack packages until after dependency paths have been updated
// to the correct versions
await Promise.all(
Array.from(pkgDatas.entries()).map(
async ([
packageName,
{ packagePath: pkgPath, packedPackageTarPath: packedPkgPath },
]) => {
return packingSpan
.traceChild('handle-package', { packageName })
.traceAsyncFn(async (handlePackageSpan) => {
/** @type {null | () => Promise<void>} */
let cleanup = null
if (packageName === '@next/swc') {
// next-swc uses a gitignore to prevent the committing of native builds but it doesn't
// use files in package.json because it publishes to individual packages based on architecture.
// When we used yarn to pack these packages the gitignore was ignored so the native builds were packed
// however npm does respect gitignore when packing so we need to remove it in this specific case
// to ensure the native builds are packed for use in gh actions and related scripts
const nativeGitignorePath = path.join(
pkgPath,
'native/.gitignore'
)
const renamedGitignorePath = path.join(
pkgPath,
'disabled-native-gitignore'
)
await handlePackageSpan
.traceChild('rename-gitignore')
.traceAsyncFn(() =>
fs.promises.rename(
nativeGitignorePath,
renamedGitignorePath
)
)
cleanup = async () => {
await fs.promises.rename(
renamedGitignorePath,
nativeGitignorePath
)
}
}
const options = {
cwd: pkgPath,
env: {
...process.env,
COREPACK_ENABLE_STRICT: '0',
},
}
let execResult
try {
execResult = await handlePackageSpan
.traceChild('pnpm-pack-try-1')
.traceAsyncFn(() => execa('pnpm', ['pack'], options))
} catch {
execResult = await handlePackageSpan
.traceChild('pnpm-pack-try-2')
.traceAsyncFn(() => execa('pnpm', ['pack'], options))
}
const { stdout } = execResult
const packedFileName = stdout.trim()
await handlePackageSpan
.traceChild('rename-packed-tar-and-cleanup')
.traceAsyncFn(() =>
Promise.all([
fs.promises.rename(
path.join(pkgPath, packedFileName),
packedPkgPath
),
cleanup?.(),
])
)
})
}
)
)
})
return pkgPaths
}
|
Runs `pnpm pack` on each package in the `packages` folder of the provided `repoDir`
@param {{ repoDir: string, nextSwcVersion: null | string }} options Required options
@returns {Promise<Map<string, string>>} List packages key is the package name, value is the path to the packed tar file.'
|
linkPackages
|
javascript
|
vercel/next.js
|
.github/actions/next-stats-action/src/prepare/repo-setup.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/next-stats-action/src/prepare/repo-setup.js
|
MIT
|
constructor(command, opts) {
this.serialize = defaultSerializer;
this.deserialize = opts?.automaticDeserialization === void 0 || opts.automaticDeserialization ? opts?.deserialize ?? parseResponse : (x) => x;
this.command = command.map((c) => this.serialize(c));
if (opts?.latencyLogging) {
const originalExec = this.exec.bind(this);
this.exec = async (client) => {
const start = performance.now();
const result = await originalExec(client);
const end = performance.now();
const loggerResult = (end - start).toFixed(2);
console.log(
`Latency for \x1B[38;2;19;185;39m${this.command[0].toString().toUpperCase()}\x1B[0m: \x1B[38;2;0;255;255m${loggerResult} ms\x1B[0m`
);
return result;
};
}
}
|
Create a new command instance.
You can define a custom `deserialize` function. By default we try to deserialize as json.
|
constructor
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
length() {
return this.commands.length;
}
|
Returns the length of pipeline before the execution
|
length
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
chain(command) {
this.commands.push(command);
return this;
}
|
Pushes a command into the pipeline and returns a chainable instance of the
pipeline
|
chain
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
get json() {
return {
/**
* @see https://redis.io/commands/json.arrappend
*/
arrappend: (...args) => this.chain(new JsonArrAppendCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.arrindex
*/
arrindex: (...args) => this.chain(new JsonArrIndexCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.arrinsert
*/
arrinsert: (...args) => this.chain(new JsonArrInsertCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.arrlen
*/
arrlen: (...args) => this.chain(new JsonArrLenCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.arrpop
*/
arrpop: (...args) => this.chain(new JsonArrPopCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.arrtrim
*/
arrtrim: (...args) => this.chain(new JsonArrTrimCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.clear
*/
clear: (...args) => this.chain(new JsonClearCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.del
*/
del: (...args) => this.chain(new JsonDelCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.forget
*/
forget: (...args) => this.chain(new JsonForgetCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.get
*/
get: (...args) => this.chain(new JsonGetCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.mget
*/
mget: (...args) => this.chain(new JsonMGetCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.mset
*/
mset: (...args) => this.chain(new JsonMSetCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.numincrby
*/
numincrby: (...args) => this.chain(new JsonNumIncrByCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.nummultby
*/
nummultby: (...args) => this.chain(new JsonNumMultByCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.objkeys
*/
objkeys: (...args) => this.chain(new JsonObjKeysCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.objlen
*/
objlen: (...args) => this.chain(new JsonObjLenCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.resp
*/
resp: (...args) => this.chain(new JsonRespCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.set
*/
set: (...args) => this.chain(new JsonSetCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.strappend
*/
strappend: (...args) => this.chain(new JsonStrAppendCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.strlen
*/
strlen: (...args) => this.chain(new JsonStrLenCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.toggle
*/
toggle: (...args) => this.chain(new JsonToggleCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.type
*/
type: (...args) => this.chain(new JsonTypeCommand(args, this.commandOptions))
};
}
|
@see https://redis.io/commands/?group=json
|
json
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
constructor(redis, script) {
this.redis = redis;
this.sha1 = this.digest(script);
this.script = script;
}
|
@see https://redis.io/commands/json.type
|
constructor
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
async eval(keys, args) {
return await this.redis.eval(this.script, keys, args);
}
|
Send an `EVAL` command to redis.
|
eval
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
async evalsha(keys, args) {
return await this.redis.evalsha(this.sha1, keys, args);
}
|
Calculates the sha1 hash of the script and then calls `EVALSHA`.
|
evalsha
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
async exec(keys, args) {
const res = await this.redis.evalsha(this.sha1, keys, args).catch(async (error) => {
if (error instanceof Error && error.message.toLowerCase().includes("noscript")) {
return await this.redis.eval(this.script, keys, args);
}
throw error;
});
return res;
}
|
Optimistically try to run `EVALSHA` first.
If the script is not loaded in redis, it will fall back and try again with `EVAL`.
Following calls will be able to use the cached script
|
exec
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
digest(s) {
return import_enc_hex.default.stringify((0, import_sha1.default)(s));
}
|
Compute the sha1 hash of the script and return its hex representation.
|
digest
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
constructor(client, opts) {
this.client = client;
this.opts = opts;
this.enableTelemetry = opts?.enableTelemetry ?? true;
if (opts?.readYourWrites === false) {
this.client.readYourWrites = false;
}
this.enableAutoPipelining = opts?.enableAutoPipelining ?? true;
}
|
Create a new redis client
@example
```typescript
const redis = new Redis({
url: "<UPSTASH_REDIS_REST_URL>",
token: "<UPSTASH_REDIS_REST_TOKEN>",
});
```
|
constructor
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
get readYourWritesSyncToken() {
return this.client.upstashSyncToken;
}
|
Create a new redis client
@example
```typescript
const redis = new Redis({
url: "<UPSTASH_REDIS_REST_URL>",
token: "<UPSTASH_REDIS_REST_TOKEN>",
});
```
|
readYourWritesSyncToken
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
set readYourWritesSyncToken(session) {
this.client.upstashSyncToken = session;
}
|
Create a new redis client
@example
```typescript
const redis = new Redis({
url: "<UPSTASH_REDIS_REST_URL>",
token: "<UPSTASH_REDIS_REST_TOKEN>",
});
```
|
readYourWritesSyncToken
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
get json() {
return {
/**
* @see https://redis.io/commands/json.arrappend
*/
arrappend: (...args) => new JsonArrAppendCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.arrindex
*/
arrindex: (...args) => new JsonArrIndexCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.arrinsert
*/
arrinsert: (...args) => new JsonArrInsertCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.arrlen
*/
arrlen: (...args) => new JsonArrLenCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.arrpop
*/
arrpop: (...args) => new JsonArrPopCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.arrtrim
*/
arrtrim: (...args) => new JsonArrTrimCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.clear
*/
clear: (...args) => new JsonClearCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.del
*/
del: (...args) => new JsonDelCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.forget
*/
forget: (...args) => new JsonForgetCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.get
*/
get: (...args) => new JsonGetCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.mget
*/
mget: (...args) => new JsonMGetCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.mset
*/
mset: (...args) => new JsonMSetCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.numincrby
*/
numincrby: (...args) => new JsonNumIncrByCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.nummultby
*/
nummultby: (...args) => new JsonNumMultByCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.objkeys
*/
objkeys: (...args) => new JsonObjKeysCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.objlen
*/
objlen: (...args) => new JsonObjLenCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.resp
*/
resp: (...args) => new JsonRespCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.set
*/
set: (...args) => new JsonSetCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.strappend
*/
strappend: (...args) => new JsonStrAppendCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.strlen
*/
strlen: (...args) => new JsonStrLenCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.toggle
*/
toggle: (...args) => new JsonToggleCommand(args, this.opts).exec(this.client),
/**
* @see https://redis.io/commands/json.type
*/
type: (...args) => new JsonTypeCommand(args, this.opts).exec(this.client)
};
}
|
Create a new redis client
@example
```typescript
const redis = new Redis({
url: "<UPSTASH_REDIS_REST_URL>",
token: "<UPSTASH_REDIS_REST_TOKEN>",
});
```
|
json
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
createScript(script) {
return new Script(this, script);
}
|
Technically this is not private, we can hide it from intellisense by doing this
|
createScript
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
constructor(configOrRequester) {
if ("request" in configOrRequester) {
super(configOrRequester);
return;
}
if (!configOrRequester.url) {
console.warn(
`[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
);
} else if (configOrRequester.url.startsWith(" ") || configOrRequester.url.endsWith(" ") || /\r|\n/.test(configOrRequester.url)) {
console.warn(
"[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!"
);
}
if (!configOrRequester.token) {
console.warn(
`[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
);
} else if (configOrRequester.token.startsWith(" ") || configOrRequester.token.endsWith(" ") || /\r|\n/.test(configOrRequester.token)) {
console.warn(
"[Upstash Redis] The redis token contains whitespace or newline, which can cause errors!"
);
}
const client = new HttpClient({
baseUrl: configOrRequester.url,
retry: configOrRequester.retry,
headers: { authorization: `Bearer ${configOrRequester.token}` },
agent: configOrRequester.agent,
responseEncoding: configOrRequester.responseEncoding,
cache: configOrRequester.cache ?? "no-store",
signal: configOrRequester.signal,
keepAlive: configOrRequester.keepAlive,
readYourWrites: configOrRequester.readYourWrites
});
super(client, {
automaticDeserialization: configOrRequester.automaticDeserialization,
enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
latencyLogging: configOrRequester.latencyLogging,
enableAutoPipelining: configOrRequester.enableAutoPipelining
});
this.addTelemetry({
runtime: (
// @ts-expect-error to silence compiler
typeof EdgeRuntime === "string" ? "edge-light" : `node@${process.version}`
),
platform: process.env.VERCEL ? "vercel" : process.env.AWS_REGION ? "aws" : "unknown",
sdk: `@upstash/redis@${VERSION}`
});
if (this.enableAutoPipelining) {
return this.autoPipeline();
}
}
|
Create a new redis client by providing a custom `Requester` implementation
@example
```ts
import { UpstashRequest, Requester, UpstashResponse, Redis } from "@upstash/redis"
const requester: Requester = {
request: <TResult>(req: UpstashRequest): Promise<UpstashResponse<TResult>> => {
// ...
}
}
const redis = new Redis(requester)
```
|
constructor
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
static fromEnv(config) {
if (process.env === void 0) {
throw new TypeError(
'[Upstash Redis] Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead'
);
}
const url = process.env.UPSTASH_REDIS_REST_URL || process.env.KV_REST_API_URL;
if (!url) {
console.warn("[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
}
const token = process.env.UPSTASH_REDIS_REST_TOKEN || process.env.KV_REST_API_TOKEN;
if (!token) {
console.warn(
"[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`"
);
}
return new _Redis({ ...config, url, token });
}
|
Create a new Upstash Redis instance from environment variables.
Use this to automatically load connection secrets from your environment
variables. For instance when using the Vercel integration.
This tries to load `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from
your environment using `process.env`.
|
fromEnv
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
async *scanIterator(options) {
let cursor = "0";
let keys;
do {
[cursor, keys] = await this.scan(cursor, options);
for (const key of keys) {
yield key;
}
} while (cursor !== "0");
}
|
Same as `scan` but returns an AsyncIterator to allow iteration via `for await`.
|
scanIterator
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
async *hscanIterator(key, options) {
let cursor = "0";
let items;
do {
[cursor, items] = await this.hscan(key, cursor, options);
for (const item of items) {
yield item;
}
} while (cursor !== "0");
}
|
Same as `hscan` but returns an AsyncIterator to allow iteration via `for await`.
|
hscanIterator
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
async *sscanIterator(key, options) {
let cursor = "0";
let items;
do {
[cursor, items] = await this.sscan(key, cursor, options);
for (const item of items) {
yield item;
}
} while (cursor !== "0");
}
|
Same as `sscan` but returns an AsyncIterator to allow iteration via `for await`.
|
sscanIterator
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
async *zscanIterator(key, options) {
let cursor = "0";
let items;
do {
[cursor, items] = await this.zscan(key, cursor, options);
for (const item of items) {
yield item;
}
} while (cursor !== "0");
}
|
Same as `zscan` but returns an AsyncIterator to allow iteration via `for await`.
|
zscanIterator
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
function createClient(config) {
return new VercelKV({
// The Next.js team recommends no value or `default` for fetch requests's `cache` option
// upstash/redis defaults to `no-store`, so we enforce `default`
cache: "default",
enableAutoPipelining: true,
...config
});
}
|
Same as `zscan` but returns an AsyncIterator to allow iteration via `for await`.
|
createClient
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
get(target, prop, receiver) {
if (prop === "then" || prop === "parse") {
return Reflect.get(target, prop, receiver);
}
if (!_kv) {
if (!process.env.KV_REST_API_URL || !process.env.KV_REST_API_TOKEN) {
throw new Error(
"@vercel/kv: Missing required environment variables KV_REST_API_URL and KV_REST_API_TOKEN"
);
}
console.warn(
'\x1B[33m"The default export has been moved to a named export and it will be removed in version 1, change to import { kv }\x1B[0m"'
);
_kv = createClient({
url: process.env.KV_REST_API_URL,
token: process.env.KV_REST_API_TOKEN
});
}
return Reflect.get(_kv, prop);
}
|
Same as `zscan` but returns an AsyncIterator to allow iteration via `for await`.
|
get
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
get(target, prop) {
if (!_kv) {
if (!process.env.KV_REST_API_URL || !process.env.KV_REST_API_TOKEN) {
throw new Error(
"@vercel/kv: Missing required environment variables KV_REST_API_URL and KV_REST_API_TOKEN"
);
}
_kv = createClient({
url: process.env.KV_REST_API_URL,
token: process.env.KV_REST_API_TOKEN
});
}
return Reflect.get(_kv, prop);
}
|
Same as `zscan` but returns an AsyncIterator to allow iteration via `for await`.
|
get
|
javascript
|
vercel/next.js
|
.github/actions/upload-turboyet-data/dist/index.js
|
https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js
|
MIT
|
TinaProvider = ({ children }) => {
return <TinaCMS {...tinaConfig}>{children}</TinaCMS>;
}
|
@private Do not import this directly, please import the dynamic provider instead
|
TinaProvider
|
javascript
|
vercel/next.js
|
examples/cms-tina/.tina/components/TinaProvider.js
|
https://github.com/vercel/next.js/blob/master/examples/cms-tina/.tina/components/TinaProvider.js
|
MIT
|
TinaProvider = ({ children }) => {
return <TinaCMS {...tinaConfig}>{children}</TinaCMS>;
}
|
@private Do not import this directly, please import the dynamic provider instead
|
TinaProvider
|
javascript
|
vercel/next.js
|
examples/cms-tina/.tina/components/TinaProvider.js
|
https://github.com/vercel/next.js/blob/master/examples/cms-tina/.tina/components/TinaProvider.js
|
MIT
|
async function createCouchbaseCluster() {
if (cached.conn) {
return cached.conn;
}
cached.conn = await couchbase.connect(
"couchbase://" +
COUCHBASE_ENDPOINT +
(IS_CLOUD_INSTANCE === "true"
? "?ssl=no_verify&console_log_level=5"
: ""),
{
username: COUCHBASE_USER,
password: COUCHBASE_PASSWORD,
},
);
return cached.conn;
}
|
Global is used here to maintain a cached connection across hot reloads
in development. This prevents connections growing exponentially
during API Route usage.
|
createCouchbaseCluster
|
javascript
|
vercel/next.js
|
examples/with-couchbase/util/couchbase.js
|
https://github.com/vercel/next.js/blob/master/examples/with-couchbase/util/couchbase.js
|
MIT
|
async function connectToDatabase() {
const cluster = await createCouchbaseCluster();
const bucket = cluster.bucket(COUCHBASE_BUCKET);
const collection = bucket.defaultCollection();
let dbConnection = {
cluster,
bucket,
collection,
};
return dbConnection;
}
|
Global is used here to maintain a cached connection across hot reloads
in development. This prevents connections growing exponentially
during API Route usage.
|
connectToDatabase
|
javascript
|
vercel/next.js
|
examples/with-couchbase/util/couchbase.js
|
https://github.com/vercel/next.js/blob/master/examples/with-couchbase/util/couchbase.js
|
MIT
|
function getKnex() {
if (!cached.instance) cached.instance = knex(config);
return cached.instance;
}
|
Global is used here to ensure the connection
is cached across hot-reloads in development
see https://github.com/vercel/next.js/discussions/12229#discussioncomment-83372
|
getKnex
|
javascript
|
vercel/next.js
|
examples/with-knex/knex/index.js
|
https://github.com/vercel/next.js/blob/master/examples/with-knex/knex/index.js
|
MIT
|
function MyApp({ Component, pageProps }) {
return (
/* Here we call NextSeo and pass our default configuration to it */
<>
<DefaultSeo {...SEO} />
<Component {...pageProps} />
</>
);
}
|
Using a custom _app.js with next-seo you can set default SEO
that will apply to every page. Full info on how the default works
can be found here: https://github.com/garmeeh/next-seo#default-seo-configuration
|
MyApp
|
javascript
|
vercel/next.js
|
examples/with-next-seo/pages/_app.js
|
https://github.com/vercel/next.js/blob/master/examples/with-next-seo/pages/_app.js
|
MIT
|
async function createUser({ username, password }) {
// Here you should create the user and save the salt and hashed password (some dbs may have
// authentication methods that will do it for you so you don't have to worry about it):
const salt = crypto.randomBytes(16).toString("hex");
const hash = crypto
.pbkdf2Sync(password, salt, 1000, 64, "sha512")
.toString("hex");
const user = {
id: crypto.randomUUID(),
createdAt: Date.now(),
username,
hash,
salt,
};
// This is an in memory store for users, there is no data persistence without a proper DB
users.push(user);
return { username, createdAt: Date.now() };
}
|
User methods. The example doesn't contain a DB, but for real applications you must use a
db here, such as MongoDB, Fauna, SQL, etc.
|
createUser
|
javascript
|
vercel/next.js
|
examples/with-passport/lib/user.js
|
https://github.com/vercel/next.js/blob/master/examples/with-passport/lib/user.js
|
MIT
|
async function findUser({ username }) {
// This is an in memory store for users, there is no data persistence without a proper DB
return users.find((user) => user.username === username);
}
|
User methods. The example doesn't contain a DB, but for real applications you must use a
db here, such as MongoDB, Fauna, SQL, etc.
|
findUser
|
javascript
|
vercel/next.js
|
examples/with-passport/lib/user.js
|
https://github.com/vercel/next.js/blob/master/examples/with-passport/lib/user.js
|
MIT
|
function validatePassword(user, inputPassword) {
const inputHash = crypto
.pbkdf2Sync(inputPassword, user.salt, 1000, 64, "sha512")
.toString("hex");
const passwordsMatch = user.hash === inputHash;
return passwordsMatch;
}
|
User methods. The example doesn't contain a DB, but for real applications you must use a
db here, such as MongoDB, Fauna, SQL, etc.
|
validatePassword
|
javascript
|
vercel/next.js
|
examples/with-passport/lib/user.js
|
https://github.com/vercel/next.js/blob/master/examples/with-passport/lib/user.js
|
MIT
|
create(context) {
function checkRequireCall(node) {
// Check if this is a require() call
if (
node.type !== 'CallExpression' ||
node.callee.type !== 'Identifier' ||
node.callee.name !== 'require' ||
node.arguments.length !== 1 ||
node.arguments[0].type !== 'Literal'
) {
return
}
const requireSource = node.arguments[0].value
const parent = node.parent
// json is fine because we have resolveJsonModule disabled in our TS project
if (requireSource.endsWith('.json')) {
return
}
// Check if the require is wrapped in a TypeScript assertion
if (parent && parent.type === 'TSAsExpression') {
const typeAnnotation = parent.typeAnnotation
// Check if it's a typeof import() expression
if (
typeAnnotation.type === 'TSTypeQuery' &&
typeAnnotation.exprName.type === 'TSImportType'
) {
const importType = typeAnnotation.exprName
// Check if the import source matches the require source
if (
importType.argument &&
importType.argument.type === 'TSLiteralType' &&
importType.argument.literal.type === 'Literal'
) {
const importSource = importType.argument.literal.value
if (requireSource !== importSource) {
context.report({
node,
messageId: 'mismatchedSource',
data: {
requireSource,
importSource,
},
fix(fixer) {
// importSource as source of truth since that's what's typechecked
// and will be changed by automated refactors.
const newCast = `(require('${importSource}') as typeof import('${importSource}'))`
return fixer.replaceText(parent, newCast)
},
})
}
}
} else {
// Has assertion but not the correct type
context.report({
node: parent,
messageId: 'missingCast',
fix(fixer) {
const newCast = `(require('${requireSource}') as typeof import('${requireSource}'))`
return fixer.replaceText(parent, newCast)
},
})
}
} else {
// No TypeScript assertion at all
context.report({
node,
messageId: 'missingCast',
fix(fixer) {
const newCast = `(require('${requireSource}') as typeof import('${requireSource}'))`
return fixer.replaceText(node, newCast)
},
})
}
}
return {
CallExpression: checkRequireCall,
}
}
|
ESLint rule: typechecked-require
Ensures every require(source) call is cast to typeof import(source)
Source: https://v0.dev/chat/eslint-cast-imports-CDvQ3iWC1Mo
|
create
|
javascript
|
vercel/next.js
|
packages/eslint-plugin-internal/src/eslint-typechecked-require.js
|
https://github.com/vercel/next.js/blob/master/packages/eslint-plugin-internal/src/eslint-typechecked-require.js
|
MIT
|
function checkRequireCall(node) {
// Check if this is a require() call
if (
node.type !== 'CallExpression' ||
node.callee.type !== 'Identifier' ||
node.callee.name !== 'require' ||
node.arguments.length !== 1 ||
node.arguments[0].type !== 'Literal'
) {
return
}
const requireSource = node.arguments[0].value
const parent = node.parent
// json is fine because we have resolveJsonModule disabled in our TS project
if (requireSource.endsWith('.json')) {
return
}
// Check if the require is wrapped in a TypeScript assertion
if (parent && parent.type === 'TSAsExpression') {
const typeAnnotation = parent.typeAnnotation
// Check if it's a typeof import() expression
if (
typeAnnotation.type === 'TSTypeQuery' &&
typeAnnotation.exprName.type === 'TSImportType'
) {
const importType = typeAnnotation.exprName
// Check if the import source matches the require source
if (
importType.argument &&
importType.argument.type === 'TSLiteralType' &&
importType.argument.literal.type === 'Literal'
) {
const importSource = importType.argument.literal.value
if (requireSource !== importSource) {
context.report({
node,
messageId: 'mismatchedSource',
data: {
requireSource,
importSource,
},
fix(fixer) {
// importSource as source of truth since that's what's typechecked
// and will be changed by automated refactors.
const newCast = `(require('${importSource}') as typeof import('${importSource}'))`
return fixer.replaceText(parent, newCast)
},
})
}
}
} else {
// Has assertion but not the correct type
context.report({
node: parent,
messageId: 'missingCast',
fix(fixer) {
const newCast = `(require('${requireSource}') as typeof import('${requireSource}'))`
return fixer.replaceText(parent, newCast)
},
})
}
} else {
// No TypeScript assertion at all
context.report({
node,
messageId: 'missingCast',
fix(fixer) {
const newCast = `(require('${requireSource}') as typeof import('${requireSource}'))`
return fixer.replaceText(node, newCast)
},
})
}
}
|
ESLint rule: typechecked-require
Ensures every require(source) call is cast to typeof import(source)
Source: https://v0.dev/chat/eslint-cast-imports-CDvQ3iWC1Mo
|
checkRequireCall
|
javascript
|
vercel/next.js
|
packages/eslint-plugin-internal/src/eslint-typechecked-require.js
|
https://github.com/vercel/next.js/blob/master/packages/eslint-plugin-internal/src/eslint-typechecked-require.js
|
MIT
|
fix(fixer) {
// importSource as source of truth since that's what's typechecked
// and will be changed by automated refactors.
const newCast = `(require('${importSource}') as typeof import('${importSource}'))`
return fixer.replaceText(parent, newCast)
}
|
ESLint rule: typechecked-require
Ensures every require(source) call is cast to typeof import(source)
Source: https://v0.dev/chat/eslint-cast-imports-CDvQ3iWC1Mo
|
fix
|
javascript
|
vercel/next.js
|
packages/eslint-plugin-internal/src/eslint-typechecked-require.js
|
https://github.com/vercel/next.js/blob/master/packages/eslint-plugin-internal/src/eslint-typechecked-require.js
|
MIT
|
fix(fixer) {
const newCast = `(require('${requireSource}') as typeof import('${requireSource}'))`
return fixer.replaceText(parent, newCast)
}
|
ESLint rule: typechecked-require
Ensures every require(source) call is cast to typeof import(source)
Source: https://v0.dev/chat/eslint-cast-imports-CDvQ3iWC1Mo
|
fix
|
javascript
|
vercel/next.js
|
packages/eslint-plugin-internal/src/eslint-typechecked-require.js
|
https://github.com/vercel/next.js/blob/master/packages/eslint-plugin-internal/src/eslint-typechecked-require.js
|
MIT
|
fix(fixer) {
const newCast = `(require('${requireSource}') as typeof import('${requireSource}'))`
return fixer.replaceText(node, newCast)
}
|
ESLint rule: typechecked-require
Ensures every require(source) call is cast to typeof import(source)
Source: https://v0.dev/chat/eslint-cast-imports-CDvQ3iWC1Mo
|
fix
|
javascript
|
vercel/next.js
|
packages/eslint-plugin-internal/src/eslint-typechecked-require.js
|
https://github.com/vercel/next.js/blob/master/packages/eslint-plugin-internal/src/eslint-typechecked-require.js
|
MIT
|
externalHandler = ({ context, request, getResolve }, callback) => {
;(async () => {
if (
request.match(
/next[/\\]dist[/\\]compiled[/\\](babel|webpack|source-map|semver|jest-worker|stacktrace-parser|@ampproject\/toolbox-optimizer)/
)
) {
callback(null, 'commonjs ' + request)
return
}
if (request.match(/(server\/image-optimizer|experimental\/testmode)/)) {
callback(null, 'commonjs ' + request)
return
}
if (request.endsWith('.external')) {
const resolve = getResolve()
const resolved = await resolve(context, request)
const relative = path.relative(
path.join(__dirname, '..'),
resolved.replace('esm' + path.sep, '')
)
callback(null, `commonjs ${relative}`)
} else {
const regexMatch = Object.keys(externalsRegexMap).find((regex) =>
new RegExp(regex).test(request)
)
if (regexMatch) {
return callback(null, 'commonjs ' + externalsRegexMap[regexMatch])
}
callback()
}
})()
}
|
@param {Object} options
@param {boolean} options.dev
@param {boolean} options.turbo
@param {keyof typeof bundleTypes} options.bundleType
@param {boolean} options.experimental
@param {Partial<webpack.Configuration>} options.rest
@returns {webpack.Configuration}
|
externalHandler
|
javascript
|
vercel/next.js
|
packages/next/next-runtime.webpack-config.js
|
https://github.com/vercel/next.js/blob/master/packages/next/next-runtime.webpack-config.js
|
MIT
|
externalHandler = ({ context, request, getResolve }, callback) => {
;(async () => {
if (
request.match(
/next[/\\]dist[/\\]compiled[/\\](babel|webpack|source-map|semver|jest-worker|stacktrace-parser|@ampproject\/toolbox-optimizer)/
)
) {
callback(null, 'commonjs ' + request)
return
}
if (request.match(/(server\/image-optimizer|experimental\/testmode)/)) {
callback(null, 'commonjs ' + request)
return
}
if (request.endsWith('.external')) {
const resolve = getResolve()
const resolved = await resolve(context, request)
const relative = path.relative(
path.join(__dirname, '..'),
resolved.replace('esm' + path.sep, '')
)
callback(null, `commonjs ${relative}`)
} else {
const regexMatch = Object.keys(externalsRegexMap).find((regex) =>
new RegExp(regex).test(request)
)
if (regexMatch) {
return callback(null, 'commonjs ' + externalsRegexMap[regexMatch])
}
callback()
}
})()
}
|
@param {Object} options
@param {boolean} options.dev
@param {boolean} options.turbo
@param {keyof typeof bundleTypes} options.bundleType
@param {boolean} options.experimental
@param {Partial<webpack.Configuration>} options.rest
@returns {webpack.Configuration}
|
externalHandler
|
javascript
|
vercel/next.js
|
packages/next/next-runtime.webpack-config.js
|
https://github.com/vercel/next.js/blob/master/packages/next/next-runtime.webpack-config.js
|
MIT
|
function calculateUniquePort(dev, turbo, experimental, bundleType) {
const devOffset = dev ? 1000 : 0
const turboOffset = turbo ? 200 : 0
const experimentalOffset = experimental ? 40 : 0
let bundleTypeOffset
switch (bundleType) {
case 'app':
bundleTypeOffset = 1
break
case 'pages':
bundleTypeOffset = 2
break
default:
bundleTypeOffset = 3
}
return 8888 + devOffset + turboOffset + experimentalOffset + bundleTypeOffset
}
|
@param {Object} options
@param {boolean} options.dev
@param {boolean} options.turbo
@param {keyof typeof bundleTypes} options.bundleType
@param {boolean} options.experimental
@param {Partial<webpack.Configuration>} options.rest
@returns {webpack.Configuration}
|
calculateUniquePort
|
javascript
|
vercel/next.js
|
packages/next/next-runtime.webpack-config.js
|
https://github.com/vercel/next.js/blob/master/packages/next/next-runtime.webpack-config.js
|
MIT
|
async function server(task, opts) {
await task
.source('src/server/**/!(*.test).+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/server')
}
|
/!(*.test).+(js|ts|tsx|json)')
.swc('server', { dev: opts.dev })
.target('dist/lib')
}
export async function lib_esm(task, opts) {
await task
.source('src/lib/*
|
server
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function server_esm(task, opts) {
await task
.source('src/server/**/!(*.test).+(js|mts|ts|tsx)')
.swc('server', { dev: opts.dev, esm: true })
.target('dist/esm/server')
}
|
/!(*.test).+(js|ts|tsx|json)')
.swc('server', { dev: opts.dev })
.target('dist/lib')
}
export async function lib_esm(task, opts) {
await task
.source('src/lib/*
|
server_esm
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function api_esm(task, opts) {
await task
.source('src/api/**/*.+(js|mts|ts|tsx)')
.swc('server', { dev: opts.dev, esm: true })
.target('dist/api')
.target('dist/esm/api')
}
|
/!(*.test).+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/server')
}
export async function server_esm(task, opts) {
await task
.source('src/server/*
|
api_esm
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function nextbuild(task, opts) {
await task
.source('src/build/**/*.+(js|ts|tsx)', {
ignore: [
'**/fixture/**',
'**/tests/**',
'**/jest/**',
'**/*.test.d.ts',
'**/*.test.+(js|ts|tsx)',
],
})
.swc('server', { dev: opts.dev })
.target('dist/build')
}
|
/!(*.test).+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/server')
}
export async function server_esm(task, opts) {
await task
.source('src/server/*
|
nextbuild
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function next_devtools_entrypoint(task, opts) {
await task
.source('src/next-devtools/dev-overlay.shim.ts')
.swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/next-devtools')
}
|
/!(*.test|*.stories).+(js|ts|tsx|woff2)')
.swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/client')
}
export async function client_esm(task, opts) {
await task
.source('src/client/*
|
next_devtools_entrypoint
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function next_devtools_server(task, opts) {
await task
.source(
'src/next-devtools/server/**/!(*.test|*.stories).+(js|ts|tsx|woff2)'
)
.swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/next-devtools/server')
}
|
/!(*.test|*.stories).+(js|ts|tsx|woff2)')
.swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/client')
}
export async function client_esm(task, opts) {
await task
.source('src/client/*
|
next_devtools_server
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function next_devtools_server_esm(task, opts) {
await task
.source(
'src/next-devtools/server/**/!(*.test|*.stories).+(js|ts|tsx|woff2)'
)
.swc('client', { dev: opts.dev, esm: true })
.target('dist/esm/next-devtools/server')
}
|
/!(*.test|*.stories).+(js|ts|tsx|woff2)')
.swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/client')
}
export async function client_esm(task, opts) {
await task
.source('src/client/*
|
next_devtools_server_esm
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function next_devtools_shared(task, opts) {
await task
.source(
'src/next-devtools/shared/**/!(*.test|*.stories).+(js|ts|tsx|woff2)'
)
.swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/next-devtools/shared')
}
|
/!(*.test|*.stories).+(js|ts|tsx|woff2)'
)
.swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/next-devtools/server')
}
export async function next_devtools_server_esm(task, opts) {
await task
.source(
'src/next-devtools/server/*
|
next_devtools_shared
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function next_devtools_shared_esm(task, opts) {
await task
.source(
'src/next-devtools/shared/**/!(*.test|*.stories).+(js|ts|tsx|woff2)'
)
.swc('client', { dev: opts.dev, esm: true })
.target('dist/esm/next-devtools/shared')
}
|
/!(*.test|*.stories).+(js|ts|tsx|woff2)'
)
.swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/next-devtools/server')
}
export async function next_devtools_server_esm(task, opts) {
await task
.source(
'src/next-devtools/server/*
|
next_devtools_shared_esm
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function next_devtools_userspace(task, opts) {
await task
.source(
'src/next-devtools/userspace/**/!(*.test|*.stories).+(js|ts|tsx|woff2)'
)
.swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/next-devtools/userspace')
}
|
/!(*.test|*.stories).+(js|ts|tsx|woff2)'
)
.swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/next-devtools/shared')
}
export async function next_devtools_shared_esm(task, opts) {
await task
.source(
'src/next-devtools/shared/*
|
next_devtools_userspace
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function next_devtools_userspace_esm(task, opts) {
await task
.source(
'src/next-devtools/userspace/**/!(*.test|*.stories).+(js|ts|tsx|woff2)'
)
.swc('client', { dev: opts.dev, esm: true })
.target('dist/esm/next-devtools/userspace')
}
|
/!(*.test|*.stories).+(js|ts|tsx|woff2)'
)
.swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/next-devtools/shared')
}
export async function next_devtools_shared_esm(task, opts) {
await task
.source(
'src/next-devtools/shared/*
|
next_devtools_userspace_esm
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function nextbuildstatic(task, opts) {
await task
.source('src/export/**/!(*.test).+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/export')
}
|
/!(*.test|*.stories).+(js|ts|tsx|woff2)'
)
.swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/next-devtools/userspace')
}
export async function next_devtools_userspace_esm(task, opts) {
await task
.source(
'src/next-devtools/userspace/*
|
nextbuildstatic
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function nextbuildstatic_esm(task, opts) {
await task
.source('src/export/**/!(*.test).+(js|ts|tsx)')
.swc('server', { dev: opts.dev, esm: true })
.target('dist/esm/export')
}
|
/!(*.test|*.stories).+(js|ts|tsx|woff2)'
)
.swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/next-devtools/userspace')
}
export async function next_devtools_userspace_esm(task, opts) {
await task
.source(
'src/next-devtools/userspace/*
|
nextbuildstatic_esm
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function pages_app(task, opts) {
await task
.source('src/pages/_app.tsx')
.swc('client', {
dev: opts.dev,
interopClientDefaultExport: true,
})
.target('dist/pages')
}
|
/!(*.test).+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/export')
}
// export is a reserved keyword for functions
export async function nextbuildstatic_esm(task, opts) {
await task
.source('src/export/*
|
pages_app
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function pages_error(task, opts) {
await task
.source('src/pages/_error.tsx')
.swc('client', {
dev: opts.dev,
interopClientDefaultExport: true,
})
.target('dist/pages')
}
|
/!(*.test).+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/export')
}
// export is a reserved keyword for functions
export async function nextbuildstatic_esm(task, opts) {
await task
.source('src/export/*
|
pages_error
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function pages_document(task, opts) {
await task
.source('src/pages/_document.tsx')
.swc('server', {
dev: opts.dev,
})
.target('dist/pages')
}
|
/!(*.test).+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/export')
}
// export is a reserved keyword for functions
export async function nextbuildstatic_esm(task, opts) {
await task
.source('src/export/*
|
pages_document
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function pages_app_esm(task, opts) {
await task
.source('src/pages/_app.tsx')
.swc('client', {
dev: opts.dev,
esm: true,
})
.target('dist/esm/pages')
}
|
/!(*.test).+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/export')
}
// export is a reserved keyword for functions
export async function nextbuildstatic_esm(task, opts) {
await task
.source('src/export/*
|
pages_app_esm
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function pages_error_esm(task, opts) {
await task
.source('src/pages/_error.tsx')
.swc('client', {
dev: opts.dev,
esm: true,
})
.target('dist/esm/pages')
}
|
/!(*.test).+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/export')
}
// export is a reserved keyword for functions
export async function nextbuildstatic_esm(task, opts) {
await task
.source('src/export/*
|
pages_error_esm
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function pages_document_esm(task, opts) {
await task
.source('src/pages/_document.tsx')
.swc('server', {
dev: opts.dev,
esm: true,
})
.target('dist/esm/pages')
}
|
/!(*.test).+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/export')
}
// export is a reserved keyword for functions
export async function nextbuildstatic_esm(task, opts) {
await task
.source('src/export/*
|
pages_document_esm
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function pages(task, opts) {
await task.parallel(['pages_app', 'pages_error', 'pages_document'], opts)
}
|
/!(*.test).+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/export')
}
// export is a reserved keyword for functions
export async function nextbuildstatic_esm(task, opts) {
await task
.source('src/export/*
|
pages
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function pages_esm(task, opts) {
await task.parallel(
['pages_app_esm', 'pages_error_esm', 'pages_document_esm'],
opts
)
}
|
/!(*.test).+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/export')
}
// export is a reserved keyword for functions
export async function nextbuildstatic_esm(task, opts) {
await task
.source('src/export/*
|
pages_esm
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function telemetry(task, opts) {
await task
.source('src/telemetry/**/*.+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/telemetry')
}
|
/!(*.test).+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/export')
}
// export is a reserved keyword for functions
export async function nextbuildstatic_esm(task, opts) {
await task
.source('src/export/*
|
telemetry
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function trace(task, opts) {
await task
.source('src/trace/**/*.+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/trace')
}
|
/!(*.test).+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/export')
}
// export is a reserved keyword for functions
export async function nextbuildstatic_esm(task, opts) {
await task
.source('src/export/*
|
trace
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function diagnostics(task, opts) {
await task
.source('src/diagnostics/**/*.+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/diagnostics')
}
|
/*.+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/telemetry')
}
export async function trace(task, opts) {
await task
.source('src/trace/*
|
diagnostics
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function build(task, opts) {
await task.serial(
['precompile', 'compile', 'check_error_codes', 'generate_types'],
opts
)
}
|
/*.+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/telemetry')
}
export async function trace(task, opts) {
await task
.source('src/trace/*
|
build
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function generate_types(task, opts) {
const watchmode = opts.dev
const typesPromise = execa(
'pnpm',
[
'run',
'types',
...(watchmode ? ['--watch', '--preserveWatchOutput'] : []),
],
{ stdio: 'inherit' }
)
// In watch-mode the process never completes i.e. the Promise never resolve.
// But taskr needs to know that it can start watching the files for the task it has to manually restart.
if (!watchmode) {
await typesPromise
}
}
|
/*.+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/telemetry')
}
export async function trace(task, opts) {
await task
.source('src/trace/*
|
generate_types
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function check_error_codes(task, opts) {
try {
await execa.command('pnpm -w run check-error-codes', {
stdio: 'inherit',
})
} catch (err) {
if (process.env.CI) {
await execa.command(
'echo check_error_codes FAILED: There are new errors introduced but no corresponding error codes are found in errors.json file, so make sure you run `pnpm build` or `pnpm update-error-codes` and then commit the change in errors.json.',
{
stdio: 'inherit',
}
)
process.exit(1)
}
await task.start('compile', opts)
}
}
|
/*.+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/telemetry')
}
export async function trace(task, opts) {
await task
.source('src/trace/*
|
check_error_codes
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function shared(task, opts) {
await task
.source('src/shared/**/*.+(js|ts|tsx)', {
ignore: [
'src/shared/**/{amp,config,constants,dynamic,app-dynamic,head,runtime-config}.+(js|ts|tsx)',
'**/*.test.d.ts',
'**/*.test.+(js|ts|tsx)',
],
})
.swc('client', { dev: opts.dev })
.target('dist/shared')
}
|
/*.+(js|ts|tsx)')
.swc('server', { dev: opts.dev })
.target('dist/telemetry')
}
export async function trace(task, opts) {
await task
.source('src/trace/*
|
shared
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function shared_esm(task, opts) {
await task
.source('src/shared/**/*.+(js|ts|tsx)', {
ignore: [
'src/shared/**/{amp,config,constants,dynamic,app-dynamic,head,runtime-config}.+(js|ts|tsx)',
'**/*.test.d.ts',
'**/*.test.+(js|ts|tsx)',
],
})
.swc('client', { dev: opts.dev, esm: true })
.target('dist/esm/shared')
}
|
/{amp,config,constants,dynamic,app-dynamic,head,runtime-config}.+(js|ts|tsx)',
'*
|
shared_esm
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function shared_re_exported(task, opts) {
await task
.source(
'src/shared/**/{amp,config,constants,dynamic,app-dynamic,head,runtime-config}.+(js|ts|tsx)',
{
ignore: ['**/*.test.d.ts', '**/*.test.+(js|ts|tsx)'],
}
)
.swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/shared')
}
|
/*.+(js|ts|tsx)', {
ignore: [
'src/shared/*
|
shared_re_exported
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function shared_re_exported_esm(task, opts) {
await task
.source(
'src/shared/**/{amp,config,constants,app-dynamic,dynamic,head}.+(js|ts|tsx)',
{
ignore: ['**/*.test.d.ts', '**/*.test.+(js|ts|tsx)'],
}
)
.swc('client', {
dev: opts.dev,
esm: true,
})
.target('dist/esm/shared')
}
|
/{amp,config,constants,dynamic,app-dynamic,head,runtime-config}.+(js|ts|tsx)',
{
ignore: ['*
|
shared_re_exported_esm
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function server_wasm(task, opts) {
await task.source('src/server/**/*.+(wasm)').target('dist/server')
}
|
/{amp,config,constants,app-dynamic,dynamic,head}.+(js|ts|tsx)',
{
ignore: ['*
|
server_wasm
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function experimental_testing(task, opts) {
await task
.source('src/experimental/testing/**/!(*.test).+(js|ts|tsx)')
.swc('server', {
dev: opts.dev,
})
.target('dist/experimental/testing')
}
|
/{amp,config,constants,app-dynamic,dynamic,head}.+(js|ts|tsx)',
{
ignore: ['*
|
experimental_testing
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function experimental_testmode(task, opts) {
await task
.source('src/experimental/testmode/**/!(*.test).+(js|ts|tsx)')
.swc('server', {
dev: opts.dev,
})
.target('dist/experimental/testmode')
}
|
/*.+(wasm)').target('dist/server')
}
export async function experimental_testing(task, opts) {
await task
.source('src/experimental/testing/*
|
experimental_testmode
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
async function release(task) {
await task.clear('dist').start('build')
}
|
/*.+(wasm)').target('dist/server')
}
export async function experimental_testing(task, opts) {
await task
.source('src/experimental/testing/*
|
release
|
javascript
|
vercel/next.js
|
packages/next/taskfile.js
|
https://github.com/vercel/next.js/blob/master/packages/next/taskfile.js
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.