nuxt4, and some changes on packages

This commit is contained in:
2025-08-19 21:38:30 +03:30
parent 61fee6c3da
commit 5b6f1a1cdf
900 changed files with 11139 additions and 15161 deletions
+23 -2
View File
@@ -31,6 +31,11 @@ function createBirpc(functions, options) {
return functions;
if (method === "$close")
return close;
if (method === "$rejectPendingCalls") {
return rejectPendingCalls;
}
if (method === "$closed")
return closed;
if (method === "then" && !eventNames.includes("then") && !("then" in functions))
return void 0;
const sendEvent = (...args) => {
@@ -75,14 +80,30 @@ function createBirpc(functions, options) {
return sendCall;
}
});
function close(error) {
function close(customError) {
closed = true;
rpcPromiseMap.forEach(({ reject, method }) => {
reject(error || new Error(`[birpc] rpc is closed, cannot call "${method}"`));
const error = new Error(`[birpc] rpc is closed, cannot call "${method}"`);
if (customError) {
customError.cause ??= error;
return reject(customError);
}
reject(error);
});
rpcPromiseMap.clear();
off(onMessage);
}
function rejectPendingCalls(handler) {
const entries = Array.from(rpcPromiseMap.values());
const handlerResults = entries.map(({ method, reject }) => {
if (!handler) {
return reject(new Error(`[birpc]: rejected pending call "${method}".`));
}
return handler({ method, reject });
});
rpcPromiseMap.clear();
return handlerResults;
}
async function onMessage(data, ...extra) {
let msg;
try {
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "birpc",
"type": "module",
"version": "2.3.0",
"version": "2.5.0",
"description": "Message based Two-way remote procedure call",
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
"license": "MIT",