wsjtx-lib 1.2.5 → 2.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 (37) hide show
  1. package/README.md +1 -1
  2. package/dist/src/index.d.ts +15 -163
  3. package/dist/src/index.d.ts.map +1 -1
  4. package/dist/src/index.js +89 -290
  5. package/dist/src/index.js.map +1 -1
  6. package/dist/src/types.d.ts +32 -170
  7. package/dist/src/types.d.ts.map +1 -1
  8. package/dist/src/types.js +3 -78
  9. package/dist/src/types.js.map +1 -1
  10. package/dist/test/wsjtx.basic.test.d.ts +3 -2
  11. package/dist/test/wsjtx.basic.test.d.ts.map +1 -1
  12. package/dist/test/wsjtx.basic.test.js +63 -200
  13. package/dist/test/wsjtx.basic.test.js.map +1 -1
  14. package/dist/test/wsjtx.test.d.ts +16 -7
  15. package/dist/test/wsjtx.test.d.ts.map +1 -1
  16. package/dist/test/wsjtx.test.js +297 -560
  17. package/dist/test/wsjtx.test.js.map +1 -1
  18. package/package.json +1 -1
  19. package/prebuilds/darwin-arm64/build-info.json +1 -1
  20. package/prebuilds/darwin-arm64/libfftw3f.3.dylib +0 -0
  21. package/prebuilds/darwin-arm64/libfftw3f_threads.3.dylib +0 -0
  22. package/prebuilds/darwin-arm64/libwsjtx_core.dylib +0 -0
  23. package/prebuilds/darwin-arm64/wsjtx_lib_nodejs.node +0 -0
  24. package/prebuilds/darwin-x64/build-info.json +1 -1
  25. package/prebuilds/darwin-x64/libfftw3f.3.dylib +0 -0
  26. package/prebuilds/darwin-x64/libfftw3f_threads.3.dylib +0 -0
  27. package/prebuilds/darwin-x64/libwsjtx_core.dylib +0 -0
  28. package/prebuilds/darwin-x64/wsjtx_lib_nodejs.node +0 -0
  29. package/prebuilds/linux-arm64/build-info.json +1 -1
  30. package/prebuilds/linux-arm64/libwsjtx_core.so +0 -0
  31. package/prebuilds/linux-arm64/wsjtx_lib_nodejs.node +0 -0
  32. package/prebuilds/linux-x64/build-info.json +1 -1
  33. package/prebuilds/linux-x64/libwsjtx_core.so +0 -0
  34. package/prebuilds/linux-x64/wsjtx_lib_nodejs.node +0 -0
  35. package/prebuilds/win32-x64/build-info.json +1 -1
  36. package/prebuilds/win32-x64/wsjtx_core.dll +0 -0
  37. package/prebuilds/win32-x64/wsjtx_lib_nodejs.node +0 -0
package/README.md CHANGED
@@ -192,7 +192,7 @@ Encode a message into audio waveform for transmission.
192
192
 
193
193
  **Parameters:**
194
194
  - `mode`: WSJTXMode enum value
195
- - `message`: Message text to encode (1-22 characters)
195
+ - `message`: Message text to encode (FT8/FT4 structured messages: 1-37 characters; free text payloads are limited by WSJT-X to 13 characters)
196
196
  - `frequency`: Audio frequency in Hz (typically 500-3000 Hz)
197
197
  - `threads`: Number of threads to use (optional, default: 4)
198
198
 
@@ -1,182 +1,34 @@
1
1
  /**
2
- * WSJTX Digital Radio Protocol Library for Node.js
2
+ * wsjtx-lib Node.js binding for the WSJT-X 3.0.0 backend.
3
3
  *
4
- * High-level TypeScript wrapper around the native C++ WSJTX library bindings.
5
- * Provides async/await support, input validation, and convenient utilities
6
- * for working with digital amateur radio protocols.
7
- *
8
- * @example
9
- * ```typescript
10
- * import { WSJTXLib, WSJTXMode } from 'wsjtx-lib';
11
- *
12
- * const lib = new WSJTXLib();
13
- *
14
- * // Decode FT8 audio data
15
- * const audioData = new Float32Array(48000 * 13); // 13 seconds at 48kHz
16
- * const result = await lib.decode(WSJTXMode.FT8, audioData, 1500);
17
- *
18
- * // Get decoded messages
19
- * const messages = lib.pullMessages();
20
- * console.log('Decoded messages:', messages);
21
- * ```
22
- */
23
- import { WSJTXMode, DecodeResult, EncodeResult, WSPRResult, WSPRDecodeOptions, WSJTXMessage, AudioData, IQData, WSJTXError, WSJTXConfig, VersionInfo, ModeCapabilities } from './types.js';
24
- /**
25
- * Main WSJTX library class providing digital radio protocol processing
26
- *
27
- * This class wraps the native C++ implementation and provides a convenient
28
- * TypeScript/JavaScript interface with proper error handling, validation,
29
- * and async/await support.
4
+ * Public surface:
5
+ * - WSJTXLib.encode(mode, message, frequency)
6
+ * - WSJTXLib.decode(mode, audio, options)
7
+ * - WSJTXLib.decodeWSPR(audio, options)
8
+ * - WSJTXLib.convertAudioFormat(audio, target)
9
+ * - capability/sample-rate query helpers
30
10
  */
11
+ import { WSJTXMode, type DecodeResult, type EncodeResult, type WSPRResult, type WSPRDecodeOptions, type WSJTXMessage, type AudioData, WSJTXError, type WSJTXConfig, type ModeCapabilities, type DecodeOptions } from './types.js';
31
12
  export declare class WSJTXLib {
32
- private native;
33
- private config;
34
- /**
35
- * Create a new WSJTX library instance
36
- *
37
- * @param config Optional configuration options
38
- * @throws {WSJTXError} If the native library fails to initialize
39
- */
13
+ private readonly native;
14
+ private readonly config;
40
15
  constructor(config?: WSJTXConfig);
41
- /**
42
- * Decode digital radio signals from audio data
43
- *
44
- * This method processes audio samples and attempts to decode digital
45
- * messages using the specified protocol mode. The operation is performed
46
- * asynchronously to avoid blocking the Node.js event loop.
47
- *
48
- * @param mode The digital mode to use for decoding
49
- * @param audioData Audio samples (Float32Array or Int16Array)
50
- * @param frequency Center frequency in Hz
51
- * @param threads Number of threads to use (1-16, default: 4)
52
- * @returns Promise that resolves when decoding is complete
53
- *
54
- * @throws {WSJTXError} If parameters are invalid or decoding fails
55
- *
56
- * @example
57
- * ```typescript
58
- * const audioData = new Float32Array(48000 * 13); // 13 seconds
59
- * await lib.decode(WSJTXMode.FT8, audioData, 1500);
60
- * const messages = lib.pullMessages();
61
- * ```
62
- */
63
- decode(mode: WSJTXMode, audioData: AudioData, frequency: number, threads?: number): Promise<DecodeResult>;
64
- /**
65
- * Encode a message into audio waveform for transmission
66
- *
67
- * Generates the audio waveform that represents the specified message
68
- * using the given digital mode. The resulting audio can be fed to
69
- * a radio transmitter or audio interface.
70
- *
71
- * @param mode The digital mode to use for encoding
72
- * @param message The message text to encode (mode-specific format)
73
- * @param frequency Center frequency in Hz
74
- * @param threads Number of threads to use (1-16, default: 4)
75
- * @returns Promise that resolves with encoded audio data and actual message sent
76
- *
77
- * @throws {WSJTXError} If parameters are invalid or encoding fails
78
- *
79
- * @example
80
- * ```typescript
81
- * const result = await lib.encode(WSJTXMode.FT8, 'CQ DX K1ABC FN20', 1500);
82
- * console.log('Generated audio samples:', result.audioData.length);
83
- * console.log('Actual message sent:', result.messageSent);
84
- * ```
85
- */
16
+ decode(mode: WSJTXMode, audioData: AudioData, options: DecodeOptions): Promise<DecodeResult>;
86
17
  encode(mode: WSJTXMode, message: string, frequency: number, threads?: number): Promise<EncodeResult>;
87
- /**
88
- * Decode WSPR signals from IQ data
89
- *
90
- * WSPR (Weak Signal Propagation Reporter) is a specialized protocol
91
- * for studying radio propagation. This method takes IQ (complex)
92
- * samples and attempts to decode WSPR transmissions.
93
- *
94
- * @param iqData Interleaved I,Q samples as Float32Array
95
- * @param options Decoder options (frequency, callsign, etc.)
96
- * @returns Promise that resolves with array of decoded WSPR results
97
- *
98
- * @throws {WSJTXError} If parameters are invalid or decoding fails
99
- *
100
- * @example
101
- * ```typescript
102
- * const iqData = new Float32Array(2 * 12000 * 111); // 2 minutes of IQ data
103
- * const options = {
104
- * dialFrequency: 14095600, // 20m WSPR frequency
105
- * callsign: 'K1ABC',
106
- * locator: 'FN20'
107
- * };
108
- * const results = await lib.decodeWSPR(iqData, options);
109
- * ```
110
- */
111
- decodeWSPR(iqData: IQData, options?: WSPRDecodeOptions): Promise<WSPRResult[]>;
112
- /**
113
- * Retrieve decoded messages from the internal queue
114
- *
115
- * Messages are added to an internal queue as they are decoded.
116
- * This method retrieves and removes all pending messages from the queue.
117
- *
118
- * @returns Array of decoded messages
119
- *
120
- * @example
121
- * ```typescript
122
- * const messages = lib.pullMessages();
123
- * messages.forEach(msg => {
124
- * console.log(`${msg.text} (SNR: ${msg.snr} dB, ΔT: ${msg.deltaTime}s)`);
125
- * });
126
- * ```
127
- */
18
+ decodeWSPR(audioData: Int16Array, options?: WSPRDecodeOptions): Promise<WSPRResult[]>;
128
19
  pullMessages(): WSJTXMessage[];
129
- /**
130
- * Check if encoding is supported for a specific mode
131
- *
132
- * @param mode The mode to check
133
- * @returns True if encoding is supported
134
- */
135
20
  isEncodingSupported(mode: WSJTXMode): boolean;
136
- /**
137
- * Check if decoding is supported for a specific mode
138
- *
139
- * @param mode The mode to check
140
- * @returns True if decoding is supported
141
- */
142
21
  isDecodingSupported(mode: WSJTXMode): boolean;
143
- /**
144
- * Get the required sample rate for a specific mode
145
- *
146
- * @param mode The mode to query
147
- * @returns Sample rate in Hz
148
- */
149
22
  getSampleRate(mode: WSJTXMode): number;
150
- /**
151
- * Get the transmission duration for a specific mode
152
- *
153
- * @param mode The mode to query
154
- * @returns Duration in seconds
155
- */
156
23
  getTransmissionDuration(mode: WSJTXMode): number;
157
- /**
158
- * Get capabilities for all supported modes
159
- *
160
- * @returns Array of mode capability information
161
- */
162
24
  getAllModeCapabilities(): ModeCapabilities[];
163
- /**
164
- * Convert audio format between Float32Array and Int16Array (async)
165
- *
166
- * Uses the native addon with Node's libuv 线程池执行,不阻塞主线程。
167
- *
168
- * @param audioData 输入音频数据
169
- * @param targetFormat 目标格式 ('float32' | 'int16')
170
- * @returns Promise 解析为转换后的数据
171
- */
172
25
  convertAudioFormat(audioData: AudioData, targetFormat: 'float32' | 'int16'): Promise<AudioData>;
173
26
  private validateMode;
174
27
  private validateFrequency;
175
28
  private validateThreads;
176
29
  private validateMessage;
177
- private validateAudioData;
178
- private validateIQData;
30
+ private validateAudio;
179
31
  }
180
- export { WSJTXMode, WSJTXError, };
181
- export type { DecodeResult, EncodeResult, WSPRResult, WSPRDecodeOptions, WSJTXMessage, AudioData, IQData, WSJTXConfig, VersionInfo, ModeCapabilities };
32
+ export { WSJTXMode, WSJTXError };
33
+ export type { DecodeResult, EncodeResult, WSPRResult, WSPRDecodeOptions, WSJTXMessage, AudioData, WSJTXConfig, DecodeOptions, ModeCapabilities, };
182
34
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"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