123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { NativeEventEmitter, NativeModules, processColor } from "react-native";
  2. const RNGSModule = NativeModules.RNLGeetestSensebot;
  3. const RNGSEventEmitter = new NativeEventEmitter(RNGSModule);
  4. const EventName = "RNLGeetestSensebotEvent";
  5. export var Lang;
  6. (function (Lang) {
  7. Lang["System"] = "system";
  8. Lang["ZH"] = "zh";
  9. Lang["ZH_TW"] = "zh-tw";
  10. Lang["ZH_HK"] = "zh-hk";
  11. Lang["EN"] = "en";
  12. Lang["ID"] = "id";
  13. Lang["JA"] = "ja";
  14. Lang["KO"] = "ko";
  15. Lang["RU"] = "ru";
  16. Lang["AR"] = "ar";
  17. Lang["ES"] = "es";
  18. Lang["PT_PT"] = "pt-pt";
  19. Lang["FR"] = "fr";
  20. Lang["DE"] = "de";
  21. })(Lang || (Lang = {}));
  22. export var BackgroundBlurEffectIOS;
  23. (function (BackgroundBlurEffectIOS) {
  24. BackgroundBlurEffectIOS[BackgroundBlurEffectIOS["None"] = -1] = "None";
  25. BackgroundBlurEffectIOS[BackgroundBlurEffectIOS["ExtraLight"] = 0] = "ExtraLight";
  26. BackgroundBlurEffectIOS[BackgroundBlurEffectIOS["Light"] = 1] = "Light";
  27. BackgroundBlurEffectIOS[BackgroundBlurEffectIOS["Dark"] = 2] = "Dark";
  28. BackgroundBlurEffectIOS[BackgroundBlurEffectIOS["Regular"] = 3] = "Regular";
  29. BackgroundBlurEffectIOS[BackgroundBlurEffectIOS["Prominent"] = 4] = "Prominent";
  30. })(BackgroundBlurEffectIOS || (BackgroundBlurEffectIOS = {}));
  31. export const start = RNGSModule.start;
  32. export const stop = RNGSModule.stop;
  33. export const addListener = (listener) => RNGSEventEmitter.addListener(EventName, listener);
  34. export function parseOption(o, defaultOption) {
  35. const option = Object.assign({}, defaultOption);
  36. option.api1Result = JSON.stringify(o.api1Result);
  37. if (typeof o.debug === "boolean") {
  38. option.debug = o.debug;
  39. }
  40. if (typeof o.loadTimeout === "number") {
  41. option.loadTimeout = o.loadTimeout >> 0;
  42. }
  43. if (typeof o.reqTimeout === "number") {
  44. option.reqTimeout = o.reqTimeout >> 0;
  45. }
  46. if (typeof o.lang === "string") {
  47. option.lang = o.lang;
  48. }
  49. if (typeof o.enableBackgroundCancel === "boolean") {
  50. option.enableBackgroundCancel = o.enableBackgroundCancel;
  51. }
  52. if (o.backgroundColorIOS !== undefined) {
  53. option.backgroundColorIOS = processColor(o.backgroundColorIOS);
  54. }
  55. if (typeof o.backgroundBlurEffectIOS === "number") {
  56. option.backgroundBlurEffectIOS = o.backgroundBlurEffectIOS;
  57. }
  58. return option;
  59. }