Compare commits
No commits in common. "v0.1.0-develop.1" and "v0.0.1" have entirely different histories.
v0.1.0-dev
...
v0.0.1
|
@ -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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
# [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
|
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:
|
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.1",
|
|
||||||
"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.11",
|
|
||||||
"streamx": "^2.15.1"
|
|
||||||
}
|
|
||||||
}
|
|
77
src/index.ts
77
src/index.ts
|
@ -1,77 +0,0 @@
|
||||||
import { BasePeer, Logger } from "@lumeweb/libs5";
|
|
||||||
import { URL } from "url";
|
|
||||||
import { Buffer } from "buffer";
|
|
||||||
import { Readable } from "streamx";
|
|
||||||
|
|
||||||
export default class HyperTransportPeer extends BasePeer {
|
|
||||||
private _peer: any;
|
|
||||||
private _muxer: any;
|
|
||||||
private _protocol: string;
|
|
||||||
protected _socket = new Readable();
|
|
||||||
private _pipe?: any;
|
|
||||||
|
|
||||||
constructor(options: any) {
|
|
||||||
super(options);
|
|
||||||
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.write(message);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue