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,42 @@
declare namespace pLimit {
interface Limit {
/**
The number of promises that are currently running.
*/
readonly activeCount: number;
/**
The number of promises that are waiting to run (i.e. their internal `fn` was not called yet).
*/
readonly pendingCount: number;
/**
Discard pending promises that are waiting to run.
This might be useful if you want to teardown the queue at the end of your program's lifecycle or discard any function calls referencing an intermediary state of your app.
Note: This does not cancel promises that are already running.
*/
clearQueue: () => void;
/**
@param fn - Promise-returning/async function.
@param arguments - Any arguments to pass through to `fn`. Support for passing arguments on to the `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a lot of functions.
@returns The promise returned by calling `fn(...arguments)`.
*/
<Arguments extends unknown[], ReturnType>(
fn: (...arguments: Arguments) => PromiseLike<ReturnType> | ReturnType,
...arguments: Arguments
): Promise<ReturnType>;
}
}
/**
Run multiple promise-returning & async functions with limited concurrency.
@param concurrency - Concurrency limit. Minimum: `1`.
@returns A `limit` function.
*/
declare function pLimit(concurrency: number): pLimit.Limit;
export = pLimit;

View File

@@ -0,0 +1,356 @@
"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 ts = __importStar(require("typescript"));
const util_1 = require("../util");
function isEnumType(type) {
return (type.getFlags() & ts.TypeFlags.EnumLike) !== 0;
}
function isEnumMemberType(type) {
const symbol = type.getSymbol();
if (!symbol) {
return false;
}
return tsutils.isSymbolFlagSet(symbol, ts.SymbolFlags.EnumMember);
}
exports.default = (0, util_1.createRule)({
name: 'no-unnecessary-type-conversion',
meta: {
type: 'suggestion',
docs: {
description: 'Disallow conversion idioms when they do not change the type or value of the expression',
recommended: 'strict',
requiresTypeChecking: true,
},
hasSuggestions: true,
messages: {
suggestRemove: 'Remove the type conversion.',
suggestSatisfies: 'Instead, assert that the value satisfies the {{type}} type.',
unnecessaryTypeConversion: '{{violation}} does not change the type or value of the {{type}}.',
},
schema: [],
},
defaultOptions: [],
create(context) {
function doesUnderlyingTypeMatchFlag(type, typeFlag) {
return tsutils
.unionConstituents(type)
.every(t => (0, util_1.isTypeFlagSet)(t, typeFlag));
}
const services = (0, util_1.getParserServices)(context);
function handleUnaryOperator(node, typeFlag, typeString, violation, isDoubleOperator) {
const outerNode = isDoubleOperator ? node.parent : node;
const type = services.getTypeAtLocation(node.argument);
if (doesUnderlyingTypeMatchFlag(type, typeFlag)) {
const wrappingFixerParams = {
node: outerNode,
innerNode: [node.argument],
sourceCode: context.sourceCode,
};
context.report({
loc: {
start: outerNode.loc.start,
end: {
column: node.loc.start.column + 1,
line: node.loc.start.line,
},
},
messageId: 'unnecessaryTypeConversion',
data: { type: typeString, violation },
suggest: [
{
messageId: 'suggestRemove',
fix: (0, util_1.getWrappingFixer)(wrappingFixerParams),
},
{
messageId: 'suggestSatisfies',
data: { type: typeString },
fix: (0, util_1.getWrappingFixer)({
...wrappingFixerParams,
wrap: expr => `${expr} satisfies ${typeString}`,
}),
},
],
});
}
}
return {
'AssignmentExpression[operator = "+="]'(node) {
if (node.right.type === utils_1.AST_NODE_TYPES.Literal &&
node.right.value === '' &&
doesUnderlyingTypeMatchFlag(services.getTypeAtLocation(node.left), ts.TypeFlags.StringLike)) {
const wrappingFixerParams = {
node,
innerNode: [node.left],
sourceCode: context.sourceCode,
};
context.report({
node,
messageId: 'unnecessaryTypeConversion',
data: {
type: 'string',
violation: "Concatenating a string with ''",
},
suggest: [
{
messageId: 'suggestRemove',
fix: node.parent.type === utils_1.AST_NODE_TYPES.ExpressionStatement
? (fixer) => [
fixer.removeRange([
node.parent.range[0],
node.parent.range[1],
]),
]
: (0, util_1.getWrappingFixer)(wrappingFixerParams),
},
{
messageId: 'suggestSatisfies',
data: { type: 'string' },
fix: (0, util_1.getWrappingFixer)({
...wrappingFixerParams,
wrap: expr => `${expr} satisfies string`,
}),
},
],
});
}
},
'BinaryExpression[operator = "+"]'(node) {
if (node.right.type === utils_1.AST_NODE_TYPES.Literal &&
node.right.value === '' &&
doesUnderlyingTypeMatchFlag(services.getTypeAtLocation(node.left), ts.TypeFlags.StringLike)) {
const wrappingFixerParams = {
node,
innerNode: [node.left],
sourceCode: context.sourceCode,
};
context.report({
loc: {
start: node.left.loc.end,
end: node.loc.end,
},
messageId: 'unnecessaryTypeConversion',
data: {
type: 'string',
violation: "Concatenating a string with ''",
},
suggest: [
{
messageId: 'suggestRemove',
fix: (0, util_1.getWrappingFixer)(wrappingFixerParams),
},
{
messageId: 'suggestSatisfies',
data: { type: 'string' },
fix: (0, util_1.getWrappingFixer)({
...wrappingFixerParams,
wrap: expr => `${expr} satisfies string`,
}),
},
],
});
}
else if (node.left.type === utils_1.AST_NODE_TYPES.Literal &&
node.left.value === '' &&
doesUnderlyingTypeMatchFlag(services.getTypeAtLocation(node.right), ts.TypeFlags.StringLike)) {
const wrappingFixerParams = {
node,
innerNode: [node.right],
sourceCode: context.sourceCode,
};
context.report({
loc: {
start: node.loc.start,
end: node.right.loc.start,
},
messageId: 'unnecessaryTypeConversion',
data: {
type: 'string',
violation: "Concatenating '' with a string",
},
suggest: [
{
messageId: 'suggestRemove',
fix: (0, util_1.getWrappingFixer)(wrappingFixerParams),
},
{
messageId: 'suggestSatisfies',
data: { type: 'string' },
fix: (0, util_1.getWrappingFixer)({
...wrappingFixerParams,
wrap: expr => `${expr} satisfies string`,
}),
},
],
});
}
},
CallExpression(node) {
const nodeCallee = node.callee;
const builtInTypeFlags = {
BigInt: ts.TypeFlags.BigIntLike,
Boolean: ts.TypeFlags.BooleanLike,
Number: ts.TypeFlags.NumberLike,
String: ts.TypeFlags.StringLike,
};
if (nodeCallee.type !== utils_1.AST_NODE_TYPES.Identifier ||
!(nodeCallee.name in builtInTypeFlags)) {
return;
}
const typeFlag = builtInTypeFlags[nodeCallee.name];
const scope = context.sourceCode.getScope(node);
const variable = utils_1.ASTUtils.findVariable(scope, nodeCallee.name);
if (!!variable?.defs.length ||
!doesUnderlyingTypeMatchFlag((0, util_1.getConstrainedTypeAtLocation)(services, node.arguments[0]), typeFlag)) {
return;
}
const wrappingFixerParams = {
node,
innerNode: [node.arguments[0]],
sourceCode: context.sourceCode,
};
const typeString = nodeCallee.name.toLowerCase();
context.report({
node: nodeCallee,
messageId: 'unnecessaryTypeConversion',
data: {
type: nodeCallee.name.toLowerCase(),
violation: `Passing a ${typeString} to ${nodeCallee.name}()`,
},
suggest: [
{
messageId: 'suggestRemove',
fix: (0, util_1.getWrappingFixer)(wrappingFixerParams),
},
{
messageId: 'suggestSatisfies',
data: { type: typeString },
fix: (0, util_1.getWrappingFixer)({
...wrappingFixerParams,
wrap: expr => `${expr} satisfies ${typeString}`,
}),
},
],
});
},
'CallExpression > MemberExpression.callee > Identifier[name = "toString"].property'(node) {
const memberExpr = node.parent;
const type = (0, util_1.getConstrainedTypeAtLocation)(services, memberExpr.object);
if (isEnumType(type) || isEnumMemberType(type)) {
return;
}
if (doesUnderlyingTypeMatchFlag(type, ts.TypeFlags.StringLike)) {
const wrappingFixerParams = {
node: memberExpr.parent,
innerNode: [memberExpr.object],
sourceCode: context.sourceCode,
};
context.report({
loc: {
start: memberExpr.property.loc.start,
end: memberExpr.parent.loc.end,
},
messageId: 'unnecessaryTypeConversion',
data: {
type: 'string',
violation: "Calling a string's .toString() method",
},
suggest: [
{
messageId: 'suggestRemove',
fix: (0, util_1.getWrappingFixer)(wrappingFixerParams),
},
{
messageId: 'suggestSatisfies',
data: { type: 'string' },
fix: (0, util_1.getWrappingFixer)({
...wrappingFixerParams,
wrap: expr => `${expr} satisfies string`,
}),
},
],
});
}
},
'UnaryExpression[operator = "!"] > UnaryExpression[operator = "!"]'(node) {
handleUnaryOperator(node, ts.TypeFlags.BooleanLike, 'boolean', 'Using !! on a boolean', true);
},
'UnaryExpression[operator = "+"]'(node) {
handleUnaryOperator(node, ts.TypeFlags.NumberLike, 'number', 'Using the unary + operator on a number', false);
},
'UnaryExpression[operator = "~"] > UnaryExpression[operator = "~"]'(node) {
const outerNode = node.parent;
const type = services.getTypeAtLocation(node.argument);
if (tsutils.unionConstituents(type).every(t => {
return ((0, util_1.isTypeFlagSet)(t, ts.TypeFlags.NumberLiteral) &&
Number.isInteger(t.value));
})) {
const wrappingFixerParams = {
node: outerNode,
innerNode: [node.argument],
sourceCode: context.sourceCode,
};
context.report({
loc: {
start: outerNode.loc.start,
end: {
column: node.loc.start.column + 1,
line: node.loc.start.line,
},
},
messageId: 'unnecessaryTypeConversion',
data: { type: 'number', violation: 'Using ~~ on an integer' },
suggest: [
{
messageId: 'suggestRemove',
fix: (0, util_1.getWrappingFixer)(wrappingFixerParams),
},
{
messageId: 'suggestSatisfies',
data: { type: 'number' },
fix: (0, util_1.getWrappingFixer)({
...wrappingFixerParams,
wrap: expr => `${expr} satisfies number`,
}),
},
],
});
}
},
};
},
});

View File

@@ -0,0 +1,70 @@
import fs from 'node:fs';
import { j as join, d as dirname } from './chunk-pathe.M-eThtNZ.js';
const packageCache = new Map();
function findNearestPackageData(basedir) {
const originalBasedir = basedir;
while (basedir) {
const cached = getCachedData(packageCache, basedir, originalBasedir);
if (cached) {
return cached;
}
const pkgPath = join(basedir, "package.json");
if (tryStatSync(pkgPath)?.isFile()) {
const pkgData = JSON.parse(stripBomTag(fs.readFileSync(pkgPath, "utf8")));
if (packageCache) {
setCacheData(packageCache, pkgData, basedir, originalBasedir);
}
return pkgData;
}
const nextBasedir = dirname(basedir);
if (nextBasedir === basedir) {
break;
}
basedir = nextBasedir;
}
return {};
}
function stripBomTag(content) {
if (content.charCodeAt(0) === 65279) {
return content.slice(1);
}
return content;
}
function tryStatSync(file) {
try {
// The "throwIfNoEntry" is a performance optimization for cases where the file does not exist
return fs.statSync(file, { throwIfNoEntry: false });
} catch {}
}
function getCachedData(cache, basedir, originalBasedir) {
const pkgData = cache.get(getFnpdCacheKey(basedir));
if (pkgData) {
traverseBetweenDirs(originalBasedir, basedir, (dir) => {
cache.set(getFnpdCacheKey(dir), pkgData);
});
return pkgData;
}
}
function setCacheData(cache, data, basedir, originalBasedir) {
cache.set(getFnpdCacheKey(basedir), data);
traverseBetweenDirs(originalBasedir, basedir, (dir) => {
cache.set(getFnpdCacheKey(dir), data);
});
}
function getFnpdCacheKey(basedir) {
return `fnpd_${basedir}`;
}
/**
* Traverse between `longerDir` (inclusive) and `shorterDir` (exclusive) and call `cb` for each dir.
* @param longerDir Longer dir path, e.g. `/User/foo/bar/baz`
* @param shorterDir Shorter dir path, e.g. `/User/foo`
*/
function traverseBetweenDirs(longerDir, shorterDir, cb) {
while (longerDir !== shorterDir) {
cb(longerDir);
longerDir = dirname(longerDir);
}
}
export { findNearestPackageData, getCachedData, setCacheData };

View File

@@ -0,0 +1,23 @@
'use strict';
const promisify = require('es6-promisify');
/** * @namespace */
const PromiseUtils = module.exports;
/**
* Wraps the client request method on an instance, making it return a promise in every case except when the fourth argument is explicitly set to false
* @param {Function} request The original request method
* @return {Function}
*/
PromiseUtils.wrapClientRequestMethod = function(request) {
const promisified = promisify(request);
return function(method, params, id, shouldCall) {
if(shouldCall === false) {
// this should return a raw request for use in batches
return request(method, params, id);
}
return promisified.apply(this, arguments);
};
};

View File

@@ -0,0 +1,56 @@
'use strict'
const { realImport, realRequire } = require('real-require')
module.exports = loadTransportStreamBuilder
/**
* Loads & returns a function to build transport streams
* @param {string} target
* @returns {Promise<function(object): Promise<import('node:stream').Writable>>}
* @throws {Error} In case the target module does not export a function
*/
async function loadTransportStreamBuilder (target) {
let fn
try {
const toLoad = target.startsWith('file://') ? target : 'file://' + target
if (toLoad.endsWith('.ts') || toLoad.endsWith('.cts')) {
// TODO: add support for the TSM modules loader ( https://github.com/lukeed/tsm ).
if (process[Symbol.for('ts-node.register.instance')]) {
realRequire('ts-node/register')
} else if (process.env && process.env.TS_NODE_DEV) {
realRequire('ts-node-dev')
}
// TODO: Support ES imports once tsc, tap & ts-node provide better compatibility guarantees.
fn = realRequire(decodeURIComponent(target))
} else {
fn = (await realImport(toLoad))
}
} catch (error) {
// See this PR for details: https://github.com/pinojs/thread-stream/pull/34
if ((error.code === 'ENOTDIR' || error.code === 'ERR_MODULE_NOT_FOUND')) {
fn = realRequire(target)
} else if (error.code === undefined || error.code === 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING') {
// When bundled with pkg, an undefined error is thrown when called with realImport
// When bundled with pkg and using node v20, an ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING error is thrown when called with realImport
// More info at: https://github.com/pinojs/thread-stream/issues/143
try {
fn = realRequire(decodeURIComponent(target))
} catch {
throw error
}
} else {
throw error
}
}
// Depending on how the default export is performed, and on how the code is
// transpiled, we may find cases of two nested "default" objects.
// See https://github.com/pinojs/pino/issues/1243#issuecomment-982774762
if (typeof fn === 'object') fn = fn.default
if (typeof fn === 'object') fn = fn.default
if (typeof fn !== 'function') throw Error('exported worker is not a function')
return fn
}

View File

@@ -0,0 +1,8 @@
'use strict'
const parse = require('./parse')
const valid = (version, options) => {
const v = parse(version, options)
return v ? v.version : null
}
module.exports = valid

View File

@@ -0,0 +1,5 @@
'use strict';
const emit = stream => stream.on('data', item => stream.emit(item.name, item.value));
module.exports = emit;

View File

@@ -0,0 +1,409 @@
'use strict'
const test = require('tape')
const split = require('./')
const callback = require('callback-stream')
const strcb = callback.bind(null, { decodeStrings: false })
const objcb = callback.bind(null, { objectMode: true })
test('split two lines on end', function (t) {
t.plan(2)
const input = split()
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['hello', 'world'])
}))
input.end('hello\nworld')
})
test('split two lines on two writes', function (t) {
t.plan(2)
const input = split()
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['hello', 'world'])
}))
input.write('hello')
input.write('\nworld')
input.end()
})
test('split four lines on three writes', function (t) {
t.plan(2)
const input = split()
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['hello', 'world', 'bye', 'world'])
}))
input.write('hello\nwor')
input.write('ld\nbye\nwo')
input.write('rld')
input.end()
})
test('accumulate multiple writes', function (t) {
t.plan(2)
const input = split()
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['helloworld'])
}))
input.write('hello')
input.write('world')
input.end()
})
test('split using a custom string matcher', function (t) {
t.plan(2)
const input = split('~')
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['hello', 'world'])
}))
input.end('hello~world')
})
test('split using a custom regexp matcher', function (t) {
t.plan(2)
const input = split(/~/)
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['hello', 'world'])
}))
input.end('hello~world')
})
test('support an option argument', function (t) {
t.plan(2)
const input = split({ highWaterMark: 2 })
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['hello', 'world'])
}))
input.end('hello\nworld')
})
test('support a mapper function', function (t) {
t.plan(2)
const a = { a: '42' }
const b = { b: '24' }
const input = split(JSON.parse)
input.pipe(objcb(function (err, list) {
t.error(err)
t.deepEqual(list, [a, b])
}))
input.write(JSON.stringify(a))
input.write('\n')
input.end(JSON.stringify(b))
})
test('split lines windows-style', function (t) {
t.plan(2)
const input = split()
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['hello', 'world'])
}))
input.end('hello\r\nworld')
})
test('splits a buffer', function (t) {
t.plan(2)
const input = split()
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['hello', 'world'])
}))
input.end(Buffer.from('hello\nworld'))
})
test('do not end on undefined', function (t) {
t.plan(2)
const input = split(function (line) { })
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, [])
}))
input.end(Buffer.from('hello\nworld'))
})
test('has destroy method', function (t) {
t.plan(1)
const input = split(function (line) { })
input.on('close', function () {
t.ok(true, 'close emitted')
t.end()
})
input.destroy()
})
test('support custom matcher and mapper', function (t) {
t.plan(4)
const a = { a: '42' }
const b = { b: '24' }
const input = split('~', JSON.parse)
t.equal(input.matcher, '~')
t.equal(typeof input.mapper, 'function')
input.pipe(objcb(function (err, list) {
t.notOk(err, 'no errors')
t.deepEqual(list, [a, b])
}))
input.write(JSON.stringify(a))
input.write('~')
input.end(JSON.stringify(b))
})
test('support custom matcher and options', function (t) {
t.plan(6)
const input = split('~', { highWaterMark: 1024 })
t.equal(input.matcher, '~')
t.equal(typeof input.mapper, 'function')
t.equal(input._readableState.highWaterMark, 1024)
t.equal(input._writableState.highWaterMark, 1024)
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['hello', 'world'])
}))
input.end('hello~world')
})
test('support mapper and options', function (t) {
t.plan(6)
const a = { a: '42' }
const b = { b: '24' }
const input = split(JSON.parse, { highWaterMark: 1024 })
t.ok(input.matcher instanceof RegExp, 'matcher is RegExp')
t.equal(typeof input.mapper, 'function')
t.equal(input._readableState.highWaterMark, 1024)
t.equal(input._writableState.highWaterMark, 1024)
input.pipe(objcb(function (err, list) {
t.error(err)
t.deepEqual(list, [a, b])
}))
input.write(JSON.stringify(a))
input.write('\n')
input.end(JSON.stringify(b))
})
test('split utf8 chars', function (t) {
t.plan(2)
const input = split()
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['烫烫烫', '锟斤拷'])
}))
const buf = Buffer.from('烫烫烫\r\n锟斤拷', 'utf8')
for (let i = 0; i < buf.length; ++i) {
input.write(buf.slice(i, i + 1))
}
input.end()
})
test('split utf8 chars 2by2', function (t) {
t.plan(2)
const input = split()
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['烫烫烫', '烫烫烫'])
}))
const str = '烫烫烫\r\n烫烫烫'
const buf = Buffer.from(str, 'utf8')
for (let i = 0; i < buf.length; i += 2) {
input.write(buf.slice(i, i + 2))
}
input.end()
})
test('split lines when the \n comes at the end of a chunk', function (t) {
t.plan(2)
const input = split()
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['hello', 'world'])
}))
input.write('hello\n')
input.end('world')
})
test('truncated utf-8 char', function (t) {
t.plan(2)
const input = split()
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['烫' + Buffer.from('e7', 'hex').toString()])
}))
const str = '烫烫'
const buf = Buffer.from(str, 'utf8')
input.write(buf.slice(0, 3))
input.end(buf.slice(3, 4))
})
test('maximum buffer limit', function (t) {
t.plan(1)
const input = split({ maxLength: 2 })
input.on('error', function (err) {
t.ok(err)
})
input.resume()
input.write('hey')
})
test('readable highWaterMark', function (t) {
const input = split()
t.equal(input._readableState.highWaterMark, 16)
t.end()
})
test('maxLength < chunk size', function (t) {
t.plan(2)
const input = split({ maxLength: 2 })
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['a', 'b'])
}))
input.end('a\nb')
})
test('maximum buffer limit w/skip', function (t) {
t.plan(2)
const input = split({ maxLength: 2, skipOverflow: true })
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['a', 'b', 'c'])
}))
input.write('a\n123')
input.write('456')
input.write('789\nb\nc')
input.end()
})
test("don't modify the options object", function (t) {
t.plan(2)
const options = {}
const input = split(options)
input.pipe(strcb(function (err, list) {
t.error(err)
t.same(options, {})
}))
input.end()
})
test('mapper throws flush', function (t) {
t.plan(1)
const error = new Error()
const input = split(function () {
throw error
})
input.on('error', (err, list) => {
t.same(err, error)
})
input.end('hello')
})
test('mapper throws on transform', function (t) {
t.plan(1)
const error = new Error()
const input = split(function (l) {
throw error
})
input.on('error', (err) => {
t.same(err, error)
})
input.write('a')
input.write('\n')
input.end('b')
})
test('supports Symbol.split', function (t) {
t.plan(2)
const input = split({
[Symbol.split] (str) {
return str.split('~')
}
})
input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['hello', 'world'])
}))
input.end('hello~world')
})

View File

@@ -0,0 +1,136 @@
"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 (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;
const util = __importStar(require("../core/util.cjs"));
const error = () => {
const Sizable = {
string: { unit: "karaktrojn", verb: "havi" },
file: { unit: "bajtojn", verb: "havi" },
array: { unit: "elementojn", verb: "havi" },
set: { unit: "elementojn", verb: "havi" },
};
function getSizing(origin) {
return Sizable[origin] ?? null;
}
const FormatDictionary = {
regex: "enigo",
email: "retadreso",
url: "URL",
emoji: "emoĝio",
uuid: "UUID",
uuidv4: "UUIDv4",
uuidv6: "UUIDv6",
nanoid: "nanoid",
guid: "GUID",
cuid: "cuid",
cuid2: "cuid2",
ulid: "ULID",
xid: "XID",
ksuid: "KSUID",
datetime: "ISO-datotempo",
date: "ISO-dato",
time: "ISO-tempo",
duration: "ISO-daŭro",
ipv4: "IPv4-adreso",
ipv6: "IPv6-adreso",
cidrv4: "IPv4-rango",
cidrv6: "IPv6-rango",
base64: "64-ume kodita karaktraro",
base64url: "URL-64-ume kodita karaktraro",
json_string: "JSON-karaktraro",
e164: "E.164-nombro",
jwt: "JWT",
template_literal: "enigo",
};
const TypeDictionary = {
nan: "NaN",
number: "nombro",
array: "tabelo",
null: "senvalora",
};
return (issue) => {
switch (issue.code) {
case "invalid_type": {
const expected = TypeDictionary[issue.expected] ?? issue.expected;
const receivedType = util.parsedType(issue.input);
const received = TypeDictionary[receivedType] ?? receivedType;
if (/^[A-Z]/.test(issue.expected)) {
return `Nevalida enigo: atendiĝis instanceof ${issue.expected}, riceviĝis ${received}`;
}
return `Nevalida enigo: atendiĝis ${expected}, riceviĝis ${received}`;
}
case "invalid_value":
if (issue.values.length === 1)
return `Nevalida enigo: atendiĝis ${util.stringifyPrimitive(issue.values[0])}`;
return `Nevalida opcio: atendiĝis unu el ${util.joinValues(issue.values, "|")}`;
case "too_big": {
const adj = issue.inclusive ? "<=" : "<";
const sizing = getSizing(issue.origin);
if (sizing)
return `Tro granda: atendiĝis ke ${issue.origin ?? "valoro"} havu ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementojn"}`;
return `Tro granda: atendiĝis ke ${issue.origin ?? "valoro"} havu ${adj}${issue.maximum.toString()}`;
}
case "too_small": {
const adj = issue.inclusive ? ">=" : ">";
const sizing = getSizing(issue.origin);
if (sizing) {
return `Tro malgranda: atendiĝis ke ${issue.origin} havu ${adj}${issue.minimum.toString()} ${sizing.unit}`;
}
return `Tro malgranda: atendiĝis ke ${issue.origin} estu ${adj}${issue.minimum.toString()}`;
}
case "invalid_format": {
const _issue = issue;
if (_issue.format === "starts_with")
return `Nevalida karaktraro: devas komenciĝi per "${_issue.prefix}"`;
if (_issue.format === "ends_with")
return `Nevalida karaktraro: devas finiĝi per "${_issue.suffix}"`;
if (_issue.format === "includes")
return `Nevalida karaktraro: devas inkluzivi "${_issue.includes}"`;
if (_issue.format === "regex")
return `Nevalida karaktraro: devas kongrui kun la modelo ${_issue.pattern}`;
return `Nevalida ${FormatDictionary[_issue.format] ?? issue.format}`;
}
case "not_multiple_of":
return `Nevalida nombro: devas esti oblo de ${issue.divisor}`;
case "unrecognized_keys":
return `Nekonata${issue.keys.length > 1 ? "j" : ""} ŝlosilo${issue.keys.length > 1 ? "j" : ""}: ${util.joinValues(issue.keys, ", ")}`;
case "invalid_key":
return `Nevalida ŝlosilo en ${issue.origin}`;
case "invalid_union":
return "Nevalida enigo";
case "invalid_element":
return `Nevalida valoro en ${issue.origin}`;
default:
return `Nevalida enigo`;
}
};
};
function default_1() {
return {
localeError: error(),
};
}
module.exports = exports.default;

View File

@@ -0,0 +1,150 @@
import { ContainerWithChildren } from './container.js'
import Node from './node.js'
declare namespace Declaration {
export interface DeclarationRaws extends Record<string, unknown> {
/**
* The space symbols before the node. It also stores `*`
* and `_` symbols before the declaration (IE hack).
*/
before?: string
/**
* The symbols between the property and value for declarations.
*/
between?: string
/**
* The content of the important statement, if it is not just `!important`.
*/
important?: string
/**
* Declaration value with comments.
*/
value?: {
raw: string
value: string
}
}
export interface DeclarationProps {
/** Whether the declaration has an `!important` annotation. */
important?: boolean
/** Name of the declaration. */
prop: string
/** Information used to generate byte-to-byte equal node string as it was in the origin input. */
raws?: DeclarationRaws
/** Value of the declaration. */
value: string
}
export { Declaration_ as default }
}
/**
* It represents a class that handles
* [CSS declarations](https://developer.mozilla.org/en-US/docs/Web/CSS/Syntax#css_declarations)
*
* ```js
* Once (root, { Declaration }) {
* const color = new Declaration({ prop: 'color', value: 'black' })
* root.append(color)
* }
* ```
*
* ```js
* const root = postcss.parse('a { color: black }')
* const decl = root.first?.first
*
* decl.type //=> 'decl'
* decl.toString() //=> ' color: black'
* ```
*/
declare class Declaration_ extends Node {
parent: ContainerWithChildren | undefined
raws: Declaration.DeclarationRaws
type: 'decl'
/**
* It represents a specificity of the declaration.
*
* If true, the CSS declaration will have an
* [important](https://developer.mozilla.org/en-US/docs/Web/CSS/important)
* specifier.
*
* ```js
* const root = postcss.parse('a { color: black !important; color: red }')
*
* root.first.first.important //=> true
* root.first.last.important //=> undefined
* ```
*/
get important(): boolean
set important(value: boolean)
/**
* The property name for a CSS declaration.
*
* ```js
* const root = postcss.parse('a { color: black }')
* const decl = root.first.first
*
* decl.prop //=> 'color'
* ```
*/
get prop(): string
set prop(value: string)
/**
* The property value for a CSS declaration.
*
* Any CSS comments inside the value string will be filtered out.
* CSS comments present in the source value will be available in
* the `raws` property.
*
* Assigning new `value` would ignore the comments in `raws`
* property while compiling node to string.
*
* ```js
* const root = postcss.parse('a { color: black }')
* const decl = root.first.first
*
* decl.value //=> 'black'
* ```
*/
get value(): string
set value(value: string)
/**
* It represents a getter that returns `true` if a declaration starts with
* `--` or `$`, which are used to declare variables in CSS and SASS/SCSS.
*
* ```js
* const root = postcss.parse(':root { --one: 1 }')
* const one = root.first.first
*
* one.variable //=> true
* ```
*
* ```js
* const root = postcss.parse('$one: 1')
* const one = root.first
*
* one.variable //=> true
* ```
*/
get variable(): boolean
constructor(defaults?: Declaration.DeclarationProps)
assign(overrides: Declaration.DeclarationProps | object): this
clone(overrides?: Partial<Declaration.DeclarationProps>): this
cloneAfter(overrides?: Partial<Declaration.DeclarationProps>): this
cloneBefore(overrides?: Partial<Declaration.DeclarationProps>): this
}
declare class Declaration extends Declaration_ {}
export = Declaration

View File

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

View File

@@ -0,0 +1,171 @@
export declare function mod(a: bigint, b: bigint): bigint;
/**
* Efficiently raise num to power and do modular division.
* Unsafe in some contexts: uses ladder, so can expose bigint bits.
* @example
* pow(2n, 6n, 11n) // 64n % 11n == 9n
*/
export declare function pow(num: bigint, power: bigint, modulo: bigint): bigint;
/** Does `x^(2^power)` mod p. `pow2(30, 4)` == `30^(2^4)` */
export declare function pow2(x: bigint, power: bigint, modulo: bigint): bigint;
/**
* Inverses number over modulo.
* Implemented using [Euclidean GCD](https://brilliant.org/wiki/extended-euclidean-algorithm/).
*/
export declare function invert(number: bigint, modulo: bigint): bigint;
/**
* Tonelli-Shanks square root search algorithm.
* 1. https://eprint.iacr.org/2012/685.pdf (page 12)
* 2. Square Roots from 1; 24, 51, 10 to Dan Shanks
* @param P field order
* @returns function that takes field Fp (created from P) and number n
*/
export declare function tonelliShanks(P: bigint): <T>(Fp: IField<T>, n: T) => T;
/**
* Square root for a finite field. Will try optimized versions first:
*
* 1. P ≡ 3 (mod 4)
* 2. P ≡ 5 (mod 8)
* 3. P ≡ 9 (mod 16)
* 4. Tonelli-Shanks algorithm
*
* Different algorithms can give different roots, it is up to user to decide which one they want.
* For example there is FpSqrtOdd/FpSqrtEven to choice root based on oddness (used for hash-to-curve).
*/
export declare function FpSqrt(P: bigint): <T>(Fp: IField<T>, n: T) => T;
export declare const isNegativeLE: (num: bigint, modulo: bigint) => boolean;
/** Field is not always over prime: for example, Fp2 has ORDER(q)=p^m. */
export interface IField<T> {
ORDER: bigint;
isLE: boolean;
BYTES: number;
BITS: number;
MASK: bigint;
ZERO: T;
ONE: T;
create: (num: T) => T;
isValid: (num: T) => boolean;
is0: (num: T) => boolean;
isValidNot0: (num: T) => boolean;
neg(num: T): T;
inv(num: T): T;
sqrt(num: T): T;
sqr(num: T): T;
eql(lhs: T, rhs: T): boolean;
add(lhs: T, rhs: T): T;
sub(lhs: T, rhs: T): T;
mul(lhs: T, rhs: T | bigint): T;
pow(lhs: T, power: bigint): T;
div(lhs: T, rhs: T | bigint): T;
addN(lhs: T, rhs: T): T;
subN(lhs: T, rhs: T): T;
mulN(lhs: T, rhs: T | bigint): T;
sqrN(num: T): T;
isOdd?(num: T): boolean;
allowedLengths?: number[];
invertBatch: (lst: T[]) => T[];
toBytes(num: T): Uint8Array;
fromBytes(bytes: Uint8Array, skipValidation?: boolean): T;
cmov(a: T, b: T, c: boolean): T;
}
export declare function validateField<T>(field: IField<T>): IField<T>;
/**
* Same as `pow` but for Fp: non-constant-time.
* Unsafe in some contexts: uses ladder, so can expose bigint bits.
*/
export declare function FpPow<T>(Fp: IField<T>, num: T, power: bigint): T;
/**
* Efficiently invert an array of Field elements.
* Exception-free. Will return `undefined` for 0 elements.
* @param passZero map 0 to 0 (instead of undefined)
*/
export declare function FpInvertBatch<T>(Fp: IField<T>, nums: T[], passZero?: boolean): T[];
export declare function FpDiv<T>(Fp: IField<T>, lhs: T, rhs: T | bigint): T;
/**
* Legendre symbol.
* Legendre constant is used to calculate Legendre symbol (a | p)
* which denotes the value of a^((p-1)/2) (mod p).
*
* * (a | p) ≡ 1 if a is a square (mod p), quadratic residue
* * (a | p) ≡ -1 if a is not a square (mod p), quadratic non residue
* * (a | p) ≡ 0 if a ≡ 0 (mod p)
*/
export declare function FpLegendre<T>(Fp: IField<T>, n: T): -1 | 0 | 1;
export declare function FpIsSquare<T>(Fp: IField<T>, n: T): boolean;
export type NLength = {
nByteLength: number;
nBitLength: number;
};
export declare function nLength(n: bigint, nBitLength?: number): NLength;
type FpField = IField<bigint> & Required<Pick<IField<bigint>, 'isOdd'>>;
type SqrtFn = (n: bigint) => bigint;
type FieldOpts = Partial<{
sqrt: SqrtFn;
isLE: boolean;
BITS: number;
modFromBytes: boolean;
allowedLengths?: readonly number[];
}>;
/**
* Creates a finite field. Major performance optimizations:
* * 1. Denormalized operations like mulN instead of mul.
* * 2. Identical object shape: never add or remove keys.
* * 3. `Object.freeze`.
* Fragile: always run a benchmark on a change.
* Security note: operations don't check 'isValid' for all elements for performance reasons,
* it is caller responsibility to check this.
* This is low-level code, please make sure you know what you're doing.
*
* Note about field properties:
* * CHARACTERISTIC p = prime number, number of elements in main subgroup.
* * ORDER q = similar to cofactor in curves, may be composite `q = p^m`.
*
* @param ORDER field order, probably prime, or could be composite
* @param bitLen how many bits the field consumes
* @param isLE (default: false) if encoding / decoding should be in little-endian
* @param redef optional faster redefinitions of sqrt and other methods
*/
export declare function Field(ORDER: bigint, bitLenOrOpts?: number | FieldOpts, // TODO: use opts only in v2?
isLE?: boolean, opts?: {
sqrt?: SqrtFn;
}): Readonly<FpField>;
export declare function FpSqrtOdd<T>(Fp: IField<T>, elm: T): T;
export declare function FpSqrtEven<T>(Fp: IField<T>, elm: T): T;
/**
* "Constant-time" private key generation utility.
* Same as mapKeyToField, but accepts less bytes (40 instead of 48 for 32-byte field).
* Which makes it slightly more biased, less secure.
* @deprecated use `mapKeyToField` instead
*/
export declare function hashToPrivateScalar(hash: string | Uint8Array, groupOrder: bigint, isLE?: boolean): bigint;
/**
* Returns total number of bytes consumed by the field element.
* For example, 32 bytes for usual 256-bit weierstrass curve.
* @param fieldOrder number of field elements, usually CURVE.n
* @returns byte length of field
*/
export declare function getFieldBytesLength(fieldOrder: bigint): number;
/**
* Returns minimal amount of bytes that can be safely reduced
* by field order.
* Should be 2^-128 for 128-bit curve such as P256.
* @param fieldOrder number of field elements, usually CURVE.n
* @returns byte length of target hash
*/
export declare function getMinHashLength(fieldOrder: bigint): number;
/**
* "Constant-time" private key generation utility.
* Can take (n + n/2) or more bytes of uniform input e.g. from CSPRNG or KDF
* and convert them into private scalar, with the modulo bias being negligible.
* Needs at least 48 bytes of input for 32-byte private key.
* https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/
* FIPS 186-5, A.2 https://csrc.nist.gov/publications/detail/fips/186/5/final
* RFC 9380, https://www.rfc-editor.org/rfc/rfc9380#section-5
* @param hash hash output from SHA3 or a similar function
* @param groupOrder size of subgroup - (e.g. secp256k1.CURVE.n)
* @param isLE interpret hash bytes as LE num
* @returns valid private scalar
*/
export declare function mapHashToField(key: Uint8Array, fieldOrder: bigint, isLE?: boolean): Uint8Array;
export {};
//# sourceMappingURL=modular.d.ts.map

View File

@@ -0,0 +1,369 @@
/**
* A language server message
*/
export interface Message {
jsonrpc: string;
}
/**
* Request message
*/
export interface RequestMessage extends Message {
/**
* The request id.
*/
id: number | string | null;
/**
* The method to be invoked.
*/
method: string;
/**
* The method's params.
*/
params?: any[] | object;
}
/**
* Predefined error codes.
*/
export declare namespace ErrorCodes {
const ParseError: -32700;
const InvalidRequest: -32600;
const MethodNotFound: -32601;
const InvalidParams: -32602;
const InternalError: -32603;
/**
* This is the start range of JSON RPC reserved error codes.
* It doesn't denote a real error code. No application error codes should
* be defined between the start and end range. For backwards
* compatibility the `ServerNotInitialized` and the `UnknownErrorCode`
* are left in the range.
*
* @since 3.16.0
*/
const jsonrpcReservedErrorRangeStart: -32099;
/** @deprecated use jsonrpcReservedErrorRangeStart */
const serverErrorStart: -32099;
/**
* An error occurred when write a message to the transport layer.
*/
const MessageWriteError: -32099;
/**
* An error occurred when reading a message from the transport layer.
*/
const MessageReadError: -32098;
/**
* The connection got disposed or lost and all pending responses got
* rejected.
*/
const PendingResponseRejected: -32097;
/**
* The connection is inactive and a use of it failed.
*/
const ConnectionInactive: -32096;
/**
* Error code indicating that a server received a notification or
* request before the server has received the `initialize` request.
*/
const ServerNotInitialized: -32002;
const UnknownErrorCode: -32001;
/**
* This is the end range of JSON RPC reserved error codes.
* It doesn't denote a real error code.
*
* @since 3.16.0
*/
const jsonrpcReservedErrorRangeEnd: -32000;
/** @deprecated use jsonrpcReservedErrorRangeEnd */
const serverErrorEnd: -32000;
}
type integer = number;
export type ErrorCodes = integer;
export interface ResponseErrorLiteral<D = void> {
/**
* A number indicating the error type that occurred.
*/
code: number;
/**
* A string providing a short description of the error.
*/
message: string;
/**
* A Primitive or Structured value that contains additional
* information about the error. Can be omitted.
*/
data?: D;
}
/**
* An error object return in a response in case a request
* has failed.
*/
export declare class ResponseError<D = void> extends Error {
readonly code: number;
readonly data: D | undefined;
constructor(code: number, message: string, data?: D);
toJson(): ResponseErrorLiteral<D>;
}
/**
* A response message.
*/
export interface ResponseMessage extends Message {
/**
* The request id.
*/
id: number | string | null;
/**
* The result of a request. This member is REQUIRED on success.
* This member MUST NOT exist if there was an error invoking the method.
*/
result?: string | number | boolean | object | any[] | null;
/**
* The error object in case a request fails.
*/
error?: ResponseErrorLiteral<any>;
}
/**
* A LSP Log Entry.
*/
export type LSPMessageType = 'send-request' | 'receive-request' | 'send-response' | 'receive-response' | 'send-notification' | 'receive-notification';
export interface LSPLogMessage {
type: LSPMessageType;
message: RequestMessage | ResponseMessage | NotificationMessage;
timestamp: number;
}
export declare class ParameterStructures {
private readonly kind;
/**
* The parameter structure is automatically inferred on the number of parameters
* and the parameter type in case of a single param.
*/
static readonly auto: ParameterStructures;
/**
* Forces `byPosition` parameter structure. This is useful if you have a single
* parameter which has a literal type.
*/
static readonly byPosition: ParameterStructures;
/**
* Forces `byName` parameter structure. This is only useful when having a single
* parameter. The library will report errors if used with a different number of
* parameters.
*/
static readonly byName: ParameterStructures;
private constructor();
static is(value: any): value is ParameterStructures;
toString(): string;
}
/**
* An interface to type messages.
*/
export interface MessageSignature {
readonly method: string;
readonly numberOfParams: number;
readonly parameterStructures: ParameterStructures;
}
/**
* An abstract implementation of a MessageType.
*/
export declare abstract class AbstractMessageSignature implements MessageSignature {
readonly method: string;
readonly numberOfParams: number;
constructor(method: string, numberOfParams: number);
get parameterStructures(): ParameterStructures;
}
/**
* End marker interface for request and notification types.
*/
export interface _EM {
_$endMarker$_: number;
}
/**
* Classes to type request response pairs
*/
export declare class RequestType0<R, E> extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [R, E, _EM] | undefined;
constructor(method: string);
}
export declare class RequestType<P, R, E> extends AbstractMessageSignature {
private _parameterStructures;
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P, R, E, _EM] | undefined;
constructor(method: string, _parameterStructures?: ParameterStructures);
get parameterStructures(): ParameterStructures;
}
export declare class RequestType1<P1, R, E> extends AbstractMessageSignature {
private _parameterStructures;
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, R, E, _EM] | undefined;
constructor(method: string, _parameterStructures?: ParameterStructures);
get parameterStructures(): ParameterStructures;
}
export declare class RequestType2<P1, P2, R, E> extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, P2, R, E, _EM] | undefined;
constructor(method: string);
}
export declare class RequestType3<P1, P2, P3, R, E> extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, P2, P3, R, E, _EM] | undefined;
constructor(method: string);
}
export declare class RequestType4<P1, P2, P3, P4, R, E> extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, P2, P3, P4, R, E, _EM] | undefined;
constructor(method: string);
}
export declare class RequestType5<P1, P2, P3, P4, P5, R, E> extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, P2, P3, P4, P5, R, E, _EM] | undefined;
constructor(method: string);
}
export declare class RequestType6<P1, P2, P3, P4, P5, P6, R, E> extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, P2, P3, P4, P5, P6, R, E, _EM] | undefined;
constructor(method: string);
}
export declare class RequestType7<P1, P2, P3, P4, P5, P6, P7, R, E> extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, P2, P3, P4, P5, P6, P7, R, E, _EM] | undefined;
constructor(method: string);
}
export declare class RequestType8<P1, P2, P3, P4, P5, P6, P7, P8, R, E> extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, P2, P3, P4, P5, P6, P7, P8, R, E, _EM] | undefined;
constructor(method: string);
}
export declare class RequestType9<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E> extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E, _EM] | undefined;
constructor(method: string);
}
/**
* Notification Message
*/
export interface NotificationMessage extends Message {
/**
* The method to be invoked.
*/
method: string;
/**
* The notification's params.
*/
params?: any[] | object;
}
export declare class NotificationType<P> extends AbstractMessageSignature {
private _parameterStructures;
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P, _EM] | undefined;
constructor(method: string, _parameterStructures?: ParameterStructures);
get parameterStructures(): ParameterStructures;
}
export declare class NotificationType0 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [_EM] | undefined;
constructor(method: string);
}
export declare class NotificationType1<P1> extends AbstractMessageSignature {
private _parameterStructures;
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, _EM] | undefined;
constructor(method: string, _parameterStructures?: ParameterStructures);
get parameterStructures(): ParameterStructures;
}
export declare class NotificationType2<P1, P2> extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, P2, _EM] | undefined;
constructor(method: string);
}
export declare class NotificationType3<P1, P2, P3> extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, P2, P3, _EM] | undefined;
constructor(method: string);
}
export declare class NotificationType4<P1, P2, P3, P4> extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, P2, P3, P4, _EM] | undefined;
constructor(method: string);
}
export declare class NotificationType5<P1, P2, P3, P4, P5> extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, P2, P3, P4, P5, _EM] | undefined;
constructor(method: string);
}
export declare class NotificationType6<P1, P2, P3, P4, P5, P6> extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, P2, P3, P4, P5, P6, _EM] | undefined;
constructor(method: string);
}
export declare class NotificationType7<P1, P2, P3, P4, P5, P6, P7> extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, P2, P3, P4, P5, P6, P7, _EM] | undefined;
constructor(method: string);
}
export declare class NotificationType8<P1, P2, P3, P4, P5, P6, P7, P8> extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, P2, P3, P4, P5, P6, P7, P8, _EM] | undefined;
constructor(method: string);
}
export declare class NotificationType9<P1, P2, P3, P4, P5, P6, P7, P8, P9> extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
readonly _: [P1, P2, P3, P4, P5, P6, P7, P8, P9, _EM] | undefined;
constructor(method: string);
}
export declare namespace Message {
/**
* Tests if the given message is a request message
*/
function isRequest(message: Message | undefined): message is RequestMessage;
/**
* Tests if the given message is a notification message
*/
function isNotification(message: Message | undefined): message is NotificationMessage;
/**
* Tests if the given message is a response message
*/
function isResponse(message: Message | undefined): message is ResponseMessage;
}
export {};

View File

@@ -0,0 +1,5 @@
import type { TSESLint } from '@typescript-eslint/utils';
declare const _default: TSESLint.RuleModule<"preferFind" | "preferFindSuggestion", [], import("../../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
name: string;
};
export default _default;

View File

@@ -0,0 +1,12 @@
export type Options = [
{
lib?: 'always' | 'never';
path?: 'always' | 'never';
types?: 'always' | 'never' | 'prefer-import';
}
];
export type MessageIds = 'tripleSlashReference';
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"tripleSlashReference", Options, import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
name: string;
};
export default _default;

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.vesta = exports.pallas = void 0;
/**
* @deprecated
* @module
*/
const misc_ts_1 = require("./misc.js");
/** @deprecated */
exports.pallas = misc_ts_1.pallas;
/** @deprecated */
exports.vesta = misc_ts_1.vesta;
//# sourceMappingURL=pasta.js.map

View File

@@ -0,0 +1,109 @@
'use strict'
function tryStringify (o) {
try { return JSON.stringify(o) } catch(e) { return '"[Circular]"' }
}
module.exports = format
function format(f, args, opts) {
var ss = (opts && opts.stringify) || tryStringify
var offset = 1
if (typeof f === 'object' && f !== null) {
var len = args.length + offset
if (len === 1) return f
var objects = new Array(len)
objects[0] = ss(f)
for (var index = 1; index < len; index++) {
objects[index] = ss(args[index])
}
return objects.join(' ')
}
if (typeof f !== 'string') {
return f
}
var argLen = args.length
if (argLen === 0) return f
var str = ''
var a = 1 - offset
var lastPos = -1
var flen = (f && f.length) || 0
for (var i = 0; i < flen;) {
if (f.charCodeAt(i) === 37 && i + 1 < flen) {
lastPos = lastPos > -1 ? lastPos : 0
switch (f.charCodeAt(i + 1)) {
case 100: // 'd'
case 102: // 'f'
if (a >= argLen)
break
if (args[a] == null) break
if (lastPos < i)
str += f.slice(lastPos, i)
str += Number(args[a])
lastPos = i + 2
i++
break
case 105: // 'i'
if (a >= argLen)
break
if (args[a] == null) break
if (lastPos < i)
str += f.slice(lastPos, i)
str += Math.floor(Number(args[a]))
lastPos = i + 2
i++
break
case 79: // 'O'
case 111: // 'o'
case 106: // 'j'
if (a >= argLen)
break
if (args[a] === undefined) break
if (lastPos < i)
str += f.slice(lastPos, i)
var type = typeof args[a]
if (type === 'string') {
str += '\'' + args[a] + '\''
lastPos = i + 2
i++
break
}
if (type === 'function') {
str += args[a].name || '<anonymous>'
lastPos = i + 2
i++
break
}
str += ss(args[a])
lastPos = i + 2
i++
break
case 115: // 's'
if (a >= argLen)
break
if (lastPos < i)
str += f.slice(lastPos, i)
str += String(args[a])
lastPos = i + 2
i++
break
case 37: // '%'
if (lastPos < i)
str += f.slice(lastPos, i)
str += '%'
lastPos = i + 2
i++
a--
break
}
++a
}
++i
}
if (lastPos === -1)
return f
else if (lastPos < flen) {
str += f.slice(lastPos)
}
return str
}

View File

@@ -0,0 +1 @@
export { _lt as lt, _lte as lte, _lte as maximum, _gt as gt, _gte as gte, _gte as minimum, _positive as positive, _negative as negative, _nonpositive as nonpositive, _nonnegative as nonnegative, _multipleOf as multipleOf, _maxSize as maxSize, _minSize as minSize, _size as size, _maxLength as maxLength, _minLength as minLength, _length as length, _regex as regex, _lowercase as lowercase, _uppercase as uppercase, _includes as includes, _startsWith as startsWith, _endsWith as endsWith, _property as property, _mime as mime, _overwrite as overwrite, _normalize as normalize, _trim as trim, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, } from "../core/index.cjs";

View File

@@ -0,0 +1,85 @@
/**
* @fileoverview Rule to flag for-in loops without if statements inside
* @author Nicholas C. Zakas
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../types').Rule.RuleModule} */
module.exports = {
meta: {
type: "suggestion",
docs: {
description: "Require `for-in` loops to include an `if` statement",
recommended: false,
url: "https://eslint.org/docs/latest/rules/guard-for-in",
},
schema: [],
messages: {
wrap: "The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype.",
},
},
create(context) {
return {
ForInStatement(node) {
const body = node.body;
// empty statement
if (body.type === "EmptyStatement") {
return;
}
// if statement
if (body.type === "IfStatement") {
return;
}
// empty block
if (body.type === "BlockStatement" && body.body.length === 0) {
return;
}
// block with just if statement
if (
body.type === "BlockStatement" &&
body.body.length === 1 &&
body.body[0].type === "IfStatement"
) {
return;
}
// block that starts with if statement
if (
body.type === "BlockStatement" &&
body.body.length >= 1 &&
body.body[0].type === "IfStatement"
) {
const i = body.body[0];
// ... whose consequent is a continue
if (i.consequent.type === "ContinueStatement") {
return;
}
// ... whose consequent is a block that contains only a continue
if (
i.consequent.type === "BlockStatement" &&
i.consequent.body.length === 1 &&
i.consequent.body[0].type === "ContinueStatement"
) {
return;
}
}
context.report({ node, messageId: "wrap" });
},
};
},
};

View File

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

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.typeDeclaredInLib = typeDeclaredInLib;
function typeDeclaredInLib(declarationFiles, program) {
// Assertion: The type is not an error type.
// Intrinsic type (i.e. string, number, boolean, etc) - Treat it as if it's from lib.
if (declarationFiles.length === 0) {
return true;
}
return declarationFiles.some(declaration => program.isSourceFileDefaultLibrary(declaration));
}

View File

@@ -0,0 +1,76 @@
import * as z from "zod/v3";
export const filePath = __filename;
// z.object()
export const Test = z.object({
f1: z.number(),
});
export type Test = z.infer<typeof Test>;
export const instanceOfTest: Test = {
f1: 1,
};
// z.object().merge()
export const TestMerge = z
.object({
f2: z.string().optional(),
})
.merge(Test);
export type TestMerge = z.infer<typeof TestMerge>;
export const instanceOfTestMerge: TestMerge = {
f1: 1,
f2: "string",
};
// z.union()
export const TestUnion = z.union([
z.object({
f2: z.string().optional(),
}),
Test,
]);
export type TestUnion = z.infer<typeof TestUnion>;
export const instanceOfTestUnion: TestUnion = {
f1: 1,
f2: "string",
};
// z.object().partial()
export const TestPartial = Test.partial();
export type TestPartial = z.infer<typeof TestPartial>;
export const instanceOfTestPartial: TestPartial = {
f1: 1,
};
// z.object().pick()
export const TestPick = TestMerge.pick({ f1: true });
export type TestPick = z.infer<typeof TestPick>;
export const instanceOfTestPick: TestPick = {
f1: 1,
};
// z.object().omit()
export const TestOmit = TestMerge.omit({ f2: true });
export type TestOmit = z.infer<typeof TestOmit>;
export const instanceOfTestOmit: TestOmit = {
f1: 1,
};

View File

@@ -0,0 +1,3 @@
import type * as ts from 'typescript';
import type { ParseSettings } from '../parseSettings';
export declare function createProjectProgramError(parseSettings: ParseSettings, programsForProjects: readonly ts.Program[]): string[];