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,35 @@
{
"for + if": {
"name": "for + if",
"browser": "Chrome 60.0.3112 (Windows 7 0.0.0)",
"suite": "itar-short",
"hz": 310902.8640157301,
"success": true,
"fastest": true,
"rme": 0.01056819380382985,
"rhz": 0.9976547366334327,
"sampleSize": 211
},
"while + if": {
"name": "while + if",
"browser": "Chrome 60.0.3112 (Windows 7 0.0.0)",
"suite": "itar-short",
"hz": 311633.7271798719,
"success": true,
"fastest": true,
"rme": 0.008028741690013557,
"rhz": 1,
"sampleSize": 212
},
"array join": {
"name": "array join",
"browser": "Chrome 60.0.3112 (Windows 7 0.0.0)",
"suite": "itar-short",
"hz": 264982.8188203513,
"success": true,
"fastest": false,
"rme": 0.010026939975144393,
"rhz": 0.8503021197940038,
"sampleSize": 212
}
}

View File

@@ -0,0 +1,53 @@
import * as ts from 'typescript';
/**
* @example
* ```ts
* class DerivedClass extends Promise<number> {}
* DerivedClass.reject
* // ^ PromiseLike
* ```
*/
export declare function isPromiseLike(program: ts.Program, type: ts.Type): boolean;
/**
* @example
* ```ts
* const value = Promise
* value.reject
* // ^ PromiseConstructorLike
* ```
*/
export declare function isPromiseConstructorLike(program: ts.Program, type: ts.Type): boolean;
/**
* @example
* ```ts
* class Foo extends Error {}
* new Foo()
* // ^ ErrorLike
* ```
*/
export declare function isErrorLike(program: ts.Program, type: ts.Type): boolean;
/**
* @example
* ```ts
* type T = Readonly<Error>
* // ^ ReadonlyErrorLike
* ```
*/
export declare function isReadonlyErrorLike(program: ts.Program, type: ts.Type): boolean;
/**
* @example
* ```ts
* type T = Readonly<{ foo: 'bar' }>
* // ^ ReadonlyTypeLike
* ```
*/
export declare function isReadonlyTypeLike(program: ts.Program, type: ts.Type, predicate?: (subType: {
aliasSymbol: ts.Symbol;
aliasTypeArguments: readonly ts.Type[];
} & ts.Type) => boolean): boolean;
export declare function isBuiltinTypeAliasLike(program: ts.Program, type: ts.Type, predicate: (subType: {
aliasSymbol: ts.Symbol;
aliasTypeArguments: readonly ts.Type[];
} & ts.Type) => boolean): boolean;
export declare function isBuiltinSymbolLike(program: ts.Program, type: ts.Type, symbolName: string | string[]): boolean;
export declare function isBuiltinSymbolLikeRecurser(program: ts.Program, type: ts.Type, predicate: (subType: ts.Type) => boolean | null): boolean;

View File

@@ -0,0 +1,149 @@
/**
* Client-side collection of per-request timing and transfer measurements.
*
* When enabled, each request records its round-trip latency and the number of
* payload bytes sent and received, accumulated into running totals and a
* fixed-size ring buffer of the most recent requests.
*
* The server measures its own per-request processing time independently. When a
* timing snapshot is requested, the client fetches the server's collection via
* a `getServerTiming` request and folds it into the returned {@link TimingInfo},
* yielding per-request and total server processing time and an estimated
* transport overhead (round-trip minus server processing time). Normal response
* messages are left unchanged.
*/
/** Number of most-recent requests retained in the ring buffer. */
export const RECENT_REQUEST_CAPACITY = 5;
function emptyAccumulators() {
return {
requestCount: 0,
roundTripMs: 0,
bytesSent: 0,
bytesReceived: 0,
serverTimeMs: 0,
transportOverheadMs: 0,
nodesMaterialized: 0,
sourceFilesFetched: 0,
nodesFetched: 0,
};
}
/** Returns a snapshot representing a disabled (never-collecting) timing state. */
export function disabledTimingInfo() {
return {
enabled: false,
totals: emptyAccumulators(),
recentRequests: [],
};
}
/** Returns a snapshot representing disabled server-side timing collection. */
export function disabledServerTimingInfo() {
return {
enabled: false,
totals: { requestCount: 0, totalProcessingTimeMs: 0 },
recentRequests: [],
};
}
/**
* Folds a server-side timing snapshot into a client-side snapshot, producing a
* combined {@link TimingInfo} with per-request and total server processing time
* plus estimated transport overhead.
*
* Recent requests are paired newest-to-newest and only matched when the method
* names agree, so that requests recorded by only one side (e.g. the meta
* requests used to fetch timing) do not misalign the two ring buffers.
*/
export function combineTimingInfo(client, server) {
if (!client.enabled) {
return client;
}
const serverTimeMs = server.totals.totalProcessingTimeMs;
const totals = {
...client.totals,
serverTimeMs,
transportOverheadMs: Math.max(0, client.totals.roundTripMs - serverTimeMs),
};
const recentRequests = client.recentRequests.map(r => ({ ...r }));
const serverRecent = server.recentRequests;
const pairs = Math.min(recentRequests.length, serverRecent.length);
for (let i = 1; i <= pairs; i++) {
const c = recentRequests[recentRequests.length - i];
const s = serverRecent[serverRecent.length - i];
if (c.method === s.method) {
c.serverTimeMs = s.processingTimeMs;
c.transportOverheadMs = Math.max(0, c.roundTripMs - s.processingTimeMs);
}
}
return {
enabled: true,
totals,
recentRequests,
};
}
/**
* Accumulates request timing samples into running totals and a fixed-size ring
* buffer of the most recent requests.
*/
export class TimingCollector {
totals = emptyAccumulators();
// Ring buffer of the most recent requests. `ring` grows to at most
// RECENT_REQUEST_CAPACITY; once full, `head` marks the oldest entry.
ring = [];
head = 0;
/** Records a single request's measurements. */
record(sample) {
this.totals.requestCount++;
this.totals.roundTripMs += sample.roundTripMs;
this.totals.bytesSent += sample.bytesSent;
this.totals.bytesReceived += sample.bytesReceived;
const entry = {
method: sample.method,
roundTripMs: sample.roundTripMs,
bytesSent: sample.bytesSent,
bytesReceived: sample.bytesReceived,
timestamp: Date.now(),
};
if (this.ring.length < RECENT_REQUEST_CAPACITY) {
this.ring.push(entry);
}
else {
this.ring[this.head] = entry;
this.head = (this.head + 1) % RECENT_REQUEST_CAPACITY;
}
}
/**
* Records a single AST node materialization. Called on demand as the consumer
* walks a binary source-file response's tree, so it is not tied to any one
* request.
*/
recordMaterialization() {
this.totals.nodesMaterialized++;
}
/**
* Records a fetched source file: increments the fetched-file counter and adds
* the file's materializable node count to the fetched-node total, which serves
* as the denominator for the share of fetched nodes that end up materialized.
*/
recordSourceFileFetched(materializableNodeCount) {
this.totals.sourceFilesFetched++;
this.totals.nodesFetched += materializableNodeCount;
}
/** Returns a snapshot of the collected timing information. */
getInfo() {
const recentRequests = [];
for (let i = 0; i < this.ring.length; i++) {
recentRequests.push(this.ring[(this.head + i) % this.ring.length]);
}
return {
enabled: true,
totals: { ...this.totals },
recentRequests,
};
}
/** Clears all accumulated totals and recent-request history. */
reset() {
this.totals = emptyAccumulators();
this.ring = [];
this.head = 0;
}
}
//# sourceMappingURL=timing.js.map

View File

@@ -0,0 +1,135 @@
/**
* @fileoverview Rule to enforce a single linebreak style.
* @author Erik Mueller
* @deprecated in ESLint v8.53.0
*/
"use strict";
//------------------------------------------------------------------------------
// Typedefs
//------------------------------------------------------------------------------
/**
* @import { SourceRange } from "@eslint/core";
*/
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const astUtils = require("./utils/ast-utils");
//------------------------------------------------------------------------------
// 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: "linebreak-style",
url: "https://eslint.style/rules/linebreak-style",
},
},
],
},
type: "layout",
docs: {
description: "Enforce consistent linebreak style",
recommended: false,
url: "https://eslint.org/docs/latest/rules/linebreak-style",
},
fixable: "whitespace",
schema: [
{
enum: ["unix", "windows"],
},
],
messages: {
expectedLF: "Expected linebreaks to be 'LF' but found 'CRLF'.",
expectedCRLF: "Expected linebreaks to be 'CRLF' but found 'LF'.",
},
},
create(context) {
const sourceCode = context.sourceCode;
//--------------------------------------------------------------------------
// Helpers
//--------------------------------------------------------------------------
/**
* Builds a fix function that replaces text at the specified range in the source text.
* @param {SourceRange} range The range to replace
* @param {string} text The text to insert.
* @returns {Function} Fixer function
* @private
*/
function createFix(range, text) {
return function (fixer) {
return fixer.replaceTextRange(range, text);
};
}
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
return {
Program: function checkForLinebreakStyle(node) {
const linebreakStyle = context.options[0] || "unix",
expectedLF = linebreakStyle === "unix",
expectedLFChars = expectedLF ? "\n" : "\r\n",
source = sourceCode.getText(),
pattern = astUtils.createGlobalLinebreakMatcher();
let match;
let i = 0;
while ((match = pattern.exec(source)) !== null) {
i++;
if (match[0] === expectedLFChars) {
continue;
}
const index = match.index;
const range = [index, index + match[0].length];
context.report({
node,
loc: {
start: {
line: i,
column: sourceCode.lines[i - 1].length,
},
end: {
line: i + 1,
column: 0,
},
},
messageId: expectedLF ? "expectedLF" : "expectedCRLF",
fix: createFix(range, expectedLFChars),
});
}
},
};
},
};

View File

@@ -0,0 +1,447 @@
/**
* @fileoverview Source code for spaced-comments rule
* @author Gyandeep Singh
* @deprecated in ESLint v8.53.0
*/
"use strict";
const escapeRegExp = require("escape-string-regexp");
const astUtils = require("./utils/ast-utils");
//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------
/**
* Escapes the control characters of a given string.
* @param {string} s A string to escape.
* @returns {string} An escaped string.
*/
function escape(s) {
return `(?:${escapeRegExp(s)})`;
}
/**
* Escapes the control characters of a given string.
* And adds a repeat flag.
* @param {string} s A string to escape.
* @returns {string} An escaped string.
*/
function escapeAndRepeat(s) {
return `${escape(s)}+`;
}
/**
* Parses `markers` option.
* If markers don't include `"*"`, this adds `"*"` to allow JSDoc comments.
* @param {string[]} [markers] A marker list.
* @returns {string[]} A marker list.
*/
function parseMarkersOption(markers) {
// `*` is a marker for JSDoc comments.
if (!markers.includes("*")) {
return markers.concat("*");
}
return markers;
}
/**
* Creates string pattern for exceptions.
* Generated pattern:
*
* 1. A space or an exception pattern sequence.
* @param {string[]} exceptions An exception pattern list.
* @returns {string} A regular expression string for exceptions.
*/
function createExceptionsPattern(exceptions) {
let pattern = "";
/*
* A space or an exception pattern sequence.
* [] ==> "\s"
* ["-"] ==> "(?:\s|\-+$)"
* ["-", "="] ==> "(?:\s|(?:\-+|=+)$)"
* ["-", "=", "--=="] ==> "(?:\s|(?:\-+|=+|(?:\-\-==)+)$)" ==> https://jex.im/regulex/#!embed=false&flags=&re=(%3F%3A%5Cs%7C(%3F%3A%5C-%2B%7C%3D%2B%7C(%3F%3A%5C-%5C-%3D%3D)%2B)%24)
*/
if (exceptions.length === 0) {
// a space.
pattern += "\\s";
} else {
// a space or...
pattern += "(?:\\s|";
if (exceptions.length === 1) {
// a sequence of the exception pattern.
pattern += escapeAndRepeat(exceptions[0]);
} else {
// a sequence of one of the exception patterns.
pattern += "(?:";
pattern += exceptions.map(escapeAndRepeat).join("|");
pattern += ")";
}
pattern += `(?:$|[${Array.from(astUtils.LINEBREAKS).join("")}]))`;
}
return pattern;
}
/**
* Creates RegExp object for `always` mode.
* Generated pattern for beginning of comment:
*
* 1. First, a marker or nothing.
* 2. Next, a space or an exception pattern sequence.
* @param {string[]} markers A marker list.
* @param {string[]} exceptions An exception pattern list.
* @returns {RegExp} A RegExp object for the beginning of a comment in `always` mode.
*/
function createAlwaysStylePattern(markers, exceptions) {
let pattern = "^";
/*
* A marker or nothing.
* ["*"] ==> "\*?"
* ["*", "!"] ==> "(?:\*|!)?"
* ["*", "/", "!<"] ==> "(?:\*|\/|(?:!<))?" ==> https://jex.im/regulex/#!embed=false&flags=&re=(%3F%3A%5C*%7C%5C%2F%7C(%3F%3A!%3C))%3F
*/
if (markers.length === 1) {
// the marker.
pattern += escape(markers[0]);
} else {
// one of markers.
pattern += "(?:";
pattern += markers.map(escape).join("|");
pattern += ")";
}
pattern += "?"; // or nothing.
pattern += createExceptionsPattern(exceptions);
return new RegExp(pattern, "u");
}
/**
* Creates RegExp object for `never` mode.
* Generated pattern for beginning of comment:
*
* 1. First, a marker or nothing (captured).
* 2. Next, a space or a tab.
* @param {string[]} markers A marker list.
* @returns {RegExp} A RegExp object for `never` mode.
*/
function createNeverStylePattern(markers) {
const pattern = `^(${markers.map(escape).join("|")})?[ \t]+`;
return new RegExp(pattern, "u");
}
//------------------------------------------------------------------------------
// 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: "spaced-comment",
url: "https://eslint.style/rules/spaced-comment",
},
},
],
},
type: "suggestion",
docs: {
description:
"Enforce consistent spacing after the `//` or `/*` in a comment",
recommended: false,
url: "https://eslint.org/docs/latest/rules/spaced-comment",
},
fixable: "whitespace",
schema: [
{
enum: ["always", "never"],
},
{
type: "object",
properties: {
exceptions: {
type: "array",
items: {
type: "string",
},
},
markers: {
type: "array",
items: {
type: "string",
},
},
line: {
type: "object",
properties: {
exceptions: {
type: "array",
items: {
type: "string",
},
},
markers: {
type: "array",
items: {
type: "string",
},
},
},
additionalProperties: false,
},
block: {
type: "object",
properties: {
exceptions: {
type: "array",
items: {
type: "string",
},
},
markers: {
type: "array",
items: {
type: "string",
},
},
balanced: {
type: "boolean",
default: false,
},
},
additionalProperties: false,
},
},
additionalProperties: false,
},
],
messages: {
unexpectedSpaceAfterMarker:
"Unexpected space or tab after marker ({{refChar}}) in comment.",
expectedExceptionAfter:
"Expected exception block, space or tab after '{{refChar}}' in comment.",
unexpectedSpaceBefore:
"Unexpected space or tab before '*/' in comment.",
unexpectedSpaceAfter:
"Unexpected space or tab after '{{refChar}}' in comment.",
expectedSpaceBefore:
"Expected space or tab before '*/' in comment.",
expectedSpaceAfter:
"Expected space or tab after '{{refChar}}' in comment.",
},
},
create(context) {
const sourceCode = context.sourceCode;
// Unless the first option is never, require a space
const requireSpace = context.options[0] !== "never";
/*
* Parse the second options.
* If markers don't include `"*"`, it's added automatically for JSDoc
* comments.
*/
const config = context.options[1] || {};
const balanced = config.block && config.block.balanced;
const styleRules = ["block", "line"].reduce((rule, type) => {
const markers = parseMarkersOption(
(config[type] && config[type].markers) || config.markers || [],
);
const exceptions =
(config[type] && config[type].exceptions) ||
config.exceptions ||
[];
const endNeverPattern = "[ \t]+$";
// Create RegExp object for valid patterns.
rule[type] = {
beginRegex: requireSpace
? createAlwaysStylePattern(markers, exceptions)
: createNeverStylePattern(markers),
endRegex:
balanced && requireSpace
? new RegExp(
`${createExceptionsPattern(exceptions)}$`,
"u",
)
: new RegExp(endNeverPattern, "u"),
hasExceptions: exceptions.length > 0,
captureMarker: new RegExp(
`^(${markers.map(escape).join("|")})`,
"u",
),
markers: new Set(markers),
};
return rule;
}, {});
/**
* Reports a beginning spacing error with an appropriate message.
* @param {ASTNode} node A comment node to check.
* @param {string} messageId An error message to report.
* @param {Array} match An array of match results for markers.
* @param {string} refChar Character used for reference in the error message.
* @returns {void}
*/
function reportBegin(node, messageId, match, refChar) {
const type = node.type.toLowerCase(),
commentIdentifier = type === "block" ? "/*" : "//";
context.report({
node,
fix(fixer) {
const start = node.range[0];
let end = start + 2;
if (requireSpace) {
if (match) {
end += match[0].length;
}
return fixer.insertTextAfterRange([start, end], " ");
}
end += match[0].length;
return fixer.replaceTextRange(
[start, end],
commentIdentifier + (match[1] ? match[1] : ""),
);
},
messageId,
data: { refChar },
});
}
/**
* Reports an ending spacing error with an appropriate message.
* @param {ASTNode} node A comment node to check.
* @param {string} messageId An error message to report.
* @param {string} match An array of the matched whitespace characters.
* @returns {void}
*/
function reportEnd(node, messageId, match) {
context.report({
node,
fix(fixer) {
if (requireSpace) {
return fixer.insertTextAfterRange(
[node.range[0], node.range[1] - 2],
" ",
);
}
const end = node.range[1] - 2,
start = end - match[0].length;
return fixer.replaceTextRange([start, end], "");
},
messageId,
});
}
/**
* Reports a given comment if it's invalid.
* @param {ASTNode} node a comment node to check.
* @returns {void}
*/
function checkCommentForSpace(node) {
const type = node.type.toLowerCase(),
rule = styleRules[type],
commentIdentifier = type === "block" ? "/*" : "//";
// Ignores empty comments and comments that consist only of a marker.
if (node.value.length === 0 || rule.markers.has(node.value)) {
return;
}
const beginMatch = rule.beginRegex.exec(node.value);
const endMatch = rule.endRegex.exec(node.value);
// Checks.
if (requireSpace) {
if (!beginMatch) {
const hasMarker = rule.captureMarker.exec(node.value);
const marker = hasMarker
? commentIdentifier + hasMarker[0]
: commentIdentifier;
if (rule.hasExceptions) {
reportBegin(
node,
"expectedExceptionAfter",
hasMarker,
marker,
);
} else {
reportBegin(
node,
"expectedSpaceAfter",
hasMarker,
marker,
);
}
}
if (balanced && type === "block" && !endMatch) {
reportEnd(node, "expectedSpaceBefore");
}
} else {
if (beginMatch) {
if (!beginMatch[1]) {
reportBegin(
node,
"unexpectedSpaceAfter",
beginMatch,
commentIdentifier,
);
} else {
reportBegin(
node,
"unexpectedSpaceAfterMarker",
beginMatch,
beginMatch[1],
);
}
}
if (balanced && type === "block" && endMatch) {
reportEnd(node, "unexpectedSpaceBefore", endMatch);
}
}
}
return {
Program() {
const comments = sourceCode.getAllComments();
comments
.filter(token => token.type !== "Shebang")
.forEach(checkCommentForSpace);
},
};
},
};

View File

@@ -0,0 +1,315 @@
/**
* @fileoverview Operator linebreak - enforces operator linebreak style of two types: after and before
* @author Benoît Zugmeyer
* @deprecated in ESLint v8.53.0
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const astUtils = require("./utils/ast-utils");
//------------------------------------------------------------------------------
// 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: "operator-linebreak",
url: "https://eslint.style/rules/operator-linebreak",
},
},
],
},
type: "layout",
docs: {
description: "Enforce consistent linebreak style for operators",
recommended: false,
url: "https://eslint.org/docs/latest/rules/operator-linebreak",
},
schema: [
{
enum: ["after", "before", "none", null],
},
{
type: "object",
properties: {
overrides: {
type: "object",
additionalProperties: {
enum: ["after", "before", "none", "ignore"],
},
},
},
additionalProperties: false,
},
],
fixable: "code",
messages: {
operatorAtBeginning:
"'{{operator}}' should be placed at the beginning of the line.",
operatorAtEnd:
"'{{operator}}' should be placed at the end of the line.",
badLinebreak: "Bad line breaking before and after '{{operator}}'.",
noLinebreak:
"There should be no line break before or after '{{operator}}'.",
},
},
create(context) {
const usedDefaultGlobal = !context.options[0];
const globalStyle = context.options[0] || "after";
const options = context.options[1] || {};
const styleOverrides = options.overrides
? Object.assign({}, options.overrides)
: {};
if (usedDefaultGlobal && !styleOverrides["?"]) {
styleOverrides["?"] = "before";
}
if (usedDefaultGlobal && !styleOverrides[":"]) {
styleOverrides[":"] = "before";
}
const sourceCode = context.sourceCode;
//--------------------------------------------------------------------------
// Helpers
//--------------------------------------------------------------------------
/**
* Gets a fixer function to fix rule issues
* @param {Token} operatorToken The operator token of an expression
* @param {string} desiredStyle The style for the rule. One of 'before', 'after', 'none'
* @returns {Function} A fixer function
*/
function getFixer(operatorToken, desiredStyle) {
return fixer => {
const tokenBefore = sourceCode.getTokenBefore(operatorToken);
const tokenAfter = sourceCode.getTokenAfter(operatorToken);
const textBefore = sourceCode.text.slice(
tokenBefore.range[1],
operatorToken.range[0],
);
const textAfter = sourceCode.text.slice(
operatorToken.range[1],
tokenAfter.range[0],
);
const hasLinebreakBefore = !astUtils.isTokenOnSameLine(
tokenBefore,
operatorToken,
);
const hasLinebreakAfter = !astUtils.isTokenOnSameLine(
operatorToken,
tokenAfter,
);
let newTextBefore, newTextAfter;
if (
hasLinebreakBefore !== hasLinebreakAfter &&
desiredStyle !== "none"
) {
// If there is a comment before and after the operator, don't do a fix.
if (
sourceCode.getTokenBefore(operatorToken, {
includeComments: true,
}) !== tokenBefore &&
sourceCode.getTokenAfter(operatorToken, {
includeComments: true,
}) !== tokenAfter
) {
return null;
}
/*
* If there is only one linebreak and it's on the wrong side of the operator, swap the text before and after the operator.
* foo &&
* bar
* would get fixed to
* foo
* && bar
*/
newTextBefore = textAfter;
newTextAfter = textBefore;
} else {
const LINEBREAK_REGEX =
astUtils.createGlobalLinebreakMatcher();
// Otherwise, if no linebreak is desired and no comments interfere, replace the linebreaks with empty strings.
newTextBefore =
desiredStyle === "before" || textBefore.trim()
? textBefore
: textBefore.replace(LINEBREAK_REGEX, "");
newTextAfter =
desiredStyle === "after" || textAfter.trim()
? textAfter
: textAfter.replace(LINEBREAK_REGEX, "");
// If there was no change (due to interfering comments), don't output a fix.
if (
newTextBefore === textBefore &&
newTextAfter === textAfter
) {
return null;
}
}
if (
newTextAfter === "" &&
tokenAfter.type === "Punctuator" &&
"+-".includes(operatorToken.value) &&
tokenAfter.value === operatorToken.value
) {
// To avoid accidentally creating a ++ or -- operator, insert a space if the operator is a +/- and the following token is a unary +/-.
newTextAfter += " ";
}
return fixer.replaceTextRange(
[tokenBefore.range[1], tokenAfter.range[0]],
newTextBefore + operatorToken.value + newTextAfter,
);
};
}
/**
* Checks the operator placement
* @param {ASTNode} node The node to check
* @param {ASTNode} rightSide The node that comes after the operator in `node`
* @param {string} operator The operator
* @private
* @returns {void}
*/
function validateNode(node, rightSide, operator) {
/*
* Find the operator token by searching from the right side, because between the left side and the operator
* there could be additional tokens from type annotations. Search specifically for the token which
* value equals the operator, in order to skip possible opening parentheses before the right side node.
*/
const operatorToken = sourceCode.getTokenBefore(
rightSide,
token => token.value === operator,
);
const leftToken = sourceCode.getTokenBefore(operatorToken);
const rightToken = sourceCode.getTokenAfter(operatorToken);
const operatorStyleOverride = styleOverrides[operator];
const style = operatorStyleOverride || globalStyle;
const fix = getFixer(operatorToken, style);
// if single line
if (
astUtils.isTokenOnSameLine(leftToken, operatorToken) &&
astUtils.isTokenOnSameLine(operatorToken, rightToken)
) {
// do nothing.
} else if (
operatorStyleOverride !== "ignore" &&
!astUtils.isTokenOnSameLine(leftToken, operatorToken) &&
!astUtils.isTokenOnSameLine(operatorToken, rightToken)
) {
// lone operator
context.report({
node,
loc: operatorToken.loc,
messageId: "badLinebreak",
data: {
operator,
},
fix,
});
} else if (
style === "before" &&
astUtils.isTokenOnSameLine(leftToken, operatorToken)
) {
context.report({
node,
loc: operatorToken.loc,
messageId: "operatorAtBeginning",
data: {
operator,
},
fix,
});
} else if (
style === "after" &&
astUtils.isTokenOnSameLine(operatorToken, rightToken)
) {
context.report({
node,
loc: operatorToken.loc,
messageId: "operatorAtEnd",
data: {
operator,
},
fix,
});
} else if (style === "none") {
context.report({
node,
loc: operatorToken.loc,
messageId: "noLinebreak",
data: {
operator,
},
fix,
});
}
}
/**
* Validates a binary expression using `validateNode`
* @param {BinaryExpression|LogicalExpression|AssignmentExpression} node node to be validated
* @returns {void}
*/
function validateBinaryExpression(node) {
validateNode(node, node.right, node.operator);
}
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
return {
BinaryExpression: validateBinaryExpression,
LogicalExpression: validateBinaryExpression,
AssignmentExpression: validateBinaryExpression,
VariableDeclarator(node) {
if (node.init) {
validateNode(node, node.init, "=");
}
},
PropertyDefinition(node) {
if (node.value) {
validateNode(node, node.value, "=");
}
},
ConditionalExpression(node) {
validateNode(node, node.consequent, "?");
validateNode(node, node.alternate, ":");
},
};
},
};

View File

@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
open-pull-requests-limit: 10
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "monthly"
open-pull-requests-limit: 10

View File

@@ -0,0 +1 @@
export { _ as default } from "../esm/_class_private_method_init.js";

View File

@@ -0,0 +1,20 @@
"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 __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./eslint-utils"), exports);
__exportStar(require("./helpers"), exports);
__exportStar(require("./misc"), exports);
__exportStar(require("./predicates"), exports);

View File

@@ -0,0 +1,477 @@
'use strict'
const { tspl } = require('@matteo.collina/tspl')
const http = require('node:http')
const { test } = require('node:test')
const serializers = require('../lib/req')
const { wrapRequestSerializer } = require('../')
test('maps request', async (t) => {
const p = tspl(t, { plan: 2 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
const serialized = serializers.mapHttpRequest(req)
p.ok(serialized.req)
p.ok(serialized.req.method)
res.end()
}
await p.completed
})
test('does not return excessively long object', async (t) => {
const p = tspl(t, { plan: 1 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
const serialized = serializers.reqSerializer(req)
p.strictEqual(Object.keys(serialized).length, 6)
res.end()
}
await p.completed
})
test('req.raw is available', async (t) => {
const p = tspl(t, { plan: 2 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
req.foo = 'foo'
const serialized = serializers.reqSerializer(req)
p.ok(serialized.raw)
p.strictEqual(serialized.raw.foo, 'foo')
res.end()
}
await p.completed
})
test('req.raw will be obtained in from input request raw property if input request raw property is truthy', async (t) => {
const p = tspl(t, { plan: 2 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
req.raw = { req: { foo: 'foo' }, res: {} }
const serialized = serializers.reqSerializer(req)
p.ok(serialized.raw)
p.strictEqual(serialized.raw.req.foo, 'foo')
res.end()
}
await p.completed
})
test('req.id defaults to undefined', async (t) => {
const p = tspl(t, { plan: 1 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
const serialized = serializers.reqSerializer(req)
p.strictEqual(serialized.id, undefined)
res.end()
}
await p.completed
})
test('req.id has a non-function value', async (t) => {
const p = tspl(t, { plan: 1 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
const serialized = serializers.reqSerializer(req)
p.strictEqual(typeof serialized.id === 'function', false)
res.end()
}
await p.completed
})
test('req.id will be obtained from input request info.id when input request id does not exist', async (t) => {
const p = tspl(t, { plan: 1 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
req.info = { id: 'test' }
const serialized = serializers.reqSerializer(req)
p.strictEqual(serialized.id, 'test')
res.end()
}
await p.completed
})
test('req.id has a non-function value with custom id function', async (t) => {
const p = tspl(t, { plan: 2 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
req.id = function () { return 42 }
const serialized = serializers.reqSerializer(req)
p.strictEqual(typeof serialized.id === 'function', false)
p.strictEqual(serialized.id, 42)
res.end()
}
await p.completed
})
test('req.url will be obtained from input request req.path when input request url is an object', async (t) => {
const p = tspl(t, { plan: 1 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
req.path = '/test'
const serialized = serializers.reqSerializer(req)
p.strictEqual(serialized.url, '/test')
res.end()
}
await p.completed
})
test('req.url will be obtained from input request url.path when input request url is an object', async (t) => {
const p = tspl(t, { plan: 1 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
req.url = { path: '/test' }
const serialized = serializers.reqSerializer(req)
p.strictEqual(serialized.url, '/test')
res.end()
}
await p.completed
})
test('req.url will be obtained from input request url when input request url is not an object', async (t) => {
const p = tspl(t, { plan: 1 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
req.url = '/test'
const serialized = serializers.reqSerializer(req)
p.strictEqual(serialized.url, '/test')
res.end()
}
await p.completed
})
test('req.url will be empty when input request path and url are not defined', async (t) => {
const p = tspl(t, { plan: 1 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
const serialized = serializers.reqSerializer(req)
p.strictEqual(serialized.url, '/')
res.end()
}
await p.completed
})
test('req.url will be obtained from input request originalUrl when available', async (t) => {
const p = tspl(t, { plan: 1 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
req.originalUrl = '/test'
const serialized = serializers.reqSerializer(req)
p.strictEqual(serialized.url, '/test')
res.end()
}
await p.completed
})
test('req.url will be obtained from input request url when req path is a function', async (t) => {
const p = tspl(t, { plan: 1 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
req.path = function () {
throw new Error('unexpected invocation')
}
req.url = '/test'
const serialized = serializers.reqSerializer(req)
p.strictEqual(serialized.url, '/test')
res.end()
}
await p.completed
})
test('req.url being undefined does not throw an error', async (t) => {
const p = tspl(t, { plan: 1 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
req.url = undefined
const serialized = serializers.reqSerializer(req)
p.strictEqual(serialized.url, undefined)
res.end()
}
await p.completed
})
test('can wrap request serializers', async (t) => {
const p = tspl(t, { plan: 3 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
const serailizer = wrapRequestSerializer(function (req) {
p.ok(req.method)
p.strictEqual(req.method, 'GET')
delete req.method
return req
})
function handler (req, res) {
const serialized = serailizer(req)
p.ok(!serialized.method)
res.end()
}
await p.completed
})
test('req.remoteAddress will be obtained from request socket.remoteAddress as fallback', async (t) => {
const p = tspl(t, { plan: 1 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
req.socket = { remoteAddress: 'http://localhost' }
const serialized = serializers.reqSerializer(req)
p.strictEqual(serialized.remoteAddress, 'http://localhost')
res.end()
}
await p.completed
})
test('req.remoteAddress will be obtained from request info.remoteAddress if available', async (t) => {
const p = tspl(t, { plan: 1 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
req.info = { remoteAddress: 'http://localhost' }
const serialized = serializers.reqSerializer(req)
p.strictEqual(serialized.remoteAddress, 'http://localhost')
res.end()
}
await p.completed
})
test('req.remotePort will be obtained from request socket.remotePort as fallback', async (t) => {
const p = tspl(t, { plan: 1 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
req.socket = { remotePort: 3000 }
const serialized = serializers.reqSerializer(req)
p.strictEqual(serialized.remotePort, 3000)
res.end()
}
await p.completed
})
test('req.remotePort will be obtained from request info.remotePort if available', async (t) => {
const p = tspl(t, { plan: 1 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
req.info = { remotePort: 3000 }
const serialized = serializers.reqSerializer(req)
p.strictEqual(serialized.remotePort, 3000)
res.end()
}
await p.completed
})
test('req.query is available', async (t) => {
const p = tspl(t, { plan: 1 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
req.query = '/foo?bar=foobar&bar=foo'
const serialized = serializers.reqSerializer(req)
p.strictEqual(serialized.query, '/foo?bar=foobar&bar=foo')
res.end()
}
await p.completed
})
test('req.params is available', async (t) => {
const p = tspl(t, { plan: 1 })
const server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.after(() => server.close())
function handler (req, res) {
req.params = '/foo/bar'
const serialized = serializers.reqSerializer(req)
p.strictEqual(serialized.params, '/foo/bar')
res.end()
}
await p.completed
})

View File

@@ -0,0 +1,4 @@
{
"main": "../../cjs/_class_private_field_loose_base.cjs",
"module": "../../esm/_class_private_field_loose_base.js"
}

View File

@@ -0,0 +1,13 @@
'use strict'
let Node = require('./node')
class Comment extends Node {
constructor(defaults) {
super(defaults)
this.type = 'comment'
}
}
module.exports = Comment
Comment.default = Comment

View File

@@ -0,0 +1,3 @@
timeout: 240
allow-incomplete-coverage: true
reporter: terse

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getHash = getHash;
exports.createCurve = createCurve;
/**
* Utilities for short weierstrass curves, combined with noble-hashes.
* @module
*/
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const weierstrass_ts_1 = require("./abstract/weierstrass.js");
/** connects noble-curves to noble-hashes */
function getHash(hash) {
return { hash };
}
/** @deprecated use new `weierstrass()` and `ecdsa()` methods */
function createCurve(curveDef, defHash) {
const create = (hash) => (0, weierstrass_ts_1.weierstrass)({ ...curveDef, hash: hash });
return { ...create(defHash), create };
}
//# sourceMappingURL=_shortw_utils.js.map

View File

@@ -0,0 +1,144 @@
/*
Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
(function () {
'use strict';
function isExpression(node) {
if (node == null) { return false; }
switch (node.type) {
case 'ArrayExpression':
case 'AssignmentExpression':
case 'BinaryExpression':
case 'CallExpression':
case 'ConditionalExpression':
case 'FunctionExpression':
case 'Identifier':
case 'Literal':
case 'LogicalExpression':
case 'MemberExpression':
case 'NewExpression':
case 'ObjectExpression':
case 'SequenceExpression':
case 'ThisExpression':
case 'UnaryExpression':
case 'UpdateExpression':
return true;
}
return false;
}
function isIterationStatement(node) {
if (node == null) { return false; }
switch (node.type) {
case 'DoWhileStatement':
case 'ForInStatement':
case 'ForStatement':
case 'WhileStatement':
return true;
}
return false;
}
function isStatement(node) {
if (node == null) { return false; }
switch (node.type) {
case 'BlockStatement':
case 'BreakStatement':
case 'ContinueStatement':
case 'DebuggerStatement':
case 'DoWhileStatement':
case 'EmptyStatement':
case 'ExpressionStatement':
case 'ForInStatement':
case 'ForStatement':
case 'IfStatement':
case 'LabeledStatement':
case 'ReturnStatement':
case 'SwitchStatement':
case 'ThrowStatement':
case 'TryStatement':
case 'VariableDeclaration':
case 'WhileStatement':
case 'WithStatement':
return true;
}
return false;
}
function isSourceElement(node) {
return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
}
function trailingStatement(node) {
switch (node.type) {
case 'IfStatement':
if (node.alternate != null) {
return node.alternate;
}
return node.consequent;
case 'LabeledStatement':
case 'ForStatement':
case 'ForInStatement':
case 'WhileStatement':
case 'WithStatement':
return node.body;
}
return null;
}
function isProblematicIfStatement(node) {
var current;
if (node.type !== 'IfStatement') {
return false;
}
if (node.alternate == null) {
return false;
}
current = node.consequent;
do {
if (current.type === 'IfStatement') {
if (current.alternate == null) {
return true;
}
}
current = trailingStatement(current);
} while (current);
return false;
}
module.exports = {
isExpression: isExpression,
isStatement: isStatement,
isIterationStatement: isIterationStatement,
isSourceElement: isSourceElement,
isProblematicIfStatement: isProblematicIfStatement,
trailingStatement: trailingStatement
};
}());
/* vim: set sw=4 ts=4 et tw=80 : */

View File

@@ -0,0 +1,11 @@
import type { TSESTree, ParserServicesWithTypeInformation } from '@typescript-eslint/utils';
import type * as ts from 'typescript';
/**
* Given a member of a class which extends another class or implements an interface,
* yields the corresponding member type for each of the base class/interfaces.
*/
export declare function getBaseTypesOfClassMember(services: ParserServicesWithTypeInformation, memberNode: TSESTree.MethodDefinition | TSESTree.PropertyDefinition): Generator<{
baseType: ts.Type;
baseMemberType: ts.Type;
heritageToken: ts.SyntaxKind.ExtendsKeyword | ts.SyntaxKind.ImplementsKeyword;
}>;

View File

@@ -0,0 +1,4 @@
{
"main": "../../cjs/_initializer_define_property.cjs",
"module": "../../esm/_initializer_define_property.js"
}

View File

@@ -0,0 +1,4 @@
import v35 from './v35.js';
import md5 from './md5.js';
var v3 = v35('v3', 0x30, md5);
export default v3;

View File

@@ -0,0 +1,4 @@
{
"main": "../../cjs/_unsupported_iterable_to_array.cjs",
"module": "../../esm/_unsupported_iterable_to_array.js"
}

View File

@@ -0,0 +1,72 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('max-params');
exports.default = (0, util_1.createRule)({
name: 'max-params',
meta: {
type: 'suggestion',
// defaultOptions, -- base rule does not use defaultOptions
docs: {
description: 'Enforce a maximum number of parameters in function definitions',
extendsBaseRule: true,
},
messages: baseRule.meta.messages,
schema: [
{
type: 'object',
additionalProperties: false,
properties: {
countVoidThis: {
type: 'boolean',
description: 'Whether to count a `this` declaration when the type is `void`.',
},
max: {
type: 'integer',
description: 'A maximum number of parameters in function definitions.',
minimum: 0,
},
maximum: {
type: 'integer',
description: '(deprecated) A maximum number of parameters in function definitions.',
minimum: 0,
},
},
},
],
},
defaultOptions: [{ countVoidThis: false, max: 3 }],
create(context, [{ countVoidThis }]) {
const baseRules = baseRule.create(context);
if (countVoidThis === true) {
return baseRules;
}
const removeVoidThisParam = (node) => {
if (node.params.length === 0 ||
node.params[0].type !== utils_1.AST_NODE_TYPES.Identifier ||
node.params[0].name !== 'this' ||
node.params[0].typeAnnotation?.typeAnnotation.type !==
utils_1.AST_NODE_TYPES.TSVoidKeyword) {
return node;
}
return {
...node,
params: node.params.slice(1),
};
};
const wrapListener = (listener) => {
return (node) => {
listener(removeVoidThisParam(node));
};
};
return {
ArrowFunctionExpression: wrapListener(baseRules.ArrowFunctionExpression),
FunctionDeclaration: wrapListener(baseRules.FunctionDeclaration),
FunctionExpression: wrapListener(baseRules.FunctionExpression),
TSDeclareFunction: wrapListener(baseRules.FunctionDeclaration),
TSFunctionType: wrapListener(baseRules.FunctionDeclaration),
};
},
});

View File

@@ -0,0 +1,5 @@
declare const lineSplitRE: RegExp;
declare function positionToOffset(source: string, lineNumber: number, columnNumber: number): number;
declare function offsetToLineNumber(source: string, offset: number): number;
export { lineSplitRE, offsetToLineNumber, positionToOffset };

View File

@@ -0,0 +1,21 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABILITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/////////////////////////////
/// WorkerGlobalScope APIs
/////////////////////////////
// These are only available in a Web Worker
declare function importScripts(...urls: string[]): void;

View File

@@ -0,0 +1,475 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/////////////////////////////
/// Window Iterable APIs
/////////////////////////////
interface AbortSignal {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/any_static) */
any(signals: Iterable<AbortSignal>): AbortSignal;
}
interface AudioParam {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioParam/setValueCurveAtTime) */
setValueCurveAtTime(values: Iterable<number>, startTime: number, duration: number): AudioParam;
}
interface AudioParamMap extends ReadonlyMap<string, AudioParam> {
}
interface BaseAudioContext {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createIIRFilter) */
createIIRFilter(feedforward: Iterable<number>, feedback: Iterable<number>): IIRFilterNode;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createPeriodicWave) */
createPeriodicWave(real: Iterable<number>, imag: Iterable<number>, constraints?: PeriodicWaveConstraints): PeriodicWave;
}
interface CSSKeyframesRule {
[Symbol.iterator](): IterableIterator<CSSKeyframeRule>;
}
interface CSSNumericArray {
[Symbol.iterator](): IterableIterator<CSSNumericValue>;
entries(): IterableIterator<[number, CSSNumericValue]>;
keys(): IterableIterator<number>;
values(): IterableIterator<CSSNumericValue>;
}
interface CSSRuleList {
[Symbol.iterator](): IterableIterator<CSSRule>;
}
interface CSSStyleDeclaration {
[Symbol.iterator](): IterableIterator<string>;
}
interface CSSTransformValue {
[Symbol.iterator](): IterableIterator<CSSTransformComponent>;
entries(): IterableIterator<[number, CSSTransformComponent]>;
keys(): IterableIterator<number>;
values(): IterableIterator<CSSTransformComponent>;
}
interface CSSUnparsedValue {
[Symbol.iterator](): IterableIterator<CSSUnparsedSegment>;
entries(): IterableIterator<[number, CSSUnparsedSegment]>;
keys(): IterableIterator<number>;
values(): IterableIterator<CSSUnparsedSegment>;
}
interface Cache {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Cache/addAll) */
addAll(requests: Iterable<RequestInfo>): Promise<void>;
}
interface CanvasPath {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/roundRect) */
roundRect(x: number, y: number, w: number, h: number, radii?: number | DOMPointInit | Iterable<number | DOMPointInit>): void;
}
interface CanvasPathDrawingStyles {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/setLineDash) */
setLineDash(segments: Iterable<number>): void;
}
interface CustomStateSet extends Set<string> {
}
interface DOMRectList {
[Symbol.iterator](): IterableIterator<DOMRect>;
}
interface DOMStringList {
[Symbol.iterator](): IterableIterator<string>;
}
interface DOMTokenList {
[Symbol.iterator](): IterableIterator<string>;
entries(): IterableIterator<[number, string]>;
keys(): IterableIterator<number>;
values(): IterableIterator<string>;
}
interface DataTransferItemList {
[Symbol.iterator](): IterableIterator<DataTransferItem>;
}
interface EventCounts extends ReadonlyMap<string, number> {
}
interface FileList {
[Symbol.iterator](): IterableIterator<File>;
}
interface FontFaceSet extends Set<FontFace> {
}
interface FormData {
[Symbol.iterator](): IterableIterator<[string, FormDataEntryValue]>;
/** Returns an array of key, value pairs for every entry in the list. */
entries(): IterableIterator<[string, FormDataEntryValue]>;
/** Returns a list of keys in the list. */
keys(): IterableIterator<string>;
/** Returns a list of values in the list. */
values(): IterableIterator<FormDataEntryValue>;
}
interface HTMLAllCollection {
[Symbol.iterator](): IterableIterator<Element>;
}
interface HTMLCollectionBase {
[Symbol.iterator](): IterableIterator<Element>;
}
interface HTMLCollectionOf<T extends Element> {
[Symbol.iterator](): IterableIterator<T>;
}
interface HTMLFormElement {
[Symbol.iterator](): IterableIterator<Element>;
}
interface HTMLSelectElement {
[Symbol.iterator](): IterableIterator<HTMLOptionElement>;
}
interface Headers {
[Symbol.iterator](): IterableIterator<[string, string]>;
/** Returns an iterator allowing to go through all key/value pairs contained in this object. */
entries(): IterableIterator<[string, string]>;
/** Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
keys(): IterableIterator<string>;
/** Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
values(): IterableIterator<string>;
}
interface Highlight extends Set<AbstractRange> {
}
interface HighlightRegistry extends Map<string, Highlight> {
}
interface IDBDatabase {
/**
* Returns a new transaction with the given mode ("readonly" or "readwrite") and scope which can be a single object store name or an array of names.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBDatabase/transaction)
*/
transaction(storeNames: string | Iterable<string>, mode?: IDBTransactionMode, options?: IDBTransactionOptions): IDBTransaction;
}
interface IDBObjectStore {
/**
* Creates a new index in store with the given name, keyPath and options and returns a new IDBIndex. If the keyPath and options define constraints that cannot be satisfied with the data already in store the upgrade transaction will abort with a "ConstraintError" DOMException.
*
* Throws an "InvalidStateError" DOMException if not called within an upgrade transaction.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/createIndex)
*/
createIndex(name: string, keyPath: string | Iterable<string>, options?: IDBIndexParameters): IDBIndex;
}
interface MIDIInputMap extends ReadonlyMap<string, MIDIInput> {
}
interface MIDIOutput {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/MIDIOutput/send) */
send(data: Iterable<number>, timestamp?: DOMHighResTimeStamp): void;
}
interface MIDIOutputMap extends ReadonlyMap<string, MIDIOutput> {
}
interface MediaKeyStatusMap {
[Symbol.iterator](): IterableIterator<[BufferSource, MediaKeyStatus]>;
entries(): IterableIterator<[BufferSource, MediaKeyStatus]>;
keys(): IterableIterator<BufferSource>;
values(): IterableIterator<MediaKeyStatus>;
}
interface MediaList {
[Symbol.iterator](): IterableIterator<string>;
}
interface MessageEvent<T = any> {
/**
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/initMessageEvent)
*/
initMessageEvent(type: string, bubbles?: boolean, cancelable?: boolean, data?: any, origin?: string, lastEventId?: string, source?: MessageEventSource | null, ports?: Iterable<MessagePort>): void;
}
interface MimeTypeArray {
[Symbol.iterator](): IterableIterator<MimeType>;
}
interface NamedNodeMap {
[Symbol.iterator](): IterableIterator<Attr>;
}
interface Navigator {
/**
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Navigator/requestMediaKeySystemAccess)
*/
requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: Iterable<MediaKeySystemConfiguration>): Promise<MediaKeySystemAccess>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Navigator/vibrate) */
vibrate(pattern: Iterable<number>): boolean;
}
interface NodeList {
[Symbol.iterator](): IterableIterator<Node>;
/** Returns an array of key, value pairs for every entry in the list. */
entries(): IterableIterator<[number, Node]>;
/** Returns an list of keys in the list. */
keys(): IterableIterator<number>;
/** Returns an list of values in the list. */
values(): IterableIterator<Node>;
}
interface NodeListOf<TNode extends Node> {
[Symbol.iterator](): IterableIterator<TNode>;
/** Returns an array of key, value pairs for every entry in the list. */
entries(): IterableIterator<[number, TNode]>;
/** Returns an list of keys in the list. */
keys(): IterableIterator<number>;
/** Returns an list of values in the list. */
values(): IterableIterator<TNode>;
}
interface Plugin {
[Symbol.iterator](): IterableIterator<MimeType>;
}
interface PluginArray {
[Symbol.iterator](): IterableIterator<Plugin>;
}
interface RTCRtpTransceiver {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/RTCRtpTransceiver/setCodecPreferences) */
setCodecPreferences(codecs: Iterable<RTCRtpCodecCapability>): void;
}
interface RTCStatsReport extends ReadonlyMap<string, any> {
}
interface SVGLengthList {
[Symbol.iterator](): IterableIterator<SVGLength>;
}
interface SVGNumberList {
[Symbol.iterator](): IterableIterator<SVGNumber>;
}
interface SVGPointList {
[Symbol.iterator](): IterableIterator<DOMPoint>;
}
interface SVGStringList {
[Symbol.iterator](): IterableIterator<string>;
}
interface SVGTransformList {
[Symbol.iterator](): IterableIterator<SVGTransform>;
}
interface SourceBufferList {
[Symbol.iterator](): IterableIterator<SourceBuffer>;
}
interface SpeechRecognitionResult {
[Symbol.iterator](): IterableIterator<SpeechRecognitionAlternative>;
}
interface SpeechRecognitionResultList {
[Symbol.iterator](): IterableIterator<SpeechRecognitionResult>;
}
interface StylePropertyMapReadOnly {
[Symbol.iterator](): IterableIterator<[string, Iterable<CSSStyleValue>]>;
entries(): IterableIterator<[string, Iterable<CSSStyleValue>]>;
keys(): IterableIterator<string>;
values(): IterableIterator<Iterable<CSSStyleValue>>;
}
interface StyleSheetList {
[Symbol.iterator](): IterableIterator<CSSStyleSheet>;
}
interface SubtleCrypto {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey) */
deriveKey(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKey>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey) */
generateKey(algorithm: "Ed25519", extractable: boolean, keyUsages: ReadonlyArray<"sign" | "verify">): Promise<CryptoKeyPair>;
generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>;
generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>;
generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKeyPair | CryptoKey>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey) */
importKey(format: "jwk", keyData: JsonWebKey, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>;
importKey(format: Exclude<KeyFormat, "jwk">, keyData: BufferSource, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKey>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey) */
unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, unwrappedKeyAlgorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKey>;
}
interface TextTrackCueList {
[Symbol.iterator](): IterableIterator<TextTrackCue>;
}
interface TextTrackList {
[Symbol.iterator](): IterableIterator<TextTrack>;
}
interface TouchList {
[Symbol.iterator](): IterableIterator<Touch>;
}
interface URLSearchParams {
[Symbol.iterator](): IterableIterator<[string, string]>;
/** Returns an array of key, value pairs for every entry in the search params. */
entries(): IterableIterator<[string, string]>;
/** Returns a list of keys in the search params. */
keys(): IterableIterator<string>;
/** Returns a list of values in the search params. */
values(): IterableIterator<string>;
}
interface WEBGL_draw_buffers {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WEBGL_draw_buffers/drawBuffersWEBGL) */
drawBuffersWEBGL(buffers: Iterable<GLenum>): void;
}
interface WEBGL_multi_draw {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WEBGL_multi_draw/multiDrawArraysInstancedWEBGL) */
multiDrawArraysInstancedWEBGL(mode: GLenum, firstsList: Int32Array | Iterable<GLint>, firstsOffset: number, countsList: Int32Array | Iterable<GLsizei>, countsOffset: number, instanceCountsList: Int32Array | Iterable<GLsizei>, instanceCountsOffset: number, drawcount: GLsizei): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WEBGL_multi_draw/multiDrawArraysWEBGL) */
multiDrawArraysWEBGL(mode: GLenum, firstsList: Int32Array | Iterable<GLint>, firstsOffset: number, countsList: Int32Array | Iterable<GLsizei>, countsOffset: number, drawcount: GLsizei): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WEBGL_multi_draw/multiDrawElementsInstancedWEBGL) */
multiDrawElementsInstancedWEBGL(mode: GLenum, countsList: Int32Array | Iterable<GLsizei>, countsOffset: number, type: GLenum, offsetsList: Int32Array | Iterable<GLsizei>, offsetsOffset: number, instanceCountsList: Int32Array | Iterable<GLsizei>, instanceCountsOffset: number, drawcount: GLsizei): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WEBGL_multi_draw/multiDrawElementsWEBGL) */
multiDrawElementsWEBGL(mode: GLenum, countsList: Int32Array | Iterable<GLsizei>, countsOffset: number, type: GLenum, offsetsList: Int32Array | Iterable<GLsizei>, offsetsOffset: number, drawcount: GLsizei): void;
}
interface WebGL2RenderingContextBase {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/clearBuffer) */
clearBufferfv(buffer: GLenum, drawbuffer: GLint, values: Iterable<GLfloat>, srcOffset?: number): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/clearBuffer) */
clearBufferiv(buffer: GLenum, drawbuffer: GLint, values: Iterable<GLint>, srcOffset?: number): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/clearBuffer) */
clearBufferuiv(buffer: GLenum, drawbuffer: GLint, values: Iterable<GLuint>, srcOffset?: number): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/drawBuffers) */
drawBuffers(buffers: Iterable<GLenum>): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/getActiveUniforms) */
getActiveUniforms(program: WebGLProgram, uniformIndices: Iterable<GLuint>, pname: GLenum): any;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/getUniformIndices) */
getUniformIndices(program: WebGLProgram, uniformNames: Iterable<string>): Iterable<GLuint> | null;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/invalidateFramebuffer) */
invalidateFramebuffer(target: GLenum, attachments: Iterable<GLenum>): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/invalidateSubFramebuffer) */
invalidateSubFramebuffer(target: GLenum, attachments: Iterable<GLenum>, x: GLint, y: GLint, width: GLsizei, height: GLsizei): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings) */
transformFeedbackVaryings(program: WebGLProgram, varyings: Iterable<string>, bufferMode: GLenum): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniform) */
uniform1uiv(location: WebGLUniformLocation | null, data: Iterable<GLuint>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniform) */
uniform2uiv(location: WebGLUniformLocation | null, data: Iterable<GLuint>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniform) */
uniform3uiv(location: WebGLUniformLocation | null, data: Iterable<GLuint>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniform) */
uniform4uiv(location: WebGLUniformLocation | null, data: Iterable<GLuint>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniformMatrix) */
uniformMatrix2x3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniformMatrix) */
uniformMatrix2x4fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniformMatrix) */
uniformMatrix3x2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniformMatrix) */
uniformMatrix3x4fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniformMatrix) */
uniformMatrix4x2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/uniformMatrix) */
uniformMatrix4x3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/vertexAttribI) */
vertexAttribI4iv(index: GLuint, values: Iterable<GLint>): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/vertexAttribI) */
vertexAttribI4uiv(index: GLuint, values: Iterable<GLuint>): void;
}
interface WebGL2RenderingContextOverloads {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
uniform1fv(location: WebGLUniformLocation | null, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
uniform1iv(location: WebGLUniformLocation | null, data: Iterable<GLint>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
uniform2fv(location: WebGLUniformLocation | null, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
uniform2iv(location: WebGLUniformLocation | null, data: Iterable<GLint>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
uniform3fv(location: WebGLUniformLocation | null, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
uniform3iv(location: WebGLUniformLocation | null, data: Iterable<GLint>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
uniform4fv(location: WebGLUniformLocation | null, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
uniform4iv(location: WebGLUniformLocation | null, data: Iterable<GLint>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniformMatrix) */
uniformMatrix2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniformMatrix) */
uniformMatrix3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniformMatrix) */
uniformMatrix4fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable<GLfloat>, srcOffset?: number, srcLength?: GLuint): void;
}
interface WebGLRenderingContextBase {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/vertexAttrib) */
vertexAttrib1fv(index: GLuint, values: Iterable<GLfloat>): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/vertexAttrib) */
vertexAttrib2fv(index: GLuint, values: Iterable<GLfloat>): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/vertexAttrib) */
vertexAttrib3fv(index: GLuint, values: Iterable<GLfloat>): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/vertexAttrib) */
vertexAttrib4fv(index: GLuint, values: Iterable<GLfloat>): void;
}
interface WebGLRenderingContextOverloads {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
uniform1fv(location: WebGLUniformLocation | null, v: Iterable<GLfloat>): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
uniform1iv(location: WebGLUniformLocation | null, v: Iterable<GLint>): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
uniform2fv(location: WebGLUniformLocation | null, v: Iterable<GLfloat>): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
uniform2iv(location: WebGLUniformLocation | null, v: Iterable<GLint>): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
uniform3fv(location: WebGLUniformLocation | null, v: Iterable<GLfloat>): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
uniform3iv(location: WebGLUniformLocation | null, v: Iterable<GLint>): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
uniform4fv(location: WebGLUniformLocation | null, v: Iterable<GLfloat>): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniform) */
uniform4iv(location: WebGLUniformLocation | null, v: Iterable<GLint>): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniformMatrix) */
uniformMatrix2fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Iterable<GLfloat>): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniformMatrix) */
uniformMatrix3fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Iterable<GLfloat>): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/uniformMatrix) */
uniformMatrix4fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Iterable<GLfloat>): void;
}

View File

@@ -0,0 +1,30 @@
# Pino is an OPEN Open Source Project
## What?
Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.
## Rules
Before you start coding, please read [Contributing to projects with git](https://jrfom.com/posts/2017/03/08/a-primer-on-contributing-to-projects-with-git/).
Notice that as long as you don't have commit-access to the project, you have to fork the project and open PRs from the feature branches of the forked project.
There are a few basic ground-rules for contributors:
1. **No `--force` pushes** on `main` or modifying the Git history in any way after a PR has been merged.
1. **Non-main branches** ought to be used for ongoing work.
1. **Non-trivial changes** ought to be subject to an **internal pull-request** to solicit feedback from other contributors.
1. All pull-requests for new features **must** target the `main` branch. PRs to fix bugs in LTS releases are also allowed.
1. Contributors should attempt to adhere to the prevailing code-style.
1. 100% code coverage
## Releases
Declaring formal releases remains the prerogative of the project maintainer.
## Changes to this arrangement
This is an experiment and feedback is welcome! This document may also be subject to pull-requests or changes by contributors where you believe you have something valuable to add or change.
-----------------------------------------

View File

@@ -0,0 +1,30 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABILITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
interface RegExpConstructor {
/**
* Escapes any RegExp syntax characters in the input string, returning a
* new string that can be safely interpolated into a RegExp as a literal
* string to match.
* @example
* ```ts
* const regExp = new RegExp(RegExp.escape("foo.bar"));
* regExp.test("foo.bar"); // true
* regExp.test("foo!bar"); // false
* ```
*/
escape(string: string): string;
}

View File

@@ -0,0 +1,3 @@
import * as ts from 'typescript';
export declare function isSourceFile(code: unknown): code is ts.SourceFile;
export declare function getCodeText(code: string | ts.SourceFile): string;

View File

@@ -0,0 +1,8 @@
'use strict'
const SonicBoom = require('.')
const sonic = new SonicBoom({ fd: process.stdout.fd }) // or 'destination'
for (let i = 0; i < 10; i++) {
sonic.write('hello sonic\n')
}

View File

@@ -0,0 +1,12 @@
{{# def.definitions }}
{{# def.errors }}
{{# def.setupKeyword }}
{{# def.$data }}
{{# def.numberKeyword }}
{{ var $op = $keyword == 'maxItems' ? '>' : '<'; }}
if ({{# def.$dataNotType:'number' }} {{=$data}}.length {{=$op}} {{=$schemaValue}}) {
{{ var $errorKeyword = $keyword; }}
{{# def.error:'_limitItems' }}
} {{? $breakOnError }} else { {{?}}

View File

@@ -0,0 +1,80 @@
'use strict';
module.exports = function generate_multipleOf(it, $keyword, $ruleType) {
var out = ' ';
var $lvl = it.level;
var $dataLvl = it.dataLevel;
var $schema = it.schema[$keyword];
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
var $breakOnError = !it.opts.allErrors;
var $data = 'data' + ($dataLvl || '');
var $isData = it.opts.$data && $schema && $schema.$data,
$schemaValue;
if ($isData) {
out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
$schemaValue = 'schema' + $lvl;
} else {
$schemaValue = $schema;
}
if (!($isData || typeof $schema == 'number')) {
throw new Error($keyword + ' must be number');
}
out += 'var division' + ($lvl) + ';if (';
if ($isData) {
out += ' ' + ($schemaValue) + ' !== undefined && ( typeof ' + ($schemaValue) + ' != \'number\' || ';
}
out += ' (division' + ($lvl) + ' = ' + ($data) + ' / ' + ($schemaValue) + ', ';
if (it.opts.multipleOfPrecision) {
out += ' Math.abs(Math.round(division' + ($lvl) + ') - division' + ($lvl) + ') > 1e-' + (it.opts.multipleOfPrecision) + ' ';
} else {
out += ' division' + ($lvl) + ' !== parseInt(division' + ($lvl) + ') ';
}
out += ' ) ';
if ($isData) {
out += ' ) ';
}
out += ' ) { ';
var $$outStack = $$outStack || [];
$$outStack.push(out);
out = ''; /* istanbul ignore else */
if (it.createErrors !== false) {
out += ' { keyword: \'' + ('multipleOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { multipleOf: ' + ($schemaValue) + ' } ';
if (it.opts.messages !== false) {
out += ' , message: \'should be multiple of ';
if ($isData) {
out += '\' + ' + ($schemaValue);
} else {
out += '' + ($schemaValue) + '\'';
}
}
if (it.opts.verbose) {
out += ' , schema: ';
if ($isData) {
out += 'validate.schema' + ($schemaPath);
} else {
out += '' + ($schema);
}
out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
}
out += ' } ';
} else {
out += ' {} ';
}
var __err = out;
out = $$outStack.pop();
if (!it.compositeRule && $breakOnError) {
/* istanbul ignore if */
if (it.async) {
out += ' throw new ValidationError([' + (__err) + ']); ';
} else {
out += ' validate.errors = [' + (__err) + ']; return false; ';
}
} else {
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
}
out += '} ';
if ($breakOnError) {
out += ' else { ';
}
return out;
}

View File

@@ -0,0 +1,15 @@
import { r as rpc } from './chunk-mocker.js';
class ModuleMockerServerInterceptor {
async register(module) {
await rpc("vitest:interceptor:register", module.toJSON());
}
async delete(id) {
await rpc("vitest:interceptor:delete", id);
}
async invalidate() {
await rpc("vitest:interceptor:invalidate");
}
}
export { ModuleMockerServerInterceptor as M };

View File

@@ -0,0 +1,257 @@
'use strict'
const test = require('node:test')
const assert = require('node:assert')
const stdSerializers = require('pino-std-serializers')
const { sink, once } = require('./helper')
const pino = require('../')
const parentSerializers = {
test: () => 'parent'
}
const childSerializers = {
test: () => 'child'
}
test('default err namespace error serializer', async () => {
const stream = sink()
const parent = pino(stream)
parent.info({ err: ReferenceError('test') })
const o = await once(stream, 'data')
assert.equal(typeof o.err, 'object')
assert.equal(o.err.type, 'ReferenceError')
assert.equal(o.err.message, 'test')
assert.equal(typeof o.err.stack, 'string')
})
test('custom serializer overrides default err namespace error serializer', async () => {
const stream = sink()
const parent = pino({
serializers: {
err: (e) => ({
t: e.constructor.name,
m: e.message,
s: e.stack
})
}
}, stream)
parent.info({ err: ReferenceError('test') })
const o = await once(stream, 'data')
assert.equal(typeof o.err, 'object')
assert.equal(o.err.t, 'ReferenceError')
assert.equal(o.err.m, 'test')
assert.equal(typeof o.err.s, 'string')
})
test('custom serializer overrides default err namespace error serializer when nestedKey is on', async () => {
const stream = sink()
const parent = pino({
nestedKey: 'obj',
serializers: {
err: (e) => {
return {
t: e.constructor.name,
m: e.message,
s: e.stack
}
}
}
}, stream)
parent.info({ err: ReferenceError('test') })
const o = await once(stream, 'data')
assert.equal(typeof o.obj.err, 'object')
assert.equal(o.obj.err.t, 'ReferenceError')
assert.equal(o.obj.err.m, 'test')
assert.equal(typeof o.obj.err.s, 'string')
})
test('null overrides default err namespace error serializer', async () => {
const stream = sink()
const parent = pino({ serializers: { err: null } }, stream)
parent.info({ err: ReferenceError('test') })
const o = await once(stream, 'data')
assert.equal(typeof o.err, 'object')
assert.equal(typeof o.err.type, 'undefined')
assert.equal(typeof o.err.message, 'undefined')
assert.equal(typeof o.err.stack, 'undefined')
})
test('undefined overrides default err namespace error serializer', async () => {
const stream = sink()
const parent = pino({ serializers: { err: undefined } }, stream)
parent.info({ err: ReferenceError('test') })
const o = await once(stream, 'data')
assert.equal(typeof o.err, 'object')
assert.equal(typeof o.err.type, 'undefined')
assert.equal(typeof o.err.message, 'undefined')
assert.equal(typeof o.err.stack, 'undefined')
})
test('serializers override values', async () => {
const stream = sink()
const parent = pino({ serializers: parentSerializers }, stream)
parent.child({}, { serializers: childSerializers })
parent.fatal({ test: 'test' })
const o = await once(stream, 'data')
assert.equal(o.test, 'parent')
})
test('child does not overwrite parent serializers', async () => {
const stream = sink()
const parent = pino({ serializers: parentSerializers }, stream)
const child = parent.child({}, { serializers: childSerializers })
parent.fatal({ test: 'test' })
const o = once(stream, 'data')
assert.equal((await o).test, 'parent')
const o2 = once(stream, 'data')
child.fatal({ test: 'test' })
assert.equal((await o2).test, 'child')
})
test('Symbol.for(\'pino.serializers\')', async () => {
const stream = sink()
const expected = Object.assign({
err: stdSerializers.err
}, parentSerializers)
const parent = pino({ serializers: parentSerializers }, stream)
const child = parent.child({ a: 'property' })
assert.deepEqual(parent[Symbol.for('pino.serializers')], expected)
assert.deepEqual(child[Symbol.for('pino.serializers')], expected)
assert.equal(parent[Symbol.for('pino.serializers')], child[Symbol.for('pino.serializers')])
const child2 = parent.child({}, {
serializers: {
a
}
})
function a () {
return 'hello'
}
// eslint-disable-next-line eqeqeq
assert.equal(child2[Symbol.for('pino.serializers')] != parentSerializers, true)
assert.equal(child2[Symbol.for('pino.serializers')].a, a)
assert.equal(child2[Symbol.for('pino.serializers')].test, parentSerializers.test)
})
test('children inherit parent serializers', async () => {
const stream = sink()
const parent = pino({ serializers: parentSerializers }, stream)
const child = parent.child({ a: 'property' })
child.fatal({ test: 'test' })
const o = await once(stream, 'data')
assert.equal(o.test, 'parent')
})
test('children inherit parent Symbol serializers', async () => {
const stream = sink()
const symbolSerializers = {
[Symbol.for('b')]: b
}
const expected = Object.assign({
err: stdSerializers.err
}, symbolSerializers)
const parent = pino({ serializers: symbolSerializers }, stream)
assert.deepEqual(parent[Symbol.for('pino.serializers')], expected)
const child = parent.child({}, {
serializers: {
[Symbol.for('a')]: a,
a
}
})
function a () {
return 'hello'
}
function b () {
return 'world'
}
assert.deepEqual(child[Symbol.for('pino.serializers')].a, a)
assert.deepEqual(child[Symbol.for('pino.serializers')][Symbol.for('b')], b)
assert.deepEqual(child[Symbol.for('pino.serializers')][Symbol.for('a')], a)
})
test('children serializers get called', async () => {
const stream = sink()
const parent = pino({
test: 'this'
}, stream)
const child = parent.child({ a: 'property' }, { serializers: childSerializers })
child.fatal({ test: 'test' })
const o = await once(stream, 'data')
assert.equal(o.test, 'child')
})
test('children serializers get called when inherited from parent', async () => {
const stream = sink()
const parent = pino({
test: 'this',
serializers: parentSerializers
}, stream)
const child = parent.child({}, { serializers: { test: function () { return 'pass' } } })
child.fatal({ test: 'fail' })
const o = await once(stream, 'data')
assert.equal(o.test, 'pass')
})
test('non-overridden serializers are available in the children', async () => {
const stream = sink()
const pSerializers = {
onlyParent: function () { return 'parent' },
shared: function () { return 'parent' }
}
const cSerializers = {
shared: function () { return 'child' },
onlyChild: function () { return 'child' }
}
const parent = pino({ serializers: pSerializers }, stream)
const child = parent.child({}, { serializers: cSerializers })
const o = once(stream, 'data')
child.fatal({ shared: 'test' })
assert.equal((await o).shared, 'child')
const o2 = once(stream, 'data')
child.fatal({ onlyParent: 'test' })
assert.equal((await o2).onlyParent, 'parent')
const o3 = once(stream, 'data')
child.fatal({ onlyChild: 'test' })
assert.equal((await o3).onlyChild, 'child')
const o4 = once(stream, 'data')
parent.fatal({ onlyChild: 'test' })
assert.equal((await o4).onlyChild, 'test')
})
test('custom serializer for messageKey', async () => {
const stream = sink()
const instance = pino({ serializers: { msg: () => '422' } }, stream)
const o = { num: NaN }
instance.info(o, 42)
const { msg } = await once(stream, 'data')
assert.equal(msg, '422')
})

View File

@@ -0,0 +1,57 @@
# Installation
> `npm install --save @types/deep-eql`
# Summary
This package contains type definitions for deep-eql (https://github.com/chaijs/deep-eql).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/deep-eql.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/deep-eql/index.d.ts)
````ts
declare namespace deepEqual {
/**
* Memoization class used to speed up comparison.
*/
class MemoizeMap extends WeakMap<object, MemoizeMap | boolean> {}
interface DeepEqualOptions<T1 = unknown, T2 = unknown> {
/**
* Override default algorithm, determining custom equality.
*/
comparator?: (leftHandOperand: T1, rightHandOperand: T2) => boolean | null;
/**
* Provide a custom memoization object which will cache the results of
* complex objects for a speed boost.
*
* By passing `false` you can disable memoization, but this will cause circular
* references to blow the stack.
*/
memoize?: MemoizeMap | false;
}
}
/**
* Assert deeply nested sameValue equality between two objects of any type.
*
* @param leftHandOperand
* @param rightHandOperand
* @param [options] Additional options
* @return equal match
*/
declare function deepEqual<T1, T2>(
leftHandOperand: T1,
rightHandOperand: T2,
options?: deepEqual.DeepEqualOptions<T1, T2>,
): boolean;
export = deepEqual;
````
### Additional Details
* Last updated: Mon, 06 Nov 2023 22:41:05 GMT
* Dependencies: none
# Credits
These definitions were written by [Rodrigo Pietnechuk](https://github.com/ghnoob).

View File

@@ -0,0 +1,170 @@
/**
* @fileoverview Globals for ecmaVersion/sourceType
* @author Nicholas C. Zakas
*/
"use strict";
//-----------------------------------------------------------------------------
// Globals
//-----------------------------------------------------------------------------
const commonjs = {
exports: true,
global: false,
module: false,
require: false,
};
const es3 = {
Array: false,
Boolean: false,
constructor: false,
Date: false,
decodeURI: false,
decodeURIComponent: false,
encodeURI: false,
encodeURIComponent: false,
Error: false,
escape: false,
eval: false,
EvalError: false,
Function: false,
hasOwnProperty: false,
Infinity: false,
isFinite: false,
isNaN: false,
isPrototypeOf: false,
Math: false,
NaN: false,
Number: false,
Object: false,
parseFloat: false,
parseInt: false,
propertyIsEnumerable: false,
RangeError: false,
ReferenceError: false,
RegExp: false,
String: false,
SyntaxError: false,
toLocaleString: false,
toString: false,
TypeError: false,
undefined: false,
unescape: false,
URIError: false,
valueOf: false,
};
const es5 = {
...es3,
JSON: false,
};
const es2015 = {
...es5,
ArrayBuffer: false,
DataView: false,
Float32Array: false,
Float64Array: false,
Int16Array: false,
Int32Array: false,
Int8Array: false,
Intl: false,
Map: false,
Promise: false,
Proxy: false,
Reflect: false,
Set: false,
Symbol: false,
Uint16Array: false,
Uint32Array: false,
Uint8Array: false,
Uint8ClampedArray: false,
WeakMap: false,
WeakSet: false,
};
// no new globals in ES2016
const es2016 = {
...es2015,
};
const es2017 = {
...es2016,
Atomics: false,
SharedArrayBuffer: false,
};
// no new globals in ES2018
const es2018 = {
...es2017,
};
// no new globals in ES2019
const es2019 = {
...es2018,
};
const es2020 = {
...es2019,
BigInt: false,
BigInt64Array: false,
BigUint64Array: false,
globalThis: false,
};
const es2021 = {
...es2020,
AggregateError: false,
FinalizationRegistry: false,
WeakRef: false,
};
const es2022 = {
...es2021,
};
const es2023 = {
...es2022,
};
const es2024 = {
...es2023,
};
const es2025 = {
...es2024,
Float16Array: false,
Iterator: false,
};
const es2026 = {
...es2025,
AsyncDisposableStack: false,
DisposableStack: false,
SuppressedError: false,
Temporal: false,
};
//-----------------------------------------------------------------------------
// Exports
//-----------------------------------------------------------------------------
module.exports = {
commonjs,
es3,
es5,
es2015,
es2016,
es2017,
es2018,
es2019,
es2020,
es2021,
es2022,
es2023,
es2024,
es2025,
es2026,
};