modality-kit 0.7.6 → 0.7.7
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/dist/index.js
CHANGED
|
@@ -4993,11 +4993,13 @@ async function compressWithLanguageDetection(text, maxTokens = DEFAULT_CONFIG.ma
|
|
|
4993
4993
|
// src/schemas/jsonrpc.ts
|
|
4994
4994
|
var exports_jsonrpc = {};
|
|
4995
4995
|
__export(exports_jsonrpc, {
|
|
4996
|
+
getUUID: () => getUUID,
|
|
4996
4997
|
STANDARD_ERROR_MESSAGES: () => STANDARD_ERROR_MESSAGES,
|
|
4997
4998
|
JSONRPC_VERSION: () => JSONRPC_VERSION,
|
|
4998
4999
|
JSONRPCUtils: () => JSONRPCUtils,
|
|
4999
5000
|
JSONRPCErrorCode: () => JSONRPCErrorCode
|
|
5000
5001
|
});
|
|
5002
|
+
var getUUID = () => crypto.randomUUID();
|
|
5001
5003
|
var JSONRPC_VERSION = "2.0";
|
|
5002
5004
|
var JSONRPCErrorCode;
|
|
5003
5005
|
((JSONRPCErrorCode2) => {
|
|
@@ -5122,7 +5124,7 @@ class JSONRPCUtils {
|
|
|
5122
5124
|
return { code, message, data };
|
|
5123
5125
|
}
|
|
5124
5126
|
static generateId() {
|
|
5125
|
-
return
|
|
5127
|
+
return getUUID();
|
|
5126
5128
|
}
|
|
5127
5129
|
static isRequest(message) {
|
|
5128
5130
|
return message && message.jsonrpc === JSONRPC_VERSION && typeof message.method === "string" && "id" in message;
|
|
@@ -5167,8 +5169,6 @@ var STANDARD_ERROR_MESSAGES = {
|
|
|
5167
5169
|
};
|
|
5168
5170
|
|
|
5169
5171
|
// src/util_pending.ts
|
|
5170
|
-
var getUUID = () => crypto.randomUUID();
|
|
5171
|
-
|
|
5172
5172
|
class PendingOperationsBase {
|
|
5173
5173
|
operations = new Map;
|
|
5174
5174
|
config;
|
|
@@ -5423,9 +5423,11 @@ class JSONRPCCall {
|
|
|
5423
5423
|
this.pendingRequests.reject(id, new Error(response.error.message));
|
|
5424
5424
|
}
|
|
5425
5425
|
}
|
|
5426
|
-
|
|
5426
|
+
handleRequest(method, params, options = {}) {
|
|
5427
|
+
const request = JSONRPCUtils.createRequest(method, params);
|
|
5428
|
+
options.customId = request.id;
|
|
5427
5429
|
const { promise } = this.pendingRequests.add({ method, params }, options);
|
|
5428
|
-
return promise;
|
|
5430
|
+
return { promise, request };
|
|
5429
5431
|
}
|
|
5430
5432
|
getStats() {
|
|
5431
5433
|
return {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,4 +11,4 @@ export { compressWithLanguageDetection as compressText } from "./util_text_compr
|
|
|
11
11
|
export { JSONRPCCall, createDataPendingOperations } from "./util_pending";
|
|
12
12
|
export type { DataPendingOperation, PendingOperation } from "./util_pending";
|
|
13
13
|
export * as JSONRPCTypes from "./schemas/jsonrpc";
|
|
14
|
-
export type { JSONRPCMessage, JSONRPCRequest, JSONRPCNotification, JSONRPCResponse, JSONRPCBatchRequest, JSONRPCBatchResponse, JSONRPCErrorResponse, } from "./schemas/jsonrpc";
|
|
14
|
+
export type { JSONRPCMessage, JSONRPCRequest, JSONRPCNotification, JSONRPCResponse, JSONRPCBatchRequest, JSONRPCBatchResponse, JSONRPCErrorResponse, JSONRPCValidationResult, } from "./schemas/jsonrpc";
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* Usage: type MyMethod = JSONRPCMethod<MyParams, MyResult>
|
|
12
12
|
* Or as object: { methodName: JSONRPCMethod<MyParams, MyResult> }
|
|
13
13
|
*/
|
|
14
|
+
export declare const getUUID: () => `${string}-${string}-${string}-${string}-${string}`;
|
|
14
15
|
export type JSONRPCMethod<TParams = JSONRPCParams, TResult = any> = (method: string, params?: TParams, options?: any) => Promise<TResult>;
|
|
15
16
|
/**
|
|
16
17
|
* JSON-RPC 2.0 version identifier
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* and lifecycle management. Can be used on both client and server sides
|
|
6
6
|
* for WebSocket communication or any async operation tracking.
|
|
7
7
|
*/
|
|
8
|
-
import { JSONRPCResponse } from "./schemas/jsonrpc";
|
|
8
|
+
import { JSONRPCResponse, JSONRPCId, type JSONRPCRequest } from "./schemas/jsonrpc";
|
|
9
9
|
/**
|
|
10
10
|
* Configuration options for PendingOperations
|
|
11
11
|
*
|
|
@@ -49,7 +49,7 @@ export interface PendingOperationBase {
|
|
|
49
49
|
* Unique identifier for the operation
|
|
50
50
|
* @description Generated automatically by the ID generator function
|
|
51
51
|
*/
|
|
52
|
-
id:
|
|
52
|
+
id: JSONRPCId;
|
|
53
53
|
/**
|
|
54
54
|
* Timestamp when the operation was created
|
|
55
55
|
* @description Used for age calculations and timeout management
|
|
@@ -171,7 +171,7 @@ export interface PendingOperationStats {
|
|
|
171
171
|
* Contains all common functionality while allowing specialized subclasses
|
|
172
172
|
*/
|
|
173
173
|
export declare abstract class PendingOperationsBase {
|
|
174
|
-
protected operations: Map<
|
|
174
|
+
protected operations: Map<JSONRPCId, PendingOperation>;
|
|
175
175
|
protected config: Required<PendingOperationsConfig>;
|
|
176
176
|
protected cleanupIntervalHandle?: NodeJS.Timeout;
|
|
177
177
|
protected eventHandlers: PendingOperationEventHandlers;
|
|
@@ -179,27 +179,27 @@ export declare abstract class PendingOperationsBase {
|
|
|
179
179
|
/**
|
|
180
180
|
* Resolve a pending operation with a result
|
|
181
181
|
*/
|
|
182
|
-
resolve(id:
|
|
182
|
+
resolve(id: JSONRPCId, result?: any): boolean;
|
|
183
183
|
/**
|
|
184
184
|
* Reject a pending operation with a reason
|
|
185
185
|
*/
|
|
186
|
-
reject(id:
|
|
186
|
+
reject(id: JSONRPCId, reason?: any): boolean;
|
|
187
187
|
/**
|
|
188
188
|
* Get a pending operation by ID
|
|
189
189
|
*/
|
|
190
|
-
get(id:
|
|
190
|
+
get(id: JSONRPCId): PendingOperation | undefined;
|
|
191
191
|
/**
|
|
192
192
|
* Check if an operation exists
|
|
193
193
|
*/
|
|
194
|
-
has(id:
|
|
194
|
+
has(id: JSONRPCId): boolean;
|
|
195
195
|
/**
|
|
196
196
|
* Remove an operation without resolving or rejecting
|
|
197
197
|
*/
|
|
198
|
-
remove(id:
|
|
198
|
+
remove(id: JSONRPCId): boolean;
|
|
199
199
|
/**
|
|
200
200
|
* Get all pending operations
|
|
201
201
|
*/
|
|
202
|
-
getAll(): Map<
|
|
202
|
+
getAll(): Map<JSONRPCId, PendingOperation>;
|
|
203
203
|
/**
|
|
204
204
|
* Get pending operations by type
|
|
205
205
|
*/
|
|
@@ -228,7 +228,7 @@ export declare abstract class PendingOperationsBase {
|
|
|
228
228
|
* Handle operation timeout
|
|
229
229
|
*/
|
|
230
230
|
protected handleTimeout({ id }: {
|
|
231
|
-
id:
|
|
231
|
+
id: JSONRPCId;
|
|
232
232
|
}): void;
|
|
233
233
|
/**
|
|
234
234
|
* Destroy the pending operations manager
|
|
@@ -248,9 +248,9 @@ export declare abstract class PendingOperationsBase {
|
|
|
248
248
|
abstract add(...args: any[]): any;
|
|
249
249
|
handleAdd(options?: {
|
|
250
250
|
timeout?: number;
|
|
251
|
-
customId?:
|
|
251
|
+
customId?: JSONRPCId;
|
|
252
252
|
}): {
|
|
253
|
-
id: string;
|
|
253
|
+
id: string | number;
|
|
254
254
|
timeout: number;
|
|
255
255
|
timeoutHandle: NodeJS.Timeout | undefined;
|
|
256
256
|
};
|
|
@@ -265,9 +265,9 @@ export declare class PromisePendingOperations extends PendingOperationsBase {
|
|
|
265
265
|
*/
|
|
266
266
|
add(data: any, options?: {
|
|
267
267
|
timeout?: number;
|
|
268
|
-
customId?:
|
|
268
|
+
customId?: JSONRPCId;
|
|
269
269
|
}): {
|
|
270
|
-
id:
|
|
270
|
+
id: JSONRPCId;
|
|
271
271
|
promise: Promise<any>;
|
|
272
272
|
};
|
|
273
273
|
}
|
|
@@ -281,9 +281,9 @@ export declare class DataPendingOperations extends PendingOperationsBase {
|
|
|
281
281
|
*/
|
|
282
282
|
add(data: any, options?: {
|
|
283
283
|
timeout?: number;
|
|
284
|
-
customId?:
|
|
284
|
+
customId?: JSONRPCId;
|
|
285
285
|
}): {
|
|
286
|
-
id:
|
|
286
|
+
id: JSONRPCId;
|
|
287
287
|
};
|
|
288
288
|
}
|
|
289
289
|
/**
|
|
@@ -316,7 +316,11 @@ export declare class JSONRPCCall {
|
|
|
316
316
|
*/
|
|
317
317
|
handleRequest(method: string, params?: any, options?: {
|
|
318
318
|
timeout?: number;
|
|
319
|
-
|
|
319
|
+
customId?: JSONRPCId;
|
|
320
|
+
}): {
|
|
321
|
+
promise: Promise<any>;
|
|
322
|
+
request: JSONRPCRequest;
|
|
323
|
+
};
|
|
320
324
|
/**
|
|
321
325
|
* Get manager statistics
|
|
322
326
|
*/
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.7.
|
|
2
|
+
"version": "0.7.7",
|
|
3
3
|
"name": "modality-kit",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"scripts": {
|
|
29
29
|
"update-compile-sh": "yo reshow:compile-sh",
|
|
30
30
|
"build:clean": "find ./dist -name '*.*' | xargs rm -rf",
|
|
31
|
+
"dev": "bunx concurrently 'bunx --watch tsc -p ./' 'bun build:src -- --watch --sourcemap=inline'",
|
|
31
32
|
"build:types": "bunx tsc -p ./",
|
|
32
33
|
"build:src": "bun build src/index.ts --outdir dist",
|
|
33
34
|
"build": "bun run build:clean && bun run build:src && bun run build:types",
|