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,12 @@
/**
* @deprecated
* @module
*/
import { jubjub_findGroupHash, jubjub_groupHash, jubjub as jubjubn } from './misc.ts';
/** @deprecated use `import { jubjub } from '@noble/curves/misc.js';` */
export declare const jubjub: typeof jubjubn;
/** @deprecated use `import { jubjub_findGroupHash } from '@noble/curves/misc.js';` */
export declare const findGroupHash: typeof jubjub_findGroupHash;
/** @deprecated use `import { jubjub_groupHash } from '@noble/curves/misc.js';` */
export declare const groupHash: typeof jubjub_groupHash;
//# sourceMappingURL=jubjub.d.ts.map

View File

@@ -0,0 +1,55 @@
{
"name": "@solana/buffer-layout",
"version": "4.0.1",
"description": "Translation between JavaScript values and Buffers",
"keywords": [
"Buffer",
"struct",
"endian",
"pack data"
],
"homepage": "https://github.com/solana-labs/buffer-layout",
"bugs": "https://github.com/solana-labs/buffer-layout/issues",
"repository": {
"type": "git",
"url": "https://github.com/solana-labs/buffer-layout.git"
},
"license": "MIT",
"author": "Peter A. Bigot <pab@pabigot.com>",
"main": "./lib/Layout.js",
"types": "./lib/Layout.d.ts",
"files": [
"/lib"
],
"dependencies": {
"buffer": "~6.0.3"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.28.2",
"@typescript-eslint/parser": "^4.28.2",
"coveralls": "^3.0.0",
"eslint": "~7.30.0",
"gh-pages": "^3.2.3",
"istanbul": "~0.4.5",
"jsdoc": "~3.5.5",
"lodash": "~4.17.5",
"mocha": "~5.0.4",
"shx": "^0.3.3",
"typedoc": "^0.22.10",
"typescript": "^4.4.4"
},
"engines": {
"node": ">=5.10"
},
"scripts": {
"build": "tsc",
"coverage": "npm run build && istanbul cover _mocha -- -u tdd",
"coveralls": "npm run build && istanbul cover _mocha --report lcovonly -- -u tdd && cat ./coverage/lcov.info | coveralls",
"docs": "shx rm -rf docs && typedoc && shx cp .nojekyll docs/",
"eslint": "eslint src/ --ext .ts",
"jsdoc": "jsdoc -c jsdoc/conf.json",
"pages": "gh-pages --dist docs --dotfiles",
"prepare": "npm run build",
"test": "npm run build && mocha -u tdd"
}
}

View File

@@ -0,0 +1,9 @@
'use strict'
const { PassThrough } = require('stream')
async function run (opts) {
return new PassThrough({})
}
module.exports = run

View File

@@ -0,0 +1,886 @@
'use strict'
const os = require('node:os')
const { readFileSync } = require('node:fs')
const test = require('node:test')
const assert = require('node:assert')
const { sink, check, match, once, watchFileCreated, file } = require('./helper')
const pino = require('../')
const { version } = require('../package.json')
const { pid } = process
const hostname = os.hostname()
test('pino version is exposed on export', () => {
assert.equal(pino.version, version)
})
test('pino version is exposed on instance', () => {
const instance = pino()
assert.equal(instance.version, version)
})
test('child instance exposes pino version', () => {
const child = pino().child({ foo: 'bar' })
assert.equal(child.version, version)
})
test('bindings are exposed on every instance', () => {
const instance = pino()
assert.deepEqual(instance.bindings(), {})
})
test('bindings contain the name and the child bindings', () => {
const instance = pino({ name: 'basicTest', level: 'info' }).child({ foo: 'bar' }).child({ a: 2 })
assert.deepEqual(instance.bindings(), { name: 'basicTest', foo: 'bar', a: 2 })
})
test('set bindings on instance', () => {
const instance = pino({ name: 'basicTest', level: 'info' })
instance.setBindings({ foo: 'bar' })
assert.deepEqual(instance.bindings(), { name: 'basicTest', foo: 'bar' })
})
test('newly set bindings overwrite old bindings', () => {
const instance = pino({ name: 'basicTest', level: 'info', base: { foo: 'bar' } })
instance.setBindings({ foo: 'baz' })
assert.deepEqual(instance.bindings(), { name: 'basicTest', foo: 'baz' })
})
test('set bindings on child instance', () => {
const child = pino({ name: 'basicTest', level: 'info' }).child({})
child.setBindings({ foo: 'bar' })
assert.deepEqual(child.bindings(), { name: 'basicTest', foo: 'bar' })
})
test('child should have bindings set by parent', () => {
const instance = pino({ name: 'basicTest', level: 'info' })
instance.setBindings({ foo: 'bar' })
const child = instance.child({})
assert.deepEqual(child.bindings(), { name: 'basicTest', foo: 'bar' })
})
test('child should not share bindings of parent set after child creation', () => {
const instance = pino({ name: 'basicTest', level: 'info' })
const child = instance.child({})
instance.setBindings({ foo: 'bar' })
assert.deepEqual(instance.bindings(), { name: 'basicTest', foo: 'bar' })
assert.deepEqual(child.bindings(), { name: 'basicTest' })
})
function levelTest (name, level) {
test(`${name} logs as ${level}`, async () => {
const stream = sink()
const instance = pino(stream)
instance.level = name
instance[name]('hello world')
check(assert.equal, await once(stream, 'data'), level, 'hello world')
})
test(`passing objects at level ${name}`, async () => {
const stream = sink()
const instance = pino(stream)
instance.level = name
const obj = { hello: 'world' }
instance[name](obj)
const result = await once(stream, 'data')
assert.equal(new Date(result.time) <= new Date(), true, 'time is greater than Date.now()')
assert.equal(result.pid, pid)
assert.equal(result.hostname, hostname)
assert.equal(result.level, level)
assert.equal(result.hello, 'world')
assert.deepEqual(Object.keys(obj), ['hello'])
})
test(`passing an object and a string at level ${name}`, async () => {
const stream = sink()
const instance = pino(stream)
instance.level = name
const obj = { hello: 'world' }
instance[name](obj, 'a string')
const result = await once(stream, 'data')
assert.equal(new Date(result.time) <= new Date(), true, 'time is greater than Date.now()')
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level,
msg: 'a string',
hello: 'world'
})
assert.deepEqual(Object.keys(obj), ['hello'])
})
test(`passing a undefined and a string at level ${name}`, async () => {
const stream = sink()
const instance = pino(stream)
instance.level = name
instance[name](undefined, 'a string')
const result = await once(stream, 'data')
assert.equal(new Date(result.time) <= new Date(), true, 'time is greater than Date.now()')
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level,
msg: 'a string'
})
})
test(`overriding object key by string at level ${name}`, async () => {
const stream = sink()
const instance = pino(stream)
instance.level = name
instance[name]({ hello: 'world', msg: 'object' }, 'string')
const result = await once(stream, 'data')
assert.equal(new Date(result.time) <= new Date(), true, 'time is greater than Date.now()')
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level,
msg: 'string',
hello: 'world'
})
})
test(`formatting logs as ${name}`, async () => {
const stream = sink()
const instance = pino(stream)
instance.level = name
instance[name]('hello %d', 42)
const result = await once(stream, 'data')
check(assert.equal, result, level, 'hello 42')
})
test(`formatting a symbol at level ${name}`, async () => {
const stream = sink()
const instance = pino(stream)
instance.level = name
const sym = Symbol('foo')
instance[name]('hello %s', sym)
const result = await once(stream, 'data')
check(assert.equal, result, level, 'hello Symbol(foo)')
})
test(`passing error with a serializer at level ${name}`, async () => {
const stream = sink()
const err = new Error('myerror')
const instance = pino({
serializers: {
err: pino.stdSerializers.err
}
}, stream)
instance.level = name
instance[name]({ err })
const result = await once(stream, 'data')
assert.equal(new Date(result.time) <= new Date(), true, 'time is greater than Date.now()')
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level,
err: {
type: 'Error',
message: err.message,
stack: err.stack
},
msg: err.message
})
})
test(`child logger for level ${name}`, async () => {
const stream = sink()
const instance = pino(stream)
instance.level = name
const child = instance.child({ hello: 'world' })
child[name]('hello world')
const result = await once(stream, 'data')
assert.equal(new Date(result.time) <= new Date(), true, 'time is greater than Date.now()')
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level,
msg: 'hello world',
hello: 'world'
})
})
}
levelTest('fatal', 60)
levelTest('error', 50)
levelTest('warn', 40)
levelTest('info', 30)
levelTest('debug', 20)
levelTest('trace', 10)
test('serializers can return undefined to strip field', async () => {
const stream = sink()
const instance = pino({
serializers: {
test () { return undefined }
}
}, stream)
instance.info({ test: 'sensitive info' })
const result = await once(stream, 'data')
assert.equal('test' in result, false)
})
test('streams receive a message event with PINO_CONFIG', (t, end) => {
const stream = sink()
stream.once('message', (message) => {
match(message, {
code: 'PINO_CONFIG',
config: {
errorKey: 'err',
levels: {
labels: {
10: 'trace',
20: 'debug',
30: 'info',
40: 'warn',
50: 'error',
60: 'fatal'
},
values: {
debug: 20,
error: 50,
fatal: 60,
info: 30,
trace: 10,
warn: 40
}
},
messageKey: 'msg'
}
})
end()
})
pino(stream)
})
test('does not explode with a circular ref', () => {
const stream = sink()
const instance = pino(stream)
const b = {}
const a = {
hello: b
}
b.a = a // circular ref
assert.doesNotThrow(() => instance.info(a))
})
test('set the name', async () => {
const stream = sink()
const instance = pino({
name: 'hello'
}, stream)
instance.fatal('this is fatal')
const result = await once(stream, 'data')
assert.equal(new Date(result.time) <= new Date(), true, 'time is greater than Date.now()')
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level: 60,
name: 'hello',
msg: 'this is fatal'
})
})
test('set the messageKey', async () => {
const stream = sink()
const message = 'hello world'
const messageKey = 'fooMessage'
const instance = pino({
messageKey
}, stream)
instance.info(message)
const result = await once(stream, 'data')
assert.equal(new Date(result.time) <= new Date(), true, 'time is greater than Date.now()')
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level: 30,
fooMessage: message
})
})
test('set the nestedKey', async () => {
const stream = sink()
const object = { hello: 'world' }
const nestedKey = 'stuff'
const instance = pino({
nestedKey
}, stream)
instance.info(object)
const result = await once(stream, 'data')
assert.equal(new Date(result.time) <= new Date(), true, 'time is greater than Date.now()')
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level: 30,
stuff: object
})
})
test('set undefined properties', async () => {
const stream = sink()
const instance = pino(stream)
instance.info({ hello: 'world', property: undefined })
const result = await once(stream, 'data')
assert.equal(new Date(result.time) <= new Date(), true, 'time is greater than Date.now()')
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level: 30,
hello: 'world'
})
})
test('prototype properties are not logged', async () => {
const stream = sink()
const instance = pino(stream)
instance.info(Object.create({ hello: 'world' }))
const { hello } = await once(stream, 'data')
assert.equal(hello, undefined)
})
test('set the base', async () => {
const stream = sink()
const instance = pino({
base: {
a: 'b'
}
}, stream)
instance.fatal('this is fatal')
const result = await once(stream, 'data')
assert.equal(new Date(result.time) <= new Date(), true, 'time is greater than Date.now()')
delete result.time
assert.deepEqual(result, {
a: 'b',
level: 60,
msg: 'this is fatal'
})
})
test('set the base to null', async () => {
const stream = sink()
const instance = pino({
base: null
}, stream)
instance.fatal('this is fatal')
const result = await once(stream, 'data')
assert.equal(new Date(result.time) <= new Date(), true, 'time is greater than Date.now()')
delete result.time
assert.deepEqual(result, {
level: 60,
msg: 'this is fatal'
})
})
test('set the base to null and use a formatter', async () => {
const stream = sink()
const instance = pino({
base: null,
formatters: {
log (input) {
return Object.assign({}, input, { additionalMessage: 'using pino' })
}
}
}, stream)
instance.fatal('this is fatal too')
const result = await once(stream, 'data')
assert.equal(new Date(result.time) <= new Date(), true, 'time is greater than Date.now()')
delete result.time
assert.deepEqual(result, {
level: 60,
msg: 'this is fatal too',
additionalMessage: 'using pino'
})
})
test('throw if creating child without bindings', () => {
const stream = sink()
const instance = pino(stream)
try {
instance.child()
assert.fail('it should throw')
} catch (err) {
assert.equal(err.message, 'missing bindings for child Pino')
}
})
test('correctly escapes msg strings with stray double quote at end', async () => {
const stream = sink()
const instance = pino({
name: 'hello'
}, stream)
instance.fatal('this contains "')
const result = await once(stream, 'data')
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level: 60,
name: 'hello',
msg: 'this contains "'
})
})
test('correctly escape msg strings with unclosed double quote', async () => {
const stream = sink()
const instance = pino({
name: 'hello'
}, stream)
instance.fatal('" this contains')
const result = await once(stream, 'data')
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level: 60,
name: 'hello',
msg: '" this contains'
})
})
test('correctly escape quote in a key', async () => {
const stream = sink()
const instance = pino(stream)
const obj = { 'some"obj': 'world' }
instance.info(obj, 'a string')
const result = await once(stream, 'data')
delete result.time
assert.deepEqual(result, {
level: 30,
pid,
hostname,
msg: 'a string',
'some"obj': 'world'
})
assert.deepEqual(Object.keys(obj), ['some"obj'])
})
// https://github.com/pinojs/pino/issues/139
test('object and format string', async () => {
const stream = sink()
const instance = pino(stream)
instance.info({}, 'foo %s', 'bar')
const result = await once(stream, 'data')
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level: 30,
msg: 'foo bar'
})
})
test('object and format string property', async () => {
const stream = sink()
const instance = pino(stream)
instance.info({ answer: 42 }, 'foo %s', 'bar')
const result = await once(stream, 'data')
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level: 30,
msg: 'foo bar',
answer: 42
})
})
test('correctly strip undefined when returned from toJSON', async () => {
const stream = sink()
const instance = pino({
test: 'this'
}, stream)
instance.fatal({ test: { toJSON () { return undefined } } })
const result = await once(stream, 'data')
assert.equal('test' in result, false)
})
test('correctly supports stderr', (t, end) => {
// stderr inherits from Stream, rather than Writable
const dest = {
writable: true,
write (result) {
result = JSON.parse(result)
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level: 60,
msg: 'a message'
})
end()
}
}
const instance = pino(dest)
instance.fatal('a message')
})
test('normalize number to string', async () => {
const stream = sink()
const instance = pino(stream)
instance.info(1)
const result = await once(stream, 'data')
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level: 30,
msg: '1'
})
})
test('normalize number to string with an object', async () => {
const stream = sink()
const instance = pino(stream)
instance.info({ answer: 42 }, 1)
const result = await once(stream, 'data')
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level: 30,
msg: '1',
answer: 42
})
})
test('handles objects with null prototype', async () => {
const stream = sink()
const instance = pino(stream)
const o = Object.create(null)
o.test = 'test'
instance.info(o)
const result = await once(stream, 'data')
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level: 30,
test: 'test'
})
})
test('pino.destination', async () => {
const tmp = file()
const instance = pino(pino.destination(tmp))
instance.info('hello')
await watchFileCreated(tmp)
const result = JSON.parse(readFileSync(tmp).toString())
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level: 30,
msg: 'hello'
})
})
test('auto pino.destination with a string', async () => {
const tmp = file()
const instance = pino(tmp)
instance.info('hello')
await watchFileCreated(tmp)
const result = JSON.parse(readFileSync(tmp).toString())
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level: 30,
msg: 'hello'
})
})
test('auto pino.destination with a string as second argument', async () => {
const tmp = file()
const instance = pino(null, tmp)
instance.info('hello')
await watchFileCreated(tmp)
const result = JSON.parse(readFileSync(tmp).toString())
delete result.time
assert.deepEqual(result, {
pid,
hostname,
level: 30,
msg: 'hello'
})
})
test('does not override opts with a string as second argument', async () => {
const tmp = file()
const instance = pino({
timestamp: () => ',"time":"none"'
}, tmp)
instance.info('hello')
await watchFileCreated(tmp)
const result = JSON.parse(readFileSync(tmp).toString())
assert.deepEqual(result, {
pid,
hostname,
level: 30,
time: 'none',
msg: 'hello'
})
})
// https://github.com/pinojs/pino/issues/222
test('children with same names render in correct order', async () => {
const stream = sink()
const root = pino(stream)
root.child({ a: 1 }).child({ a: 2 }).info({ a: 3 })
const { a } = await once(stream, 'data')
assert.equal(a, 3, 'last logged object takes precedence')
})
test('use `safe-stable-stringify` to avoid circular dependencies', async () => {
const stream = sink()
const root = pino(stream)
// circular depth
const obj = {}
obj.a = obj
root.info(obj)
const { a } = await once(stream, 'data')
assert.deepEqual(a, { a: '[Circular]' })
})
test('correctly log non circular objects', async () => {
const stream = sink()
const root = pino(stream)
const obj = {}
let parent = obj
for (let i = 0; i < 10; i++) {
parent.node = {}
parent = parent.node
}
root.info(obj)
const { node } = await once(stream, 'data')
assert.deepEqual(node, { node: { node: { node: { node: { node: { node: { node: { node: { node: {} } } } } } } } } })
})
test('safe-stable-stringify must be used when interpolating', async () => {
const stream = sink()
const instance = pino(stream)
const o = { a: { b: {} } }
o.a.b.c = o.a.b
instance.info('test %j', o)
const { msg } = await once(stream, 'data')
assert.equal(msg, 'test {"a":{"b":{"c":"[Circular]"}}}')
})
test('throws when setting useOnlyCustomLevels without customLevels', () => {
assert.throws(
() => {
pino({
useOnlyCustomLevels: true
})
},
/customLevels is required if useOnlyCustomLevels is set true/
)
})
test('correctly log Infinity', async () => {
const stream = sink()
const instance = pino(stream)
const o = { num: Infinity }
instance.info(o)
const { num } = await once(stream, 'data')
assert.equal(num, null)
})
test('correctly log -Infinity', async () => {
const stream = sink()
const instance = pino(stream)
const o = { num: -Infinity }
instance.info(o)
const { num } = await once(stream, 'data')
assert.equal(num, null)
})
test('correctly log NaN', async () => {
const stream = sink()
const instance = pino(stream)
const o = { num: NaN }
instance.info(o)
const { num } = await once(stream, 'data')
assert.equal(num, null)
})
test('offers a .default() method to please typescript', async () => {
assert.equal(pino.default, pino)
const stream = sink()
const instance = pino.default(stream)
instance.info('hello world')
check(assert.equal, await once(stream, 'data'), 30, 'hello world')
})
test('correctly skip function', async () => {
const stream = sink()
const instance = pino(stream)
const o = { num: NaN }
instance.info(o, () => {})
const { msg } = await once(stream, 'data')
assert.equal(msg, undefined)
})
test('correctly skip Infinity', async () => {
const stream = sink()
const instance = pino(stream)
const o = { num: NaN }
instance.info(o, Infinity)
const { msg } = await once(stream, 'data')
assert.equal(msg, null)
})
test('correctly log number', async () => {
const stream = sink()
const instance = pino(stream)
const o = { num: NaN }
instance.info(o, 42)
const { msg } = await once(stream, 'data')
assert.equal(msg, 42)
})
test('nestedKey should not be used for non-objects', async () => {
const stream = sink()
const message = 'hello'
const nestedKey = 'stuff'
const instance = pino({
nestedKey
}, stream)
instance.info(message)
const result = await once(stream, 'data')
delete result.time
assert.deepStrictEqual(result, {
pid,
hostname,
level: 30,
msg: message
})
})
test('throws if prettyPrint is passed in as an option', async () => {
assert.throws(
() => {
pino({
prettyPrint: true
})
},
Error('prettyPrint option is no longer supported, see the pino-pretty package (https://github.com/pinojs/pino-pretty)')
)
})
test('Should invoke `onChild` with the newly created child', () => {
let innerChild
const child = pino({
onChild: (instance) => {
innerChild = instance
}
}).child({ foo: 'bar' })
assert.equal(child, innerChild)
})
test('logger message should have the prefix message that defined in the logger creation', async () => {
const stream = sink()
const logger = pino({
msgPrefix: 'My name is Bond '
}, stream)
assert.equal(logger.msgPrefix, 'My name is Bond ')
logger.info('James Bond')
const { msg } = await once(stream, 'data')
assert.equal(msg, 'My name is Bond James Bond')
})
test('child message should have the prefix message that defined in the child creation', async () => {
const stream = sink()
const instance = pino(stream)
const child = instance.child({}, { msgPrefix: 'My name is Bond ' })
child.info('James Bond')
const { msg } = await once(stream, 'data')
assert.equal(msg, 'My name is Bond James Bond')
})
test('child message should have the prefix message that defined in the child creation when logging with log meta', async () => {
const stream = sink()
const instance = pino(stream)
const child = instance.child({}, { msgPrefix: 'My name is Bond ' })
child.info({ hello: 'world' }, 'James Bond')
const { msg, hello } = await once(stream, 'data')
assert.equal(hello, 'world')
assert.equal(msg, 'My name is Bond James Bond')
})
test('logged message should not have the prefix when not providing any message', async () => {
const stream = sink()
const instance = pino(stream)
const child = instance.child({}, { msgPrefix: 'This should not be shown ' })
child.info({ hello: 'world' })
const { msg, hello } = await once(stream, 'data')
assert.equal(hello, 'world')
assert.equal(msg, undefined)
})
test('child message should append parent prefix to current prefix that defined in the child creation', async () => {
const stream = sink()
const instance = pino({
msgPrefix: 'My name is Bond '
}, stream)
const child = instance.child({}, { msgPrefix: 'James ' })
child.info('Bond')
assert.equal(child.msgPrefix, 'My name is Bond James ')
const { msg } = await once(stream, 'data')
assert.equal(msg, 'My name is Bond James Bond')
})
test('child message should inherent parent prefix', async () => {
const stream = sink()
const instance = pino({
msgPrefix: 'My name is Bond '
}, stream)
const child = instance.child({})
child.info('James Bond')
const { msg } = await once(stream, 'data')
assert.equal(msg, 'My name is Bond James Bond')
})
test('grandchild message should inherent parent prefix', async () => {
const stream = sink()
const instance = pino(stream)
const child = instance.child({}, { msgPrefix: 'My name is Bond ' })
const grandchild = child.child({})
grandchild.info('James Bond')
const { msg } = await once(stream, 'data')
assert.equal(msg, 'My name is Bond James Bond')
})

View File

@@ -0,0 +1,16 @@
export * from "./core.cjs";
export * from "./parse.cjs";
export * from "./errors.cjs";
export * from "./schemas.cjs";
export * from "./checks.cjs";
export * from "./versions.cjs";
export * as util from "./util.cjs";
export * as regexes from "./regexes.cjs";
export * as locales from "../locales/index.cjs";
export * from "./registries.cjs";
export * from "./doc.cjs";
export * from "./api.cjs";
export * from "./to-json-schema.cjs";
export { toJSONSchema } from "./json-schema-processors.cjs";
export { JSONSchemaGenerator } from "./json-schema-generator.cjs";
export * as JSONSchema from "./json-schema.cjs";

View File

@@ -0,0 +1,16 @@
import * as nodeFetch from 'node-fetch';
export default (typeof globalThis.fetch === 'function'
? // The Fetch API is supported experimentally in Node 17.5+ and natively in Node 18+.
globalThis.fetch
: // Otherwise use the polyfill.
async function (
input: nodeFetch.RequestInfo,
init?: nodeFetch.RequestInit,
): Promise<nodeFetch.Response> {
const processedInput =
typeof input === 'string' && input.slice(0, 2) === '//'
? 'https:' + input
: input;
return await nodeFetch.default(processedInput, init);
}) as typeof globalThis.fetch;

View File

@@ -0,0 +1,72 @@
{
"name": "@types/ws",
"version": "8.18.1",
"description": "TypeScript definitions for ws",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ws",
"license": "MIT",
"contributors": [
{
"name": "Paul Loyd",
"githubUsername": "loyd",
"url": "https://github.com/loyd"
},
{
"name": "Margus Lamp",
"githubUsername": "mlamp",
"url": "https://github.com/mlamp"
},
{
"name": "Philippe D'Alva",
"githubUsername": "TitaneBoy",
"url": "https://github.com/TitaneBoy"
},
{
"name": "reduckted",
"githubUsername": "reduckted",
"url": "https://github.com/reduckted"
},
{
"name": "teidesu",
"githubUsername": "teidesu",
"url": "https://github.com/teidesu"
},
{
"name": "Bartosz Wojtkowiak",
"githubUsername": "wojtkowiak",
"url": "https://github.com/wojtkowiak"
},
{
"name": "Kyle Hensel",
"githubUsername": "k-yle",
"url": "https://github.com/k-yle"
},
{
"name": "Samuel Skeen",
"githubUsername": "cwadrupldijjit",
"url": "https://github.com/cwadrupldijjit"
}
],
"main": "",
"types": "index.d.ts",
"exports": {
".": {
"types": {
"import": "./index.d.mts",
"default": "./index.d.ts"
}
},
"./package.json": "./package.json"
},
"repository": {
"type": "git",
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/ws"
},
"scripts": {},
"dependencies": {
"@types/node": "*"
},
"peerDependencies": {},
"typesPublisherContentHash": "043c83a4bb92503ab01243879ee715fb6db391090d10883c5a2eb72099d22724",
"typeScriptVersion": "5.1"
}

View File

@@ -0,0 +1,4 @@
import type { Version4Options } from './types.js';
declare function v4(options?: Version4Options, buf?: undefined, offset?: number): string;
declare function v4<TBuf extends Uint8Array = Uint8Array>(options: Version4Options | undefined, buf: TBuf, offset?: number): TBuf;
export default v4;

View File

@@ -0,0 +1,4 @@
function _OverloadYield(e, d) {
this.v = e, this.k = d;
}
module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;

View File

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

View File

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

View File

@@ -0,0 +1,156 @@
import pino from '../../pino'
import { expectType } from 'tsd'
// Single
const transport = pino.transport({
target: '#pino/pretty',
options: { some: 'options for', the: 'transport' }
})
pino(transport)
expectType<pino.Logger>(pino({
transport: {
target: 'pino-pretty'
},
}))
// Multiple
const transports = pino.transport({
targets: [
{
level: 'info',
target: '#pino/pretty',
options: { some: 'options for', the: 'transport' }
},
{
level: 'trace',
target: '#pino/file',
options: { destination: './test.log' }
}
]
})
pino(transports)
expectType<pino.Logger>(pino({
transport: {
targets: [
{
level: 'info',
target: '#pino/pretty',
options: { some: 'options for', the: 'transport' }
},
{
level: 'trace',
target: '#pino/file',
options: { destination: './test.log' }
}
]
},
}))
const transportsWithCustomLevels = pino.transport({
targets: [
{
level: 'info',
target: '#pino/pretty',
options: { some: 'options for', the: 'transport' }
},
{
level: 'foo',
target: '#pino/file',
options: { destination: './test.log' }
}
],
levels: { foo: 35 }
})
pino(transports)
expectType<pino.Logger>(pino({
transport: {
targets: [
{
level: 'info',
target: '#pino/pretty',
options: { some: 'options for', the: 'transport' }
},
{
level: 'trace',
target: '#pino/file',
options: { destination: './test.log' }
}
],
levels: { foo: 35 }
},
}))
const transportsWithoutOptions = pino.transport({
targets: [
{ target: '#pino/pretty' },
{ target: '#pino/file' }
],
levels: { foo: 35 }
})
pino(transports)
expectType<pino.Logger>(pino({
transport: {
targets: [
{ target: '#pino/pretty' },
{ target: '#pino/file' }
],
levels: { foo: 35 }
},
}))
const pipelineTransport = pino.transport({
pipeline: [{
target: './my-transform.js'
}, {
// Use target: 'pino/file' to write to stdout
// without any change.
target: 'pino-pretty'
}]
})
pino(pipelineTransport)
expectType<pino.Logger>(pino({
transport: {
pipeline: [{
target: './my-transform.js'
}, {
// Use target: 'pino/file' to write to stdout
// without any change.
target: 'pino-pretty'
}]
}
}))
type TransportConfig = {
id: string
}
// Custom transport params
const customTransport = pino.transport<TransportConfig>({
target: 'custom',
options: { id: 'abc' }
})
pino(customTransport)
// Worker
pino.transport({
target: 'custom',
worker: {
argv: ['a', 'b'],
stdin: false,
stderr: true,
stdout: false,
autoEnd: true,
},
options: { id: 'abc' }
})
// Dedupe
pino.transport({
targets: [],
dedupe: true,
})

View File

@@ -0,0 +1,436 @@
"use strict";
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Message = exports.NotificationType9 = exports.NotificationType8 = exports.NotificationType7 = exports.NotificationType6 = exports.NotificationType5 = exports.NotificationType4 = exports.NotificationType3 = exports.NotificationType2 = exports.NotificationType1 = exports.NotificationType0 = exports.NotificationType = exports.RequestType9 = exports.RequestType8 = exports.RequestType7 = exports.RequestType6 = exports.RequestType5 = exports.RequestType4 = exports.RequestType3 = exports.RequestType2 = exports.RequestType1 = exports.RequestType = exports.RequestType0 = exports.AbstractMessageSignature = exports.ParameterStructures = exports.ResponseError = exports.ErrorCodes = void 0;
const is = __importStar(require("./is"));
/**
* Predefined error codes.
*/
var ErrorCodes;
(function (ErrorCodes) {
// Defined by JSON RPC
ErrorCodes.ParseError = -32700;
ErrorCodes.InvalidRequest = -32600;
ErrorCodes.MethodNotFound = -32601;
ErrorCodes.InvalidParams = -32602;
ErrorCodes.InternalError = -32603;
/**
* This is the start range of JSON RPC reserved error codes.
* It doesn't denote a real error code. No application error codes should
* be defined between the start and end range. For backwards
* compatibility the `ServerNotInitialized` and the `UnknownErrorCode`
* are left in the range.
*
* @since 3.16.0
*/
ErrorCodes.jsonrpcReservedErrorRangeStart = -32099;
/** @deprecated use jsonrpcReservedErrorRangeStart */
ErrorCodes.serverErrorStart = -32099;
/**
* An error occurred when write a message to the transport layer.
*/
ErrorCodes.MessageWriteError = -32099;
/**
* An error occurred when reading a message from the transport layer.
*/
ErrorCodes.MessageReadError = -32098;
/**
* The connection got disposed or lost and all pending responses got
* rejected.
*/
ErrorCodes.PendingResponseRejected = -32097;
/**
* The connection is inactive and a use of it failed.
*/
ErrorCodes.ConnectionInactive = -32096;
/**
* Error code indicating that a server received a notification or
* request before the server has received the `initialize` request.
*/
ErrorCodes.ServerNotInitialized = -32002;
ErrorCodes.UnknownErrorCode = -32001;
/**
* This is the end range of JSON RPC reserved error codes.
* It doesn't denote a real error code.
*
* @since 3.16.0
*/
ErrorCodes.jsonrpcReservedErrorRangeEnd = -32000;
/** @deprecated use jsonrpcReservedErrorRangeEnd */
ErrorCodes.serverErrorEnd = -32000;
})(ErrorCodes || (exports.ErrorCodes = ErrorCodes = {}));
/**
* An error object return in a response in case a request
* has failed.
*/
class ResponseError extends Error {
code;
data;
constructor(code, message, data) {
super(message);
this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;
this.data = data;
Object.setPrototypeOf(this, ResponseError.prototype);
}
toJson() {
const result = {
code: this.code,
message: this.message
};
if (this.data !== undefined) {
result.data = this.data;
}
return result;
}
}
exports.ResponseError = ResponseError;
class ParameterStructures {
kind;
/**
* The parameter structure is automatically inferred on the number of parameters
* and the parameter type in case of a single param.
*/
static auto = new ParameterStructures('auto');
/**
* Forces `byPosition` parameter structure. This is useful if you have a single
* parameter which has a literal type.
*/
static byPosition = new ParameterStructures('byPosition');
/**
* Forces `byName` parameter structure. This is only useful when having a single
* parameter. The library will report errors if used with a different number of
* parameters.
*/
static byName = new ParameterStructures('byName');
constructor(kind) {
this.kind = kind;
}
static is(value) {
return value === ParameterStructures.auto || value === ParameterStructures.byName || value === ParameterStructures.byPosition;
}
toString() {
return this.kind;
}
}
exports.ParameterStructures = ParameterStructures;
/**
* An abstract implementation of a MessageType.
*/
class AbstractMessageSignature {
method;
numberOfParams;
constructor(method, numberOfParams) {
this.method = method;
this.numberOfParams = numberOfParams;
}
get parameterStructures() {
return ParameterStructures.auto;
}
}
exports.AbstractMessageSignature = AbstractMessageSignature;
/**
* Classes to type request response pairs
*/
class RequestType0 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 0);
}
}
exports.RequestType0 = RequestType0;
class RequestType extends AbstractMessageSignature {
_parameterStructures;
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method, _parameterStructures = ParameterStructures.auto) {
super(method, 1);
this._parameterStructures = _parameterStructures;
}
get parameterStructures() {
return this._parameterStructures;
}
}
exports.RequestType = RequestType;
class RequestType1 extends AbstractMessageSignature {
_parameterStructures;
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method, _parameterStructures = ParameterStructures.auto) {
super(method, 1);
this._parameterStructures = _parameterStructures;
}
get parameterStructures() {
return this._parameterStructures;
}
}
exports.RequestType1 = RequestType1;
class RequestType2 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 2);
}
}
exports.RequestType2 = RequestType2;
class RequestType3 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 3);
}
}
exports.RequestType3 = RequestType3;
class RequestType4 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 4);
}
}
exports.RequestType4 = RequestType4;
class RequestType5 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 5);
}
}
exports.RequestType5 = RequestType5;
class RequestType6 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 6);
}
}
exports.RequestType6 = RequestType6;
class RequestType7 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 7);
}
}
exports.RequestType7 = RequestType7;
class RequestType8 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 8);
}
}
exports.RequestType8 = RequestType8;
class RequestType9 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 9);
}
}
exports.RequestType9 = RequestType9;
class NotificationType extends AbstractMessageSignature {
_parameterStructures;
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method, _parameterStructures = ParameterStructures.auto) {
super(method, 1);
this._parameterStructures = _parameterStructures;
}
get parameterStructures() {
return this._parameterStructures;
}
}
exports.NotificationType = NotificationType;
class NotificationType0 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 0);
}
}
exports.NotificationType0 = NotificationType0;
class NotificationType1 extends AbstractMessageSignature {
_parameterStructures;
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method, _parameterStructures = ParameterStructures.auto) {
super(method, 1);
this._parameterStructures = _parameterStructures;
}
get parameterStructures() {
return this._parameterStructures;
}
}
exports.NotificationType1 = NotificationType1;
class NotificationType2 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 2);
}
}
exports.NotificationType2 = NotificationType2;
class NotificationType3 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 3);
}
}
exports.NotificationType3 = NotificationType3;
class NotificationType4 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 4);
}
}
exports.NotificationType4 = NotificationType4;
class NotificationType5 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 5);
}
}
exports.NotificationType5 = NotificationType5;
class NotificationType6 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 6);
}
}
exports.NotificationType6 = NotificationType6;
class NotificationType7 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 7);
}
}
exports.NotificationType7 = NotificationType7;
class NotificationType8 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 8);
}
}
exports.NotificationType8 = NotificationType8;
class NotificationType9 extends AbstractMessageSignature {
/**
* Clients must not use this property. It is here to ensure correct typing.
*/
_;
constructor(method) {
super(method, 9);
}
}
exports.NotificationType9 = NotificationType9;
var Message;
(function (Message) {
/**
* Tests if the given message is a request message
*/
function isRequest(message) {
const candidate = message;
return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));
}
Message.isRequest = isRequest;
/**
* Tests if the given message is a notification message
*/
function isNotification(message) {
const candidate = message;
return candidate && is.string(candidate.method) && message.id === void 0;
}
Message.isNotification = isNotification;
/**
* Tests if the given message is a response message
*/
function isResponse(message) {
const candidate = message;
return candidate && (candidate.result !== void 0 || !!candidate.error) && (is.string(candidate.id) || is.number(candidate.id) || candidate.id === null);
}
Message.isResponse = isResponse;
})(Message || (exports.Message = Message = {}));

View File

@@ -0,0 +1,19 @@
import Pool from './pool'
export default PoolStats
declare class PoolStats {
constructor (pool: Pool)
/** Number of open socket connections in this pool. */
connected: number
/** Number of open socket connections in this pool that do not have an active request. */
free: number
/** Number of pending requests across all clients in this pool. */
pending: number
/** Number of queued requests across all clients in this pool. */
queued: number
/** Number of currently active requests across all clients in this pool. */
running: number
/** Number of active, pending, or queued requests across all clients in this pool. */
size: number
}

View File

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

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Mathias Buus
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.

View File

@@ -0,0 +1,23 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABILITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
interface Atomics {
/**
* Performs a finite-time microwait by signaling to the operating system or
* CPU that the current executing code is in a spin-wait loop.
*/
pause(n?: number): void;
}

View File

@@ -0,0 +1,7 @@
export declare enum ModuleDetectionKind {
None = 0,
Auto = 1,
Legacy = 2,
Force = 3
}
//# sourceMappingURL=moduleDetectionKind.enum.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"completionItemKind.js","sourceRoot":"","sources":["../../src/enums/completionItemKind.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,MAAM,CAAC,IAAI,kBAAuB,CAAC;AACnC,CAAC,UAAU,kBAAkB;IACzB,kBAAkB,CAAC,kBAAkB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;IAC5D,kBAAkB,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;IAChE,kBAAkB,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;IACpE,kBAAkB,CAAC,kBAAkB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,aAAa,CAAC;IAC1E,kBAAkB,CAAC,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC;IAC9D,kBAAkB,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;IACpE,kBAAkB,CAAC,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC;IAC9D,kBAAkB,CAAC,kBAAkB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC;IACtE,kBAAkB,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;IAChE,kBAAkB,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,UAAU,CAAC;IACrE,kBAAkB,CAAC,kBAAkB,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC;IAC7D,kBAAkB,CAAC,kBAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC;IAC/D,kBAAkB,CAAC,kBAAkB,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC;IAC7D,kBAAkB,CAAC,kBAAkB,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC;IACnE,kBAAkB,CAAC,kBAAkB,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC;IACnE,kBAAkB,CAAC,kBAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC;IAC/D,kBAAkB,CAAC,kBAAkB,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC;IAC7D,kBAAkB,CAAC,kBAAkB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,GAAG,WAAW,CAAC;IACvE,kBAAkB,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,QAAQ,CAAC;IACjE,kBAAkB,CAAC,kBAAkB,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,GAAG,YAAY,CAAC;IACzE,kBAAkB,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,UAAU,CAAC;IACrE,kBAAkB,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,QAAQ,CAAC;IACjE,kBAAkB,CAAC,kBAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC;IAC/D,kBAAkB,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,UAAU,CAAC;IACrE,kBAAkB,CAAC,kBAAkB,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC,GAAG,eAAe,CAAC;AACnF,CAAC,CAAC,CAAC,kBAAkB,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC,CAAC,CAAC"}

View File

@@ -0,0 +1,221 @@
/**
* @fileoverview Rule to disallow unsafe optional chaining
* @author Yeon JuAn
*/
"use strict";
const UNSAFE_ARITHMETIC_OPERATORS = new Set(["+", "-", "/", "*", "%", "**"]);
const UNSAFE_ASSIGNMENT_OPERATORS = new Set([
"+=",
"-=",
"/=",
"*=",
"%=",
"**=",
]);
const UNSAFE_RELATIONAL_OPERATORS = new Set(["in", "instanceof"]);
/**
* Checks whether a node is a destructuring pattern or not
* @param {ASTNode} node node to check
* @returns {boolean} `true` if a node is a destructuring pattern, otherwise `false`
*/
function isDestructuringPattern(node) {
return node.type === "ObjectPattern" || node.type === "ArrayPattern";
}
/** @type {import('../types').Rule.RuleModule} */
module.exports = {
meta: {
type: "problem",
defaultOptions: [
{
disallowArithmeticOperators: false,
},
],
docs: {
description:
"Disallow use of optional chaining in contexts where the `undefined` value is not allowed",
recommended: true,
url: "https://eslint.org/docs/latest/rules/no-unsafe-optional-chaining",
},
schema: [
{
type: "object",
properties: {
disallowArithmeticOperators: {
type: "boolean",
},
},
additionalProperties: false,
},
],
fixable: null,
messages: {
unsafeOptionalChain:
"Unsafe usage of optional chaining. If it short-circuits with 'undefined' the evaluation will throw TypeError.",
unsafeArithmetic:
"Unsafe arithmetic operation on optional chaining. It can result in NaN.",
},
},
create(context) {
const [{ disallowArithmeticOperators }] = context.options;
/**
* Reports unsafe usage of optional chaining
* @param {ASTNode} node node to report
* @returns {void}
*/
function reportUnsafeUsage(node) {
context.report({
messageId: "unsafeOptionalChain",
node,
});
}
/**
* Reports unsafe arithmetic operation on optional chaining
* @param {ASTNode} node node to report
* @returns {void}
*/
function reportUnsafeArithmetic(node) {
context.report({
messageId: "unsafeArithmetic",
node,
});
}
/**
* Checks and reports if a node can short-circuit with `undefined` by optional chaining.
* @param {ASTNode} [node] node to check
* @param {Function} reportFunc report function
* @returns {void}
*/
function checkUndefinedShortCircuit(node, reportFunc) {
if (!node) {
return;
}
switch (node.type) {
case "LogicalExpression":
if (node.operator === "||" || node.operator === "??") {
checkUndefinedShortCircuit(node.right, reportFunc);
} else if (node.operator === "&&") {
checkUndefinedShortCircuit(node.left, reportFunc);
checkUndefinedShortCircuit(node.right, reportFunc);
}
break;
case "SequenceExpression":
checkUndefinedShortCircuit(
node.expressions.at(-1),
reportFunc,
);
break;
case "ConditionalExpression":
checkUndefinedShortCircuit(node.consequent, reportFunc);
checkUndefinedShortCircuit(node.alternate, reportFunc);
break;
case "AwaitExpression":
checkUndefinedShortCircuit(node.argument, reportFunc);
break;
case "ChainExpression":
reportFunc(node);
break;
default:
break;
}
}
/**
* Checks unsafe usage of optional chaining
* @param {ASTNode} node node to check
* @returns {void}
*/
function checkUnsafeUsage(node) {
checkUndefinedShortCircuit(node, reportUnsafeUsage);
}
/**
* Checks unsafe arithmetic operations on optional chaining
* @param {ASTNode} node node to check
* @returns {void}
*/
function checkUnsafeArithmetic(node) {
checkUndefinedShortCircuit(node, reportUnsafeArithmetic);
}
return {
"AssignmentExpression, AssignmentPattern"(node) {
if (isDestructuringPattern(node.left)) {
checkUnsafeUsage(node.right);
}
},
"ClassDeclaration, ClassExpression"(node) {
checkUnsafeUsage(node.superClass);
},
CallExpression(node) {
if (!node.optional) {
checkUnsafeUsage(node.callee);
}
},
NewExpression(node) {
checkUnsafeUsage(node.callee);
},
VariableDeclarator(node) {
if (isDestructuringPattern(node.id)) {
checkUnsafeUsage(node.init);
}
},
MemberExpression(node) {
if (!node.optional) {
checkUnsafeUsage(node.object);
}
},
TaggedTemplateExpression(node) {
checkUnsafeUsage(node.tag);
},
ForOfStatement(node) {
checkUnsafeUsage(node.right);
},
SpreadElement(node) {
if (node.parent && node.parent.type !== "ObjectExpression") {
checkUnsafeUsage(node.argument);
}
},
BinaryExpression(node) {
if (UNSAFE_RELATIONAL_OPERATORS.has(node.operator)) {
checkUnsafeUsage(node.right);
}
if (
disallowArithmeticOperators &&
UNSAFE_ARITHMETIC_OPERATORS.has(node.operator)
) {
checkUnsafeArithmetic(node.right);
checkUnsafeArithmetic(node.left);
}
},
WithStatement(node) {
checkUnsafeUsage(node.object);
},
UnaryExpression(node) {
if (
disallowArithmeticOperators &&
UNSAFE_ARITHMETIC_OPERATORS.has(node.operator)
) {
checkUnsafeArithmetic(node.argument);
}
},
AssignmentExpression(node) {
if (
disallowArithmeticOperators &&
UNSAFE_ASSIGNMENT_OPERATORS.has(node.operator)
) {
checkUnsafeArithmetic(node.right);
}
},
};
},
};

View File

@@ -0,0 +1,73 @@
// Code generated by Herebyfile.mjs generate:enums from internal/ast/symbolflags.go. DO NOT EDIT.
export var SymbolFlags;
(function (SymbolFlags) {
SymbolFlags[SymbolFlags["None"] = 0] = "None";
SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable";
SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable";
SymbolFlags[SymbolFlags["Property"] = 4] = "Property";
SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember";
SymbolFlags[SymbolFlags["Function"] = 16] = "Function";
SymbolFlags[SymbolFlags["Class"] = 32] = "Class";
SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface";
SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum";
SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum";
SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule";
SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule";
SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral";
SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral";
SymbolFlags[SymbolFlags["Method"] = 8192] = "Method";
SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor";
SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor";
SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor";
SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature";
SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter";
SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias";
SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue";
SymbolFlags[SymbolFlags["Alias"] = 2097152] = "Alias";
SymbolFlags[SymbolFlags["Prototype"] = 4194304] = "Prototype";
SymbolFlags[SymbolFlags["ExportStar"] = 8388608] = "ExportStar";
SymbolFlags[SymbolFlags["Optional"] = 16777216] = "Optional";
SymbolFlags[SymbolFlags["Transient"] = 33554432] = "Transient";
SymbolFlags[SymbolFlags["Assignment"] = 67108864] = "Assignment";
SymbolFlags[SymbolFlags["ModuleExports"] = 134217728] = "ModuleExports";
SymbolFlags[SymbolFlags["ConstEnumOnlyModule"] = 268435456] = "ConstEnumOnlyModule";
SymbolFlags[SymbolFlags["ReplaceableByMethod"] = 536870912] = "ReplaceableByMethod";
SymbolFlags[SymbolFlags["GlobalLookup"] = 1073741824] = "GlobalLookup";
SymbolFlags[SymbolFlags["All"] = 536870912] = "All";
SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum";
SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable";
SymbolFlags[SymbolFlags["Value"] = 111551] = "Value";
SymbolFlags[SymbolFlags["Type"] = 788968] = "Type";
SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace";
SymbolFlags[SymbolFlags["Module"] = 1536] = "Module";
SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor";
SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 111550] = "FunctionScopedVariableExcludes";
SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 111551] = "BlockScopedVariableExcludes";
SymbolFlags[SymbolFlags["ParameterExcludes"] = 111551] = "ParameterExcludes";
SymbolFlags[SymbolFlags["PropertyExcludes"] = 13243] = "PropertyExcludes";
SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes";
SymbolFlags[SymbolFlags["FunctionExcludes"] = 110991] = "FunctionExcludes";
SymbolFlags[SymbolFlags["ClassExcludes"] = 899503] = "ClassExcludes";
SymbolFlags[SymbolFlags["InterfaceExcludes"] = 788872] = "InterfaceExcludes";
SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes";
SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes";
SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 110735] = "ValueModuleExcludes";
SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes";
SymbolFlags[SymbolFlags["MethodExcludes"] = 103359] = "MethodExcludes";
SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 46011] = "GetAccessorExcludes";
SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 78779] = "SetAccessorExcludes";
SymbolFlags[SymbolFlags["AccessorExcludes"] = 111547] = "AccessorExcludes";
SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 526824] = "TypeParameterExcludes";
SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 788968] = "TypeAliasExcludes";
SymbolFlags[SymbolFlags["AliasExcludes"] = 2097152] = "AliasExcludes";
SymbolFlags[SymbolFlags["ModuleMember"] = 2623475] = "ModuleMember";
SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal";
SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped";
SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor";
SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember";
SymbolFlags[SymbolFlags["ExportSupportsDefaultModifier"] = 112] = "ExportSupportsDefaultModifier";
SymbolFlags[SymbolFlags["ExportDoesNotSupportDefaultModifier"] = -113] = "ExportDoesNotSupportDefaultModifier";
SymbolFlags[SymbolFlags["Classifiable"] = 2885600] = "Classifiable";
SymbolFlags[SymbolFlags["LateBindingContainer"] = 6256] = "LateBindingContainer";
})(SymbolFlags || (SymbolFlags = {}));
//# sourceMappingURL=symbolFlags.enum.js.map

View File

@@ -0,0 +1,7 @@
var classApplyDescriptorGet = require("./classApplyDescriptorGet.js");
var classPrivateFieldGet2 = require("./classPrivateFieldGet2.js");
function _classPrivateFieldGet(e, t) {
var r = classPrivateFieldGet2(t, e);
return classApplyDescriptorGet(e, r);
}
module.exports = _classPrivateFieldGet, module.exports.__esModule = true, module.exports["default"] = module.exports;

View File

@@ -0,0 +1,34 @@
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
/**
* Delegates to `Array#shift`, but throws if the array is zero-length.
*/
export function guardedShift<T>(byteArray: T[]): T {
if (byteArray.length === 0) {
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
}
return byteArray.shift() as T;
}
/**
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
* the array.
*/
export function guardedSplice<T>(
byteArray: T[],
...args:
| [start: number, deleteCount?: number]
| [start: number, deleteCount: number, ...items: T[]]
): T[] {
const [start] = args;
if (
args.length === 2 // Implies that `deleteCount` was supplied
? start + (args[1] ?? 0) > byteArray.length
: start >= byteArray.length
) {
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
}
return byteArray.splice(
...(args as Parameters<typeof Array.prototype.splice>),
);
}

View File

@@ -0,0 +1,47 @@
interface PatternMatcher {
/**
* Replace all matched parts by a given replacer.
*
* @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#matcher-symbol-replace}
* @example
* const { PatternMatcher } = require("eslint-utils")
* const matcher = new PatternMatcher(/\\p{Script=Greek}/g)
*
* module.exports = {
* meta: {},
* create(context) {
* return {
* "Literal[regex]"(node) {
* const replacedPattern = node.regex.pattern.replace(
* matcher,
* "[\\u0370-\\u0373\\u0375-\\u0377\\u037A-\\u037D\\u037F\\u0384\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03E1\\u03F0-\\u03FF\\u1D26-\\u1D2A\\u1D5D-\\u1D61\\u1D66-\\u1D6A\\u1DBF\\u1F00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FC4\\u1FC6-\\u1FD3\\u1FD6-\\u1FDB\\u1FDD-\\u1FEF\\u1FF2-\\u1FF4\\u1FF6-\\u1FFE\\u2126\\uAB65]|\\uD800[\\uDD40-\\uDD8E\\uDDA0]|\\uD834[\\uDE00-\\uDE45]"
* )
* },
* }
* },
* }
*/
[Symbol.replace](str: string, replacer: string | ((...strs: string[]) => string)): string;
/**
* Iterate all matched parts in a given string.
*
* @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#matcher-execall}
*/
execAll(str: string): IterableIterator<RegExpExecArray>;
/**
* Check whether this pattern matches a given string or not.
*
* @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#matcher-test}
*/
test(str: string): boolean;
}
/**
* The class to find a pattern in strings as handling escape sequences.
* It ignores the found pattern if it's escaped with `\`.
*
* @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#patternmatcher-class}
*/
export declare const PatternMatcher: new (pattern: RegExp, options?: {
escaped?: boolean;
}) => PatternMatcher;
export {};

View File

@@ -0,0 +1,50 @@
import { expect, test } from "vitest";
import type { StandardSchemaWithJSON } from "../../core/standard-schema.js";
import * as z from "../index.js";
function acceptSchema(schema: StandardSchemaWithJSON) {
return schema;
}
test("Zod Mini schemas are NOT assignable to StandardJSONSchema", () => {
const schema = z.string();
// @ts-expect-error
const _standard: StandardSchemaWithJSON["~standard"] = schema;
// @ts-expect-error
acceptSchema(schema);
});
test("toJSONSchema result ~standard.jsonSchema works with objects", () => {
const schema = z.object({
firstName: z.string(),
lastName: z.string(),
});
const jsonSchema = z.toJSONSchema(schema);
// Call ~standard.jsonSchema.input - this should not throw
const inputSchema = jsonSchema["~standard"].jsonSchema.input({ target: "draft-07" });
expect(inputSchema).toMatchObject({
type: "object",
properties: {
firstName: { type: "string" },
lastName: { type: "string" },
},
required: ["firstName", "lastName"],
});
// Call ~standard.jsonSchema.output - this should not throw
const outputSchema = jsonSchema["~standard"].jsonSchema.output({ target: "draft-07" });
expect(outputSchema).toMatchObject({
type: "object",
properties: {
firstName: { type: "string" },
lastName: { type: "string" },
},
required: ["firstName", "lastName"],
});
});

View File

@@ -0,0 +1,20 @@
var Ajv = require('ajv');
var ajv = new Ajv({allErrors: true});
var schema = {
"properties": {
"foo": { "type": "string" },
"bar": { "type": "number", "maximum": 3 }
}
};
var validate = ajv.compile(schema);
test({"foo": "abc", "bar": 2});
test({"foo": 2, "bar": 4});
function test(data) {
var valid = validate(data);
if (valid) console.log('Valid!');
else console.log('Invalid: ' + ajv.errorsText(validate.errors));
}

View File

@@ -0,0 +1,17 @@
import { SyntaxKind } from "#enums/syntaxKind";
import type { __String, SourceFile } from "./ast.ts";
export declare function formatSyntaxKind(kind: SyntaxKind): string;
/**
* Remove one extra leading underscore from an identifier name, recovering the
* display form from its escaped {@link __String} key.
*/
export declare function unescapeLeadingUnderscores(identifier: __String): string;
/**
* Add an extra leading underscore to a display name that already begins with
* `__`, producing its escaped {@link __String} key.
*/
export declare function escapeLeadingUnderscores(identifier: string): __String;
export declare function tryCast<TOut extends TIn, TIn = any>(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut | undefined;
export declare function cast<TOut extends TIn, TIn = any>(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut;
export declare function cloneSourceFileData(sourceFile: SourceFile): Record<string, unknown>;
//# sourceMappingURL=utils.d.ts.map

View File

@@ -0,0 +1,55 @@
import type { StringReader, StringWriter } from './strings';
export const comma = ','.charCodeAt(0);
export const semicolon = ';'.charCodeAt(0);
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
const intToChar = new Uint8Array(64); // 64 possible chars.
const charToInt = new Uint8Array(128); // z is 122 in ASCII
for (let i = 0; i < chars.length; i++) {
const c = chars.charCodeAt(i);
intToChar[i] = c;
charToInt[c] = i;
}
export function decodeInteger(reader: StringReader, relative: number): number {
let value = 0;
let shift = 0;
let integer = 0;
do {
const c = reader.next();
integer = charToInt[c];
value |= (integer & 31) << shift;
shift += 5;
} while (integer & 32);
const shouldNegate = value & 1;
value >>>= 1;
if (shouldNegate) {
value = -0x80000000 | -value;
}
return relative + value;
}
export function encodeInteger(builder: StringWriter, num: number, relative: number): number {
let delta = num - relative;
delta = delta < 0 ? (-delta << 1) | 1 : delta << 1;
do {
let clamped = delta & 0b011111;
delta >>>= 5;
if (delta > 0) clamped |= 0b100000;
builder.write(intToChar[clamped]);
} while (delta > 0);
return num;
}
export function hasMoreVlq(reader: StringReader, max: number) {
if (reader.pos >= max) return false;
return reader.peek() !== comma;
}

View File

@@ -0,0 +1,16 @@
"use strict";
var _get = require("./_get.cjs");
var _set = require("./_set.cjs");
function _update(target, property, receiver, isStrict) {
return {
get _() {
return _get._(target, property, receiver);
},
set _(value) {
_set._(target, property, value, receiver, isStrict);
}
};
}
exports._ = _update;

View File

@@ -0,0 +1,54 @@
'use strict'
const eq = require('./eq')
const neq = require('./neq')
const gt = require('./gt')
const gte = require('./gte')
const lt = require('./lt')
const lte = require('./lte')
const cmp = (a, op, b, loose) => {
switch (op) {
case '===':
if (typeof a === 'object') {
a = a.version
}
if (typeof b === 'object') {
b = b.version
}
return a === b
case '!==':
if (typeof a === 'object') {
a = a.version
}
if (typeof b === 'object') {
b = b.version
}
return a !== b
case '':
case '=':
case '==':
return eq(a, b, loose)
case '!=':
return neq(a, b, loose)
case '>':
return gt(a, b, loose)
case '>=':
return gte(a, b, loose)
case '<':
return lt(a, b, loose)
case '<=':
return lte(a, b, loose)
default:
throw new TypeError(`Invalid operator: ${op}`)
}
}
module.exports = cmp

View File

@@ -0,0 +1,8 @@
import type { ZodArray, ZodNullable, ZodObject, ZodOptional, ZodRawShape, ZodTuple, ZodTupleItems, ZodTypeAny } from "../types.js";
export declare namespace partialUtil {
type DeepPartial<T extends ZodTypeAny> = T extends ZodObject<ZodRawShape> ? ZodObject<{
[k in keyof T["shape"]]: ZodOptional<DeepPartial<T["shape"][k]>>;
}, T["_def"]["unknownKeys"], T["_def"]["catchall"]> : T extends ZodArray<infer Type, infer Card> ? ZodArray<DeepPartial<Type>, Card> : T extends ZodOptional<infer Type> ? ZodOptional<DeepPartial<Type>> : T extends ZodNullable<infer Type> ? ZodNullable<DeepPartial<Type>> : T extends ZodTuple<infer Items> ? {
[k in keyof Items]: Items[k] extends ZodTypeAny ? DeepPartial<Items[k]> : never;
} extends infer PI ? PI extends ZodTupleItems ? ZodTuple<PI> : never : never : T;
}

View File

@@ -0,0 +1,40 @@
{
"name": "@rolldown/pluginutils",
"version": "1.0.1",
"description": "Plugin utilities for Rolldown",
"keywords": [
"filter",
"plugin",
"rolldown"
],
"homepage": "https://github.com/rolldown/plugins/tree/main/packages/pluginutils#readme",
"bugs": {
"url": "https://github.com/rolldown/plugins/issues"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/rolldown/plugins.git",
"directory": "packages/pluginutils"
},
"files": [
"dist"
],
"type": "module",
"exports": {
".": "./dist/index.mjs",
"./filter": "./dist/filter/index.mjs",
"./package.json": "./package.json"
},
"devDependencies": {
"@types/picomatch": "^4.0.3",
"picomatch": "^4.0.4",
"typescript": "^5.9.3"
},
"scripts": {
"dev": "tsdown --watch",
"build": "tsdown",
"test": "vitest --project pluginutils",
"test:types": "vitest --project pluginutils --typecheck.only"
}
}

View File

@@ -0,0 +1,3 @@
import * as ts from 'typescript';
export declare const isPossiblyFalsy: (type: ts.Type) => boolean;
export declare const isPossiblyTruthy: (type: ts.Type) => boolean;

View File

@@ -0,0 +1,22 @@
import Agent from './agent'
import ProxyAgent from './proxy-agent'
import Dispatcher from './dispatcher'
export default EnvHttpProxyAgent
declare class EnvHttpProxyAgent extends Dispatcher {
constructor (opts?: EnvHttpProxyAgent.Options)
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
}
declare namespace EnvHttpProxyAgent {
export interface Options extends Omit<ProxyAgent.Options, 'uri'> {
/** Overrides the value of the HTTP_PROXY environment variable */
httpProxy?: string;
/** Overrides the value of the HTTPS_PROXY environment variable */
httpsProxy?: string;
/** Overrides the value of the NO_PROXY environment variable */
noProxy?: string;
}
}

View File

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

View File

@@ -0,0 +1,9 @@
function _isNativeReflectConstruct() {
try {
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
} catch (t) {}
return (module.exports = _isNativeReflectConstruct = function _isNativeReflectConstruct() {
return !!t;
}, module.exports.__esModule = true, module.exports["default"] = module.exports)();
}
module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;

View File

@@ -0,0 +1,35 @@
/*! *****************************************************************************
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 RegExpMatchArray {
groups?: {
[key: string]: string;
};
}
interface RegExpExecArray {
groups?: {
[key: string]: string;
};
}
interface RegExp {
/**
* Returns a Boolean value indicating the state of the dotAll flag (s) used with a regular expression.
* Default is false. Read-only.
*/
readonly dotAll: boolean;
}