@tx5dr/contracts 1.2.2 → 1.4.0
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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/schema/cpu-profile.schema.d.ts +95 -0
- package/dist/schema/cpu-profile.schema.d.ts.map +1 -0
- package/dist/schema/cpu-profile.schema.js +35 -0
- package/dist/schema/cpu-profile.schema.js.map +1 -0
- package/dist/schema/operator.schema.d.ts +70 -103
- package/dist/schema/operator.schema.d.ts.map +1 -1
- package/dist/schema/operator.schema.js +0 -5
- package/dist/schema/operator.schema.js.map +1 -1
- package/dist/schema/plugin.schema.d.ts +137 -61
- package/dist/schema/plugin.schema.d.ts.map +1 -1
- package/dist/schema/plugin.schema.js +22 -14
- package/dist/schema/plugin.schema.js.map +1 -1
- package/dist/schema/process-monitor.schema.d.ts +100 -0
- package/dist/schema/process-monitor.schema.d.ts.map +1 -1
- package/dist/schema/process-monitor.schema.js +8 -0
- package/dist/schema/process-monitor.schema.js.map +1 -1
- package/dist/schema/voice-keyer.schema.d.ts +164 -0
- package/dist/schema/voice-keyer.schema.d.ts.map +1 -0
- package/dist/schema/voice-keyer.schema.js +43 -0
- package/dist/schema/voice-keyer.schema.js.map +1 -0
- package/dist/schema/websocket.schema.d.ts +711 -613
- package/dist/schema/websocket.schema.d.ts.map +1 -1
- package/dist/schema/websocket.schema.js +17 -5
- package/dist/schema/websocket.schema.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +4 -0
- package/src/schema/cpu-profile.schema.ts +47 -0
- package/src/schema/operator.schema.ts +0 -5
- package/src/schema/plugin.schema.ts +26 -16
- package/src/schema/process-monitor.schema.ts +10 -0
- package/src/schema/voice-keyer.schema.ts +55 -0
- package/src/schema/websocket.schema.ts +28 -5
- package/test/plugin-slot-schema.test.ts +30 -0
|
@@ -26,6 +26,7 @@ import { RadioInfoSchema, HamlibConfigSchema, TunerStatusSchema, TunerCapabiliti
|
|
|
26
26
|
import { RadioProfileSchema, ProfileChangedEventSchema } from './radio-profile.schema.js';
|
|
27
27
|
import { UserRole } from './auth.schema.js';
|
|
28
28
|
import type { VoicePTTLock } from './voice.schema.js';
|
|
29
|
+
import type { VoiceKeyerStatus } from './voice-keyer.schema.js';
|
|
29
30
|
import { CapabilityListSchema, CapabilityStateSchema, WriteCapabilityPayloadSchema } from './radio-capability.schema.js';
|
|
30
31
|
import { RadioPowerStateEventSchema } from './radio-power.schema.js';
|
|
31
32
|
import { AudioSidecarStatusPayloadSchema } from './audio-sidecar.schema.js';
|
|
@@ -116,6 +117,9 @@ export enum WSMessageType {
|
|
|
116
117
|
// ===== 电台数值表 =====
|
|
117
118
|
METER_DATA = 'meterData',
|
|
118
119
|
|
|
120
|
+
// ===== 电台实际静噪状态 =====
|
|
121
|
+
SQUELCH_STATUS_CHANGED = 'squelchStatusChanged',
|
|
122
|
+
|
|
119
123
|
// ===== 极简文本消息 =====
|
|
120
124
|
TEXT_MESSAGE = 'textMessage',
|
|
121
125
|
|
|
@@ -164,6 +168,9 @@ export enum WSMessageType {
|
|
|
164
168
|
VOICE_PTT_LOCK_CHANGED = 'voicePttLockChanged',
|
|
165
169
|
VOICE_SET_RADIO_MODE = 'voiceSetRadioMode',
|
|
166
170
|
VOICE_RADIO_MODE_CHANGED = 'voiceRadioModeChanged',
|
|
171
|
+
VOICE_KEYER_PLAY = 'voiceKeyerPlay',
|
|
172
|
+
VOICE_KEYER_STOP = 'voiceKeyerStop',
|
|
173
|
+
VOICE_KEYER_STATUS_CHANGED = 'voiceKeyerStatusChanged',
|
|
167
174
|
|
|
168
175
|
// ===== 进程监控 =====
|
|
169
176
|
PROCESS_SNAPSHOT = 'processSnapshot',
|
|
@@ -259,6 +266,14 @@ export const PTTStatusSchema = z.object({
|
|
|
259
266
|
operatorIds: z.array(z.string()),
|
|
260
267
|
});
|
|
261
268
|
|
|
269
|
+
export const SquelchStatusSchema = z.object({
|
|
270
|
+
supported: z.boolean(),
|
|
271
|
+
open: z.boolean().nullable(),
|
|
272
|
+
muted: z.boolean(),
|
|
273
|
+
source: z.enum(['hamlib-dcd', 'unsupported']),
|
|
274
|
+
updatedAt: z.number(),
|
|
275
|
+
});
|
|
276
|
+
|
|
262
277
|
export const OperatorRuntimeSlotSchema = z.enum(['TX1', 'TX2', 'TX3', 'TX4', 'TX5', 'TX6']);
|
|
263
278
|
export type OperatorRuntimeSlot = z.infer<typeof OperatorRuntimeSlotSchema>;
|
|
264
279
|
|
|
@@ -357,6 +372,7 @@ export type SubWindowInfo = z.infer<typeof SubWindowInfoSchema>;
|
|
|
357
372
|
export type DecodeErrorInfo = z.infer<typeof DecodeErrorInfoSchema>;
|
|
358
373
|
export type FrequencyState = z.infer<typeof FrequencyStateSchema>;
|
|
359
374
|
export type PTTStatus = z.infer<typeof PTTStatusSchema>;
|
|
375
|
+
export type SquelchStatus = z.infer<typeof SquelchStatusSchema>;
|
|
360
376
|
export type MeterData = z.infer<typeof MeterDataSchema>;
|
|
361
377
|
|
|
362
378
|
// ===== WebSocket消息Schema定义 =====
|
|
@@ -526,11 +542,6 @@ export const OperatorStatusSchema = z.object({
|
|
|
526
542
|
availableSlots: z.array(z.string()),
|
|
527
543
|
}),
|
|
528
544
|
runtime: StrategyRuntimeSnapshotSchema.optional(),
|
|
529
|
-
cycleInfo: z.object({
|
|
530
|
-
currentCycle: z.number(),
|
|
531
|
-
isTransmitCycle: z.boolean(),
|
|
532
|
-
cycleProgress: z.number().min(0).max(1), // 0-1 表示周期进度百分比
|
|
533
|
-
}).optional(),
|
|
534
545
|
// TX1-TX6 时隙内容
|
|
535
546
|
slots: z.object({
|
|
536
547
|
TX1: z.string().optional(),
|
|
@@ -1020,6 +1031,13 @@ export const WSMeterDataMessageSchema = WSBaseMessageSchema.extend({
|
|
|
1020
1031
|
|
|
1021
1032
|
export type WSMeterDataMessage = z.infer<typeof WSMeterDataMessageSchema>;
|
|
1022
1033
|
|
|
1034
|
+
export const WSSquelchStatusChangedMessageSchema = WSBaseMessageSchema.extend({
|
|
1035
|
+
type: z.literal(WSMessageType.SQUELCH_STATUS_CHANGED),
|
|
1036
|
+
data: SquelchStatusSchema,
|
|
1037
|
+
});
|
|
1038
|
+
|
|
1039
|
+
export type WSSquelchStatusChangedMessage = z.infer<typeof WSSquelchStatusChangedMessageSchema>;
|
|
1040
|
+
|
|
1023
1041
|
/**
|
|
1024
1042
|
* 文本消息(Toast通知)
|
|
1025
1043
|
* 用于向客户端推送提示信息
|
|
@@ -1270,6 +1288,7 @@ export const WSMessageSchema = z.discriminatedUnion('type', [
|
|
|
1270
1288
|
|
|
1271
1289
|
// 电台数值表消息
|
|
1272
1290
|
WSMeterDataMessageSchema,
|
|
1291
|
+
WSSquelchStatusChangedMessageSchema,
|
|
1273
1292
|
|
|
1274
1293
|
// 文本消息(Toast通知)
|
|
1275
1294
|
WSTextMessageSchema,
|
|
@@ -1404,6 +1423,9 @@ export interface DigitalRadioEngineEvents {
|
|
|
1404
1423
|
// 电台数值表事件
|
|
1405
1424
|
meterData: (data: MeterData) => void;
|
|
1406
1425
|
|
|
1426
|
+
// 电台实际静噪状态事件
|
|
1427
|
+
squelchStatusChanged: (data: SquelchStatus) => void;
|
|
1428
|
+
|
|
1407
1429
|
// QSO 日志事件
|
|
1408
1430
|
qsoRecordAdded: (data: { operatorId: string; logBookId: string; qsoRecord: z.infer<typeof QSORecordSchema> }) => void;
|
|
1409
1431
|
qsoRecordUpdated: (data: { operatorId: string; logBookId: string; qsoRecord: z.infer<typeof QSORecordSchema> }) => void;
|
|
@@ -1439,6 +1461,7 @@ export interface DigitalRadioEngineEvents {
|
|
|
1439
1461
|
// 语音模式事件
|
|
1440
1462
|
voicePttLockChanged: (data: VoicePTTLock) => void;
|
|
1441
1463
|
voiceRadioModeChanged: (data: { radioMode: string }) => void;
|
|
1464
|
+
voiceKeyerStatusChanged: (data: VoiceKeyerStatus) => void;
|
|
1442
1465
|
|
|
1443
1466
|
// 进程监控事件
|
|
1444
1467
|
processSnapshot: (data: import('./process-monitor.schema.js').ProcessSnapshot) => void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { PluginPanelDescriptorSchema, PluginPanelSlotSchema } from '../src/schema/plugin.schema';
|
|
3
|
+
|
|
4
|
+
describe('PluginPanelSlotSchema', () => {
|
|
5
|
+
it('accepts every supported plugin panel slot', () => {
|
|
6
|
+
expect(PluginPanelSlotSchema.parse('operator')).toBe('operator');
|
|
7
|
+
expect(PluginPanelSlotSchema.parse('automation')).toBe('automation');
|
|
8
|
+
expect(PluginPanelSlotSchema.parse('main-right')).toBe('main-right');
|
|
9
|
+
expect(PluginPanelSlotSchema.parse('voice-left-top')).toBe('voice-left-top');
|
|
10
|
+
expect(PluginPanelSlotSchema.parse('voice-right-top')).toBe('voice-right-top');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('validates iframe panels declared in the new host slots', () => {
|
|
14
|
+
expect(() => PluginPanelDescriptorSchema.parse({
|
|
15
|
+
id: 'main-pane',
|
|
16
|
+
title: 'mainPaneTitle',
|
|
17
|
+
component: 'iframe',
|
|
18
|
+
pageId: 'main-pane',
|
|
19
|
+
slot: 'main-right',
|
|
20
|
+
})).not.toThrow();
|
|
21
|
+
|
|
22
|
+
expect(() => PluginPanelDescriptorSchema.parse({
|
|
23
|
+
id: 'voice-top',
|
|
24
|
+
title: 'voiceTopTitle',
|
|
25
|
+
component: 'iframe',
|
|
26
|
+
pageId: 'voice-top',
|
|
27
|
+
slot: 'voice-right-top',
|
|
28
|
+
})).not.toThrow();
|
|
29
|
+
});
|
|
30
|
+
});
|