WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
SemVer: require('./semver.js'),
|
||||
Range: require('./range.js'),
|
||||
Comparator: require('./comparator.js'),
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import RAL from './ral';
|
||||
export declare abstract class AbstractMessageBuffer implements RAL.MessageBuffer {
|
||||
private _encoding;
|
||||
private _chunks;
|
||||
private _totalLength;
|
||||
constructor(encoding?: RAL.MessageBufferEncoding);
|
||||
protected abstract emptyBuffer(): Uint8Array;
|
||||
protected abstract fromString(value: string, encoding: RAL.MessageBufferEncoding): Uint8Array;
|
||||
protected abstract toString(value: Uint8Array, encoding: RAL.MessageBufferEncoding): string;
|
||||
protected abstract asNative(buffer: Uint8Array, length?: number): Uint8Array;
|
||||
protected abstract allocNative(length: number): Uint8Array;
|
||||
get encoding(): RAL.MessageBufferEncoding;
|
||||
append(chunk: Uint8Array | string): void;
|
||||
tryReadHeaders(lowerCaseKeys?: boolean): Map<string, string> | undefined;
|
||||
tryReadBody(length: number): Uint8Array | undefined;
|
||||
get numberOfBytes(): number;
|
||||
private _read;
|
||||
}
|
||||
@@ -0,0 +1,418 @@
|
||||
/**
|
||||
* @fileoverview Rule to require braces in arrow function body.
|
||||
* @author Alberto Rodríguez
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
defaultOptions: ["as-needed"],
|
||||
|
||||
docs: {
|
||||
description: "Require braces around arrow function bodies",
|
||||
recommended: false,
|
||||
frozen: true,
|
||||
url: "https://eslint.org/docs/latest/rules/arrow-body-style",
|
||||
},
|
||||
|
||||
schema: {
|
||||
anyOf: [
|
||||
{
|
||||
type: "array",
|
||||
items: [
|
||||
{
|
||||
enum: ["always", "never"],
|
||||
},
|
||||
],
|
||||
minItems: 0,
|
||||
maxItems: 1,
|
||||
},
|
||||
{
|
||||
type: "array",
|
||||
items: [
|
||||
{
|
||||
enum: ["as-needed"],
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
requireReturnForObjectLiteral: {
|
||||
type: "boolean",
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
minItems: 0,
|
||||
maxItems: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
fixable: "code",
|
||||
|
||||
messages: {
|
||||
unexpectedOtherBlock:
|
||||
"Unexpected block statement surrounding arrow body.",
|
||||
unexpectedEmptyBlock:
|
||||
"Unexpected block statement surrounding arrow body; put a value of `undefined` immediately after the `=>`.",
|
||||
unexpectedObjectBlock:
|
||||
"Unexpected block statement surrounding arrow body; parenthesize the returned value and move it immediately after the `=>`.",
|
||||
unexpectedSingleBlock:
|
||||
"Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`.",
|
||||
expectedBlock: "Expected block statement surrounding arrow body.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const options = context.options;
|
||||
const always = options[0] === "always";
|
||||
const asNeeded = options[0] === "as-needed";
|
||||
const never = options[0] === "never";
|
||||
const requireReturnForObjectLiteral =
|
||||
options[1] && options[1].requireReturnForObjectLiteral;
|
||||
const sourceCode = context.sourceCode;
|
||||
let funcInfo = null;
|
||||
|
||||
/**
|
||||
* Checks whether the given node has ASI problem or not.
|
||||
* @param {Token} token The token to check.
|
||||
* @returns {boolean} `true` if it changes semantics if `;` or `}` followed by the token are removed.
|
||||
*/
|
||||
function hasASIProblem(token) {
|
||||
return (
|
||||
token &&
|
||||
token.type === "Punctuator" &&
|
||||
/^[([/`+-]/u.test(token.value)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the closing parenthesis by the given node.
|
||||
* @param {ASTNode} node first node after an opening parenthesis.
|
||||
* @returns {Token} The found closing parenthesis token.
|
||||
*/
|
||||
function findClosingParen(node) {
|
||||
let nodeToCheck = node;
|
||||
|
||||
while (!astUtils.isParenthesised(sourceCode, nodeToCheck)) {
|
||||
nodeToCheck = nodeToCheck.parent;
|
||||
}
|
||||
return sourceCode.getTokenAfter(nodeToCheck);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the node is inside of a for loop's init
|
||||
* @param {ASTNode} node node is inside for loop
|
||||
* @returns {boolean} `true` if the node is inside of a for loop, else `false`
|
||||
*/
|
||||
function isInsideForLoopInitializer(node) {
|
||||
if (node && node.parent) {
|
||||
if (
|
||||
node.parent.type === "ForStatement" &&
|
||||
node.parent.init === node
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return isInsideForLoopInitializer(node.parent);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a arrow function body needs braces
|
||||
* @param {ASTNode} node The arrow function node.
|
||||
* @returns {void}
|
||||
*/
|
||||
function validate(node) {
|
||||
const arrowBody = node.body;
|
||||
|
||||
if (arrowBody.type === "BlockStatement") {
|
||||
const blockBody = arrowBody.body;
|
||||
|
||||
if (blockBody.length !== 1 && !never) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
asNeeded &&
|
||||
requireReturnForObjectLiteral &&
|
||||
blockBody[0].type === "ReturnStatement" &&
|
||||
blockBody[0].argument &&
|
||||
blockBody[0].argument.type === "ObjectExpression"
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
never ||
|
||||
(asNeeded && blockBody[0].type === "ReturnStatement")
|
||||
) {
|
||||
let messageId;
|
||||
|
||||
if (blockBody.length === 0) {
|
||||
messageId = "unexpectedEmptyBlock";
|
||||
} else if (
|
||||
blockBody.length > 1 ||
|
||||
blockBody[0].type !== "ReturnStatement"
|
||||
) {
|
||||
messageId = "unexpectedOtherBlock";
|
||||
} else if (blockBody[0].argument === null) {
|
||||
messageId = "unexpectedSingleBlock";
|
||||
} else if (
|
||||
astUtils.isOpeningBraceToken(
|
||||
sourceCode.getFirstToken(blockBody[0], { skip: 1 }),
|
||||
)
|
||||
) {
|
||||
messageId = "unexpectedObjectBlock";
|
||||
} else {
|
||||
messageId = "unexpectedSingleBlock";
|
||||
}
|
||||
|
||||
context.report({
|
||||
node,
|
||||
loc: arrowBody.loc,
|
||||
messageId,
|
||||
fix(fixer) {
|
||||
const fixes = [];
|
||||
|
||||
if (
|
||||
blockBody.length !== 1 ||
|
||||
blockBody[0].type !== "ReturnStatement" ||
|
||||
!blockBody[0].argument ||
|
||||
hasASIProblem(
|
||||
sourceCode.getTokenAfter(arrowBody),
|
||||
)
|
||||
) {
|
||||
return fixes;
|
||||
}
|
||||
|
||||
const openingBrace =
|
||||
sourceCode.getFirstToken(arrowBody);
|
||||
const closingBrace =
|
||||
sourceCode.getLastToken(arrowBody);
|
||||
const firstValueToken = sourceCode.getFirstToken(
|
||||
blockBody[0],
|
||||
1,
|
||||
);
|
||||
const lastValueToken = sourceCode.getLastToken(
|
||||
blockBody[0],
|
||||
);
|
||||
const commentsExist =
|
||||
sourceCode.commentsExistBetween(
|
||||
openingBrace,
|
||||
firstValueToken,
|
||||
) ||
|
||||
sourceCode.commentsExistBetween(
|
||||
lastValueToken,
|
||||
closingBrace,
|
||||
);
|
||||
|
||||
/*
|
||||
* Remove tokens around the return value.
|
||||
* If comments don't exist, remove extra spaces as well.
|
||||
*/
|
||||
if (commentsExist) {
|
||||
fixes.push(
|
||||
fixer.remove(openingBrace),
|
||||
fixer.remove(closingBrace),
|
||||
fixer.remove(
|
||||
sourceCode.getTokenAfter(openingBrace),
|
||||
), // return keyword
|
||||
);
|
||||
} else {
|
||||
fixes.push(
|
||||
fixer.removeRange([
|
||||
openingBrace.range[0],
|
||||
firstValueToken.range[0],
|
||||
]),
|
||||
fixer.removeRange([
|
||||
lastValueToken.range[1],
|
||||
closingBrace.range[1],
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the first token of the return value is `{` or the return value is a sequence expression,
|
||||
* enclose the return value by parentheses to avoid syntax error.
|
||||
*/
|
||||
if (
|
||||
astUtils.isOpeningBraceToken(firstValueToken) ||
|
||||
blockBody[0].argument.type ===
|
||||
"SequenceExpression" ||
|
||||
(funcInfo.hasInOperator &&
|
||||
isInsideForLoopInitializer(node))
|
||||
) {
|
||||
if (
|
||||
!astUtils.isParenthesised(
|
||||
sourceCode,
|
||||
blockBody[0].argument,
|
||||
)
|
||||
) {
|
||||
fixes.push(
|
||||
fixer.insertTextBefore(
|
||||
firstValueToken,
|
||||
"(",
|
||||
),
|
||||
fixer.insertTextAfter(
|
||||
lastValueToken,
|
||||
")",
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If the last token of the return statement is semicolon, remove it.
|
||||
* Non-block arrow body is an expression, not a statement.
|
||||
*/
|
||||
if (astUtils.isSemicolonToken(lastValueToken)) {
|
||||
fixes.push(fixer.remove(lastValueToken));
|
||||
}
|
||||
|
||||
return fixes;
|
||||
},
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
always ||
|
||||
(asNeeded &&
|
||||
requireReturnForObjectLiteral &&
|
||||
arrowBody.type === "ObjectExpression")
|
||||
) {
|
||||
context.report({
|
||||
node,
|
||||
loc: arrowBody.loc,
|
||||
messageId: "expectedBlock",
|
||||
fix(fixer) {
|
||||
const fixes = [];
|
||||
const arrowToken = sourceCode.getTokenBefore(
|
||||
arrowBody,
|
||||
astUtils.isArrowToken,
|
||||
);
|
||||
const [
|
||||
firstTokenAfterArrow,
|
||||
secondTokenAfterArrow,
|
||||
] = sourceCode.getTokensAfter(arrowToken, {
|
||||
count: 2,
|
||||
});
|
||||
const lastToken = sourceCode.getLastToken(node);
|
||||
|
||||
let parenthesisedObjectLiteral = null;
|
||||
|
||||
if (
|
||||
astUtils.isOpeningParenToken(
|
||||
firstTokenAfterArrow,
|
||||
) &&
|
||||
astUtils.isOpeningBraceToken(
|
||||
secondTokenAfterArrow,
|
||||
)
|
||||
) {
|
||||
const braceNode =
|
||||
sourceCode.getNodeByRangeIndex(
|
||||
secondTokenAfterArrow.range[0],
|
||||
);
|
||||
|
||||
if (braceNode.type === "ObjectExpression") {
|
||||
parenthesisedObjectLiteral = braceNode;
|
||||
}
|
||||
}
|
||||
|
||||
// If the value is object literal, remove parentheses which were forced by syntax.
|
||||
if (parenthesisedObjectLiteral) {
|
||||
const openingParenToken = firstTokenAfterArrow;
|
||||
const openingBraceToken = secondTokenAfterArrow;
|
||||
|
||||
if (
|
||||
astUtils.isTokenOnSameLine(
|
||||
openingParenToken,
|
||||
openingBraceToken,
|
||||
)
|
||||
) {
|
||||
fixes.push(
|
||||
fixer.replaceText(
|
||||
openingParenToken,
|
||||
"{return ",
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// Avoid ASI
|
||||
fixes.push(
|
||||
fixer.replaceText(
|
||||
openingParenToken,
|
||||
"{",
|
||||
),
|
||||
fixer.insertTextBefore(
|
||||
openingBraceToken,
|
||||
"return ",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Closing paren for the object doesn't have to be lastToken, e.g.: () => ({}).foo()
|
||||
fixes.push(
|
||||
fixer.remove(
|
||||
findClosingParen(
|
||||
parenthesisedObjectLiteral,
|
||||
),
|
||||
),
|
||||
);
|
||||
fixes.push(
|
||||
fixer.insertTextAfter(lastToken, "}"),
|
||||
);
|
||||
} else {
|
||||
fixes.push(
|
||||
fixer.insertTextBefore(
|
||||
firstTokenAfterArrow,
|
||||
"{return ",
|
||||
),
|
||||
);
|
||||
fixes.push(
|
||||
fixer.insertTextAfter(lastToken, "}"),
|
||||
);
|
||||
}
|
||||
|
||||
return fixes;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
"BinaryExpression[operator='in']"() {
|
||||
let info = funcInfo;
|
||||
|
||||
while (info) {
|
||||
info.hasInOperator = true;
|
||||
info = info.upper;
|
||||
}
|
||||
},
|
||||
ArrowFunctionExpression() {
|
||||
funcInfo = {
|
||||
upper: funcInfo,
|
||||
hasInOperator: false,
|
||||
};
|
||||
},
|
||||
"ArrowFunctionExpression:exit"(node) {
|
||||
validate(node);
|
||||
funcInfo = funcInfo.upper;
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,2 @@
|
||||
import type { LibDefinition } from '../variable';
|
||||
export declare const es2025_regexp: LibDefinition;
|
||||
@@ -0,0 +1,2 @@
|
||||
import type { LibDefinition } from '../variable';
|
||||
export declare const esnext_float16: LibDefinition;
|
||||
@@ -0,0 +1,409 @@
|
||||
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^net|tls$" }] */
|
||||
|
||||
'use strict';
|
||||
|
||||
const net = require('net');
|
||||
const tls = require('tls');
|
||||
const { randomFillSync } = require('crypto');
|
||||
|
||||
const PerMessageDeflate = require('./permessage-deflate');
|
||||
const { EMPTY_BUFFER } = require('./constants');
|
||||
const { isValidStatusCode } = require('./validation');
|
||||
const { mask: applyMask, toBuffer } = require('./buffer-util');
|
||||
|
||||
const mask = Buffer.alloc(4);
|
||||
|
||||
/**
|
||||
* HyBi Sender implementation.
|
||||
*/
|
||||
class Sender {
|
||||
/**
|
||||
* Creates a Sender instance.
|
||||
*
|
||||
* @param {(net.Socket|tls.Socket)} socket The connection socket
|
||||
* @param {Object} [extensions] An object containing the negotiated extensions
|
||||
*/
|
||||
constructor(socket, extensions) {
|
||||
this._extensions = extensions || {};
|
||||
this._socket = socket;
|
||||
|
||||
this._firstFragment = true;
|
||||
this._compress = false;
|
||||
|
||||
this._bufferedBytes = 0;
|
||||
this._deflating = false;
|
||||
this._queue = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Frames a piece of data according to the HyBi WebSocket protocol.
|
||||
*
|
||||
* @param {Buffer} data The data to frame
|
||||
* @param {Object} options Options object
|
||||
* @param {Number} options.opcode The opcode
|
||||
* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
|
||||
* modified
|
||||
* @param {Boolean} [options.fin=false] Specifies whether or not to set the
|
||||
* FIN bit
|
||||
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
||||
* `data`
|
||||
* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
|
||||
* RSV1 bit
|
||||
* @return {Buffer[]} The framed data as a list of `Buffer` instances
|
||||
* @public
|
||||
*/
|
||||
static frame(data, options) {
|
||||
const merge = options.mask && options.readOnly;
|
||||
let offset = options.mask ? 6 : 2;
|
||||
let payloadLength = data.length;
|
||||
|
||||
if (data.length >= 65536) {
|
||||
offset += 8;
|
||||
payloadLength = 127;
|
||||
} else if (data.length > 125) {
|
||||
offset += 2;
|
||||
payloadLength = 126;
|
||||
}
|
||||
|
||||
const target = Buffer.allocUnsafe(merge ? data.length + offset : offset);
|
||||
|
||||
target[0] = options.fin ? options.opcode | 0x80 : options.opcode;
|
||||
if (options.rsv1) target[0] |= 0x40;
|
||||
|
||||
target[1] = payloadLength;
|
||||
|
||||
if (payloadLength === 126) {
|
||||
target.writeUInt16BE(data.length, 2);
|
||||
} else if (payloadLength === 127) {
|
||||
target.writeUInt32BE(0, 2);
|
||||
target.writeUInt32BE(data.length, 6);
|
||||
}
|
||||
|
||||
if (!options.mask) return [target, data];
|
||||
|
||||
randomFillSync(mask, 0, 4);
|
||||
|
||||
target[1] |= 0x80;
|
||||
target[offset - 4] = mask[0];
|
||||
target[offset - 3] = mask[1];
|
||||
target[offset - 2] = mask[2];
|
||||
target[offset - 1] = mask[3];
|
||||
|
||||
if (merge) {
|
||||
applyMask(data, mask, target, offset, data.length);
|
||||
return [target];
|
||||
}
|
||||
|
||||
applyMask(data, mask, data, 0, data.length);
|
||||
return [target, data];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a close message to the other peer.
|
||||
*
|
||||
* @param {Number} [code] The status code component of the body
|
||||
* @param {String} [data] The message component of the body
|
||||
* @param {Boolean} [mask=false] Specifies whether or not to mask the message
|
||||
* @param {Function} [cb] Callback
|
||||
* @public
|
||||
*/
|
||||
close(code, data, mask, cb) {
|
||||
let buf;
|
||||
|
||||
if (code === undefined) {
|
||||
buf = EMPTY_BUFFER;
|
||||
} else if (typeof code !== 'number' || !isValidStatusCode(code)) {
|
||||
throw new TypeError('First argument must be a valid error code number');
|
||||
} else if (data === undefined || data === '') {
|
||||
buf = Buffer.allocUnsafe(2);
|
||||
buf.writeUInt16BE(code, 0);
|
||||
} else {
|
||||
const length = Buffer.byteLength(data);
|
||||
|
||||
if (length > 123) {
|
||||
throw new RangeError('The message must not be greater than 123 bytes');
|
||||
}
|
||||
|
||||
buf = Buffer.allocUnsafe(2 + length);
|
||||
buf.writeUInt16BE(code, 0);
|
||||
buf.write(data, 2);
|
||||
}
|
||||
|
||||
if (this._deflating) {
|
||||
this.enqueue([this.doClose, buf, mask, cb]);
|
||||
} else {
|
||||
this.doClose(buf, mask, cb);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Frames and sends a close message.
|
||||
*
|
||||
* @param {Buffer} data The message to send
|
||||
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
||||
* @param {Function} [cb] Callback
|
||||
* @private
|
||||
*/
|
||||
doClose(data, mask, cb) {
|
||||
this.sendFrame(
|
||||
Sender.frame(data, {
|
||||
fin: true,
|
||||
rsv1: false,
|
||||
opcode: 0x08,
|
||||
mask,
|
||||
readOnly: false
|
||||
}),
|
||||
cb
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a ping message to the other peer.
|
||||
*
|
||||
* @param {*} data The message to send
|
||||
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
||||
* @param {Function} [cb] Callback
|
||||
* @public
|
||||
*/
|
||||
ping(data, mask, cb) {
|
||||
const buf = toBuffer(data);
|
||||
|
||||
if (buf.length > 125) {
|
||||
throw new RangeError('The data size must not be greater than 125 bytes');
|
||||
}
|
||||
|
||||
if (this._deflating) {
|
||||
this.enqueue([this.doPing, buf, mask, toBuffer.readOnly, cb]);
|
||||
} else {
|
||||
this.doPing(buf, mask, toBuffer.readOnly, cb);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Frames and sends a ping message.
|
||||
*
|
||||
* @param {Buffer} data The message to send
|
||||
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
||||
* @param {Boolean} [readOnly=false] Specifies whether `data` can be modified
|
||||
* @param {Function} [cb] Callback
|
||||
* @private
|
||||
*/
|
||||
doPing(data, mask, readOnly, cb) {
|
||||
this.sendFrame(
|
||||
Sender.frame(data, {
|
||||
fin: true,
|
||||
rsv1: false,
|
||||
opcode: 0x09,
|
||||
mask,
|
||||
readOnly
|
||||
}),
|
||||
cb
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a pong message to the other peer.
|
||||
*
|
||||
* @param {*} data The message to send
|
||||
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
||||
* @param {Function} [cb] Callback
|
||||
* @public
|
||||
*/
|
||||
pong(data, mask, cb) {
|
||||
const buf = toBuffer(data);
|
||||
|
||||
if (buf.length > 125) {
|
||||
throw new RangeError('The data size must not be greater than 125 bytes');
|
||||
}
|
||||
|
||||
if (this._deflating) {
|
||||
this.enqueue([this.doPong, buf, mask, toBuffer.readOnly, cb]);
|
||||
} else {
|
||||
this.doPong(buf, mask, toBuffer.readOnly, cb);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Frames and sends a pong message.
|
||||
*
|
||||
* @param {Buffer} data The message to send
|
||||
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
||||
* @param {Boolean} [readOnly=false] Specifies whether `data` can be modified
|
||||
* @param {Function} [cb] Callback
|
||||
* @private
|
||||
*/
|
||||
doPong(data, mask, readOnly, cb) {
|
||||
this.sendFrame(
|
||||
Sender.frame(data, {
|
||||
fin: true,
|
||||
rsv1: false,
|
||||
opcode: 0x0a,
|
||||
mask,
|
||||
readOnly
|
||||
}),
|
||||
cb
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a data message to the other peer.
|
||||
*
|
||||
* @param {*} data The message to send
|
||||
* @param {Object} options Options object
|
||||
* @param {Boolean} [options.compress=false] Specifies whether or not to
|
||||
* compress `data`
|
||||
* @param {Boolean} [options.binary=false] Specifies whether `data` is binary
|
||||
* or text
|
||||
* @param {Boolean} [options.fin=false] Specifies whether the fragment is the
|
||||
* last one
|
||||
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
||||
* `data`
|
||||
* @param {Function} [cb] Callback
|
||||
* @public
|
||||
*/
|
||||
send(data, options, cb) {
|
||||
const buf = toBuffer(data);
|
||||
const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
|
||||
let opcode = options.binary ? 2 : 1;
|
||||
let rsv1 = options.compress;
|
||||
|
||||
if (this._firstFragment) {
|
||||
this._firstFragment = false;
|
||||
if (rsv1 && perMessageDeflate) {
|
||||
rsv1 = buf.length >= perMessageDeflate._threshold;
|
||||
}
|
||||
this._compress = rsv1;
|
||||
} else {
|
||||
rsv1 = false;
|
||||
opcode = 0;
|
||||
}
|
||||
|
||||
if (options.fin) this._firstFragment = true;
|
||||
|
||||
if (perMessageDeflate) {
|
||||
const opts = {
|
||||
fin: options.fin,
|
||||
rsv1,
|
||||
opcode,
|
||||
mask: options.mask,
|
||||
readOnly: toBuffer.readOnly
|
||||
};
|
||||
|
||||
if (this._deflating) {
|
||||
this.enqueue([this.dispatch, buf, this._compress, opts, cb]);
|
||||
} else {
|
||||
this.dispatch(buf, this._compress, opts, cb);
|
||||
}
|
||||
} else {
|
||||
this.sendFrame(
|
||||
Sender.frame(buf, {
|
||||
fin: options.fin,
|
||||
rsv1: false,
|
||||
opcode,
|
||||
mask: options.mask,
|
||||
readOnly: toBuffer.readOnly
|
||||
}),
|
||||
cb
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches a data message.
|
||||
*
|
||||
* @param {Buffer} data The message to send
|
||||
* @param {Boolean} [compress=false] Specifies whether or not to compress
|
||||
* `data`
|
||||
* @param {Object} options Options object
|
||||
* @param {Number} options.opcode The opcode
|
||||
* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
|
||||
* modified
|
||||
* @param {Boolean} [options.fin=false] Specifies whether or not to set the
|
||||
* FIN bit
|
||||
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
||||
* `data`
|
||||
* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
|
||||
* RSV1 bit
|
||||
* @param {Function} [cb] Callback
|
||||
* @private
|
||||
*/
|
||||
dispatch(data, compress, options, cb) {
|
||||
if (!compress) {
|
||||
this.sendFrame(Sender.frame(data, options), cb);
|
||||
return;
|
||||
}
|
||||
|
||||
const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
|
||||
|
||||
this._bufferedBytes += data.length;
|
||||
this._deflating = true;
|
||||
perMessageDeflate.compress(data, options.fin, (_, buf) => {
|
||||
if (this._socket.destroyed) {
|
||||
const err = new Error(
|
||||
'The socket was closed while data was being compressed'
|
||||
);
|
||||
|
||||
if (typeof cb === 'function') cb(err);
|
||||
|
||||
for (let i = 0; i < this._queue.length; i++) {
|
||||
const callback = this._queue[i][4];
|
||||
|
||||
if (typeof callback === 'function') callback(err);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this._bufferedBytes -= data.length;
|
||||
this._deflating = false;
|
||||
options.readOnly = false;
|
||||
this.sendFrame(Sender.frame(buf, options), cb);
|
||||
this.dequeue();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes queued send operations.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
dequeue() {
|
||||
while (!this._deflating && this._queue.length) {
|
||||
const params = this._queue.shift();
|
||||
|
||||
this._bufferedBytes -= params[1].length;
|
||||
Reflect.apply(params[0], this, params.slice(1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueues a send operation.
|
||||
*
|
||||
* @param {Array} params Send operation parameters.
|
||||
* @private
|
||||
*/
|
||||
enqueue(params) {
|
||||
this._bufferedBytes += params[1].length;
|
||||
this._queue.push(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a frame.
|
||||
*
|
||||
* @param {Buffer[]} list The frame to send
|
||||
* @param {Function} [cb] Callback
|
||||
* @private
|
||||
*/
|
||||
sendFrame(list, cb) {
|
||||
if (list.length === 2) {
|
||||
this._socket.cork();
|
||||
this._socket.write(list[0]);
|
||||
this._socket.write(list[1], cb);
|
||||
this._socket.uncork();
|
||||
} else {
|
||||
this._socket.write(list[0], cb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Sender;
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* NIST secp384r1 aka p384.
|
||||
* @module
|
||||
*/
|
||||
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||||
import { type H2CMethod } from './abstract/hash-to-curve.ts';
|
||||
import { p384_hasher, p384 as p384n } from './nist.ts';
|
||||
/** @deprecated use `import { p384 } from '@noble/curves/nist.js';` */
|
||||
export const p384: typeof p384n = p384n;
|
||||
/** @deprecated use `import { p384 } from '@noble/curves/nist.js';` */
|
||||
export const secp384r1: typeof p384n = p384n;
|
||||
/** @deprecated use `import { p384_hasher } from '@noble/curves/nist.js';` */
|
||||
export const hashToCurve: H2CMethod<bigint> = /* @__PURE__ */ (() => p384_hasher.hashToCurve)();
|
||||
/** @deprecated use `import { p384_hasher } from '@noble/curves/nist.js';` */
|
||||
export const encodeToCurve: H2CMethod<bigint> = /* @__PURE__ */ (() => p384_hasher.encodeToCurve)();
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"regularExpressionFlags.enum.js","sourceRoot":"","sources":["../../src/enums/regularExpressionFlags.enum.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,sBAWX;AAXD,WAAY,sBAAsB;IAC9B,mEAAQ,CAAA;IACR,+EAAmB,CAAA;IACnB,uEAAe,CAAA;IACf,+EAAmB,CAAA;IACnB,6EAAkB,CAAA;IAClB,wEAAe,CAAA;IACf,0EAAgB,CAAA;IAChB,kFAAoB,CAAA;IACpB,yEAAe,CAAA;IACf,wFAAsC,CAAA;AAC1C,CAAC,EAXW,sBAAsB,KAAtB,sBAAsB,QAWjC"}
|
||||
@@ -0,0 +1,124 @@
|
||||
import _typeof from "./typeof.js";
|
||||
import checkInRHS from "./checkInRHS.js";
|
||||
import setFunctionName from "./setFunctionName.js";
|
||||
import toPropertyKey from "./toPropertyKey.js";
|
||||
function applyDecs2311(e, t, n, r, o, i) {
|
||||
var a,
|
||||
c,
|
||||
u,
|
||||
s,
|
||||
f,
|
||||
l,
|
||||
p,
|
||||
d = Symbol.metadata || Symbol["for"]("Symbol.metadata"),
|
||||
m = Object.defineProperty,
|
||||
h = Object.create,
|
||||
y = [h(null), h(null)],
|
||||
v = t.length;
|
||||
function g(t, n, r) {
|
||||
return function (o, i) {
|
||||
n && (i = o, o = e);
|
||||
for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []);
|
||||
return r ? i : o;
|
||||
};
|
||||
}
|
||||
function b(e, t, n, r) {
|
||||
if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined"));
|
||||
return e;
|
||||
}
|
||||
function applyDec(e, t, n, r, o, i, u, s, f, l, p) {
|
||||
function d(e) {
|
||||
if (!p(e)) throw new TypeError("Attempted to access private element on non-instance");
|
||||
}
|
||||
var h = [].concat(t[0]),
|
||||
v = t[3],
|
||||
w = !u,
|
||||
D = 1 === o,
|
||||
S = 3 === o,
|
||||
j = 4 === o,
|
||||
E = 2 === o;
|
||||
function I(t, n, r) {
|
||||
return function (o, i) {
|
||||
return n && (i = o, o = e), r && r(o), P[t].call(o, i);
|
||||
};
|
||||
}
|
||||
if (!w) {
|
||||
var P = {},
|
||||
k = [],
|
||||
F = S ? "get" : j || D ? "set" : "value";
|
||||
if (f ? (l || D ? P = {
|
||||
get: setFunctionName(function () {
|
||||
return v(this);
|
||||
}, r, "get"),
|
||||
set: function set(e) {
|
||||
t[4](this, e);
|
||||
}
|
||||
} : P[F] = v, l || setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) {
|
||||
if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet");
|
||||
y[+s][r] = o < 3 ? 1 : o;
|
||||
}
|
||||
}
|
||||
for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) {
|
||||
var T = b(h[O], "A decorator", "be", !0),
|
||||
z = n ? h[O - 1] : void 0,
|
||||
A = {},
|
||||
H = {
|
||||
kind: ["field", "accessor", "method", "getter", "setter", "class"][o],
|
||||
name: r,
|
||||
metadata: a,
|
||||
addInitializer: function (e, t) {
|
||||
if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished");
|
||||
b(t, "An initializer", "be", !0), i.push(t);
|
||||
}.bind(null, A)
|
||||
};
|
||||
if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H["static"] = s, H["private"] = f, c = H.access = {
|
||||
has: f ? p.bind() : function (e) {
|
||||
return r in e;
|
||||
}
|
||||
}, j || (c.get = f ? E ? function (e) {
|
||||
return d(e), P.value;
|
||||
} : I("get", 0, d) : function (e) {
|
||||
return e[r];
|
||||
}), E || S || (c.set = f ? I("set", 0, d) : function (e, t) {
|
||||
e[r] = t;
|
||||
}), N = T.call(z, D ? {
|
||||
get: P.get,
|
||||
set: P.set
|
||||
} : P[F], H), A.v = 1, D) {
|
||||
if ("object" == _typeof(N) && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined");
|
||||
} else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N);
|
||||
}
|
||||
return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N;
|
||||
}
|
||||
function w(e) {
|
||||
return m(e, d, {
|
||||
configurable: !0,
|
||||
enumerable: !0,
|
||||
value: a
|
||||
});
|
||||
}
|
||||
return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function l(e) {
|
||||
e && f.push(g(e));
|
||||
}, p = function p(t, r) {
|
||||
for (var i = 0; i < n.length; i++) {
|
||||
var a = n[i],
|
||||
c = a[1],
|
||||
l = 7 & c;
|
||||
if ((8 & c) == t && !l == r) {
|
||||
var p = a[2],
|
||||
d = !!a[3],
|
||||
m = 16 & c;
|
||||
applyDec(t ? e : e.prototype, a, m, d ? "#" + p : toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) {
|
||||
return checkInRHS(t) === e;
|
||||
} : o);
|
||||
}
|
||||
}
|
||||
}, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), {
|
||||
e: c,
|
||||
get c() {
|
||||
var n = [];
|
||||
return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)];
|
||||
}
|
||||
};
|
||||
}
|
||||
export { applyDecs2311 as default };
|
||||
@@ -0,0 +1,8 @@
|
||||
function _taggedTemplateLiteral(e, t) {
|
||||
return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, {
|
||||
raw: {
|
||||
value: Object.freeze(t)
|
||||
}
|
||||
}));
|
||||
}
|
||||
module.exports = _taggedTemplateLiteral, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @fileoverview Types for the config-array package.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
/**
|
||||
* A file matcher used in `files` and `ignores`.
|
||||
*/
|
||||
export type FileMatcher = string | ((filePath: string) => boolean);
|
||||
|
||||
/**
|
||||
* An entry in a config's `files` array.
|
||||
*
|
||||
* A subarray means all matchers must match.
|
||||
*/
|
||||
export type FilesMatcher = FileMatcher | FileMatcher[];
|
||||
|
||||
/**
|
||||
* The config types allowed in the `extraConfigTypes` option.
|
||||
*/
|
||||
export type ExtraConfigType = "array" | "function";
|
||||
|
||||
export interface ConfigObject {
|
||||
/**
|
||||
* The base path for files and ignores.
|
||||
*/
|
||||
basePath?: string;
|
||||
|
||||
/**
|
||||
* The files to include.
|
||||
*/
|
||||
files?: FilesMatcher[];
|
||||
|
||||
/**
|
||||
* The files to exclude.
|
||||
*/
|
||||
ignores?: FileMatcher[];
|
||||
|
||||
/**
|
||||
* The name of the config object.
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
// may also have any number of other properties
|
||||
[key: string]: unknown;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "assertion-error",
|
||||
"version": "2.0.1",
|
||||
"description": "Error constructor for test and validation frameworks that implements standardized AssertionError specification.",
|
||||
"author": "Jake Luer <jake@qualiancy.com> (http://qualiancy.com)",
|
||||
"license": "MIT",
|
||||
"types": "./index.d.ts",
|
||||
"keywords": [
|
||||
"test",
|
||||
"assertion",
|
||||
"assertion-error"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:chaijs/assertion-error.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts"
|
||||
],
|
||||
"type": "module",
|
||||
"module": "index.js",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "deno bundle mod.ts > index.js",
|
||||
"pretest": "rm -rf coverage/",
|
||||
"test": "deno test --coverage=coverage",
|
||||
"posttest": "deno coverage coverage --lcov > coverage/lcov.info && lcov --summary coverage/lcov.info"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
import { type FileReference, type LineAndCharacter, type Node, type Path, SyntaxKind } from "../../ast/index.ts";
|
||||
import type { TimingCollector } from "../timing.ts";
|
||||
import { RemoteNode, RemoteNodeList } from "./node.generated.ts";
|
||||
import { type SourceFileInfo, type TextDecoder } from "./node.infrastructure.ts";
|
||||
export { RemoteNode, RemoteNodeList } from "./node.generated.ts";
|
||||
export { readParseOptionsKey, readSourceFileHash, RemoteNodeBase } from "./node.infrastructure.ts";
|
||||
export declare class RemoteSourceFile extends RemoteNode implements SourceFileInfo {
|
||||
readonly nodes: (RemoteNode | RemoteNodeList)[];
|
||||
readonly _offsetNodes: number;
|
||||
readonly _offsetStringTableOffsets: number;
|
||||
readonly _offsetStringTable: number;
|
||||
readonly _offsetExtendedData: number;
|
||||
readonly _offsetStructuredData: number;
|
||||
readonly _decoder: TextDecoder;
|
||||
readonly _timing: TimingCollector | undefined;
|
||||
private _lineStarts;
|
||||
private _cachedText;
|
||||
private _cachedReferencedFiles;
|
||||
private _cachedTypeReferenceDirectives;
|
||||
private _cachedLibReferenceDirectives;
|
||||
private _cachedImports;
|
||||
private _cachedModuleAugmentations;
|
||||
private _cachedAmbientModuleNames;
|
||||
constructor(data: Uint8Array, decoder: TextDecoder, timing?: TimingCollector);
|
||||
readFileReferences(structuredDataOffset: number): readonly FileReference[];
|
||||
readNodeIndexArray(structuredDataOffset: number): readonly Node[];
|
||||
readStringArray(structuredDataOffset: number): readonly string[];
|
||||
/** @internal */
|
||||
getOrCreateNodeAtIndex(index: number): Node;
|
||||
private get extendedDataOffset();
|
||||
get fileName(): string;
|
||||
get path(): string;
|
||||
get languageVariant(): number;
|
||||
get scriptKind(): number;
|
||||
get referencedFiles(): readonly FileReference[];
|
||||
get typeReferenceDirectives(): readonly FileReference[];
|
||||
get libReferenceDirectives(): readonly FileReference[];
|
||||
get imports(): readonly Node[];
|
||||
get moduleAugmentations(): readonly Node[];
|
||||
get ambientModuleNames(): readonly string[];
|
||||
get externalModuleIndicator(): Node | true | undefined;
|
||||
get isDeclarationFile(): boolean;
|
||||
get text(): string;
|
||||
getLineStarts(): readonly number[];
|
||||
getLineAndCharacterOfPosition(position: number): LineAndCharacter;
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
}
|
||||
/**
|
||||
* Find a descendant node at a specific position with matching kind and end position.
|
||||
*/
|
||||
export declare function findDescendant(root: Node, pos: number, end: number, kind: SyntaxKind): Node | undefined;
|
||||
/**
|
||||
* Parsed components of a node handle.
|
||||
*/
|
||||
export interface ParsedNodeHandle {
|
||||
index: number;
|
||||
kind: SyntaxKind;
|
||||
path: Path;
|
||||
}
|
||||
/**
|
||||
* Parse a node handle string into its components.
|
||||
* Handle format: "index.kind.path" where path may contain dots.
|
||||
*/
|
||||
export declare function parseNodeHandle(handle: string): ParsedNodeHandle;
|
||||
/**
|
||||
* Decode binary-encoded AST data into a Node.
|
||||
* Works for any binary-encoded node, including synthetic nodes
|
||||
* (e.g. from typeToTypeNode) that don't have a source file.
|
||||
*/
|
||||
export declare function decodeNode(data: Uint8Array): Node;
|
||||
/**
|
||||
* Get the unique ID string for a remote node.
|
||||
* Throws if the node is not a RemoteNode (i.e. not decoded from binary data).
|
||||
*/
|
||||
export declare function getNodeId(node: Node): string;
|
||||
//# sourceMappingURL=node.d.ts.map
|
||||
@@ -0,0 +1,19 @@
|
||||
import unsupportedIterableToArray from "./unsupportedIterableToArray.js";
|
||||
function _createForOfIteratorHelperLoose(r, e) {
|
||||
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
||||
if (t) return (t = t.call(r)).next.bind(t);
|
||||
if (Array.isArray(r) || (t = unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
|
||||
t && (r = t);
|
||||
var o = 0;
|
||||
return function () {
|
||||
return o >= r.length ? {
|
||||
done: !0
|
||||
} : {
|
||||
done: !1,
|
||||
value: r[o++]
|
||||
};
|
||||
};
|
||||
}
|
||||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||||
}
|
||||
export { _createForOfIteratorHelperLoose as default };
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/abstract/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AAWjC,oDAAoD;AACpD,MAAM,CAAC,MAAM,MAAM,GAAoB,CAAC,CAAC,MAAM,CAAC;AAChD,oDAAoD;AACpD,MAAM,CAAC,MAAM,OAAO,GAAqB,CAAC,CAAC,OAAO,CAAC;AACnD,oDAAoD;AACpD,MAAM,CAAC,MAAM,UAAU,GAAwB,CAAC,CAAC,UAAU,CAAC;AAC5D,oDAAoD;AACpD,MAAM,CAAC,MAAM,WAAW,GAAyB,CAAC,CAAC,WAAW,CAAC;AAC/D,oDAAoD;AACpD,MAAM,CAAC,MAAM,WAAW,GAAyB,CAAC,CAAC,WAAW,CAAC;AAC/D,oDAAoD;AACpD,MAAM,CAAC,MAAM,UAAU,GAAwB,CAAC,CAAC,UAAU,CAAC;AAC5D,oDAAoD;AACpD,MAAM,CAAC,MAAM,OAAO,GAAqB,CAAC,CAAC,OAAO,CAAC;AACnD,oDAAoD;AACpD,MAAM,CAAC,MAAM,WAAW,GAAyB,CAAC,CAAC,WAAW,CAAC;AAC/D,oDAAoD;AACpD,MAAM,CAAC,MAAM,WAAW,GAAyB,CAAC,CAAC,WAAW,CAAC;AAE/D,oDAAoD;AACpD,MAAM,CAAC,MAAM,KAAK,GAAmB,CAAC,CAAC,KAAK,CAAC;AAC7C,oDAAoD;AACpD,MAAM,CAAC,MAAM,mBAAmB,GAAiC,CAAC,CAAC,mBAAmB,CAAC;AACvF,oDAAoD;AACpD,MAAM,CAAC,MAAM,WAAW,GAAyB,CAAC,CAAC,WAAW,CAAC;AAC/D,oDAAoD;AACpD,MAA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AC,MAAM,cAAc,GAA4B,CAAC,CAAC,cAAc,CAAC;AACxE,oDAAoD;AACpD,MAAM,CAAC,MAAM,QAAQ,GAAsB,CAAC,CAAC,QAAQ,CAAC;AACtD,oDAAoD;AACpD,MAAM,CAAC,MAAM,cAAc,GAA4B,CAAC,CAAC,cAAc,CAAC;AACxE,oDAAoD;AACpD,MAAM,CAAC,MAAM,MAAM,GAAoB,CAAC,CAAC,MAAM,CAAC"}
|
||||
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
var _array_with_holes = require("./_array_with_holes.cjs");
|
||||
var _iterable_to_array_limit_loose = require("./_iterable_to_array_limit_loose.cjs");
|
||||
var _non_iterable_rest = require("./_non_iterable_rest.cjs");
|
||||
var _unsupported_iterable_to_array = require("./_unsupported_iterable_to_array.cjs");
|
||||
|
||||
function _sliced_to_array_loose(arr, i) {
|
||||
return _array_with_holes._(arr) || _iterable_to_array_limit_loose._(arr, i) || _unsupported_iterable_to_array._(arr, i) || _non_iterable_rest._();
|
||||
}
|
||||
exports._ = _sliced_to_array_loose;
|
||||
@@ -0,0 +1,17 @@
|
||||
'use strict'
|
||||
|
||||
// parse out just the options we care about
|
||||
const looseOption = Object.freeze({ loose: true })
|
||||
const emptyOpts = Object.freeze({ })
|
||||
const parseOptions = options => {
|
||||
if (!options) {
|
||||
return emptyOpts
|
||||
}
|
||||
|
||||
if (typeof options !== 'object') {
|
||||
return looseOption
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
module.exports = parseOptions
|
||||
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
* @fileoverview Require or disallow newline at the end of files
|
||||
* @author Nodeca Team <https://github.com/nodeca>
|
||||
* @deprecated in ESLint v8.53.0
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
deprecated: {
|
||||
message: "Formatting rules are being moved out of ESLint core.",
|
||||
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
||||
deprecatedSince: "8.53.0",
|
||||
availableUntil: "11.0.0",
|
||||
replacedBy: [
|
||||
{
|
||||
message:
|
||||
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
||||
url: "https://eslint.style/guide/migration",
|
||||
plugin: {
|
||||
name: "@stylistic/eslint-plugin",
|
||||
url: "https://eslint.style",
|
||||
},
|
||||
rule: {
|
||||
name: "eol-last",
|
||||
url: "https://eslint.style/rules/eol-last",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
type: "layout",
|
||||
|
||||
docs: {
|
||||
description: "Require or disallow newline at the end of files",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/eol-last",
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
|
||||
schema: [
|
||||
{
|
||||
enum: ["always", "never", "unix", "windows"],
|
||||
},
|
||||
],
|
||||
|
||||
messages: {
|
||||
missing: "Newline required at end of file but not found.",
|
||||
unexpected: "Newline not allowed at end of file.",
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
//--------------------------------------------------------------------------
|
||||
// Public
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
return {
|
||||
Program: function checkBadEOF(node) {
|
||||
const sourceCode = context.sourceCode,
|
||||
src = sourceCode.getText(),
|
||||
lastLine = sourceCode.lines.at(-1),
|
||||
location = {
|
||||
column: lastLine.length,
|
||||
line: sourceCode.lines.length,
|
||||
},
|
||||
LF = "\n",
|
||||
CRLF = `\r${LF}`,
|
||||
endsWithNewline = src.endsWith(LF);
|
||||
|
||||
/*
|
||||
* Empty source is always valid: No content in file so we don't
|
||||
* need to lint for a newline on the last line of content.
|
||||
*/
|
||||
if (!src.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
let mode = context.options[0] || "always",
|
||||
appendCRLF = false;
|
||||
|
||||
if (mode === "unix") {
|
||||
// `"unix"` should behave exactly as `"always"`
|
||||
mode = "always";
|
||||
}
|
||||
if (mode === "windows") {
|
||||
// `"windows"` should behave exactly as `"always"`, but append CRLF in the fixer for backwards compatibility
|
||||
mode = "always";
|
||||
appendCRLF = true;
|
||||
}
|
||||
if (mode === "always" && !endsWithNewline) {
|
||||
// File is not newline-terminated, but should be
|
||||
context.report({
|
||||
node,
|
||||
loc: location,
|
||||
messageId: "missing",
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfterRange(
|
||||
[0, src.length],
|
||||
appendCRLF ? CRLF : LF,
|
||||
);
|
||||
},
|
||||
});
|
||||
} else if (mode === "never" && endsWithNewline) {
|
||||
const secondLastLine = sourceCode.lines.at(-2);
|
||||
|
||||
// File is newline-terminated, but shouldn't be
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: {
|
||||
line: sourceCode.lines.length - 1,
|
||||
column: secondLastLine.length,
|
||||
},
|
||||
end: { line: sourceCode.lines.length, column: 0 },
|
||||
},
|
||||
messageId: "unexpected",
|
||||
fix(fixer) {
|
||||
const finalEOLs = /(?:\r?\n)+$/u,
|
||||
match = finalEOLs.exec(sourceCode.text),
|
||||
start = match.index,
|
||||
end = sourceCode.text.length;
|
||||
|
||||
return fixer.replaceTextRange([start, end], "");
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export { Referencer, type ReferencerOptions } from './Referencer';
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pbkdf2.js","sourceRoot":"","sources":["src/pbkdf2.ts"],"names":[],"mappings":";;AA4DA,wBA2BC;AAOD,kCA2BC;AAzHD;;;GAGG;AACH,uCAAiC;AACjC,kBAAkB;AAClB,yCAKoB;AAOpB,wDAAwD;AACxD,SAAS,UAAU,CAAC,IAAW,EAAE,SAAmB,EAAE,KAAe,EAAE,KAAgB;IACrF,IAAA,gBAAK,EAAC,IAAI,CAAC,CAAC;IACZ,MAAM,IAAI,G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AM,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC5D,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QACjC,MAAM,IAAA,oBAAS,EAAC,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE;YACrC,2BAA2B;YAC3B,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE;gBAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,42 @@
|
||||
'use strict'
|
||||
|
||||
const { test, teardown } = require('tap')
|
||||
const fs = require('fs')
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
|
||||
const files = []
|
||||
let count = 0
|
||||
|
||||
function file () {
|
||||
const file = path.join(os.tmpdir(), `sonic-boom-${process.pid}-${process.hrtime().toString()}-${count++}`)
|
||||
files.push(file)
|
||||
return file
|
||||
}
|
||||
|
||||
teardown(() => {
|
||||
const rmSync = fs.rmSync || fs.rmdirSync
|
||||
files.forEach((file) => {
|
||||
try {
|
||||
if (fs.existsSync(file)) {
|
||||
fs.statSync(file).isDirectory() ? rmSync(file, { recursive: true, maxRetries: 10 }) : fs.unlinkSync(file)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
function runTests (buildTests) {
|
||||
test('sync false', (t) => {
|
||||
buildTests(t.test, false)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('sync true', (t) => {
|
||||
buildTests(t.test, true)
|
||||
t.end()
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { file, runTests }
|
||||
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
* Internal Merkle-Damgard hash utils.
|
||||
* @module
|
||||
*/
|
||||
import { Hash, abytes, aexists, aoutput, clean, createView, toBytes } from "./utils.js";
|
||||
/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */
|
||||
export function setBigUint64(view, byteOffset, value, isLE) {
|
||||
if (typeof view.setBigUint64 === 'function')
|
||||
return view.setBigUint64(byteOffset, value, isLE);
|
||||
const _32n = BigInt(32);
|
||||
const _u32_max = BigInt(0xffffffff);
|
||||
const wh = Number((value >> _32n) & _u32_max);
|
||||
const wl = Number(value & _u32_max);
|
||||
const h = isLE ? 4 : 0;
|
||||
const l = isLE ? 0 : 4;
|
||||
view.setUint32(byteOffset + h, wh, isLE);
|
||||
view.setUint32(byteOffset + l, wl, isLE);
|
||||
}
|
||||
/** Choice: a ? b : c */
|
||||
export function Chi(a, b, c) {
|
||||
return (a & b) ^ (~a & c);
|
||||
}
|
||||
/** Majority function, true if any two inputs is true. */
|
||||
export function Maj(a, b, c) {
|
||||
return (a & b) ^ (a & c) ^ (b & c);
|
||||
}
|
||||
/**
|
||||
* Merkle-Damgard hash construction base class.
|
||||
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
||||
*/
|
||||
export class HashMD extends Hash {
|
||||
constructor(blockLen, outputLen, padOffset, isLE) {
|
||||
super();
|
||||
this.finished = false;
|
||||
this.length = 0;
|
||||
this.pos = 0;
|
||||
this.destroyed = false;
|
||||
this.blockLen = blockLen;
|
||||
this.outputLen = outputLen;
|
||||
this.padOffset = padOffset;
|
||||
this.isLE = isLE;
|
||||
this.buffer = new Uint8Array(blockLen);
|
||||
this.view = createView(this.buffer);
|
||||
}
|
||||
update(data) {
|
||||
aexists(this);
|
||||
data = toBytes(data);
|
||||
abytes(data);
|
||||
const { view, buffer, blockLen } = this;
|
||||
const len = data.length;
|
||||
for (let pos = 0; pos < len;) {
|
||||
const take = Math.min(blockLen - this.pos, len - pos);
|
||||
// Fast path: we have at least one block in input, cast it to view and process
|
||||
if (take === blockLen) {
|
||||
const dataView = createView(data);
|
||||
for (; blockLen <= len - pos; pos += blockLen)
|
||||
this.process(dataView, pos);
|
||||
continue;
|
||||
}
|
||||
buffer.set(data.subarray(pos, pos + take), this.pos);
|
||||
this.pos += take;
|
||||
pos += take;
|
||||
if (this.pos === blockLen) {
|
||||
this.process(view, 0);
|
||||
this.pos = 0;
|
||||
}
|
||||
}
|
||||
this.length += data.length;
|
||||
this.roundClean();
|
||||
return this;
|
||||
}
|
||||
digestInto(out) {
|
||||
aexists(this);
|
||||
aoutput(out, this);
|
||||
this.finished = true;
|
||||
// Padding
|
||||
// We can avoid allocation of buffer for padding completely if it
|
||||
// was previously not allocated here. But it won't change performance.
|
||||
const { buffer, view, blockLen, isLE } = this;
|
||||
let { pos } = this;
|
||||
// append the bit '1' to the message
|
||||
buffer[pos++] = 0b10000000;
|
||||
clean(this.buffer.subarray(pos));
|
||||
// we have less than padOffset left in buffer, so we cannot put length in
|
||||
// current block, need process it and pad again
|
||||
if (this.padOffset > blockLen - pos) {
|
||||
this.process(view, 0);
|
||||
pos = 0;
|
||||
}
|
||||
// Pad until full block byte with zeros
|
||||
for (let i = pos; i < blockLen; i++)
|
||||
buffer[i] = 0;
|
||||
// Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
|
||||
// You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
|
||||
// So we just write lowest 64 bits of that value.
|
||||
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
||||
this.process(view, 0);
|
||||
const oview = createView(out);
|
||||
const len = this.outputLen;
|
||||
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
||||
if (len % 4)
|
||||
throw new Error('_sha2: outputLen should be aligned to 32bit');
|
||||
const outLen = len / 4;
|
||||
const state = this.get();
|
||||
if (outLen > state.length)
|
||||
throw new Error('_sha2: outputLen bigger than state');
|
||||
for (let i = 0; i < outLen; i++)
|
||||
oview.setUint32(4 * i, state[i], isLE);
|
||||
}
|
||||
digest() {
|
||||
const { buffer, outputLen } = this;
|
||||
this.digestInto(buffer);
|
||||
const res = buffer.slice(0, outputLen);
|
||||
this.destroy();
|
||||
return res;
|
||||
}
|
||||
_cloneInto(to) {
|
||||
to || (to = new this.constructor());
|
||||
to.set(...this.get());
|
||||
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
||||
to.destroyed = destroyed;
|
||||
to.finished = finished;
|
||||
to.length = length;
|
||||
to.pos = pos;
|
||||
if (length % blockLen)
|
||||
to.buffer.set(buffer);
|
||||
return to;
|
||||
}
|
||||
clone() {
|
||||
return this._cloneInto();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
|
||||
* Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
|
||||
*/
|
||||
/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */
|
||||
export const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
||||
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
|
||||
]);
|
||||
/** Initial SHA224 state. Bits 32..64 of frac part of sqrt of primes 23..53 */
|
||||
export const SHA224_IV = /* @__PURE__ */ Uint32Array.from([
|
||||
0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4,
|
||||
]);
|
||||
/** Initial SHA384 state. Bits 0..64 of frac part of sqrt of primes 23..53 */
|
||||
export const SHA384_IV = /* @__PURE__ */ Uint32Array.from([
|
||||
0xcbbb9d5d, 0xc1059ed8, 0x629a292a, 0x367cd507, 0x9159015a, 0x3070dd17, 0x152fecd8, 0xf70e5939,
|
||||
0x67332667, 0xffc00b31, 0x8eb44a87, 0x68581511, 0xdb0c2e0d, 0x64f98fa7, 0x47b5481d, 0xbefa4fa4,
|
||||
]);
|
||||
/** Initial SHA512 state. Bits 0..64 of frac part of sqrt of primes 2..19 */
|
||||
export const SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
||||
0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1,
|
||||
0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179,
|
||||
]);
|
||||
//# sourceMappingURL=_md.js.map
|
||||
@@ -0,0 +1,298 @@
|
||||
'use strict'
|
||||
|
||||
const { realImport, realRequire } = require('real-require')
|
||||
const { workerData, parentPort } = require('worker_threads')
|
||||
const { StringDecoder } = require('string_decoder')
|
||||
const { WRITE_INDEX, READ_INDEX, SEQ_INDEX } = require('./indexes')
|
||||
const { waitDiff } = require('./wait')
|
||||
|
||||
const {
|
||||
dataBuf,
|
||||
filename,
|
||||
stateBuf
|
||||
} = workerData
|
||||
|
||||
let destination
|
||||
const flushQueue = []
|
||||
let flushing = false
|
||||
|
||||
const state = new Int32Array(stateBuf)
|
||||
const data = Buffer.from(dataBuf)
|
||||
const decoder = new StringDecoder('utf8')
|
||||
|
||||
// Keep the event loop alive - Atomics.waitAsync promises don't prevent worker exit
|
||||
const keepAlive = setInterval(() => {}, 60 * 60 * 1000)
|
||||
|
||||
function onParentPortMessage (msg) {
|
||||
if (!msg || msg.code !== 'FLUSH' || msg.context !== 'thread-stream') {
|
||||
return
|
||||
}
|
||||
|
||||
flushQueue.push(msg.id)
|
||||
processFlushQueue()
|
||||
}
|
||||
|
||||
function processFlushQueue () {
|
||||
if (flushing || !destination) {
|
||||
return
|
||||
}
|
||||
|
||||
const id = flushQueue.shift()
|
||||
if (id === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
flushing = true
|
||||
flushDestination((err) => {
|
||||
flushing = false
|
||||
|
||||
if (err) {
|
||||
parentPort.postMessage({
|
||||
code: 'ERROR',
|
||||
err
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
parentPort.postMessage({
|
||||
code: 'FLUSHED',
|
||||
context: 'thread-stream',
|
||||
id
|
||||
})
|
||||
|
||||
processFlushQueue()
|
||||
})
|
||||
}
|
||||
|
||||
function flushDestination (cb) {
|
||||
if (typeof destination?.flush === 'function') {
|
||||
if (destination.flush.length === 0) {
|
||||
try {
|
||||
const result = destination.flush()
|
||||
if (result && typeof result.then === 'function') {
|
||||
result.then(() => cb(), cb)
|
||||
} else {
|
||||
cb()
|
||||
}
|
||||
} catch (err) {
|
||||
cb(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
let done = false
|
||||
const onDone = (err) => {
|
||||
if (done) {
|
||||
return
|
||||
}
|
||||
done = true
|
||||
cb(err)
|
||||
}
|
||||
|
||||
try {
|
||||
const result = destination.flush(onDone)
|
||||
if (result && typeof result.then === 'function') {
|
||||
result.then(() => onDone(), onDone)
|
||||
}
|
||||
} catch (err) {
|
||||
onDone(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (typeof destination?.flushSync === 'function') {
|
||||
try {
|
||||
destination.flushSync()
|
||||
cb()
|
||||
} catch (err) {
|
||||
cb(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (destination?.writableNeedDrain && !destination?.writableEnded) {
|
||||
destination.once('drain', cb)
|
||||
return
|
||||
}
|
||||
|
||||
cb()
|
||||
}
|
||||
|
||||
async function start () {
|
||||
let worker
|
||||
try {
|
||||
worker = (await realImport(filename))
|
||||
} catch (error) {
|
||||
// A yarn user that tries to start a ThreadStream for an external module
|
||||
// provides a filename pointing to a zip file.
|
||||
// eg. require.resolve('pino-elasticsearch') // returns /foo/pino-elasticsearch-npm-6.1.0-0c03079478-6915435172.zip/bar.js
|
||||
// The `import` will fail to try to load it.
|
||||
// This catch block executes the `require` fallback to load the module correctly.
|
||||
// In fact, yarn modifies the `require` function to manage the zipped path.
|
||||
// More details at https://github.com/pinojs/pino/pull/1113
|
||||
// The error codes may change based on the node.js version (ENOTDIR > 12, ERR_MODULE_NOT_FOUND <= 12 )
|
||||
if ((error.code === 'ENOTDIR' || error.code === 'ERR_MODULE_NOT_FOUND') &&
|
||||
filename.startsWith('file://')) {
|
||||
worker = realRequire(decodeURIComponent(filename.replace('file://', '')))
|
||||
} else if (error.code === undefined || error.code === 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING') {
|
||||
// When bundled with pkg, an undefined error is thrown when called with realImport
|
||||
// When bundled with pkg and using node v20, an ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING error is thrown when called with realImport
|
||||
// More info at: https://github.com/pinojs/thread-stream/issues/143
|
||||
try {
|
||||
worker = realRequire(decodeURIComponent(filename.replace(process.platform === 'win32' ? 'file:///' : 'file://', '')))
|
||||
} catch {
|
||||
throw error
|
||||
}
|
||||
} else if (filename.endsWith('.ts') || filename.endsWith('.cts')) {
|
||||
// Native TypeScript import failed (type stripping not enabled).
|
||||
// Fall back to ts-node for TypeScript files.
|
||||
try {
|
||||
if (!process[Symbol.for('ts-node.register.instance')]) {
|
||||
realRequire('ts-node/register')
|
||||
} else if (process.env.TS_NODE_DEV) {
|
||||
realRequire('ts-node-dev')
|
||||
}
|
||||
worker = realRequire(decodeURIComponent(filename.replace(process.platform === 'win32' ? 'file:///' : 'file://', '')))
|
||||
} catch {
|
||||
throw error
|
||||
}
|
||||
} else {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// Depending on how the default export is performed, and on how the code is
|
||||
// transpiled, we may find cases of two nested "default" objects.
|
||||
// See https://github.com/pinojs/pino/issues/1243#issuecomment-982774762
|
||||
if (typeof worker === 'object') worker = worker.default
|
||||
if (typeof worker === 'object') worker = worker.default
|
||||
|
||||
destination = await worker(workerData.workerData)
|
||||
|
||||
destination.on('error', function (err) {
|
||||
Atomics.store(state, WRITE_INDEX, -2)
|
||||
Atomics.notify(state, WRITE_INDEX)
|
||||
|
||||
Atomics.store(state, READ_INDEX, -2)
|
||||
Atomics.notify(state, READ_INDEX)
|
||||
|
||||
parentPort.postMessage({
|
||||
code: 'ERROR',
|
||||
err
|
||||
})
|
||||
})
|
||||
|
||||
destination.on('close', function () {
|
||||
// process._rawDebug('worker close emitted')
|
||||
const end = Atomics.load(state, WRITE_INDEX)
|
||||
Atomics.store(state, READ_INDEX, end)
|
||||
Atomics.notify(state, READ_INDEX)
|
||||
clearInterval(keepAlive)
|
||||
setImmediate(() => {
|
||||
process.exit(0)
|
||||
})
|
||||
})
|
||||
|
||||
processFlushQueue()
|
||||
}
|
||||
|
||||
// No .catch() handler,
|
||||
// in case there is an error it goes
|
||||
// to unhandledRejection
|
||||
start().then(function () {
|
||||
parentPort.on('message', onParentPortMessage)
|
||||
|
||||
parentPort.postMessage({
|
||||
code: 'READY'
|
||||
})
|
||||
|
||||
process.nextTick(run)
|
||||
})
|
||||
|
||||
function readState () {
|
||||
while (true) {
|
||||
const seq = Atomics.load(state, SEQ_INDEX)
|
||||
|
||||
if ((seq & 1) !== 0) {
|
||||
continue
|
||||
}
|
||||
|
||||
const current = Atomics.load(state, READ_INDEX)
|
||||
const end = Atomics.load(state, WRITE_INDEX)
|
||||
|
||||
if (seq === Atomics.load(state, SEQ_INDEX)) {
|
||||
return { current, end, seq }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function run () {
|
||||
const { current, end, seq } = readState()
|
||||
|
||||
// process._rawDebug(`pre state ${current} ${end}`)
|
||||
|
||||
if (end === current) {
|
||||
waitDiff(state, SEQ_INDEX, seq, Infinity, run)
|
||||
return
|
||||
}
|
||||
|
||||
// process._rawDebug(`post state ${current} ${end}`)
|
||||
|
||||
if (end === -1) {
|
||||
// process._rawDebug('end')
|
||||
const remaining = decoder.end()
|
||||
if (remaining.length > 0) {
|
||||
destination.write(remaining)
|
||||
}
|
||||
destination.end()
|
||||
return
|
||||
}
|
||||
|
||||
const toWrite = decoder.write(data.subarray(current, end))
|
||||
// process._rawDebug('worker writing: ' + toWrite)
|
||||
|
||||
const res = destination.write(toWrite)
|
||||
|
||||
if (res) {
|
||||
Atomics.store(state, READ_INDEX, end)
|
||||
Atomics.notify(state, READ_INDEX)
|
||||
setImmediate(run)
|
||||
} else {
|
||||
destination.once('drain', function () {
|
||||
Atomics.store(state, READ_INDEX, end)
|
||||
Atomics.notify(state, READ_INDEX)
|
||||
run()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
process.on('unhandledRejection', function (err) {
|
||||
parentPort.postMessage({
|
||||
code: 'ERROR',
|
||||
err
|
||||
})
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
process.on('uncaughtException', function (err) {
|
||||
parentPort.postMessage({
|
||||
code: 'ERROR',
|
||||
err
|
||||
})
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
process.once('exit', exitCode => {
|
||||
if (exitCode !== 0) {
|
||||
process.exit(exitCode)
|
||||
return
|
||||
}
|
||||
if (destination?.writableNeedDrain && !destination?.writableEnded) {
|
||||
parentPort.postMessage({
|
||||
code: 'WARNING',
|
||||
err: new Error('ThreadStream: process exited before destination stream was drained. this may indicate that the destination stream try to write to a another missing stream')
|
||||
})
|
||||
}
|
||||
|
||||
process.exit(0)
|
||||
})
|
||||
@@ -0,0 +1,62 @@
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
import * as z from "zod/v4";
|
||||
|
||||
const beforeBenchmarkDate = new Date(Date.UTC(2022, 10, 4));
|
||||
const benchmarkDate = new Date(Date.UTC(2022, 10, 5));
|
||||
const afterBenchmarkDate = new Date(Date.UTC(2022, 10, 6));
|
||||
|
||||
const minCheck = z.date().min(benchmarkDate);
|
||||
const maxCheck = z.date().max(benchmarkDate);
|
||||
|
||||
test("passing validations", () => {
|
||||
minCheck.parse(benchmarkDate);
|
||||
minCheck.parse(afterBenchmarkDate);
|
||||
|
||||
maxCheck.parse(benchmarkDate);
|
||||
maxCheck.parse(beforeBenchmarkDate);
|
||||
});
|
||||
|
||||
test("date min", () => {
|
||||
const result = minCheck.safeParse(beforeBenchmarkDate);
|
||||
|
||||
expect(result.success).toEqual(false);
|
||||
expect(result.error!.issues).toMatchInlineSnapshot(`
|
||||
[
|
||||
{
|
||||
"code": "too_small",
|
||||
"inclusive": true,
|
||||
"message": "Too small: expected date to be >=1667606400000",
|
||||
"minimum": 1667606400000,
|
||||
"origin": "date",
|
||||
"path": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
test("date max", () => {
|
||||
const result = maxCheck.safeParse(afterBenchmarkDate);
|
||||
|
||||
expect(result.success).toEqual(false);
|
||||
expect(result.error!.issues).toMatchInlineSnapshot(`
|
||||
[
|
||||
{
|
||||
"code": "too_big",
|
||||
"inclusive": true,
|
||||
"maximum": 1667606400000,
|
||||
"message": "Too big: expected date to be <=1667606400000",
|
||||
"origin": "date",
|
||||
"path": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
test("min max getters", () => {
|
||||
expect(minCheck.minDate).toEqual(benchmarkDate);
|
||||
expect(minCheck.min(afterBenchmarkDate).minDate).toEqual(afterBenchmarkDate);
|
||||
|
||||
expect(maxCheck.maxDate).toEqual(benchmarkDate);
|
||||
expect(maxCheck.max(beforeBenchmarkDate).maxDate).toEqual(beforeBenchmarkDate);
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
|
||||
function _define_enumerable_properties(obj, descs) {
|
||||
for (var key in descs) {
|
||||
var desc = descs[key];
|
||||
desc.configurable = desc.enumerable = true;
|
||||
|
||||
if ("value" in desc) desc.writable = true;
|
||||
|
||||
Object.defineProperty(obj, key, desc);
|
||||
}
|
||||
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var objectSymbols = Object.getOwnPropertySymbols(descs);
|
||||
for (var i = 0; i < objectSymbols.length; i++) {
|
||||
var sym = objectSymbols[i];
|
||||
var desc = descs[sym];
|
||||
desc.configurable = desc.enumerable = true;
|
||||
if ("value" in desc) desc.writable = true;
|
||||
Object.defineProperty(obj, sym, desc);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
exports._ = _define_enumerable_properties;
|
||||
@@ -0,0 +1,26 @@
|
||||
export { M as AgentReporter, B as BenchmarkReporter, a as BenchmarkReportsMap, D as DefaultReporter, b as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, J as JUnitReporter, c as JsonReporter, M as MinimalReporter, R as ReportersMap, T as TapFlatReporter, d as TapReporter, V as VerboseBenchmarkReporter, e as VerboseReporter } from './chunks/index.UpGiHP7g.js';
|
||||
import 'node:fs';
|
||||
import '@vitest/runner/utils';
|
||||
import 'pathe';
|
||||
import 'tinyrainbow';
|
||||
import './chunks/utils.BS4fH3nR.js';
|
||||
import 'node:util';
|
||||
import '@vitest/utils/helpers';
|
||||
import 'node:fs/promises';
|
||||
import 'node:perf_hooks';
|
||||
import '@vitest/utils/source-map';
|
||||
import './chunks/env.D4Lgay0q.js';
|
||||
import 'std-env';
|
||||
import 'node:console';
|
||||
import 'node:stream';
|
||||
import '@vitest/utils/display';
|
||||
import 'node:os';
|
||||
import 'tinyexec';
|
||||
import './path.js';
|
||||
import 'node:path';
|
||||
import 'node:url';
|
||||
import 'vite';
|
||||
import '@vitest/utils/offset';
|
||||
import 'node:module';
|
||||
|
||||
console.warn("Importing from \"vitest/reporters\" is deprecated since Vitest 4.1. Please use \"vitest/node\" instead.");
|
||||
@@ -0,0 +1 @@
|
||||
export * from './dist/snapshot.js'
|
||||
@@ -0,0 +1,52 @@
|
||||
{{# def.definitions }}
|
||||
{{# def.errors }}
|
||||
{{# def.setupKeyword }}
|
||||
{{# def.setupNextLevel }}
|
||||
|
||||
var {{=$errs}} = errors;
|
||||
|
||||
{{? {{# def.nonEmptySchema:$schema }} }}
|
||||
{{
|
||||
$it.schema = $schema;
|
||||
$it.schemaPath = $schemaPath;
|
||||
$it.errSchemaPath = $errSchemaPath;
|
||||
}}
|
||||
|
||||
{{
|
||||
var $key = 'key' + $lvl
|
||||
, $idx = 'idx' + $lvl
|
||||
, $i = 'i' + $lvl
|
||||
, $invalidName = '\' + ' + $key + ' + \''
|
||||
, $dataNxt = $it.dataLevel = it.dataLevel + 1
|
||||
, $nextData = 'data' + $dataNxt
|
||||
, $dataProperties = 'dataProperties' + $lvl
|
||||
, $ownProperties = it.opts.ownProperties
|
||||
, $currentBaseId = it.baseId;
|
||||
}}
|
||||
|
||||
{{? $ownProperties }}
|
||||
var {{=$dataProperties}} = undefined;
|
||||
{{?}}
|
||||
{{# def.iterateProperties }}
|
||||
var startErrs{{=$lvl}} = errors;
|
||||
|
||||
{{ var $passData = $key; }}
|
||||
{{# def.setCompositeRule }}
|
||||
{{# def.generateSubschemaCode }}
|
||||
{{# def.optimizeValidate }}
|
||||
{{# def.resetCompositeRule }}
|
||||
|
||||
if (!{{=$nextValid}}) {
|
||||
for (var {{=$i}}=startErrs{{=$lvl}}; {{=$i}}<errors; {{=$i}}++) {
|
||||
vErrors[{{=$i}}].propertyName = {{=$key}};
|
||||
}
|
||||
{{# def.extraError:'propertyNames' }}
|
||||
{{? $breakOnError }} break; {{?}}
|
||||
}
|
||||
}
|
||||
{{?}}
|
||||
|
||||
{{? $breakOnError }}
|
||||
{{= $closingBraces }}
|
||||
if ({{=$errs}} == errors) {
|
||||
{{?}}
|
||||
Reference in New Issue
Block a user