UNPKG

@socketsupply/socket

Version:

A Cross-Platform, Native Runtime for Desktop and Mobile Apps — Create apps using HTML, CSS, and JavaScript. Written from the ground up to be small and maintainable.

1,458 lines (1,439 loc) 616 kB
declare module "socket:async/context" { /** * @module async.context * * Async Context for JavaScript based on the TC39 proposal. * * Example usage: * ```js * // `AsyncContext` is also globally available as `globalThis.AsyncContext` * import AsyncContext from 'socket:async/context' * * const var = new AsyncContext.Variable() * var.run('top', () => { * console.log(var.get()) // 'top' * queueMicrotask(() => { * var.run('nested', () => { * console.log(var.get()) // 'nested' * }) * }) * }) * ``` * * @see {@link https://tc39.es/proposal-async-context} * @see {@link https://github.com/tc39/proposal-async-context} */ /** * @template T * @typedef {{ * name?: string, * defaultValue?: T * }} VariableOptions */ /** * @callback AnyFunc * @template T * @this T * @param {...any} args * @returns {any} */ /** * `FrozenRevert` holds a frozen Mapping that will be simply restored * when the revert is run. * @see {@link https://github.com/tc39/proposal-async-context/blob/master/src/fork.ts} */ export class FrozenRevert { /** * `FrozenRevert` class constructor. * @param {Mapping} mapping */ constructor(mapping: Mapping); /** * Restores (unchaged) mapping from this `FrozenRevert`. This function is * called by `AsyncContext.Storage` when it reverts a current mapping to the * previous state before a "fork". * @param {Mapping=} [unused] * @return {Mapping} */ restore(unused?: Mapping | undefined): Mapping; #private; } /** * Revert holds the state on how to revert a change to the * `AsyncContext.Storage` current `Mapping` * @see {@link https://github.com/tc39/proposal-async-context/blob/master/src/fork.ts} * @template T */ export class Revert<T> { /** * `Revert` class constructor. * @param {Mapping} mapping * @param {Variable<T>} key */ constructor(mapping: Mapping, key: Variable<T>); /** * @type {T|undefined} */ get previousVariable(): T; /** * Restores a mapping from this `Revert`. This function is called by * `AsyncContext.Storage` when it reverts a current mapping to the * previous state before a "fork". * @param {Mapping} current * @return {Mapping} */ restore(current: Mapping): Mapping; #private; } /** * A container for all `AsyncContext.Variable` instances and snapshot state. * @see {@link https://github.com/tc39/proposal-async-context/blob/master/src/mapping.ts} */ export class Mapping { /** * `Mapping` class constructor. * @param {Map<Variable<any>, any>} data */ constructor(data: Map<Variable<any>, any>); /** * Freezes the `Mapping` preventing `AsyncContext.Variable` modifications with * `set()` and `delete()`. */ freeze(): void; /** * Returns `true` if the `Mapping` is frozen, otherwise `false`. * @return {boolean} */ isFrozen(): boolean; /** * Optionally returns a new `Mapping` if the current one is "frozen", * otherwise it just returns the current instance. * @return {Mapping} */ fork(): Mapping; /** * Returns `true` if the `Mapping` has a `AsyncContext.Variable` at `key`, * otherwise `false. * @template T * @param {Variable<T>} key * @return {boolean} */ has<T>(key: Variable<T>): boolean; /** * Gets an `AsyncContext.Variable` value at `key`. If not set, this function * returns `undefined`. * @template T * @param {Variable<T>} key * @return {boolean} */ get<T>(key: Variable<T>): boolean; /** * Sets an `AsyncContext.Variable` value at `key`. If the `Mapping` is frozen, * then a "forked" (new) instance with the value set on it is returned, * otherwise the current instance. * @template T * @param {Variable<T>} key * @param {T} value * @return {Mapping} */ set<T>(key: Variable<T>, value: T): Mapping; /** * Delete an `AsyncContext.Variable` value at `key`. * If the `Mapping` is frozen, then a "forked" (new) instance is returned, * otherwise the current instance. * @template T * @param {Variable<T>} key * @param {T} value * @return {Mapping} */ delete<T>(key: Variable<T>): Mapping; #private; } /** * A container of all `AsyncContext.Variable` data. * @ignore * @see {@link https://github.com/tc39/proposal-async-context/blob/master/src/storage.ts} */ export class Storage { /** * The current `Mapping` for this `AsyncContext`. * @type {Mapping} */ static "__#4@#current": Mapping; /** * Returns `true` if the current `Mapping` has a * `AsyncContext.Variable` at `key`, * otherwise `false. * @template T * @param {Variable<T>} key * @return {boolean} */ static has<T>(key: Variable<T>): boolean; /** * Gets an `AsyncContext.Variable` value at `key` for the current `Mapping`. * If not set, this function returns `undefined`. * @template T * @param {Variable<T>} key * @return {T|undefined} */ static get<T>(key: Variable<T>): T | undefined; /** * Set updates the `AsyncContext.Variable` with a new value and returns a * revert action that allows the modification to be reversed in the future. * @template T * @param {Variable<T>} key * @param {T} value * @return {Revert<T>|FrozenRevert} */ static set<T>(key: Variable<T>, value: T): Revert<T> | FrozenRevert; /** * "Freezes" the current storage `Mapping`, and returns a new `FrozenRevert` * or `Revert` which can restore the storage state to the state at * the time of the snapshot. * @return {FrozenRevert} */ static snapshot(): FrozenRevert; /** * Restores the storage `Mapping` state to state at the time the * "revert" (`FrozenRevert` or `Revert`) was created. * @template T * @param {Revert<T>|FrozenRevert} revert */ static restore<T>(revert: Revert<T> | FrozenRevert): void; /** * Switches storage `Mapping` state to the state at the time of a * "snapshot". * @param {FrozenRevert} snapshot * @return {FrozenRevert} */ static switch(snapshot: FrozenRevert): FrozenRevert; } /** * `AsyncContext.Variable` is a container for a value that is associated with * the current execution flow. The value is propagated through async execution * flows, and can be snapshot and restored with Snapshot. * @template T * @see {@link https://github.com/tc39/proposal-async-context/blob/master/README.md#asynccontextvariable} */ export class Variable<T> { /** * `Variable` class constructor. * @param {VariableOptions<T>=} [options] */ constructor(options?: VariableOptions<T> | undefined); set defaultValue(defaultValue: T); /** * @ignore */ get defaultValue(): T; /** * @ignore */ get revert(): FrozenRevert | Revert<T>; /** * The name of this async context variable. * @type {string} */ get name(): string; /** * Executes a function `fn` with specified arguments, * setting a new value to the current context before the call, * and ensuring the environment is reverted back afterwards. * The function allows for the modification of a specific context's * state in a controlled manner, ensuring that any changes can be undone. * @template T, F extends AnyFunc<null> * @param {T} value * @param {F} fn * @param {...Parameters<F>} args * @returns {ReturnType<F>} */ run<T_1, F>(value: T_1, fn: F, ...args: Parameters<F>[]): ReturnType<F>; /** * Get the `AsyncContext.Variable` value. * @template T * @return {T|undefined} */ get<T_1>(): T_1 | undefined; #private; } /** * `AsyncContext.Snapshot` allows you to opaquely capture the current values of * all `AsyncContext.Variable` instances and execute a function at a later time * as if those values were still the current values (a snapshot and restore). * @see {@link https://github.com/tc39/proposal-async-context/blob/master/README.md#asynccontextsnapshot} */ export class Snapshot { /** * Wraps a given function `fn` with additional logic to take a snapshot of * `Storage` before invoking `fn`. Returns a new function with the same * signature as `fn` that when called, will invoke `fn` with the current * `this` context and provided arguments, after restoring the `Storage` * snapshot. * * `AsyncContext.Snapshot.wrap` is a helper which captures the current values * of all Variables and returns a wrapped function. When invoked, this * wrapped function restores the state of all Variables and executes the * inner function. * * @see {@link https://github.com/tc39/proposal-async-context/blob/master/README.md#asynccontextsnapshotwrap} * * @template F * @param {F} fn * @returns {F} */ static wrap<F>(fn: F): F; /** * Runs the given function `fn` with arguments `args`, using a `null` * context and the current snapshot. * * @template F extends AnyFunc<null> * @param {F} fn * @param {...Parameters<F>} args * @returns {ReturnType<F>} */ run<F>(fn: F, ...args: Parameters<F>[]): ReturnType<F>; #private; } /** * `AsyncContext` container. */ export class AsyncContext { /** * `AsyncContext.Variable` is a container for a value that is associated with * the current execution flow. The value is propagated through async execution * flows, and can be snapshot and restored with Snapshot. * @see {@link https://github.com/tc39/proposal-async-context/blob/master/README.md#asynccontextvariable} * @type {typeof Variable} */ static Variable: typeof Variable; /** * `AsyncContext.Snapshot` allows you to opaquely capture the current values of * all `AsyncContext.Variable` instances and execute a function at a later time * as if those values were still the current values (a snapshot and restore). * @see {@link https://github.com/tc39/proposal-async-context/blob/master/README.md#asynccontextsnapshot} * @type {typeof Snapshot} */ static Snapshot: typeof Snapshot; } export default AsyncContext; export type VariableOptions<T> = { name?: string; defaultValue?: T; }; export type AnyFunc = () => any; } declare module "socket:events" { export const Event: { new (type: string, eventInitDict?: EventInit): Event; prototype: Event; readonly NONE: 0; readonly CAPTURING_PHASE: 1; readonly AT_TARGET: 2; readonly BUBBLING_PHASE: 3; } | { new (): {}; }; export const EventTarget: { new (): {}; }; export const CustomEvent: { new <T>(type: string, eventInitDict?: CustomEventInit<T>): CustomEvent<T>; prototype: CustomEvent; } | { new (type: any, options: any): { "__#7@#detail": any; readonly detail: any; }; }; export const MessageEvent: { new <T>(type: string, eventInitDict?: MessageEventInit<T>): MessageEvent<T>; prototype: MessageEvent; } | { new (type: any, options: any): { "__#8@#detail": any; "__#8@#data": any; readonly detail: any; readonly data: any; }; }; export const ErrorEvent: { new (type: string, eventInitDict?: ErrorEventInit): ErrorEvent; prototype: ErrorEvent; } | { new (type: any, options: any): { "__#9@#detail": any; "__#9@#error": any; readonly detail: any; readonly error: any; }; }; export default EventEmitter; export function EventEmitter(): void; export class EventEmitter { _events: any; _contexts: any; _eventsCount: number; _maxListeners: number; setMaxListeners(n: any): this; getMaxListeners(): any; emit(type: any, ...args: any[]): boolean; addListener(type: any, listener: any): any; on(arg0: any, arg1: any): any; prependListener(type: any, listener: any): any; once(type: any, listener: any): this; prependOnceListener(type: any, listener: any): this; removeListener(type: any, listener: any): this; off(type: any, listener: any): this; removeAllListeners(type: any, ...args: any[]): this; listeners(type: any): any[]; rawListeners(type: any): any[]; listenerCount(type: any): any; eventNames(): (string | symbol)[]; } export namespace EventEmitter { export { EventEmitter }; export let defaultMaxListeners: number; export function init(): void; export function listenerCount(emitter: any, type: any): any; export { once }; } export function once(emitter: any, name: any): Promise<any>; } declare module "socket:url/urlpattern/urlpattern" { export { me as URLPattern }; var me: { new (t: {}, r: any, n: any): { "__#11@#i": any; "__#11@#n": {}; "__#11@#t": {}; "__#11@#e": {}; "__#11@#s": {}; "__#11@#l": boolean; test(t: {}, r: any): boolean; exec(t: {}, r: any): { inputs: any[] | {}[]; }; readonly protocol: any; readonly username: any; readonly password: any; readonly hostname: any; readonly port: any; readonly pathname: any; readonly search: any; readonly hash: any; readonly hasRegExpGroups: boolean; }; compareComponent(t: any, r: any, n: any): number; }; } declare module "socket:url/url/url" { const _default: any; export default _default; } declare module "socket:buffer" { export default Buffer; export const File: { new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag): File; prototype: File; }; export const Blob: { new (blobParts?: BlobPart[], options?: BlobPropertyBag): Blob; prototype: Blob; }; export namespace constants { export { kMaxLength as MAX_LENGTH }; export { kMaxLength as MAX_STRING_LENGTH }; } export const btoa: any; export const atob: any; /** * The Buffer constructor returns instances of `Uint8Array` that have their * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of * `Uint8Array`, so the returned instances will have all the node `Buffer` methods * and the `Uint8Array` methods. Square bracket notation works as expected -- it * returns a single octet. * * The `Uint8Array` prototype remains unmodified. */ /** * @name Buffer * @extends {Uint8Array} */ export function Buffer(arg: any, encodingOrOffset: any, length: any): any; export class Buffer { /** * The Buffer constructor returns instances of `Uint8Array` that have their * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of * `Uint8Array`, so the returned instances will have all the node `Buffer` methods * and the `Uint8Array` methods. Square bracket notation works as expected -- it * returns a single octet. * * The `Uint8Array` prototype remains unmodified. */ /** * @name Buffer * @extends {Uint8Array} */ constructor(arg: any, encodingOrOffset: any, length: any); get parent(): any; get offset(): any; _isBuffer: boolean; swap16(): this; swap32(): this; swap64(): this; toString(...args: any[]): any; toLocaleString: any; equals(b: any): boolean; inspect(): string; compare(target: any, start: any, end: any, thisStart: any, thisEnd: any): 0 | 1 | -1; includes(val: any, byteOffset: any, encoding: any): boolean; indexOf(val: any, byteOffset: any, encoding: any): any; lastIndexOf(val: any, byteOffset: any, encoding: any): any; write(string: any, offset: any, length: any, encoding: any): number; toJSON(): { type: string; data: any; }; slice(start: any, end: any): any; readUintLE: (offset: any, byteLength: any, noAssert: any) => any; readUIntLE(offset: any, byteLength: any, noAssert: any): any; readUintBE: (offset: any, byteLength: any, noAssert: any) => any; readUIntBE(offset: any, byteLength: any, noAssert: any): any; readUint8: (offset: any, noAssert: any) => any; readUInt8(offset: any, noAssert: any): any; readUint16LE: (offset: any, noAssert: any) => number; readUInt16LE(offset: any, noAssert: any): number; readUint16BE: (offset: any, noAssert: any) => number; readUInt16BE(offset: any, noAssert: any): number; readUint32LE: (offset: any, noAssert: any) => number; readUInt32LE(offset: any, noAssert: any): number; readUint32BE: (offset: any, noAssert: any) => number; readUInt32BE(offset: any, noAssert: any): number; readBigUInt64LE: any; readBigUInt64BE: any; readIntLE(offset: any, byteLength: any, noAssert: any): any; readIntBE(offset: any, byteLength: any, noAssert: any): any; readInt8(offset: any, noAssert: any): any; readInt16LE(offset: any, noAssert: any): number; readInt16BE(offset: any, noAssert: any): number; readInt32LE(offset: any, noAssert: any): number; readInt32BE(offset: any, noAssert: any): number; readBigInt64LE: any; readBigInt64BE: any; readFloatLE(offset: any, noAssert: any): number; readFloatBE(offset: any, noAssert: any): number; readDoubleLE(offset: any, noAssert: any): number; readDoubleBE(offset: any, noAssert: any): number; writeUintLE: (value: any, offset: any, byteLength: any, noAssert: any) => any; writeUIntLE(value: any, offset: any, byteLength: any, noAssert: any): any; writeUintBE: (value: any, offset: any, byteLength: any, noAssert: any) => any; writeUIntBE(value: any, offset: any, byteLength: any, noAssert: any): any; writeUint8: (value: any, offset: any, noAssert: any) => any; writeUInt8(value: any, offset: any, noAssert: any): any; writeUint16LE: (value: any, offset: any, noAssert: any) => any; writeUInt16LE(value: any, offset: any, noAssert: any): any; writeUint16BE: (value: any, offset: any, noAssert: any) => any; writeUInt16BE(value: any, offset: any, noAssert: any): any; writeUint32LE: (value: any, offset: any, noAssert: any) => any; writeUInt32LE(value: any, offset: any, noAssert: any): any; writeUint32BE: (value: any, offset: any, noAssert: any) => any; writeUInt32BE(value: any, offset: any, noAssert: any): any; writeBigUInt64LE: any; writeBigUInt64BE: any; writeIntLE(value: any, offset: any, byteLength: any, noAssert: any): any; writeIntBE(value: any, offset: any, byteLength: any, noAssert: any): any; writeInt8(value: any, offset: any, noAssert: any): any; writeInt16LE(value: any, offset: any, noAssert: any): any; writeInt16BE(value: any, offset: any, noAssert: any): any; writeInt32LE(value: any, offset: any, noAssert: any): any; writeInt32BE(value: any, offset: any, noAssert: any): any; writeBigInt64LE: any; writeBigInt64BE: any; writeFloatLE(value: any, offset: any, noAssert: any): any; writeFloatBE(value: any, offset: any, noAssert: any): any; writeDoubleLE(value: any, offset: any, noAssert: any): any; writeDoubleBE(value: any, offset: any, noAssert: any): any; copy(target: any, targetStart: any, start: any, end: any): number; fill(val: any, start: any, end: any, encoding: any): this; } export namespace Buffer { export let TYPED_ARRAY_SUPPORT: boolean; export let poolSize: number; /** * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError * if value is a number. * Buffer.from(str[, encoding]) * Buffer.from(array) * Buffer.from(buffer) * Buffer.from(arrayBuffer[, byteOffset[, length]]) **/ export function from(value: any, encodingOrOffset?: any, length?: any): any; /** * Creates a new filled Buffer instance. * alloc(size[, fill[, encoding]]) **/ export function alloc(size: any, fill: any, encoding: any): Uint8Array; /** * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. * */ export function allocUnsafe(size: any): Uint8Array; /** * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. */ export function allocUnsafeSlow(size: any): Uint8Array; export function isBuffer(b: any): boolean; export function compare(a: any, b: any): 0 | 1 | -1; export function isEncoding(encoding: any): boolean; export function concat(list: any, length: any): Uint8Array; export { byteLength }; } export const kMaxLength: 2147483647; export function SlowBuffer(length: any): Uint8Array; export const INSPECT_MAX_BYTES: 50; function byteLength(string: any, encoding: any, ...args: any[]): any; } declare module "socket:querystring" { export function unescapeBuffer(s: any, decodeSpaces: any): any; export function unescape(s: any, decodeSpaces: any): any; export function escape(str: any): any; export function stringify(obj: any, sep: any, eq: any, options: any): string; export function parse(qs: any, sep: any, eq: any, options: any): {}; export function decode(qs: any, sep: any, eq: any, options: any): {}; export function encode(obj: any, sep: any, eq: any, options: any): string; namespace _default { export { decode }; export { encode }; export { parse }; export { stringify }; export { escape }; export { unescape }; } export default _default; } declare module "socket:url/index" { export function parse(input: any, options?: any): { hash: any; host: any; hostname: any; origin: any; auth: string; password: any; pathname: any; path: any; port: any; protocol: any; search: any; searchParams: any; username: any; [Symbol.toStringTag]: string; }; export function resolve(from: any, to: any): any; export function format(input: any): any; export function fileURLToPath(url: any): any; /** * @type {Set & { handlers: Set<string> }} */ export const protocols: Set<any> & { handlers: Set<string>; }; export default URL; export class URL { private constructor(); } export const URLSearchParams: any; export const parseURL: any; import { URLPattern } from "socket:url/urlpattern/urlpattern"; export { URLPattern }; } declare module "socket:url" { export * from "socket:url/index"; export default URL; import URL from "socket:url/index"; } declare module "socket:fs/bookmarks" { /** * A map of known absolute file paths to file IDs that * have been granted access outside of the sandbox. * XXX(@jwerle): this is currently only used on linux, but valaues may * be added for all platforms, likely from a file system picker dialog. * @type {Map<string, string>} */ export const temporary: Map<string, string>; namespace _default { export { temporary }; } export default _default; } declare module "socket:internal/serialize" { export default function serialize(value: any): any; } declare module "socket:location" { export class Location { get url(): URL; get protocol(): string; get host(): string; get hostname(): string; get port(): string; get pathname(): string; get search(): string; get origin(): string; get href(): string; get hash(): string; toString(): string; } const _default: Location; export default _default; } declare module "socket:internal/symbols" { export const dispose: any; export const serialize: any; namespace _default { export { dispose }; export { serialize }; } export default _default; } declare module "socket:gc" { /** * Track `object` ref to call `Symbol.for('socket.runtime.gc.finalize')` method when * environment garbage collects object. * @param {object} object * @return {boolean} */ export function ref(object: object, ...args: any[]): boolean; /** * Stop tracking `object` ref to call `Symbol.for('socket.runtime.gc.finalize')` method when * environment garbage collects object. * @param {object} object * @return {boolean} */ export function unref(object: object): boolean; /** * An alias for `unref()` * @param {object} object} * @return {boolean} */ export function retain(object: object): boolean; /** * Call finalize on `object` for `gc.finalizer` implementation. * @param {object} object] * @return {Promise<boolean>} */ export function finalize(object: object, ...args: any[]): Promise<boolean>; /** * Calls all pending finalization handlers forcefully. This function * may have unintended consequences as objects be considered finalized * and still strongly held (retained) somewhere. */ export function release(): Promise<void>; export const finalizers: WeakMap<object, any>; export const kFinalizer: unique symbol; export const finalizer: symbol; /** * @type {Set<WeakRef>} */ export const pool: Set<WeakRef<any>>; /** * Static registry for objects to clean up underlying resources when they * are gc'd by the environment. There is no guarantee that the `finalizer()` * is called at any time. */ export const registry: FinalizationRegistry<Finalizer>; /** * Default exports which also acts a retained value to persist bound * `Finalizer#handle()` functions from being gc'd before the * `FinalizationRegistry` callback is called because `heldValue` must be * strongly held (retained) in order for the callback to be called. */ export const gc: any; export default gc; /** * A container for strongly (retain) referenced finalizer function * with arguments weakly referenced to an object that will be * garbage collected. */ export class Finalizer { /** * Creates a `Finalizer` from input. */ static from(handler: any): Finalizer; /** * `Finalizer` class constructor. * @private * @param {array} args * @param {function} handle */ private constructor(); args: any[]; handle: any; } } declare module "socket:ipc" { export function maybeMakeError(error: any, caller: any): any; /** * Parses `seq` as integer value * @param {string|number} seq * @param {object=} [options] * @param {boolean} [options.bigint = false] * @ignore */ export function parseSeq(seq: string | number, options?: object | undefined): number | bigint; /** * If `debug.enabled === true`, then debug output will be printed to console. * @param {(boolean)} [enable] * @return {boolean} * @ignore */ export function debug(enable?: (boolean)): boolean; export namespace debug { let enabled: boolean; function log(...args: any[]): any; } /** * Find transfers for an in worker global `postMessage` * that is proxied to the main thread. * @ignore */ export function findMessageTransfers(transfers: any, object: any): any; /** * @ignore */ export function postMessage(message: any, ...args: any[]): any; /** * Waits for the native IPC layer to be ready and exposed on the * global window object. * @ignore */ export function ready(): Promise<any>; /** * Sends a synchronous IPC command over XHR returning a `Result` * upon success or error. * @param {string} command * @param {any?} [value] * @param {object?} [options] * @return {Result} * @ignore */ export function sendSync(command: string, value?: any | null, options?: object | null, buffer?: any): Result; /** * Emit event to be dispatched on `window` object. * @param {string} name * @param {any} value * @param {EventTarget=} [target = window] * @param {Object=} options */ export function emit(name: string, value: any, target?: EventTarget | undefined, options?: any | undefined): Promise<void>; /** * Resolves a request by `seq` with possible value. * @param {string} seq * @param {any} value * @ignore */ export function resolve(seq: string, value: any): Promise<void>; /** * Sends an async IPC command request with parameters. * @param {string} command * @param {any=} value * @param {object=} [options] * @param {boolean=} [options.cache=false] * @param {boolean=} [options.bytes=false] * @return {Promise<Result>} */ export function send(command: string, value?: any | undefined, options?: object | undefined): Promise<Result>; /** * Sends an async IPC command request with parameters and buffered bytes. * @param {string} command * @param {any=} value * @param {(Buffer|Uint8Array|ArrayBuffer|string|Array)=} buffer * @param {object=} options * @ignore */ export function write(command: string, value?: any | undefined, buffer?: (Buffer | Uint8Array | ArrayBuffer | string | any[]) | undefined, options?: object | undefined): Promise<any>; /** * Sends an async IPC command request with parameters requesting a response * with buffered bytes. * @param {string} command * @param {any=} value * @param {object=} options * @ignore */ export function request(command: string, value?: any | undefined, options?: object | undefined): Promise<any>; /** * Factory for creating a proxy based IPC API. * @param {string} domain * @param {(function|object)=} ctx * @param {string=} [ctx.default] * @return {Proxy} * @ignore */ export function createBinding(domain: string, ctx?: (Function | object) | undefined): ProxyConstructor; export function inflateIPCMessageTransfers(object: any, types?: Map<any, any>): any; export function findIPCMessageTransfers(transfers: any, object: any): any; /** * Represents an OK IPC status. * @ignore */ export const OK: 0; /** * Represents an ERROR IPC status. * @ignore */ export const ERROR: 1; /** * Timeout in milliseconds for IPC requests. * @ignore */ export const TIMEOUT: number; /** * Symbol for the `ipc.debug.enabled` property * @ignore */ export const kDebugEnabled: unique symbol; /** * @ignore */ export class Headers extends globalThis.Headers { /** * @ignore */ static from(input: any): Headers; /** * @ignore */ get length(): number; /** * @ignore */ toJSON(): { [k: string]: string; }; } const Message_base: any; /** * A container for a IPC message based on a `ipc://` URI scheme. * @ignore */ export class Message extends Message_base { [x: string]: any; /** * The expected protocol for an IPC message. * @ignore */ static get PROTOCOL(): string; /** * Creates a `Message` instance from a variety of input. * @param {string|URL|Message|Buffer|object} input * @param {(object|string|URLSearchParams)=} [params] * @param {(ArrayBuffer|Uint8Array|string)?} [bytes] * @return {Message} * @ignore */ static from(input: string | URL | Message | Buffer | object, params?: (object | string | URLSearchParams) | undefined, bytes?: (ArrayBuffer | Uint8Array | string) | null): Message; /** * Predicate to determine if `input` is valid for constructing * a new `Message` instance. * @param {string|URL|Message|Buffer|object} input * @return {boolean} * @ignore */ static isValidInput(input: string | URL | Message | Buffer | object): boolean; /** * `Message` class constructor. * @protected * @param {string|URL} input * @param {(object|Uint8Array)?} [bytes] * @ignore */ protected constructor(); /** * @type {Uint8Array?} * @ignore */ bytes: Uint8Array | null; /** * Computed IPC message name. * @type {string} * @ignore */ get command(): string; /** * Computed IPC message name. * @type {string} * @ignore */ get name(): string; /** * Computed `id` value for the command. * @type {string} * @ignore */ get id(): string; /** * Computed `seq` (sequence) value for the command. * @type {string} * @ignore */ get seq(): string; /** * Computed message value potentially given in message parameters. * This value is automatically decoded, but not treated as JSON. * @type {string} * @ignore */ get value(): string; /** * Computed `index` value for the command potentially referring to * the window index the command is scoped to or originating from. If not * specified in the message parameters, then this value defaults to `-1`. * @type {number} * @ignore */ get index(): number; /** * Computed value parsed as JSON. This value is `null` if the value is not present * or it is invalid JSON. * @type {object?} * @ignore */ get json(): any; /** * Computed readonly object of message parameters. * @type {object} * @ignore */ get params(): any; /** * Gets unparsed message parameters. * @type {Array<Array<string>>} * @ignore */ get rawParams(): string[][]; /** * Returns computed parameters as entries * @return {Array<Array<any>>} * @ignore */ entries(): Array<Array<any>>; /** * Set a parameter `value` by `key`. * @param {string} key * @param {any} value * @ignore */ set(key: string, value: any): any; /** * Get a parameter value by `key`. * @param {string} key * @param {any=} [defaultValue] * @return {any} * @ignore */ get(key: string, defaultValue?: any | undefined): any; /** * Delete a parameter by `key`. * @param {string} key * @return {boolean} * @ignore */ delete(key: string): boolean; /** * Computed parameter keys. * @return {Array<string>} * @ignore */ keys(): Array<string>; /** * Computed parameter values. * @return {Array<any>} * @ignore */ values(): Array<any>; /** * Predicate to determine if parameter `key` is present in parameters. * @param {string} key * @return {boolean} * @ignore */ has(key: string): boolean; } /** * A result type used internally for handling * IPC result values from the native layer that are in the form * of `{ err?, data? }`. The `data` and `err` properties on this * type of object are in tuple form and be accessed at `[data?,err?]` * @ignore */ export class Result { /** * Creates a `Result` instance from input that may be an object * like `{ err?, data? }`, an `Error` instance, or just `data`. * @param {(object|Error|any)?} result * @param {Error|object} [maybeError] * @param {string} [maybeSource] * @param {object|string|Headers} [maybeHeaders] * @return {Result} * @ignore */ static from(result: (object | Error | any) | null, maybeError?: Error | object, maybeSource?: string, maybeHeaders?: object | string | Headers): Result; /** * `Result` class constructor. * @private * @param {string?} [id = null] * @param {Error?} [err = null] * @param {object?} [data = null] * @param {string?} [source = null] * @param {(object|string|Headers)?} [headers = null] * @ignore */ private constructor(); /** * The unique ID for this result. * @type {string} * @ignore */ id: string; /** * An optional error in the result. * @type {Error?} * @ignore */ err: Error | null; /** * Result data if given. * @type {(string|object|Uint8Array)?} * @ignore */ data: (string | object | Uint8Array) | null; /** * The source of this result. * @type {string?} * @ignore */ source: string | null; /** * Result headers, if given. * @type {Headers?} * @ignore */ headers: Headers | null; /** * Computed result length. * @ignore */ get length(): any; /** * @ignore */ toJSON(): { headers: { [k: string]: string; }; source: string; data: any; err: { name: string; message: string; stack?: string; cause?: unknown; type: any; code: any; }; }; /** * Generator for an `Iterable` interface over this instance. * @ignore */ [Symbol.iterator](): Generator<any, void, unknown>; } export class IPCSearchParams extends URLSearchParams { constructor(params: any, nonce?: any); } /** * @ignore */ export const primordials: any; export const ports: Map<any, any>; export class IPCMessagePort extends MessagePort { static from(options?: any): any; static create(options?: any): any; get id(): any; get started(): any; get closed(): any; set onmessage(onmessage: any); get onmessage(): any; set onmessageerror(onmessageerror: any); get onmessageerror(): any; close(purge?: boolean): void; postMessage(message: any, optionsOrTransferList: any): void; addEventListener(...args: any[]): any; removeEventListener(...args: any[]): any; dispatchEvent(event: any): any; } export class IPCMessageChannel extends MessageChannel { constructor(options?: any); get id(): any; get port1(): any; get port2(): any; get channel(): any; #private; } export default exports; import { Buffer } from "socket:buffer"; import { URL } from "socket:url/index"; import * as exports from "socket:ipc"; } declare module "socket:os/constants" { export type errno = number; /** * @typedef {number} errno * @typedef {number} signal */ /** * A container for all known "errno" constant values. * Unsupported values have a default value of `0`. */ export const errno: any; export type signal = number; /** * A container for all known "signal" constant values. * Unsupported values have a default value of `0`. */ export const signal: any; namespace _default { export { errno }; export { signal }; } export default _default; } declare module "socket:errno" { /** * Converts an `errno` code to its corresponding string message. * @param {import('./os/constants.js').errno} {code} * @return {string} */ export function toString(code: any): string; /** * Gets the code for a given 'errno' name. * @param {string|number} name * @return {errno} */ export function getCode(name: string | number): errno; /** * Gets the name for a given 'errno' code * @return {string} * @param {string|number} code */ export function getName(code: string | number): string; /** * Gets the message for a 'errno' code. * @param {number|string} code * @return {string} */ export function getMessage(code: number | string): string; /** * @typedef {import('./os/constants.js').errno} errno */ export const E2BIG: any; export const EACCES: any; export const EADDRINUSE: any; export const EADDRNOTAVAIL: any; export const EAFNOSUPPORT: any; export const EAGAIN: any; export const EALREADY: any; export const EBADF: any; export const EBADMSG: any; export const EBUSY: any; export const ECANCELED: any; export const ECHILD: any; export const ECONNABORTED: any; export const ECONNREFUSED: any; export const ECONNRESET: any; export const EDEADLK: any; export const EDESTADDRREQ: any; export const EDOM: any; export const EDQUOT: any; export const EEXIST: any; export const EFAULT: any; export const EFBIG: any; export const EHOSTUNREACH: any; export const EIDRM: any; export const EILSEQ: any; export const EINPROGRESS: any; export const EINTR: any; export const EINVAL: any; export const EIO: any; export const EISCONN: any; export const EISDIR: any; export const ELOOP: any; export const EMFILE: any; export const EMLINK: any; export const EMSGSIZE: any; export const EMULTIHOP: any; export const ENAMETOOLONG: any; export const ENETDOWN: any; export const ENETRESET: any; export const ENETUNREACH: any; export const ENFILE: any; export const ENOBUFS: any; export const ENODATA: any; export const ENODEV: any; export const ENOENT: any; export const ENOEXEC: any; export const ENOLCK: any; export const ENOLINK: any; export const ENOMEM: any; export const ENOMSG: any; export const ENOPROTOOPT: any; export const ENOSPC: any; export const ENOSR: any; export const ENOSTR: any; export const ENOSYS: any; export const ENOTCONN: any; export const ENOTDIR: any; export const ENOTEMPTY: any; export const ENOTSOCK: any; export const ENOTSUP: any; export const ENOTTY: any; export const ENXIO: any; export const EOPNOTSUPP: any; export const EOVERFLOW: any; export const EPERM: any; export const EPIPE: any; export const EPROTO: any; export const EPROTONOSUPPORT: any; export const EPROTOTYPE: any; export const ERANGE: any; export const EROFS: any; export const ESPIPE: any; export const ESRCH: any; export const ESTALE: any; export const ETIME: any; export const ETIMEDOUT: any; export const ETXTBSY: any; export const EWOULDBLOCK: any; export const EXDEV: any; export const strings: any; export { constants }; namespace _default { export { constants }; export { strings }; export { toString }; export { getCode }; export { getMessage }; } export default _default; export type errno = import("socket:os/constants").errno; import { errno as constants } from "socket:os/constants"; } declare module "socket:errors" { export default exports; export const ABORT_ERR: any; export const ENCODING_ERR: any; export const INVALID_ACCESS_ERR: any; export const INDEX_SIZE_ERR: any; export const NETWORK_ERR: any; export const NOT_ALLOWED_ERR: any; export const NOT_FOUND_ERR: any; export const NOT_SUPPORTED_ERR: any; export const OPERATION_ERR: any; export const SECURITY_ERR: any; export const TIMEOUT_ERR: any; /** * An `AbortError` is an error type thrown in an `onabort()` level 0 * event handler on an `AbortSignal` instance. */ export class AbortError extends Error { /** * The code given to an `ABORT_ERR` `DOMException` * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException} */ static get code(): any; /** * `AbortError` class constructor. * @param {AbortSignal|string} reasonOrSignal * @param {AbortSignal=} [signal] */ constructor(reason: any, signal?: AbortSignal | undefined, ...args: any[]); signal: AbortSignal; get name(): string; get code(): string; } /** * An `BadRequestError` is an error type thrown in an `onabort()` level 0 * event handler on an `BadRequestSignal` instance. */ export class BadRequestError extends Error { /** * The default code given to a `BadRequestError` */ static get code(): number; /** * `BadRequestError` class constructor. * @param {string} message * @param {number} [code] */ constructor(message: string, ...args: any[]); get name(): string; get code(): string; } /** * An `EncodingError` is an error type thrown when an internal exception * has occurred, such as in the native IPC layer. */ export class EncodingError extends Error { /** * The code given to an `ENCODING_ERR` `DOMException`. */ static get code(): any; /** * `EncodingError` class constructor. * @param {string} message * @param {number} [code] */ constructor(message: string, ...args: any[]); get name(): string; get code(): string; } /** * An error type derived from an `errno` code. */ export class ErrnoError extends Error { static get code(): string; static errno: any; /** * `ErrnoError` class constructor. * @param {import('./errno').errno|string} code */ constructor(code: import("socket:errno").errno | string, message?: any, ...args: any[]); get name(): string; get code(): number; #private; } /** * An `FinalizationRegistryCallbackError` is an error type thrown when an internal exception * has occurred, such as in the native IPC layer. */ export class FinalizationRegistryCallbackError extends Error { /** * The default code given to an `FinalizationRegistryCallbackError` */ static get code(): number; /** * `FinalizationRegistryCallbackError` class constructor. * @param {string} message * @param {number} [code] */ constructor(message: string, ...args: any[]); get name(): string; get code(): string; } /** * An `IllegalConstructorError` is an error type thrown when a constructor is * called for a class constructor when it shouldn't be. */ export class IllegalConstructorError extends TypeError { /** * The default code given to an `IllegalConstructorError` */ static get code(): number; /**