Skip to content

Commit

Permalink
Fix links (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-nagy committed Dec 27, 2023
1 parent 2e810a0 commit aea785b
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 93 deletions.
108 changes: 70 additions & 38 deletions packages/browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,24 @@ The browser package contains APIs designed to work in the browser.
npm add @daniel-nagy/transporter @daniel-nagy/transporter-browser
```

Transporter is distributed as ES modules. Transporter may also be imported directly in the browser from a URL.
Transporter is distributed as ES modules.

Transporter may also be imported directly in the browser from a URL. For example,

```html
<script type="importmap">
{
"imports": {
"@daniel-nagy/transporter/": "https://unpkg.com/@daniel-nagy/transporter@1.0.0-beta.3/build/",
"@daniel-nagy/transporter-browser/": "https://unpkg.com/@daniel-nagy/transporter-browser@1.0.0-beta.3/build/"
}
}
</script>
<script type="module">
import * as BrowserServer from "@daniel-nagy/transporter-browser/BrowserServer.js";
import * as Session from "@daniel-nagy/transporter/Session.js";
</script>
```

## API

Expand All @@ -16,10 +33,10 @@ The browser package contains the following modules.
- [BrowserClient](#BrowserClient)
- [BrowserRequest](#BrowserRequest)
- [BrowserResponse](#BrowserResponse)
- [BrowserServer](#MessaBrowserServerge)
- [BrowserServer](#BrowserServer)
- [BrowserSocket](#BrowserSocket)
- [BrowserSocket.Message](#BrowserSocket.Message)
- [BrowserSocket.State](#BrowserSocket.State)
- [BrowserSocket.Message](#BrowserSocketMessage)
- [BrowserSocket.State](#BrowserSocketState)
- [BrowserSocketServer](#BrowserSocketServer)
- [StructuredCloneable](#StructuredCloneable)

Expand All @@ -31,13 +48,13 @@ A `BroadcastSubject` can be used to synchronize state between same-origin browsi

###### Types

- [BroadcastSubject](#BroadcastSubject)
- [BroadcastSubject](#BroadcastSubject_BroadcastSubject)

###### Constructors

- [fromChannel](#FromChannel)

#### BroadcastSubject
<h4 id="BroadcastSubject_BroadcastSubject">BroadcastSubject</h4>

<sup>_Type_</sup>

Expand Down Expand Up @@ -75,7 +92,7 @@ An interface for making requests to a browsing context or worker.

###### Types

- [BrowserClient](#BrowserClient)
- [BrowserClient](#BrowserClient_BrowserClient)
- [Options](#Options)

###### Constructors
Expand All @@ -84,9 +101,9 @@ An interface for making requests to a browsing context or worker.

###### Methods

- [fetch](Fetch)
- [fetch](#Fetch)

#### BrowserClient
<h4 id="BrowserClient_BrowserClient">BrowserClient</h4>

<sup>_Type_</sup>

Expand Down Expand Up @@ -272,8 +289,8 @@ A `BrowserServer` provides request/response semantics on top of `postMessage`. I

###### Types

- [BrowserServer](#BrowserServer)
- [Options](#Options)
- [BrowserServer](#BrowserServer_BrowserServer)
- [Options](#BrowserServer_Options)
- [RequestHandler](#RequestHandler)
- [State](#State)

Expand All @@ -285,7 +302,7 @@ A `BrowserServer` provides request/response semantics on top of `postMessage`. I

- [stop](#Stop)

#### BrowserServer
<h4 id="BrowserServer_BrowserServer">BrowserServer</h4>

<sup>_Type_</Sup>

Expand All @@ -301,7 +318,7 @@ class BrowserServer {

A `BrowserServer` listens for incoming requests from clients.

#### Options
<h4 id="BrowserServer_Options">Options</h4>

<sup>_Type_</sup>

Expand Down Expand Up @@ -404,12 +421,12 @@ Provides a socket API on top of `postMessage` that is similar to the WebSocket A

###### Types

- [BrowserSocket](#BrowserSocket)
- [BrowserSocket](#BrowserSocket_BrowserSocket)
- [ConnectionError](#ConnectionError)
- [ConnectTimeoutError](#ConnectTimeoutError)
- [DisconnectTimeoutError](#DisconnectTimeoutError)
- [HeartbeatTimeoutError](#HeartbeatTimeoutError)
- [Options](#Options)
- [Options](#BrowserSocket_Options)
- [WindowOptions](#WindowOptions)

###### Constructors
Expand All @@ -422,7 +439,7 @@ Provides a socket API on top of `postMessage` that is similar to the WebSocket A
- [ping](#Ping)
- [send](#Send)

#### BrowserSocket
<h4 id="BrowserSocket_BrowserSocket">BrowserSocket</h4>

<sup>_Type_</sup>

Expand Down Expand Up @@ -502,7 +519,7 @@ class HeartbeatTimeoutError extends Error {}

Used to indicate that a response to a health-check was not received in the allotted time.

#### Options
<h4 id="BrowserSocket_Options">Options</h4>

<sup>_Type_</sup>

Expand Down Expand Up @@ -646,12 +663,12 @@ Internal messages to facilitate the socket API. These messages are filtered from

###### Types

- [Connect](#Connect)
- [Connect](#Message_Connect)
- [Connected](#Connected)
- [Disconnect](#Disconnect)
- [Disconnected](#Disconnected)
- [Message](#Message)
- [Ping](#Ping)
- [Ping](#Message_Ping)
- [Pong](#Pong)
- [Type](#Type)

Expand All @@ -661,7 +678,7 @@ Internal messages to facilitate the socket API. These messages are filtered from
- [isType](#IsType)
- [typeOf](#typeOf)

#### Connect
<h4 id="Message_Connect">Connect</h4>

<sup>_Type_</sup>

Expand Down Expand Up @@ -726,7 +743,7 @@ export type Message =

A variant type for the different types of messages.

#### Ping
<h4 id="Message_Ping">Ping</h4>

<sup>_Type_</sup>

Expand Down Expand Up @@ -819,10 +836,10 @@ A socket's state.

- [Closed](#Closed)
- [Closing](#Closing)
- [Connected](#Connected)
- [Connected](#State_Connected)
- [Connecting](#Connecting)
- [State](#State)
- [Type](#Type)
- [State](#State_State)
- [Type](#State_Type)

#### Closed

Expand Down Expand Up @@ -850,7 +867,7 @@ type Closing<E> = {

The socket is closing, possibly with an error.

#### Connected
<h4 id="State_Connected">Connected</h4>

<sup>_Type_</sup>

Expand All @@ -874,7 +891,7 @@ type Connecting = {

The socket is connecting.

#### State
<h4 id="State_State">State</h4>

<sup>_Type_</sup>

Expand All @@ -888,6 +905,21 @@ type State =

A variant type for the different socket states.

<h4 id="State_Type">Type</h4>

<sup>_Type_</sup>

```ts
enum Type {
Connecting = "Connecting",
Connected = "Connected",
Closing = "Closing",
Closed = "Closed"
}
```

An enumerable of the different socket states.

### BrowserSocketServer

<sup>_Module_</sup>
Expand All @@ -896,20 +928,20 @@ A `BrowserSocketServer` listens for socket connect requests. When a request is r

###### Types

- [BrowserSocketServer](#BrowserSocketServer)
- [Options](#Options)
- [BrowserSocketServer](#BrowserSocketServer_BrowserSocketServer)
- [Options](#BrowserSocketServer_Options)
- [SocketOptions](#SocketOptions)
- [State](#State)
- [State](#BrowserSocketServer_State)

###### Constructors

- [listen](#Listen)
- [listen](#BrowserSocketServer_Listen)

###### Methods

- [stop](#Stop)
- [stop](#BrowserSocketServer_Stop)

#### BrowserSocketServer
<h4 id="BrowserSocketServer_BrowserSocketServer">BrowserSocketServer</h4>

<sup>_Type_</sup>

Expand All @@ -925,7 +957,7 @@ class BrowserSocketServer {

Creates socket connections as requests come in.

#### Options
<h4 id="BrowserSocketServer_Options">Options</h4>

<sup>_Type_</sup>

Expand Down Expand Up @@ -963,7 +995,7 @@ type SocketOptions = {

Options forwarded to the `BrowserSocket` when it is created.

#### State
<h4 id="BrowserSocketServer_State">State</h4>

<sup>_Type_</sup>

Expand All @@ -976,7 +1008,7 @@ enum State {

An enumerable of the different server states.

#### Listen
<h4 id="BrowserSocketServer_Listen">Listen</h4>

<sup>_Constructor_</sup>

Expand All @@ -995,7 +1027,7 @@ const server = BrowserSocketServer.listen();
server.connect.subscribe((socket) => socket.send("👋"));
```

#### Stop
<h4 id="BrowserSocketServer_Stop">Stop</h4>

<sup>_Method_</sup>

Expand All @@ -1022,10 +1054,10 @@ A `StructuredCloneable` type can be passed between processes in the browser.

###### Types

- [StructuredCloneable](#StructuredCloneable)
- [StructuredCloneable](#StructuredCloneable_StructuredCloneable)
- [TypedArray](#TypedArray)

#### StructuredCloneable
<h4 id="StructuredCloneable_StructuredCloneable">StructuredCloneable</h4>

<sup>_Type_</sup>

Expand Down
Loading

0 comments on commit aea785b

Please sign in to comment.