WIP: bootstrap and partial real Solana watcher implementation

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

View File

@@ -0,0 +1,12 @@
import type * as JSONSchema from "../core/json-schema.cjs";
import { type $ZodRegistry } from "../core/registries.cjs";
import type { ZodType } from "./schemas.cjs";
type JSONSchemaVersion = "draft-2020-12" | "draft-7" | "draft-4" | "openapi-3.0";
interface FromJSONSchemaParams {
defaultTarget?: JSONSchemaVersion;
registry?: $ZodRegistry<any>;
}
/**
* Converts a JSON Schema to a Zod schema. This function should be considered semi-experimental. It's behavior is liable to change. */
export declare function fromJSONSchema(schema: JSONSchema.JSONSchema | boolean, params?: FromJSONSchemaParams): ZodType;
export {};

View File

@@ -0,0 +1,241 @@
// Code generated by _scripts/generate-encoder.ts. DO NOT EDIT.
import { SyntaxKind } from "../../ast/index.js";
export const childProperties = {
[SyntaxKind.QualifiedName]: ["left", "right"],
[SyntaxKind.ComputedPropertyName]: ["expression"],
[SyntaxKind.Decorator]: ["expression"],
[SyntaxKind.IfStatement]: ["expression", "thenStatement", "elseStatement"],
[SyntaxKind.DoStatement]: ["statement", "expression"],
[SyntaxKind.WhileStatement]: ["expression", "statement"],
[SyntaxKind.ForStatement]: ["initializer", "condition", "incrementor", "statement"],
[SyntaxKind.ForInStatement]: ["awaitModifier", "initializer", "expression", "statement"],
[SyntaxKind.ForOfStatement]: ["awaitModifier", "initializer", "expression", "statement"],
[SyntaxKind.BreakStatement]: ["label"],
[SyntaxKind.ContinueStatement]: ["label"],
[SyntaxKind.ReturnStatement]: ["expression"],
[SyntaxKind.WithStatement]: ["expression", "statement"],
[SyntaxKind.SwitchStatement]: ["expression", "caseBlock"],
[SyntaxKind.CaseBlock]: ["clauses"],
[SyntaxKind.CaseClause]: ["expression", "statements"],
[SyntaxKind.DefaultClause]: ["expression", "statements"],
[SyntaxKind.ThrowStatement]: ["expression"],
[SyntaxKind.TryStatement]: ["tryBlock", "catchClause", "finallyBlock"],
[SyntaxKind.CatchClause]: ["variableDeclaration", "block"],
[SyntaxKind.LabeledStatement]: ["label", "statement"],
[SyntaxKind.ExpressionStatement]: ["expression"],
[SyntaxKind.Block]: ["statements"],
[SyntaxKind.VariableStatement]: ["modifiers", "declarationList"],
[SyntaxKind.VariableDeclaration]: ["name", "exclamationToken", "type", "initializer"],
[SyntaxKind.VariableDeclarationList]: ["declarations"],
[SyntaxKind.ObjectBindingPattern]: ["elements"],
[SyntaxKind.ArrayBindingPattern]: ["elements"],
[SyntaxKind.Parameter]: ["modifiers", "dotDotDotToken", "name", "questionToken", "type", "initializer"],
[SyntaxKind.BindingElement]: ["dotDotDotToken", "propertyName", "name", "initializer"],
[SyntaxKind.MissingDeclaration]: ["modifiers"],
[SyntaxKind.FunctionDeclaration]: ["modifiers", "asteriskToken", "name", "typeParameters", "parameters", "type", "body"],
[SyntaxKind.ClassDeclaration]: ["modifiers", "name", "typeParameters", "heritageClauses", "members"],
[SyntaxKind.ClassExpression]: ["modifiers", "name", "typeParameters", "heritageClauses", "members"],
[SyntaxKind.HeritageClause]: ["types"],
[SyntaxKind.InterfaceDeclaration]: ["modifiers", "name", "typeParameters", "heritageClauses", "members"],
[SyntaxKind.TypeAliasDeclaration]: ["modifiers", "name", "typeParameters", "type"],
[SyntaxKind.JSTypeAliasDeclaration]: ["modifiers", "name", "typeParameters", "type"],
[SyntaxKind.EnumMember]: ["name", "initializer"],
[SyntaxKind.EnumDeclaration]: ["modifiers", "name", "members"],
[SyntaxKind.ModuleBlock]: ["statements"],
[SyntaxKind.ImportDeclaration]: ["modifiers", "importClause", "moduleSpecifier", "attributes"],
[SyntaxKind.JSImportDeclaration]: ["modifiers", "importClause", "moduleSpecifier", "attributes"],
[SyntaxKind.ExternalModuleReference]: ["expression"],
[SyntaxKind.NamespaceImport]: ["name"],
[SyntaxKind.NamedImports]: ["elements"],
[SyntaxKind.ExportAssignment]: ["modifiers", "type", "expression"],
[SyntaxKind.NamespaceExportDeclaration]: ["modifiers", "name"],
[SyntaxKind.NamespaceExport]: ["name"],
[SyntaxKind.NamedExports]: ["elements"],
[SyntaxKind.ExportSpecifier]: ["propertyName", "name"],
[SyntaxKind.CallSignature]: ["typeParameters", "parameters", "type"],
[SyntaxKind.ConstructSignature]: ["typeParameters", "parameters", "type"],
[SyntaxKind.Constructor]: ["modifiers", "typeParameters", "parameters", "type", "body"],
[SyntaxKind.GetAccessor]: ["modifiers", "name", "typeParameters", "parameters", "type", "body"],
[SyntaxKind.SetAccessor]: ["modifiers", "name", "typeParameters", "parameters", "type", "body"],
[SyntaxKind.IndexSignature]: ["modifiers", "parameters", "type"],
[SyntaxKind.MethodSignature]: ["modifiers", "name", "postfixToken", "typeParameters", "parameters", "type"],
[SyntaxKind.MethodDeclaration]: ["modifiers", "asteriskToken", "name", "postfixToken", "typeParameters", "parameters", "type", "body"],
[SyntaxKind.PropertySignature]: ["modifiers", "name", "postfixToken", "type", "initializer"],
[SyntaxKind.PropertyDeclaration]: ["modifiers", "name", "postfixToken", "type", "initializer"],
[SyntaxKind.ClassStaticBlockDeclaration]: ["modifiers", "body"],
[SyntaxKind.BinaryExpression]: ["modifiers", "left", "type", "operatorToken", "right"],
[SyntaxKind.PrefixUnaryExpression]: ["operand"],
[SyntaxKind.PostfixUnaryExpression]: ["operand"],
[SyntaxKind.YieldExpression]: ["asteriskToken", "expression"],
[SyntaxKind.ArrowFunction]: ["modifiers", "typeParameters", "parameters", "type", "equalsGreaterThanToken", "body"],
[SyntaxKind.FunctionExpression]: ["modifiers", "asteriskToken", "name", "typeParameters", "parameters", "type", "body"],
[SyntaxKind.AsExpression]: ["expression", "type"],
[SyntaxKind.SatisfiesExpression]: ["expression", "type"],
[SyntaxKind.ConditionalExpression]: ["condition", "questionToken", "whenTrue", "colonToken", "whenFalse"],
[SyntaxKind.PropertyAccessExpression]: ["expression", "questionDotToken", "name"],
[SyntaxKind.ElementAccessExpression]: ["expression", "questionDotToken", "argumentExpression"],
[SyntaxKind.CallExpression]: ["expression", "questionDotToken", "typeArguments", "arguments"],
[SyntaxKind.NewExpression]: ["expression", "typeArguments", "arguments"],
[SyntaxKind.MetaProperty]: ["name"],
[SyntaxKind.NonNullExpression]: ["expression"],
[SyntaxKind.SpreadElement]: ["expression"],
[SyntaxKind.TemplateExpression]: ["head", "templateSpans"],
[SyntaxKind.TemplateSpan]: ["expression", "literal"],
[SyntaxKind.TaggedTemplateExpression]: ["tag", "questionDotToken", "typeArguments", "template"],
[SyntaxKind.ParenthesizedExpression]: ["expression"],
[SyntaxKind.ArrayLiteralExpression]: ["elements"],
[SyntaxKind.ObjectLiteralExpression]: ["properties"],
[SyntaxKind.SpreadAssignment]: ["expression"],
[SyntaxKind.PropertyAssignment]: ["modifiers", "name", "postfixToken", "type", "initializer"],
[SyntaxKind.ShorthandPropertyAssignment]: ["modifiers", "name", "postfixToken", "type", "equalsToken", "objectAssignmentInitializer"],
[SyntaxKind.DeleteExpression]: ["expression"],
[SyntaxKind.TypeOfExpression]: ["expression"],
[SyntaxKind.VoidExpression]: ["expression"],
[SyntaxKind.AwaitExpression]: ["expression"],
[SyntaxKind.TypeAssertionExpression]: ["type", "expression"],
[SyntaxKind.UnionType]: ["types"],
[SyntaxKind.IntersectionType]: ["types"],
[SyntaxKind.ConditionalType]: ["checkType", "extendsType", "trueType", "falseType"],
[SyntaxKind.TypeOperator]: ["type"],
[SyntaxKind.InferType]: ["typeParameter"],
[SyntaxKind.ArrayType]: ["elementType"],
[SyntaxKind.IndexedAccessType]: ["objectType", "indexType"],
[SyntaxKind.TypeReference]: ["typeName", "typeArguments"],
[SyntaxKind.ExpressionWithTypeArguments]: ["expression", "typeArguments"],
[SyntaxKind.LiteralType]: ["literal"],
[SyntaxKind.TypePredicate]: ["assertsModifier", "parameterName", "type"],
[SyntaxKind.ImportAttribute]: ["name", "value"],
[SyntaxKind.ImportAttributes]: ["attributes"],
[SyntaxKind.TypeQuery]: ["exprName", "typeArguments"],
[SyntaxKind.MappedType]: ["readonlyToken", "typeParameter", "nameType", "questionToken", "type", "members"],
[SyntaxKind.TypeLiteral]: ["members"],
[SyntaxKind.TupleType]: ["elements"],
[SyntaxKind.NamedTupleMember]: ["dotDotDotToken", "name", "questionToken", "type"],
[SyntaxKind.OptionalType]: ["type"],
[SyntaxKind.RestType]: ["type"],
[SyntaxKind.ParenthesizedType]: ["type"],
[SyntaxKind.FunctionType]: ["typeParameters", "parameters", "type"],
[SyntaxKind.ConstructorType]: ["modifiers", "typeParameters", "parameters", "type"],
[SyntaxKind.TemplateLiteralType]: ["head", "templateSpans"],
[SyntaxKind.TemplateLiteralTypeSpan]: ["type", "literal"],
[SyntaxKind.SyntheticExpression]: ["tupleNameSource"],
[SyntaxKind.PartiallyEmittedExpression]: ["expression"],
[SyntaxKind.JsxElement]: ["openingElement", "children", "closingElement"],
[SyntaxKind.JsxAttributes]: ["properties"],
[SyntaxKind.JsxNamespacedName]: ["namespace", "name"],
[SyntaxKind.JsxOpeningElement]: ["tagName", "typeArguments", "attributes"],
[SyntaxKind.JsxSelfClosingElement]: ["tagName", "typeArguments", "attributes"],
[SyntaxKind.JsxFragment]: ["openingFragment", "children", "closingFragment"],
[SyntaxKind.JsxAttribute]: ["name", "initializer"],
[SyntaxKind.JsxSpreadAttribute]: ["expression"],
[SyntaxKind.JsxClosingElement]: ["tagName"],
[SyntaxKind.JsxExpression]: ["dotDotDotToken", "expression"],
[SyntaxKind.SyntaxList]: ["children"],
[SyntaxKind.JSDoc]: ["comment", "tags"],
[SyntaxKind.JSDocTypeExpression]: ["type"],
[SyntaxKind.JSDocNonNullableType]: ["type"],
[SyntaxKind.JSDocNullableType]: ["type"],
[SyntaxKind.JSDocVariadicType]: ["type"],
[SyntaxKind.JSDocOptionalType]: ["type"],
[SyntaxKind.JSDocTypeTag]: ["tagName", "typeExpression", "comment"],
[SyntaxKind.JSDocUnknownTag]: ["tagName", "comment"],
[SyntaxKind.JSDocTemplateTag]: ["tagName", "constraint", "typeParameters", "comment"],
[SyntaxKind.JSDocReturnTag]: ["tagName", "typeExpression", "comment"],
[SyntaxKind.JSDocPublicTag]: ["tagName", "comment"],
[SyntaxKind.JSDocPrivateTag]: ["tagName", "comment"],
[SyntaxKind.JSDocProtectedTag]: ["tagName", "comment"],
[SyntaxKind.JSDocReadonlyTag]: ["tagName", "comment"],
[SyntaxKind.JSDocOverrideTag]: ["tagName", "comment"],
[SyntaxKind.JSDocDeprecatedTag]: ["tagName", "comment"],
[SyntaxKind.JSDocSeeTag]: ["tagName", "nameExpression", "comment"],
[SyntaxKind.JSDocImplementsTag]: ["tagName", "className", "comment"],
[SyntaxKind.JSDocAugmentsTag]: ["tagName", "className", "comment"],
[SyntaxKind.JSDocSatisfiesTag]: ["tagName", "typeExpression", "comment"],
[SyntaxKind.JSDocThrowsTag]: ["tagName", "typeExpression", "comment"],
[SyntaxKind.JSDocThisTag]: ["tagName", "typeExpression", "comment"],
[SyntaxKind.JSDocImportTag]: ["tagName", "importClause", "moduleSpecifier", "attributes", "comment"],
[SyntaxKind.JSDocCallbackTag]: ["tagName", "typeExpression", "name", "comment"],
[SyntaxKind.JSDocOverloadTag]: ["tagName", "typeExpression", "comment"],
[SyntaxKind.JSDocTypedefTag]: ["tagName", "typeExpression", "name", "comment"],
[SyntaxKind.JSDocSignature]: ["typeParameters", "parameters", "type"],
[SyntaxKind.JSDocNameReference]: ["name"],
[SyntaxKind.SourceFile]: ["statements", "endOfFileToken"],
[SyntaxKind.ModuleDeclaration]: ["modifiers", "name", "body"],
[SyntaxKind.ImportEqualsDeclaration]: ["modifiers", "name", "moduleReference"],
[SyntaxKind.ExportDeclaration]: ["modifiers", "exportClause", "moduleSpecifier", "attributes"],
[SyntaxKind.ImportType]: ["argument", "attributes", "qualifier", "typeArguments"],
[SyntaxKind.ImportClause]: ["name", "namedBindings"],
[SyntaxKind.ImportSpecifier]: ["propertyName", "name"],
[SyntaxKind.JSDocLink]: ["name"],
[SyntaxKind.JSDocLinkPlain]: ["name"],
[SyntaxKind.JSDocLinkCode]: ["name"],
[SyntaxKind.TypeParameter]: ["modifiers", "name", "constraint", "expression", "defaultType"],
[SyntaxKind.SyntheticReferenceExpression]: ["expression", "thisArg"],
[SyntaxKind.JSDocTypeLiteral]: ["jsdocPropertyTags"],
[SyntaxKind.JSDocParameterTag]: ["tagName", "name", "typeExpression", "comment"],
[SyntaxKind.JSDocPropertyTag]: ["tagName", "name", "typeExpression", "comment"],
};
export const singleChildNodePropertyNames = {
[SyntaxKind.ComputedPropertyName]: "expression",
[SyntaxKind.Decorator]: "expression",
[SyntaxKind.BreakStatement]: "label",
[SyntaxKind.ContinueStatement]: "label",
[SyntaxKind.ReturnStatement]: "expression",
[SyntaxKind.CaseBlock]: "clauses",
[SyntaxKind.ThrowStatement]: "expression",
[SyntaxKind.ExpressionStatement]: "expression",
[SyntaxKind.Block]: "statements",
[SyntaxKind.VariableDeclarationList]: "declarations",
[SyntaxKind.ObjectBindingPattern]: "elements",
[SyntaxKind.ArrayBindingPattern]: "elements",
[SyntaxKind.MissingDeclaration]: "modifiers",
[SyntaxKind.HeritageClause]: "types",
[SyntaxKind.ModuleBlock]: "statements",
[SyntaxKind.ExternalModuleReference]: "expression",
[SyntaxKind.NamespaceImport]: "name",
[SyntaxKind.NamedImports]: "elements",
[SyntaxKind.NamespaceExport]: "name",
[SyntaxKind.NamedExports]: "elements",
[SyntaxKind.PrefixUnaryExpression]: "operand",
[SyntaxKind.PostfixUnaryExpression]: "operand",
[SyntaxKind.MetaProperty]: "name",
[SyntaxKind.NonNullExpression]: "expression",
[SyntaxKind.SpreadElement]: "expression",
[SyntaxKind.ParenthesizedExpression]: "expression",
[SyntaxKind.ArrayLiteralExpression]: "elements",
[SyntaxKind.ObjectLiteralExpression]: "properties",
[SyntaxKind.SpreadAssignment]: "expression",
[SyntaxKind.DeleteExpression]: "expression",
[SyntaxKind.TypeOfExpression]: "expression",
[SyntaxKind.VoidExpression]: "expression",
[SyntaxKind.AwaitExpression]: "expression",
[SyntaxKind.UnionType]: "types",
[SyntaxKind.IntersectionType]: "types",
[SyntaxKind.TypeOperator]: "type",
[SyntaxKind.InferType]: "typeParameter",
[SyntaxKind.ArrayType]: "elementType",
[SyntaxKind.LiteralType]: "literal",
[SyntaxKind.ImportAttributes]: "attributes",
[SyntaxKind.TypeLiteral]: "members",
[SyntaxKind.TupleType]: "elements",
[SyntaxKind.OptionalType]: "type",
[SyntaxKind.RestType]: "type",
[SyntaxKind.ParenthesizedType]: "type",
[SyntaxKind.SyntheticExpression]: "tupleNameSource",
[SyntaxKind.PartiallyEmittedExpression]: "expression",
[SyntaxKind.JsxAttributes]: "properties",
[SyntaxKind.JsxSpreadAttribute]: "expression",
[SyntaxKind.JsxClosingElement]: "tagName",
[SyntaxKind.SyntaxList]: "children",
[SyntaxKind.JSDocTypeExpression]: "type",
[SyntaxKind.JSDocNonNullableType]: "type",
[SyntaxKind.JSDocNullableType]: "type",
[SyntaxKind.JSDocVariadicType]: "type",
[SyntaxKind.JSDocOptionalType]: "type",
[SyntaxKind.JSDocNameReference]: "name",
[SyntaxKind.JSDocLink]: "name",
[SyntaxKind.JSDocLinkPlain]: "name",
[SyntaxKind.JSDocLinkCode]: "name",
[SyntaxKind.JSDocTypeLiteral]: "jsdocPropertyTags",
};
//# sourceMappingURL=protocol.generated.js.map

View File

@@ -0,0 +1,16 @@
export * from "./core.js";
export * from "./parse.js";
export * from "./errors.js";
export * from "./schemas.js";
export * from "./checks.js";
export * from "./versions.js";
export * as util from "./util.js";
export * as regexes from "./regexes.js";
export * as locales from "../locales/index.js";
export * from "./registries.js";
export * from "./doc.js";
export * from "./api.js";
export * from "./to-json-schema.js";
export { toJSONSchema } from "./json-schema-processors.js";
export { JSONSchemaGenerator } from "./json-schema-generator.js";
export * as JSONSchema from "./json-schema.js";

View File

@@ -0,0 +1,382 @@
/*! *****************************************************************************
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.
***************************************************************************** */
/**
* The decorator context types provided to class element decorators.
*/
type ClassMemberDecoratorContext =
| ClassMethodDecoratorContext
| ClassGetterDecoratorContext
| ClassSetterDecoratorContext
| ClassFieldDecoratorContext
| ClassAccessorDecoratorContext;
/**
* The decorator context types provided to any decorator.
*/
type DecoratorContext =
| ClassDecoratorContext
| ClassMemberDecoratorContext;
type DecoratorMetadataObject = Record<PropertyKey, unknown> & object;
type DecoratorMetadata = typeof globalThis extends { Symbol: { readonly metadata: symbol; }; } ? DecoratorMetadataObject : DecoratorMetadataObject | undefined;
/**
* Context provided to a class decorator.
* @template Class The type of the decorated class associated with this context.
*/
interface ClassDecoratorContext<
Class extends abstract new (...args: any) => any = abstract new (...args: any) => any,
> {
/** The kind of element that was decorated. */
readonly kind: "class";
/** The name of the decorated class. */
readonly name: string | undefined;
/**
* Adds a callback to be invoked after the class definition has been finalized.
*
* @example
* ```ts
* function customElement(name: string): ClassDecoratorFunction {
* return (target, context) => {
* context.addInitializer(function () {
* customElements.define(name, this);
* });
* }
* }
*
* @customElement("my-element")
* class MyElement {}
* ```
*/
addInitializer(initializer: (this: Class) => void): void;
readonly metadata: DecoratorMetadata;
}
/**
* Context provided to a class method decorator.
* @template This The type on which the class element will be defined. For a static class element, this will be
* the type of the constructor. For a non-static class element, this will be the type of the instance.
* @template Value The type of the decorated class method.
*/
interface ClassMethodDecoratorContext<
This = unknown,
Value extends (this: This, ...args: any) => any = (this: This, ...args: any) => any,
> {
/** The kind of class element that was decorated. */
readonly kind: "method";
/** The name of the decorated class element. */
readonly name: string | symbol;
/** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
readonly static: boolean;
/** A value indicating whether the class element has a private name. */
readonly private: boolean;
/** An object that can be used to access the current value of the class element at runtime. */
readonly access: {
/**
* Determines whether an object has a property with the same name as the decorated element.
*/
has(object: This): boolean;
/**
* Gets the current value of the method from the provided object.
*
* @example
* let fn = context.access.get(instance);
*/
get(object: This): Value;
};
/**
* Adds a callback to be invoked either after static methods are defined but before
* static initializers are run (when decorating a `static` element), or before instance
* initializers are run (when decorating a non-`static` element).
*
* @example
* ```ts
* const bound: ClassMethodDecoratorFunction = (value, context) {
* if (context.private) throw new TypeError("Not supported on private methods.");
* context.addInitializer(function () {
* this[context.name] = this[context.name].bind(this);
* });
* }
*
* class C {
* message = "Hello";
*
* @bound
* m() {
* console.log(this.message);
* }
* }
* ```
*/
addInitializer(initializer: (this: This) => void): void;
readonly metadata: DecoratorMetadata;
}
/**
* Context provided to a class getter decorator.
* @template This The type on which the class element will be defined. For a static class element, this will be
* the type of the constructor. For a non-static class element, this will be the type of the instance.
* @template Value The property type of the decorated class getter.
*/
interface ClassGetterDecoratorContext<
This = unknown,
Value = unknown,
> {
/** The kind of class element that was decorated. */
readonly kind: "getter";
/** The name of the decorated class element. */
readonly name: string | symbol;
/** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
readonly static: boolean;
/** A value indicating whether the class element has a private name. */
readonly private: boolean;
/** An object that can be used to access the current value of the class element at runtime. */
readonly access: {
/**
* Determines whether an object has a property with the same name as the decorated element.
*/
has(object: This): boolean;
/**
* Invokes the getter on the provided object.
*
* @example
* let value = context.access.get(instance);
*/
get(object: This): Value;
};
/**
* Adds a callback to be invoked either after static methods are defined but before
* static initializers are run (when decorating a `static` element), or before instance
* initializers are run (when decorating a non-`static` element).
*/
addInitializer(initializer: (this: This) => void): void;
readonly metadata: DecoratorMetadata;
}
/**
* Context provided to a class setter decorator.
* @template This The type on which the class element will be defined. For a static class element, this will be
* the type of the constructor. For a non-static class element, this will be the type of the instance.
* @template Value The type of the decorated class setter.
*/
interface ClassSetterDecoratorContext<
This = unknown,
Value = unknown,
> {
/** The kind of class element that was decorated. */
readonly kind: "setter";
/** The name of the decorated class element. */
readonly name: string | symbol;
/** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
readonly static: boolean;
/** A value indicating whether the class element has a private name. */
readonly private: boolean;
/** An object that can be used to access the current value of the class element at runtime. */
readonly access: {
/**
* Determines whether an object has a property with the same name as the decorated element.
*/
has(object: This): boolean;
/**
* Invokes the setter on the provided object.
*
* @example
* context.access.set(instance, value);
*/
set(object: This, value: Value): void;
};
/**
* Adds a callback to be invoked either after static methods are defined but before
* static initializers are run (when decorating a `static` element), or before instance
* initializers are run (when decorating a non-`static` element).
*/
addInitializer(initializer: (this: This) => void): void;
readonly metadata: DecoratorMetadata;
}
/**
* Context provided to a class `accessor` field decorator.
* @template This The type on which the class element will be defined. For a static class element, this will be
* the type of the constructor. For a non-static class element, this will be the type of the instance.
* @template Value The type of decorated class field.
*/
interface ClassAccessorDecoratorContext<
This = unknown,
Value = unknown,
> {
/** The kind of class element that was decorated. */
readonly kind: "accessor";
/** The name of the decorated class element. */
readonly name: string | symbol;
/** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
readonly static: boolean;
/** A value indicating whether the class element has a private name. */
readonly private: boolean;
/** An object that can be used to access the current value of the class element at runtime. */
readonly access: {
/**
* Determines whether an object has a property with the same name as the decorated element.
*/
has(object: This): boolean;
/**
* Invokes the getter on the provided object.
*
* @example
* let value = context.access.get(instance);
*/
get(object: This): Value;
/**
* Invokes the setter on the provided object.
*
* @example
* context.access.set(instance, value);
*/
set(object: This, value: Value): void;
};
/**
* Adds a callback to be invoked immediately after the auto `accessor` being
* decorated is initialized (regardless if the `accessor` is `static` or not).
*/
addInitializer(initializer: (this: This) => void): void;
readonly metadata: DecoratorMetadata;
}
/**
* Describes the target provided to class `accessor` field decorators.
* @template This The `this` type to which the target applies.
* @template Value The property type for the class `accessor` field.
*/
interface ClassAccessorDecoratorTarget<This, Value> {
/**
* Invokes the getter that was defined prior to decorator application.
*
* @example
* let value = target.get.call(instance);
*/
get(this: This): Value;
/**
* Invokes the setter that was defined prior to decorator application.
*
* @example
* target.set.call(instance, value);
*/
set(this: This, value: Value): void;
}
/**
* Describes the allowed return value from a class `accessor` field decorator.
* @template This The `this` type to which the target applies.
* @template Value The property type for the class `accessor` field.
*/
interface ClassAccessorDecoratorResult<This, Value> {
/**
* An optional replacement getter function. If not provided, the existing getter function is used instead.
*/
get?(this: This): Value;
/**
* An optional replacement setter function. If not provided, the existing setter function is used instead.
*/
set?(this: This, value: Value): void;
/**
* An optional initializer mutator that is invoked when the underlying field initializer is evaluated.
* @param value The incoming initializer value.
* @returns The replacement initializer value.
*/
init?(this: This, value: Value): Value;
}
/**
* Context provided to a class field decorator.
* @template This The type on which the class element will be defined. For a static class element, this will be
* the type of the constructor. For a non-static class element, this will be the type of the instance.
* @template Value The type of the decorated class field.
*/
interface ClassFieldDecoratorContext<
This = unknown,
Value = unknown,
> {
/** The kind of class element that was decorated. */
readonly kind: "field";
/** The name of the decorated class element. */
readonly name: string | symbol;
/** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
readonly static: boolean;
/** A value indicating whether the class element has a private name. */
readonly private: boolean;
/** An object that can be used to access the current value of the class element at runtime. */
readonly access: {
/**
* Determines whether an object has a property with the same name as the decorated element.
*/
has(object: This): boolean;
/**
* Gets the value of the field on the provided object.
*/
get(object: This): Value;
/**
* Sets the value of the field on the provided object.
*/
set(object: This, value: Value): void;
};
/**
* Adds a callback to be invoked immediately after the field being decorated
* is initialized (regardless if the field is `static` or not).
*/
addInitializer(initializer: (this: This) => void): void;
readonly metadata: DecoratorMetadata;
}

View File

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

View File

@@ -0,0 +1,216 @@
import { expectTypeOf, test } from "vitest";
import * as z from "zod/v4";
test("assignability", () => {
// $ZodString
z.string() satisfies z.core.$ZodString;
z.string() satisfies z.ZodString;
// $ZodNumber
z.number() satisfies z.core.$ZodNumber;
z.number() satisfies z.ZodNumber;
// $ZodBigInt
z.bigint() satisfies z.core.$ZodBigInt;
z.bigint() satisfies z.ZodBigInt;
// $ZodBoolean
z.boolean() satisfies z.core.$ZodBoolean;
z.boolean() satisfies z.ZodBoolean;
// $ZodDate
z.date() satisfies z.core.$ZodDate;
z.date() satisfies z.ZodDate;
// $ZodSymbol
z.symbol() satisfies z.core.$ZodSymbol;
z.symbol() satisfies z.ZodSymbol;
// $ZodUndefined
z.undefined() satisfies z.core.$ZodUndefined;
z.undefined() satisfies z.ZodUndefined;
// $ZodNullable
z.string().nullable() satisfies z.core.$ZodNullable;
z.string().nullable() satisfies z.ZodNullable;
// $ZodNull
z.null() satisfies z.core.$ZodNull;
z.null() satisfies z.ZodNull;
// $ZodAny
z.any() satisfies z.core.$ZodAny;
z.any() satisfies z.ZodAny;
// $ZodUnknown
z.unknown() satisfies z.core.$ZodUnknown;
z.unknown() satisfies z.ZodUnknown;
// $ZodNever
z.never() satisfies z.core.$ZodNever;
z.never() satisfies z.ZodNever;
// $ZodVoid
z.void() satisfies z.core.$ZodVoid;
z.void() satisfies z.ZodVoid;
// $ZodArray
z.array(z.string()) satisfies z.core.$ZodArray;
z.array(z.string()) satisfies z.ZodArray;
z.array(z.string()) satisfies z.ZodType<Array<unknown>>;
// $ZodObject
z.object({ key: z.string() }) satisfies z.core.$ZodObject;
z.object({ key: z.string() }) satisfies z.ZodObject<{ key: z.ZodType }>;
z.object({ key: z.string() }) satisfies z.ZodType<{ key: string }>;
// $ZodUnion
z.union([z.string(), z.number()]) satisfies z.core.$ZodUnion;
z.union([z.string(), z.number()]) satisfies z.ZodUnion;
z.union([z.string(), z.number()]) satisfies z.ZodType<string | number>;
// $ZodIntersection
z.intersection(z.string(), z.number()) satisfies z.core.$ZodIntersection;
z.intersection(z.string(), z.number()) satisfies z.ZodIntersection;
// $ZodTuple
z.tuple([z.string(), z.number()]) satisfies z.core.$ZodTuple;
z.tuple([z.string(), z.number()]) satisfies z.ZodTuple;
// $ZodRecord
z.record(z.string(), z.number()) satisfies z.core.$ZodRecord;
z.record(z.string(), z.number()) satisfies z.ZodRecord;
// $ZodMap
z.map(z.string(), z.number()) satisfies z.core.$ZodMap;
z.map(z.string(), z.number()) satisfies z.ZodMap;
// $ZodSet
z.set(z.string()) satisfies z.core.$ZodSet;
z.set(z.string()) satisfies z.ZodSet;
// $ZodLiteral
z.literal("example") satisfies z.core.$ZodLiteral;
z.literal("example") satisfies z.ZodLiteral;
// $ZodEnum
z.enum(["a", "b", "c"]) satisfies z.core.$ZodEnum;
z.enum(["a", "b", "c"]) satisfies z.ZodEnum;
// $ZodPromise
z.promise(z.string()) satisfies z.core.$ZodPromise;
z.promise(z.string()) satisfies z.ZodPromise;
// $ZodLazy
const lazySchema = z.lazy(() => z.string());
lazySchema satisfies z.core.$ZodLazy;
lazySchema satisfies z.ZodLazy;
// $ZodOptional
z.string().optional() satisfies z.core.$ZodOptional;
z.string().optional() satisfies z.ZodOptional;
// $ZodDefault
z.string().default("default") satisfies z.core.$ZodDefault;
z.string().default("default") satisfies z.ZodDefault;
// $ZodTemplateLiteral
z.templateLiteral([z.literal("a"), z.literal("b")]) satisfies z.core.$ZodTemplateLiteral;
z.templateLiteral([z.literal("a"), z.literal("b")]) satisfies z.ZodTemplateLiteral;
// $ZodCustom
z.custom<string>((val) => typeof val === "string") satisfies z.core.$ZodCustom;
z.custom<string>((val) => typeof val === "string") satisfies z.ZodCustom;
// $ZodTransform
z.transform((val) => val as string) satisfies z.core.$ZodTransform;
z.transform((val) => val as string) satisfies z.ZodTransform;
// $ZodNonOptional
z.string().optional().nonoptional() satisfies z.core.$ZodNonOptional;
z.string().optional().nonoptional() satisfies z.ZodNonOptional;
// $ZodReadonly
z.object({ key: z.string() }).readonly() satisfies z.core.$ZodReadonly;
z.object({ key: z.string() }).readonly() satisfies z.ZodReadonly;
// $ZodNaN
z.nan() satisfies z.core.$ZodNaN;
z.nan() satisfies z.ZodNaN;
// $ZodPipe
z.unknown().pipe(z.number()) satisfies z.core.$ZodPipe;
z.unknown().pipe(z.number()) satisfies z.ZodPipe;
// $ZodPreprocess
z.preprocess((v) => v, z.number()) satisfies z.core.$ZodPreprocess;
z.preprocess((v) => v, z.number()) satisfies z.ZodPreprocess;
z.preprocess((v) => v, z.number()) satisfies z.core.$ZodPipe<z.core.$ZodTransform, z.ZodNumber>;
z.preprocess((v) => v, z.number()) satisfies z.ZodPipe<z.core.$ZodTransform, z.ZodNumber>;
// $ZodSuccess
z.success(z.string()) satisfies z.core.$ZodSuccess;
z.success(z.string()) satisfies z.ZodSuccess;
// $ZodCatch
z.string().catch("fallback") satisfies z.core.$ZodCatch;
z.string().catch("fallback") satisfies z.ZodCatch;
// $ZodFile
z.file() satisfies z.core.$ZodFile;
z.file() satisfies z.ZodFile;
});
test("checks", () => {
const _a: z.core.$ZodCheck = {} as any as z.core.$ZodChecks;
const _b: z.core.$ZodCheck = {} as any as z.core.$ZodStringFormatChecks;
const _c: z.core.$ZodType = {} as any as z.core.$ZodTypes;
const _d: z.core.$ZodType = {} as any as z.core.$ZodStringFormatTypes;
});
test("assignability to $ZodType", () => {
z.string() satisfies z.ZodType;
z.number() satisfies z.ZodType;
z.boolean() satisfies z.ZodType;
z.object({ key: z.string() }) satisfies z.ZodType;
z.object({ key: z.string() }) satisfies z.ZodType<{ key: string }>;
z.array(z.string()) satisfies z.ZodType;
z.union([z.string(), z.number()]) satisfies z.ZodType;
z.intersection(z.string(), z.number()) satisfies z.ZodType;
z.tuple([z.string(), z.number()]) satisfies z.ZodType;
z.record(z.string(), z.number()) satisfies z.ZodType;
z.map(z.string(), z.number()) satisfies z.ZodType;
z.set(z.string()) satisfies z.ZodType;
z.literal("example") satisfies z.ZodType;
expectTypeOf<z.ZodType extends z.core.$ZodType ? true : false>().toEqualTypeOf<true>();
});
test("assignability with narrowing", () => {
type _RefinedSchema<T extends z.ZodType<object> | z.ZodUnion> = T extends z.ZodUnion
? RefinedUnionSchema<T> // <-- Type instantiation is excessively deep and possibly infinite.
: T extends z.ZodType<object>
? RefinedTypeSchema<z.output<T>> // <-- Type instantiation is excessively deep and possibly infinite.
: never;
type RefinedTypeSchema<T extends object> = T;
type RefinedUnionSchema<T extends z.ZodUnion> = T;
});
test("generic assignability in objects", () => {
interface SortItem<T extends string> {
key: T;
order: string;
}
const createSortItemSchema = <T extends z.ZodType<string>>(sortKeySchema: T) =>
z.object({
key: sortKeySchema,
order: z.string(),
});
<T extends z.ZodType<string>>(sortKeySchema: T, defaultSortBy: SortItem<z.output<T>>[] = []) =>
createSortItemSchema(sortKeySchema).array().default(defaultSortBy);
});

View File

@@ -0,0 +1,36 @@
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== "function") return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function(nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) return obj;
if (obj === null || typeof obj !== "object" && typeof obj !== "function") return { default: obj };
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) return cache.get(obj);
var newObj = { __proto__: null };
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj) {
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
else newObj[key] = obj[key];
}
}
newObj.default = obj;
if (cache) cache.set(obj, newObj);
return newObj;
}
export { _interop_require_wildcard as _ };

View File

@@ -0,0 +1,54 @@
{{# def.definitions }}
{{# def.errors }}
{{# def.setupKeyword }}
{{# def.setupNextLevel }}
{{
var $currentBaseId = $it.baseId
, $prevValid = 'prevValid' + $lvl
, $passingSchemas = 'passingSchemas' + $lvl;
}}
var {{=$errs}} = errors
, {{=$prevValid}} = false
, {{=$valid}} = false
, {{=$passingSchemas}} = null;
{{# def.setCompositeRule }}
{{~ $schema:$sch:$i }}
{{? {{# def.nonEmptySchema:$sch }} }}
{{
$it.schema = $sch;
$it.schemaPath = $schemaPath + '[' + $i + ']';
$it.errSchemaPath = $errSchemaPath + '/' + $i;
}}
{{# def.insertSubschemaCode }}
{{??}}
var {{=$nextValid}} = true;
{{?}}
{{? $i }}
if ({{=$nextValid}} && {{=$prevValid}}) {
{{=$valid}} = false;
{{=$passingSchemas}} = [{{=$passingSchemas}}, {{=$i}}];
} else {
{{ $closingBraces += '}'; }}
{{?}}
if ({{=$nextValid}}) {
{{=$valid}} = {{=$prevValid}} = true;
{{=$passingSchemas}} = {{=$i}};
}
{{~}}
{{# def.resetCompositeRule }}
{{= $closingBraces }}
if (!{{=$valid}}) {
{{# def.extraError:'oneOf' }}
} else {
{{# def.resetErrors }}
{{? it.opts.allErrors }} } {{?}}

View File

@@ -0,0 +1,9 @@
import { Parser, Printer } from "../index.js";
export declare const parsers: {
yaml: Parser;
};
export declare const printers: {
yaml: Printer;
};

View File

@@ -0,0 +1,56 @@
{
"name": "agentkeepalive",
"version": "4.6.0",
"description": "Missing keepalive http.Agent",
"main": "index.js",
"browser": "browser.js",
"files": [
"index.js",
"index.d.ts",
"browser.js",
"lib"
],
"scripts": {
"contributor": "git-contributor",
"test": "npm run lint && egg-bin test --full-trace",
"test-local": "egg-bin test --full-trace",
"cov": "cross-env NODE_DEBUG=agentkeepalive egg-bin cov --full-trace",
"ci": "npm run lint && npm run cov",
"lint": "eslint lib test index.js"
},
"repository": {
"type": "git",
"url": "git://github.com/node-modules/agentkeepalive.git"
},
"bugs": {
"url": "https://github.com/node-modules/agentkeepalive/issues"
},
"keywords": [
"http",
"https",
"agent",
"keepalive",
"agentkeepalive",
"HttpAgent",
"HttpsAgent"
],
"dependencies": {
"humanize-ms": "^1.2.1"
},
"devDependencies": {
"coffee": "^5.3.0",
"cross-env": "^6.0.3",
"egg-bin": "^4.9.0",
"eslint": "^5.7.0",
"eslint-config-egg": "^7.1.0",
"git-contributor": "^2.0.0",
"mm": "^2.4.1",
"pedding": "^1.1.0",
"typescript": "^3.8.3"
},
"engines": {
"node": ">= 8.0.0"
},
"author": "fengmk2 <fengmk2@gmail.com> (https://github.com/fengmk2)",
"license": "MIT"
}

View File

@@ -0,0 +1,12 @@
'use strict'
Object.freeze(console)
const test = require('tape')
const pino = require('../browser')
test('silent level', ({ end, fail, pass }) => {
pino({
level: 'silent',
browser: { }
})
end()
})

View File

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

View File

@@ -0,0 +1,13 @@
"use strict";
function _initializer_define_property(target, property, descriptor, context) {
if (!descriptor) return;
Object.defineProperty(target, property, {
enumerable: descriptor.enumerable,
configurable: descriptor.configurable,
writable: descriptor.writable,
value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
});
}
exports._ = _initializer_define_property;

View File

@@ -0,0 +1,28 @@
const CoverageProviderMap = {
v8: "@vitest/coverage-v8",
istanbul: "@vitest/coverage-istanbul"
};
async function resolveCoverageProviderModule(options, loader) {
if (!options?.enabled || !options.provider) return null;
const provider = options.provider;
if (provider === "v8" || provider === "istanbul") {
let builtInModule = CoverageProviderMap[provider];
if (provider === "v8" && loader.isBrowser) builtInModule += "/browser";
const { default: coverageModule } = loader.isBrowser ? await loader.import(builtInModule) : await import(
/* @vite-ignore */
builtInModule
);
if (!coverageModule) throw new Error(`Failed to load ${CoverageProviderMap[provider]}. Default export is missing.`);
return coverageModule;
}
let customProviderModule;
try {
customProviderModule = await loader.import(options.customProviderModule);
} catch (error) {
throw new Error(`Failed to load custom CoverageProviderModule from ${options.customProviderModule}`, { cause: error });
}
if (customProviderModule.default == null) throw new Error(`Custom CoverageProviderModule loaded from ${options.customProviderModule} was not the default export`);
return customProviderModule.default;
}
export { CoverageProviderMap as C, resolveCoverageProviderModule as r };

View File

@@ -0,0 +1,13 @@
'use strict'
const Range = require('../classes/range')
const validRange = (range, options) => {
try {
// Return '*' instead of '' so that truthiness works.
// This will throw if it's invalid anyway
return new Range(range, options).range || '*'
} catch (er) {
return null
}
}
module.exports = validRange

View File

@@ -0,0 +1,444 @@
/* -*- Mode: js; js-indent-level: 2; -*- */
/*
* Copyright 2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE or:
* http://opensource.org/licenses/BSD-3-Clause
*/
var base64VLQ = require('./base64-vlq');
var util = require('./util');
var ArraySet = require('./array-set').ArraySet;
var MappingList = require('./mapping-list').MappingList;
/**
* An instance of the SourceMapGenerator represents a source map which is
* being built incrementally. You may pass an object with the following
* properties:
*
* - file: The filename of the generated source.
* - sourceRoot: A root for all relative URLs in this source map.
*/
function SourceMapGenerator(aArgs) {
if (!aArgs) {
aArgs = {};
}
this._file = util.getArg(aArgs, 'file', null);
this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
this._ignoreInvalidMapping = util.getArg(aArgs, 'ignoreInvalidMapping', false);
this._sources = new ArraySet();
this._names = new ArraySet();
this._mappings = new MappingList();
this._sourcesContents = null;
}
SourceMapGenerator.prototype._version = 3;
/**
* Creates a new SourceMapGenerator based on a SourceMapConsumer
*
* @param aSourceMapConsumer The SourceMap.
*/
SourceMapGenerator.fromSourceMap =
function SourceMapGenerator_fromSourceMap(aSourceMapConsumer, generatorOps) {
var sourceRoot = aSourceMapConsumer.sourceRoot;
var generator = new SourceMapGenerator(Object.assign(generatorOps || {}, {
file: aSourceMapConsumer.file,
sourceRoot: sourceRoot
}));
aSourceMapConsumer.eachMapping(function (mapping) {
var newMapping = {
generated: {
line: mapping.generatedLine,
column: mapping.generatedColumn
}
};
if (mapping.source != null) {
newMapping.source = mapping.source;
if (sourceRoot != null) {
newMapping.source = util.relative(sourceRoot, newMapping.source);
}
newMapping.original = {
line: mapping.originalLine,
column: mapping.originalColumn
};
if (mapping.name != null) {
newMapping.name = mapping.name;
}
}
generator.addMapping(newMapping);
});
aSourceMapConsumer.sources.forEach(function (sourceFile) {
var sourceRelative = sourceFile;
if (sourceRoot !== null) {
sourceRelative = util.relative(sourceRoot, sourceFile);
}
if (!generator._sources.has(sourceRelative)) {
generator._sources.add(sourceRelative);
}
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
if (content != null) {
generator.setSourceContent(sourceFile, content);
}
});
return generator;
};
/**
* Add a single mapping from original source line and column to the generated
* source's line and column for this source map being created. The mapping
* object should have the following properties:
*
* - generated: An object with the generated line and column positions.
* - original: An object with the original line and column positions.
* - source: The original source file (relative to the sourceRoot).
* - name: An optional original token name for this mapping.
*/
SourceMapGenerator.prototype.addMapping =
function SourceMapGenerator_addMapping(aArgs) {
var generated = util.getArg(aArgs, 'generated');
var original = util.getArg(aArgs, 'original', null);
var source = util.getArg(aArgs, 'source', null);
var name = util.getArg(aArgs, 'name', null);
if (!this._skipValidation) {
if (this._validateMapping(generated, original, source, name) === false) {
return;
}
}
if (source != null) {
source = String(source);
if (!this._sources.has(source)) {
this._sources.add(source);
}
}
if (name != null) {
name = String(name);
if (!this._names.has(name)) {
this._names.add(name);
}
}
this._mappings.add({
generatedLine: generated.line,
generatedColumn: generated.column,
originalLine: original != null && original.line,
originalColumn: original != null && original.column,
source: source,
name: name
});
};
/**
* Set the source content for a source file.
*/
SourceMapGenerator.prototype.setSourceContent =
function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
var source = aSourceFile;
if (this._sourceRoot != null) {
source = util.relative(this._sourceRoot, source);
}
if (aSourceContent != null) {
// Add the source content to the _sourcesContents map.
// Create a new _sourcesContents map if the property is null.
if (!this._sourcesContents) {
this._sourcesContents = Object.create(null);
}
this._sourcesContents[util.toSetString(source)] = aSourceContent;
} else if (this._sourcesContents) {
// Remove the source file from the _sourcesContents map.
// If the _sourcesContents map is empty, set the property to null.
delete this._sourcesContents[util.toSetString(source)];
if (Object.keys(this._sourcesContents).length === 0) {
this._sourcesContents = null;
}
}
};
/**
* Applies the mappings of a sub-source-map for a specific source file to the
* source map being generated. Each mapping to the supplied source file is
* rewritten using the supplied source map. Note: The resolution for the
* resulting mappings is the minimium of this map and the supplied map.
*
* @param aSourceMapConsumer The source map to be applied.
* @param aSourceFile Optional. The filename of the source file.
* If omitted, SourceMapConsumer's file property will be used.
* @param aSourceMapPath Optional. The dirname of the path to the source map
* to be applied. If relative, it is relative to the SourceMapConsumer.
* This parameter is needed when the two source maps aren't in the same
* directory, and the source map to be applied contains relative source
* paths. If so, those relative source paths need to be rewritten
* relative to the SourceMapGenerator.
*/
SourceMapGenerator.prototype.applySourceMap =
function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
var sourceFile = aSourceFile;
// If aSourceFile is omitted, we will use the file property of the SourceMap
if (aSourceFile == null) {
if (aSourceMapConsumer.file == null) {
throw new Error(
'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
'or the source map\'s "file" property. Both were omitted.'
);
}
sourceFile = aSourceMapConsumer.file;
}
var sourceRoot = this._sourceRoot;
// Make "sourceFile" relative if an absolute Url is passed.
if (sourceRoot != null) {
sourceFile = util.relative(sourceRoot, sourceFile);
}
// Applying the SourceMap can add and remove items from the sources and
// the names array.
var newSources = new ArraySet();
var newNames = new ArraySet();
// Find mappings for the "sourceFile"
this._mappings.unsortedForEach(function (mapping) {
if (mapping.source === sourceFile && mapping.originalLine != null) {
// Check if it can be mapped by the source map, then update the mapping.
var original = aSourceMapConsumer.originalPositionFor({
line: mapping.originalLine,
column: mapping.originalColumn
});
if (original.source != null) {
// Copy mapping
mapping.source = original.source;
if (aSourceMapPath != null) {
mapping.source = util.join(aSourceMapPath, mapping.source)
}
if (sourceRoot != null) {
mapping.source = util.relative(sourceRoot, mapping.source);
}
mapping.originalLine = original.line;
mapping.originalColumn = original.column;
if (original.name != null) {
mapping.name = original.name;
}
}
}
var source = mapping.source;
if (source != null && !newSources.has(source)) {
newSources.add(source);
}
var name = mapping.name;
if (name != null && !newNames.has(name)) {
newNames.add(name);
}
}, this);
this._sources = newSources;
this._names = newNames;
// Copy sourcesContents of applied map.
aSourceMapConsumer.sources.forEach(function (sourceFile) {
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
if (content != null) {
if (aSourceMapPath != null) {
sourceFile = util.join(aSourceMapPath, sourceFile);
}
if (sourceRoot != null) {
sourceFile = util.relative(sourceRoot, sourceFile);
}
this.setSourceContent(sourceFile, content);
}
}, this);
};
/**
* A mapping can have one of the three levels of data:
*
* 1. Just the generated position.
* 2. The Generated position, original position, and original source.
* 3. Generated and original position, original source, as well as a name
* token.
*
* To maintain consistency, we validate that any new mapping being added falls
* in to one of these categories.
*/
SourceMapGenerator.prototype._validateMapping =
function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
aName) {
// When aOriginal is truthy but has empty values for .line and .column,
// it is most likely a programmer error. In this case we throw a very
// specific error message to try to guide them the right way.
// For example: https://github.com/Polymer/polymer-bundler/pull/519
if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
var message = 'original.line and original.column are not numbers -- you probably meant to omit ' +
'the original mapping entirely and only map the generated position. If so, pass ' +
'null for the original mapping instead of an object with empty or null values.'
if (this._ignoreInvalidMapping) {
if (typeof console !== 'undefined' && console.warn) {
console.warn(message);
}
return false;
} else {
throw new Error(message);
}
}
if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
&& aGenerated.line > 0 && aGenerated.column >= 0
&& !aOriginal && !aSource && !aName) {
// Case 1.
return;
}
else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
&& aOriginal && 'line' in aOriginal && 'column' in aOriginal
&& aGenerated.line > 0 && aGenerated.column >= 0
&& aOriginal.line > 0 && aOriginal.column >= 0
&& aSource) {
// Cases 2 and 3.
return;
}
else {
var message = 'Invalid mapping: ' + JSON.stringify({
generated: aGenerated,
source: aSource,
original: aOriginal,
name: aName
});
if (this._ignoreInvalidMapping) {
if (typeof console !== 'undefined' && console.warn) {
console.warn(message);
}
return false;
} else {
throw new Error(message)
}
}
};
/**
* Serialize the accumulated mappings in to the stream of base 64 VLQs
* specified by the source map format.
*/
SourceMapGenerator.prototype._serializeMappings =
function SourceMapGenerator_serializeMappings() {
var previousGeneratedColumn = 0;
var previousGeneratedLine = 1;
var previousOriginalColumn = 0;
var previousOriginalLine = 0;
var previousName = 0;
var previousSource = 0;
var result = '';
var next;
var mapping;
var nameIdx;
var sourceIdx;
var mappings = this._mappings.toArray();
for (var i = 0, len = mappings.length; i < len; i++) {
mapping = mappings[i];
next = ''
if (mapping.generatedLine !== previousGeneratedLine) {
previousGeneratedColumn = 0;
while (mapping.generatedLine !== previousGeneratedLine) {
next += ';';
previousGeneratedLine++;
}
}
else {
if (i > 0) {
if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
continue;
}
next += ',';
}
}
next += base64VLQ.encode(mapping.generatedColumn
- previousGeneratedColumn);
previousGeneratedColumn = mapping.generatedColumn;
if (mapping.source != null) {
sourceIdx = this._sources.indexOf(mapping.source);
next += base64VLQ.encode(sourceIdx - previousSource);
previousSource = sourceIdx;
// lines are stored 0-based in SourceMap spec version 3
next += base64VLQ.encode(mapping.originalLine - 1
- previousOriginalLine);
previousOriginalLine = mapping.originalLine - 1;
next += base64VLQ.encode(mapping.originalColumn
- previousOriginalColumn);
previousOriginalColumn = mapping.originalColumn;
if (mapping.name != null) {
nameIdx = this._names.indexOf(mapping.name);
next += base64VLQ.encode(nameIdx - previousName);
previousName = nameIdx;
}
}
result += next;
}
return result;
};
SourceMapGenerator.prototype._generateSourcesContent =
function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
return aSources.map(function (source) {
if (!this._sourcesContents) {
return null;
}
if (aSourceRoot != null) {
source = util.relative(aSourceRoot, source);
}
var key = util.toSetString(source);
return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
? this._sourcesContents[key]
: null;
}, this);
};
/**
* Externalize the source map.
*/
SourceMapGenerator.prototype.toJSON =
function SourceMapGenerator_toJSON() {
var map = {
version: this._version,
sources: this._sources.toArray(),
names: this._names.toArray(),
mappings: this._serializeMappings()
};
if (this._file != null) {
map.file = this._file;
}
if (this._sourceRoot != null) {
map.sourceRoot = this._sourceRoot;
}
if (this._sourcesContents) {
map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
}
return map;
};
/**
* Render the source map being generated to a string.
*/
SourceMapGenerator.prototype.toString =
function SourceMapGenerator_toString() {
return JSON.stringify(this.toJSON());
};
exports.SourceMapGenerator = SourceMapGenerator;

View File

@@ -0,0 +1,123 @@
'use strict'
// base-x encoding / decoding
// Copyright (c) 2018 base-x contributors
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
// Distributed under the MIT software license, see the accompanying
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
// @ts-ignore
var _Buffer = require('safe-buffer').Buffer
function base (ALPHABET) {
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
var BASE_MAP = new Uint8Array(256)
for (var j = 0; j < BASE_MAP.length; j++) {
BASE_MAP[j] = 255
}
for (var i = 0; i < ALPHABET.length; i++) {
var x = ALPHABET.charAt(i)
var xc = x.charCodeAt(0)
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
BASE_MAP[xc] = i
}
var BASE = ALPHABET.length
var LEADER = ALPHABET.charAt(0)
var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up
var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up
function encode (source) {
if (Array.isArray(source) || source instanceof Uint8Array) { source = _Buffer.from(source) }
if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') }
if (source.length === 0) { return '' }
// Skip & count leading zeroes.
var zeroes = 0
var length = 0
var pbegin = 0
var pend = source.length
while (pbegin !== pend && source[pbegin] === 0) {
pbegin++
zeroes++
}
// Allocate enough space in big-endian base58 representation.
var size = ((pend - pbegin) * iFACTOR + 1) >>> 0
var b58 = new Uint8Array(size)
// Process the bytes.
while (pbegin !== pend) {
var carry = source[pbegin]
// Apply "b58 = b58 * 256 + ch".
var i = 0
for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
carry += (256 * b58[it1]) >>> 0
b58[it1] = (carry % BASE) >>> 0
carry = (carry / BASE) >>> 0
}
if (carry !== 0) { throw new Error('Non-zero carry') }
length = i
pbegin++
}
// Skip leading zeroes in base58 result.
var it2 = size - length
while (it2 !== size && b58[it2] === 0) {
it2++
}
// Translate the result into a string.
var str = LEADER.repeat(zeroes)
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) }
return str
}
function decodeUnsafe (source) {
if (typeof source !== 'string') { throw new TypeError('Expected String') }
if (source.length === 0) { return _Buffer.alloc(0) }
var psz = 0
// Skip and count leading '1's.
var zeroes = 0
var length = 0
while (source[psz] === LEADER) {
zeroes++
psz++
}
// Allocate enough space in big-endian base256 representation.
var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up.
var b256 = new Uint8Array(size)
// Process the characters.
while (psz < source.length) {
// Find code of next character
var charCode = source.charCodeAt(psz)
// Base map can not be indexed using char code
if (charCode > 255) { return }
// Decode character
var carry = BASE_MAP[charCode]
// Invalid character
if (carry === 255) { return }
var i = 0
for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
carry += (BASE * b256[it3]) >>> 0
b256[it3] = (carry % 256) >>> 0
carry = (carry / 256) >>> 0
}
if (carry !== 0) { throw new Error('Non-zero carry') }
length = i
psz++
}
// Skip leading zeroes in b256.
var it4 = size - length
while (it4 !== size && b256[it4] === 0) {
it4++
}
var vch = _Buffer.allocUnsafe(zeroes + (size - it4))
vch.fill(0x00, 0, zeroes)
var j = zeroes
while (it4 !== size) {
vch[j++] = b256[it4++]
}
return vch
}
function decode (string) {
var buffer = decodeUnsafe(string)
if (buffer) { return buffer }
throw new Error('Non-base' + BASE + ' character')
}
return {
encode: encode,
decodeUnsafe: decodeUnsafe,
decode: decode
}
}
module.exports = base

View File

@@ -0,0 +1,4 @@
function _array_with_holes(arr) {
if (Array.isArray(arr)) return arr;
}
export { _array_with_holes as _ };

View File

@@ -0,0 +1,6 @@
export * as ASTUtils from './ast-utils';
export * as ESLintUtils from './eslint-utils';
export * as JSONSchema from './json-schema';
export * as TSESLint from './ts-eslint';
export * from './ts-estree';
export * as TSUtils from './ts-utils';

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 pino
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.

View File

@@ -0,0 +1,242 @@
/**
* @fileoverview Rule to require newlines before `return` statement
* @author Kai Cataldo
* @deprecated in ESLint v4.0.0
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../types').Rule.RuleModule} */
module.exports = {
meta: {
type: "layout",
docs: {
description: "Require an empty line before `return` statements",
recommended: false,
url: "https://eslint.org/docs/latest/rules/newline-before-return",
},
fixable: "whitespace",
schema: [],
messages: {
expected: "Expected newline before return statement.",
},
deprecated: {
message: "The rule was replaced with a more general rule.",
url: "https://eslint.org/blog/2017/06/eslint-v4.0.0-released/",
deprecatedSince: "4.0.0",
availableUntil: "11.0.0",
replacedBy: [
{
message: "The new rule moved to a plugin.",
url: "https://eslint.org/docs/latest/rules/padding-line-between-statements#examples",
plugin: {
name: "@stylistic/eslint-plugin",
url: "https://eslint.style",
},
rule: {
name: "padding-line-between-statements",
url: "https://eslint.style/rules/padding-line-between-statements",
},
},
],
},
},
create(context) {
const sourceCode = context.sourceCode;
//--------------------------------------------------------------------------
// Helpers
//--------------------------------------------------------------------------
/**
* Tests whether node is preceded by supplied tokens
* @param {ASTNode} node node to check
* @param {Array} testTokens array of tokens to test against
* @returns {boolean} Whether or not the node is preceded by one of the supplied tokens
* @private
*/
function isPrecededByTokens(node, testTokens) {
const tokenBefore = sourceCode.getTokenBefore(node);
return testTokens.includes(tokenBefore.value);
}
/**
* Checks whether node is the first node after statement or in block
* @param {ASTNode} node node to check
* @returns {boolean} Whether or not the node is the first node after statement or in block
* @private
*/
function isFirstNode(node) {
const parentType = node.parent.type;
if (node.parent.body) {
return Array.isArray(node.parent.body)
? node.parent.body[0] === node
: node.parent.body === node;
}
if (parentType === "IfStatement") {
return isPrecededByTokens(node, ["else", ")"]);
}
if (parentType === "DoWhileStatement") {
return isPrecededByTokens(node, ["do"]);
}
if (parentType === "SwitchCase") {
return isPrecededByTokens(node, [":"]);
}
return isPrecededByTokens(node, [")"]);
}
/**
* Returns the number of lines of comments that precede the node
* @param {ASTNode} node node to check for overlapping comments
* @param {number} lineNumTokenBefore line number of previous token, to check for overlapping comments
* @returns {number} Number of lines of comments that precede the node
* @private
*/
function calcCommentLines(node, lineNumTokenBefore) {
const comments = sourceCode.getCommentsBefore(node);
let numLinesComments = 0;
if (!comments.length) {
return numLinesComments;
}
comments.forEach(comment => {
numLinesComments++;
if (comment.type === "Block") {
numLinesComments +=
comment.loc.end.line - comment.loc.start.line;
}
// avoid counting lines with inline comments twice
if (comment.loc.start.line === lineNumTokenBefore) {
numLinesComments--;
}
if (comment.loc.end.line === node.loc.start.line) {
numLinesComments--;
}
});
return numLinesComments;
}
/**
* Returns the line number of the token before the node that is passed in as an argument
* @param {ASTNode} node The node to use as the start of the calculation
* @returns {number} Line number of the token before `node`
* @private
*/
function getLineNumberOfTokenBefore(node) {
const tokenBefore = sourceCode.getTokenBefore(node);
let lineNumTokenBefore;
/**
* Global return (at the beginning of a script) is a special case.
* If there is no token before `return`, then we expect no line
* break before the return. Comments are allowed to occupy lines
* before the global return, just no blank lines.
* Setting lineNumTokenBefore to zero in that case results in the
* desired behavior.
*/
if (tokenBefore) {
lineNumTokenBefore = tokenBefore.loc.end.line;
} else {
lineNumTokenBefore = 0; // global return at beginning of script
}
return lineNumTokenBefore;
}
/**
* Checks whether node is preceded by a newline
* @param {ASTNode} node node to check
* @returns {boolean} Whether or not the node is preceded by a newline
* @private
*/
function hasNewlineBefore(node) {
const lineNumNode = node.loc.start.line;
const lineNumTokenBefore = getLineNumberOfTokenBefore(node);
const commentLines = calcCommentLines(node, lineNumTokenBefore);
return lineNumNode - lineNumTokenBefore - commentLines > 1;
}
/**
* Checks whether it is safe to apply a fix to a given return statement.
*
* The fix is not considered safe if the given return statement has leading comments,
* as we cannot safely determine if the newline should be added before or after the comments.
* For more information, see: https://github.com/eslint/eslint/issues/5958#issuecomment-222767211
* @param {ASTNode} node The return statement node to check.
* @returns {boolean} `true` if it can fix the node.
* @private
*/
function canFix(node) {
const leadingComments = sourceCode.getCommentsBefore(node);
const lastLeadingComment = leadingComments.at(-1);
const tokenBefore = sourceCode.getTokenBefore(node);
if (leadingComments.length === 0) {
return true;
}
/*
* if the last leading comment ends in the same line as the previous token and
* does not share a line with the `return` node, we can consider it safe to fix.
* Example:
* function a() {
* var b; //comment
* return;
* }
*/
if (
lastLeadingComment.loc.end.line === tokenBefore.loc.end.line &&
lastLeadingComment.loc.end.line !== node.loc.start.line
) {
return true;
}
return false;
}
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
return {
ReturnStatement(node) {
if (!isFirstNode(node) && !hasNewlineBefore(node)) {
context.report({
node,
messageId: "expected",
fix(fixer) {
if (canFix(node)) {
const tokenBefore =
sourceCode.getTokenBefore(node);
const newlines =
node.loc.start.line ===
tokenBefore.loc.end.line
? "\n\n"
: "\n";
return fixer.insertTextBefore(node, newlines);
}
return null;
},
});
}
},
};
},
};

View File

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

View File

@@ -0,0 +1,8 @@
import { _ as _async_generator } from "./_async_generator.js";
function _wrap_async_generator(fn) {
return function() {
return new _async_generator(fn.apply(this, arguments));
};
}
export { _wrap_async_generator as _ };