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,246 @@
/**
* @fileoverview Rule to flag fall-through cases in switch statements.
* @author Matt DuVall <http://mattduvall.com/>
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const { directivesPattern } = require("../shared/directives");
const { isAnySegmentReachable } = require("./utils/code-path-utils");
//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------
const DEFAULT_FALLTHROUGH_COMMENT = /falls?\s?through/iu;
/**
* Checks whether or not a given comment string is really a fallthrough comment and not an ESLint directive.
* @param {string} comment The comment string to check.
* @param {RegExp} fallthroughCommentPattern The regular expression used for checking for fallthrough comments.
* @returns {boolean} `true` if the comment string is truly a fallthrough comment.
*/
function isFallThroughComment(comment, fallthroughCommentPattern) {
return (
fallthroughCommentPattern.test(comment) &&
!directivesPattern.test(comment.trim())
);
}
/**
* Checks whether or not a given case has a fallthrough comment.
* @param {ASTNode} caseWhichFallsThrough SwitchCase node which falls through.
* @param {ASTNode} subsequentCase The case after caseWhichFallsThrough.
* @param {RuleContext} context A rule context which stores comments.
* @param {RegExp} fallthroughCommentPattern A pattern to match comment to.
* @returns {null | object} the comment if the case has a valid fallthrough comment, otherwise null
*/
function getFallthroughComment(
caseWhichFallsThrough,
subsequentCase,
context,
fallthroughCommentPattern,
) {
const sourceCode = context.sourceCode;
if (
caseWhichFallsThrough.consequent.length === 1 &&
caseWhichFallsThrough.consequent[0].type === "BlockStatement"
) {
const trailingCloseBrace = sourceCode.getLastToken(
caseWhichFallsThrough.consequent[0],
);
const commentInBlock = sourceCode
.getCommentsBefore(trailingCloseBrace)
.pop();
if (
commentInBlock &&
isFallThroughComment(
commentInBlock.value,
fallthroughCommentPattern,
)
) {
return commentInBlock;
}
}
const comment = sourceCode.getCommentsBefore(subsequentCase).pop();
if (
comment &&
isFallThroughComment(comment.value, fallthroughCommentPattern)
) {
return comment;
}
return null;
}
/**
* Checks whether a node and a token are separated by blank lines
* @param {ASTNode} node The node to check
* @param {Token} token The token to compare against
* @returns {boolean} `true` if there are blank lines between node and token
*/
function hasBlankLinesBetween(node, token) {
return token.loc.start.line > node.loc.end.line + 1;
}
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../types').Rule.RuleModule} */
module.exports = {
meta: {
type: "problem",
defaultOptions: [
{
allowEmptyCase: false,
reportUnusedFallthroughComment: false,
},
],
docs: {
description: "Disallow fallthrough of `case` statements",
recommended: true,
url: "https://eslint.org/docs/latest/rules/no-fallthrough",
},
schema: [
{
type: "object",
properties: {
commentPattern: {
type: "string",
},
allowEmptyCase: {
type: "boolean",
},
reportUnusedFallthroughComment: {
type: "boolean",
},
},
additionalProperties: false,
},
],
messages: {
unusedFallthroughComment:
"Found a comment that would permit fallthrough, but case cannot fall through.",
case: "Expected a 'break' statement before 'case'.",
default: "Expected a 'break' statement before 'default'.",
},
},
create(context) {
const codePathSegments = [];
let currentCodePathSegments = new Set();
const sourceCode = context.sourceCode;
const [
{ allowEmptyCase, commentPattern, reportUnusedFallthroughComment },
] = context.options;
const fallthroughCommentPattern = commentPattern
? new RegExp(commentPattern, "u")
: DEFAULT_FALLTHROUGH_COMMENT;
/*
* We need to use leading comments of the next SwitchCase node because
* trailing comments is wrong if semicolons are omitted.
*/
let previousCase = null;
return {
onCodePathStart() {
codePathSegments.push(currentCodePathSegments);
currentCodePathSegments = new Set();
},
onCodePathEnd() {
currentCodePathSegments = codePathSegments.pop();
},
onUnreachableCodePathSegmentStart(segment) {
currentCodePathSegments.add(segment);
},
onUnreachableCodePathSegmentEnd(segment) {
currentCodePathSegments.delete(segment);
},
onCodePathSegmentStart(segment) {
currentCodePathSegments.add(segment);
},
onCodePathSegmentEnd(segment) {
currentCodePathSegments.delete(segment);
},
SwitchCase(node) {
/*
* Checks whether or not there is a fallthrough comment.
* And reports the previous fallthrough node if that does not exist.
*/
if (previousCase && previousCase.node.parent === node.parent) {
const previousCaseFallthroughComment =
getFallthroughComment(
previousCase.node,
node,
context,
fallthroughCommentPattern,
);
if (
previousCase.isFallthrough &&
!previousCaseFallthroughComment
) {
context.report({
messageId: node.test ? "case" : "default",
node,
});
} else if (
reportUnusedFallthroughComment &&
!previousCase.isSwitchExitReachable &&
previousCaseFallthroughComment
) {
context.report({
messageId: "unusedFallthroughComment",
node: previousCaseFallthroughComment,
});
}
}
previousCase = null;
},
"SwitchCase:exit"(node) {
const nextToken = sourceCode.getTokenAfter(node);
/*
* `reachable` meant fall through because statements preceded by
* `break`, `return`, or `throw` are unreachable.
* And allows empty cases and the last case.
*/
const isSwitchExitReachable = isAnySegmentReachable(
currentCodePathSegments,
);
const isFallthrough =
isSwitchExitReachable &&
(node.consequent.length > 0 ||
(!allowEmptyCase &&
hasBlankLinesBetween(node, nextToken))) &&
node.parent.cases.at(-1) !== node;
previousCase = {
node,
isSwitchExitReachable,
isFallthrough,
};
},
};
},
};

View File

@@ -0,0 +1,63 @@
text-encoding-utf-8
==============
This is a **partial** polyfill for the [Encoding Living Standard](https://encoding.spec.whatwg.org/)
API for the Web, allowing encoding and decoding of textual data to and from Typed Array
buffers for binary data in JavaScript.
This is fork of [text-encoding](https://github.com/inexorabletash/text-encoding)
that **only** support **UTF-8**.
Basic examples and tests are included.
### Install ###
There are a few ways you can get the `text-encoding-utf-8` library.
#### Node ####
`text-encoding-utf-8` is on `npm`. Simply run:
```js
npm install text-encoding-utf-8
```
Or add it to your `package.json` dependencies.
### HTML Page Usage ###
```html
<script src="encoding.js"></script>
```
### API Overview ###
Basic Usage
```js
var uint8array = TextEncoder(encoding).encode(string);
var string = TextDecoder(encoding).decode(uint8array);
```
Streaming Decode
```js
var string = "", decoder = TextDecoder(encoding), buffer;
while (buffer = next_chunk()) {
string += decoder.decode(buffer, {stream:true});
}
string += decoder.decode(); // finish the stream
```
### Encodings ###
Only `utf-8` and `UTF-8` are supported.
### Non-Standard Behavior ###
Only `utf-8` and `UTF-8` are supported.
### Motivation
Binary size matters, especially on a mobile phone. Safari on iOS does not
support TextDecoder or TextEncoder.

View File

@@ -0,0 +1,133 @@
export var util;
(function (util) {
util.assertEqual = (_) => { };
function assertIs(_arg) { }
util.assertIs = assertIs;
function assertNever(_x) {
throw new Error();
}
util.assertNever = assertNever;
util.arrayToEnum = (items) => {
const obj = {};
for (const item of items) {
obj[item] = item;
}
return obj;
};
util.getValidEnumValues = (obj) => {
const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
const filtered = {};
for (const k of validKeys) {
filtered[k] = obj[k];
}
return util.objectValues(filtered);
};
util.objectValues = (obj) => {
return util.objectKeys(obj).map(function (e) {
return obj[e];
});
};
util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban
? (obj) => Object.keys(obj) // eslint-disable-line ban/ban
: (object) => {
const keys = [];
for (const key in object) {
if (Object.prototype.hasOwnProperty.call(object, key)) {
keys.push(key);
}
}
return keys;
};
util.find = (arr, checker) => {
for (const item of arr) {
if (checker(item))
return item;
}
return undefined;
};
util.isInteger = typeof Number.isInteger === "function"
? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
: (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
function joinValues(array, separator = " | ") {
return array.map((val) => (typeof val === "string" ? `'${val}'` : val)).join(separator);
}
util.joinValues = joinValues;
util.jsonStringifyReplacer = (_, value) => {
if (typeof value === "bigint") {
return value.toString();
}
return value;
};
})(util || (util = {}));
export var objectUtil;
(function (objectUtil) {
objectUtil.mergeShapes = (first, second) => {
return {
...first,
...second, // second overwrites first
};
};
})(objectUtil || (objectUtil = {}));
export const ZodParsedType = util.arrayToEnum([
"string",
"nan",
"number",
"integer",
"float",
"boolean",
"date",
"bigint",
"symbol",
"function",
"undefined",
"null",
"array",
"object",
"unknown",
"promise",
"void",
"never",
"map",
"set",
]);
export const getParsedType = (data) => {
const t = typeof data;
switch (t) {
case "undefined":
return ZodParsedType.undefined;
case "string":
return ZodParsedType.string;
case "number":
return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
case "boolean":
return ZodParsedType.boolean;
case "function":
return ZodParsedType.function;
case "bigint":
return ZodParsedType.bigint;
case "symbol":
return ZodParsedType.symbol;
case "object":
if (Array.isArray(data)) {
return ZodParsedType.array;
}
if (data === null) {
return ZodParsedType.null;
}
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
return ZodParsedType.promise;
}
if (typeof Map !== "undefined" && data instanceof Map) {
return ZodParsedType.map;
}
if (typeof Set !== "undefined" && data instanceof Set) {
return ZodParsedType.set;
}
if (typeof Date !== "undefined" && data instanceof Date) {
return ZodParsedType.date;
}
return ZodParsedType.object;
default:
return ZodParsedType.unknown;
}
};

View File

@@ -0,0 +1 @@
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["src/misc.ts"],"names":[],"mappings":"AAUA,OAAO,EAEL,KAAK,OAAO,EAEZ,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAe,KAAK,OAAO,IAAI,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAgBlF,8DAA8D;AAC9D,eAAO,MAAM,MAAM,EAAE,OAInB,CAAC;AAWH,gEAAgE;AAChE,eAAO,MAAM,UAAU,EAAE,OAIvB,CAAC;AAOH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,GAAG,YAAY,CAU3F;AAKD,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,GAAG,YAAY,CAW7F;AAID,eAAO,MAAM,OAAO,EAAE,MAErB,CAAC;AACF,eAAO,MAAM,OAAO,EAAE,MAErB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,QASnB,CAAC;AACH;;GAEG;AACH,eAAO,MAAM,KAAK,EAAE,QASlB,CAAC"}

View File

@@ -0,0 +1,291 @@
import type { Parser as ParserType } from './Parser';
import type * as ParserOptionsTypes from './ParserOptions';
import type { Processor as ProcessorType } from './Processor';
import type { LooseRuleDefinition, SharedConfigurationSettings } from './Rule';
/** @internal */
export declare namespace SharedConfig {
type Severity = 0 | 1 | 2;
type SeverityString = 'error' | 'off' | 'warn';
type RuleLevel = Severity | SeverityString;
type RuleLevelAndOptions = [RuleLevel, ...unknown[]];
type RuleEntry = RuleLevel | RuleLevelAndOptions;
type RulesRecord = Partial<Record<string, RuleEntry>>;
type GlobalVariableOptionBase = 'off' | /** @deprecated use `'readonly'` */ 'readable' | 'readonly' | 'writable' | /** @deprecated use `'writable'` */ 'writeable';
type GlobalVariableOptionBoolean = /** @deprecated use `'readonly'` */ false | /** @deprecated use `'writable'` */ true;
type GlobalVariableOption = GlobalVariableOptionBase | GlobalVariableOptionBoolean;
interface GlobalsConfig {
[name: string]: GlobalVariableOption;
}
interface EnvironmentConfig {
[name: string]: boolean;
}
type ParserOptions = ParserOptionsTypes.ParserOptions;
interface PluginMeta {
/**
* The meta.name property should match the npm package name for your plugin.
*/
name: string;
/**
* If you followed the classic style to name your package
* (e.g. `eslint-plugin-X`, `@X/eslint-plugin`, or `@X/eslint-plugin-Y`),
* then this should match the classic namespace inferred for your package
* (e.g. `X`, `@X`, or `@X/Y`, respectively).
*/
namespace?: string;
/**
* The meta.version property should match the npm package version for your plugin.
*/
version: string;
}
}
export declare namespace ClassicConfig {
export type EnvironmentConfig = SharedConfig.EnvironmentConfig;
export type GlobalsConfig = SharedConfig.GlobalsConfig;
export type GlobalVariableOption = SharedConfig.GlobalVariableOption;
export type GlobalVariableOptionBase = SharedConfig.GlobalVariableOptionBase;
export type ParserOptions = SharedConfig.ParserOptions;
export type RuleEntry = SharedConfig.RuleEntry;
export type RuleLevel = SharedConfig.RuleLevel;
export type RuleLevelAndOptions = SharedConfig.RuleLevelAndOptions;
export type RulesRecord = SharedConfig.RulesRecord;
export type Severity = SharedConfig.Severity;
export type SeverityString = SharedConfig.SeverityString;
interface BaseConfig {
$schema?: string;
/**
* The environment settings.
*/
env?: EnvironmentConfig;
/**
* The path to other config files or the package name of shareable configs.
*/
extends?: string | string[];
/**
* The global variable settings.
*/
globals?: GlobalsConfig;
/**
* The flag that disables comment directives.
*/
noInlineConfig?: boolean;
/**
* The override settings per kind of files.
*/
overrides?: ConfigOverride[];
/**
* The path to a parser or the package name of a parser.
*/
parser?: string | null;
/**
* The parser options.
*/
parserOptions?: ParserOptions;
/**
* The plugin specifiers.
*/
plugins?: string[];
/**
* The processor specifier.
*/
processor?: string;
/**
* The flag to report unused `eslint-disable` comments.
*/
reportUnusedDisableDirectives?: boolean;
/**
* The rule settings.
*/
rules?: RulesRecord;
/**
* The shared settings.
*/
settings?: SharedConfigurationSettings;
}
export interface ConfigOverride extends BaseConfig {
excludedFiles?: string | string[];
files: string | string[];
}
export interface Config extends BaseConfig {
/**
* The glob patterns that ignore to lint.
*/
ignorePatterns?: string | string[];
/**
* The root flag.
*/
root?: boolean;
}
export {};
}
export declare namespace FlatConfig {
type EcmaVersion = ParserOptionsTypes.EcmaVersion;
type GlobalsConfig = SharedConfig.GlobalsConfig;
type Parser = ParserType.LooseParserModule;
type ParserOptions = SharedConfig.ParserOptions;
type PluginMeta = SharedConfig.PluginMeta;
type Processor = ProcessorType.LooseProcessorModule;
type RuleEntry = SharedConfig.RuleEntry;
type RuleLevel = SharedConfig.RuleLevel;
type RuleLevelAndOptions = SharedConfig.RuleLevelAndOptions;
type Rules = SharedConfig.RulesRecord;
type Settings = SharedConfigurationSettings;
type Severity = SharedConfig.Severity;
type SeverityString = SharedConfig.SeverityString;
type SourceType = 'commonjs' | ParserOptionsTypes.SourceType;
interface SharedConfigs {
[key: string]: Config | ConfigArray;
}
interface Plugin {
/**
* Shared configurations bundled with the plugin.
* Users will reference these directly in their config (i.e. `plugin.configs.recommended`).
*/
configs?: SharedConfigs;
/**
* Metadata about your plugin for easier debugging and more effective caching of plugins.
*/
meta?: {
[K in keyof PluginMeta]?: PluginMeta[K] | undefined;
};
/**
* The definition of plugin processors.
* Users can stringly reference the processor using the key in their config (i.e., `"pluginName/processorName"`).
*/
processors?: Partial<Record<string, Processor>> | undefined;
/**
* The definition of plugin rules.
* The key must be the name of the rule that users will use
* Users can stringly reference the rule using the key they registered the plugin under combined with the rule name.
* i.e. for the user config `plugins: { foo: pluginReference }` - the reference would be `"foo/ruleName"`.
*/
rules?: Record<string, LooseRuleDefinition> | undefined;
}
interface Plugins {
/**
* We intentionally omit the `configs` key from this object because it avoids
* type conflicts with old plugins that haven't updated their configs to flat configs yet.
* It's valid to reference these old plugins because ESLint won't access the
* `.config` property of a plugin when evaluating a flat config.
*/
[pluginAlias: string]: Omit<Plugin, 'configs'>;
}
interface LinterOptions {
/**
* A Boolean value indicating if inline configuration is allowed.
*/
noInlineConfig?: boolean;
/**
* A severity string indicating if and how unused disable and enable
* directives should be tracked and reported. For legacy compatibility, `true`
* is equivalent to `"warn"` and `false` is equivalent to `"off"`.
* @default "warn"
*/
reportUnusedDisableDirectives?: boolean | SharedConfig.Severity | SharedConfig.SeverityString;
/**
* A severity string indicating if and how unused inline directives
* should be tracked and reported.
*
* since ESLint 9.19.0
* @default "off"
*/
reportUnusedInlineConfigs?: SharedConfig.Severity | SharedConfig.SeverityString;
}
interface LanguageOptions {
/**
* The version of ECMAScript to support.
* May be any year (i.e., `2022`) or version (i.e., `5`).
* Set to `"latest"` for the most recent supported version.
* @default "latest"
*/
ecmaVersion?: EcmaVersion | undefined;
/**
* An object specifying additional objects that should be added to the global scope during linting.
*/
globals?: GlobalsConfig | undefined;
/**
* An object containing a `parse()` method or a `parseForESLint()` method.
* @default
* ```
* // https://github.com/eslint/espree
* require('espree')
* ```
*/
parser?: Parser | undefined;
/**
* An object specifying additional options that are passed directly to the parser.
* The available options are parser-dependent.
*/
parserOptions?: ParserOptions | undefined;
/**
* The type of JavaScript source code.
* Possible values are `"script"` for traditional script files, `"module"` for ECMAScript modules (ESM), and `"commonjs"` for CommonJS files.
* @default
* ```
* // for `.js` and `.mjs` files
* "module"
* // for `.cjs` files
* "commonjs"
* ```
*/
sourceType?: SourceType | undefined;
}
interface Config {
/**
* The base path for files and ignores.
*
* Note that this is not permitted inside an `extends` array.
*
* Since ESLint 9.30.0
*/
basePath?: string;
/**
* An array of glob patterns indicating the files that the configuration object should apply to.
* If not specified, the configuration object applies to all files matched by any other configuration object.
*/
files?: (string | string[])[];
/**
* An array of glob patterns indicating the files that the configuration object should not apply to.
* If not specified, the configuration object applies to all files matched by files.
*/
ignores?: string[];
/**
* Language specifier in the form `namespace/language-name` where `namespace` is a plugin name set in the `plugins` field.
*/
language?: string;
/**
* An object containing settings related to how JavaScript is configured for linting.
*/
languageOptions?: LanguageOptions;
/**
* An object containing settings related to the linting process.
*/
linterOptions?: LinterOptions;
/**
* An string to identify the configuration object. Used in error messages and inspection tools.
*/
name?: string;
/**
* An object containing a name-value mapping of plugin names to plugin objects.
* When `files` is specified, these plugins are only available to the matching files.
*/
plugins?: Plugins;
/**
* Either an object containing `preprocess()` and `postprocess()` methods or
* a string indicating the name of a processor inside of a plugin
* (i.e., `"pluginName/processorName"`).
*/
processor?: string | Processor;
/**
* An object containing the configured rules.
* When `files` or `ignores` are specified, these rule configurations are only available to the matching files.
*/
rules?: Rules;
/**
* An object containing name-value pairs of information that should be available to all rules.
*/
settings?: Settings;
}
type ConfigArray = Config[];
type ConfigPromise = Promise<ConfigArray>;
type ConfigFile = ConfigArray | ConfigPromise;
}

View File

@@ -0,0 +1 @@
{"version":3,"file":"_u64.d.ts","sourceRoot":"","sources":["../src/_u64.ts"],"names":[],"mappings":"AAQA,iBAAS,OAAO,CACd,CAAC,EAAE,MAAM,EACT,EAAE,UAAQ,GACT;IACD,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAGA;AAED,iBAAS,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,UAAQ,GAAG,WAAW,EAAE,CASvD;AAED,QAAA,MAAM,KAAK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EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAAC,GAAG,EAAE,OAAO,GAAG,CAAC;IAAC,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;CAOrpC,CAAC;AACF,eAAe,GAAG,CAAC"}

View File

@@ -0,0 +1,53 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
commit-message:
# Prefix all commit messages with "chore: "
prefix: "chore"
schedule:
interval: "weekly"
cooldown:
default-days: 7
allow:
- dependency-name: "*"
update-types:
- "version-update:semver-major"
open-pull-requests-limit: 10
- package-ecosystem: "npm"
directory: "/"
commit-message:
# Prefix all commit messages with "chore: "
prefix: "chore"
schedule:
interval: "weekly"
cooldown:
default-days: 7
versioning-strategy: "increase-if-necessary"
allow:
- dependency-name: "*"
update-types:
- "version-update:semver-major"
ignore:
# TODO: remove ignore until neostandard support ESLint 10
- dependency-name: "eslint"
- dependency-name: "neostandard"
- dependency-name: "@stylistic/*"
open-pull-requests-limit: 10
groups:
# Production dependencies with breaking changes
dependencies:
dependency-type: "production"
# ESLint related dependencies
dev-dependencies-eslint:
patterns:
- "eslint"
- "neostandard"
- "@stylistic/*"
# TypeScript related dependencies
dev-dependencies-typescript:
patterns:
- "@types/*"
- "tstyche"
- "typescript"

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = void 0;
exports.version = {
major: 4,
minor: 4,
patch: 3,
};

View File

@@ -0,0 +1,211 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._DST_scalar = void 0;
exports.expand_message_xmd = expand_message_xmd;
exports.expand_message_xof = expand_message_xof;
exports.hash_to_field = hash_to_field;
exports.isogenyMap = isogenyMap;
exports.createHasher = createHasher;
const utils_ts_1 = require("../utils.js");
const modular_ts_1 = require("./modular.js");
// Octet Stream to Integer. "spec" implementation of os2ip is 2.5x slower vs bytesToNumberBE.
const os2ip = utils_ts_1.bytesToNumberBE;
// Integer to Octet Stream (numberToBytesBE)
function i2osp(value, length) {
anum(value);
anum(length);
if (value < 0 || value >= 1 << (8 * length))
throw new Error('invalid I2OSP input: ' + value);
const res = Array.from({ length }).fill(0);
for (let i = length - 1; i >= 0; i--) {
res[i] = value & 0xff;
value >>>= 8;
}
return new Uint8Array(res);
}
function strxor(a, b) {
const arr = new Uint8Array(a.length);
for (let i = 0; i < a.length; i++) {
arr[i] = a[i] ^ b[i];
}
return arr;
}
function anum(item) {
if (!Number.isSafeInteger(item))
throw new Error('number expected');
}
function normDST(DST) {
if (!(0, utils_ts_1.isBytes)(DST) && typeof DST !== 'string')
throw new Error('DST must be Uint8Array or string');
return typeof DST === 'string' ? (0, utils_ts_1.utf8ToBytes)(DST) : DST;
}
/**
* Produces a uniformly random byte string using a cryptographic hash function H that outputs b bits.
* [RFC 9380 5.3.1](https://www.rfc-editor.org/rfc/rfc9380#section-5.3.1).
*/
function expand_message_xmd(msg, DST, lenInBytes, H) {
(0, utils_ts_1.abytes)(msg);
anum(lenInBytes);
DST = normDST(DST);
// https://www.rfc-editor.org/rfc/rfc9380#section-5.3.3
if (DST.length > 255)
DST = H((0, utils_ts_1.concatBytes)((0, utils_ts_1.utf8ToBytes)('H2C-OVERSIZE-DST-'), DST));
const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H;
const ell = Math.ceil(lenInBytes / b_in_bytes);
if (lenInBytes > 65535 || ell > 255)
throw new Error('expand_message_xmd: invalid lenInBytes');
const DST_prime = (0, utils_ts_1.concatBytes)(DST, i2osp(DST.length, 1));
const Z_pad = i2osp(0, r_in_bytes);
const l_i_b_str = i2osp(lenInBytes, 2); // len_in_bytes_str
const b = new Array(ell);
const b_0 = H((0, utils_ts_1.concatBytes)(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime));
b[0] = H((0, utils_ts_1.concatBytes)(b_0, i2osp(1, 1), DST_prime));
for (let i = 1; i <= ell; i++) {
const args = [strxor(b_0, b[i - 1]), i2osp(i + 1, 1), DST_prime];
b[i] = H((0, utils_ts_1.concatBytes)(...args));
}
const pseudo_random_bytes = (0, utils_ts_1.concatBytes)(...b);
return pseudo_random_bytes.slice(0, lenInBytes);
}
/**
* Produces a uniformly random byte string using an extendable-output function (XOF) H.
* 1. The collision resistance of H MUST be at least k bits.
* 2. H MUST be an XOF that has been proved indifferentiable from
* a random oracle under a reasonable cryptographic assumption.
* [RFC 9380 5.3.2](https://www.rfc-editor.org/rfc/rfc9380#section-5.3.2).
*/
function expand_message_xof(msg, DST, lenInBytes, k, H) {
(0, utils_ts_1.abytes)(msg);
anum(lenInBytes);
DST = normDST(DST);
// https://www.rfc-editor.org/rfc/rfc9380#section-5.3.3
// DST = H('H2C-OVERSIZE-DST-' || a_very_long_DST, Math.ceil((lenInBytes * k) / 8));
if (DST.length > 255) {
const dkLen = Math.ceil((2 * k) / 8);
DST = H.create({ dkLen }).update((0, utils_ts_1.utf8ToBytes)('H2C-OVERSIZE-DST-')).update(DST).digest();
}
if (lenInBytes > 65535 || DST.length > 255)
throw new Error('expand_message_xof: invalid lenInBytes');
return (H.create({ dkLen: lenInBytes })
.update(msg)
.update(i2osp(lenInBytes, 2))
// 2. DST_prime = DST || I2OSP(len(DST), 1)
.update(DST)
.update(i2osp(DST.length, 1))
.digest());
}
/**
* Hashes arbitrary-length byte strings to a list of one or more elements of a finite field F.
* [RFC 9380 5.2](https://www.rfc-editor.org/rfc/rfc9380#section-5.2).
* @param msg a byte string containing the message to hash
* @param count the number of elements of F to output
* @param options `{DST: string, p: bigint, m: number, k: number, expand: 'xmd' | 'xof', hash: H}`, see above
* @returns [u_0, ..., u_(count - 1)], a list of field elements.
*/
function hash_to_field(msg, count, options) {
(0, utils_ts_1._validateObject)(options, {
p: 'bigint',
m: 'number',
k: 'number',
hash: 'function',
});
const { p, k, m, hash, expand, DST } = options;
if (!(0, utils_ts_1.isHash)(options.hash))
throw new Error('expected valid hash');
(0, utils_ts_1.abytes)(msg);
anum(count);
const log2p = p.toString(2).length;
const L = Math.ceil((log2p + k) / 8); // section 5.1 of ietf draft link above
const len_in_bytes = count * m * L;
let prb; // pseudo_random_bytes
if (expand === 'xmd') {
prb = expand_message_xmd(msg, DST, len_in_bytes, hash);
}
else if (expand === 'xof') {
prb = expand_message_xof(msg, DST, len_in_bytes, k, hash);
}
else if (expand === '_internal_pass') {
// for internal tests only
prb = msg;
}
else {
throw new Error('expand must be "xmd" or "xof"');
}
const u = new Array(count);
for (let i = 0; i < count; i++) {
const e = new Array(m);
for (let j = 0; j < m; j++) {
const elm_offset = L * (j + i * m);
const tv = prb.subarray(elm_offset, elm_offset + L);
e[j] = (0, modular_ts_1.mod)(os2ip(tv), p);
}
u[i] = e;
}
return u;
}
function isogenyMap(field, map) {
// Make same order as in spec
const coeff = map.map((i) => Array.from(i).reverse());
return (x, y) => {
const [xn, xd, yn, yd] = coeff.map((val) => val.reduce((acc, i) => field.add(field.mul(acc, x), i)));
// 6.6.3
// Exceptional cases of iso_map are inputs that cause the denominator of
// either rational function to evaluate to zero; such cases MUST return
// the identity point on E.
const [xd_inv, yd_inv] = (0, modular_ts_1.FpInvertBatch)(field, [xd, yd], true);
x = field.mul(xn, xd_inv); // xNum / xDen
y = field.mul(y, field.mul(yn, yd_inv)); // y * (yNum / yDev)
return { x, y };
};
}
exports._DST_scalar = (0, utils_ts_1.utf8ToBytes)('HashToScalar-');
/** Creates hash-to-curve methods from EC Point and mapToCurve function. See {@link H2CHasher}. */
function createHasher(Point, mapToCurve, defaults) {
if (typeof mapToCurve !== 'function')
throw new Error('mapToCurve() must be defined');
function map(num) {
return Point.fromAffine(mapToCurve(num));
}
function clear(initial) {
const P = initial.clearCofactor();
if (P.equals(Point.ZERO))
return Point.ZERO; // zero will throw in assert
P.assertValidity();
return P;
}
return {
defaults,
hashToCurve(msg, options) {
const opts = Object.assign({}, defaults, options);
const u = hash_to_field(msg, 2, opts);
const u0 = map(u[0]);
const u1 = map(u[1]);
return clear(u0.add(u1));
},
encodeToCurve(msg, options) {
const optsDst = defaults.encodeDST ? { DST: defaults.encodeDST } : {};
const opts = Object.assign({}, defaults, optsDst, options);
const u = hash_to_field(msg, 1, opts);
const u0 = map(u[0]);
return clear(u0);
},
/** See {@link H2CHasher} */
mapToCurve(scalars) {
if (!Array.isArray(scalars))
throw new Error('expected array of bigints');
for (const i of scalars)
if (typeof i !== 'bigint')
throw new Error('expected array of bigints');
return clear(map(scalars));
},
// hash_to_scalar can produce 0: https://www.rfc-editor.org/errata/eid8393
// RFC 9380, draft-irtf-cfrg-bbs-signatures-08
hashToScalar(msg, options) {
// @ts-ignore
const N = Point.Fn.ORDER;
const opts = Object.assign({}, defaults, { p: N, m: 1, DST: exports._DST_scalar }, options);
return hash_to_field(msg, 1, opts)[0][0];
},
};
}
//# sourceMappingURL=hash-to-curve.js.map

View File

@@ -0,0 +1,23 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABILITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference lib="es2024" />
/// <reference lib="es2025.collection" />
/// <reference lib="es2025.float16" />
/// <reference lib="es2025.intl" />
/// <reference lib="es2025.iterator" />
/// <reference lib="es2025.promise" />
/// <reference lib="es2025.regexp" />

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAIA,sBAIC;AARD,yCAA0C;AAUtB,8FAVX,wBAAa,OAUW;AATjC,6CAAwC;AAS/B,0FATA,sBAAS,OASA;AARlB,qCAAkD;AAElD,SAAgB,KAAK,CAAC,MAA6B,EAAE,QAAyB;IAC5E,MAAM,MAAM,GAAG,IAAI,eAAM,EAAE,CAAA;IAC3B,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAA;IACrE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;AACpE,CAAC"}

View File

@@ -0,0 +1,142 @@
// @ts-ignore TS6133
import { expect, test } from "vitest";
import * as z from "zod/v3";
import { ZodIssueCode } from "zod/v3";
import { util } from "../helpers/util.js";
const stringSet = z.set(z.string());
type stringSet = z.infer<typeof stringSet>;
const minTwo = z.set(z.string()).min(2);
const maxTwo = z.set(z.string()).max(2);
const justTwo = z.set(z.string()).size(2);
const nonEmpty = z.set(z.string()).nonempty();
const nonEmptyMax = z.set(z.string()).nonempty().max(2);
test("type inference", () => {
util.assertEqual<stringSet, Set<string>>(true);
});
test("valid parse", () => {
const result = stringSet.safeParse(new Set(["first", "second"]));
expect(result.success).toEqual(true);
if (result.success) {
expect(result.data.has("first")).toEqual(true);
expect(result.data.has("second")).toEqual(true);
expect(result.data.has("third")).toEqual(false);
}
expect(() => {
minTwo.parse(new Set(["a", "b"]));
minTwo.parse(new Set(["a", "b", "c"]));
maxTwo.parse(new Set(["a", "b"]));
maxTwo.parse(new Set(["a"]));
justTwo.parse(new Set(["a", "b"]));
nonEmpty.parse(new Set(["a"]));
nonEmptyMax.parse(new Set(["a"]));
}).not.toThrow();
});
test("valid parse async", async () => {
const result = await stringSet.spa(new Set(["first", "second"]));
expect(result.success).toEqual(true);
if (result.success) {
expect(result.data.has("first")).toEqual(true);
expect(result.data.has("second")).toEqual(true);
expect(result.data.has("third")).toEqual(false);
}
const asyncResult = await stringSet.safeParse(new Set(["first", "second"]));
expect(asyncResult.success).toEqual(true);
if (asyncResult.success) {
expect(asyncResult.data.has("first")).toEqual(true);
expect(asyncResult.data.has("second")).toEqual(true);
expect(asyncResult.data.has("third")).toEqual(false);
}
});
test("valid parse: size-related methods", () => {
expect(() => {
minTwo.parse(new Set(["a", "b"]));
minTwo.parse(new Set(["a", "b", "c"]));
maxTwo.parse(new Set(["a", "b"]));
maxTwo.parse(new Set(["a"]));
justTwo.parse(new Set(["a", "b"]));
nonEmpty.parse(new Set(["a"]));
nonEmptyMax.parse(new Set(["a"]));
}).not.toThrow();
const sizeZeroResult = stringSet.parse(new Set());
expect(sizeZeroResult.size).toBe(0);
const sizeTwoResult = minTwo.parse(new Set(["a", "b"]));
expect(sizeTwoResult.size).toBe(2);
});
test("failing when parsing empty set in nonempty ", () => {
const result = nonEmpty.safeParse(new Set());
expect(result.success).toEqual(false);
if (result.success === false) {
expect(result.error.issues.length).toEqual(1);
expect(result.error.issues[0].code).toEqual(ZodIssueCode.too_small);
}
});
test("failing when set is smaller than min() ", () => {
const result = minTwo.safeParse(new Set(["just_one"]));
expect(result.success).toEqual(false);
if (result.success === false) {
expect(result.error.issues.length).toEqual(1);
expect(result.error.issues[0].code).toEqual(ZodIssueCode.too_small);
}
});
test("failing when set is bigger than max() ", () => {
const result = maxTwo.safeParse(new Set(["one", "two", "three"]));
expect(result.success).toEqual(false);
if (result.success === false) {
expect(result.error.issues.length).toEqual(1);
expect(result.error.issues[0].code).toEqual(ZodIssueCode.too_big);
}
});
test("doesnt throw when an empty set is given", () => {
const result = stringSet.safeParse(new Set([]));
expect(result.success).toEqual(true);
});
test("throws when a Map is given", () => {
const result = stringSet.safeParse(new Map([]));
expect(result.success).toEqual(false);
if (result.success === false) {
expect(result.error.issues.length).toEqual(1);
expect(result.error.issues[0].code).toEqual(ZodIssueCode.invalid_type);
}
});
test("throws when the given set has invalid input", () => {
const result = stringSet.safeParse(new Set([Symbol()]));
expect(result.success).toEqual(false);
if (result.success === false) {
expect(result.error.issues.length).toEqual(1);
expect(result.error.issues[0].code).toEqual(ZodIssueCode.invalid_type);
expect(result.error.issues[0].path).toEqual([0]);
}
});
test("throws when the given set has multiple invalid entries", () => {
const result = stringSet.safeParse(new Set([1, 2] as any[]) as Set<any>);
expect(result.success).toEqual(false);
if (result.success === false) {
expect(result.error.issues.length).toEqual(2);
expect(result.error.issues[0].code).toEqual(ZodIssueCode.invalid_type);
expect(result.error.issues[0].path).toEqual([0]);
expect(result.error.issues[1].code).toEqual(ZodIssueCode.invalid_type);
expect(result.error.issues[1].path).toEqual([1]);
}
});

View File

@@ -0,0 +1 @@
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/schemes/http.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAoB;IAChC,MAAM,EAAG,MAAM;IAEf,UAAU,EAAG,IAAI;IAEjB,KAAK,EAAG,UAAU,UAAwB,EAAE,OAAkB;QAC7D,qBAAqB;QACrB,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;YACrB,UAAU,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,IAAI,6BAA6B,CAAC;SACrE;QAED,OAAO,UAAU,CAAC;IACnB,CAAC;IAED,SAAS,EAAG,UAAU,UAAwB,EAAE,OAAkB;QACjE,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC;QAEnE,4BAA4B;QAC5B,IAAI,UAAU,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,UAAU,CAAC,IAAI,KAAK,EAAE,EAAE;YACtE,UAAU,CAAC,IAAI,GAAG,SAAS,CAAC;SAC5B;QAED,0BAA0B;QAC1B,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;YACrB,UAAU,CAAC,IAAI,GAAG,GAAG,CAAC;SACtB;QAED,mDAAmD;QACnD,oEAAoE;QACpE,wBAAwB;QAExB,OAAO,UAAU,CAAC;IACnB,CAAC;CACD,CAAC;AAEF,eAAe,OAAO,CAAC"}

View File

@@ -0,0 +1,101 @@
export {}; // Make this a module
declare global {
namespace NodeJS {
type TypedArray<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> =
| Uint8Array<TArrayBuffer>
| Uint8ClampedArray<TArrayBuffer>
| Uint16Array<TArrayBuffer>
| Uint32Array<TArrayBuffer>
| Int8Array<TArrayBuffer>
| Int16Array<TArrayBuffer>
| Int32Array<TArrayBuffer>
| BigUint64Array<TArrayBuffer>
| BigInt64Array<TArrayBuffer>
| Float16Array<TArrayBuffer>
| Float32Array<TArrayBuffer>
| Float64Array<TArrayBuffer>;
type ArrayBufferView<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> =
| TypedArray<TArrayBuffer>
| DataView<TArrayBuffer>;
// The following aliases are required to allow use of non-shared ArrayBufferViews in @types/node
// while maintaining compatibility with TS <=5.6.
// TODO: remove once @types/node no longer supports TS 5.6, and replace with native types.
/**
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
* TypeScript versions earlier than 5.7.
*/
type NonSharedUint8Array = Uint8Array<ArrayBuffer>;
/**
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
* TypeScript versions earlier than 5.7.
*/
type NonSharedUint8ClampedArray = Uint8ClampedArray<ArrayBuffer>;
/**
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
* TypeScript versions earlier than 5.7.
*/
type NonSharedUint16Array = Uint16Array<ArrayBuffer>;
/**
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
* TypeScript versions earlier than 5.7.
*/
type NonSharedUint32Array = Uint32Array<ArrayBuffer>;
/**
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
* TypeScript versions earlier than 5.7.
*/
type NonSharedInt8Array = Int8Array<ArrayBuffer>;
/**
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
* TypeScript versions earlier than 5.7.
*/
type NonSharedInt16Array = Int16Array<ArrayBuffer>;
/**
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
* TypeScript versions earlier than 5.7.
*/
type NonSharedInt32Array = Int32Array<ArrayBuffer>;
/**
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
* TypeScript versions earlier than 5.7.
*/
type NonSharedBigUint64Array = BigUint64Array<ArrayBuffer>;
/**
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
* TypeScript versions earlier than 5.7.
*/
type NonSharedBigInt64Array = BigInt64Array<ArrayBuffer>;
/**
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
* TypeScript versions earlier than 5.7.
*/
type NonSharedFloat16Array = Float16Array<ArrayBuffer>;
/**
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
* TypeScript versions earlier than 5.7.
*/
type NonSharedFloat32Array = Float32Array<ArrayBuffer>;
/**
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
* TypeScript versions earlier than 5.7.
*/
type NonSharedFloat64Array = Float64Array<ArrayBuffer>;
/**
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
* TypeScript versions earlier than 5.7.
*/
type NonSharedDataView = DataView<ArrayBuffer>;
/**
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
* TypeScript versions earlier than 5.7.
*/
type NonSharedTypedArray = TypedArray<ArrayBuffer>;
/**
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
* TypeScript versions earlier than 5.7.
*/
type NonSharedArrayBufferView = ArrayBufferView<ArrayBuffer>;
}
}

View File

@@ -0,0 +1,191 @@
Copyright 2024 Misha Kaletsky
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
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

View File

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

View File

@@ -0,0 +1,90 @@
/*! *****************************************************************************
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 Uint8Array<TArrayBuffer extends ArrayBufferLike> {
/**
* Converts the `Uint8Array` to a base64-encoded string.
* @param options If provided, sets the alphabet and padding behavior used.
* @returns A base64-encoded string.
*/
toBase64(
options?: {
alphabet?: "base64" | "base64url" | undefined;
omitPadding?: boolean | undefined;
},
): string;
/**
* Sets the `Uint8Array` from a base64-encoded string.
* @param string The base64-encoded string.
* @param options If provided, specifies the alphabet and handling of the last chunk.
* @returns An object containing the number of bytes read and written.
* @throws {SyntaxError} If the input string contains characters outside the specified alphabet, or if the last
* chunk is inconsistent with the `lastChunkHandling` option.
*/
setFromBase64(
string: string,
options?: {
alphabet?: "base64" | "base64url" | undefined;
lastChunkHandling?: "loose" | "strict" | "stop-before-partial" | undefined;
},
): {
read: number;
written: number;
};
/**
* Converts the `Uint8Array` to a base16-encoded string.
* @returns A base16-encoded string.
*/
toHex(): string;
/**
* Sets the `Uint8Array` from a base16-encoded string.
* @param string The base16-encoded string.
* @returns An object containing the number of bytes read and written.
*/
setFromHex(string: string): {
read: number;
written: number;
};
}
interface Uint8ArrayConstructor {
/**
* Creates a new `Uint8Array` from a base64-encoded string.
* @param string The base64-encoded string.
* @param options If provided, specifies the alphabet and handling of the last chunk.
* @returns A new `Uint8Array` instance.
* @throws {SyntaxError} If the input string contains characters outside the specified alphabet, or if the last
* chunk is inconsistent with the `lastChunkHandling` option.
*/
fromBase64(
string: string,
options?: {
alphabet?: "base64" | "base64url" | undefined;
lastChunkHandling?: "loose" | "strict" | "stop-before-partial" | undefined;
},
): Uint8Array<ArrayBuffer>;
/**
* Creates a new `Uint8Array` from a base16-encoded string.
* @returns A new `Uint8Array` instance.
*/
fromHex(
string: string,
): Uint8Array<ArrayBuffer>;
}

View File

@@ -0,0 +1,152 @@
'use strict';
const { isUtf8 } = require('buffer');
const { hasBlob } = require('./constants');
//
// Allowed token characters:
//
// '!', '#', '$', '%', '&', ''', '*', '+', '-',
// '.', 0-9, A-Z, '^', '_', '`', a-z, '|', '~'
//
// tokenChars[32] === 0 // ' '
// tokenChars[33] === 1 // '!'
// tokenChars[34] === 0 // '"'
// ...
//
// prettier-ignore
const tokenChars = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 - 15
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 - 31
0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, // 32 - 47
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 48 - 63
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 64 - 79
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, // 80 - 95
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 96 - 111
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0 // 112 - 127
];
/**
* Checks if a status code is allowed in a close frame.
*
* @param {Number} code The status code
* @return {Boolean} `true` if the status code is valid, else `false`
* @public
*/
function isValidStatusCode(code) {
return (
(code >= 1000 &&
code <= 1014 &&
code !== 1004 &&
code !== 1005 &&
code !== 1006) ||
(code >= 3000 && code <= 4999)
);
}
/**
* Checks if a given buffer contains only correct UTF-8.
* Ported from https://www.cl.cam.ac.uk/%7Emgk25/ucs/utf8_check.c by
* Markus Kuhn.
*
* @param {Buffer} buf The buffer to check
* @return {Boolean} `true` if `buf` contains only correct UTF-8, else `false`
* @public
*/
function _isValidUTF8(buf) {
const len = buf.length;
let i = 0;
while (i < len) {
if ((buf[i] & 0x80) === 0) {
// 0xxxxxxx
i++;
} else if ((buf[i] & 0xe0) === 0xc0) {
// 110xxxxx 10xxxxxx
if (
i + 1 === len ||
(buf[i + 1] & 0xc0) !== 0x80 ||
(buf[i] & 0xfe) === 0xc0 // Overlong
) {
return false;
}
i += 2;
} else if ((buf[i] & 0xf0) === 0xe0) {
// 1110xxxx 10xxxxxx 10xxxxxx
if (
i + 2 >= len ||
(buf[i + 1] & 0xc0) !== 0x80 ||
(buf[i + 2] & 0xc0) !== 0x80 ||
(buf[i] === 0xe0 && (buf[i + 1] & 0xe0) === 0x80) || // Overlong
(buf[i] === 0xed && (buf[i + 1] & 0xe0) === 0xa0) // Surrogate (U+D800 - U+DFFF)
) {
return false;
}
i += 3;
} else if ((buf[i] & 0xf8) === 0xf0) {
// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
if (
i + 3 >= len ||
(buf[i + 1] & 0xc0) !== 0x80 ||
(buf[i + 2] & 0xc0) !== 0x80 ||
(buf[i + 3] & 0xc0) !== 0x80 ||
(buf[i] === 0xf0 && (buf[i + 1] & 0xf0) === 0x80) || // Overlong
(buf[i] === 0xf4 && buf[i + 1] > 0x8f) ||
buf[i] > 0xf4 // > U+10FFFF
) {
return false;
}
i += 4;
} else {
return false;
}
}
return true;
}
/**
* Determines whether a value is a `Blob`.
*
* @param {*} value The value to be tested
* @return {Boolean} `true` if `value` is a `Blob`, else `false`
* @private
*/
function isBlob(value) {
return (
hasBlob &&
typeof value === 'object' &&
typeof value.arrayBuffer === 'function' &&
typeof value.type === 'string' &&
typeof value.stream === 'function' &&
(value[Symbol.toStringTag] === 'Blob' ||
value[Symbol.toStringTag] === 'File')
);
}
module.exports = {
isBlob,
isValidStatusCode,
isValidUTF8: _isValidUTF8,
tokenChars
};
if (isUtf8) {
module.exports.isValidUTF8 = function (buf) {
return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
};
} /* istanbul ignore else */ else if (!process.env.WS_NO_UTF_8_VALIDATE) {
try {
const isValidUTF8 = require('utf-8-validate');
module.exports.isValidUTF8 = function (buf) {
return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
};
} catch (e) {
// Continue regardless of the error.
}
}

View File

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

View File

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

View File

@@ -0,0 +1,47 @@
declare module "node:sea" {
type AssetKey = string;
/**
* @since v20.12.0
* @return Whether this script is running inside a single-executable application.
*/
function isSea(): boolean;
/**
* This method can be used to retrieve the assets configured to be bundled into the
* single-executable application at build time.
* An error is thrown when no matching asset can be found.
* @since v20.12.0
*/
function getAsset(key: AssetKey): ArrayBuffer;
function getAsset(key: AssetKey, encoding: string): string;
/**
* Similar to `sea.getAsset()`, but returns the result in a [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob).
* An error is thrown when no matching asset can be found.
* @since v20.12.0
*/
function getAssetAsBlob(key: AssetKey, options?: {
type: string;
}): Blob;
/**
* This method can be used to retrieve the assets configured to be bundled into the
* single-executable application at build time.
* An error is thrown when no matching asset can be found.
*
* Unlike `sea.getRawAsset()` or `sea.getAssetAsBlob()`, this method does not
* return a copy. Instead, it returns the raw asset bundled inside the executable.
*
* For now, users should avoid writing to the returned array buffer. If the
* injected section is not marked as writable or not aligned properly,
* writes to the returned array buffer is likely to result in a crash.
* @since v20.12.0
*/
function getRawAsset(key: AssetKey): ArrayBuffer;
/**
* This method can be used to retrieve an array of all the keys of assets
* embedded into the single-executable application.
* An error is thrown when not running inside a single-executable application.
* @since v24.8.0
* @returns An array containing all the keys of the assets
* embedded in the executable. If no assets are embedded, returns an empty array.
*/
function getAssetKeys(): string[];
}

View File

@@ -0,0 +1,46 @@
/**
* @fileoverview Types for the plugin-kit package.
* @author Nicholas C. Zakas
*/
import type { RuleDefinition, RuleDefinitionTypeOptions, RuleVisitor } from "@eslint/core";
/**
* Defaults for non-language-related `RuleDefinition` options.
*/
export interface CustomRuleTypeDefinitions {
RuleOptions: unknown[];
MessageIds: string;
ExtRuleDocs: Record<string, unknown>;
}
/**
* A helper type to define language specific specializations of the `RuleDefinition` type.
*
* @example
* ```ts
* type YourRuleDefinition<
* Options extends Partial<CustomRuleTypeDefinitions> = {},
* > = CustomRuleDefinitionType<
* {
* LangOptions: YourLanguageOptions;
* Code: YourSourceCode;
* Visitor: YourRuleVisitor;
* Node: YourNode;
* },
* Options
* >;
* ```
*/
export type CustomRuleDefinitionType<LanguageSpecificOptions extends Omit<RuleDefinitionTypeOptions, keyof CustomRuleTypeDefinitions>, Options extends Partial<CustomRuleTypeDefinitions>> = RuleDefinition<LanguageSpecificOptions & Required<Options & Omit<CustomRuleTypeDefinitions, keyof Options>>>;
/**
* Adds matching `:exit` selector properties for each key of a `RuleVisitor`.
*/
export type CustomRuleVisitorWithExit<RuleVisitorType extends RuleVisitor> = {
[Key in keyof RuleVisitorType as Key | `${Key & string}:exit`]: RuleVisitorType[Key];
};
/**
* A map of names to string values, or `null` when no value is provided.
*/
export type StringConfig = Record<string, string | null>;
/**
* A map of names to boolean flags.
*/
export type BooleanConfig = Record<string, boolean>;

View File

@@ -0,0 +1 @@
{"version":3,"file":"timing.js","sourceRoot":"","sources":["../../src/api/timing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,kEAAkE;AAClE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AA8HzC,SAAS,iBAAiB;IACtB,OAAO;QACH,YAAY,EAAE,CAAC;QACf,WAAW,EAAE,CAAC;QACd,SAAS,EAAE,CAAC;QACZ,aAAa,EAAE,CAAC;QAChB,YAAY,EAAE,CAAC;QACf,mBAAmB,EAAE,CAAC;QACtB,iBAAiB,EAAE,CAAC;QACpB,kBAAkB,EAAE,CAAC;QACrB,YAAY,EAAE,CAAC;KAClB,CAAC;AACN,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,kBAAkB;IAC9B,OAAO;QACH,OAAO,EAAE,KAAK;QACd,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