Compare commits
60 Commits
Author | SHA1 | Date |
---|---|---|
semantic-release-bot | acef9c9989 | |
Derrick Hammer | 46cdabf0cb | |
Derrick Hammer | 9a6e6f337b | |
semantic-release-bot | 7f6da3a721 | |
Derrick Hammer | 096ef18940 | |
Derrick Hammer | 6d0c208e71 | |
semantic-release-bot | 9f6a7db502 | |
Derrick Hammer | 28c99db8e7 | |
Derrick Hammer | dde0708a90 | |
semantic-release-bot | 2f7e06e16f | |
Derrick Hammer | 7c0fafab4a | |
Derrick Hammer | 683f761d0a | |
semantic-release-bot | a52e1e24bb | |
Derrick Hammer | 7ccd0b3c89 | |
Derrick Hammer | 36b42578d1 | |
semantic-release-bot | a71c1b0bea | |
Derrick Hammer | 84aef2c751 | |
Derrick Hammer | 77e9324e97 | |
semantic-release-bot | 54e89b6525 | |
Derrick Hammer | 5671c775d3 | |
Derrick Hammer | 6223f8cda2 | |
semantic-release-bot | 2a6b52386f | |
Derrick Hammer | 5e097b1fb3 | |
Derrick Hammer | b711ae4625 | |
semantic-release-bot | 271609cd83 | |
Derrick Hammer | d73cf9b074 | |
Derrick Hammer | f7bbb6ece4 | |
semantic-release-bot | fca2025c3f | |
Derrick Hammer | 4aaa5c2306 | |
Derrick Hammer | ac235131ad | |
semantic-release-bot | 10c5fbb9d5 | |
Derrick Hammer | 7689890dcc | |
Derrick Hammer | b138ac0cc6 | |
semantic-release-bot | efd67b4b30 | |
Derrick Hammer | 15ba1d8d46 | |
Derrick Hammer | 85ff008ed6 | |
semantic-release-bot | e122c5608f | |
Derrick Hammer | b2d3db9e93 | |
Derrick Hammer | 61d2edc54e | |
semantic-release-bot | 0d9a00030e | |
Derrick Hammer | 6ed331a66c | |
Derrick Hammer | de64ddd1e5 | |
semantic-release-bot | 58bb660266 | |
Derrick Hammer | cbbf085640 | |
Derrick Hammer | f8aa950ae0 | |
semantic-release-bot | a2d7e3c302 | |
Derrick Hammer | 0e29cedbe3 | |
Derrick Hammer | 239b735b73 | |
semantic-release-bot | 68bb0320b2 | |
Derrick Hammer | 626b34ad81 | |
Derrick Hammer | 6dcd446c55 | |
semantic-release-bot | 5291ff160f | |
Derrick Hammer | 7796e30f49 | |
Derrick Hammer | 9ba5ac3102 | |
semantic-release-bot | 2e80c0c99f | |
Derrick Hammer | 5df0ef6678 | |
Derrick Hammer | da8e2c1298 | |
semantic-release-bot | 5bbdbd8548 | |
Derrick Hammer | 2e7dadd19d | |
Derrick Hammer | 1fb9c77d55 |
|
@ -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
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"preset": [
|
||||||
|
"@lumeweb/node-library-preset"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
## [0.0.2-develop.20](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.19...v0.0.2-develop.20) (2023-10-13)
|
||||||
|
|
||||||
|
## [0.0.2-develop.19](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.18...v0.0.2-develop.19) (2023-09-03)
|
||||||
|
|
||||||
|
## [0.0.2-develop.18](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.17...v0.0.2-develop.18) (2023-09-02)
|
||||||
|
|
||||||
|
## [0.0.2-develop.17](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.16...v0.0.2-develop.17) (2023-09-02)
|
||||||
|
|
||||||
|
## [0.0.2-develop.16](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.15...v0.0.2-develop.16) (2023-07-29)
|
||||||
|
|
||||||
|
## [0.0.2-develop.15](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.14...v0.0.2-develop.15) (2023-07-24)
|
||||||
|
|
||||||
|
## [0.0.2-develop.14](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.13...v0.0.2-develop.14) (2023-07-23)
|
||||||
|
|
||||||
|
## [0.0.2-develop.13](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.12...v0.0.2-develop.13) (2023-07-23)
|
||||||
|
|
||||||
|
## [0.0.2-develop.12](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.11...v0.0.2-develop.12) (2023-07-22)
|
||||||
|
|
||||||
|
## [0.0.2-develop.11](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.10...v0.0.2-develop.11) (2023-07-22)
|
||||||
|
|
||||||
|
## [0.0.2-develop.10](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.9...v0.0.2-develop.10) (2023-07-22)
|
||||||
|
|
||||||
|
## [0.0.2-develop.9](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.8...v0.0.2-develop.9) (2023-07-22)
|
||||||
|
|
||||||
|
## [0.0.2-develop.8](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.7...v0.0.2-develop.8) (2023-07-22)
|
||||||
|
|
||||||
|
## [0.0.2-develop.7](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.6...v0.0.2-develop.7) (2023-07-12)
|
||||||
|
|
||||||
|
## [0.0.2-develop.6](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.5...v0.0.2-develop.6) (2023-07-08)
|
||||||
|
|
||||||
|
## [0.0.2-develop.5](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.4...v0.0.2-develop.5) (2023-07-08)
|
||||||
|
|
||||||
|
## [0.0.2-develop.4](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.3...v0.0.2-develop.4) (2023-07-05)
|
||||||
|
|
||||||
|
## [0.0.2-develop.3](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.2...v0.0.2-develop.3) (2023-07-05)
|
||||||
|
|
||||||
|
## [0.0.2-develop.2](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.2-develop.1...v0.0.2-develop.2) (2023-07-04)
|
||||||
|
|
||||||
|
## [0.0.2-develop.1](https://git.lumeweb.com/LumeWeb/protomux-rpc-web/compare/v0.0.1...v0.0.2-develop.1) (2023-07-04)
|
45
LICENSE
45
LICENSE
|
@ -1,37 +1,14 @@
|
||||||
MIT License
|
Copyright 2023 Holepunch Inc
|
||||||
|
Copyright 2023 Hammer Technologies LLC
|
||||||
|
|
||||||
Copyright (c) 2022 Hammer Technologies LLC
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
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:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
Unless required by applicable law or agreed to in writing, software
|
||||||
copies or substantial portions of the Software.
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
See the License for the specific language governing permissions and
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
limitations under the License.
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
|
|
||||||
ISC License
|
|
||||||
|
|
||||||
Copyright (c) 2022 Kasper Isager Dalsgarð <kasper@funktionel.co> & Contributors
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
||||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
||||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
||||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
||||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
/// <reference types="node" />
|
|
||||||
import EventEmitter from "events";
|
|
||||||
export default class ProtomuxRPC extends EventEmitter {
|
|
||||||
private _id;
|
|
||||||
private _ending;
|
|
||||||
private _error?;
|
|
||||||
private _responding;
|
|
||||||
private _requests;
|
|
||||||
private _defaultValueEncoding;
|
|
||||||
private _responders;
|
|
||||||
private _channel;
|
|
||||||
private _request;
|
|
||||||
private _response;
|
|
||||||
constructor(stream: any, options?: any);
|
|
||||||
private _mux;
|
|
||||||
get mux(): any;
|
|
||||||
private _ready;
|
|
||||||
get ready(): Promise<void>;
|
|
||||||
get closed(): any;
|
|
||||||
get stream(): any;
|
|
||||||
private _init;
|
|
||||||
_onopen(handshake: any): void;
|
|
||||||
_onclose(): void;
|
|
||||||
_ondestroy(): void;
|
|
||||||
_onrequest({ id, method, value, }: {
|
|
||||||
id: number;
|
|
||||||
method: string;
|
|
||||||
value: any;
|
|
||||||
}): Promise<void>;
|
|
||||||
_onresponse({ id, error, value }: {
|
|
||||||
id: number;
|
|
||||||
error: string;
|
|
||||||
value: any;
|
|
||||||
}): void;
|
|
||||||
respond(method: string, options: Function | any, handler: Function): this;
|
|
||||||
unrespond(method: string): this;
|
|
||||||
request(method: string, value: any, options?: any): Promise<unknown>;
|
|
||||||
event(method: string, value: any, options?: any): void;
|
|
||||||
cork(): void;
|
|
||||||
uncork(): void;
|
|
||||||
end(): Promise<void>;
|
|
||||||
_endMaybe(): void;
|
|
||||||
destroy(err: Error): void;
|
|
||||||
}
|
|
|
@ -1,224 +0,0 @@
|
||||||
import EventEmitter from "events";
|
|
||||||
// @ts-ignore
|
|
||||||
import Protomux from "@lumeweb/kernel-protomux-client";
|
|
||||||
// @ts-ignore
|
|
||||||
import c from "compact-encoding";
|
|
||||||
// @ts-ignore
|
|
||||||
import bitfield from "compact-encoding-bitfield";
|
|
||||||
// @ts-ignore
|
|
||||||
import bits from "bits-to-bytes";
|
|
||||||
export default class ProtomuxRPC extends EventEmitter {
|
|
||||||
_id;
|
|
||||||
_ending;
|
|
||||||
_error;
|
|
||||||
_responding;
|
|
||||||
_requests;
|
|
||||||
_defaultValueEncoding;
|
|
||||||
_responders;
|
|
||||||
_channel;
|
|
||||||
_request;
|
|
||||||
_response;
|
|
||||||
constructor(stream, options = {}) {
|
|
||||||
super();
|
|
||||||
this._mux = Protomux.from(stream);
|
|
||||||
this._defaultValueEncoding = options?.valueEncoding;
|
|
||||||
this._id = 1;
|
|
||||||
this._ending = false;
|
|
||||||
this._responding = 0;
|
|
||||||
this._requests = new Map();
|
|
||||||
this._responders = new Map();
|
|
||||||
this._ready = this._init(options);
|
|
||||||
}
|
|
||||||
_mux;
|
|
||||||
get mux() {
|
|
||||||
return this._mux;
|
|
||||||
}
|
|
||||||
_ready;
|
|
||||||
get ready() {
|
|
||||||
return this._ready;
|
|
||||||
}
|
|
||||||
get closed() {
|
|
||||||
return this._channel.closed;
|
|
||||||
}
|
|
||||||
get stream() {
|
|
||||||
return this._mux.stream;
|
|
||||||
}
|
|
||||||
async _init(options) {
|
|
||||||
this._channel = await this._mux.createChannel({
|
|
||||||
protocol: "protomux-rpc",
|
|
||||||
id: options?.id,
|
|
||||||
handshake: options?.handshake
|
|
||||||
? options?.handshakeEncoding || c.raw
|
|
||||||
: null,
|
|
||||||
onopen: this._onopen.bind(this),
|
|
||||||
onclose: this._onclose.bind(this),
|
|
||||||
ondestroy: this._ondestroy.bind(this),
|
|
||||||
});
|
|
||||||
if (this._channel === null)
|
|
||||||
throw new Error("duplicate channel");
|
|
||||||
this._request = await this._channel.addMessage({
|
|
||||||
encoding: request,
|
|
||||||
onmessage: this._onrequest.bind(this),
|
|
||||||
});
|
|
||||||
this._response = await this._channel.addMessage({
|
|
||||||
encoding: response,
|
|
||||||
onmessage: this._onresponse.bind(this),
|
|
||||||
});
|
|
||||||
await this._channel.open(options?.handshake);
|
|
||||||
}
|
|
||||||
_onopen(handshake) {
|
|
||||||
this.emit("open", handshake);
|
|
||||||
}
|
|
||||||
_onclose() {
|
|
||||||
const err = this._error || new Error("channel closed");
|
|
||||||
for (const request of this._requests.values()) {
|
|
||||||
request.reject(err);
|
|
||||||
}
|
|
||||||
this._requests.clear();
|
|
||||||
this._responders.clear();
|
|
||||||
this.emit("close");
|
|
||||||
}
|
|
||||||
_ondestroy() {
|
|
||||||
this.emit("destroy");
|
|
||||||
}
|
|
||||||
async _onrequest({ id, method, value, }) {
|
|
||||||
let error = null;
|
|
||||||
const responder = this._responders.get(method);
|
|
||||||
if (responder === undefined)
|
|
||||||
error = `unknown method '${method}'`;
|
|
||||||
else {
|
|
||||||
const { valueEncoding = this._defaultValueEncoding, requestEncoding = valueEncoding, responseEncoding = valueEncoding, } = responder.options;
|
|
||||||
if (requestEncoding)
|
|
||||||
value = c.decode(requestEncoding, value);
|
|
||||||
this._responding++;
|
|
||||||
try {
|
|
||||||
value = await responder.handler(value);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
error = err.message;
|
|
||||||
}
|
|
||||||
this._responding--;
|
|
||||||
if (!error && responseEncoding && id) {
|
|
||||||
value = c.encode(responseEncoding, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (id)
|
|
||||||
this._response.send({ id, error, value });
|
|
||||||
this._endMaybe();
|
|
||||||
}
|
|
||||||
_onresponse({ id, error, value }) {
|
|
||||||
if (id === 0)
|
|
||||||
return;
|
|
||||||
const request = this._requests.get(id);
|
|
||||||
if (request === undefined)
|
|
||||||
return;
|
|
||||||
this._requests.delete(id);
|
|
||||||
if (error)
|
|
||||||
request.reject(new Error(error));
|
|
||||||
else {
|
|
||||||
const { valueEncoding = this._defaultValueEncoding, responseEncoding = valueEncoding, } = request.options;
|
|
||||||
if (responseEncoding)
|
|
||||||
value = c.decode(responseEncoding, value);
|
|
||||||
request.resolve(value);
|
|
||||||
}
|
|
||||||
this._endMaybe();
|
|
||||||
}
|
|
||||||
respond(method, options, handler) {
|
|
||||||
if (typeof options === "function") {
|
|
||||||
handler = options;
|
|
||||||
options = {};
|
|
||||||
}
|
|
||||||
this._responders.set(method, { options, handler });
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
unrespond(method) {
|
|
||||||
this._responders.delete(method);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
async request(method, value, options = {}) {
|
|
||||||
if (this.closed)
|
|
||||||
throw new Error("channel closed");
|
|
||||||
const { valueEncoding = this._defaultValueEncoding, requestEncoding = valueEncoding, } = options;
|
|
||||||
if (requestEncoding)
|
|
||||||
value = c.encode(requestEncoding, value);
|
|
||||||
const id = this._id++;
|
|
||||||
this._request.send({ id, method, value });
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this._requests.set(id, { options, resolve, reject });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
event(method, value, options = {}) {
|
|
||||||
if (this.closed)
|
|
||||||
throw new Error("channel closed");
|
|
||||||
const { valueEncoding = this._defaultValueEncoding, requestEncoding = valueEncoding, } = options;
|
|
||||||
if (requestEncoding)
|
|
||||||
value = c.encode(requestEncoding, value);
|
|
||||||
this._request.send({ id: 0, method, value });
|
|
||||||
}
|
|
||||||
cork() {
|
|
||||||
this._channel.cork();
|
|
||||||
}
|
|
||||||
uncork() {
|
|
||||||
this._channel.uncork();
|
|
||||||
}
|
|
||||||
async end() {
|
|
||||||
this._ending = true;
|
|
||||||
this._endMaybe();
|
|
||||||
await EventEmitter.once(this, "close");
|
|
||||||
}
|
|
||||||
_endMaybe() {
|
|
||||||
if (this._ending && this._responding === 0 && this._requests.size === 0) {
|
|
||||||
this._channel.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
destroy(err) {
|
|
||||||
this._error = err || new Error("channel destroyed");
|
|
||||||
this._channel.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const request = {
|
|
||||||
preencode(state, m) {
|
|
||||||
c.uint.preencode(state, m.id);
|
|
||||||
c.string.preencode(state, m.method);
|
|
||||||
c.raw.preencode(state, m.value);
|
|
||||||
},
|
|
||||||
encode(state, m) {
|
|
||||||
c.uint.encode(state, m.id);
|
|
||||||
c.string.encode(state, m.method);
|
|
||||||
c.raw.encode(state, m.value);
|
|
||||||
},
|
|
||||||
decode(state) {
|
|
||||||
return {
|
|
||||||
id: c.uint.decode(state),
|
|
||||||
method: c.string.decode(state),
|
|
||||||
value: c.raw.decode(state),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const flags = bitfield(1);
|
|
||||||
const response = {
|
|
||||||
preencode(state, m) {
|
|
||||||
flags.preencode(state);
|
|
||||||
c.uint.preencode(state, m.id);
|
|
||||||
if (m.error)
|
|
||||||
c.string.preencode(state, m.error);
|
|
||||||
else
|
|
||||||
c.raw.preencode(state, m.value);
|
|
||||||
},
|
|
||||||
encode(state, m) {
|
|
||||||
flags.encode(state, bits.of(m.error));
|
|
||||||
c.uint.encode(state, m.id);
|
|
||||||
if (m.error)
|
|
||||||
c.string.encode(state, m.error);
|
|
||||||
else
|
|
||||||
c.raw.encode(state, m.value);
|
|
||||||
},
|
|
||||||
decode(state) {
|
|
||||||
const [error] = bits.iterator(flags.decode(state));
|
|
||||||
return {
|
|
||||||
id: c.uint.decode(state),
|
|
||||||
error: error ? c.string.decode(state) : null,
|
|
||||||
value: !error ? c.raw.decode(state) : null,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
File diff suppressed because it is too large
Load Diff
36
package.json
36
package.json
|
@ -1,19 +1,29 @@
|
||||||
{
|
{
|
||||||
"name": "@lumeweb/protomux-rpc-web",
|
"name": "@lumeweb/protomux-rpc-web",
|
||||||
"version": "0.1.0",
|
"version": "0.0.2-develop.20",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
|
||||||
"@lumeweb/kernel-protomux-client": "git+https://git.lumeweb.com/LumeWeb/kernel-protomux-client.git",
|
|
||||||
"bits-to-bytes": "^1.3.0",
|
|
||||||
"compact-encoding": "^2.11.0",
|
|
||||||
"compact-encoding-bitfield": "^1.0.0",
|
|
||||||
"events": "^3.3.0",
|
|
||||||
"protomux": "^3.4.1"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^18.15.11",
|
"@lumeweb/node-library-preset": "^0.2.7",
|
||||||
"prettier": "^2.8.7",
|
"presetter": "*"
|
||||||
"typescript": "^5.0.4"
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "gitea@git.lumeweb.com:LumeWeb/protomux-rpc-web.git"
|
||||||
|
},
|
||||||
|
"readme": "ERROR: No README data found!",
|
||||||
|
"scripts": {
|
||||||
|
"prepare": "presetter bootstrap",
|
||||||
|
"build": "run build",
|
||||||
|
"semantic-release": "semantic-release"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@lumeweb/kernel-protomux-client": "^0.0.2-develop.21"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"lib"
|
||||||
|
],
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import EventEmitter from "events";
|
import EventEmitter from "events";
|
||||||
// @ts-ignore
|
|
||||||
import Protomux from "@lumeweb/kernel-protomux-client";
|
import Protomux from "@lumeweb/kernel-protomux-client";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import c from "compact-encoding";
|
import c from "compact-encoding";
|
||||||
|
@ -112,12 +111,13 @@ export default class ProtomuxRPC extends EventEmitter {
|
||||||
method: string;
|
method: string;
|
||||||
value: any;
|
value: any;
|
||||||
}) {
|
}) {
|
||||||
let error = null;
|
let error: string | null = null;
|
||||||
|
|
||||||
const responder = this._responders.get(method);
|
const responder = this._responders.get(method);
|
||||||
|
|
||||||
if (responder === undefined) error = `unknown method '${method}'`;
|
if (responder === undefined) {
|
||||||
else {
|
error = `unknown method '${method}'`;
|
||||||
|
} else {
|
||||||
const {
|
const {
|
||||||
valueEncoding = this._defaultValueEncoding,
|
valueEncoding = this._defaultValueEncoding,
|
||||||
requestEncoding = valueEncoding,
|
requestEncoding = valueEncoding,
|
||||||
|
|
|
@ -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__/*"]
|
|
||||||
}
|
|
Loading…
Reference in New Issue