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
constructor(type, eventInitDict = {}) { var __super = (...args) => { super(...args); __privateAdd(this, _eventInit, void 0); return this; }; if (type === kConstruct) { __super(arguments[1], arguments[2]); webidl.util.markAsUncloneable(this); return; } const prefix = "MessageEvent constructor"; webidl.argumentLengthCheck(arguments, 1, prefix); type = webidl.converters.DOMString(type, prefix, "type"); eventInitDict = webidl.converters.MessageEventInit(eventInitDict, prefix, "eventInitDict"); __super(type, eventInitDict); __privateSet(this, _eventInit, eventInitDict); webidl.util.markAsUncloneable(this); }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
__super = (...args) => { super(...args); __privateAdd(this, _eventInit, void 0); return this; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
__super
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get data() { webidl.brandCheck(this, _MessageEvent); return __privateGet(this, _eventInit).data; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
data
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get origin() { webidl.brandCheck(this, _MessageEvent); return __privateGet(this, _eventInit).origin; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
origin
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get lastEventId() { webidl.brandCheck(this, _MessageEvent); return __privateGet(this, _eventInit).lastEventId; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
lastEventId
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get source() { webidl.brandCheck(this, _MessageEvent); return __privateGet(this, _eventInit).source; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
source
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get ports() { webidl.brandCheck(this, _MessageEvent); if (!Object.isFrozen(__privateGet(this, _eventInit).ports)) { Object.freeze(__privateGet(this, _eventInit).ports); } return __privateGet(this, _eventInit).ports; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
ports
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
initMessageEvent(type, bubbles = false, cancelable = false, data = null, origin = "", lastEventId = "", source = null, ports = []) { webidl.brandCheck(this, _MessageEvent); webidl.argumentLengthCheck(arguments, 1, "MessageEvent.initMessageEvent"); return new _MessageEvent(type, { bubbles, cancelable, data, origin, lastEventId, source, ports }); }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
initMessageEvent
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
static createFastMessageEvent(type, init) { const messageEvent = new _MessageEvent(kConstruct, type, init); __privateSet(messageEvent, _eventInit, init); __privateGet(messageEvent, _eventInit).data ??= null; __privateGet(messageEvent, _eventInit).origin ??= ""; __privateGet(messageEvent, _eventInit).lastEventId ??= ""; __privateGet(messageEvent, _eventInit).source ??= null; __privateGet(messageEvent, _eventInit).ports ??= []; return messageEvent; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
createFastMessageEvent
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
constructor(type, eventInitDict = {}) { const prefix = "CloseEvent constructor"; webidl.argumentLengthCheck(arguments, 1, prefix); type = webidl.converters.DOMString(type, prefix, "type"); eventInitDict = webidl.converters.CloseEventInit(eventInitDict); super(type, eventInitDict); __privateAdd(this, _eventInit2, void 0); __privateSet(this, _eventInit2, eventInitDict); webidl.util.markAsUncloneable(this); }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get wasClean() { webidl.brandCheck(this, _CloseEvent); return __privateGet(this, _eventInit2).wasClean; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
wasClean
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get code() { webidl.brandCheck(this, _CloseEvent); return __privateGet(this, _eventInit2).code; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
code
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get reason() { webidl.brandCheck(this, _CloseEvent); return __privateGet(this, _eventInit2).reason; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
reason
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
constructor(type, eventInitDict) { const prefix = "ErrorEvent constructor"; webidl.argumentLengthCheck(arguments, 1, prefix); super(type, eventInitDict); __privateAdd(this, _eventInit3, void 0); webidl.util.markAsUncloneable(this); type = webidl.converters.DOMString(type, prefix, "type"); eventInitDict = webidl.converters.ErrorEventInit(eventInitDict ?? {}); __privateSet(this, _eventInit3, eventInitDict); }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get message() { webidl.brandCheck(this, _ErrorEvent); return __privateGet(this, _eventInit3).message; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
message
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get filename() { webidl.brandCheck(this, _ErrorEvent); return __privateGet(this, _eventInit3).filename; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
filename
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get lineno() { webidl.brandCheck(this, _ErrorEvent); return __privateGet(this, _eventInit3).lineno; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
lineno
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get colno() { webidl.brandCheck(this, _ErrorEvent); return __privateGet(this, _eventInit3).colno; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
colno
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get error() { webidl.brandCheck(this, _ErrorEvent); return __privateGet(this, _eventInit3).error; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
error
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function isConnecting(ws) { return ws[kReadyState] === states.CONNECTING; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
isConnecting
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function isEstablished(ws) { return ws[kReadyState] === states.OPEN; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
isEstablished
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function isClosing(ws) { return ws[kReadyState] === states.CLOSING; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
isClosing
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function isClosed(ws) { return ws[kReadyState] === states.CLOSED; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
isClosed
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function fireEvent(e, target, eventFactory = (type, init) => new Event(type, init), eventInitDict = {}) { const event = eventFactory(e, eventInitDict); target.dispatchEvent(event); }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
fireEvent
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function websocketMessageReceived(ws, type, data) { if (ws[kReadyState] !== states.OPEN) { return; } let dataForEvent; if (type === opcodes.TEXT) { try { dataForEvent = utf8Decode(data); } catch { failWebsocketConnection(ws, "Received invalid UTF-8 in text frame."); return; } } else if (type === opcodes.BINARY) { if (ws[kBinaryType] === "blob") { dataForEvent = new Blob([data]); } else { dataForEvent = toArrayBuffer(data); } } fireEvent("message", ws, createFastMessageEvent, { origin: ws[kWebSocketURL].origin, data: dataForEvent }); }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
websocketMessageReceived
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function toArrayBuffer(buffer) { if (buffer.byteLength === buffer.buffer.byteLength) { return buffer.buffer; } return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength); }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
toArrayBuffer
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function isValidSubprotocol(protocol) { if (protocol.length === 0) { return false; } for (let i = 0; i < protocol.length; ++i) { const code = protocol.charCodeAt(i); if (code < 33 || // CTL, contains SP (0x20) and HT (0x09) code > 126 || code === 34 || // " code === 40 || // ( code === 41 || // ) code === 44 || // , code === 47 || // / code === 58 || // : code === 59 || // ; code === 60 || // < code === 61 || // = code === 62 || // > code === 63 || // ? code === 64 || // @ code === 91 || // [ code === 92 || // \ code === 93 || // ] code === 123 || // { code === 125) { return false; } } return true; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
isValidSubprotocol
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function isValidStatusCode(code) { if (code >= 1e3 && code < 1015) { return code !== 1004 && // reserved code !== 1005 && // "MUST NOT be set as a status code" code !== 1006; } return code >= 3e3 && code <= 4999; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
isValidStatusCode
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.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, (type, init) => new ErrorEvent(type, init), { error: new Error(reason), message: reason }); } }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
failWebsocketConnection
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function isControlFrame(opcode) { return opcode === opcodes.CLOSE || opcode === opcodes.PING || opcode === opcodes.PONG; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
isControlFrame
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function isContinuationFrame(opcode) { return opcode === opcodes.CONTINUATION; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
isContinuationFrame
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function isTextBinaryFrame(opcode) { return opcode === opcodes.TEXT || opcode === opcodes.BINARY; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
isTextBinaryFrame
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function isValidOpcode(opcode) { return isTextBinaryFrame(opcode) || isContinuationFrame(opcode) || isControlFrame(opcode); }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
isValidOpcode
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function parseExtensions(extensions) { const position = { position: 0 }; const extensionList = /* @__PURE__ */ new Map(); while (position.position < extensions.length) { const pair = collectASequenceOfCodePointsFast(";", extensions, position); const [name, value = ""] = pair.split("="); extensionList.set( removeHTTPWhitespace(name, true, false), removeHTTPWhitespace(value, false, true) ); position.position++; } return extensionList; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
parseExtensions
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function isValidClientWindowBits(value) { for (let i = 0; i < value.length; i++) { const byte = value.charCodeAt(i); if (byte < 48 || byte > 57) { return false; } } return true; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
isValidClientWindowBits
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function generateMask() { if (bufIdx === BUFFER_SIZE) { bufIdx = 0; crypto.randomFillSync(buffer ??= Buffer.allocUnsafe(BUFFER_SIZE), 0, BUFFER_SIZE); } return [buffer[bufIdx++], buffer[bufIdx++], buffer[bufIdx++], buffer[bufIdx++]]; }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {Promise<string[]>}
generateMask
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
_write(chunk, _, callback) { __privateGet(this, _buffers).push(chunk); __privateSet(this, _byteOffset, __privateGet(this, _byteOffset) + chunk.length); __privateSet(this, _loop, true); this.run(callback); }
@param {Buffer} chunk @param {() => void} callback
_write
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
run(callback) { while (__privateGet(this, _loop)) { if (__privateGet(this, _state) === parserStates.INFO) { if (__privateGet(this, _byteOffset) < 2) { return callback(); } const buffer = this.consume(2); const fin = (buffer[0] & 128) !== 0; const opcode = buffer[0] & 15; const masked = (buffer[1] & 128) === 128; const fragmented = !fin && opcode !== opcodes.CONTINUATION; const payloadLength = buffer[1] & 127; const rsv1 = buffer[0] & 64; const rsv2 = buffer[0] & 32; const rsv3 = buffer[0] & 16; if (!isValidOpcode(opcode)) { failWebsocketConnection(this.ws, "Invalid opcode received"); return callback(); } if (masked) { failWebsocketConnection(this.ws, "Frame cannot be masked"); return callback(); } if (rsv1 !== 0 && !__privateGet(this, _extensions).has("permessage-deflate")) { failWebsocketConnection(this.ws, "Expected RSV1 to be clear."); return; } if (rsv2 !== 0 || rsv3 !== 0) { failWebsocketConnection(this.ws, "RSV1, RSV2, RSV3 must be clear"); return; } if (fragmented && !isTextBinaryFrame(opcode)) { failWebsocketConnection(this.ws, "Invalid frame type was fragmented."); return; } if (isTextBinaryFrame(opcode) && __privateGet(this, _fragments).length > 0) { failWebsocketConnection(this.ws, "Expected continuation frame"); return; } if (__privateGet(this, _info).fragmented && fragmented) { failWebsocketConnection(this.ws, "Fragmented frame exceeded 125 bytes."); return; } if ((payloadLength > 125 || fragmented) && isControlFrame(opcode)) { failWebsocketConnection(this.ws, "Control frame either too large or fragmented"); return; } if (isContinuationFrame(opcode) && __privateGet(this, _fragments).length === 0 && !__privateGet(this, _info).compressed) { failWebsocketConnection(this.ws, "Unexpected continuation frame"); return; } if (payloadLength <= 125) { __privateGet(this, _info).payloadLength = payloadLength; __privateSet(this, _state, parserStates.READ_DATA); } else if (payloadLength === 126) { __privateSet(this, _state, parserStates.PAYLOADLENGTH_16); } else if (payloadLength === 127) { __privateSet(this, _state, parserStates.PAYLOADLENGTH_64); } if (isTextBinaryFrame(opcode)) { __privateGet(this, _info).binaryType = opcode; __privateGet(this, _info).compressed = rsv1 !== 0; } __privateGet(this, _info).opcode = opcode; __privateGet(this, _info).masked = masked; __privateGet(this, _info).fin = fin; __privateGet(this, _info).fragmented = fragmented; } else if (__privateGet(this, _state) === parserStates.PAYLOADLENGTH_16) { if (__privateGet(this, _byteOffset) < 2) { return callback(); } const buffer = this.consume(2); __privateGet(this, _info).payloadLength = buffer.readUInt16BE(0); __privateSet(this, _state, parserStates.READ_DATA); } else if (__privateGet(this, _state) === parserStates.PAYLOADLENGTH_64) { if (__privateGet(this, _byteOffset) < 8) { return callback(); } const buffer = this.consume(8); const upper = buffer.readUInt32BE(0); if (upper > 2 ** 31 - 1) { failWebsocketConnection(this.ws, "Received payload length > 2^31 bytes."); return; } const lower = buffer.readUInt32BE(4); __privateGet(this, _info).payloadLength = (upper << 8) + lower; __privateSet(this, _state, parserStates.READ_DATA); } else if (__privateGet(this, _state) === parserStates.READ_DATA) { if (__privateGet(this, _byteOffset) < __privateGet(this, _info).payloadLength) { return callback(); } const body = this.consume(__privateGet(this, _info).payloadLength); if (isControlFrame(__privateGet(this, _info).opcode)) { __privateSet(this, _loop, this.parseControlFrame(body)); __privateSet(this, _state, parserStates.INFO); } else { if (!__privateGet(this, _info).compressed) { __privateGet(this, _fragments).push(body); if (!__privateGet(this, _info).fragmented && __privateGet(this, _info).fin) { const fullMessage = Buffer.concat(__privateGet(this, _fragments)); websocketMessageReceived(this.ws, __privateGet(this, _info).binaryType, fullMessage); __privateGet(this, _fragments).length = 0; } __privateSet(this, _state, parserStates.INFO); } else { __privateGet(this, _extensions).get("permessage-deflate").decompress(body, __privateGet(this, _info).fin, (error, data) => { if (error) { closeWebSocketConnection(this.ws, 1007, error.message, error.message.length); return; } __privateGet(this, _fragments).push(data); if (!__privateGet(this, _info).fin) { __privateSet(this, _state, parserStates.INFO); __privateSet(this, _loop, true); this.run(callback); return; } websocketMessageReceived(this.ws, __privateGet(this, _info).binaryType, Buffer.concat(__privateGet(this, _fragments))); __privateSet(this, _loop, true); __privateSet(this, _state, parserStates.INFO); __privateGet(this, _fragments).length = 0; this.run(callback); }); __privateSet(this, _loop, false); 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
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
consume(n) { if (n > __privateGet(this, _byteOffset)) { throw new Error("Called consume() before buffers satiated."); } else if (n === 0) { return emptyBuffer; } if (__privateGet(this, _buffers)[0].length === n) { __privateSet(this, _byteOffset, __privateGet(this, _byteOffset) - __privateGet(this, _buffers)[0].length); return __privateGet(this, _buffers).shift(); } const buffer = Buffer.allocUnsafe(n); let offset = 0; while (offset !== n) { const next = __privateGet(this, _buffers)[0]; const { length } = next; if (length + offset === n) { buffer.set(__privateGet(this, _buffers).shift(), offset); break; } else if (length + offset > n) { buffer.set(next.subarray(0, n - offset), offset); __privateGet(this, _buffers)[0] = next.subarray(n - offset); break; } else { buffer.set(__privateGet(this, _buffers).shift(), offset); offset += next.length; } } __privateSet(this, _byteOffset, __privateGet(this, _byteOffset) - n); return buffer; }
Take n bytes from the buffered Buffers @param {number} n @returns {Buffer}
consume
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
parseCloseBody(data) { assert(data.length !== 1); let code; if (data.length >= 2) { code = data.readUInt16BE(0); } if (code !== void 0 && !isValidStatusCode(code)) { return { code: 1002, reason: "Invalid status code", error: true }; } let reason = data.subarray(2); if (reason[0] === 239 && reason[1] === 187 && reason[2] === 191) { reason = reason.subarray(3); } try { reason = utf8Decode(reason); } catch { return { code: 1007, reason: "Invalid UTF-8", error: true }; } return { code, reason, error: false }; }
Take n bytes from the buffered Buffers @param {number} n @returns {Buffer}
parseCloseBody
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
parseControlFrame(body) { const { opcode, payloadLength } = __privateGet(this, _info); if (opcode === opcodes.CLOSE) { if (payloadLength === 1) { failWebsocketConnection(this.ws, "Received close frame with a 1-byte body."); return false; } __privateGet(this, _info).closeInfo = this.parseCloseBody(body); if (__privateGet(this, _info).closeInfo.error) { const { code, reason } = __privateGet(this, _info).closeInfo; closeWebSocketConnection(this.ws, code, reason, reason.length); failWebsocketConnection(this.ws, reason); return false; } if (this.ws[kSentClose] !== sentCloseFrameState.SENT) { let body2 = emptyBuffer; if (__privateGet(this, _info).closeInfo.code) { body2 = Buffer.allocUnsafe(2); body2.writeUInt16BE(__privateGet(this, _info).closeInfo.code, 0); } const closeFrame = new WebsocketFrameSend(body2); this.ws[kResponse].socket.write( closeFrame.createFrame(opcodes.CLOSE), (err) => { if (!err) { this.ws[kSentClose] = sentCloseFrameState.SENT; } } ); } this.ws[kReadyState] = states.CLOSING; this.ws[kReceivedClose] = true; return false; } else if (opcode === opcodes.PING) { 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 }); } } } else if (opcode === opcodes.PONG) { if (channels.pong.hasSubscribers) { channels.pong.publish({ payload: body }); } } return true; }
Parses control frames. @param {Buffer} body
parseControlFrame
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get closingInfo() { return __privateGet(this, _info).closeInfo; }
Parses control frames. @param {Buffer} body
closingInfo
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
constructor(socket) { __privateAdd(this, _run); /** * @type {FixedQueue} */ __privateAdd(this, _queue, new FixedQueue()); /** * @type {boolean} */ __privateAdd(this, _running, false); /** @type {import('node:net').Socket} */ __privateAdd(this, _socket, void 0); __privateSet(this, _socket, socket); }
Parses control frames. @param {Buffer} body
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
constructor(url, protocols = []) { super(); /** * @see https://websockets.spec.whatwg.org/#feedback-from-the-protocol */ __privateAdd(this, _onConnectionEstablished); __privateAdd(this, _events, { open: null, error: null, close: null, message: null }); __privateAdd(this, _bufferedAmount, 0); __privateAdd(this, _protocol, ""); __privateAdd(this, _extensions, ""); /** @type {SendQueue} */ __privateAdd(this, _sendQueue, void 0); webidl.util.markAsUncloneable(this); const prefix = "WebSocket constructor"; webidl.argumentLengthCheck(arguments, 1, prefix); const options = webidl.converters["DOMString or sequence<DOMString> or WebSocketInit"](protocols, prefix, "options"); url = webidl.converters.USVString(url, prefix, "url"); protocols = options.protocols; const baseURL = environmentSettingsObject.settingsObject.baseUrl; let urlRecord; try { urlRecord = new URL(url, baseURL); } catch (e) { throw new DOMException(e, "SyntaxError"); } if (urlRecord.protocol === "http:") { urlRecord.protocol = "ws:"; } else if (urlRecord.protocol === "https:") { urlRecord.protocol = "wss:"; } if (urlRecord.protocol !== "ws:" && urlRecord.protocol !== "wss:") { throw new DOMException( `Expected a ws: or wss: protocol, got ${urlRecord.protocol}`, "SyntaxError" ); } if (urlRecord.hash || urlRecord.href.endsWith("#")) { throw new DOMException("Got fragment", "SyntaxError"); } if (typeof protocols === "string") { protocols = [protocols]; } if (protocols.length !== new Set(protocols.map((p) => p.toLowerCase())).size) { throw new DOMException("Invalid Sec-WebSocket-Protocol value", "SyntaxError"); } if (protocols.length > 0 && !protocols.every((p) => isValidSubprotocol(p))) { throw new DOMException("Invalid Sec-WebSocket-Protocol value", "SyntaxError"); } this[kWebSocketURL] = new URL(urlRecord.href); const client = environmentSettingsObject.settingsObject; this[kController] = establishWebSocketConnection( urlRecord, protocols, client, this, (response, extensions) => __privateMethod(this, _onConnectionEstablished, onConnectionEstablished_fn).call(this, response, extensions), options ); this[kReadyState] = _WebSocket.CONNECTING; this[kSentClose] = sentCloseFrameState.NOT_SENT; this[kBinaryType] = "blob"; }
@param {string} url @param {string|string[]} protocols
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
close(code = void 0, reason = void 0) { webidl.brandCheck(this, _WebSocket); const prefix = "WebSocket.close"; if (code !== void 0) { code = webidl.converters["unsigned short"](code, prefix, "code", { clamp: true }); } if (reason !== void 0) { reason = webidl.converters.USVString(reason, prefix, "reason"); } if (code !== void 0) { if (code !== 1e3 && (code < 3e3 || code > 4999)) { throw new DOMException("invalid code", "InvalidAccessError"); } } let reasonByteLength = 0; if (reason !== void 0) { reasonByteLength = Buffer.byteLength(reason); if (reasonByteLength > 123) { throw new DOMException( `Reason must be less than 123 bytes; received ${reasonByteLength}`, "SyntaxError" ); } } closeWebSocketConnection(this, code, reason, reasonByteLength); }
@see https://websockets.spec.whatwg.org/#dom-websocket-close @param {number|undefined} code @param {string|undefined} reason
close
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
send(data) { webidl.brandCheck(this, _WebSocket); const prefix = "WebSocket.send"; webidl.argumentLengthCheck(arguments, 1, prefix); data = webidl.converters.WebSocketSendData(data, prefix, "data"); if (isConnecting(this)) { throw new DOMException("Sent before connected.", "InvalidStateError"); } if (!isEstablished(this) || isClosing(this)) { return; } if (typeof data === "string") { const length = Buffer.byteLength(data); __privateSet(this, _bufferedAmount, __privateGet(this, _bufferedAmount) + length); __privateGet(this, _sendQueue).add(data, () => { __privateSet(this, _bufferedAmount, __privateGet(this, _bufferedAmount) - length); }, sendHints.string); } else if (types.isArrayBuffer(data)) { __privateSet(this, _bufferedAmount, __privateGet(this, _bufferedAmount) + data.byteLength); __privateGet(this, _sendQueue).add(data, () => { __privateSet(this, _bufferedAmount, __privateGet(this, _bufferedAmount) - data.byteLength); }, sendHints.arrayBuffer); } else if (ArrayBuffer.isView(data)) { __privateSet(this, _bufferedAmount, __privateGet(this, _bufferedAmount) + data.byteLength); __privateGet(this, _sendQueue).add(data, () => { __privateSet(this, _bufferedAmount, __privateGet(this, _bufferedAmount) - data.byteLength); }, sendHints.typedArray); } else if (isBlobLike(data)) { __privateSet(this, _bufferedAmount, __privateGet(this, _bufferedAmount) + data.size); __privateGet(this, _sendQueue).add(data, () => { __privateSet(this, _bufferedAmount, __privateGet(this, _bufferedAmount) - data.size); }, sendHints.blob); } }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
send
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get readyState() { webidl.brandCheck(this, _WebSocket); return this[kReadyState]; }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
readyState
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get bufferedAmount() { webidl.brandCheck(this, _WebSocket); return __privateGet(this, _bufferedAmount); }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
bufferedAmount
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get url() { webidl.brandCheck(this, _WebSocket); return URLSerializer(this[kWebSocketURL]); }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
url
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get extensions() { webidl.brandCheck(this, _WebSocket); return __privateGet(this, _extensions); }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
extensions
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get protocol() { webidl.brandCheck(this, _WebSocket); return __privateGet(this, _protocol); }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
protocol
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get onopen() { webidl.brandCheck(this, _WebSocket); return __privateGet(this, _events).open; }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
onopen
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
set onopen(fn) { webidl.brandCheck(this, _WebSocket); if (__privateGet(this, _events).open) { this.removeEventListener("open", __privateGet(this, _events).open); } if (typeof fn === "function") { __privateGet(this, _events).open = fn; this.addEventListener("open", fn); } else { __privateGet(this, _events).open = null; } }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
onopen
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get onerror() { webidl.brandCheck(this, _WebSocket); return __privateGet(this, _events).error; }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
onerror
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
set onerror(fn) { webidl.brandCheck(this, _WebSocket); if (__privateGet(this, _events).error) { this.removeEventListener("error", __privateGet(this, _events).error); } if (typeof fn === "function") { __privateGet(this, _events).error = fn; this.addEventListener("error", fn); } else { __privateGet(this, _events).error = null; } }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
onerror
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get onclose() { webidl.brandCheck(this, _WebSocket); return __privateGet(this, _events).close; }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
onclose
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
set onclose(fn) { webidl.brandCheck(this, _WebSocket); if (__privateGet(this, _events).close) { this.removeEventListener("close", __privateGet(this, _events).close); } if (typeof fn === "function") { __privateGet(this, _events).close = fn; this.addEventListener("close", fn); } else { __privateGet(this, _events).close = null; } }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
onclose
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get onmessage() { webidl.brandCheck(this, _WebSocket); return __privateGet(this, _events).message; }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
onmessage
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
set onmessage(fn) { webidl.brandCheck(this, _WebSocket); if (__privateGet(this, _events).message) { this.removeEventListener("message", __privateGet(this, _events).message); } if (typeof fn === "function") { __privateGet(this, _events).message = fn; this.addEventListener("message", fn); } else { __privateGet(this, _events).message = null; } }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
onmessage
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get binaryType() { webidl.brandCheck(this, _WebSocket); return this[kBinaryType]; }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
binaryType
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.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/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
binaryType
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function onParserError(err) { let message; let code; if (err instanceof CloseEvent) { message = err.reason; code = err.code; } else { message = err.message; } fireEvent("error", this, () => new ErrorEvent("error", { error: err, message })); closeWebSocketConnection(this, code); }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
onParserError
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function isValidLastEventId(value) { return value.indexOf("\0") === -1; }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
isValidLastEventId
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function isASCIINumber(value) { if (value.length === 0) return false; for (let i = 0; i < value.length; i++) { if (value.charCodeAt(i) < 48 || value.charCodeAt(i) > 57) return false; } return true; }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
isASCIINumber
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function delay(ms) { return new Promise((resolve) => { setTimeout(resolve, ms).unref(); }); }
@see https://websockets.spec.whatwg.org/#dom-websocket-send @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
delay
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
constructor(options = {}) { options.readableObjectMode = true; super(options); this.state = options.eventSourceSettings || {}; if (options.push) { this.push = options.push; } }
@param {object} options @param {eventSourceSettings} options.eventSourceSettings @param {Function} [options.push]
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
_transform(chunk, _encoding, callback) { if (chunk.length === 0) { callback(); return; } if (this.buffer) { this.buffer = Buffer.concat([this.buffer, chunk]); } else { this.buffer = chunk; } if (this.checkBOM) { switch (this.buffer.length) { case 1: if (this.buffer[0] === BOM[0]) { callback(); return; } this.checkBOM = false; callback(); return; case 2: if (this.buffer[0] === BOM[0] && this.buffer[1] === BOM[1]) { callback(); return; } this.checkBOM = false; break; case 3: if (this.buffer[0] === BOM[0] && this.buffer[1] === BOM[1] && this.buffer[2] === BOM[2]) { this.buffer = Buffer.alloc(0); this.checkBOM = false; callback(); return; } this.checkBOM = false; break; default: if (this.buffer[0] === BOM[0] && this.buffer[1] === BOM[1] && this.buffer[2] === BOM[2]) { this.buffer = this.buffer.subarray(3); } this.checkBOM = false; break; } } while (this.pos < this.buffer.length) { if (this.eventEndCheck) { if (this.crlfCheck) { if (this.buffer[this.pos] === LF) { this.buffer = this.buffer.subarray(this.pos + 1); this.pos = 0; this.crlfCheck = false; continue; } this.crlfCheck = false; } if (this.buffer[this.pos] === LF || this.buffer[this.pos] === CR) { if (this.buffer[this.pos] === CR) { this.crlfCheck = true; } this.buffer = this.buffer.subarray(this.pos + 1); this.pos = 0; if (this.event.data !== void 0 || this.event.event || this.event.id || this.event.retry) { this.processEvent(this.event); } this.clearEvent(); continue; } this.eventEndCheck = false; continue; } if (this.buffer[this.pos] === LF || this.buffer[this.pos] === CR) { if (this.buffer[this.pos] === CR) { this.crlfCheck = true; } this.parseLine(this.buffer.subarray(0, this.pos), this.event); this.buffer = this.buffer.subarray(this.pos + 1); this.pos = 0; this.eventEndCheck = true; continue; } this.pos++; } callback(); }
@param {Buffer} chunk @param {string} _encoding @param {Function} callback @returns {void}
_transform
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
parseLine(line, event) { if (line.length === 0) { return; } const colonPosition = line.indexOf(COLON); if (colonPosition === 0) { return; } let field = ""; let value = ""; if (colonPosition !== -1) { field = line.subarray(0, colonPosition).toString("utf8"); let valueStart = colonPosition + 1; if (line[valueStart] === SPACE) { ++valueStart; } value = line.subarray(valueStart).toString("utf8"); } else { field = line.toString("utf8"); value = ""; } switch (field) { case "data": if (event[field] === void 0) { event[field] = value; } else { event[field] += ` ${value}`; } break; case "retry": if (isASCIINumber(value)) { event[field] = value; } break; case "id": if (isValidLastEventId(value)) { event[field] = value; } break; case "event": if (value.length > 0) { event[field] = value; } break; } }
@param {Buffer} line @param {EventStreamEvent} event
parseLine
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
constructor(url, eventSourceInitDict = {}) { super(); __privateAdd(this, _connect); /** * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#sse-processing-model * @returns {Promise<void>} */ __privateAdd(this, _reconnect); __privateAdd(this, _events, { open: null, error: null, message: null }); __privateAdd(this, _url, null); __privateAdd(this, _withCredentials, false); __privateAdd(this, _readyState, CONNECTING); __privateAdd(this, _request, null); __privateAdd(this, _controller, null); __privateAdd(this, _dispatcher, void 0); /** * @type {import('./eventsource-stream').eventSourceSettings} */ __privateAdd(this, _state, void 0); webidl.util.markAsUncloneable(this); const prefix = "EventSource constructor"; webidl.argumentLengthCheck(arguments, 1, prefix); if (!experimentalWarned) { experimentalWarned = true; define_process_default.emitWarning("EventSource is experimental, expect them to change at any time.", { code: "UNDICI-ES" }); } url = webidl.converters.USVString(url, prefix, "url"); eventSourceInitDict = webidl.converters.EventSourceInitDict(eventSourceInitDict, prefix, "eventSourceInitDict"); __privateSet(this, _dispatcher, eventSourceInitDict.dispatcher); __privateSet(this, _state, { lastEventId: "", reconnectionTime: defaultReconnectionTime }); const settings = environmentSettingsObject; let urlRecord; try { urlRecord = new URL(url, settings.settingsObject.baseUrl); __privateGet(this, _state).origin = urlRecord.origin; } catch (e) { throw new DOMException(e, "SyntaxError"); } __privateSet(this, _url, urlRecord.href); let corsAttributeState = ANONYMOUS; if (eventSourceInitDict.withCredentials) { corsAttributeState = USE_CREDENTIALS; __privateSet(this, _withCredentials, true); } const initRequest = { redirect: "follow", keepalive: true, // @see https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-settings-attributes mode: "cors", credentials: corsAttributeState === "anonymous" ? "same-origin" : "omit", referrer: "no-referrer" }; initRequest.client = environmentSettingsObject.settingsObject; initRequest.headersList = [["accept", { name: "accept", value: "text/event-stream" }]]; initRequest.cache = "no-store"; initRequest.initiator = "other"; initRequest.urlList = [new URL(__privateGet(this, _url))]; __privateSet(this, _request, makeRequest(initRequest)); __privateMethod(this, _connect, connect_fn).call(this); }
Creates a new EventSource object. @param {string} url @param {EventSourceInit} [eventSourceInitDict] @see https://html.spec.whatwg.org/multipage/server-sent-events.html#the-eventsource-interface
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get readyState() { return __privateGet(this, _readyState); }
Returns the state of this EventSource object's connection. It can have the values described below. @returns {0|1|2} @readonly
readyState
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get url() { return __privateGet(this, _url); }
Returns the URL providing the event stream. @readonly @returns {string}
url
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get withCredentials() { return __privateGet(this, _withCredentials); }
Returns a boolean indicating whether the EventSource object was instantiated with CORS credentials set (true), or not (false, the default).
withCredentials
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
close() { webidl.brandCheck(this, _EventSource); if (__privateGet(this, _readyState) === CLOSED) return; __privateSet(this, _readyState, CLOSED); __privateGet(this, _controller).abort(); __privateSet(this, _request, null); }
Closes the connection, if any, and sets the readyState attribute to CLOSED.
close
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get onopen() { return __privateGet(this, _events).open; }
Closes the connection, if any, and sets the readyState attribute to CLOSED.
onopen
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
set onopen(fn) { if (__privateGet(this, _events).open) { this.removeEventListener("open", __privateGet(this, _events).open); } if (typeof fn === "function") { __privateGet(this, _events).open = fn; this.addEventListener("open", fn); } else { __privateGet(this, _events).open = null; } }
Closes the connection, if any, and sets the readyState attribute to CLOSED.
onopen
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get onmessage() { return __privateGet(this, _events).message; }
Closes the connection, if any, and sets the readyState attribute to CLOSED.
onmessage
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
set onmessage(fn) { if (__privateGet(this, _events).message) { this.removeEventListener("message", __privateGet(this, _events).message); } if (typeof fn === "function") { __privateGet(this, _events).message = fn; this.addEventListener("message", fn); } else { __privateGet(this, _events).message = null; } }
Closes the connection, if any, and sets the readyState attribute to CLOSED.
onmessage
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
get onerror() { return __privateGet(this, _events).error; }
Closes the connection, if any, and sets the readyState attribute to CLOSED.
onerror
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
set onerror(fn) { if (__privateGet(this, _events).error) { this.removeEventListener("error", __privateGet(this, _events).error); } if (typeof fn === "function") { __privateGet(this, _events).error = fn; this.addEventListener("error", fn); } else { __privateGet(this, _events).error = null; } }
Closes the connection, if any, and sets the readyState attribute to CLOSED.
onerror
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function makeDispatcher(fn) { return (url, opts, handler) => { if (typeof opts === "function") { handler = opts; opts = null; } if (!url || typeof url !== "string" && typeof url !== "object" && !(url instanceof URL)) { throw new InvalidArgumentError("invalid url"); } if (opts != null && typeof opts !== "object") { throw new InvalidArgumentError("invalid opts"); } if (opts && opts.path != null) { if (typeof opts.path !== "string") { throw new InvalidArgumentError("invalid opts.path"); } let path = opts.path; if (!opts.path.startsWith("/")) { path = `/${path}`; } url = new URL(util.parseOrigin(url).origin + path); } else { if (!opts) { opts = typeof url === "object" ? url : {}; } url = util.parseURL(url); } const { agent, dispatcher = getGlobalDispatcher() } = opts; if (agent) { throw new InvalidArgumentError("unsupported opts.agent. Did you mean opts.client?"); } return fn.call(dispatcher, { ...opts, origin: url.origin, path: url.search ? `${url.pathname}${url.search}` : url.pathname, method: opts.method || (opts.body ? "PUT" : "GET") }, handler); }; }
Closes the connection, if any, and sets the readyState attribute to CLOSED.
makeDispatcher
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function addDuplexToInit(options) { return typeof options === "undefined" || typeof options === "object" && options.duplex === void 0 ? { duplex: "half", ...options } : options; }
Closes the connection, if any, and sets the readyState attribute to CLOSED.
addDuplexToInit
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
async function fetch(resource, options) { const res = await import_undici.default.fetch(resource, addDuplexToInit(options)); const response = new Response(res.body, res); Object.defineProperty(response, "url", { value: res.url }); return response; }
Closes the connection, if any, and sets the readyState attribute to CLOSED.
fetch
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
constructor(input, options) { super(input, addDuplexToInit(options)); }
Closes the connection, if any, and sets the readyState attribute to CLOSED.
constructor
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function load(scopedContext = {}) { const context = {}; Object.assign(context, { TextDecoder, TextEncoder, TextEncoderStream, TextDecoderStream, atob, btoa, performance }); const consoleImpl = requireWithFakeGlobalScope({ context, id: "console.js", sourceCode: require("./console.js.text.js"), scopedContext }); Object.assign(context, { console: consoleImpl.console }); const timersImpl = requireWithFakeGlobalScope({ context, id: "timers.js", sourceCode: require("./timers.js.text.js"), scopedContext }); Object.assign(context, { setTimeout: timersImpl.setTimeout, setInterval: timersImpl.setInterval }); const eventsImpl = requireWithFakeGlobalScope({ context, id: "events.js", sourceCode: require("./events.js.text.js"), scopedContext }); Object.assign(context, { Event, EventTarget, FetchEvent: eventsImpl.FetchEvent, // @ts-expect-error we need to add this to the type definitions maybe PromiseRejectionEvent: eventsImpl.PromiseRejectionEvent }); Object.assign(context, require("./stream")); const abortControllerImpl = requireWithFakeGlobalScope({ context, id: "abort-controller.js", sourceCode: require("./abort-controller.js.text.js"), scopedContext: { ...scopedContext } }); Object.assign(context, { AbortController: abortControllerImpl.AbortController, AbortSignal: abortControllerImpl.AbortSignal, DOMException: abortControllerImpl.DOMException }); const urlImpl = requireWithFakeGlobalScope({ context, id: "url.js", sourceCode: require("./url.js.text.js"), scopedContext: { ...scopedContext } }); Object.assign(context, { URL, URLSearchParams, URLPattern: urlImpl.URLPattern }); Object.assign(context, { structuredClone }); Object.assign(context, (init_fetch(), __toCommonJS(fetch_exports))); Object.assign(context, getCrypto(scopedContext)); return context; }
Closes the connection, if any, and sets the readyState attribute to CLOSED.
load
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function getCrypto(scopedContext) { if (typeof SubtleCrypto !== "undefined" || scopedContext.SubtleCrypto) { return { crypto: scopedContext.crypto || globalThis.crypto, Crypto: scopedContext.Crypto || globalThis.Crypto, CryptoKey: scopedContext.CryptoKey || globalThis.CryptoKey, SubtleCrypto: scopedContext.SubtleCrypto || globalThis.SubtleCrypto }; } else { const webcrypto = require("crypto").webcrypto; return { crypto: webcrypto, Crypto: webcrypto.constructor, CryptoKey: webcrypto.CryptoKey, SubtleCrypto: webcrypto.subtle.constructor }; } }
Closes the connection, if any, and sets the readyState attribute to CLOSED.
getCrypto
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function requireWithFakeGlobalScope(params) { const getModuleCode = `(function(module,exports,require,globalThis,${Object.keys( params.scopedContext ).join(",")}) {${params.sourceCode} })`; const module = { exports: {}, loaded: false, id: params.id }; const moduleRequire = (import_module.default.createRequire || import_module.default.createRequireFromPath)( __filename ); function throwingRequire(pathToRequire) { if (pathToRequire.startsWith("./")) { const moduleName = pathToRequire.replace(/^\.\//, ""); if (!params.cache || !params.cache.has(moduleName)) { throw new Error(`Cannot find module '${moduleName}'`); } return params.cache.get(moduleName).exports; } return moduleRequire(pathToRequire); } __name(throwingRequire, "throwingRequire"); throwingRequire.resolve = moduleRequire.resolve.bind(moduleRequire); eval(getModuleCode)( module, module.exports, throwingRequire, params.context, ...Object.values(params.scopedContext) ); return module.exports; }
Closes the connection, if any, and sets the readyState attribute to CLOSED.
requireWithFakeGlobalScope
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
function throwingRequire(pathToRequire) { if (pathToRequire.startsWith("./")) { const moduleName = pathToRequire.replace(/^\.\//, ""); if (!params.cache || !params.cache.has(moduleName)) { throw new Error(`Cannot find module '${moduleName}'`); } return params.cache.get(moduleName).exports; } return moduleRequire(pathToRequire); }
Closes the connection, if any, and sets the readyState attribute to CLOSED.
throwingRequire
javascript
vercel/next.js
packages/next/src/compiled/@edge-runtime/primitives/load.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
MIT
constructor() { this._array = []; this._set = new Map(); }
A data structure which is a combination of an array and a set. Adding a new member is O(1), testing for membership is O(1), and finding the index of an element is O(1). Removing elements from the set is not supported. Only strings are supported for membership.
constructor
javascript
vercel/next.js
packages/next/src/compiled/source-map08/source-map.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js
MIT
static fromArray(aArray, aAllowDuplicates) { const set = new ArraySet(); for (let i = 0, len = aArray.length; i < len; i++) { set.add(aArray[i], aAllowDuplicates); } return set; }
Static method for creating ArraySet instances from an existing array.
fromArray
javascript
vercel/next.js
packages/next/src/compiled/source-map08/source-map.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js
MIT
size() { return this._set.size; }
Return how many unique items are in this ArraySet. If duplicates have been added, than those do not count towards the size. @returns Number
size
javascript
vercel/next.js
packages/next/src/compiled/source-map08/source-map.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js
MIT
add(aStr, aAllowDuplicates) { const isDuplicate = this.has(aStr); const idx = this._array.length; if (!isDuplicate || aAllowDuplicates) { this._array.push(aStr); } if (!isDuplicate) { this._set.set(aStr, idx); } }
Add the given string to this set. @param String aStr
add
javascript
vercel/next.js
packages/next/src/compiled/source-map08/source-map.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js
MIT
has(aStr) { return this._set.has(aStr); }
Is the given string a member of this set? @param String aStr
has
javascript
vercel/next.js
packages/next/src/compiled/source-map08/source-map.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js
MIT
indexOf(aStr) { const idx = this._set.get(aStr); if (idx >= 0) { return idx; } throw new Error('"' + aStr + '" is not in the set.'); }
What is the index of the given string in the array? @param String aStr
indexOf
javascript
vercel/next.js
packages/next/src/compiled/source-map08/source-map.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js
MIT
at(aIdx) { if (aIdx >= 0 && aIdx < this._array.length) { return this._array[aIdx]; } throw new Error("No element indexed by " + aIdx); }
What is the element at the given index? @param Number aIdx
at
javascript
vercel/next.js
packages/next/src/compiled/source-map08/source-map.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js
MIT
toArray() { return this._array.slice(); }
Returns the array representation of this set (which has the proper indices indicated by indexOf). Note that this is a copy of the internal array used for storing the members so that no one can mess with internal state.
toArray
javascript
vercel/next.js
packages/next/src/compiled/source-map08/source-map.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js
MIT
function toVLQSigned(aValue) { return aValue < 0 ? ((-aValue) << 1) + 1 : (aValue << 1) + 0; }
Converts from a two-complement value to a value where the sign bit is placed in the least significant bit. For example, as decimals: 1 becomes 2 (10 binary), -1 becomes 3 (11 binary) 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
toVLQSigned
javascript
vercel/next.js
packages/next/src/compiled/source-map08/source-map.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js
MIT
function fromVLQSigned(aValue) { const isNegative = (aValue & 1) === 1; const shifted = aValue >> 1; return isNegative ? -shifted : shifted; }
Converts to a two-complement value from a value where the sign bit is placed in the least significant bit. For example, as decimals: 2 (10 binary) becomes 1, 3 (11 binary) becomes -1 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
fromVLQSigned
javascript
vercel/next.js
packages/next/src/compiled/source-map08/source-map.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js
MIT
function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) { // This function terminates when one of the following is true: // // 1. We find the exact element we are looking for. // // 2. We did not find the exact element, but we can return the index of // the next-closest element. // // 3. We did not find the exact element, and there is no next-closest // element than the one we are searching for, so we return -1. const mid = Math.floor((aHigh - aLow) / 2) + aLow; const cmp = aCompare(aNeedle, aHaystack[mid], true); if (cmp === 0) { // Found the element we are looking for. return mid; } else if (cmp > 0) { // Our needle is greater than aHaystack[mid]. if (aHigh - mid > 1) { // The element is in the upper half. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias); } // The exact needle element was not found in this haystack. Determine if // we are in termination case (3) or (2) and return the appropriate thing. if (aBias == exports.LEAST_UPPER_BOUND) { return aHigh < aHaystack.length ? aHigh : -1; } return mid; } // Our needle is less than aHaystack[mid]. if (mid - aLow > 1) { // The element is in the lower half. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias); } // we are in termination case (3) or (2) and return the appropriate thing. if (aBias == exports.LEAST_UPPER_BOUND) { return mid; } return aLow < 0 ? -1 : aLow; }
Recursive implementation of binary search. @param aLow Indices here and lower do not contain the needle. @param aHigh Indices here and higher do not contain the needle. @param aNeedle The element being searched for. @param aHaystack The non-empty array being searched. @param aCompare Function which takes two elements and returns -1, 0, or 1. @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the closest element that is smaller than or greater than the one we are searching for, respectively, if the exact element cannot be found.
recursiveSearch
javascript
vercel/next.js
packages/next/src/compiled/source-map08/source-map.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js
MIT
function generatedPositionAfter(mappingA, mappingB) { // Optimized for most common case const lineA = mappingA.generatedLine; const lineB = mappingB.generatedLine; const columnA = mappingA.generatedColumn; const columnB = mappingB.generatedColumn; return lineB > lineA || lineB == lineA && columnB >= columnA || util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0; }
Determine whether mappingB is after mappingA with respect to generated position.
generatedPositionAfter
javascript
vercel/next.js
packages/next/src/compiled/source-map08/source-map.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js
MIT
constructor() { this._array = []; this._sorted = true; // Serves as infimum this._last = {generatedLine: -1, generatedColumn: 0}; }
A data structure to provide a sorted view of accumulated mappings in a performance conscious manner. It trades a negligible overhead in general case for a large speedup in case of mappings being added in order.
constructor
javascript
vercel/next.js
packages/next/src/compiled/source-map08/source-map.js
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js
MIT