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.
Files changed (137) hide show
  1. package/README.md +42 -46
  2. package/USAGE.md +87 -312
  3. package/dist/cli/src/embedded_paths.d.ts +0 -2
  4. package/dist/cli/src/embedded_paths.js +3 -25
  5. package/dist/cli/src/index.js +82 -584
  6. package/dist/cli/src/role_driver.d.ts +33 -0
  7. package/dist/cli/src/role_driver.js +500 -0
  8. package/dist/cli/src/token_command.js +4 -2
  9. package/dist/cli/src/token_issue.d.ts +9 -0
  10. package/dist/cli/src/token_issue.js +138 -0
  11. package/dist/cli/src/token_tool.d.ts +2 -4
  12. package/dist/cli/src/token_tool.js +12 -186
  13. package/package.json +3 -2
  14. package/vendor/devtools/driver/macos-arm64/devtools_driver_probe +0 -0
  15. package/vendor/devtools/driver/macos-arm64/runtime_validation_client_bin +0 -0
  16. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio.h +56 -2
  17. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_io.h +9 -0
  18. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/av.h +52 -0
  19. package/vendor/{app-server/bin/runtime/linux-x64 → runtime/macos-arm64}/include/tirtc/error.h +11 -0
  20. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/media_downlink.h +11 -5
  21. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/media_uplink.h +4 -0
  22. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/transport.h +52 -15
  23. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/trp.h +7 -5
  24. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_codec.h +41 -0
  25. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_io.h +7 -0
  26. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_io_android.h +2 -0
  27. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libmatrix_runtime_audio.a +0 -0
  28. package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_facade.a +0 -0
  29. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libmatrix_runtime_foundation_http.a +0 -0
  30. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  31. package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_media.a +0 -0
  32. package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_transport.a +0 -0
  33. package/vendor/runtime/macos-arm64/lib/libmatrix_runtime_video.a +0 -0
  34. package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/manifest.txt +20 -25
  35. package/vendor/runtime/script/prepare_runtime_media_dataset.sh +308 -12
  36. package/dist/app-server/protocol-client/index.d.ts +0 -25
  37. package/dist/app-server/protocol-client/index.js +0 -114
  38. package/dist/cli/src/bootstrap_flows.d.ts +0 -46
  39. package/dist/cli/src/bootstrap_flows.js +0 -249
  40. package/dist/cli/src/config.d.ts +0 -26
  41. package/dist/cli/src/config.js +0 -62
  42. package/dist/cli/src/facade.d.ts +0 -430
  43. package/dist/cli/src/facade.js +0 -170
  44. package/dist/cli/src/guide.d.ts +0 -1
  45. package/dist/cli/src/guide.js +0 -48
  46. package/dist/cli/src/session_manager.d.ts +0 -25
  47. package/dist/cli/src/session_manager.js +0 -391
  48. package/dist/cli/src/transport.d.ts +0 -30
  49. package/dist/cli/src/transport.js +0 -84
  50. package/vendor/app-server/bin/native/linux-x64/credential_napi.node +0 -0
  51. package/vendor/app-server/bin/native/macos-arm64/credential_napi.node +0 -0
  52. package/vendor/app-server/bin/runtime/linux-x64/include/tirtc/credential.h +0 -34
  53. package/vendor/app-server/bin/runtime/linux-x64/lib/libcrypto.a +0 -0
  54. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_credential.a +0 -0
  55. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_http.a +0 -0
  56. package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_logging.a +0 -0
  57. package/vendor/app-server/bin/runtime/linux-x64/lib/libssl.a +0 -0
  58. package/vendor/app-server/bin/runtime/linux-x64/lib/libxlog.a +0 -0
  59. package/vendor/app-server/bin/runtime/linux-x64/manifest.txt +0 -4
  60. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/credential.h +0 -34
  61. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/error.h +0 -52
  62. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/foundation/build_info.h +0 -27
  63. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/http.h +0 -57
  64. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/logging.h +0 -55
  65. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_fixture_av_sync.h +0 -61
  66. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_fixture_source.h +0 -77
  67. package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/media_live_source.h +0 -71
  68. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_credential.a +0 -0
  69. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_facade.a +0 -0
  70. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_media.a +0 -0
  71. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_transport.a +0 -0
  72. package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_video.a +0 -0
  73. package/vendor/app-server/bin/tirtc-devtool-host.js +0 -2
  74. package/vendor/app-server/dist/host/ArtifactManager.d.ts +0 -18
  75. package/vendor/app-server/dist/host/ArtifactManager.js +0 -98
  76. package/vendor/app-server/dist/host/HostCommandCoordinator.d.ts +0 -19
  77. package/vendor/app-server/dist/host/HostCommandCoordinator.js +0 -196
  78. package/vendor/app-server/dist/host/HostProtocol.d.ts +0 -103
  79. package/vendor/app-server/dist/host/HostProtocol.js +0 -239
  80. package/vendor/app-server/dist/host/HostServer.d.ts +0 -52
  81. package/vendor/app-server/dist/host/HostServer.js +0 -727
  82. package/vendor/app-server/dist/host/HostState.d.ts +0 -69
  83. package/vendor/app-server/dist/host/HostState.js +0 -19
  84. package/vendor/app-server/dist/host/RuntimeAdapter.d.ts +0 -95
  85. package/vendor/app-server/dist/host/RuntimeAdapter.js +0 -636
  86. package/vendor/app-server/dist/host/RuntimeReceiveWorker.d.ts +0 -37
  87. package/vendor/app-server/dist/host/RuntimeReceiveWorker.js +0 -186
  88. package/vendor/app-server/dist/host/RuntimeSendWorker.d.ts +0 -58
  89. package/vendor/app-server/dist/host/RuntimeSendWorker.js +0 -438
  90. package/vendor/app-server/dist/host/TokenTool.d.ts +0 -15
  91. package/vendor/app-server/dist/host/TokenTool.js +0 -84
  92. package/vendor/app-server/dist/host/WebPreviewGateway.d.ts +0 -28
  93. package/vendor/app-server/dist/host/WebPreviewGateway.js +0 -815
  94. package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.d.ts +0 -23
  95. package/vendor/app-server/dist/host/native/RuntimeCredentialTokenIssuer.js +0 -115
  96. package/vendor/app-server/dist/host/native/RuntimeHostBridge.d.ts +0 -32
  97. package/vendor/app-server/dist/host/native/RuntimeHostBridge.js +0 -157
  98. package/vendor/app-server/dist/host/runtime_backed_preflight.d.ts +0 -10
  99. package/vendor/app-server/dist/host/runtime_backed_preflight.js +0 -78
  100. package/vendor/app-server/dist/host/tests/helpers/host_socket_client.d.ts +0 -28
  101. package/vendor/app-server/dist/host/tests/helpers/host_socket_client.js +0 -85
  102. package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.d.ts +0 -10
  103. package/vendor/app-server/dist/host/tests/helpers/runtime_e2e_local_config.js +0 -41
  104. package/vendor/app-server/dist/host/tests/helpers/runtime_test_env.d.ts +0 -11
  105. package/vendor/app-server/dist/host/tests/helpers/runtime_test_env.js +0 -32
  106. package/vendor/app-server/dist/protocol/contract.d.ts +0 -1128
  107. package/vendor/app-server/dist/protocol/contract.js +0 -217
  108. package/vendor/app-server/dist/protocol-client/index.d.ts +0 -25
  109. package/vendor/app-server/dist/protocol-client/index.js +0 -114
  110. package/vendor/app-server/dist/src/index.d.ts +0 -1
  111. package/vendor/app-server/dist/src/index.js +0 -294
  112. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_codec.h +0 -0
  113. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_frame.h +0 -0
  114. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_io_android.h +0 -0
  115. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_io_apple.h +0 -0
  116. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_io_harmony.h +0 -0
  117. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_io_windows.h +0 -0
  118. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_processing.h +0 -0
  119. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/audio_sample_rate.h +0 -0
  120. /package/vendor/{app-server/bin/runtime/linux-x64 → runtime/macos-arm64}/include/tirtc/foundation/build_info.h +0 -0
  121. /package/vendor/{app-server/bin/runtime/linux-x64 → runtime/macos-arm64}/include/tirtc/http.h +0 -0
  122. /package/vendor/{app-server/bin/runtime/linux-x64 → runtime/macos-arm64}/include/tirtc/logging.h +0 -0
  123. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/media_codec.h +0 -0
  124. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_frame.h +0 -0
  125. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_io_apple.h +0 -0
  126. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_io_harmony.h +0 -0
  127. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_io_windows.h +0 -0
  128. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/include/tirtc/video_processing.h +0 -0
  129. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libTGTRP.a +0 -0
  130. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libTiRTC.a +0 -0
  131. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libcrypto.a +0 -0
  132. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libcrypto.dylib +0 -0
  133. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libssl.a +0 -0
  134. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libssl.dylib +0 -0
  135. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libtgrtc.dylib +0 -0
  136. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libwebrtc_apm.a +0 -0
  137. /package/vendor/{app-server/bin/runtime → runtime}/macos-arm64/lib/libxlog.a +0 -0
@@ -1,249 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.BootstrapStepError = void 0;
7
- exports.validateServerConfig = validateServerConfig;
8
- exports.validateClientConfig = validateClientConfig;
9
- exports.applyConfiguredServerBootstrap = applyConfiguredServerBootstrap;
10
- exports.applyClientStartBootstrap = applyClientStartBootstrap;
11
- const fs_1 = __importDefault(require("fs"));
12
- const os_1 = __importDefault(require("os"));
13
- const path_1 = __importDefault(require("path"));
14
- const default_paths_1 = require("./default_paths");
15
- const media_assets_1 = require("./media_assets");
16
- class BootstrapStepError extends Error {
17
- reasonCode;
18
- data;
19
- constructor(reasonCode, message, data) {
20
- super(message);
21
- this.name = 'BootstrapStepError';
22
- this.reasonCode = reasonCode;
23
- this.data = data;
24
- }
25
- }
26
- exports.BootstrapStepError = BootstrapStepError;
27
- function resolveProtocolError(error) {
28
- if (typeof error === 'object' && error !== null) {
29
- const typed = error;
30
- if (typed.data?.reasonCode && typed.data.reasonCode.trim().length > 0) {
31
- return {
32
- reasonCode: typed.data.reasonCode,
33
- message: typed.data.message ?? typed.message ?? 'Request failed',
34
- };
35
- }
36
- if (typed.message && typed.message.trim().length > 0) {
37
- return {
38
- reasonCode: 'internal_error',
39
- message: typed.message,
40
- };
41
- }
42
- }
43
- if (error instanceof Error) {
44
- return {
45
- reasonCode: 'internal_error',
46
- message: error.message,
47
- };
48
- }
49
- return {
50
- reasonCode: 'internal_error',
51
- message: 'Request failed',
52
- };
53
- }
54
- function ensureNonNegativeInteger(value, field) {
55
- if (typeof value !== 'number' || !Number.isInteger(value) || value < 0) {
56
- throw new Error(field + ' must be a non-negative integer');
57
- }
58
- return value;
59
- }
60
- function ensureNonEmptyString(value, field) {
61
- if (typeof value !== 'string' || value.trim().length === 0) {
62
- throw new Error(field + ' must be a non-empty string');
63
- }
64
- return value.trim();
65
- }
66
- function extractPreview(result, step) {
67
- if (typeof result !== 'object' || result === null) {
68
- throw new Error(step + ' did not return an object result');
69
- }
70
- const previewRaw = result.preview;
71
- if (typeof previewRaw !== 'object' || previewRaw === null) {
72
- throw new Error(step + ' did not return preview metadata');
73
- }
74
- const preview = previewRaw;
75
- const url = ensureNonEmptyString(preview.url, step + ' preview.url');
76
- return {
77
- url,
78
- token: typeof preview.token === 'string' && preview.token.trim().length > 0 ? preview.token.trim() : undefined,
79
- endpoint: typeof preview.endpoint === 'string' && preview.endpoint.trim().length > 0 ? preview.endpoint.trim() : undefined,
80
- };
81
- }
82
- async function runBootstrapStep(client, method, params, step, completed) {
83
- try {
84
- return await client.sendRequest(method, params);
85
- }
86
- catch (error) {
87
- const resolved = resolveProtocolError(error);
88
- throw new BootstrapStepError(resolved.reasonCode, resolved.message, {
89
- failedStep: step,
90
- completedSteps: completed,
91
- });
92
- }
93
- }
94
- function validateServerConfig(config) {
95
- const server = config.server;
96
- const license = server?.license?.trim() ?? '';
97
- const mp4Path = server?.mp4_path?.trim() ?? '';
98
- const audioStreamId = ensureNonNegativeInteger(server?.audio_stream_id, '[server].audio_stream_id');
99
- const videoStreamId = ensureNonNegativeInteger(server?.video_stream_id, '[server].video_stream_id');
100
- if (license.length === 0) {
101
- throw new Error('server-only config requires [server].license');
102
- }
103
- if (mp4Path.length === 0) {
104
- throw new Error('server-only config requires [server].mp4_path');
105
- }
106
- if (audioStreamId === videoStreamId) {
107
- throw new Error('server-only config requires distinct audio_stream_id and video_stream_id');
108
- }
109
- const resolvedMp4Path = path_1.default.resolve(mp4Path);
110
- let stats;
111
- try {
112
- stats = fs_1.default.statSync(resolvedMp4Path);
113
- }
114
- catch {
115
- throw new Error('server-only config mp4_path does not exist: ' + resolvedMp4Path);
116
- }
117
- if (!stats.isFile()) {
118
- throw new Error('server-only config mp4_path must be a readable file: ' + resolvedMp4Path);
119
- }
120
- const serviceEntry = server?.service_entry?.trim();
121
- return {
122
- serviceEntry: serviceEntry && serviceEntry.length > 0 ? serviceEntry : undefined,
123
- license,
124
- mp4Path: resolvedMp4Path,
125
- audioStreamId,
126
- videoStreamId,
127
- };
128
- }
129
- function validateClientConfig(config) {
130
- const client = config.client;
131
- if (!client) {
132
- throw new Error('client start requires [client] config');
133
- }
134
- const peerId = ensureNonEmptyString(client.peer_id, '[client].peer_id');
135
- const audioStreamId = ensureNonNegativeInteger(client.audio_stream_id, '[client].audio_stream_id');
136
- const videoStreamId = ensureNonNegativeInteger(client.video_stream_id, '[client].video_stream_id');
137
- if (audioStreamId === videoStreamId) {
138
- throw new Error('client config requires distinct audio_stream_id and video_stream_id');
139
- }
140
- if (client.consumer !== 'web_preview') {
141
- throw new Error('client config requires [client].consumer = "web_preview"');
142
- }
143
- const serviceEntry = client.service_entry?.trim();
144
- return {
145
- serviceEntry: serviceEntry && serviceEntry.length > 0 ? serviceEntry : undefined,
146
- peerId,
147
- audioStreamId,
148
- videoStreamId,
149
- consumer: 'web_preview',
150
- };
151
- }
152
- async function applyConfiguredServerBootstrap(client, config, progress) {
153
- const server = validateServerConfig(config);
154
- progress?.start('Preparing MP4 assets');
155
- const prepared = await (0, media_assets_1.prepareMediaAssets)({
156
- source: server.mp4Path,
157
- outputRoot: (0, default_paths_1.resolveCliPreparedAssetsRoot)(),
158
- });
159
- progress?.update('Prepared MP4 assets');
160
- const bootstrapSendStreams = [
161
- { streamId: server.audioStreamId, media: 'audio' },
162
- { streamId: server.videoStreamId, media: 'video' },
163
- ].map(({ streamId, media }) => ({
164
- streamId,
165
- media,
166
- source: {
167
- mode: 'local_assets',
168
- local_assets: {
169
- assets_dir: prepared.assets_dir,
170
- },
171
- },
172
- }));
173
- return {
174
- preparedAssetsDir: prepared.assets_dir,
175
- mediaSendPolicy: 'AUTO_ON_CONNECTED',
176
- bootstrapSendStreams,
177
- };
178
- }
179
- async function applyClientStartBootstrap(client, config, token, progress) {
180
- const normalizedToken = ensureNonEmptyString(token, '--token');
181
- const clientConfig = validateClientConfig(config);
182
- const audioArtifactPath = path_1.default.join(os_1.default.tmpdir(), `tirtc-client-preview-audio-${Date.now()}-${process.pid}.pcm`);
183
- const videoArtifactPath = path_1.default.join(os_1.default.tmpdir(), `tirtc-client-preview-video-${Date.now()}-${process.pid}.jpeg`);
184
- const completed = {
185
- consumer: clientConfig.consumer,
186
- };
187
- progress?.start('Connecting client session');
188
- const connection = await runBootstrapStep(client, 'connection/connect', {
189
- serviceEntry: clientConfig.serviceEntry,
190
- peerId: clientConfig.peerId,
191
- token: normalizedToken,
192
- timeoutMs: 5000,
193
- }, 'connect', completed);
194
- completed.connection = connection;
195
- progress?.update('Connected client session');
196
- const audioStream = await runBootstrapStep(client, 'stream/receiveStart', {
197
- streamId: clientConfig.audioStreamId,
198
- media: 'audio',
199
- }, 'receive audio', completed);
200
- completed.audioStream = audioStream;
201
- progress?.update('Attached audio receive stream');
202
- const videoStream = await runBootstrapStep(client, 'stream/receiveStart', {
203
- streamId: clientConfig.videoStreamId,
204
- media: 'video',
205
- }, 'receive video', completed);
206
- completed.videoStream = videoStream;
207
- progress?.update('Attached video receive stream');
208
- const audioOutput = await runBootstrapStep(client, 'output/attach', {
209
- streamId: clientConfig.audioStreamId,
210
- consumer: clientConfig.consumer,
211
- mediaView: 'encoded_packet',
212
- format: 'pcm',
213
- delivery: 'artifact_path',
214
- targetPath: audioArtifactPath,
215
- }, 'attach audio preview', completed);
216
- completed.audioOutput = audioOutput;
217
- progress?.update('Attached audio preview output');
218
- const videoOutput = await runBootstrapStep(client, 'output/attach', {
219
- streamId: clientConfig.videoStreamId,
220
- consumer: clientConfig.consumer,
221
- mediaView: 'encoded_packet',
222
- format: 'jpeg',
223
- delivery: 'artifact_path',
224
- targetPath: videoArtifactPath,
225
- }, 'attach video preview', completed);
226
- completed.videoOutput = videoOutput;
227
- progress?.succeed('Client preview session is ready');
228
- const audioPreview = extractPreview(audioOutput, 'attach audio preview');
229
- const videoPreview = extractPreview(videoOutput, 'attach video preview');
230
- if (audioPreview.url !== videoPreview.url) {
231
- throw new BootstrapStepError('internal_error', 'web_preview outputs returned different preview URLs', {
232
- failedStep: 'preview aggregation',
233
- completedSteps: completed,
234
- audioPreview,
235
- videoPreview,
236
- });
237
- }
238
- return {
239
- connection,
240
- autoApplied: {
241
- consumer: clientConfig.consumer,
242
- audioStream,
243
- videoStream,
244
- audioOutput,
245
- videoOutput,
246
- preview: audioPreview,
247
- },
248
- };
249
- }
@@ -1,26 +0,0 @@
1
- export type CliConfig = {
2
- server?: {
3
- service_entry?: string;
4
- license?: string;
5
- mp4_path?: string;
6
- video_stream_id?: number;
7
- audio_stream_id?: number;
8
- };
9
- client?: {
10
- service_entry?: string;
11
- peer_id?: string;
12
- audio_stream_id?: number;
13
- video_stream_id?: number;
14
- consumer?: 'web_preview';
15
- };
16
- debug?: {
17
- connect_bootstrap?: {
18
- access_id?: string;
19
- secret_key?: string;
20
- peer_id?: string;
21
- service_entry?: string;
22
- };
23
- };
24
- };
25
- export declare function loadConfig(configPath?: string): CliConfig;
26
- export declare function writeConfigTemplate(outputPath?: string): string;
@@ -1,62 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.loadConfig = loadConfig;
7
- exports.writeConfigTemplate = writeConfigTemplate;
8
- const fs_1 = __importDefault(require("fs"));
9
- const path_1 = __importDefault(require("path"));
10
- const toml_1 = __importDefault(require("@iarna/toml"));
11
- const facade_1 = require("./facade");
12
- function loadConfig(configPath) {
13
- if (!configPath || !fs_1.default.existsSync(configPath)) {
14
- return {};
15
- }
16
- const ext = path_1.default.extname(configPath).toLowerCase();
17
- if (ext !== '.toml') {
18
- throw new Error('config must be TOML (.toml): ' + configPath);
19
- }
20
- const content = fs_1.default.readFileSync(configPath, 'utf-8');
21
- return facade_1.CliConfigSchema.parse(toml_1.default.parse(content));
22
- }
23
- function resolveConfigOutputPath(outputPath) {
24
- if (outputPath && outputPath.trim().length > 0) {
25
- return path_1.default.resolve(outputPath.trim());
26
- }
27
- return path_1.default.resolve(process.cwd(), '.tmp/tirtc-devtools-cli/config.toml');
28
- }
29
- function renderTomlConfigTemplate() {
30
- return [
31
- '# TiRTC DevTool CLI 配置模板(TOML)',
32
- '# client token 通过命令行 --token 显式提供,不写入配置文件。',
33
- '',
34
- '[server]',
35
- '# 可留空,走 runtime/core/transport 默认 service_entry',
36
- 'service_entry = ""',
37
- '# server-only service start 时必填',
38
- 'license = ""',
39
- 'mp4_path = "./source.mp4"',
40
- 'video_stream_id = 11',
41
- 'audio_stream_id = 10',
42
- '',
43
- '[client]',
44
- '# client start 正式路径读取这里的最小连接事实',
45
- 'service_entry = ""',
46
- 'peer_id = "peer-123"',
47
- 'audio_stream_id = 10',
48
- 'video_stream_id = 11',
49
- 'consumer = "web_preview"',
50
- '',
51
- ].join('\n');
52
- }
53
- function writeConfigTemplate(outputPath) {
54
- const targetPath = resolveConfigOutputPath(outputPath);
55
- if (path_1.default.extname(targetPath).toLowerCase() !== '.toml') {
56
- throw new Error('init output must be TOML (.toml): ' + targetPath);
57
- }
58
- const dir = path_1.default.dirname(targetPath);
59
- fs_1.default.mkdirSync(dir, { recursive: true });
60
- fs_1.default.writeFileSync(targetPath, renderTomlConfigTemplate(), 'utf8');
61
- return targetPath;
62
- }