tirtc-devtools-cli 0.0.1

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.
Files changed (156) hide show
  1. package/README.md +52 -0
  2. package/USAGE.md +417 -0
  3. package/bin/tirtc-devtool.js +2 -0
  4. package/dist/app-server/protocol-client/index.d.ts +25 -0
  5. package/dist/app-server/protocol-client/index.js +114 -0
  6. package/dist/devtools/cli/src/config.d.ts +46 -0
  7. package/dist/devtools/cli/src/config.js +98 -0
  8. package/dist/devtools/cli/src/dummy.d.ts +0 -0
  9. package/dist/devtools/cli/src/dummy.js +1 -0
  10. package/dist/devtools/cli/src/embedded_paths.d.ts +7 -0
  11. package/dist/devtools/cli/src/embedded_paths.js +85 -0
  12. package/dist/devtools/cli/src/facade.d.ts +723 -0
  13. package/dist/devtools/cli/src/facade.js +194 -0
  14. package/dist/devtools/cli/src/ffmpeg_tool.d.ts +6 -0
  15. package/dist/devtools/cli/src/ffmpeg_tool.js +146 -0
  16. package/dist/devtools/cli/src/guide.d.ts +1 -0
  17. package/dist/devtools/cli/src/guide.js +49 -0
  18. package/dist/devtools/cli/src/index.d.ts +1 -0
  19. package/dist/devtools/cli/src/index.js +753 -0
  20. package/dist/devtools/cli/src/media_assets.d.ts +25 -0
  21. package/dist/devtools/cli/src/media_assets.js +121 -0
  22. package/dist/devtools/cli/src/session_manager.d.ts +25 -0
  23. package/dist/devtools/cli/src/session_manager.js +393 -0
  24. package/dist/devtools/cli/src/token_tool.d.ts +33 -0
  25. package/dist/devtools/cli/src/token_tool.js +217 -0
  26. package/dist/devtools/cli/src/transport.d.ts +30 -0
  27. package/dist/devtools/cli/src/transport.js +84 -0
  28. package/dist/dummy.d.ts +0 -0
  29. package/dist/dummy.js +1 -0
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.js +48 -0
  32. package/package.json +54 -0
  33. package/script/ensure_ffmpeg.sh +22 -0
  34. package/vendor/app-server/bin/native/macos-arm64/credential_napi.node +0 -0
  35. package/vendor/app-server/bin/native/macos-arm64/libcrypto.dylib +0 -0
  36. package/vendor/app-server/bin/native/macos-arm64/libssl.dylib +0 -0
  37. package/vendor/app-server/bin/native/macos-arm64/libtgrtc.dylib +0 -0
  38. package/vendor/app-server/bin/native/macos-arm64/runtime_host_napi.node +0 -0
  39. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_codec.h +23 -0
  40. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_frame.h +36 -0
  41. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io.h +56 -0
  42. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_android.h +19 -0
  43. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_apple.h +19 -0
  44. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_harmony.h +19 -0
  45. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_io_windows.h +19 -0
  46. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_processing.h +56 -0
  47. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/audio_sample_rate.h +18 -0
  48. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/error.h +20 -0
  49. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/logging.h +53 -0
  50. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_codec.h +21 -0
  51. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_downlink.h +89 -0
  52. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/media_uplink.h +115 -0
  53. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/runtime.h +236 -0
  54. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_codec.h +57 -0
  55. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_frame.h +55 -0
  56. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io.h +46 -0
  57. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_android.h +32 -0
  58. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_apple.h +34 -0
  59. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_harmony.h +32 -0
  60. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_io_windows.h +26 -0
  61. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/video_processing.h +34 -0
  62. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_audio.a +0 -0
  63. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_facade.a +0 -0
  64. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  65. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_media.a +0 -0
  66. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_video.a +0 -0
  67. package/vendor/app-server/bin/runtime/linux-x64/lib/libwebrtc_apm.a +0 -0
  68. package/vendor/app-server/bin/runtime/linux-x64/lib/libxlog.a +0 -0
  69. package/vendor/app-server/bin/runtime/linux-x64/manifest.txt +34 -0
  70. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio.h +398 -0
  71. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_codec.h +23 -0
  72. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_frame.h +36 -0
  73. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io.h +56 -0
  74. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_android.h +19 -0
  75. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_apple.h +19 -0
  76. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_harmony.h +19 -0
  77. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_io_windows.h +19 -0
  78. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_processing.h +56 -0
  79. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio_sample_rate.h +18 -0
  80. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/av.h +452 -0
  81. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/credential.h +34 -0
  82. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/error.h +30 -0
  83. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/foundation/build_info.h +27 -0
  84. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/http.h +57 -0
  85. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/logging.h +55 -0
  86. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_codec.h +21 -0
  87. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_downlink.h +95 -0
  88. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_fixture_av_sync.h +61 -0
  89. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_fixture_source.h +77 -0
  90. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_live_source.h +71 -0
  91. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_uplink.h +116 -0
  92. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/transport.h +481 -0
  93. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/trp.h +541 -0
  94. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_codec.h +58 -0
  95. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_frame.h +55 -0
  96. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io.h +46 -0
  97. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_android.h +32 -0
  98. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_apple.h +47 -0
  99. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_harmony.h +32 -0
  100. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_io_windows.h +26 -0
  101. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/video_processing.h +34 -0
  102. package/vendor/app-server/bin/runtime/macos-arm64/lib/libcrypto.a +0 -0
  103. package/vendor/app-server/bin/runtime/macos-arm64/lib/libcrypto.dylib +0 -0
  104. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_audio.a +0 -0
  105. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_credential.a +0 -0
  106. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_facade.a +0 -0
  107. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_http.a +0 -0
  108. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  109. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_media.a +0 -0
  110. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_transport.a +0 -0
  111. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_video.a +0 -0
  112. package/vendor/app-server/bin/runtime/macos-arm64/lib/libssl.a +0 -0
  113. package/vendor/app-server/bin/runtime/macos-arm64/lib/libssl.dylib +0 -0
  114. package/vendor/app-server/bin/runtime/macos-arm64/lib/libwebrtc_apm.a +0 -0
  115. package/vendor/app-server/bin/runtime/macos-arm64/lib/libxlog.a +0 -0
  116. package/vendor/app-server/bin/runtime/macos-arm64/manifest.txt +50 -0
  117. package/vendor/app-server/bin/tirtc-devtool-host.js +2 -0
  118. package/vendor/app-server/dist/host/ArtifactManager.d.ts +18 -0
  119. package/vendor/app-server/dist/host/ArtifactManager.js +83 -0
  120. package/vendor/app-server/dist/host/HostProtocol.d.ts +107 -0
  121. package/vendor/app-server/dist/host/HostProtocol.js +256 -0
  122. package/vendor/app-server/dist/host/HostServer.d.ts +49 -0
  123. package/vendor/app-server/dist/host/HostServer.js +635 -0
  124. package/vendor/app-server/dist/host/HostState.d.ts +60 -0
  125. package/vendor/app-server/dist/host/HostState.js +19 -0
  126. package/vendor/app-server/dist/host/RuntimeAdapter.d.ts +81 -0
  127. package/vendor/app-server/dist/host/RuntimeAdapter.js +559 -0
  128. package/vendor/app-server/dist/host/RuntimeCredentialTokenIssuer.d.ts +30 -0
  129. package/vendor/app-server/dist/host/RuntimeCredentialTokenIssuer.js +224 -0
  130. package/vendor/app-server/dist/host/RuntimeReceiveWorker.d.ts +37 -0
  131. package/vendor/app-server/dist/host/RuntimeReceiveWorker.js +186 -0
  132. package/vendor/app-server/dist/host/RuntimeSendWorker.d.ts +42 -0
  133. package/vendor/app-server/dist/host/RuntimeSendWorker.js +274 -0
  134. package/vendor/app-server/dist/host/TokenTool.d.ts +15 -0
  135. package/vendor/app-server/dist/host/TokenTool.js +84 -0
  136. package/vendor/app-server/dist/host/WebPreviewGateway.d.ts +28 -0
  137. package/vendor/app-server/dist/host/WebPreviewGateway.js +815 -0
  138. package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.d.ts +26 -0
  139. package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.js +118 -0
  140. package/vendor/app-server/dist/host/native/RuntimeHostBridge.d.ts +19 -0
  141. package/vendor/app-server/dist/host/native/RuntimeHostBridge.js +141 -0
  142. package/vendor/app-server/dist/host/runtime_backed_preflight.d.ts +10 -0
  143. package/vendor/app-server/dist/host/runtime_backed_preflight.js +78 -0
  144. package/vendor/app-server/dist/host/tests/helpers/host_socket_client.d.ts +28 -0
  145. package/vendor/app-server/dist/host/tests/helpers/host_socket_client.js +85 -0
  146. package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.d.ts +10 -0
  147. package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.js +41 -0
  148. package/vendor/app-server/dist/host/tests/helpers/runtime_test_env.d.ts +11 -0
  149. package/vendor/app-server/dist/host/tests/helpers/runtime_test_env.js +32 -0
  150. package/vendor/app-server/dist/protocol/contract.d.ts +983 -0
  151. package/vendor/app-server/dist/protocol/contract.js +198 -0
  152. package/vendor/app-server/dist/protocol-client/index.d.ts +25 -0
  153. package/vendor/app-server/dist/protocol-client/index.js +114 -0
  154. package/vendor/app-server/dist/src/index.d.ts +1 -0
  155. package/vendor/app-server/dist/src/index.js +294 -0
  156. package/vendor/runtime/script/prepare_runtime_media_dataset.sh +427 -0
@@ -0,0 +1,274 @@
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 ensureValidAssetsDir(assetsDir) {
47
+ const resolved = path.resolve(assetsDir);
48
+ let stats;
49
+ try {
50
+ stats = fs.statSync(resolved);
51
+ }
52
+ catch {
53
+ throw new Error('stream local assets directory does not exist: ' + resolved);
54
+ }
55
+ if (!stats.isDirectory()) {
56
+ throw new Error('stream local assets path is not a directory: ' + resolved);
57
+ }
58
+ const manifestPath = path.join(resolved, 'manifest.json');
59
+ if (!pathExists(manifestPath)) {
60
+ throw new Error('stream local assets manifest not found: ' + manifestPath);
61
+ }
62
+ return resolved;
63
+ }
64
+ function findPreparedAssetsDir(rootDir) {
65
+ if (!pathExists(rootDir)) {
66
+ return undefined;
67
+ }
68
+ const manifestPath = path.join(rootDir, 'manifest.json');
69
+ const audioIndexPath = path.join(rootDir, 'audio', 'audio_packets.csv');
70
+ const videoIndexPath = path.join(rootDir, 'video', 'video_packets.csv');
71
+ if (pathExists(manifestPath) && pathExists(audioIndexPath) && pathExists(videoIndexPath)) {
72
+ return rootDir;
73
+ }
74
+ let entries = [];
75
+ try {
76
+ entries = fs.readdirSync(rootDir, { withFileTypes: true });
77
+ }
78
+ catch {
79
+ return undefined;
80
+ }
81
+ const dirs = entries
82
+ .filter((entry) => entry.isDirectory())
83
+ .map((entry) => entry.name)
84
+ .sort();
85
+ for (const dirName of dirs) {
86
+ if (!dirName.includes('_runtime_local_assets_prepare_')) {
87
+ continue;
88
+ }
89
+ const candidate = path.join(rootDir, dirName);
90
+ const candidateManifest = path.join(candidate, 'manifest.json');
91
+ const candidateAudioIndex = path.join(candidate, 'audio', 'audio_packets.csv');
92
+ const candidateVideoIndex = path.join(candidate, 'video', 'video_packets.csv');
93
+ if (pathExists(candidateManifest) && pathExists(candidateAudioIndex) && pathExists(candidateVideoIndex)) {
94
+ return candidate;
95
+ }
96
+ }
97
+ return undefined;
98
+ }
99
+ function resolveFallbackFixtureDir(repoRoot) {
100
+ const explicit = process.env.TIRTC_MEDIA_FIXTURE_DIR;
101
+ if (explicit && explicit.trim().length > 0) {
102
+ return path.resolve(explicit.trim());
103
+ }
104
+ const candidateRoots = [
105
+ path.join(repoRoot, 'runtime/assets/.workspace/runtime-assets-current'),
106
+ path.join(repoRoot, '.build/runtime-assets-local-flat/bundle/runtime-assets-current'),
107
+ path.join(repoRoot, '.build/runtime-assets-workspace-flat/workspace/runtime-assets-current'),
108
+ path.join(repoRoot, '.build/runtime-assets-local-flat-skill-v2/bundle/runtime-assets-current'),
109
+ ];
110
+ for (const rootDir of candidateRoots) {
111
+ const resolved = findPreparedAssetsDir(rootDir);
112
+ if (resolved) {
113
+ return resolved;
114
+ }
115
+ }
116
+ return candidateRoots[0];
117
+ }
118
+ function sameDesiredConfig(left, right) {
119
+ return left.audioEnabled === right.audioEnabled &&
120
+ left.videoEnabled === right.videoEnabled &&
121
+ left.audioStreamId === right.audioStreamId &&
122
+ left.videoStreamId === right.videoStreamId;
123
+ }
124
+ class RuntimeSendWorkerManager {
125
+ repoRoot;
126
+ bindings = new Map();
127
+ onLogLine;
128
+ bridge;
129
+ sharedSession;
130
+ constructor(options) {
131
+ this.repoRoot = options.repoRoot;
132
+ this.onLogLine = options.onLogLine;
133
+ this.bridge = new RuntimeHostBridge_1.RuntimeHostBridge({
134
+ repoRoot: options.repoRoot,
135
+ platform: options.platform,
136
+ });
137
+ }
138
+ emitLog(stream, line) {
139
+ const normalized = line.trim();
140
+ if (!this.onLogLine || normalized.length === 0) {
141
+ return;
142
+ }
143
+ this.onLogLine({ source: 'uplink', stream, line: normalized });
144
+ }
145
+ resolveFixtureAssetsDir(serviceEntry, license, desired) {
146
+ const explicit = process.env.TIRTC_MEDIA_FIXTURE_DIR;
147
+ if (explicit && explicit.trim().length > 0) {
148
+ return path.resolve(explicit.trim());
149
+ }
150
+ if (!desired.audioEnabled && !desired.videoEnabled) {
151
+ return resolveFallbackFixtureDir(this.repoRoot);
152
+ }
153
+ const requiredMedias = [];
154
+ if (desired.audioEnabled) {
155
+ requiredMedias.push('audio');
156
+ }
157
+ if (desired.videoEnabled) {
158
+ requiredMedias.push('video');
159
+ }
160
+ const assetsDirs = [];
161
+ for (const media of requiredMedias) {
162
+ const found = Array.from(this.bindings.values()).find((binding) => (binding.serviceEntry === serviceEntry &&
163
+ binding.license === license &&
164
+ binding.media === media));
165
+ if (!found) {
166
+ throw new Error('missing local assets binding for media=' + media + ' serviceEntry=' + serviceEntry);
167
+ }
168
+ assetsDirs.push(found.assetsDir);
169
+ }
170
+ const selected = assetsDirs[0];
171
+ for (const candidate of assetsDirs) {
172
+ if (candidate !== selected) {
173
+ throw new Error('mismatched local assets dir across bound medias: ' + selected + ' vs ' + candidate);
174
+ }
175
+ }
176
+ return selected;
177
+ }
178
+ buildDesiredConfig(serviceEntry, license) {
179
+ const desired = {
180
+ audioEnabled: false,
181
+ videoEnabled: false,
182
+ };
183
+ for (const binding of this.bindings.values()) {
184
+ if (binding.serviceEntry !== serviceEntry || binding.license !== license) {
185
+ continue;
186
+ }
187
+ if (binding.media === 'audio') {
188
+ desired.audioEnabled = true;
189
+ desired.audioStreamId = binding.streamId;
190
+ }
191
+ else if (binding.media === 'video') {
192
+ desired.videoEnabled = true;
193
+ desired.videoStreamId = binding.streamId;
194
+ }
195
+ }
196
+ return desired;
197
+ }
198
+ async stopSharedSession() {
199
+ if (!this.sharedSession) {
200
+ return;
201
+ }
202
+ this.bridge.stopUplink();
203
+ this.sharedSession = undefined;
204
+ this.emitLog('stdout', '[runtime-backed sender] session stopped');
205
+ }
206
+ async ensureSharedSession(serviceEntry, license, keepAliveWhenNoStreams) {
207
+ const desired = this.buildDesiredConfig(serviceEntry, license);
208
+ if (!desired.audioEnabled && !desired.videoEnabled && !keepAliveWhenNoStreams) {
209
+ await this.stopSharedSession();
210
+ return { started: false };
211
+ }
212
+ const current = this.sharedSession;
213
+ if (current &&
214
+ current.serviceEntry === serviceEntry &&
215
+ current.license === license &&
216
+ sameDesiredConfig(current.config, desired)) {
217
+ return { started: false, pid: current.sessionId };
218
+ }
219
+ await this.stopSharedSession();
220
+ const fixtureDir = this.resolveFixtureAssetsDir(serviceEntry, license, desired);
221
+ const args = [
222
+ '--license=' + license,
223
+ '--fixture-dir=' + fixtureDir,
224
+ '--enable-audio=' + (desired.audioEnabled ? '1' : '0'),
225
+ '--enable-video=' + (desired.videoEnabled ? '1' : '0'),
226
+ ];
227
+ if (serviceEntry.trim().length > 0) {
228
+ args.push('--service-entry=' + serviceEntry);
229
+ }
230
+ if (desired.audioStreamId !== undefined) {
231
+ args.push('--audio-stream-id=' + String(desired.audioStreamId));
232
+ }
233
+ if (desired.videoStreamId !== undefined) {
234
+ args.push('--video-stream-id=' + String(desired.videoStreamId));
235
+ }
236
+ const sessionId = this.bridge.startUplink(args);
237
+ this.sharedSession = {
238
+ startedAt: nowIsoString(),
239
+ serviceEntry,
240
+ license,
241
+ config: desired,
242
+ sessionId,
243
+ };
244
+ this.emitLog('stdout', '[runtime-backed sender] session started sessionId=' + String(sessionId));
245
+ return { started: true, pid: sessionId };
246
+ }
247
+ async ensureServiceSession(serviceEntry, license) {
248
+ return await this.ensureSharedSession(serviceEntry, license, true);
249
+ }
250
+ async startDeviceStream(options) {
251
+ this.bindings.set(options.key, {
252
+ key: options.key,
253
+ serviceEntry: options.serviceEntry,
254
+ license: options.license,
255
+ assetsDir: ensureValidAssetsDir(options.assetsDir),
256
+ streamId: options.streamId,
257
+ media: options.media,
258
+ });
259
+ return await this.ensureSharedSession(options.serviceEntry, options.license, true);
260
+ }
261
+ async stopStream(key) {
262
+ this.bindings.delete(key);
263
+ const current = this.sharedSession;
264
+ if (!current) {
265
+ return;
266
+ }
267
+ await this.ensureSharedSession(current.serviceEntry, current.license, false);
268
+ }
269
+ async stopAll() {
270
+ this.bindings.clear();
271
+ await this.stopSharedSession();
272
+ }
273
+ }
274
+ exports.RuntimeSendWorkerManager = RuntimeSendWorkerManager;
@@ -0,0 +1,15 @@
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
+ }
@@ -0,0 +1,84 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.TokenTool = void 0;
40
+ const fs = __importStar(require("fs"));
41
+ const path = __importStar(require("path"));
42
+ const qrcode_1 = __importDefault(require("qrcode"));
43
+ function nowStamp() {
44
+ return new Date().toISOString().replace(/[:.]/g, '-');
45
+ }
46
+ function ensureDir(dirPath) {
47
+ if (!fs.existsSync(dirPath)) {
48
+ fs.mkdirSync(dirPath, { recursive: true });
49
+ }
50
+ }
51
+ class TokenTool {
52
+ debugDir;
53
+ constructor(artifactRootPath) {
54
+ this.debugDir = path.join(artifactRootPath, 'debug');
55
+ ensureDir(this.debugDir);
56
+ }
57
+ makeStem(prefix, preferred) {
58
+ const stem = preferred && preferred.trim().length > 0 ? preferred.trim() : `${prefix}-${nowStamp()}`;
59
+ return stem.replace(/[^a-zA-Z0-9._-]/g, '_');
60
+ }
61
+ async generateQrcode(params) {
62
+ const stem = this.makeStem('bootstrap', params.outputStem);
63
+ const asciiPath = path.join(this.debugDir, `${stem}.qr.txt`);
64
+ const pngPath = path.join(this.debugDir, `${stem}.qr.png`);
65
+ const ascii = await qrcode_1.default.toString(params.payload, {
66
+ type: 'terminal',
67
+ small: true,
68
+ errorCorrectionLevel: 'M',
69
+ });
70
+ await qrcode_1.default.toFile(pngPath, params.payload, {
71
+ type: 'png',
72
+ errorCorrectionLevel: 'M',
73
+ margin: 2,
74
+ width: 480,
75
+ });
76
+ fs.writeFileSync(asciiPath, ascii);
77
+ return {
78
+ payload: params.payload,
79
+ asciiPath,
80
+ pngPath,
81
+ };
82
+ }
83
+ }
84
+ exports.TokenTool = TokenTool;
@@ -0,0 +1,28 @@
1
+ type PreviewMedia = 'audio' | 'video';
2
+ export type PreviewRegistration = {
3
+ url: string;
4
+ token: string;
5
+ endpoint: string;
6
+ };
7
+ export declare class WebPreviewGateway {
8
+ private server?;
9
+ private serverStarting?;
10
+ private pollTimer?;
11
+ private readonly sources;
12
+ private readonly clients;
13
+ private token;
14
+ private port;
15
+ private parseStreamFilter;
16
+ private sourceMatchesFilter;
17
+ private startSources;
18
+ private stopSources;
19
+ private getStatus;
20
+ private ensureServer;
21
+ registerSource(outputId: string, media: PreviewMedia, streamId: number, filePath: string, onStart?: () => Promise<void>, onStop?: () => Promise<void>): Promise<PreviewRegistration>;
22
+ unregisterSource(outputId: string): void;
23
+ dispose(): void;
24
+ private pollOnce;
25
+ private writeEvent;
26
+ private broadcast;
27
+ }
28
+ export {};