@push.rocks/smartrust 1.2.1 → 1.3.0
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/changelog.md +11 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.linescanner.d.ts +18 -0
- package/dist_ts/classes.linescanner.js +43 -0
- package/dist_ts/classes.rustbridge.d.ts +19 -16
- package/dist_ts/classes.rustbridge.js +86 -152
- package/dist_ts/classes.sockettransport.d.ts +48 -0
- package/dist_ts/classes.sockettransport.js +138 -0
- package/dist_ts/classes.stdiotransport.d.ts +35 -0
- package/dist_ts/classes.stdiotransport.js +136 -0
- package/dist_ts/index.d.ts +3 -0
- package/dist_ts/index.js +4 -1
- package/dist_ts/interfaces/config.d.ts +13 -0
- package/dist_ts/interfaces/index.d.ts +1 -0
- package/dist_ts/interfaces/index.js +2 -1
- package/dist_ts/interfaces/transport.d.ts +22 -0
- package/dist_ts/interfaces/transport.js +2 -0
- package/dist_ts/plugins.d.ts +2 -1
- package/dist_ts/plugins.js +3 -2
- package/package.json +1 -1
- package/test/helpers/mock-socket-server.mjs +124 -0
- package/test/test.linescanner.node.ts +89 -0
- package/test/test.sockettransport.node.ts +312 -0
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.linescanner.ts +51 -0
- package/ts/classes.rustbridge.ts +93 -147
- package/ts/classes.sockettransport.ts +187 -0
- package/ts/classes.stdiotransport.ts +149 -0
- package/ts/index.ts +3 -0
- package/ts/interfaces/config.ts +14 -0
- package/ts/interfaces/index.ts +1 -0
- package/ts/interfaces/transport.ts +26 -0
- package/ts/plugins.ts +2 -1
package/ts/interfaces/config.ts
CHANGED
|
@@ -45,3 +45,17 @@ export interface IRustBridgeOptions extends IBinaryLocatorOptions {
|
|
|
45
45
|
* Resets on each chunk received. */
|
|
46
46
|
streamTimeoutMs?: number;
|
|
47
47
|
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Options for connecting to an already-running daemon via Unix socket or named pipe.
|
|
51
|
+
*/
|
|
52
|
+
export interface ISocketConnectOptions {
|
|
53
|
+
/** Enable auto-reconnect on unexpected disconnect (default: false) */
|
|
54
|
+
autoReconnect?: boolean;
|
|
55
|
+
/** Initial delay between reconnect attempts in ms (default: 100) */
|
|
56
|
+
reconnectBaseDelayMs?: number;
|
|
57
|
+
/** Maximum delay between reconnect attempts in ms (default: 30000) */
|
|
58
|
+
reconnectMaxDelayMs?: number;
|
|
59
|
+
/** Maximum number of reconnect attempts before giving up (default: 10) */
|
|
60
|
+
maxReconnectAttempts?: number;
|
|
61
|
+
}
|
package/ts/interfaces/index.ts
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type * as plugins from '../plugins.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Abstract transport for communicating with a Rust process.
|
|
5
|
+
* Both stdio and socket transports implement this interface.
|
|
6
|
+
*
|
|
7
|
+
* Events emitted:
|
|
8
|
+
* - 'line' (line: string) — a complete newline-terminated JSON line received
|
|
9
|
+
* - 'error' (err: Error) — transport-level error
|
|
10
|
+
* - 'close' (...args: any[]) — transport has closed/disconnected
|
|
11
|
+
* - 'stderr' (line: string) — stderr output (stdio transport only)
|
|
12
|
+
* - 'reconnected' () — transport reconnected after unexpected disconnect (socket only)
|
|
13
|
+
*/
|
|
14
|
+
export interface IRustTransport extends plugins.events.EventEmitter {
|
|
15
|
+
/** Connect the transport (spawn process or connect to socket). Resolves when I/O channel is open. */
|
|
16
|
+
connect(): Promise<void>;
|
|
17
|
+
|
|
18
|
+
/** Write a string to the transport. Handles backpressure. */
|
|
19
|
+
write(data: string): Promise<void>;
|
|
20
|
+
|
|
21
|
+
/** Disconnect the transport. For stdio: kills the process. For socket: closes the connection. */
|
|
22
|
+
disconnect(): void;
|
|
23
|
+
|
|
24
|
+
/** Whether the transport is currently connected and writable. */
|
|
25
|
+
readonly connected: boolean;
|
|
26
|
+
}
|
package/ts/plugins.ts
CHANGED
|
@@ -4,8 +4,9 @@ import * as fs from 'fs';
|
|
|
4
4
|
import * as childProcess from 'child_process';
|
|
5
5
|
import * as events from 'events';
|
|
6
6
|
import * as url from 'url';
|
|
7
|
+
import * as net from 'net';
|
|
7
8
|
|
|
8
|
-
export { path, fs, childProcess, events, url };
|
|
9
|
+
export { path, fs, childProcess, events, url, net };
|
|
9
10
|
|
|
10
11
|
// @push.rocks scope
|
|
11
12
|
import * as smartpath from '@push.rocks/smartpath';
|