@mercuryworkshop/bare-mux
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

Bare-Mux

A system for managing http transports in a project such as Ultraviolet.

Written to make the job of creating new standards for transporting http data seamless.

Implements the TompHTTP Bare client interface in a modular way.

Specifically, this is what allows proxies such as Nebula to switch HTTP transports seamlessly.

A transport is a module that implements the BareTransport interface.

export interface BareTransport {
  init: () => Promise<void>;
  ready: boolean;
  connect: (
    url: URL,
    origin: string,
    protocols: string[],
    requestHeaders: BareHeaders,
    onopen: (protocol: string) => void,
    onmessage: (data: Blob | ArrayBuffer | string) => void,
    onclose: (code: number, reason: string) => void,
    onerror: (error: string) => void,
  ) => (data: Blob | ArrayBuffer | string) => void;

  request: (
    remote: URL,
    method: string,
    body: BodyInit | null,
    headers: BareHeaders,
    signal: AbortSignal | undefined
  ) => Promise<TransferrableResponse>;

  meta: () => BareMeta
}

Examples of transports include EpoxyTransport, CurlTransport, and Bare-Client.

To switch between transports, use the SetTransport function.

import { SetTransport } from '@mercuryworkshop/bare-mux';

SetTransport("EpxMod.EpoxyClient", { wisp: "wss://wisp.mercurywork.shop" });
SetTransport("BareMod.BareClient", "https://some-bare-server.com" });

If not using a bundler, include the bare.cjs file in releases and call BareMux.SetTransport.

Readme

Keywords

none

Package Sidebar

Install

npm i @mercuryworkshop/bare-mux

Weekly Downloads

1,179

Version

1.0.9

License

none

Unpacked Size

108 kB

Total Files

14

Last publish

Collaborators

  • ading2210
  • programmerin-wonderland
  • r58playz
  • percslol
  • coolelectronics