html2apk 0.8.0 → 0.11.0

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.
@@ -7,6 +7,9 @@ var notificationListeners = [];
7
7
  var eventListeners = {};
8
8
  var initialNotification = null;
9
9
  var initialLink = null;
10
+ var initialShare = null;
11
+ var bluetoothServerStartPromise = null;
12
+ var wifiServerStartPromise = null;
10
13
  var scheduledNotificationCounter = 0;
11
14
  var notificationActionCounter = 0;
12
15
  var notificationActionCallbacks = {};
@@ -21,6 +24,35 @@ var eventAliases = {
21
24
  "link:opened": "link:aberto",
22
25
  "network:changed": "rede:mudou",
23
26
  "battery:changed": "bateria:mudou",
27
+ "location:changed": "localizacao:mudou",
28
+ "biometric:failed": "biometria:falhou",
29
+ "share:received": "compartilhamento:recebido",
30
+ "sharing:received": "compartilhamento:recebido",
31
+ "bt:connected": "bluetooth:conectado",
32
+ "bluetooth:connected": "bluetooth:conectado",
33
+ "bt:data": "bluetooth:dados",
34
+ "bluetooth:data": "bluetooth:dados",
35
+ "bt:disconnected": "bluetooth:desconectado",
36
+ "bluetooth:disconnected": "bluetooth:desconectado",
37
+ "bt:error": "bluetooth:erro",
38
+ "bluetooth:error": "bluetooth:erro",
39
+ "wifi:connected": "wifi:conectado",
40
+ "wifi:data": "wifi:dados",
41
+ "wifi:disconnected": "wifi:desconectado",
42
+ "wifi:error": "wifi:erro",
43
+ "usb:connected": "usb:conectado",
44
+ "usb:disconnected": "usb:desconectado",
45
+ "headphone:connected": "fone:conectado",
46
+ "headphone:disconnected": "fone:desconectado",
47
+ "volume:changed": "volume:mudou",
48
+ "keyboard:opened": "teclado:abriu",
49
+ "keyboard:closed": "teclado:fechou",
50
+ "phone:shaken": "celular:sacudido",
51
+ "phone:faceDown": "celular:tela_para_baixo",
52
+ "proximity:near": "proximidade:perto",
53
+ "screenshot:taken": "print:tela",
54
+ "orientation:changed": "orientacao:mudou",
55
+ "nfc:received": "nfc:recebido",
24
56
  "notification:received": "notificacao:recebida",
25
57
  "notification:clicked": "notificacao:clicada"
26
58
  };
@@ -537,6 +569,440 @@ function openInAppUrl(url, options) {
537
569
  });
538
570
  }
539
571
 
572
+ function hasOwn(object, key) {
573
+ return Object.prototype.hasOwnProperty.call(object || {}, key);
574
+ }
575
+
576
+ function storedFileOptions(nameOrOptions, value, options) {
577
+ var normalized;
578
+ if (nameOrOptions && typeof nameOrOptions === "object" && !Array.isArray(nameOrOptions)) {
579
+ return cloneSerializable(nameOrOptions) || {};
580
+ }
581
+
582
+ normalized = cloneSerializable(options || {}) || {};
583
+ normalized.name = String(nameOrOptions || "");
584
+ normalized.nome = normalized.name;
585
+ normalized.value = cloneSerializable(value);
586
+ normalized.valor = normalized.value;
587
+ if (typeof value !== "string" && !hasOwn(normalized, "json")) {
588
+ normalized.json = true;
589
+ }
590
+ return normalized;
591
+ }
592
+
593
+ function storedFileNameOptions(nameOrOptions, options) {
594
+ var normalized;
595
+ if (nameOrOptions && typeof nameOrOptions === "object" && !Array.isArray(nameOrOptions)) {
596
+ return cloneSerializable(nameOrOptions) || {};
597
+ }
598
+ normalized = cloneSerializable(options || {}) || {};
599
+ normalized.name = String(nameOrOptions || "");
600
+ normalized.nome = normalized.name;
601
+ return normalized;
602
+ }
603
+
604
+ function applyDownloadName(normalized, nameOrOptions) {
605
+ if (typeof nameOrOptions === "string") {
606
+ normalized.name = nameOrOptions;
607
+ normalized.nome = nameOrOptions;
608
+ normalized.fileName = nameOrOptions;
609
+ normalized.nomeArquivo = nameOrOptions;
610
+ } else if (nameOrOptions && typeof nameOrOptions === "object" && !Array.isArray(nameOrOptions)) {
611
+ Object.assign(normalized, cloneSerializable(nameOrOptions) || {});
612
+ }
613
+ return normalized;
614
+ }
615
+
616
+ function applyBase64DownloadSource(normalized, value) {
617
+ var source = String(value || "");
618
+ var comma;
619
+ var header;
620
+ var mimeType;
621
+
622
+ if (source.indexOf("data:") === 0) {
623
+ comma = source.indexOf(",");
624
+ header = comma >= 0 ? source.slice(5, comma) : "";
625
+ mimeType = header.split(";")[0];
626
+ normalized.base64 = comma >= 0 ? source.slice(comma + 1) : source;
627
+ if (mimeType) {
628
+ normalized.mimeType = normalized.mimeType || mimeType;
629
+ normalized.tipoMime = normalized.tipoMime || mimeType;
630
+ }
631
+ return normalized;
632
+ }
633
+
634
+ normalized.base64 = source;
635
+ return normalized;
636
+ }
637
+
638
+ function downloadFileOptions(urlOrOptions, nameOrOptions, options) {
639
+ var normalized;
640
+ var source;
641
+
642
+ if (urlOrOptions && typeof urlOrOptions === "object" && !Array.isArray(urlOrOptions)) {
643
+ normalized = cloneSerializable(urlOrOptions) || {};
644
+ applyDownloadName(normalized, nameOrOptions);
645
+ if (options && typeof options === "object" && !Array.isArray(options)) {
646
+ Object.assign(normalized, cloneSerializable(options) || {});
647
+ }
648
+ return normalized;
649
+ }
650
+
651
+ normalized = cloneSerializable(options || {}) || {};
652
+ source = String(urlOrOptions || "").trim();
653
+ if (source.indexOf("data:") === 0) {
654
+ applyBase64DownloadSource(normalized, source);
655
+ } else {
656
+ normalized.url = source;
657
+ }
658
+ return applyDownloadName(normalized, nameOrOptions);
659
+ }
660
+
661
+ function downloadBase64Options(nameOrOptions, base64, options) {
662
+ var normalized;
663
+ if (nameOrOptions && typeof nameOrOptions === "object" && !Array.isArray(nameOrOptions)) {
664
+ normalized = cloneSerializable(nameOrOptions) || {};
665
+ if (typeof base64 === "string") {
666
+ applyBase64DownloadSource(normalized, base64);
667
+ } else if (base64 && typeof base64 === "object" && !Array.isArray(base64)) {
668
+ Object.assign(normalized, cloneSerializable(base64) || {});
669
+ }
670
+ return normalized;
671
+ }
672
+
673
+ normalized = cloneSerializable(options || {}) || {};
674
+ applyDownloadName(normalized, String(nameOrOptions || ""));
675
+ return applyBase64DownloadSource(normalized, base64);
676
+ }
677
+
678
+ function downloadLocalFileOptions(fileOrOptions, nameOrOptions, options) {
679
+ var normalized;
680
+ var source;
681
+
682
+ if (fileOrOptions && typeof fileOrOptions === "object" && !Array.isArray(fileOrOptions)) {
683
+ normalized = cloneSerializable(fileOrOptions) || {};
684
+ applyDownloadName(normalized, nameOrOptions);
685
+ if (options && typeof options === "object" && !Array.isArray(options)) {
686
+ Object.assign(normalized, cloneSerializable(options) || {});
687
+ }
688
+ return normalized;
689
+ }
690
+
691
+ normalized = cloneSerializable(options || {}) || {};
692
+ source = String(fileOrOptions || "").trim();
693
+ if (/^(content|file):\/\//.test(source)) {
694
+ normalized.uri = source;
695
+ normalized.contentUri = source;
696
+ } else if (/^[A-Za-z]:[\\/]/.test(source) || source.charAt(0) === "/" || source.charAt(0) === "\\") {
697
+ normalized.path = source;
698
+ normalized.caminho = source;
699
+ } else {
700
+ normalized.sourceName = source;
701
+ normalized.arquivoOrigem = source;
702
+ }
703
+ return applyDownloadName(normalized, nameOrOptions);
704
+ }
705
+
706
+ function ocrOptions(sourceOrOptions) {
707
+ if (sourceOrOptions && typeof sourceOrOptions === "object" && !Array.isArray(sourceOrOptions)) {
708
+ return cloneSerializable(sourceOrOptions) || {};
709
+ }
710
+ var source = String(sourceOrOptions || "").trim();
711
+ if (source.indexOf("data:") === 0) {
712
+ return { base64: source };
713
+ }
714
+ if (/^(content|file):\/\//.test(source)) {
715
+ return { uri: source, contentUri: source };
716
+ }
717
+ if (/^[A-Za-z]:[\\/]/.test(source) || source.charAt(0) === "/" || source.charAt(0) === "\\") {
718
+ return { path: source, caminho: source };
719
+ }
720
+ return { name: source, nome: source };
721
+ }
722
+
723
+ function normalizeReceivedShare(detail) {
724
+ var normalized = cloneSerializable(detail || {}) || {};
725
+ var kind = normalized.tipoConteudo || normalized.contentType || normalized.tipo || normalized.type;
726
+ if (kind) {
727
+ normalized.tipo = kind;
728
+ normalized.type = kind;
729
+ }
730
+ return normalized;
731
+ }
732
+
733
+ function bluetoothReceivedData(detail) {
734
+ if (!detail || typeof detail !== "object") {
735
+ return detail;
736
+ }
737
+ if (Object.prototype.hasOwnProperty.call(detail, "dados")) {
738
+ return detail.dados;
739
+ }
740
+ if (Object.prototype.hasOwnProperty.call(detail, "data")) {
741
+ return detail.data;
742
+ }
743
+ return detail;
744
+ }
745
+
746
+ function bluetoothErrorDetail(errorOrDetail) {
747
+ var detail = errorOrDetail && typeof errorOrDetail === "object"
748
+ ? cloneSerializable(errorOrDetail) || {}
749
+ : {};
750
+ var message = detail.message || detail.mensagem || detail.error || detail.erro ||
751
+ (errorOrDetail && (errorOrDetail.message || errorOrDetail.mensagem || errorOrDetail.error || errorOrDetail.erro)) ||
752
+ String(errorOrDetail || "");
753
+ detail.ok = false;
754
+ detail.message = message;
755
+ detail.mensagem = message;
756
+ detail.error = message;
757
+ detail.erro = message;
758
+ detail.timestamp = detail.timestamp || Date.now();
759
+ return detail;
760
+ }
761
+
762
+ function startBluetoothServerSilently() {
763
+ if (bluetoothServerStartPromise) {
764
+ return bluetoothServerStartPromise;
765
+ }
766
+
767
+ bluetoothServerStartPromise = call("startBluetoothServer").catch(function (error) {
768
+ bluetoothServerStartPromise = null;
769
+ emitEvent("bluetooth:erro", bluetoothErrorDetail(error));
770
+ });
771
+ return bluetoothServerStartPromise;
772
+ }
773
+
774
+ function wifiReceivedData(detail) {
775
+ if (!detail || typeof detail !== "object") {
776
+ return detail;
777
+ }
778
+ if (Object.prototype.hasOwnProperty.call(detail, "dados")) {
779
+ return detail.dados;
780
+ }
781
+ if (Object.prototype.hasOwnProperty.call(detail, "data")) {
782
+ return detail.data;
783
+ }
784
+ return detail;
785
+ }
786
+
787
+ function wifiErrorDetail(errorOrDetail) {
788
+ var detail = errorOrDetail && typeof errorOrDetail === "object"
789
+ ? cloneSerializable(errorOrDetail) || {}
790
+ : {};
791
+ var message = detail.message || detail.mensagem || detail.error || detail.erro ||
792
+ (errorOrDetail && (errorOrDetail.message || errorOrDetail.mensagem || errorOrDetail.error || errorOrDetail.erro)) ||
793
+ String(errorOrDetail || "");
794
+ detail.ok = false;
795
+ detail.message = message;
796
+ detail.mensagem = message;
797
+ detail.error = message;
798
+ detail.erro = message;
799
+ detail.timestamp = detail.timestamp || Date.now();
800
+ return detail;
801
+ }
802
+
803
+ function startWifiServerSilently() {
804
+ if (wifiServerStartPromise) {
805
+ return wifiServerStartPromise;
806
+ }
807
+
808
+ wifiServerStartPromise = call("startWifiServer").catch(function (error) {
809
+ wifiServerStartPromise = null;
810
+ emitEvent("wifi:erro", wifiErrorDetail(error));
811
+ });
812
+ return wifiServerStartPromise;
813
+ }
814
+
815
+ function wallpaperOptions(sourceOrOptions, options) {
816
+ var normalized;
817
+ var source;
818
+ var comma;
819
+ var header;
820
+ var mimeType;
821
+
822
+ if (sourceOrOptions && typeof sourceOrOptions === "object" && !Array.isArray(sourceOrOptions)) {
823
+ normalized = cloneSerializable(sourceOrOptions) || {};
824
+ } else {
825
+ normalized = cloneSerializable(options || {}) || {};
826
+ source = String(sourceOrOptions || "").trim();
827
+ if (source.indexOf("data:") === 0) {
828
+ comma = source.indexOf(",");
829
+ header = comma >= 0 ? source.slice(5, comma) : "";
830
+ mimeType = header.split(";")[0];
831
+ normalized.base64 = comma >= 0 ? source.slice(comma + 1) : source;
832
+ if (mimeType) {
833
+ normalized.mimeType = normalized.mimeType || mimeType;
834
+ normalized.tipoMime = normalized.tipoMime || mimeType;
835
+ }
836
+ } else if (/^(content|file):\/\//.test(source)) {
837
+ normalized.uri = source;
838
+ normalized.contentUri = source;
839
+ } else if (/^[A-Za-z]:[\\/]/.test(source) || source.charAt(0) === "/" || source.charAt(0) === "\\") {
840
+ normalized.path = source;
841
+ normalized.caminho = source;
842
+ } else {
843
+ normalized.name = source;
844
+ normalized.nome = source;
845
+ normalized.fileName = source;
846
+ normalized.nomeArquivo = source;
847
+ }
848
+ }
849
+
850
+ if (normalized.alvo && !normalized.target) {
851
+ normalized.target = normalized.alvo;
852
+ }
853
+ if (normalized.target && !normalized.alvo) {
854
+ normalized.alvo = normalized.target;
855
+ }
856
+ return normalized;
857
+ }
858
+
859
+ function volumeOptions(streamOrOptions, value, options) {
860
+ var normalized = {};
861
+ if (streamOrOptions && typeof streamOrOptions === "object" && !Array.isArray(streamOrOptions)) {
862
+ normalized = cloneSerializable(streamOrOptions) || {};
863
+ } else {
864
+ if (typeof streamOrOptions === "number") {
865
+ normalized.value = streamOrOptions;
866
+ normalized.valor = streamOrOptions;
867
+ } else if (typeof streamOrOptions === "string") {
868
+ normalized.stream = streamOrOptions;
869
+ normalized.tipo = streamOrOptions;
870
+ }
871
+ if (typeof value !== "undefined" && value !== null && typeof value !== "object") {
872
+ normalized.value = value;
873
+ normalized.valor = value;
874
+ }
875
+ if (value && typeof value === "object" && !Array.isArray(value)) {
876
+ Object.assign(normalized, cloneSerializable(value) || {});
877
+ }
878
+ if (options && typeof options === "object" && !Array.isArray(options)) {
879
+ Object.assign(normalized, cloneSerializable(options) || {});
880
+ }
881
+ }
882
+ return normalized;
883
+ }
884
+
885
+ function adjustVolumeOptions(streamOrOptions, amountOrOptions, options, direction) {
886
+ var normalized = volumeOptions(streamOrOptions);
887
+ if (typeof amountOrOptions === "number") {
888
+ normalized.amount = amountOrOptions;
889
+ normalized.quantidade = amountOrOptions;
890
+ } else if (amountOrOptions && typeof amountOrOptions === "object" && !Array.isArray(amountOrOptions)) {
891
+ Object.assign(normalized, cloneSerializable(amountOrOptions) || {});
892
+ }
893
+ if (options && typeof options === "object" && !Array.isArray(options)) {
894
+ Object.assign(normalized, cloneSerializable(options) || {});
895
+ }
896
+ normalized.direction = direction;
897
+ normalized.direcao = direction;
898
+ return normalized;
899
+ }
900
+
901
+ function floatingIconOptions(optionsOrOpacity) {
902
+ if (optionsOrOpacity && typeof optionsOrOpacity === "object" && !Array.isArray(optionsOrOpacity)) {
903
+ return cloneSerializable(optionsOrOpacity) || {};
904
+ }
905
+ if (typeof optionsOrOpacity === "number" || typeof optionsOrOpacity === "string") {
906
+ return {
907
+ opacity: Number(optionsOrOpacity),
908
+ opacidade: Number(optionsOrOpacity)
909
+ };
910
+ }
911
+ return {};
912
+ }
913
+
914
+ function secureItemOptions(keyOrOptions, value, options) {
915
+ var normalized;
916
+ if (keyOrOptions && typeof keyOrOptions === "object" && !Array.isArray(keyOrOptions)) {
917
+ return cloneSerializable(keyOrOptions) || {};
918
+ }
919
+ normalized = cloneSerializable(options || {}) || {};
920
+ normalized.key = String(keyOrOptions || "");
921
+ normalized.chave = normalized.key;
922
+ normalized.value = cloneSerializable(value);
923
+ normalized.valor = normalized.value;
924
+ if (typeof value !== "string" && !hasOwn(normalized, "json")) {
925
+ normalized.json = true;
926
+ }
927
+ return normalized;
928
+ }
929
+
930
+ function secureKeyOptions(keyOrOptions, options) {
931
+ var normalized;
932
+ if (keyOrOptions && typeof keyOrOptions === "object" && !Array.isArray(keyOrOptions)) {
933
+ return cloneSerializable(keyOrOptions) || {};
934
+ }
935
+ normalized = cloneSerializable(options || {}) || {};
936
+ normalized.key = String(keyOrOptions || "");
937
+ normalized.chave = normalized.key;
938
+ return normalized;
939
+ }
940
+
941
+ function unwrapStoredValue(result) {
942
+ if (!result || result.exists === false || result.existe === false) {
943
+ return null;
944
+ }
945
+ if (hasOwn(result, "value")) {
946
+ return result.value;
947
+ }
948
+ if (hasOwn(result, "valor")) {
949
+ return result.valor;
950
+ }
951
+ if (hasOwn(result, "base64")) {
952
+ return result.base64;
953
+ }
954
+ if (hasOwn(result, "content")) {
955
+ return result.content;
956
+ }
957
+ if (hasOwn(result, "conteudo")) {
958
+ return result.conteudo;
959
+ }
960
+ return result;
961
+ }
962
+
963
+ function detectQRCodeFromPhoto(photo) {
964
+ var source;
965
+ var detector;
966
+
967
+ if (!photo || !photo.base64) {
968
+ return null;
969
+ }
970
+ if (typeof BarcodeDetector !== "function" || typeof createImageBitmap !== "function" || typeof fetch !== "function") {
971
+ throw new Error("QR code scanning requires BarcodeDetector support in this Android WebView.");
972
+ }
973
+
974
+ detector = new BarcodeDetector({ formats: ["qr_code"] });
975
+ source = "data:" + (photo.mimeType || "image/jpeg") + ";base64," + photo.base64;
976
+ return fetch(source)
977
+ .then(function (response) {
978
+ return response.blob();
979
+ })
980
+ .then(function (blob) {
981
+ return createImageBitmap(blob);
982
+ })
983
+ .then(function (image) {
984
+ return detector.detect(image);
985
+ })
986
+ .then(function (codes) {
987
+ var first = codes && codes[0];
988
+ if (!first) {
989
+ return null;
990
+ }
991
+ return {
992
+ text: first.rawValue || "",
993
+ texto: first.rawValue || "",
994
+ rawValue: first.rawValue || "",
995
+ valorBruto: first.rawValue || "",
996
+ format: first.format || "qr_code",
997
+ formato: first.format || "qr_code",
998
+ codes: codes,
999
+ codigos: codes,
1000
+ photo: photo,
1001
+ foto: photo
1002
+ };
1003
+ });
1004
+ }
1005
+
540
1006
  var api = {
541
1007
  notificar: function (messageOrOptions) {
542
1008
  return call("notify", [normalizeNotificationOptions(messageOrOptions)]);
@@ -566,6 +1032,14 @@ var api = {
566
1032
  toast: function (message) {
567
1033
  return call("toast", [String(message || "")]);
568
1034
  },
1035
+ aguardar: function (ms) {
1036
+ var delay = Math.max(0, Math.min(Number(ms) || 0, 2147483647));
1037
+ return new Promise(function (resolve) {
1038
+ setTimeout(function () {
1039
+ resolve({ ok: true, ms: delay });
1040
+ }, delay);
1041
+ });
1042
+ },
569
1043
  fullscreen: function (enabled) {
570
1044
  return call("fullscreen", [Boolean(enabled)]);
571
1045
  },
@@ -590,6 +1064,15 @@ var api = {
590
1064
  statusLanterna: function () {
591
1065
  return call("flashlightStatus");
592
1066
  },
1067
+ tirarFoto: function (options) {
1068
+ return call("capturePhoto", [options || {}]);
1069
+ },
1070
+ capturarVideo: function (options) {
1071
+ return call("captureVideo", [options || {}]);
1072
+ },
1073
+ escanearQRCode: function (options) {
1074
+ return api.tirarFoto(Object.assign({ base64: true }, options || {})).then(detectQRCodeFromPhoto);
1075
+ },
593
1076
  solicitarPermissaoCamera: function () {
594
1077
  return call("requestCameraPermission");
595
1078
  },
@@ -617,6 +1100,87 @@ var api = {
617
1100
  compartilhar: function (options) {
618
1101
  return call("share", [options || {}]);
619
1102
  },
1103
+ compartilharApp: function (options) {
1104
+ return call("shareCurrentApp", [options || {}]);
1105
+ },
1106
+ procurarBT: function (options) {
1107
+ return call("scanBluetooth", [options || {}]);
1108
+ },
1109
+ conectarBT: function (idDispositivo) {
1110
+ return call("connectBluetooth", [String(idDispositivo || "")]);
1111
+ },
1112
+ enviarBT: function (data) {
1113
+ return call("sendBluetooth", [data]);
1114
+ },
1115
+ aoConectarBT: function (listener) {
1116
+ if (typeof listener !== "function") {
1117
+ throw new TypeError("listener must be a function");
1118
+ }
1119
+ startBluetoothServerSilently();
1120
+ return onEvent("bluetooth:conectado", listener);
1121
+ },
1122
+ aoReceberDadosBT: function (listener) {
1123
+ if (typeof listener !== "function") {
1124
+ throw new TypeError("listener must be a function");
1125
+ }
1126
+ startBluetoothServerSilently();
1127
+ return onEvent("bluetooth:dados", function (detail) {
1128
+ listener(bluetoothReceivedData(detail));
1129
+ });
1130
+ },
1131
+ aoDarErroBT: function (listener) {
1132
+ if (typeof listener !== "function") {
1133
+ throw new TypeError("listener must be a function");
1134
+ }
1135
+ return onEvent("bluetooth:erro", function (detail) {
1136
+ listener(bluetoothErrorDetail(detail));
1137
+ });
1138
+ },
1139
+ procurarWiFi: function (options) {
1140
+ return call("scanWifi", [options || {}]);
1141
+ },
1142
+ conectarWiFi: function (idDispositivo) {
1143
+ return call("connectWifi", [String(idDispositivo || "")]);
1144
+ },
1145
+ enviarWiFi: function (data) {
1146
+ return call("sendWifi", [data]);
1147
+ },
1148
+ aoConectarWiFi: function (listener) {
1149
+ if (typeof listener !== "function") {
1150
+ throw new TypeError("listener must be a function");
1151
+ }
1152
+ startWifiServerSilently();
1153
+ return onEvent("wifi:conectado", listener);
1154
+ },
1155
+ aoReceberDadosWiFi: function (listener) {
1156
+ if (typeof listener !== "function") {
1157
+ throw new TypeError("listener must be a function");
1158
+ }
1159
+ startWifiServerSilently();
1160
+ return onEvent("wifi:dados", function (detail) {
1161
+ listener(wifiReceivedData(detail));
1162
+ });
1163
+ },
1164
+ aoDarErroWiFi: function (listener) {
1165
+ if (typeof listener !== "function") {
1166
+ throw new TypeError("listener must be a function");
1167
+ }
1168
+ return onEvent("wifi:erro", function (detail) {
1169
+ listener(wifiErrorDetail(detail));
1170
+ });
1171
+ },
1172
+ ocr: function (sourceOrOptions) {
1173
+ return call("ocr", [ocrOptions(sourceOrOptions)]);
1174
+ },
1175
+ falar: function (text, options) {
1176
+ return call("speakText", [String(text || ""), options || {}]);
1177
+ },
1178
+ pararFala: function () {
1179
+ return call("stopSpeaking");
1180
+ },
1181
+ ouvir: function (options) {
1182
+ return call("recognizeSpeech", [options || {}]);
1183
+ },
620
1184
  abrirUrl: function (url) {
621
1185
  return call("openUrl", [String(url || "")]);
622
1186
  },
@@ -659,8 +1223,61 @@ var api = {
659
1223
  escolherPasta: function () {
660
1224
  return call("pickFolder");
661
1225
  },
662
- salvarArquivo: function (options) {
663
- return call("saveFile", [options || {}]);
1226
+ salvarArquivo: function (nameOrOptions, value, options) {
1227
+ if (typeof nameOrOptions === "string") {
1228
+ return call("saveStoredFile", [storedFileOptions(nameOrOptions, value, options)]);
1229
+ }
1230
+ return call("saveFile", [nameOrOptions || {}]);
1231
+ },
1232
+ lerArquivo: function (nameOrOptions, options) {
1233
+ return call("readStoredFile", [storedFileNameOptions(nameOrOptions, options)]).then(unwrapStoredValue);
1234
+ },
1235
+ lerArquivoCompleto: function (nameOrOptions, options) {
1236
+ return call("readStoredFile", [storedFileNameOptions(nameOrOptions, options)]);
1237
+ },
1238
+ excluirArquivo: function (nameOrOptions, options) {
1239
+ return call("deleteStoredFile", [storedFileNameOptions(nameOrOptions, options)]);
1240
+ },
1241
+ infoArquivo: function (nameOrOptions, options) {
1242
+ return call("storedFileInfo", [storedFileNameOptions(nameOrOptions, options)]);
1243
+ },
1244
+ arquivoExiste: function (nameOrOptions, options) {
1245
+ return api.infoArquivo(nameOrOptions, options).then(function (info) {
1246
+ return Boolean(info && (info.exists || info.existe));
1247
+ });
1248
+ },
1249
+ listarArquivos: function () {
1250
+ return call("listStoredFiles");
1251
+ },
1252
+ abrirArquivo: function (nameOrOptions, options) {
1253
+ return call("openStoredFile", [storedFileNameOptions(nameOrOptions, options)]);
1254
+ },
1255
+ compartilharArquivo: function (nameOrOptions, options) {
1256
+ return call("shareStoredFile", [storedFileNameOptions(nameOrOptions, options)]);
1257
+ },
1258
+ baixarArquivo: function (urlOrOptions, nameOrOptions, options) {
1259
+ return call("downloadFile", [downloadFileOptions(urlOrOptions, nameOrOptions, options)]);
1260
+ },
1261
+ baixarBase64: function (nameOrOptions, base64, options) {
1262
+ return call("downloadFile", [downloadBase64Options(nameOrOptions, base64, options)]);
1263
+ },
1264
+ baixarArquivoLocal: function (fileOrOptions, nameOrOptions, options) {
1265
+ return call("downloadFile", [downloadLocalFileOptions(fileOrOptions, nameOrOptions, options)]);
1266
+ },
1267
+ definirPapelParede: function (sourceOrOptions, options) {
1268
+ return call("setWallpaper", [wallpaperOptions(sourceOrOptions, options)]);
1269
+ },
1270
+ infoPapelParede: function () {
1271
+ return call("wallpaperInfo");
1272
+ },
1273
+ abrirConfiguracaoPapelParede: function () {
1274
+ return call("openWallpaperSettings");
1275
+ },
1276
+ capturarTela: function (options) {
1277
+ return call("captureScreen", [options || {}]);
1278
+ },
1279
+ tirarPrint: function (options) {
1280
+ return call("captureScreen", [options || {}]);
664
1281
  },
665
1282
  infoDispositivo: function () {
666
1283
  return call("deviceInfo");
@@ -680,12 +1297,57 @@ var api = {
680
1297
  infoDesempenho: function () {
681
1298
  return call("performanceInfo");
682
1299
  },
1300
+ volumeAtual: function () {
1301
+ return call("getVolume");
1302
+ },
1303
+ definirVolume: function (streamOrOptions, value, options) {
1304
+ return call("setVolume", [volumeOptions(streamOrOptions, value, options)]);
1305
+ },
1306
+ aumentarVolume: function (streamOrOptions, amountOrOptions, options) {
1307
+ return call("adjustVolume", [adjustVolumeOptions(streamOrOptions, amountOrOptions, options, "up")]);
1308
+ },
1309
+ diminuirVolume: function (streamOrOptions, amountOrOptions, options) {
1310
+ return call("adjustVolume", [adjustVolumeOptions(streamOrOptions, amountOrOptions, options, "down")]);
1311
+ },
683
1312
  appsAbertos: function () {
684
1313
  return call("openAppsMemory");
685
1314
  },
686
1315
  infoAppsAbertos: function () {
687
1316
  return call("openAppsMemory");
688
1317
  },
1318
+ obterLocalizacao: function (options) {
1319
+ return call("getLocation", [options || {}]);
1320
+ },
1321
+ acompanharLocalizacao: function (options) {
1322
+ return call("watchLocation", [options || {}]);
1323
+ },
1324
+ pararLocalizacao: function (id) {
1325
+ return call("stopLocationWatch", [id || ""]);
1326
+ },
1327
+ aoMudarLocalizacao: function (listener) {
1328
+ return onEvent("localizacao:mudou", listener);
1329
+ },
1330
+ autenticarBiometria: function (options) {
1331
+ return call("authenticateBiometric", [options || {}]);
1332
+ },
1333
+ salvarSeguro: function (keyOrOptions, value, options) {
1334
+ return call("saveSecureItem", [secureItemOptions(keyOrOptions, value, options)]);
1335
+ },
1336
+ lerSeguro: function (keyOrOptions, options) {
1337
+ return call("readSecureItem", [secureKeyOptions(keyOrOptions, options)]).then(unwrapStoredValue);
1338
+ },
1339
+ lerSeguroCompleto: function (keyOrOptions, options) {
1340
+ return call("readSecureItem", [secureKeyOptions(keyOrOptions, options)]);
1341
+ },
1342
+ removerSeguro: function (keyOrOptions, options) {
1343
+ return call("deleteSecureItem", [secureKeyOptions(keyOrOptions, options)]);
1344
+ },
1345
+ listarSeguro: function () {
1346
+ return call("listSecureKeys");
1347
+ },
1348
+ limparSeguro: function () {
1349
+ return call("clearSecureStorage");
1350
+ },
689
1351
  statusPermissoes: function (permissions) {
690
1352
  return call("permissionStatus", [permissions || []]);
691
1353
  },
@@ -710,12 +1372,24 @@ var api = {
710
1372
  abrirConfiguracaoSobreposicao: function () {
711
1373
  return call("openOverlaySettings");
712
1374
  },
713
- iniciarIconeFlutuante: function () {
714
- return call("startFloatingIcon");
1375
+ iniciarIconeFlutuante: function (options) {
1376
+ return call("startFloatingIcon", [floatingIconOptions(options)]);
715
1377
  },
716
1378
  pararIconeFlutuante: function () {
717
1379
  return call("stopFloatingIcon");
718
1380
  },
1381
+ configurarIconeFlutuante: function (options) {
1382
+ return call("configureFloatingIcon", [floatingIconOptions(options)]);
1383
+ },
1384
+ definirOpacidadeIconeFlutuante: function (opacity) {
1385
+ return call("configureFloatingIcon", [floatingIconOptions(opacity)]);
1386
+ },
1387
+ minimizarApp: function () {
1388
+ return call("minimizeApp");
1389
+ },
1390
+ fecharApp: function () {
1391
+ return call("closeApp");
1392
+ },
719
1393
  obterNotificacaoInicial: function () {
720
1394
  return call("getInitialNotification").then(function (notification) {
721
1395
  initialNotification = notification && notification.id ? notification : null;
@@ -728,6 +1402,12 @@ var api = {
728
1402
  return initialLink;
729
1403
  });
730
1404
  },
1405
+ obterCompartilhamentoInicial: function () {
1406
+ return call("getInitialShare").then(function (share) {
1407
+ initialShare = share && (share.text || share.texto || share.uri || (share.items && share.items.length)) ? normalizeReceivedShare(share) : null;
1408
+ return initialShare;
1409
+ });
1410
+ },
731
1411
  aoEvento: onEvent,
732
1412
  aoMinimizar: function (listener) {
733
1413
  return onEvent("app:background", listener);
@@ -746,12 +1426,67 @@ var api = {
746
1426
  }
747
1427
  return onEvent("link:aberto", listener);
748
1428
  },
1429
+ aoReceberCompartilhamento: function (listener) {
1430
+ if (typeof listener !== "function") {
1431
+ throw new TypeError("listener must be a function");
1432
+ }
1433
+ if (initialShare) {
1434
+ setTimeout(function () {
1435
+ listener(normalizeReceivedShare(initialShare));
1436
+ }, 0);
1437
+ }
1438
+ return onEvent("compartilhamento:recebido", function (detail) {
1439
+ listener(normalizeReceivedShare(detail));
1440
+ });
1441
+ },
749
1442
  aoMudarRede: function (listener) {
750
1443
  return onEvent("rede:mudou", listener);
751
1444
  },
752
1445
  aoMudarBateria: function (listener) {
753
1446
  return onEvent("bateria:mudou", listener);
754
1447
  },
1448
+ aoConectarUSB: function (listener) {
1449
+ return onEvent("usb:conectado", listener);
1450
+ },
1451
+ aoDesconectarUSB: function (listener) {
1452
+ return onEvent("usb:desconectado", listener);
1453
+ },
1454
+ aoConectarFone: function (listener) {
1455
+ return onEvent("fone:conectado", listener);
1456
+ },
1457
+ aoDesconectarFone: function (listener) {
1458
+ return onEvent("fone:desconectado", listener);
1459
+ },
1460
+ aoMudarVolume: function (listener) {
1461
+ return onEvent("volume:mudou", listener);
1462
+ },
1463
+ aoAbrirTeclado: function (listener) {
1464
+ return onEvent("teclado:abriu", listener);
1465
+ },
1466
+ aoFecharTeclado: function (listener) {
1467
+ return onEvent("teclado:fechou", listener);
1468
+ },
1469
+ aoSacudirCelular: function (listener) {
1470
+ return onEvent("celular:sacudido", listener);
1471
+ },
1472
+ aoVirarCelularParaBaixo: function (listener) {
1473
+ return onEvent("celular:tela_para_baixo", listener);
1474
+ },
1475
+ aoAproximarObjeto: function (listener) {
1476
+ return onEvent("proximidade:perto", listener);
1477
+ },
1478
+ aoTirarPrint: function (listener) {
1479
+ return onEvent("print:tela", listener);
1480
+ },
1481
+ aoMudarOrientacao: function (listener) {
1482
+ return onEvent("orientacao:mudou", listener);
1483
+ },
1484
+ aoNFC: function (listener) {
1485
+ return onEvent("nfc:recebido", listener);
1486
+ },
1487
+ aoReceberNotificacao: function (listener) {
1488
+ return onEvent("notificacao:recebida", listener);
1489
+ },
755
1490
  aoClicarNotificacao: function (listener) {
756
1491
  if (typeof listener !== "function") {
757
1492
  throw new TypeError("listener must be a function");
@@ -784,6 +1519,7 @@ Object.assign(api, {
784
1519
  cancelNotification: api.cancelarNotificacao,
785
1520
  cancelNotificationLoop: api.cancelarLoopNotificacoes,
786
1521
  vibrate: api.vibrar,
1522
+ loading: api.aguardar,
787
1523
  manterTelaLigada: api.manterTelaAcordada,
788
1524
  keepScreenAwake: api.manterTelaAcordada,
789
1525
  keepScreenOn: api.manterTelaAcordada,
@@ -793,6 +1529,11 @@ Object.assign(api, {
793
1529
  flashlight: api.lanterna,
794
1530
  toggleFlashlight: api.alternarLanterna,
795
1531
  flashlightStatus: api.statusLanterna,
1532
+ takePhoto: api.tirarFoto,
1533
+ capturePhoto: api.tirarFoto,
1534
+ captureVideo: api.capturarVideo,
1535
+ scanQRCode: api.escanearQRCode,
1536
+ scanQrCode: api.escanearQRCode,
796
1537
  requestCameraPermission: api.solicitarPermissaoCamera,
797
1538
  requestMicrophonePermission: api.solicitarPermissaoMicrofone,
798
1539
  microphoneStatus: api.statusMicrofone,
@@ -805,6 +1546,46 @@ Object.assign(api, {
805
1546
  readText: api.lerTextoCopiado,
806
1547
  shareText: api.compartilharTexto,
807
1548
  share: api.compartilhar,
1549
+ shareApp: api.compartilharApp,
1550
+ share_me: api.compartilharApp,
1551
+ scanBluetooth: api.procurarBT,
1552
+ procurarBluetooth: api.procurarBT,
1553
+ buscarBT: api.procurarBT,
1554
+ connectBluetooth: api.conectarBT,
1555
+ conectarBluetooth: api.conectarBT,
1556
+ sendBluetooth: api.enviarBT,
1557
+ onBluetoothConnect: api.aoConectarBT,
1558
+ onBluetoothConnected: api.aoConectarBT,
1559
+ onBluetoothData: api.aoReceberDadosBT,
1560
+ onBTData: api.aoReceberDadosBT,
1561
+ onBluetoothError: api.aoDarErroBT,
1562
+ onBTError: api.aoDarErroBT,
1563
+ scanWiFi: api.procurarWiFi,
1564
+ scanWifi: api.procurarWiFi,
1565
+ procurarWifi: api.procurarWiFi,
1566
+ connectWiFi: api.conectarWiFi,
1567
+ connectWifi: api.conectarWiFi,
1568
+ conectarWifi: api.conectarWiFi,
1569
+ sendWiFi: api.enviarWiFi,
1570
+ sendWifi: api.enviarWiFi,
1571
+ enviarWifi: api.enviarWiFi,
1572
+ onWiFiConnect: api.aoConectarWiFi,
1573
+ onWifiConnect: api.aoConectarWiFi,
1574
+ onWiFiConnected: api.aoConectarWiFi,
1575
+ onWifiConnected: api.aoConectarWiFi,
1576
+ onWiFiData: api.aoReceberDadosWiFi,
1577
+ onWifiData: api.aoReceberDadosWiFi,
1578
+ onWiFiError: api.aoDarErroWiFi,
1579
+ onWifiError: api.aoDarErroWiFi,
1580
+ recognizeText: api.ocr,
1581
+ textFromImage: api.ocr,
1582
+ speak: api.falar,
1583
+ textToSpeech: api.falar,
1584
+ stopSpeaking: api.pararFala,
1585
+ stopSpeech: api.pararFala,
1586
+ listen: api.ouvir,
1587
+ recognizeSpeech: api.ouvir,
1588
+ speechToText: api.ouvir,
808
1589
  openUrl: api.abrirUrl,
809
1590
  openExternalUrl: api.abrirUrlExterno,
810
1591
  openOutsideApp: api.abrirForaDoApp,
@@ -819,14 +1600,66 @@ Object.assign(api, {
819
1600
  pickVideo: api.escolherVideo,
820
1601
  pickFolder: api.escolherPasta,
821
1602
  saveFile: api.salvarArquivo,
1603
+ readFile: api.lerArquivo,
1604
+ readStoredFile: api.lerArquivo,
1605
+ readStoredFileInfo: api.lerArquivoCompleto,
1606
+ deleteFile: api.excluirArquivo,
1607
+ removeFile: api.excluirArquivo,
1608
+ excluirArquivoArmazenado: api.excluirArquivo,
1609
+ removerArquivo: api.excluirArquivo,
1610
+ apagarArquivo: api.excluirArquivo,
1611
+ fileInfo: api.infoArquivo,
1612
+ storedFileInfo: api.infoArquivo,
1613
+ fileExists: api.arquivoExiste,
1614
+ listFiles: api.listarArquivos,
1615
+ listStoredFiles: api.listarArquivos,
1616
+ openFile: api.abrirArquivo,
1617
+ openStoredFile: api.abrirArquivo,
1618
+ shareFile: api.compartilharArquivo,
1619
+ shareStoredFile: api.compartilharArquivo,
1620
+ downloadFile: api.baixarArquivo,
1621
+ downloadBase64: api.baixarBase64,
1622
+ downloadFromBase64: api.baixarBase64,
1623
+ baixarArquivoBase64: api.baixarBase64,
1624
+ downloadLocalFile: api.baixarArquivoLocal,
1625
+ downloadFromFile: api.baixarArquivoLocal,
1626
+ baixarArquivoNormal: api.baixarArquivoLocal,
1627
+ setWallpaper: api.definirPapelParede,
1628
+ setPhoneWallpaper: api.definirPapelParede,
1629
+ wallpaper: api.definirPapelParede,
1630
+ wallpaperInfo: api.infoPapelParede,
1631
+ openWallpaperSettings: api.abrirConfiguracaoPapelParede,
1632
+ captureScreen: api.capturarTela,
1633
+ takeScreenshot: api.capturarTela,
1634
+ screenshot: api.capturarTela,
822
1635
  deviceInfo: api.infoDispositivo,
823
1636
  networkInfo: api.infoRede,
824
1637
  batteryInfo: api.infoBateria,
825
1638
  memoryInfo: api.infoMemoria,
826
1639
  storageInfo: api.infoArmazenamento,
827
1640
  performanceInfo: api.infoDesempenho,
1641
+ currentVolume: api.volumeAtual,
1642
+ getVolume: api.volumeAtual,
1643
+ setVolume: api.definirVolume,
1644
+ increaseVolume: api.aumentarVolume,
1645
+ decreaseVolume: api.diminuirVolume,
828
1646
  openAppsMemory: api.appsAbertos,
829
1647
  openAppsInfo: api.infoAppsAbertos,
1648
+ getLocation: api.obterLocalizacao,
1649
+ watchLocation: api.acompanharLocalizacao,
1650
+ stopLocationWatch: api.pararLocalizacao,
1651
+ onLocationChange: api.aoMudarLocalizacao,
1652
+ authenticateBiometric: api.autenticarBiometria,
1653
+ saveSecure: api.salvarSeguro,
1654
+ secureSet: api.salvarSeguro,
1655
+ readSecure: api.lerSeguro,
1656
+ secureGet: api.lerSeguro,
1657
+ readSecureItem: api.lerSeguroCompleto,
1658
+ deleteSecure: api.removerSeguro,
1659
+ removeSecure: api.removerSeguro,
1660
+ secureDelete: api.removerSeguro,
1661
+ listSecureKeys: api.listarSeguro,
1662
+ clearSecureStorage: api.limparSeguro,
830
1663
  permissionStatus: api.statusPermissoes,
831
1664
  requestNotificationPermission: api.solicitarPermissaoNotificacoes,
832
1665
  notificationPermissionStatus: api.statusPermissaoNotificacoes,
@@ -836,15 +1669,51 @@ Object.assign(api, {
836
1669
  requestOverlayPermission: api.solicitarPermissaoSobreposicao,
837
1670
  openOverlaySettings: api.abrirConfiguracaoSobreposicao,
838
1671
  startFloatingIcon: api.iniciarIconeFlutuante,
1672
+ configureFloatingIcon: api.configurarIconeFlutuante,
1673
+ setFloatingIconOpacity: api.definirOpacidadeIconeFlutuante,
839
1674
  stopFloatingIcon: api.pararIconeFlutuante,
1675
+ minimizeApp: api.minimizarApp,
1676
+ closeApp: api.fecharApp,
1677
+ exitApp: api.fecharApp,
840
1678
  getInitialNotification: api.obterNotificacaoInicial,
841
1679
  getInitialLink: api.obterLinkInicial,
1680
+ getInitialShare: api.obterCompartilhamentoInicial,
1681
+ onShareReceived: api.aoReceberCompartilhamento,
1682
+ onReceiveShare: api.aoReceberCompartilhamento,
842
1683
  onEvent: api.aoEvento,
843
1684
  onMinimize: api.aoMinimizar,
844
1685
  onAppResume: api.aoVoltarParaApp,
845
1686
  onOpenLink: api.aoAbrirLink,
846
1687
  onNetworkChange: api.aoMudarRede,
847
1688
  onBatteryChange: api.aoMudarBateria,
1689
+ onUSBConnect: api.aoConectarUSB,
1690
+ onUsbConnect: api.aoConectarUSB,
1691
+ onUSBDisconnect: api.aoDesconectarUSB,
1692
+ onUsbDisconnect: api.aoDesconectarUSB,
1693
+ onHeadphoneConnect: api.aoConectarFone,
1694
+ onHeadphoneConnected: api.aoConectarFone,
1695
+ onHeadphoneDisconnect: api.aoDesconectarFone,
1696
+ onHeadphoneDisconnected: api.aoDesconectarFone,
1697
+ onVolumeChange: api.aoMudarVolume,
1698
+ onKeyboardOpen: api.aoAbrirTeclado,
1699
+ onKeyboardOpened: api.aoAbrirTeclado,
1700
+ onKeyboardClose: api.aoFecharTeclado,
1701
+ onKeyboardClosed: api.aoFecharTeclado,
1702
+ onPhoneShake: api.aoSacudirCelular,
1703
+ onShake: api.aoSacudirCelular,
1704
+ onPhoneFaceDown: api.aoVirarCelularParaBaixo,
1705
+ onFaceDown: api.aoVirarCelularParaBaixo,
1706
+ onProximityNear: api.aoAproximarObjeto,
1707
+ onObjectNear: api.aoAproximarObjeto,
1708
+ onScreenshot: api.aoTirarPrint,
1709
+ onScreenshotTaken: api.aoTirarPrint,
1710
+ onOrientationChange: api.aoMudarOrientacao,
1711
+ onNFC: api.aoNFC,
1712
+ onNfc: api.aoNFC,
1713
+ onNFCReceived: api.aoNFC,
1714
+ onNfcReceived: api.aoNFC,
1715
+ onNotificationReceived: api.aoReceberNotificacao,
1716
+ onReceiveNotification: api.aoReceberNotificacao,
848
1717
  onNotificationClick: api.aoClicarNotificacao
849
1718
  });
850
1719
 
@@ -881,6 +1750,9 @@ if (typeof window !== "undefined") {
881
1750
  window.escolherVideo = api.escolherVideo;
882
1751
  window.escolherPasta = api.escolherPasta;
883
1752
  window.salvarArquivo = api.salvarArquivo;
1753
+ window.definirPapelParede = api.definirPapelParede;
1754
+ window.infoPapelParede = api.infoPapelParede;
1755
+ window.abrirConfiguracaoPapelParede = api.abrirConfiguracaoPapelParede;
884
1756
  window.infoDispositivo = api.infoDispositivo;
885
1757
  window.infoRede = api.infoRede;
886
1758
  window.infoBateria = api.infoBateria;
@@ -943,6 +1815,12 @@ if (typeof window !== "undefined") {
943
1815
  emitEvent("link:aberto", link);
944
1816
  }
945
1817
  });
1818
+ api.obterCompartilhamentoInicial().then(function (share) {
1819
+ if (share) {
1820
+ initialShare = share;
1821
+ emitEvent("compartilhamento:recebido", share);
1822
+ }
1823
+ });
946
1824
  }, false);
947
1825
  }
948
1826