A system for managing http transports in a project such as Ultraviolet.
Find a file
CoolElectronics b678854acd
docs
2024-03-03 21:15:33 -05:00
dist fix ready behavior 2024-03-03 17:38:12 -05:00
lib add static dir thingy 2024-03-03 19:44:28 -05:00
src fix ready behavior 2024-03-03 17:38:12 -05:00
.gitignore gyghhhhhhhh 2024-02-09 23:39:25 -05:00
index.js gyghhhhhhhh 2024-02-09 23:39:25 -05:00
LICENSE docs 2024-03-03 21:15:33 -05:00
package.json include lib/ 2024-03-03 19:58:17 -05:00
README.md docs 2024-03-03 21:15:33 -05:00
rollup.config.js gyatt 2024-02-11 20:53:00 -05:00
tsconfig.json gyghhhhhhhh 2024-02-09 23:39:25 -05:00

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", "wss://some-bare-server.com" });

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