native-recorder-nodejs 1.0.1 → 1.0.5
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/LICENSE +21 -0
- package/package.json +5 -2
- package/prebuilds/NativeAudioSDK-darwin-arm64.node +0 -0
- package/prebuilds/NativeAudioSDK-darwin-x64.node +0 -0
- package/prebuilds/NativeAudioSDK-win32-x64.node +0 -0
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/recorder.d.ts +0 -56
- package/dist/recorder.d.ts.map +0 -1
- package/dist/recorder.js +0 -343
- package/dist/recorder.js.map +0 -1
- package/dist/types.d.ts +0 -108
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -49
- package/dist/types.js.map +0 -1
- package/prebuilds/native-audio-recorder-v0.1.0-napi-v8-darwin-arm64.tar.gz +0 -0
- package/prebuilds/native-recorder-nodejs-v1.0.0-napi-v8-darwin-arm64.tar.gz +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Yidadaa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "native-recorder-nodejs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Cross-platform (Win/Mac) Native Audio SDK for Node.js",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
"test:native": "npm run build:tests && cd build && ctest -C Release --output-on-failure",
|
|
18
18
|
"test:cli": "node ./test/cli_test.js",
|
|
19
19
|
"clean": "rimraf dist build prebuilds",
|
|
20
|
-
"prepublishOnly": "npm run build:ts"
|
|
20
|
+
"prepublishOnly": "npm run build:ts",
|
|
21
|
+
"release": "npm version patch && git push && git push --tags",
|
|
22
|
+
"release:minor": "npm version minor && git push && git push --tags",
|
|
23
|
+
"release:major": "npm version major && git push && git push --tags"
|
|
21
24
|
},
|
|
22
25
|
"keywords": [
|
|
23
26
|
"audio",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/typescript/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAG3B,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/typescript/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+BAA+B;AAC/B,0CAAwB;AACxB,6CAA2B;AAE3B,iCAAiC;AACjC,uCAAiD;AAAxC,mGAAA,QAAQ,OAAW"}
|
package/dist/recorder.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Result, PermissionStatus, AudioDevice, RecordingOptions, RecordingState, AudioSDKError, AudioDeviceType, RecordingStreamEvent } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Main Audio SDK Recorder class
|
|
4
|
-
*/
|
|
5
|
-
export declare class Recorder {
|
|
6
|
-
private state;
|
|
7
|
-
private currentController?;
|
|
8
|
-
private recorderId?;
|
|
9
|
-
/**
|
|
10
|
-
* Private constructor that prevents direct instantiation of the Recorder class.
|
|
11
|
-
*
|
|
12
|
-
* Use the static `Recorder.create()` method instead to create instances.
|
|
13
|
-
*
|
|
14
|
-
* @deprecated This constructor should not be called directly. Use Recorder.create() instead.
|
|
15
|
-
* @private
|
|
16
|
-
*/
|
|
17
|
-
constructor(internal?: boolean);
|
|
18
|
-
/**
|
|
19
|
-
* Factory method to create a new Recorder instance
|
|
20
|
-
*/
|
|
21
|
-
static create(): Promise<Recorder>;
|
|
22
|
-
private initializeNative;
|
|
23
|
-
/**
|
|
24
|
-
* Check current permissions without requesting them
|
|
25
|
-
*/
|
|
26
|
-
checkPermissions(): Promise<Result<PermissionStatus>>;
|
|
27
|
-
/**
|
|
28
|
-
* Get list of available audio devices
|
|
29
|
-
*/
|
|
30
|
-
getAudioDevices(type?: AudioDeviceType): Promise<Result<AudioDevice[]>>;
|
|
31
|
-
/**
|
|
32
|
-
* Start recording with async generator pattern
|
|
33
|
-
*/
|
|
34
|
-
startRecording(options: RecordingOptions): Promise<Result<AsyncGenerator<RecordingStreamEvent>, AudioSDKError>>;
|
|
35
|
-
/**
|
|
36
|
-
* Private method to create the recording generator
|
|
37
|
-
*/
|
|
38
|
-
private createRecordingGenerator;
|
|
39
|
-
/**
|
|
40
|
-
* Stop current recording
|
|
41
|
-
*/
|
|
42
|
-
stopRecording(): Promise<Result<void>>;
|
|
43
|
-
/**
|
|
44
|
-
* Get current recording state
|
|
45
|
-
*/
|
|
46
|
-
getState(): RecordingState;
|
|
47
|
-
/**
|
|
48
|
-
* Clean up resources
|
|
49
|
-
*/
|
|
50
|
-
private cleanup;
|
|
51
|
-
/**
|
|
52
|
-
* Dispose of the recorder and free native resources
|
|
53
|
-
*/
|
|
54
|
-
dispose(): Promise<void>;
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=recorder.d.ts.map
|
package/dist/recorder.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recorder.d.ts","sourceRoot":"","sources":["../src/typescript/recorder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAEhB,cAAc,EACd,aAAa,EAEb,eAAe,EACf,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAejB;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,KAAK,CAAuC;IACpD,OAAO,CAAC,iBAAiB,CAAC,CAAkB;IAC5C,OAAO,CAAC,UAAU,CAAC,CAAS;IAE5B;;;;;;;OAOG;gBACS,QAAQ,UAAQ;IAQ5B;;OAEG;WACU,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC;YAM1B,gBAAgB;IAY9B;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAqC3D;;OAEG;IACG,eAAe,CACnB,IAAI,CAAC,EAAE,eAAe,GACrB,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;IAkEjC;;OAEG;IACG,cAAc,CAClB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,oBAAoB,CAAC,EAAE,aAAa,CAAC,CAAC;IA4EvE;;OAEG;YACY,wBAAwB;IAoEvC;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAsD5C;;OAEG;IACH,QAAQ,IAAI,cAAc;IAI1B;;OAEG;YACW,OAAO;IAarB;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAY/B"}
|
package/dist/recorder.js
DELETED
|
@@ -1,343 +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.Recorder = void 0;
|
|
37
|
-
const types_1 = require("./types");
|
|
38
|
-
const path = __importStar(require("path"));
|
|
39
|
-
// import nativeAddon from "../../build/Release/audio_sdk_native.node";
|
|
40
|
-
// Import the native addon with correct path resolution
|
|
41
|
-
const nativeAddon = require(path.join(__dirname, "../..", "build", "Release", "audio_sdk_native.node"));
|
|
42
|
-
/**
|
|
43
|
-
* Main Audio SDK Recorder class
|
|
44
|
-
*/
|
|
45
|
-
class Recorder {
|
|
46
|
-
/**
|
|
47
|
-
* Private constructor that prevents direct instantiation of the Recorder class.
|
|
48
|
-
*
|
|
49
|
-
* Use the static `Recorder.create()` method instead to create instances.
|
|
50
|
-
*
|
|
51
|
-
* @deprecated This constructor should not be called directly. Use Recorder.create() instead.
|
|
52
|
-
* @private
|
|
53
|
-
*/
|
|
54
|
-
constructor(internal = false) {
|
|
55
|
-
this.state = types_1.RecordingState.IDLE;
|
|
56
|
-
if (!internal) {
|
|
57
|
-
console.error("Do not instantiate Recorder directly, use Recorder.create() instead");
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Factory method to create a new Recorder instance
|
|
62
|
-
*/
|
|
63
|
-
static async create() {
|
|
64
|
-
const recorder = new Recorder(true);
|
|
65
|
-
await recorder.initializeNative();
|
|
66
|
-
return recorder;
|
|
67
|
-
}
|
|
68
|
-
async initializeNative() {
|
|
69
|
-
const result = nativeAddon.createRecorder();
|
|
70
|
-
if (!result.success) {
|
|
71
|
-
throw new types_1.AudioSDKError(types_1.AudioSDKErrorType.INITIALIZATION_FAILED, "Failed to initialize native recorder", result.error);
|
|
72
|
-
}
|
|
73
|
-
this.recorderId = result.value;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Check current permissions without requesting them
|
|
77
|
-
*/
|
|
78
|
-
async checkPermissions() {
|
|
79
|
-
if (!this.recorderId) {
|
|
80
|
-
return {
|
|
81
|
-
success: false,
|
|
82
|
-
error: new types_1.AudioSDKError(types_1.AudioSDKErrorType.INITIALIZATION_FAILED, "Recorder not initialized"),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
try {
|
|
86
|
-
const result = nativeAddon.checkPermissions(this.recorderId);
|
|
87
|
-
if (result.success) {
|
|
88
|
-
return { success: true, value: result.value };
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
return {
|
|
92
|
-
success: false,
|
|
93
|
-
error: new types_1.AudioSDKError(types_1.AudioSDKErrorType.PERMISSION_DENIED, result.error.message, result.error),
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
return {
|
|
99
|
-
success: false,
|
|
100
|
-
error: new types_1.AudioSDKError(types_1.AudioSDKErrorType.PERMISSION_DENIED, "Failed to check permissions", error),
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Get list of available audio devices
|
|
106
|
-
*/
|
|
107
|
-
async getAudioDevices(type) {
|
|
108
|
-
if (!this.recorderId) {
|
|
109
|
-
return {
|
|
110
|
-
success: false,
|
|
111
|
-
error: new types_1.AudioSDKError(types_1.AudioSDKErrorType.INITIALIZATION_FAILED, "Recorder not initialized"),
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
try {
|
|
115
|
-
const devices = [];
|
|
116
|
-
const deviceTypes = type !== undefined
|
|
117
|
-
? [type]
|
|
118
|
-
: [
|
|
119
|
-
types_1.AudioDeviceType.MICROPHONE,
|
|
120
|
-
types_1.AudioDeviceType.SYSTEM_AUDIO,
|
|
121
|
-
types_1.AudioDeviceType.APPLICATION,
|
|
122
|
-
];
|
|
123
|
-
for (const deviceType of deviceTypes) {
|
|
124
|
-
const countResult = nativeAddon.getDeviceCount(this.recorderId, deviceType);
|
|
125
|
-
if (!countResult.success) {
|
|
126
|
-
console.warn(`Failed to get device count for type ${deviceType}: ${countResult.error.message}`);
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
const count = countResult.value;
|
|
130
|
-
for (let i = 0; i < count; i++) {
|
|
131
|
-
const deviceResult = nativeAddon.getDeviceInfo(this.recorderId, deviceType, i);
|
|
132
|
-
if (deviceResult.success) {
|
|
133
|
-
devices.push({
|
|
134
|
-
id: deviceResult.value.id,
|
|
135
|
-
name: deviceResult.value.name,
|
|
136
|
-
type: deviceResult.value.type,
|
|
137
|
-
isDefault: deviceResult.value.isDefault,
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return { success: true, value: devices };
|
|
143
|
-
}
|
|
144
|
-
catch (error) {
|
|
145
|
-
return {
|
|
146
|
-
success: false,
|
|
147
|
-
error: new types_1.AudioSDKError(types_1.AudioSDKErrorType.DEVICE_NOT_FOUND, "Failed to enumerate audio devices", error),
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Start recording with async generator pattern
|
|
153
|
-
*/
|
|
154
|
-
async startRecording(options) {
|
|
155
|
-
if (this.state !== types_1.RecordingState.IDLE) {
|
|
156
|
-
return {
|
|
157
|
-
success: false,
|
|
158
|
-
error: new types_1.AudioSDKError(types_1.AudioSDKErrorType.RECORDING_FAILED, `Cannot start recording in ${this.state} state`),
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
if (!this.recorderId) {
|
|
162
|
-
return {
|
|
163
|
-
success: false,
|
|
164
|
-
error: new types_1.AudioSDKError(types_1.AudioSDKErrorType.INITIALIZATION_FAILED, "Recorder not initialized"),
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
try {
|
|
168
|
-
// Convert options to native format
|
|
169
|
-
const nativeOptions = {
|
|
170
|
-
deviceType: options.deviceType,
|
|
171
|
-
deviceId: options.deviceId,
|
|
172
|
-
format: options.format || {
|
|
173
|
-
sampleRate: 44100,
|
|
174
|
-
channels: 2,
|
|
175
|
-
bitDepth: 16,
|
|
176
|
-
},
|
|
177
|
-
application: options.application,
|
|
178
|
-
};
|
|
179
|
-
// Initialize native recording
|
|
180
|
-
const initResult = nativeAddon.startRecording(this.recorderId, nativeOptions);
|
|
181
|
-
if (!initResult.success) {
|
|
182
|
-
this.state = types_1.RecordingState.ERROR;
|
|
183
|
-
return {
|
|
184
|
-
success: false,
|
|
185
|
-
error: new types_1.AudioSDKError(types_1.AudioSDKErrorType.INITIALIZATION_FAILED, initResult.error.message, initResult.error),
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
this.state = types_1.RecordingState.RECORDING;
|
|
189
|
-
// Create abort controller for clean cancellation
|
|
190
|
-
this.currentController = new AbortController();
|
|
191
|
-
// Create the async generator
|
|
192
|
-
const generator = this.createRecordingGenerator();
|
|
193
|
-
return {
|
|
194
|
-
success: true,
|
|
195
|
-
value: generator,
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
catch (error) {
|
|
199
|
-
this.state = types_1.RecordingState.ERROR;
|
|
200
|
-
return {
|
|
201
|
-
success: false,
|
|
202
|
-
error: new types_1.AudioSDKError(types_1.AudioSDKErrorType.INITIALIZATION_FAILED, "Failed to initialize recording", error),
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Private method to create the recording generator
|
|
208
|
-
*/
|
|
209
|
-
async *createRecordingGenerator() {
|
|
210
|
-
try {
|
|
211
|
-
// Start audio stream
|
|
212
|
-
while (!this.currentController?.signal.aborted &&
|
|
213
|
-
this.state === types_1.RecordingState.RECORDING) {
|
|
214
|
-
try {
|
|
215
|
-
// Check if still recording
|
|
216
|
-
const statusResult = nativeAddon.isRecording(this.recorderId);
|
|
217
|
-
if (!statusResult.success || !statusResult.value) {
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
const chunkResult = nativeAddon.getAudioChunk(this.recorderId);
|
|
221
|
-
if (chunkResult.success) {
|
|
222
|
-
yield {
|
|
223
|
-
type: "chunk",
|
|
224
|
-
data: {
|
|
225
|
-
data: chunkResult.value.data,
|
|
226
|
-
timestamp: chunkResult.value.timestamp,
|
|
227
|
-
format: chunkResult.value.format,
|
|
228
|
-
},
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
else {
|
|
232
|
-
this.state = types_1.RecordingState.ERROR;
|
|
233
|
-
yield {
|
|
234
|
-
type: "error",
|
|
235
|
-
error: new types_1.AudioSDKError(types_1.AudioSDKErrorType.RECORDING_FAILED, chunkResult.error.message, chunkResult.error),
|
|
236
|
-
};
|
|
237
|
-
break;
|
|
238
|
-
}
|
|
239
|
-
// Small delay to prevent busy waiting
|
|
240
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
241
|
-
}
|
|
242
|
-
catch (error) {
|
|
243
|
-
this.state = types_1.RecordingState.ERROR;
|
|
244
|
-
yield {
|
|
245
|
-
type: "error",
|
|
246
|
-
error: new types_1.AudioSDKError(types_1.AudioSDKErrorType.RECORDING_FAILED, "Error during recording", error),
|
|
247
|
-
};
|
|
248
|
-
break;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
catch (error) {
|
|
253
|
-
this.state = types_1.RecordingState.ERROR;
|
|
254
|
-
yield {
|
|
255
|
-
type: "error",
|
|
256
|
-
error: new types_1.AudioSDKError(types_1.AudioSDKErrorType.INITIALIZATION_FAILED, "Failed to initialize recording", error),
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
finally {
|
|
260
|
-
await this.cleanup();
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Stop current recording
|
|
265
|
-
*/
|
|
266
|
-
async stopRecording() {
|
|
267
|
-
if (this.state !== types_1.RecordingState.RECORDING) {
|
|
268
|
-
return {
|
|
269
|
-
success: false,
|
|
270
|
-
error: new types_1.AudioSDKError(types_1.AudioSDKErrorType.RECORDING_FAILED, `Cannot stop recording in ${this.state} state`),
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
if (!this.recorderId) {
|
|
274
|
-
return {
|
|
275
|
-
success: false,
|
|
276
|
-
error: new types_1.AudioSDKError(types_1.AudioSDKErrorType.INITIALIZATION_FAILED, "Recorder not initialized"),
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
try {
|
|
280
|
-
if (this.currentController) {
|
|
281
|
-
this.currentController.abort();
|
|
282
|
-
}
|
|
283
|
-
const result = nativeAddon.stopRecording(this.recorderId);
|
|
284
|
-
if (result.success) {
|
|
285
|
-
this.state = types_1.RecordingState.STOPPED;
|
|
286
|
-
return { success: true, value: undefined };
|
|
287
|
-
}
|
|
288
|
-
else {
|
|
289
|
-
this.state = types_1.RecordingState.ERROR;
|
|
290
|
-
return {
|
|
291
|
-
success: false,
|
|
292
|
-
error: new types_1.AudioSDKError(types_1.AudioSDKErrorType.RECORDING_FAILED, result.error.message, result.error),
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
catch (error) {
|
|
297
|
-
this.state = types_1.RecordingState.ERROR;
|
|
298
|
-
return {
|
|
299
|
-
success: false,
|
|
300
|
-
error: new types_1.AudioSDKError(types_1.AudioSDKErrorType.RECORDING_FAILED, "Failed to stop recording", error),
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Get current recording state
|
|
306
|
-
*/
|
|
307
|
-
getState() {
|
|
308
|
-
return this.state;
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Clean up resources
|
|
312
|
-
*/
|
|
313
|
-
async cleanup() {
|
|
314
|
-
try {
|
|
315
|
-
if (this.state === types_1.RecordingState.RECORDING && this.recorderId) {
|
|
316
|
-
nativeAddon.stopRecording(this.recorderId);
|
|
317
|
-
}
|
|
318
|
-
this.state = types_1.RecordingState.IDLE;
|
|
319
|
-
this.currentController = undefined;
|
|
320
|
-
}
|
|
321
|
-
catch (error) {
|
|
322
|
-
// Log error but don't throw in cleanup
|
|
323
|
-
console.error("Error during cleanup:", error);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Dispose of the recorder and free native resources
|
|
328
|
-
*/
|
|
329
|
-
async dispose() {
|
|
330
|
-
await this.cleanup();
|
|
331
|
-
if (this.recorderId) {
|
|
332
|
-
try {
|
|
333
|
-
nativeAddon.destroyRecorder(this.recorderId);
|
|
334
|
-
}
|
|
335
|
-
catch (error) {
|
|
336
|
-
console.error("Error destroying native recorder:", error);
|
|
337
|
-
}
|
|
338
|
-
this.recorderId = undefined;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
exports.Recorder = Recorder;
|
|
343
|
-
//# sourceMappingURL=recorder.js.map
|
package/dist/recorder.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recorder.js","sourceRoot":"","sources":["../src/typescript/recorder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAWiB;AAEjB,2CAA6B;AAE7B,uEAAuE;AAEvE,uDAAuD;AACvD,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CACnC,SAAS,EACT,OAAO,EACP,OAAO,EACP,SAAS,EACT,uBAAuB,CACxB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAa,QAAQ;IAKnB;;;;;;;OAOG;IACH,YAAY,QAAQ,GAAG,KAAK;QAZpB,UAAK,GAAmB,sBAAc,CAAC,IAAI,CAAC;QAalD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,CAAC,KAAK,CACX,qEAAqE,CACtE,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;OAEG;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CAAmC,EAAE,KAAK,CAAC,CAAC;YAC5D,CAAC;YACD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC9B,CAAC;IACH,CAAC;CACF;AAhZD,4BAgZC"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Result type for error handling - Either success with value or failure with error
|
|
3
|
-
*/
|
|
4
|
-
export type Result<T, E = Error> = {
|
|
5
|
-
success: true;
|
|
6
|
-
value: T;
|
|
7
|
-
} | {
|
|
8
|
-
success: false;
|
|
9
|
-
error: E;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Audio device types
|
|
13
|
-
*/
|
|
14
|
-
export declare enum AudioDeviceType {
|
|
15
|
-
MICROPHONE = 0,
|
|
16
|
-
SYSTEM_AUDIO = 1,
|
|
17
|
-
APPLICATION = 2
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Audio format configuration
|
|
21
|
-
*/
|
|
22
|
-
export interface AudioFormat {
|
|
23
|
-
sampleRate: number;
|
|
24
|
-
channels: number;
|
|
25
|
-
bitDepth: 16 | 24 | 32;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Audio device information
|
|
29
|
-
*/
|
|
30
|
-
export interface AudioDevice {
|
|
31
|
-
id: string;
|
|
32
|
-
name: string;
|
|
33
|
-
type: AudioDeviceType;
|
|
34
|
-
isDefault: boolean;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Application information for application-specific recording
|
|
38
|
-
*/
|
|
39
|
-
export interface ApplicationInfo {
|
|
40
|
-
pid: number;
|
|
41
|
-
name: string;
|
|
42
|
-
bundleId?: string;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Recording options
|
|
46
|
-
*/
|
|
47
|
-
export interface RecordingOptions {
|
|
48
|
-
deviceType: AudioDeviceType;
|
|
49
|
-
deviceId: string;
|
|
50
|
-
format?: AudioFormat;
|
|
51
|
-
application?: ApplicationInfo;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Audio chunk data
|
|
55
|
-
*/
|
|
56
|
-
export interface AudioChunk {
|
|
57
|
-
data: Buffer;
|
|
58
|
-
timestamp: number;
|
|
59
|
-
format: AudioFormat;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Permission types
|
|
63
|
-
*/
|
|
64
|
-
export interface PermissionStatus {
|
|
65
|
-
microphone: boolean;
|
|
66
|
-
systemAudio: boolean;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Error types
|
|
70
|
-
*/
|
|
71
|
-
export declare enum AudioSDKErrorType {
|
|
72
|
-
PERMISSION_DENIED = "PERMISSION_DENIED",
|
|
73
|
-
DEVICE_NOT_FOUND = "DEVICE_NOT_FOUND",
|
|
74
|
-
DEVICE_BUSY = "DEVICE_BUSY",
|
|
75
|
-
INITIALIZATION_FAILED = "INITIALIZATION_FAILED",
|
|
76
|
-
RECORDING_FAILED = "RECORDING_FAILED",
|
|
77
|
-
INVALID_FORMAT = "INVALID_FORMAT",
|
|
78
|
-
PLATFORM_NOT_SUPPORTED = "PLATFORM_NOT_SUPPORTED"
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Custom error class for Audio SDK
|
|
82
|
-
*/
|
|
83
|
-
export declare class AudioSDKError extends Error {
|
|
84
|
-
type: AudioSDKErrorType;
|
|
85
|
-
details?: any | undefined;
|
|
86
|
-
constructor(type: AudioSDKErrorType, message: string, details?: any | undefined);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Recording state
|
|
90
|
-
*/
|
|
91
|
-
export declare enum RecordingState {
|
|
92
|
-
IDLE = "idle",
|
|
93
|
-
RECORDING = "recording",
|
|
94
|
-
PAUSED = "paused",
|
|
95
|
-
STOPPED = "stopped",
|
|
96
|
-
ERROR = "error"
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Recording stream event types
|
|
100
|
-
*/
|
|
101
|
-
export type RecordingStreamEvent = {
|
|
102
|
-
type: "chunk";
|
|
103
|
-
data: AudioChunk;
|
|
104
|
-
} | {
|
|
105
|
-
type: "error";
|
|
106
|
-
error: AudioSDKError;
|
|
107
|
-
};
|
|
108
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/typescript/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAC3B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAC3B;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAEjC;;GAEG;AACH,oBAAY,eAAe;IACzB,UAAU,IAAI;IACd,YAAY,IAAI;IAChB,WAAW,IAAI;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,eAAe,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,eAAe,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,oBAAY,iBAAiB;IAC3B,iBAAiB,sBAAsB;IACvC,gBAAgB,qBAAqB;IACrC,WAAW,gBAAgB;IAC3B,qBAAqB,0BAA0B;IAC/C,gBAAgB,qBAAqB;IACrC,cAAc,mBAAmB;IACjC,sBAAsB,2BAA2B;CAClD;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;IAE7B,IAAI,EAAE,iBAAiB;IAEvB,OAAO,CAAC,EAAE,GAAG;gBAFb,IAAI,EAAE,iBAAiB,EAC9B,OAAO,EAAE,MAAM,EACR,OAAO,CAAC,EAAE,GAAG,YAAA;CAKvB;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,aAAa,CAAA;CAAE,CAAC"}
|
package/dist/types.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RecordingState = exports.AudioSDKError = exports.AudioSDKErrorType = exports.AudioDeviceType = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Audio device types
|
|
6
|
-
*/
|
|
7
|
-
var AudioDeviceType;
|
|
8
|
-
(function (AudioDeviceType) {
|
|
9
|
-
AudioDeviceType[AudioDeviceType["MICROPHONE"] = 0] = "MICROPHONE";
|
|
10
|
-
AudioDeviceType[AudioDeviceType["SYSTEM_AUDIO"] = 1] = "SYSTEM_AUDIO";
|
|
11
|
-
AudioDeviceType[AudioDeviceType["APPLICATION"] = 2] = "APPLICATION";
|
|
12
|
-
})(AudioDeviceType || (exports.AudioDeviceType = AudioDeviceType = {}));
|
|
13
|
-
/**
|
|
14
|
-
* Error types
|
|
15
|
-
*/
|
|
16
|
-
var AudioSDKErrorType;
|
|
17
|
-
(function (AudioSDKErrorType) {
|
|
18
|
-
AudioSDKErrorType["PERMISSION_DENIED"] = "PERMISSION_DENIED";
|
|
19
|
-
AudioSDKErrorType["DEVICE_NOT_FOUND"] = "DEVICE_NOT_FOUND";
|
|
20
|
-
AudioSDKErrorType["DEVICE_BUSY"] = "DEVICE_BUSY";
|
|
21
|
-
AudioSDKErrorType["INITIALIZATION_FAILED"] = "INITIALIZATION_FAILED";
|
|
22
|
-
AudioSDKErrorType["RECORDING_FAILED"] = "RECORDING_FAILED";
|
|
23
|
-
AudioSDKErrorType["INVALID_FORMAT"] = "INVALID_FORMAT";
|
|
24
|
-
AudioSDKErrorType["PLATFORM_NOT_SUPPORTED"] = "PLATFORM_NOT_SUPPORTED";
|
|
25
|
-
})(AudioSDKErrorType || (exports.AudioSDKErrorType = AudioSDKErrorType = {}));
|
|
26
|
-
/**
|
|
27
|
-
* Custom error class for Audio SDK
|
|
28
|
-
*/
|
|
29
|
-
class AudioSDKError extends Error {
|
|
30
|
-
constructor(type, message, details) {
|
|
31
|
-
super(message);
|
|
32
|
-
this.type = type;
|
|
33
|
-
this.details = details;
|
|
34
|
-
this.name = "AudioSDKError";
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.AudioSDKError = AudioSDKError;
|
|
38
|
-
/**
|
|
39
|
-
* Recording state
|
|
40
|
-
*/
|
|
41
|
-
var RecordingState;
|
|
42
|
-
(function (RecordingState) {
|
|
43
|
-
RecordingState["IDLE"] = "idle";
|
|
44
|
-
RecordingState["RECORDING"] = "recording";
|
|
45
|
-
RecordingState["PAUSED"] = "paused";
|
|
46
|
-
RecordingState["STOPPED"] = "stopped";
|
|
47
|
-
RecordingState["ERROR"] = "error";
|
|
48
|
-
})(RecordingState || (exports.RecordingState = RecordingState = {}));
|
|
49
|
-
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/typescript/types.ts"],"names":[],"mappings":";;;AAOA;;GAEG;AACH,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,iEAAc,CAAA;IACd,qEAAgB,CAAA;IAChB,mEAAe,CAAA;AACjB,CAAC,EAJW,eAAe,+BAAf,eAAe,QAI1B;AAyDD;;GAEG;AACH,IAAY,iBAQX;AARD,WAAY,iBAAiB;IAC3B,4DAAuC,CAAA;IACvC,0DAAqC,CAAA;IACrC,gDAA2B,CAAA;IAC3B,oEAA+C,CAAA;IAC/C,0DAAqC,CAAA;IACrC,sDAAiC,CAAA;IACjC,sEAAiD,CAAA;AACnD,CAAC,EARW,iBAAiB,iCAAjB,iBAAiB,QAQ5B;AAED;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;IACtC,YACS,IAAuB,EAC9B,OAAe,EACR,OAAa;QAEpB,KAAK,CAAC,OAAO,CAAC,CAAC;QAJR,SAAI,GAAJ,IAAI,CAAmB;QAEvB,YAAO,GAAP,OAAO,CAAM;QAGpB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AATD,sCASC;AAED;;GAEG;AACH,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,+BAAa,CAAA;IACb,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;IACjB,qCAAmB,CAAA;IACnB,iCAAe,CAAA;AACjB,CAAC,EANW,cAAc,8BAAd,cAAc,QAMzB"}
|
|
Binary file
|
|
Binary file
|