node-mac-recorder 2.15.3 → 2.15.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-mac-recorder",
3
- "version": "2.15.3",
3
+ "version": "2.15.4",
4
4
  "description": "Native macOS screen recording package for Node.js applications",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -401,10 +401,37 @@ Napi::Value GetAudioDevices(const Napi::CallbackInfo& info) {
401
401
  for (NSUInteger i = 0; i < devices.count; i++) {
402
402
  NSDictionary *device = devices[i];
403
403
  Napi::Object deviceObj = Napi::Object::New(env);
404
- deviceObj.Set("id", Napi::String::New(env, [device[@"id"] UTF8String]));
405
- deviceObj.Set("name", Napi::String::New(env, [device[@"name"] UTF8String]));
406
- deviceObj.Set("manufacturer", Napi::String::New(env, [device[@"manufacturer"] UTF8String]));
407
- deviceObj.Set("isDefault", Napi::Boolean::New(env, [device[@"isDefault"] boolValue]));
404
+
405
+ // Safe string conversion with null checks
406
+ NSString *deviceId = device[@"id"];
407
+ NSString *deviceName = device[@"name"];
408
+ NSString *deviceManufacturer = device[@"manufacturer"];
409
+ NSNumber *isDefault = device[@"isDefault"];
410
+
411
+ if (deviceId && [deviceId isKindOfClass:[NSString class]]) {
412
+ deviceObj.Set("id", Napi::String::New(env, [deviceId UTF8String]));
413
+ } else {
414
+ deviceObj.Set("id", Napi::String::New(env, "default"));
415
+ }
416
+
417
+ if (deviceName && [deviceName isKindOfClass:[NSString class]]) {
418
+ deviceObj.Set("name", Napi::String::New(env, [deviceName UTF8String]));
419
+ } else {
420
+ deviceObj.Set("name", Napi::String::New(env, "Default Audio Device"));
421
+ }
422
+
423
+ if (deviceManufacturer && [deviceManufacturer isKindOfClass:[NSString class]]) {
424
+ deviceObj.Set("manufacturer", Napi::String::New(env, [deviceManufacturer UTF8String]));
425
+ } else {
426
+ deviceObj.Set("manufacturer", Napi::String::New(env, "System"));
427
+ }
428
+
429
+ if (isDefault && [isDefault isKindOfClass:[NSNumber class]]) {
430
+ deviceObj.Set("isDefault", Napi::Boolean::New(env, [isDefault boolValue]));
431
+ } else {
432
+ deviceObj.Set("isDefault", Napi::Boolean::New(env, true));
433
+ }
434
+
408
435
  result[i] = deviceObj;
409
436
  }
410
437