WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1,261 @@
|
||||
// @ts-ignore TS6133
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
import * as z from "zod/v3";
|
||||
import { util } from "../helpers/util.js";
|
||||
|
||||
const args1 = z.tuple([z.string()]);
|
||||
const returns1 = z.number();
|
||||
const func1 = z.function(args1, returns1);
|
||||
|
||||
test("function parsing", () => {
|
||||
const parsed = func1.parse((arg: any) => arg.length);
|
||||
const result = parsed("asdf");
|
||||
expect(result).toBe(4);
|
||||
});
|
||||
|
||||
test("parsed function fail 1", () => {
|
||||
const parsed = func1.parse((x: string) => x);
|
||||
expect(() => parsed("asdf")).toThrow();
|
||||
});
|
||||
|
||||
test("parsed function fail 2", () => {
|
||||
const parsed = func1.parse((x: string) => x);
|
||||
expect(() => parsed(13 as any)).toThrow();
|
||||
});
|
||||
|
||||
test("function inference 1", () => {
|
||||
type func1 = z.TypeOf<typeof func1>;
|
||||
util.assertEqual<func1, (k: string) => number>(true);
|
||||
});
|
||||
|
||||
test("method parsing", () => {
|
||||
const methodObject = z.object({
|
||||
property: z.number(),
|
||||
method: z.function().args(z.string()).returns(z.number()),
|
||||
});
|
||||
const methodInstance = {
|
||||
property: 3,
|
||||
method: function (s: string) {
|
||||
return s.length + this.property;
|
||||
},
|
||||
};
|
||||
const parsed = methodObject.parse(methodInstance);
|
||||
expect(parsed.method("length=8")).toBe(11); // 8 length + 3 property
|
||||
});
|
||||
|
||||
test("async method parsing", async () => {
|
||||
const methodObject = z.object({
|
||||
property: z.number(),
|
||||
method: z.function().args(z.string()).returns(z.promise(z.number())),
|
||||
});
|
||||
const methodInstance = {
|
||||
property: 3,
|
||||
method: async function (s: string) {
|
||||
return s.length + this.property;
|
||||
},
|
||||
};
|
||||
const parsed = methodObject.parse(methodInstance);
|
||||
expect(await parsed.method("length=8")).toBe(11); // 8 length + 3 property
|
||||
});
|
||||
|
||||
test("args method", () => {
|
||||
const t1 = z.function();
|
||||
type t1 = z.infer<typeof t1>;
|
||||
util.assertEqual<t1, (...args_1: unknown[]) => unknown>(true);
|
||||
|
||||
const t2 = t1.args(z.string());
|
||||
type t2 = z.infer<typeof t2>;
|
||||
util.assertEqual<t2, (arg: string, ...args_1: unknown[]) => unknown>(true);
|
||||
|
||||
const t3 = t2.returns(z.boolean());
|
||||
type t3 = z.infer<typeof t3>;
|
||||
util.assertEqual<t3, (arg: string, ...args_1: unknown[]) => boolean>(true);
|
||||
});
|
||||
|
||||
const args2 = z.tuple([
|
||||
z.object({
|
||||
f1: z.number(),
|
||||
f2: z.string().nullable(),
|
||||
f3: z.array(z.boolean().optional()).optional(),
|
||||
}),
|
||||
]);
|
||||
const returns2 = z.union([z.string(), z.number()]);
|
||||
|
||||
const func2 = z.function(args2, returns2);
|
||||
|
||||
test("function inference 2", () => {
|
||||
type func2 = z.TypeOf<typeof func2>;
|
||||
util.assertEqual<
|
||||
func2,
|
||||
(arg: {
|
||||
f1: number;
|
||||
f2: string | null;
|
||||
f3?: (boolean | undefined)[] | undefined;
|
||||
}) => string | number
|
||||
>(true);
|
||||
});
|
||||
|
||||
test("valid function run", () => {
|
||||
const validFunc2Instance = func2.validate((_x) => {
|
||||
return "adf" as any;
|
||||
});
|
||||
|
||||
const checker = () => {
|
||||
validFunc2Instance({
|
||||
f1: 21,
|
||||
f2: "asdf",
|
||||
f3: [true, false],
|
||||
});
|
||||
};
|
||||
|
||||
checker();
|
||||
});
|
||||
|
||||
test("input validation error", () => {
|
||||
const invalidFuncInstance = func2.validate((_x) => {
|
||||
return "adf" as any;
|
||||
});
|
||||
|
||||
const checker = () => {
|
||||
invalidFuncInstance("Invalid_input" as any);
|
||||
};
|
||||
|
||||
expect(checker).toThrow();
|
||||
});
|
||||
|
||||
test("output validation error", () => {
|
||||
const invalidFuncInstance = func2.validate((_x) => {
|
||||
return ["this", "is", "not", "valid", "output"] as any;
|
||||
});
|
||||
|
||||
const checker = () => {
|
||||
invalidFuncInstance({
|
||||
f1: 21,
|
||||
f2: "asdf",
|
||||
f3: [true, false],
|
||||
});
|
||||
};
|
||||
|
||||
expect(checker).toThrow();
|
||||
});
|
||||
|
||||
z.function(z.tuple([z.string()])).args()._def.args;
|
||||
|
||||
test("special function error codes", () => {
|
||||
const checker = z.function(z.tuple([z.string()]), z.boolean()).implement((arg) => {
|
||||
return arg.length as any;
|
||||
});
|
||||
try {
|
||||
checker("12" as any);
|
||||
} catch (err) {
|
||||
const zerr = err as z.ZodError;
|
||||
const first = zerr.issues[0];
|
||||
if (first.code !== z.ZodIssueCode.invalid_return_type) throw new Error();
|
||||
|
||||
expect(first.returnTypeError).toBeInstanceOf(z.ZodError);
|
||||
}
|
||||
|
||||
try {
|
||||
checker(12 as any);
|
||||
} catch (err) {
|
||||
const zerr = err as z.ZodError;
|
||||
const first = zerr.issues[0];
|
||||
if (first.code !== z.ZodIssueCode.invalid_arguments) throw new Error();
|
||||
expect(first.argumentsError).toBeInstanceOf(z.ZodError);
|
||||
}
|
||||
});
|
||||
|
||||
test("function with async refinements", async () => {
|
||||
const func = z
|
||||
.function()
|
||||
.args(z.string().refine(async (val) => val.length > 10))
|
||||
.returns(z.promise(z.number().refine(async (val) => val > 10)))
|
||||
.implement(async (val) => {
|
||||
return val.length;
|
||||
});
|
||||
const results = [];
|
||||
try {
|
||||
await func("asdfasdf");
|
||||
results.push("success");
|
||||
} catch (_err) {
|
||||
results.push("fail");
|
||||
}
|
||||
try {
|
||||
await func("asdflkjasdflkjsf");
|
||||
results.push("success");
|
||||
} catch (_err) {
|
||||
results.push("fail");
|
||||
}
|
||||
|
||||
expect(results).toEqual(["fail", "success"]);
|
||||
});
|
||||
|
||||
test("non async function with async refinements should fail", async () => {
|
||||
const func = z
|
||||
.function()
|
||||
.args(z.string().refine(async (val) => val.length > 10))
|
||||
.returns(z.number().refine(async (val) => val > 10))
|
||||
.implement((val) => {
|
||||
return val.length;
|
||||
});
|
||||
|
||||
const results = [];
|
||||
try {
|
||||
await func("asdasdfasdffasdf");
|
||||
results.push("success");
|
||||
} catch (_err) {
|
||||
results.push("fail");
|
||||
}
|
||||
|
||||
expect(results).toEqual(["fail"]);
|
||||
});
|
||||
|
||||
test("allow extra parameters", () => {
|
||||
const maxLength5 = z
|
||||
.function()
|
||||
.args(z.string())
|
||||
.returns(z.boolean())
|
||||
.implement((str, _arg, _qewr) => {
|
||||
return str.length <= 5;
|
||||
});
|
||||
|
||||
const filteredList = ["apple", "orange", "pear", "banana", "strawberry"].filter(maxLength5);
|
||||
expect(filteredList.length).toEqual(2);
|
||||
});
|
||||
|
||||
test("params and returnType getters", () => {
|
||||
const func = z.function().args(z.string()).returns(z.string());
|
||||
|
||||
const paramResult = func.parameters().items[0].parse("asdf");
|
||||
expect(paramResult).toBe("asdf");
|
||||
|
||||
const returnResult = func.returnType().parse("asdf");
|
||||
expect(returnResult).toBe("asdf");
|
||||
});
|
||||
|
||||
test("inference with transforms", () => {
|
||||
const funcSchema = z
|
||||
.function()
|
||||
.args(z.string().transform((val) => val.length))
|
||||
.returns(z.object({ val: z.number() }));
|
||||
const myFunc = funcSchema.implement((val) => {
|
||||
return { val, extra: "stuff" };
|
||||
});
|
||||
myFunc("asdf");
|
||||
|
||||
util.assertEqual<typeof myFunc, (arg: string, ...args_1: unknown[]) => { val: number; extra: string }>(true);
|
||||
});
|
||||
|
||||
test("fallback to OuterTypeOfFunction", () => {
|
||||
const funcSchema = z
|
||||
.function()
|
||||
.args(z.string().transform((val) => val.length))
|
||||
.returns(z.object({ arg: z.number() }).transform((val) => val.arg));
|
||||
|
||||
const myFunc = funcSchema.implement((val) => {
|
||||
return { arg: val, arg2: false };
|
||||
});
|
||||
|
||||
util.assertEqual<typeof myFunc, (arg: string, ...args_1: unknown[]) => number>(true);
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"name": "pg",
|
||||
"version": "8.23.0",
|
||||
"description": "PostgreSQL client - pure javascript & libpq with the same API",
|
||||
"keywords": [
|
||||
"database",
|
||||
"libpq",
|
||||
"pg",
|
||||
"postgre",
|
||||
"postgres",
|
||||
"postgresql",
|
||||
"rdbms"
|
||||
],
|
||||
"homepage": "https://github.com/brianc/node-postgres",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/brianc/node-postgres.git",
|
||||
"directory": "packages/pg"
|
||||
},
|
||||
"author": "Brian Carlson <brian.m.carlson@gmail.com>",
|
||||
"main": "./lib",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./esm/index.mjs",
|
||||
"require": "./lib/index.js",
|
||||
"default": "./lib/index.js"
|
||||
},
|
||||
"./package.json": {
|
||||
"default": "./package.json"
|
||||
},
|
||||
"./lib/*": "./lib/*.js",
|
||||
"./lib/*.js": "./lib/*.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"pg-connection-string": "^2.14.0",
|
||||
"pg-pool": "^3.14.0",
|
||||
"pg-protocol": "^1.16.0",
|
||||
"pg-types": "2.2.0",
|
||||
"pgpass": "1.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/vitest-pool-workers": "0.8.23",
|
||||
"@cloudflare/workers-types": "^4.20230404.0",
|
||||
"async": "2.6.4",
|
||||
"bluebird": "3.7.2",
|
||||
"co": "4.6.0",
|
||||
"pg-copy-streams": "0.3.0",
|
||||
"typescript": "^6.0.3",
|
||||
"vitest": "~3.0.9",
|
||||
"wrangler": "^3.x"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"pg-cloudflare": "^1.4.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"pg-native": ">=3.0.1"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"pg-native": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test-all"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"esm",
|
||||
"SPONSORS.md"
|
||||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 16.0.0"
|
||||
},
|
||||
"gitHead": "df274d1ba9ad9d11a8f1079314faeafde7208207"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { type CurveFn, type EdwardsPoint } from './abstract/edwards.ts';
|
||||
import { type CurveFn as WCurveFn } from './abstract/weierstrass.ts';
|
||||
/** Curve over scalar field of bls12-381. jubjub Fp = bls n */
|
||||
export declare const jubjub: CurveFn;
|
||||
/** Curve over scalar field of bn254. babyjubjub Fp = bn254 n */
|
||||
export declare const babyjubjub: CurveFn;
|
||||
export declare function jubjub_groupHash(tag: Uint8Array, personalization: Uint8Array): EdwardsPoint;
|
||||
export declare function jubjub_findGroupHash(m: Uint8Array, personalization: Uint8Array): EdwardsPoint;
|
||||
export declare const pasta_p: bigint;
|
||||
export declare const pasta_q: bigint;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export declare const pallas: WCurveFn;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export declare const vesta: WCurveFn;
|
||||
//# sourceMappingURL=misc.d.ts.map
|
||||
@@ -0,0 +1,196 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.serialize = void 0;
|
||||
const buffer_writer_1 = require("./buffer-writer");
|
||||
const writer = new buffer_writer_1.Writer();
|
||||
const startup = (opts) => {
|
||||
// protocol version
|
||||
writer.addInt16(3).addInt16(0);
|
||||
for (const key of Object.keys(opts)) {
|
||||
writer.addCString(key).addCString(opts[key]);
|
||||
}
|
||||
writer.addCString('client_encoding').addCString('UTF8');
|
||||
const bodyBuffer = writer.addCString('').flush();
|
||||
// this message is sent without a code
|
||||
const length = bodyBuffer.length + 4;
|
||||
return new buffer_writer_1.Writer().addInt32(length).add(bodyBuffer).flush();
|
||||
};
|
||||
const requestSsl = () => {
|
||||
const response = Buffer.allocUnsafe(8);
|
||||
response.writeInt32BE(8, 0);
|
||||
response.writeInt32BE(80877103, 4);
|
||||
return response;
|
||||
};
|
||||
const password = (password) => {
|
||||
return writer.addCString(password).flush(112 /* code.startup */);
|
||||
};
|
||||
const sendSASLInitialResponseMessage = function (mechanism, initialResponse) {
|
||||
// 0x70 = 'p'
|
||||
writer.addCString(mechanism).addInt32PrefixedString(initialResponse);
|
||||
return writer.flush(112 /* code.startup */);
|
||||
};
|
||||
const sendSCRAMClientFinalMessage = function (additionalData) {
|
||||
return writer.addString(additionalData).flush(112 /* code.startup */);
|
||||
};
|
||||
const query = (text) => {
|
||||
return writer.addCString(text).flush(81 /* code.query */);
|
||||
};
|
||||
const emptyArray = [];
|
||||
const parse = (query) => {
|
||||
// expect something like this:
|
||||
// { name: 'queryName',
|
||||
// text: 'select * from blah',
|
||||
// types: ['int8', 'bool'] }
|
||||
// normalize missing query names to allow for null
|
||||
const name = query.name || '';
|
||||
if (name.length > 63) {
|
||||
console.error('Warning! Postgres only supports 63 characters for query names.');
|
||||
console.error('You supplied %s (%s)', name, name.length);
|
||||
console.error('This can cause conflicts and silent errors executing queries');
|
||||
}
|
||||
const types = query.types || emptyArray;
|
||||
const len = types.length;
|
||||
const buffer = writer
|
||||
.addCString(name) // name of query
|
||||
.addCString(query.text) // actual query text
|
||||
.addInt16(len);
|
||||
for (let i = 0; i < len; i++) {
|
||||
buffer.addInt32(types[i]);
|
||||
}
|
||||
return writer.flush(80 /* code.parse */);
|
||||
};
|
||||
const paramWriter = new buffer_writer_1.Writer();
|
||||
const writeValues = function (values, valueMapper) {
|
||||
for (let i = 0; i < values.length; i++) {
|
||||
const mappedVal = valueMapper ? valueMapper(values[i], i) : values[i];
|
||||
if (mappedVal == null) {
|
||||
// add the param type (string) to the writer
|
||||
writer.addInt16(0 /* ParamType.STRING */);
|
||||
// write -1 to the param writer to indicate null
|
||||
paramWriter.addInt32(-1);
|
||||
}
|
||||
else if (mappedVal instanceof Buffer) {
|
||||
// add the param type (binary) to the writer
|
||||
writer.addInt16(1 /* ParamType.BINARY */);
|
||||
// add the buffer to the param writer
|
||||
paramWriter.addInt32(mappedVal.length);
|
||||
paramWriter.add(mappedVal);
|
||||
}
|
||||
else {
|
||||
// add the param type (string) to the writer
|
||||
writer.addInt16(0 /* ParamType.STRING */);
|
||||
// length prefix + UTF-8 bytes in one pass (Buffer.byteLength computed once)
|
||||
paramWriter.addInt32PrefixedString(mappedVal);
|
||||
}
|
||||
}
|
||||
};
|
||||
const bind = (config = {}) => {
|
||||
// normalize config
|
||||
const portal = config.portal || '';
|
||||
const statement = config.statement || '';
|
||||
const binary = config.binary || false;
|
||||
const values = config.values || emptyArray;
|
||||
const len = values.length;
|
||||
writer.addCString(portal).addCString(statement);
|
||||
writer.addInt16(len);
|
||||
try {
|
||||
writeValues(values, config.valueMapper);
|
||||
}
|
||||
catch (err) {
|
||||
writer.clear();
|
||||
paramWriter.clear();
|
||||
throw err;
|
||||
}
|
||||
writer.addInt16(len);
|
||||
writer.add(paramWriter.flush());
|
||||
// all results use the same format code
|
||||
writer.addInt16(1);
|
||||
// format code
|
||||
writer.addInt16(binary ? 1 /* ParamType.BINARY */ : 0 /* ParamType.STRING */);
|
||||
return writer.flush(66 /* code.bind */);
|
||||
};
|
||||
const emptyExecute = Buffer.from([69 /* code.execute */, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00]);
|
||||
const execute = (config) => {
|
||||
// this is the happy path for most queries
|
||||
if (!config || (!config.portal && !config.rows)) {
|
||||
return emptyExecute;
|
||||
}
|
||||
const portal = config.portal || '';
|
||||
const rows = config.rows || 0;
|
||||
const portalLength = Buffer.byteLength(portal);
|
||||
const len = 4 + portalLength + 1 + 4;
|
||||
// one extra bit for code
|
||||
const buff = Buffer.allocUnsafe(1 + len);
|
||||
buff[0] = 69 /* code.execute */;
|
||||
buff.writeInt32BE(len, 1);
|
||||
buff.write(portal, 5, 'utf-8');
|
||||
buff[portalLength + 5] = 0; // null terminate portal cString
|
||||
buff.writeUInt32BE(rows, buff.length - 4);
|
||||
return buff;
|
||||
};
|
||||
const cancel = (processID, secretKey) => {
|
||||
const buffer = Buffer.allocUnsafe(16);
|
||||
buffer.writeInt32BE(16, 0);
|
||||
buffer.writeInt16BE(1234, 4);
|
||||
buffer.writeInt16BE(5678, 6);
|
||||
buffer.writeInt32BE(processID, 8);
|
||||
buffer.writeInt32BE(secretKey, 12);
|
||||
return buffer;
|
||||
};
|
||||
const cstringMessage = (code, string) => {
|
||||
const stringLen = Buffer.byteLength(string);
|
||||
const len = 4 + stringLen + 1;
|
||||
// one extra bit for code
|
||||
const buffer = Buffer.allocUnsafe(1 + len);
|
||||
buffer[0] = code;
|
||||
buffer.writeInt32BE(len, 1);
|
||||
buffer.write(string, 5, 'utf-8');
|
||||
buffer[len] = 0; // null terminate cString
|
||||
return buffer;
|
||||
};
|
||||
const emptyDescribePortal = writer.addCString('P').flush(68 /* code.describe */);
|
||||
const emptyDescribeStatement = writer.addCString('S').flush(68 /* code.describe */);
|
||||
const describe = (msg) => {
|
||||
return msg.name
|
||||
? cstringMessage(68 /* code.describe */, `${msg.type}${msg.name || ''}`)
|
||||
: msg.type === 'P'
|
||||
? emptyDescribePortal
|
||||
: emptyDescribeStatement;
|
||||
};
|
||||
const close = (msg) => {
|
||||
const text = `${msg.type}${msg.name || ''}`;
|
||||
return cstringMessage(67 /* code.close */, text);
|
||||
};
|
||||
const copyData = (chunk) => {
|
||||
return writer.add(chunk).flush(100 /* code.copyFromChunk */);
|
||||
};
|
||||
const copyFail = (message) => {
|
||||
return cstringMessage(102 /* code.copyFail */, message);
|
||||
};
|
||||
const codeOnlyBuffer = (code) => Buffer.from([code, 0x00, 0x00, 0x00, 0x04]);
|
||||
const flushBuffer = codeOnlyBuffer(72 /* code.flush */);
|
||||
const syncBuffer = codeOnlyBuffer(83 /* code.sync */);
|
||||
const endBuffer = codeOnlyBuffer(88 /* code.end */);
|
||||
const copyDoneBuffer = codeOnlyBuffer(99 /* code.copyDone */);
|
||||
const serialize = {
|
||||
startup,
|
||||
password,
|
||||
requestSsl,
|
||||
sendSASLInitialResponseMessage,
|
||||
sendSCRAMClientFinalMessage,
|
||||
query,
|
||||
parse,
|
||||
bind,
|
||||
execute,
|
||||
describe,
|
||||
close,
|
||||
flush: () => flushBuffer,
|
||||
sync: () => syncBuffer,
|
||||
end: () => endBuffer,
|
||||
copyData,
|
||||
copyDone: () => copyDoneBuffer,
|
||||
copyFail,
|
||||
cancel,
|
||||
};
|
||||
exports.serialize = serialize;
|
||||
//# sourceMappingURL=serializer.js.map
|
||||
@@ -0,0 +1,35 @@
|
||||
# Pretty Printing
|
||||
|
||||
By default, Pino log lines are newline delimited JSON (NDJSON). This is perfect
|
||||
for production usage and long-term storage. It's not so great for development
|
||||
environments. Thus, Pino logs can be prettified by using a Pino prettifier
|
||||
module like [`pino-pretty`][pp]:
|
||||
|
||||
1. Install a prettifier module as a separate dependency, e.g. `npm install pino-pretty`.
|
||||
2. Instantiate the logger with the `transport.target` option set to `'pino-pretty'`:
|
||||
```js
|
||||
const pino = require('pino')
|
||||
const logger = pino({
|
||||
transport: {
|
||||
target: 'pino-pretty'
|
||||
},
|
||||
})
|
||||
|
||||
logger.info('hi')
|
||||
```
|
||||
3. The transport option can also have an options object containing `pino-pretty` options:
|
||||
```js
|
||||
const pino = require('pino')
|
||||
const logger = pino({
|
||||
transport: {
|
||||
target: 'pino-pretty',
|
||||
options: {
|
||||
colorize: true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
logger.info('hi')
|
||||
```
|
||||
|
||||
[pp]: https://github.com/pinojs/pino-pretty
|
||||
@@ -0,0 +1,2 @@
|
||||
import type { LibDefinition } from '../variable';
|
||||
export declare const es2022_regexp: LibDefinition;
|
||||
@@ -0,0 +1,23 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 David Mark Clements
|
||||
Copyright (c) 2017 David Mark Clements & Matteo Collina
|
||||
Copyright (c) 2018 David Mark Clements, Matteo Collina & Ruben Bridgewater
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,32 @@
|
||||
"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.es2015 = void 0;
|
||||
const es5_1 = require("./es5");
|
||||
const es2015_collection_1 = require("./es2015.collection");
|
||||
const es2015_core_1 = require("./es2015.core");
|
||||
const es2015_generator_1 = require("./es2015.generator");
|
||||
const es2015_iterable_1 = require("./es2015.iterable");
|
||||
const es2015_promise_1 = require("./es2015.promise");
|
||||
const es2015_proxy_1 = require("./es2015.proxy");
|
||||
const es2015_reflect_1 = require("./es2015.reflect");
|
||||
const es2015_symbol_1 = require("./es2015.symbol");
|
||||
const es2015_symbol_wellknown_1 = require("./es2015.symbol.wellknown");
|
||||
exports.es2015 = {
|
||||
libs: [
|
||||
es5_1.es5,
|
||||
es2015_core_1.es2015_core,
|
||||
es2015_collection_1.es2015_collection,
|
||||
es2015_iterable_1.es2015_iterable,
|
||||
es2015_generator_1.es2015_generator,
|
||||
es2015_promise_1.es2015_promise,
|
||||
es2015_proxy_1.es2015_proxy,
|
||||
es2015_reflect_1.es2015_reflect,
|
||||
es2015_symbol_1.es2015_symbol,
|
||||
es2015_symbol_wellknown_1.es2015_symbol_wellknown,
|
||||
],
|
||||
variables: [],
|
||||
};
|
||||
@@ -0,0 +1,54 @@
|
||||
interface Cache {
|
||||
has: (value: any) => boolean;
|
||||
set: (key: any, value: any) => void;
|
||||
get: (key: any) => any;
|
||||
}
|
||||
|
||||
type InternalCopier<Value> = (value: Value, state: State) => Value;
|
||||
interface State {
|
||||
Constructor: any;
|
||||
cache: Cache;
|
||||
copier: InternalCopier<any>;
|
||||
prototype: any;
|
||||
}
|
||||
|
||||
interface CopierMethods {
|
||||
array?: InternalCopier<any[]>;
|
||||
arrayBuffer?: InternalCopier<ArrayBuffer>;
|
||||
asyncGenerator?: InternalCopier<AsyncGenerator>;
|
||||
blob?: InternalCopier<Blob>;
|
||||
dataView?: InternalCopier<DataView>;
|
||||
date?: InternalCopier<Date>;
|
||||
error?: InternalCopier<Error>;
|
||||
generator?: InternalCopier<Generator>;
|
||||
map?: InternalCopier<Map<any, any>>;
|
||||
object?: InternalCopier<Record<string, any>>;
|
||||
regExp?: InternalCopier<RegExp>;
|
||||
set?: InternalCopier<Set<any>>;
|
||||
}
|
||||
interface CreateCopierOptions {
|
||||
createCache?: () => Cache;
|
||||
methods?: CopierMethods;
|
||||
strict?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a custom copier based on custom options for any of the following:
|
||||
* - `createCache` method to create a cache for copied objects
|
||||
* - custom copier `methods` for specific object types
|
||||
* - `strict` mode to copy all properties with their descriptors
|
||||
*/
|
||||
declare function createCopier(options?: CreateCopierOptions): <Value>(value: Value) => Value;
|
||||
/**
|
||||
* Copy an value deeply as much as possible, where strict recreation of object properties
|
||||
* are maintained. All properties (including non-enumerable ones) are copied with their
|
||||
* original property descriptors on both objects and arrays.
|
||||
*/
|
||||
declare const copyStrict: <Value>(value: Value) => Value;
|
||||
/**
|
||||
* Copy an value deeply as much as possible.
|
||||
*/
|
||||
declare const copy: <Value>(value: Value) => Value;
|
||||
|
||||
export { copy, copyStrict, createCopier };
|
||||
export type { CreateCopierOptions, State };
|
||||
@@ -0,0 +1,461 @@
|
||||
'use strict'
|
||||
|
||||
// Escapes sequences that could break out of an HTML <style> context.
|
||||
// Uses CSS unicode escaping (\3c = '<') which is valid CSS and parsed
|
||||
// correctly by all compliant CSS consumers.
|
||||
const STYLE_TAG = /(<)(\/?style\b)/gi
|
||||
const COMMENT_OPEN = /(<)(!--)/g
|
||||
|
||||
// Characters that end an at-rule name, mirroring RE_AT_END in the tokenizer.
|
||||
// Params starting with anything else need a space to stay separate tokens.
|
||||
const AT_NAME_END = /[\t\n\f\r "#'()/;[\\\]{}]/
|
||||
|
||||
function escapeHTMLInCSS(str) {
|
||||
if (typeof str !== 'string') return str
|
||||
if (!str.includes('<')) return str
|
||||
return str.replace(STYLE_TAG, '\\3c $2').replace(COMMENT_OPEN, '\\3c $2')
|
||||
}
|
||||
|
||||
const DEFAULT_RAW = {
|
||||
after: '\n',
|
||||
beforeClose: '\n',
|
||||
beforeComment: '\n',
|
||||
beforeDecl: '\n',
|
||||
beforeOpen: ' ',
|
||||
beforeRule: '\n',
|
||||
colon: ': ',
|
||||
commentLeft: ' ',
|
||||
commentRight: ' ',
|
||||
emptyBody: '',
|
||||
indent: ' ',
|
||||
semicolon: false
|
||||
}
|
||||
|
||||
function capitalize(str) {
|
||||
return str[0].toUpperCase() + str.slice(1)
|
||||
}
|
||||
|
||||
function atruleStart(str, node) {
|
||||
let name = '@' + node.name
|
||||
let params = node.params ? str.rawValue(node, 'params') : ''
|
||||
let afterName = node.raws.afterName
|
||||
|
||||
if (typeof afterName === 'undefined') {
|
||||
afterName = params ? ' ' : ''
|
||||
} else if (afterName === '' && params && !AT_NAME_END.test(params[0])) {
|
||||
afterName = ' '
|
||||
}
|
||||
|
||||
return name + afterName + params
|
||||
}
|
||||
|
||||
function pushBody(str, stack, node) {
|
||||
let nodes = node.nodes
|
||||
let last = nodes.length - 1
|
||||
while (last > 0) {
|
||||
if (nodes[last].type !== 'comment') break
|
||||
last -= 1
|
||||
}
|
||||
|
||||
let semicolon = str.raw(node, 'semicolon')
|
||||
let isDocument = node.type === 'document'
|
||||
for (let i = nodes.length - 1; i >= 0; i--) {
|
||||
let child = nodes[i]
|
||||
let childSemicolon = last !== i || semicolon
|
||||
// A childless at-rule or a custom property declaration that still has
|
||||
// following siblings must be terminated. Without the semicolon those
|
||||
// trailing comments are folded into the at-rule's prelude or the custom
|
||||
// property's value and disappear when the output is re-parsed.
|
||||
if (
|
||||
!childSemicolon &&
|
||||
i < nodes.length - 1 &&
|
||||
((child.type === 'atrule' && !child.nodes) ||
|
||||
(child.type === 'decl' && child.prop.startsWith('--')))
|
||||
) {
|
||||
childSemicolon = true
|
||||
}
|
||||
stack.push({
|
||||
document: isDocument,
|
||||
node: child,
|
||||
semicolon: childSemicolon
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function pushBlock(str, stack, node, start) {
|
||||
let between = str.raw(node, 'between', 'beforeOpen')
|
||||
str.builder(escapeHTMLInCSS(start + between) + '{', node, 'start')
|
||||
|
||||
let hasNodes = node.nodes && node.nodes.length
|
||||
let close = () => {
|
||||
let after = hasNodes
|
||||
? str.raw(node, 'after')
|
||||
: str.raw(node, 'after', 'emptyBody')
|
||||
if (after) str.builder(escapeHTMLInCSS(after))
|
||||
str.builder('}', node, 'end')
|
||||
if (node.type === 'rule' && node.raws.ownSemicolon) {
|
||||
str.builder(escapeHTMLInCSS(node.raws.ownSemicolon), node, 'end')
|
||||
}
|
||||
}
|
||||
|
||||
if (hasNodes) {
|
||||
stack.push(close)
|
||||
pushBody(str, stack, node)
|
||||
} else {
|
||||
close()
|
||||
}
|
||||
}
|
||||
|
||||
class Stringifier {
|
||||
constructor(builder) {
|
||||
this.builder = builder
|
||||
}
|
||||
|
||||
atrule(node, semicolon) {
|
||||
let start = atruleStart(this, node)
|
||||
if (node.nodes) {
|
||||
this.block(node, start)
|
||||
} else {
|
||||
let end = (node.raws.between || '') + (semicolon ? ';' : '')
|
||||
this.builder(escapeHTMLInCSS(start + end), node)
|
||||
}
|
||||
}
|
||||
|
||||
beforeAfter(node, detect) {
|
||||
let value
|
||||
if (node.type === 'decl') {
|
||||
value = this.raw(node, null, 'beforeDecl')
|
||||
} else if (node.type === 'comment') {
|
||||
value = this.raw(node, null, 'beforeComment')
|
||||
} else if (detect === 'before') {
|
||||
value = this.raw(node, null, 'beforeRule')
|
||||
} else {
|
||||
value = this.raw(node, null, 'beforeClose')
|
||||
}
|
||||
|
||||
let buf = node.parent
|
||||
let depth = 0
|
||||
while (buf && buf.type !== 'root') {
|
||||
depth += 1
|
||||
buf = buf.parent
|
||||
}
|
||||
|
||||
if (value.includes('\n')) {
|
||||
let indent = this.raw(node, null, 'indent')
|
||||
if (indent.length) {
|
||||
for (let step = 0; step < depth; step++) value += indent
|
||||
}
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
block(node, start) {
|
||||
let between = this.raw(node, 'between', 'beforeOpen')
|
||||
this.builder(escapeHTMLInCSS(start + between) + '{', node, 'start')
|
||||
|
||||
let after
|
||||
if (node.nodes && node.nodes.length) {
|
||||
this.body(node)
|
||||
after = this.raw(node, 'after')
|
||||
} else {
|
||||
after = this.raw(node, 'after', 'emptyBody')
|
||||
}
|
||||
|
||||
if (after) this.builder(escapeHTMLInCSS(after))
|
||||
this.builder('}', node, 'end')
|
||||
}
|
||||
|
||||
body(node) {
|
||||
// Rules and at-rules are expanded into an explicit stack instead of
|
||||
// recursive `stringify()` calls to survive deeply nested trees.
|
||||
// If a subclass changes the traversal methods, its children go
|
||||
// through `stringify()` to keep the override in charge.
|
||||
let proto = Stringifier.prototype
|
||||
let expandable = ['atrule', 'block', 'body', 'rule', 'stringify'].every(
|
||||
method => this[method] === proto[method]
|
||||
)
|
||||
|
||||
let stack = []
|
||||
pushBody(this, stack, node)
|
||||
|
||||
while (stack.length > 0) {
|
||||
let entry = stack.pop()
|
||||
if (typeof entry === 'function') {
|
||||
entry()
|
||||
continue
|
||||
}
|
||||
|
||||
let child = entry.node
|
||||
let before = this.raw(child, 'before')
|
||||
if (before) {
|
||||
this.builder(entry.document ? before : escapeHTMLInCSS(before))
|
||||
}
|
||||
|
||||
if (expandable && child.type === 'rule') {
|
||||
pushBlock(this, stack, child, this.rawValue(child, 'selector'))
|
||||
} else if (expandable && child.type === 'atrule' && child.nodes) {
|
||||
pushBlock(this, stack, child, atruleStart(this, child))
|
||||
} else {
|
||||
this.stringify(child, entry.semicolon)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
comment(node) {
|
||||
let left = this.raw(node, 'left', 'commentLeft')
|
||||
let right = this.raw(node, 'right', 'commentRight')
|
||||
this.builder(escapeHTMLInCSS('/*' + left + node.text + right + '*/'), node)
|
||||
}
|
||||
|
||||
decl(node, semicolon) {
|
||||
let raws = node.raws
|
||||
let between = this.raw(node, 'between', 'colon')
|
||||
|
||||
let string = node.prop + between + this.rawValue(node, 'value')
|
||||
|
||||
if (node.important) {
|
||||
string += raws.important || ' !important'
|
||||
}
|
||||
|
||||
if (semicolon) string += ';'
|
||||
this.builder(escapeHTMLInCSS(string), node)
|
||||
}
|
||||
|
||||
document(node) {
|
||||
this.body(node)
|
||||
}
|
||||
|
||||
raw(node, own, detect) {
|
||||
let value
|
||||
if (!detect) detect = own
|
||||
|
||||
// Already had
|
||||
if (own) {
|
||||
value = node.raws[own]
|
||||
if (typeof value !== 'undefined') return value
|
||||
}
|
||||
|
||||
let parent = node.parent
|
||||
|
||||
if (detect === 'before') {
|
||||
// Hack for first rule in CSS
|
||||
if (!parent || (parent.type === 'root' && parent.first === node)) {
|
||||
return ''
|
||||
}
|
||||
|
||||
// `root` nodes in `document` should use only their own raws
|
||||
if (parent && parent.type === 'document') {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
// Floating child without parent
|
||||
if (!parent) return DEFAULT_RAW[detect]
|
||||
|
||||
// Detect style by other nodes
|
||||
let root = node.root()
|
||||
let cache = root.rawCache || (root.rawCache = {})
|
||||
if (typeof cache[detect] !== 'undefined') {
|
||||
return cache[detect]
|
||||
}
|
||||
|
||||
if (detect === 'before' || detect === 'after') {
|
||||
return this.beforeAfter(node, detect)
|
||||
} else {
|
||||
let method = 'raw' + capitalize(detect)
|
||||
if (this[method]) {
|
||||
value = this[method](root, node)
|
||||
} else {
|
||||
root.walk(i => {
|
||||
value = i.raws[own]
|
||||
if (typeof value !== 'undefined') return false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof value === 'undefined') value = DEFAULT_RAW[detect]
|
||||
|
||||
cache[detect] = value
|
||||
return value
|
||||
}
|
||||
|
||||
rawBeforeClose(root) {
|
||||
let value
|
||||
root.walk(i => {
|
||||
if (i.nodes && i.nodes.length > 0) {
|
||||
if (typeof i.raws.after !== 'undefined') {
|
||||
value = i.raws.after
|
||||
if (value.includes('\n')) {
|
||||
value = value.replace(/[^\n]+$/, '')
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
})
|
||||
if (value) value = value.replace(/\S/g, '')
|
||||
return value
|
||||
}
|
||||
|
||||
rawBeforeComment(root, node) {
|
||||
let value
|
||||
root.walkComments(i => {
|
||||
if (typeof i.raws.before !== 'undefined') {
|
||||
value = i.raws.before
|
||||
if (value.includes('\n')) {
|
||||
value = value.replace(/[^\n]+$/, '')
|
||||
}
|
||||
return false
|
||||
}
|
||||
})
|
||||
if (typeof value === 'undefined') {
|
||||
value = this.raw(node, null, 'beforeDecl')
|
||||
} else if (value) {
|
||||
value = value.replace(/\S/g, '')
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
rawBeforeDecl(root, node) {
|
||||
let value
|
||||
root.walkDecls(i => {
|
||||
if (typeof i.raws.before !== 'undefined') {
|
||||
value = i.raws.before
|
||||
if (value.includes('\n')) {
|
||||
value = value.replace(/[^\n]+$/, '')
|
||||
}
|
||||
return false
|
||||
}
|
||||
})
|
||||
if (typeof value === 'undefined') {
|
||||
value = this.raw(node, null, 'beforeRule')
|
||||
} else if (value) {
|
||||
value = value.replace(/\S/g, '')
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
rawBeforeOpen(root) {
|
||||
let value
|
||||
root.walk(i => {
|
||||
if (i.type !== 'decl') {
|
||||
value = i.raws.between
|
||||
if (typeof value !== 'undefined') return false
|
||||
}
|
||||
})
|
||||
return value
|
||||
}
|
||||
|
||||
rawBeforeRule(root) {
|
||||
let value
|
||||
root.walk(i => {
|
||||
if (i.nodes && (i.parent !== root || root.first !== i)) {
|
||||
if (typeof i.raws.before !== 'undefined') {
|
||||
value = i.raws.before
|
||||
if (value.includes('\n')) {
|
||||
value = value.replace(/[^\n]+$/, '')
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
})
|
||||
if (value) value = value.replace(/\S/g, '')
|
||||
return value
|
||||
}
|
||||
|
||||
rawColon(root) {
|
||||
let value
|
||||
root.walkDecls(i => {
|
||||
if (typeof i.raws.between !== 'undefined') {
|
||||
value = i.raws.between.replace(/[^\s:]/g, '')
|
||||
return false
|
||||
}
|
||||
})
|
||||
return value
|
||||
}
|
||||
|
||||
rawEmptyBody(root) {
|
||||
let value
|
||||
root.walk(i => {
|
||||
if (i.nodes && i.nodes.length === 0) {
|
||||
value = i.raws.after
|
||||
if (typeof value !== 'undefined') return false
|
||||
}
|
||||
})
|
||||
return value
|
||||
}
|
||||
|
||||
rawIndent(root) {
|
||||
if (root.raws.indent) return root.raws.indent
|
||||
let value
|
||||
root.walk(i => {
|
||||
let p = i.parent
|
||||
if (p && p !== root && p.parent && p.parent === root) {
|
||||
if (typeof i.raws.before !== 'undefined') {
|
||||
let parts = i.raws.before.split('\n')
|
||||
value = parts[parts.length - 1]
|
||||
value = value.replace(/\S/g, '')
|
||||
return false
|
||||
}
|
||||
}
|
||||
})
|
||||
return value
|
||||
}
|
||||
|
||||
rawSemicolon(root) {
|
||||
let value
|
||||
root.walk(i => {
|
||||
if (i.nodes && i.nodes.length && i.last.type === 'decl') {
|
||||
value = i.raws.semicolon
|
||||
if (typeof value !== 'undefined') return false
|
||||
}
|
||||
})
|
||||
return value
|
||||
}
|
||||
|
||||
rawValue(node, prop) {
|
||||
let value = node[prop]
|
||||
let raw = node.raws[prop]
|
||||
if (raw && raw.value === value) {
|
||||
return raw.raw
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
root(node) {
|
||||
if (node.source && node.source.input.hasBOM) {
|
||||
this.builder('\uFEFF', node, 'start')
|
||||
}
|
||||
this.body(node)
|
||||
if (node.raws.after) {
|
||||
let after = node.raws.after
|
||||
let isDocument = node.parent && node.parent.type === 'document'
|
||||
this.builder(isDocument ? after : escapeHTMLInCSS(after))
|
||||
}
|
||||
}
|
||||
|
||||
rule(node) {
|
||||
this.block(node, this.rawValue(node, 'selector'))
|
||||
if (node.raws.ownSemicolon) {
|
||||
this.builder(escapeHTMLInCSS(node.raws.ownSemicolon), node, 'end')
|
||||
}
|
||||
}
|
||||
|
||||
stringify(node, semicolon) {
|
||||
/* c8 ignore start */
|
||||
if (!this[node.type]) {
|
||||
throw new Error(
|
||||
'Unknown AST node type ' +
|
||||
node.type +
|
||||
'. ' +
|
||||
'Maybe you need to change PostCSS stringifier.'
|
||||
)
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
this[node.type](node, semicolon)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Stringifier
|
||||
Stringifier.default = Stringifier
|
||||
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const HttpAgent = require('./lib/agent');
|
||||
module.exports = HttpAgent;
|
||||
module.exports.HttpAgent = HttpAgent;
|
||||
module.exports.HttpsAgent = require('./lib/https_agent');
|
||||
module.exports.constants = require('./lib/constants');
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
||||
import type { TSESTree } from '@typescript-eslint/types';
|
||||
import { VariableBase } from './VariableBase';
|
||||
/**
|
||||
* ESLint defines global variables using the eslint-scope Variable class
|
||||
* This is declared here for consumers to use
|
||||
*/
|
||||
export declare class ESLintScopeVariable extends VariableBase {
|
||||
/**
|
||||
* Written to by ESLint.
|
||||
* If this key exists, this variable is a global variable added by ESLint.
|
||||
* If this is `true`, this variable can be assigned arbitrary values.
|
||||
* If this is `false`, this variable is readonly.
|
||||
*/
|
||||
writeable?: boolean;
|
||||
/**
|
||||
* Written to by ESLint.
|
||||
* This property is undefined if there are no globals comment directives.
|
||||
* The array of globals comment directives which defined this global variable in the source code file.
|
||||
*/
|
||||
eslintExplicitGlobal?: boolean;
|
||||
/**
|
||||
* Written to by ESLint.
|
||||
* The configured value in config files. This can be different from `variable.writeable` if there are globals comment directives.
|
||||
*/
|
||||
eslintImplicitGlobalSetting?: 'readonly' | 'writable';
|
||||
/**
|
||||
* Written to by ESLint.
|
||||
* If this key exists, it is a global variable added by ESLint.
|
||||
* If `true`, this global variable was defined by a globals comment directive in the source code file.
|
||||
*/
|
||||
eslintExplicitGlobalComments?: TSESTree.Comment[];
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
'use strict'
|
||||
|
||||
const pino = require('../../')
|
||||
const { join } = require('node:path')
|
||||
|
||||
const destination = process.argv[2]
|
||||
|
||||
process.env.NODE_OPTIONS = `--require ${join(__dirname, 'this-file-does-not-exist.js')}`
|
||||
|
||||
const transport = pino.transport({
|
||||
target: join(__dirname, 'to-file-transport.js'),
|
||||
options: { destination }
|
||||
})
|
||||
|
||||
const logger = pino(transport)
|
||||
transport.on('ready', () => {
|
||||
logger.info('hello with invalid node options preload')
|
||||
setTimeout(() => {
|
||||
transport.end()
|
||||
}, 50)
|
||||
})
|
||||
|
||||
transport.on('error', (err) => {
|
||||
process.stderr.write(`${err.stack}\n`)
|
||||
process.exitCode = 1
|
||||
})
|
||||
@@ -0,0 +1,3 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = require('neostandard')({})
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* To add a new error, follow the instructions at
|
||||
* https://github.com/anza-xyz/kit/tree/main/packages/errors#adding-a-new-error
|
||||
*
|
||||
* WARNING:
|
||||
* - Don't change the meaning of an error message.
|
||||
*/
|
||||
import { SolanaErrorCode } from './codes';
|
||||
/**
|
||||
* A map of every {@link SolanaError} code to the error message shown to developers in development
|
||||
* mode.
|
||||
*/
|
||||
export declare const SolanaErrorMessages: Readonly<{
|
||||
[P in SolanaErrorCode]: string;
|
||||
}>;
|
||||
//# sourceMappingURL=messages.d.ts.map
|
||||
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Maximum over-the-wire size of a Transaction
|
||||
*
|
||||
* 1280 is IPv6 minimum MTU
|
||||
* 40 bytes is the size of the IPv6 header
|
||||
* 8 bytes is the size of the fragment header
|
||||
*/
|
||||
export const PACKET_DATA_SIZE = 1280 - 40 - 8;
|
||||
|
||||
export const VERSION_PREFIX_MASK = 0x7f;
|
||||
|
||||
export const SIGNATURE_LENGTH_IN_BYTES = 64;
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,24 @@
|
||||
'use strict'
|
||||
|
||||
const { test } = require('node:test')
|
||||
const assert = require('node:assert')
|
||||
const { join } = require('path')
|
||||
const ThreadStream = require('..')
|
||||
|
||||
test('event propagate', (t, done) => {
|
||||
const stream = new ThreadStream({
|
||||
filename: join(__dirname, 'emit-event.js'),
|
||||
workerData: {},
|
||||
sync: true
|
||||
})
|
||||
t.after(() => stream.end())
|
||||
stream.on('socketError', function (a, b, c, n, error) {
|
||||
assert.deepStrictEqual(a, 'list')
|
||||
assert.deepStrictEqual(b, 'of')
|
||||
assert.deepStrictEqual(c, 'args')
|
||||
assert.deepStrictEqual(n, 123)
|
||||
assert.deepStrictEqual(error, new Error('unable to write data to the TCP socket'))
|
||||
done()
|
||||
})
|
||||
stream.write('hello')
|
||||
})
|
||||
@@ -0,0 +1,32 @@
|
||||
const lineSplitRE = /\r?\n/;
|
||||
function positionToOffset(source, lineNumber, columnNumber) {
|
||||
const lines = source.split(lineSplitRE);
|
||||
const nl = /\r\n/.test(source) ? 2 : 1;
|
||||
let start = 0;
|
||||
if (lineNumber > lines.length) {
|
||||
return source.length;
|
||||
}
|
||||
for (let i = 0; i < lineNumber - 1; i++) {
|
||||
start += lines[i].length + nl;
|
||||
}
|
||||
return start + columnNumber;
|
||||
}
|
||||
function offsetToLineNumber(source, offset) {
|
||||
if (offset > source.length) {
|
||||
throw new Error(`offset is longer than source length! offset ${offset} > length ${source.length}`);
|
||||
}
|
||||
const lines = source.split(lineSplitRE);
|
||||
const nl = /\r\n/.test(source) ? 2 : 1;
|
||||
let counted = 0;
|
||||
let line = 0;
|
||||
for (; line < lines.length; line++) {
|
||||
const lineLength = lines[line].length + nl;
|
||||
if (counted + lineLength >= offset) {
|
||||
break;
|
||||
}
|
||||
counted += lineLength;
|
||||
}
|
||||
return line + 1;
|
||||
}
|
||||
|
||||
export { lineSplitRE, offsetToLineNumber, positionToOffset };
|
||||
@@ -0,0 +1,22 @@
|
||||
var getGitHashSync = require('./get-git-hash-sync');
|
||||
var path = require('path');
|
||||
|
||||
module.exports = function(libName) {
|
||||
var pkg;
|
||||
var version;
|
||||
if (libName == 'index') {
|
||||
pkg = require('../package.json');
|
||||
version = getGitHashSync(require.resolve('../index'));
|
||||
} else if (libName == 'native') {
|
||||
pkg = { name: 'JSON.stringify', url: 'n/a' };
|
||||
version = 'native';
|
||||
} else {
|
||||
pkg = require(libName + '/package.json');
|
||||
version = pkg.version;
|
||||
}
|
||||
return {
|
||||
name: pkg.name,
|
||||
url: pkg.url,
|
||||
version: version
|
||||
}
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,263 @@
|
||||
'use strict';
|
||||
|
||||
function hasKey(obj, keys) {
|
||||
var o = obj;
|
||||
keys.slice(0, -1).forEach(function (key) {
|
||||
o = o[key] || {};
|
||||
});
|
||||
|
||||
var key = keys[keys.length - 1];
|
||||
return key in o;
|
||||
}
|
||||
|
||||
function isNumber(x) {
|
||||
if (typeof x === 'number') { return true; }
|
||||
if ((/^0x[0-9a-f]+$/i).test(x)) { return true; }
|
||||
return (/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/).test(x);
|
||||
}
|
||||
|
||||
function isConstructorOrProto(obj, key) {
|
||||
return (key === 'constructor' && typeof obj[key] === 'function') || key === '__proto__';
|
||||
}
|
||||
|
||||
module.exports = function (args, opts) {
|
||||
if (!opts) { opts = {}; }
|
||||
|
||||
var flags = {
|
||||
bools: {},
|
||||
strings: {},
|
||||
unknownFn: null,
|
||||
};
|
||||
|
||||
if (typeof opts.unknown === 'function') {
|
||||
flags.unknownFn = opts.unknown;
|
||||
}
|
||||
|
||||
if (typeof opts.boolean === 'boolean' && opts.boolean) {
|
||||
flags.allBools = true;
|
||||
} else {
|
||||
[].concat(opts.boolean).filter(Boolean).forEach(function (key) {
|
||||
flags.bools[key] = true;
|
||||
});
|
||||
}
|
||||
|
||||
var aliases = {};
|
||||
|
||||
function aliasIsBoolean(key) {
|
||||
return aliases[key].some(function (x) {
|
||||
return flags.bools[x];
|
||||
});
|
||||
}
|
||||
|
||||
Object.keys(opts.alias || {}).forEach(function (key) {
|
||||
aliases[key] = [].concat(opts.alias[key]);
|
||||
aliases[key].forEach(function (x) {
|
||||
aliases[x] = [key].concat(aliases[key].filter(function (y) {
|
||||
return x !== y;
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
[].concat(opts.string).filter(Boolean).forEach(function (key) {
|
||||
flags.strings[key] = true;
|
||||
if (aliases[key]) {
|
||||
[].concat(aliases[key]).forEach(function (k) {
|
||||
flags.strings[k] = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var defaults = opts.default || {};
|
||||
|
||||
var argv = { _: [] };
|
||||
|
||||
function argDefined(key, arg) {
|
||||
return (flags.allBools && (/^--[^=]+$/).test(arg))
|
||||
|| flags.strings[key]
|
||||
|| flags.bools[key]
|
||||
|| aliases[key];
|
||||
}
|
||||
|
||||
function setKey(obj, keys, value) {
|
||||
var o = obj;
|
||||
for (var i = 0; i < keys.length - 1; i++) {
|
||||
var key = keys[i];
|
||||
if (isConstructorOrProto(o, key)) { return; }
|
||||
if (o[key] === undefined) { o[key] = {}; }
|
||||
if (
|
||||
o[key] === Object.prototype
|
||||
|| o[key] === Number.prototype
|
||||
|| o[key] === String.prototype
|
||||
) {
|
||||
o[key] = {};
|
||||
}
|
||||
if (o[key] === Array.prototype) { o[key] = []; }
|
||||
o = o[key];
|
||||
}
|
||||
|
||||
var lastKey = keys[keys.length - 1];
|
||||
if (isConstructorOrProto(o, lastKey)) { return; }
|
||||
if (
|
||||
o === Object.prototype
|
||||
|| o === Number.prototype
|
||||
|| o === String.prototype
|
||||
) {
|
||||
o = {};
|
||||
}
|
||||
if (o === Array.prototype) { o = []; }
|
||||
if (o[lastKey] === undefined || flags.bools[lastKey] || typeof o[lastKey] === 'boolean') {
|
||||
o[lastKey] = value;
|
||||
} else if (Array.isArray(o[lastKey])) {
|
||||
o[lastKey].push(value);
|
||||
} else {
|
||||
o[lastKey] = [o[lastKey], value];
|
||||
}
|
||||
}
|
||||
|
||||
function setArg(key, val, arg) {
|
||||
if (arg && flags.unknownFn && !argDefined(key, arg)) {
|
||||
if (flags.unknownFn(arg) === false) { return; }
|
||||
}
|
||||
|
||||
var value = !flags.strings[key] && isNumber(val)
|
||||
? Number(val)
|
||||
: val;
|
||||
setKey(argv, key.split('.'), value);
|
||||
|
||||
(aliases[key] || []).forEach(function (x) {
|
||||
setKey(argv, x.split('.'), value);
|
||||
});
|
||||
}
|
||||
|
||||
Object.keys(flags.bools).forEach(function (key) {
|
||||
setArg(key, defaults[key] === undefined ? false : defaults[key]);
|
||||
});
|
||||
|
||||
var notFlags = [];
|
||||
|
||||
if (args.indexOf('--') !== -1) {
|
||||
notFlags = args.slice(args.indexOf('--') + 1);
|
||||
args = args.slice(0, args.indexOf('--'));
|
||||
}
|
||||
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
var arg = args[i];
|
||||
var key;
|
||||
var next;
|
||||
|
||||
if ((/^--.+=/).test(arg)) {
|
||||
// Using [\s\S] instead of . because js doesn't support the
|
||||
// 'dotall' regex modifier. See:
|
||||
// http://stackoverflow.com/a/1068308/13216
|
||||
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
|
||||
key = m[1];
|
||||
var value = m[2];
|
||||
if (flags.bools[key]) {
|
||||
value = value !== 'false';
|
||||
}
|
||||
setArg(key, value, arg);
|
||||
} else if ((/^--no-.+/).test(arg)) {
|
||||
key = arg.match(/^--no-(.+)/)[1];
|
||||
setArg(key, false, arg);
|
||||
} else if ((/^--.+/).test(arg)) {
|
||||
key = arg.match(/^--(.+)/)[1];
|
||||
next = args[i + 1];
|
||||
if (
|
||||
next !== undefined
|
||||
&& !(/^(-|--)[^-]/).test(next)
|
||||
&& !flags.bools[key]
|
||||
&& !flags.allBools
|
||||
&& (aliases[key] ? !aliasIsBoolean(key) : true)
|
||||
) {
|
||||
setArg(key, next, arg);
|
||||
i += 1;
|
||||
} else if ((/^(true|false)$/).test(next)) {
|
||||
setArg(key, next === 'true', arg);
|
||||
i += 1;
|
||||
} else {
|
||||
setArg(key, flags.strings[key] ? '' : true, arg);
|
||||
}
|
||||
} else if ((/^-[^-]+/).test(arg)) {
|
||||
var letters = arg.slice(1, -1).split('');
|
||||
|
||||
var broken = false;
|
||||
for (var j = 0; j < letters.length; j++) {
|
||||
next = arg.slice(j + 2);
|
||||
|
||||
if (next === '-') {
|
||||
setArg(letters[j], next, arg);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((/[A-Za-z]/).test(letters[j]) && next[0] === '=') {
|
||||
setArg(letters[j], next.slice(1), arg);
|
||||
broken = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (
|
||||
(/[A-Za-z]/).test(letters[j])
|
||||
&& (/-?\d+(\.\d*)?(e-?\d+)?$/).test(next)
|
||||
) {
|
||||
setArg(letters[j], next, arg);
|
||||
broken = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (letters[j + 1] && letters[j + 1].match(/\W/)) {
|
||||
setArg(letters[j], arg.slice(j + 2), arg);
|
||||
broken = true;
|
||||
break;
|
||||
} else {
|
||||
setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
|
||||
}
|
||||
}
|
||||
|
||||
key = arg.slice(-1)[0];
|
||||
if (!broken && key !== '-') {
|
||||
if (
|
||||
args[i + 1]
|
||||
&& !(/^(-|--)[^-]/).test(args[i + 1])
|
||||
&& !flags.bools[key]
|
||||
&& (aliases[key] ? !aliasIsBoolean(key) : true)
|
||||
) {
|
||||
setArg(key, args[i + 1], arg);
|
||||
i += 1;
|
||||
} else if (args[i + 1] && (/^(true|false)$/).test(args[i + 1])) {
|
||||
setArg(key, args[i + 1] === 'true', arg);
|
||||
i += 1;
|
||||
} else {
|
||||
setArg(key, flags.strings[key] ? '' : true, arg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
|
||||
argv._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg));
|
||||
}
|
||||
if (opts.stopEarly) {
|
||||
argv._.push.apply(argv._, args.slice(i + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Object.keys(defaults).forEach(function (k) {
|
||||
if (!hasKey(argv, k.split('.'))) {
|
||||
setKey(argv, k.split('.'), defaults[k]);
|
||||
|
||||
(aliases[k] || []).forEach(function (x) {
|
||||
setKey(argv, x.split('.'), defaults[k]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (opts['--']) {
|
||||
argv['--'] = notFlags.slice();
|
||||
} else {
|
||||
notFlags.forEach(function (k) {
|
||||
argv._.push(k);
|
||||
});
|
||||
}
|
||||
|
||||
return argv;
|
||||
};
|
||||
@@ -0,0 +1,63 @@
|
||||
'use strict'
|
||||
|
||||
const SemVer = require('../classes/semver')
|
||||
const Range = require('../classes/range')
|
||||
const gt = require('../functions/gt')
|
||||
|
||||
const minVersion = (range, loose) => {
|
||||
range = new Range(range, loose)
|
||||
|
||||
let minver = new SemVer('0.0.0')
|
||||
if (range.test(minver)) {
|
||||
return minver
|
||||
}
|
||||
|
||||
minver = new SemVer('0.0.0-0')
|
||||
if (range.test(minver)) {
|
||||
return minver
|
||||
}
|
||||
|
||||
minver = null
|
||||
for (let i = 0; i < range.set.length; ++i) {
|
||||
const comparators = range.set[i]
|
||||
|
||||
let setMin = null
|
||||
comparators.forEach((comparator) => {
|
||||
// Clone to avoid manipulating the comparator's semver object.
|
||||
const compver = new SemVer(comparator.semver.version)
|
||||
switch (comparator.operator) {
|
||||
case '>':
|
||||
if (compver.prerelease.length === 0) {
|
||||
compver.patch++
|
||||
} else {
|
||||
compver.prerelease.push(0)
|
||||
}
|
||||
compver.raw = compver.format()
|
||||
/* fallthrough */
|
||||
case '':
|
||||
case '>=':
|
||||
if (!setMin || gt(compver, setMin)) {
|
||||
setMin = compver
|
||||
}
|
||||
break
|
||||
case '<':
|
||||
case '<=':
|
||||
/* Ignore maximum versions */
|
||||
break
|
||||
/* istanbul ignore next */
|
||||
default:
|
||||
throw new Error(`Unexpected operation: ${comparator.operator}`)
|
||||
}
|
||||
})
|
||||
if (setMin && (!minver || gt(minver, setMin))) {
|
||||
minver = setMin
|
||||
}
|
||||
}
|
||||
|
||||
if (minver && range.test(minver)) {
|
||||
return minver
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
module.exports = minVersion
|
||||
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* @fileoverview Rule to check spacing between template tags and their literals
|
||||
* @author Jonathan Wilsson
|
||||
* @deprecated in ESLint v8.53.0
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @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: "template-tag-spacing",
|
||||
url: "https://eslint.style/rules/template-tag-spacing",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
type: "layout",
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Require or disallow spacing between template tags and their literals",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/template-tag-spacing",
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
|
||||
schema: [{ enum: ["always", "never"] }],
|
||||
messages: {
|
||||
unexpected:
|
||||
"Unexpected space between template tag and template literal.",
|
||||
missing: "Missing space between template tag and template literal.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const never = context.options[0] !== "always";
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Check if a space is present between a template tag and its literal
|
||||
* @param {ASTNode} node node to evaluate
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function checkSpacing(node) {
|
||||
const tagToken = sourceCode.getTokenBefore(node.quasi);
|
||||
const literalToken = sourceCode.getFirstToken(node.quasi);
|
||||
const hasWhitespace = sourceCode.isSpaceBetween(
|
||||
tagToken,
|
||||
literalToken,
|
||||
);
|
||||
|
||||
if (never && hasWhitespace) {
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: tagToken.loc.end,
|
||||
end: literalToken.loc.start,
|
||||
},
|
||||
messageId: "unexpected",
|
||||
fix(fixer) {
|
||||
const comments = sourceCode.getCommentsBefore(
|
||||
node.quasi,
|
||||
);
|
||||
|
||||
// Don't fix anything if there's a single line comment after the template tag
|
||||
if (comments.some(comment => comment.type === "Line")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return fixer.replaceTextRange(
|
||||
[tagToken.range[1], literalToken.range[0]],
|
||||
comments.reduce(
|
||||
(text, comment) =>
|
||||
text + sourceCode.getText(comment),
|
||||
"",
|
||||
),
|
||||
);
|
||||
},
|
||||
});
|
||||
} else if (!never && !hasWhitespace) {
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: node.loc.start,
|
||||
end: literalToken.loc.start,
|
||||
},
|
||||
messageId: "missing",
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(tagToken, " ");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
TaggedTemplateExpression: checkSpacing,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"signatureFlags.enum.js","sourceRoot":"","sources":["../../src/enums/signatureFlags.enum.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAE/F,MAAM,CAAN,IAAY,cAaX;AAbD,WAAY,cAAc;IACtB,mDAAQ,CAAA;IACR,2EAAyB,CAAA;IACzB,yEAAwB,CAAA;IACxB,6DAAkB,CAAA;IAClB,2DAAiB,CAAA;IACjB,4EAAyB,CAAA;IACzB,4EAAyB,CAAA;IACzB,gGAAmC,CAAA;IACnC,2EAAwB,CAAA;IACxB,yHAA+C,CAAA;IAC/C,6EAAkJ,CAAA;IAClJ,wEAAoD,CAAA;AACxD,CAAC,EAbW,cAAc,KAAd,cAAc,QAazB"}
|
||||
@@ -0,0 +1,24 @@
|
||||
function _define_enumerable_properties(obj, descs) {
|
||||
for (var key in descs) {
|
||||
var desc = descs[key];
|
||||
desc.configurable = desc.enumerable = true;
|
||||
|
||||
if ("value" in desc) desc.writable = true;
|
||||
|
||||
Object.defineProperty(obj, key, desc);
|
||||
}
|
||||
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var objectSymbols = Object.getOwnPropertySymbols(descs);
|
||||
for (var i = 0; i < objectSymbols.length; i++) {
|
||||
var sym = objectSymbols[i];
|
||||
var desc = descs[sym];
|
||||
desc.configurable = desc.enumerable = true;
|
||||
if ("value" in desc) desc.writable = true;
|
||||
Object.defineProperty(obj, sym, desc);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
export { _define_enumerable_properties as _ };
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../src/ast/clone.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,IAAI,EACJ,SAAS,EAIZ,MAAM,UAAU,CAAC;AAgFlB;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC;AAC7F,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,SAAS,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,CAAC,GAAG,SAAS,CAAC;AAUrH;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AACrH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC"}
|
||||
@@ -0,0 +1,5 @@
|
||||
// ESM wrapper for pg-pool
|
||||
import Pool from '../index.js'
|
||||
|
||||
// Export as default only to match CJS module
|
||||
export default Pool
|
||||
@@ -0,0 +1,74 @@
|
||||
import { S as SnapshotState, a as SnapshotStateOptions, b as SnapshotResult, R as RawSnapshotInfo, D as DomainSnapshotAdapter } from './rawSnapshot.d-D_X3-62x.js';
|
||||
export { c as DomainMatchResult, d as SnapshotData, e as SnapshotMatchOptions, f as SnapshotSerializer, g as SnapshotSummary, h as SnapshotUpdateState, U as UncheckedSnapshot } from './rawSnapshot.d-D_X3-62x.js';
|
||||
import { Plugin, Plugins } from '@vitest/pretty-format';
|
||||
export { S as SnapshotEnvironment } from './environment.d-DOJxxZV9.js';
|
||||
import '@vitest/utils';
|
||||
|
||||
interface AssertOptions {
|
||||
received: unknown;
|
||||
filepath: string;
|
||||
name: string;
|
||||
/**
|
||||
* Not required but needed for `SnapshotClient.clearTest` to implement test-retry behavior.
|
||||
* @default name
|
||||
*/
|
||||
testId?: string;
|
||||
message?: string;
|
||||
isInline?: boolean;
|
||||
properties?: object;
|
||||
inlineSnapshot?: string;
|
||||
error?: Error;
|
||||
errorMessage?: string;
|
||||
rawSnapshot?: RawSnapshotInfo;
|
||||
assertionName?: string;
|
||||
}
|
||||
interface AssertDomainOptions extends Omit<AssertOptions, "received"> {
|
||||
received: unknown;
|
||||
adapter: DomainSnapshotAdapter<any, any>;
|
||||
}
|
||||
interface AssertDomainPollOptions extends Omit<AssertDomainOptions, "received"> {
|
||||
poll: () => Promise<unknown> | unknown;
|
||||
timeout?: number;
|
||||
interval?: number;
|
||||
}
|
||||
/** Same shape as expect.extend custom matcher result (SyncExpectationResult from @vitest/expect) */
|
||||
interface MatchResult {
|
||||
pass: boolean;
|
||||
message: () => string;
|
||||
actual?: unknown;
|
||||
expected?: unknown;
|
||||
}
|
||||
interface SnapshotClientOptions {
|
||||
isEqual?: (received: unknown, expected: unknown) => boolean;
|
||||
}
|
||||
declare class SnapshotClient {
|
||||
private options;
|
||||
snapshotStateMap: Map<string, SnapshotState>;
|
||||
constructor(options?: SnapshotClientOptions);
|
||||
setup(filepath: string, options: SnapshotStateOptions): Promise<void>;
|
||||
finish(filepath: string): Promise<SnapshotResult>;
|
||||
skipTest(filepath: string, testName: string): void;
|
||||
clearTest(filepath: string, testId: string): void;
|
||||
getSnapshotState(filepath: string): SnapshotState;
|
||||
match(options: AssertOptions): MatchResult;
|
||||
assert(options: AssertOptions): void;
|
||||
matchDomain(options: AssertDomainOptions): MatchResult;
|
||||
pollMatchDomain(options: AssertDomainPollOptions): Promise<MatchResult>;
|
||||
assertRaw(options: AssertOptions): Promise<void>;
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
declare function stripSnapshotIndentation(inlineSnapshot: string): string;
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
declare function addSerializer(plugin: Plugin): void;
|
||||
declare function getSerializers(): Plugins;
|
||||
|
||||
export { DomainSnapshotAdapter, SnapshotClient, SnapshotResult, SnapshotState, SnapshotStateOptions, addSerializer, getSerializers, stripSnapshotIndentation };
|
||||
export type { MatchResult };
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { FlatConfig } from '@typescript-eslint/utils/ts-eslint';
|
||||
export default _default;
|
||||
/**
|
||||
* Rules considered to be best practice for modern TypeScript codebases, but that do not impact program logic.
|
||||
* @see {@link https://typescript-eslint.io/users/configs#stylistic}
|
||||
*/
|
||||
declare function _default(plugin: FlatConfig.Plugin, parser: FlatConfig.Parser): FlatConfig.ConfigArray;
|
||||
@@ -0,0 +1,2 @@
|
||||
import type * as ts from 'typescript';
|
||||
export declare function isSymbolFromDefaultLibrary(program: ts.Program, symbol: ts.Symbol | undefined): boolean;
|
||||
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "thread-stream",
|
||||
"version": "4.2.0",
|
||||
"description": "A streaming way to send data to a Node.js Worker Thread",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"dependencies": {
|
||||
"real-require": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^25.0.2",
|
||||
"@yao-pkg/pkg": "^6.0.0",
|
||||
"borp": "^1.0.0",
|
||||
"desm": "^1.3.0",
|
||||
"eslint": "^9.39.1",
|
||||
"fastbench": "^1.0.1",
|
||||
"neostandard": "^0.13.0",
|
||||
"pino-elasticsearch": "^9.0.0",
|
||||
"sonic-boom": "^5.0.0",
|
||||
"ts-node": "^10.8.0",
|
||||
"typescript": "~5.7.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc --noEmit",
|
||||
"lint": "eslint",
|
||||
"test": "npm run lint && npm run build && npm run transpile && borp --pattern \"test/*.test.{js,mjs}\"",
|
||||
"test:ci": "npm run lint && npm run transpile && borp --pattern \"test/*.test.{js,mjs}\"",
|
||||
"test:yarn": "npm run transpile && borp --pattern \"test/*.test.js\"",
|
||||
"transpile": "sh ./test/ts/transpile.sh"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mcollina/thread-stream.git"
|
||||
},
|
||||
"keywords": [
|
||||
"worker",
|
||||
"thread",
|
||||
"threads",
|
||||
"stream"
|
||||
],
|
||||
"author": "Matteo Collina <hello@matteocollina.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/mcollina/thread-stream/issues"
|
||||
},
|
||||
"homepage": "https://github.com/mcollina/thread-stream#readme"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"type":"commonjs"}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
import * as z from "zod/v4";
|
||||
|
||||
test(".nullable()", () => {
|
||||
const nullable = z.string().nullable();
|
||||
expect(nullable.parse(null)).toBe(null);
|
||||
expect(nullable.parse("asdf")).toBe("asdf");
|
||||
expect(() => nullable.parse(123)).toThrow();
|
||||
});
|
||||
|
||||
test(".nullable unwrap", () => {
|
||||
const schema = z.string().nullable();
|
||||
expect(schema).toBeInstanceOf(z.ZodNullable);
|
||||
expect(schema.unwrap()).toBeInstanceOf(z.ZodString);
|
||||
});
|
||||
|
||||
test("z.null", () => {
|
||||
const n = z.null();
|
||||
expect(n.parse(null)).toBe(null);
|
||||
expect(() => n.parse("asdf")).toThrow();
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
function _classApplyDescriptorSet(e, t, l) {
|
||||
if (t.set) t.set.call(e, l);else {
|
||||
if (!t.writable) throw new TypeError("attempted to set read only private field");
|
||||
t.value = l;
|
||||
}
|
||||
}
|
||||
export { _classApplyDescriptorSet as default };
|
||||
@@ -0,0 +1,15 @@
|
||||
declare const _default: {
|
||||
extends: string[];
|
||||
rules: {
|
||||
'dot-notation': "off";
|
||||
'@typescript-eslint/dot-notation': "error";
|
||||
'@typescript-eslint/non-nullable-type-assertion-style': "error";
|
||||
'@typescript-eslint/prefer-find': "error";
|
||||
'@typescript-eslint/prefer-includes': "error";
|
||||
'@typescript-eslint/prefer-nullish-coalescing': "error";
|
||||
'@typescript-eslint/prefer-optional-chain': "error";
|
||||
'@typescript-eslint/prefer-regexp-exec': "error";
|
||||
'@typescript-eslint/prefer-string-starts-ends-with': "error";
|
||||
};
|
||||
};
|
||||
export = _default;
|
||||
@@ -0,0 +1,29 @@
|
||||
// @ts-ignore TS6133
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
import * as z from "zod/v3";
|
||||
|
||||
const RealSet = Set;
|
||||
const RealMap = Map;
|
||||
const RealDate = Date;
|
||||
|
||||
test("doesn’t throw when Date is undefined", () => {
|
||||
delete (globalThis as any).Date;
|
||||
const result = z.object({}).safeParse({});
|
||||
expect(result.success).toEqual(true);
|
||||
globalThis.Date = RealDate;
|
||||
});
|
||||
|
||||
test("doesn’t throw when Set is undefined", () => {
|
||||
delete (globalThis as any).Set;
|
||||
const result = z.object({}).safeParse({});
|
||||
expect(result.success).toEqual(true);
|
||||
globalThis.Set = RealSet;
|
||||
});
|
||||
|
||||
test("doesn’t throw when Map is undefined", () => {
|
||||
delete (globalThis as any).Map;
|
||||
const result = z.object({}).safeParse({});
|
||||
expect(result.success).toEqual(true);
|
||||
globalThis.Map = RealMap;
|
||||
});
|
||||
Reference in New Issue
Block a user