@zoreal/oauth2-react 0.2.15 → 0.2.16
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.cjs +54 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -19
- package/dist/index.d.ts +0 -19
- package/dist/index.js +57 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -243,25 +243,6 @@ declare function useZorealOAuth(): ZorealOAuthContextProps;
|
|
|
243
243
|
|
|
244
244
|
declare function ZorealLogin(props: ZorealLoginProps): react.JSX.Element;
|
|
245
245
|
|
|
246
|
-
/**
|
|
247
|
-
* The light of the pairing dialog's QR well, run around whatever this wraps
|
|
248
|
-
* while `busy` is true: the well's colours, line, halo and lap, on a dash
|
|
249
|
-
* that travels the outline at one speed whatever the shape.
|
|
250
|
-
*
|
|
251
|
-
* The SDK's own button uses it for the gap on a phone between the tap and the
|
|
252
|
-
* hand-over to the app. A site with its own sign-in button MAY wrap that
|
|
253
|
-
* button the same way: set your busy state on the tap, clear it when
|
|
254
|
-
* `onSuccess` or `onError` fires. `radius` is the wrapped control's corner
|
|
255
|
-
* radius in pixels, so the light follows its shape; `theme` picks the light
|
|
256
|
-
* and dark strengths the dialog uses, following the OS by default.
|
|
257
|
-
*
|
|
258
|
-
* It is a wrapper, and a wrapper is a change to your markup, so know what it
|
|
259
|
-
* does before you use it: it is inline by default and shrinks to the button,
|
|
260
|
-
* so a full-width button needs `block`; the light sits outside the button,
|
|
261
|
-
* so an ancestor with `overflow: hidden` clips it; and a selector that relies
|
|
262
|
-
* on the button's parent (`.card > button`) no longer matches. A site that
|
|
263
|
-
* would rather draw its own busy state needs nothing from here.
|
|
264
|
-
*/
|
|
265
246
|
declare function ZorealBusyRing({ busy, radius, theme, block, className, style, children, }: {
|
|
266
247
|
busy: boolean;
|
|
267
248
|
radius?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -243,25 +243,6 @@ declare function useZorealOAuth(): ZorealOAuthContextProps;
|
|
|
243
243
|
|
|
244
244
|
declare function ZorealLogin(props: ZorealLoginProps): react.JSX.Element;
|
|
245
245
|
|
|
246
|
-
/**
|
|
247
|
-
* The light of the pairing dialog's QR well, run around whatever this wraps
|
|
248
|
-
* while `busy` is true: the well's colours, line, halo and lap, on a dash
|
|
249
|
-
* that travels the outline at one speed whatever the shape.
|
|
250
|
-
*
|
|
251
|
-
* The SDK's own button uses it for the gap on a phone between the tap and the
|
|
252
|
-
* hand-over to the app. A site with its own sign-in button MAY wrap that
|
|
253
|
-
* button the same way: set your busy state on the tap, clear it when
|
|
254
|
-
* `onSuccess` or `onError` fires. `radius` is the wrapped control's corner
|
|
255
|
-
* radius in pixels, so the light follows its shape; `theme` picks the light
|
|
256
|
-
* and dark strengths the dialog uses, following the OS by default.
|
|
257
|
-
*
|
|
258
|
-
* It is a wrapper, and a wrapper is a change to your markup, so know what it
|
|
259
|
-
* does before you use it: it is inline by default and shrinks to the button,
|
|
260
|
-
* so a full-width button needs `block`; the light sits outside the button,
|
|
261
|
-
* so an ancestor with `overflow: hidden` clips it; and a selector that relies
|
|
262
|
-
* on the button's parent (`.card > button`) no longer matches. A site that
|
|
263
|
-
* would rather draw its own busy state needs nothing from here.
|
|
264
|
-
*/
|
|
265
246
|
declare function ZorealBusyRing({ busy, radius, theme, block, className, style, children, }: {
|
|
266
247
|
busy: boolean;
|
|
267
248
|
radius?: number;
|
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.
|
|
8
|
+
var SDK_VERSION = "0.2.16";
|
|
9
9
|
var DEFAULT_ISSUER = "https://id.zoreal.com";
|
|
10
10
|
var POLL_INTERVAL_MS = 2e3;
|
|
11
11
|
var POLL_INTERVAL_ENROLLING_MS = 5e3;
|
|
@@ -1334,10 +1334,15 @@ var CSS = `
|
|
|
1334
1334
|
sides and lights two edges at once near the ends. So here the light is a
|
|
1335
1335
|
dash on an SVG outline, which moves at one speed the whole way round
|
|
1336
1336
|
whatever the shape, drawn with the well's tokens: its colour and head
|
|
1337
|
-
tint, its line width, its halo, its four second lap.
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1337
|
+
tint, its line width, its halo, its four second lap. The outline's length
|
|
1338
|
+
is measured by the component and set as --zrl-ring-len, and every dash
|
|
1339
|
+
and offset is a fraction of it, because pathLength does not scale dash
|
|
1340
|
+
values given from CSS. A stroke cannot fade along its length, so the tail
|
|
1341
|
+
is a stack of dashes sharing one head, each shorter and more opaque than
|
|
1342
|
+
the one under it, with opacities chosen so the stack composes to a
|
|
1343
|
+
straight fade from the head to nothing three tenths of the way back; the
|
|
1344
|
+
component sets each layer's length, offset and opacity. Shown only while
|
|
1345
|
+
busy. */
|
|
1341
1346
|
.${PREFIX}-ring {
|
|
1342
1347
|
position: relative;
|
|
1343
1348
|
display: inline-flex;
|
|
@@ -1356,6 +1361,7 @@ var CSS = `
|
|
|
1356
1361
|
}
|
|
1357
1362
|
.${PREFIX}-ring[data-busy="true"] > .${PREFIX}-ring-svg { opacity: 1; }
|
|
1358
1363
|
.${PREFIX}-ring-svg rect {
|
|
1364
|
+
--zrl-l: var(--zrl-ring-len, 600px);
|
|
1359
1365
|
x: 2px;
|
|
1360
1366
|
y: 2px;
|
|
1361
1367
|
width: calc(100% - 4px);
|
|
@@ -1364,23 +1370,18 @@ var CSS = `
|
|
|
1364
1370
|
stroke: var(--zrl-beam);
|
|
1365
1371
|
stroke-width: var(--zrl-beam-line);
|
|
1366
1372
|
stroke-linecap: round;
|
|
1373
|
+
stroke-dashoffset: var(--zrl-s, 0px);
|
|
1367
1374
|
animation: ${PREFIX}-dash var(--zrl-beam-time) linear infinite;
|
|
1368
1375
|
}
|
|
1369
|
-
.${PREFIX}-ring-
|
|
1370
|
-
.${PREFIX}-ring-body { stroke-dasharray: 16 84; stroke-dashoffset: -14; opacity: 0.8; }
|
|
1371
|
-
.${PREFIX}-ring-head { stroke-dasharray: 5 95; stroke-dashoffset: -25; stroke: var(--zrl-beam-head); }
|
|
1376
|
+
.${PREFIX}-ring-head { stroke: var(--zrl-beam-head); }
|
|
1372
1377
|
.${PREFIX}-ring-halo {
|
|
1373
|
-
stroke-dasharray: 30 70;
|
|
1374
|
-
stroke-dashoffset: 0;
|
|
1375
1378
|
stroke-width: calc(var(--zrl-glow-core) * 2 + var(--zrl-beam-line));
|
|
1376
|
-
opacity: calc(var(--zrl-glow-opacity) * 0.5);
|
|
1377
1379
|
filter: blur(var(--zrl-glow-blur));
|
|
1378
1380
|
}
|
|
1379
1381
|
@keyframes ${PREFIX}-dash {
|
|
1380
|
-
|
|
1382
|
+
from { stroke-dashoffset: var(--zrl-s, 0px); }
|
|
1383
|
+
to { stroke-dashoffset: calc(var(--zrl-s, 0px) - var(--zrl-l)); }
|
|
1381
1384
|
}
|
|
1382
|
-
.${PREFIX}-ring-body { --zrl-dash-start: -14; }
|
|
1383
|
-
.${PREFIX}-ring-head { --zrl-dash-start: -25; }
|
|
1384
1385
|
@media (prefers-reduced-motion: reduce) {
|
|
1385
1386
|
.${PREFIX}-ring-svg rect { animation: none; stroke-dasharray: none; opacity: 0.45; }
|
|
1386
1387
|
.${PREFIX}-ring-halo, .${PREFIX}-ring-head { display: none; }
|
|
@@ -1962,8 +1963,11 @@ function useZorealLogin(options) {
|
|
|
1962
1963
|
}
|
|
1963
1964
|
|
|
1964
1965
|
// src/ring.tsx
|
|
1965
|
-
import { useEffect as useEffect3 } from "react";
|
|
1966
|
+
import { useEffect as useEffect3, useLayoutEffect, useRef as useRef3 } from "react";
|
|
1966
1967
|
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1968
|
+
var TAIL = 0.3;
|
|
1969
|
+
var STACK = Array.from({ length: 12 }, (_, i) => 12 - i);
|
|
1970
|
+
var HALO = [3, 2, 1];
|
|
1967
1971
|
function ZorealBusyRing({
|
|
1968
1972
|
busy,
|
|
1969
1973
|
radius = 8,
|
|
@@ -1976,11 +1980,42 @@ function ZorealBusyRing({
|
|
|
1976
1980
|
useEffect3(() => {
|
|
1977
1981
|
ensureStyles();
|
|
1978
1982
|
}, []);
|
|
1983
|
+
const wrapRef = useRef3(null);
|
|
1984
|
+
const measureRef = useRef3(null);
|
|
1985
|
+
useLayoutEffect(() => {
|
|
1986
|
+
const wrap = wrapRef.current;
|
|
1987
|
+
const rect = measureRef.current;
|
|
1988
|
+
if (!wrap || !rect) return;
|
|
1989
|
+
const measure = () => {
|
|
1990
|
+
const length = rect.getTotalLength();
|
|
1991
|
+
if (length > 0) wrap.style.setProperty("--zrl-ring-len", `${length}px`);
|
|
1992
|
+
};
|
|
1993
|
+
measure();
|
|
1994
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
1995
|
+
const observer = new ResizeObserver(measure);
|
|
1996
|
+
observer.observe(wrap);
|
|
1997
|
+
return () => observer.disconnect();
|
|
1998
|
+
}, [radius]);
|
|
1979
1999
|
const rx = radius + 2;
|
|
1980
|
-
const layer = (name) => /* @__PURE__ */ jsx5(
|
|
2000
|
+
const layer = (key, name, len, alpha, ref) => /* @__PURE__ */ jsx5(
|
|
2001
|
+
"rect",
|
|
2002
|
+
{
|
|
2003
|
+
ref,
|
|
2004
|
+
className: cx(name),
|
|
2005
|
+
rx,
|
|
2006
|
+
ry: rx,
|
|
2007
|
+
style: {
|
|
2008
|
+
strokeDasharray: `calc(var(--zrl-l) * ${len}) calc(var(--zrl-l) * ${1 - len})`,
|
|
2009
|
+
"--zrl-s": `calc(var(--zrl-l) * ${-(TAIL - len)})`,
|
|
2010
|
+
opacity: alpha
|
|
2011
|
+
}
|
|
2012
|
+
},
|
|
2013
|
+
key
|
|
2014
|
+
);
|
|
1981
2015
|
return /* @__PURE__ */ jsxs5(
|
|
1982
2016
|
"span",
|
|
1983
2017
|
{
|
|
2018
|
+
ref: wrapRef,
|
|
1984
2019
|
className: className ? `${cx("root")} ${cx("ring")} ${className}` : `${cx("root")} ${cx("ring")}`,
|
|
1985
2020
|
"data-theme": theme,
|
|
1986
2021
|
"data-busy": busy,
|
|
@@ -1988,10 +2023,10 @@ function ZorealBusyRing({
|
|
|
1988
2023
|
children: [
|
|
1989
2024
|
children,
|
|
1990
2025
|
/* @__PURE__ */ jsxs5("svg", { className: cx("ring-svg"), "aria-hidden": "true", children: [
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
layer("ring-head")
|
|
2026
|
+
HALO.map(
|
|
2027
|
+
(n, i) => layer(`h${n}`, "ring-halo", TAIL * n / HALO.length, `calc(var(--zrl-glow-opacity) * 0.6 / ${n})`, i === 0 ? measureRef : void 0)
|
|
2028
|
+
),
|
|
2029
|
+
STACK.map((n) => layer(`t${n}`, n <= 2 ? "ring-head" : "ring-tail", TAIL * n / STACK.length, String(1 / n)))
|
|
1995
2030
|
] })
|
|
1996
2031
|
]
|
|
1997
2032
|
}
|
|
@@ -2094,7 +2129,7 @@ function ZorealLogin(props) {
|
|
|
2094
2129
|
}
|
|
2095
2130
|
|
|
2096
2131
|
// src/useZorealAutoLogin.ts
|
|
2097
|
-
import { useEffect as useEffect4, useRef as
|
|
2132
|
+
import { useEffect as useEffect4, useRef as useRef4 } from "react";
|
|
2098
2133
|
function useZorealAutoLogin(options) {
|
|
2099
2134
|
const { login } = useZorealFlow({
|
|
2100
2135
|
flow: "browser-direct",
|
|
@@ -2111,7 +2146,7 @@ function useZorealAutoLogin(options) {
|
|
|
2111
2146
|
},
|
|
2112
2147
|
onNonOAuthError: (e) => options.onError?.(e)
|
|
2113
2148
|
});
|
|
2114
|
-
const fired =
|
|
2149
|
+
const fired = useRef4(false);
|
|
2115
2150
|
useEffect4(() => {
|
|
2116
2151
|
if (options.disabled || fired.current) return;
|
|
2117
2152
|
fired.current = true;
|