WIP: bootstrap and partial real Solana watcher implementation

This commit is contained in:
2026-08-16 09:17:45 +00:00
commit dc23412c3f
7232 changed files with 1687637 additions and 0 deletions

View File

@@ -0,0 +1,122 @@
// Type definitions for pino-abstract-transport 0.4.0
// Project: https://github.com/pinojs/pino-abstract-transport#readme
// Definitions by: Diyar Oktay <https://github.com/windupbird144>
/// <reference types="node" />
import { Transform } from "stream";
type BuildOptions = {
/**
* `parseLine(line)` a function that is used to parse line received from pino.
* @default JSON.parse
*/
parseLine?: (line: string) => unknown;
/**
* `parse` an option to change to data format passed to build function.
* @default undefined
*
*/
parse?: "lines";
/**
* `close(err, cb)` a function that is called to shutdown the transport.
* It's called both on error and non-error shutdowns. It can also return
* a promise. In this case discard the the cb argument.
*
* @example
* ```typescript
* {
* close: function (err, cb) {
* process.nextTick(cb, err)
* }
* }
* ```
* */
close?: (err: Error, cb: Function) => void | Promise<void>;
/**
* `metadata` If set to false, do not add metadata properties to the returned stream
*/
metadata?: false;
/**
* `expectPinoConfig` If set to true, the transport will wait for pino to send its
* configuration before starting to process logs.
*/
expectPinoConfig?: boolean;
};
/**
* Pass these options to wrap the split2 stream and
* the returned stream into a Duplex
*/
type EnablePipelining = BuildOptions & {
enablePipelining: true;
};
/**
* Create a split2 instance and returns it. This same instance is also passed
* to the given function, which is called after pino has sent its configuration.
*
* @returns {Promise<Transform>} the split2 instance
*/
declare function build(
fn: (transform: Transform & build.OnUnknown) => void | Promise<void>,
opts: BuildOptions & { expectPinoConfig: true }
): Promise<Transform & build.OnUnknown>;
/**
* Create a split2 instance and returns it. This same instance is also passed
* to the given function, which is called synchronously.
*
* @returns {Transform} the split2 instance
*/
declare function build(
fn: (transform: Transform & build.OnUnknown) => void | Promise<void>,
opts?: BuildOptions
): Transform & build.OnUnknown;
/**
* Creates a split2 instance and passes it to the given function, which is called
* after pino has sent its configuration. Then wraps the split2 instance and
* the returned stream into a Duplex, so they can be concatenated into multiple
* transports.
*
* @returns {Promise<Transform>} the wrapped split2 instance
*/
declare function build(
fn: (transform: Transform & build.OnUnknown) => Transform & build.OnUnknown,
opts: EnablePipelining & { expectPinoConfig: true }
): Promise<Transform>;
/**
* Creates a split2 instance and passes it to the given function, which is called
* synchronously. Then wraps the split2 instance and the returned stream into a
* Duplex, so they can be concatenated into multiple transports.
*
* @returns {Transform} the wrapped split2 instance
*/
declare function build(
fn: (transform: Transform & build.OnUnknown) => Transform & build.OnUnknown,
opts: EnablePipelining
): Transform;
declare namespace build {
export interface OnUnknown {
/**
* `unknown` is the event emitted where an unparsable line is found
*
* @param event 'unknown'
* @param line the unparsable line
* @param error the error that was thrown when parsing the line
*/
on(
event: "unknown",
listener: (line: string, error: unknown) => void
): void;
}
}
export = build;

View File

@@ -0,0 +1,232 @@
/**
* @fileoverview Rule to flag statements that use != and == instead of !== and ===
* @author Nicholas C. Zakas
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const astUtils = require("./utils/ast-utils");
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../types').Rule.RuleModule} */
module.exports = {
meta: {
type: "suggestion",
hasSuggestions: true,
docs: {
description: "Require the use of `===` and `!==`",
recommended: false,
url: "https://eslint.org/docs/latest/rules/eqeqeq",
},
schema: {
anyOf: [
{
type: "array",
items: [
{
enum: ["always"],
},
{
type: "object",
properties: {
null: {
enum: ["always", "never", "ignore"],
},
},
additionalProperties: false,
},
],
additionalItems: false,
},
{
type: "array",
items: [
{
enum: ["smart", "allow-null"],
},
],
additionalItems: false,
},
],
},
defaultOptions: ["always"],
fixable: "code",
messages: {
unexpected:
"Expected '{{expectedOperator}}' and instead saw '{{actualOperator}}'.",
replaceOperator:
"Use '{{expectedOperator}}' instead of '{{actualOperator}}'.",
},
},
create(context) {
const config = context.options[0];
const options = context.options[1] || {};
const sourceCode = context.sourceCode;
const nullOption =
config === "always" ? options.null || "always" : "ignore";
const enforceRuleForNull = nullOption === "always";
const enforceInverseRuleForNull = nullOption === "never";
/**
* Checks if an expression is a typeof expression
* @param {ASTNode} node The node to check
* @returns {boolean} if the node is a typeof expression
*/
function isTypeOf(node) {
return (
node.type === "UnaryExpression" && node.operator === "typeof"
);
}
/**
* Checks if either operand of a binary expression is a typeof operation
* @param {ASTNode} node The node to check
* @returns {boolean} if one of the operands is typeof
* @private
*/
function isTypeOfBinary(node) {
return isTypeOf(node.left) || isTypeOf(node.right);
}
/**
* Gets the type of a literal node.
* @param {ASTNode} node The node to check
* @returns {string|null} The type of the literal
* @private
*/
function getLiteralType(node) {
if (node.type === "Literal") {
return typeof node.value;
}
if (astUtils.isStaticTemplateLiteral(node)) {
return "string";
}
return null;
}
/**
* Checks if operands are literals of the same type (via typeof)
* @param {ASTNode} node The node to check
* @returns {boolean} if operands are of same type
* @private
*/
function areLiteralsAndSameType(node) {
const leftType = getLiteralType(node.left);
return leftType !== null && leftType === getLiteralType(node.right);
}
/**
* Checks if one of the operands is a literal null
* @param {ASTNode} node The node to check
* @returns {boolean} if operands are null
* @private
*/
function isNullCheck(node) {
return (
astUtils.isNullLiteral(node.right) ||
astUtils.isNullLiteral(node.left)
);
}
/**
* Reports a message for this rule.
* @param {ASTNode} node The binary expression node that was checked
* @param {string} expectedOperator The operator that was expected (either '==', '!=', '===', or '!==')
* @returns {void}
* @private
*/
function report(node, expectedOperator) {
const operatorToken = sourceCode.getFirstTokenBetween(
node.left,
node.right,
token => token.value === node.operator,
);
const commonReportParams = {
node,
loc: operatorToken.loc,
messageId: "unexpected",
data: { expectedOperator, actualOperator: node.operator },
};
if (isTypeOfBinary(node) || areLiteralsAndSameType(node)) {
context.report({
...commonReportParams,
fix(fixer) {
return fixer.replaceText(
operatorToken,
expectedOperator,
);
},
});
} else {
context.report({
...commonReportParams,
suggest: [
{
messageId: "replaceOperator",
data: {
expectedOperator,
actualOperator: node.operator,
},
fix: fixer =>
fixer.replaceText(
operatorToken,
expectedOperator,
),
},
],
});
}
}
return {
BinaryExpression(node) {
const isNull = isNullCheck(node);
if (node.operator !== "==" && node.operator !== "!=") {
if (
enforceInverseRuleForNull &&
isNull &&
(node.operator === "===" || node.operator === "!==")
) {
report(node, node.operator.slice(0, -1));
}
return;
}
if (
config === "smart" &&
(isTypeOfBinary(node) ||
areLiteralsAndSameType(node) ||
isNull)
) {
return;
}
if (!enforceRuleForNull && isNull) {
return;
}
report(node, `${node.operator}=`);
},
};
},
};

View File

@@ -0,0 +1,8 @@
import type { TSESTree } from '@typescript-eslint/types';
import type { ScopeManager } from '../ScopeManager';
import type { Scope } from './Scope';
import { ScopeBase } from './ScopeBase';
import { ScopeType } from './ScopeType';
export declare class ForScope extends ScopeBase<ScopeType.for, TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement, Scope> {
constructor(scopeManager: ScopeManager, upperScope: ForScope['upper'], block: ForScope['block']);
}

View File

@@ -0,0 +1,60 @@
import RAL from './ral';
import { Message } from './messages';
import { Event } from './events';
import { ContentEncoder, ContentTypeEncoder } from './encoding';
/**
* Writes JSON-RPC messages to an underlying transport.
*/
export interface MessageWriter {
/**
* Raised whenever an error occurs while writing a message.
*/
readonly onError: Event<[Error, Message | undefined, number | undefined]>;
/**
* An event raised when the underlying transport has closed and writing is no longer possible.
*/
readonly onClose: Event<void>;
/**
* Sends a JSON-RPC message.
* @param msg The JSON-RPC message to be sent.
* @description Implementations should guarantee messages are transmitted in the same order that they are received by this method.
*/
write(msg: Message): Promise<void>;
/**
* Call when the connection using this message writer ends
* (e.g. MessageConnection.end() is called)
*/
end(): void;
/** Releases resources incurred from writing or raising events. Does NOT close the underlying transport, if any. */
dispose(): void;
}
export declare namespace MessageWriter {
function is(value: any): value is MessageWriter;
}
export declare abstract class AbstractMessageWriter {
private errorEmitter;
private closeEmitter;
constructor();
dispose(): void;
get onError(): Event<[Error, Message | undefined, number | undefined]>;
protected fireError(error: any, message?: Message, count?: number): void;
get onClose(): Event<void>;
protected fireClose(): void;
private asError;
}
export interface MessageWriterOptions {
charset?: RAL.MessageBufferEncoding;
contentEncoder?: ContentEncoder;
contentTypeEncoder?: ContentTypeEncoder;
}
export declare class WriteableStreamMessageWriter extends AbstractMessageWriter implements MessageWriter {
private writable;
private options;
private errorCount;
private writeSemaphore;
constructor(writable: RAL.WritableStream, options?: RAL.MessageBufferEncoding | MessageWriterOptions);
write(msg: Message): Promise<void>;
private doWrite;
private handleError;
end(): void;
}

View File

@@ -0,0 +1,39 @@
import type { TSESTree } from '@typescript-eslint/utils';
import { SyntaxKind } from 'typescript';
import type { ValueOf } from './types';
export declare enum OperatorPrecedence {
Comma = 0,
Spread = 1,
Yield = 2,
Assignment = 3,
Conditional = 4,
Coalesce = 4,// NOTE: This is wrong
LogicalOR = 5,
LogicalAND = 6,
BitwiseOR = 7,
BitwiseXOR = 8,
BitwiseAND = 9,
Equality = 10,
Relational = 11,
Shift = 12,
Additive = 13,
Multiplicative = 14,
Exponentiation = 15,
Unary = 16,
Update = 17,
LeftHandSide = 18,
Member = 19,
Primary = 20,
Highest = 20,
Lowest = 0,
Invalid = -1
}
/**
* Note that this does not take into account parenthesization. You should check
* for parenthesization separately if it's relevant to your usage.
*/
export declare function getOperatorPrecedenceForNode(node: TSESTree.Node): OperatorPrecedence;
type TSESTreeOperatorKind = ValueOf<TSESTree.BinaryOperatorToText> | ValueOf<TSESTree.PunctuatorTokenToText>;
export declare function getOperatorPrecedence(nodeKind: SyntaxKind, operatorKind: SyntaxKind, hasArguments?: boolean): OperatorPrecedence;
export declare function getBinaryOperatorPrecedence(kind: SyntaxKind | TSESTreeOperatorKind): OperatorPrecedence;
export {};

View File

@@ -0,0 +1,2 @@
export declare var JsxEmit: any;
//# sourceMappingURL=jsxEmit.d.ts.map

View File

@@ -0,0 +1,14 @@
import test from 'node:test'
import assert from 'node:assert'
import pino from '../../pino.js'
import helper from '../helper.js'
const { sink, check, once } = helper
test('esm support', async () => {
const stream = sink()
const instance = pino(stream)
instance.info('hello world')
check(assert.equal, await once(stream, 'data'), 30, 'hello world')
})

View File

@@ -0,0 +1,325 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Parser = void 0;
const messages_1 = require("./messages");
const buffer_reader_1 = require("./buffer-reader");
// every message is prefixed with a single byte
const CODE_LENGTH = 1;
// every message has an int32 length which includes itself but does
// NOT include the code in the length
const LEN_LENGTH = 4;
const HEADER_LENGTH = CODE_LENGTH + LEN_LENGTH;
// A placeholder for a `BackendMessage`s length value that will be set after construction.
const LATEINIT_LENGTH = -1;
const emptyBuffer = Buffer.allocUnsafe(0);
class Parser {
constructor(opts) {
this.buffer = emptyBuffer;
this.bufferLength = 0;
this.bufferOffset = 0;
this.reader = new buffer_reader_1.BufferReader();
if ((opts === null || opts === void 0 ? void 0 : opts.mode) === 'binary') {
throw new Error('Binary mode not supported yet');
}
this.mode = (opts === null || opts === void 0 ? void 0 : opts.mode) || 'text';
}
parse(buffer, callback) {
this.mergeBuffer(buffer);
const bufferFullLength = this.bufferOffset + this.bufferLength;
let offset = this.bufferOffset;
while (offset + HEADER_LENGTH <= bufferFullLength) {
// code is 1 byte long - it identifies the message type
const code = this.buffer[offset];
// length is 1 Uint32BE - it is the length of the message EXCLUDING the code
const length = this.buffer.readUInt32BE(offset + CODE_LENGTH);
const fullMessageLength = CODE_LENGTH + length;
if (fullMessageLength + offset <= bufferFullLength) {
const message = this.handlePacket(offset + HEADER_LENGTH, code, length, this.buffer);
callback(message);
offset += fullMessageLength;
}
else {
break;
}
}
if (offset === bufferFullLength) {
// No more use for the buffer
this.buffer = emptyBuffer;
this.bufferLength = 0;
this.bufferOffset = 0;
}
else {
// Adjust the cursors of remainingBuffer
this.bufferLength = bufferFullLength - offset;
this.bufferOffset = offset;
}
}
mergeBuffer(buffer) {
if (this.bufferLength > 0) {
const newLength = this.bufferLength + buffer.byteLength;
const newFullLength = newLength + this.bufferOffset;
if (newFullLength > this.buffer.byteLength) {
// We can't concat the new buffer with the remaining one
let newBuffer;
if (newLength <= this.buffer.byteLength && this.bufferOffset >= this.bufferLength) {
// We can move the relevant part to the beginning of the buffer instead of allocating a new buffer
newBuffer = this.buffer;
}
else {
// Allocate a new larger buffer
let newBufferLength = this.buffer.byteLength * 2;
while (newLength >= newBufferLength) {
newBufferLength *= 2;
}
newBuffer = Buffer.allocUnsafe(newBufferLength);
}
// Move the remaining buffer to the new one
this.buffer.copy(newBuffer, 0, this.bufferOffset, this.bufferOffset + this.bufferLength);
this.buffer = newBuffer;
this.bufferOffset = 0;
}
// Concat the new buffer with the remaining one
buffer.copy(this.buffer, this.bufferOffset + this.bufferLength);
this.bufferLength = newLength;
}
else {
this.buffer = buffer;
this.bufferOffset = 0;
this.bufferLength = buffer.byteLength;
}
}
handlePacket(offset, code, length, bytes) {
const { reader } = this;
// NOTE: This undesirably retains the buffer in `this.reader` if the `parse*Message` calls below throw. However, those should only throw in the case of a protocol error, which normally results in the reader being discarded.
reader.setBuffer(offset, bytes);
let message;
switch (code) {
case 50 /* MessageCodes.BindComplete */:
message = messages_1.bindComplete;
break;
case 49 /* MessageCodes.ParseComplete */:
message = messages_1.parseComplete;
break;
case 51 /* MessageCodes.CloseComplete */:
message = messages_1.closeComplete;
break;
case 110 /* MessageCodes.NoData */:
message = messages_1.noData;
break;
case 115 /* MessageCodes.PortalSuspended */:
message = messages_1.portalSuspended;
break;
case 99 /* MessageCodes.CopyDone */:
message = messages_1.copyDone;
break;
case 87 /* MessageCodes.ReplicationStart */:
message = messages_1.replicationStart;
break;
case 73 /* MessageCodes.EmptyQuery */:
message = messages_1.emptyQuery;
break;
case 68 /* MessageCodes.DataRow */:
message = parseDataRowMessage(reader);
break;
case 67 /* MessageCodes.CommandComplete */:
message = parseCommandCompleteMessage(reader);
break;
case 90 /* MessageCodes.ReadyForQuery */:
message = parseReadyForQueryMessage(reader);
break;
case 65 /* MessageCodes.NotificationResponse */:
message = parseNotificationMessage(reader);
break;
case 82 /* MessageCodes.AuthenticationResponse */:
message = parseAuthenticationResponse(reader, length);
break;
case 83 /* MessageCodes.ParameterStatus */:
message = parseParameterStatusMessage(reader);
break;
case 75 /* MessageCodes.BackendKeyData */:
message = parseBackendKeyData(reader);
break;
case 69 /* MessageCodes.ErrorMessage */:
message = parseErrorMessage(reader, 'error');
break;
case 78 /* MessageCodes.NoticeMessage */:
message = parseErrorMessage(reader, 'notice');
break;
case 84 /* MessageCodes.RowDescriptionMessage */:
message = parseRowDescriptionMessage(reader);
break;
case 116 /* MessageCodes.ParameterDescriptionMessage */:
message = parseParameterDescriptionMessage(reader);
break;
case 71 /* MessageCodes.CopyIn */:
message = parseCopyInMessage(reader);
break;
case 72 /* MessageCodes.CopyOut */:
message = parseCopyOutMessage(reader);
break;
case 100 /* MessageCodes.CopyData */:
message = parseCopyData(reader, length);
break;
default:
return new messages_1.DatabaseError('received invalid response: ' + code.toString(16), length, 'error');
}
reader.setBuffer(0, emptyBuffer);
message.length = length;
return message;
}
}
exports.Parser = Parser;
const parseReadyForQueryMessage = (reader) => {
const status = reader.string(1);
return new messages_1.ReadyForQueryMessage(LATEINIT_LENGTH, status);
};
const parseCommandCompleteMessage = (reader) => {
const text = reader.cstring();
return new messages_1.CommandCompleteMessage(LATEINIT_LENGTH, text);
};
const parseCopyData = (reader, length) => {
const chunk = reader.bytes(length - 4);
return new messages_1.CopyDataMessage(LATEINIT_LENGTH, chunk);
};
const parseCopyInMessage = (reader) => parseCopyMessage(reader, 'copyInResponse');
const parseCopyOutMessage = (reader) => parseCopyMessage(reader, 'copyOutResponse');
const parseCopyMessage = (reader, messageName) => {
const isBinary = reader.byte() !== 0;
const columnCount = reader.int16();
const message = new messages_1.CopyResponse(LATEINIT_LENGTH, messageName, isBinary, columnCount);
for (let i = 0; i < columnCount; i++) {
message.columnTypes[i] = reader.int16();
}
return message;
};
const parseNotificationMessage = (reader) => {
const processId = reader.int32();
const channel = reader.cstring();
const payload = reader.cstring();
return new messages_1.NotificationResponseMessage(LATEINIT_LENGTH, processId, channel, payload);
};
const parseRowDescriptionMessage = (reader) => {
const fieldCount = reader.int16();
const message = new messages_1.RowDescriptionMessage(LATEINIT_LENGTH, fieldCount);
for (let i = 0; i < fieldCount; i++) {
message.fields[i] = parseField(reader);
}
return message;
};
const parseField = (reader) => {
const name = reader.cstring();
const tableID = reader.uint32();
const columnID = reader.int16();
const dataTypeID = reader.uint32();
const dataTypeSize = reader.int16();
const dataTypeModifier = reader.int32();
const mode = reader.int16() === 0 ? 'text' : 'binary';
return new messages_1.Field(name, tableID, columnID, dataTypeID, dataTypeSize, dataTypeModifier, mode);
};
const parseParameterDescriptionMessage = (reader) => {
const parameterCount = reader.int16();
const message = new messages_1.ParameterDescriptionMessage(LATEINIT_LENGTH, parameterCount);
for (let i = 0; i < parameterCount; i++) {
// OIDs are unsigned, same as dataTypeID in parseField above
message.dataTypeIDs[i] = reader.uint32();
}
return message;
};
const parseDataRowMessage = (reader) => {
const fieldCount = reader.int16();
const fields = new Array(fieldCount);
for (let i = 0; i < fieldCount; i++) {
const len = reader.int32();
// a -1 for length means the value of the field is null
fields[i] = len === -1 ? null : reader.string(len);
}
return new messages_1.DataRowMessage(LATEINIT_LENGTH, fields);
};
const parseParameterStatusMessage = (reader) => {
const name = reader.cstring();
const value = reader.cstring();
return new messages_1.ParameterStatusMessage(LATEINIT_LENGTH, name, value);
};
const parseBackendKeyData = (reader) => {
const processID = reader.int32();
const secretKey = reader.int32();
return new messages_1.BackendKeyDataMessage(LATEINIT_LENGTH, processID, secretKey);
};
const parseAuthenticationResponse = (reader, length) => {
const code = reader.int32();
// TODO(bmc): maybe better types here
const message = {
name: 'authenticationOk',
length,
};
switch (code) {
case 0: // AuthenticationOk
break;
case 3: // AuthenticationCleartextPassword
if (message.length === 8) {
message.name = 'authenticationCleartextPassword';
}
break;
case 5: // AuthenticationMD5Password
if (message.length === 12) {
message.name = 'authenticationMD5Password';
const salt = reader.bytes(4);
return new messages_1.AuthenticationMD5Password(LATEINIT_LENGTH, salt);
}
break;
case 10: // AuthenticationSASL
{
message.name = 'authenticationSASL';
message.mechanisms = [];
let mechanism;
do {
mechanism = reader.cstring();
if (mechanism) {
message.mechanisms.push(mechanism);
}
} while (mechanism);
}
break;
case 11: // AuthenticationSASLContinue
message.name = 'authenticationSASLContinue';
message.data = reader.string(length - 8);
break;
case 12: // AuthenticationSASLFinal
message.name = 'authenticationSASLFinal';
message.data = reader.string(length - 8);
break;
default:
throw new Error('Unknown authenticationOk message type ' + code);
}
return message;
};
const parseErrorMessage = (reader, name) => {
const fields = {};
let fieldType = reader.string(1);
while (fieldType !== '\0') {
fields[fieldType] = reader.cstring();
fieldType = reader.string(1);
}
const messageValue = fields.M;
const message = name === 'notice'
? new messages_1.NoticeMessage(LATEINIT_LENGTH, messageValue)
: new messages_1.DatabaseError(messageValue, LATEINIT_LENGTH, name);
message.severity = fields.S;
message.code = fields.C;
message.detail = fields.D;
message.hint = fields.H;
message.position = fields.P;
message.internalPosition = fields.p;
message.internalQuery = fields.q;
message.where = fields.W;
message.schema = fields.s;
message.table = fields.t;
message.column = fields.c;
message.dataType = fields.d;
message.constraint = fields.n;
message.file = fields.F;
message.line = fields.L;
message.routine = fields.R;
return message;
};
//# sourceMappingURL=parser.js.map

View File

@@ -0,0 +1,46 @@
{
"JSON.stringify@native": {
"name": "JSON.stringify@native",
"browser": "Firefox 54.0.0 (Windows 7 0.0.0)",
"suite": "libs",
"hz": 12763.618282362055,
"success": true,
"fastest": false,
"rme": 0.03332406073767073,
"rhz": 3.133737310719279,
"sampleSize": 171
},
"fast-stable-stringify@a9f81e8": {
"name": "fast-stable-stringify@a9f81e8",
"browser": "Firefox 54.0.0 (Windows 7 0.0.0)",
"suite": "libs",
"hz": 4072.9700727316076,
"success": true,
"fastest": true,
"rme": 0.014051350129001836,
"rhz": 1,
"sampleSize": 140
},
"json-stable-stringify@1.0.1": {
"name": "json-stable-stringify@1.0.1",
"browser": "Firefox 54.0.0 (Windows 7 0.0.0)",
"suite": "libs",
"hz": 2405.242424808171,
"success": true,
"fastest": false,
"rme": 0.016842437737423815,
"rhz": 0.5905377112665731,
"sampleSize": 132
},
"faster-stable-stringify@1.0.0": {
"name": "faster-stable-stringify@1.0.0",
"browser": "Firefox 54.0.0 (Windows 7 0.0.0)",
"suite": "libs",
"hz": 3663.1315639282516,
"success": true,
"fastest": false,
"rme": 0.01626300385787352,
"rhz": 0.8993760078063892,
"sampleSize": 169
}
}

View File

@@ -0,0 +1,26 @@
/**
* SHA2-512 a.k.a. sha512 and sha384. It is slower than sha256 in js because u64 operations are slow.
*
* Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and
* [the paper on truncated SHA512/256](https://eprint.iacr.org/2010/548.pdf).
* @module
* @deprecated
*/
import { SHA384 as SHA384n, sha384 as sha384n, sha512_224 as sha512_224n, SHA512_224 as SHA512_224n, sha512_256 as sha512_256n, SHA512_256 as SHA512_256n, SHA512 as SHA512n, sha512 as sha512n } from './sha2.ts';
/** @deprecated Use import from `noble/hashes/sha2` module */
export declare const SHA512: typeof SHA512n;
/** @deprecated Use import from `noble/hashes/sha2` module */
export declare const sha512: typeof sha512n;
/** @deprecated Use import from `noble/hashes/sha2` module */
export declare const SHA384: typeof SHA384n;
/** @deprecated Use import from `noble/hashes/sha2` module */
export declare const sha384: typeof sha384n;
/** @deprecated Use import from `noble/hashes/sha2` module */
export declare const SHA512_224: typeof SHA512_224n;
/** @deprecated Use import from `noble/hashes/sha2` module */
export declare const sha512_224: typeof sha512_224n;
/** @deprecated Use import from `noble/hashes/sha2` module */
export declare const SHA512_256: typeof SHA512_256n;
/** @deprecated Use import from `noble/hashes/sha2` module */
export declare const sha512_256: typeof sha512_256n;
//# sourceMappingURL=sha512.d.ts.map

View File

@@ -0,0 +1,216 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const tsutils = __importStar(require("ts-api-utils"));
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('prefer-destructuring');
const destructuringTypeConfig = {
type: 'object',
additionalProperties: false,
properties: {
array: {
type: 'boolean',
},
object: {
type: 'boolean',
},
},
};
const schema = [
{
oneOf: [
{
type: 'object',
additionalProperties: false,
properties: {
AssignmentExpression: destructuringTypeConfig,
VariableDeclarator: destructuringTypeConfig,
},
},
destructuringTypeConfig,
],
},
{
type: 'object',
additionalProperties: false,
properties: {
enforceForDeclarationWithTypeAnnotation: {
type: 'boolean',
description: 'Whether to enforce destructuring on variable declarations with type annotations.',
},
enforceForRenamedProperties: {
type: 'boolean',
description: 'Whether to enforce destructuring that use a different variable name than the property name.',
},
},
},
];
exports.default = (0, util_1.createRule)({
name: 'prefer-destructuring',
meta: {
type: 'suggestion',
// defaultOptions, -- base rule does not use defaultOptions
docs: {
description: 'Require destructuring from arrays and/or objects',
extendsBaseRule: true,
frozen: true,
requiresTypeChecking: true,
},
fixable: baseRule.meta.fixable,
hasSuggestions: baseRule.meta.hasSuggestions,
messages: baseRule.meta.messages,
schema,
},
defaultOptions: [
{
AssignmentExpression: {
array: true,
object: true,
},
VariableDeclarator: {
array: true,
object: true,
},
},
{},
],
create(context, [enabledTypes, options]) {
const { enforceForDeclarationWithTypeAnnotation = false, enforceForRenamedProperties = false, } = options;
const { esTreeNodeToTSNodeMap, program } = (0, util_1.getParserServices)(context);
const typeChecker = program.getTypeChecker();
const baseRules = baseRule.create(context);
let baseRulesWithoutFixCache = null;
return {
AssignmentExpression(node) {
if (node.operator !== '=') {
return;
}
performCheck(node.left, node.right, node);
},
VariableDeclarator(node) {
performCheck(node.id, node.init, node);
},
};
function performCheck(leftNode, rightNode, reportNode) {
const rules = leftNode.type === utils_1.AST_NODE_TYPES.Identifier &&
leftNode.typeAnnotation == null
? baseRules
: baseRulesWithoutFix();
if ((leftNode.type === utils_1.AST_NODE_TYPES.ArrayPattern ||
leftNode.type === utils_1.AST_NODE_TYPES.Identifier ||
leftNode.type === utils_1.AST_NODE_TYPES.ObjectPattern) &&
leftNode.typeAnnotation != null &&
!enforceForDeclarationWithTypeAnnotation) {
return;
}
if (rightNode != null &&
isArrayLiteralIntegerIndexAccess(rightNode) &&
rightNode.object.type !== utils_1.AST_NODE_TYPES.Super) {
const tsObj = esTreeNodeToTSNodeMap.get(rightNode.object);
const objType = typeChecker.getTypeAtLocation(tsObj);
if (!isTypeAnyOrIterableType(objType, typeChecker)) {
if (!enforceForRenamedProperties ||
!getNormalizedEnabledType(reportNode.type, 'object')) {
return;
}
context.report({
node: reportNode,
messageId: 'preferDestructuring',
data: { type: 'object' },
});
return;
}
}
if (reportNode.type === utils_1.AST_NODE_TYPES.AssignmentExpression) {
rules.AssignmentExpression(reportNode);
}
else {
rules.VariableDeclarator(reportNode);
}
}
function getNormalizedEnabledType(nodeType, destructuringType) {
if ('object' in enabledTypes || 'array' in enabledTypes) {
return enabledTypes[destructuringType];
}
return enabledTypes[nodeType][destructuringType];
}
function baseRulesWithoutFix() {
baseRulesWithoutFixCache ??= baseRule.create(noFixContext(context));
return baseRulesWithoutFixCache;
}
},
});
function noFixContext(context) {
const customContext = {
report: (descriptor) => {
context.report({
...descriptor,
fix: undefined,
});
},
};
// we can't directly proxy `context` because its `report` property is non-configurable
// and non-writable. So we proxy `customContext` and redirect all
// property access to the original context except for `report`
return new Proxy(customContext, {
get(target, path, receiver) {
if (path !== 'report') {
return Reflect.get(context, path, receiver);
}
return Reflect.get(target, path, receiver);
},
});
}
function isTypeAnyOrIterableType(type, typeChecker) {
if ((0, util_1.isTypeAnyType)(type)) {
return true;
}
if (!type.isUnion()) {
const iterator = tsutils.getWellKnownSymbolPropertyOfType(type, 'iterator', typeChecker);
return iterator != null;
}
return type.types.every(t => isTypeAnyOrIterableType(t, typeChecker));
}
function isArrayLiteralIntegerIndexAccess(node) {
if (node.type !== utils_1.AST_NODE_TYPES.MemberExpression) {
return false;
}
if (node.property.type !== utils_1.AST_NODE_TYPES.Literal) {
return false;
}
return Number.isInteger(node.property.value);
}

View File

@@ -0,0 +1,38 @@
import { Struct, Refiner } from '../struct.js';
/**
* Ensure that a string, array, map, or set is empty.
*/
export declare function empty<T extends string | any[] | Map<any, any> | Set<any>, S extends any>(struct: Struct<T, S>): Struct<T, S>;
/**
* Ensure that a number or date is below a threshold.
*/
export declare function max<T extends number | Date, S extends any>(struct: Struct<T, S>, threshold: T, options?: {
exclusive?: boolean;
}): Struct<T, S>;
/**
* Ensure that a number or date is above a threshold.
*/
export declare function min<T extends number | Date, S extends any>(struct: Struct<T, S>, threshold: T, options?: {
exclusive?: boolean;
}): Struct<T, S>;
/**
* Ensure that a string, array, map or set is not empty.
*/
export declare function nonempty<T extends string | any[] | Map<any, any> | Set<any>, S extends any>(struct: Struct<T, S>): Struct<T, S>;
/**
* Ensure that a string matches a regular expression.
*/
export declare function pattern<T extends string, S extends any>(struct: Struct<T, S>, regexp: RegExp): Struct<T, S>;
/**
* Ensure that a string, array, number, date, map, or set has a size (or length, or time) between `min` and `max`.
*/
export declare function size<T extends string | number | Date | any[] | Map<any, any> | Set<any>, S extends any>(struct: Struct<T, S>, min: number, max?: number): Struct<T, S>;
/**
* Augment a `Struct` to add an additional refinement to the validation.
*
* The refiner function is guaranteed to receive a value of the struct's type,
* because the struct's existing validation will already have passed. This
* allows you to layer additional validation on top of existing structs.
*/
export declare function refine<T, S>(struct: Struct<T, S>, name: string, refiner: Refiner<T>): Struct<T, S>;
//# sourceMappingURL=refinements.d.ts.map

View File

@@ -0,0 +1,15 @@
"use strict";
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// RUN THE FOLLOWING COMMAND FROM THE WORKSPACE ROOT TO REGENERATE:
// npx nx generate-lib repo
Object.defineProperty(exports, "__esModule", { value: true });
exports.es2024_promise = void 0;
const base_config_1 = require("./base-config");
exports.es2024_promise = {
libs: [],
variables: [
['PromiseWithResolvers', base_config_1.TYPE],
['PromiseConstructor', base_config_1.TYPE],
],
};

View File

@@ -0,0 +1,2 @@
import type { LibDefinition } from '../variable';
export declare const es6: LibDefinition;