FRE-600: Fix code review blockers

- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-04-25 00:08:01 -04:00
parent 65b552bb08
commit 7c684a42cc
48450 changed files with 5679671 additions and 383 deletions

391
node_modules/jayson/promise/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,391 @@
import net = require('net');
import tls = require('tls');
import https = require('https');
import http = require('http');
import events = require('events');
import Stream = require('stream');
import WebSocket = require('isomorphic-ws');
import * as connect from 'connect';
type ConstructorOf<Proto, CtorArgs extends any[]> = {
(...args: CtorArgs): Proto;
new(...args: CtorArgs): Proto;
prototype: Proto;
}
export interface UtilsJSONParseOptions {
reviver?: Function;
}
export interface UtilsJSONStringifyOptions {
replacer?: Function;
}
export interface GenerateRequestOptions {
version?: number;
notificationIdNull?: boolean;
generator?: IDGenerator;
}
export declare class Utils {
static request(method: string, params: RequestParamsLike, options?: GenerateRequestOptions): JSONRPCRequest;
static request(method: string, params: RequestParamsLike, id?: JSONRPCIDLike | null | undefined, options?: GenerateRequestOptions): JSONRPCRequest;
static response(error: JSONRPCError | undefined | null, result: JSONRPCResultLike | undefined | null, id: JSONRPCIDLike | null | undefined, version?: number): JSONRPCVersionTwoResponse;
static response(error: JSONRPCError | undefined | null, result: JSONRPCResultLike | undefined | null, id: JSONRPCIDLike | null | undefined, version:2): JSONRPCVersionTwoResponse;
static response(error: JSONRPCError | undefined | null, result: JSONRPCResultLike | undefined | null, id: JSONRPCIDLike | null | undefined, version:1): JSONRPCVersionOneResponse;
static generateId(): string;
static merge(...objs: object[]): object;
static parseStream(stream:Stream, options:UtilsJSONParseOptions, onRequest: (err?:Error, data?:any) => void): void;
static parseBody(stream:Stream, options:UtilsJSONParseOptions, callback: (err?:Error, obj?:any) => void): void;
static getHttpListener(self:http.Server, server:Server): Function;
static isContentType(request:http.IncomingMessage, typ:string): boolean;
static isMethod(request:http.IncomingMessage, method:string): boolean;
static walk(obj:object, key:string, fn: (key:string, value:any) => any): object;
static once<T extends (...args: any[]) => any>(fn: T): T;
static isPlainObject(obj: any): boolean;
static toArray(obj: any): Array<any>;
static toPlainObject(obj: any): object;
static pick(obj: object, keys: string[]): object;
static JSON: UtilsJSON;
static Request: UtilsRequest;
static Response: UtilsResponse;
}
// lowercase Utils
export declare class utils extends Utils {
}
type UtilsJSON = {
parse(str:string, options:UtilsJSONParseOptions | null | undefined, callback: (err?:Error, obj?:object) => void):void;
stringify(obj:object, options:UtilsJSONStringifyOptions | null | undefined, callback: (err?:Error, str?:string) => void):void;
}
type UtilsRequest = {
isBatch(request:any): boolean;
isNotification(request:any): boolean;
isValidVersionTwoRequest(request:any): boolean;
isValidVersionOneRequest(request:any): boolean;
isValidRequest(request:any, version?:number): boolean;
}
type UtilsResponse = {
isValidError(error:any, version?:number): boolean;
isValidResponse(response:any, version?:number): boolean;
}
export type RequestParamsLike = Array<any> | object | undefined;
export interface JSONRPCError {
code: number;
message: string;
data?: object;
}
export type JSONRPCErrorLike = Error | JSONRPCError;
export interface JSONRPCVersionOneRequest {
method: string;
params: Array<any>;
id: JSONRPCIDLike;
}
export interface JSONRPCVersionTwoRequest {
jsonrpc: string;
method: string;
params: RequestParamsLike;
id?: JSONRPCIDLike | null;
}
export interface JSONRPCVersionOneResponseWithResult {
result: any;
error: null;
id: any;
}
export interface JSONRPCVersionOneResponseWithError {
result: null;
error: object;
id: any;
}
export type JSONRPCVersionOneResponse = JSONRPCVersionOneResponseWithError | JSONRPCVersionOneResponseWithResult;
export interface JSONRPCVersionTwoResponseWithResult {
jsonrpc: string;
result: any;
id: JSONRPCIDLike | null;
}
export interface JSONRPCVersionTwoResponseWithError {
jsonrpc: string;
error: JSONRPCError;
id: JSONRPCIDLike | null;
}
export type JSONRPCVersionTwoResponse = JSONRPCVersionTwoResponseWithResult | JSONRPCVersionTwoResponseWithError;
export type JSONRPCResponseWithError = JSONRPCVersionOneResponseWithError | JSONRPCVersionTwoResponseWithError;
export type JSONRPCResponseWithResult = JSONRPCVersionOneResponseWithResult | JSONRPCVersionTwoResponseWithResult;
export type JSONRPCResponse = JSONRPCVersionOneResponse | JSONRPCVersionTwoResponse;
export type JSONRPCIDLike = number | string;
export type JSONRPCRequest = JSONRPCVersionOneRequest | JSONRPCVersionTwoRequest;
export type JSONRPCRequestLike = JSONRPCRequest | string;
export type JSONRPCResultLike = any;
export interface JSONRPCCallbackTypePlain {
(err?: JSONRPCErrorLike | null, result?: JSONRPCResultLike): void
}
export interface JSONRPCCallbackTypeSugared {
(err?: Error | null, error?: JSONRPCErrorLike, result?: JSONRPCResultLike): void
}
type JSONRPCCallbackType = JSONRPCCallbackTypePlain | JSONRPCCallbackTypeSugared;
export interface JSONRPCCallbackTypeBatchPlain {
(err: JSONRPCErrorLike, results?: Array<JSONRPCResultLike>): void
}
export interface JSONRPCCallbackTypeBatchSugared {
(err: Error, errors?: Array<JSONRPCErrorLike>, results?: Array<JSONRPCResultLike>): void
}
type JSONRPCCallbackTypeBatch = JSONRPCCallbackTypeBatchPlain | JSONRPCCallbackTypeBatchSugared;
export interface MethodHandler {
(this:Server, args:RequestParamsLike, callback:JSONRPCCallbackTypePlain): Promise<JSONRPCResultLike> | void;
}
export interface MethodHandlerContext {
(this:Server, args:RequestParamsLike, context:object, callback:JSONRPCCallbackTypePlain): Promise<JSONRPCResultLike> | void;
}
export type MethodHandlerType = MethodHandlerContext | MethodHandler;
export type MethodOptionsParamsLike = Array<any> | Object | object;
export interface MethodOptions {
handler?: MethodHandlerType;
useContext?: boolean;
params?: MethodOptionsParamsLike;
}
export type MethodExecuteCallbackType = {
(err?: Error | null, result?: JSONRPCResultLike): void
}
type MethodConstructor= ConstructorOf<Method, [options: MethodOptions] | [handler?: MethodHandlerType, options?: MethodOptions]>;
export interface Method {
getHandler(): MethodHandlerType;
setHandler(handler: MethodHandlerType): void;
execute(server: Server, requestParams: RequestParamsLike, callback: MethodExecuteCallbackType): any | Promise<any>;
execute(server: Server, requestParams: RequestParamsLike, context:object, callback: MethodExecuteCallbackType): any | Promise<any>;
}
export declare const Method: MethodConstructor;
// lowercase Method
export type method = Method;
export declare const method: MethodConstructor;
export type MethodLike = Function | Method | Client;
export type ServerRouterFunction = (this: Server, method: string, params: RequestParamsLike) => MethodLike;
export interface ServerOptions {
useContext?: boolean;
params?: MethodOptionsParamsLike;
version?: number;
reviver?: JSONParseReviver;
replacer?: JSONStringifyReplacer;
encoding?: string;
router?: ServerRouterFunction;
methodConstructor?: Function;
maxBatchLength?: number;
}
export type ServerCallCallbackType = {
(err?: JSONRPCResponseWithError | null, result?: JSONRPCResponseWithResult): void
}
export interface MethodMap { [methodName:string]: Method }
type ServerConstructor = ConstructorOf<Server, [methods?: { [methodName: string]: MethodLike }, options?: ServerOptions]> & {
errors: {[errorName: string]: number};
errorMessages: {[errorMessage: string]: string};
interfaces: {[interfaces: string]: Function};
}
export interface Server extends events.EventEmitter {
_methods: MethodMap;
options: ServerOptions;
errorMessages: {[errorMessage: string]: string};
http(options?: HttpServerOptions): HttpServer;
https(options?: HttpsServerOptions): HttpsServer;
tcp(options?: TcpServerOptions): TcpServer;
tls(options?: TlsServerOptions): TlsServer;
websocket(options?: WebsocketServerOptions): WebsocketServer;
middleware(options?: MiddlewareServerOptions): connect.HandleFunction;
method(name: string, definition: MethodLike): void;
methods(methods: {[methodName: string]: MethodLike}): void;
hasMethod(name: string): boolean;
removeMethod(name: string): void;
getMethod(name: string): MethodLike;
error(code?: number, message?: string, data?: object): JSONRPCError;
call(request: JSONRPCRequestLike | Array<JSONRPCRequestLike>, originalCallback?: ServerCallCallbackType): void;
call(request: JSONRPCRequestLike | Array<JSONRPCRequestLike>, context: object, originalCallback?: ServerCallCallbackType): void;
callp(request: JSONRPCRequestLike | Array<JSONRPCRequestLike>, context?: object): Promise<JSONRPCResultLike>;
}
export declare const Server: ServerConstructor;
// lowercase Server
export type server = Server;
export declare const server: ServerConstructor;
export interface MiddlewareServerOptions extends ServerOptions {
end?: boolean;
}
export interface HttpServerOptions extends ServerOptions {
}
declare class HttpServer extends http.Server {
constructor(server: Server, options?: HttpServerOptions);
}
export interface HttpsServerOptions extends ServerOptions, https.ServerOptions {
}
declare class HttpsServer extends https.Server {
constructor(server: Server, options?: HttpsServerOptions);
}
export interface TcpServerOptions extends ServerOptions {
}
declare class TcpServer extends net.Server {
constructor(server: Server, options?: TcpServerOptions);
}
export interface TlsServerOptions extends tls.TlsOptions {
}
declare class TlsServer extends tls.Server {
constructor(server: Server, options?: TlsServerOptions);
}
export interface WebsocketServerOptions extends ServerOptions, WebSocket.ServerOptions {
wss?: WebSocket.Server;
}
declare class WebsocketServer {
constructor(server: Server, options?: WebsocketServerOptions);
}
type JSONParseReviver = (key: string, value: any) => any;
type JSONStringifyReplacer = (key: string, value: any) => any;
type IDGenerator = () => JSONRPCIDLike;
export interface ClientOptions {
version?: number;
reviver?: JSONParseReviver;
replacer?: JSONStringifyReplacer;
generator?: IDGenerator;
notificationIdNull?: boolean;
}
export interface HttpClientOptions extends ClientOptions, http.RequestOptions {
}
declare class HttpClient extends Client {
constructor(options?: HttpClientOptions);
}
export interface TlsClientOptions extends ClientOptions, tls.ConnectionOptions {
}
declare class TlsClient extends Client {
constructor(options?: TlsClientOptions);
}
export interface TcpClientOptions extends ClientOptions, net.TcpSocketConnectOpts {
}
declare class TcpClient extends Client {
constructor(options?: TcpClientOptions);
}
export interface HttpsClientOptions extends ClientOptions, https.RequestOptions {
}
declare class HttpsClient extends Client {
constructor(options?: HttpsClientOptions);
}
export interface WebsocketClientOptions extends ClientOptions {
url?: string;
ws?: WebSocket;
timeout?: number;
}
declare class WebsocketClient extends Client {
constructor(options?: WebsocketClientOptions);
}
export type BrowserClientCallServerFunction = (request: string) => Promise<string>;
declare class BrowserClient {
constructor(callServer: BrowserClientCallServerFunction, options?: ClientOptions);
request(method: string, params: RequestParamsLike, id: JSONRPCIDLike | undefined, shouldCall: false): JSONRPCRequest;
request(method: string, params: RequestParamsLike, id?: JSONRPCIDLike): Promise<JSONRPCResultLike>;
request(method: Array<JSONRPCRequestLike>): Promise<JSONRPCResultLike>;
}
type ClientConstructor = ConstructorOf<Client, [options: ClientOptions] | [server: Server, options?: ClientOptions]> & {
http(options?: HttpClientOptions): HttpClient;
https(options?: HttpsClientOptions): HttpsClient;
tcp(options?: TcpClientOptions): TcpClient;
tls(options?: TlsClientOptions): TlsClient;
websocket(options?: WebsocketClientOptions): WebsocketClient;
browser(callServer: BrowserClientCallServerFunction, options?: ClientOptions): BrowserClient;
}
export interface Client extends events.EventEmitter {
request(method:string, params:RequestParamsLike, id:JSONRPCIDLike | undefined, shouldCall:false): JSONRPCRequest;
request(method:string, params:RequestParamsLike, id?:JSONRPCIDLike): Promise<JSONRPCResultLike>;
request(method: Array<JSONRPCRequestLike>): Promise<JSONRPCResultLike>;
}
export declare const Client: ClientConstructor;
// lowercase Client
export type client = Client;
export declare const client: ClientConstructor;

3
node_modules/jayson/promise/index.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
'use strict';
module.exports = require('./lib');

View File

@@ -0,0 +1,12 @@
import * as jayson from '../../../..';
type PromiseClientBrowserCallServerFunction = (request:string) => Promise<string>;
declare class PromiseClientBrowser {
constructor(callServer:PromiseClientBrowserCallServerFunction, options?:jayson.ClientOptions);
request(method:string, params:jayson.RequestParamsLike, id:jayson.JSONRPCIDLike | undefined, shouldCall:false): jayson.JSONRPCRequest;
request(method:string, params:jayson.RequestParamsLike, id?:jayson.JSONRPCIDLike): Promise<jayson.JSONRPCResultLike>;
request(method: Array<jayson.JSONRPCRequestLike>): Promise<jayson.JSONRPCResultLike>;
}
export = PromiseClientBrowser;

View File

@@ -0,0 +1,28 @@
'use strict';
const ClientBrowser = require('../../../../lib/client/browser/index');
const promiseUtils = require('../../utils');
/**
* Constructor for a Jayson Promise Browser Client that does not depend any node.js core libraries
* @class PromiseClientBrowser
* @extends ClientBrowser
* @return {PromiseClientBrowser}
*/
const PromiseClientBrowser = function(callServerPromise, options) {
if(!(this instanceof PromiseClientBrowser)) {
return new PromiseClientBrowser(callServerPromise, options);
}
const callServer = function (request, callback) {
callServerPromise(request).then(res => callback(null, res), err => callback(err));
};
ClientBrowser.call(this, callServer, options);
this.request = promiseUtils.wrapClientRequestMethod(this.request.bind(this));
};
// let's hope this ancient method of inheriting works the way I remember it.
PromiseClientBrowser.prototype = ClientBrowser.prototype;
module.exports = PromiseClientBrowser;

23
node_modules/jayson/promise/lib/client/http.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
'use strict';
const promisify = require('es6-promisify');
const jayson = require('../../../');
const promiseUtils = require('../utils');
/**
* Constructor for a Jayson Promise Client Http
* @see Client
* @class PromiseClientHttp
* @extends ClientHttp
* @return {PromiseClientHttp}
*/
const PromiseClientHttp = function(options) {
if(!(this instanceof PromiseClientHttp)) {
return new PromiseClientHttp(options);
}
jayson.Client.http.apply(this, arguments);
this.request = promiseUtils.wrapClientRequestMethod(this.request.bind(this));
};
require('util').inherits(PromiseClientHttp, jayson.Client.http);
module.exports = PromiseClientHttp;

24
node_modules/jayson/promise/lib/client/https.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
'use strict';
const promisify = require('es6-promisify');
const jayson = require('../../../');
const promiseUtils = require('../utils');
/**
* Constructor for a Jayson Promise Client Http
* @see Client
* @class PromiseClientHttps
* @extends ClientHttps
* @return {PromiseClientHttps}
*/
const PromiseClientHttps = function(options) {
if(!(this instanceof PromiseClientHttps)) {
return new PromiseClientHttps(options);
}
jayson.Client.https.apply(this, arguments);
this.request = promiseUtils.wrapClientRequestMethod(this.request.bind(this));
};
require('util').inherits(PromiseClientHttps, jayson.Client.https);
module.exports = PromiseClientHttps;

53
node_modules/jayson/promise/lib/client/index.js generated vendored Normal file
View File

@@ -0,0 +1,53 @@
'use strict';
const promisify = require('es6-promisify');
const jayson = require('../../../');
const promiseUtils = require('../utils');
/**
* Constructor for a Jayson Promise Client
* @see Client
* @class PromiseClient
* @extends Client
* @return {PromiseClient}
*/
const PromiseClient = function(server, options) {
if(!(this instanceof PromiseClient)) {
return new PromiseClient(server, options);
}
jayson.Client.apply(this, arguments);
this.request = promiseUtils.wrapClientRequestMethod(this.request.bind(this));
};
require('util').inherits(PromiseClient, jayson.Client);
/**
* @type PromiseClientHttp
* @static
*/
PromiseClient.http = require('./http');
/**
* @type PromiseClientHttps
* @static
*/
PromiseClient.https = require('./https');
/**
* @type PromiseClientTls
* @static
*/
PromiseClient.tls = require('./tls');
/**
* @type PromiseClientTcp
* @static
*/
PromiseClient.tcp = require('./tcp');
/**
* @type PromiseClientWebsocket
* @static
*/
PromiseClient.websocket = require('./websocket');
module.exports = PromiseClient;

23
node_modules/jayson/promise/lib/client/tcp.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
'use strict';
const promisify = require('es6-promisify');
const jayson = require('../../../');
const promiseUtils = require('../utils');
/**
* Constructor for a Jayson Promise Client Tcp
* @see Client
* @class PromiseClientTcp
* @extends ClientTcp
* @return {PromiseClientTcp}
*/
const PromiseClientTcp = function(options) {
if(!(this instanceof PromiseClientTcp)) {
return new PromiseClientTcp(options);
}
jayson.Client.tcp.apply(this, arguments);
this.request = promiseUtils.wrapClientRequestMethod(this.request.bind(this));
};
require('util').inherits(PromiseClientTcp, jayson.Client.tcp);
module.exports = PromiseClientTcp;

23
node_modules/jayson/promise/lib/client/tls.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
'use strict';
const promisify = require('es6-promisify');
const jayson = require('../../../');
const promiseUtils = require('../utils');
/**
* Constructor for a Jayson Promise Client Tls
* @see Client
* @class PromiseClientTls
* @extends ClientTls
* @return {PromiseClientTls}
*/
const PromiseClientTls = function(options) {
if(!(this instanceof PromiseClientTls)) {
return new PromiseClientTls(options);
}
jayson.Client.tls.apply(this, arguments);
this.request = promiseUtils.wrapClientRequestMethod(this.request.bind(this));
};
require('util').inherits(PromiseClientTls, jayson.Client.tls);
module.exports = PromiseClientTls;

23
node_modules/jayson/promise/lib/client/websocket.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
'use strict';
const promisify = require('es6-promisify');
const jayson = require('../../../');
const promiseUtils = require('../utils');
/**
* Constructor for a Jayson Promise Client Websocket
* @see Client
* @class PromiseClientWebsocket
* @extends ClientWebsocket
* @return {PromiseClientWebsocket}
*/
const PromiseClientWebsocket = function(options) {
if(!(this instanceof PromiseClientWebsocket)) {
return new PromiseClientWebsocket(options);
}
jayson.Client.websocket.apply(this, arguments);
this.request = promiseUtils.wrapClientRequestMethod(this.request.bind(this));
};
require('util').inherits(PromiseClientWebsocket, jayson.Client.websocket);
module.exports = PromiseClientWebsocket;

33
node_modules/jayson/promise/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
'use strict';
const Jayson = require('../..');
/**
* Namespace available as require('jayson/promise')
* @namespace JaysonPromise
*/
const JaysonPromise = module.exports;
/**
* @static
* @type PromiseClient
*/
JaysonPromise.Client = JaysonPromise.client = require('./client');
/**
* @static
* @type Server
*/
JaysonPromise.Server = JaysonPromise.server = require('./server');
/**
* @static
* @type Utils
*/
JaysonPromise.Utils = JaysonPromise.utils = Jayson.utils;
/**
* @static
* @type PromiseMethod
*/
JaysonPromise.Method = JaysonPromise.method = require('./method');

54
node_modules/jayson/promise/lib/method.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
'use strict';
const jayson = require('../../');
/**
* Constructor for a Jayson Promise Method
* @see Method
* @class PromiseMethod
* @extends Method
* @return {PromiseMethod}
*/
const PromiseMethod = module.exports = function(handler, options) {
if(!(this instanceof PromiseMethod)) {
return new PromiseMethod(handler, options);
}
jayson.Method.apply(this, arguments);
};
require('util').inherits(PromiseMethod, jayson.Method);
module.exports = PromiseMethod;
/**
* @summary Executes this method in the context of a server
* @param {Server} server
* @param {Array|Object} requestParams
* @param {Object} [context] Optional context object passed to methods
* @param {Function} outerCallback
* @return {Promise}
*/
PromiseMethod.prototype.execute = function(server, requestParams, context, outerCallback) {
let wasPromised = false;
if(typeof(context) === 'function') {
outerCallback = context;
context = {};
}
const promise = jayson.Method.prototype.execute.call(this, server, requestParams, context, function() {
if(wasPromised) {
return; // ignore any invocations of the callback if a promise was returned
}
outerCallback.apply(null, arguments);
});
wasPromised = promise && typeof promise.then === 'function';
// if the handler returned a promise, call the callback when it resolves
if(wasPromised) {
return promise.then(
function(fulfilled) { outerCallback(null, fulfilled); },
function(rejected) { outerCallback(rejected); }
);
}
};

23
node_modules/jayson/promise/lib/server.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
'use strict';
const Method = require('./method');
const jayson = require('../../');
/**
* Constructor for a Jayson Promise Server
* @see Server
* @class PromiseServer
* @extends Server
* @return {PromiseServer}
*/
const PromiseServer = function(methods, options) {
if(!(this instanceof PromiseServer)) {
return new PromiseServer(methods, options);
}
options = options || {};
options.methodConstructor = options.methodConstructor || Method;
jayson.Server.call(this, methods, options);
};
require('util').inherits(PromiseServer, jayson.Server);
module.exports = PromiseServer;

23
node_modules/jayson/promise/lib/utils.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
'use strict';
const promisify = require('es6-promisify');
/** * @namespace */
const PromiseUtils = module.exports;
/**
* Wraps the client request method on an instance, making it return a promise in every case except when the fourth argument is explicitly set to false
* @param {Function} request The original request method
* @return {Function}
*/
PromiseUtils.wrapClientRequestMethod = function(request) {
const promisified = promisify(request);
return function(method, params, id, shouldCall) {
if(shouldCall === false) {
// this should return a raw request for use in batches
return request(method, params, id);
}
return promisified.apply(this, arguments);
};
};