btc-wallet 0.5.58-beta → 0.5.59-beta

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/dist/index.js CHANGED
@@ -4461,7 +4461,7 @@ function setupWalletButton({
4461
4461
  }
4462
4462
  const iframe = createIframe({
4463
4463
  iframeUrl: walletUrl || walletConfig[env].walletUrl,
4464
- iframeStyle: { width: "400px", height: "650px" }
4464
+ iframeStyle: isMobile() ? { width: "calc(100% - 40px)", height: "80%" } : { width: "400px", height: "650px" }
4465
4465
  });
4466
4466
  iframe.addEventListener("mouseenter", () => {
4467
4467
  var _a;
@@ -4502,15 +4502,20 @@ function createFloatingButtonWithIframe({
4502
4502
  position: "fixed",
4503
4503
  bottom: `${bottom}px`,
4504
4504
  right: `${right}px`,
4505
- zIndex: "2147483647",
4505
+ zIndex: "100000",
4506
4506
  width: "60px",
4507
4507
  height: "60px",
4508
4508
  cursor: "grab",
4509
4509
  transition: "transform 0.15s ease",
4510
4510
  userSelect: "none",
4511
- touchAction: "none",
4512
- pointerEvents: "auto"
4511
+ touchAction: "none"
4513
4512
  });
4513
+ if (isMobile()) {
4514
+ Object.assign(button.style, {
4515
+ width: "40px",
4516
+ height: "40px"
4517
+ });
4518
+ }
4514
4519
  document.body.appendChild(button);
4515
4520
  updateIframePosition(iframe, right, bottom, windowWidth, windowHeight);
4516
4521
  let isDragging = false;
@@ -4518,71 +4523,86 @@ function createFloatingButtonWithIframe({
4518
4523
  let startY = 0;
4519
4524
  let initialRight = 0;
4520
4525
  let initialBottom = 0;
4521
- let isLongPress = false;
4526
+ let dragStartTime = 0;
4527
+ function startDrag(clientX, clientY) {
4528
+ isDragging = true;
4529
+ startX = clientX;
4530
+ startY = clientY;
4531
+ initialRight = parseInt(button.style.right);
4532
+ initialBottom = parseInt(button.style.bottom);
4533
+ dragStartTime = Date.now();
4534
+ button.style.cursor = "grabbing";
4535
+ button.style.transition = "none";
4536
+ }
4537
+ function toggleWallet() {
4538
+ const isCurrentlyVisible = iframe.style.display === "block";
4539
+ button.style.transform = "scale(0.8)";
4540
+ setTimeout(() => {
4541
+ button.style.transform = "scale(1)";
4542
+ }, 150);
4543
+ const newVisibleState = !isCurrentlyVisible;
4544
+ iframe.style.display = newVisibleState ? "block" : "none";
4545
+ button.src = newVisibleState ? closeImageUrl : openImageUrl;
4546
+ storage4 == null ? void 0 : storage4.set("visible", newVisibleState);
4547
+ setTimeout(() => {
4548
+ if (newVisibleState) {
4549
+ iframe.focus();
4550
+ }
4551
+ }, 0);
4552
+ }
4522
4553
  button.addEventListener(
4523
4554
  "click",
4524
4555
  (e) => {
4525
- if (isLongPress) {
4526
- isLongPress = false;
4527
- return;
4556
+ if (!isDragging) {
4557
+ toggleWallet();
4528
4558
  }
4529
- handleButtonClick();
4530
4559
  e.preventDefault();
4531
4560
  e.stopPropagation();
4532
4561
  },
4533
4562
  { capture: true }
4534
4563
  );
4535
- const handleMouseDown = (e) => {
4536
- startDrag(e.clientX, e.clientY);
4537
- e.preventDefault();
4538
- e.stopPropagation();
4539
- };
4540
- const handleTouchStart = (e) => {
4541
- if (e.touches.length === 1) {
4542
- const touch = e.touches[0];
4543
- startDrag(touch.clientX, touch.clientY);
4564
+ button.addEventListener(
4565
+ "mousedown",
4566
+ (e) => {
4567
+ startDrag(e.clientX, e.clientY);
4544
4568
  e.preventDefault();
4545
4569
  e.stopPropagation();
4546
- }
4547
- };
4548
- button.addEventListener("mousedown", handleMouseDown, { capture: true });
4549
- button.addEventListener("touchstart", handleTouchStart, { capture: true });
4550
- function startDrag(clientX, clientY) {
4551
- isDragging = true;
4552
- startX = clientX;
4553
- startY = clientY;
4554
- initialRight = parseInt(button.style.right);
4555
- initialBottom = parseInt(button.style.bottom);
4556
- button.style.cursor = "grabbing";
4557
- button.style.transition = "none";
4558
- }
4559
- const handleMouseMove = (e) => {
4560
- if (!isDragging)
4561
- return;
4562
- const deltaX = Math.abs(startX - e.clientX);
4563
- const deltaY = Math.abs(startY - e.clientY);
4564
- if (deltaX > 5 || deltaY > 5) {
4565
- isLongPress = true;
4566
- }
4567
- moveButton(e.clientX, e.clientY);
4568
- e.preventDefault();
4569
- e.stopPropagation();
4570
- };
4571
- const handleTouchMove = (e) => {
4572
- if (!isDragging || e.touches.length !== 1)
4573
- return;
4574
- const touch = e.touches[0];
4575
- const deltaX = Math.abs(startX - touch.clientX);
4576
- const deltaY = Math.abs(startY - touch.clientY);
4577
- if (deltaX > 5 || deltaY > 5) {
4578
- isLongPress = true;
4579
- }
4580
- moveButton(touch.clientX, touch.clientY);
4581
- e.preventDefault();
4582
- e.stopPropagation();
4583
- };
4584
- document.addEventListener("mousemove", handleMouseMove, { capture: true });
4585
- document.addEventListener("touchmove", handleTouchMove, { capture: true });
4570
+ },
4571
+ { capture: true }
4572
+ );
4573
+ button.addEventListener(
4574
+ "touchstart",
4575
+ (e) => {
4576
+ if (e.touches.length === 1) {
4577
+ const touch = e.touches[0];
4578
+ startDrag(touch.clientX, touch.clientY);
4579
+ e.preventDefault();
4580
+ e.stopPropagation();
4581
+ }
4582
+ },
4583
+ { capture: true }
4584
+ );
4585
+ document.addEventListener(
4586
+ "mousemove",
4587
+ (e) => {
4588
+ if (!isDragging)
4589
+ return;
4590
+ moveButton(e.clientX, e.clientY);
4591
+ e.preventDefault();
4592
+ },
4593
+ { capture: true }
4594
+ );
4595
+ document.addEventListener(
4596
+ "touchmove",
4597
+ (e) => {
4598
+ if (!isDragging || e.touches.length !== 1)
4599
+ return;
4600
+ const touch = e.touches[0];
4601
+ moveButton(touch.clientX, touch.clientY);
4602
+ e.preventDefault();
4603
+ },
4604
+ { capture: true }
4605
+ );
4586
4606
  function moveButton(clientX, clientY) {
4587
4607
  const deltaX = startX - clientX;
4588
4608
  const deltaY = startY - clientY;
@@ -4606,23 +4626,40 @@ function createFloatingButtonWithIframe({
4606
4626
  button.style.bottom = `${newBottom}px`;
4607
4627
  updateIframePosition(iframe, newRight, newBottom, windowWidth, windowHeight);
4608
4628
  }
4609
- const handleMouseUp = (e) => {
4610
- if (isDragging) {
4611
- e.preventDefault();
4612
- e.stopPropagation();
4613
- }
4614
- endDrag();
4615
- };
4616
- const handleTouchEnd = (e) => {
4617
- if (isDragging) {
4618
- e.preventDefault();
4619
- e.stopPropagation();
4620
- }
4621
- endDrag();
4622
- };
4623
- document.addEventListener("mouseup", handleMouseUp, { capture: true });
4624
- document.addEventListener("touchend", handleTouchEnd, { capture: true });
4625
- document.addEventListener("touchcancel", handleTouchEnd, { capture: true });
4629
+ document.addEventListener(
4630
+ "mouseup",
4631
+ (e) => {
4632
+ if (isDragging) {
4633
+ e.preventDefault();
4634
+ e.stopPropagation();
4635
+ }
4636
+ endDrag();
4637
+ },
4638
+ { capture: true }
4639
+ );
4640
+ document.addEventListener(
4641
+ "touchend",
4642
+ (e) => {
4643
+ if (isDragging) {
4644
+ e.preventDefault();
4645
+ e.stopPropagation();
4646
+ }
4647
+ endDrag();
4648
+ const dragEndTime = Date.now();
4649
+ const dragDuration = dragEndTime - dragStartTime;
4650
+ if (dragDuration < 200 && Math.abs(parseInt(button.style.right) - initialRight) < 5 && Math.abs(parseInt(button.style.bottom) - initialBottom) < 5) {
4651
+ toggleWallet();
4652
+ }
4653
+ },
4654
+ { capture: true }
4655
+ );
4656
+ document.addEventListener(
4657
+ "touchcancel",
4658
+ () => {
4659
+ endDrag();
4660
+ },
4661
+ { capture: true }
4662
+ );
4626
4663
  function endDrag() {
4627
4664
  if (!isDragging)
4628
4665
  return;
@@ -4635,20 +4672,6 @@ function createFloatingButtonWithIframe({
4635
4672
  });
4636
4673
  }
4637
4674
  const handleButtonClick = () => {
4638
- const isCurrentlyVisible = iframe.style.display === "block";
4639
- button.style.transform = "scale(0.8)";
4640
- setTimeout(() => {
4641
- button.style.transform = "scale(1)";
4642
- }, 150);
4643
- const newVisibleState = !isCurrentlyVisible;
4644
- iframe.style.display = newVisibleState ? "block" : "none";
4645
- button.src = newVisibleState ? closeImageUrl : openImageUrl;
4646
- storage4 == null ? void 0 : storage4.set("visible", newVisibleState);
4647
- setTimeout(() => {
4648
- if (newVisibleState) {
4649
- iframe.focus();
4650
- }
4651
- }, 0);
4652
4675
  };
4653
4676
  button.onclick = null;
4654
4677
  return button;
@@ -4667,12 +4690,11 @@ function createIframe({
4667
4690
  position: "fixed",
4668
4691
  bottom: "90px",
4669
4692
  right: "20px",
4670
- zIndex: "2147483646",
4693
+ zIndex: "100000",
4671
4694
  boxShadow: "0 0 10px rgba(0, 0, 0, 0.1)",
4672
4695
  borderRadius: "10px",
4673
4696
  display: isVisible ? "block" : "none",
4674
- border: "none",
4675
- pointerEvents: "auto"
4697
+ border: "none"
4676
4698
  }, iframeStyle));
4677
4699
  document.body.appendChild(iframe);
4678
4700
  return iframe;
@@ -5184,7 +5206,7 @@ function getGroup(state) {
5184
5206
 
5185
5207
  // src/index.ts
5186
5208
  var getVersion = () => {
5187
- return "0.5.58-beta";
5209
+ return "0.5.59-beta";
5188
5210
  };
5189
5211
  if (typeof window !== "undefined") {
5190
5212
  window.__BTC_WALLET_VERSION = getVersion();