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,70 @@
import type * as errors from "./errors.cjs";
import type * as schemas from "./schemas.cjs";
import type { Class } from "./util.cjs";
type ZodTrait = {
_zod: {
def: any;
[k: string]: any;
};
};
export interface $constructor<T extends ZodTrait, D = T["_zod"]["def"]> {
new (def: D): T;
init(inst: T, def: D): asserts inst is T;
}
/** A special constant with type `never` */
export declare const NEVER: never;
export declare function $constructor<T extends ZodTrait, D = T["_zod"]["def"]>(name: string, initializer: (inst: T, def: D) => void, params?: {
Parent?: typeof Class;
}): $constructor<T, D>;
export declare const $brand: unique symbol;
export type $brand<T extends string | number | symbol = string | number | symbol> = {
[$brand]: {
[k in T]: true;
};
};
export type $ZodBranded<T extends schemas.SomeType, Brand extends string | number | symbol, Dir extends "in" | "out" | "inout" = "out"> = T & (Dir extends "inout" ? {
_zod: {
input: input<T> & $brand<Brand>;
output: output<T> & $brand<Brand>;
};
} : Dir extends "in" ? {
_zod: {
input: input<T> & $brand<Brand>;
};
} : {
_zod: {
output: output<T> & $brand<Brand>;
};
});
export type $ZodNarrow<T extends schemas.SomeType, Out> = T & {
_zod: {
output: Out;
};
};
export declare class $ZodAsyncError extends Error {
constructor();
}
export declare class $ZodEncodeError extends Error {
constructor(name: string);
}
export type input<T> = T extends {
_zod: {
input: any;
};
} ? T["_zod"]["input"] : unknown;
export type output<T> = T extends {
_zod: {
output: any;
};
} ? T["_zod"]["output"] : unknown;
export type { output as infer };
export interface $ZodConfig {
/** Custom error map. Overrides `config().localeError`. */
customError?: errors.$ZodErrorMap | undefined;
/** Localized error map. Lowest priority. */
localeError?: errors.$ZodErrorMap | undefined;
/** Disable JIT schema compilation. Useful in environments that disallow `eval`. */
jitless?: boolean | undefined;
}
export declare const globalConfig: $ZodConfig;
export declare function config(newConfig?: Partial<$ZodConfig>): $ZodConfig;

View File

@@ -0,0 +1,66 @@
var stream = require('stream')
var pump = require('./index')
var rs = new stream.Readable()
var ws = new stream.Writable()
rs._read = function (size) {
this.push(Buffer(size).fill('abc'))
}
ws._write = function (chunk, encoding, cb) {
setTimeout(function () {
cb()
}, 100)
}
var toHex = function () {
var reverse = new (require('stream').Transform)()
reverse._transform = function (chunk, enc, callback) {
reverse.push(chunk.toString('hex'))
callback()
}
return reverse
}
var wsClosed = false
var rsClosed = false
var callbackCalled = false
var check = function () {
if (wsClosed && rsClosed && callbackCalled) {
console.log('test-browser.js passes')
clearTimeout(timeout)
}
}
ws.on('finish', function () {
wsClosed = true
check()
})
rs.on('end', function () {
rsClosed = true
check()
})
var res = pump(rs, toHex(), toHex(), toHex(), ws, function () {
callbackCalled = true
check()
})
if (res !== ws) {
throw new Error('should return last stream')
}
setTimeout(function () {
rs.push(null)
rs.emit('close')
}, 1000)
var timeout = setTimeout(function () {
check()
throw new Error('timeout')
}, 5000)

View File

@@ -0,0 +1,8 @@
import type { TSESTree } from '@typescript-eslint/types';
import type { ScopeManager } from '../ScopeManager';
import type { Scope } from './Scope';
import { ScopeBase } from './ScopeBase';
import { ScopeType } from './ScopeType';
export declare class BlockScope extends ScopeBase<ScopeType.block, TSESTree.BlockStatement, Scope> {
constructor(scopeManager: ScopeManager, upperScope: BlockScope['upper'], block: BlockScope['block']);
}

View File

@@ -0,0 +1,6 @@
export var LanguageVariant;
(function (LanguageVariant) {
LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard";
LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX";
})(LanguageVariant || (LanguageVariant = {}));
//# sourceMappingURL=languageVariant.js.map

View File

@@ -0,0 +1,53 @@
"use strict";
/* eslint-disable import/first -- intentionally executing code before rest of the require()s. This will not work with ESM. */
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;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const ts = __importStar(require("typescript"));
const [versionMajor, _versionMinor] = ts.versionMajorMinor
.split('.')
.map(Number);
if (versionMajor >= 7) {
// eslint-disable-next-line no-console
console.error([
'typescript-eslint does not support TS 7.0.',
'Please see https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/#running-side-by-side-with-typescript-6.0 to run typescript-eslint using the TS 6 API.',
"See also https://github.com/typescript-eslint/typescript-eslint/issues/10940 for tracking typescript-eslint's support for TS >=7.1",
].join('\n'));
throw new Error('typescript-eslint does not support TS 7.0.');
}
const raw_plugin_1 = __importDefault(require("./raw-plugin"));
module.exports = raw_plugin_1.default.plugin;

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DatabaseError = exports.serialize = void 0;
exports.parse = parse;
const messages_1 = require("./messages");
Object.defineProperty(exports, "DatabaseError", { enumerable: true, get: function () { return messages_1.DatabaseError; } });
const serializer_1 = require("./serializer");
Object.defineProperty(exports, "serialize", { enumerable: true, get: function () { return serializer_1.serialize; } });
const parser_1 = require("./parser");
function parse(stream, callback) {
const parser = new parser_1.Parser();
stream.on('data', (buffer) => parser.parse(buffer, callback));
return new Promise((resolve) => stream.on('end', () => resolve()));
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1,32 @@
// @ts-ignore TS6133
import { expect, test } from "vitest";
import * as z from "zod/v3";
const beforeBenchmarkDate = new Date(2022, 10, 4);
const benchmarkDate = new Date(2022, 10, 5);
const afterBenchmarkDate = new Date(2022, 10, 6);
const minCheck = z.date().min(benchmarkDate);
const maxCheck = z.date().max(benchmarkDate);
test("passing validations", () => {
minCheck.parse(benchmarkDate);
minCheck.parse(afterBenchmarkDate);
maxCheck.parse(benchmarkDate);
maxCheck.parse(beforeBenchmarkDate);
});
test("failing validations", () => {
expect(() => minCheck.parse(beforeBenchmarkDate)).toThrow();
expect(() => maxCheck.parse(afterBenchmarkDate)).toThrow();
});
test("min max getters", () => {
expect(minCheck.minDate).toEqual(benchmarkDate);
expect(minCheck.min(afterBenchmarkDate).minDate).toEqual(afterBenchmarkDate);
expect(maxCheck.maxDate).toEqual(benchmarkDate);
expect(maxCheck.max(beforeBenchmarkDate).maxDate).toEqual(beforeBenchmarkDate);
});

View File

@@ -0,0 +1,6 @@
import type { TSESLint } from '@typescript-eslint/utils';
export type MessageIds = 'addUnknownRestTypeAnnotationSuggestion' | 'addUnknownTypeAnnotationSuggestion' | 'useUnknown' | 'useUnknownArrayDestructuringPattern' | 'useUnknownObjectDestructuringPattern' | 'wrongRestTypeAnnotationSuggestion' | 'wrongTypeAnnotationSuggestion';
declare const _default: TSESLint.RuleModule<MessageIds, [], import("../../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
name: string;
};
export default _default;

View File

@@ -0,0 +1,51 @@
// Copyright 2017 Lovell Fuller and others.
// SPDX-License-Identifier: Apache-2.0
'use strict';
const fs = require('fs');
const LDD_PATH = '/usr/bin/ldd';
const SELF_PATH = '/proc/self/exe';
const MAX_LENGTH = 2048;
/**
* Read the content of a file synchronous
*
* @param {string} path
* @returns {Buffer}
*/
const readFileSync = (path) => {
const fd = fs.openSync(path, 'r');
const buffer = Buffer.alloc(MAX_LENGTH);
const bytesRead = fs.readSync(fd, buffer, 0, MAX_LENGTH, 0);
fs.close(fd, () => {});
return buffer.subarray(0, bytesRead);
};
/**
* Read the content of a file
*
* @param {string} path
* @returns {Promise<Buffer>}
*/
const readFile = (path) => new Promise((resolve, reject) => {
fs.open(path, 'r', (err, fd) => {
if (err) {
reject(err);
} else {
const buffer = Buffer.alloc(MAX_LENGTH);
fs.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
resolve(buffer.subarray(0, bytesRead));
fs.close(fd, () => {});
});
}
});
});
module.exports = {
LDD_PATH,
SELF_PATH,
readFileSync,
readFile
};

View File

@@ -0,0 +1,6 @@
import type { TSESLint } from '@typescript-eslint/utils';
export type MessageId = 'confusingAssign' | 'confusingEqual' | 'confusingOperator' | 'notNeedInAssign' | 'notNeedInEqualTest' | 'notNeedInOperator' | 'wrapUpLeft';
declare const _default: TSESLint.RuleModule<MessageId, [], import("../../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
name: string;
};
export default _default;

View File

@@ -0,0 +1,8 @@
language: node_js
node_js:
- "8"
- "10"
- "12"
- "13"
after_script:
- coveralls < coverage/lcov.info

View File

@@ -0,0 +1,135 @@
'use strict';
const WebSocket = require('isomorphic-ws');
const utils = require('../utils');
const delay = require('delay');
const Client = require('../client');
/**
* Constructor for a Jayson Websocket Client
* @class ClientWebsocket
* @constructor
* @extends Client
* @param {Object} [options]
* @param {String} [options.url] When options.ws not provided this will be the URL to open the websocket to
* @param {ws.WebSocket} [options.ws] When not provided will create a WebSocket instance with options.url
* @param {Number} [options.timeout] Will wait this long in ms until callbacking with an error
* @return {ClientWebsocket}
*/
const ClientWebsocket = function(options) {
if(!(this instanceof ClientWebsocket)) {
return new ClientWebsocket(options);
}
Client.call(this, options);
const defaults = utils.merge(this.options, {});
this.options = utils.merge(defaults, options || {});
const self = this;
this.ws = this.options.ws || new WebSocket(this.options.url);
this.outstandingRequests = [];
this.handlers = {};
this.handlers.message = function (str) {
utils.JSON.parse(str, self.options, function(err, response) {
if (err) {
// invalid JSON is ignored
return;
}
if (Array.isArray(response)) {
// we have a batch reply
const matchingRequest = self.outstandingRequests.find(function ([request]) {
if (Array.isArray(request)) {
// a batch is considered matching if at least one response id matches one request id
return response.some(function (resp) {
if (utils.Response.isValidResponse(resp)) {
return request.some(function (req) {
return req.id === resp.id;
});
}
return false;
});
}
});
if (matchingRequest) {
const [ , resolve ] = matchingRequest;
return resolve(response);
}
} else if (utils.Response.isValidResponse(response)) {
const matchingRequest = self.outstandingRequests.find(function ([request]) {
return !Array.isArray(request) && request.id === response.id;
});
if (matchingRequest) {
const [ , resolve ] = matchingRequest;
return resolve(response);
}
}
});
};
this.ws.on('message', this.handlers.message);
};
require('util').inherits(ClientWebsocket, Client);
module.exports = ClientWebsocket;
/**
* @desc Removes all event listeners from Websocket instance which cancels all outstanding requests too
*/
ClientWebsocket.prototype.unlisten = function () {
for (const eventName in this.handlers) {
this.ws.off(eventName, this.handlers[eventName]);
}
};
ClientWebsocket.prototype._request = function(request, callback) {
const self = this;
const { ws, options } = this;
// we have to remove the object representing this request when the promise resolves/rejects
let outstandingItem;
Promise.race([
options.timeout > 0 ? delay(options.timeout).then(function () {
throw new Error('timeout reached after ' + options.timeout + ' ms');
}) : null,
new Promise(function (resolve, reject) {
utils.JSON.stringify(request, options, function(err, body) {
if (err) {
return resolve(err);
}
ws.send(body);
if (utils.Request.isNotification(request)) {
// notifications callback immediately since they don't have a reply
return resolve();
}
outstandingItem = [request, resolve, reject];
self.outstandingRequests.push(outstandingItem);
});
}),
].filter(v => v !== null)).then(function (result) {
removeOutstandingRequest();
callback(null, result);
}).catch(function (err) {
removeOutstandingRequest();
callback(err);
});
function removeOutstandingRequest () {
if (!outstandingItem) {
return;
}
self.outstandingRequests = self.outstandingRequests.filter(v => v !== outstandingItem);
}
};

View File

@@ -0,0 +1,4 @@
{
"main": "../../cjs/_class_private_method_init.cjs",
"module": "../../esm/_class_private_method_init.js"
}

View File

@@ -0,0 +1,23 @@
export {};
import * as worker_threads from "node:worker_threads";
type _BroadcastChannel = typeof globalThis extends { onmessage: any } ? {} : worker_threads.BroadcastChannel;
type _MessageChannel = typeof globalThis extends { onmessage: any } ? {} : worker_threads.MessageChannel;
type _MessagePort = typeof globalThis extends { onmessage: any } ? {} : worker_threads.MessagePort;
declare global {
function structuredClone<T = any>(value: T, options?: worker_threads.StructuredSerializeOptions): T;
interface BroadcastChannel extends _BroadcastChannel {}
var BroadcastChannel: typeof globalThis extends { onmessage: any; BroadcastChannel: infer T } ? T
: typeof worker_threads.BroadcastChannel;
interface MessageChannel extends _MessageChannel {}
var MessageChannel: typeof globalThis extends { onmessage: any; MessageChannel: infer T } ? T
: typeof worker_threads.MessageChannel;
interface MessagePort extends _MessagePort {}
var MessagePort: typeof globalThis extends { onmessage: any; MessagePort: infer T } ? T
: typeof worker_threads.MessagePort;
}

View File

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