@camera.ui/common 0.0.14 → 0.0.15
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/cameraUtils/ffmpeg-process.d.ts +2 -2
- package/dist/cameraUtils/ffmpeg-process.js +2 -1
- package/dist/cameraUtils/ffmpeg-process.js.map +1 -1
- package/dist/cameraUtils/index.d.ts +0 -4
- package/dist/cameraUtils/index.js +0 -4
- package/dist/cameraUtils/index.js.map +1 -1
- package/dist/cameraUtils/mp4.js +1 -1
- package/dist/cameraUtils/mp4.js.map +1 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -8
- package/dist/index.js.map +1 -1
- package/dist/logger/index.d.ts +2 -2
- package/dist/utils/subscribed.d.ts +9 -0
- package/dist/utils/subscribed.js +16 -0
- package/dist/utils/subscribed.js.map +1 -1
- package/dist/utils/utils.d.ts +5 -0
- package/dist/utils/utils.js +38 -0
- package/dist/utils/utils.js.map +1 -1
- package/package.json +6 -32
- package/dist/cameraUtils/processor.d.ts +0 -49
- package/dist/cameraUtils/processor.js +0 -154
- package/dist/cameraUtils/processor.js.map +0 -1
- package/dist/cameraUtils/return-audio-transcoder.d.ts +0 -40
- package/dist/cameraUtils/return-audio-transcoder.js +0 -84
- package/dist/cameraUtils/return-audio-transcoder.js.map +0 -1
- package/dist/cameraUtils/srtp.d.ts +0 -8
- package/dist/cameraUtils/srtp.js +0 -22
- package/dist/cameraUtils/srtp.js.map +0 -1
- package/dist/cameraUtils/utils.d.ts +0 -1
- package/dist/cameraUtils/utils.js +0 -15
- package/dist/cameraUtils/utils.js.map +0 -1
- package/dist/messaging/index.d.ts +0 -48
- package/dist/messaging/index.js +0 -141
- package/dist/messaging/index.js.map +0 -1
- package/dist/nats/index.d.ts +0 -30
- package/dist/nats/index.js +0 -85
- package/dist/nats/index.js.map +0 -1
- package/dist/packer/index.d.ts +0 -2
- package/dist/packer/index.js +0 -17
- package/dist/packer/index.js.map +0 -1
- package/dist/python/index.d.ts +0 -48
- package/dist/python/index.js +0 -478
- package/dist/python/index.js.map +0 -1
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { FfmpegProcess } from './ffmpeg-process.js';
|
|
2
|
-
import { reservePorts } from './ports.js';
|
|
3
|
-
import { getSsrc } from './rtp.js';
|
|
4
|
-
import { createCryptoLine } from './srtp.js';
|
|
5
|
-
const defaultStartStreamReqeuest = {
|
|
6
|
-
audio: {
|
|
7
|
-
codec: 'AAC_eld',
|
|
8
|
-
channel: 1,
|
|
9
|
-
sample_rate: 16,
|
|
10
|
-
pt: 110,
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
export class ReturnAudioTranscoder {
|
|
14
|
-
options;
|
|
15
|
-
returnRtpSplitter;
|
|
16
|
-
startStreamRequest;
|
|
17
|
-
ffmpegProcess;
|
|
18
|
-
reservedPortsPromise = reservePorts({ count: 2 });
|
|
19
|
-
constructor(options) {
|
|
20
|
-
this.options = options;
|
|
21
|
-
this.startStreamRequest = this.options.startStreamRequest || defaultStartStreamReqeuest;
|
|
22
|
-
this.ffmpegProcess = new FfmpegProcess({
|
|
23
|
-
ffmpegArgs: [
|
|
24
|
-
'-hide_banner',
|
|
25
|
-
'-protocol_whitelist',
|
|
26
|
-
'pipe,udp,rtp,file,crypto',
|
|
27
|
-
'-f',
|
|
28
|
-
'sdp',
|
|
29
|
-
'-acodec',
|
|
30
|
-
this.startStreamRequest.audio.codec === 'OPUS' ? 'libopus' : 'libfdk_aac',
|
|
31
|
-
'-i',
|
|
32
|
-
'pipe:',
|
|
33
|
-
'-map',
|
|
34
|
-
'0:0',
|
|
35
|
-
...this.options.outputArgs,
|
|
36
|
-
],
|
|
37
|
-
...this.options,
|
|
38
|
-
});
|
|
39
|
-
// allow return audio splitter to be passed in if you want to create one in the prepare stream phase, and create the transcoder in the stream request phase
|
|
40
|
-
this.returnRtpSplitter = options.returnAudioSplitter;
|
|
41
|
-
}
|
|
42
|
-
async start() {
|
|
43
|
-
const [rtpPort, rtcpPort] = await this.reservedPortsPromise, { targetAddress, addressVersion, audio: { srtp_key: srtpKey, srtp_salt: srtpSalt }, } = this.options.prepareStreamRequest, { ssrc: incomingAudioSsrc, rtcpPort: incomingAudioRtcpPort } = this.options.incomingAudioOptions, { codec, sample_rate, channel, pt: packetType } = this.startStreamRequest.audio;
|
|
44
|
-
this.ffmpegProcess.writeStdin(
|
|
45
|
-
// This SDP was generated using ffmpeg, and describes the type of packets we expect to receive from HomeKit.
|
|
46
|
-
[
|
|
47
|
-
'v=0',
|
|
48
|
-
'o=- 0 0 IN IP4 127.0.0.1',
|
|
49
|
-
's=Talk',
|
|
50
|
-
`c=IN ${addressVersion.replace('v', '').toUpperCase()} ${targetAddress}`,
|
|
51
|
-
't=0 0',
|
|
52
|
-
'a=tool:libavformat 58.38.100',
|
|
53
|
-
`m=audio ${rtpPort} RTP/AVP ${packetType}`,
|
|
54
|
-
'b=AS:24',
|
|
55
|
-
...(codec === 'OPUS'
|
|
56
|
-
? [`a=rtpmap:${packetType} opus/${sample_rate}000/${channel}`, `a=fmtp:${packetType} minptime=10;useinbandfec=1`]
|
|
57
|
-
: [
|
|
58
|
-
`a=rtpmap:${packetType} MPEG4-GENERIC/${sample_rate}000/${channel}`,
|
|
59
|
-
`a=fmtp:${packetType} profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=F8F0212C00BC00`,
|
|
60
|
-
]),
|
|
61
|
-
createCryptoLine({
|
|
62
|
-
srtpKey,
|
|
63
|
-
srtpSalt,
|
|
64
|
-
}),
|
|
65
|
-
].join('\n'));
|
|
66
|
-
this.returnRtpSplitter.addMessageHandler(({ isRtpMessage, message }) => {
|
|
67
|
-
// This splitter will receive all audio-related packets from HomeKit.
|
|
68
|
-
// This includes RTP + RTCP for return audio, as well as RTCP for incoming audio
|
|
69
|
-
if (!isRtpMessage && getSsrc(message) === incomingAudioSsrc) {
|
|
70
|
-
return {
|
|
71
|
-
port: incomingAudioRtcpPort,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
port: isRtpMessage ? rtpPort : rtcpPort,
|
|
76
|
-
};
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
stop() {
|
|
80
|
-
this.ffmpegProcess.stop();
|
|
81
|
-
this.returnRtpSplitter.close();
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=return-audio-transcoder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"return-audio-transcoder.js","sourceRoot":"","sources":["../../src/cameraUtils/return-audio-transcoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAyB7C,MAAM,0BAA0B,GAAuB;IACrD,KAAK,EAAE;QACL,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,CAAC;QACV,WAAW,EAAE,EAAE;QACf,EAAE,EAAE,GAAG;KACR;CACF,CAAC;AAEF,MAAM,OAAO,qBAAqB;IAOtB;IANM,iBAAiB,CAAC;IAC1B,kBAAkB,CAAqB;IAC/B,aAAa,CAAgB;IAC7B,oBAAoB,GAAG,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IAElE,YACU,OASoC;QATpC,YAAO,GAAP,OAAO,CAS6B;QAE5C,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,IAAI,0BAA0B,CAAC;QAExF,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC;YACrC,UAAU,EAAE;gBACV,cAAc;gBACd,qBAAqB;gBACrB,0BAA0B;gBAC1B,IAAI;gBACJ,KAAK;gBACL,SAAS;gBACT,IAAI,CAAC,kBA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BAAkB,WAAW,OAAO,OAAO,EAAE;oBACnE,UAAU,UAAU,wGAAwG;iBAC7H,CAAC;YACN,gBAAgB,CAAC;gBACf,OAAO;gBACP,QAAQ;aACT,CAAC;SACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;QAEF,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,EAAE;YACrE,qEAAqE;YACrE,gFAAgF;YAChF,IAAI,CAAC,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,iBAAiB,EAAE,CAAC;gBAC5D,OAAO;oBACL,IAAI,EAAE,qBAAqB;iBAC5B,CAAC;YACJ,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;aACxC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,IAAI;QACT,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface SrtpOptions {
|
|
2
|
-
srtpKey: Buffer;
|
|
3
|
-
srtpSalt: Buffer;
|
|
4
|
-
}
|
|
5
|
-
export declare function encodeSrtpOptions({ srtpKey, srtpSalt }: SrtpOptions): string;
|
|
6
|
-
export declare function decodeSrtpOptions(encodedOptions: string): SrtpOptions;
|
|
7
|
-
export declare function createCryptoLine(srtpOptions: SrtpOptions): string;
|
|
8
|
-
export declare function generateSrtpOptions(): SrtpOptions;
|
package/dist/cameraUtils/srtp.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from 'node:crypto';
|
|
2
|
-
export function encodeSrtpOptions({ srtpKey, srtpSalt }) {
|
|
3
|
-
return Buffer.concat([srtpKey, srtpSalt]).toString('base64');
|
|
4
|
-
}
|
|
5
|
-
export function decodeSrtpOptions(encodedOptions) {
|
|
6
|
-
const crypto = Buffer.from(encodedOptions, 'base64');
|
|
7
|
-
return {
|
|
8
|
-
srtpKey: crypto.subarray(0, 16),
|
|
9
|
-
srtpSalt: crypto.subarray(16, 30),
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export function createCryptoLine(srtpOptions) {
|
|
13
|
-
const encodedOptions = encodeSrtpOptions(srtpOptions);
|
|
14
|
-
return `a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:${encodedOptions}`;
|
|
15
|
-
}
|
|
16
|
-
export function generateSrtpOptions() {
|
|
17
|
-
return {
|
|
18
|
-
srtpKey: randomBytes(16),
|
|
19
|
-
srtpSalt: randomBytes(14),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=srtp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"srtp.js","sourceRoot":"","sources":["../../src/cameraUtils/srtp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO1C,MAAM,UAAU,iBAAiB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAe;IAClE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,cAAsB;IACtD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IAErD,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC;QAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;KAClC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,WAAwB;IACvD,MAAM,cAAc,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAEtD,OAAO,6CAA6C,cAAc,EAAE,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,OAAO;QACL,OAAO,EAAE,WAAW,CAAC,EAAE,CAAC;QACxB,QAAQ,EAAE,WAAW,CAAC,EAAE,CAAC;KAC1B,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function timeoutPromise<T>(timeout: number, promise: Promise<T>): Promise<T>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export function timeoutPromise(timeout, promise) {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
const t = setTimeout(() => reject(new Error('Operation timed out')), timeout);
|
|
4
|
-
promise
|
|
5
|
-
.then((v) => {
|
|
6
|
-
clearTimeout(t);
|
|
7
|
-
resolve(v);
|
|
8
|
-
})
|
|
9
|
-
.catch((e) => {
|
|
10
|
-
clearTimeout(t);
|
|
11
|
-
reject(e);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/cameraUtils/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAI,OAAe,EAAE,OAAmB;IACpE,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACxC,MAAM,CAAC,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAE9E,OAAO;aACJ,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YACV,YAAY,CAAC,CAAC,CAAC,CAAC;YAChB,OAAO,CAAC,CAAC,CAAC,CAAC;QACb,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACX,YAAY,CAAC,CAAC,CAAC,CAAC;YAChB,MAAM,CAAC,CAAC,CAAC,CAAC;QACZ,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { CameraDelegates, PluginLogger } from '@camera.ui/types';
|
|
2
|
-
import type { ProxyConnection, ProxySubscription } from '../nats/index.js';
|
|
3
|
-
export declare const NATS_SERVER_SUBJECT = "camera.ui-server";
|
|
4
|
-
export interface DeserializedError {
|
|
5
|
-
name: string;
|
|
6
|
-
message: string;
|
|
7
|
-
stack: string;
|
|
8
|
-
}
|
|
9
|
-
export declare class RemoteError extends Error {
|
|
10
|
-
constructor(error: DeserializedError, cause: Omit<ProxyMessageStructure, 'error'>);
|
|
11
|
-
}
|
|
12
|
-
export interface QueueItem {
|
|
13
|
-
message: ProxyMessageStructure;
|
|
14
|
-
resolve: (response: any) => void;
|
|
15
|
-
reject: (error: RemoteError) => void;
|
|
16
|
-
}
|
|
17
|
-
export interface ProxyMessageStructure {
|
|
18
|
-
requestId: string;
|
|
19
|
-
cameraId?: string;
|
|
20
|
-
targetId: string;
|
|
21
|
-
targetName?: string;
|
|
22
|
-
pluginId: string;
|
|
23
|
-
type: 'request' | 'reply';
|
|
24
|
-
proxy: 'device' | 'camera' | 'plugin' | 'core';
|
|
25
|
-
client: 'cameraFn' | 'pluginFn' | 'deviceFn' | 'storageFn' | 'coreFn' | keyof CameraDelegates;
|
|
26
|
-
fn: string;
|
|
27
|
-
args: any[];
|
|
28
|
-
timeout: number;
|
|
29
|
-
timestamp: number;
|
|
30
|
-
response?: any;
|
|
31
|
-
error?: DeserializedError;
|
|
32
|
-
}
|
|
33
|
-
export declare class MessageQueue {
|
|
34
|
-
private logger;
|
|
35
|
-
private type;
|
|
36
|
-
private publisher;
|
|
37
|
-
private subscriber;
|
|
38
|
-
private requestHandler;
|
|
39
|
-
private aborted;
|
|
40
|
-
private isProcessing;
|
|
41
|
-
private queue;
|
|
42
|
-
private pendingResponses;
|
|
43
|
-
constructor(type: 'server' | 'client', publisher: ProxyConnection, subscriber: ProxySubscription, logger: PluginLogger, requestHandler: (message: ProxyMessageStructure) => void);
|
|
44
|
-
abortQueue(): void;
|
|
45
|
-
enqueue(message: ProxyMessageStructure): Promise<any>;
|
|
46
|
-
private processQueue;
|
|
47
|
-
private onMessage;
|
|
48
|
-
}
|
package/dist/messaging/index.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { unpack } from '../packer/index.js';
|
|
2
|
-
export const NATS_SERVER_SUBJECT = 'camera.ui-server';
|
|
3
|
-
export class RemoteError extends Error {
|
|
4
|
-
constructor(error, cause) {
|
|
5
|
-
super(error.message);
|
|
6
|
-
this.name = error.name;
|
|
7
|
-
this.cause = cause;
|
|
8
|
-
if (error.stack && error.stack !== '') {
|
|
9
|
-
this.stack = error.stack;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export class MessageQueue {
|
|
14
|
-
logger;
|
|
15
|
-
type;
|
|
16
|
-
publisher;
|
|
17
|
-
subscriber;
|
|
18
|
-
requestHandler;
|
|
19
|
-
aborted = false;
|
|
20
|
-
isProcessing = false;
|
|
21
|
-
queue = [];
|
|
22
|
-
pendingResponses = new Map();
|
|
23
|
-
constructor(type, publisher, subscriber, logger, requestHandler) {
|
|
24
|
-
this.type = type;
|
|
25
|
-
this.logger = logger;
|
|
26
|
-
this.publisher = publisher;
|
|
27
|
-
this.subscriber = subscriber;
|
|
28
|
-
this.requestHandler = requestHandler;
|
|
29
|
-
this.subscriber.on('message', this.onMessage.bind(this));
|
|
30
|
-
}
|
|
31
|
-
abortQueue() {
|
|
32
|
-
this.aborted = true;
|
|
33
|
-
this.isProcessing = false;
|
|
34
|
-
while (this.queue.length > 0) {
|
|
35
|
-
const item = this.queue.shift();
|
|
36
|
-
const remoteError = new RemoteError({
|
|
37
|
-
name: 'AbortError',
|
|
38
|
-
message: 'Message processing aborted',
|
|
39
|
-
stack: '',
|
|
40
|
-
}, item.message);
|
|
41
|
-
item.reject(remoteError);
|
|
42
|
-
}
|
|
43
|
-
for (const [requestId, { reject, message }] of this.pendingResponses) {
|
|
44
|
-
const remoteError = new RemoteError({
|
|
45
|
-
name: 'AbortError',
|
|
46
|
-
message: 'Request aborted due to queue abort',
|
|
47
|
-
stack: '',
|
|
48
|
-
}, message);
|
|
49
|
-
reject(remoteError);
|
|
50
|
-
this.pendingResponses.delete(requestId);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
async enqueue(message) {
|
|
54
|
-
if (message.type === 'request' && message.timeout > 0) {
|
|
55
|
-
// console.log(`${this.type.toUpperCase()} => Enqueueing message:`, message);
|
|
56
|
-
const promise = new Promise((_resolve, _reject) => {
|
|
57
|
-
const queueItem = {
|
|
58
|
-
message,
|
|
59
|
-
resolve: _resolve,
|
|
60
|
-
reject: _reject,
|
|
61
|
-
};
|
|
62
|
-
this.queue.push(queueItem);
|
|
63
|
-
});
|
|
64
|
-
if (!this.isProcessing) {
|
|
65
|
-
this.processQueue();
|
|
66
|
-
}
|
|
67
|
-
return promise;
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
const targetId = this.type === 'server' ? message.targetId : NATS_SERVER_SUBJECT;
|
|
71
|
-
this.publisher.publish(targetId, message);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
processQueue() {
|
|
75
|
-
if (this.isProcessing || this.queue.length === 0 || this.aborted) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
this.isProcessing = true;
|
|
79
|
-
while (this.queue.length && !this.aborted) {
|
|
80
|
-
const currentItem = this.queue.shift();
|
|
81
|
-
// console.log(`${this.type.toUpperCase()} => Sending request to ${this.type === 'server' ? 'CLIENT' : 'SERVER'}:`, currentItem.message);
|
|
82
|
-
const cleanup = () => {
|
|
83
|
-
clearTimeout(timeout);
|
|
84
|
-
this.pendingResponses.delete(currentItem.message.requestId);
|
|
85
|
-
};
|
|
86
|
-
const timeout = setTimeout(() => {
|
|
87
|
-
const remoteError = new RemoteError({
|
|
88
|
-
name: 'TimeoutError',
|
|
89
|
-
message: `Request timed out after ${currentItem.message.timeout}ms`,
|
|
90
|
-
stack: '',
|
|
91
|
-
}, currentItem.message);
|
|
92
|
-
currentItem.reject(remoteError);
|
|
93
|
-
cleanup();
|
|
94
|
-
}, currentItem.message.timeout);
|
|
95
|
-
this.pendingResponses.set(currentItem.message.requestId, {
|
|
96
|
-
message: currentItem.message,
|
|
97
|
-
resolve: (response) => {
|
|
98
|
-
currentItem.resolve(response);
|
|
99
|
-
cleanup();
|
|
100
|
-
},
|
|
101
|
-
reject: (error) => {
|
|
102
|
-
currentItem.reject(error);
|
|
103
|
-
cleanup();
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
const targetId = this.type === 'server' ? currentItem.message.targetId : NATS_SERVER_SUBJECT;
|
|
107
|
-
this.publisher.publish(targetId, currentItem.message);
|
|
108
|
-
}
|
|
109
|
-
this.isProcessing = false;
|
|
110
|
-
}
|
|
111
|
-
async onMessage(msg) {
|
|
112
|
-
if (this.aborted) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const message = unpack(msg.data);
|
|
116
|
-
if (message.type === 'reply') {
|
|
117
|
-
// console.log(`${this.type.toUpperCase()} => Received reply from ${this.type === 'server' ? 'CLIENT' : 'SERVER'}:`, message);
|
|
118
|
-
const currentItem = this.pendingResponses.get(message.requestId);
|
|
119
|
-
if (!currentItem) {
|
|
120
|
-
// this.logger.error(`Unknown reply from ${this.type === 'server' ? 'client' : 'server'}:`, message);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if (message.error) {
|
|
124
|
-
const { error, ...cause } = message;
|
|
125
|
-
const remoteError = new RemoteError(error, cause);
|
|
126
|
-
currentItem.reject(remoteError);
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
currentItem.resolve(message.response);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
else if (message.type === 'request') {
|
|
133
|
-
// console.log(`${this.type.toUpperCase()} => Received request from ${this.type === 'server' ? 'CLIENT' : 'SERVER'}:`, message);
|
|
134
|
-
this.requestHandler(message);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
this.logger.error('Invalid message type received:', message);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/messaging/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAM5C,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAQtD,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,YAAY,KAAwB,EAAE,KAA2C;QAC/E,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAErB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,IAAI,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,KAAK,EAAE,EAAE,CAAC;YACtC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAC3B,CAAC;IACH,CAAC;CACF;AAyBD,MAAM,OAAO,YAAY;IACf,MAAM,CAAe;IACrB,IAAI,CAAsB;IAE1B,SAAS,CAAkB;IAC3B,UAAU,CAAoB;IAC9B,cAAc,CAA2C;IAEzD,OAAO,GAAG,KAAK,CAAC;IAChB,YAAY,GAAG,KAAK,CAAC;IACrB,KAAK,GAAgB,EAAE,CAAC;IACxB,gBAAgB,GAAG,IAAI,GAAG,EAAqB,CAAC;IAExD,YACE,IAAyB,EACzB,SAA0B,EAC1B,UAA6B,EAC7B,MAAoB,EACpB,cAAwD;QAExD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB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,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC7B,8HAA8H;YAE9H,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YACjE,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,qGAAqG;gBACrG,OAAO;YACT,CAAC;YAED,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;gBAClB,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;gBACpC,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBAClD,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YAClC,CAAC;iBAAM,CAAC;gBACN,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACxC,CAAC;QACH,CAAC;aAAM,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YACtC,gIAAgI;YAEhI,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;CACF"}
|
package/dist/nats/index.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import type { Msg, NatsConnection, Subscription as NatsSubscription, RequestOptions } from 'nats';
|
|
3
|
-
export interface AuthConfig {
|
|
4
|
-
user: string;
|
|
5
|
-
password: string;
|
|
6
|
-
}
|
|
7
|
-
export declare interface ProxySubscription {
|
|
8
|
-
on(event: 'message', listener: (message: Msg) => void): this;
|
|
9
|
-
emit(event: 'message', message: Msg): boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare class ProxySubscription extends EventEmitter implements ProxySubscription {
|
|
12
|
-
readonly subscriber: NatsSubscription;
|
|
13
|
-
constructor(subscriber: NatsSubscription);
|
|
14
|
-
listen(): Promise<void>;
|
|
15
|
-
close(): void;
|
|
16
|
-
}
|
|
17
|
-
export declare class ProxyConnection {
|
|
18
|
-
private name;
|
|
19
|
-
private servers;
|
|
20
|
-
private auth;
|
|
21
|
-
private publisher?;
|
|
22
|
-
private subscribers;
|
|
23
|
-
private closed;
|
|
24
|
-
constructor(name: string, servers: string[], auth: AuthConfig);
|
|
25
|
-
connect(): Promise<NatsConnection>;
|
|
26
|
-
subscribe(subject: string, skipListening?: boolean): ProxySubscription;
|
|
27
|
-
publish(subject: string, message: any): void;
|
|
28
|
-
request(subject: string, message: any, opts?: RequestOptions): Promise<any>;
|
|
29
|
-
close(): Promise<void>;
|
|
30
|
-
}
|
package/dist/nats/index.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import { connect } from 'nats';
|
|
3
|
-
import { pack, unpack } from '../packer/index.js';
|
|
4
|
-
export class ProxySubscription extends EventEmitter {
|
|
5
|
-
subscriber;
|
|
6
|
-
constructor(subscriber) {
|
|
7
|
-
super();
|
|
8
|
-
this.subscriber = subscriber;
|
|
9
|
-
}
|
|
10
|
-
async listen() {
|
|
11
|
-
for await (const msg of this.subscriber) {
|
|
12
|
-
if (msg.data.length == 0) {
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
this.emit('message', msg);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
close() {
|
|
19
|
-
this.removeAllListeners();
|
|
20
|
-
this.subscriber.unsubscribe();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export class ProxyConnection {
|
|
24
|
-
name;
|
|
25
|
-
servers = [];
|
|
26
|
-
auth;
|
|
27
|
-
publisher;
|
|
28
|
-
subscribers = [];
|
|
29
|
-
closed = false;
|
|
30
|
-
constructor(name, servers, auth) {
|
|
31
|
-
this.name = name;
|
|
32
|
-
this.servers = servers;
|
|
33
|
-
this.auth = auth;
|
|
34
|
-
}
|
|
35
|
-
async connect() {
|
|
36
|
-
this.publisher = await connect({
|
|
37
|
-
servers: this.servers,
|
|
38
|
-
name: this.name,
|
|
39
|
-
maxReconnectAttempts: -1,
|
|
40
|
-
noAsyncTraces: true,
|
|
41
|
-
user: this.auth.user,
|
|
42
|
-
pass: this.auth.password,
|
|
43
|
-
});
|
|
44
|
-
return this.publisher;
|
|
45
|
-
}
|
|
46
|
-
subscribe(subject, skipListening) {
|
|
47
|
-
if (!this.publisher || this.publisher.isClosed()) {
|
|
48
|
-
throw new Error('Connection not established');
|
|
49
|
-
}
|
|
50
|
-
const subscriber = new ProxySubscription(this.publisher.subscribe(subject));
|
|
51
|
-
if (!skipListening) {
|
|
52
|
-
subscriber.listen();
|
|
53
|
-
}
|
|
54
|
-
this.subscribers.push(subscriber);
|
|
55
|
-
return subscriber;
|
|
56
|
-
}
|
|
57
|
-
publish(subject, message) {
|
|
58
|
-
if (this.closed) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (!this.publisher || this.publisher.isClosed()) {
|
|
62
|
-
throw new Error('Connection not established');
|
|
63
|
-
}
|
|
64
|
-
this.publisher.publish(subject, pack(message));
|
|
65
|
-
}
|
|
66
|
-
async request(subject, message, opts) {
|
|
67
|
-
if (this.closed) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (!this.publisher || this.publisher.isClosed()) {
|
|
71
|
-
throw new Error('Connection not established');
|
|
72
|
-
}
|
|
73
|
-
const msg = await this.publisher.request(subject, pack(message), opts);
|
|
74
|
-
const response = unpack(msg.data);
|
|
75
|
-
return response;
|
|
76
|
-
}
|
|
77
|
-
async close() {
|
|
78
|
-
this.closed = true;
|
|
79
|
-
for (const subscriber of this.subscribers) {
|
|
80
|
-
subscriber.close();
|
|
81
|
-
}
|
|
82
|
-
await this.publisher?.close();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
//# sourceMappingURL=index.js.map
|
package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,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;QACvE,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAElC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QAEnB,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YAC1C,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;QAED,MAAM,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC;IAChC,CAAC;CACF"}
|
package/dist/packer/index.d.ts
DELETED
package/dist/packer/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Packr, Unpackr } from 'msgpackr';
|
|
2
|
-
const packr = new Packr({
|
|
3
|
-
useRecords: false,
|
|
4
|
-
encodeUndefinedAsNil: true,
|
|
5
|
-
int64AsType: 'number',
|
|
6
|
-
});
|
|
7
|
-
const unpackr = new Unpackr({
|
|
8
|
-
useRecords: false,
|
|
9
|
-
int64AsType: 'number',
|
|
10
|
-
});
|
|
11
|
-
export const pack = (message) => {
|
|
12
|
-
return packr.pack(message);
|
|
13
|
-
};
|
|
14
|
-
export const unpack = (message) => {
|
|
15
|
-
return unpackr.unpack(message);
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
package/dist/packer/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/packer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC;IACtB,UAAU,EAAE,KAAK;IACjB,oBAAoB,EAAE,IAAI;IAC1B,WAAW,EAAE,QAAQ;CACtB,CAAC,CAAC;AAEH,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC;IAC1B,UAAU,EAAE,KAAK;IACjB,WAAW,EAAE,QAAQ;CACtB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,OAAY,EAAU,EAAE;IAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAU,OAA4B,EAAK,EAAE;IACjE,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC,CAAC"}
|
package/dist/python/index.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { PortablePython } from '@bjia56/portable-python';
|
|
2
|
-
import { Logger } from '../logger/index.js';
|
|
3
|
-
import type { LoggerOptions } from '../logger/index.js';
|
|
4
|
-
export declare const DEFAULT_PY_VERSION = "3.11";
|
|
5
|
-
export declare class PythonInstaller {
|
|
6
|
-
static readonly versions: string[];
|
|
7
|
-
logger: Logger;
|
|
8
|
-
readonly python: PortablePython;
|
|
9
|
-
readonly venvPath?: string;
|
|
10
|
-
readonly installPath: string;
|
|
11
|
-
private identifier;
|
|
12
|
-
private needsUpdate;
|
|
13
|
-
get isInstalled(): boolean;
|
|
14
|
-
get pluginPythonPath(): string;
|
|
15
|
-
get serverPythonPath(): string;
|
|
16
|
-
get pluginPackagesPath(): string;
|
|
17
|
-
get serverPackagesPath(): string;
|
|
18
|
-
get version(): string;
|
|
19
|
-
private get logPrefix();
|
|
20
|
-
constructor(homePath: string, identifier: string, venvDir?: string, version?: string, loggerOptions?: LoggerOptions);
|
|
21
|
-
install(type: 'plugin' | 'server', requirementsPath?: string): Promise<void>;
|
|
22
|
-
installPluginPython(): Promise<void>;
|
|
23
|
-
uninstall(): Promise<void>;
|
|
24
|
-
updatePluginDependencies(requirementsPath: string): Promise<void>;
|
|
25
|
-
updateServerDependencies(requirementsPath: string): Promise<void>;
|
|
26
|
-
installPluginPackages(pkgs: string[]): Promise<string>;
|
|
27
|
-
installServerPackages(pkgs: string[]): Promise<string>;
|
|
28
|
-
reinstallPluginPackes(pkgs: string[]): Promise<string>;
|
|
29
|
-
reinstallServerPackages(pkgs: string[]): Promise<string>;
|
|
30
|
-
uninstallPluginPackages(pkgs: string[]): Promise<string>;
|
|
31
|
-
uninstallServerPackages(pkgs: string[]): Promise<string>;
|
|
32
|
-
private installPluginRequirements;
|
|
33
|
-
private installServerRequirements;
|
|
34
|
-
private updateRequirements;
|
|
35
|
-
private analyzeDependencies;
|
|
36
|
-
private updateDependencies;
|
|
37
|
-
private installRequirements;
|
|
38
|
-
private installPackages;
|
|
39
|
-
private uninstallPackages;
|
|
40
|
-
private reinstallPackages;
|
|
41
|
-
private ensureVenv;
|
|
42
|
-
private createVenv;
|
|
43
|
-
private removeVenv;
|
|
44
|
-
private removeOldVersions;
|
|
45
|
-
private getMajorMinorVersion;
|
|
46
|
-
private cleanPackageName;
|
|
47
|
-
private difference;
|
|
48
|
-
}
|