Compare commits

...

69 Commits

Author SHA1 Message Date
semantic-release-bot a424678cc3 chore(release): 0.0.2-develop.23 [skip ci]
## [0.0.2-develop.23](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.22...v0.0.2-develop.23) (2023-11-17)
2023-11-17 13:53:08 +00:00
Derrick Hammer 65fad263a9
Merge remote-tracking branch 'origin/develop' into develop 2023-11-17 08:52:14 -05:00
Derrick Hammer 87961d53e1
dep: update kernel-swarm-client 2023-11-17 08:52:10 -05:00
semantic-release-bot a741c710c2 chore(release): 0.0.2-develop.22 [skip ci]
## [0.0.2-develop.22](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.21...v0.0.2-develop.22) (2023-10-13)
2023-10-13 10:49:21 +00:00
Derrick Hammer 8ad6fd20f3
Merge remote-tracking branch 'origin/develop' into develop 2023-10-13 06:48:13 -04:00
Derrick Hammer 32f02ecf61
dep: update kernel-swarm-client 2023-10-13 06:48:10 -04:00
semantic-release-bot 1faa059a4e chore(release): 0.0.2-develop.21 [skip ci]
## [0.0.2-develop.21](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.20...v0.0.2-develop.21) (2023-10-12)
2023-10-12 12:05:07 +00:00
Derrick Hammer a6e1f24dc9
Merge remote-tracking branch 'origin/develop' into develop 2023-10-12 08:03:57 -04:00
Derrick Hammer 5d0d70d674
dep: update kernel-swarm-client and libkernel 2023-10-12 08:03:53 -04:00
semantic-release-bot 600e8564ef chore(release): 0.0.2-develop.20 [skip ci]
## [0.0.2-develop.20](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.19...v0.0.2-develop.20) (2023-09-03)
2023-09-03 04:37:45 +00:00
Derrick Hammer e5f1994bb7
Merge remote-tracking branch 'origin/develop' into develop 2023-09-03 00:36:37 -04:00
Derrick Hammer 4ef5b06927
dep: update kernel-swarm-client and libkernel 2023-09-03 00:36:32 -04:00
semantic-release-bot 2a73cb9d4d chore(release): 0.0.2-develop.19 [skip ci]
## [0.0.2-develop.19](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.18...v0.0.2-develop.19) (2023-09-02)
2023-09-02 14:13:54 +00:00
Derrick Hammer e6fe6deb6f
Merge remote-tracking branch 'origin/develop' into develop 2023-09-02 10:13:01 -04:00
Derrick Hammer 50a742a5db
dep: update kernel-swarm-client 2023-09-02 10:12:58 -04:00
semantic-release-bot 571cf53d00 chore(release): 0.0.2-develop.18 [skip ci]
## [0.0.2-develop.18](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.17...v0.0.2-develop.18) (2023-09-02)
2023-09-02 13:16:25 +00:00
Derrick Hammer 1b93a0a319
Merge remote-tracking branch 'origin/develop' into develop 2023-09-02 09:15:32 -04:00
Derrick Hammer 82f4a84a1d
dep: update libkernel 2023-09-02 09:15:26 -04:00
semantic-release-bot c796a910b6 chore(release): 0.0.2-develop.17 [skip ci]
## [0.0.2-develop.17](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.16...v0.0.2-develop.17) (2023-09-02)
2023-09-02 12:37:32 +00:00
Derrick Hammer af7a76fa31
Merge remote-tracking branch 'origin/develop' into develop 2023-09-02 08:36:20 -04:00
Derrick Hammer 6d7650f63f
dep: update kernel-swarm-client 2023-09-02 08:36:14 -04:00
semantic-release-bot b5d2c712db chore(release): 0.0.2-develop.16 [skip ci]
## [0.0.2-develop.16](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.15...v0.0.2-develop.16) (2023-07-29)
2023-07-29 16:16:48 +00:00
Derrick Hammer 1dbea04663
Merge remote-tracking branch 'origin/develop' into develop 2023-07-29 12:15:58 -04:00
Derrick Hammer 79bc1b2a06
dep: update kernel-swarm-client 2023-07-29 12:15:53 -04:00
semantic-release-bot 2498abdc9e chore(release): 0.0.2-develop.15 [skip ci]
## [0.0.2-develop.15](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.14...v0.0.2-develop.15) (2023-07-24)
2023-07-24 17:37:39 +00:00
Derrick Hammer 30fb0dae4b
Merge remote-tracking branch 'origin/develop' into develop 2023-07-24 13:36:33 -04:00
Derrick Hammer 6f755a13fe
dep: update kernel-swarm-client 2023-07-24 13:36:27 -04:00
semantic-release-bot 0ab55697aa chore(release): 0.0.2-develop.14 [skip ci]
## [0.0.2-develop.14](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.13...v0.0.2-develop.14) (2023-07-23)
2023-07-23 18:42:46 +00:00
Derrick Hammer aee9a5dd10
Merge remote-tracking branch 'origin/develop' into develop 2023-07-23 14:41:51 -04:00
Derrick Hammer f8addcbab7
dep: update kernel-swarm-client 2023-07-23 14:41:48 -04:00
semantic-release-bot 083425fce8 chore(release): 0.0.2-develop.13 [skip ci]
## [0.0.2-develop.13](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.12...v0.0.2-develop.13) (2023-07-23)
2023-07-23 00:15:52 +00:00
Derrick Hammer 74a6dde625
Merge remote-tracking branch 'origin/develop' into develop 2023-07-22 20:14:32 -04:00
Derrick Hammer 47cd348363
dep: update kernel-swarm-client 2023-07-22 20:14:27 -04:00
semantic-release-bot 3d36605a54 chore(release): 0.0.2-develop.12 [skip ci]
## [0.0.2-develop.12](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.11...v0.0.2-develop.12) (2023-07-22)
2023-07-22 14:18:13 +00:00
Derrick Hammer 5cc0bc4796
Merge remote-tracking branch 'origin/develop' into develop 2023-07-22 10:17:21 -04:00
Derrick Hammer b0024d7b97
dep: update kernel-swarm-client 2023-07-22 10:17:18 -04:00
semantic-release-bot 1b96852f3e chore(release): 0.0.2-develop.11 [skip ci]
## [0.0.2-develop.11](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.10...v0.0.2-develop.11) (2023-07-22)
2023-07-22 11:22:53 +00:00
Derrick Hammer 3ac50039e3
Merge remote-tracking branch 'origin/develop' into develop 2023-07-22 07:21:38 -04:00
Derrick Hammer f60d09e461
dep: update kernel-swarm-client 2023-07-22 07:21:32 -04:00
semantic-release-bot 2e9c9c7823 chore(release): 0.0.2-develop.10 [skip ci]
## [0.0.2-develop.10](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.9...v0.0.2-develop.10) (2023-07-22)
2023-07-22 10:22:56 +00:00
Derrick Hammer 7f9db26115
Merge remote-tracking branch 'origin/develop' into develop 2023-07-22 06:21:38 -04:00
Derrick Hammer 5ec389b5f2
dep: update kernel-swarm-client 2023-07-22 06:21:34 -04:00
semantic-release-bot 163dfeede9 chore(release): 0.0.2-develop.9 [skip ci]
## [0.0.2-develop.9](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.8...v0.0.2-develop.9) (2023-07-22)
2023-07-22 01:46:34 +00:00
Derrick Hammer e309940cba
Merge remote-tracking branch 'origin/develop' into develop 2023-07-21 21:45:19 -04:00
Derrick Hammer a3ad81acf4
dep: update kernel-swarm-client 2023-07-21 21:45:14 -04:00
semantic-release-bot a3eae98da2 chore(release): 0.0.2-develop.8 [skip ci]
## [0.0.2-develop.8](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.7...v0.0.2-develop.8) (2023-07-22)
2023-07-22 00:41:35 +00:00
Derrick Hammer 14d8f46fbd
Merge remote-tracking branch 'origin/develop' into develop 2023-07-21 20:40:27 -04:00
Derrick Hammer 9a88ae2e47
dep: update kernel-swarm-client 2023-07-21 20:40:20 -04:00
semantic-release-bot 5ed715b856 chore(release): 0.0.2-develop.7 [skip ci]
## [0.0.2-develop.7](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.6...v0.0.2-develop.7) (2023-07-12)
2023-07-12 10:47:48 +00:00
Derrick Hammer 97b9c57deb
Merge remote-tracking branch 'origin/develop' into develop 2023-07-12 06:46:59 -04:00
Derrick Hammer 3dc1689bc7
dep: update deps 2023-07-12 06:46:51 -04:00
semantic-release-bot 08bacdece0 chore(release): 0.0.2-develop.6 [skip ci]
## [0.0.2-develop.6](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.5...v0.0.2-develop.6) (2023-07-08)
2023-07-08 11:37:22 +00:00
Derrick Hammer 73af092287
Merge remote-tracking branch 'origin/develop' into develop 2023-07-08 07:36:29 -04:00
Derrick Hammer b959a599dc
dep: update kernel-swarm-client 2023-07-08 07:36:26 -04:00
semantic-release-bot bd74fd69a3 chore(release): 0.0.2-develop.5 [skip ci]
## [0.0.2-develop.5](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.4...v0.0.2-develop.5) (2023-07-08)
2023-07-08 08:10:48 +00:00
Derrick Hammer 0a69d6f6df
Merge remote-tracking branch 'origin/develop' into develop 2023-07-08 04:09:33 -04:00
Derrick Hammer 8f07a95fb3
dep: update kernel-swarm-client 2023-07-08 04:09:28 -04:00
semantic-release-bot f6c41c50fa chore(release): 0.0.2-develop.4 [skip ci]
## [0.0.2-develop.4](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.3...v0.0.2-develop.4) (2023-07-05)
2023-07-05 03:17:48 +00:00
Derrick Hammer 3b16ce7d4a
Merge remote-tracking branch 'origin/develop' into develop 2023-07-04 23:16:37 -04:00
Derrick Hammer 7567aceb0d
dep: update kernel-swarm-client 2023-07-04 23:16:30 -04:00
semantic-release-bot 8c0757c24a chore(release): 0.0.2-develop.3 [skip ci]
## [0.0.2-develop.3](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.2...v0.0.2-develop.3) (2023-07-05)
2023-07-05 01:05:40 +00:00
Derrick Hammer d1c5a20b9d
Merge remote-tracking branch 'origin/develop' into develop 2023-07-04 21:04:46 -04:00
Derrick Hammer 67a8d7f8f0
dep: update kernel-swarm-client 2023-07-04 21:04:39 -04:00
semantic-release-bot 25559f7bba chore(release): 0.0.2-develop.2 [skip ci]
## [0.0.2-develop.2](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.1...v0.0.2-develop.2) (2023-07-04)
2023-07-04 15:25:37 +00:00
Derrick Hammer ec72551e0b
Merge remote-tracking branch 'origin/develop' into develop 2023-07-04 11:24:44 -04:00
Derrick Hammer 37dcdd25f2
dep: update kernel-swarm-client 2023-07-04 11:24:40 -04:00
semantic-release-bot d35f1bd871 chore(release): 0.0.2-develop.1 [skip ci]
## [0.0.2-develop.1](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.1...v0.0.2-develop.1) (2023-07-04)

### Reverts

* Revert "*add destroy method" ([10ad05f](10ad05f1da))
2023-07-04 10:32:22 +00:00
Derrick Hammer 3bd2b43b01
ci: setup 2023-07-04 06:31:07 -04:00
Derrick Hammer 20c53cd59e
refactor: switch to new sdks 2023-07-04 06:27:38 -04:00
9 changed files with 18029 additions and 288 deletions

13
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,13 @@
name: Build/Publish
on:
push:
branches:
- master
- develop
- develop-*
jobs:
main:
uses: lumeweb/github-node-deploy-workflow/.github/workflows/main.yml@master
secrets: inherit

5
.presetterrc.json Normal file
View File

@ -0,0 +1,5 @@
{
"preset": [
"@lumeweb/node-library-preset"
]
}

50
CHANGELOG.md Normal file
View File

@ -0,0 +1,50 @@
## [0.0.2-develop.23](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.22...v0.0.2-develop.23) (2023-11-17)
## [0.0.2-develop.22](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.21...v0.0.2-develop.22) (2023-10-13)
## [0.0.2-develop.21](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.20...v0.0.2-develop.21) (2023-10-12)
## [0.0.2-develop.20](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.19...v0.0.2-develop.20) (2023-09-03)
## [0.0.2-develop.19](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.18...v0.0.2-develop.19) (2023-09-02)
## [0.0.2-develop.18](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.17...v0.0.2-develop.18) (2023-09-02)
## [0.0.2-develop.17](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.16...v0.0.2-develop.17) (2023-09-02)
## [0.0.2-develop.16](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.15...v0.0.2-develop.16) (2023-07-29)
## [0.0.2-develop.15](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.14...v0.0.2-develop.15) (2023-07-24)
## [0.0.2-develop.14](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.13...v0.0.2-develop.14) (2023-07-23)
## [0.0.2-develop.13](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.12...v0.0.2-develop.13) (2023-07-23)
## [0.0.2-develop.12](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.11...v0.0.2-develop.12) (2023-07-22)
## [0.0.2-develop.11](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.10...v0.0.2-develop.11) (2023-07-22)
## [0.0.2-develop.10](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.9...v0.0.2-develop.10) (2023-07-22)
## [0.0.2-develop.9](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.8...v0.0.2-develop.9) (2023-07-22)
## [0.0.2-develop.8](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.7...v0.0.2-develop.8) (2023-07-22)
## [0.0.2-develop.7](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.6...v0.0.2-develop.7) (2023-07-12)
## [0.0.2-develop.6](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.5...v0.0.2-develop.6) (2023-07-08)
## [0.0.2-develop.5](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.4...v0.0.2-develop.5) (2023-07-08)
## [0.0.2-develop.4](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.3...v0.0.2-develop.4) (2023-07-05)
## [0.0.2-develop.3](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.2...v0.0.2-develop.3) (2023-07-05)
## [0.0.2-develop.2](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.2-develop.1...v0.0.2-develop.2) (2023-07-04)
## [0.0.2-develop.1](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/compare/v0.0.1...v0.0.2-develop.1) (2023-07-04)
### Reverts
* Revert "*add destroy method" ([10ad05f](https://git.lumeweb.com/LumeWeb/kernel-protomux-client/commit/10ad05f1dad6bf52198ab910d0da7eac51e206d3))

57
dist/index.d.ts vendored
View File

@ -1,57 +0,0 @@
import { Client } from "@lumeweb/libkernel-universal";
export default class Protomux {
private isProtomux;
constructor(stream: any);
private _stream;
get stream(): any;
static from(stream: any): any;
createChannel({ protocol, id, handshake, onopen, onclose, ondestroy, }: {
protocol: string;
id: any;
handshake: any;
onopen?: Function;
onclose?: Function;
ondestroy?: Function;
}): Promise<Channel>;
}
declare class Channel extends Client {
private protocol;
private id;
private handshake;
private onopen?;
private onclose?;
private ondestroy?;
private _created;
private _send?;
private _queue;
private _inited;
constructor(mux: Protomux, protocol: string, id: any, handshake: any, onopen?: Function, onclose?: Function, ondestroy?: Function);
private _ready;
get ready(): Promise<void>;
private _mux;
get mux(): Protomux;
private _channelId;
get channelId(): number;
open(): Promise<void>;
addMessage({ encoding, onmessage, }: {
encoding?: any;
onmessage: Function;
}): Message;
queueMessage(message: Message): Promise<void>;
private init;
destroy(error: Error): void;
}
declare class Message extends Client {
private encoding;
private onmessage;
private channel;
private _send?;
constructor({ channel, encoding, onmessage, }: {
channel: Channel;
encoding?: any;
onmessage: Function;
});
init(): Promise<void>;
send(data: any): void;
}
export {};

189
dist/index.js vendored
View File

@ -1,189 +0,0 @@
import { Client, factory } from "@lumeweb/libkernel-universal";
import { MODULE } from "@lumeweb/kernel-swarm-client";
import defer from "p-defer";
import { Buffer } from "buffer";
export default class Protomux {
isProtomux = true;
constructor(stream) {
this._stream = stream;
if (!stream.userData) {
stream.userData = this;
}
}
_stream;
get stream() {
return this._stream;
}
static from(stream) {
if (stream.userData && stream.userData.isProtomux)
return stream.userData;
if (stream.isProtomux)
return stream;
return new this(stream);
}
async createChannel({ protocol, id = null, handshake = null, onopen = undefined, onclose = undefined, ondestroy = undefined, }) {
return createChannel(this, protocol, id, handshake, onopen, onclose, ondestroy);
}
}
class Channel extends Client {
protocol;
id;
handshake;
onopen;
onclose;
ondestroy;
_created = defer();
_send;
_queue = [];
_inited = false;
constructor(mux, protocol, id, handshake, onopen, onclose, ondestroy) {
super();
this._mux = mux;
this.protocol = protocol;
this.id = id;
this.handshake = handshake;
this.onopen = onopen;
this.onclose = onclose;
this.ondestroy = ondestroy;
}
_ready = defer();
get ready() {
return this._ready.promise;
}
_mux;
get mux() {
return this._mux;
}
_channelId = -1;
get channelId() {
return this._channelId;
}
async open() {
await this.init();
await this._created;
while (this._queue.length) {
await this._queue.shift()?.init();
}
this._ready.resolve();
}
addMessage({ encoding = undefined, onmessage, }) {
return createMessage({ channel: this, encoding, onmessage });
}
async queueMessage(message) {
this._queue.push(message);
}
async init() {
if (this._inited) {
return;
}
this._inited = true;
const [update, ret] = this.connectModule("createProtomuxChannel", {
id: this._mux.stream.id,
data: {
protocol: this.protocol,
id: this.id,
handshake: this.handshake,
onopen: !!this.onopen,
onclose: !!this.onclose,
ondestroy: !!this.ondestroy,
},
}, (data) => {
switch (data.action) {
case "onopen":
this.onopen?.(...data.args);
break;
case "onclose":
this.onclose?.(...data.args);
break;
case "ondestroy":
this.ondestroy?.(...data.args);
break;
default:
this._channelId = data;
this._created.resolve();
}
});
this._send = update;
ret.catch((e) => this._created.reject(e));
return this._created.promise;
}
destroy(error) {
this._send?.({ action: "destroy", args: [error] });
}
}
class Message extends Client {
encoding;
onmessage;
channel;
_send;
constructor({ channel, encoding = undefined, onmessage = () => { }, }) {
super();
this.channel = channel;
this.encoding = encoding;
this.onmessage = onmessage;
this.channel.queueMessage(this);
}
async init() {
const created = defer();
await this.loadLibs(MODULE);
const [update] = this.connectModule("createProtomuxMessage", {
id: this.channel.mux.stream.id,
channelId: this.channel.channelId,
data: {
encoding: !!this.encoding,
onmessage: !!this.onmessage,
},
}, async (data) => {
if (data.args) {
data.args = data.args.filter((arg) => {
if (arg instanceof Uint8Array) {
return Buffer.from(arg);
}
return arg;
});
}
if (data?.args && data?.args[0]?.buffer instanceof Uint8Array) {
data.args[0].buffer = Buffer.from(data.args[0].buffer);
}
switch (data.action) {
case "encode":
update({
id: data.id,
action: "encode",
args: [await this.encoding.encode?.(...data.args), data.args[0]],
});
break;
case "decode":
update({
id: data.id,
action: "decode",
args: [await this.encoding.decode?.(...data.args), data.args[0]],
});
break;
case "preencode":
update({
id: data.id,
action: "preencode",
args: [
await this.encoding.preencode?.(...data.args),
data.args[0],
],
});
break;
case "onmessage":
this.onmessage?.(...data.args);
break;
case "created":
created.resolve();
break;
}
});
this._send = update;
return created.promise;
}
send(data) {
this._send?.({ action: "send", args: [data] });
}
}
const createChannel = factory(Channel, MODULE);
const createMessage = factory(Message, MODULE);

17917
npm-shrinkwrap.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,32 @@
{ {
"name": "@lumeweb/kernel-protomux-client", "name": "@lumeweb/kernel-protomux-client",
"version": "0.1.0", "version": "0.0.2-develop.23",
"main": "dist/index.js", "type": "module",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "gitea@git.lumeweb.com:LumeWeb/kernel-protomux-client.git"
},
"readme": "ERROR: No README data found!",
"scripts": {
"prepare": "presetter bootstrap",
"build": "run build",
"semantic-release": "semantic-release"
},
"devDependencies": {
"@lumeweb/node-library-preset": "^0.2.7",
"presetter": "*"
},
"dependencies": { "dependencies": {
"@lumeweb/kernel-swarm-client": "git+https://git.lumeweb.com/LumeWeb/kernel-swarm-client.git", "@lumeweb/kernel-swarm-client": "^0.1.0-develop.13",
"@lumeweb/libkernel-universal": "git+https://git.lumeweb.com/LumeWeb/libkernel-universal.git", "@lumeweb/libkernel": "^0.1.0-develop.68",
"b4a": "^1.6.3",
"buffer": "^6.0.3", "buffer": "^6.0.3",
"p-defer": "^4.0.0" "p-defer": "^4.0.0"
}, },
"devDependencies": { "files": [
"@types/b4a": "^1.6.0", "lib"
"prettier": "^2.8.7", ],
"typescript": "^5.0.4" "publishConfig": {
"access": "public"
} }
} }

View File

@ -1,9 +1,8 @@
import { Client, factory } from "@lumeweb/libkernel-universal"; import { Client, factory } from "@lumeweb/libkernel/module";
import { MODULE } from "@lumeweb/kernel-swarm-client"; import { MODULE } from "@lumeweb/kernel-swarm-client";
import defer from "p-defer"; import defer from "p-defer";
import b4a from "b4a";
import { Buffer } from "buffer"; import { Buffer } from "buffer";
export default class Protomux { export default class Protomux {
@ -50,7 +49,7 @@ export default class Protomux {
handshake, handshake,
onopen, onopen,
onclose, onclose,
ondestroy ondestroy,
); );
} }
} }
@ -68,15 +67,16 @@ class Channel extends Client {
private _inited = false; private _inited = false;
constructor( constructor(
module: string,
mux: Protomux, mux: Protomux,
protocol: string, protocol: string,
id: any, id: any,
handshake: any, handshake: any,
onopen?: Function, onopen?: Function,
onclose?: Function, onclose?: Function,
ondestroy?: Function ondestroy?: Function,
) { ) {
super(); super(module);
this._mux = mux; this._mux = mux;
this.protocol = protocol; this.protocol = protocol;
this.id = id; this.id = id;
@ -164,7 +164,7 @@ class Channel extends Client {
this._channelId = data; this._channelId = data;
this._created.resolve(); this._created.resolve();
} }
} },
); );
this._send = update; this._send = update;
@ -185,7 +185,9 @@ class Message extends Client {
private _send?: (data?: any) => void; private _send?: (data?: any) => void;
constructor({ constructor(
module: string,
{
channel, channel,
encoding = undefined, encoding = undefined,
onmessage = () => {}, onmessage = () => {},
@ -193,8 +195,9 @@ class Message extends Client {
channel: Channel; channel: Channel;
encoding?: any; encoding?: any;
onmessage: Function; onmessage: Function;
}) { },
super(); ) {
super(module);
this.channel = channel; this.channel = channel;
this.encoding = encoding; this.encoding = encoding;
this.onmessage = onmessage; this.onmessage = onmessage;
@ -203,9 +206,6 @@ class Message extends Client {
async init(): Promise<void> { async init(): Promise<void> {
const created = defer(); const created = defer();
await this.loadLibs(MODULE);
const [update] = this.connectModule( const [update] = this.connectModule(
"createProtomuxMessage", "createProtomuxMessage",
{ {
@ -262,7 +262,7 @@ class Message extends Client {
created.resolve(); created.resolve();
break; break;
} }
} },
); );
this._send = update; this._send = update;

View File

@ -1,13 +0,0 @@
{
"compilerOptions": {
"target": "esnext",
"declaration": true,
"moduleResolution": "node",
"outDir": "./dist",
"strict": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/*"]
}