@wowlabtech/mini-app-adapter 0.2.83 → 0.2.84

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.
package/README.md CHANGED
@@ -52,7 +52,7 @@ bootstrap();
52
52
  import { createAdapter } from '@wowlabtech/mini-app-adapter';
53
53
 
54
54
  const adapter = createAdapter('telegram');
55
- await adapter.init({ eruda: true });
55
+ await adapter.init({ eruda: true }); // сработает, только если host заранее положил eruda в window.eruda
56
56
 
57
57
  adapter.setColors({ header: '#0a0a0a', background: '#ffffff' });
58
58
  adapter.onBackButton(() => adapter.closeApp());
package/dist/index.cjs CHANGED
@@ -1219,11 +1219,9 @@ var TelegramMiniAppAdapter = class extends BaseMiniAppAdapter {
1219
1219
  if (!import_sdk_react.miniApp.isSupported()) {
1220
1220
  console.warn("[tvm-app-adapter] miniApp feature is not supported; falling back to limited mode.");
1221
1221
  }
1222
- if (eruda) {
1223
- void import("eruda").then(({ default: erudaInstance }) => {
1224
- erudaInstance.init();
1225
- erudaInstance.position({ x: window.innerWidth - 150, y: window.innerHeight - 150 });
1226
- });
1222
+ if (eruda && typeof window !== "undefined" && window.eruda) {
1223
+ window.eruda.init();
1224
+ window.eruda.position({ x: window.innerWidth - 150, y: window.innerHeight - 150 });
1227
1225
  }
1228
1226
  if (mockForMacOS) {
1229
1227
  let firstThemeSent = false;
@@ -2680,6 +2678,9 @@ var WebMiniAppAdapter = class extends BaseMiniAppAdapter {
2680
2678
  overlay.style.flexDirection = "column";
2681
2679
  overlay.style.alignItems = "center";
2682
2680
  overlay.style.justifyContent = "center";
2681
+ overlay.style.gap = "20px";
2682
+ overlay.style.padding = "24px";
2683
+ overlay.style.boxSizing = "border-box";
2683
2684
  overlay.style.overflow = "hidden";
2684
2685
  overlay.style.backdropFilter = "blur(3px)";
2685
2686
  document.body.appendChild(overlay);
@@ -2753,10 +2754,23 @@ var WebMiniAppAdapter = class extends BaseMiniAppAdapter {
2753
2754
  const hint = document.createElement("div");
2754
2755
  hint.innerText = "\u041D\u0430\u0432\u0435\u0434\u0438\u0442\u0435 \u043A\u0430\u043C\u0435\u0440\u0443 \u043D\u0430 QR-\u043A\u043E\u0434";
2755
2756
  hint.style.color = "white";
2756
- hint.style.marginTop = "30px";
2757
2757
  hint.style.fontSize = "17px";
2758
2758
  hint.style.opacity = "0.9";
2759
2759
  overlay.appendChild(hint);
2760
+ const bottomCloseBtn = document.createElement("button");
2761
+ bottomCloseBtn.innerText = "\u0417\u0430\u043A\u0440\u044B\u0442\u044C";
2762
+ bottomCloseBtn.style.minWidth = `${Math.min(scanSize, 220)}px`;
2763
+ bottomCloseBtn.style.height = "48px";
2764
+ bottomCloseBtn.style.padding = "0 20px";
2765
+ bottomCloseBtn.style.border = "1px solid rgba(255,255,255,0.24)";
2766
+ bottomCloseBtn.style.borderRadius = "14px";
2767
+ bottomCloseBtn.style.background = "rgba(255,255,255,0.12)";
2768
+ bottomCloseBtn.style.color = "white";
2769
+ bottomCloseBtn.style.fontSize = "16px";
2770
+ bottomCloseBtn.style.fontWeight = "600";
2771
+ bottomCloseBtn.style.cursor = "pointer";
2772
+ bottomCloseBtn.style.backdropFilter = "blur(8px)";
2773
+ overlay.appendChild(bottomCloseBtn);
2760
2774
  const canvas = document.createElement("canvas");
2761
2775
  const context = canvas.getContext("2d", { willReadFrequently: true });
2762
2776
  let stream = null;
@@ -2794,10 +2808,26 @@ var WebMiniAppAdapter = class extends BaseMiniAppAdapter {
2794
2808
  removeFromBag();
2795
2809
  };
2796
2810
  closeBtn.onclick = () => closeScanner(null);
2811
+ bottomCloseBtn.onclick = () => closeScanner(null);
2797
2812
  try {
2798
2813
  const constraints = [
2799
- { video: { facingMode: { ideal: "environment" } }, audio: false },
2800
- { video: { facingMode: "environment" }, audio: false },
2814
+ {
2815
+ video: {
2816
+ facingMode: { ideal: "environment" },
2817
+ width: { ideal: 1920 },
2818
+ height: { ideal: 1080 },
2819
+ aspectRatio: { ideal: 1.7777777778 }
2820
+ },
2821
+ audio: false
2822
+ },
2823
+ {
2824
+ video: {
2825
+ facingMode: "environment",
2826
+ width: { ideal: 1280 },
2827
+ height: { ideal: 720 }
2828
+ },
2829
+ audio: false
2830
+ },
2801
2831
  { video: true, audio: false }
2802
2832
  ];
2803
2833
  let lastError = null;
@@ -2812,13 +2842,27 @@ var WebMiniAppAdapter = class extends BaseMiniAppAdapter {
2812
2842
  if (!stream) {
2813
2843
  throw lastError instanceof Error ? lastError : new Error("Unable to access camera");
2814
2844
  }
2845
+ const [videoTrack] = stream.getVideoTracks();
2846
+ if (videoTrack) {
2847
+ try {
2848
+ const advancedConstraints = [
2849
+ { focusMode: "continuous" },
2850
+ { exposureMode: "continuous" },
2851
+ { whiteBalanceMode: "continuous" }
2852
+ ];
2853
+ await videoTrack.applyConstraints({
2854
+ advanced: advancedConstraints
2855
+ });
2856
+ } catch {
2857
+ }
2858
+ }
2815
2859
  video.srcObject = stream;
2816
2860
  await video.play();
2817
2861
  const scanFrame = (now) => {
2818
2862
  if (closed) {
2819
2863
  return;
2820
2864
  }
2821
- if (now - lastScanAt >= 100 && context && video.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA) {
2865
+ if (now - lastScanAt >= 80 && context && video.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA) {
2822
2866
  const width = video.videoWidth;
2823
2867
  const height = video.videoHeight;
2824
2868
  if (width > 0 && height > 0) {