html2apk 0.7.0 → 0.9.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.
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <paths xmlns:android="http://schemas.android.com/apk/res/android">
3
+ <files-path name="files" path="." />
4
+ <cache-path name="cache" path="." />
5
+ <external-files-path name="external_files" path="." />
6
+ </paths>
@@ -21,6 +21,8 @@ var eventAliases = {
21
21
  "link:opened": "link:aberto",
22
22
  "network:changed": "rede:mudou",
23
23
  "battery:changed": "bateria:mudou",
24
+ "location:changed": "localizacao:mudou",
25
+ "biometric:failed": "biometria:falhou",
24
26
  "notification:received": "notificacao:recebida",
25
27
  "notification:clicked": "notificacao:clicada"
26
28
  };
@@ -537,6 +539,268 @@ function openInAppUrl(url, options) {
537
539
  });
538
540
  }
539
541
 
542
+ function hasOwn(object, key) {
543
+ return Object.prototype.hasOwnProperty.call(object || {}, key);
544
+ }
545
+
546
+ function storedFileOptions(nameOrOptions, value, options) {
547
+ var normalized;
548
+ if (nameOrOptions && typeof nameOrOptions === "object" && !Array.isArray(nameOrOptions)) {
549
+ return cloneSerializable(nameOrOptions) || {};
550
+ }
551
+
552
+ normalized = cloneSerializable(options || {}) || {};
553
+ normalized.name = String(nameOrOptions || "");
554
+ normalized.nome = normalized.name;
555
+ normalized.value = cloneSerializable(value);
556
+ normalized.valor = normalized.value;
557
+ if (typeof value !== "string" && !hasOwn(normalized, "json")) {
558
+ normalized.json = true;
559
+ }
560
+ return normalized;
561
+ }
562
+
563
+ function storedFileNameOptions(nameOrOptions, options) {
564
+ var normalized;
565
+ if (nameOrOptions && typeof nameOrOptions === "object" && !Array.isArray(nameOrOptions)) {
566
+ return cloneSerializable(nameOrOptions) || {};
567
+ }
568
+ normalized = cloneSerializable(options || {}) || {};
569
+ normalized.name = String(nameOrOptions || "");
570
+ normalized.nome = normalized.name;
571
+ return normalized;
572
+ }
573
+
574
+ function applyDownloadName(normalized, nameOrOptions) {
575
+ if (typeof nameOrOptions === "string") {
576
+ normalized.name = nameOrOptions;
577
+ normalized.nome = nameOrOptions;
578
+ normalized.fileName = nameOrOptions;
579
+ normalized.nomeArquivo = nameOrOptions;
580
+ } else if (nameOrOptions && typeof nameOrOptions === "object" && !Array.isArray(nameOrOptions)) {
581
+ Object.assign(normalized, cloneSerializable(nameOrOptions) || {});
582
+ }
583
+ return normalized;
584
+ }
585
+
586
+ function applyBase64DownloadSource(normalized, value) {
587
+ var source = String(value || "");
588
+ var comma;
589
+ var header;
590
+ var mimeType;
591
+
592
+ if (source.indexOf("data:") === 0) {
593
+ comma = source.indexOf(",");
594
+ header = comma >= 0 ? source.slice(5, comma) : "";
595
+ mimeType = header.split(";")[0];
596
+ normalized.base64 = comma >= 0 ? source.slice(comma + 1) : source;
597
+ if (mimeType) {
598
+ normalized.mimeType = normalized.mimeType || mimeType;
599
+ normalized.tipoMime = normalized.tipoMime || mimeType;
600
+ }
601
+ return normalized;
602
+ }
603
+
604
+ normalized.base64 = source;
605
+ return normalized;
606
+ }
607
+
608
+ function downloadFileOptions(urlOrOptions, nameOrOptions) {
609
+ var normalized;
610
+ var source;
611
+
612
+ if (urlOrOptions && typeof urlOrOptions === "object" && !Array.isArray(urlOrOptions)) {
613
+ normalized = cloneSerializable(urlOrOptions) || {};
614
+ return applyDownloadName(normalized, nameOrOptions);
615
+ }
616
+
617
+ normalized = {};
618
+ source = String(urlOrOptions || "").trim();
619
+ if (source.indexOf("data:") === 0) {
620
+ applyBase64DownloadSource(normalized, source);
621
+ } else {
622
+ normalized.url = source;
623
+ }
624
+ return applyDownloadName(normalized, nameOrOptions);
625
+ }
626
+
627
+ function downloadBase64Options(nameOrOptions, base64, options) {
628
+ var normalized;
629
+ if (nameOrOptions && typeof nameOrOptions === "object" && !Array.isArray(nameOrOptions)) {
630
+ normalized = cloneSerializable(nameOrOptions) || {};
631
+ if (typeof base64 === "string") {
632
+ applyBase64DownloadSource(normalized, base64);
633
+ } else if (base64 && typeof base64 === "object" && !Array.isArray(base64)) {
634
+ Object.assign(normalized, cloneSerializable(base64) || {});
635
+ }
636
+ return normalized;
637
+ }
638
+
639
+ normalized = cloneSerializable(options || {}) || {};
640
+ applyDownloadName(normalized, String(nameOrOptions || ""));
641
+ return applyBase64DownloadSource(normalized, base64);
642
+ }
643
+
644
+ function downloadLocalFileOptions(fileOrOptions, nameOrOptions) {
645
+ var normalized;
646
+ var source;
647
+
648
+ if (fileOrOptions && typeof fileOrOptions === "object" && !Array.isArray(fileOrOptions)) {
649
+ normalized = cloneSerializable(fileOrOptions) || {};
650
+ return applyDownloadName(normalized, nameOrOptions);
651
+ }
652
+
653
+ normalized = {};
654
+ source = String(fileOrOptions || "").trim();
655
+ if (/^(content|file):\/\//.test(source)) {
656
+ normalized.uri = source;
657
+ normalized.contentUri = source;
658
+ } else if (/^[A-Za-z]:[\\/]/.test(source) || source.charAt(0) === "/" || source.charAt(0) === "\\") {
659
+ normalized.path = source;
660
+ normalized.caminho = source;
661
+ } else {
662
+ normalized.sourceName = source;
663
+ normalized.arquivoOrigem = source;
664
+ }
665
+ return applyDownloadName(normalized, nameOrOptions);
666
+ }
667
+
668
+ function wallpaperOptions(sourceOrOptions, options) {
669
+ var normalized;
670
+ var source;
671
+ var comma;
672
+ var header;
673
+ var mimeType;
674
+
675
+ if (sourceOrOptions && typeof sourceOrOptions === "object" && !Array.isArray(sourceOrOptions)) {
676
+ normalized = cloneSerializable(sourceOrOptions) || {};
677
+ } else {
678
+ normalized = cloneSerializable(options || {}) || {};
679
+ source = String(sourceOrOptions || "").trim();
680
+ if (source.indexOf("data:") === 0) {
681
+ comma = source.indexOf(",");
682
+ header = comma >= 0 ? source.slice(5, comma) : "";
683
+ mimeType = header.split(";")[0];
684
+ normalized.base64 = comma >= 0 ? source.slice(comma + 1) : source;
685
+ if (mimeType) {
686
+ normalized.mimeType = normalized.mimeType || mimeType;
687
+ normalized.tipoMime = normalized.tipoMime || mimeType;
688
+ }
689
+ } else if (/^(content|file):\/\//.test(source)) {
690
+ normalized.uri = source;
691
+ normalized.contentUri = source;
692
+ } else if (/^[A-Za-z]:[\\/]/.test(source) || source.charAt(0) === "/" || source.charAt(0) === "\\") {
693
+ normalized.path = source;
694
+ normalized.caminho = source;
695
+ } else {
696
+ normalized.name = source;
697
+ normalized.nome = source;
698
+ normalized.fileName = source;
699
+ normalized.nomeArquivo = source;
700
+ }
701
+ }
702
+
703
+ if (normalized.alvo && !normalized.target) {
704
+ normalized.target = normalized.alvo;
705
+ }
706
+ if (normalized.target && !normalized.alvo) {
707
+ normalized.alvo = normalized.target;
708
+ }
709
+ return normalized;
710
+ }
711
+
712
+ function secureItemOptions(keyOrOptions, value, options) {
713
+ var normalized;
714
+ if (keyOrOptions && typeof keyOrOptions === "object" && !Array.isArray(keyOrOptions)) {
715
+ return cloneSerializable(keyOrOptions) || {};
716
+ }
717
+ normalized = cloneSerializable(options || {}) || {};
718
+ normalized.key = String(keyOrOptions || "");
719
+ normalized.chave = normalized.key;
720
+ normalized.value = cloneSerializable(value);
721
+ normalized.valor = normalized.value;
722
+ if (typeof value !== "string" && !hasOwn(normalized, "json")) {
723
+ normalized.json = true;
724
+ }
725
+ return normalized;
726
+ }
727
+
728
+ function secureKeyOptions(keyOrOptions, options) {
729
+ var normalized;
730
+ if (keyOrOptions && typeof keyOrOptions === "object" && !Array.isArray(keyOrOptions)) {
731
+ return cloneSerializable(keyOrOptions) || {};
732
+ }
733
+ normalized = cloneSerializable(options || {}) || {};
734
+ normalized.key = String(keyOrOptions || "");
735
+ normalized.chave = normalized.key;
736
+ return normalized;
737
+ }
738
+
739
+ function unwrapStoredValue(result) {
740
+ if (!result || result.exists === false || result.existe === false) {
741
+ return null;
742
+ }
743
+ if (hasOwn(result, "value")) {
744
+ return result.value;
745
+ }
746
+ if (hasOwn(result, "valor")) {
747
+ return result.valor;
748
+ }
749
+ if (hasOwn(result, "base64")) {
750
+ return result.base64;
751
+ }
752
+ if (hasOwn(result, "content")) {
753
+ return result.content;
754
+ }
755
+ if (hasOwn(result, "conteudo")) {
756
+ return result.conteudo;
757
+ }
758
+ return result;
759
+ }
760
+
761
+ function detectQRCodeFromPhoto(photo) {
762
+ var source;
763
+ var detector;
764
+
765
+ if (!photo || !photo.base64) {
766
+ return null;
767
+ }
768
+ if (typeof BarcodeDetector !== "function" || typeof createImageBitmap !== "function" || typeof fetch !== "function") {
769
+ throw new Error("QR code scanning requires BarcodeDetector support in this Android WebView.");
770
+ }
771
+
772
+ detector = new BarcodeDetector({ formats: ["qr_code"] });
773
+ source = "data:" + (photo.mimeType || "image/jpeg") + ";base64," + photo.base64;
774
+ return fetch(source)
775
+ .then(function (response) {
776
+ return response.blob();
777
+ })
778
+ .then(function (blob) {
779
+ return createImageBitmap(blob);
780
+ })
781
+ .then(function (image) {
782
+ return detector.detect(image);
783
+ })
784
+ .then(function (codes) {
785
+ var first = codes && codes[0];
786
+ if (!first) {
787
+ return null;
788
+ }
789
+ return {
790
+ text: first.rawValue || "",
791
+ texto: first.rawValue || "",
792
+ rawValue: first.rawValue || "",
793
+ valorBruto: first.rawValue || "",
794
+ format: first.format || "qr_code",
795
+ formato: first.format || "qr_code",
796
+ codes: codes,
797
+ codigos: codes,
798
+ photo: photo,
799
+ foto: photo
800
+ };
801
+ });
802
+ }
803
+
540
804
  var api = {
541
805
  notificar: function (messageOrOptions) {
542
806
  return call("notify", [normalizeNotificationOptions(messageOrOptions)]);
@@ -590,6 +854,15 @@ var api = {
590
854
  statusLanterna: function () {
591
855
  return call("flashlightStatus");
592
856
  },
857
+ tirarFoto: function (options) {
858
+ return call("capturePhoto", [options || {}]);
859
+ },
860
+ capturarVideo: function (options) {
861
+ return call("captureVideo", [options || {}]);
862
+ },
863
+ escanearQRCode: function (options) {
864
+ return api.tirarFoto(Object.assign({ base64: true }, options || {})).then(detectQRCodeFromPhoto);
865
+ },
593
866
  solicitarPermissaoCamera: function () {
594
867
  return call("requestCameraPermission");
595
868
  },
@@ -659,8 +932,55 @@ var api = {
659
932
  escolherPasta: function () {
660
933
  return call("pickFolder");
661
934
  },
662
- salvarArquivo: function (options) {
663
- return call("saveFile", [options || {}]);
935
+ salvarArquivo: function (nameOrOptions, value, options) {
936
+ if (typeof nameOrOptions === "string") {
937
+ return call("saveStoredFile", [storedFileOptions(nameOrOptions, value, options)]);
938
+ }
939
+ return call("saveFile", [nameOrOptions || {}]);
940
+ },
941
+ lerArquivo: function (nameOrOptions, options) {
942
+ return call("readStoredFile", [storedFileNameOptions(nameOrOptions, options)]).then(unwrapStoredValue);
943
+ },
944
+ lerArquivoCompleto: function (nameOrOptions, options) {
945
+ return call("readStoredFile", [storedFileNameOptions(nameOrOptions, options)]);
946
+ },
947
+ excluirArquivo: function (nameOrOptions, options) {
948
+ return call("deleteStoredFile", [storedFileNameOptions(nameOrOptions, options)]);
949
+ },
950
+ infoArquivo: function (nameOrOptions, options) {
951
+ return call("storedFileInfo", [storedFileNameOptions(nameOrOptions, options)]);
952
+ },
953
+ arquivoExiste: function (nameOrOptions, options) {
954
+ return api.infoArquivo(nameOrOptions, options).then(function (info) {
955
+ return Boolean(info && (info.exists || info.existe));
956
+ });
957
+ },
958
+ listarArquivos: function () {
959
+ return call("listStoredFiles");
960
+ },
961
+ abrirArquivo: function (nameOrOptions, options) {
962
+ return call("openStoredFile", [storedFileNameOptions(nameOrOptions, options)]);
963
+ },
964
+ compartilharArquivo: function (nameOrOptions, options) {
965
+ return call("shareStoredFile", [storedFileNameOptions(nameOrOptions, options)]);
966
+ },
967
+ baixarArquivo: function (urlOrOptions, nameOrOptions) {
968
+ return call("downloadFile", [downloadFileOptions(urlOrOptions, nameOrOptions)]);
969
+ },
970
+ baixarBase64: function (nameOrOptions, base64, options) {
971
+ return call("downloadFile", [downloadBase64Options(nameOrOptions, base64, options)]);
972
+ },
973
+ baixarArquivoLocal: function (fileOrOptions, nameOrOptions) {
974
+ return call("downloadFile", [downloadLocalFileOptions(fileOrOptions, nameOrOptions)]);
975
+ },
976
+ definirPapelParede: function (sourceOrOptions, options) {
977
+ return call("setWallpaper", [wallpaperOptions(sourceOrOptions, options)]);
978
+ },
979
+ infoPapelParede: function () {
980
+ return call("wallpaperInfo");
981
+ },
982
+ abrirConfiguracaoPapelParede: function () {
983
+ return call("openWallpaperSettings");
664
984
  },
665
985
  infoDispositivo: function () {
666
986
  return call("deviceInfo");
@@ -686,6 +1006,39 @@ var api = {
686
1006
  infoAppsAbertos: function () {
687
1007
  return call("openAppsMemory");
688
1008
  },
1009
+ obterLocalizacao: function (options) {
1010
+ return call("getLocation", [options || {}]);
1011
+ },
1012
+ acompanharLocalizacao: function (options) {
1013
+ return call("watchLocation", [options || {}]);
1014
+ },
1015
+ pararLocalizacao: function (id) {
1016
+ return call("stopLocationWatch", [id || ""]);
1017
+ },
1018
+ aoMudarLocalizacao: function (listener) {
1019
+ return onEvent("localizacao:mudou", listener);
1020
+ },
1021
+ autenticarBiometria: function (options) {
1022
+ return call("authenticateBiometric", [options || {}]);
1023
+ },
1024
+ salvarSeguro: function (keyOrOptions, value, options) {
1025
+ return call("saveSecureItem", [secureItemOptions(keyOrOptions, value, options)]);
1026
+ },
1027
+ lerSeguro: function (keyOrOptions, options) {
1028
+ return call("readSecureItem", [secureKeyOptions(keyOrOptions, options)]).then(unwrapStoredValue);
1029
+ },
1030
+ lerSeguroCompleto: function (keyOrOptions, options) {
1031
+ return call("readSecureItem", [secureKeyOptions(keyOrOptions, options)]);
1032
+ },
1033
+ removerSeguro: function (keyOrOptions, options) {
1034
+ return call("deleteSecureItem", [secureKeyOptions(keyOrOptions, options)]);
1035
+ },
1036
+ listarSeguro: function () {
1037
+ return call("listSecureKeys");
1038
+ },
1039
+ limparSeguro: function () {
1040
+ return call("clearSecureStorage");
1041
+ },
689
1042
  statusPermissoes: function (permissions) {
690
1043
  return call("permissionStatus", [permissions || []]);
691
1044
  },
@@ -793,6 +1146,11 @@ Object.assign(api, {
793
1146
  flashlight: api.lanterna,
794
1147
  toggleFlashlight: api.alternarLanterna,
795
1148
  flashlightStatus: api.statusLanterna,
1149
+ takePhoto: api.tirarFoto,
1150
+ capturePhoto: api.tirarFoto,
1151
+ captureVideo: api.capturarVideo,
1152
+ scanQRCode: api.escanearQRCode,
1153
+ scanQrCode: api.escanearQRCode,
796
1154
  requestCameraPermission: api.solicitarPermissaoCamera,
797
1155
  requestMicrophonePermission: api.solicitarPermissaoMicrofone,
798
1156
  microphoneStatus: api.statusMicrofone,
@@ -819,6 +1177,35 @@ Object.assign(api, {
819
1177
  pickVideo: api.escolherVideo,
820
1178
  pickFolder: api.escolherPasta,
821
1179
  saveFile: api.salvarArquivo,
1180
+ readFile: api.lerArquivo,
1181
+ readStoredFile: api.lerArquivo,
1182
+ readStoredFileInfo: api.lerArquivoCompleto,
1183
+ deleteFile: api.excluirArquivo,
1184
+ removeFile: api.excluirArquivo,
1185
+ excluirArquivoArmazenado: api.excluirArquivo,
1186
+ removerArquivo: api.excluirArquivo,
1187
+ apagarArquivo: api.excluirArquivo,
1188
+ fileInfo: api.infoArquivo,
1189
+ storedFileInfo: api.infoArquivo,
1190
+ fileExists: api.arquivoExiste,
1191
+ listFiles: api.listarArquivos,
1192
+ listStoredFiles: api.listarArquivos,
1193
+ openFile: api.abrirArquivo,
1194
+ openStoredFile: api.abrirArquivo,
1195
+ shareFile: api.compartilharArquivo,
1196
+ shareStoredFile: api.compartilharArquivo,
1197
+ downloadFile: api.baixarArquivo,
1198
+ downloadBase64: api.baixarBase64,
1199
+ downloadFromBase64: api.baixarBase64,
1200
+ baixarArquivoBase64: api.baixarBase64,
1201
+ downloadLocalFile: api.baixarArquivoLocal,
1202
+ downloadFromFile: api.baixarArquivoLocal,
1203
+ baixarArquivoNormal: api.baixarArquivoLocal,
1204
+ setWallpaper: api.definirPapelParede,
1205
+ setPhoneWallpaper: api.definirPapelParede,
1206
+ wallpaper: api.definirPapelParede,
1207
+ wallpaperInfo: api.infoPapelParede,
1208
+ openWallpaperSettings: api.abrirConfiguracaoPapelParede,
822
1209
  deviceInfo: api.infoDispositivo,
823
1210
  networkInfo: api.infoRede,
824
1211
  batteryInfo: api.infoBateria,
@@ -827,6 +1214,21 @@ Object.assign(api, {
827
1214
  performanceInfo: api.infoDesempenho,
828
1215
  openAppsMemory: api.appsAbertos,
829
1216
  openAppsInfo: api.infoAppsAbertos,
1217
+ getLocation: api.obterLocalizacao,
1218
+ watchLocation: api.acompanharLocalizacao,
1219
+ stopLocationWatch: api.pararLocalizacao,
1220
+ onLocationChange: api.aoMudarLocalizacao,
1221
+ authenticateBiometric: api.autenticarBiometria,
1222
+ saveSecure: api.salvarSeguro,
1223
+ secureSet: api.salvarSeguro,
1224
+ readSecure: api.lerSeguro,
1225
+ secureGet: api.lerSeguro,
1226
+ readSecureItem: api.lerSeguroCompleto,
1227
+ deleteSecure: api.removerSeguro,
1228
+ removeSecure: api.removerSeguro,
1229
+ secureDelete: api.removerSeguro,
1230
+ listSecureKeys: api.listarSeguro,
1231
+ clearSecureStorage: api.limparSeguro,
830
1232
  permissionStatus: api.statusPermissoes,
831
1233
  requestNotificationPermission: api.solicitarPermissaoNotificacoes,
832
1234
  notificationPermissionStatus: api.statusPermissaoNotificacoes,
@@ -881,6 +1283,9 @@ if (typeof window !== "undefined") {
881
1283
  window.escolherVideo = api.escolherVideo;
882
1284
  window.escolherPasta = api.escolherPasta;
883
1285
  window.salvarArquivo = api.salvarArquivo;
1286
+ window.definirPapelParede = api.definirPapelParede;
1287
+ window.infoPapelParede = api.infoPapelParede;
1288
+ window.abrirConfiguracaoPapelParede = api.abrirConfiguracaoPapelParede;
884
1289
  window.infoDispositivo = api.infoDispositivo;
885
1290
  window.infoRede = api.infoRede;
886
1291
  window.infoBateria = api.infoBateria;