html2apk 0.9.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.
@@ -16,6 +16,11 @@
16
16
  var consoleList = null;
17
17
  var networkList = null;
18
18
  var badge = null;
19
+ var consoleCount = null;
20
+ var networkCount = null;
21
+ var errorCount = null;
22
+ var copyAllButton = null;
23
+ var copyOnlyErrorsButton = null;
19
24
  var activeTab = "console";
20
25
  var opened = false;
21
26
  var dragMoved = false;
@@ -39,18 +44,64 @@
39
44
  "solicitarPermissaoNotificacoes", "requestNotificationPermission",
40
45
  "escolherArquivo", "pickFile",
41
46
  "escolherImagem", "pickImage",
47
+ "escolherImagens", "pickImages",
48
+ "escolherPasta", "pickFolder",
42
49
  "salvarArquivo", "saveFile",
43
50
  "lerArquivo", "readFile", "readStoredFile",
44
51
  "excluirArquivo", "deleteFile", "removeFile",
45
52
  "listarArquivos", "listFiles",
46
53
  "abrirArquivo", "openFile",
47
54
  "compartilharArquivo", "shareFile",
55
+ "compartilhar", "share",
56
+ "compartilharApp", "shareApp", "share_me",
57
+ "aguardar", "loading",
58
+ "aoReceberCompartilhamento", "onShareReceived",
59
+ "obterCompartilhamentoInicial", "getInitialShare",
60
+ "procurarBT", "scanBluetooth", "procurarBluetooth", "buscarBT",
61
+ "conectarBT", "connectBluetooth", "conectarBluetooth",
62
+ "enviarBT", "sendBluetooth",
63
+ "aoConectarBT", "onBluetoothConnect",
64
+ "aoReceberDadosBT", "onBluetoothData",
65
+ "aoDarErroBT", "onBluetoothError",
66
+ "procurarWiFi", "scanWiFi", "scanWifi",
67
+ "conectarWiFi", "connectWiFi", "connectWifi",
68
+ "enviarWiFi", "sendWiFi", "sendWifi",
69
+ "aoConectarWiFi", "onWiFiConnect", "onWifiConnect",
70
+ "aoReceberDadosWiFi", "onWiFiData", "onWifiData",
71
+ "aoDarErroWiFi", "onWiFiError", "onWifiError",
72
+ "ocr", "recognizeText", "textFromImage",
73
+ "falar", "speak", "textToSpeech",
74
+ "pararFala", "stopSpeaking",
75
+ "ouvir", "recognizeSpeech", "speechToText",
48
76
  "baixarArquivo", "downloadFile",
49
77
  "baixarBase64", "downloadBase64", "downloadFromBase64",
50
78
  "baixarArquivoLocal", "downloadLocalFile", "downloadFromFile",
79
+ "aoConectarUSB", "onUSBConnect", "onUsbConnect",
80
+ "aoDesconectarUSB", "onUSBDisconnect", "onUsbDisconnect",
81
+ "aoConectarFone", "onHeadphoneConnect",
82
+ "aoDesconectarFone", "onHeadphoneDisconnect",
83
+ "aoMudarVolume", "onVolumeChange",
84
+ "aoAbrirTeclado", "onKeyboardOpen",
85
+ "aoFecharTeclado", "onKeyboardClose",
86
+ "aoSacudirCelular", "onPhoneShake", "onShake",
87
+ "aoVirarCelularParaBaixo", "onPhoneFaceDown",
88
+ "aoAproximarObjeto", "onProximityNear",
89
+ "aoTirarPrint", "onScreenshot",
90
+ "aoMudarOrientacao", "onOrientationChange",
91
+ "aoNFC", "onNFC", "onNfc",
92
+ "aoReceberNotificacao", "onNotificationReceived",
51
93
  "definirPapelParede", "setWallpaper", "setPhoneWallpaper",
52
94
  "infoPapelParede", "wallpaperInfo",
53
95
  "abrirConfiguracaoPapelParede", "openWallpaperSettings",
96
+ "capturarTela", "tirarPrint", "captureScreen", "takeScreenshot", "screenshot",
97
+ "volumeAtual", "currentVolume", "getVolume",
98
+ "definirVolume", "setVolume",
99
+ "aumentarVolume", "increaseVolume",
100
+ "diminuirVolume", "decreaseVolume",
101
+ "configurarIconeFlutuante", "configureFloatingIcon",
102
+ "definirOpacidadeIconeFlutuante", "setFloatingIconOpacity",
103
+ "minimizarApp", "minimizeApp",
104
+ "fecharApp", "closeApp", "exitApp",
54
105
  "abrirNoApp", "openInApp",
55
106
  "abrirForaDoApp", "openOutsideApp",
56
107
  "abrirUrl", "openUrl",
@@ -122,6 +173,8 @@
122
173
  function renderEntry(entry, target) {
123
174
  var item;
124
175
  var meta;
176
+ var label;
177
+ var time;
125
178
  var body;
126
179
 
127
180
  if (!target) {
@@ -133,11 +186,17 @@
133
186
 
134
187
  meta = document.createElement("div");
135
188
  meta.className = "html2apk-console-meta";
136
- meta.textContent = "[" + entry.time + "] " + entry.kind.toUpperCase();
189
+ label = document.createElement("span");
190
+ label.className = "html2apk-console-kind";
191
+ label.textContent = entry.kind.toUpperCase();
192
+ time = document.createElement("time");
193
+ time.textContent = entry.time;
137
194
 
138
195
  body = document.createElement("pre");
139
196
  body.textContent = entry.message;
140
197
 
198
+ meta.appendChild(label);
199
+ meta.appendChild(time);
141
200
  item.appendChild(meta);
142
201
  item.appendChild(body);
143
202
  target.appendChild(item);
@@ -146,7 +205,19 @@
146
205
  target.removeChild(target.firstChild);
147
206
  }
148
207
 
208
+ scrollListToBottom(target);
209
+ }
210
+
211
+ function scrollListToBottom(target) {
212
+ if (!target) {
213
+ return;
214
+ }
149
215
  target.scrollTop = target.scrollHeight;
216
+ if (typeof window.requestAnimationFrame === "function") {
217
+ window.requestAnimationFrame(function () {
218
+ target.scrollTop = target.scrollHeight;
219
+ });
220
+ }
150
221
  }
151
222
 
152
223
  function renderNetworkEntry(entry) {
@@ -186,16 +257,24 @@
186
257
 
187
258
  function updateBadge() {
188
259
  var count;
189
- if (!badge) {
190
- return;
191
- }
192
260
  count = entries.filter(function (entry) {
193
261
  return entry.kind === "error";
194
262
  }).length + networkEntries.filter(function (entry) {
195
263
  return !entry.ok;
196
264
  }).length;
197
- badge.textContent = count ? String(count) : "";
198
- badge.style.display = count ? "inline-flex" : "none";
265
+ if (badge) {
266
+ badge.textContent = count ? String(count) : "";
267
+ badge.style.display = count ? "inline-flex" : "none";
268
+ }
269
+ if (consoleCount) {
270
+ consoleCount.textContent = String(entries.length);
271
+ }
272
+ if (networkCount) {
273
+ networkCount.textContent = String(networkEntries.length);
274
+ }
275
+ if (errorCount) {
276
+ errorCount.textContent = String(count);
277
+ }
199
278
  }
200
279
 
201
280
  function add(kind, message, detail) {
@@ -313,13 +392,30 @@
313
392
  return fallbackCopyText(text);
314
393
  }
315
394
 
395
+ function flashActionButton(target, label) {
396
+ var original;
397
+ if (!target) {
398
+ return;
399
+ }
400
+ original = target.getAttribute("data-original-label") || target.textContent;
401
+ target.setAttribute("data-original-label", original);
402
+ target.textContent = label;
403
+ target.disabled = true;
404
+ setTimeout(function () {
405
+ target.textContent = original;
406
+ target.disabled = false;
407
+ }, 1200);
408
+ }
409
+
316
410
  function copyConsole() {
317
411
  var text = runtimeConsoleText(false);
318
412
  return copyTextToClipboard(text).then(function () {
319
413
  add("info", "Console copiado.");
414
+ flashActionButton(copyAllButton, "Copiado");
320
415
  return { ok: true, copied: "console" };
321
416
  }, function (error) {
322
417
  add("error", "Falha ao copiar console", error);
418
+ flashActionButton(copyAllButton, "Falhou");
323
419
  return { ok: false, copied: "console", message: error && error.message ? error.message : String(error) };
324
420
  });
325
421
  }
@@ -328,9 +424,11 @@
328
424
  var text = runtimeConsoleText(true);
329
425
  return copyTextToClipboard(text).then(function () {
330
426
  add("info", "Erros copiados.");
427
+ flashActionButton(copyOnlyErrorsButton, "Copiado");
331
428
  return { ok: true, copied: "errors" };
332
429
  }, function (error) {
333
430
  add("error", "Falha ao copiar erros", error);
431
+ flashActionButton(copyOnlyErrorsButton, "Falhou");
334
432
  return { ok: false, copied: "errors", message: error && error.message ? error.message : String(error) };
335
433
  });
336
434
  }
@@ -349,6 +447,7 @@
349
447
  if (networkList) {
350
448
  networkList.classList.toggle("active", activeTab === "network");
351
449
  }
450
+ updateBadge();
352
451
  }
353
452
 
354
453
  function clearActiveTab() {
@@ -489,6 +588,11 @@
489
588
  var tabs;
490
589
  var consoleTab;
491
590
  var networkTab;
591
+ var summary;
592
+ var consoleStat;
593
+ var networkStat;
594
+ var errorStat;
595
+ var controls;
492
596
  var actions;
493
597
  var copyButton;
494
598
  var copyErrorsButton;
@@ -502,21 +606,23 @@
502
606
 
503
607
  style = document.createElement("style");
504
608
  style.textContent = [
505
- ".html2apk-console-button{position:fixed;right:14px;bottom:14px;z-index:2147483640;width:54px;height:54px;border:0;border-radius:999px;background:#126fff;color:#fff;padding:0;box-shadow:0 10px 30px rgba(0,0,0,.3);touch-action:none}",
506
- ".html2apk-console-button img{width:100%;height:100%;object-fit:cover;border-radius:999px;display:block}.html2apk-console-button.fallback:before{content:'Console';font:800 10px system-ui,Segoe UI,Arial}",
507
- ".html2apk-console-badge{position:absolute;right:-3px;top:-3px;display:none;align-items:center;justify-content:center;min-width:20px;height:20px;border-radius:999px;background:#ff4d5d;color:#fff;font:800 11px system-ui,Segoe UI,Arial;border:2px solid #fff}",
508
- ".html2apk-console-modal{position:fixed;inset:0;z-index:2147483641;display:none;background:rgba(8,13,22,.42);padding:16px}",
609
+ ".html2apk-console-button{position:fixed;right:14px;bottom:14px;z-index:2147483640;width:58px;height:58px;border:0;border-radius:999px;background:#126fff;color:#fff;padding:0;box-shadow:0 16px 36px rgba(18,111,255,.34),0 8px 24px rgba(0,0,0,.28);touch-action:none}",
610
+ ".html2apk-console-button:active{transform:scale(.98)}.html2apk-console-button img{width:100%;height:100%;object-fit:cover;border-radius:999px;display:block}.html2apk-console-button.fallback:before{content:'Console';font:800 10px system-ui,Segoe UI,Arial}",
611
+ ".html2apk-console-badge{position:absolute;right:-3px;top:-3px;display:none;align-items:center;justify-content:center;min-width:21px;height:21px;border-radius:999px;background:#ef4444;color:#fff;font:900 11px system-ui,Segoe UI,Arial;border:2px solid #fff}",
612
+ ".html2apk-console-modal{position:fixed;inset:0;z-index:2147483641;display:none;background:rgba(5,10,20,.56);padding:12px;font-family:system-ui,Segoe UI,Arial}",
509
613
  ".html2apk-console-modal.open{display:flex;align-items:flex-end;justify-content:center}",
510
- ".html2apk-console-panel{width:min(980px,calc(100vw - 24px));max-height:min(74vh,700px);background:#10141b;color:#edf4ff;border:1px solid rgba(255,255,255,.14);border-radius:14px;box-shadow:0 28px 90px rgba(0,0,0,.42);overflow:hidden;font-family:system-ui,Segoe UI,Arial}",
511
- ".html2apk-console-header{display:grid;grid-template-columns:auto minmax(0,1fr);align-items:center;gap:12px;padding:12px 14px;border-bottom:1px solid rgba(255,255,255,.12);background:#161d27;touch-action:none}",
512
- ".html2apk-console-header strong{font-size:15px}.html2apk-console-tabs{display:flex;gap:8px;flex-wrap:wrap}.html2apk-console-actions{grid-column:1/-1;display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}",
513
- ".html2apk-console-header button{border:1px solid rgba(255,255,255,.18);background:#202b3a;color:#edf4ff;border-radius:8px;padding:7px 10px;font:700 12px system-ui,Segoe UI,Arial}",
514
- ".html2apk-console-header button.active{background:#126fff;border-color:#126fff;color:#fff}",
515
- ".html2apk-console-body{height:min(59vh,570px);background:#0d1118}.html2apk-console-list{display:none;height:100%;overflow:auto;padding:10px}.html2apk-console-list.active{display:block}",
516
- ".html2apk-console-entry{border:1px solid rgba(255,255,255,.1);border-radius:10px;padding:8px 10px;margin-bottom:8px;background:#141b25}",
517
- ".html2apk-console-entry.error{border-color:rgba(255,110,123,.65)}.html2apk-console-entry.warn{border-color:rgba(231,173,76,.6)}.html2apk-console-entry.call,.html2apk-console-entry.network{border-color:rgba(98,160,255,.55)}.html2apk-console-entry.ok{border-color:rgba(67,201,133,.55)}",
518
- ".html2apk-console-meta{color:#9baabd;font-size:11px;font-weight:800;margin-bottom:4px}.html2apk-console-entry pre{white-space:pre-wrap;word-break:break-word;margin:0;font:12px ui-monospace,SFMono-Regular,Consolas,monospace;line-height:1.45}",
519
- "@media (min-width:700px){.html2apk-console-header{grid-template-columns:auto minmax(0,1fr) auto}.html2apk-console-actions{grid-column:auto}}"
614
+ ".html2apk-console-panel{width:min(1040px,calc(100vw - 18px));max-height:min(82vh,760px);background:#0b1020;color:#edf4ff;border:1px solid rgba(148,163,184,.25);border-radius:16px;box-shadow:0 28px 90px rgba(0,0,0,.5);overflow:hidden}",
615
+ ".html2apk-console-header{display:grid;grid-template-columns:minmax(0,1fr);gap:10px;padding:12px;border-bottom:1px solid rgba(148,163,184,.22);background:linear-gradient(180deg,#111827,#0f172a);touch-action:none}",
616
+ ".html2apk-console-title{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0}.html2apk-console-title strong{font-size:15px;line-height:1.2}.html2apk-console-subtitle{display:block;color:#94a3b8;font-size:11px;font-weight:700;margin-top:2px}",
617
+ ".html2apk-console-summary{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.html2apk-console-stat{border:1px solid rgba(148,163,184,.22);background:rgba(15,23,42,.8);border-radius:10px;padding:8px}.html2apk-console-stat span{display:block;color:#94a3b8;font-size:10px;font-weight:900;text-transform:uppercase;letter-spacing:.04em}.html2apk-console-stat strong{display:block;margin-top:2px;font-size:18px;line-height:1;color:#f8fafc}",
618
+ ".html2apk-console-controls{display:grid;grid-template-columns:minmax(0,1fr);gap:8px}.html2apk-console-tabs,.html2apk-console-actions{display:flex;gap:8px;flex-wrap:wrap}.html2apk-console-actions{justify-content:flex-start}",
619
+ ".html2apk-console-header button{border:1px solid rgba(148,163,184,.28);background:#1e293b;color:#e2e8f0;border-radius:9px;padding:8px 10px;font:800 12px system-ui,Segoe UI,Arial}",
620
+ ".html2apk-console-header button.active{background:#126fff;border-color:#60a5fa;color:#fff}.html2apk-console-header button:hover{border-color:#93c5fd}.html2apk-console-header button:disabled{opacity:.72}",
621
+ ".html2apk-console-body{height:min(58vh,560px);background:#050816;overflow:hidden}.html2apk-console-list{display:none;height:100%;box-sizing:border-box;overflow:auto;padding:10px 10px 30px;scroll-padding-bottom:30px;overscroll-behavior:contain}.html2apk-console-list:after{content:'';display:block;height:14px}.html2apk-console-list.active{display:block}",
622
+ ".html2apk-console-entry{border:1px solid rgba(148,163,184,.16);border-left:4px solid #64748b;border-radius:11px;padding:9px 10px;margin-bottom:8px;background:#0f172a}",
623
+ ".html2apk-console-entry.error{border-left-color:#ef4444;background:#1b1117}.html2apk-console-entry.warn{border-left-color:#f59e0b;background:#1a1610}.html2apk-console-entry.call,.html2apk-console-entry.network{border-left-color:#60a5fa}.html2apk-console-entry.ok{border-left-color:#22c55e;background:#0f1a15}.html2apk-console-entry.info{border-left-color:#94a3b8}",
624
+ ".html2apk-console-meta{display:flex;align-items:center;justify-content:space-between;gap:10px;color:#94a3b8;font-size:11px;font-weight:900;margin-bottom:6px}.html2apk-console-kind{color:#e2e8f0}.html2apk-console-entry pre{white-space:pre-wrap;word-break:break-word;margin:0;color:#dbeafe;font:12px ui-monospace,SFMono-Regular,Consolas,monospace;line-height:1.48}",
625
+ "@media (min-width:760px){.html2apk-console-header{grid-template-columns:minmax(170px,.8fr) minmax(220px,1fr) minmax(300px,1.2fr);align-items:center}.html2apk-console-controls{grid-template-columns:minmax(0,.9fr) minmax(0,1.1fr)}.html2apk-console-actions{justify-content:flex-end}.html2apk-console-summary{grid-template-columns:repeat(3,minmax(80px,1fr))}}"
520
626
  ].join("");
521
627
  document.head.appendChild(style);
522
628
 
@@ -556,11 +662,49 @@
556
662
 
557
663
  header = document.createElement("div");
558
664
  header.className = "html2apk-console-header";
559
- title = document.createElement("strong");
560
- title.textContent = "Console";
665
+ title = document.createElement("div");
666
+ title.className = "html2apk-console-title";
667
+ title.innerHTML = "<div><strong>Console html2apk</strong><span class=\"html2apk-console-subtitle\">Logs, erros, rede e chamadas nativas</span></div>";
668
+
669
+ summary = document.createElement("div");
670
+ summary.className = "html2apk-console-summary";
671
+ consoleStat = document.createElement("div");
672
+ consoleStat.className = "html2apk-console-stat";
673
+ consoleStat.innerHTML = "<span>Console</span>";
674
+ consoleCount = document.createElement("strong");
675
+ consoleCount.textContent = "0";
676
+ consoleStat.appendChild(consoleCount);
677
+ networkStat = document.createElement("div");
678
+ networkStat.className = "html2apk-console-stat";
679
+ networkStat.innerHTML = "<span>Rede</span>";
680
+ networkCount = document.createElement("strong");
681
+ networkCount.textContent = "0";
682
+ networkStat.appendChild(networkCount);
683
+ errorStat = document.createElement("div");
684
+ errorStat.className = "html2apk-console-stat";
685
+ errorStat.innerHTML = "<span>Erros</span>";
686
+ errorCount = document.createElement("strong");
687
+ errorCount.textContent = "0";
688
+ errorStat.appendChild(errorCount);
689
+ summary.appendChild(consoleStat);
690
+ summary.appendChild(networkStat);
691
+ summary.appendChild(errorStat);
692
+
693
+ controls = document.createElement("div");
694
+ controls.className = "html2apk-console-controls";
561
695
 
562
696
  tabs = document.createElement("div");
563
697
  tabs.className = "html2apk-console-tabs";
698
+ controls.appendChild(tabs);
699
+
700
+ closeButton = document.createElement("button");
701
+ closeButton.type = "button";
702
+ closeButton.textContent = "Fechar";
703
+ title.appendChild(closeButton);
704
+
705
+ header.appendChild(title);
706
+ header.appendChild(summary);
707
+ header.appendChild(controls);
564
708
  consoleTab = document.createElement("button");
565
709
  consoleTab.type = "button";
566
710
  consoleTab.textContent = "Console";
@@ -584,22 +728,21 @@
584
728
  copyButton.type = "button";
585
729
  copyButton.textContent = "Copiar console";
586
730
  copyButton.addEventListener("click", copyConsole);
731
+ copyAllButton = copyButton;
587
732
  copyErrorsButton = document.createElement("button");
588
733
  copyErrorsButton.type = "button";
589
734
  copyErrorsButton.textContent = "Copiar apenas erros";
590
735
  copyErrorsButton.addEventListener("click", copyErrors);
736
+ copyOnlyErrorsButton = copyErrorsButton;
591
737
  clearButton = document.createElement("button");
592
738
  clearButton.type = "button";
593
739
  clearButton.textContent = "Limpar";
594
740
  clearButton.addEventListener("click", clearActiveTab);
595
- closeButton = document.createElement("button");
596
- closeButton.type = "button";
597
- closeButton.textContent = "Fechar";
598
741
  closeButton.addEventListener("click", closeConsole);
599
742
  actions.appendChild(copyButton);
600
743
  actions.appendChild(copyErrorsButton);
601
744
  actions.appendChild(clearButton);
602
- actions.appendChild(closeButton);
745
+ controls.appendChild(actions);
603
746
 
604
747
  body = document.createElement("div");
605
748
  body.className = "html2apk-console-body";
@@ -610,9 +753,6 @@
610
753
  body.appendChild(consoleList);
611
754
  body.appendChild(networkList);
612
755
 
613
- header.appendChild(title);
614
- header.appendChild(tabs);
615
- header.appendChild(actions);
616
756
  panel.appendChild(header);
617
757
  panel.appendChild(body);
618
758
  modal.appendChild(panel);