Compare commits
No commits in common. "develop" and "master" have entirely different histories.
|
@ -1,13 +0,0 @@
|
|||
name: Build/Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- develop-*
|
||||
|
||||
jobs:
|
||||
main:
|
||||
uses: lumeweb/github-node-deploy-workflow/.github/workflows/main.yml@master
|
||||
secrets: inherit
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"preset": [
|
||||
"@lumeweb/node-library-preset"
|
||||
],
|
||||
"config": {
|
||||
"tsconfig": {
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "node"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
71
CHANGELOG.md
71
CHANGELOG.md
|
@ -1,71 +0,0 @@
|
|||
# [0.1.0-develop.21](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.20...v0.1.0-develop.21) (2023-11-17)
|
||||
|
||||
# [0.1.0-develop.20](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.19...v0.1.0-develop.20) (2023-11-17)
|
||||
|
||||
# [0.1.0-develop.19](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.18...v0.1.0-develop.19) (2023-09-04)
|
||||
|
||||
# [0.1.0-develop.18](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.17...v0.1.0-develop.18) (2023-09-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* implement end ([d4d6e38](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/commit/d4d6e38eb1e4fd1fa00a974f279ea49ecb4703b3))
|
||||
|
||||
# [0.1.0-develop.17](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.16...v0.1.0-develop.17) (2023-09-01)
|
||||
|
||||
# [0.1.0-develop.16](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.15...v0.1.0-develop.16) (2023-09-01)
|
||||
|
||||
# [0.1.0-develop.15](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/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-transport-hyper/compare/v0.1.0-develop.13...v0.1.0-develop.14) (2023-09-01)
|
||||
|
||||
# [0.1.0-develop.13](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.12...v0.1.0-develop.13) (2023-09-01)
|
||||
|
||||
# [0.1.0-develop.12](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.11...v0.1.0-develop.12) (2023-09-01)
|
||||
|
||||
# [0.1.0-develop.11](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.10...v0.1.0-develop.11) (2023-09-01)
|
||||
|
||||
# [0.1.0-develop.10](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.9...v0.1.0-develop.10) (2023-09-01)
|
||||
|
||||
# [0.1.0-develop.9](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.8...v0.1.0-develop.9) (2023-09-01)
|
||||
|
||||
# [0.1.0-develop.8](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.7...v0.1.0-develop.8) (2023-09-01)
|
||||
|
||||
# [0.1.0-develop.7](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.6...v0.1.0-develop.7) (2023-09-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* use send not write ([940d768](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/commit/940d768d5babb65b0ca268fac20c193debf2d65d))
|
||||
|
||||
# [0.1.0-develop.6](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.5...v0.1.0-develop.6) (2023-08-31)
|
||||
|
||||
# [0.1.0-develop.5](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.4...v0.1.0-develop.5) (2023-08-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* change approach to make socket optional ([d22c757](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/commit/d22c757c520e38f71ef0a303a3e116013555d01b))
|
||||
|
||||
# [0.1.0-develop.4](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.3...v0.1.0-develop.4) (2023-08-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* make socket optional since we define it ourselves ([89e7d45](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/commit/89e7d452cbbf55271a4bb928d0cd02b1e03fe6ab))
|
||||
|
||||
# [0.1.0-develop.3](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.2...v0.1.0-develop.3) (2023-08-31)
|
||||
|
||||
# [0.1.0-develop.2](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.1.0-develop.1...v0.1.0-develop.2) (2023-08-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* set constructor typing ([331e5ad](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/commit/331e5adbf7b91ca01d44b3647442ad056a50957e))
|
||||
|
||||
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/compare/v0.0.1...v0.1.0-develop.1) (2023-08-31)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* initial version ([53ddfc0](https://git.lumeweb.com/LumeWeb/libs5-transport-hyper/commit/53ddfc03c918aedbb57734bed84f7fcc93ef2520))
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2023 Hammer Technologies LLC
|
||||
Copyright (c) 2023 LumeWeb
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
30
package.json
30
package.json
|
@ -1,30 +0,0 @@
|
|||
{
|
||||
"name": "@lumeweb/libs5-transport-hyper",
|
||||
"version": "0.1.0-develop.21",
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "gitea@git.lumeweb.com:LumeWeb/libs5-transport-hyper.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@lumeweb/node-library-preset": "^0.2.7",
|
||||
"presetter": "*"
|
||||
},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"scripts": {
|
||||
"prepare": "presetter bootstrap",
|
||||
"build": "run build",
|
||||
"semantic-release": "semantic-release"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"dependencies": {
|
||||
"@lumeweb/libs5": "^0.1.0-develop.61",
|
||||
"streamx": "^2.15.1"
|
||||
}
|
||||
}
|
93
src/index.ts
93
src/index.ts
|
@ -1,93 +0,0 @@
|
|||
import { BasePeer, Logger, PeerConstructorOptions } from "@lumeweb/libs5";
|
||||
import { URL } from "url";
|
||||
import { Buffer } from "buffer";
|
||||
import { Readable } from "streamx";
|
||||
|
||||
type OmitSocket<T> = Omit<T, "socket">;
|
||||
|
||||
export default class HyperTransportPeer extends BasePeer {
|
||||
private _peer: any;
|
||||
private _muxer: any;
|
||||
private _protocol: string;
|
||||
protected _socket = new Readable();
|
||||
private _pipe?: any;
|
||||
|
||||
constructor(
|
||||
options: OmitSocket<PeerConstructorOptions> & {
|
||||
peer: any;
|
||||
muxer: any;
|
||||
protocol: string;
|
||||
},
|
||||
) {
|
||||
super({
|
||||
...options,
|
||||
socket: undefined,
|
||||
});
|
||||
const { peer, muxer, protocol } = options;
|
||||
this._peer = peer;
|
||||
this._muxer = muxer;
|
||||
this._protocol = protocol;
|
||||
}
|
||||
|
||||
public async init() {
|
||||
const channel = await this._muxer.createChannel({
|
||||
protocol: this._protocol,
|
||||
});
|
||||
|
||||
const self = this;
|
||||
|
||||
this._pipe = await channel.addMessage({
|
||||
async onmessage(m) {
|
||||
if (m instanceof Uint8Array) {
|
||||
m = Buffer.from(m);
|
||||
}
|
||||
|
||||
self._socket.push(m);
|
||||
},
|
||||
});
|
||||
|
||||
await channel.open();
|
||||
}
|
||||
|
||||
public static async connect(uri: URL): Promise<any> {
|
||||
return Promise.reject("not supported");
|
||||
}
|
||||
|
||||
listenForMessages(
|
||||
callback: (event: any) => Promise<void>,
|
||||
{
|
||||
onDone,
|
||||
onError,
|
||||
logger,
|
||||
}: {
|
||||
onDone?: any;
|
||||
onError?: (...args: any[]) => void;
|
||||
logger: Logger;
|
||||
},
|
||||
): void {
|
||||
this._socket.on("data", async (data: Buffer) => {
|
||||
await callback(data);
|
||||
});
|
||||
|
||||
if (onDone) {
|
||||
this._socket.on("end", onDone);
|
||||
}
|
||||
|
||||
if (onError) {
|
||||
this._socket.on("error", onError);
|
||||
}
|
||||
}
|
||||
|
||||
renderLocationUri(): string {
|
||||
return "Hypercore client";
|
||||
}
|
||||
|
||||
sendMessage(message: Uint8Array): void {
|
||||
this._pipe.send(message);
|
||||
}
|
||||
|
||||
end(): void {
|
||||
this._pipe.end();
|
||||
this._socket.end();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue