kkrpc 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -4
- package/dist/browser-mod.cjs +36 -29
- package/dist/browser-mod.d.cts +4 -4
- package/dist/browser-mod.d.ts +4 -4
- package/dist/browser-mod.js +3 -7
- package/dist/{channel-D6ZClufP.d.cts → channel-C01VCxab.d.cts} +35 -1
- package/dist/{channel-D6ZClufP.d.ts → channel-C01VCxab.d.ts} +35 -1
- package/dist/chrome.cjs +36 -29
- package/dist/chrome.d.cts +3 -42
- package/dist/chrome.d.ts +3 -42
- package/dist/chrome.js +3 -7
- package/dist/chunk-GRCUBSPR.js +27 -0
- package/dist/{chunk-ZSSFWNSX.js → chunk-YIQVRWAJ.js} +34 -25
- package/dist/deno-mod.cjs +380 -0
- package/dist/deno-mod.d.cts +19 -0
- package/dist/deno-mod.d.ts +19 -0
- package/dist/deno-mod.js +10 -0
- package/dist/{http-CvGfNM3D.d.cts → http-D0k1TiAJ.d.cts} +1 -1
- package/dist/{http-Bz7mwStC.d.ts → http-D6N0U5-p.d.ts} +1 -1
- package/dist/http.cjs +34 -9
- package/dist/http.d.cts +2 -2
- package/dist/http.d.ts +2 -2
- package/dist/http.js +1 -1
- package/dist/mod.cjs +36 -29
- package/dist/mod.d.cts +7 -20
- package/dist/mod.d.ts +7 -20
- package/dist/mod.js +6 -31
- package/dist/{tauri-CRNRbu3f.d.cts → tauri-ohph68oo.d.cts} +1 -1
- package/dist/{tauri-PdcZTVUI.d.ts → tauri-pC0wuvjw.d.ts} +1 -1
- package/package.json +10 -1
package/dist/http.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RPCChannel, I as IoInterface } from './channel-
|
|
2
|
-
export { H as HTTPClientIO, a as HTTPServerIO } from './http-
|
|
1
|
+
import { R as RPCChannel, I as IoInterface } from './channel-C01VCxab.cjs';
|
|
2
|
+
export { H as HTTPClientIO, a as HTTPServerIO } from './http-D0k1TiAJ.cjs';
|
|
3
3
|
import 'node:buffer';
|
|
4
4
|
|
|
5
5
|
declare function createHttpClient<API extends Record<string, any>>(url: string): {
|
package/dist/http.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RPCChannel, I as IoInterface } from './channel-
|
|
2
|
-
export { H as HTTPClientIO, a as HTTPServerIO } from './http-
|
|
1
|
+
import { R as RPCChannel, I as IoInterface } from './channel-C01VCxab.js';
|
|
2
|
+
export { H as HTTPClientIO, a as HTTPServerIO } from './http-D6N0U5-p.js';
|
|
3
3
|
import 'node:buffer';
|
|
4
4
|
|
|
5
5
|
declare function createHttpClient<API extends Record<string, any>>(url: string): {
|
package/dist/http.js
CHANGED
package/dist/mod.cjs
CHANGED
|
@@ -44,10 +44,8 @@ __export(mod_exports, {
|
|
|
44
44
|
WorkerChildIO: () => WorkerChildIO,
|
|
45
45
|
WorkerParentIO: () => WorkerParentIO,
|
|
46
46
|
deserializeMessage: () => deserializeMessage,
|
|
47
|
-
deserializeResponse: () => deserializeResponse,
|
|
48
47
|
generateUUID: () => generateUUID,
|
|
49
|
-
serializeMessage: () => serializeMessage
|
|
50
|
-
serializeResponse: () => serializeResponse
|
|
48
|
+
serializeMessage: () => serializeMessage
|
|
51
49
|
});
|
|
52
50
|
module.exports = __toCommonJS(mod_exports);
|
|
53
51
|
|
|
@@ -503,30 +501,39 @@ var TauriShellStdio = class {
|
|
|
503
501
|
|
|
504
502
|
// src/serialization.ts
|
|
505
503
|
var import_superjson2 = __toESM(require("superjson"), 1);
|
|
506
|
-
function
|
|
507
|
-
|
|
504
|
+
function replacer(key, value) {
|
|
505
|
+
if (value instanceof Uint8Array) {
|
|
506
|
+
return {
|
|
507
|
+
type: "Uint8Array",
|
|
508
|
+
data: Array.from(value)
|
|
509
|
+
// Convert to regular array
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
return value;
|
|
508
513
|
}
|
|
509
|
-
function
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
} catch (error) {
|
|
515
|
-
console.error("failed to parse message", typeof message, message, error);
|
|
516
|
-
reject(error);
|
|
517
|
-
}
|
|
518
|
-
});
|
|
514
|
+
function reviver(key, value) {
|
|
515
|
+
if (value && value.type === "Uint8Array" && Array.isArray(value.data)) {
|
|
516
|
+
return new Uint8Array(value.data);
|
|
517
|
+
}
|
|
518
|
+
return value;
|
|
519
519
|
}
|
|
520
|
-
function
|
|
521
|
-
|
|
520
|
+
function serializeMessage(message, options = {}) {
|
|
521
|
+
const version = options.version || "superjson";
|
|
522
|
+
const msgWithVersion = { ...message, version };
|
|
523
|
+
return version === "json" ? JSON.stringify(msgWithVersion, replacer) + "\n" : import_superjson2.default.stringify(msgWithVersion) + "\n";
|
|
522
524
|
}
|
|
523
|
-
function
|
|
525
|
+
function deserializeMessage(message) {
|
|
524
526
|
return new Promise((resolve, reject) => {
|
|
525
527
|
try {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
+
if (message.startsWith('{"json":')) {
|
|
529
|
+
const parsed = import_superjson2.default.parse(message);
|
|
530
|
+
resolve(parsed);
|
|
531
|
+
} else {
|
|
532
|
+
const parsed = JSON.parse(message, reviver);
|
|
533
|
+
resolve(parsed);
|
|
534
|
+
}
|
|
528
535
|
} catch (error) {
|
|
529
|
-
console.error("failed to parse
|
|
536
|
+
console.error("failed to parse message", typeof message, message, error);
|
|
530
537
|
reject(error);
|
|
531
538
|
}
|
|
532
539
|
});
|
|
@@ -542,6 +549,7 @@ var RPCChannel = class {
|
|
|
542
549
|
constructor(io, options) {
|
|
543
550
|
this.io = io;
|
|
544
551
|
this.apiImplementation = options?.expose;
|
|
552
|
+
this.serializationOptions = options?.serialization || {};
|
|
545
553
|
this.listen();
|
|
546
554
|
}
|
|
547
555
|
pendingRequests = {};
|
|
@@ -550,6 +558,7 @@ var RPCChannel = class {
|
|
|
550
558
|
count = 0;
|
|
551
559
|
messageStr = "";
|
|
552
560
|
apiImplementation;
|
|
561
|
+
serializationOptions;
|
|
553
562
|
/**
|
|
554
563
|
* Exposes a local API implementation that can be called remotely
|
|
555
564
|
* @param api The local API implementation to expose
|
|
@@ -596,7 +605,7 @@ var RPCChannel = class {
|
|
|
596
605
|
/**
|
|
597
606
|
* Handles a single message string by parsing and routing it
|
|
598
607
|
* @param messageStr The message string to handle
|
|
599
|
-
* @private
|
|
608
|
+
* @private
|
|
600
609
|
*/
|
|
601
610
|
async handleMessageStr(messageStr) {
|
|
602
611
|
this.count++;
|
|
@@ -646,7 +655,7 @@ var RPCChannel = class {
|
|
|
646
655
|
type: "request",
|
|
647
656
|
callbackIds: callbackIds.length > 0 ? callbackIds : void 0
|
|
648
657
|
};
|
|
649
|
-
this.io.write(serializeMessage(message));
|
|
658
|
+
this.io.write(serializeMessage(message, this.serializationOptions));
|
|
650
659
|
});
|
|
651
660
|
}
|
|
652
661
|
/**
|
|
@@ -720,7 +729,7 @@ var RPCChannel = class {
|
|
|
720
729
|
args,
|
|
721
730
|
type: "callback"
|
|
722
731
|
};
|
|
723
|
-
this.io.write(serializeMessage(message));
|
|
732
|
+
this.io.write(serializeMessage(message, this.serializationOptions));
|
|
724
733
|
}
|
|
725
734
|
/**
|
|
726
735
|
* Handles callback invocations received from the remote endpoint
|
|
@@ -749,7 +758,7 @@ var RPCChannel = class {
|
|
|
749
758
|
args: { result },
|
|
750
759
|
type: "response"
|
|
751
760
|
};
|
|
752
|
-
this.io.write(serializeMessage(response));
|
|
761
|
+
this.io.write(serializeMessage(response, this.serializationOptions));
|
|
753
762
|
}
|
|
754
763
|
/**
|
|
755
764
|
* Sends an error response back to the remote endpoint
|
|
@@ -764,7 +773,7 @@ var RPCChannel = class {
|
|
|
764
773
|
args: { error },
|
|
765
774
|
type: "response"
|
|
766
775
|
};
|
|
767
|
-
this.io.write(serializeMessage(response));
|
|
776
|
+
this.io.write(serializeMessage(response, this.serializationOptions));
|
|
768
777
|
}
|
|
769
778
|
/**
|
|
770
779
|
* Creates a nested proxy object for chaining remote method calls
|
|
@@ -844,8 +853,6 @@ var DenoIo = class {
|
|
|
844
853
|
WorkerChildIO,
|
|
845
854
|
WorkerParentIO,
|
|
846
855
|
deserializeMessage,
|
|
847
|
-
deserializeResponse,
|
|
848
856
|
generateUUID,
|
|
849
|
-
serializeMessage
|
|
850
|
-
serializeResponse
|
|
857
|
+
serializeMessage
|
|
851
858
|
});
|
package/dist/mod.d.cts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export { T as TauriShellStdio, a as WorkerChildIO, W as WorkerParentIO } from './tauri-
|
|
2
|
-
export { ChromeBackgroundIO, ChromeContentIO,
|
|
1
|
+
export { T as TauriShellStdio, a as WorkerChildIO, W as WorkerParentIO } from './tauri-ohph68oo.cjs';
|
|
2
|
+
export { ChromeBackgroundIO, ChromeContentIO, generateUUID } from './chrome.cjs';
|
|
3
3
|
import { Buffer } from 'node:buffer';
|
|
4
|
-
import { I as IoInterface, D as DestroyableIoInterface } from './channel-
|
|
5
|
-
export { R as RPCChannel } from './channel-
|
|
4
|
+
import { I as IoInterface, D as DestroyableIoInterface } from './channel-C01VCxab.cjs';
|
|
5
|
+
export { M as Message, R as RPCChannel, a as Response, S as SerializationOptions, d as deserializeMessage, s as serializeMessage } from './channel-C01VCxab.cjs';
|
|
6
6
|
import { Readable, Writable } from 'node:stream';
|
|
7
|
-
export { H as HTTPClientIO, a as HTTPServerIO } from './http-
|
|
7
|
+
export { H as HTTPClientIO, a as HTTPServerIO } from './http-D0k1TiAJ.cjs';
|
|
8
|
+
export { DenoIo } from './deno-mod.cjs';
|
|
8
9
|
import '@tauri-apps/plugin-shell';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -80,18 +81,4 @@ declare class WebSocketServerIO implements DestroyableIoInterface {
|
|
|
80
81
|
signalDestroy(): void;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
* Stdio implementation for Deno
|
|
85
|
-
* Deno doesn't have `process` object, and have a completely different stdio API,
|
|
86
|
-
* This implementation wrap Deno's `Deno.stdin` and `Deno.stdout` to follow StdioInterface
|
|
87
|
-
*/
|
|
88
|
-
declare class DenoIo implements IoInterface {
|
|
89
|
-
private readStream;
|
|
90
|
-
private reader;
|
|
91
|
-
name: string;
|
|
92
|
-
constructor(readStream: ReadableStream<Uint8Array>);
|
|
93
|
-
read(): Promise<Buffer | null>;
|
|
94
|
-
write(data: string): Promise<void>;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export { BunIo, DenoIo, DestroyableIoInterface, IoInterface, NodeIo, WebSocketClientIO, WebSocketServerIO };
|
|
84
|
+
export { BunIo, DestroyableIoInterface, IoInterface, NodeIo, WebSocketClientIO, WebSocketServerIO };
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export { T as TauriShellStdio, a as WorkerChildIO, W as WorkerParentIO } from './tauri-
|
|
2
|
-
export { ChromeBackgroundIO, ChromeContentIO,
|
|
1
|
+
export { T as TauriShellStdio, a as WorkerChildIO, W as WorkerParentIO } from './tauri-pC0wuvjw.js';
|
|
2
|
+
export { ChromeBackgroundIO, ChromeContentIO, generateUUID } from './chrome.js';
|
|
3
3
|
import { Buffer } from 'node:buffer';
|
|
4
|
-
import { I as IoInterface, D as DestroyableIoInterface } from './channel-
|
|
5
|
-
export { R as RPCChannel } from './channel-
|
|
4
|
+
import { I as IoInterface, D as DestroyableIoInterface } from './channel-C01VCxab.js';
|
|
5
|
+
export { M as Message, R as RPCChannel, a as Response, S as SerializationOptions, d as deserializeMessage, s as serializeMessage } from './channel-C01VCxab.js';
|
|
6
6
|
import { Readable, Writable } from 'node:stream';
|
|
7
|
-
export { H as HTTPClientIO, a as HTTPServerIO } from './http-
|
|
7
|
+
export { H as HTTPClientIO, a as HTTPServerIO } from './http-D6N0U5-p.js';
|
|
8
|
+
export { DenoIo } from './deno-mod.js';
|
|
8
9
|
import '@tauri-apps/plugin-shell';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -80,18 +81,4 @@ declare class WebSocketServerIO implements DestroyableIoInterface {
|
|
|
80
81
|
signalDestroy(): void;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
* Stdio implementation for Deno
|
|
85
|
-
* Deno doesn't have `process` object, and have a completely different stdio API,
|
|
86
|
-
* This implementation wrap Deno's `Deno.stdin` and `Deno.stdout` to follow StdioInterface
|
|
87
|
-
*/
|
|
88
|
-
declare class DenoIo implements IoInterface {
|
|
89
|
-
private readStream;
|
|
90
|
-
private reader;
|
|
91
|
-
name: string;
|
|
92
|
-
constructor(readStream: ReadableStream<Uint8Array>);
|
|
93
|
-
read(): Promise<Buffer | null>;
|
|
94
|
-
write(data: string): Promise<void>;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export { BunIo, DenoIo, DestroyableIoInterface, IoInterface, NodeIo, WebSocketClientIO, WebSocketServerIO };
|
|
84
|
+
export { BunIo, DestroyableIoInterface, IoInterface, NodeIo, WebSocketClientIO, WebSocketServerIO };
|
package/dist/mod.js
CHANGED
|
@@ -7,6 +7,9 @@ import {
|
|
|
7
7
|
ChromeBackgroundIO,
|
|
8
8
|
ChromeContentIO
|
|
9
9
|
} from "./chunk-INKNKSKA.js";
|
|
10
|
+
import {
|
|
11
|
+
DenoIo
|
|
12
|
+
} from "./chunk-GRCUBSPR.js";
|
|
10
13
|
import {
|
|
11
14
|
HTTPClientIO,
|
|
12
15
|
HTTPServerIO
|
|
@@ -14,11 +17,9 @@ import {
|
|
|
14
17
|
import {
|
|
15
18
|
RPCChannel,
|
|
16
19
|
deserializeMessage,
|
|
17
|
-
deserializeResponse,
|
|
18
20
|
generateUUID,
|
|
19
|
-
serializeMessage
|
|
20
|
-
|
|
21
|
-
} from "./chunk-ZSSFWNSX.js";
|
|
21
|
+
serializeMessage
|
|
22
|
+
} from "./chunk-YIQVRWAJ.js";
|
|
22
23
|
|
|
23
24
|
// src/adapters/bun.ts
|
|
24
25
|
import { Buffer } from "node:buffer";
|
|
@@ -188,30 +189,6 @@ var WebSocketServerIO = class {
|
|
|
188
189
|
this.write(DESTROY_SIGNAL);
|
|
189
190
|
}
|
|
190
191
|
};
|
|
191
|
-
|
|
192
|
-
// src/adapters/deno.ts
|
|
193
|
-
import { Buffer as Buffer2 } from "node:buffer";
|
|
194
|
-
var DenoIo = class {
|
|
195
|
-
constructor(readStream) {
|
|
196
|
-
this.readStream = readStream;
|
|
197
|
-
this.reader = this.readStream.getReader();
|
|
198
|
-
}
|
|
199
|
-
reader;
|
|
200
|
-
name = "deno-io";
|
|
201
|
-
async read() {
|
|
202
|
-
const { value, done } = await this.reader.read();
|
|
203
|
-
if (done) {
|
|
204
|
-
return null;
|
|
205
|
-
}
|
|
206
|
-
return Buffer2.from(value);
|
|
207
|
-
}
|
|
208
|
-
write(data) {
|
|
209
|
-
const encoder = new TextEncoder();
|
|
210
|
-
const encodedData = encoder.encode(data + "\n");
|
|
211
|
-
Deno.stdout.writeSync(encodedData);
|
|
212
|
-
return Promise.resolve();
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
192
|
export {
|
|
216
193
|
BunIo,
|
|
217
194
|
ChromeBackgroundIO,
|
|
@@ -227,8 +204,6 @@ export {
|
|
|
227
204
|
WorkerChildIO,
|
|
228
205
|
WorkerParentIO,
|
|
229
206
|
deserializeMessage,
|
|
230
|
-
deserializeResponse,
|
|
231
207
|
generateUUID,
|
|
232
|
-
serializeMessage
|
|
233
|
-
serializeResponse
|
|
208
|
+
serializeMessage
|
|
234
209
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DestroyableIoInterface, I as IoInterface } from './channel-
|
|
1
|
+
import { D as DestroyableIoInterface, I as IoInterface } from './channel-C01VCxab.cjs';
|
|
2
2
|
import { EventEmitter, OutputEvents, Child } from '@tauri-apps/plugin-shell';
|
|
3
3
|
|
|
4
4
|
declare class WorkerParentIO implements DestroyableIoInterface {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DestroyableIoInterface, I as IoInterface } from './channel-
|
|
1
|
+
import { D as DestroyableIoInterface, I as IoInterface } from './channel-C01VCxab.js';
|
|
2
2
|
import { EventEmitter, OutputEvents, Child } from '@tauri-apps/plugin-shell';
|
|
3
3
|
|
|
4
4
|
declare class WorkerParentIO implements DestroyableIoInterface {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kkrpc",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,6 +43,15 @@
|
|
|
43
43
|
"import": "./dist/http.js",
|
|
44
44
|
"require": "./dist/http.cjs"
|
|
45
45
|
},
|
|
46
|
+
"./deno": {
|
|
47
|
+
"types": {
|
|
48
|
+
"import": "./dist/deno-mod.d.ts",
|
|
49
|
+
"require": "./dist/deno-mod.cjs",
|
|
50
|
+
"default": "./dist/deno-mod.js"
|
|
51
|
+
},
|
|
52
|
+
"import": "./dist/deno-mod.js",
|
|
53
|
+
"require": "./dist/deno-mod.cjs"
|
|
54
|
+
},
|
|
46
55
|
"./chrome": {
|
|
47
56
|
"types": {
|
|
48
57
|
"import": "./dist/chrome.d.ts",
|