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,96 @@
"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;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createIsolatedProgram = createIsolatedProgram;
const debug_1 = __importDefault(require("debug"));
const ts = __importStar(require("typescript"));
const getScriptKind_1 = require("./getScriptKind");
const shared_1 = require("./shared");
const log = (0, debug_1.default)('typescript-eslint:typescript-estree:create-program:createIsolatedProgram');
/**
* @returns Returns a new source file and program corresponding to the linted code
*/
function createIsolatedProgram(parseSettings) {
log('Getting isolated program in %s mode for: %s', parseSettings.jsx ? 'TSX' : 'TS', parseSettings.filePath);
const compilerHost = {
fileExists() {
return true;
},
getCanonicalFileName() {
return parseSettings.filePath;
},
getCurrentDirectory() {
return '';
},
getDefaultLibFileName() {
return 'lib.d.ts';
},
getDirectories() {
return [];
},
// TODO: Support Windows CRLF
getNewLine() {
return '\n';
},
getSourceFile(filename) {
return ts.createSourceFile(filename, parseSettings.codeFullText, ts.ScriptTarget.Latest,
/* setParentNodes */ true, (0, getScriptKind_1.getScriptKind)(parseSettings.filePath, parseSettings.jsx));
},
readFile() {
return undefined;
},
useCaseSensitiveFileNames() {
return true;
},
writeFile() {
return null;
},
};
const program = ts.createProgram([parseSettings.filePath], {
jsDocParsingMode: parseSettings.jsDocParsingMode,
jsx: parseSettings.jsx ? ts.JsxEmit.Preserve : undefined,
noResolve: true,
target: ts.ScriptTarget.Latest,
...(0, shared_1.createDefaultCompilerOptionsFromExtra)(parseSettings),
}, compilerHost);
const ast = program.getSourceFile(parseSettings.filePath);
if (!ast) {
throw new Error('Expected an ast to be returned for the single-file isolated program.');
}
return { ast, program };
}

View File

@@ -0,0 +1,153 @@
import type * as errors from "./errors.js";
import type * as schemas from "./schemas.js";
import type { Class } from "./util.js";
////////////////////////////// CONSTRUCTORS ///////////////////////////////////////
type ZodTrait = { _zod: { def: any; [k: string]: any } };
export interface $constructor<T extends ZodTrait, D = T["_zod"]["def"]> {
new (def: D): T;
init(inst: T, def: D): asserts inst is T;
}
/** A special constant with type `never` */
export const NEVER: never = /*@__PURE__*/ Object.freeze({
status: "aborted",
}) as never;
export /*@__NO_SIDE_EFFECTS__*/ function $constructor<T extends ZodTrait, D = T["_zod"]["def"]>(
name: string,
initializer: (inst: T, def: D) => void,
params?: { Parent?: typeof Class }
): $constructor<T, D> {
function init(inst: T, def: D) {
if (!inst._zod) {
Object.defineProperty(inst, "_zod", {
value: {
def,
constr: _,
traits: new Set(),
},
enumerable: false,
});
}
if (inst._zod.traits.has(name)) {
return;
}
inst._zod.traits.add(name);
initializer(inst, def);
// support prototype modifications
const proto = _.prototype;
const keys = Object.keys(proto);
for (let i = 0; i < keys.length; i++) {
const k = keys[i]!;
if (!(k in inst)) {
(inst as any)[k] = proto[k].bind(inst);
}
}
}
// doesn't work if Parent has a constructor with arguments
const Parent = params?.Parent ?? Object;
class Definition extends Parent {}
Object.defineProperty(Definition, "name", { value: name });
function _(this: any, def: D) {
const inst = params?.Parent ? new Definition() : this;
init(inst, def);
inst._zod.deferred ??= [];
for (const fn of inst._zod.deferred) {
fn();
}
return inst;
}
Object.defineProperty(_, "init", { value: init });
Object.defineProperty(_, Symbol.hasInstance, {
value: (inst: any) => {
if (params?.Parent && inst instanceof params.Parent) return true;
return inst?._zod?.traits?.has(name);
},
});
Object.defineProperty(_, "name", { value: name });
return _ as any;
}
////////////////////////////// UTILITIES ///////////////////////////////////////
export const $brand: unique symbol = Symbol("zod_brand");
export type $brand<T extends string | number | symbol = string | number | symbol> = {
[$brand]: { [k in T]: true };
};
export type $ZodBranded<
T extends schemas.SomeType,
Brand extends string | number | symbol,
Dir extends "in" | "out" | "inout" = "out",
> = T &
(Dir extends "inout"
? { _zod: { input: input<T> & $brand<Brand>; output: output<T> & $brand<Brand> } }
: Dir extends "in"
? { _zod: { input: input<T> & $brand<Brand> } }
: { _zod: { output: output<T> & $brand<Brand> } });
export type $ZodNarrow<T extends schemas.SomeType, Out> = T & { _zod: { output: Out } };
export class $ZodAsyncError extends Error {
constructor() {
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
}
}
export class $ZodEncodeError extends Error {
constructor(name: string) {
super(`Encountered unidirectional transform during encode: ${name}`);
this.name = "ZodEncodeError";
}
}
//////////////////////////// TYPE HELPERS ///////////////////////////////////
// export type input<T extends schemas.$ZodType> = T["_zod"]["input"];
// export type output<T extends schemas.$ZodType> = T["_zod"]["output"];
// export type input<T extends schemas.$ZodType> = T["_zod"]["input"];
// export type output<T extends schemas.$ZodType> = T["_zod"]["output"];
export type input<T> = T extends { _zod: { input: any } } ? T["_zod"]["input"] : unknown;
export type output<T> = T extends { _zod: { output: any } } ? T["_zod"]["output"] : unknown;
export type { output as infer };
////////////////////////////// CONFIG ///////////////////////////////////////
export interface $ZodConfig {
/** Custom error map. Overrides `config().localeError`. */
customError?: errors.$ZodErrorMap | undefined;
/** Localized error map. Lowest priority. */
localeError?: errors.$ZodErrorMap | undefined;
/** Disable JIT schema compilation. Useful in environments that disallow `eval`. */
jitless?: boolean | undefined;
}
interface GlobalThisWithConfig {
/**
* The globalConfig instance shared across both CommonJS and ESM builds.
* Attached to `globalThis` (mirroring `__zod_globalRegistry`) so that a
* single config object is used regardless of how Zod is loaded — CJS,
* ESM, multiple bundles in a monorepo, etc. This means `z.config(...)`
* applied against any one instance is observed by all of them, and
* pre-populating it before Zod loads (e.g. `globalThis.__zod_globalConfig
* = { jitless: true }` in an inline script) takes effect immediately on
* import.
*/
__zod_globalConfig?: $ZodConfig;
}
(globalThis as GlobalThisWithConfig).__zod_globalConfig ??= {};
export const globalConfig: $ZodConfig = (globalThis as GlobalThisWithConfig).__zod_globalConfig!;
export function config(newConfig?: Partial<$ZodConfig>): $ZodConfig {
if (newConfig) Object.assign(globalConfig, newConfig);
return globalConfig;
}

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VariableDefinition = void 0;
const DefinitionBase_1 = require("./DefinitionBase");
const DefinitionType_1 = require("./DefinitionType");
class VariableDefinition extends DefinitionBase_1.DefinitionBase {
isTypeDefinition = false;
isVariableDefinition = true;
constructor(name, node, decl) {
super(DefinitionType_1.DefinitionType.Variable, name, node, decl);
}
}
exports.VariableDefinition = VariableDefinition;

View File

@@ -0,0 +1,59 @@
"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.isNotSemicolonToken = exports.isSemicolonToken = exports.isNotOpeningParenToken = exports.isOpeningParenToken = exports.isNotOpeningBracketToken = exports.isOpeningBracketToken = exports.isNotOpeningBraceToken = exports.isOpeningBraceToken = exports.isNotCommentToken = exports.isCommentToken = exports.isNotCommaToken = exports.isCommaToken = exports.isNotColonToken = exports.isColonToken = exports.isNotClosingParenToken = exports.isClosingParenToken = exports.isNotClosingBracketToken = exports.isClosingBracketToken = exports.isNotClosingBraceToken = exports.isClosingBraceToken = exports.isNotArrowToken = exports.isArrowToken = void 0;
const eslintUtils = __importStar(require("@eslint-community/eslint-utils"));
exports.isArrowToken = eslintUtils.isArrowToken;
exports.isNotArrowToken = eslintUtils.isNotArrowToken;
exports.isClosingBraceToken = eslintUtils.isClosingBraceToken;
exports.isNotClosingBraceToken = eslintUtils.isNotClosingBraceToken;
exports.isClosingBracketToken = eslintUtils.isClosingBracketToken;
exports.isNotClosingBracketToken = eslintUtils.isNotClosingBracketToken;
exports.isClosingParenToken = eslintUtils.isClosingParenToken;
exports.isNotClosingParenToken = eslintUtils.isNotClosingParenToken;
exports.isColonToken = eslintUtils.isColonToken;
exports.isNotColonToken = eslintUtils.isNotColonToken;
exports.isCommaToken = eslintUtils.isCommaToken;
exports.isNotCommaToken = eslintUtils.isNotCommaToken;
exports.isCommentToken = eslintUtils.isCommentToken;
exports.isNotCommentToken = eslintUtils.isNotCommentToken;
exports.isOpeningBraceToken = eslintUtils.isOpeningBraceToken;
exports.isNotOpeningBraceToken = eslintUtils.isNotOpeningBraceToken;
exports.isOpeningBracketToken = eslintUtils.isOpeningBracketToken;
exports.isNotOpeningBracketToken = eslintUtils.isNotOpeningBracketToken;
exports.isOpeningParenToken = eslintUtils.isOpeningParenToken;
exports.isNotOpeningParenToken = eslintUtils.isNotOpeningParenToken;
exports.isSemicolonToken = eslintUtils.isSemicolonToken;
exports.isNotSemicolonToken = eslintUtils.isNotSemicolonToken;

View File

@@ -0,0 +1,137 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;
const util = __importStar(require("../core/util.cjs"));
const error = () => {
const Sizable = {
string: { unit: "ตัวอักษร", verb: "ควรมี" },
file: { unit: "ไบต์", verb: "ควรมี" },
array: { unit: "รายการ", verb: "ควรมี" },
set: { unit: "รายการ", verb: "ควรมี" },
};
function getSizing(origin) {
return Sizable[origin] ?? null;
}
const FormatDictionary = {
regex: "ข้อมูลที่ป้อน",
email: "ที่อยู่อีเมล",
url: "URL",
emoji: "อิโมจิ",
uuid: "UUID",
uuidv4: "UUIDv4",
uuidv6: "UUIDv6",
nanoid: "nanoid",
guid: "GUID",
cuid: "cuid",
cuid2: "cuid2",
ulid: "ULID",
xid: "XID",
ksuid: "KSUID",
datetime: "วันที่เวลาแบบ ISO",
date: "วันที่แบบ ISO",
time: "เวลาแบบ ISO",
duration: "ช่วงเวลาแบบ ISO",
ipv4: "ที่อยู่ IPv4",
ipv6: "ที่อยู่ IPv6",
cidrv4: "ช่วง IP แบบ IPv4",
cidrv6: "ช่วง IP แบบ IPv6",
base64: "ข้อความแบบ Base64",
base64url: "ข้อความแบบ Base64 สำหรับ URL",
json_string: "ข้อความแบบ JSON",
e164: "เบอร์โทรศัพท์ระหว่างประเทศ (E.164)",
jwt: "โทเคน JWT",
template_literal: "ข้อมูลที่ป้อน",
};
const TypeDictionary = {
nan: "NaN",
number: "ตัวเลข",
array: "อาร์เรย์ (Array)",
null: "ไม่มีค่า (null)",
};
return (issue) => {
switch (issue.code) {
case "invalid_type": {
const expected = TypeDictionary[issue.expected] ?? issue.expected;
const receivedType = util.parsedType(issue.input);
const received = TypeDictionary[receivedType] ?? receivedType;
if (/^[A-Z]/.test(issue.expected)) {
return `ประเภทข้อมูลไม่ถูกต้อง: ควรเป็น instanceof ${issue.expected} แต่ได้รับ ${received}`;
}
return `ประเภทข้อมูลไม่ถูกต้อง: ควรเป็น ${expected} แต่ได้รับ ${received}`;
}
case "invalid_value":
if (issue.values.length === 1)
return `ค่าไม่ถูกต้อง: ควรเป็น ${util.stringifyPrimitive(issue.values[0])}`;
return `ตัวเลือกไม่ถูกต้อง: ควรเป็นหนึ่งใน ${util.joinValues(issue.values, "|")}`;
case "too_big": {
const adj = issue.inclusive ? "ไม่เกิน" : "น้อยกว่า";
const sizing = getSizing(issue.origin);
if (sizing)
return `เกินกำหนด: ${issue.origin ?? "ค่า"} ควรมี${adj} ${issue.maximum.toString()} ${sizing.unit ?? "รายการ"}`;
return `เกินกำหนด: ${issue.origin ?? "ค่า"} ควรมี${adj} ${issue.maximum.toString()}`;
}
case "too_small": {
const adj = issue.inclusive ? "อย่างน้อย" : "มากกว่า";
const sizing = getSizing(issue.origin);
if (sizing) {
return `น้อยกว่ากำหนด: ${issue.origin} ควรมี${adj} ${issue.minimum.toString()} ${sizing.unit}`;
}
return `น้อยกว่ากำหนด: ${issue.origin} ควรมี${adj} ${issue.minimum.toString()}`;
}
case "invalid_format": {
const _issue = issue;
if (_issue.format === "starts_with") {
return `รูปแบบไม่ถูกต้อง: ข้อความต้องขึ้นต้นด้วย "${_issue.prefix}"`;
}
if (_issue.format === "ends_with")
return `รูปแบบไม่ถูกต้อง: ข้อความต้องลงท้ายด้วย "${_issue.suffix}"`;
if (_issue.format === "includes")
return `รูปแบบไม่ถูกต้อง: ข้อความต้องมี "${_issue.includes}" อยู่ในข้อความ`;
if (_issue.format === "regex")
return `รูปแบบไม่ถูกต้อง: ต้องตรงกับรูปแบบที่กำหนด ${_issue.pattern}`;
return `รูปแบบไม่ถูกต้อง: ${FormatDictionary[_issue.format] ?? issue.format}`;
}
case "not_multiple_of":
return `ตัวเลขไม่ถูกต้อง: ต้องเป็นจำนวนที่หารด้วย ${issue.divisor} ได้ลงตัว`;
case "unrecognized_keys":
return `พบคีย์ที่ไม่รู้จัก: ${util.joinValues(issue.keys, ", ")}`;
case "invalid_key":
return `คีย์ไม่ถูกต้องใน ${issue.origin}`;
case "invalid_union":
return "ข้อมูลไม่ถูกต้อง: ไม่ตรงกับรูปแบบยูเนียนที่กำหนดไว้";
case "invalid_element":
return `ข้อมูลไม่ถูกต้องใน ${issue.origin}`;
default:
return `ข้อมูลไม่ถูกต้อง`;
}
};
};
function default_1() {
return {
localeError: error(),
};
}
module.exports = exports.default;

View File

@@ -0,0 +1 @@
export let nanoid=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce(((t,e)=>t+=(e&=63)<36?e.toString(36):e<62?(e-26).toString(36).toUpperCase():e<63?"_":"-"),"");

View File

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

View File

@@ -0,0 +1,86 @@
import Container, { ContainerProps } from './container.js'
import Document from './document.js'
import { ProcessOptions } from './postcss.js'
import Result from './result.js'
declare namespace Root {
export interface RootRaws extends Record<string, any> {
/**
* The space symbols after the last child to the end of file.
*/
after?: string
/**
* Non-CSS code after `Root`, when `Root` is inside `Document`.
*
* **Experimental:** some aspects of this node could change within minor
* or patch version releases.
*/
codeAfter?: string
/**
* Non-CSS code before `Root`, when `Root` is inside `Document`.
*
* **Experimental:** some aspects of this node could change within minor
* or patch version releases.
*/
codeBefore?: string
/**
* Is the last child has an (optional) semicolon.
*/
semicolon?: boolean
}
export interface RootProps extends ContainerProps {
/**
* Information used to generate byte-to-byte equal node string
* as it was in the origin input.
* */
raws?: RootRaws
}
export { Root_ as default }
}
/**
* Represents a CSS file and contains all its parsed nodes.
*
* ```js
* const root = postcss.parse('a{color:black} b{z-index:2}')
* root.type //=> 'root'
* root.nodes.length //=> 2
* ```
*/
declare class Root_ extends Container {
nodes: NonNullable<Container['nodes']>
parent: Document | undefined
raws: Root.RootRaws
type: 'root'
constructor(defaults?: Root.RootProps)
assign(overrides: object | Root.RootProps): this
clone(overrides?: Partial<Root.RootProps>): this
cloneAfter(overrides?: Partial<Root.RootProps>): this
cloneBefore(overrides?: Partial<Root.RootProps>): this
/**
* Returns a `Result` instance representing the roots CSS.
*
* ```js
* const root1 = postcss.parse(css1, { from: 'a.css' })
* const root2 = postcss.parse(css2, { from: 'b.css' })
* root1.append(root2)
* const result = root1.toResult({ to: 'all.css', map: true })
* ```
*
* @param options Options.
* @return Result with current roots CSS.
*/
toResult(options?: ProcessOptions): Result
}
declare class Root extends Root_ {}
export = Root

View File

@@ -0,0 +1,174 @@
import { a as namespaces, i as enabled, n as disable, o as humanize, r as enable$1, s as selectColor, t as createDebug$1 } from "./core.js";
import { isatty } from "node:tty";
import { formatWithOptions, inspect } from "node:util";
//#region src/node.ts
let env = {};
try {
process.env.DEBUG;
env = process.env;
} catch (_unused) {}
const colors = process.stderr.getColorDepth && process.stderr.getColorDepth(env) > 2 ? [
20,
21,
26,
27,
32,
33,
38,
39,
40,
41,
42,
43,
44,
45,
56,
57,
62,
63,
68,
69,
74,
75,
76,
77,
78,
79,
80,
81,
92,
93,
98,
99,
112,
113,
128,
129,
134,
135,
148,
149,
160,
161,
162,
163,
164,
165,
166,
167,
168,
169,
170,
171,
172,
173,
178,
179,
184,
185,
196,
197,
198,
199,
200,
201,
202,
203,
204,
205,
206,
207,
208,
209,
214,
215,
220,
221
] : [
6,
2,
3,
4,
5,
1
];
const inspectOpts = Object.keys(env).filter((key) => /^debug_/i.test(key)).reduce((obj, key) => {
const prop = key.slice(6).toLowerCase().replace(/_([a-z])/g, (_, k) => k.toUpperCase());
let value = env[key];
const lowerCase = typeof value === "string" && value.toLowerCase();
if (value === "null") value = null;
else if (lowerCase === "yes" || lowerCase === "on" || lowerCase === "true" || lowerCase === "enabled") value = true;
else if (lowerCase === "no" || lowerCase === "off" || lowerCase === "false" || lowerCase === "disabled") value = false;
else value = Number(value);
obj[prop] = value;
return obj;
}, Object.create(null));
/**
* Is stdout a TTY? Colored output is enabled when `true`.
*/
function useColors() {
return "colors" in inspectOpts ? Boolean(inspectOpts.colors) : isatty(process.stderr.fd);
}
function getDate() {
if (inspectOpts.hideDate) return "";
return `${(/* @__PURE__ */ new Date()).toISOString()} `;
}
/**
* Adds ANSI color escape codes if enabled.
*/
function formatArgs(diff, args) {
const { namespace: name, useColors } = this;
if (useColors) {
const c = this.color;
const colorCode = `\u001B[3${c < 8 ? c : `8;5;${c}`}`;
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
args[0] = prefix + args[0].split("\n").join(`\n${prefix}`);
args.push(`${colorCode}m+${this.humanize(diff)}\u001B[0m`);
} else args[0] = `${getDate()}${name} ${args[0]}`;
}
function log(...args) {
process.stderr.write(`${formatWithOptions(this.inspectOpts, ...args)}\n`);
}
const defaultOptions = {
useColors: useColors(),
formatArgs,
formatters: {
/**
* Map %o to `util.inspect()`, all on a single line.
*/
o(v) {
this.inspectOpts.colors = this.useColors;
return inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
},
/**
* Map %O to `util.inspect()`, allowing multiple lines if needed.
*/
O(v) {
this.inspectOpts.colors = this.useColors;
return inspect(v, this.inspectOpts);
}
},
inspectOpts,
log,
humanize
};
function createDebug(namespace, options) {
var _ref;
const color = (_ref = options && options.color) !== null && _ref !== void 0 ? _ref : selectColor(colors, namespace);
return createDebug$1(namespace, Object.assign(defaultOptions, { color }, options));
}
function save(namespaces) {
if (namespaces) env.DEBUG = namespaces;
else delete env.DEBUG;
}
/**
* Enables a debug mode by namespaces. This can include modes
* separated by a colon and wildcards.
*/
function enable(namespaces) {
save(namespaces);
enable$1(namespaces);
}
enable$1(env.DEBUG || "");
//#endregion
export { createDebug, disable, enable, enabled, namespaces };

View File

@@ -0,0 +1,156 @@
/**
* @fileoverview Disallow Labeled Statements
* @author Nicholas C. Zakas
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const astUtils = require("./utils/ast-utils");
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../types').Rule.RuleModule} */
module.exports = {
meta: {
type: "suggestion",
defaultOptions: [
{
allowLoop: false,
allowSwitch: false,
},
],
docs: {
description: "Disallow labeled statements",
recommended: false,
frozen: true,
url: "https://eslint.org/docs/latest/rules/no-labels",
},
schema: [
{
type: "object",
properties: {
allowLoop: {
type: "boolean",
},
allowSwitch: {
type: "boolean",
},
},
additionalProperties: false,
},
],
messages: {
unexpectedLabel: "Unexpected labeled statement.",
unexpectedLabelInBreak: "Unexpected label in break statement.",
unexpectedLabelInContinue:
"Unexpected label in continue statement.",
},
},
create(context) {
const [{ allowLoop, allowSwitch }] = context.options;
let scopeInfo = null;
/**
* Gets the kind of a given node.
* @param {ASTNode} node A node to get.
* @returns {string} The kind of the node.
*/
function getBodyKind(node) {
if (astUtils.isLoop(node)) {
return "loop";
}
if (node.type === "SwitchStatement") {
return "switch";
}
return "other";
}
/**
* Checks whether the label of a given kind is allowed or not.
* @param {string} kind A kind to check.
* @returns {boolean} `true` if the kind is allowed.
*/
function isAllowed(kind) {
switch (kind) {
case "loop":
return allowLoop;
case "switch":
return allowSwitch;
default:
return false;
}
}
/**
* Checks whether a given name is a label of a loop or not.
* @param {string} label A name of a label to check.
* @returns {boolean} `true` if the name is a label of a loop.
*/
function getKind(label) {
let info = scopeInfo;
while (info) {
if (info.label === label) {
return info.kind;
}
info = info.upper;
}
/* c8 ignore next */
return "other";
}
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
return {
LabeledStatement(node) {
scopeInfo = {
label: node.label.name,
kind: getBodyKind(node.body),
upper: scopeInfo,
};
},
"LabeledStatement:exit"(node) {
if (!isAllowed(scopeInfo.kind)) {
context.report({
node,
messageId: "unexpectedLabel",
});
}
scopeInfo = scopeInfo.upper;
},
BreakStatement(node) {
if (node.label && !isAllowed(getKind(node.label.name))) {
context.report({
node,
messageId: "unexpectedLabelInBreak",
});
}
},
ContinueStatement(node) {
if (node.label && !isAllowed(getKind(node.label.name))) {
context.report({
node,
messageId: "unexpectedLabelInContinue",
});
}
},
};
},
};

View File

@@ -0,0 +1,85 @@
'use strict';
const {none, final, isFinal, getFinalValue, many, isMany, getManyValues} = require('../defs');
const next = async (value, fns, index, push) => {
for (let i = index; i <= fns.length; ++i) {
if (value && typeof value.then == 'function') {
// thenable
value = await value;
}
if (value === none) break;
if (isFinal(value)) {
const val = getFinalValue(value);
val !== none && push(val);
break;
}
if (isMany(value)) {
const values = getManyValues(value);
if (i == fns.length) {
values.forEach(val => push(val));
} else {
for (let j = 0; j < values.length; ++j) {
await next(values[j], fns, i, push);
}
}
break;
}
if (value && typeof value.next == 'function') {
// generator
for (;;) {
let data = value.next();
if (data && typeof data.then == 'function') {
data = await data;
}
if (data.done) break;
if (i == fns.length) {
push(data.value);
} else {
await next(data.value, fns, i, push);
}
}
break;
}
if (i == fns.length) {
push(value);
break;
}
value = fns[i](value);
}
};
const nop = () => {};
const asFun = (...fns) => {
fns = fns.filter(fn => fn);
if (!fns.length) return nop;
if (Symbol.asyncIterator && fns[0][Symbol.asyncIterator]) {
fns[0] = fns[0][Symbol.asyncIterator];
} else if (Symbol.iterator && fns[0][Symbol.iterator]) {
fns[0] = fns[0][Symbol.iterator];
}
return async value => {
const results = [];
await next(value, fns, 0, value => results.push(value));
switch (results.length) {
case 0:
return none;
case 1:
return results[0];
}
return many(results);
};
};
asFun.next = next;
asFun.none = none;
asFun.final = final;
asFun.isFinal = isFinal;
asFun.getFinalValue = getFinalValue;
asFun.many = many;
asFun.isMany = isMany;
asFun.getManyValues = getManyValues;
module.exports = asFun;

View File

@@ -0,0 +1,4 @@
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferNonNullAssertion", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
name: string;
};
export default _default;

View File

@@ -0,0 +1,61 @@
'use strict';
var fs = require('fs')
, path = require('path')
, browserify = require('browserify')
, uglify = require('uglify-js');
var pkg = process.argv[2]
, standalone = process.argv[3]
, compress = process.argv[4];
var packageDir = path.join(__dirname, '..');
if (pkg != '.') packageDir = path.join(packageDir, 'node_modules', pkg);
var json = require(path.join(packageDir, 'package.json'));
var distDir = path.join(__dirname, '..', 'dist');
if (!fs.existsSync(distDir)) fs.mkdirSync(distDir);
var bOpts = {};
if (standalone) bOpts.standalone = standalone;
browserify(bOpts)
.require(path.join(packageDir, json.main), {expose: json.name})
.bundle(function (err, buf) {
if (err) {
console.error('browserify error:', err);
process.exit(1);
}
var outputFile = path.join(distDir, json.name);
var uglifyOpts = {
warnings: true,
compress: {},
output: {
preamble: '/* ' + json.name + ' ' + json.version + ': ' + json.description + ' */'
}
};
if (compress) {
var compressOpts = compress.split(',');
for (var i=0, il = compressOpts.length; i<il; ++i) {
var pair = compressOpts[i].split('=');
uglifyOpts.compress[pair[0]] = pair.length < 1 || pair[1] != 'false';
}
}
if (standalone) {
uglifyOpts.sourceMap = {
filename: json.name + '.min.js',
url: json.name + '.min.js.map'
};
}
var result = uglify.minify(buf.toString(), uglifyOpts);
fs.writeFileSync(outputFile + '.min.js', result.code);
if (result.map) fs.writeFileSync(outputFile + '.min.js.map', result.map);
if (standalone) fs.writeFileSync(outputFile + '.bundle.js', buf);
if (result.warnings) {
for (var j=0, jl = result.warnings.length; j<jl; ++j)
console.warn('UglifyJS warning:', result.warnings[j]);
}
});

View File

@@ -0,0 +1,156 @@
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
function normalizeWindowsPath(input = "") {
if (!input) {
return input;
}
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
}
const _UNC_REGEX = /^[/\\]{2}/;
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
const normalize = function(path) {
if (path.length === 0) {
return ".";
}
path = normalizeWindowsPath(path);
const isUNCPath = path.match(_UNC_REGEX);
const isPathAbsolute = isAbsolute(path);
const trailingSeparator = path[path.length - 1] === "/";
path = normalizeString(path, !isPathAbsolute);
if (path.length === 0) {
if (isPathAbsolute) {
return "/";
}
return trailingSeparator ? "./" : ".";
}
if (trailingSeparator) {
path += "/";
}
if (_DRIVE_LETTER_RE.test(path)) {
path += "/";
}
if (isUNCPath) {
if (!isPathAbsolute) {
return `//./${path}`;
}
return `//${path}`;
}
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
};
const join = function(...segments) {
let path = "";
for (const seg of segments) {
if (!seg) {
continue;
}
if (path.length > 0) {
const pathTrailing = path[path.length - 1] === "/";
const segLeading = seg[0] === "/";
const both = pathTrailing && segLeading;
if (both) {
path += seg.slice(1);
} else {
path += pathTrailing || segLeading ? seg : `/${seg}`;
}
} else {
path += seg;
}
}
return normalize(path);
};
function cwd() {
if (typeof process !== "undefined" && typeof process.cwd === "function") {
return process.cwd().replace(/\\/g, "/");
}
return "/";
}
const resolve = function(...arguments_) {
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
let resolvedPath = "";
let resolvedAbsolute = false;
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
const path = index >= 0 ? arguments_[index] : cwd();
if (!path || path.length === 0) {
continue;
}
resolvedPath = `${path}/${resolvedPath}`;
resolvedAbsolute = isAbsolute(path);
}
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
return `/${resolvedPath}`;
}
return resolvedPath.length > 0 ? resolvedPath : ".";
};
function normalizeString(path, allowAboveRoot) {
let res = "";
let lastSegmentLength = 0;
let lastSlash = -1;
let dots = 0;
let char = null;
for (let index = 0; index <= path.length; ++index) {
if (index < path.length) {
char = path[index];
} else if (char === "/") {
break;
} else {
char = "/";
}
if (char === "/") {
if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) {
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
if (res.length > 2) {
const lastSlashIndex = res.lastIndexOf("/");
if (lastSlashIndex === -1) {
res = "";
lastSegmentLength = 0;
} else {
res = res.slice(0, lastSlashIndex);
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
}
lastSlash = index;
dots = 0;
continue;
} else if (res.length > 0) {
res = "";
lastSegmentLength = 0;
lastSlash = index;
dots = 0;
continue;
}
}
if (allowAboveRoot) {
res += res.length > 0 ? "/.." : "..";
lastSegmentLength = 2;
}
} else {
if (res.length > 0) {
res += `/${path.slice(lastSlash + 1, index)}`;
} else {
res = path.slice(lastSlash + 1, index);
}
lastSegmentLength = index - lastSlash - 1;
}
lastSlash = index;
dots = 0;
} else if (char === "." && dots !== -1) {
++dots;
} else {
dots = -1;
}
}
return res;
}
const isAbsolute = function(p) {
return _IS_ABSOLUTE_RE.test(p);
};
const dirname = function(p) {
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
segments[0] += "/";
}
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
};
export { dirname as d, join as j, resolve as r };

View File

@@ -0,0 +1,204 @@
"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 ts = __importStar(require("typescript"));
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'promise-function-async',
meta: {
type: 'suggestion',
docs: {
description: 'Require any function or method that returns a Promise to be marked async',
requiresTypeChecking: true,
},
fixable: 'code',
messages: {
missingAsync: 'Functions that return promises must be async.',
missingAsyncHybridReturn: 'Functions that return promises must be async. Consider adding an explicit return type annotation if the function is intended to return a union of promise and non-promise types.',
},
schema: [
{
type: 'object',
additionalProperties: false,
properties: {
allowAny: {
type: 'boolean',
description: 'Whether to consider `any` and `unknown` to be Promises.',
},
allowedPromiseNames: {
type: 'array',
description: 'Any extra names of classes or interfaces to be considered Promises.',
items: {
type: 'string',
},
},
checkArrowFunctions: {
type: 'boolean',
description: 'Whether to check arrow functions.',
},
checkFunctionDeclarations: {
type: 'boolean',
description: 'Whether to check standalone function declarations.',
},
checkFunctionExpressions: {
type: 'boolean',
description: 'Whether to check inline function expressions',
},
checkMethodDeclarations: {
type: 'boolean',
description: 'Whether to check methods on classes and object literals.',
},
},
},
],
},
defaultOptions: [
{
allowAny: true,
allowedPromiseNames: [],
checkArrowFunctions: true,
checkFunctionDeclarations: true,
checkFunctionExpressions: true,
checkMethodDeclarations: true,
},
],
create(context, [{ allowAny, allowedPromiseNames, checkArrowFunctions, checkFunctionDeclarations, checkFunctionExpressions, checkMethodDeclarations, },]) {
const allAllowedPromiseNames = new Set([
'Promise',
// https://github.com/typescript-eslint/typescript-eslint/issues/5439
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
...allowedPromiseNames,
]);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();
function validateNode(node) {
if (node.parent.type === utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition) {
// Abstract method can't be async
return;
}
if ((node.parent.type === utils_1.AST_NODE_TYPES.Property ||
node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition) &&
(node.parent.kind === 'get' || node.parent.kind === 'set')) {
// Getters and setters can't be async
return;
}
const signatures = services.getTypeAtLocation(node).getCallSignatures();
if (!signatures.length) {
return;
}
const returnTypes = signatures.map(signature => checker.getReturnTypeOfSignature(signature));
if (!allowAny &&
returnTypes.some(type => (0, util_1.isTypeFlagSet)(type, ts.TypeFlags.Any | ts.TypeFlags.Unknown))) {
// Report without auto fixer because the return type is unknown
return context.report({
loc: (0, util_1.getFunctionHeadLoc)(node, context.sourceCode),
node,
messageId: 'missingAsync',
});
}
if (
// require all potential return types to be promise/any/unknown
returnTypes.every(type => (0, util_1.containsAllTypesByName)(type, true, allAllowedPromiseNames,
// If no return type is explicitly set, we check if any parts of the return type match a Promise (instead of requiring all to match).
node.returnType == null))) {
const isHybridReturnType = returnTypes.some(type => type.isUnion() &&
!type.types.every(part => (0, util_1.containsAllTypesByName)(part, true, allAllowedPromiseNames)));
context.report({
loc: (0, util_1.getFunctionHeadLoc)(node, context.sourceCode),
node,
messageId: isHybridReturnType
? 'missingAsyncHybridReturn'
: 'missingAsync',
fix: fixer => {
if (node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition ||
(node.parent.type === utils_1.AST_NODE_TYPES.Property &&
node.parent.method)) {
// this function is a class method or object function property shorthand
const method = node.parent;
// the token to put `async` before
let keyToken = (0, util_1.nullThrows)(context.sourceCode.getFirstToken(method), util_1.NullThrowsReasons.MissingToken('key token', 'method'));
// if there are decorators then skip past them
if (method.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
method.decorators.length) {
const lastDecorator = method.decorators[method.decorators.length - 1];
keyToken = (0, util_1.nullThrows)(context.sourceCode.getTokenAfter(lastDecorator), util_1.NullThrowsReasons.MissingToken('key token', 'last decorator'));
}
// if current token is a keyword like `static` or `public`, or the `override` modifier, then skip it
while ((keyToken.type === utils_1.AST_TOKEN_TYPES.Keyword ||
(keyToken.type === utils_1.AST_TOKEN_TYPES.Identifier &&
keyToken.value === 'override')) &&
keyToken.range[0] < method.key.range[0]) {
keyToken = (0, util_1.nullThrows)(context.sourceCode.getTokenAfter(keyToken), util_1.NullThrowsReasons.MissingToken('token', 'modifier keyword'));
}
// check if there is a space between key and previous token
const insertSpace = !context.sourceCode.isSpaceBetween((0, util_1.nullThrows)(context.sourceCode.getTokenBefore(keyToken), util_1.NullThrowsReasons.MissingToken('token', 'keyword')), keyToken);
let code = 'async ';
if (insertSpace) {
code = ` ${code}`;
}
return fixer.insertTextBefore(keyToken, code);
}
return fixer.insertTextBefore(node, 'async ');
},
});
}
}
return {
...(checkArrowFunctions && {
'ArrowFunctionExpression[async = false]'(node) {
validateNode(node);
},
}),
...(checkFunctionDeclarations && {
'FunctionDeclaration[async = false]'(node) {
validateNode(node);
},
}),
'FunctionExpression[async = false]'(node) {
if (node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
node.parent.kind === 'method') {
if (checkMethodDeclarations) {
validateNode(node);
}
return;
}
if (checkFunctionExpressions) {
validateNode(node);
}
},
};
},
});

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.specifierNameMatches = specifierNameMatches;
function specifierNameMatches(type, names) {
if (typeof names === 'string') {
names = [names];
}
const symbol = type.aliasSymbol ?? type.getSymbol();
const candidateNames = symbol
? [symbol.escapedName, type.intrinsicName]
: [type.intrinsicName];
if (names.some(item => candidateNames.includes(item))) {
return true;
}
return false;
}

View File

@@ -0,0 +1,98 @@
/**
* @fileoverview Rule to flag duplicate arguments
* @author Jamund Ferguson
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const astUtils = require("./utils/ast-utils");
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
/** @typedef {import("eslint-scope").Definition} Definition */
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../types').Rule.RuleModule} */
module.exports = {
meta: {
type: "problem",
docs: {
description:
"Disallow duplicate arguments in `function` definitions",
recommended: true,
url: "https://eslint.org/docs/latest/rules/no-dupe-args",
},
schema: [],
messages: {
unexpected: "Duplicate param '{{name}}'.",
},
},
create(context) {
const sourceCode = context.sourceCode;
//--------------------------------------------------------------------------
// Helpers
//--------------------------------------------------------------------------
/**
* Checks whether or not a given definition is a parameter's.
* @param {Definition} def A definition to check.
* @returns {boolean} `true` if the definition is a parameter's.
*/
function isParameter(def) {
return def.type === "Parameter";
}
/**
* Determines if a given node has duplicate parameters.
* @param {ASTNode} node The node to check.
* @returns {void}
* @private
*/
function checkParams(node) {
const variables = sourceCode.getDeclaredVariables(node);
for (let i = 0; i < variables.length; ++i) {
const variable = variables[i];
// Checks and reports duplications.
const defs = variable.defs.filter(isParameter);
const loc = {
start: astUtils.getOpeningParenOfParams(node, sourceCode)
.loc.start,
end: sourceCode.getTokenBefore(node.body).loc.end,
};
if (defs.length >= 2) {
context.report({
loc,
messageId: "unexpected",
data: { name: variable.name },
});
}
}
}
//--------------------------------------------------------------------------
// Public API
//--------------------------------------------------------------------------
return {
FunctionDeclaration: checkParams,
FunctionExpression: checkParams,
};
},
};

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC"}

View File

@@ -0,0 +1,18 @@
"use strict";
var _type_of = require("./_type_of.cjs");
function _to_primitive(input, hint) {
if (_type_of._(input) !== "object" || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || "default");
if (_type_of._(res) !== "object") return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (hint === "string" ? String : Number)(input);
}
exports._ = _to_primitive;

View File

@@ -0,0 +1,2 @@
export type VisitorKeys = Record<string, readonly string[] | undefined>;
export declare const visitorKeys: VisitorKeys;

View File

@@ -0,0 +1,6 @@
'use strict'
module.exports = require('neostandard')({
ignores: require('neostandard').resolveIgnoresFromGitignore(),
ts: true
})

View File

@@ -0,0 +1,110 @@
import * as util from "../core/util.js";
const error = () => {
const Sizable = {
string: { unit: "belgi", verb: "bolishi kerak" },
file: { unit: "bayt", verb: "bolishi kerak" },
array: { unit: "element", verb: "bolishi kerak" },
set: { unit: "element", verb: "bolishi kerak" },
map: { unit: "yozuv", verb: "bolishi kerak" },
};
function getSizing(origin) {
return Sizable[origin] ?? null;
}
const FormatDictionary = {
regex: "kirish",
email: "elektron pochta manzili",
url: "URL",
emoji: "emoji",
uuid: "UUID",
uuidv4: "UUIDv4",
uuidv6: "UUIDv6",
nanoid: "nanoid",
guid: "GUID",
cuid: "cuid",
cuid2: "cuid2",
ulid: "ULID",
xid: "XID",
ksuid: "KSUID",
datetime: "ISO sana va vaqti",
date: "ISO sana",
time: "ISO vaqt",
duration: "ISO davomiylik",
ipv4: "IPv4 manzil",
ipv6: "IPv6 manzil",
mac: "MAC manzil",
cidrv4: "IPv4 diapazon",
cidrv6: "IPv6 diapazon",
base64: "base64 kodlangan satr",
base64url: "base64url kodlangan satr",
json_string: "JSON satr",
e164: "E.164 raqam",
jwt: "JWT",
template_literal: "kirish",
};
const TypeDictionary = {
nan: "NaN",
number: "raqam",
array: "massiv",
};
return (issue) => {
switch (issue.code) {
case "invalid_type": {
const expected = TypeDictionary[issue.expected] ?? issue.expected;
const receivedType = util.parsedType(issue.input);
const received = TypeDictionary[receivedType] ?? receivedType;
if (/^[A-Z]/.test(issue.expected)) {
return `Notogri kirish: kutilgan instanceof ${issue.expected}, qabul qilingan ${received}`;
}
return `Notogri kirish: kutilgan ${expected}, qabul qilingan ${received}`;
}
case "invalid_value":
if (issue.values.length === 1)
return `Notogri kirish: kutilgan ${util.stringifyPrimitive(issue.values[0])}`;
return `Notogri variant: quyidagilardan biri kutilgan ${util.joinValues(issue.values, "|")}`;
case "too_big": {
const adj = issue.inclusive ? "<=" : "<";
const sizing = getSizing(issue.origin);
if (sizing)
return `Juda katta: kutilgan ${issue.origin ?? "qiymat"} ${adj}${issue.maximum.toString()} ${sizing.unit} ${sizing.verb}`;
return `Juda katta: kutilgan ${issue.origin ?? "qiymat"} ${adj}${issue.maximum.toString()}`;
}
case "too_small": {
const adj = issue.inclusive ? ">=" : ">";
const sizing = getSizing(issue.origin);
if (sizing) {
return `Juda kichik: kutilgan ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit} ${sizing.verb}`;
}
return `Juda kichik: kutilgan ${issue.origin} ${adj}${issue.minimum.toString()}`;
}
case "invalid_format": {
const _issue = issue;
if (_issue.format === "starts_with")
return `Notogri satr: "${_issue.prefix}" bilan boshlanishi kerak`;
if (_issue.format === "ends_with")
return `Notogri satr: "${_issue.suffix}" bilan tugashi kerak`;
if (_issue.format === "includes")
return `Notogri satr: "${_issue.includes}" ni oz ichiga olishi kerak`;
if (_issue.format === "regex")
return `Notogri satr: ${_issue.pattern} shabloniga mos kelishi kerak`;
return `Notogri ${FormatDictionary[_issue.format] ?? issue.format}`;
}
case "not_multiple_of":
return `Notogri raqam: ${issue.divisor} ning karralisi bolishi kerak`;
case "unrecognized_keys":
return `Nomalum kalit${issue.keys.length > 1 ? "lar" : ""}: ${util.joinValues(issue.keys, ", ")}`;
case "invalid_key":
return `${issue.origin} dagi kalit notogri`;
case "invalid_union":
return "Notogri kirish";
case "invalid_element":
return `${issue.origin} da notogri qiymat`;
default:
return `Notogri kirish`;
}
};
};
export default function () {
return {
localeError: error(),
};
}

View File

@@ -0,0 +1,7 @@
# @vitest/spy
[![NPM version](https://img.shields.io/npm/v/@vitest/spy?color=a1b858&label=)](https://npmx.dev/package/@vitest/spy)
Lightweight Jest-compatible mocking implementation.
[GitHub](https://github.com/vitest-dev/vitest/tree/main/packages/spy) | [Documentation](https://vitest.dev/api/mock)

View File

@@ -0,0 +1 @@
"use strict";var i=Object.defineProperty;var a=(r,t)=>i(r,"name",{value:t,configurable:!0});var n=require("node:repl"),u=require("esbuild");const f=a(r=>{const{eval:t}=r,c=a(async function(e,l,s,o){try{e=(await u.transform(e,{sourcefile:s,loader:"ts",tsconfigRaw:{compilerOptions:{preserveValueImports:!0}},define:{require:"global.require"}})).code}catch{}return t.call(this,e,l,s,o)},"preEval");r.eval=c},"patchEval"),{start:p}=n;n.start=function(){const r=Reflect.apply(p,this,arguments);return f(r),r};

View File

@@ -0,0 +1,52 @@
var _typeof = require("./typeof.js")["default"];
var setPrototypeOf = require("./setPrototypeOf.js");
var inherits = require("./inherits.js");
function _wrapRegExp() {
module.exports = _wrapRegExp = function _wrapRegExp(e, r) {
return new BabelRegExp(e, void 0, r);
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
var e = RegExp.prototype,
r = new WeakMap();
function BabelRegExp(e, t, p) {
var o = RegExp(e, t);
return r.set(o, p || r.get(e)), setPrototypeOf(o, BabelRegExp.prototype);
}
function buildGroups(e, t) {
var p = r.get(t);
return Object.keys(p).reduce(function (r, t) {
var o = p[t];
if ("number" == typeof o) r[t] = e[o];else {
for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++;
r[t] = e[o[i]];
}
return r;
}, Object.create(null));
}
return inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) {
var t = e.exec.call(this, r);
if (t) {
t.groups = buildGroups(t, this);
var p = t.indices;
p && (p.groups = buildGroups(p, this));
}
return t;
}, BabelRegExp.prototype[Symbol.replace] = function (t, p) {
if ("string" == typeof p) {
var o = r.get(this);
return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)(>|$)/g, function (e, r, t) {
if ("" === t) return e;
var p = o[r];
return Array.isArray(p) ? "$" + p.join("$") : "number" == typeof p ? "$" + p : "";
}));
}
if ("function" == typeof p) {
var i = this;
return e[Symbol.replace].call(this, t, function () {
var e = arguments;
return "object" != _typeof(e[e.length - 1]) && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e);
});
}
return e[Symbol.replace].call(this, t, p);
}, _wrapRegExp.apply(this, arguments);
}
module.exports = _wrapRegExp, module.exports.__esModule = true, module.exports["default"] = module.exports;