@olane/o-core 0.7.12-alpha.51 → 0.7.12-alpha.53
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import os from 'os';
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as os from 'os';
|
|
3
3
|
export const DEFAULT_CONFIG_PATH = path.join(os.homedir(), '.olane');
|
|
4
4
|
export const DEFAULT_INSTANCE_PATH = path.join(DEFAULT_CONFIG_PATH, 'os-instances');
|
|
5
5
|
export const DEFAULT_CONFIG_FILE = path.join(DEFAULT_CONFIG_PATH, 'config.json');
|
|
@@ -24,7 +24,19 @@ export declare class CoreUtils extends oObject {
|
|
|
24
24
|
static phraseToSeedBytes(phrase: string): Uint8Array;
|
|
25
25
|
static phraseToSeed(phrase: string): string;
|
|
26
26
|
static childAddress(parentAddress: oAddress, childAddress: oAddress): oAddress;
|
|
27
|
+
/**
|
|
28
|
+
* Sends a response through a stream
|
|
29
|
+
* Consolidated method that handles both regular and streaming responses
|
|
30
|
+
*
|
|
31
|
+
* @param response - The response to send
|
|
32
|
+
* @param stream - The stream to send the response through
|
|
33
|
+
*/
|
|
27
34
|
static sendResponse(response: oResponse, stream: Stream): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated Use sendResponse instead - both methods are now identical
|
|
37
|
+
* Sends a streaming response through a stream
|
|
38
|
+
* This method is maintained for backward compatibility
|
|
39
|
+
*/
|
|
28
40
|
static sendStreamResponse(response: oResponse, stream: Stream): Promise<void>;
|
|
29
41
|
static processStream(event: any): Promise<any>;
|
|
30
42
|
static processStreamRequest(event: any): Promise<oRequest>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.utils.d.ts","sourceRoot":"","sources":["../../../src/utils/core.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAGP,MAAM,iBAAiB,CAAC;A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,33 +75,43 @@ export class CoreUtils extends oObject {
|
|
|
75
75
|
static childAddress(parentAddress, childAddress) {
|
|
76
76
|
return new oAddress(parentAddress.toString() + '/' + childAddress.paths);
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Sends a response through a stream
|
|
80
|
+
* Consolidated method that handles both regular and streaming responses
|
|
81
|
+
*
|
|
82
|
+
* @param response - The response to send
|
|
83
|
+
* @param stream - The stream to send the response through
|
|
84
|
+
*/
|
|
78
85
|
static async sendResponse(response, stream) {
|
|
79
|
-
if (stream.status !== 'open') {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
try {
|
|
83
|
-
await stream.send(new TextEncoder().encode(response.toString()));
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
console.error('Error sending response: ', error);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
static async sendStreamResponse(response, stream) {
|
|
90
86
|
const utils = new CoreUtils();
|
|
91
87
|
if (!stream || stream.status !== 'open') {
|
|
92
|
-
utils.logger.warn('Stream is not open. Status: ' + stream?.status || 'undefined');
|
|
88
|
+
utils.logger.warn('Stream is not open. Status: ' + (stream?.status || 'undefined'));
|
|
93
89
|
return;
|
|
94
90
|
}
|
|
95
91
|
try {
|
|
96
92
|
await stream.send(new TextEncoder().encode(response.toString()));
|
|
97
93
|
}
|
|
98
94
|
catch (error) {
|
|
99
|
-
utils.logger.error('Error sending
|
|
95
|
+
utils.logger.error('Error sending response: ', error);
|
|
100
96
|
}
|
|
101
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* @deprecated Use sendResponse instead - both methods are now identical
|
|
100
|
+
* Sends a streaming response through a stream
|
|
101
|
+
* This method is maintained for backward compatibility
|
|
102
|
+
*/
|
|
103
|
+
static async sendStreamResponse(response, stream) {
|
|
104
|
+
return CoreUtils.sendResponse(response, stream);
|
|
105
|
+
}
|
|
102
106
|
static async processStream(event) {
|
|
103
107
|
const bytes = event.data instanceof Uint8ArrayList ? event.data.subarray() : event.data;
|
|
104
|
-
|
|
108
|
+
const decoded = new TextDecoder().decode(bytes);
|
|
109
|
+
if (decoded.startsWith('{')) {
|
|
110
|
+
return JSON.parse(decoded);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
return decoded;
|
|
114
|
+
}
|
|
105
115
|
}
|
|
106
116
|
static async processStreamRequest(event) {
|
|
107
117
|
const req = await CoreUtils.processStream(event);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-core",
|
|
3
|
-
"version": "0.7.12-alpha.
|
|
3
|
+
"version": "0.7.12-alpha.53",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -63,11 +63,11 @@
|
|
|
63
63
|
"typescript": "^5.8.3"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@olane/o-protocol": "0.7.12-alpha.
|
|
66
|
+
"@olane/o-protocol": "0.7.12-alpha.53",
|
|
67
67
|
"chalk": "^5.4.1",
|
|
68
68
|
"debug": "^4.4.1",
|
|
69
69
|
"dotenv": "^16.5.0",
|
|
70
70
|
"multiformats": "^13.3.7"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "f6cd4162b80dd265aba3a8bf322a009fa0ff81e4"
|
|
73
73
|
}
|