@zoreal/oauth2-react 0.2.22 → 0.2.24

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
@@ -5,7 +5,7 @@ import { createContext, useContext, useMemo, useState as useState2 } from "react
5
5
 
6
6
  // src/wire.ts
7
7
  var WIRE_VERSION = 1;
8
- var SDK_VERSION = "0.2.22";
8
+ var SDK_VERSION = "0.2.24";
9
9
  var DEFAULT_ISSUER = "https://id.zoreal.com";
10
10
  var POLL_INTERVAL_MS = 2e3;
11
11
  var POLL_INTERVAL_ENROLLING_MS = 5e3;
@@ -1615,9 +1615,16 @@ var SVG_NS = "http://www.w3.org/2000/svg";
1615
1615
  var TAIL = 0.3;
1616
1616
  var STACK = Array.from({ length: 12 }, (_, i) => 12 - i);
1617
1617
  var HALO = [3, 2, 1];
1618
- function radiusOf(control) {
1619
- const value = parseFloat(getComputedStyle(control).borderTopLeftRadius);
1620
- return Number.isFinite(value) ? value : 8;
1618
+ function cornerOf(radius, width, height) {
1619
+ const raw = radius.trim();
1620
+ const value = parseFloat(raw);
1621
+ const offset = 2;
1622
+ if (raw.endsWith("%") && Number.isFinite(value)) {
1623
+ return [width * value / 100 + offset, height * value / 100 + offset];
1624
+ }
1625
+ const px = Number.isFinite(value) ? value : /infinity/i.test(raw) ? Infinity : 8;
1626
+ const r = Math.min(px, width / 2, height / 2) + offset;
1627
+ return [r, r];
1621
1628
  }
1622
1629
  function holdBusy(control) {
1623
1630
  if (typeof document === "undefined") return () => {
@@ -1638,12 +1645,11 @@ function holdBusy(control) {
1638
1645
  overlay.setAttribute("aria-hidden", "true");
1639
1646
  const svg = document.createElementNS(SVG_NS, "svg");
1640
1647
  svg.setAttribute("class", cx("ring-svg"));
1641
- const rx = radiusOf(control) + 2;
1648
+ const rects = [];
1642
1649
  const layer = (name, len, alpha) => {
1643
1650
  const rect = document.createElementNS(SVG_NS, "rect");
1644
1651
  rect.setAttribute("class", cx(name));
1645
- rect.setAttribute("rx", String(rx));
1646
- rect.setAttribute("ry", String(rx));
1652
+ rects.push(rect);
1647
1653
  rect.style.strokeDasharray = `calc(var(--zrl-l) * ${len}) calc(var(--zrl-l) * ${1 - len})`;
1648
1654
  rect.style.setProperty("--zrl-s", `calc(var(--zrl-l) * ${-(TAIL - len)})`);
1649
1655
  rect.style.opacity = alpha;
@@ -1666,6 +1672,11 @@ function holdBusy(control) {
1666
1672
  overlay.style.top = `${box.top}px`;
1667
1673
  overlay.style.width = `${box.width}px`;
1668
1674
  overlay.style.height = `${box.height}px`;
1675
+ const [rx, ry] = cornerOf(getComputedStyle(control).borderTopLeftRadius, box.width, box.height);
1676
+ for (const rect of rects) {
1677
+ rect.setAttribute("rx", String(rx));
1678
+ rect.setAttribute("ry", String(ry));
1679
+ }
1669
1680
  const length = typeof measured?.getTotalLength === "function" ? measured.getTotalLength() : 0;
1670
1681
  if (length > 0) overlay.style.setProperty("--zrl-ring-len", `${length}px`);
1671
1682
  };
@@ -1749,6 +1760,30 @@ function markReturnDone(requestId) {
1749
1760
  function isReturnDone(requestId) {
1750
1761
  return storage()?.getItem(DONE + requestId) !== null && storage()?.getItem(DONE + requestId) !== void 0;
1751
1762
  }
1763
+ function visibleOrDone(requestId, signal) {
1764
+ if (typeof document === "undefined" || document.visibilityState !== "hidden") {
1765
+ return Promise.resolve(!isReturnDone(requestId));
1766
+ }
1767
+ return new Promise((resolve) => {
1768
+ const finish = (value) => {
1769
+ document.removeEventListener("visibilitychange", onVisible);
1770
+ window.removeEventListener("storage", onStorage);
1771
+ signal?.removeEventListener("abort", onAbort);
1772
+ resolve(value);
1773
+ };
1774
+ const onVisible = () => {
1775
+ if (document.visibilityState !== "hidden") finish(!isReturnDone(requestId));
1776
+ };
1777
+ const onStorage = () => {
1778
+ if (isReturnDone(requestId)) finish(false);
1779
+ };
1780
+ const onAbort = () => finish(false);
1781
+ document.addEventListener("visibilitychange", onVisible);
1782
+ window.addEventListener("storage", onStorage);
1783
+ signal?.addEventListener("abort", onAbort, { once: true });
1784
+ if (isReturnDone(requestId)) finish(false);
1785
+ });
1786
+ }
1752
1787
  function returnToUrl() {
1753
1788
  if (typeof window === "undefined") return void 0;
1754
1789
  const { href } = window.location;
@@ -2311,7 +2346,7 @@ function useZorealFlow(options) {
2311
2346
  controller.signal,
2312
2347
  { tolerateUnknownUntil: Date.now() + 15e3 }
2313
2348
  );
2314
- if (isReturnDone(requestId)) {
2349
+ if (!await visibleOrDone(requestId, controller.signal)) {
2315
2350
  throw new DOMException("aborted", "AbortError");
2316
2351
  }
2317
2352
  } else {