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,237 @@
/**
* @fileoverview The Path class.
* @author Nicholas C. Zakas
*/
/* globals URL */
//-----------------------------------------------------------------------------
// Types
//-----------------------------------------------------------------------------
/** @typedef{import("@humanfs/types").HfsImpl} HfsImpl */
/** @typedef{import("@humanfs/types").HfsDirectoryEntry} HfsDirectoryEntry */
//-----------------------------------------------------------------------------
// Helpers
//-----------------------------------------------------------------------------
/**
* Normalizes a path to use forward slashes.
* @param {string} filePath The path to normalize.
* @returns {string} The normalized path.
*/
function normalizePath(filePath) {
let startIndex = 0;
let endIndex = filePath.length;
if (/[a-z]:\//i.test(filePath)) {
startIndex = 3;
}
if (filePath.startsWith("./")) {
startIndex = 2;
}
if (filePath.startsWith("/")) {
startIndex = 1;
}
if (filePath.endsWith("/")) {
endIndex = filePath.length - 1;
}
return filePath.slice(startIndex, endIndex).replace(/\\/g, "/");
}
/**
* Asserts that the given name is a non-empty string, no equal to "." or "..",
* and does not contain a forward slash or backslash.
* @param {string} name The name to check.
* @returns {void}
* @throws {TypeError} When name is not valid.
*/
function assertValidName(name) {
if (typeof name !== "string") {
throw new TypeError("name must be a string");
}
if (!name) {
throw new TypeError("name cannot be empty");
}
if (name === ".") {
throw new TypeError(`name cannot be "."`);
}
if (name === "..") {
throw new TypeError(`name cannot be ".."`);
}
if (name.includes("/") || name.includes("\\")) {
throw new TypeError(
`name cannot contain a slash or backslash: "${name}"`,
);
}
}
//-----------------------------------------------------------------------------
// Exports
//-----------------------------------------------------------------------------
export class Path {
/**
* The steps in the path.
* @type {Array<string>}
*/
#steps;
/**
* Creates a new instance.
* @param {Iterable<string>} [steps] The steps to use for the path.
* @throws {TypeError} When steps is not iterable.
*/
constructor(steps = []) {
if (typeof steps[Symbol.iterator] !== "function") {
throw new TypeError("steps must be iterable");
}
this.#steps = [...steps];
this.#steps.forEach(assertValidName);
}
/**
* Adds steps to the end of the path.
* @param {...string} steps The steps to add to the path.
* @returns {void}
*/
push(...steps) {
steps.forEach(assertValidName);
this.#steps.push(...steps);
}
/**
* Removes the last step from the path.
* @returns {string} The last step in the path.
*/
pop() {
return this.#steps.pop();
}
/**
* Returns an iterator for steps in the path.
* @returns {IterableIterator<string>} An iterator for the steps in the path.
*/
steps() {
return this.#steps.values();
}
/**
* Returns an iterator for the steps in the path.
* @returns {IterableIterator<string>} An iterator for the steps in the path.
*/
[Symbol.iterator]() {
return this.steps();
}
/**
* Retrieves the name (the last step) of the path.
* @type {string}
*/
get name() {
return this.#steps[this.#steps.length - 1];
}
/**
* Sets the name (the last step) of the path.
* @type {string}
*/
set name(value) {
assertValidName(value);
this.#steps[this.#steps.length - 1] = value;
}
/**
* Retrieves the size of the path.
* @type {number}
*/
get size() {
return this.#steps.length;
}
/**
* Returns the path as a string.
* @returns {string} The path as a string.
*/
toString() {
return this.#steps.join("/");
}
/**
* Creates a new path based on the argument type. If the argument is a string,
* it is assumed to be a file or directory path and is converted to a Path
* instance. If the argument is a URL, it is assumed to be a file URL and is
* converted to a Path instance. If the argument is a Path instance, it is
* copied into a new Path instance. If the argument is an array, it is assumed
* to be the steps of a path and is used to create a new Path instance.
* @param {string|URL|Path|Array<string>} pathish The value to convert to a Path instance.
* @returns {Path} A new Path instance.
* @throws {TypeError} When pathish is not a string, URL, Path, or Array.
* @throws {TypeError} When pathish is a string and is empty.
*/
static from(pathish) {
if (typeof pathish === "string") {
if (!pathish) {
throw new TypeError("argument cannot be empty");
}
return Path.fromString(pathish);
}
if (pathish instanceof URL) {
return Path.fromURL(pathish);
}
if (pathish instanceof Path || Array.isArray(pathish)) {
return new Path(pathish);
}
throw new TypeError("argument must be a string, URL, Path, or Array");
}
/**
* Creates a new Path instance from a string.
* @param {string} fileOrDirPath The file or directory path to convert.
* @returns {Path} A new Path instance.
* @deprecated Use Path.from() instead.
*/
static fromString(fileOrDirPath) {
return new Path(normalizePath(fileOrDirPath).split("/"));
}
/**
* Creates a new Path instance from a URL.
* @param {URL} url The URL to convert.
* @returns {Path} A new Path instance.
* @throws {TypeError} When url is not a URL instance.
* @throws {TypeError} When url.pathname is empty.
* @throws {TypeError} When url.protocol is not "file:".
* @deprecated Use Path.from() instead.
*/
static fromURL(url) {
if (!(url instanceof URL)) {
throw new TypeError("url must be a URL instance");
}
if (!url.pathname || url.pathname === "/") {
throw new TypeError("url.pathname cannot be empty");
}
if (url.protocol !== "file:") {
throw new TypeError(`url.protocol must be "file:"`);
}
// Remove leading slash in pathname
return new Path(normalizePath(url.pathname.slice(1)).split("/"));
}
}

View File

@@ -0,0 +1,33 @@
'use strict';
const StreamBase = require('./StreamBase');
const withParser = require('../utils/withParser');
class StreamValues extends StreamBase {
static make(options) {
return new StreamValues(options);
}
static withParser(options) {
return withParser(StreamValues.make, Object.assign({}, options, {jsonStreaming: true}));
}
constructor(options) {
super(options);
this._counter = 0;
this._level = 0;
}
_push(discard) {
if (discard) {
++this._counter;
} else {
this.push({key: this._counter++, value: this._assembler.current});
}
this._assembler.current = this._assembler.key = null;
}
}
StreamValues.streamValues = StreamValues.make;
StreamValues.make.Constructor = StreamValues;
module.exports = StreamValues;

View File

@@ -0,0 +1,22 @@
/*! *****************************************************************************
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 Symbol {
/**
* Expose the [[Description]] internal slot of a symbol directly.
*/
readonly description: string | undefined;
}

View File

@@ -0,0 +1,4 @@
import type { PathLike } from 'node:fs'
export declare function watchFileCreated (filename: PathLike): Promise<void>
export declare function watchForWrite (filename: PathLike, testString: string): Promise<void>

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _validate = _interopRequireDefault(require("./validate.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function version(uuid) {
if (!(0, _validate.default)(uuid)) {
throw TypeError('Invalid UUID');
}
return parseInt(uuid.substr(14, 1), 16);
}
var _default = version;
exports.default = _default;

View File

@@ -0,0 +1,218 @@
/**
* @fileoverview Rule to enforce location of semicolons.
* @author Toru Nagashima
* @deprecated in ESLint v8.53.0
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const astUtils = require("./utils/ast-utils");
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
const SELECTOR = [
"BreakStatement",
"ContinueStatement",
"DebuggerStatement",
"DoWhileStatement",
"ExportAllDeclaration",
"ExportDefaultDeclaration",
"ExportNamedDeclaration",
"ExpressionStatement",
"ImportDeclaration",
"ReturnStatement",
"ThrowStatement",
"VariableDeclaration",
"PropertyDefinition",
].join(",");
/**
* Get the child node list of a given node.
* This returns `BlockStatement#body`, `StaticBlock#body`, `Program#body`,
* `ClassBody#body`, or `SwitchCase#consequent`.
* This is used to check whether a node is the first/last child.
* @param {Node} node A node to get child node list.
* @returns {Node[]|null} The child node list.
*/
function getChildren(node) {
const t = node.type;
if (
t === "BlockStatement" ||
t === "StaticBlock" ||
t === "Program" ||
t === "ClassBody"
) {
return node.body;
}
if (t === "SwitchCase") {
return node.consequent;
}
return null;
}
/**
* Check whether a given node is the last statement in the parent block.
* @param {Node} node A node to check.
* @returns {boolean} `true` if the node is the last statement in the parent block.
*/
function isLastChild(node) {
const t = node.parent.type;
if (
t === "IfStatement" &&
node.parent.consequent === node &&
node.parent.alternate
) {
// before `else` keyword.
return true;
}
if (t === "DoWhileStatement") {
// before `while` keyword.
return true;
}
const nodeList = getChildren(node.parent);
return nodeList !== null && nodeList.at(-1) === node; // before `}` or etc.
}
/** @type {import('../types').Rule.RuleModule} */
module.exports = {
meta: {
deprecated: {
message: "Formatting rules are being moved out of ESLint core.",
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
deprecatedSince: "8.53.0",
availableUntil: "11.0.0",
replacedBy: [
{
message:
"ESLint Stylistic now maintains deprecated stylistic core rules.",
url: "https://eslint.style/guide/migration",
plugin: {
name: "@stylistic/eslint-plugin",
url: "https://eslint.style",
},
rule: {
name: "semi-style",
url: "https://eslint.style/rules/semi-style",
},
},
],
},
type: "layout",
docs: {
description: "Enforce location of semicolons",
recommended: false,
url: "https://eslint.org/docs/latest/rules/semi-style",
},
schema: [{ enum: ["last", "first"] }],
fixable: "whitespace",
messages: {
expectedSemiColon: "Expected this semicolon to be at {{pos}}.",
},
},
create(context) {
const sourceCode = context.sourceCode;
const option = context.options[0] || "last";
/**
* Check the given semicolon token.
* @param {Token} semiToken The semicolon token to check.
* @param {"first"|"last"} expected The expected location to check.
* @returns {void}
*/
function check(semiToken, expected) {
const prevToken = sourceCode.getTokenBefore(semiToken);
const nextToken = sourceCode.getTokenAfter(semiToken);
const prevIsSameLine =
!prevToken || astUtils.isTokenOnSameLine(prevToken, semiToken);
const nextIsSameLine =
!nextToken || astUtils.isTokenOnSameLine(semiToken, nextToken);
if (
(expected === "last" && !prevIsSameLine) ||
(expected === "first" && !nextIsSameLine)
) {
context.report({
loc: semiToken.loc,
messageId: "expectedSemiColon",
data: {
pos:
expected === "last"
? "the end of the previous line"
: "the beginning of the next line",
},
fix(fixer) {
if (
prevToken &&
nextToken &&
sourceCode.commentsExistBetween(
prevToken,
nextToken,
)
) {
return null;
}
const start = prevToken
? prevToken.range[1]
: semiToken.range[0];
const end = nextToken
? nextToken.range[0]
: semiToken.range[1];
const text = expected === "last" ? ";\n" : "\n;";
return fixer.replaceTextRange([start, end], text);
},
});
}
}
return {
[SELECTOR](node) {
if (option === "first" && isLastChild(node)) {
return;
}
const lastToken = sourceCode.getLastToken(node);
if (astUtils.isSemicolonToken(lastToken)) {
check(lastToken, option);
}
},
ForStatement(node) {
const firstSemi =
node.init &&
sourceCode.getTokenAfter(
node.init,
astUtils.isSemicolonToken,
);
const secondSemi =
node.test &&
sourceCode.getTokenAfter(
node.test,
astUtils.isSemicolonToken,
);
if (firstSemi) {
check(firstSemi, "last");
}
if (secondSemi) {
check(secondSemi, "last");
}
},
};
},
};

View File

@@ -0,0 +1,29 @@
'use strict'
const { test } = require('node:test')
const assert = require('node:assert')
const { join } = require('path')
const { file } = require('./helper')
const ThreadStream = require('..')
function basic (esVersion) {
test(`transpiled-ts-to-${esVersion}`, function () {
const dest = file()
const stream = new ThreadStream({
filename: join(__dirname, 'ts', `to-file.${esVersion}.cjs`),
workerData: { dest },
sync: true
})
// There are arbitrary checks, the important aspect of this test is to ensure
// that we can properly load the transpiled file into our worker thread.
assert.deepStrictEqual(stream.writableEnded, false)
stream.end()
assert.deepStrictEqual(stream.writableEnded, true)
})
}
basic('es5')
basic('es6')
basic('es2017')
basic('esnext')

View File

@@ -0,0 +1,61 @@
{
"name": "fast-deep-equal",
"version": "3.1.3",
"description": "Fast deep equal",
"main": "index.js",
"scripts": {
"eslint": "eslint *.js benchmark/*.js spec/*.js",
"build": "node build",
"benchmark": "npm i && npm run build && cd ./benchmark && npm i && node ./",
"test-spec": "mocha spec/*.spec.js -R spec",
"test-cov": "nyc npm run test-spec",
"test-ts": "tsc --target ES5 --noImplicitAny index.d.ts",
"test": "npm run build && npm run eslint && npm run test-ts && npm run test-cov",
"prepublish": "npm run build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/epoberezkin/fast-deep-equal.git"
},
"keywords": [
"fast",
"equal",
"deep-equal"
],
"author": "Evgeny Poberezkin",
"license": "MIT",
"bugs": {
"url": "https://github.com/epoberezkin/fast-deep-equal/issues"
},
"homepage": "https://github.com/epoberezkin/fast-deep-equal#readme",
"devDependencies": {
"coveralls": "^3.1.0",
"dot": "^1.1.2",
"eslint": "^7.2.0",
"mocha": "^7.2.0",
"nyc": "^15.1.0",
"pre-commit": "^1.2.2",
"react": "^16.12.0",
"react-test-renderer": "^16.12.0",
"sinon": "^9.0.2",
"typescript": "^3.9.5"
},
"nyc": {
"exclude": [
"**/spec/**",
"node_modules"
],
"reporter": [
"lcov",
"text-summary"
]
},
"files": [
"index.js",
"index.d.ts",
"react.js",
"react.d.ts",
"es6/"
],
"types": "index.d.ts"
}

View File

@@ -0,0 +1,25 @@
"use strict";
function _class_apply_descriptor_destructure(receiver, descriptor) {
if (descriptor.set) {
if (!("__destrObj" in descriptor)) {
descriptor.__destrObj = {
set value(v) {
descriptor.set.call(receiver, v);
}
};
}
return descriptor.__destrObj;
} else {
if (!descriptor.writable) {
// This should only throw in strict mode, but class bodies are
// always strict and private fields can only be used inside
// class bodies.
throw new TypeError("attempted to set read only private field");
}
return descriptor;
}
}
exports._ = _class_apply_descriptor_destructure;

View File

@@ -0,0 +1,4 @@
function _objectDestructuringEmpty(t) {
if (null == t) throw new TypeError("Cannot destructure " + t);
}
export { _objectDestructuringEmpty as default };

View File

@@ -0,0 +1,211 @@
import { expect, expectTypeOf, test } from "vitest";
import * as z from "zod/v4";
const fish = z.object({
name: z.string(),
age: z.number(),
nested: z.object({}),
});
test("pick type inference", () => {
const nameonlyFish = fish.pick({ name: true });
type nameonlyFish = z.infer<typeof nameonlyFish>;
expectTypeOf<nameonlyFish>().toEqualTypeOf<{ name: string }>();
});
test("pick parse - success", () => {
const nameonlyFish = fish.pick({ name: true });
nameonlyFish.parse({ name: "bob" });
// @ts-expect-error checking runtime picks `name` only.
const anotherNameonlyFish = fish.pick({ name: true, age: false });
anotherNameonlyFish.parse({ name: "bob" });
});
test("pick parse - fail", () => {
fish.pick({ name: true }).parse({ name: "12" } as any);
fish.pick({ name: true }).parse({ name: "bob", age: 12 } as any);
fish.pick({ age: true }).parse({ age: 12 } as any);
const nameonlyFish = fish.pick({ name: true }).strict();
const bad1 = () => nameonlyFish.parse({ name: 12 } as any);
const bad2 = () => nameonlyFish.parse({ name: "bob", age: 12 } as any);
const bad3 = () => nameonlyFish.parse({ age: 12 } as any);
// @ts-expect-error checking runtime picks `name` only.
const anotherNameonlyFish = fish.pick({ name: true, age: false }).strict();
const bad4 = () => anotherNameonlyFish.parse({ name: "bob", age: 12 } as any);
expect(bad1).toThrow();
expect(bad2).toThrow();
expect(bad3).toThrow();
expect(bad4).toThrow();
});
test("pick - remove optional", () => {
const schema = z.object({ a: z.string(), b: z.string().optional() });
expect("a" in schema._zod.def.shape).toEqual(true);
expect("b" in schema._zod.def.shape!).toEqual(true);
const picked = schema.pick({ a: true });
expect("a" in picked._zod.def.shape).toEqual(true);
expect("b" in picked._zod.def.shape!).toEqual(false);
});
test("omit type inference", () => {
const nonameFish = fish.omit({ name: true });
type nonameFish = z.infer<typeof nonameFish>;
expectTypeOf<nonameFish>().toEqualTypeOf<{ age: number; nested: Record<string, never> }>();
});
test("omit parse - success", () => {
const nonameFish = fish.omit({ name: true });
nonameFish.parse({ age: 12, nested: {} });
// @ts-expect-error checking runtime omits `name` only.
const anotherNonameFish = fish.omit({ name: true, age: false });
anotherNonameFish.parse({ age: 12, nested: {} });
});
test("omit parse - fail", () => {
const nonameFish = fish.omit({ name: true });
const bad1 = () => nonameFish.parse({ name: 12 } as any);
const bad2 = () => nonameFish.parse({ age: 12 } as any);
const bad3 = () => nonameFish.parse({} as any);
// @ts-expect-error checking runtime omits `name` only.
const anotherNonameFish = fish.omit({ name: true, age: false });
const bad4 = () => anotherNonameFish.parse({ nested: {} } as any);
expect(bad1).toThrow();
expect(bad2).toThrow();
expect(bad3).toThrow();
expect(bad4).toThrow();
});
test("omit - remove optional", () => {
const schema = z.object({ a: z.string(), b: z.string().optional() });
expect("a" in schema._zod.def.shape).toEqual(true);
const omitted = schema.omit({ a: true });
expect("a" in omitted._zod.def.shape).toEqual(false);
});
test("nonstrict inference", () => {
const laxfish = fish.pick({ name: true }).catchall(z.any());
type laxfish = z.infer<typeof laxfish>;
expectTypeOf<laxfish>().toEqualTypeOf<{ name: string; [k: string]: any }>();
});
test("nonstrict parsing - pass", () => {
const laxfish = fish.passthrough().pick({ name: true });
laxfish.parse({ name: "asdf", whatever: "asdf" });
laxfish.parse({ name: "asdf", age: 12, nested: {} });
});
test("nonstrict parsing - fail", () => {
const laxfish = fish.passthrough().pick({ name: true });
const bad = () => laxfish.parse({ whatever: "asdf" } as any);
expect(bad).toThrow();
});
test("pick/omit/required/partial - do not allow unknown keys", () => {
const schema = z.object({
name: z.string(),
age: z.number(),
});
// Mixed valid + invalid keys
// @ts-expect-error
expect(() => schema.pick({ name: true, asdf: true }).safeParse({})).toThrow();
// @ts-expect-error
expect(() => schema.omit({ name: true, asdf: true }).safeParse({})).toThrow();
// @ts-expect-error
expect(() => schema.partial({ name: true, asdf: true }).safeParse({})).toThrow();
// @ts-expect-error
expect(() => schema.required({ name: true, asdf: true }).safeParse({})).toThrow();
// Only invalid keys
// @ts-expect-error
expect(() => schema.pick({ $unknown: true }).safeParse({})).toThrow();
// @ts-expect-error
expect(() => schema.omit({ $unknown: true }).safeParse({})).toThrow();
// @ts-expect-error
expect(() => schema.required({ $unknown: true }).safeParse({})).toThrow();
// @ts-expect-error
expect(() => schema.partial({ $unknown: true }).safeParse({})).toThrow();
});
test("pick - throws error on schema with refinements", () => {
const baseSchema = z.object({
id: z.string(),
name: z.string(),
items: z.string().array(),
});
const refinedSchema = baseSchema.superRefine((val, ctx) => {
if (val.items.length === 0) {
ctx.addIssue({
message: "Must have at least one item",
code: "custom",
path: ["items"],
});
}
});
expect(() => refinedSchema.pick({ name: true })).toThrow(
".pick() cannot be used on object schemas containing refinements"
);
});
test("omit - throws error on schema with refinements", () => {
const baseSchema = z.object({
id: z.string(),
name: z.string(),
items: z.string().array(),
});
const refinedSchema = baseSchema.superRefine((val, ctx) => {
if (val.items.length === 0) {
ctx.addIssue({
message: "Must have at least one item",
code: "custom",
path: ["items"],
});
}
});
expect(() => refinedSchema.omit({ id: true })).toThrow(
".omit() cannot be used on object schemas containing refinements"
);
});
test("pick - throws error on schema with refine", () => {
const baseSchema = z.object({
password: z.string(),
confirmPassword: z.string(),
});
const refinedSchema = baseSchema.refine((data) => data.password === data.confirmPassword, {
message: "Passwords must match",
});
expect(() => refinedSchema.pick({ password: true })).toThrow(
".pick() cannot be used on object schemas containing refinements"
);
});
test("omit - throws error on schema with refine", () => {
const baseSchema = z.object({
password: z.string(),
confirmPassword: z.string(),
email: z.string(),
});
const refinedSchema = baseSchema.refine((data) => data.password === data.confirmPassword, {
message: "Passwords must match",
});
expect(() => refinedSchema.omit({ email: true })).toThrow(
".omit() cannot be used on object schemas containing refinements"
);
});

View File

@@ -0,0 +1,176 @@
'use strict'
let { existsSync, readFileSync, realpathSync } = require('fs')
let { dirname, isAbsolute, join, relative, sep } = require('path')
let { SourceMapConsumer, SourceMapGenerator } = require('source-map-js')
function realPath(path) {
try {
return realpathSync(path)
} catch {
// Missing or dangling: keep the literal path. The existsSync() check below
// still gates the read, and a path that does not exist cannot escape.
return path
}
}
function fromBase64(str) {
if (Buffer) {
return Buffer.from(str, 'base64').toString()
} else {
/* c8 ignore next 2 */
return window.atob(str)
}
}
class PreviousMap {
constructor(css, opts) {
if (opts.map === false) return
if (opts.unsafeMap) this.unsafeMap = true
this.loadAnnotation(css)
this.inline = this.startWith(this.annotation, 'data:')
let prev = opts.map ? opts.map.prev : undefined
let text = this.loadMap(opts.from, prev)
if (!this.mapFile && opts.from) {
this.mapFile = opts.from
}
if (this.mapFile) this.root = dirname(this.mapFile)
if (text) this.text = text
}
consumer() {
if (!this.consumerCache) {
this.consumerCache = new SourceMapConsumer(this.json || this.text)
}
return this.consumerCache
}
decodeInline(text) {
let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/
let baseUri = /^data:application\/json;base64,/
let charsetUri = /^data:application\/json;charset=utf-?8,/
let uri = /^data:application\/json,/
let uriMatch = text.match(charsetUri) || text.match(uri)
if (uriMatch) {
return decodeURIComponent(text.substr(uriMatch[0].length))
}
let baseUriMatch = text.match(baseCharsetUri) || text.match(baseUri)
if (baseUriMatch) {
return fromBase64(text.substr(baseUriMatch[0].length))
}
let encoding = text.slice('data:application/json;'.length)
encoding = encoding.slice(0, encoding.indexOf(','))
throw new Error('Unsupported source map encoding ' + encoding)
}
getAnnotationURL(sourceMapString) {
return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, '').trim()
}
isMap(map) {
if (typeof map !== 'object') return false
return (
typeof map.mappings === 'string' ||
typeof map._mappings === 'string' ||
Array.isArray(map.sections)
)
}
loadAnnotation(css) {
let comments = css.match(/\/\*\s*# sourceMappingURL=/g)
if (!comments) return
// sourceMappingURLs from comments, strings, etc.
let start = css.lastIndexOf(comments.pop())
let end = css.indexOf('*/', start)
if (start > -1 && end > -1) {
// Locate the last sourceMappingURL to avoid pickin
this.annotation = this.getAnnotationURL(css.substring(start, end))
}
}
loadFile(path, cssFile, trusted) {
if (!trusted && !this.unsafeMap) {
if (!/\.map$/i.test(path)) return undefined
if (!cssFile) return undefined
// Compare *resolved* paths: relative() is textual, so without this a
// symlink at or below the CSS file's directory points the map outside it.
let rel = relative(realPath(dirname(cssFile)), realPath(path))
if (rel === '..' || rel.startsWith('..' + sep) || isAbsolute(rel)) {
return undefined
}
}
this.root = dirname(path)
if (existsSync(path)) {
this.mapFile = path
return readFileSync(path, 'utf-8').toString().trim()
}
}
loadMap(file, prev) {
if (prev === false) return false
if (prev) {
if (typeof prev === 'string') {
return prev
} else if (typeof prev === 'function') {
let prevPath = prev(file)
if (prevPath) {
let map = this.loadFile(prevPath, file, true)
if (!map) {
throw new Error(
'Unable to load previous source map: ' + prevPath.toString()
)
}
return map
}
} else if (prev instanceof SourceMapConsumer) {
return SourceMapGenerator.fromSourceMap(prev).toString()
} else if (prev instanceof SourceMapGenerator) {
return prev.toString()
} else if (this.isMap(prev)) {
return JSON.stringify(prev)
} else {
throw new Error(
'Unsupported previous source map format: ' + prev.toString()
)
}
} else if (this.inline) {
return this.decodeInline(this.annotation)
} else if (this.annotation) {
let map = this.annotation
if (file) map = join(dirname(file), map)
let unknown = this.loadFile(map, file, false)
if (unknown) {
try {
/* c8 ignore next 4 */
this.json = JSON.parse(unknown.replace(/^\)]}'[^\n]*\n/, ''))
} catch {
return undefined
}
}
return unknown
}
}
startWith(string, start) {
if (!string) return false
return string.substr(0, start.length) === start
}
withContent() {
return !!(
this.consumer().sourcesContent &&
this.consumer().sourcesContent.length > 0
)
}
}
module.exports = PreviousMap
PreviousMap.default = PreviousMap

View File

@@ -0,0 +1,52 @@
var assert = require('assert');
var arrTest = [];
var arrExpected;
for (var i = 0; i < 100; i++) { arrTest[i] = i; }
arrExpected = JSON.stringify(arrTest);
var arrReuse = [];
suite('itar-long', function() {
var minSamples = 160;
benchmark("for + if", function() {
var val = arrTest.slice();
var str = '[';
var max = val.length - 1;
var i;
for (i = 0; i < max; i++) {
str += JSON.stringify(val[i]) + ',';
}
if (max > -1) {
str += JSON.stringify(val[i]);
}
assert.equal(str + ']', arrExpected);
}, { minSamples: minSamples });
benchmark("while + if", function() {
var val = arrTest.slice();
var str = '[';
var max = val.length - 1;
var i = 0;
while (i < max) {
str += JSON.stringify(val[i++]) + ',';
}
if (max > -1) {
str += JSON.stringify(val[i]);
}
assert.equal(str + ']', arrExpected);
}, { minSamples: minSamples });
benchmark("array join", function() {
arrReuse.length = 0;
var val = arrTest.slice();
var max = val.length;
var i;
for (i = 0; i < max; i++) {
arrReuse[i] = JSON.stringify(val[i]);
}
assert.equal('[' + arrReuse.join(',') + ']', arrExpected);
}, { minSamples: minSamples });
});

View File

@@ -0,0 +1,22 @@
import { TransformOptions } from 'stream';
import { Mode, BackendMessage } from './messages';
export type Packet = {
code: number;
packet: Buffer;
};
type StreamOptions = TransformOptions & {
mode: Mode;
};
export type MessageCallback = (msg: BackendMessage) => void;
export declare class Parser {
private buffer;
private bufferLength;
private bufferOffset;
private reader;
private mode;
constructor(opts?: StreamOptions);
parse(buffer: Buffer, callback: MessageCallback): void;
private mergeBuffer;
private handlePacket;
}
export {};

View File

@@ -0,0 +1,278 @@
import * as core from "./core.cjs";
import type * as errors from "./errors.cjs";
import type * as schemas from "./schemas.cjs";
import * as util from "./util.cjs";
export interface $ZodCheckDef {
check: string;
error?: errors.$ZodErrorMap<never> | undefined;
/** If true, no later checks will be executed if this check fails. Default `false`. */
abort?: boolean | undefined;
/** If provided, the check runs only when this returns `true`. By default, it is skipped if prior parsing produced aborting issues. */
when?: ((payload: schemas.ParsePayload) => boolean) | undefined;
}
export interface $ZodCheckInternals<T> {
def: $ZodCheckDef;
/** The set of issues this check might throw. */
issc?: errors.$ZodIssueBase;
check(payload: schemas.ParsePayload<T>): util.MaybeAsync<void>;
onattach: ((schema: schemas.$ZodType) => void)[];
}
export interface $ZodCheck<in T = never> {
_zod: $ZodCheckInternals<T>;
}
export declare const $ZodCheck: core.$constructor<$ZodCheck<any>>;
export interface $ZodCheckLessThanDef extends $ZodCheckDef {
check: "less_than";
value: util.Numeric;
inclusive: boolean;
}
export interface $ZodCheckLessThanInternals<T extends util.Numeric = util.Numeric> extends $ZodCheckInternals<T> {
def: $ZodCheckLessThanDef;
issc: errors.$ZodIssueTooBig<T>;
}
export interface $ZodCheckLessThan<T extends util.Numeric = util.Numeric> extends $ZodCheck<T> {
_zod: $ZodCheckLessThanInternals<T>;
}
export declare const $ZodCheckLessThan: core.$constructor<$ZodCheckLessThan>;
export interface $ZodCheckGreaterThanDef extends $ZodCheckDef {
check: "greater_than";
value: util.Numeric;
inclusive: boolean;
}
export interface $ZodCheckGreaterThanInternals<T extends util.Numeric = util.Numeric> extends $ZodCheckInternals<T> {
def: $ZodCheckGreaterThanDef;
issc: errors.$ZodIssueTooSmall<T>;
}
export interface $ZodCheckGreaterThan<T extends util.Numeric = util.Numeric> extends $ZodCheck<T> {
_zod: $ZodCheckGreaterThanInternals<T>;
}
export declare const $ZodCheckGreaterThan: core.$constructor<$ZodCheckGreaterThan>;
export interface $ZodCheckMultipleOfDef<T extends number | bigint = number | bigint> extends $ZodCheckDef {
check: "multiple_of";
value: T;
}
export interface $ZodCheckMultipleOfInternals<T extends number | bigint = number | bigint> extends $ZodCheckInternals<T> {
def: $ZodCheckMultipleOfDef<T>;
issc: errors.$ZodIssueNotMultipleOf;
}
export interface $ZodCheckMultipleOf<T extends number | bigint = number | bigint> extends $ZodCheck<T> {
_zod: $ZodCheckMultipleOfInternals<T>;
}
export declare const $ZodCheckMultipleOf: core.$constructor<$ZodCheckMultipleOf<number | bigint>>;
export type $ZodNumberFormats = "int32" | "uint32" | "float32" | "float64" | "safeint";
export interface $ZodCheckNumberFormatDef extends $ZodCheckDef {
check: "number_format";
format: $ZodNumberFormats;
}
export interface $ZodCheckNumberFormatInternals extends $ZodCheckInternals<number> {
def: $ZodCheckNumberFormatDef;
issc: errors.$ZodIssueInvalidType | errors.$ZodIssueTooBig<"number"> | errors.$ZodIssueTooSmall<"number">;
}
export interface $ZodCheckNumberFormat extends $ZodCheck<number> {
_zod: $ZodCheckNumberFormatInternals;
}
export declare const $ZodCheckNumberFormat: core.$constructor<$ZodCheckNumberFormat>;
export type $ZodBigIntFormats = "int64" | "uint64";
export interface $ZodCheckBigIntFormatDef extends $ZodCheckDef {
check: "bigint_format";
format: $ZodBigIntFormats | undefined;
}
export interface $ZodCheckBigIntFormatInternals extends $ZodCheckInternals<bigint> {
def: $ZodCheckBigIntFormatDef;
issc: errors.$ZodIssueTooBig<"bigint"> | errors.$ZodIssueTooSmall<"bigint">;
}
export interface $ZodCheckBigIntFormat extends $ZodCheck<bigint> {
_zod: $ZodCheckBigIntFormatInternals;
}
export declare const $ZodCheckBigIntFormat: core.$constructor<$ZodCheckBigIntFormat>;
export interface $ZodCheckMaxSizeDef extends $ZodCheckDef {
check: "max_size";
maximum: number;
}
export interface $ZodCheckMaxSizeInternals<T extends util.HasSize = util.HasSize> extends $ZodCheckInternals<T> {
def: $ZodCheckMaxSizeDef;
issc: errors.$ZodIssueTooBig<T>;
}
export interface $ZodCheckMaxSize<T extends util.HasSize = util.HasSize> extends $ZodCheck<T> {
_zod: $ZodCheckMaxSizeInternals<T>;
}
export declare const $ZodCheckMaxSize: core.$constructor<$ZodCheckMaxSize>;
export interface $ZodCheckMinSizeDef extends $ZodCheckDef {
check: "min_size";
minimum: number;
}
export interface $ZodCheckMinSizeInternals<T extends util.HasSize = util.HasSize> extends $ZodCheckInternals<T> {
def: $ZodCheckMinSizeDef;
issc: errors.$ZodIssueTooSmall<T>;
}
export interface $ZodCheckMinSize<T extends util.HasSize = util.HasSize> extends $ZodCheck<T> {
_zod: $ZodCheckMinSizeInternals<T>;
}
export declare const $ZodCheckMinSize: core.$constructor<$ZodCheckMinSize>;
export interface $ZodCheckSizeEqualsDef extends $ZodCheckDef {
check: "size_equals";
size: number;
}
export interface $ZodCheckSizeEqualsInternals<T extends util.HasSize = util.HasSize> extends $ZodCheckInternals<T> {
def: $ZodCheckSizeEqualsDef;
issc: errors.$ZodIssueTooBig<T> | errors.$ZodIssueTooSmall<T>;
}
export interface $ZodCheckSizeEquals<T extends util.HasSize = util.HasSize> extends $ZodCheck<T> {
_zod: $ZodCheckSizeEqualsInternals<T>;
}
export declare const $ZodCheckSizeEquals: core.$constructor<$ZodCheckSizeEquals>;
export interface $ZodCheckMaxLengthDef extends $ZodCheckDef {
check: "max_length";
maximum: number;
}
export interface $ZodCheckMaxLengthInternals<T extends util.HasLength = util.HasLength> extends $ZodCheckInternals<T> {
def: $ZodCheckMaxLengthDef;
issc: errors.$ZodIssueTooBig<T>;
}
export interface $ZodCheckMaxLength<T extends util.HasLength = util.HasLength> extends $ZodCheck<T> {
_zod: $ZodCheckMaxLengthInternals<T>;
}
export declare const $ZodCheckMaxLength: core.$constructor<$ZodCheckMaxLength>;
export interface $ZodCheckMinLengthDef extends $ZodCheckDef {
check: "min_length";
minimum: number;
}
export interface $ZodCheckMinLengthInternals<T extends util.HasLength = util.HasLength> extends $ZodCheckInternals<T> {
def: $ZodCheckMinLengthDef;
issc: errors.$ZodIssueTooSmall<T>;
}
export interface $ZodCheckMinLength<T extends util.HasLength = util.HasLength> extends $ZodCheck<T> {
_zod: $ZodCheckMinLengthInternals<T>;
}
export declare const $ZodCheckMinLength: core.$constructor<$ZodCheckMinLength>;
export interface $ZodCheckLengthEqualsDef extends $ZodCheckDef {
check: "length_equals";
length: number;
}
export interface $ZodCheckLengthEqualsInternals<T extends util.HasLength = util.HasLength> extends $ZodCheckInternals<T> {
def: $ZodCheckLengthEqualsDef;
issc: errors.$ZodIssueTooBig<T> | errors.$ZodIssueTooSmall<T>;
}
export interface $ZodCheckLengthEquals<T extends util.HasLength = util.HasLength> extends $ZodCheck<T> {
_zod: $ZodCheckLengthEqualsInternals<T>;
}
export declare const $ZodCheckLengthEquals: core.$constructor<$ZodCheckLengthEquals>;
export type $ZodStringFormats = "email" | "url" | "emoji" | "uuid" | "guid" | "nanoid" | "cuid" | "cuid2" | "ulid" | "xid" | "ksuid" | "datetime" | "date" | "time" | "duration" | "ipv4" | "ipv6" | "cidrv4" | "cidrv6" | "base64" | "base64url" | "json_string" | "e164" | "lowercase" | "uppercase" | "regex" | "jwt" | "starts_with" | "ends_with" | "includes";
export interface $ZodCheckStringFormatDef<Format extends string = string> extends $ZodCheckDef {
check: "string_format";
format: Format;
pattern?: RegExp | undefined;
}
export interface $ZodCheckStringFormatInternals extends $ZodCheckInternals<string> {
def: $ZodCheckStringFormatDef;
issc: errors.$ZodIssueInvalidStringFormat;
}
export interface $ZodCheckStringFormat extends $ZodCheck<string> {
_zod: $ZodCheckStringFormatInternals;
}
export declare const $ZodCheckStringFormat: core.$constructor<$ZodCheckStringFormat>;
export interface $ZodCheckRegexDef extends $ZodCheckStringFormatDef {
format: "regex";
pattern: RegExp;
}
export interface $ZodCheckRegexInternals extends $ZodCheckInternals<string> {
def: $ZodCheckRegexDef;
issc: errors.$ZodIssueInvalidStringFormat;
}
export interface $ZodCheckRegex extends $ZodCheck<string> {
_zod: $ZodCheckRegexInternals;
}
export declare const $ZodCheckRegex: core.$constructor<$ZodCheckRegex>;
export interface $ZodCheckLowerCaseDef extends $ZodCheckStringFormatDef<"lowercase"> {
}
export interface $ZodCheckLowerCaseInternals extends $ZodCheckInternals<string> {
def: $ZodCheckLowerCaseDef;
issc: errors.$ZodIssueInvalidStringFormat;
}
export interface $ZodCheckLowerCase extends $ZodCheck<string> {
_zod: $ZodCheckLowerCaseInternals;
}
export declare const $ZodCheckLowerCase: core.$constructor<$ZodCheckLowerCase>;
export interface $ZodCheckUpperCaseDef extends $ZodCheckStringFormatDef<"uppercase"> {
}
export interface $ZodCheckUpperCaseInternals extends $ZodCheckInternals<string> {
def: $ZodCheckUpperCaseDef;
issc: errors.$ZodIssueInvalidStringFormat;
}
export interface $ZodCheckUpperCase extends $ZodCheck<string> {
_zod: $ZodCheckUpperCaseInternals;
}
export declare const $ZodCheckUpperCase: core.$constructor<$ZodCheckUpperCase>;
export interface $ZodCheckIncludesDef extends $ZodCheckStringFormatDef<"includes"> {
includes: string;
position?: number | undefined;
}
export interface $ZodCheckIncludesInternals extends $ZodCheckInternals<string> {
def: $ZodCheckIncludesDef;
issc: errors.$ZodIssueInvalidStringFormat;
}
export interface $ZodCheckIncludes extends $ZodCheck<string> {
_zod: $ZodCheckIncludesInternals;
}
export declare const $ZodCheckIncludes: core.$constructor<$ZodCheckIncludes>;
export interface $ZodCheckStartsWithDef extends $ZodCheckStringFormatDef<"starts_with"> {
prefix: string;
}
export interface $ZodCheckStartsWithInternals extends $ZodCheckInternals<string> {
def: $ZodCheckStartsWithDef;
issc: errors.$ZodIssueInvalidStringFormat;
}
export interface $ZodCheckStartsWith extends $ZodCheck<string> {
_zod: $ZodCheckStartsWithInternals;
}
export declare const $ZodCheckStartsWith: core.$constructor<$ZodCheckStartsWith>;
export interface $ZodCheckEndsWithDef extends $ZodCheckStringFormatDef<"ends_with"> {
suffix: string;
}
export interface $ZodCheckEndsWithInternals extends $ZodCheckInternals<string> {
def: $ZodCheckEndsWithDef;
issc: errors.$ZodIssueInvalidStringFormat;
}
export interface $ZodCheckEndsWith extends $ZodCheckInternals<string> {
_zod: $ZodCheckEndsWithInternals;
}
export declare const $ZodCheckEndsWith: core.$constructor<$ZodCheckEndsWith>;
export interface $ZodCheckPropertyDef extends $ZodCheckDef {
check: "property";
property: string;
schema: schemas.$ZodType;
}
export interface $ZodCheckPropertyInternals<T extends object = object> extends $ZodCheckInternals<T> {
def: $ZodCheckPropertyDef;
issc: errors.$ZodIssue;
}
export interface $ZodCheckProperty<T extends object = object> extends $ZodCheck<T> {
_zod: $ZodCheckPropertyInternals<T>;
}
export declare const $ZodCheckProperty: core.$constructor<$ZodCheckProperty>;
export interface $ZodCheckMimeTypeDef extends $ZodCheckDef {
check: "mime_type";
mime: util.MimeTypes[];
}
export interface $ZodCheckMimeTypeInternals<T extends schemas.File = schemas.File> extends $ZodCheckInternals<T> {
def: $ZodCheckMimeTypeDef;
issc: errors.$ZodIssueInvalidValue;
}
export interface $ZodCheckMimeType<T extends schemas.File = schemas.File> extends $ZodCheck<T> {
_zod: $ZodCheckMimeTypeInternals<T>;
}
export declare const $ZodCheckMimeType: core.$constructor<$ZodCheckMimeType>;
export interface $ZodCheckOverwriteDef<T = unknown> extends $ZodCheckDef {
check: "overwrite";
tx(value: T): T;
}
export interface $ZodCheckOverwriteInternals<T = unknown> extends $ZodCheckInternals<T> {
def: $ZodCheckOverwriteDef<T>;
issc: never;
}
export interface $ZodCheckOverwrite<T = unknown> extends $ZodCheck<T> {
_zod: $ZodCheckOverwriteInternals<T>;
}
export declare const $ZodCheckOverwrite: core.$constructor<$ZodCheckOverwrite>;
export type $ZodChecks = $ZodCheckLessThan | $ZodCheckGreaterThan | $ZodCheckMultipleOf | $ZodCheckNumberFormat | $ZodCheckBigIntFormat | $ZodCheckMaxSize | $ZodCheckMinSize | $ZodCheckSizeEquals | $ZodCheckMaxLength | $ZodCheckMinLength | $ZodCheckLengthEquals | $ZodCheckStringFormat | $ZodCheckProperty | $ZodCheckMimeType | $ZodCheckOverwrite;
export type $ZodStringFormatChecks = $ZodCheckRegex | $ZodCheckLowerCase | $ZodCheckUpperCase | $ZodCheckIncludes | $ZodCheckStartsWith | $ZodCheckEndsWith | schemas.$ZodStringFormatTypes;

View File

@@ -0,0 +1,79 @@
# bufferutil
[![Version npm](https://img.shields.io/npm/v/bufferutil.svg?logo=npm)](https://www.npmjs.com/package/bufferutil)
[![Linux/macOS/Windows Build](https://img.shields.io/github/actions/workflow/status/websockets/bufferutil/ci.yml?branch=master&label=build&logo=github)](https://github.com/websockets/bufferutil/actions?query=workflow%3ACI+branch%3Amaster)
`bufferutil` is what makes `ws` fast. It provides some utilities to efficiently
perform some operations such as masking and unmasking the data payload of
WebSocket frames.
## Installation
```
npm install bufferutil --save-optional
```
The `--save-optional` flag tells npm to save the package in your package.json
under the
[`optionalDependencies`](https://docs.npmjs.com/files/package.json#optionaldependencies)
key.
## API
The module exports two functions. To maximize performance, parameters are not
validated. It is the caller's responsibility to ensure that they are correct.
### `bufferUtil.mask(source, mask, output, offset, length)`
Masks a buffer using the given masking-key as specified by the WebSocket
protocol.
#### Arguments
- `source` - The buffer to mask.
- `mask` - A buffer representing the masking-key.
- `output` - The buffer where to store the result.
- `offset` - The offset at which to start writing.
- `length` - The number of bytes to mask.
#### Example
```js
'use strict';
const bufferUtil = require('bufferutil');
const crypto = require('crypto');
const source = crypto.randomBytes(10);
const mask = crypto.randomBytes(4);
bufferUtil.mask(source, mask, source, 0, source.length);
```
### `bufferUtil.unmask(buffer, mask)`
Unmasks a buffer using the given masking-key as specified by the WebSocket
protocol.
#### Arguments
- `buffer` - The buffer to unmask.
- `mask` - A buffer representing the masking-key.
#### Example
```js
'use strict';
const bufferUtil = require('bufferutil');
const crypto = require('crypto');
const buffer = crypto.randomBytes(10);
const mask = crypto.randomBytes(4);
bufferUtil.unmask(buffer, mask);
```
## License
[MIT](LICENSE)

View File

@@ -0,0 +1 @@
{"version":3,"file":"u64.d.ts","sourceRoot":"","sources":["../../src/u64.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvG,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG7C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa,GAAI,SAAQ,iBAAsB,KAAG,gBAAgB,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,CAO5F,CAAC;AAEP;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa,GAAI,SAAQ,iBAAsB,KAAG,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAMnF,CAAC;AAEP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,WAAW,GAAI,SAAQ,iBAAsB,KAAG,cAAc,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,CACxC,CAAC"}

View File

@@ -0,0 +1,15 @@
"use strict";
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// RUN THE FOLLOWING COMMAND FROM THE WORKSPACE ROOT TO REGENERATE:
// npx nx generate-lib repo
Object.defineProperty(exports, "__esModule", { value: true });
exports.lib = void 0;
const dom_1 = require("./dom");
const es5_1 = require("./es5");
const scripthost_1 = require("./scripthost");
const webworker_importscripts_1 = require("./webworker.importscripts");
exports.lib = {
libs: [es5_1.es5, dom_1.dom, webworker_importscripts_1.webworker_importscripts, scripthost_1.scripthost],
variables: [],
};

View File

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

View File

@@ -0,0 +1,24 @@
/*! *****************************************************************************
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,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es2019" />
/// <reference lib="dom" />
/// <reference lib="webworker.importscripts" />
/// <reference lib="scripthost" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.asynciterable" />

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"nist.js","sourceRoot":"","sources":["../src/nist.ts"],"names":[],"mappings":"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"}

View File

@@ -0,0 +1,105 @@
import * as util from "../core/util.js";
const error = () => {
const Sizable = {
string: { unit: "karakter", verb: "olmalı" },
file: { unit: "bayt", verb: "olmalı" },
array: { unit: "öğe", verb: "olmalı" },
set: { unit: "öğe", verb: "olmalı" },
};
function getSizing(origin) {
return Sizable[origin] ?? null;
}
const FormatDictionary = {
regex: "girdi",
email: "e-posta adresi",
url: "URL",
emoji: "emoji",
uuid: "UUID",
uuidv4: "UUIDv4",
uuidv6: "UUIDv6",
nanoid: "nanoid",
guid: "GUID",
cuid: "cuid",
cuid2: "cuid2",
ulid: "ULID",
xid: "XID",
ksuid: "KSUID",
datetime: "ISO tarih ve saat",
date: "ISO tarih",
time: "ISO saat",
duration: "ISO süre",
ipv4: "IPv4 adresi",
ipv6: "IPv6 adresi",
cidrv4: "IPv4 aralığı",
cidrv6: "IPv6 aralığı",
base64: "base64 ile şifrelenmiş metin",
base64url: "base64url ile şifrelenmiş metin",
json_string: "JSON dizesi",
e164: "E.164 sayısı",
jwt: "JWT",
template_literal: "Şablon dizesi",
};
const TypeDictionary = {
nan: "NaN",
};
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 `Geçersiz değer: beklenen instanceof ${issue.expected}, alınan ${received}`;
}
return `Geçersiz değer: beklenen ${expected}, alınan ${received}`;
}
case "invalid_value":
if (issue.values.length === 1)
return `Geçersiz değer: beklenen ${util.stringifyPrimitive(issue.values[0])}`;
return `Geçersiz seçenek: aşağıdakilerden biri olmalı: ${util.joinValues(issue.values, "|")}`;
case "too_big": {
const adj = issue.inclusive ? "<=" : "<";
const sizing = getSizing(issue.origin);
if (sizing)
return `Çok büyük: beklenen ${issue.origin ?? "değer"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "öğe"}`;
return `Çok büyük: beklenen ${issue.origin ?? "değer"} ${adj}${issue.maximum.toString()}`;
}
case "too_small": {
const adj = issue.inclusive ? ">=" : ">";
const sizing = getSizing(issue.origin);
if (sizing)
return `Çok küçük: beklenen ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
return `Çok küçük: beklenen ${issue.origin} ${adj}${issue.minimum.toString()}`;
}
case "invalid_format": {
const _issue = issue;
if (_issue.format === "starts_with")
return `Geçersiz metin: "${_issue.prefix}" ile başlamalı`;
if (_issue.format === "ends_with")
return `Geçersiz metin: "${_issue.suffix}" ile bitmeli`;
if (_issue.format === "includes")
return `Geçersiz metin: "${_issue.includes}" içermeli`;
if (_issue.format === "regex")
return `Geçersiz metin: ${_issue.pattern} desenine uymalı`;
return `Geçersiz ${FormatDictionary[_issue.format] ?? issue.format}`;
}
case "not_multiple_of":
return `Geçersiz sayı: ${issue.divisor} ile tam bölünebilmeli`;
case "unrecognized_keys":
return `Tanınmayan anahtar${issue.keys.length > 1 ? "lar" : ""}: ${util.joinValues(issue.keys, ", ")}`;
case "invalid_key":
return `${issue.origin} içinde geçersiz anahtar`;
case "invalid_union":
return "Geçersiz değer";
case "invalid_element":
return `${issue.origin} içinde geçersiz değer`;
default:
return `Geçersiz değer`;
}
};
};
export default function () {
return {
localeError: error(),
};
}

View File

@@ -0,0 +1,42 @@
/**
* @fileoverview Rule to flag statements with function invocation preceded by
* "new" and not part of assignment
* @author Ilya Volodin
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../types').Rule.RuleModule} */
module.exports = {
meta: {
type: "suggestion",
docs: {
description:
"Disallow `new` operators outside of assignments or comparisons",
recommended: false,
url: "https://eslint.org/docs/latest/rules/no-new",
},
schema: [],
messages: {
noNewStatement: "Do not use 'new' for side effects.",
},
},
create(context) {
return {
"ExpressionStatement > NewExpression"(node) {
context.report({
node: node.parent,
messageId: "noNewStatement",
});
},
};
},
};

View File

@@ -0,0 +1,48 @@
'use strict'
const test = require('node:test')
const { join } = require('node:path')
const Writable = require('node:stream').Writable
const proxyquire = require('proxyquire')
const tspl = require('@matteo.collina/tspl')
const pino = require('../../pino')
test('file-target mocked', async function (t) {
const plan = tspl(t, { plan: 1 })
let ret
const fileTarget = proxyquire('../../file', {
'./pino': {
destination (opts) {
plan.deepEqual(opts, { dest: 1, sync: false })
ret = new Writable()
ret.fd = opts.dest
process.nextTick(() => {
ret.emit('ready')
})
return ret
}
}
})
await fileTarget()
await plan
})
test('pino.transport with syntax error', async (t) => {
const plan = tspl(t, { plan: 1 })
const transport = pino.transport({
targets: [{
target: join(__dirname, '..', 'fixtures', 'syntax-error-esm.mjs')
}]
})
t.after(transport.end.bind(transport))
transport.on('error', (err) => {
plan.deepEqual(err, new SyntaxError('Unexpected end of input'))
})
await plan
})

View File

@@ -0,0 +1 @@
import s from"node:path";import o from"node:os";const{geteuid:r}=process,t=r?r():o.userInfo().username,e=s.join(o.tmpdir(),`tsx-${t}`);export{e as t};

View File

@@ -0,0 +1,136 @@
/**
* @fileoverview Rule to disallow returning values from setters
* @author Milos Djermanovic
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const astUtils = require("./utils/ast-utils");
//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------
/**
* Determines whether the given function node is used as a setter function.
* @param {ASTNode} node The node to check.
* @param {SourceCode} sourceCode Source code to which the node belongs.
* @returns {boolean} `true` if the node is a setter.
*/
function isSetter(node, sourceCode) {
const parent = node.parent;
if (
(parent.type === "Property" || parent.type === "MethodDefinition") &&
parent.kind === "set" &&
parent.value === node
) {
// Setter in an object literal or in a class
return true;
}
if (
parent.type === "Property" &&
parent.value === node &&
astUtils.getStaticPropertyName(parent) === "set" &&
parent.parent.type === "ObjectExpression" &&
astUtils.isPropertyDescriptor(parent.parent, sourceCode)
) {
// Setter in a property descriptor
return true;
}
return false;
}
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../types').Rule.RuleModule} */
module.exports = {
meta: {
type: "problem",
docs: {
description: "Disallow returning values from setters",
recommended: true,
url: "https://eslint.org/docs/latest/rules/no-setter-return",
},
schema: [],
messages: {
returnsValue: "Setter cannot return a value.",
},
},
create(context) {
let funcInfo = null;
const sourceCode = context.sourceCode;
/**
* Creates and pushes to the stack a function info object for the given function node.
* @param {ASTNode} node The function node.
* @returns {void}
*/
function enterFunction(node) {
funcInfo = {
upper: funcInfo,
isSetter: isSetter(node, sourceCode),
};
}
/**
* Pops the current function info object from the stack.
* @returns {void}
*/
function exitFunction() {
funcInfo = funcInfo.upper;
}
/**
* Reports the given node.
* @param {ASTNode} node Node to report.
* @returns {void}
*/
function report(node) {
context.report({ node, messageId: "returnsValue" });
}
return {
/*
* Function declarations cannot be setters, but we still have to track them in the `funcInfo` stack to avoid
* false positives, because a ReturnStatement node can belong to a function declaration inside a setter.
*
* Note: A previously declared function can be referenced and actually used as a setter in a property descriptor,
* but that's out of scope for this rule.
*/
FunctionDeclaration: enterFunction,
FunctionExpression: enterFunction,
ArrowFunctionExpression(node) {
enterFunction(node);
if (funcInfo.isSetter && node.expression) {
// { set: foo => bar } property descriptor. Report implicit return 'bar' as the equivalent for a return statement.
report(node.body);
}
},
"FunctionDeclaration:exit": exitFunction,
"FunctionExpression:exit": exitFunction,
"ArrowFunctionExpression:exit": exitFunction,
ReturnStatement(node) {
// Global returns (e.g., at the top level of a Node module) don't have `funcInfo`.
if (funcInfo && funcInfo.isSetter && node.argument) {
report(node);
}
},
};
},
};

View File

@@ -0,0 +1,16 @@
'use strict'
const { Writable } = require('stream')
function run (opts) {
const { port } = opts
return new Writable({
autoDestroy: true,
write (chunk, enc, cb) {
port.postMessage(chunk.toString())
cb()
}
})
}
module.exports = run

View File

@@ -0,0 +1,100 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'consistent-type-definitions',
meta: {
type: 'suggestion',
docs: {
description: 'Enforce type definitions to consistently use either `interface` or `type`',
recommended: 'stylistic',
},
fixable: 'code',
messages: {
interfaceOverType: 'Use an `interface` instead of a `type`.',
typeOverInterface: 'Use a `type` instead of an `interface`.',
},
schema: [
{
type: 'string',
description: 'Which type definition syntax to prefer.',
enum: ['interface', 'type'],
},
],
},
defaultOptions: ['interface'],
create(context, [option]) {
/**
* Iterates from the highest parent to the currently traversed node
* to determine whether any node in tree is globally declared module declaration
*/
function isCurrentlyTraversedNodeWithinModuleDeclaration(node) {
return context.sourceCode
.getAncestors(node)
.some(node => node.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration &&
node.declare &&
node.kind === 'global');
}
return {
...(option === 'interface' && {
"TSTypeAliasDeclaration[typeAnnotation.type='TSTypeLiteral']"(node) {
context.report({
node: node.id,
messageId: 'interfaceOverType',
fix(fixer) {
const typeToken = (0, util_1.nullThrows)(context.sourceCode.getTokenBefore(node.id, token => token.value === 'type'), util_1.NullThrowsReasons.MissingToken('type keyword', 'type alias'));
const equalsToken = (0, util_1.nullThrows)(context.sourceCode.getTokenBefore(node.typeAnnotation, token => token.value === '='), util_1.NullThrowsReasons.MissingToken('=', 'type alias'));
const beforeEqualsToken = (0, util_1.nullThrows)(context.sourceCode.getTokenBefore(equalsToken, {
includeComments: true,
}), util_1.NullThrowsReasons.MissingToken('before =', 'type alias'));
return [
// replace 'type' with 'interface'.
fixer.replaceText(typeToken, 'interface'),
// delete from the = to the { of the type, and put a space to be pretty.
fixer.replaceTextRange([beforeEqualsToken.range[1], node.typeAnnotation.range[0]], ' '),
// remove from the closing } through the end of the statement.
fixer.removeRange([
node.typeAnnotation.range[1],
node.range[1],
]),
];
},
});
},
}),
...(option === 'type' && {
TSInterfaceDeclaration(node) {
const fix = isCurrentlyTraversedNodeWithinModuleDeclaration(node)
? null
: (fixer) => {
const typeNode = node.typeParameters ?? node.id;
const fixes = [];
const firstToken = context.sourceCode.getTokenBefore(node.id);
if (firstToken) {
fixes.push(fixer.replaceText(firstToken, 'type'));
fixes.push(fixer.replaceTextRange([typeNode.range[1], node.body.range[0]], ' = '));
}
node.extends.forEach(heritage => {
const typeIdentifier = context.sourceCode.getText(heritage);
fixes.push(fixer.insertTextAfter(node.body, ` & ${typeIdentifier}`));
});
if (node.parent.type === utils_1.AST_NODE_TYPES.ExportDefaultDeclaration) {
fixes.push(fixer.removeRange([node.parent.range[0], node.range[0]]), fixer.insertTextAfter(node.body, `\nexport default ${node.id.name}`));
}
return fixes;
};
context.report({
node: node.id,
messageId: 'typeOverInterface',
/**
* remove automatically fix when the interface is within a declare global
* @see {@link https://github.com/typescript-eslint/typescript-eslint/issues/2707}
*/
fix,
});
},
}),
};
},
});

View File

@@ -0,0 +1,131 @@
'use strict';
const Utf8Stream = require('../utils/Utf8Stream');
class JsonlParser extends Utf8Stream {
static make(options) {
return new JsonlParser(options);
}
static checkedParse(input, reviver, errorIndicator) {
try {
return JSON.parse(input, reviver);
} catch (error) {
if (typeof errorIndicator == 'function') return errorIndicator(error, input, reviver);
}
return errorIndicator;
}
constructor(options) {
super(Object.assign({}, options, {readableObjectMode: true}));
this._rest = '';
this._counter = 0;
this._reviver = options && options.reviver;
this._errorIndicator = options && options.errorIndicator;
if (options && options.checkErrors) {
this._processBuffer = this._checked_processBuffer;
this._flush = this._checked_flush;
}
if (options && 'errorIndicator' in options) {
this._processBuffer = this._suppressed_processBuffer;
this._flush = this._suppressed_flush;
}
}
_processBuffer(callback) {
const lines = this._buffer.split('\n');
this._rest += lines[0];
if (lines.length > 1) {
this._rest && this.push({key: this._counter++, value: JSON.parse(this._rest, this._reviver)});
this._rest = lines.pop();
for (let i = 1; i < lines.length; ++i) {
lines[i] && this.push({key: this._counter++, value: JSON.parse(lines[i], this._reviver)});
}
}
this._buffer = '';
callback(null);
}
_flush(callback) {
super._flush(error => {
if (error) return callback(error);
if (this._rest) {
this.push({key: this._counter++, value: JSON.parse(this._rest, this._reviver)});
this._rest = '';
}
callback(null);
});
}
_suppressed_processBuffer(callback) {
const lines = this._buffer.split('\n');
this._rest += lines[0];
if (lines.length > 1) {
if (this._rest) {
const value = JsonlParser.checkedParse(this._rest, this._reviver, this._errorIndicator);
value !== undefined && this.push({key: this._counter++, value});
}
this._rest = lines.pop();
for (let i = 1; i < lines.length; ++i) {
if (!lines[i]) continue;
const value = JsonlParser.checkedParse(lines[i], this._reviver, this._errorIndicator);
value !== undefined && this.push({key: this._counter++, value});
}
}
this._buffer = '';
callback(null);
}
_suppressed_flush(callback) {
super._flush(error => {
if (error) return callback(error);
if (this._rest) {
const value = JsonlParser.checkedParse(this._rest, this._reviver, this._errorIndicator);
value !== undefined && this.push({key: this._counter++, value});
this._rest = '';
}
callback(null);
});
}
_checked_processBuffer(callback) {
const lines = this._buffer.split('\n');
this._rest += lines[0];
if (lines.length > 1) {
try {
this._rest && this.push({key: this._counter++, value: JSON.parse(this._rest, this._reviver)});
this._rest = lines.pop();
for (let i = 1; i < lines.length; ++i) {
lines[i] && this.push({key: this._counter++, value: JSON.parse(lines[i], this._reviver)});
}
} catch (cbErr) {
this._buffer = '';
callback(cbErr);
return;
}
}
this._buffer = '';
callback(null);
}
_checked_flush(callback) {
super._flush(error => {
if (error) return callback(error);
if (this._rest) {
try {
this.push({key: this._counter++, value: JSON.parse(this._rest, this._reviver)});
} catch (cbErr) {
this._rest = '';
callback(cbErr);
return;
}
this._rest = '';
}
callback(null);
});
}
}
JsonlParser.parser = JsonlParser.make;
JsonlParser.make.Constructor = JsonlParser;
module.exports = JsonlParser;

View File

@@ -0,0 +1 @@
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/api/options.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,WAAW,mBAAmB;IAChC,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IAC/B,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gCAAgC;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,MAAM,aAAa,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;AAErE,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,IAAI,kBAAkB,CAEpF;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAElE;AAED,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;CAChE;AAED,MAAM,WAAW,UAAW,SAAQ,kBAAkB;CACrD"}

View File

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