frida 17.2.4 → 17.2.6

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.
@@ -976,9 +976,5 @@ async function getMatchingDevice(predicate, options = {}, cancellable = null) {
976
976
  async function findMatchingDevice(predicate, cancellable) {
977
977
  const deviceManager = getDeviceManager();
978
978
  const devices = await deviceManager.enumerateDevices(cancellable);
979
- const matching = devices.filter(predicate);
980
- if (matching.length === 0) {
981
- return null;
982
- }
983
- return matching[0];
979
+ return devices.find(predicate) ?? null;
984
980
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frida",
3
- "version": "17.2.4",
3
+ "version": "17.2.6",
4
4
  "authors": [
5
5
  "Frida Developers"
6
6
  ],
@@ -146,12 +146,7 @@ async function findMatchingDevice(predicate: DevicePredicate, cancellable?: Canc
146
146
 
147
147
  const devices = await deviceManager.enumerateDevices(cancellable);
148
148
 
149
- const matching = devices.filter(predicate);
150
- if (matching.length === 0) {
151
- return null;
152
- }
153
-
154
- return matching[0];
149
+ return devices.find(predicate) ?? null;
155
150
  }
156
151
 
157
152
  type DevicePredicate = (device: Device) => boolean;
@@ -586,6 +586,7 @@ def generate_operation_structs(object_types: List[ObjectType]) -> str:
586
586
  f"""\
587
587
  typedef struct {{
588
588
  napi_deferred deferred;
589
+ napi_threadsafe_function tsfn;
589
590
  {otype.c_type} * handle;{decls}
590
591
  }} {method.operation_type_name};
591
592
  """
@@ -751,14 +752,6 @@ def generate_tsfn_declarations(object_types: List[ObjectType]) -> str:
751
752
  declarations = []
752
753
 
753
754
  for otype in object_types:
754
- async_methods = [method for method in otype.methods if method.is_async]
755
- if async_methods:
756
- declarations.append("")
757
- for method in async_methods:
758
- declarations.append(
759
- f"static napi_threadsafe_function {otype.c_symbol_prefix}_{method.name}_tsfn;"
760
- )
761
-
762
755
  if isinstance(otype, InterfaceObjectType) and otype.has_abstract_base:
763
756
  declarations.append(
764
757
  f"static napi_threadsafe_function {otype.abstract_base_c_symbol_prefix}_release_js_resources_tsfn;"
@@ -908,18 +901,11 @@ def generate_object_type_registration_code(otype: ObjectType, model: Model) -> s
908
901
  else f"\n napi_create_reference (env, constructor, 1, &{otype_cprefix}_constructor);"
909
902
  )
910
903
  jsprop_registrations = []
911
- tsfn_initializations = []
912
904
 
913
905
  for method in otype.methods:
914
906
  if method.is_property_accessor:
915
907
  continue
916
908
  jsprop_registrations.append(generate_method_registration_entry(method))
917
- if method.is_async:
918
- tsfn_initializations.append(
919
- f"""\
920
- napi_create_threadsafe_function (env, NULL, NULL, fdn_utf8_to_value (env, "{method.prefixed_js_name}"), 0, 1, NULL, NULL, NULL, {otype_cprefix}_{method.name}_deliver, &{otype_cprefix}_{method.name}_tsfn);
921
- napi_unref_threadsafe_function (env, {otype_cprefix}_{method.name}_tsfn);"""
922
- )
923
909
 
924
910
  for prop in otype.properties:
925
911
  jsprop_registrations.append(generate_property_registration_entry(prop))
@@ -941,7 +927,6 @@ napi_unref_threadsafe_function (env, {otype_cprefix}_{method.name}_tsfn);"""
941
927
  jsprop_registrations.append(generate_signal_registration_entry(signal))
942
928
 
943
929
  jsprop_registrations_str = "\n ".join(jsprop_registrations)
944
- tsfn_initializations_code = "\n\n".join(tsfn_initializations)
945
930
 
946
931
  def calculate_indent(suffix: str) -> str:
947
932
  return " " * (len(otype_cprefix) + len(suffix) + 2)
@@ -961,7 +946,7 @@ static void
961
946
 
962
947
  napi_define_class (env, "{otype.prefixed_js_name}", NAPI_AUTO_LENGTH, {otype_cprefix}_construct, NULL, G_N_ELEMENTS (properties), properties, &constructor);{ctor_ref_creation}
963
948
 
964
- napi_set_named_property (env, exports, "{otype.prefixed_js_name}", constructor);{indent_c_code(tsfn_initializations_code, 1, prologue=two_newlines)}
949
+ napi_set_named_property (env, exports, "{otype.prefixed_js_name}", constructor);
965
950
  }}
966
951
  """
967
952
 
@@ -1279,6 +1264,8 @@ static napi_value
1279
1264
 
1280
1265
  operation = g_slice_new0 ({operation_type_name});
1281
1266
  operation->deferred = deferred;
1267
+ napi_create_threadsafe_function (env, NULL, NULL, fdn_utf8_to_value (env, "{method.prefixed_js_name}"), 0, 1, NULL, NULL, NULL,
1268
+ {otype_cprefix}_{method.name}_deliver, &operation->tsfn);
1282
1269
  operation->handle = handle;
1283
1270
  operation->error = NULL;{indent_c_code(param_conversions, 1, prologue=two_newlines)}
1284
1271
 
@@ -1288,8 +1275,6 @@ static napi_value
1288
1275
  g_source_attach (source, frida_get_main_context ());
1289
1276
  g_source_unref (source);
1290
1277
 
1291
- napi_ref_threadsafe_function (env, {otype_cprefix}_{method.name}_tsfn);
1292
-
1293
1278
  return promise;
1294
1279
 
1295
1280
  invalid_argument:
@@ -1321,7 +1306,7 @@ static void
1321
1306
 
1322
1307
  {return_assignment}{method.finish_c_identifier} (operation->handle, res, &operation->error);
1323
1308
 
1324
- napi_call_threadsafe_function ({otype_cprefix}_{method.name}_tsfn, operation, napi_tsfn_blocking);
1309
+ napi_call_threadsafe_function (operation->tsfn, operation, napi_tsfn_blocking);
1325
1310
  }}
1326
1311
 
1327
1312
  static void
@@ -1345,9 +1330,9 @@ static void
1345
1330
  napi_resolve_deferred (env, operation->deferred, js_retval);{indent_c_code(keep_alive_code, 2)}
1346
1331
  }}
1347
1332
 
1348
- {otype_cprefix}_{method.name}_operation_free (operation);
1333
+ napi_release_threadsafe_function (operation->tsfn, napi_tsfn_release);
1349
1334
 
1350
- napi_unref_threadsafe_function (env, {otype_cprefix}_{method.name}_tsfn);
1335
+ {otype_cprefix}_{method.name}_operation_free (operation);
1351
1336
  }}
1352
1337
 
1353
1338
  {operation_free_function}
@@ -1,6 +1,6 @@
1
1
  [wrap-git]
2
2
  url = https://github.com/frida/frida-core.git
3
- revision = 17.2.4
3
+ revision = 17.2.6
4
4
  depth = 1
5
5
 
6
6
  [provide]