tirtc-devtools-cli 0.0.13 → 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/README.md +42 -46
- package/USAGE.md +87 -312
- package/dist/cli/src/embedded_paths.d.ts +0 -2
- package/dist/cli/src/embedded_paths.js +3 -25
- package/dist/cli/src/index.js +82 -584
- package/dist/cli/src/role_driver.d.ts +33 -0
- package/dist/cli/src/role_driver.js +500 -0
- package/dist/cli/src/token_command.js +4 -2
- package/dist/cli/src/token_issue.d.ts +9 -0
- package/dist/cli/src/token_issue.js +138 -0
- package/dist/cli/src/token_tool.d.ts +2 -4
- package/dist/cli/src/token_tool.js +12 -186
- package/package.json +3 -2
- package/vendor/devtools/driver/macos-arm64/devtools_driver_probe +0 -0
- package/vendor/devtools/driver/macos-arm64/runtime_validation_client_bin +0 -0
- package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio.h +56 -2
- package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_io.h +9 -0
- package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/av.h +52 -0
- package/vendor/{app-server/bin/runtime/linux-x64 → runtime/macos-arm64}/include/tirtc/error.h +11 -0
- package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/media_downlink.h +11 -5
- package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/media_uplink.h +4 -0
- package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/transport.h +52 -15
- package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/trp.h +7 -5
- package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_codec.h +41 -0
- package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_io.h +7 -0
- package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_io_android.h +2 -0
- package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libmatrix_runtime_audio.a +0 -0
- package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_facade.a +0 -0
- package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libmatrix_runtime_foundation_http.a +0 -0
- package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libmatrix_runtime_foundation_logging.a +0 -0
- package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_media.a +0 -0
- package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_transport.a +0 -0
- package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_video.a +0 -0
- package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/manifest.txt +20 -25
- package/vendor/runtime/script/prepare_runtime_media_dataset.sh +308 -12
- package/dist/app-server/protocol-client/index.d.ts +0 -25
- package/dist/app-server/protocol-client/index.js +0 -114
- package/dist/cli/src/bootstrap_flows.d.ts +0 -46
- package/dist/cli/src/bootstrap_flows.js +0 -249
- package/dist/cli/src/config.d.ts +0 -26
- package/dist/cli/src/config.js +0 -62
- package/dist/cli/src/facade.d.ts +0 -430
- package/dist/cli/src/facade.js +0 -170
- package/dist/cli/src/guide.d.ts +0 -1
- package/dist/cli/src/guide.js +0 -48
- package/dist/cli/src/session_manager.d.ts +0 -25
- package/dist/cli/src/session_manager.js +0 -391
- package/dist/cli/src/transport.d.ts +0 -30
- package/dist/cli/src/transport.js +0 -84
- package/vendor/app-server/bin/native/linux-x64/credential_napi.node +0 -0
- package/vendor/app-server/bin/native/macos-arm64/credential_napi.node +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/credential.h +0 -34
- package/vendor/app-server/bin/runtime/linux-x64/lib/libcrypto.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_credential.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_http.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_logging.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libssl.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libxlog.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/manifest.txt +0 -4
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/credential.h +0 -34
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/error.h +0 -52
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/foundation/build_info.h +0 -27
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/http.h +0 -57
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/logging.h +0 -55
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_fixture_av_sync.h +0 -61
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_fixture_source.h +0 -77
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_live_source.h +0 -71
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_credential.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_facade.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_media.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_transport.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_video.a +0 -0
- package/vendor/app-server/bin/tirtc-devtool-host.js +0 -2
- package/vendor/app-server/dist/host/ArtifactManager.d.ts +0 -18
- package/vendor/app-server/dist/host/ArtifactManager.js +0 -98
- package/vendor/app-server/dist/host/HostCommandCoordinator.d.ts +0 -19
- package/vendor/app-server/dist/host/HostCommandCoordinator.js +0 -196
- package/vendor/app-server/dist/host/HostProtocol.d.ts +0 -103
- package/vendor/app-server/dist/host/HostProtocol.js +0 -239
- package/vendor/app-server/dist/host/HostServer.d.ts +0 -52
- package/vendor/app-server/dist/host/HostServer.js +0 -727
- package/vendor/app-server/dist/host/HostState.d.ts +0 -69
- package/vendor/app-server/dist/host/HostState.js +0 -19
- package/vendor/app-server/dist/host/RuntimeAdapter.d.ts +0 -95
- package/vendor/app-server/dist/host/RuntimeAdapter.js +0 -636
- package/vendor/app-server/dist/host/RuntimeReceiveWorker.d.ts +0 -37
- package/vendor/app-server/dist/host/RuntimeReceiveWorker.js +0 -186
- package/vendor/app-server/dist/host/RuntimeSendWorker.d.ts +0 -58
- package/vendor/app-server/dist/host/RuntimeSendWorker.js +0 -438
- package/vendor/app-server/dist/host/TokenTool.d.ts +0 -15
- package/vendor/app-server/dist/host/TokenTool.js +0 -84
- package/vendor/app-server/dist/host/WebPreviewGateway.d.ts +0 -28
- package/vendor/app-server/dist/host/WebPreviewGateway.js +0 -815
- package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.d.ts +0 -23
- package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.js +0 -115
- package/vendor/app-server/dist/host/native/RuntimeHostBridge.d.ts +0 -32
- package/vendor/app-server/dist/host/native/RuntimeHostBridge.js +0 -157
- package/vendor/app-server/dist/host/runtime_backed_preflight.d.ts +0 -10
- package/vendor/app-server/dist/host/runtime_backed_preflight.js +0 -78
- package/vendor/app-server/dist/host/tests/helpers/host_socket_client.d.ts +0 -28
- package/vendor/app-server/dist/host/tests/helpers/host_socket_client.js +0 -85
- package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.d.ts +0 -10
- package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.js +0 -41
- package/vendor/app-server/dist/host/tests/helpers/runtime_test_env.d.ts +0 -11
- package/vendor/app-server/dist/host/tests/helpers/runtime_test_env.js +0 -32
- package/vendor/app-server/dist/protocol/contract.d.ts +0 -1128
- package/vendor/app-server/dist/protocol/contract.js +0 -217
- package/vendor/app-server/dist/protocol-client/index.d.ts +0 -25
- package/vendor/app-server/dist/protocol-client/index.js +0 -114
- package/vendor/app-server/dist/src/index.d.ts +0 -1
- package/vendor/app-server/dist/src/index.js +0 -294
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_codec.h +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_frame.h +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_io_android.h +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_io_apple.h +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_io_harmony.h +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_io_windows.h +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_processing.h +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_sample_rate.h +0 -0
- /package/vendor/{app-server/bin/runtime/linux-x64 → runtime/macos-arm64}/include/tirtc/foundation/build_info.h +0 -0
- /package/vendor/{app-server/bin/runtime/linux-x64 → runtime/macos-arm64}/include/tirtc/http.h +0 -0
- /package/vendor/{app-server/bin/runtime/linux-x64 → runtime/macos-arm64}/include/tirtc/logging.h +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/media_codec.h +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_frame.h +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_io_apple.h +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_io_harmony.h +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_io_windows.h +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_processing.h +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libTGTRP.a +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libTiRTC.a +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libcrypto.a +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libcrypto.dylib +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libssl.a +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libssl.dylib +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libtgrtc.dylib +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libwebrtc_apm.a +0 -0
- /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libxlog.a +0 -0
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.RuntimeReceiveWorkerManager = void 0;
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
39
|
-
const RuntimeHostBridge_1 = require("./native/RuntimeHostBridge");
|
|
40
|
-
function ensureDir(dirPath) {
|
|
41
|
-
if (!fs.existsSync(dirPath)) {
|
|
42
|
-
fs.mkdirSync(dirPath, { recursive: true });
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function nowIsoString() {
|
|
46
|
-
return new Date().toISOString();
|
|
47
|
-
}
|
|
48
|
-
function sameDesiredConfig(left, right) {
|
|
49
|
-
return left.serviceEntry === right.serviceEntry &&
|
|
50
|
-
left.peerId === right.peerId &&
|
|
51
|
-
left.token === right.token &&
|
|
52
|
-
left.audioEnabled === right.audioEnabled &&
|
|
53
|
-
left.videoEnabled === right.videoEnabled &&
|
|
54
|
-
left.audioStreamId === right.audioStreamId &&
|
|
55
|
-
left.videoStreamId === right.videoStreamId &&
|
|
56
|
-
left.audioOutputPath === right.audioOutputPath &&
|
|
57
|
-
left.videoOutputPath === right.videoOutputPath &&
|
|
58
|
-
left.audioFramed === right.audioFramed &&
|
|
59
|
-
left.videoFramed === right.videoFramed;
|
|
60
|
-
}
|
|
61
|
-
class RuntimeReceiveWorkerManager {
|
|
62
|
-
bindings = new Map();
|
|
63
|
-
onLogLine;
|
|
64
|
-
bridge;
|
|
65
|
-
sharedSession;
|
|
66
|
-
constructor(options) {
|
|
67
|
-
this.onLogLine = options.onLogLine;
|
|
68
|
-
this.bridge = new RuntimeHostBridge_1.RuntimeHostBridge({
|
|
69
|
-
repoRoot: options.repoRoot,
|
|
70
|
-
platform: options.platform,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
emitLog(stream, line) {
|
|
74
|
-
const normalized = line.trim();
|
|
75
|
-
if (!this.onLogLine || normalized.length === 0) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
this.onLogLine({ source: 'downlink', stream, line: normalized });
|
|
79
|
-
}
|
|
80
|
-
buildDesiredConfig(serviceEntry, peerId, token) {
|
|
81
|
-
const desired = {
|
|
82
|
-
serviceEntry,
|
|
83
|
-
peerId,
|
|
84
|
-
token,
|
|
85
|
-
audioEnabled: false,
|
|
86
|
-
videoEnabled: false,
|
|
87
|
-
};
|
|
88
|
-
for (const binding of this.bindings.values()) {
|
|
89
|
-
if (binding.serviceEntry !== serviceEntry || binding.peerId !== peerId || binding.token !== token) {
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (binding.media === 'audio') {
|
|
93
|
-
desired.audioEnabled = true;
|
|
94
|
-
desired.audioStreamId = binding.streamId;
|
|
95
|
-
desired.audioOutputPath = binding.targetPath;
|
|
96
|
-
desired.audioFramed = binding.framed;
|
|
97
|
-
}
|
|
98
|
-
else if (binding.media === 'video') {
|
|
99
|
-
desired.videoEnabled = true;
|
|
100
|
-
desired.videoStreamId = binding.streamId;
|
|
101
|
-
desired.videoOutputPath = binding.targetPath;
|
|
102
|
-
desired.videoFramed = binding.framed;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return desired;
|
|
106
|
-
}
|
|
107
|
-
async stopSharedSession() {
|
|
108
|
-
if (!this.sharedSession) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
this.bridge.stopDownlink();
|
|
112
|
-
this.sharedSession = undefined;
|
|
113
|
-
this.emitLog('stdout', '[runtime-backed receiver] session stopped');
|
|
114
|
-
}
|
|
115
|
-
async ensureSharedSession(serviceEntry, peerId, token) {
|
|
116
|
-
const desired = this.buildDesiredConfig(serviceEntry, peerId, token);
|
|
117
|
-
if (!desired.audioEnabled && !desired.videoEnabled) {
|
|
118
|
-
await this.stopSharedSession();
|
|
119
|
-
return { started: false };
|
|
120
|
-
}
|
|
121
|
-
const current = this.sharedSession;
|
|
122
|
-
if (current && sameDesiredConfig(current.config, desired)) {
|
|
123
|
-
return { started: false, pid: current.sessionId };
|
|
124
|
-
}
|
|
125
|
-
await this.stopSharedSession();
|
|
126
|
-
if (desired.audioOutputPath) {
|
|
127
|
-
ensureDir(path.dirname(desired.audioOutputPath));
|
|
128
|
-
}
|
|
129
|
-
if (desired.videoOutputPath) {
|
|
130
|
-
ensureDir(path.dirname(desired.videoOutputPath));
|
|
131
|
-
}
|
|
132
|
-
const args = [
|
|
133
|
-
'--service-entry=' + desired.serviceEntry,
|
|
134
|
-
'--peer-id=' + desired.peerId,
|
|
135
|
-
'--token=' + desired.token,
|
|
136
|
-
];
|
|
137
|
-
if (desired.audioEnabled && desired.audioStreamId !== undefined && desired.audioOutputPath) {
|
|
138
|
-
args.push('--audio-stream-id=' + String(desired.audioStreamId));
|
|
139
|
-
args.push('--audio-output=' + desired.audioOutputPath);
|
|
140
|
-
if (desired.audioFramed) {
|
|
141
|
-
args.push('--audio-framed=1');
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
if (desired.videoEnabled && desired.videoStreamId !== undefined && desired.videoOutputPath) {
|
|
145
|
-
args.push('--video-stream-id=' + String(desired.videoStreamId));
|
|
146
|
-
args.push('--video-output=' + desired.videoOutputPath);
|
|
147
|
-
if (desired.videoFramed) {
|
|
148
|
-
args.push('--video-framed=1');
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
const sessionId = this.bridge.startDownlink(args);
|
|
152
|
-
this.sharedSession = {
|
|
153
|
-
startedAt: nowIsoString(),
|
|
154
|
-
config: desired,
|
|
155
|
-
sessionId,
|
|
156
|
-
};
|
|
157
|
-
this.emitLog('stdout', '[runtime-backed receiver] session started sessionId=' + String(sessionId));
|
|
158
|
-
return { started: true, pid: sessionId };
|
|
159
|
-
}
|
|
160
|
-
async syncBindings(bindings) {
|
|
161
|
-
this.bindings.clear();
|
|
162
|
-
for (const binding of bindings) {
|
|
163
|
-
this.bindings.set(binding.key, {
|
|
164
|
-
key: binding.key,
|
|
165
|
-
serviceEntry: binding.serviceEntry,
|
|
166
|
-
peerId: binding.peerId,
|
|
167
|
-
token: binding.token,
|
|
168
|
-
streamId: binding.streamId,
|
|
169
|
-
media: binding.media,
|
|
170
|
-
targetPath: binding.targetPath,
|
|
171
|
-
framed: binding.framed,
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
if (bindings.length === 0) {
|
|
175
|
-
await this.stopSharedSession();
|
|
176
|
-
return { started: false };
|
|
177
|
-
}
|
|
178
|
-
const first = bindings[0];
|
|
179
|
-
return await this.ensureSharedSession(first.serviceEntry, first.peerId, first.token);
|
|
180
|
-
}
|
|
181
|
-
async stopAll() {
|
|
182
|
-
this.bindings.clear();
|
|
183
|
-
await this.stopSharedSession();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
exports.RuntimeReceiveWorkerManager = RuntimeReceiveWorkerManager;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
type SendWorkerManagerOptions = {
|
|
2
|
-
repoRoot: string;
|
|
3
|
-
platform: string;
|
|
4
|
-
onLogLine?: (payload: {
|
|
5
|
-
source: 'uplink';
|
|
6
|
-
stream: 'stdout' | 'stderr';
|
|
7
|
-
line: string;
|
|
8
|
-
pid?: number;
|
|
9
|
-
}) => void;
|
|
10
|
-
onRuntimeEvent?: (kind: string, payload: Record<string, unknown>) => void;
|
|
11
|
-
};
|
|
12
|
-
type SendWorkerStartOptions = {
|
|
13
|
-
key: string;
|
|
14
|
-
serviceEntry: string;
|
|
15
|
-
license: string;
|
|
16
|
-
assetsDir: string;
|
|
17
|
-
streamId: number;
|
|
18
|
-
media: 'audio' | 'video';
|
|
19
|
-
};
|
|
20
|
-
export declare class RuntimeSendWorkerManager {
|
|
21
|
-
private readonly repoRoot;
|
|
22
|
-
private readonly bindings;
|
|
23
|
-
private readonly onLogLine?;
|
|
24
|
-
private readonly onRuntimeEvent?;
|
|
25
|
-
private readonly bridge;
|
|
26
|
-
private sharedSession?;
|
|
27
|
-
private nextCommandRequestId;
|
|
28
|
-
private readonly pendingCommandRequests;
|
|
29
|
-
constructor(options: SendWorkerManagerOptions);
|
|
30
|
-
private handleNativeEvent;
|
|
31
|
-
private rejectPendingCommandRequests;
|
|
32
|
-
private emitLog;
|
|
33
|
-
private resolveFixtureAssetsDir;
|
|
34
|
-
private buildDesiredConfig;
|
|
35
|
-
private stopSharedSession;
|
|
36
|
-
private ensureSharedSession;
|
|
37
|
-
ensureServiceSession(serviceEntry: string, license: string): Promise<{
|
|
38
|
-
started: boolean;
|
|
39
|
-
pid?: number;
|
|
40
|
-
}>;
|
|
41
|
-
startDeviceStream(options: SendWorkerStartOptions): Promise<{
|
|
42
|
-
started: boolean;
|
|
43
|
-
pid?: number;
|
|
44
|
-
}>;
|
|
45
|
-
startDeviceStreams(optionsList: SendWorkerStartOptions[]): Promise<{
|
|
46
|
-
started: boolean;
|
|
47
|
-
pid?: number;
|
|
48
|
-
}>;
|
|
49
|
-
stopStream(key: string): Promise<void>;
|
|
50
|
-
stopAll(): Promise<void>;
|
|
51
|
-
sendStreamMessage(streamId: number, payload: Uint8Array): Promise<void>;
|
|
52
|
-
requestCommand(commandId: number, payload: Uint8Array, timeoutMs: number): Promise<{
|
|
53
|
-
commandId: number;
|
|
54
|
-
payload: Uint8Array;
|
|
55
|
-
}>;
|
|
56
|
-
replyRemoteCommand(remoteRequestId: number, commandId: number, payload: Uint8Array): Promise<void>;
|
|
57
|
-
}
|
|
58
|
-
export {};
|
|
@@ -1,438 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.RuntimeSendWorkerManager = void 0;
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
39
|
-
const RuntimeHostBridge_1 = require("./native/RuntimeHostBridge");
|
|
40
|
-
function pathExists(filePath) {
|
|
41
|
-
return fs.existsSync(filePath);
|
|
42
|
-
}
|
|
43
|
-
function nowIsoString() {
|
|
44
|
-
return new Date().toISOString();
|
|
45
|
-
}
|
|
46
|
-
function toSafeInteger(value) {
|
|
47
|
-
if (typeof value === 'number' && Number.isSafeInteger(value)) {
|
|
48
|
-
return value;
|
|
49
|
-
}
|
|
50
|
-
if (typeof value === 'bigint') {
|
|
51
|
-
const normalized = Number(value);
|
|
52
|
-
if (Number.isSafeInteger(normalized)) {
|
|
53
|
-
return normalized;
|
|
54
|
-
}
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
if (typeof value === 'string' && value.trim().length > 0) {
|
|
58
|
-
const normalized = Number(value);
|
|
59
|
-
if (Number.isSafeInteger(normalized)) {
|
|
60
|
-
return normalized;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
function ensureValidAssetsDir(assetsDir) {
|
|
66
|
-
const resolved = path.resolve(assetsDir);
|
|
67
|
-
let stats;
|
|
68
|
-
try {
|
|
69
|
-
stats = fs.statSync(resolved);
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
throw new Error('stream local assets directory does not exist: ' + resolved);
|
|
73
|
-
}
|
|
74
|
-
if (!stats.isDirectory()) {
|
|
75
|
-
throw new Error('stream local assets path is not a directory: ' + resolved);
|
|
76
|
-
}
|
|
77
|
-
const manifestPath = path.join(resolved, 'manifest.json');
|
|
78
|
-
if (!pathExists(manifestPath)) {
|
|
79
|
-
throw new Error('stream local assets manifest not found: ' + manifestPath);
|
|
80
|
-
}
|
|
81
|
-
return resolved;
|
|
82
|
-
}
|
|
83
|
-
function findPreparedAssetsDir(rootDir) {
|
|
84
|
-
if (!pathExists(rootDir)) {
|
|
85
|
-
return undefined;
|
|
86
|
-
}
|
|
87
|
-
const manifestPath = path.join(rootDir, 'manifest.json');
|
|
88
|
-
const audioIndexPath = path.join(rootDir, 'audio', 'audio_packets.csv');
|
|
89
|
-
const videoIndexPath = path.join(rootDir, 'video', 'video_packets.csv');
|
|
90
|
-
if (pathExists(manifestPath) && pathExists(audioIndexPath) && pathExists(videoIndexPath)) {
|
|
91
|
-
return rootDir;
|
|
92
|
-
}
|
|
93
|
-
let entries = [];
|
|
94
|
-
try {
|
|
95
|
-
entries = fs.readdirSync(rootDir, { withFileTypes: true });
|
|
96
|
-
}
|
|
97
|
-
catch {
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
const dirs = entries
|
|
101
|
-
.filter((entry) => entry.isDirectory())
|
|
102
|
-
.map((entry) => entry.name)
|
|
103
|
-
.sort();
|
|
104
|
-
for (const dirName of dirs) {
|
|
105
|
-
if (!dirName.includes('_runtime_local_assets_prepare_')) {
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
const candidate = path.join(rootDir, dirName);
|
|
109
|
-
const candidateManifest = path.join(candidate, 'manifest.json');
|
|
110
|
-
const candidateAudioIndex = path.join(candidate, 'audio', 'audio_packets.csv');
|
|
111
|
-
const candidateVideoIndex = path.join(candidate, 'video', 'video_packets.csv');
|
|
112
|
-
if (pathExists(candidateManifest) && pathExists(candidateAudioIndex) && pathExists(candidateVideoIndex)) {
|
|
113
|
-
return candidate;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return undefined;
|
|
117
|
-
}
|
|
118
|
-
function resolveFallbackFixtureDir(repoRoot) {
|
|
119
|
-
const explicit = process.env.TIRTC_MEDIA_FIXTURE_DIR;
|
|
120
|
-
if (explicit && explicit.trim().length > 0) {
|
|
121
|
-
return path.resolve(explicit.trim());
|
|
122
|
-
}
|
|
123
|
-
const candidateRoots = [
|
|
124
|
-
path.join(repoRoot, 'runtime/assets/.workspace/runtime-assets-current'),
|
|
125
|
-
path.join(repoRoot, '.build/runtime-assets-local-flat/bundle/runtime-assets-current'),
|
|
126
|
-
path.join(repoRoot, '.build/runtime-assets-workspace-flat/workspace/runtime-assets-current'),
|
|
127
|
-
path.join(repoRoot, '.build/runtime-assets-local-flat-skill-v2/bundle/runtime-assets-current'),
|
|
128
|
-
];
|
|
129
|
-
for (const rootDir of candidateRoots) {
|
|
130
|
-
const resolved = findPreparedAssetsDir(rootDir);
|
|
131
|
-
if (resolved) {
|
|
132
|
-
return resolved;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return candidateRoots[0];
|
|
136
|
-
}
|
|
137
|
-
function sameDesiredConfig(left, right) {
|
|
138
|
-
return left.audioEnabled === right.audioEnabled &&
|
|
139
|
-
left.videoEnabled === right.videoEnabled &&
|
|
140
|
-
left.audioStreamId === right.audioStreamId &&
|
|
141
|
-
left.videoStreamId === right.videoStreamId;
|
|
142
|
-
}
|
|
143
|
-
class RuntimeSendWorkerManager {
|
|
144
|
-
repoRoot;
|
|
145
|
-
bindings = new Map();
|
|
146
|
-
onLogLine;
|
|
147
|
-
onRuntimeEvent;
|
|
148
|
-
bridge;
|
|
149
|
-
sharedSession;
|
|
150
|
-
nextCommandRequestId = 1;
|
|
151
|
-
pendingCommandRequests = new Map();
|
|
152
|
-
constructor(options) {
|
|
153
|
-
this.repoRoot = options.repoRoot;
|
|
154
|
-
this.onLogLine = options.onLogLine;
|
|
155
|
-
this.onRuntimeEvent = options.onRuntimeEvent;
|
|
156
|
-
this.bridge = new RuntimeHostBridge_1.RuntimeHostBridge({
|
|
157
|
-
repoRoot: options.repoRoot,
|
|
158
|
-
platform: options.platform,
|
|
159
|
-
});
|
|
160
|
-
this.bridge.setUplinkEventHandler((event) => {
|
|
161
|
-
this.handleNativeEvent(event);
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
handleNativeEvent(event) {
|
|
165
|
-
this.emitLog('stdout', '[runtime-backed sender] native event kind=' + event.kind +
|
|
166
|
-
' requestId=' + String(event.requestId ?? '') +
|
|
167
|
-
' remoteRequestId=' + String(event.remoteRequestId ?? '') +
|
|
168
|
-
' commandId=' + String(event.commandId ?? '') +
|
|
169
|
-
' errorCode=' + String(event.errorCode ?? '') +
|
|
170
|
-
' reasonCode=' + String(event.reasonCode ?? '') +
|
|
171
|
-
' payloadLength=' + String(event.payload?.byteLength ?? 0));
|
|
172
|
-
if (event.kind === 'command.response') {
|
|
173
|
-
const requestId = Number(event.requestId);
|
|
174
|
-
if (!Number.isInteger(requestId)) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
const pending = this.pendingCommandRequests.get(requestId);
|
|
178
|
-
if (!pending) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
this.pendingCommandRequests.delete(requestId);
|
|
182
|
-
if (pending.timer) {
|
|
183
|
-
clearTimeout(pending.timer);
|
|
184
|
-
}
|
|
185
|
-
if ((event.errorCode ?? 0) !== 0) {
|
|
186
|
-
pending.reject(new Error(`uplink command request failed error=${String(event.errorCode ?? -1)}`));
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
pending.resolve({
|
|
190
|
-
commandId: Number.isInteger(event.commandId) ? Number(event.commandId) : pending.commandId,
|
|
191
|
-
payload: event.payload ?? new Uint8Array(),
|
|
192
|
-
});
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
if (!this.onRuntimeEvent) {
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
if (event.kind === 'connection.accepted') {
|
|
199
|
-
this.onRuntimeEvent(event.kind, { at: nowIsoString() });
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
if (event.kind === 'connection.disconnected') {
|
|
203
|
-
this.onRuntimeEvent(event.kind, {
|
|
204
|
-
at: nowIsoString(),
|
|
205
|
-
reasonCode: String(event.reasonCode ?? 0),
|
|
206
|
-
});
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
if (event.kind === 'command.remote.requested') {
|
|
210
|
-
const remoteRequestId = toSafeInteger(event.remoteRequestId);
|
|
211
|
-
const commandId = toSafeInteger(event.commandId);
|
|
212
|
-
this.onRuntimeEvent(event.kind, {
|
|
213
|
-
at: nowIsoString(),
|
|
214
|
-
remoteRequestId: remoteRequestId ?? String(event.remoteRequestId ?? ''),
|
|
215
|
-
commandId: commandId ?? event.commandId,
|
|
216
|
-
payload: event.payload,
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
rejectPendingCommandRequests(message) {
|
|
221
|
-
if (this.pendingCommandRequests.size === 0) {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
for (const [requestId, pending] of this.pendingCommandRequests.entries()) {
|
|
225
|
-
if (pending.timer) {
|
|
226
|
-
clearTimeout(pending.timer);
|
|
227
|
-
}
|
|
228
|
-
pending.reject(new Error(`${message} requestId=${requestId}`));
|
|
229
|
-
}
|
|
230
|
-
this.pendingCommandRequests.clear();
|
|
231
|
-
}
|
|
232
|
-
emitLog(stream, line) {
|
|
233
|
-
const normalized = line.trim();
|
|
234
|
-
if (!this.onLogLine || normalized.length === 0) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
this.onLogLine({ source: 'uplink', stream, line: normalized });
|
|
238
|
-
}
|
|
239
|
-
resolveFixtureAssetsDir(serviceEntry, license, desired) {
|
|
240
|
-
const explicit = process.env.TIRTC_MEDIA_FIXTURE_DIR;
|
|
241
|
-
if (explicit && explicit.trim().length > 0) {
|
|
242
|
-
return path.resolve(explicit.trim());
|
|
243
|
-
}
|
|
244
|
-
if (!desired.audioEnabled && !desired.videoEnabled) {
|
|
245
|
-
return resolveFallbackFixtureDir(this.repoRoot);
|
|
246
|
-
}
|
|
247
|
-
const requiredMedias = [];
|
|
248
|
-
if (desired.audioEnabled) {
|
|
249
|
-
requiredMedias.push('audio');
|
|
250
|
-
}
|
|
251
|
-
if (desired.videoEnabled) {
|
|
252
|
-
requiredMedias.push('video');
|
|
253
|
-
}
|
|
254
|
-
const assetsDirs = [];
|
|
255
|
-
for (const media of requiredMedias) {
|
|
256
|
-
const found = Array.from(this.bindings.values()).find((binding) => (binding.serviceEntry === serviceEntry &&
|
|
257
|
-
binding.license === license &&
|
|
258
|
-
binding.media === media));
|
|
259
|
-
if (!found) {
|
|
260
|
-
throw new Error('missing local assets binding for media=' + media + ' serviceEntry=' + serviceEntry);
|
|
261
|
-
}
|
|
262
|
-
assetsDirs.push(found.assetsDir);
|
|
263
|
-
}
|
|
264
|
-
const selected = assetsDirs[0];
|
|
265
|
-
for (const candidate of assetsDirs) {
|
|
266
|
-
if (candidate !== selected) {
|
|
267
|
-
throw new Error('mismatched local assets dir across bound medias: ' + selected + ' vs ' + candidate);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return selected;
|
|
271
|
-
}
|
|
272
|
-
buildDesiredConfig(serviceEntry, license) {
|
|
273
|
-
const desired = {
|
|
274
|
-
audioEnabled: false,
|
|
275
|
-
videoEnabled: false,
|
|
276
|
-
};
|
|
277
|
-
for (const binding of this.bindings.values()) {
|
|
278
|
-
if (binding.serviceEntry !== serviceEntry || binding.license !== license) {
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
if (binding.media === 'audio') {
|
|
282
|
-
desired.audioEnabled = true;
|
|
283
|
-
desired.audioStreamId = binding.streamId;
|
|
284
|
-
}
|
|
285
|
-
else if (binding.media === 'video') {
|
|
286
|
-
desired.videoEnabled = true;
|
|
287
|
-
desired.videoStreamId = binding.streamId;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
return desired;
|
|
291
|
-
}
|
|
292
|
-
async stopSharedSession() {
|
|
293
|
-
if (!this.sharedSession) {
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
this.bridge.stopUplink();
|
|
297
|
-
this.sharedSession = undefined;
|
|
298
|
-
this.rejectPendingCommandRequests('uplink session stopped');
|
|
299
|
-
this.emitLog('stdout', '[runtime-backed sender] session stopped');
|
|
300
|
-
}
|
|
301
|
-
async ensureSharedSession(serviceEntry, license, keepAliveWhenNoStreams) {
|
|
302
|
-
const desired = this.buildDesiredConfig(serviceEntry, license);
|
|
303
|
-
if (!desired.audioEnabled && !desired.videoEnabled && !keepAliveWhenNoStreams) {
|
|
304
|
-
await this.stopSharedSession();
|
|
305
|
-
return { started: false };
|
|
306
|
-
}
|
|
307
|
-
const current = this.sharedSession;
|
|
308
|
-
if (current &&
|
|
309
|
-
current.serviceEntry === serviceEntry &&
|
|
310
|
-
current.license === license &&
|
|
311
|
-
sameDesiredConfig(current.config, desired)) {
|
|
312
|
-
return { started: false, pid: current.sessionId };
|
|
313
|
-
}
|
|
314
|
-
await this.stopSharedSession();
|
|
315
|
-
const fixtureDir = this.resolveFixtureAssetsDir(serviceEntry, license, desired);
|
|
316
|
-
const args = [
|
|
317
|
-
'--license=' + license,
|
|
318
|
-
'--fixture-dir=' + fixtureDir,
|
|
319
|
-
'--enable-audio=' + (desired.audioEnabled ? '1' : '0'),
|
|
320
|
-
'--enable-video=' + (desired.videoEnabled ? '1' : '0'),
|
|
321
|
-
];
|
|
322
|
-
if (serviceEntry.trim().length > 0) {
|
|
323
|
-
args.push('--service-entry=' + serviceEntry);
|
|
324
|
-
}
|
|
325
|
-
if (desired.audioStreamId !== undefined) {
|
|
326
|
-
args.push('--audio-stream-id=' + String(desired.audioStreamId));
|
|
327
|
-
}
|
|
328
|
-
if (desired.videoStreamId !== undefined) {
|
|
329
|
-
args.push('--video-stream-id=' + String(desired.videoStreamId));
|
|
330
|
-
}
|
|
331
|
-
const sessionId = this.bridge.startUplink(args);
|
|
332
|
-
this.sharedSession = {
|
|
333
|
-
startedAt: nowIsoString(),
|
|
334
|
-
serviceEntry,
|
|
335
|
-
license,
|
|
336
|
-
config: desired,
|
|
337
|
-
sessionId,
|
|
338
|
-
};
|
|
339
|
-
this.emitLog('stdout', '[runtime-backed sender] session started sessionId=' + String(sessionId));
|
|
340
|
-
return { started: true, pid: sessionId };
|
|
341
|
-
}
|
|
342
|
-
async ensureServiceSession(serviceEntry, license) {
|
|
343
|
-
return await this.ensureSharedSession(serviceEntry, license, true);
|
|
344
|
-
}
|
|
345
|
-
async startDeviceStream(options) {
|
|
346
|
-
this.bindings.set(options.key, {
|
|
347
|
-
key: options.key,
|
|
348
|
-
serviceEntry: options.serviceEntry,
|
|
349
|
-
license: options.license,
|
|
350
|
-
assetsDir: ensureValidAssetsDir(options.assetsDir),
|
|
351
|
-
streamId: options.streamId,
|
|
352
|
-
media: options.media,
|
|
353
|
-
});
|
|
354
|
-
return await this.ensureSharedSession(options.serviceEntry, options.license, true);
|
|
355
|
-
}
|
|
356
|
-
async startDeviceStreams(optionsList) {
|
|
357
|
-
if (optionsList.length === 0) {
|
|
358
|
-
return { started: false };
|
|
359
|
-
}
|
|
360
|
-
for (const options of optionsList) {
|
|
361
|
-
this.bindings.set(options.key, {
|
|
362
|
-
key: options.key,
|
|
363
|
-
serviceEntry: options.serviceEntry,
|
|
364
|
-
license: options.license,
|
|
365
|
-
assetsDir: ensureValidAssetsDir(options.assetsDir),
|
|
366
|
-
streamId: options.streamId,
|
|
367
|
-
media: options.media,
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
const first = optionsList[0];
|
|
371
|
-
return await this.ensureSharedSession(first.serviceEntry, first.license, true);
|
|
372
|
-
}
|
|
373
|
-
async stopStream(key) {
|
|
374
|
-
this.bindings.delete(key);
|
|
375
|
-
const current = this.sharedSession;
|
|
376
|
-
if (!current) {
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
await this.ensureSharedSession(current.serviceEntry, current.license, false);
|
|
380
|
-
}
|
|
381
|
-
async stopAll() {
|
|
382
|
-
this.bindings.clear();
|
|
383
|
-
await this.stopSharedSession();
|
|
384
|
-
}
|
|
385
|
-
async sendStreamMessage(streamId, payload) {
|
|
386
|
-
if (!this.sharedSession) {
|
|
387
|
-
throw new Error('uplink session is not started');
|
|
388
|
-
}
|
|
389
|
-
try {
|
|
390
|
-
this.bridge.sendUplinkStreamMessage(streamId, payload);
|
|
391
|
-
this.emitLog('stdout', '[runtime-backed sender] send_stream_message accepted streamId=' +
|
|
392
|
-
String(streamId) + ' payloadLength=' + String(payload.byteLength));
|
|
393
|
-
}
|
|
394
|
-
catch (error) {
|
|
395
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
396
|
-
this.emitLog('stderr', '[runtime-backed sender] send_stream_message failed streamId=' +
|
|
397
|
-
String(streamId) + ' payloadLength=' + String(payload.byteLength) + ' error=' + message);
|
|
398
|
-
throw error;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
async requestCommand(commandId, payload, timeoutMs) {
|
|
402
|
-
if (!this.sharedSession) {
|
|
403
|
-
throw new Error('uplink session is not started');
|
|
404
|
-
}
|
|
405
|
-
const requestId = this.nextCommandRequestId++;
|
|
406
|
-
return await new Promise((resolve, reject) => {
|
|
407
|
-
const pending = {
|
|
408
|
-
commandId,
|
|
409
|
-
resolve,
|
|
410
|
-
reject,
|
|
411
|
-
};
|
|
412
|
-
pending.timer = setTimeout(() => {
|
|
413
|
-
if (!this.pendingCommandRequests.delete(requestId)) {
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
reject(new Error(`uplink command response timeout requestId=${requestId}`));
|
|
417
|
-
}, Math.max(timeoutMs * 2, timeoutMs + 2000));
|
|
418
|
-
this.pendingCommandRequests.set(requestId, pending);
|
|
419
|
-
try {
|
|
420
|
-
this.bridge.requestUplinkCommand(requestId, commandId, payload, timeoutMs);
|
|
421
|
-
}
|
|
422
|
-
catch (error) {
|
|
423
|
-
this.pendingCommandRequests.delete(requestId);
|
|
424
|
-
if (pending.timer) {
|
|
425
|
-
clearTimeout(pending.timer);
|
|
426
|
-
}
|
|
427
|
-
reject(error instanceof Error ? error : new Error(String(error)));
|
|
428
|
-
}
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
async replyRemoteCommand(remoteRequestId, commandId, payload) {
|
|
432
|
-
if (!this.sharedSession) {
|
|
433
|
-
throw new Error('uplink session is not started');
|
|
434
|
-
}
|
|
435
|
-
this.bridge.replyUplinkRemoteCommand(remoteRequestId, commandId, payload);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
exports.RuntimeSendWorkerManager = RuntimeSendWorkerManager;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type TokenQrcodeParams = {
|
|
2
|
-
payload: string;
|
|
3
|
-
outputStem?: string;
|
|
4
|
-
};
|
|
5
|
-
export type TokenQrcodeResult = {
|
|
6
|
-
payload: string;
|
|
7
|
-
asciiPath: string;
|
|
8
|
-
pngPath: string;
|
|
9
|
-
};
|
|
10
|
-
export declare class TokenTool {
|
|
11
|
-
private readonly debugDir;
|
|
12
|
-
constructor(artifactRootPath: string);
|
|
13
|
-
private makeStem;
|
|
14
|
-
generateQrcode(params: TokenQrcodeParams): Promise<TokenQrcodeResult>;
|
|
15
|
-
}
|