WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GlobalScope = void 0;
|
||||
const types_1 = require("@typescript-eslint/types");
|
||||
const assert_1 = require("../assert");
|
||||
const ImplicitGlobalVariableDefinition_1 = require("../definition/ImplicitGlobalVariableDefinition");
|
||||
const variable_1 = require("../variable");
|
||||
const ScopeBase_1 = require("./ScopeBase");
|
||||
const ScopeType_1 = require("./ScopeType");
|
||||
class GlobalScope extends ScopeBase_1.ScopeBase {
|
||||
// note this is accessed in used in the legacy eslint-scope tests, so it can't be true private
|
||||
implicit;
|
||||
constructor(scopeManager, block) {
|
||||
super(scopeManager, ScopeType_1.ScopeType.global, null, block, false);
|
||||
this.implicit = {
|
||||
leftToBeResolved: [],
|
||||
set: new Map(),
|
||||
variables: [],
|
||||
};
|
||||
}
|
||||
addVariables(names) {
|
||||
for (const name of names) {
|
||||
this.defineVariable(name, this.set, this.variables, null, null);
|
||||
this.implicit.set.delete(name);
|
||||
}
|
||||
const nameSet = new Set(names);
|
||||
for (const reference of this.through) {
|
||||
if (nameSet.has(reference.identifier.name)) {
|
||||
const variable = this.set.get(reference.identifier.name);
|
||||
(0, assert_1.assert)(variable, `Expected variable with name "${reference.identifier.name}" to be specified.`);
|
||||
reference.resolved = variable;
|
||||
variable.references.push(reference);
|
||||
}
|
||||
}
|
||||
this.through = this.through.filter(reference => !nameSet.has(reference.identifier.name));
|
||||
this.implicit.variables = this.implicit.variables.filter(variable => !nameSet.has(variable.name));
|
||||
this.implicit.leftToBeResolved = this.implicit.leftToBeResolved.filter(reference => !nameSet.has(reference.identifier.name));
|
||||
}
|
||||
close(scopeManager) {
|
||||
(0, assert_1.assert)(this.leftToResolve);
|
||||
for (const ref of this.leftToResolve) {
|
||||
if (ref.maybeImplicitGlobal && !this.set.has(ref.identifier.name)) {
|
||||
// create an implicit global variable from assignment expression
|
||||
const info = ref.maybeImplicitGlobal;
|
||||
const node = info.pattern;
|
||||
if (node.type === types_1.AST_NODE_TYPES.Identifier) {
|
||||
this.defineVariable(node.name, this.implicit.set, this.implicit.variables, node, new ImplicitGlobalVariableDefinition_1.ImplicitGlobalVariableDefinition(info.pattern, info.node));
|
||||
}
|
||||
}
|
||||
}
|
||||
this.implicit.leftToBeResolved = this.leftToResolve;
|
||||
super.close(scopeManager);
|
||||
this.implicit.leftToBeResolved = [...this.through];
|
||||
return null;
|
||||
}
|
||||
defineImplicitVariable(name, options) {
|
||||
this.defineVariable(new variable_1.ImplicitLibVariable(this, name, options), this.set, this.variables, null, null);
|
||||
}
|
||||
}
|
||||
exports.GlobalScope = GlobalScope;
|
||||
@@ -0,0 +1 @@
|
||||
export { _ as default } from "../esm/_using_ctx.js";
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"immed": true,
|
||||
"eqnull": true,
|
||||
"latedef": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"quotmark": "single",
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"strict": true,
|
||||
"trailing": true,
|
||||
|
||||
"node": true
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# `@typescript/typescript-linux-x64`
|
||||
|
||||
This package provides linux-x64 support for [typescript](https://www.npmjs.com/package/typescript).
|
||||
@@ -0,0 +1,118 @@
|
||||
const IS_RECORD_SYMBOL = "@@__IMMUTABLE_RECORD__@@";
|
||||
const IS_COLLECTION_SYMBOL = "@@__IMMUTABLE_ITERABLE__@@";
|
||||
function isImmutable(v) {
|
||||
return v && (v[IS_COLLECTION_SYMBOL] || v[IS_RECORD_SYMBOL]);
|
||||
}
|
||||
const OBJECT_PROTO = Object.getPrototypeOf({});
|
||||
function getUnserializableMessage(err) {
|
||||
if (err instanceof Error) {
|
||||
return `<unserializable>: ${err.message}`;
|
||||
}
|
||||
if (typeof err === "string") {
|
||||
return `<unserializable>: ${err}`;
|
||||
}
|
||||
return "<unserializable>";
|
||||
}
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
|
||||
function serializeValue(val, seen = new WeakMap()) {
|
||||
if (!val || typeof val === "string") {
|
||||
return val;
|
||||
}
|
||||
if (val instanceof Error && "toJSON" in val && typeof val.toJSON === "function") {
|
||||
const jsonValue = val.toJSON();
|
||||
if (jsonValue && jsonValue !== val && typeof jsonValue === "object") {
|
||||
if (typeof val.message === "string") {
|
||||
safe(() => jsonValue.message ??= normalizeErrorMessage(val.message));
|
||||
}
|
||||
if (typeof val.stack === "string") {
|
||||
safe(() => jsonValue.stack ??= val.stack);
|
||||
}
|
||||
if (typeof val.name === "string") {
|
||||
safe(() => jsonValue.name ??= val.name);
|
||||
}
|
||||
if (val.cause != null) {
|
||||
safe(() => jsonValue.cause ??= serializeValue(val.cause, seen));
|
||||
}
|
||||
}
|
||||
return serializeValue(jsonValue, seen);
|
||||
}
|
||||
if (typeof val === "function") {
|
||||
return `Function<${val.name || "anonymous"}>`;
|
||||
}
|
||||
if (typeof val === "symbol") {
|
||||
return val.toString();
|
||||
}
|
||||
if (typeof val !== "object") {
|
||||
return val;
|
||||
}
|
||||
if (typeof Buffer !== "undefined" && val instanceof Buffer) {
|
||||
return `<Buffer(${val.length}) ...>`;
|
||||
}
|
||||
if (typeof Uint8Array !== "undefined" && val instanceof Uint8Array) {
|
||||
return `<Uint8Array(${val.length}) ...>`;
|
||||
}
|
||||
// cannot serialize immutables as immutables
|
||||
if (isImmutable(val)) {
|
||||
return serializeValue(val.toJSON(), seen);
|
||||
}
|
||||
if (val instanceof Promise || val.constructor && val.constructor.prototype === "AsyncFunction") {
|
||||
return "Promise";
|
||||
}
|
||||
if (typeof Element !== "undefined" && val instanceof Element) {
|
||||
return val.tagName;
|
||||
}
|
||||
if (typeof val.toJSON === "function") {
|
||||
return serializeValue(val.toJSON(), seen);
|
||||
}
|
||||
if (seen.has(val)) {
|
||||
return seen.get(val);
|
||||
}
|
||||
if (Array.isArray(val)) {
|
||||
// eslint-disable-next-line unicorn/no-new-array -- we need to keep sparse arrays ([1,,3])
|
||||
const clone = new Array(val.length);
|
||||
seen.set(val, clone);
|
||||
val.forEach((e, i) => {
|
||||
try {
|
||||
clone[i] = serializeValue(e, seen);
|
||||
} catch (err) {
|
||||
clone[i] = getUnserializableMessage(err);
|
||||
}
|
||||
});
|
||||
return clone;
|
||||
} else {
|
||||
// Objects with `Error` constructors appear to cause problems during worker communication
|
||||
// using `MessagePort`, so the serialized error object is being recreated as plain object.
|
||||
const clone = Object.create(null);
|
||||
seen.set(val, clone);
|
||||
let obj = val;
|
||||
while (obj && obj !== OBJECT_PROTO) {
|
||||
Object.getOwnPropertyNames(obj).forEach((key) => {
|
||||
if (key in clone) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
clone[key] = serializeValue(val[key], seen);
|
||||
} catch (err) {
|
||||
// delete in case it has a setter from prototype that might throw
|
||||
delete clone[key];
|
||||
clone[key] = getUnserializableMessage(err);
|
||||
}
|
||||
});
|
||||
obj = Object.getPrototypeOf(obj);
|
||||
}
|
||||
if (val instanceof Error) {
|
||||
safe(() => clone.message = normalizeErrorMessage(val.message));
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
function safe(fn) {
|
||||
try {
|
||||
return fn();
|
||||
} catch {}
|
||||
}
|
||||
function normalizeErrorMessage(message) {
|
||||
return message.replace(/\(0\s?,\s?__vite_ssr_import_\d+__.(\w+)\)/g, "$1").replace(/__(vite_ssr_import|vi_import)_\d+__\./g, "").replace(/getByTestId('__vitest_\d+__')/g, "page");
|
||||
}
|
||||
|
||||
export { serializeValue };
|
||||
@@ -0,0 +1,2 @@
|
||||
import type { LibDefinition } from '../variable';
|
||||
export declare const dom: LibDefinition;
|
||||
@@ -0,0 +1,97 @@
|
||||
/*! *****************************************************************************
|
||||
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.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference lib="es2020.bigint" />
|
||||
|
||||
interface Atomics {
|
||||
/**
|
||||
* Adds a value to the value at the given position in the array, returning the original value.
|
||||
* Until this atomic operation completes, any other read or write operation against the array
|
||||
* will block.
|
||||
*/
|
||||
add(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number, value: bigint): bigint;
|
||||
|
||||
/**
|
||||
* Stores the bitwise AND of a value with the value at the given position in the array,
|
||||
* returning the original value. Until this atomic operation completes, any other read or
|
||||
* write operation against the array will block.
|
||||
*/
|
||||
and(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number, value: bigint): bigint;
|
||||
|
||||
/**
|
||||
* Replaces the value at the given position in the array if the original value equals the given
|
||||
* expected value, returning the original value. Until this atomic operation completes, any
|
||||
* other read or write operation against the array will block.
|
||||
*/
|
||||
compareExchange(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number, expectedValue: bigint, replacementValue: bigint): bigint;
|
||||
|
||||
/**
|
||||
* Replaces the value at the given position in the array, returning the original value. Until
|
||||
* this atomic operation completes, any other read or write operation against the array will
|
||||
* block.
|
||||
*/
|
||||
exchange(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number, value: bigint): bigint;
|
||||
|
||||
/**
|
||||
* Returns the value at the given position in the array. Until this atomic operation completes,
|
||||
* any other read or write operation against the array will block.
|
||||
*/
|
||||
load(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number): bigint;
|
||||
|
||||
/**
|
||||
* Stores the bitwise OR of a value with the value at the given position in the array,
|
||||
* returning the original value. Until this atomic operation completes, any other read or write
|
||||
* operation against the array will block.
|
||||
*/
|
||||
or(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number, value: bigint): bigint;
|
||||
|
||||
/**
|
||||
* Stores a value at the given position in the array, returning the new value. Until this
|
||||
* atomic operation completes, any other read or write operation against the array will block.
|
||||
*/
|
||||
store(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number, value: bigint): bigint;
|
||||
|
||||
/**
|
||||
* Subtracts a value from the value at the given position in the array, returning the original
|
||||
* value. Until this atomic operation completes, any other read or write operation against the
|
||||
* array will block.
|
||||
*/
|
||||
sub(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number, value: bigint): bigint;
|
||||
|
||||
/**
|
||||
* If the value at the given position in the array is equal to the provided value, the current
|
||||
* agent is put to sleep causing execution to suspend until the timeout expires (returning
|
||||
* `"timed-out"`) or until the agent is awoken (returning `"ok"`); otherwise, returns
|
||||
* `"not-equal"`.
|
||||
*/
|
||||
wait(typedArray: BigInt64Array<ArrayBufferLike>, index: number, value: bigint, timeout?: number): "ok" | "not-equal" | "timed-out";
|
||||
|
||||
/**
|
||||
* Wakes up sleeping agents that are waiting on the given index of the array, returning the
|
||||
* number of agents that were awoken.
|
||||
* @param typedArray A shared BigInt64Array.
|
||||
* @param index The position in the typedArray to wake up on.
|
||||
* @param count The number of sleeping agents to notify. Defaults to +Infinity.
|
||||
*/
|
||||
notify(typedArray: BigInt64Array<ArrayBufferLike>, index: number, count?: number): number;
|
||||
|
||||
/**
|
||||
* Stores the bitwise XOR of a value with the value at the given position in the array,
|
||||
* returning the original value. Until this atomic operation completes, any other read or write
|
||||
* operation against the array will block.
|
||||
*/
|
||||
xor(typedArray: BigInt64Array<ArrayBufferLike> | BigUint64Array<ArrayBufferLike>, index: number, value: bigint): bigint;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "siginfo",
|
||||
"version": "2.0.0",
|
||||
"description": "Utility module to print pretty messages on SIGINFO/SIGUSR1",
|
||||
"main": "index.js",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"standard": "^14.3.4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/emilbayes/siginfo.git"
|
||||
},
|
||||
"keywords": [
|
||||
"siginfo",
|
||||
"sigusr1",
|
||||
"ctrl",
|
||||
"t",
|
||||
"info",
|
||||
"progress",
|
||||
"inspect"
|
||||
],
|
||||
"author": "Emil Bay <github@tixz.dk>",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/emilbayes/siginfo/issues"
|
||||
},
|
||||
"homepage": "https://github.com/emilbayes/siginfo#readme"
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
declare module "node:stream/promises" {
|
||||
import { Abortable } from "node:events";
|
||||
import {
|
||||
FinishedOptions as _FinishedOptions,
|
||||
PipelineDestination,
|
||||
PipelineSource,
|
||||
PipelineTransform,
|
||||
} from "node:stream";
|
||||
import { ReadableStream, WritableStream } from "node:stream/web";
|
||||
interface FinishedOptions extends _FinishedOptions {
|
||||
/**
|
||||
* If true, removes the listeners registered by this function before the promise is fulfilled.
|
||||
* @default false
|
||||
*/
|
||||
cleanup?: boolean | undefined;
|
||||
}
|
||||
/**
|
||||
* ```js
|
||||
* import { finished } from 'node:stream/promises';
|
||||
* import { createReadStream } from 'node:fs';
|
||||
*
|
||||
* const rs = createReadStream('archive.tar');
|
||||
*
|
||||
* async function run() {
|
||||
* await finished(rs);
|
||||
* console.log('Stream is done reading.');
|
||||
* }
|
||||
*
|
||||
* run().catch(console.error);
|
||||
* rs.resume(); // Drain the stream.
|
||||
* ```
|
||||
*
|
||||
* The `finished` API also provides a [callback version](https://nodejs.org/docs/latest-v26.x/api/stream.html#streamfinishedstream-options-callback).
|
||||
*
|
||||
* `stream.finished()` leaves dangling event listeners (in particular
|
||||
* `'error'`, `'end'`, `'finish'` and `'close'`) after the returned promise is
|
||||
* resolved or rejected. The reason for this is so that unexpected `'error'`
|
||||
* events (due to incorrect stream implementations) do not cause unexpected
|
||||
* crashes. If this is unwanted behavior then `options.cleanup` should be set to
|
||||
* `true`:
|
||||
*
|
||||
* ```js
|
||||
* await finished(rs, { cleanup: true });
|
||||
* ```
|
||||
* @since v15.0.0
|
||||
* @returns Fulfills when the stream is no longer readable or writable.
|
||||
*/
|
||||
function finished(
|
||||
stream: NodeJS.ReadableStream | NodeJS.WritableStream | ReadableStream | WritableStream,
|
||||
options?: FinishedOptions,
|
||||
): Promise<void>;
|
||||
interface PipelineOptions extends Abortable {
|
||||
end?: boolean | undefined;
|
||||
}
|
||||
type PipelineResult<S extends PipelineDestination<any, any>> = S extends (...args: any[]) => PromiseLike<infer R>
|
||||
? Promise<R>
|
||||
: Promise<void>;
|
||||
/**
|
||||
* ```js
|
||||
* import { pipeline } from 'node:stream/promises';
|
||||
* import { createReadStream, createWriteStream } from 'node:fs';
|
||||
* import { createGzip } from 'node:zlib';
|
||||
*
|
||||
* await pipeline(
|
||||
* createReadStream('archive.tar'),
|
||||
* createGzip(),
|
||||
* createWriteStream('archive.tar.gz'),
|
||||
* );
|
||||
* console.log('Pipeline succeeded.');
|
||||
* ```
|
||||
*
|
||||
* To use an `AbortSignal`, pass it inside an options object, as the last argument.
|
||||
* When the signal is aborted, `destroy` will be called on the underlying pipeline,
|
||||
* with an `AbortError`.
|
||||
*
|
||||
* ```js
|
||||
* import { pipeline } from 'node:stream/promises';
|
||||
* import { createReadStream, createWriteStream } from 'node:fs';
|
||||
* import { createGzip } from 'node:zlib';
|
||||
*
|
||||
* const ac = new AbortController();
|
||||
* const { signal } = ac;
|
||||
* setImmediate(() => ac.abort());
|
||||
* try {
|
||||
* await pipeline(
|
||||
* createReadStream('archive.tar'),
|
||||
* createGzip(),
|
||||
* createWriteStream('archive.tar.gz'),
|
||||
* { signal },
|
||||
* );
|
||||
* } catch (err) {
|
||||
* console.error(err); // AbortError
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* The `pipeline` API also supports async generators:
|
||||
*
|
||||
* ```js
|
||||
* import { pipeline } from 'node:stream/promises';
|
||||
* import { createReadStream, createWriteStream } from 'node:fs';
|
||||
*
|
||||
* await pipeline(
|
||||
* createReadStream('lowercase.txt'),
|
||||
* async function* (source, { signal }) {
|
||||
* source.setEncoding('utf8'); // Work with strings rather than `Buffer`s.
|
||||
* for await (const chunk of source) {
|
||||
* yield await processChunk(chunk, { signal });
|
||||
* }
|
||||
* },
|
||||
* createWriteStream('uppercase.txt'),
|
||||
* );
|
||||
* console.log('Pipeline succeeded.');
|
||||
* ```
|
||||
*
|
||||
* Remember to handle the `signal` argument passed into the async generator.
|
||||
* Especially in the case where the async generator is the source for the
|
||||
* pipeline (i.e. first argument) or the pipeline will never complete.
|
||||
*
|
||||
* ```js
|
||||
* import { pipeline } from 'node:stream/promises';
|
||||
* import fs from 'node:fs';
|
||||
* await pipeline(
|
||||
* async function* ({ signal }) {
|
||||
* await someLongRunningfn({ signal });
|
||||
* yield 'asd';
|
||||
* },
|
||||
* fs.createWriteStream('uppercase.txt'),
|
||||
* );
|
||||
* console.log('Pipeline succeeded.');
|
||||
* ```
|
||||
*
|
||||
* The `pipeline` API provides [callback version](https://nodejs.org/docs/latest-v26.x/api/stream.html#streampipelinesource-transforms-destination-callback):
|
||||
* @since v15.0.0
|
||||
* @returns Fulfills when the pipeline is complete.
|
||||
*/
|
||||
function pipeline<A extends PipelineSource<any>, B extends PipelineDestination<A, any>>(
|
||||
source: A,
|
||||
destination: B,
|
||||
options?: PipelineOptions,
|
||||
): PipelineResult<B>;
|
||||
function pipeline<
|
||||
A extends PipelineSource<any>,
|
||||
T1 extends PipelineTransform<A, any>,
|
||||
B extends PipelineDestination<T1, any>,
|
||||
>(
|
||||
source: A,
|
||||
transform1: T1,
|
||||
destination: B,
|
||||
options?: PipelineOptions,
|
||||
): PipelineResult<B>;
|
||||
function pipeline<
|
||||
A extends PipelineSource<any>,
|
||||
T1 extends PipelineTransform<A, any>,
|
||||
T2 extends PipelineTransform<T1, any>,
|
||||
B extends PipelineDestination<T2, any>,
|
||||
>(
|
||||
source: A,
|
||||
transform1: T1,
|
||||
transform2: T2,
|
||||
destination: B,
|
||||
options?: PipelineOptions,
|
||||
): PipelineResult<B>;
|
||||
function pipeline<
|
||||
A extends PipelineSource<any>,
|
||||
T1 extends PipelineTransform<A, any>,
|
||||
T2 extends PipelineTransform<T1, any>,
|
||||
T3 extends PipelineTransform<T2, any>,
|
||||
B extends PipelineDestination<T3, any>,
|
||||
>(
|
||||
source: A,
|
||||
transform1: T1,
|
||||
transform2: T2,
|
||||
transform3: T3,
|
||||
destination: B,
|
||||
options?: PipelineOptions,
|
||||
): PipelineResult<B>;
|
||||
function pipeline<
|
||||
A extends PipelineSource<any>,
|
||||
T1 extends PipelineTransform<A, any>,
|
||||
T2 extends PipelineTransform<T1, any>,
|
||||
T3 extends PipelineTransform<T2, any>,
|
||||
T4 extends PipelineTransform<T3, any>,
|
||||
B extends PipelineDestination<T4, any>,
|
||||
>(
|
||||
source: A,
|
||||
transform1: T1,
|
||||
transform2: T2,
|
||||
transform3: T3,
|
||||
transform4: T4,
|
||||
destination: B,
|
||||
options?: PipelineOptions,
|
||||
): PipelineResult<B>;
|
||||
function pipeline(
|
||||
streams: readonly [PipelineSource<any>, ...PipelineTransform<any, any>[], PipelineDestination<any, any>],
|
||||
options?: PipelineOptions,
|
||||
): Promise<void>;
|
||||
function pipeline(
|
||||
...streams: [PipelineSource<any>, ...PipelineTransform<any, any>[], PipelineDestination<any, any>]
|
||||
): Promise<void>;
|
||||
function pipeline(
|
||||
...streams: [
|
||||
PipelineSource<any>,
|
||||
...PipelineTransform<any, any>[],
|
||||
PipelineDestination<any, any>,
|
||||
options: PipelineOptions,
|
||||
]
|
||||
): Promise<void>;
|
||||
}
|
||||
declare module "stream/promises" {
|
||||
export * from "node:stream/promises";
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "node-gyp-build",
|
||||
"version": "4.8.4",
|
||||
"description": "Build tool and bindings loader for node-gyp that supports prebuilds",
|
||||
"main": "index.js",
|
||||
"imports": {
|
||||
"fs": {
|
||||
"bare": "builtin:fs",
|
||||
"default": "fs"
|
||||
},
|
||||
"path": {
|
||||
"bare": "builtin:path",
|
||||
"default": "path"
|
||||
},
|
||||
"os": {
|
||||
"bare": "builtin:os",
|
||||
"default": "os"
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"array-shuffle": "^1.0.1",
|
||||
"standard": "^14.0.0",
|
||||
"tape": "^5.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && node test"
|
||||
},
|
||||
"bin": {
|
||||
"node-gyp-build": "./bin.js",
|
||||
"node-gyp-build-optional": "./optional.js",
|
||||
"node-gyp-build-test": "./build-test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/prebuild/node-gyp-build.git"
|
||||
},
|
||||
"author": "Mathias Buus (@mafintosh)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/prebuild/node-gyp-build/issues"
|
||||
},
|
||||
"homepage": "https://github.com/prebuild/node-gyp-build"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FunctionExpressionNameScope = void 0;
|
||||
const definition_1 = require("../definition");
|
||||
const ScopeBase_1 = require("./ScopeBase");
|
||||
const ScopeType_1 = require("./ScopeType");
|
||||
class FunctionExpressionNameScope extends ScopeBase_1.ScopeBase {
|
||||
functionExpressionScope;
|
||||
constructor(scopeManager, upperScope, block) {
|
||||
super(scopeManager, ScopeType_1.ScopeType.functionExpressionName, upperScope, block, false);
|
||||
if (block.id) {
|
||||
this.defineIdentifier(block.id, new definition_1.FunctionNameDefinition(block.id, block));
|
||||
}
|
||||
this.functionExpressionScope = true;
|
||||
}
|
||||
}
|
||||
exports.FunctionExpressionNameScope = FunctionExpressionNameScope;
|
||||
@@ -0,0 +1,78 @@
|
||||
// Code generated by Herebyfile.mjs generate:enums from internal/checker/types.go. DO NOT EDIT.
|
||||
export var TypeFlags;
|
||||
(function (TypeFlags) {
|
||||
TypeFlags[TypeFlags["None"] = 0] = "None";
|
||||
TypeFlags[TypeFlags["Any"] = 1] = "Any";
|
||||
TypeFlags[TypeFlags["Unknown"] = 2] = "Unknown";
|
||||
TypeFlags[TypeFlags["Undefined"] = 4] = "Undefined";
|
||||
TypeFlags[TypeFlags["Null"] = 8] = "Null";
|
||||
TypeFlags[TypeFlags["Void"] = 16] = "Void";
|
||||
TypeFlags[TypeFlags["String"] = 32] = "String";
|
||||
TypeFlags[TypeFlags["Number"] = 64] = "Number";
|
||||
TypeFlags[TypeFlags["BigInt"] = 128] = "BigInt";
|
||||
TypeFlags[TypeFlags["Boolean"] = 256] = "Boolean";
|
||||
TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol";
|
||||
TypeFlags[TypeFlags["StringLiteral"] = 1024] = "StringLiteral";
|
||||
TypeFlags[TypeFlags["NumberLiteral"] = 2048] = "NumberLiteral";
|
||||
TypeFlags[TypeFlags["BigIntLiteral"] = 4096] = "BigIntLiteral";
|
||||
TypeFlags[TypeFlags["BooleanLiteral"] = 8192] = "BooleanLiteral";
|
||||
TypeFlags[TypeFlags["UniqueESSymbol"] = 16384] = "UniqueESSymbol";
|
||||
TypeFlags[TypeFlags["EnumLiteral"] = 32768] = "EnumLiteral";
|
||||
TypeFlags[TypeFlags["Enum"] = 65536] = "Enum";
|
||||
TypeFlags[TypeFlags["NonPrimitive"] = 131072] = "NonPrimitive";
|
||||
TypeFlags[TypeFlags["Never"] = 262144] = "Never";
|
||||
TypeFlags[TypeFlags["TypeParameter"] = 524288] = "TypeParameter";
|
||||
TypeFlags[TypeFlags["Object"] = 1048576] = "Object";
|
||||
TypeFlags[TypeFlags["Index"] = 2097152] = "Index";
|
||||
TypeFlags[TypeFlags["TemplateLiteral"] = 4194304] = "TemplateLiteral";
|
||||
TypeFlags[TypeFlags["StringMapping"] = 8388608] = "StringMapping";
|
||||
TypeFlags[TypeFlags["Substitution"] = 16777216] = "Substitution";
|
||||
TypeFlags[TypeFlags["IndexedAccess"] = 33554432] = "IndexedAccess";
|
||||
TypeFlags[TypeFlags["Conditional"] = 67108864] = "Conditional";
|
||||
TypeFlags[TypeFlags["Union"] = 134217728] = "Union";
|
||||
TypeFlags[TypeFlags["Intersection"] = 268435456] = "Intersection";
|
||||
TypeFlags[TypeFlags["Reserved1"] = 536870912] = "Reserved1";
|
||||
TypeFlags[TypeFlags["Reserved2"] = 1073741824] = "Reserved2";
|
||||
TypeFlags[TypeFlags["Reserved3"] = -2147483648] = "Reserved3";
|
||||
TypeFlags[TypeFlags["AnyOrUnknown"] = 3] = "AnyOrUnknown";
|
||||
TypeFlags[TypeFlags["Nullable"] = 12] = "Nullable";
|
||||
TypeFlags[TypeFlags["Literal"] = 15360] = "Literal";
|
||||
TypeFlags[TypeFlags["Unit"] = 97292] = "Unit";
|
||||
TypeFlags[TypeFlags["Freshable"] = 80896] = "Freshable";
|
||||
TypeFlags[TypeFlags["StringOrNumberLiteral"] = 3072] = "StringOrNumberLiteral";
|
||||
TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 19456] = "StringOrNumberLiteralOrUnique";
|
||||
TypeFlags[TypeFlags["DefinitelyFalsy"] = 15388] = "DefinitelyFalsy";
|
||||
TypeFlags[TypeFlags["PossiblyFalsy"] = 15868] = "PossiblyFalsy";
|
||||
TypeFlags[TypeFlags["Intrinsic"] = 393983] = "Intrinsic";
|
||||
TypeFlags[TypeFlags["StringLike"] = 12583968] = "StringLike";
|
||||
TypeFlags[TypeFlags["NumberLike"] = 67648] = "NumberLike";
|
||||
TypeFlags[TypeFlags["BigIntLike"] = 4224] = "BigIntLike";
|
||||
TypeFlags[TypeFlags["BooleanLike"] = 8448] = "BooleanLike";
|
||||
TypeFlags[TypeFlags["EnumLike"] = 98304] = "EnumLike";
|
||||
TypeFlags[TypeFlags["ESSymbolLike"] = 16896] = "ESSymbolLike";
|
||||
TypeFlags[TypeFlags["VoidLike"] = 20] = "VoidLike";
|
||||
TypeFlags[TypeFlags["Primitive"] = 12713980] = "Primitive";
|
||||
TypeFlags[TypeFlags["DefinitelyNonNullable"] = 13893600] = "DefinitelyNonNullable";
|
||||
TypeFlags[TypeFlags["DisjointDomains"] = 12812284] = "DisjointDomains";
|
||||
TypeFlags[TypeFlags["UnionOrIntersection"] = 402653184] = "UnionOrIntersection";
|
||||
TypeFlags[TypeFlags["StructuredType"] = 403701760] = "StructuredType";
|
||||
TypeFlags[TypeFlags["TypeVariable"] = 34078720] = "TypeVariable";
|
||||
TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 117964800] = "InstantiableNonPrimitive";
|
||||
TypeFlags[TypeFlags["InstantiablePrimitive"] = 14680064] = "InstantiablePrimitive";
|
||||
TypeFlags[TypeFlags["Instantiable"] = 132644864] = "Instantiable";
|
||||
TypeFlags[TypeFlags["StructuredOrInstantiable"] = 536346624] = "StructuredOrInstantiable";
|
||||
TypeFlags[TypeFlags["ObjectFlagsType"] = 403963917] = "ObjectFlagsType";
|
||||
TypeFlags[TypeFlags["Simplifiable"] = 102760448] = "Simplifiable";
|
||||
TypeFlags[TypeFlags["Singleton"] = 394239] = "Singleton";
|
||||
TypeFlags[TypeFlags["Narrowable"] = 536575971] = "Narrowable";
|
||||
TypeFlags[TypeFlags["IncludesMask"] = 416808959] = "IncludesMask";
|
||||
TypeFlags[TypeFlags["IncludesMissingType"] = 524288] = "IncludesMissingType";
|
||||
TypeFlags[TypeFlags["IncludesNonWideningType"] = 2097152] = "IncludesNonWideningType";
|
||||
TypeFlags[TypeFlags["IncludesWildcard"] = 33554432] = "IncludesWildcard";
|
||||
TypeFlags[TypeFlags["IncludesEmptyObject"] = 67108864] = "IncludesEmptyObject";
|
||||
TypeFlags[TypeFlags["IncludesInstantiable"] = 16777216] = "IncludesInstantiable";
|
||||
TypeFlags[TypeFlags["IncludesConstrainedTypeVariable"] = 536870912] = "IncludesConstrainedTypeVariable";
|
||||
TypeFlags[TypeFlags["IncludesError"] = 1073741824] = "IncludesError";
|
||||
TypeFlags[TypeFlags["NotPrimitiveUnion"] = 286523411] = "NotPrimitiveUnion";
|
||||
})(TypeFlags || (TypeFlags = {}));
|
||||
//# sourceMappingURL=typeFlags.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
|
||||
export { analyze, type AnalyzeOptions } from './analyze';
|
||||
export * from './definition';
|
||||
export { PatternVisitor, type PatternVisitorCallback, type PatternVisitorOptions, } from './referencer/PatternVisitor';
|
||||
export { Reference } from './referencer/Reference';
|
||||
export { Visitor } from './referencer/Visitor';
|
||||
export * from './scope';
|
||||
export { ScopeManager } from './ScopeManager';
|
||||
export * from './variable';
|
||||
@@ -0,0 +1,4 @@
|
||||
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferTypeParameter", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
||||
name: string;
|
||||
};
|
||||
export default _default;
|
||||
@@ -0,0 +1,10 @@
|
||||
MIT License
|
||||
-----------
|
||||
|
||||
Copyright (C) 2018-2022 Guy Bedford
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1 @@
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).uuidStringify=t()}(this,(function(){"use strict";var e=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function t(t){return"string"==typeof t&&e.test(t)}for(var i=[],n=0;n<256;++n)i.push((n+256).toString(16).substr(1));return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,f=(i[e[n+0]]+i[e[n+1]]+i[e[n+2]]+i[e[n+3]]+"-"+i[e[n+4]]+i[e[n+5]]+"-"+i[e[n+6]]+i[e[n+7]]+"-"+i[e[n+8]]+i[e[n+9]]+"-"+i[e[n+10]]+i[e[n+11]]+i[e[n+12]]+i[e[n+13]]+i[e[n+14]]+i[e[n+15]]).toLowerCase();if(!t(f))throw TypeError("Stringified UUID is invalid");return f}}));
|
||||
@@ -0,0 +1,3 @@
|
||||
import Promise from './es6-promise';
|
||||
Promise.polyfill();
|
||||
export default Promise;
|
||||
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* HMAC: RFC2104 message authentication code.
|
||||
* @module
|
||||
*/
|
||||
import { abytes, aexists, ahash, clean, Hash, toBytes, type CHash, type Input } from './utils.ts';
|
||||
|
||||
export class HMAC<T extends Hash<T>> extends Hash<HMAC<T>> {
|
||||
oHash: T;
|
||||
iHash: T;
|
||||
blockLen: number;
|
||||
outputLen: number;
|
||||
private finished = false;
|
||||
private destroyed = false;
|
||||
|
||||
constructor(hash: CHash, _key: Input) {
|
||||
super();
|
||||
ahash(hash);
|
||||
const key = toBytes(_key);
|
||||
this.iHash = hash.create() as T;
|
||||
if (typeof this.iHash.update !== 'function')
|
||||
throw new Error('Expected instance of class which extends utils.Hash');
|
||||
this.blockLen = this.iHash.blockLen;
|
||||
this.outputLen = this.iHash.outputLen;
|
||||
const blockLen = this.blockLen;
|
||||
const pad = new Uint8Array(blockLen);
|
||||
// blockLen can be bigger than outputLen
|
||||
pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
|
||||
for (let i = 0; i < pad.length; i++) pad[i] ^= 0x36;
|
||||
this.iHash.update(pad);
|
||||
// By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone
|
||||
this.oHash = hash.create() as T;
|
||||
// Undo internal XOR && apply outer XOR
|
||||
for (let i = 0; i < pad.length; i++) pad[i] ^= 0x36 ^ 0x5c;
|
||||
this.oHash.update(pad);
|
||||
clean(pad);
|
||||
}
|
||||
update(buf: Input): this {
|
||||
aexists(this);
|
||||
this.iHash.update(buf);
|
||||
return this;
|
||||
}
|
||||
digestInto(out: Uint8Array): void {
|
||||
aexists(this);
|
||||
abytes(out, this.outputLen);
|
||||
this.finished = true;
|
||||
this.iHash.digestInto(out);
|
||||
this.oHash.update(out);
|
||||
this.oHash.digestInto(out);
|
||||
this.destroy();
|
||||
}
|
||||
digest(): Uint8Array {
|
||||
const out = new Uint8Array(this.oHash.outputLen);
|
||||
this.digestInto(out);
|
||||
return out;
|
||||
}
|
||||
_cloneInto(to?: HMAC<T>): HMAC<T> {
|
||||
// Create new instance without calling constructor since key already in state and we don't know it.
|
||||
to ||= Object.create(Object.getPrototypeOf(this), {});
|
||||
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
||||
to = to as this;
|
||||
to.finished = finished;
|
||||
to.destroyed = destroyed;
|
||||
to.blockLen = blockLen;
|
||||
to.outputLen = outputLen;
|
||||
to.oHash = oHash._cloneInto(to.oHash);
|
||||
to.iHash = iHash._cloneInto(to.iHash);
|
||||
return to;
|
||||
}
|
||||
clone(): HMAC<T> {
|
||||
return this._cloneInto();
|
||||
}
|
||||
destroy(): void {
|
||||
this.destroyed = true;
|
||||
this.oHash.destroy();
|
||||
this.iHash.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HMAC: RFC2104 message authentication code.
|
||||
* @param hash - function that would be used e.g. sha256
|
||||
* @param key - message key
|
||||
* @param message - message data
|
||||
* @example
|
||||
* import { hmac } from '@noble/hashes/hmac';
|
||||
* import { sha256 } from '@noble/hashes/sha2';
|
||||
* const mac1 = hmac(sha256, 'key', 'message');
|
||||
*/
|
||||
export const hmac: {
|
||||
(hash: CHash, key: Input, message: Input): Uint8Array;
|
||||
create(hash: CHash, key: Input): HMAC<any>;
|
||||
} = (hash: CHash, key: Input, message: Input): Uint8Array =>
|
||||
new HMAC<any>(hash, key).update(message).digest();
|
||||
hmac.create = (hash: CHash, key: Input) => new HMAC<any>(hash, key);
|
||||
@@ -0,0 +1,35 @@
|
||||
NODE_OPTS =
|
||||
TEST_OPTS =
|
||||
|
||||
love:
|
||||
@echo "Feel like makin' love."
|
||||
|
||||
test:
|
||||
@node $(NODE_OPTS) ./node_modules/.bin/_mocha -R dot $(TEST_OPTS)
|
||||
|
||||
spec:
|
||||
@node $(NODE_OPTS) ./node_modules/.bin/_mocha -R spec $(TEST_OPTS)
|
||||
|
||||
autotest:
|
||||
@node $(NODE_OPTS) ./node_modules/.bin/_mocha -R dot --watch $(TEST_OPTS)
|
||||
|
||||
autospec:
|
||||
@node $(NODE_OPTS) ./node_modules/.bin/_mocha -R spec --watch $(TEST_OPTS)
|
||||
|
||||
pack:
|
||||
@file=$$(npm pack); echo "$$file"; tar tf "$$file"
|
||||
|
||||
publish:
|
||||
npm publish
|
||||
|
||||
tag:
|
||||
git tag "v$$(node -e 'console.log(require("./package").version)')"
|
||||
|
||||
clean:
|
||||
rm -f *.tgz
|
||||
npm prune --production
|
||||
|
||||
.PHONY: love
|
||||
.PHONY: test spec autotest autospec
|
||||
.PHONY: pack publish tag
|
||||
.PHONY: clean
|
||||
@@ -0,0 +1,371 @@
|
||||
import { ft as __commonJSMin } from "./node.js";
|
||||
//#region ../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/parse.js
|
||||
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
||||
var openParentheses = "(".charCodeAt(0);
|
||||
var closeParentheses = ")".charCodeAt(0);
|
||||
var singleQuote = "'".charCodeAt(0);
|
||||
var doubleQuote = "\"".charCodeAt(0);
|
||||
var backslash = "\\".charCodeAt(0);
|
||||
var slash = "/".charCodeAt(0);
|
||||
var comma = ",".charCodeAt(0);
|
||||
var colon = ":".charCodeAt(0);
|
||||
var star = "*".charCodeAt(0);
|
||||
var uLower = "u".charCodeAt(0);
|
||||
var uUpper = "U".charCodeAt(0);
|
||||
var plus = "+".charCodeAt(0);
|
||||
var isUnicodeRange = /^[a-f0-9?-]+$/i;
|
||||
module.exports = function(input) {
|
||||
var tokens = [];
|
||||
var value = input;
|
||||
var next, quote, prev, token, escape, escapePos, whitespacePos, parenthesesOpenPos;
|
||||
var pos = 0;
|
||||
var code = value.charCodeAt(pos);
|
||||
var max = value.length;
|
||||
var stack = [{ nodes: tokens }];
|
||||
var balanced = 0;
|
||||
var parent;
|
||||
var name = "";
|
||||
var before = "";
|
||||
var after = "";
|
||||
while (pos < max) if (code <= 32) {
|
||||
next = pos;
|
||||
do {
|
||||
next += 1;
|
||||
code = value.charCodeAt(next);
|
||||
} while (code <= 32);
|
||||
token = value.slice(pos, next);
|
||||
prev = tokens[tokens.length - 1];
|
||||
if (code === closeParentheses && balanced) after = token;
|
||||
else if (prev && prev.type === "div") {
|
||||
prev.after = token;
|
||||
prev.sourceEndIndex += token.length;
|
||||
} else if (code === comma || code === colon || code === slash && value.charCodeAt(next + 1) !== star && (!parent || parent && parent.type === "function" && parent.value !== "calc")) before = token;
|
||||
else tokens.push({
|
||||
type: "space",
|
||||
sourceIndex: pos,
|
||||
sourceEndIndex: next,
|
||||
value: token
|
||||
});
|
||||
pos = next;
|
||||
} else if (code === singleQuote || code === doubleQuote) {
|
||||
next = pos;
|
||||
quote = code === singleQuote ? "'" : "\"";
|
||||
token = {
|
||||
type: "string",
|
||||
sourceIndex: pos,
|
||||
quote
|
||||
};
|
||||
do {
|
||||
escape = false;
|
||||
next = value.indexOf(quote, next + 1);
|
||||
if (~next) {
|
||||
escapePos = next;
|
||||
while (value.charCodeAt(escapePos - 1) === backslash) {
|
||||
escapePos -= 1;
|
||||
escape = !escape;
|
||||
}
|
||||
} else {
|
||||
value += quote;
|
||||
next = value.length - 1;
|
||||
token.unclosed = true;
|
||||
}
|
||||
} while (escape);
|
||||
token.value = value.slice(pos + 1, next);
|
||||
token.sourceEndIndex = token.unclosed ? next : next + 1;
|
||||
tokens.push(token);
|
||||
pos = next + 1;
|
||||
code = value.charCodeAt(pos);
|
||||
} else if (code === slash && value.charCodeAt(pos + 1) === star) {
|
||||
next = value.indexOf("*/", pos);
|
||||
token = {
|
||||
type: "comment",
|
||||
sourceIndex: pos,
|
||||
sourceEndIndex: next + 2
|
||||
};
|
||||
if (next === -1) {
|
||||
token.unclosed = true;
|
||||
next = value.length;
|
||||
token.sourceEndIndex = next;
|
||||
}
|
||||
token.value = value.slice(pos + 2, next);
|
||||
tokens.push(token);
|
||||
pos = next + 2;
|
||||
code = value.charCodeAt(pos);
|
||||
} else if ((code === slash || code === star) && parent && parent.type === "function" && parent.value === "calc") {
|
||||
token = value[pos];
|
||||
tokens.push({
|
||||
type: "word",
|
||||
sourceIndex: pos - before.length,
|
||||
sourceEndIndex: pos + token.length,
|
||||
value: token
|
||||
});
|
||||
pos += 1;
|
||||
code = value.charCodeAt(pos);
|
||||
} else if (code === slash || code === comma || code === colon) {
|
||||
token = value[pos];
|
||||
tokens.push({
|
||||
type: "div",
|
||||
sourceIndex: pos - before.length,
|
||||
sourceEndIndex: pos + token.length,
|
||||
value: token,
|
||||
before,
|
||||
after: ""
|
||||
});
|
||||
before = "";
|
||||
pos += 1;
|
||||
code = value.charCodeAt(pos);
|
||||
} else if (openParentheses === code) {
|
||||
next = pos;
|
||||
do {
|
||||
next += 1;
|
||||
code = value.charCodeAt(next);
|
||||
} while (code <= 32);
|
||||
parenthesesOpenPos = pos;
|
||||
token = {
|
||||
type: "function",
|
||||
sourceIndex: pos - name.length,
|
||||
value: name,
|
||||
before: value.slice(parenthesesOpenPos + 1, next)
|
||||
};
|
||||
pos = next;
|
||||
if (name === "url" && code !== singleQuote && code !== doubleQuote) {
|
||||
next -= 1;
|
||||
do {
|
||||
escape = false;
|
||||
next = value.indexOf(")", next + 1);
|
||||
if (~next) {
|
||||
escapePos = next;
|
||||
while (value.charCodeAt(escapePos - 1) === backslash) {
|
||||
escapePos -= 1;
|
||||
escape = !escape;
|
||||
}
|
||||
} else {
|
||||
value += ")";
|
||||
next = value.length - 1;
|
||||
token.unclosed = true;
|
||||
}
|
||||
} while (escape);
|
||||
whitespacePos = next;
|
||||
do {
|
||||
whitespacePos -= 1;
|
||||
code = value.charCodeAt(whitespacePos);
|
||||
} while (code <= 32);
|
||||
if (parenthesesOpenPos < whitespacePos) {
|
||||
if (pos !== whitespacePos + 1) token.nodes = [{
|
||||
type: "word",
|
||||
sourceIndex: pos,
|
||||
sourceEndIndex: whitespacePos + 1,
|
||||
value: value.slice(pos, whitespacePos + 1)
|
||||
}];
|
||||
else token.nodes = [];
|
||||
if (token.unclosed && whitespacePos + 1 !== next) {
|
||||
token.after = "";
|
||||
token.nodes.push({
|
||||
type: "space",
|
||||
sourceIndex: whitespacePos + 1,
|
||||
sourceEndIndex: next,
|
||||
value: value.slice(whitespacePos + 1, next)
|
||||
});
|
||||
} else {
|
||||
token.after = value.slice(whitespacePos + 1, next);
|
||||
token.sourceEndIndex = next;
|
||||
}
|
||||
} else {
|
||||
token.after = "";
|
||||
token.nodes = [];
|
||||
}
|
||||
pos = next + 1;
|
||||
token.sourceEndIndex = token.unclosed ? next : pos;
|
||||
code = value.charCodeAt(pos);
|
||||
tokens.push(token);
|
||||
} else {
|
||||
balanced += 1;
|
||||
token.after = "";
|
||||
token.sourceEndIndex = pos + 1;
|
||||
tokens.push(token);
|
||||
stack.push(token);
|
||||
tokens = token.nodes = [];
|
||||
parent = token;
|
||||
}
|
||||
name = "";
|
||||
} else if (closeParentheses === code && balanced) {
|
||||
pos += 1;
|
||||
code = value.charCodeAt(pos);
|
||||
parent.after = after;
|
||||
parent.sourceEndIndex += after.length;
|
||||
after = "";
|
||||
balanced -= 1;
|
||||
stack[stack.length - 1].sourceEndIndex = pos;
|
||||
stack.pop();
|
||||
parent = stack[balanced];
|
||||
tokens = parent.nodes;
|
||||
} else {
|
||||
next = pos;
|
||||
do {
|
||||
if (code === backslash) next += 1;
|
||||
next += 1;
|
||||
code = value.charCodeAt(next);
|
||||
} while (next < max && !(code <= 32 || code === singleQuote || code === doubleQuote || code === comma || code === colon || code === slash || code === openParentheses || code === star && parent && parent.type === "function" && parent.value === "calc" || code === slash && parent.type === "function" && parent.value === "calc" || code === closeParentheses && balanced));
|
||||
token = value.slice(pos, next);
|
||||
if (openParentheses === code) name = token;
|
||||
else if ((uLower === token.charCodeAt(0) || uUpper === token.charCodeAt(0)) && plus === token.charCodeAt(1) && isUnicodeRange.test(token.slice(2))) tokens.push({
|
||||
type: "unicode-range",
|
||||
sourceIndex: pos,
|
||||
sourceEndIndex: next,
|
||||
value: token
|
||||
});
|
||||
else tokens.push({
|
||||
type: "word",
|
||||
sourceIndex: pos,
|
||||
sourceEndIndex: next,
|
||||
value: token
|
||||
});
|
||||
pos = next;
|
||||
}
|
||||
for (pos = stack.length - 1; pos; pos -= 1) {
|
||||
stack[pos].unclosed = true;
|
||||
stack[pos].sourceEndIndex = value.length;
|
||||
}
|
||||
return stack[0].nodes;
|
||||
};
|
||||
}));
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/walk.js
|
||||
var require_walk = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
||||
module.exports = function walk(nodes, cb, bubble) {
|
||||
var i, max, node, result;
|
||||
for (i = 0, max = nodes.length; i < max; i += 1) {
|
||||
node = nodes[i];
|
||||
if (!bubble) result = cb(node, i, nodes);
|
||||
if (result !== false && node.type === "function" && Array.isArray(node.nodes)) walk(node.nodes, cb, bubble);
|
||||
if (bubble) cb(node, i, nodes);
|
||||
}
|
||||
};
|
||||
}));
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/stringify.js
|
||||
var require_stringify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
||||
function stringifyNode(node, custom) {
|
||||
var type = node.type;
|
||||
var value = node.value;
|
||||
var buf;
|
||||
var customResult;
|
||||
if (custom && (customResult = custom(node)) !== void 0) return customResult;
|
||||
else if (type === "word" || type === "space") return value;
|
||||
else if (type === "string") {
|
||||
buf = node.quote || "";
|
||||
return buf + value + (node.unclosed ? "" : buf);
|
||||
} else if (type === "comment") return "/*" + value + (node.unclosed ? "" : "*/");
|
||||
else if (type === "div") return (node.before || "") + value + (node.after || "");
|
||||
else if (Array.isArray(node.nodes)) {
|
||||
buf = stringify(node.nodes, custom);
|
||||
if (type !== "function") return buf;
|
||||
return value + "(" + (node.before || "") + buf + (node.after || "") + (node.unclosed ? "" : ")");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
function stringify(nodes, custom) {
|
||||
var result, i;
|
||||
if (Array.isArray(nodes)) {
|
||||
result = "";
|
||||
for (i = nodes.length - 1; ~i; i -= 1) result = stringifyNode(nodes[i], custom) + result;
|
||||
return result;
|
||||
}
|
||||
return stringifyNode(nodes, custom);
|
||||
}
|
||||
module.exports = stringify;
|
||||
}));
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/unit.js
|
||||
var require_unit = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
||||
var minus = "-".charCodeAt(0);
|
||||
var plus = "+".charCodeAt(0);
|
||||
var dot = ".".charCodeAt(0);
|
||||
var exp = "e".charCodeAt(0);
|
||||
var EXP = "E".charCodeAt(0);
|
||||
function likeNumber(value) {
|
||||
var code = value.charCodeAt(0);
|
||||
var nextCode;
|
||||
if (code === plus || code === minus) {
|
||||
nextCode = value.charCodeAt(1);
|
||||
if (nextCode >= 48 && nextCode <= 57) return true;
|
||||
var nextNextCode = value.charCodeAt(2);
|
||||
if (nextCode === dot && nextNextCode >= 48 && nextNextCode <= 57) return true;
|
||||
return false;
|
||||
}
|
||||
if (code === dot) {
|
||||
nextCode = value.charCodeAt(1);
|
||||
if (nextCode >= 48 && nextCode <= 57) return true;
|
||||
return false;
|
||||
}
|
||||
if (code >= 48 && code <= 57) return true;
|
||||
return false;
|
||||
}
|
||||
module.exports = function(value) {
|
||||
var pos = 0;
|
||||
var length = value.length;
|
||||
var code;
|
||||
var nextCode;
|
||||
var nextNextCode;
|
||||
if (length === 0 || !likeNumber(value)) return false;
|
||||
code = value.charCodeAt(pos);
|
||||
if (code === plus || code === minus) pos++;
|
||||
while (pos < length) {
|
||||
code = value.charCodeAt(pos);
|
||||
if (code < 48 || code > 57) break;
|
||||
pos += 1;
|
||||
}
|
||||
code = value.charCodeAt(pos);
|
||||
nextCode = value.charCodeAt(pos + 1);
|
||||
if (code === dot && nextCode >= 48 && nextCode <= 57) {
|
||||
pos += 2;
|
||||
while (pos < length) {
|
||||
code = value.charCodeAt(pos);
|
||||
if (code < 48 || code > 57) break;
|
||||
pos += 1;
|
||||
}
|
||||
}
|
||||
code = value.charCodeAt(pos);
|
||||
nextCode = value.charCodeAt(pos + 1);
|
||||
nextNextCode = value.charCodeAt(pos + 2);
|
||||
if ((code === exp || code === EXP) && (nextCode >= 48 && nextCode <= 57 || (nextCode === plus || nextCode === minus) && nextNextCode >= 48 && nextNextCode <= 57)) {
|
||||
pos += nextCode === plus || nextCode === minus ? 3 : 2;
|
||||
while (pos < length) {
|
||||
code = value.charCodeAt(pos);
|
||||
if (code < 48 || code > 57) break;
|
||||
pos += 1;
|
||||
}
|
||||
}
|
||||
return {
|
||||
number: value.slice(0, pos),
|
||||
unit: value.slice(pos)
|
||||
};
|
||||
};
|
||||
}));
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/index.js
|
||||
var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
||||
var parse = require_parse();
|
||||
var walk = require_walk();
|
||||
var stringify = require_stringify();
|
||||
function ValueParser(value) {
|
||||
if (this instanceof ValueParser) {
|
||||
this.nodes = parse(value);
|
||||
return this;
|
||||
}
|
||||
return new ValueParser(value);
|
||||
}
|
||||
ValueParser.prototype.toString = function() {
|
||||
return Array.isArray(this.nodes) ? stringify(this.nodes) : "";
|
||||
};
|
||||
ValueParser.prototype.walk = function(cb, bubble) {
|
||||
walk(this.nodes, cb, bubble);
|
||||
return this;
|
||||
};
|
||||
ValueParser.unit = require_unit();
|
||||
ValueParser.walk = walk;
|
||||
ValueParser.stringify = stringify;
|
||||
module.exports = ValueParser;
|
||||
}));
|
||||
//#endregion
|
||||
export { require_lib as t };
|
||||
@@ -0,0 +1,15 @@
|
||||
function _export_star(from, to) {
|
||||
Object.keys(from).forEach(function(k) {
|
||||
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
||||
Object.defineProperty(to, k, {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return from[k];
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return from;
|
||||
}
|
||||
export { _export_star as _ };
|
||||
@@ -0,0 +1,118 @@
|
||||
'use strict';
|
||||
|
||||
const http = require('http');
|
||||
const url = require('url');
|
||||
const utils = require('../utils');
|
||||
const Client = require('../client');
|
||||
const { version } = require('../../package.json');
|
||||
|
||||
/**
|
||||
* Constructor for a Jayson HTTP Client
|
||||
* @class ClientHttp
|
||||
* @constructor
|
||||
* @extends Client
|
||||
* @param {Object|String} [options] String interpreted as a URL
|
||||
* @param {String} [options.encoding="utf8"] Encoding to use
|
||||
* @return {ClientHttp}
|
||||
*/
|
||||
const ClientHttp = function(options) {
|
||||
// accept first parameter as a url string
|
||||
if(typeof(options) === 'string') {
|
||||
options = url.parse(options);
|
||||
}
|
||||
|
||||
if(!(this instanceof ClientHttp)) {
|
||||
return new ClientHttp(options);
|
||||
}
|
||||
Client.call(this, options);
|
||||
|
||||
const defaults = utils.merge(this.options, {
|
||||
encoding: 'utf8'
|
||||
});
|
||||
|
||||
this.options = utils.merge(defaults, options || {});
|
||||
};
|
||||
require('util').inherits(ClientHttp, Client);
|
||||
|
||||
module.exports = ClientHttp;
|
||||
|
||||
ClientHttp.prototype._request = function(request, callback) {
|
||||
const self = this;
|
||||
// copies options so object can be modified in this context
|
||||
const options = utils.merge({}, this.options);
|
||||
|
||||
utils.JSON.stringify(request, options, function(err, body) {
|
||||
if(err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
options.method = options.method || 'POST';
|
||||
|
||||
const headers = {
|
||||
'Content-Length': Buffer.byteLength(body, options.encoding),
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
Accept: 'application/json',
|
||||
'User-Agent': `jayson-${version}`,
|
||||
};
|
||||
|
||||
// let user override the headers
|
||||
options.headers = utils.merge(headers, options.headers || {});
|
||||
|
||||
const req = self._getRequestStream(options);
|
||||
|
||||
self.emit('http request', req);
|
||||
|
||||
req.on('response', function(res) {
|
||||
self.emit('http response', res, req);
|
||||
|
||||
res.setEncoding(options.encoding);
|
||||
|
||||
let data = '';
|
||||
res.on('data', function(chunk) { data += chunk; });
|
||||
|
||||
res.on('end', function() {
|
||||
|
||||
// assume we have an error
|
||||
if(res.statusCode < 200 || res.statusCode >= 300) {
|
||||
// assume the server gave the reason in the body
|
||||
const err = new Error(data);
|
||||
err.code = res.statusCode;
|
||||
callback(err);
|
||||
} else {
|
||||
// empty reply
|
||||
if(!data || typeof(data) !== 'string') {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
utils.JSON.parse(data, options, callback);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// abort on timeout
|
||||
req.on('timeout', function() {
|
||||
req.abort(); // req.abort causes "error" event
|
||||
});
|
||||
|
||||
// abort on error
|
||||
req.on('error', function(err) {
|
||||
self.emit('http error', err);
|
||||
callback(err);
|
||||
req.abort();
|
||||
});
|
||||
|
||||
req.end(body);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets a stream interface to a http server
|
||||
* @param {Object} options An options object
|
||||
* @return {require('http').ClientRequest}
|
||||
* @private
|
||||
*/
|
||||
ClientHttp.prototype._getRequestStream = function(options) {
|
||||
return http.request(options || {});
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
// TODO(Babel 8): Remove this file.
|
||||
|
||||
var runtime = require("../helpers/regeneratorRuntime")();
|
||||
module.exports = runtime;
|
||||
|
||||
// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
|
||||
try {
|
||||
regeneratorRuntime = runtime;
|
||||
} catch (accidentalStrictMode) {
|
||||
if (typeof globalThis === "object") {
|
||||
globalThis.regeneratorRuntime = runtime;
|
||||
} else {
|
||||
Function("r", "regeneratorRuntime = r")(runtime);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
'use strict'
|
||||
|
||||
const EE = require('node:events')
|
||||
const { pipeline, PassThrough } = require('node:stream')
|
||||
const pino = require('../pino.js')
|
||||
const build = require('pino-abstract-transport')
|
||||
const loadTransportStreamBuilder = require('./transport-stream')
|
||||
|
||||
// This file is not checked by the code coverage tool,
|
||||
// as it is not reliable.
|
||||
|
||||
/* istanbul ignore file */
|
||||
|
||||
/*
|
||||
* > Multiple targets & pipelines
|
||||
*
|
||||
*
|
||||
* ┌─────────────────────────────────────────────────┐ ┌─────┐
|
||||
* │ │ │ p │
|
||||
* │ │ │ i │
|
||||
* │ target │ │ n │
|
||||
* │ │ ────────────────────────────────┼────┤ o │
|
||||
* │ targets │ target │ │ . │
|
||||
* │ ────────────► │ ────────────────────────────────┼────┤ m │ source
|
||||
* │ │ target │ │ u │ │
|
||||
* │ │ ────────────────────────────────┼────┤ l │ │write
|
||||
* │ │ │ │ t │ ▼
|
||||
* │ │ pipeline ┌───────────────┐ │ │ i │ ┌────────┐
|
||||
* │ │ ──────────► │ PassThrough ├───┼────┤ s ├──────┤ │
|
||||
* │ │ └───────────────┘ │ │ t │ write│ Thread │
|
||||
* │ │ │ │ r │◄─────┤ Stream │
|
||||
* │ │ pipeline ┌───────────────┐ │ │ e │ │ │
|
||||
* │ │ ──────────► │ PassThrough ├───┼────┤ a │ └────────┘
|
||||
* │ └───────────────┘ │ │ m │
|
||||
* │ │ │ │
|
||||
* └─────────────────────────────────────────────────┘ └─────┘
|
||||
*
|
||||
*
|
||||
*
|
||||
* > One single pipeline or target
|
||||
*
|
||||
*
|
||||
* source
|
||||
* │
|
||||
* ┌────────────────────────────────────────────────┐ │write
|
||||
* │ │ ▼
|
||||
* │ │ ┌────────┐
|
||||
* │ targets │ target │ │ │
|
||||
* │ ────────────► │ ──────────────────────────────┤ │ │
|
||||
* │ │ │ │ │
|
||||
* │ ├──────┤ │
|
||||
* │ │ │ │
|
||||
* │ │ │ │
|
||||
* │ OR │ │ │
|
||||
* │ │ │ │
|
||||
* │ │ │ │
|
||||
* │ ┌──────────────┐ │ │ │
|
||||
* │ targets │ pipeline │ │ │ │ Thread │
|
||||
* │ ────────────► │ ────────────►│ PassThrough ├─┤ │ Stream │
|
||||
* │ │ │ │ │ │ │
|
||||
* │ └──────────────┘ │ │ │
|
||||
* │ │ │ │
|
||||
* │ OR │ write│ │
|
||||
* │ │◄─────┤ │
|
||||
* │ │ │ │
|
||||
* │ ┌──────────────┐ │ │ │
|
||||
* │ pipeline │ │ │ │ │
|
||||
* │ ──────────────►│ PassThrough ├────────────────┤ │ │
|
||||
* │ │ │ │ │ │
|
||||
* │ └──────────────┘ │ └────────┘
|
||||
* │ │
|
||||
* │ │
|
||||
* └────────────────────────────────────────────────┘
|
||||
*/
|
||||
|
||||
module.exports = async function ({ targets, pipelines, levels, dedupe }) {
|
||||
const targetStreams = []
|
||||
|
||||
// Process targets
|
||||
if (targets && targets.length) {
|
||||
targets = await Promise.all(targets.map(async (t) => {
|
||||
const fn = await loadTransportStreamBuilder(t.target)
|
||||
const stream = await fn(t.options)
|
||||
return {
|
||||
level: t.level,
|
||||
stream
|
||||
}
|
||||
}))
|
||||
|
||||
targetStreams.push(...targets)
|
||||
}
|
||||
|
||||
// Process pipelines
|
||||
if (pipelines && pipelines.length) {
|
||||
pipelines = await Promise.all(
|
||||
pipelines.map(async (p) => {
|
||||
let level
|
||||
const pipeDests = await Promise.all(
|
||||
p.map(async (t) => {
|
||||
// level assigned to pipeline is duplicated over all its targets, just store it
|
||||
level = t.level
|
||||
const fn = await loadTransportStreamBuilder(t.target)
|
||||
const stream = await fn(t.options)
|
||||
return stream
|
||||
}
|
||||
))
|
||||
|
||||
return {
|
||||
level,
|
||||
stream: createPipeline(pipeDests)
|
||||
}
|
||||
})
|
||||
)
|
||||
targetStreams.push(...pipelines)
|
||||
}
|
||||
|
||||
// Skip building the multistream step if either one single pipeline or target is defined and
|
||||
// return directly the stream instance back to TreadStream.
|
||||
// This is equivalent to define either:
|
||||
//
|
||||
// pino.transport({ target: ... })
|
||||
//
|
||||
// OR
|
||||
//
|
||||
// pino.transport({ pipeline: ... })
|
||||
if (targetStreams.length === 1) {
|
||||
return targetStreams[0].stream
|
||||
} else {
|
||||
return build(process, {
|
||||
parse: 'lines',
|
||||
metadata: true,
|
||||
close (err, cb) {
|
||||
let expected = 0
|
||||
for (const transport of targetStreams) {
|
||||
expected++
|
||||
transport.stream.on('close', closeCb)
|
||||
transport.stream.end()
|
||||
}
|
||||
|
||||
function closeCb () {
|
||||
if (--expected === 0) {
|
||||
cb(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// TODO: Why split2 was not used for pipelines?
|
||||
function process (stream) {
|
||||
const multi = pino.multistream(targetStreams, { levels, dedupe })
|
||||
// TODO manage backpressure
|
||||
stream.on('data', function (chunk) {
|
||||
const { lastTime, lastMsg, lastObj, lastLevel } = this
|
||||
multi.lastLevel = lastLevel
|
||||
multi.lastTime = lastTime
|
||||
multi.lastMsg = lastMsg
|
||||
multi.lastObj = lastObj
|
||||
|
||||
// TODO handle backpressure
|
||||
multi.write(chunk + '\n')
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a pipeline using the provided streams and return an instance of `PassThrough` stream
|
||||
* as a source for the pipeline.
|
||||
*
|
||||
* @param {(TransformStream|WritableStream)[]} streams An array of streams.
|
||||
* All intermediate streams in the array *MUST* be `Transform` streams and only the last one `Writable`.
|
||||
* @returns A `PassThrough` stream instance representing the source stream of the pipeline
|
||||
*/
|
||||
function createPipeline (streams) {
|
||||
const ee = new EE()
|
||||
const stream = new PassThrough({
|
||||
autoDestroy: true,
|
||||
destroy (_, cb) {
|
||||
ee.on('error', cb)
|
||||
ee.on('closed', cb)
|
||||
}
|
||||
})
|
||||
|
||||
pipeline(stream, ...streams, function (err) {
|
||||
if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
|
||||
ee.emit('error', err)
|
||||
return
|
||||
}
|
||||
|
||||
ee.emit('closed')
|
||||
})
|
||||
|
||||
return stream
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"commentDetected", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
||||
name: string;
|
||||
};
|
||||
export default _default;
|
||||
@@ -0,0 +1,46 @@
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert'
|
||||
import { readFile } from 'fs'
|
||||
import ThreadStream from '../index.js'
|
||||
import { join } from 'desm'
|
||||
import { pathToFileURL } from 'url'
|
||||
import { file } from './helper.js'
|
||||
|
||||
function basic (text, filename) {
|
||||
test(text, function (t, done) {
|
||||
const dest = file()
|
||||
const stream = new ThreadStream({
|
||||
filename,
|
||||
workerData: { dest },
|
||||
sync: true
|
||||
})
|
||||
|
||||
stream.on('finish', () => {
|
||||
readFile(dest, 'utf8', (err, data) => {
|
||||
assert.ifError(err)
|
||||
assert.strictEqual(data, 'hello world\nsomething else\n')
|
||||
})
|
||||
})
|
||||
|
||||
stream.on('close', () => {
|
||||
done()
|
||||
})
|
||||
|
||||
assert.ok(stream.write('hello world\n'))
|
||||
assert.ok(stream.write('something else\n'))
|
||||
|
||||
stream.end()
|
||||
})
|
||||
}
|
||||
|
||||
basic('esm with path', join(import.meta.url, 'to-file.mjs'))
|
||||
basic('esm with file URL', pathToFileURL(join(import.meta.url, 'to-file.mjs')).href)
|
||||
|
||||
basic('(ts -> es6) esm with path', join(import.meta.url, 'ts', 'to-file.es6.mjs'))
|
||||
basic('(ts -> es6) esm with file URL', pathToFileURL(join(import.meta.url, 'ts', 'to-file.es6.mjs')).href)
|
||||
|
||||
basic('(ts -> es2017) esm with path', join(import.meta.url, 'ts', 'to-file.es2017.mjs'))
|
||||
basic('(ts -> es2017) esm with file URL', pathToFileURL(join(import.meta.url, 'ts', 'to-file.es2017.mjs')).href)
|
||||
|
||||
basic('(ts -> esnext) esm with path', join(import.meta.url, 'ts', 'to-file.esnext.mjs'))
|
||||
basic('(ts -> esnext) esm with file URL', pathToFileURL(join(import.meta.url, 'ts', 'to-file.esnext.mjs')).href)
|
||||
@@ -0,0 +1,61 @@
|
||||
"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 });
|
||||
exports.convertComments = convertComments;
|
||||
const tsutils = __importStar(require("ts-api-utils"));
|
||||
const ts = __importStar(require("typescript"));
|
||||
const node_utils_1 = require("./node-utils");
|
||||
const ts_estree_1 = require("./ts-estree");
|
||||
/**
|
||||
* Convert all comments for the given AST.
|
||||
* @param ast the AST object
|
||||
* @returns the converted ESTreeComment
|
||||
* @private
|
||||
*/
|
||||
function convertComments(ast) {
|
||||
return Array.from(tsutils.iterateComments(ast), ({ end, kind, pos, value }) => {
|
||||
const type = kind === ts.SyntaxKind.SingleLineCommentTrivia
|
||||
? ts_estree_1.AST_TOKEN_TYPES.Line
|
||||
: ts_estree_1.AST_TOKEN_TYPES.Block;
|
||||
const range = [pos, end];
|
||||
const loc = (0, node_utils_1.getLocFor)(range, ast);
|
||||
return {
|
||||
type,
|
||||
loc,
|
||||
range,
|
||||
value,
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// Code generated by Herebyfile.mjs generate:enums from internal/core/compileroptions.go. DO NOT EDIT.
|
||||
export var NewLineKind;
|
||||
(function (NewLineKind) {
|
||||
NewLineKind[NewLineKind["None"] = 0] = "None";
|
||||
NewLineKind[NewLineKind["CRLF"] = 1] = "CRLF";
|
||||
NewLineKind[NewLineKind["LF"] = 2] = "LF";
|
||||
})(NewLineKind || (NewLineKind = {}));
|
||||
//# sourceMappingURL=newLineKind.js.map
|
||||
@@ -0,0 +1,23 @@
|
||||
import { type CHash, type KDFInput } from './utils.ts';
|
||||
export type Pbkdf2Opt = {
|
||||
c: number;
|
||||
dkLen?: number;
|
||||
asyncTick?: number;
|
||||
};
|
||||
/**
|
||||
* PBKDF2-HMAC: RFC 2898 key derivation function
|
||||
* @param hash - hash function that would be used e.g. sha256
|
||||
* @param password - password from which a derived key is generated
|
||||
* @param salt - cryptographic salt
|
||||
* @param opts - {c, dkLen} where c is work factor and dkLen is output message size
|
||||
* @example
|
||||
* const key = pbkdf2(sha256, 'password', 'salt', { dkLen: 32, c: Math.pow(2, 18) });
|
||||
*/
|
||||
export declare function pbkdf2(hash: CHash, password: KDFInput, salt: KDFInput, opts: Pbkdf2Opt): Uint8Array;
|
||||
/**
|
||||
* PBKDF2-HMAC: RFC 2898 key derivation function. Async version.
|
||||
* @example
|
||||
* await pbkdf2Async(sha256, 'password', 'salt', { dkLen: 32, c: 500_000 });
|
||||
*/
|
||||
export declare function pbkdf2Async(hash: CHash, password: KDFInput, salt: KDFInput, opts: Pbkdf2Opt): Promise<Uint8Array>;
|
||||
//# sourceMappingURL=pbkdf2.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/ast/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EACR,QAAQ,EACR,UAAU,EACb,MAAM,UAAU,CAAC;AAiBlB,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAEzD;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,QAAQ,GAAG,MAAM,CAKvE;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAIrE;AAED,wBAAgB,OAAO,CAAC,IAAI,SAAS,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,SAAS,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,SAAS,CAElI;AAED,wBAAgB,IAAI,CAAC,IAAI,SAAS,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,SAAS,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,KAAK,IAAI,IAAI,GAAG,IAAI,CAInH;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAmBnF"}
|
||||
@@ -0,0 +1,52 @@
|
||||
export = F;
|
||||
|
||||
/**
|
||||
* When called without any options, or with a zero length paths array, @pinojs/redact will return JSON.stringify or the serialize option, if set.
|
||||
* @param redactOptions
|
||||
* @param redactOptions.paths An array of strings describing the nested location of a key in an object.
|
||||
* @param redactOptions.censor This is the value which overwrites redacted properties.
|
||||
* @param redactOptions.remove The remove option, when set to true will cause keys to be removed from the serialized output.
|
||||
* @param redactOptions.serialize The serialize option may either be a function or a boolean. If a function is supplied, this will be used to serialize the redacted object.
|
||||
* @param redactOptions.strict The strict option, when set to true, will cause the redactor function to throw if instead of an object it finds a primitive.
|
||||
* @returns Redacted value from input
|
||||
*/
|
||||
declare function F(
|
||||
redactOptions: F.RedactOptionsNoSerialize
|
||||
): F.redactFnNoSerialize;
|
||||
declare function F(redactOptions?: F.RedactOptions): F.redactFn;
|
||||
|
||||
declare namespace F {
|
||||
/** Redacts input */
|
||||
type redactFn = <T>(input: T) => string | T;
|
||||
|
||||
/** Redacts input without serialization */
|
||||
type redactFnNoSerialize = redactFn & {
|
||||
/** Method that allowing the redacted keys to be restored with the original data. Supplied only when serialize option set to false. */
|
||||
restore<T>(input: T): T;
|
||||
};
|
||||
|
||||
interface RedactOptions {
|
||||
/** An array of strings describing the nested location of a key in an object. */
|
||||
paths?: string[] | undefined;
|
||||
|
||||
/** This is the value which overwrites redacted properties. */
|
||||
censor?: string | ((v: any) => any) | undefined;
|
||||
|
||||
/** The remove option, when set to true will cause keys to be removed from the serialized output. */
|
||||
remove?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* The serialize option may either be a function or a boolean. If a function is supplied, this will be used to serialize the redacted object.
|
||||
* The default serialize is the function JSON.stringify
|
||||
*/
|
||||
serialize?: boolean | ((v: any) => any) | undefined;
|
||||
|
||||
/** The strict option, when set to true, will cause the redactor function to throw if instead of an object it finds a primitive. */
|
||||
strict?: boolean | undefined;
|
||||
}
|
||||
|
||||
/** RedactOptions without serialization. Instead of the serialized object, the output of the redactor function will be the mutated object itself. */
|
||||
interface RedactOptionsNoSerialize extends RedactOptions {
|
||||
serialize: false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,377 @@
|
||||
"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 = __importStar(require("../util"));
|
||||
exports.default = util.createRule({
|
||||
name: 'strict-void-return',
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: 'Disallow passing a value-returning function in a position accepting a void function',
|
||||
requiresTypeChecking: true,
|
||||
},
|
||||
messages: {
|
||||
asyncFunc: 'Async function used in a context where a void function is expected.',
|
||||
nonVoidFunc: 'Value-returning function used in a context where a void function is expected.',
|
||||
nonVoidReturn: 'Value returned in a context where a void return is expected.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
allowReturnAny: {
|
||||
type: 'boolean',
|
||||
description: 'Whether to allow functions returning `any` to be used in place expecting a `void` function.',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
allowReturnAny: false,
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const parserServices = util.getParserServices(context);
|
||||
const checker = parserServices.program.getTypeChecker();
|
||||
return {
|
||||
ArrayExpression: (node) => {
|
||||
for (const elemNode of node.elements) {
|
||||
if (elemNode != null &&
|
||||
elemNode.type !== utils_1.AST_NODE_TYPES.SpreadElement) {
|
||||
checkExpressionNode(elemNode);
|
||||
}
|
||||
}
|
||||
},
|
||||
ArrowFunctionExpression: (node) => {
|
||||
if (node.body.type !== utils_1.AST_NODE_TYPES.BlockStatement) {
|
||||
checkExpressionNode(node.body);
|
||||
}
|
||||
},
|
||||
AssignmentExpression: (node) => {
|
||||
checkExpressionNode(node.right); // should ignore operators like `+=` or `-=` automatically
|
||||
},
|
||||
'CallExpression, NewExpression': checkFunctionCallNode,
|
||||
JSXAttribute: (node) => {
|
||||
if (node.value?.type === utils_1.AST_NODE_TYPES.JSXExpressionContainer &&
|
||||
node.value.expression.type !== utils_1.AST_NODE_TYPES.JSXEmptyExpression) {
|
||||
checkExpressionNode(node.value.expression);
|
||||
}
|
||||
},
|
||||
MethodDefinition: checkClassMethodNode,
|
||||
ObjectExpression: (node) => {
|
||||
for (const propNode of node.properties) {
|
||||
if (propNode.type !== utils_1.AST_NODE_TYPES.SpreadElement) {
|
||||
checkObjectPropertyNode(propNode);
|
||||
}
|
||||
}
|
||||
},
|
||||
PropertyDefinition: checkClassPropertyNode,
|
||||
ReturnStatement: (node) => {
|
||||
if (node.argument != null) {
|
||||
checkExpressionNode(node.argument);
|
||||
}
|
||||
},
|
||||
VariableDeclarator: (node) => {
|
||||
if (node.init != null) {
|
||||
checkExpressionNode(node.init);
|
||||
}
|
||||
},
|
||||
};
|
||||
function isVoidReturningFunctionType(type) {
|
||||
const returnTypes = tsutils
|
||||
.getCallSignaturesOfType(type)
|
||||
.flatMap(signature => tsutils.unionConstituents(signature.getReturnType()));
|
||||
return (returnTypes.length > 0 &&
|
||||
returnTypes.every(type => tsutils.isTypeFlagSet(type, ts.TypeFlags.Void)));
|
||||
}
|
||||
/**
|
||||
* Finds errors in any expression node.
|
||||
*
|
||||
* Compares the type of the node against the contextual (expected) type.
|
||||
*
|
||||
* @returns `true` if the expected type was void function.
|
||||
*/
|
||||
function checkExpressionNode(node) {
|
||||
const expectedType = parserServices.getContextualType(node);
|
||||
if (expectedType != null && isVoidReturningFunctionType(expectedType)) {
|
||||
reportIfNonVoidFunction(node);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Finds errors in function calls.
|
||||
*
|
||||
* When checking arguments, we also manually figure out the argument types
|
||||
* by iterating over all the function signatures.
|
||||
* Thanks to this, we can find arguments like `(() => void) | (() => any)`
|
||||
* and treat them as void too.
|
||||
* This is done to also support checking functions like `addEventListener`
|
||||
* which have overloads where one callback returns any.
|
||||
*
|
||||
* Implementation mostly based on no-misused-promises,
|
||||
* which does this to find `(() => void) | (() => NotThenable)`
|
||||
* and report them too.
|
||||
*/
|
||||
function checkFunctionCallNode(callNode) {
|
||||
if (callNode.arguments.length === 0) {
|
||||
return;
|
||||
}
|
||||
const callTsNode = parserServices.esTreeNodeToTSNodeMap.get(callNode);
|
||||
const funcType = checker.getTypeAtLocation(callTsNode.expression);
|
||||
const funcSignatures = tsutils
|
||||
.unionConstituents(funcType)
|
||||
.flatMap(type => ts.isCallExpression(callTsNode)
|
||||
? type.getCallSignatures()
|
||||
: type.getConstructSignatures());
|
||||
for (const [argIdx, argNode] of callNode.arguments.entries()) {
|
||||
if (argNode.type === utils_1.AST_NODE_TYPES.SpreadElement) {
|
||||
continue;
|
||||
}
|
||||
// Collect the types from all of the call signatures
|
||||
const argExpectedReturnTypes = funcSignatures
|
||||
.map(s => s.parameters[argIdx])
|
||||
.filter(Boolean)
|
||||
.map(param => checker.getTypeOfSymbolAtLocation(param, callTsNode.expression))
|
||||
.flatMap(paramType => tsutils.unionConstituents(paramType))
|
||||
.flatMap(paramType => paramType.getCallSignatures())
|
||||
.map(paramSignature => paramSignature.getReturnType());
|
||||
const hasSingleSignature = funcSignatures.length === 1;
|
||||
const allSignaturesReturnVoid = argExpectedReturnTypes.every(type => isVoid(type) ||
|
||||
// Treat as void even though it might be technically any.
|
||||
isNullishOrAny(type) ||
|
||||
// `getTypeOfSymbolAtLocation` returns unresolved type parameters
|
||||
// (e.g. `T`), even for overloads that match the call.
|
||||
//
|
||||
// Since we can't tell whether a generic overload currently matches,
|
||||
// we treat TypeParameters similar to void.
|
||||
tsutils.isTypeParameter(type));
|
||||
// Check against the contextual type first, but only when there is a
|
||||
// single signature or when all signatures return void, because
|
||||
// `getContextualType` resolves to the first overload's return type even
|
||||
// though there may be another one that matches the call.
|
||||
if ((hasSingleSignature || allSignaturesReturnVoid) &&
|
||||
checkExpressionNode(argNode)) {
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
// At least one return type is void
|
||||
argExpectedReturnTypes.some(isVoid) &&
|
||||
// The rest are nullish or any
|
||||
argExpectedReturnTypes.every(isNullishOrAny)) {
|
||||
// We treat this argument as void even though it might be technically any.
|
||||
reportIfNonVoidFunction(argNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
function isNullishOrAny(type) {
|
||||
return tsutils.isTypeFlagSet(type, ts.TypeFlags.VoidLike |
|
||||
ts.TypeFlags.Undefined |
|
||||
ts.TypeFlags.Null |
|
||||
ts.TypeFlags.Any |
|
||||
ts.TypeFlags.Never);
|
||||
}
|
||||
function isVoid(type) {
|
||||
return tsutils.isTypeFlagSet(type, ts.TypeFlags.Void);
|
||||
}
|
||||
/**
|
||||
* Finds errors in an object property.
|
||||
*
|
||||
* Object properties require different logic
|
||||
* when the property is a method shorthand.
|
||||
*/
|
||||
function checkObjectPropertyNode(propNode) {
|
||||
const valueNode = propNode.value;
|
||||
const propTsNode = parserServices.esTreeNodeToTSNodeMap.get(propNode);
|
||||
if (propTsNode.kind === ts.SyntaxKind.MethodDeclaration) {
|
||||
// Object property is a method shorthand.
|
||||
if (propTsNode.name.kind === ts.SyntaxKind.ComputedPropertyName) {
|
||||
// Don't check object methods with computed name.
|
||||
return;
|
||||
}
|
||||
const objType = parserServices.getContextualType(propNode.parent);
|
||||
if (objType == null) {
|
||||
// Expected object type is unknown.
|
||||
return;
|
||||
}
|
||||
const propSymbol = checker.getPropertyOfType(objType, propTsNode.name.text);
|
||||
if (propSymbol == null) {
|
||||
// Expected object type is known, but it doesn't have this method.
|
||||
return;
|
||||
}
|
||||
const propExpectedType = checker.getTypeOfSymbolAtLocation(propSymbol, propTsNode);
|
||||
if (isVoidReturningFunctionType(propExpectedType)) {
|
||||
reportIfNonVoidFunction(valueNode);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Object property is a regular property.
|
||||
checkExpressionNode(valueNode);
|
||||
}
|
||||
/**
|
||||
* Finds errors in a class property.
|
||||
*
|
||||
* In addition to the regular check against the contextual type,
|
||||
* we also check against the base class property (when the class extends another class)
|
||||
* and the implemented interfaces (when the class implements an interface).
|
||||
*/
|
||||
function checkClassPropertyNode(propNode) {
|
||||
if (propNode.value == null) {
|
||||
return;
|
||||
}
|
||||
// Check in comparison to the base types.
|
||||
for (const { baseMemberType } of util.getBaseTypesOfClassMember(parserServices, propNode)) {
|
||||
if (isVoidReturningFunctionType(baseMemberType)) {
|
||||
reportIfNonVoidFunction(propNode.value);
|
||||
return; // Report at most one error.
|
||||
}
|
||||
}
|
||||
// Check in comparison to the contextual type.
|
||||
checkExpressionNode(propNode.value);
|
||||
}
|
||||
/**
|
||||
* Finds errors in a class method.
|
||||
*
|
||||
* We check against the base class method (when the class extends another class)
|
||||
* and the implemented interfaces (when the class implements an interface).
|
||||
*/
|
||||
function checkClassMethodNode(methodNode) {
|
||||
if (methodNode.value.type === utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression) {
|
||||
return;
|
||||
}
|
||||
// Check in comparison to the base types.
|
||||
for (const { baseMemberType } of util.getBaseTypesOfClassMember(parserServices, methodNode)) {
|
||||
if (isVoidReturningFunctionType(baseMemberType)) {
|
||||
reportIfNonVoidFunction(methodNode.value);
|
||||
return; // Report at most one error.
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Reports an error if the provided node is not allowed in a void function context.
|
||||
*/
|
||||
function reportIfNonVoidFunction(funcNode) {
|
||||
const allowedReturnType = ts.TypeFlags.Void |
|
||||
ts.TypeFlags.Never |
|
||||
ts.TypeFlags.Undefined |
|
||||
(options.allowReturnAny ? ts.TypeFlags.Any : 0);
|
||||
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(funcNode);
|
||||
const actualType = checker.getApparentType(checker.getTypeAtLocation(tsNode));
|
||||
if (tsutils
|
||||
.getCallSignaturesOfType(actualType)
|
||||
.map(signature => signature.getReturnType())
|
||||
.flatMap(returnType => tsutils.unionConstituents(returnType))
|
||||
.every(type => tsutils.isTypeFlagSet(type, allowedReturnType))) {
|
||||
// The function is already void.
|
||||
return;
|
||||
}
|
||||
if (funcNode.type !== utils_1.AST_NODE_TYPES.ArrowFunctionExpression &&
|
||||
funcNode.type !== utils_1.AST_NODE_TYPES.FunctionExpression) {
|
||||
// The provided function is not a function literal.
|
||||
// Report a generic error.
|
||||
return context.report({
|
||||
node: funcNode,
|
||||
messageId: `nonVoidFunc`,
|
||||
});
|
||||
}
|
||||
// The provided function is a function literal.
|
||||
if (funcNode.generator) {
|
||||
// The provided function is a generator function.
|
||||
// Generator functions are not allowed.
|
||||
return context.report({
|
||||
loc: util.getFunctionHeadLoc(funcNode, sourceCode),
|
||||
messageId: `nonVoidFunc`,
|
||||
});
|
||||
}
|
||||
if (funcNode.async) {
|
||||
// The provided function is an async function.
|
||||
// Async functions aren't allowed.
|
||||
return context.report({
|
||||
loc: util.getFunctionHeadLoc(funcNode, sourceCode),
|
||||
messageId: `asyncFunc`,
|
||||
});
|
||||
}
|
||||
if (funcNode.body.type !== utils_1.AST_NODE_TYPES.BlockStatement) {
|
||||
// The provided function is an arrow function shorthand without braces.
|
||||
return context.report({
|
||||
node: funcNode.body,
|
||||
messageId: `nonVoidReturn`,
|
||||
});
|
||||
}
|
||||
// The function is a regular or arrow function with a block body.
|
||||
// Check return type annotation.
|
||||
if (funcNode.returnType != null) {
|
||||
// The provided function has an explicit return type annotation.
|
||||
const typeAnnotationNode = funcNode.returnType.typeAnnotation;
|
||||
if (typeAnnotationNode.type !== utils_1.AST_NODE_TYPES.TSVoidKeyword) {
|
||||
// The explicit return type is not `void`.
|
||||
return context.report({
|
||||
node: typeAnnotationNode,
|
||||
messageId: `nonVoidFunc`,
|
||||
});
|
||||
}
|
||||
}
|
||||
// Iterate over all function's return statements.
|
||||
for (const statement of util.walkStatements(funcNode.body.body)) {
|
||||
if (statement.type !== utils_1.AST_NODE_TYPES.ReturnStatement ||
|
||||
statement.argument == null) {
|
||||
// We only care about return statements with a value.
|
||||
continue;
|
||||
}
|
||||
const returnType = checker.getTypeAtLocation(parserServices.esTreeNodeToTSNodeMap.get(statement.argument));
|
||||
if (tsutils.isTypeFlagSet(returnType, allowedReturnType)) {
|
||||
// Only visit return statements with invalid type.
|
||||
continue;
|
||||
}
|
||||
// This return statement causes the non-void return type.
|
||||
const returnKeyword = util.nullThrows(sourceCode.getFirstToken(statement, {
|
||||
filter: token => token.value === 'return',
|
||||
}), util.NullThrowsReasons.MissingToken('return keyword', statement.type));
|
||||
context.report({
|
||||
node: returnKeyword,
|
||||
messageId: `nonVoidReturn`,
|
||||
});
|
||||
}
|
||||
// No invalid returns found. The function is allowed.
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,952 @@
|
||||
declare module 'http2' {
|
||||
import EventEmitter = require('events');
|
||||
import * as fs from 'fs';
|
||||
import * as net from 'net';
|
||||
import * as stream from 'stream';
|
||||
import * as tls from 'tls';
|
||||
import * as url from 'url';
|
||||
|
||||
import {
|
||||
IncomingHttpHeaders as Http1IncomingHttpHeaders,
|
||||
OutgoingHttpHeaders,
|
||||
IncomingMessage,
|
||||
ServerResponse,
|
||||
} from 'http';
|
||||
export { OutgoingHttpHeaders } from 'http';
|
||||
|
||||
export interface IncomingHttpStatusHeader {
|
||||
":status"?: number | undefined;
|
||||
}
|
||||
|
||||
export interface IncomingHttpHeaders extends Http1IncomingHttpHeaders {
|
||||
":path"?: string | undefined;
|
||||
":method"?: string | undefined;
|
||||
":authority"?: string | undefined;
|
||||
":scheme"?: string | undefined;
|
||||
}
|
||||
|
||||
// Http2Stream
|
||||
|
||||
export interface StreamPriorityOptions {
|
||||
exclusive?: boolean | undefined;
|
||||
parent?: number | undefined;
|
||||
weight?: number | undefined;
|
||||
silent?: boolean | undefined;
|
||||
}
|
||||
|
||||
export interface StreamState {
|
||||
localWindowSize?: number | undefined;
|
||||
state?: number | undefined;
|
||||
localClose?: number | undefined;
|
||||
remoteClose?: number | undefined;
|
||||
sumDependencyWeight?: number | undefined;
|
||||
weight?: number | undefined;
|
||||
}
|
||||
|
||||
export interface ServerStreamResponseOptions {
|
||||
endStream?: boolean | undefined;
|
||||
waitForTrailers?: boolean | undefined;
|
||||
}
|
||||
|
||||
export interface StatOptions {
|
||||
offset: number;
|
||||
length: number;
|
||||
}
|
||||
|
||||
export interface ServerStreamFileResponseOptions {
|
||||
statCheck?(stats: fs.Stats, headers: OutgoingHttpHeaders, statOptions: StatOptions): void | boolean;
|
||||
waitForTrailers?: boolean | undefined;
|
||||
offset?: number | undefined;
|
||||
length?: number | undefined;
|
||||
}
|
||||
|
||||
export interface ServerStreamFileResponseOptionsWithError extends ServerStreamFileResponseOptions {
|
||||
onError?(err: NodeJS.ErrnoException): void;
|
||||
}
|
||||
|
||||
export interface Http2Stream extends stream.Duplex {
|
||||
readonly aborted: boolean;
|
||||
readonly bufferSize: number;
|
||||
readonly closed: boolean;
|
||||
readonly destroyed: boolean;
|
||||
/**
|
||||
* Set the true if the END_STREAM flag was set in the request or response HEADERS frame received,
|
||||
* indicating that no additional data should be received and the readable side of the Http2Stream will be closed.
|
||||
*/
|
||||
readonly endAfterHeaders: boolean;
|
||||
readonly id?: number | undefined;
|
||||
readonly pending: boolean;
|
||||
readonly rstCode: number;
|
||||
readonly sentHeaders: OutgoingHttpHeaders;
|
||||
readonly sentInfoHeaders?: OutgoingHttpHeaders[] | undefined;
|
||||
readonly sentTrailers?: OutgoingHttpHeaders | undefined;
|
||||
readonly session: Http2Session;
|
||||
readonly state: StreamState;
|
||||
|
||||
close(code?: number, callback?: () => void): void;
|
||||
priority(options: StreamPriorityOptions): void;
|
||||
setTimeout(msecs: number, callback?: () => void): void;
|
||||
sendTrailers(headers: OutgoingHttpHeaders): void;
|
||||
|
||||
addListener(event: "aborted", listener: () => void): this;
|
||||
addListener(event: "close", listener: () => void): this;
|
||||
addListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||
addListener(event: "drain", listener: () => void): this;
|
||||
addListener(event: "end", listener: () => void): this;
|
||||
addListener(event: "error", listener: (err: Error) => void): this;
|
||||
addListener(event: "finish", listener: () => void): this;
|
||||
addListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
|
||||
addListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||
addListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||
addListener(event: "streamClosed", listener: (code: number) => void): this;
|
||||
addListener(event: "timeout", listener: () => void): this;
|
||||
addListener(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
addListener(event: "wantTrailers", listener: () => void): this;
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
emit(event: "aborted"): boolean;
|
||||
emit(event: "close"): boolean;
|
||||
emit(event: "data", chunk: Buffer | string): boolean;
|
||||
emit(event: "drain"): boolean;
|
||||
emit(event: "end"): boolean;
|
||||
emit(event: "error", err: Error): boolean;
|
||||
emit(event: "finish"): boolean;
|
||||
emit(event: "frameError", frameType: number, errorCode: number): boolean;
|
||||
emit(event: "pipe", src: stream.Readable): boolean;
|
||||
emit(event: "unpipe", src: stream.Readable): boolean;
|
||||
emit(event: "streamClosed", code: number): boolean;
|
||||
emit(event: "timeout"): boolean;
|
||||
emit(event: "trailers", trailers: IncomingHttpHeaders, flags: number): boolean;
|
||||
emit(event: "wantTrailers"): boolean;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
|
||||
on(event: "aborted", listener: () => void): this;
|
||||
on(event: "close", listener: () => void): this;
|
||||
on(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||
on(event: "drain", listener: () => void): this;
|
||||
on(event: "end", listener: () => void): this;
|
||||
on(event: "error", listener: (err: Error) => void): this;
|
||||
on(event: "finish", listener: () => void): this;
|
||||
on(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
|
||||
on(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||
on(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||
on(event: "streamClosed", listener: (code: number) => void): this;
|
||||
on(event: "timeout", listener: () => void): this;
|
||||
on(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
on(event: "wantTrailers", listener: () => void): this;
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
once(event: "aborted", listener: () => void): this;
|
||||
once(event: "close", listener: () => void): this;
|
||||
once(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||
once(event: "drain", listener: () => void): this;
|
||||
once(event: "end", listener: () => void): this;
|
||||
once(event: "error", listener: (err: Error) => void): this;
|
||||
once(event: "finish", listener: () => void): this;
|
||||
once(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
|
||||
once(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||
once(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||
once(event: "streamClosed", listener: (code: number) => void): this;
|
||||
once(event: "timeout", listener: () => void): this;
|
||||
once(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
once(event: "wantTrailers", listener: () => void): this;
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependListener(event: "aborted", listener: () => void): this;
|
||||
prependListener(event: "close", listener: () => void): this;
|
||||
prependListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||
prependListener(event: "drain", listener: () => void): this;
|
||||
prependListener(event: "end", listener: () => void): this;
|
||||
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependListener(event: "finish", listener: () => void): this;
|
||||
prependListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
|
||||
prependListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||
prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||
prependListener(event: "streamClosed", listener: (code: number) => void): this;
|
||||
prependListener(event: "timeout", listener: () => void): this;
|
||||
prependListener(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
prependListener(event: "wantTrailers", listener: () => void): this;
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependOnceListener(event: "aborted", listener: () => void): this;
|
||||
prependOnceListener(event: "close", listener: () => void): this;
|
||||
prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||
prependOnceListener(event: "drain", listener: () => void): this;
|
||||
prependOnceListener(event: "end", listener: () => void): this;
|
||||
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: "finish", listener: () => void): this;
|
||||
prependOnceListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
|
||||
prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||
prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||
prependOnceListener(event: "streamClosed", listener: (code: number) => void): this;
|
||||
prependOnceListener(event: "timeout", listener: () => void): this;
|
||||
prependOnceListener(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
prependOnceListener(event: "wantTrailers", listener: () => void): this;
|
||||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
|
||||
export interface ClientHttp2Stream extends Http2Stream {
|
||||
addListener(event: "continue", listener: () => {}): this;
|
||||
addListener(event: "headers", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
|
||||
addListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
addListener(event: "response", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
emit(event: "continue"): boolean;
|
||||
emit(event: "headers", headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number): boolean;
|
||||
emit(event: "push", headers: IncomingHttpHeaders, flags: number): boolean;
|
||||
emit(event: "response", headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number): boolean;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
|
||||
on(event: "continue", listener: () => {}): this;
|
||||
on(event: "headers", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
|
||||
on(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
on(event: "response", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
once(event: "continue", listener: () => {}): this;
|
||||
once(event: "headers", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
|
||||
once(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
once(event: "response", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependListener(event: "continue", listener: () => {}): this;
|
||||
prependListener(event: "headers", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
|
||||
prependListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
prependListener(event: "response", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependOnceListener(event: "continue", listener: () => {}): this;
|
||||
prependOnceListener(event: "headers", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
|
||||
prependOnceListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
prependOnceListener(event: "response", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
|
||||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
|
||||
export interface ServerHttp2Stream extends Http2Stream {
|
||||
readonly headersSent: boolean;
|
||||
readonly pushAllowed: boolean;
|
||||
additionalHeaders(headers: OutgoingHttpHeaders): void;
|
||||
pushStream(headers: OutgoingHttpHeaders, callback?: (err: Error | null, pushStream: ServerHttp2Stream, headers: OutgoingHttpHeaders) => void): void;
|
||||
pushStream(headers: OutgoingHttpHeaders, options?: StreamPriorityOptions, callback?: (err: Error | null, pushStream: ServerHttp2Stream, headers: OutgoingHttpHeaders) => void): void;
|
||||
respond(headers?: OutgoingHttpHeaders, options?: ServerStreamResponseOptions): void;
|
||||
respondWithFD(fd: number | fs.promises.FileHandle, headers?: OutgoingHttpHeaders, options?: ServerStreamFileResponseOptions): void;
|
||||
respondWithFile(path: string, headers?: OutgoingHttpHeaders, options?: ServerStreamFileResponseOptionsWithError): void;
|
||||
}
|
||||
|
||||
// Http2Session
|
||||
|
||||
export interface Settings {
|
||||
headerTableSize?: number | undefined;
|
||||
enablePush?: boolean | undefined;
|
||||
initialWindowSize?: number | undefined;
|
||||
maxFrameSize?: number | undefined;
|
||||
maxConcurrentStreams?: number | undefined;
|
||||
maxHeaderListSize?: number | undefined;
|
||||
enableConnectProtocol?: boolean | undefined;
|
||||
}
|
||||
|
||||
export interface ClientSessionRequestOptions {
|
||||
endStream?: boolean | undefined;
|
||||
exclusive?: boolean | undefined;
|
||||
parent?: number | undefined;
|
||||
weight?: number | undefined;
|
||||
waitForTrailers?: boolean | undefined;
|
||||
}
|
||||
|
||||
export interface SessionState {
|
||||
effectiveLocalWindowSize?: number | undefined;
|
||||
effectiveRecvDataLength?: number | undefined;
|
||||
nextStreamID?: number | undefined;
|
||||
localWindowSize?: number | undefined;
|
||||
lastProcStreamID?: number | undefined;
|
||||
remoteWindowSize?: number | undefined;
|
||||
outboundQueueSize?: number | undefined;
|
||||
deflateDynamicTableSize?: number | undefined;
|
||||
inflateDynamicTableSize?: number | undefined;
|
||||
}
|
||||
|
||||
export interface Http2Session extends EventEmitter {
|
||||
readonly alpnProtocol?: string | undefined;
|
||||
readonly closed: boolean;
|
||||
readonly connecting: boolean;
|
||||
readonly destroyed: boolean;
|
||||
readonly encrypted?: boolean | undefined;
|
||||
readonly localSettings: Settings;
|
||||
readonly originSet?: string[] | undefined;
|
||||
readonly pendingSettingsAck: boolean;
|
||||
readonly remoteSettings: Settings;
|
||||
readonly socket: net.Socket | tls.TLSSocket;
|
||||
readonly state: SessionState;
|
||||
readonly type: number;
|
||||
|
||||
close(callback?: () => void): void;
|
||||
destroy(error?: Error, code?: number): void;
|
||||
goaway(code?: number, lastStreamID?: number, opaqueData?: NodeJS.ArrayBufferView): void;
|
||||
ping(callback: (err: Error | null, duration: number, payload: Buffer) => void): boolean;
|
||||
ping(payload: NodeJS.ArrayBufferView, callback: (err: Error | null, duration: number, payload: Buffer) => void): boolean;
|
||||
ref(): void;
|
||||
setTimeout(msecs: number, callback?: () => void): void;
|
||||
settings(settings: Settings): void;
|
||||
unref(): void;
|
||||
|
||||
addListener(event: "close", listener: () => void): this;
|
||||
addListener(event: "error", listener: (err: Error) => void): this;
|
||||
addListener(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this;
|
||||
addListener(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData: Buffer) => void): this;
|
||||
addListener(event: "localSettings", listener: (settings: Settings) => void): this;
|
||||
addListener(event: "ping", listener: () => void): this;
|
||||
addListener(event: "remoteSettings", listener: (settings: Settings) => void): this;
|
||||
addListener(event: "timeout", listener: () => void): this;
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
emit(event: "close"): boolean;
|
||||
emit(event: "error", err: Error): boolean;
|
||||
emit(event: "frameError", frameType: number, errorCode: number, streamID: number): boolean;
|
||||
emit(event: "goaway", errorCode: number, lastStreamID: number, opaqueData: Buffer): boolean;
|
||||
emit(event: "localSettings", settings: Settings): boolean;
|
||||
emit(event: "ping"): boolean;
|
||||
emit(event: "remoteSettings", settings: Settings): boolean;
|
||||
emit(event: "timeout"): boolean;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
|
||||
on(event: "close", listener: () => void): this;
|
||||
on(event: "error", listener: (err: Error) => void): this;
|
||||
on(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this;
|
||||
on(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData: Buffer) => void): this;
|
||||
on(event: "localSettings", listener: (settings: Settings) => void): this;
|
||||
on(event: "ping", listener: () => void): this;
|
||||
on(event: "remoteSettings", listener: (settings: Settings) => void): this;
|
||||
on(event: "timeout", listener: () => void): this;
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
once(event: "close", listener: () => void): this;
|
||||
once(event: "error", listener: (err: Error) => void): this;
|
||||
once(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this;
|
||||
once(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData: Buffer) => void): this;
|
||||
once(event: "localSettings", listener: (settings: Settings) => void): this;
|
||||
once(event: "ping", listener: () => void): this;
|
||||
once(event: "remoteSettings", listener: (settings: Settings) => void): this;
|
||||
once(event: "timeout", listener: () => void): this;
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependListener(event: "close", listener: () => void): this;
|
||||
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependListener(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this;
|
||||
prependListener(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData: Buffer) => void): this;
|
||||
prependListener(event: "localSettings", listener: (settings: Settings) => void): this;
|
||||
prependListener(event: "ping", listener: () => void): this;
|
||||
prependListener(event: "remoteSettings", listener: (settings: Settings) => void): this;
|
||||
prependListener(event: "timeout", listener: () => void): this;
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependOnceListener(event: "close", listener: () => void): this;
|
||||
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this;
|
||||
prependOnceListener(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData: Buffer) => void): this;
|
||||
prependOnceListener(event: "localSettings", listener: (settings: Settings) => void): this;
|
||||
prependOnceListener(event: "ping", listener: () => void): this;
|
||||
prependOnceListener(event: "remoteSettings", listener: (settings: Settings) => void): this;
|
||||
prependOnceListener(event: "timeout", listener: () => void): this;
|
||||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
|
||||
export interface ClientHttp2Session extends Http2Session {
|
||||
request(headers?: OutgoingHttpHeaders, options?: ClientSessionRequestOptions): ClientHttp2Stream;
|
||||
|
||||
addListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
|
||||
addListener(event: "origin", listener: (origins: string[]) => void): this;
|
||||
addListener(event: "connect", listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
|
||||
addListener(event: "stream", listener: (stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
emit(event: "altsvc", alt: string, origin: string, stream: number): boolean;
|
||||
emit(event: "origin", origins: ReadonlyArray<string>): boolean;
|
||||
emit(event: "connect", session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket): boolean;
|
||||
emit(event: "stream", stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number): boolean;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
|
||||
on(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
|
||||
on(event: "origin", listener: (origins: string[]) => void): this;
|
||||
on(event: "connect", listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
|
||||
on(event: "stream", listener: (stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
once(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
|
||||
once(event: "origin", listener: (origins: string[]) => void): this;
|
||||
once(event: "connect", listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
|
||||
once(event: "stream", listener: (stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
|
||||
prependListener(event: "origin", listener: (origins: string[]) => void): this;
|
||||
prependListener(event: "connect", listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
|
||||
prependListener(event: "stream", listener: (stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependOnceListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
|
||||
prependOnceListener(event: "origin", listener: (origins: string[]) => void): this;
|
||||
prependOnceListener(event: "connect", listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
|
||||
prependOnceListener(event: "stream", listener: (stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
|
||||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
|
||||
export interface AlternativeServiceOptions {
|
||||
origin: number | string | url.URL;
|
||||
}
|
||||
|
||||
export interface ServerHttp2Session extends Http2Session {
|
||||
readonly server: Http2Server | Http2SecureServer;
|
||||
|
||||
altsvc(alt: string, originOrStream: number | string | url.URL | AlternativeServiceOptions): void;
|
||||
origin(...args: Array<string | url.URL | { origin: string }>): void;
|
||||
|
||||
addListener(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
|
||||
addListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
emit(event: "connect", session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket): boolean;
|
||||
emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
|
||||
on(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
|
||||
on(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
once(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
|
||||
once(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependListener(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
|
||||
prependListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependOnceListener(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
|
||||
prependOnceListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
|
||||
// Http2Server
|
||||
|
||||
export interface SessionOptions {
|
||||
maxDeflateDynamicTableSize?: number | undefined;
|
||||
maxSessionMemory?: number | undefined;
|
||||
maxHeaderListPairs?: number | undefined;
|
||||
maxOutstandingPings?: number | undefined;
|
||||
maxSendHeaderBlockLength?: number | undefined;
|
||||
paddingStrategy?: number | undefined;
|
||||
peerMaxConcurrentStreams?: number | undefined;
|
||||
settings?: Settings | undefined;
|
||||
|
||||
selectPadding?(frameLen: number, maxFrameLen: number): number;
|
||||
createConnection?(authority: url.URL, option: SessionOptions): stream.Duplex;
|
||||
}
|
||||
|
||||
export interface ClientSessionOptions extends SessionOptions {
|
||||
maxReservedRemoteStreams?: number | undefined;
|
||||
createConnection?: ((authority: url.URL, option: SessionOptions) => stream.Duplex) | undefined;
|
||||
}
|
||||
|
||||
export interface ServerSessionOptions extends SessionOptions {
|
||||
Http1IncomingMessage?: typeof IncomingMessage | undefined;
|
||||
Http1ServerResponse?: typeof ServerResponse | undefined;
|
||||
Http2ServerRequest?: typeof Http2ServerRequest | undefined;
|
||||
Http2ServerResponse?: typeof Http2ServerResponse | undefined;
|
||||
}
|
||||
|
||||
export interface SecureClientSessionOptions extends ClientSessionOptions, tls.ConnectionOptions { }
|
||||
export interface SecureServerSessionOptions extends ServerSessionOptions, tls.TlsOptions { }
|
||||
|
||||
export interface ServerOptions extends ServerSessionOptions { }
|
||||
|
||||
export interface SecureServerOptions extends SecureServerSessionOptions {
|
||||
allowHTTP1?: boolean | undefined;
|
||||
origins?: string[] | undefined;
|
||||
}
|
||||
|
||||
export interface Http2Server extends net.Server {
|
||||
addListener(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
addListener(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
addListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
|
||||
addListener(event: "sessionError", listener: (err: Error) => void): this;
|
||||
addListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
addListener(event: "timeout", listener: () => void): this;
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
emit(event: "checkContinue", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
|
||||
emit(event: "request", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
|
||||
emit(event: "session", session: ServerHttp2Session): boolean;
|
||||
emit(event: "sessionError", err: Error): boolean;
|
||||
emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
|
||||
emit(event: "timeout"): boolean;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
|
||||
on(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
on(event: "session", listener: (session: ServerHttp2Session) => void): this;
|
||||
on(event: "sessionError", listener: (err: Error) => void): this;
|
||||
on(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
on(event: "timeout", listener: () => void): this;
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
once(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
once(event: "session", listener: (session: ServerHttp2Session) => void): this;
|
||||
once(event: "sessionError", listener: (err: Error) => void): this;
|
||||
once(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
once(event: "timeout", listener: () => void): this;
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependListener(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
prependListener(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
|
||||
prependListener(event: "sessionError", listener: (err: Error) => void): this;
|
||||
prependListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
prependListener(event: "timeout", listener: () => void): this;
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependOnceListener(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
prependOnceListener(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
|
||||
prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
prependOnceListener(event: "timeout", listener: () => void): this;
|
||||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
setTimeout(msec?: number, callback?: () => void): this;
|
||||
}
|
||||
|
||||
export interface Http2SecureServer extends tls.Server {
|
||||
addListener(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
addListener(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
addListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
|
||||
addListener(event: "sessionError", listener: (err: Error) => void): this;
|
||||
addListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
addListener(event: "timeout", listener: () => void): this;
|
||||
addListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
emit(event: "checkContinue", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
|
||||
emit(event: "request", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
|
||||
emit(event: "session", session: ServerHttp2Session): boolean;
|
||||
emit(event: "sessionError", err: Error): boolean;
|
||||
emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
|
||||
emit(event: "timeout"): boolean;
|
||||
emit(event: "unknownProtocol", socket: tls.TLSSocket): boolean;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
|
||||
on(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
on(event: "session", listener: (session: ServerHttp2Session) => void): this;
|
||||
on(event: "sessionError", listener: (err: Error) => void): this;
|
||||
on(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
on(event: "timeout", listener: () => void): this;
|
||||
on(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
once(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
once(event: "session", listener: (session: ServerHttp2Session) => void): this;
|
||||
once(event: "sessionError", listener: (err: Error) => void): this;
|
||||
once(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
once(event: "timeout", listener: () => void): this;
|
||||
once(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependListener(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
prependListener(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
|
||||
prependListener(event: "sessionError", listener: (err: Error) => void): this;
|
||||
prependListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
prependListener(event: "timeout", listener: () => void): this;
|
||||
prependListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependOnceListener(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
prependOnceListener(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
|
||||
prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
|
||||
prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
|
||||
prependOnceListener(event: "timeout", listener: () => void): this;
|
||||
prependOnceListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
|
||||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
setTimeout(msec?: number, callback?: () => void): this;
|
||||
}
|
||||
|
||||
export class Http2ServerRequest extends stream.Readable {
|
||||
constructor(stream: ServerHttp2Stream, headers: IncomingHttpHeaders, options: stream.ReadableOptions, rawHeaders: ReadonlyArray<string>);
|
||||
|
||||
readonly aborted: boolean;
|
||||
readonly authority: string;
|
||||
readonly headers: IncomingHttpHeaders;
|
||||
readonly httpVersion: string;
|
||||
readonly method: string;
|
||||
readonly rawHeaders: string[];
|
||||
readonly rawTrailers: string[];
|
||||
readonly scheme: string;
|
||||
readonly socket: net.Socket | tls.TLSSocket;
|
||||
readonly stream: ServerHttp2Stream;
|
||||
readonly trailers: IncomingHttpHeaders;
|
||||
url: string;
|
||||
|
||||
setTimeout(msecs: number, callback?: () => void): void;
|
||||
read(size?: number): Buffer | string | null;
|
||||
|
||||
addListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
|
||||
addListener(event: "close", listener: () => void): this;
|
||||
addListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||
addListener(event: "end", listener: () => void): this;
|
||||
addListener(event: "readable", listener: () => void): this;
|
||||
addListener(event: "error", listener: (err: Error) => void): this;
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
emit(event: "aborted", hadError: boolean, code: number): boolean;
|
||||
emit(event: "close"): boolean;
|
||||
emit(event: "data", chunk: Buffer | string): boolean;
|
||||
emit(event: "end"): boolean;
|
||||
emit(event: "readable"): boolean;
|
||||
emit(event: "error", err: Error): boolean;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
|
||||
on(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
|
||||
on(event: "close", listener: () => void): this;
|
||||
on(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||
on(event: "end", listener: () => void): this;
|
||||
on(event: "readable", listener: () => void): this;
|
||||
on(event: "error", listener: (err: Error) => void): this;
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
once(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
|
||||
once(event: "close", listener: () => void): this;
|
||||
once(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||
once(event: "end", listener: () => void): this;
|
||||
once(event: "readable", listener: () => void): this;
|
||||
once(event: "error", listener: (err: Error) => void): this;
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
|
||||
prependListener(event: "close", listener: () => void): this;
|
||||
prependListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||
prependListener(event: "end", listener: () => void): this;
|
||||
prependListener(event: "readable", listener: () => void): this;
|
||||
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependOnceListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
|
||||
prependOnceListener(event: "close", listener: () => void): this;
|
||||
prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||
prependOnceListener(event: "end", listener: () => void): this;
|
||||
prependOnceListener(event: "readable", listener: () => void): this;
|
||||
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
|
||||
export class Http2ServerResponse extends stream.Writable {
|
||||
constructor(stream: ServerHttp2Stream);
|
||||
|
||||
readonly connection: net.Socket | tls.TLSSocket;
|
||||
readonly finished: boolean;
|
||||
readonly headersSent: boolean;
|
||||
readonly socket: net.Socket | tls.TLSSocket;
|
||||
readonly stream: ServerHttp2Stream;
|
||||
sendDate: boolean;
|
||||
statusCode: number;
|
||||
statusMessage: '';
|
||||
addTrailers(trailers: OutgoingHttpHeaders): void;
|
||||
end(callback?: () => void): this;
|
||||
end(data: string | Uint8Array, callback?: () => void): this;
|
||||
end(data: string | Uint8Array, encoding: string, callback?: () => void): this;
|
||||
getHeader(name: string): string;
|
||||
getHeaderNames(): string[];
|
||||
getHeaders(): OutgoingHttpHeaders;
|
||||
hasHeader(name: string): boolean;
|
||||
removeHeader(name: string): void;
|
||||
setHeader(name: string, value: number | string | ReadonlyArray<string>): void;
|
||||
setTimeout(msecs: number, callback?: () => void): void;
|
||||
write(chunk: string | Uint8Array, callback?: (err: Error) => void): boolean;
|
||||
write(chunk: string | Uint8Array, encoding: string, callback?: (err: Error) => void): boolean;
|
||||
writeContinue(): void;
|
||||
writeHead(statusCode: number, headers?: OutgoingHttpHeaders): this;
|
||||
writeHead(statusCode: number, statusMessage: string, headers?: OutgoingHttpHeaders): this;
|
||||
createPushResponse(headers: OutgoingHttpHeaders, callback: (err: Error | null, res: Http2ServerResponse) => void): void;
|
||||
|
||||
addListener(event: "close", listener: () => void): this;
|
||||
addListener(event: "drain", listener: () => void): this;
|
||||
addListener(event: "error", listener: (error: Error) => void): this;
|
||||
addListener(event: "finish", listener: () => void): this;
|
||||
addListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||
addListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
emit(event: "close"): boolean;
|
||||
emit(event: "drain"): boolean;
|
||||
emit(event: "error", error: Error): boolean;
|
||||
emit(event: "finish"): boolean;
|
||||
emit(event: "pipe", src: stream.Readable): boolean;
|
||||
emit(event: "unpipe", src: stream.Readable): boolean;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
|
||||
on(event: "close", listener: () => void): this;
|
||||
on(event: "drain", listener: () => void): this;
|
||||
on(event: "error", listener: (error: Error) => void): this;
|
||||
on(event: "finish", listener: () => void): this;
|
||||
on(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||
on(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
once(event: "close", listener: () => void): this;
|
||||
once(event: "drain", listener: () => void): this;
|
||||
once(event: "error", listener: (error: Error) => void): this;
|
||||
once(event: "finish", listener: () => void): this;
|
||||
once(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||
once(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependListener(event: "close", listener: () => void): this;
|
||||
prependListener(event: "drain", listener: () => void): this;
|
||||
prependListener(event: "error", listener: (error: Error) => void): this;
|
||||
prependListener(event: "finish", listener: () => void): this;
|
||||
prependListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||
prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependOnceListener(event: "close", listener: () => void): this;
|
||||
prependOnceListener(event: "drain", listener: () => void): this;
|
||||
prependOnceListener(event: "error", listener: (error: Error) => void): this;
|
||||
prependOnceListener(event: "finish", listener: () => void): this;
|
||||
prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||
prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
|
||||
// Public API
|
||||
|
||||
export namespace constants {
|
||||
const NGHTTP2_SESSION_SERVER: number;
|
||||
const NGHTTP2_SESSION_CLIENT: number;
|
||||
const NGHTTP2_STREAM_STATE_IDLE: number;
|
||||
const NGHTTP2_STREAM_STATE_OPEN: number;
|
||||
const NGHTTP2_STREAM_STATE_RESERVED_LOCAL: number;
|
||||
const NGHTTP2_STREAM_STATE_RESERVED_REMOTE: number;
|
||||
const NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL: number;
|
||||
const NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE: number;
|
||||
const NGHTTP2_STREAM_STATE_CLOSED: number;
|
||||
const NGHTTP2_NO_ERROR: number;
|
||||
const NGHTTP2_PROTOCOL_ERROR: number;
|
||||
const NGHTTP2_INTERNAL_ERROR: number;
|
||||
const NGHTTP2_FLOW_CONTROL_ERROR: number;
|
||||
const NGHTTP2_SETTINGS_TIMEOUT: number;
|
||||
const NGHTTP2_STREAM_CLOSED: number;
|
||||
const NGHTTP2_FRAME_SIZE_ERROR: number;
|
||||
const NGHTTP2_REFUSED_STREAM: number;
|
||||
const NGHTTP2_CANCEL: number;
|
||||
const NGHTTP2_COMPRESSION_ERROR: number;
|
||||
const NGHTTP2_CONNECT_ERROR: number;
|
||||
const NGHTTP2_ENHANCE_YOUR_CALM: number;
|
||||
const NGHTTP2_INADEQUATE_SECURITY: number;
|
||||
const NGHTTP2_HTTP_1_1_REQUIRED: number;
|
||||
const NGHTTP2_ERR_FRAME_SIZE_ERROR: number;
|
||||
const NGHTTP2_FLAG_NONE: number;
|
||||
const NGHTTP2_FLAG_END_STREAM: number;
|
||||
const NGHTTP2_FLAG_END_HEADERS: number;
|
||||
const NGHTTP2_FLAG_ACK: number;
|
||||
const NGHTTP2_FLAG_PADDED: number;
|
||||
const NGHTTP2_FLAG_PRIORITY: number;
|
||||
const DEFAULT_SETTINGS_HEADER_TABLE_SIZE: number;
|
||||
const DEFAULT_SETTINGS_ENABLE_PUSH: number;
|
||||
const DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE: number;
|
||||
const DEFAULT_SETTINGS_MAX_FRAME_SIZE: number;
|
||||
const MAX_MAX_FRAME_SIZE: number;
|
||||
const MIN_MAX_FRAME_SIZE: number;
|
||||
const MAX_INITIAL_WINDOW_SIZE: number;
|
||||
const NGHTTP2_DEFAULT_WEIGHT: number;
|
||||
const NGHTTP2_SETTINGS_HEADER_TABLE_SIZE: number;
|
||||
const NGHTTP2_SETTINGS_ENABLE_PUSH: number;
|
||||
const NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS: number;
|
||||
const NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE: number;
|
||||
const NGHTTP2_SETTINGS_MAX_FRAME_SIZE: number;
|
||||
const NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE: number;
|
||||
const PADDING_STRATEGY_NONE: number;
|
||||
const PADDING_STRATEGY_MAX: number;
|
||||
const PADDING_STRATEGY_CALLBACK: number;
|
||||
const HTTP2_HEADER_STATUS: string;
|
||||
const HTTP2_HEADER_METHOD: string;
|
||||
const HTTP2_HEADER_AUTHORITY: string;
|
||||
const HTTP2_HEADER_SCHEME: string;
|
||||
const HTTP2_HEADER_PATH: string;
|
||||
const HTTP2_HEADER_ACCEPT_CHARSET: string;
|
||||
const HTTP2_HEADER_ACCEPT_ENCODING: string;
|
||||
const HTTP2_HEADER_ACCEPT_LANGUAGE: string;
|
||||
const HTTP2_HEADER_ACCEPT_RANGES: string;
|
||||
const HTTP2_HEADER_ACCEPT: string;
|
||||
const HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN: string;
|
||||
const HTTP2_HEADER_AGE: string;
|
||||
const HTTP2_HEADER_ALLOW: string;
|
||||
const HTTP2_HEADER_AUTHORIZATION: string;
|
||||
const HTTP2_HEADER_CACHE_CONTROL: string;
|
||||
const HTTP2_HEADER_CONNECTION: string;
|
||||
const HTTP2_HEADER_CONTENT_DISPOSITION: string;
|
||||
const HTTP2_HEADER_CONTENT_ENCODING: string;
|
||||
const HTTP2_HEADER_CONTENT_LANGUAGE: string;
|
||||
const HTTP2_HEADER_CONTENT_LENGTH: string;
|
||||
const HTTP2_HEADER_CONTENT_LOCATION: string;
|
||||
const HTTP2_HEADER_CONTENT_MD5: string;
|
||||
const HTTP2_HEADER_CONTENT_RANGE: string;
|
||||
const HTTP2_HEADER_CONTENT_TYPE: string;
|
||||
const HTTP2_HEADER_COOKIE: string;
|
||||
const HTTP2_HEADER_DATE: string;
|
||||
const HTTP2_HEADER_ETAG: string;
|
||||
const HTTP2_HEADER_EXPECT: string;
|
||||
const HTTP2_HEADER_EXPIRES: string;
|
||||
const HTTP2_HEADER_FROM: string;
|
||||
const HTTP2_HEADER_HOST: string;
|
||||
const HTTP2_HEADER_IF_MATCH: string;
|
||||
const HTTP2_HEADER_IF_MODIFIED_SINCE: string;
|
||||
const HTTP2_HEADER_IF_NONE_MATCH: string;
|
||||
const HTTP2_HEADER_IF_RANGE: string;
|
||||
const HTTP2_HEADER_IF_UNMODIFIED_SINCE: string;
|
||||
const HTTP2_HEADER_LAST_MODIFIED: string;
|
||||
const HTTP2_HEADER_LINK: string;
|
||||
const HTTP2_HEADER_LOCATION: string;
|
||||
const HTTP2_HEADER_MAX_FORWARDS: string;
|
||||
const HTTP2_HEADER_PREFER: string;
|
||||
const HTTP2_HEADER_PROXY_AUTHENTICATE: string;
|
||||
const HTTP2_HEADER_PROXY_AUTHORIZATION: string;
|
||||
const HTTP2_HEADER_RANGE: string;
|
||||
const HTTP2_HEADER_REFERER: string;
|
||||
const HTTP2_HEADER_REFRESH: string;
|
||||
const HTTP2_HEADER_RETRY_AFTER: string;
|
||||
const HTTP2_HEADER_SERVER: string;
|
||||
const HTTP2_HEADER_SET_COOKIE: string;
|
||||
const HTTP2_HEADER_STRICT_TRANSPORT_SECURITY: string;
|
||||
const HTTP2_HEADER_TRANSFER_ENCODING: string;
|
||||
const HTTP2_HEADER_TE: string;
|
||||
const HTTP2_HEADER_UPGRADE: string;
|
||||
const HTTP2_HEADER_USER_AGENT: string;
|
||||
const HTTP2_HEADER_VARY: string;
|
||||
const HTTP2_HEADER_VIA: string;
|
||||
const HTTP2_HEADER_WWW_AUTHENTICATE: string;
|
||||
const HTTP2_HEADER_HTTP2_SETTINGS: string;
|
||||
const HTTP2_HEADER_KEEP_ALIVE: string;
|
||||
const HTTP2_HEADER_PROXY_CONNECTION: string;
|
||||
const HTTP2_METHOD_ACL: string;
|
||||
const HTTP2_METHOD_BASELINE_CONTROL: string;
|
||||
const HTTP2_METHOD_BIND: string;
|
||||
const HTTP2_METHOD_CHECKIN: string;
|
||||
const HTTP2_METHOD_CHECKOUT: string;
|
||||
const HTTP2_METHOD_CONNECT: string;
|
||||
const HTTP2_METHOD_COPY: string;
|
||||
const HTTP2_METHOD_DELETE: string;
|
||||
const HTTP2_METHOD_GET: string;
|
||||
const HTTP2_METHOD_HEAD: string;
|
||||
const HTTP2_METHOD_LABEL: string;
|
||||
const HTTP2_METHOD_LINK: string;
|
||||
const HTTP2_METHOD_LOCK: string;
|
||||
const HTTP2_METHOD_MERGE: string;
|
||||
const HTTP2_METHOD_MKACTIVITY: string;
|
||||
const HTTP2_METHOD_MKCALENDAR: string;
|
||||
const HTTP2_METHOD_MKCOL: string;
|
||||
const HTTP2_METHOD_MKREDIRECTREF: string;
|
||||
const HTTP2_METHOD_MKWORKSPACE: string;
|
||||
const HTTP2_METHOD_MOVE: string;
|
||||
const HTTP2_METHOD_OPTIONS: string;
|
||||
const HTTP2_METHOD_ORDERPATCH: string;
|
||||
const HTTP2_METHOD_PATCH: string;
|
||||
const HTTP2_METHOD_POST: string;
|
||||
const HTTP2_METHOD_PRI: string;
|
||||
const HTTP2_METHOD_PROPFIND: string;
|
||||
const HTTP2_METHOD_PROPPATCH: string;
|
||||
const HTTP2_METHOD_PUT: string;
|
||||
const HTTP2_METHOD_REBIND: string;
|
||||
const HTTP2_METHOD_REPORT: string;
|
||||
const HTTP2_METHOD_SEARCH: string;
|
||||
const HTTP2_METHOD_TRACE: string;
|
||||
const HTTP2_METHOD_UNBIND: string;
|
||||
const HTTP2_METHOD_UNCHECKOUT: string;
|
||||
const HTTP2_METHOD_UNLINK: string;
|
||||
const HTTP2_METHOD_UNLOCK: string;
|
||||
const HTTP2_METHOD_UPDATE: string;
|
||||
const HTTP2_METHOD_UPDATEREDIRECTREF: string;
|
||||
const HTTP2_METHOD_VERSION_CONTROL: string;
|
||||
const HTTP_STATUS_CONTINUE: number;
|
||||
const HTTP_STATUS_SWITCHING_PROTOCOLS: number;
|
||||
const HTTP_STATUS_PROCESSING: number;
|
||||
const HTTP_STATUS_OK: number;
|
||||
const HTTP_STATUS_CREATED: number;
|
||||
const HTTP_STATUS_ACCEPTED: number;
|
||||
const HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION: number;
|
||||
const HTTP_STATUS_NO_CONTENT: number;
|
||||
const HTTP_STATUS_RESET_CONTENT: number;
|
||||
const HTTP_STATUS_PARTIAL_CONTENT: number;
|
||||
const HTTP_STATUS_MULTI_STATUS: number;
|
||||
const HTTP_STATUS_ALREADY_REPORTED: number;
|
||||
const HTTP_STATUS_IM_USED: number;
|
||||
const HTTP_STATUS_MULTIPLE_CHOICES: number;
|
||||
const HTTP_STATUS_MOVED_PERMANENTLY: number;
|
||||
const HTTP_STATUS_FOUND: number;
|
||||
const HTTP_STATUS_SEE_OTHER: number;
|
||||
const HTTP_STATUS_NOT_MODIFIED: number;
|
||||
const HTTP_STATUS_USE_PROXY: number;
|
||||
const HTTP_STATUS_TEMPORARY_REDIRECT: number;
|
||||
const HTTP_STATUS_PERMANENT_REDIRECT: number;
|
||||
const HTTP_STATUS_BAD_REQUEST: number;
|
||||
const HTTP_STATUS_UNAUTHORIZED: number;
|
||||
const HTTP_STATUS_PAYMENT_REQUIRED: number;
|
||||
const HTTP_STATUS_FORBIDDEN: number;
|
||||
const HTTP_STATUS_NOT_FOUND: number;
|
||||
const HTTP_STATUS_METHOD_NOT_ALLOWED: number;
|
||||
const HTTP_STATUS_NOT_ACCEPTABLE: number;
|
||||
const HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED: number;
|
||||
const HTTP_STATUS_REQUEST_TIMEOUT: number;
|
||||
const HTTP_STATUS_CONFLICT: number;
|
||||
const HTTP_STATUS_GONE: number;
|
||||
const HTTP_STATUS_LENGTH_REQUIRED: number;
|
||||
const HTTP_STATUS_PRECONDITION_FAILED: number;
|
||||
const HTTP_STATUS_PAYLOAD_TOO_LARGE: number;
|
||||
const HTTP_STATUS_URI_TOO_LONG: number;
|
||||
const HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE: number;
|
||||
const HTTP_STATUS_RANGE_NOT_SATISFIABLE: number;
|
||||
const HTTP_STATUS_EXPECTATION_FAILED: number;
|
||||
const HTTP_STATUS_TEAPOT: number;
|
||||
const HTTP_STATUS_MISDIRECTED_REQUEST: number;
|
||||
const HTTP_STATUS_UNPROCESSABLE_ENTITY: number;
|
||||
const HTTP_STATUS_LOCKED: number;
|
||||
const HTTP_STATUS_FAILED_DEPENDENCY: number;
|
||||
const HTTP_STATUS_UNORDERED_COLLECTION: number;
|
||||
const HTTP_STATUS_UPGRADE_REQUIRED: number;
|
||||
const HTTP_STATUS_PRECONDITION_REQUIRED: number;
|
||||
const HTTP_STATUS_TOO_MANY_REQUESTS: number;
|
||||
const HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE: number;
|
||||
const HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS: number;
|
||||
const HTTP_STATUS_INTERNAL_SERVER_ERROR: number;
|
||||
const HTTP_STATUS_NOT_IMPLEMENTED: number;
|
||||
const HTTP_STATUS_BAD_GATEWAY: number;
|
||||
const HTTP_STATUS_SERVICE_UNAVAILABLE: number;
|
||||
const HTTP_STATUS_GATEWAY_TIMEOUT: number;
|
||||
const HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED: number;
|
||||
const HTTP_STATUS_VARIANT_ALSO_NEGOTIATES: number;
|
||||
const HTTP_STATUS_INSUFFICIENT_STORAGE: number;
|
||||
const HTTP_STATUS_LOOP_DETECTED: number;
|
||||
const HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED: number;
|
||||
const HTTP_STATUS_NOT_EXTENDED: number;
|
||||
const HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED: number;
|
||||
}
|
||||
|
||||
export function getDefaultSettings(): Settings;
|
||||
export function getPackedSettings(settings: Settings): Buffer;
|
||||
export function getUnpackedSettings(buf: Uint8Array): Settings;
|
||||
|
||||
export function createServer(onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void): Http2Server;
|
||||
export function createServer(options: ServerOptions, onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void): Http2Server;
|
||||
|
||||
export function createSecureServer(onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void): Http2SecureServer;
|
||||
export function createSecureServer(options: SecureServerOptions, onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void): Http2SecureServer;
|
||||
|
||||
export function connect(authority: string | url.URL, listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void): ClientHttp2Session;
|
||||
export function connect(
|
||||
authority: string | url.URL,
|
||||
options?: ClientSessionOptions | SecureClientSessionOptions,
|
||||
listener?: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void
|
||||
): ClientHttp2Session;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "bufferutil",
|
||||
"version": "4.1.0",
|
||||
"description": "WebSocket buffer utils",
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=6.14.2"
|
||||
},
|
||||
"scripts": {
|
||||
"install": "node-gyp-build",
|
||||
"prebuild": "prebuildify --napi --strip --target=8.11.2",
|
||||
"test": "mocha"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/websockets/bufferutil"
|
||||
},
|
||||
"keywords": [
|
||||
"bufferutil"
|
||||
],
|
||||
"author": "Einar Otto Stangvik <einaros@gmail.com> (http://2x.io)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/websockets/bufferutil/issues"
|
||||
},
|
||||
"homepage": "https://github.com/websockets/bufferutil",
|
||||
"dependencies": {
|
||||
"node-gyp-build": "^4.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^11.0.1",
|
||||
"node-gyp": "^12.1.0",
|
||||
"prebuildify": "^6.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,577 @@
|
||||
'use strict'
|
||||
|
||||
const SPACE_CHARACTERS = /\s+/g
|
||||
|
||||
// hoisted class for cyclic dependency
|
||||
class Range {
|
||||
constructor (range, options) {
|
||||
options = parseOptions(options)
|
||||
|
||||
if (range instanceof Range) {
|
||||
if (
|
||||
range.loose === !!options.loose &&
|
||||
range.includePrerelease === !!options.includePrerelease
|
||||
) {
|
||||
return range
|
||||
} else {
|
||||
return new Range(range.raw, options)
|
||||
}
|
||||
}
|
||||
|
||||
if (range instanceof Comparator) {
|
||||
// just put it in the set and return
|
||||
this.raw = range.value
|
||||
this.set = [[range]]
|
||||
this.formatted = undefined
|
||||
return this
|
||||
}
|
||||
|
||||
this.options = options
|
||||
this.loose = !!options.loose
|
||||
this.includePrerelease = !!options.includePrerelease
|
||||
|
||||
// First reduce all whitespace as much as possible so we do not have to rely
|
||||
// on potentially slow regexes like \s*. This is then stored and used for
|
||||
// future error messages as well.
|
||||
this.raw = range.trim().replace(SPACE_CHARACTERS, ' ')
|
||||
|
||||
// First, split on ||
|
||||
this.set = this.raw
|
||||
.split('||')
|
||||
// map the range to a 2d array of comparators
|
||||
.map(r => this.parseRange(r.trim()))
|
||||
// throw out any comparator lists that are empty
|
||||
// this generally means that it was not a valid range, which is allowed
|
||||
// in loose mode, but will still throw if the WHOLE range is invalid.
|
||||
.filter(c => c.length)
|
||||
|
||||
if (!this.set.length) {
|
||||
throw new TypeError(`Invalid SemVer Range: ${this.raw}`)
|
||||
}
|
||||
|
||||
// if we have any that are not the null set, throw out null sets.
|
||||
if (this.set.length > 1) {
|
||||
// keep the first one, in case they're all null sets
|
||||
const first = this.set[0]
|
||||
this.set = this.set.filter(c => !isNullSet(c[0]))
|
||||
if (this.set.length === 0) {
|
||||
this.set = [first]
|
||||
} else if (this.set.length > 1) {
|
||||
// if we have any that are *, then the range is just *
|
||||
for (const c of this.set) {
|
||||
if (c.length === 1 && isAny(c[0])) {
|
||||
this.set = [c]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.formatted = undefined
|
||||
}
|
||||
|
||||
get range () {
|
||||
if (this.formatted === undefined) {
|
||||
this.formatted = ''
|
||||
for (let i = 0; i < this.set.length; i++) {
|
||||
if (i > 0) {
|
||||
this.formatted += '||'
|
||||
}
|
||||
const comps = this.set[i]
|
||||
for (let k = 0; k < comps.length; k++) {
|
||||
if (k > 0) {
|
||||
this.formatted += ' '
|
||||
}
|
||||
this.formatted += comps[k].toString().trim()
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.formatted
|
||||
}
|
||||
|
||||
format () {
|
||||
return this.range
|
||||
}
|
||||
|
||||
toString () {
|
||||
return this.range
|
||||
}
|
||||
|
||||
parseRange (range) {
|
||||
// strip build metadata so it can't bleed into the version
|
||||
range = range.replace(BUILDSTRIPRE, '')
|
||||
|
||||
// memoize range parsing for performance.
|
||||
// this is a very hot path, and fully deterministic.
|
||||
const memoOpts =
|
||||
(this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) |
|
||||
(this.options.loose && FLAG_LOOSE)
|
||||
const memoKey = memoOpts + ':' + range
|
||||
const cached = cache.get(memoKey)
|
||||
if (cached) {
|
||||
return cached
|
||||
}
|
||||
|
||||
const loose = this.options.loose
|
||||
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
||||
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]
|
||||
range = range.replace(hr, hyphenReplace(this.options.includePrerelease))
|
||||
debug('hyphen replace', range)
|
||||
|
||||
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
||||
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
|
||||
debug('comparator trim', range)
|
||||
|
||||
// `~ 1.2.3` => `~1.2.3`
|
||||
range = range.replace(re[t.TILDETRIM], tildeTrimReplace)
|
||||
debug('tilde trim', range)
|
||||
|
||||
// `^ 1.2.3` => `^1.2.3`
|
||||
range = range.replace(re[t.CARETTRIM], caretTrimReplace)
|
||||
debug('caret trim', range)
|
||||
|
||||
// At this point, the range is completely trimmed and
|
||||
// ready to be split into comparators.
|
||||
|
||||
let rangeList = range
|
||||
.split(' ')
|
||||
.map(comp => parseComparator(comp, this.options))
|
||||
.join(' ')
|
||||
.split(/\s+/)
|
||||
// >=0.0.0 is equivalent to *
|
||||
.map(comp => replaceGTE0(comp, this.options))
|
||||
|
||||
if (loose) {
|
||||
// in loose mode, throw out any that are not valid comparators
|
||||
rangeList = rangeList.filter(comp => {
|
||||
debug('loose invalid filter', comp, this.options)
|
||||
return !!comp.match(re[t.COMPARATORLOOSE])
|
||||
})
|
||||
}
|
||||
debug('range list', rangeList)
|
||||
|
||||
// if any comparators are the null set, then replace with JUST null set
|
||||
// if more than one comparator, remove any * comparators
|
||||
// also, don't include the same comparator more than once
|
||||
const rangeMap = new Map()
|
||||
const comparators = rangeList.map(comp => new Comparator(comp, this.options))
|
||||
for (const comp of comparators) {
|
||||
if (isNullSet(comp)) {
|
||||
return [comp]
|
||||
}
|
||||
rangeMap.set(comp.value, comp)
|
||||
}
|
||||
if (rangeMap.size > 1 && rangeMap.has('')) {
|
||||
rangeMap.delete('')
|
||||
}
|
||||
|
||||
const result = [...rangeMap.values()]
|
||||
cache.set(memoKey, result)
|
||||
return result
|
||||
}
|
||||
|
||||
intersects (range, options) {
|
||||
if (!(range instanceof Range)) {
|
||||
throw new TypeError('a Range is required')
|
||||
}
|
||||
|
||||
return this.set.some((thisComparators) => {
|
||||
return (
|
||||
isSatisfiable(thisComparators, options) &&
|
||||
range.set.some((rangeComparators) => {
|
||||
return (
|
||||
isSatisfiable(rangeComparators, options) &&
|
||||
thisComparators.every((thisComparator) => {
|
||||
return rangeComparators.every((rangeComparator) => {
|
||||
return thisComparator.intersects(rangeComparator, options)
|
||||
})
|
||||
})
|
||||
)
|
||||
})
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// if ANY of the sets match ALL of its comparators, then pass
|
||||
test (version) {
|
||||
if (!version) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (typeof version === 'string') {
|
||||
try {
|
||||
version = new SemVer(version, this.options)
|
||||
} catch (er) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.set.length; i++) {
|
||||
if (testSet(this.set[i], version, this.options)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Range
|
||||
|
||||
const LRU = require('../internal/lrucache')
|
||||
const cache = new LRU()
|
||||
|
||||
const parseOptions = require('../internal/parse-options')
|
||||
const Comparator = require('./comparator')
|
||||
const debug = require('../internal/debug')
|
||||
const SemVer = require('./semver')
|
||||
const {
|
||||
safeRe: re,
|
||||
src,
|
||||
t,
|
||||
comparatorTrimReplace,
|
||||
tildeTrimReplace,
|
||||
caretTrimReplace,
|
||||
} = require('../internal/re')
|
||||
const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require('../internal/constants')
|
||||
|
||||
// unbounded global build-metadata stripper used by parseRange
|
||||
const BUILDSTRIPRE = new RegExp(src[t.BUILD], 'g')
|
||||
|
||||
const isNullSet = c => c.value === '<0.0.0-0'
|
||||
const isAny = c => c.value === ''
|
||||
|
||||
// take a set of comparators and determine whether there
|
||||
// exists a version which can satisfy it
|
||||
const isSatisfiable = (comparators, options) => {
|
||||
let result = true
|
||||
const remainingComparators = comparators.slice()
|
||||
let testComparator = remainingComparators.pop()
|
||||
|
||||
while (result && remainingComparators.length) {
|
||||
result = remainingComparators.every((otherComparator) => {
|
||||
return testComparator.intersects(otherComparator, options)
|
||||
})
|
||||
|
||||
testComparator = remainingComparators.pop()
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// comprised of xranges, tildes, stars, and gtlt's at this point.
|
||||
// already replaced the hyphen ranges
|
||||
// turn into a set of JUST comparators.
|
||||
const parseComparator = (comp, options) => {
|
||||
comp = comp.replace(re[t.BUILD], '')
|
||||
debug('comp', comp, options)
|
||||
comp = replaceCarets(comp, options)
|
||||
debug('caret', comp)
|
||||
comp = replaceTildes(comp, options)
|
||||
debug('tildes', comp)
|
||||
comp = replaceXRanges(comp, options)
|
||||
debug('xrange', comp)
|
||||
comp = replaceStars(comp, options)
|
||||
debug('stars', comp)
|
||||
return comp
|
||||
}
|
||||
|
||||
const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
|
||||
|
||||
const invalidXRangeOrder = (M, m, p) => (
|
||||
(isX(M) && !isX(m)) ||
|
||||
(isX(m) && p && !isX(p))
|
||||
)
|
||||
|
||||
// ~, ~> --> * (any, kinda silly)
|
||||
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
|
||||
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
|
||||
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
|
||||
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
|
||||
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
|
||||
// ~0.0.1 --> >=0.0.1 <0.1.0-0
|
||||
const replaceTildes = (comp, options) => {
|
||||
return comp
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
.map((c) => replaceTilde(c, options))
|
||||
.join(' ')
|
||||
}
|
||||
|
||||
const replaceTilde = (comp, options) => {
|
||||
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
|
||||
// if we're including prereleases in the match, then the lower bound is
|
||||
// -0, the lowest possible prerelease value, just like x-ranges and carets.
|
||||
// this keeps `~1.2` equivalent to the `1.2.x` x-range it's documented as.
|
||||
const z = options.includePrerelease ? '-0' : ''
|
||||
return comp.replace(r, (_, M, m, p, pr) => {
|
||||
debug('tilde', comp, _, M, m, p, pr)
|
||||
let ret
|
||||
|
||||
if (isX(M)) {
|
||||
ret = ''
|
||||
} else if (isX(m)) {
|
||||
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`
|
||||
} else if (isX(p)) {
|
||||
// ~1.2 == >=1.2.0 <1.3.0-0
|
||||
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`
|
||||
} else if (pr) {
|
||||
debug('replaceTilde pr', pr)
|
||||
ret = `>=${M}.${m}.${p}-${pr
|
||||
} <${M}.${+m + 1}.0-0`
|
||||
} else {
|
||||
// ~1.2.3 == >=1.2.3 <1.3.0-0
|
||||
ret = `>=${M}.${m}.${p
|
||||
} <${M}.${+m + 1}.0-0`
|
||||
}
|
||||
|
||||
debug('tilde return', ret)
|
||||
return ret
|
||||
})
|
||||
}
|
||||
|
||||
// ^ --> * (any, kinda silly)
|
||||
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
|
||||
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
|
||||
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
|
||||
// ^1.2.3 --> >=1.2.3 <2.0.0-0
|
||||
// ^1.2.0 --> >=1.2.0 <2.0.0-0
|
||||
// ^0.0.1 --> >=0.0.1 <0.0.2-0
|
||||
// ^0.1.0 --> >=0.1.0 <0.2.0-0
|
||||
const replaceCarets = (comp, options) => {
|
||||
return comp
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
.map((c) => replaceCaret(c, options))
|
||||
.join(' ')
|
||||
}
|
||||
|
||||
const replaceCaret = (comp, options) => {
|
||||
debug('caret', comp, options)
|
||||
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]
|
||||
const z = options.includePrerelease ? '-0' : ''
|
||||
return comp.replace(r, (_, M, m, p, pr) => {
|
||||
debug('caret', comp, _, M, m, p, pr)
|
||||
let ret
|
||||
|
||||
if (isX(M)) {
|
||||
ret = ''
|
||||
} else if (isX(m)) {
|
||||
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`
|
||||
} else if (isX(p)) {
|
||||
if (M === '0') {
|
||||
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`
|
||||
} else {
|
||||
ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`
|
||||
}
|
||||
} else if (pr) {
|
||||
debug('replaceCaret pr', pr)
|
||||
if (M === '0') {
|
||||
if (m === '0') {
|
||||
ret = `>=${M}.${m}.${p}-${pr
|
||||
} <${M}.${m}.${+p + 1}-0`
|
||||
} else {
|
||||
ret = `>=${M}.${m}.${p}-${pr
|
||||
} <${M}.${+m + 1}.0-0`
|
||||
}
|
||||
} else {
|
||||
ret = `>=${M}.${m}.${p}-${pr
|
||||
} <${+M + 1}.0.0-0`
|
||||
}
|
||||
} else {
|
||||
debug('no pr')
|
||||
if (M === '0') {
|
||||
if (m === '0') {
|
||||
ret = `>=${M}.${m}.${p
|
||||
} <${M}.${m}.${+p + 1}-0`
|
||||
} else {
|
||||
ret = `>=${M}.${m}.${p
|
||||
} <${M}.${+m + 1}.0-0`
|
||||
}
|
||||
} else {
|
||||
ret = `>=${M}.${m}.${p
|
||||
} <${+M + 1}.0.0-0`
|
||||
}
|
||||
}
|
||||
|
||||
debug('caret return', ret)
|
||||
return ret
|
||||
})
|
||||
}
|
||||
|
||||
const replaceXRanges = (comp, options) => {
|
||||
debug('replaceXRanges', comp, options)
|
||||
return comp
|
||||
.split(/\s+/)
|
||||
.map((c) => replaceXRange(c, options))
|
||||
.join(' ')
|
||||
}
|
||||
|
||||
const replaceXRange = (comp, options) => {
|
||||
comp = comp.trim()
|
||||
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]
|
||||
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
||||
debug('xRange', comp, ret, gtlt, M, m, p, pr)
|
||||
if (invalidXRangeOrder(M, m, p)) {
|
||||
return comp
|
||||
}
|
||||
|
||||
const xM = isX(M)
|
||||
const xm = xM || isX(m)
|
||||
const xp = xm || isX(p)
|
||||
const anyX = xp
|
||||
|
||||
if (gtlt === '=' && anyX) {
|
||||
gtlt = ''
|
||||
}
|
||||
|
||||
// if we're including prereleases in the match, then we need
|
||||
// to fix this to -0, the lowest possible prerelease value
|
||||
pr = options.includePrerelease ? '-0' : ''
|
||||
|
||||
if (xM) {
|
||||
if (gtlt === '>' || gtlt === '<') {
|
||||
// nothing is allowed
|
||||
ret = '<0.0.0-0'
|
||||
} else {
|
||||
// nothing is forbidden
|
||||
ret = '*'
|
||||
}
|
||||
} else if (gtlt && anyX) {
|
||||
// we know patch is an x, because we have any x at all.
|
||||
// replace X with 0
|
||||
if (xm) {
|
||||
m = 0
|
||||
}
|
||||
p = 0
|
||||
|
||||
if (gtlt === '>') {
|
||||
// >1 => >=2.0.0
|
||||
// >1.2 => >=1.3.0
|
||||
gtlt = '>='
|
||||
if (xm) {
|
||||
M = +M + 1
|
||||
m = 0
|
||||
p = 0
|
||||
} else {
|
||||
m = +m + 1
|
||||
p = 0
|
||||
}
|
||||
} else if (gtlt === '<=') {
|
||||
// <=0.7.x is actually <0.8.0, since any 0.7.x should
|
||||
// pass. Similarly, <=7.x is actually <8.0.0, etc.
|
||||
gtlt = '<'
|
||||
if (xm) {
|
||||
M = +M + 1
|
||||
} else {
|
||||
m = +m + 1
|
||||
}
|
||||
}
|
||||
|
||||
if (gtlt === '<') {
|
||||
pr = '-0'
|
||||
}
|
||||
|
||||
ret = `${gtlt + M}.${m}.${p}${pr}`
|
||||
} else if (xm) {
|
||||
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`
|
||||
} else if (xp) {
|
||||
ret = `>=${M}.${m}.0${pr
|
||||
} <${M}.${+m + 1}.0-0`
|
||||
}
|
||||
|
||||
debug('xRange return', ret)
|
||||
|
||||
return ret
|
||||
})
|
||||
}
|
||||
|
||||
// Because * is AND-ed with everything else in the comparator,
|
||||
// and '' means "any version", just remove the *s entirely.
|
||||
const replaceStars = (comp, options) => {
|
||||
debug('replaceStars', comp, options)
|
||||
// Looseness is ignored here. star is always as loose as it gets!
|
||||
return comp
|
||||
.trim()
|
||||
.replace(re[t.STAR], '')
|
||||
}
|
||||
|
||||
const replaceGTE0 = (comp, options) => {
|
||||
debug('replaceGTE0', comp, options)
|
||||
return comp
|
||||
.trim()
|
||||
.replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
|
||||
}
|
||||
|
||||
// This function is passed to string.replace(re[t.HYPHENRANGE])
|
||||
// M, m, patch, prerelease, build
|
||||
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
||||
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
|
||||
// 1.2 - 3.4 => >=1.2.0 <3.5.0-0
|
||||
// TODO build?
|
||||
const hyphenReplace = incPr => ($0,
|
||||
from, fM, fm, fp, fpr, fb,
|
||||
to, tM, tm, tp, tpr) => {
|
||||
if (isX(fM)) {
|
||||
from = ''
|
||||
} else if (isX(fm)) {
|
||||
from = `>=${fM}.0.0${incPr ? '-0' : ''}`
|
||||
} else if (isX(fp)) {
|
||||
from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`
|
||||
} else if (fpr) {
|
||||
from = `>=${from}`
|
||||
} else {
|
||||
from = `>=${from}${incPr ? '-0' : ''}`
|
||||
}
|
||||
|
||||
if (isX(tM)) {
|
||||
to = ''
|
||||
} else if (isX(tm)) {
|
||||
to = `<${+tM + 1}.0.0-0`
|
||||
} else if (isX(tp)) {
|
||||
to = `<${tM}.${+tm + 1}.0-0`
|
||||
} else if (tpr) {
|
||||
to = `<=${tM}.${tm}.${tp}-${tpr}`
|
||||
} else if (incPr) {
|
||||
to = `<${tM}.${tm}.${+tp + 1}-0`
|
||||
} else {
|
||||
to = `<=${to}`
|
||||
}
|
||||
|
||||
return `${from} ${to}`.trim()
|
||||
}
|
||||
|
||||
const testSet = (set, version, options) => {
|
||||
for (let i = 0; i < set.length; i++) {
|
||||
if (!set[i].test(version)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (version.prerelease.length && !options.includePrerelease) {
|
||||
// Find the set of versions that are allowed to have prereleases
|
||||
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
|
||||
// That should allow `1.2.3-pr.2` to pass.
|
||||
// However, `1.2.4-alpha.notready` should NOT be allowed,
|
||||
// even though it's within the range set by the comparators.
|
||||
for (let i = 0; i < set.length; i++) {
|
||||
debug(set[i].semver)
|
||||
if (set[i].semver === Comparator.ANY) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (set[i].semver.prerelease.length > 0) {
|
||||
const allowed = set[i].semver
|
||||
if (allowed.major === version.major &&
|
||||
allowed.minor === version.minor &&
|
||||
allowed.patch === version.patch) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Version has a -pre, but it's not one of the ones we like.
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user