Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mercuryworkshop/bare-mux

Package Overview
Dependencies
Maintainers
0
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mercuryworkshop/bare-mux - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

4

dist/client.d.ts

@@ -58,3 +58,3 @@ import { BareHeaders, BareTransport } from './baretypes';

worker: WorkerConnection;
constructor(workerPath: string);
constructor(worker: string | Promise<MessagePort> | MessagePort);
getTransport(): Promise<string>;

@@ -71,5 +71,5 @@ setTransport(path: string, options: any[], transferables?: Transferable[]): Promise<void>;

*/
constructor(worker?: string | MessagePort);
constructor(worker?: string | Promise<MessagePort> | MessagePort);
createWebSocket(remote: string | URL, protocols?: string | string[] | undefined, webSocketImpl?: WebSocketImpl, requestHeaders?: BareHeaders, arrayBufferImpl?: ArrayBuffer): WebSocket;
fetch(url: string | URL, init?: RequestInit): Promise<BareResponseFetch>;
}

@@ -40,5 +40,5 @@ import { BareHeaders, TransferrableResponse } from "./baretypes";

workerPath: string;
constructor(worker?: string | MessagePort);
constructor(worker?: string | Promise<MessagePort> | MessagePort);
createChannel(workerPath?: string, inInit?: boolean): void;
sendMessage(message: WorkerMessage, transferable?: Transferable[]): Promise<WorkerResponse>;
}

@@ -36,3 +36,6 @@ (function (global, factory) {

});
const promise = Promise.race([Promise.any(promises), new Promise((_, reject) => setTimeout(reject, 1000, new TypeError("timeout")))]);
const promise = Promise.race([
Promise.any(promises),
new Promise((_, reject) => setTimeout(reject, 1000, new TypeError("timeout")))
]);
try {

@@ -109,3 +112,3 @@ return await promise;

this.channel = new BroadcastChannel("bare-mux");
if (worker instanceof MessagePort) {
if (worker instanceof MessagePort || worker instanceof Promise) {
this.port = worker;

@@ -242,4 +245,4 @@ }

class BareMuxConnection {
constructor(workerPath) {
this.worker = new WorkerConnection(workerPath);
constructor(worker) {
this.worker = new WorkerConnection(worker);
}

@@ -246,0 +249,0 @@ async getTransport() {

{
"name": "@mercuryworkshop/bare-mux",
"version": "2.0.4",
"version": "2.0.5",
"description": "",

@@ -5,0 +5,0 @@ "type": "module",

@@ -1,4 +0,5 @@

# Bare-Mux
# bare-mux
<a href="https://www.npmjs.com/package/@mercuryworkshop/bare-mux"><img src="https://img.shields.io/npm/v/@mercuryworkshop/bare-mux.svg?maxAge=3600" alt="npm version" /></a>
A system for managing http transports in a project such as [Ultraviolet](https://github.com/Titaniumnetwork-dev/Ultraviolet).
A system for managing http transports in a project such as [Ultraviolet](https://github.com/Titaniumnetwork-dev/Ultraviolet) and [Scramjet](https://github.com/MercuryWorkshop/Scramjet).

@@ -38,7 +39,10 @@ Written to make the job of creating new standards for transporting http data seamless.

```
A guide to making a transport can be found [here](./documentation/Transport.md).
## Upgrading
A guide for updating from v1 to v2 can be found [here](https://github.com/MercuryWorkshop/bare-mux/blob/master/documentation/Upgrading.md).
A guide for updating from v1 to v2 can be found [here](./documentation/Upgrading.md).
## Older bare-mux versions
### Older bare-mux versions

@@ -55,3 +59,4 @@ Starting from v2, bare-mux uses [SharedWorkers](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker) to provide stability and improve on resource usage.

Examples of transports include [EpoxyTransport](https://github.com/MercuryWorkshop/EpoxyTransport), [CurlTransport](https://github.com/MercuryWorkshop/CurlTransport), and [Bare-Client](https://github.com/MercuryWorkshop/Bare-as-module3).
## Usage
Examples of transports include [EpoxyTransport](https://github.com/MercuryWorkshop/EpoxyTransport), [CurlTransport](https://github.com/MercuryWorkshop/CurlTransport), and [Bare-Client](https://github.com/MercuryWorkshop/Bare-as-module3).

@@ -63,7 +68,9 @@ Here is an example of using bare-mux:

const conn = new BareMuxConnection("/bare-mux/worker.js");
// Set Bare-Client transport
// If your transport is an ES module and exports the class as the default export
await conn.setTransport("/bare-mux/transport-module.js", ["arg1", "ws://localhost:4000"]);
await conn.setTransport("/path/to/transport/index.mjs", ["arg1", { wisp: "wss://wisp.mercurywork.shop" }, "arg3"]);
// Epoxy Client as an example
await conn.setTransport("/epoxy/index.mjs", [{ wisp: "wss://wisp.mercurywork.shop/" }]);
```
```js
/// As a proxy developer

@@ -77,12 +84,1 @@ import { BareClient } from "@mercuryworkshop/bare-mux";

```
## WebWorker support
Due to limitations in browsers, there is no way for bare-mux to get a connection to the bare-mux SharedWorker while inside a WebWorker. Proxies that use bare-mux must manually pass in a MessagePort to the SharedWorker to be able to use BareClient in a WebWorker.
```js
const connection = new Ultraviolet.BareMuxConnection();
let port = connection.getInnerPort();
// this could be a promise, but right now it's only a promise when called inside a service worker
if (port instanceof Promise) port = await port;
// ... transfer it to worker ...
this.bareClient = new BareClient(port)
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc