Compare commits
3 Commits
v0.1.0-dev
...
v0.1.0-dev
Author | SHA1 | Date |
---|---|---|
semantic-release-bot | eeb8a816a0 | |
Derrick Hammer | f81f170ee9 | |
Derrick Hammer | 0a153379c8 |
|
@ -1,3 +1,10 @@
|
||||||
|
# [0.1.0-develop.16](https://git.lumeweb.com/LumeWeb/libs5/compare/v0.1.0-develop.15...v0.1.0-develop.16) (2023-09-01)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add support for browser WS by checking if we are in node ([0a15337](https://git.lumeweb.com/LumeWeb/libs5/commit/0a153379c87ebbee8c7d7b3015fe4c1b77f379ca))
|
||||||
|
|
||||||
# [0.1.0-develop.15](https://git.lumeweb.com/LumeWeb/libs5/compare/v0.1.0-develop.14...v0.1.0-develop.15) (2023-09-01)
|
# [0.1.0-develop.15](https://git.lumeweb.com/LumeWeb/libs5/compare/v0.1.0-develop.14...v0.1.0-develop.15) (2023-09-01)
|
||||||
|
|
||||||
# [0.1.0-develop.14](https://git.lumeweb.com/LumeWeb/libs5/compare/v0.1.0-develop.13...v0.1.0-develop.14) (2023-08-31)
|
# [0.1.0-develop.14](https://git.lumeweb.com/LumeWeb/libs5/compare/v0.1.0-develop.13...v0.1.0-develop.14) (2023-08-31)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@lumeweb/libs5",
|
"name": "@lumeweb/libs5",
|
||||||
"version": "0.1.0-develop.15",
|
"version": "0.1.0-develop.16",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@lumeweb/libs5",
|
"name": "@lumeweb/libs5",
|
||||||
"version": "0.1.0-develop.15",
|
"version": "0.1.0-develop.16",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@noble/curves": "^1.1.0",
|
"@noble/curves": "^1.1.0",
|
||||||
"@noble/hashes": "^1.3.1",
|
"@noble/hashes": "^1.3.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lumeweb/libs5",
|
"name": "@lumeweb/libs5",
|
||||||
"version": "0.1.0-develop.15",
|
"version": "0.1.0-develop.16",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { Logger, Peer } from "../types.js";
|
import { Logger, Peer } from "../types.js";
|
||||||
import NodeId from "../nodeId.js";
|
|
||||||
import { URL } from "url";
|
import { URL } from "url";
|
||||||
import { WebSocket } from "ws";
|
import * as WS from "ws";
|
||||||
import { BasePeer } from "#transports/base.js";
|
import { BasePeer } from "#transports/base.js";
|
||||||
|
import isNode from "detect-node";
|
||||||
|
|
||||||
export class WebSocketPeer extends BasePeer implements Peer {
|
export class WebSocketPeer extends BasePeer implements Peer {
|
||||||
sendMessage(message: Uint8Array): void {
|
sendMessage(message: Uint8Array): void {
|
||||||
|
@ -39,7 +39,7 @@ export class WebSocketPeer extends BasePeer implements Peer {
|
||||||
|
|
||||||
public static async connect(uri: URL): Promise<WebSocket> {
|
public static async connect(uri: URL): Promise<WebSocket> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const socket = new WebSocket(uri);
|
const socket = isNode ? new WS.WebSocket() : new WebSocket(uri);
|
||||||
socket.addEventListener("open", () => {
|
socket.addEventListener("open", () => {
|
||||||
resolve(socket);
|
resolve(socket);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue