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/esm/index.js CHANGED
@@ -4391,7 +4391,7 @@ function setupWalletButton({
4391
4391
  }
4392
4392
  const iframe = createIframe({
4393
4393
  iframeUrl: walletUrl || walletConfig[env].walletUrl,
4394
- iframeStyle: { width: "400px", height: "650px" }
4394
+ iframeStyle: isMobile() ? { width: "calc(100% - 40px)", height: "80%" } : { width: "400px", height: "650px" }
4395
4395
  });
4396
4396
  iframe.addEventListener("mouseenter", () => {
4397
4397
  var _a;
@@ -4432,15 +4432,20 @@ function createFloatingButtonWithIframe({
4432
4432
  position: "fixed",
4433
4433
  bottom: `${bottom}px`,
4434
4434
  right: `${right}px`,
4435
- zIndex: "2147483647",
4435
+ zIndex: "100000",
4436
4436
  width: "60px",
4437
4437
  height: "60px",
4438
4438
  cursor: "grab",
4439
4439
  transition: "transform 0.15s ease",
4440
4440
  userSelect: "none",
4441
- touchAction: "none",
4442
- pointerEvents: "auto"
4441
+ touchAction: "none"
4443
4442
  });
4443
+ if (isMobile()) {
4444
+ Object.assign(button.style, {
4445
+ width: "40px",
4446
+ height: "40px"
4447
+ });
4448
+ }
4444
4449
  document.body.appendChild(button);
4445
4450
  updateIframePosition(iframe, right, bottom, windowWidth, windowHeight);
4446
4451
  let isDragging = false;
@@ -4448,71 +4453,86 @@ function createFloatingButtonWithIframe({
4448
4453
  let startY = 0;
4449
4454
  let initialRight = 0;
4450
4455
  let initialBottom = 0;
4451
- let isLongPress = false;
4456
+ let dragStartTime = 0;
4457
+ function startDrag(clientX, clientY) {
4458
+ isDragging = true;
4459
+ startX = clientX;
4460
+ startY = clientY;
4461
+ initialRight = parseInt(button.style.right);
4462
+ initialBottom = parseInt(button.style.bottom);
4463
+ dragStartTime = Date.now();
4464
+ button.style.cursor = "grabbing";
4465
+ button.style.transition = "none";
4466
+ }
4467
+ function toggleWallet() {
4468
+ const isCurrentlyVisible = iframe.style.display === "block";
4469
+ button.style.transform = "scale(0.8)";
4470
+ setTimeout(() => {
4471
+ button.style.transform = "scale(1)";
4472
+ }, 150);
4473
+ const newVisibleState = !isCurrentlyVisible;
4474
+ iframe.style.display = newVisibleState ? "block" : "none";
4475
+ button.src = newVisibleState ? closeImageUrl : openImageUrl;
4476
+ storage4 == null ? void 0 : storage4.set("visible", newVisibleState);
4477
+ setTimeout(() => {
4478
+ if (newVisibleState) {
4479
+ iframe.focus();
4480
+ }
4481
+ }, 0);
4482
+ }
4452
4483
  button.addEventListener(
4453
4484
  "click",
4454
4485
  (e) => {
4455
- if (isLongPress) {
4456
- isLongPress = false;
4457
- return;
4486
+ if (!isDragging) {
4487
+ toggleWallet();
4458
4488
  }
4459
- handleButtonClick();
4460
4489
  e.preventDefault();
4461
4490
  e.stopPropagation();
4462
4491
  },
4463
4492
  { capture: true }
4464
4493
  );
4465
- const handleMouseDown = (e) => {
4466
- startDrag(e.clientX, e.clientY);
4467
- e.preventDefault();
4468
- e.stopPropagation();
4469
- };
4470
- const handleTouchStart = (e) => {
4471
- if (e.touches.length === 1) {
4472
- const touch = e.touches[0];
4473
- startDrag(touch.clientX, touch.clientY);
4494
+ button.addEventListener(
4495
+ "mousedown",
4496
+ (e) => {
4497
+ startDrag(e.clientX, e.clientY);
4474
4498
  e.preventDefault();
4475
4499
  e.stopPropagation();
4476
- }
4477
- };
4478
- button.addEventListener("mousedown", handleMouseDown, { capture: true });
4479
- button.addEventListener("touchstart", handleTouchStart, { capture: true });
4480
- function startDrag(clientX, clientY) {
4481
- isDragging = true;
4482
- startX = clientX;
4483
- startY = clientY;
4484
- initialRight = parseInt(button.style.right);
4485
- initialBottom = parseInt(button.style.bottom);
4486
- button.style.cursor = "grabbing";
4487
- button.style.transition = "none";
4488
- }
4489
- const handleMouseMove = (e) => {
4490
- if (!isDragging)
4491
- return;
4492
- const deltaX = Math.abs(startX - e.clientX);
4493
- const deltaY = Math.abs(startY - e.clientY);
4494
- if (deltaX > 5 || deltaY > 5) {
4495
- isLongPress = true;
4496
- }
4497
- moveButton(e.clientX, e.clientY);
4498
- e.preventDefault();
4499
- e.stopPropagation();
4500
- };
4501
- const handleTouchMove = (e) => {
4502
- if (!isDragging || e.touches.length !== 1)
4503
- return;
4504
- const touch = e.touches[0];
4505
- const deltaX = Math.abs(startX - touch.clientX);
4506
- const deltaY = Math.abs(startY - touch.clientY);
4507
- if (deltaX > 5 || deltaY > 5) {
4508
- isLongPress = true;
4509
- }
4510
- moveButton(touch.clientX, touch.clientY);
4511
- e.preventDefault();
4512
- e.stopPropagation();
4513
- };
4514
- document.addEventListener("mousemove", handleMouseMove, { capture: true });
4515
- document.addEventListener("touchmove", handleTouchMove, { capture: true });
4500
+ },
4501
+ { capture: true }
4502
+ );
4503
+ button.addEventListener(
4504
+ "touchstart",
4505
+ (e) => {
4506
+ if (e.touches.length === 1) {
4507
+ const touch = e.touches[0];
4508
+ startDrag(touch.clientX, touch.clientY);
4509
+ e.preventDefault();
4510
+ e.stopPropagation();
4511
+ }
4512
+ },
4513
+ { capture: true }
4514
+ );
4515
+ document.addEventListener(
4516
+ "mousemove",
4517
+ (e) => {
4518
+ if (!isDragging)
4519
+ return;
4520
+ moveButton(e.clientX, e.clientY);
4521
+ e.preventDefault();
4522
+ },
4523
+ { capture: true }
4524
+ );
4525
+ document.addEventListener(
4526
+ "touchmove",
4527
+ (e) => {
4528
+ if (!isDragging || e.touches.length !== 1)
4529
+ return;
4530
+ const touch = e.touches[0];
4531
+ moveButton(touch.clientX, touch.clientY);
4532
+ e.preventDefault();
4533
+ },
4534
+ { capture: true }
4535
+ );
4516
4536
  function moveButton(clientX, clientY) {
4517
4537
  const deltaX = startX - clientX;
4518
4538
  const deltaY = startY - clientY;
@@ -4536,23 +4556,40 @@ function createFloatingButtonWithIframe({
4536
4556
  button.style.bottom = `${newBottom}px`;
4537
4557
  updateIframePosition(iframe, newRight, newBottom, windowWidth, windowHeight);
4538
4558
  }
4539
- const handleMouseUp = (e) => {
4540
- if (isDragging) {
4541
- e.preventDefault();
4542
- e.stopPropagation();
4543
- }
4544
- endDrag();
4545
- };
4546
- const handleTouchEnd = (e) => {
4547
- if (isDragging) {
4548
- e.preventDefault();
4549
- e.stopPropagation();
4550
- }
4551
- endDrag();
4552
- };
4553
- document.addEventListener("mouseup", handleMouseUp, { capture: true });
4554
- document.addEventListener("touchend", handleTouchEnd, { capture: true });
4555
- document.addEventListener("touchcancel", handleTouchEnd, { capture: true });
4559
+ document.addEventListener(
4560
+ "mouseup",
4561
+ (e) => {
4562
+ if (isDragging) {
4563
+ e.preventDefault();
4564
+ e.stopPropagation();
4565
+ }
4566
+ endDrag();
4567
+ },
4568
+ { capture: true }
4569
+ );
4570
+ document.addEventListener(
4571
+ "touchend",
4572
+ (e) => {
4573
+ if (isDragging) {
4574
+ e.preventDefault();
4575
+ e.stopPropagation();
4576
+ }
4577
+ endDrag();
4578
+ const dragEndTime = Date.now();
4579
+ const dragDuration = dragEndTime - dragStartTime;
4580
+ if (dragDuration < 200 && Math.abs(parseInt(button.style.right) - initialRight) < 5 && Math.abs(parseInt(button.style.bottom) - initialBottom) < 5) {
4581
+ toggleWallet();
4582
+ }
4583
+ },
4584
+ { capture: true }
4585
+ );
4586
+ document.addEventListener(
4587
+ "touchcancel",
4588
+ () => {
4589
+ endDrag();
4590
+ },
4591
+ { capture: true }
4592
+ );
4556
4593
  function endDrag() {
4557
4594
  if (!isDragging)
4558
4595
  return;
@@ -4565,20 +4602,6 @@ function createFloatingButtonWithIframe({
4565
4602
  });
4566
4603
  }
4567
4604
  const handleButtonClick = () => {
4568
- const isCurrentlyVisible = iframe.style.display === "block";
4569
- button.style.transform = "scale(0.8)";
4570
- setTimeout(() => {
4571
- button.style.transform = "scale(1)";
4572
- }, 150);
4573
- const newVisibleState = !isCurrentlyVisible;
4574
- iframe.style.display = newVisibleState ? "block" : "none";
4575
- button.src = newVisibleState ? closeImageUrl : openImageUrl;
4576
- storage4 == null ? void 0 : storage4.set("visible", newVisibleState);
4577
- setTimeout(() => {
4578
- if (newVisibleState) {
4579
- iframe.focus();
4580
- }
4581
- }, 0);
4582
4605
  };
4583
4606
  button.onclick = null;
4584
4607
  return button;
@@ -4597,12 +4620,11 @@ function createIframe({
4597
4620
  position: "fixed",
4598
4621
  bottom: "90px",
4599
4622
  right: "20px",
4600
- zIndex: "2147483646",
4623
+ zIndex: "100000",
4601
4624
  boxShadow: "0 0 10px rgba(0, 0, 0, 0.1)",
4602
4625
  borderRadius: "10px",
4603
4626
  display: isVisible ? "block" : "none",
4604
- border: "none",
4605
- pointerEvents: "auto"
4627
+ border: "none"
4606
4628
  }, iframeStyle));
4607
4629
  document.body.appendChild(iframe);
4608
4630
  return iframe;
@@ -5116,7 +5138,7 @@ function getGroup(state) {
5116
5138
 
5117
5139
  // src/index.ts
5118
5140
  var getVersion = () => {
5119
- return "0.5.58-beta";
5141
+ return "0.5.59-beta";
5120
5142
  };
5121
5143
  if (typeof window !== "undefined") {
5122
5144
  window.__BTC_WALLET_VERSION = getVersion();