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 @@
{"version":3,"file":"node.infrastructure.d.ts","sourceRoot":"","sources":["../../../src/api/node/node.infrastructure.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,aAAa,EAClB,aAAa,EACb,KAAK,IAAI,EACT,UAAU,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAMH,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,EAOxB,MAAM,eAAe,CAAC;AAMvB,eAAO,MAAM,SAAS,EAAE,MAAM,EAAqwB,CAAC;AAEpyB,MAAM,MAAM,YAAY,GAAG,OAAO,uBAAuB,GAAG,OAAO,qBAAqB,GAAG,OAAO,uBAAuB,CAAC;AAC1H,eAAO,MAAM,mBAAmB,aAAgB,CAAC;AACjD,eAAO,MAAM,eAAe,MAAgB,CAAC;AAC7C,eAAO,MAAM,sBAAsB,WAAgB,CAAC;AACpD,eAAO,MAAM,uBAAuB,WAAgB,CAAC;AAQrD,MAAM,WAAW,WAAW;IACxB,MAAM,CAAC,KAAK,CAAC,EAAE,eAAe,GAAG,eAAe,GAAG,MAAM,CAAC;CAC7D;AAED,MAAM,WAAW,cAAc;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAC;IAC3C,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,KAAK,EAAE,GAAG,EAAE,CAAC;IACb,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;IAC/C,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,aAAa,EAAE,CAAC;IAC7D,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,IAAI,EAAE,CAAC;IACpD,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IACnD,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/C;AAMD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAMzD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAE1D;AAMD,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,aAAa,CAqC9D;AAMD,qBAAa,cAAc;IACvB,MAAM,EAAE,GAAG,CAAC;IACZ,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEjB,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM;IAOzE,IAAI,IAAI,IAAI,UAAU,CAErB;IAED,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,SAAS,KAAK,WAAW,IAAI,MAAM,CAElC;IAED,SAAS,KAAK,IAAI,IAAI,MAAM,CAE3B;IAED,SAAS,KAAK,QAAQ,IAAI,YAAY,CAErC;IAED,SAAS,KAAK,SAAS,IAAI,MAAM,CAKhC;IAED,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAIzD,SAAS,KAAK,UAAU,IAAI,cAAc,CAGzC;CACJ"}

View File

@@ -0,0 +1,105 @@
# brace-expansion
[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
as known from sh/bash, in JavaScript.
[![CI](https://github.com/juliangruber/brace-expansion/actions/workflows/ci.yml/badge.svg)](https://github.com/juliangruber/brace-expansion/actions/workflows/ci.yml)
[![downloads](https://img.shields.io/npm/dm/brace-expansion.svg)](https://www.npmjs.org/package/brace-expansion)
## Example
```js
import { expand } from 'brace-expansion'
expand('file-{a,b,c}.jpg')
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
expand('-v{,,}')
// => ['-v', '-v', '-v']
expand('file{0..2}.jpg')
// => ['file0.jpg', 'file1.jpg', 'file2.jpg']
expand('file-{a..c}.jpg')
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
expand('file{2..0}.jpg')
// => ['file2.jpg', 'file1.jpg', 'file0.jpg']
expand('file{0..4..2}.jpg')
// => ['file0.jpg', 'file2.jpg', 'file4.jpg']
expand('file-{a..e..2}.jpg')
// => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg']
expand('file{00..10..5}.jpg')
// => ['file00.jpg', 'file05.jpg', 'file10.jpg']
expand('{{A..C},{a..c}}')
// => ['A', 'B', 'C', 'a', 'b', 'c']
expand('ppp{,config,oe{,conf}}')
// => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf']
```
## API
```js
import { expand } from 'brace-expansion'
```
### const expanded = expand(str, [options])
Return an array of all possible and valid expansions of `str`. If
none are found, `[str]` is returned.
The `options` object can provide a `max` value to cap the number
of expansions allowed. This is limited to `100_000` by default,
to prevent DoS attacks.
```js
const expansions = expand('{1..100}'.repeat(5), {
max: 100,
})
// expansions.length will be 100, not 100^5
```
The `options` object can also provide a `maxLength` value to cap the
total number of characters across all expansions. This is limited to
`4_000_000` by default, to prevent memory exhaustion from inputs whose
result count stays under `max` while each result grows very long.
```js
const expansions = expand('{a,b}'.repeat(1500), {
maxLength: 10_000,
})
```
Valid expansions are:
```js
;/^(.*,)+(.+)?$/
// {a,b,...}
```
A comma separated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`.
```js
;/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
// {x..y[..incr]}
```
A numeric sequence from `x` to `y` inclusive, with optional increment.
If `x` or `y` start with a leading `0`, all the numbers will be padded
to have equal length. Negative numbers and backwards iteration work too.
```js
;/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
// {x..y[..incr]}
```
An alphabetic sequence from `x` to `y` inclusive, with optional increment.
`x` and `y` must be exactly one character, and if given, `incr` must be a
number.
For compatibility reasons, the string `${` is not eligible for brace expansion.

View File

@@ -0,0 +1,13 @@
function _extends() {
_extends = Object.assign || function assign(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
}
return target;
};
return _extends.apply(this, arguments);
}
export { _extends as _ };

View File

@@ -0,0 +1,101 @@
# p-limit
> Run multiple promise-returning & async functions with limited concurrency
## Install
```
$ npm install p-limit
```
## Usage
```js
const pLimit = require('p-limit');
const limit = pLimit(1);
const input = [
limit(() => fetchSomething('foo')),
limit(() => fetchSomething('bar')),
limit(() => doSomething())
];
(async () => {
// Only one promise is run at once
const result = await Promise.all(input);
console.log(result);
})();
```
## API
### pLimit(concurrency)
Returns a `limit` function.
#### concurrency
Type: `number`\
Minimum: `1`\
Default: `Infinity`
Concurrency limit.
### limit(fn, ...args)
Returns the promise returned by calling `fn(...args)`.
#### fn
Type: `Function`
Promise-returning/async function.
#### args
Any arguments to pass through to `fn`.
Support for passing arguments on to the `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a *lot* of functions.
### limit.activeCount
The number of promises that are currently running.
### limit.pendingCount
The number of promises that are waiting to run (i.e. their internal `fn` was not called yet).
### limit.clearQueue()
Discard pending promises that are waiting to run.
This might be useful if you want to teardown the queue at the end of your program's lifecycle or discard any function calls referencing an intermediary state of your app.
Note: This does not cancel promises that are already running.
## FAQ
### How is this different from the [`p-queue`](https://github.com/sindresorhus/p-queue) package?
This package is only about limiting the number of concurrent executions, while `p-queue` is a fully featured queue implementation with lots of different options, introspection, and ability to pause the queue.
## Related
- [p-queue](https://github.com/sindresorhus/p-queue) - Promise queue with concurrency control
- [p-throttle](https://github.com/sindresorhus/p-throttle) - Throttle promise-returning & async functions
- [p-debounce](https://github.com/sindresorhus/p-debounce) - Debounce promise-returning & async functions
- [p-all](https://github.com/sindresorhus/p-all) - Run promise-returning & async functions concurrently with optional limited concurrency
- [More…](https://github.com/sindresorhus/promise-fun)
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-p-limit?utm_source=npm-p-limit&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>

View File

@@ -0,0 +1,22 @@
import * as core from "../core/index.js";
import * as schemas from "./schemas.js";
// @__NO_SIDE_EFFECTS__
export function string(params) {
return core._coercedString(schemas.ZodMiniString, params);
}
// @__NO_SIDE_EFFECTS__
export function number(params) {
return core._coercedNumber(schemas.ZodMiniNumber, params);
}
// @__NO_SIDE_EFFECTS__
export function boolean(params) {
return core._coercedBoolean(schemas.ZodMiniBoolean, params);
}
// @__NO_SIDE_EFFECTS__
export function bigint(params) {
return core._coercedBigint(schemas.ZodMiniBigInt, params);
}
// @__NO_SIDE_EFFECTS__
export function date(params) {
return core._coercedDate(schemas.ZodMiniDate, params);
}

View File

@@ -0,0 +1,35 @@
import validate from './validate.js';
const byteToHex = [];
for (let i = 0; i < 256; ++i) {
byteToHex.push((i + 0x100).toString(16).slice(1));
}
export function unsafeStringify(arr, offset = 0) {
return (byteToHex[arr[offset + 0]] +
byteToHex[arr[offset + 1]] +
byteToHex[arr[offset + 2]] +
byteToHex[arr[offset + 3]] +
'-' +
byteToHex[arr[offset + 4]] +
byteToHex[arr[offset + 5]] +
'-' +
byteToHex[arr[offset + 6]] +
byteToHex[arr[offset + 7]] +
'-' +
byteToHex[arr[offset + 8]] +
byteToHex[arr[offset + 9]] +
'-' +
byteToHex[arr[offset + 10]] +
byteToHex[arr[offset + 11]] +
byteToHex[arr[offset + 12]] +
byteToHex[arr[offset + 13]] +
byteToHex[arr[offset + 14]] +
byteToHex[arr[offset + 15]]).toLowerCase();
}
function stringify(arr, offset = 0) {
const uuid = unsafeStringify(arr, offset);
if (!validate(uuid)) {
throw TypeError('Stringified UUID is invalid');
}
return uuid;
}
export default stringify;

View File

@@ -0,0 +1 @@
{"version":3,"file":"modifierFlags.d.ts","sourceRoot":"","sources":["../../src/enums/modifierFlags.ts"],"names":[],"mappings":"AACA,eAAO,IAAI,aAAa,EAAE,GAAG,CAAC"}

View File

@@ -0,0 +1,46 @@
{
"JSON.stringify@native": {
"name": "JSON.stringify@native",
"browser": "Chrome Mobile 55.0.2883 (Android 6.0.0)",
"suite": "libs",
"hz": 22212.791828443846,
"success": true,
"fastest": false,
"rme": 0.034133757882904736,
"rhz": 3.053112613993719,
"sampleSize": 168
},
"fast-stable-stringify@a9f81e8": {
"name": "fast-stable-stringify@a9f81e8",
"browser": "Chrome Mobile 55.0.2883 (Android 6.0.0)",
"suite": "libs",
"hz": 7275.4577497839855,
"success": true,
"fastest": true,
"rme": 0.022136656281279646,
"rhz": 1,
"sampleSize": 172
},
"json-stable-stringify@1.0.1": {
"name": "json-stable-stringify@1.0.1",
"browser": "Chrome Mobile 55.0.2883 (Android 6.0.0)",
"suite": "libs",
"hz": 4486.002693832929,
"success": true,
"fastest": false,
"rme": 0.05442614536157505,
"rhz": 0.6165938760301539,
"sampleSize": 168
},
"faster-stable-stringify@1.0.0": {
"name": "faster-stable-stringify@1.0.0",
"browser": "Chrome Mobile 55.0.2883 (Android 6.0.0)",
"suite": "libs",
"hz": 5816.35383305631,
"success": true,
"fastest": false,
"rme": 0.024694090743245932,
"rhz": 0.7994485066220063,
"sampleSize": 147
}
}

View File

@@ -0,0 +1,65 @@
{
"name": "safe-stable-stringify",
"version": "2.5.0",
"description": "Deterministic and safely JSON.stringify to quickly serialize JavaScript objects",
"exports": {
"require": "./index.js",
"import": "./esm/wrapper.js"
},
"keywords": [
"stable",
"stringify",
"JSON",
"JSON.stringify",
"safe",
"serialize",
"deterministic",
"circular",
"object",
"predicable",
"repeatable",
"fast",
"bigint"
],
"main": "index.js",
"scripts": {
"test": "standard && tap test.js",
"tap": "tap test.js",
"tap:only": "tap test.js --watch --only",
"benchmark": "node benchmark.js",
"compare": "node compare.js",
"lint": "standard --fix",
"tsc": "tsc --project tsconfig.json"
},
"engines": {
"node": ">=10"
},
"author": "Ruben Bridgewater",
"license": "MIT",
"typings": "index.d.ts",
"devDependencies": {
"@types/json-stable-stringify": "^1.0.34",
"@types/node": "^18.11.18",
"benchmark": "^2.1.4",
"clone": "^2.1.2",
"fast-json-stable-stringify": "^2.1.0",
"fast-safe-stringify": "^2.1.1",
"fast-stable-stringify": "^1.0.0",
"faster-stable-stringify": "^1.0.0",
"fastest-stable-stringify": "^2.0.2",
"json-stable-stringify": "^1.0.1",
"json-stringify-deterministic": "^1.0.7",
"json-stringify-safe": "^5.0.1",
"standard": "^16.0.4",
"tap": "^15.0.9",
"typescript": "^4.8.3"
},
"repository": {
"type": "git",
"url": "git+https://github.com/BridgeAR/safe-stable-stringify.git"
},
"bugs": {
"url": "https://github.com/BridgeAR/safe-stable-stringify/issues"
},
"homepage": "https://github.com/BridgeAR/safe-stable-stringify#readme"
}

View File

@@ -0,0 +1,566 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Member = void 0;
exports.analyzeClassMemberUsage = analyzeClassMemberUsage;
const scope_manager_1 = require("@typescript-eslint/scope-manager");
const utils_1 = require("@typescript-eslint/utils");
const __1 = require("..");
const extractComputedName_1 = require("./extractComputedName");
const types_1 = require("./types");
class Member {
/**
* The node that declares this member
*/
node;
/**
* The resolved, unique key for this member.
*/
key;
/**
* The member name, as given in the source code.
*/
name;
/**
* The node that represents the member name in the source code.
* Used for reporting errors.
*/
nameNode;
/**
* The number of writes to this member.
*/
writeCount = 0;
/**
* The number of reads from this member.
*/
readCount = 0;
constructor(node, key, name, nameNode) {
this.node = node;
this.key = key;
this.name = name;
this.nameNode = nameNode;
}
static create(node) {
const name = (0, extractComputedName_1.extractNameForMember)(node);
if (name == null) {
return null;
}
return new Member(node, name.key, name.codeName, name.nameNode);
}
isAccessor() {
if (this.node.type === utils_1.AST_NODE_TYPES.MethodDefinition ||
this.node.type === utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition) {
return this.node.kind === 'set' || this.node.kind === 'get';
}
return (this.node.type === utils_1.AST_NODE_TYPES.AccessorProperty ||
this.node.type === utils_1.AST_NODE_TYPES.TSAbstractAccessorProperty);
}
isHashPrivate() {
return ('key' in this.node &&
this.node.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier);
}
isPrivate() {
return this.node.accessibility === 'private';
}
isStatic() {
return this.node.static;
}
isUsed() {
return (this.readCount > 0 ||
// any usage of an accessor is considered a usage as accessor can have side effects
(this.writeCount > 0 && this.isAccessor()));
}
}
exports.Member = Member;
function isWriteOnlyUsage(node, parent) {
if (parent.type !== utils_1.AST_NODE_TYPES.AssignmentExpression &&
parent.type !== utils_1.AST_NODE_TYPES.ForInStatement &&
parent.type !== utils_1.AST_NODE_TYPES.ForOfStatement &&
parent.type !== utils_1.AST_NODE_TYPES.AssignmentPattern) {
return false;
}
// If it's on the right then it's a read not a write
if (parent.left !== node) {
return false;
}
if (parent.type === utils_1.AST_NODE_TYPES.AssignmentExpression &&
// For any other operator (such as '+=') we still consider it a read operation
parent.operator !== '=') {
// if the read operation is "discarded" in an empty statement, then it is write only.
return parent.parent.type === utils_1.AST_NODE_TYPES.ExpressionStatement;
}
return true;
}
function countReference(identifierParent, member) {
const identifierGrandparent = (0, __1.nullThrows)(identifierParent.parent, __1.NullThrowsReasons.MissingParent);
if (isWriteOnlyUsage(identifierParent, identifierGrandparent)) {
member.writeCount += 1;
return;
}
const identifierGreatGrandparent = identifierGrandparent.parent;
// A statement which only increments (`this.#x++;`)
if (identifierGrandparent.type === utils_1.AST_NODE_TYPES.UpdateExpression &&
identifierGreatGrandparent?.type === utils_1.AST_NODE_TYPES.ExpressionStatement) {
member.writeCount += 1;
return;
}
/*
* ({ x: this.#usedInDestructuring } = bar);
*
* But should treat the following as a read:
* ({ [this.#x]: a } = foo);
*/
if (identifierGrandparent.type === utils_1.AST_NODE_TYPES.Property &&
identifierGreatGrandparent?.type === utils_1.AST_NODE_TYPES.ObjectPattern &&
identifierGrandparent.value === identifierParent) {
member.writeCount += 1;
return;
}
// [...this.#unusedInRestPattern] = bar;
if (identifierGrandparent.type === utils_1.AST_NODE_TYPES.RestElement) {
member.writeCount += 1;
return;
}
// [this.#unusedInAssignmentPattern] = bar;
if (identifierGrandparent.type === utils_1.AST_NODE_TYPES.ArrayPattern) {
member.writeCount += 1;
return;
}
member.readCount += 1;
}
class ThisScope extends scope_manager_1.Visitor {
/**
* True if the context is considered a static context and so `this` refers to
* the class and not an instance (eg a static method or a static block).
*/
isStaticThisContext;
/**
* The classes directly declared within this class -- for example a class declared within a method.
* This does not include grandchild classes.
*/
childScopes = [];
/**
* The scope manager instance used to resolve variables to improve discovery of usages.
*/
scopeManager;
/**
* The parent class scope if one exists.
*/
upper;
/**
* The context of the `this` reference in the current scope.
*/
thisContext;
constructor(scopeManager, upper, thisContext, isStaticThisContext) {
super({});
this.scopeManager = scopeManager;
this.upper = upper;
this.isStaticThisContext = isStaticThisContext;
if (thisContext === 'self') {
if (!(this instanceof ClassScope)) {
throw new Error('Cannot use `self` unless it is in a ClassScope');
}
this.thisContext = this;
}
else if (thisContext === 'none') {
this.thisContext = null;
}
else {
this.thisContext = thisContext;
}
}
findNearestScope(node) {
let currentScope;
let currentNode = node;
do {
currentScope = this.scopeManager.acquire(currentNode);
if (currentNode.parent == null) {
break;
}
currentNode = currentNode.parent;
} while (currentScope == null);
return currentScope;
}
findVariableInScope(node, name) {
let currentScope = this.findNearestScope(node);
let variable = null;
while (currentScope != null) {
variable = currentScope.set.get(name) ?? null;
if (variable != null) {
break;
}
currentScope = currentScope.upper;
}
return variable;
}
getObjectClass(node) {
switch (node.object.type) {
case utils_1.AST_NODE_TYPES.ThisExpression: {
if (this.thisContext == null) {
return null;
}
return {
thisContext: this.thisContext,
type: this.isStaticThisContext ? 'static' : 'instance',
};
}
case utils_1.AST_NODE_TYPES.Identifier: {
const thisContext = this.findClassScopeWithName(node.object.name);
if (thisContext != null) {
return { thisContext, type: 'static' };
}
// the following code does some very rudimentary scope analysis to handle some trivial cases
const variable = this.findVariableInScope(node, node.object.name);
if (variable == null || variable.defs.length === 0) {
return null;
}
const firstDef = variable.defs[0];
switch (firstDef.node.type) {
// detect simple reassignment of `this`
// ```
// class Foo {
// private prop: number;
// method(thing: Foo) {
// const self = this;
// return self.prop;
// }
// }
// ```
case utils_1.AST_NODE_TYPES.VariableDeclarator: {
const value = firstDef.node.init;
if (value?.type !== utils_1.AST_NODE_TYPES.ThisExpression) {
return null;
}
if (variable.references.some(ref => ref.isWrite() && ref.init !== true)) {
// variable is assigned to multiple times so we can't be sure that it's still the same class
return null;
}
// we have a case like `const self = this` or `let self = this` that is not reassigned
// so we can safely assume that it's still the same class!
return {
thisContext: this.thisContext,
type: this.isStaticThisContext ? 'static' : 'instance',
};
}
// Look for variables typed as the current class:
// ```
// class Foo {
// private prop: number;
// method(thing: Foo) {
// // this references the private instance member but not via `this` so we can't see it
// thing.prop = 1;
// }
// }
// ```
default: {
const typeAnnotation = (() => {
if ('typeAnnotation' in firstDef.name &&
firstDef.name.typeAnnotation != null) {
return firstDef.name.typeAnnotation.typeAnnotation;
}
return null;
})();
if (typeAnnotation == null) {
return null;
}
// Cases like `method(thing: Foo) { ... }`
if (typeAnnotation.type === utils_1.AST_NODE_TYPES.TSTypeReference &&
typeAnnotation.typeName.type === utils_1.AST_NODE_TYPES.Identifier) {
const typeName = typeAnnotation.typeName.name;
const typeScope = this.findClassScopeWithName(typeName);
if (typeScope != null) {
return { thisContext: typeScope, type: 'instance' };
}
}
// Cases like `method(thing: typeof Foo) { ... }`
if (typeAnnotation.type === utils_1.AST_NODE_TYPES.TSTypeQuery &&
typeAnnotation.exprName.type === utils_1.AST_NODE_TYPES.Identifier) {
const exprName = typeAnnotation.exprName.name;
const exprScope = this.findClassScopeWithName(exprName);
if (exprScope != null) {
return { thisContext: exprScope, type: 'static' };
}
}
}
}
return null;
}
case utils_1.AST_NODE_TYPES.MemberExpression:
// TODO - we could probably recurse here to do some more complex analysis and support like `foo.bar.baz` nested references
return null;
default:
return null;
}
}
visitClass(node) {
const classScope = new ClassScope(node, this, this.scopeManager);
this.childScopes.push(classScope);
classScope.visitChildren(node);
}
visitIntermediate(node) {
const intermediateScope = new IntermediateScope(this.scopeManager, this, node);
this.childScopes.push(intermediateScope);
intermediateScope.visitChildren(node);
}
/**
* Gets the nearest class scope with the given name.
*/
findClassScopeWithName(name) {
let currentScope = this;
while (currentScope != null) {
if (currentScope instanceof ClassScope &&
currentScope.className === name) {
return currentScope;
}
currentScope = currentScope.upper;
}
return null;
}
/////////////////////
// Visit selectors //
/////////////////////
AssignmentExpression(node) {
this.visitChildren(node);
if (node.right.type === utils_1.AST_NODE_TYPES.ThisExpression &&
node.left.type === utils_1.AST_NODE_TYPES.ObjectPattern) {
this.handleThisDestructuring(node.left);
}
}
AssignmentPattern(node) {
this.visitChildren(node);
if (node.right.type === utils_1.AST_NODE_TYPES.ThisExpression &&
node.left.type === utils_1.AST_NODE_TYPES.ObjectPattern) {
this.handleThisDestructuring(node.left);
}
}
ClassDeclaration(node) {
this.visitClass(node);
}
ClassExpression(node) {
this.visitClass(node);
}
FunctionDeclaration(node) {
this.visitIntermediate(node);
}
FunctionExpression(node) {
this.visitIntermediate(node);
}
MemberExpression(node) {
this.visitChildren(node);
if (node.property.type === utils_1.AST_NODE_TYPES.PrivateIdentifier) {
// will be handled by the PrivateIdentifier visitor
return;
}
const propertyName = (0, extractComputedName_1.extractNameForMemberExpression)(node);
if (propertyName == null) {
return;
}
const objectClassName = this.getObjectClass(node);
if (objectClassName == null) {
return;
}
if (objectClassName.thisContext == null) {
return;
}
const members = objectClassName.type === 'instance'
? objectClassName.thisContext.members.instance
: objectClassName.thisContext.members.static;
const member = members.get(propertyName.key);
if (member == null) {
return;
}
countReference(node, member);
}
PrivateIdentifier(node) {
this.visitChildren(node);
if ((node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition ||
node.parent.type === utils_1.AST_NODE_TYPES.PropertyDefinition) &&
node.parent.key === node) {
// ignore the member definition
return;
}
// We can actually be pretty loose with our code here thanks to how private
// members are designed.
//
// 1) classes CANNOT have a static and instance private member with the
// same name, so we don't need to match up static access.
// 2) nested classes CANNOT access a private member of their parent class if
// the member has the same name as a private member of the nested class.
//
// together this means that we can just look for the member upwards until we
// find a match and we know that will be the correct match!
let currentScope = this;
const key = (0, types_1.privateKey)(node);
while (currentScope != null) {
if (currentScope.thisContext != null) {
const member = currentScope.thisContext.members.instance.get(key) ??
currentScope.thisContext.members.static.get(key);
if (member != null) {
countReference(node.parent, member);
return;
}
}
currentScope = currentScope.upper;
}
}
StaticBlock(node) {
this.visitIntermediate(node);
}
VariableDeclarator(node) {
this.visitChildren(node);
if (node.init?.type === utils_1.AST_NODE_TYPES.ThisExpression &&
node.id.type === utils_1.AST_NODE_TYPES.ObjectPattern) {
this.handleThisDestructuring(node.id);
}
}
/**
* Handles destructuring from `this` in ObjectPattern.
* Example: const { property } = this;
*/
handleThisDestructuring(pattern) {
if (this.thisContext == null) {
return;
}
for (const prop of pattern.properties) {
if (prop.type !== utils_1.AST_NODE_TYPES.Property) {
continue;
}
if (prop.key.type !== utils_1.AST_NODE_TYPES.Identifier || prop.computed) {
continue;
}
const memberKey = (0, types_1.publicKey)(prop.key.name);
const members = this.isStaticThisContext
? this.thisContext.members.static
: this.thisContext.members.instance;
const member = members.get(memberKey);
if (member == null) {
continue;
}
countReference(prop.key, member);
}
}
}
/**
* Any other scope that is not a class scope
*
* When we visit a function declaration/expression the `this` reference is
* rebound so it no longer refers to the class.
*
* This also supports a function's `this` parameter.
*/
class IntermediateScope extends ThisScope {
constructor(scopeManager, upper, node) {
if (node.type === utils_1.AST_NODE_TYPES.Program) {
super(scopeManager, upper, 'none', false);
return;
}
if (node.type === utils_1.AST_NODE_TYPES.StaticBlock) {
if (upper == null || !(upper instanceof ClassScope)) {
throw new Error('Cannot have a static block without an upper ClassScope');
}
super(scopeManager, upper, upper, true);
return;
}
// method definition
if ((node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition ||
node.parent.type === utils_1.AST_NODE_TYPES.PropertyDefinition) &&
node.parent.value === node) {
if (upper == null || !(upper instanceof ClassScope)) {
throw new Error('Cannot have a class method/property without an upper ClassScope');
}
super(scopeManager, upper, upper, node.parent.static);
return;
}
// function with a `this` parameter
if (upper != null &&
node.params.length > 0 &&
node.params[0].type === utils_1.AST_NODE_TYPES.Identifier &&
node.params[0].name === 'this') {
const thisType = node.params[0].typeAnnotation?.typeAnnotation;
if (thisType?.type === utils_1.AST_NODE_TYPES.TSTypeReference &&
thisType.typeName.type === utils_1.AST_NODE_TYPES.Identifier) {
const thisContext = upper.findClassScopeWithName(thisType.typeName.name);
if (thisContext != null) {
super(scopeManager, upper, thisContext, false);
return;
}
}
}
super(scopeManager, upper, 'none', false);
}
}
class ClassScope extends ThisScope {
className;
/**
* The class's members, keyed by their name
*/
members = {
instance: new Map(),
static: new Map(),
};
/**
* The node that declares this class.
*/
theClass;
constructor(theClass, upper, scopeManager) {
super(scopeManager, upper, 'self', false);
this.theClass = theClass;
this.className = theClass.id?.name ?? null;
for (const memberNode of theClass.body.body) {
switch (memberNode.type) {
case utils_1.AST_NODE_TYPES.MethodDefinition:
if (memberNode.kind === 'constructor') {
for (const parameter of memberNode.value.params) {
if (parameter.type !== utils_1.AST_NODE_TYPES.TSParameterProperty) {
continue;
}
const member = Member.create(parameter);
if (member == null) {
continue;
}
this.members.instance.set(member.key, member);
}
// break instead of falling through because the constructor is not a "member" we track
break;
}
// intentional fallthrough
case utils_1.AST_NODE_TYPES.AccessorProperty:
case utils_1.AST_NODE_TYPES.PropertyDefinition:
case utils_1.AST_NODE_TYPES.TSAbstractAccessorProperty:
case utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition:
case utils_1.AST_NODE_TYPES.TSAbstractPropertyDefinition: {
const member = Member.create(memberNode);
if (member == null) {
continue;
}
if (member.isStatic()) {
this.members.static.set(member.key, member);
}
else {
this.members.instance.set(member.key, member);
}
break;
}
case utils_1.AST_NODE_TYPES.StaticBlock:
// static blocks declare no members
continue;
case utils_1.AST_NODE_TYPES.TSIndexSignature:
// index signatures are type signatures only and are fully computed
continue;
}
}
}
}
function analyzeClassMemberUsage(program, scopeManager) {
const rootScope = new IntermediateScope(scopeManager, null, program);
rootScope.visit(program);
return traverseScopes(rootScope);
}
function traverseScopes(currentScope, analysisResults = new Map()) {
if (currentScope instanceof ClassScope) {
analysisResults.set(currentScope.theClass, currentScope);
}
for (const childScope of currentScope.childScopes) {
traverseScopes(childScope, analysisResults);
}
return analysisResults;
}

View File

@@ -0,0 +1,15 @@
import type { ScopeVariable } from '@typescript-eslint/scope-manager';
import { TSESLint } from '@typescript-eslint/utils';
interface VariableAnalysis {
readonly unusedVariables: ReadonlySet<ScopeVariable>;
readonly usedVariables: ReadonlySet<ScopeVariable>;
}
/**
* Collects the set of unused variables for a given context.
*
* Due to complexity, this does not take into consideration:
* - variables within declaration files
* - variables within ambient module declarations
*/
export declare function collectVariables<MessageIds extends string, Options extends readonly unknown[]>(context: Readonly<TSESLint.RuleContext<MessageIds, Options>>): VariableAnalysis;
export {};

View File

@@ -0,0 +1,35 @@
import { C as BindingViteJsonPluginConfig, D as BindingViteReporterPluginConfig, E as BindingViteReactRefreshWrapperPluginConfig, O as BindingViteResolvePluginConfig, S as BindingViteImportGlobPluginConfig, T as BindingViteModulePreloadPolyfillPluginConfig, b as BindingViteBuildImportAnalysisPluginConfig, l as BindingIsolatedDeclarationPluginConfig, s as BindingEsmExternalRequirePluginConfig, x as BindingViteDynamicImportVarsPluginConfig } from "./binding-CVtkJvyl.mjs";
import { Gt as StringOrRegExp, I as BuiltinPlugin } from "./define-config-Dsp5YQR4.mjs";
//#region src/builtin-plugin/constructors.d.ts
declare function viteModulePreloadPolyfillPlugin(config?: BindingViteModulePreloadPolyfillPluginConfig): BuiltinPlugin;
type DynamicImportVarsPluginConfig = Omit<BindingViteDynamicImportVarsPluginConfig, "include" | "exclude"> & {
include?: StringOrRegExp | StringOrRegExp[];
exclude?: StringOrRegExp | StringOrRegExp[];
};
declare function viteDynamicImportVarsPlugin(config?: DynamicImportVarsPluginConfig): BuiltinPlugin;
declare function viteImportGlobPlugin(config?: BindingViteImportGlobPluginConfig): BuiltinPlugin;
declare function viteReporterPlugin(config: BindingViteReporterPluginConfig): BuiltinPlugin;
declare function viteLoadFallbackPlugin(): BuiltinPlugin;
declare function viteJsonPlugin(config: BindingViteJsonPluginConfig): BuiltinPlugin;
declare function viteBuildImportAnalysisPlugin(config: BindingViteBuildImportAnalysisPluginConfig): BuiltinPlugin;
declare function viteResolvePlugin(config: Omit<BindingViteResolvePluginConfig, "yarnPnp">): BuiltinPlugin;
declare function isolatedDeclarationPlugin(config?: BindingIsolatedDeclarationPluginConfig): BuiltinPlugin;
declare function viteWebWorkerPostPlugin(): BuiltinPlugin;
/**
* A plugin that converts CommonJS require() calls for external dependencies into ESM import statements.
*
* @see https://rolldown.rs/builtin-plugins/esm-external-require
* @category Builtin Plugins
*/
declare function esmExternalRequirePlugin(config?: BindingEsmExternalRequirePluginConfig): BuiltinPlugin;
type ViteReactRefreshWrapperPluginConfig = Omit<BindingViteReactRefreshWrapperPluginConfig, "include" | "exclude"> & {
include?: StringOrRegExp | StringOrRegExp[];
exclude?: StringOrRegExp | StringOrRegExp[];
};
/**
* This plugin should not be used for Rolldown.
*/
declare function oxcRuntimePlugin(): BuiltinPlugin;
declare function viteReactRefreshWrapperPlugin(config: ViteReactRefreshWrapperPluginConfig): BuiltinPlugin;
//#endregion
export { viteDynamicImportVarsPlugin as a, viteLoadFallbackPlugin as c, viteReporterPlugin as d, viteResolvePlugin as f, viteBuildImportAnalysisPlugin as i, viteModulePreloadPolyfillPlugin as l, isolatedDeclarationPlugin as n, viteImportGlobPlugin as o, viteWebWorkerPostPlugin as p, oxcRuntimePlugin as r, viteJsonPlugin as s, esmExternalRequirePlugin as t, viteReactRefreshWrapperPlugin as u };

View File

@@ -0,0 +1,5 @@
function _classPrivateFieldBase(e, t) {
if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance");
return e;
}
export { _classPrivateFieldBase as default };

View File

@@ -0,0 +1,47 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABILITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
interface ObjectConstructor {
/**
* Returns an array of values of the enumerable own properties of an object
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
values<T>(o: { [s: string]: T; } | ArrayLike<T>): T[];
/**
* Returns an array of values of the enumerable own properties of an object
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
values(o: {}): any[];
/**
* Returns an array of key/values of the enumerable own properties of an object
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
entries<T>(o: { [s: string]: T; } | ArrayLike<T>): [string, T][];
/**
* Returns an array of key/values of the enumerable own properties of an object
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
entries(o: {}): [string, any][];
/**
* Returns an object containing all own property descriptors of an object
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
getOwnPropertyDescriptors<T>(o: T): { [P in keyof T]: TypedPropertyDescriptor<T[P]>; } & { [x: string]: PropertyDescriptor; };
}

View File

@@ -0,0 +1,52 @@
export * as core from "../core/index.js";
export * from "./schemas.js";
export * from "./checks.js";
export * from "./errors.js";
export * from "./parse.js";
export * from "./compat.js";
// zod-specified
import { config } from "../core/index.js";
import en from "../locales/en.js";
config(en());
export type { infer, output, input } from "../core/index.js";
export type { JSONType } from "../core/util.js";
export {
globalRegistry,
type GlobalMeta,
registry,
config,
$output,
$input,
$brand,
clone,
regexes,
treeifyError,
prettifyError,
formatError,
flattenError,
TimePrecision,
util,
NEVER,
} from "../core/index.js";
export { toJSONSchema } from "../core/json-schema-processors.js";
export { fromJSONSchema } from "./from-json-schema.js";
export * as locales from "../locales/index.js";
// iso
// must be exported from top-level
// https://github.com/colinhacks/zod/issues/4491
export { ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration } from "./iso.js";
export * as iso from "./iso.js";
// coerce
export type {
ZodCoercedString,
ZodCoercedNumber,
ZodCoercedBigInt,
ZodCoercedBoolean,
ZodCoercedDate,
} from "./coerce.js";
export * as coerce from "./coerce.js";

View File

@@ -0,0 +1,95 @@
import rng from './rng.js';
import stringify from './stringify.js'; // **`v1()` - Generate time-based UUID**
//
// Inspired by https://github.com/LiosK/UUID.js
// and http://docs.python.org/library/uuid.html
var _nodeId;
var _clockseq; // Previous uuid creation time
var _lastMSecs = 0;
var _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
function v1(options, buf, offset) {
var i = buf && offset || 0;
var b = buf || new Array(16);
options = options || {};
var node = options.node || _nodeId;
var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
// specified. We do this lazily to minimize issues related to insufficient
// system entropy. See #189
if (node == null || clockseq == null) {
var seedBytes = options.random || (options.rng || rng)();
if (node == null) {
// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
}
if (clockseq == null) {
// Per 4.2.2, randomize (14 bit) clockseq
clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
}
} // UUID timestamps are 100 nano-second units since the Gregorian epoch,
// (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
// time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
var msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
// cycle to simulate higher resolution clock
var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
if (dt < 0 && options.clockseq === undefined) {
clockseq = clockseq + 1 & 0x3fff;
} // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
// time interval
if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
nsecs = 0;
} // Per 4.2.1.2 Throw error if too many uuids are requested
if (nsecs >= 10000) {
throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
}
_lastMSecs = msecs;
_lastNSecs = nsecs;
_clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
msecs += 12219292800000; // `time_low`
var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
b[i++] = tl >>> 24 & 0xff;
b[i++] = tl >>> 16 & 0xff;
b[i++] = tl >>> 8 & 0xff;
b[i++] = tl & 0xff; // `time_mid`
var tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
b[i++] = tmh >>> 8 & 0xff;
b[i++] = tmh & 0xff; // `time_high_and_version`
b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
b[i++] = clockseq & 0xff; // `node`
for (var n = 0; n < 6; ++n) {
b[i + n] = node[n];
}
return buf || stringify(b);
}
export default v1;

View File

@@ -0,0 +1,39 @@
{
"name": "bn.js",
"version": "5.2.5",
"description": "Big number implementation in pure javascript",
"keywords": [
"BN",
"Big number",
"BigNum",
"Modulo",
"Montgomery"
],
"homepage": "https://github.com/indutny/bn.js",
"bugs": {
"url": "https://github.com/indutny/bn.js/issues"
},
"repository": {
"type": "git",
"url": "git@github.com:indutny/bn.js"
},
"license": "MIT",
"author": "Fedor Indutny <fedor@indutny.com>",
"files": [
"lib/bn.js"
],
"main": "lib/bn.js",
"browser": {
"buffer": false
},
"scripts": {
"lint": "standardx",
"test": "npm run lint && npm run unit",
"unit": "mocha --reporter=spec test/*-test.js"
},
"devDependencies": {
"eslint-plugin-es5": "^1.5.0",
"mocha": "^8.3.0",
"standardx": "^7.0.0"
}
}

View File

@@ -0,0 +1,35 @@
export class Doc {
constructor(args = []) {
this.content = [];
this.indent = 0;
if (this)
this.args = args;
}
indented(fn) {
this.indent += 1;
fn(this);
this.indent -= 1;
}
write(arg) {
if (typeof arg === "function") {
arg(this, { execution: "sync" });
arg(this, { execution: "async" });
return;
}
const content = arg;
const lines = content.split("\n").filter((x) => x);
const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
for (const line of dedented) {
this.content.push(line);
}
}
compile() {
const F = Function;
const args = this?.args;
const content = this?.content ?? [``];
const lines = [...content.map((x) => ` ${x}`)];
// console.log(lines.join("\n"));
return new F(...args, lines.join("\n"));
}
}

View File

@@ -0,0 +1,124 @@
// Karma configuration
// Generated on Sun Sep 03 2017 04:55:32 GMT+0200 (CEST)
module.exports = function(config) {
// in seconds
var TIMEOUT = 360;
var customLaunchers = {
// desktop evergreen
sl_chrome: { base: 'SauceLabs', browserName: 'chrome', version: '60', idleTimeout: TIMEOUT },
sl_firefox: { base: 'SauceLabs', browserName: 'firefox', version: '54', idleTimeout: TIMEOUT },
sl_safari: { base: "SauceLabs", browserName: "safari", version: '10', platform: 'macOS 10.12', idleTimeout: TIMEOUT },
sl_edge: { base: "SauceLabs", browserName: "microsoftedge", version: '14', platform: 'Windows 10', idleTimeout: TIMEOUT },
//sl_opera: { base: "SauceLabs", browsername: "opera", version: '12', platform: 'Windows 7', idleTimeout: TIMEOUT },
// desktop legacy
sl_ie_9: { base: 'SauceLabs', browserName: 'internet explorer', version: '9', idleTimeout: TIMEOUT },
sl_ie_10: { base: 'SauceLabs', browserName: 'internet explorer', version: '10', idleTimeout: TIMEOUT },
sl_ie_11: { base: 'SauceLabs', browserName: 'internet explorer', version: '11', idleTimeout: TIMEOUT },
// mobile
sl_iphone: { base: 'SauceLabs', browserName: 'iphone', version: '10.3', idleTimeout: TIMEOUT },
sl_android: { base: 'SauceLabs', browserName: 'android', version: '6.0', idleTimeout: TIMEOUT },
};
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['benchmark'],
// list of files / patterns to load in the browser
files: [
'test/index.js'
],
// list of files to exclude
exclude: [
],
client: {
captureConsole: true,
logLevel: config.LOG_LOG,
mocha: {
ui: 'tdd'
}
},
browserConsoleLogOptions: {
level: 'log',
format: '%b %T: %m',
terminal: true
},
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'test/index.js': ['webpack']
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['benchmark'],
benchmarkReporter: {
destDir: 'results',
exclude: ['native', 'faster-stable-stringify', 'fast-stable-stringify'],
resolveName: function(benchName, suiteName) {
if (suiteName == 'libs') {
var libInfo = require('./util/get-lib-info')(benchName);
return libInfo.name + '@' + libInfo.version;
} else {
return benchName;
}
},
logStyle: 'benchmark'
},
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
customLaunchers: customLaunchers,
browsers: Object.keys(customLaunchers),
//browsers: ['Chrome', 'Firefox'],
browserNoActivityTimeout: TIMEOUT * 1000,
captureTimeout: TIMEOUT * 1000,
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
// Concurrency level
// how many browser should be started simultaneous
concurrency: 5
})
};

View File

@@ -0,0 +1,150 @@
/**
* @fileoverview Rule to suggest using "Reflect" api over Function/Object methods
* @author Keith Cirkel <http://keithcirkel.co.uk>
* @deprecated in ESLint v3.9.0
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../types').Rule.RuleModule} */
module.exports = {
meta: {
type: "suggestion",
docs: {
description: "Require `Reflect` methods where applicable",
recommended: false,
url: "https://eslint.org/docs/latest/rules/prefer-reflect",
},
deprecated: {
message: "The original intention of this rule was misguided.",
deprecatedSince: "3.9.0",
availableUntil: null,
replacedBy: [],
},
schema: [
{
type: "object",
properties: {
exceptions: {
type: "array",
items: {
enum: [
"apply",
"call",
"delete",
"defineProperty",
"getOwnPropertyDescriptor",
"getPrototypeOf",
"setPrototypeOf",
"isExtensible",
"getOwnPropertyNames",
"preventExtensions",
],
},
uniqueItems: true,
},
},
additionalProperties: false,
},
],
messages: {
preferReflect:
"Avoid using {{existing}}, instead use {{substitute}}.",
},
},
create(context) {
const existingNames = {
apply: "Function.prototype.apply",
call: "Function.prototype.call",
defineProperty: "Object.defineProperty",
getOwnPropertyDescriptor: "Object.getOwnPropertyDescriptor",
getPrototypeOf: "Object.getPrototypeOf",
setPrototypeOf: "Object.setPrototypeOf",
isExtensible: "Object.isExtensible",
getOwnPropertyNames: "Object.getOwnPropertyNames",
preventExtensions: "Object.preventExtensions",
};
const reflectSubstitutes = {
apply: "Reflect.apply",
call: "Reflect.apply",
defineProperty: "Reflect.defineProperty",
getOwnPropertyDescriptor: "Reflect.getOwnPropertyDescriptor",
getPrototypeOf: "Reflect.getPrototypeOf",
setPrototypeOf: "Reflect.setPrototypeOf",
isExtensible: "Reflect.isExtensible",
getOwnPropertyNames: "Reflect.getOwnPropertyNames",
preventExtensions: "Reflect.preventExtensions",
};
const exceptions = (context.options[0] || {}).exceptions || [];
/**
* Reports the Reflect violation based on the `existing` and `substitute`
* @param {Object} node The node that violates the rule.
* @param {string} existing The existing method name that has been used.
* @param {string} substitute The Reflect substitute that should be used.
* @returns {void}
*/
function report(node, existing, substitute) {
context.report({
node,
messageId: "preferReflect",
data: {
existing,
substitute,
},
});
}
return {
CallExpression(node) {
const methodName = (node.callee.property || {}).name;
const isReflectCall =
(node.callee.object || {}).name === "Reflect";
const hasReflectSubstitute = Object.hasOwn(
reflectSubstitutes,
methodName,
);
const userConfiguredException = exceptions.includes(methodName);
if (
hasReflectSubstitute &&
!isReflectCall &&
!userConfiguredException
) {
report(
node,
existingNames[methodName],
reflectSubstitutes[methodName],
);
}
},
UnaryExpression(node) {
const isDeleteOperator = node.operator === "delete";
const targetsIdentifier = node.argument.type === "Identifier";
const userConfiguredException = exceptions.includes("delete");
if (
isDeleteOperator &&
!targetsIdentifier &&
!userConfiguredException
) {
report(
node,
"the delete keyword",
"Reflect.deleteProperty",
);
}
},
};
},
};

View File

@@ -0,0 +1,34 @@
"use strict";
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
Object.defineProperty(exports, "__esModule", { value: true });
exports.boolean = boolean;
exports.string = string;
exports.number = number;
exports.error = error;
exports.func = func;
exports.array = array;
exports.stringArray = stringArray;
function boolean(value) {
return value === true || value === false;
}
function string(value) {
return typeof value === 'string' || value instanceof String;
}
function number(value) {
return typeof value === 'number' || value instanceof Number;
}
function error(value) {
return value instanceof Error;
}
function func(value) {
return typeof value === 'function';
}
function array(value) {
return Array.isArray(value);
}
function stringArray(value) {
return array(value) && value.every(elem => string(elem));
}

View File

@@ -0,0 +1,28 @@
# 🌈 tinyrainbow
> Output your colorful messages in the terminal or browser console that support ANSI colors (Chrome engines).
Originally a fork of [picocolors](https://www.npmjs.com/package/picocolors), tinyrainbow is a tiny and fast library for coloring terminal output.
It is published as ES modules and supports TypeScript out of the box.
## Installing
```bash
# with npm
$ npm install -D tinyrainbow
# with pnpm
$ pnpm add -D tinyrainbow
# with yarn
$ yarn add -D tinyrainbow
```
## Usage
```js
import c from 'tinyrainbow'
console.log(c.red(c.bold('Hello World!')))
```

View File

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

View File

@@ -0,0 +1,174 @@
"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"));
function getArmenianPlural(count, one, many) {
return Math.abs(count) === 1 ? one : many;
}
function withDefiniteArticle(word) {
if (!word)
return "";
const vowels = ["ա", "ե", "ը", "ի", "ո", "ու", "օ"];
const lastChar = word[word.length - 1];
return word + (vowels.includes(lastChar) ? "ն" : "ը");
}
const error = () => {
const Sizable = {
string: {
unit: {
one: "նշան",
many: "նշաններ",
},
verb: "ունենալ",
},
file: {
unit: {
one: "բայթ",
many: "բայթեր",
},
verb: "ունենալ",
},
array: {
unit: {
one: "տարր",
many: "տարրեր",
},
verb: "ունենալ",
},
set: {
unit: {
one: "տարր",
many: "տարրեր",
},
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: "IPv4 միջակայք",
cidrv6: "IPv6 միջակայք",
base64: "base64 ձևաչափով տող",
base64url: "base64url ձևաչափով տող",
json_string: "JSON տող",
e164: "E.164 համար",
jwt: "JWT",
template_literal: "մուտք",
};
const TypeDictionary = {
nan: "NaN",
number: "թիվ",
array: "զանգված",
};
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[1])}`;
return `Սխալ տարբերակ․ սպասվում էր հետևյալներից մեկը՝ ${util.joinValues(issue.values, "|")}`;
case "too_big": {
const adj = issue.inclusive ? "<=" : "<";
const sizing = getSizing(issue.origin);
if (sizing) {
const maxValue = Number(issue.maximum);
const unit = getArmenianPlural(maxValue, sizing.unit.one, sizing.unit.many);
return `Չափազանց մեծ արժեք․ սպասվում է, որ ${withDefiniteArticle(issue.origin ?? "արժեք")} կունենա ${adj}${issue.maximum.toString()} ${unit}`;
}
return `Չափազանց մեծ արժեք․ սպասվում է, որ ${withDefiniteArticle(issue.origin ?? "արժեք")} լինի ${adj}${issue.maximum.toString()}`;
}
case "too_small": {
const adj = issue.inclusive ? ">=" : ">";
const sizing = getSizing(issue.origin);
if (sizing) {
const minValue = Number(issue.minimum);
const unit = getArmenianPlural(minValue, sizing.unit.one, sizing.unit.many);
return `Չափազանց փոքր արժեք․ սպասվում է, որ ${withDefiniteArticle(issue.origin)} կունենա ${adj}${issue.minimum.toString()} ${unit}`;
}
return `Չափազանց փոքր արժեք․ սպասվում է, որ ${withDefiniteArticle(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 `Չճանաչված բանալի${issue.keys.length > 1 ? "ներ" : ""}. ${util.joinValues(issue.keys, ", ")}`;
case "invalid_key":
return `Սխալ բանալի ${withDefiniteArticle(issue.origin)}-ում`;
case "invalid_union":
return "Սխալ մուտքագրում";
case "invalid_element":
return `Սխալ արժեք ${withDefiniteArticle(issue.origin)}-ում`;
default:
return `Սխալ մուտքագրում`;
}
};
};
function default_1() {
return {
localeError: error(),
};
}
module.exports = exports.default;