@ikonai/sdk-react-ui 1.3.2 → 1.3.3

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.
@@ -26,6 +26,12 @@ export declare function hasPendingOAuthContinuation(): boolean;
26
26
  /**
27
27
  * Report the completed sign-in and hand the browser to the consent screen.
28
28
  *
29
+ * The token is passed in rather than read from storage. A signed-in browser does not necessarily have
30
+ * one there: a session backed by a refresh cookie is held in memory and its localStorage record is
31
+ * deliberately REMOVED, so reading storage returned null for a fully signed-in user and the handoff
32
+ * waited for a session that was never going to appear. The auth context holds the live token either
33
+ * way, so it is the only source that is right for both.
34
+ *
29
35
  * Only ever called after a REAL sign-in — `useAuthGuard` treats an anonymous session as not satisfying a
30
36
  * prompt, which is the guest/global exclusion this flow needs and already had. A `global` visitor is one
31
37
  * shared space-wide user, so authorizing as one would hand every client the same identity.
@@ -33,4 +39,4 @@ export declare function hasPendingOAuthContinuation(): boolean;
33
39
  * Failure clears the pointer and returns false: the app then carries on as a normally signed-in session
34
40
  * rather than trapping the user in a flow that cannot finish.
35
41
  */
36
- export declare function completeOAuthContinuation(): Promise<boolean>;
42
+ export declare function completeOAuthContinuation(token: string | null): Promise<boolean>;
package/index.js CHANGED
@@ -3395,55 +3395,67 @@ function ti() {
3395
3395
  }
3396
3396
  //#endregion
3397
3397
  //#region src/auth/oauth-continuation.ts
3398
- var ni = "ikon-oauth", ri = "ikon-oauth-continue";
3399
- function ii() {
3398
+ var ni = "ikon-oauth", ri = "ikon-oauth-continue", ii = "ikon-oauth-continue-attempts", ai = 5, oi = 6e5;
3399
+ function si() {
3400
3400
  if (typeof window > "u") return !1;
3401
3401
  let e = new URL(window.location.href).searchParams.get(ni);
3402
- return e ? (li(e), !0) : ci() !== null;
3402
+ return e ? (pi(e), !0) : fi() !== null;
3403
3403
  }
3404
- function ai() {
3405
- return oi() !== null;
3404
+ function ci() {
3405
+ return li() !== null;
3406
3406
  }
3407
- function oi() {
3408
- return typeof window > "u" ? null : new URL(window.location.href).searchParams.get("ikon-oauth") ?? ci();
3407
+ function li() {
3408
+ return typeof window > "u" ? null : new URL(window.location.href).searchParams.get("ikon-oauth") ?? fi();
3409
3409
  }
3410
- async function si() {
3411
- let e = oi();
3412
- if (!e) return !1;
3413
- ui();
3410
+ async function ui(e) {
3411
+ let t = li();
3412
+ if (!t) return !1;
3413
+ if (!e) return di() < ai ? (console.warn("[ikon] Waiting for the signed-in session before continuing the authorization that sent you here."), !1) : (mi(), console.warn("[ikon] Gave up continuing the authorization that sent you here: no signed-in session became readable. Start the connection again from the application."), !1);
3414
3414
  try {
3415
- let t = rr();
3416
- if (!t?.token) return !1;
3417
3415
  let n = await fetch("/ikon/oauth/continue", {
3418
3416
  method: "POST",
3419
3417
  headers: {
3420
3418
  "content-type": "application/json",
3421
- authorization: `Bearer ${t.token}`
3419
+ authorization: `Bearer ${e}`
3422
3420
  },
3423
- body: JSON.stringify({ continueId: e })
3421
+ body: JSON.stringify({ continueId: t })
3424
3422
  });
3425
- if (!n.ok) return !1;
3423
+ if (!n.ok) return mi(), console.warn(`[ikon] Could not continue the authorization that sent you here (${n.status}). Start the connection again from the application.`), !1;
3426
3424
  let { consentUrl: r } = await n.json();
3427
- return r ? (window.location.href = r, !0) : !1;
3425
+ return r ? (mi(), window.location.href = r, !0) : (mi(), console.warn("[ikon] The authorization that sent you here returned no consent step. Start the connection again from the application."), !1);
3428
3426
  } catch {
3429
3427
  return !1;
3430
3428
  }
3431
3429
  }
3432
- function ci() {
3430
+ function di() {
3433
3431
  try {
3434
- return sessionStorage.getItem(ri);
3432
+ let e = Number(sessionStorage.getItem(ii) ?? "0") + 1;
3433
+ return sessionStorage.setItem(ii, String(e)), e;
3435
3434
  } catch {
3436
- return null;
3435
+ return ai;
3436
+ }
3437
+ }
3438
+ function fi() {
3439
+ try {
3440
+ let e = sessionStorage.getItem(ri);
3441
+ if (!e) return null;
3442
+ let { id: t, at: n } = JSON.parse(e);
3443
+ return !t || Date.now() - n > oi ? (mi(), null) : t;
3444
+ } catch {
3445
+ return mi(), null;
3437
3446
  }
3438
3447
  }
3439
- function li(e) {
3448
+ function pi(e) {
3440
3449
  try {
3441
- sessionStorage.setItem(ri, e);
3450
+ sessionStorage.setItem(ri, JSON.stringify({
3451
+ id: e,
3452
+ at: Date.now()
3453
+ }));
3442
3454
  } catch {}
3443
3455
  }
3444
- function ui() {
3456
+ function mi() {
3445
3457
  try {
3446
- sessionStorage.removeItem(ri);
3458
+ sessionStorage.removeItem(ri), sessionStorage.removeItem(ii);
3447
3459
  } catch {}
3448
3460
  try {
3449
3461
  let e = new URL(window.location.href);
@@ -3452,25 +3464,36 @@ function ui() {
3452
3464
  }
3453
3465
  //#endregion
3454
3466
  //#region src/auth/use-auth-guard.ts
3455
- function di(e) {
3456
- let { config: t, guestUrlParam: n } = e, { state: r, login: i } = ei(), a = j(!1), o = N(de, re, re), s = o.required;
3467
+ function hi(e) {
3468
+ let { config: t, guestUrlParam: n } = e, { state: r, login: i, getToken: a } = ei(), o = j(!1), s = j(!1), c = N(de, re, re), l = c.required;
3457
3469
  k(() => {
3458
- ii() && ue("An application is asking to act as you. Sign in to review what it wants.");
3470
+ si() && ue("An application is asking to act as you. Sign in to review what it wants.");
3459
3471
  }, []), k(() => {
3460
- s && r.isAuthenticated && r.user && r.user.provider !== "anonymous" && (_(), ai() && si());
3472
+ if (!(!l || !r.isAuthenticated || !r.user || r.user.provider === "anonymous")) {
3473
+ if (!ci()) {
3474
+ _();
3475
+ return;
3476
+ }
3477
+ s.current || (s.current = !0, ui(a()).then((e) => {
3478
+ e && _();
3479
+ }).finally(() => {
3480
+ s.current = !1;
3481
+ }));
3482
+ }
3461
3483
  }, [
3462
- s,
3484
+ l,
3463
3485
  r.isAuthenticated,
3464
- r.user
3486
+ r.user,
3487
+ a
3465
3488
  ]), k(() => {
3466
- if (!n || r.isAuthenticated || r.isLoading || a.current) return;
3489
+ if (!n || r.isAuthenticated || r.isLoading || o.current) return;
3467
3490
  let e = t.methods.includes("global") ? "global" : t.methods.includes("guest") ? "guest" : null;
3468
3491
  if (!e) return;
3469
- let o = new URLSearchParams(window.location.search), s = o.get(n);
3492
+ let a = new URLSearchParams(window.location.search), s = a.get(n);
3470
3493
  if (s === "true" || s === "1" || s === "" || Er()) {
3471
- o.delete(n);
3472
- let t = o.toString(), r = window.location.pathname + (t ? `?${t}` : "");
3473
- window.history.replaceState({}, "", r), a.current = !0, i(e);
3494
+ a.delete(n);
3495
+ let t = a.toString(), r = window.location.pathname + (t ? `?${t}` : "");
3496
+ window.history.replaceState({}, "", r), o.current = !0, i(e);
3474
3497
  }
3475
3498
  }, [
3476
3499
  n,
@@ -3479,30 +3502,30 @@ function di(e) {
3479
3502
  t.methods,
3480
3503
  i
3481
3504
  ]);
3482
- let c = t.methods.includes("guest") || t.methods.includes("global"), l = r.isAuthenticated && (c || r.user?.provider !== "anonymous"), u = !!t.requireSignIn && !l;
3505
+ let u = t.methods.includes("guest") || t.methods.includes("global"), d = r.isAuthenticated && (u || r.user?.provider !== "anonymous"), f = !!t.requireSignIn && !d;
3483
3506
  return {
3484
- shouldRenderChildren: !u && !s,
3507
+ shouldRenderChildren: !f && !l,
3485
3508
  isCheckingAuth: r.isLoading,
3486
3509
  isAuthenticated: r.isAuthenticated,
3487
3510
  error: r.error,
3488
- isLoginPrompt: s && !u,
3511
+ isLoginPrompt: l && !f,
3489
3512
  dismissLoginPrompt: _,
3490
- loginPromptReason: s ? o.reason : null
3513
+ loginPromptReason: l ? c.reason : null
3491
3514
  };
3492
3515
  }
3493
3516
  //#endregion
3494
3517
  //#region src/debug/debug-overlay.tsx
3495
- var fi = (() => {
3518
+ var gi = (() => {
3496
3519
  try {
3497
3520
  return te();
3498
3521
  } catch {
3499
3522
  return !1;
3500
3523
  }
3501
- })(), pi = Date.now(), $ = [], mi = 300;
3502
- function hi(e) {
3503
- $.push(`[+${((Date.now() - pi) / 1e3).toFixed(1)}s] ${e}`), $.length > mi && $.shift();
3524
+ })(), _i = Date.now(), $ = [], vi = 300;
3525
+ function yi(e) {
3526
+ $.push(`[+${((Date.now() - _i) / 1e3).toFixed(1)}s] ${e}`), $.length > vi && $.shift();
3504
3527
  }
3505
- function gi(e) {
3528
+ function bi(e) {
3506
3529
  if (typeof e == "string") return e;
3507
3530
  if (e instanceof Error) return `${e.name}: ${e.message}`;
3508
3531
  try {
@@ -3511,10 +3534,10 @@ function gi(e) {
3511
3534
  return String(e);
3512
3535
  }
3513
3536
  }
3514
- var _i = !1;
3515
- function vi() {
3516
- if (_i || typeof window > "u") return;
3517
- _i = !0, window.addEventListener("error", (e) => hi(`window.error: ${e.message} @ ${e.filename ?? "?"}:${e.lineno ?? "?"}:${e.colno ?? "?"}`)), window.addEventListener("unhandledrejection", (e) => hi(`unhandledRejection: ${gi(e.reason)}`));
3537
+ var xi = !1;
3538
+ function Si() {
3539
+ if (xi || typeof window > "u") return;
3540
+ xi = !0, window.addEventListener("error", (e) => yi(`window.error: ${e.message} @ ${e.filename ?? "?"}:${e.lineno ?? "?"}:${e.colno ?? "?"}`)), window.addEventListener("unhandledrejection", (e) => yi(`unhandledRejection: ${bi(e.reason)}`));
3518
3541
  let e = console;
3519
3542
  for (let t of [
3520
3543
  "error",
@@ -3525,17 +3548,17 @@ function vi() {
3525
3548
  let n = e[t]?.bind(console) ?? (() => void 0);
3526
3549
  e[t] = (...e) => {
3527
3550
  try {
3528
- hi(`console.${t}: ${e.map(gi).join(" ")}`);
3551
+ yi(`console.${t}: ${e.map(bi).join(" ")}`);
3529
3552
  } catch {}
3530
3553
  n(...e);
3531
3554
  };
3532
3555
  }
3533
3556
  try {
3534
- fe((e) => hi(`${e.levelName} [${e.component}] ${e.message}`), { minLevel: d.DEBUG });
3557
+ fe((e) => yi(`${e.levelName} [${e.component}] ${e.message}`), { minLevel: d.DEBUG });
3535
3558
  } catch {}
3536
3559
  }
3537
- fi && vi();
3538
- function yi() {
3560
+ gi && Si();
3561
+ function Ci() {
3539
3562
  let e = !1;
3540
3563
  try {
3541
3564
  let t = URL.createObjectURL(new Blob([""]));
@@ -3545,11 +3568,11 @@ function yi() {
3545
3568
  } catch {}
3546
3569
  return e;
3547
3570
  }
3548
- function bi() {
3571
+ function wi() {
3549
3572
  let e = globalThis;
3550
3573
  return [
3551
3574
  `Worker=${typeof Worker < "u"}`,
3552
- `moduleWorker=${yi()}`,
3575
+ `moduleWorker=${Ci()}`,
3553
3576
  `WebSocket=${typeof WebSocket < "u"}`,
3554
3577
  `WebTransport=${e.WebTransport !== void 0}`,
3555
3578
  `RTCPeerConnection=${typeof RTCPeerConnection < "u"}`,
@@ -3562,14 +3585,14 @@ function bi() {
3562
3585
  `online=${typeof navigator < "u" ? navigator.onLine : "?"}`
3563
3586
  ].join(" ");
3564
3587
  }
3565
- function xi(e) {
3588
+ function Ti(e) {
3566
3589
  return /ERROR|error:|Rejection/.test(e) ? "#f88" : /WARN|warn:/.test(e) ? "#fc6" : "#9d9";
3567
3590
  }
3568
- function Si({ state: e = "", forceVisible: t = !1 }) {
3569
- let n = fi || t, r = e === "connected" || e === "reconnecting", [, i] = ve((e) => e + 1, 0), [a, o] = M(!0);
3591
+ function Ei({ state: e = "", forceVisible: t = !1 }) {
3592
+ let n = gi || t, r = e === "connected" || e === "reconnecting", [, i] = ve((e) => e + 1, 0), [a, o] = M(!0);
3570
3593
  return k(() => {
3571
3594
  if (!n) return;
3572
- vi();
3595
+ Si();
3573
3596
  let e = setInterval(i, 1e3);
3574
3597
  return () => clearInterval(e);
3575
3598
  }, [n]), n ? r && a ? /* @__PURE__ */ F("button", {
@@ -3623,7 +3646,7 @@ function Si({ state: e = "", forceVisible: t = !1 }) {
3623
3646
  "Ikon debug overlay — state: ",
3624
3647
  e || "?",
3625
3648
  ", +",
3626
- Math.round((Date.now() - pi) / 1e3),
3649
+ Math.round((Date.now() - _i) / 1e3),
3627
3650
  "s, ",
3628
3651
  $.length,
3629
3652
  " entries",
@@ -3664,7 +3687,7 @@ function Si({ state: e = "", forceVisible: t = !1 }) {
3664
3687
  color: "#8cf",
3665
3688
  marginBottom: "4px"
3666
3689
  },
3667
- children: bi()
3690
+ children: wi()
3668
3691
  }),
3669
3692
  /* @__PURE__ */ P("div", {
3670
3693
  style: {
@@ -3675,7 +3698,7 @@ function Si({ state: e = "", forceVisible: t = !1 }) {
3675
3698
  }),
3676
3699
  /* @__PURE__ */ P("div", { children: $.length === 0 ? "(nothing captured yet)" : $.map((e, t) => /* @__PURE__ */ P("div", {
3677
3700
  style: {
3678
- color: xi(e),
3701
+ color: Ti(e),
3679
3702
  wordBreak: "break-all"
3680
3703
  },
3681
3704
  children: e
@@ -3685,7 +3708,7 @@ function Si({ state: e = "", forceVisible: t = !1 }) {
3685
3708
  }
3686
3709
  //#endregion
3687
3710
  //#region src/app/connection-state-renderer.tsx
3688
- function Ci({ connectionState: e, error: t, isReady: n, isConnectingSlow: r, stores: i, registry: a, client: o, onAction: s, renderIdle: c, renderConnecting: l, renderConnectingSlow: u, renderConnected: d, renderOffline: f, renderError: p }) {
3711
+ function Di({ connectionState: e, error: t, isReady: n, isConnectingSlow: r, stores: i, registry: a, client: o, onAction: s, renderIdle: c, renderConnecting: l, renderConnectingSlow: u, renderConnected: d, renderOffline: f, renderError: p }) {
3689
3712
  let m = j(!1), h = (() => {
3690
3713
  switch (e) {
3691
3714
  case "waitingForExternalConnectUrl":
@@ -3711,30 +3734,30 @@ function Ci({ connectionState: e, error: t, isReady: n, isConnectingSlow: r, sto
3711
3734
  default: return null;
3712
3735
  }
3713
3736
  })();
3714
- return /* @__PURE__ */ F(ye, { children: [h, /* @__PURE__ */ P(Si, { state: e })] });
3737
+ return /* @__PURE__ */ F(ye, { children: [h, /* @__PURE__ */ P(Ei, { state: e })] });
3715
3738
  }
3716
3739
  //#endregion
3717
3740
  //#region src/app/boot-snapshot-variant.ts
3718
- function wi(e, t) {
3741
+ function Oi(e, t) {
3719
3742
  return e === !1 ? !1 : t ? "signed-in" : "guest";
3720
3743
  }
3721
3744
  //#endregion
3722
3745
  //#region src/app/use-ikon-app.ts
3723
- var Ti = v("useIkonApp");
3724
- function Ei() {
3746
+ var ki = v("useIkonApp");
3747
+ function Ai() {
3725
3748
  if (typeof window < "u" && window.__IKON_AUTH_CONFIG__) return window.__IKON_AUTH_CONFIG__;
3726
3749
  }
3727
- function Di() {
3750
+ function ji() {
3728
3751
  if (typeof window < "u" && window.__IKON_LOCAL_IKON_SERVER_CONFIG__) return window.__IKON_LOCAL_IKON_SERVER_CONFIG__;
3729
3752
  }
3730
- function Oi(e, t) {
3753
+ function Mi(e, t) {
3731
3754
  return {
3732
3755
  ...e,
3733
3756
  ...t ?? {}
3734
3757
  };
3735
3758
  }
3736
- function ki(e) {
3737
- let { authConfig: n, modules: r, parameters: l, timeouts: d, backgroundAudio: g, webRtc: _, audio: v, video: y, websocket: S, webtransport: te, proxy: ne, liveSnapshot: re, bootSnapshot: ie } = e, C = n === void 0 ? Ei() ?? null : n, oe = Di(), w = ti(), se = !!w && w.state.isLoading, T = j(null), ue = j(null), E = j(null), de = j(!1), fe = j(!1), pe = j(g), me = j(d), he = j(_), D = j(v), ge = j(y), _e = j(S), ve = j(te), N = j(ne), ye = j(re), P = j(ie), F = j("local"), be = j(void 0);
3759
+ function Ni(e) {
3760
+ let { authConfig: n, modules: r, parameters: l, timeouts: d, backgroundAudio: g, webRtc: _, audio: v, video: y, websocket: S, webtransport: te, proxy: ne, liveSnapshot: re, bootSnapshot: ie } = e, C = n === void 0 ? Ai() ?? null : n, oe = ji(), w = ti(), se = !!w && w.state.isLoading, T = j(null), ue = j(null), E = j(null), de = j(!1), fe = j(!1), pe = j(g), me = j(d), he = j(_), D = j(v), ge = j(y), _e = j(S), ve = j(te), N = j(ne), ye = j(re), P = j(ie), F = j("local"), be = j(void 0);
3738
3761
  pe.current = g, me.current = d, he.current = _, D.current = v, ge.current = y, _e.current = S, ve.current = te, N.current = ne, ye.current = re, P.current = ie;
3739
3762
  let [I, xe] = M("connecting"), [Se, Ce] = M(!1), [we, Te] = M(!1), [Ee, De] = M(null), [Oe, ke] = M(null), [Ae, je] = M(!1), [Me, Ne] = M(!1), [Pe, Fe] = M(!1), [Ie, Le] = M(null), [L, Re] = M(null), [ze, Be] = M(!1), He = j(!1), [R, Ue] = M(0), z = A(() => {
3740
3763
  try {
@@ -3742,7 +3765,7 @@ function ki(e) {
3742
3765
  } catch {
3743
3766
  return { parameters: {} };
3744
3767
  }
3745
- }, []), We = JSON.stringify(l ?? {}), B = A(() => Oi(z.parameters, l), [z.parameters, We]), Ge = (C?.methods?.length ?? 0) > 0, Ke = wi(ie, Ge && lr());
3768
+ }, []), We = JSON.stringify(l ?? {}), B = A(() => Mi(z.parameters, l), [z.parameters, We]), Ge = (C?.methods?.length ?? 0) > 0, Ke = Oi(ie, Ge && lr());
3746
3769
  Ke !== !1 && !i() && a(Ke);
3747
3770
  let V = A(() => {
3748
3771
  if (!C?.spaceId) return null;
@@ -3762,7 +3785,7 @@ function ki(e) {
3762
3785
  Je && !L && !ze && !He.current && (He.current = !0, b(C.authUrl).then((e) => vr(C.spaceId, e)).then((e) => {
3763
3786
  Re(e.token), Be(!0);
3764
3787
  }).catch((e) => {
3765
- Ti.error("Anonymous auth failed:", e), He.current = !1, H ? Be(!0) : De(e instanceof Error ? e.message : "Anonymous auth failed");
3788
+ ki.error("Anonymous auth failed:", e), He.current = !1, H ? Be(!0) : De(e instanceof Error ? e.message : "Anonymous auth failed");
3766
3789
  }));
3767
3790
  let W = A(() => {
3768
3791
  if (se) return null;
@@ -3822,7 +3845,7 @@ function ki(e) {
3822
3845
  if (!de.current) {
3823
3846
  if (de.current = !0, E.current = Yt(), r) for (let e of r) e(E.current);
3824
3847
  E.current.loadRegisteredModules().catch((e) => {
3825
- Ti.error("Failed to load UI modules", e);
3848
+ ki.error("Failed to load UI modules", e);
3826
3849
  });
3827
3850
  }
3828
3851
  }, []), k(() => {
@@ -3861,14 +3884,14 @@ function ki(e) {
3861
3884
  } : void 0, l = V != null && V.provider !== "anonymous", d = Ge && (l || lr()), g = new Ve({
3862
3885
  client: e,
3863
3886
  liveSnapshot: a,
3864
- bootSnapshot: wi(P.current, d)
3887
+ bootSnapshot: Oi(P.current, d)
3865
3888
  });
3866
3889
  ue.current = g, Le(g), Te(!1);
3867
3890
  let _ = g.subscribeToUiUpdates(() => {
3868
3891
  Te(!0), le();
3869
3892
  });
3870
3893
  return e.connect().catch((e) => {
3871
- if (Ti.error("Connection failed:", e), e instanceof o) {
3894
+ if (ki.error("Connection failed:", e), e instanceof o) {
3872
3895
  ke(e.reason);
3873
3896
  return;
3874
3897
  }
@@ -3885,7 +3908,7 @@ function ki(e) {
3885
3908
  Fe(!0);
3886
3909
  return;
3887
3910
  }
3888
- e instanceof f || e instanceof c && !fe.current && (fe.current = !0, Ti.warn("Auth session appears stale, clearing and retrying"), t.clearAll(), w ? w.logout() : (ur(), Ue((e) => e + 1)));
3911
+ e instanceof f || e instanceof c && !fe.current && (fe.current = !0, ki.warn("Auth session appears stale, clearing and retrying"), t.clearAll(), w ? w.logout() : (ur(), Ue((e) => e + 1)));
3889
3912
  }
3890
3913
  }), () => {
3891
3914
  _(), e.disconnect(), T.current = null, g.dispose(), ue.current = null;
@@ -3930,8 +3953,8 @@ function ki(e) {
3930
3953
  }
3931
3954
  //#endregion
3932
3955
  //#region src/hooks/use-toasts.ts
3933
- var Ai = 0;
3934
- function ji(e = 5, t = 5e3) {
3956
+ var Pi = 0;
3957
+ function Fi(e = 5, t = 5e3) {
3935
3958
  let [n, r] = M([]), i = j(/* @__PURE__ */ new Map()), a = O((e) => {
3936
3959
  let t = i.current.get(e);
3937
3960
  t && (clearTimeout(t), i.current.delete(e)), r((t) => t.filter((t) => t.id !== e));
@@ -3939,7 +3962,7 @@ function ji(e = 5, t = 5e3) {
3939
3962
  return k(() => {
3940
3963
  let n = i.current, o = fe((i) => {
3941
3964
  if (!oe()) return;
3942
- let o = `toast-${++Ai}`, s = {
3965
+ let o = `toast-${++Pi}`, s = {
3943
3966
  id: o,
3944
3967
  level: i.level === d.ERROR ? "error" : "warn",
3945
3968
  message: i.message,
@@ -3967,7 +3990,7 @@ function ji(e = 5, t = 5e3) {
3967
3990
  }
3968
3991
  //#endregion
3969
3992
  //#region src/hooks/use-ikon-reactive.ts
3970
- function Mi(e, t, n) {
3993
+ function Ii(e, t, n) {
3971
3994
  let [r, i] = M(n);
3972
3995
  return k(() => {
3973
3996
  if (!e) return;
@@ -3985,7 +4008,7 @@ function Mi(e, t, n) {
3985
4008
  }
3986
4009
  //#endregion
3987
4010
  //#region src/hooks/use-reactive.ts
3988
- function Ni(e, t, n) {
4011
+ function Li(e, t, n) {
3989
4012
  let [r, i] = M(null);
3990
4013
  return k(() => {
3991
4014
  if (!e) return;
@@ -3997,48 +4020,48 @@ function Ni(e, t, n) {
3997
4020
  }), () => {
3998
4021
  n = !1;
3999
4022
  };
4000
- }, [e, t]), Mi(r ? e : null, r ?? "", n);
4023
+ }, [e, t]), Ii(r ? e : null, r ?? "", n);
4001
4024
  }
4002
4025
  //#endregion
4003
4026
  //#region src/app/use-ikon-debug.ts
4004
- var Pi = v("IkonDebug"), Fi = {
4027
+ var Ri = v("IkonDebug"), zi = {
4005
4028
  Digit1: "connecting",
4006
4029
  Digit2: "connected",
4007
4030
  Digit3: "reconnecting",
4008
4031
  Digit4: "offline",
4009
4032
  Digit5: "offline",
4010
4033
  Digit0: "clear"
4011
- }, Ii = "Digit5", Li = "Digit6", Ri = "Synthetic debug error (Ctrl+Shift+5)", zi = "Synthetic debug access-denied (Ctrl+Shift+6)", Bi = 5e3;
4012
- function Vi(e) {
4034
+ }, Bi = "Digit5", Vi = "Digit6", Hi = "Synthetic debug error (Ctrl+Shift+5)", Ui = "Synthetic debug access-denied (Ctrl+Shift+6)", Wi = 5e3;
4035
+ function Gi(e) {
4013
4036
  let t = oe(), [n, r] = M(null), [i, a] = M(!1), [o, s] = M(null), [c, l] = M(null), [u, d] = M(!1), [f, p] = M(!1), [m, h] = M(!1);
4014
4037
  return k(() => {
4015
4038
  if (!t) return;
4016
4039
  let e = (e) => {
4017
4040
  if (!e.ctrlKey || !e.shiftKey) return;
4018
4041
  if (e.code === "KeyE") {
4019
- e.preventDefault(), d((e) => (Pi.warn(`Empty-stores override: ${e ? "off" : "on"}`), !e));
4042
+ e.preventDefault(), d((e) => (Ri.warn(`Empty-stores override: ${e ? "off" : "on"}`), !e));
4020
4043
  return;
4021
4044
  }
4022
4045
  if (e.code === "Digit7") {
4023
- e.preventDefault(), p((e) => (Pi.warn(`Branding-banner override: ${e ? "off" : "on"}`), !e));
4046
+ e.preventDefault(), p((e) => (Ri.warn(`Branding-banner override: ${e ? "off" : "on"}`), !e));
4024
4047
  return;
4025
4048
  }
4026
4049
  if (e.code === "Digit8") {
4027
- e.preventDefault(), h((e) => (Pi.warn(`Debug-overlay override: ${e ? "off" : "on"}`), !e));
4050
+ e.preventDefault(), h((e) => (Ri.warn(`Debug-overlay override: ${e ? "off" : "on"}`), !e));
4028
4051
  return;
4029
4052
  }
4030
- if (e.code === Li) {
4031
- e.preventDefault(), l(zi), r(null), s(null), Pi.warn("Forced access denied");
4053
+ if (e.code === Vi) {
4054
+ e.preventDefault(), l(Ui), r(null), s(null), Ri.warn("Forced access denied");
4032
4055
  return;
4033
4056
  }
4034
- let t = Fi[e.code];
4057
+ let t = zi[e.code];
4035
4058
  if (t === void 0) return;
4036
4059
  if (e.preventDefault(), t === "clear") {
4037
- r(null), s(null), l(null), Pi.warn("Cleared forced state");
4060
+ r(null), s(null), l(null), Ri.warn("Cleared forced state");
4038
4061
  return;
4039
4062
  }
4040
- let n = e.code === Ii;
4041
- r(t), s(n ? Ri : null), l(null), Pi.warn(`Forced state: ${t}${n ? " (with error)" : ""}`);
4063
+ let n = e.code === Bi;
4064
+ r(t), s(n ? Hi : null), l(null), Ri.warn(`Forced state: ${t}${n ? " (with error)" : ""}`);
4042
4065
  };
4043
4066
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
4044
4067
  }, [t]), k(() => {
@@ -4046,7 +4069,7 @@ function Vi(e) {
4046
4069
  a(!1);
4047
4070
  return;
4048
4071
  }
4049
- let e = setTimeout(() => a(!0), Bi);
4072
+ let e = setTimeout(() => a(!0), Wi);
4050
4073
  return () => clearTimeout(e);
4051
4074
  }, [n]), !t || n === null && !u && c === null && !f && !m ? {
4052
4075
  app: e,
@@ -4077,20 +4100,20 @@ function Vi(e) {
4077
4100
  }
4078
4101
  //#endregion
4079
4102
  //#region src/app/ikon-app.tsx
4080
- function Hi(e, t) {
4103
+ function Ki(e, t) {
4081
4104
  return e === void 0 ? null : typeof e == "function" ? e(t) : e;
4082
4105
  }
4083
- function Ui(e) {
4106
+ function qi(e) {
4084
4107
  return e === void 0 ? null : typeof e == "function" ? e() : e;
4085
4108
  }
4086
- function Wi(e, t) {
4109
+ function Ji(e, t) {
4087
4110
  return e === void 0 ? null : typeof e == "function" ? e(t) : e;
4088
4111
  }
4089
- function Gi(e, t) {
4112
+ function Yi(e, t) {
4090
4113
  return e === void 0 ? null : typeof e == "function" ? e(t) : e;
4091
4114
  }
4092
- function Ki(e) {
4093
- let { connectingOverlay: t, reconnectingOverlay: n, offlineOverlay: r, accessDeniedScreen: i, ...a } = e, o = Vi(a), { app: s } = o, { connectionState: c, isConnectingSlow: l, stores: u, registry: d, client: f, onAction: p, isReady: m, error: h, accessDeniedReason: g, brandingRequired: _ } = s, v = _ || o.forcedBranding, y = j(null);
4115
+ function Xi(e) {
4116
+ let { connectingOverlay: t, reconnectingOverlay: n, offlineOverlay: r, accessDeniedScreen: i, ...a } = e, o = Gi(a), { app: s } = o, { connectionState: c, isConnectingSlow: l, stores: u, registry: d, client: f, onAction: p, isReady: m, error: h, accessDeniedReason: g, brandingRequired: _ } = s, v = _ || o.forcedBranding, y = j(null);
4094
4117
  u && d && (m || u.size > 0) && (y.current = {
4095
4118
  stores: u,
4096
4119
  registry: d,
@@ -4099,18 +4122,18 @@ function Ki(e) {
4099
4122
  let b = y.current != null || !!g;
4100
4123
  if (_e(() => {
4101
4124
  !b || typeof document > "u" || document.querySelectorAll("[data-ikon-prerender]").forEach((e) => e.remove());
4102
- }, [b]), g) return Gi(i, g);
4125
+ }, [b]), g) return Yi(i, g);
4103
4126
  let x = y.current, S;
4104
4127
  switch (c) {
4105
4128
  case "waitingForExternalConnectUrl":
4106
4129
  case "connecting":
4107
- S = Hi(t, l);
4130
+ S = Ki(t, l);
4108
4131
  break;
4109
4132
  case "reconnecting":
4110
- S = Ui(n);
4133
+ S = qi(n);
4111
4134
  break;
4112
4135
  case "offline":
4113
- S = Wi(r, h);
4136
+ S = Ji(r, h);
4114
4137
  break;
4115
4138
  default: S = null;
4116
4139
  }
@@ -4122,19 +4145,19 @@ function Ki(e) {
4122
4145
  onAction: p
4123
4146
  }),
4124
4147
  S,
4125
- v && /* @__PURE__ */ P(Ji, {}),
4126
- /* @__PURE__ */ P(Yi, {}),
4127
- /* @__PURE__ */ P(Si, {
4148
+ v && /* @__PURE__ */ P(Qi, {}),
4149
+ /* @__PURE__ */ P($i, {}),
4150
+ /* @__PURE__ */ P(Ei, {
4128
4151
  state: c,
4129
4152
  forceVisible: o.forcedDebugOverlay
4130
4153
  })
4131
4154
  ] });
4132
4155
  }
4133
- var qi = "https://ikonai.com";
4134
- function Ji() {
4156
+ var Zi = "https://ikonai.com";
4157
+ function Qi() {
4135
4158
  return /* @__PURE__ */ F("a", {
4136
4159
  className: "ikon-branding-banner",
4137
- href: qi,
4160
+ href: Zi,
4138
4161
  target: "_blank",
4139
4162
  rel: "noopener noreferrer",
4140
4163
  style: {
@@ -4164,17 +4187,17 @@ function Ji() {
4164
4187
  })]
4165
4188
  });
4166
4189
  }
4167
- function Yi() {
4168
- let { toasts: e, dismissToast: t } = ji();
4190
+ function $i() {
4191
+ let { toasts: e, dismissToast: t } = Fi();
4169
4192
  return e.length === 0 ? null : /* @__PURE__ */ P("div", {
4170
4193
  className: "ikon-toast-overlay",
4171
- children: e.map((e) => /* @__PURE__ */ P(Xi, {
4194
+ children: e.map((e) => /* @__PURE__ */ P(ea, {
4172
4195
  toast: e,
4173
4196
  onDismiss: t
4174
4197
  }, e.id))
4175
4198
  });
4176
4199
  }
4177
- function Xi({ toast: e, onDismiss: t }) {
4200
+ function ea({ toast: e, onDismiss: t }) {
4178
4201
  return /* @__PURE__ */ F("div", {
4179
4202
  className: `ikon-toast-overlay-chip ikon-toast-overlay-chip--${e.level}`,
4180
4203
  onClick: () => t(e.id),
@@ -4200,37 +4223,37 @@ function Xi({ toast: e, onDismiss: t }) {
4200
4223
  }
4201
4224
  //#endregion
4202
4225
  //#region src/i18n/i18n.tsx
4203
- var Zi = he(null);
4204
- function Qi(e, t) {
4226
+ var ta = he(null);
4227
+ function na(e, t) {
4205
4228
  return t ? e.replace(/\{(\w+)\}/g, (e, n) => t[n] ?? `{${n}}`) : e;
4206
4229
  }
4207
- function $i(e, t) {
4230
+ function ra(e, t) {
4208
4231
  let n = ne();
4209
4232
  if (n && e.includes(n)) return n;
4210
4233
  let r = navigator.language.split("-")[0];
4211
4234
  return e.includes(r) ? r : t && e.includes(t) ? t : "en";
4212
4235
  }
4213
- function ea(e, t, n) {
4214
- return t ? $i(e, n) : n && e.includes(n) ? n : "en";
4236
+ function ia(e, t, n) {
4237
+ return t ? ra(e, n) : n && e.includes(n) ? n : "en";
4215
4238
  }
4216
- function ta({ children: e, translations: t, defaultLanguage: n, detectLanguage: r = !1 }) {
4217
- let i = ea(Object.keys(t), r, n), a = t[i] ?? t.en, o = A(() => ({
4239
+ function aa({ children: e, translations: t, defaultLanguage: n, detectLanguage: r = !1 }) {
4240
+ let i = ia(Object.keys(t), r, n), a = t[i] ?? t.en, o = A(() => ({
4218
4241
  t: (e, t) => {
4219
4242
  let n = a[e];
4220
- return Qi(n, t);
4243
+ return na(n, t);
4221
4244
  },
4222
4245
  locale: i,
4223
4246
  translations: a
4224
4247
  }), [a, i]);
4225
- return /* @__PURE__ */ P(Zi, {
4248
+ return /* @__PURE__ */ P(ta, {
4226
4249
  value: o,
4227
4250
  children: e
4228
4251
  });
4229
4252
  }
4230
- function na() {
4231
- let e = ge(Zi);
4253
+ function oa() {
4254
+ let e = ge(ta);
4232
4255
  if (!e) throw Error("useI18n must be used within an I18nProvider");
4233
4256
  return e;
4234
4257
  }
4235
4258
  //#endregion
4236
- export { $r as AuthProvider, Ci as ConnectionStateRenderer, fi as DEBUG_OVERLAY_ENABLED, Si as DebugOverlay, ta as I18nProvider, at as IKON_UI_BASE_MODULE, Et as IKON_UI_MEDIA_MODULE, Wt as IKON_UI_SHADERTOY_MODULE, Ht as IKON_UI_SHADERTOY_TYPE, Re as IKON_UI_STREAM_CATEGORY, bt as IKON_UI_VIDEO_CANVAS_TYPE, xt as IKON_UI_VIDEO_URL_PLAYER_TYPE, Ki as IkonApp, Ve as IkonUi, Jt as IkonUiRegistry, Be as IkonUiSurface, Le as InspectOverlay, $t as ParallaxView, Pe as UiComponentRegistry, Ne as UiRenderer, n as UiStreamStore, vr as authenticateAnonymous, Ar as buildOAuthRedirectUrl, ur as clearAuthSession, kr as clearOAuthParams, it as createBaseResolvers, Fe as createComponentLibrary, Yt as createIkonUiRegistry, Ct as createMediaResolvers, Ut as createShadertoyRendererResolver, ze as isIkonUiCategoryMatch, rr as loadAuthSession, ot as loadBaseModule, Dt as loadMediaModule, Gt as loadShadertoyModule, xr as parseOAuthCallback, Tr as parseOAuthError, T as randomUuid, st as registerBaseModule, Ot as registerMediaModule, Kt as registerShadertoyModule, je as renderChildren, vn as renderMotionLetters, q as saveAuthSession, yr as sendLoginCode, J as sessionToUser, ei as useAuth, di as useAuthGuard, ti as useAuthOptional, na as useI18n, ki as useIkonApp, Vi as useIkonDebug, Mi as useIkonReactive, un as useIkonStyles, fn as useIkonUiStores, Ni as useReactive, ji as useToasts, I as useUiNode, Ie as useUiStore, br as verifyLoginCode };
4259
+ export { $r as AuthProvider, Di as ConnectionStateRenderer, gi as DEBUG_OVERLAY_ENABLED, Ei as DebugOverlay, aa as I18nProvider, at as IKON_UI_BASE_MODULE, Et as IKON_UI_MEDIA_MODULE, Wt as IKON_UI_SHADERTOY_MODULE, Ht as IKON_UI_SHADERTOY_TYPE, Re as IKON_UI_STREAM_CATEGORY, bt as IKON_UI_VIDEO_CANVAS_TYPE, xt as IKON_UI_VIDEO_URL_PLAYER_TYPE, Xi as IkonApp, Ve as IkonUi, Jt as IkonUiRegistry, Be as IkonUiSurface, Le as InspectOverlay, $t as ParallaxView, Pe as UiComponentRegistry, Ne as UiRenderer, n as UiStreamStore, vr as authenticateAnonymous, Ar as buildOAuthRedirectUrl, ur as clearAuthSession, kr as clearOAuthParams, it as createBaseResolvers, Fe as createComponentLibrary, Yt as createIkonUiRegistry, Ct as createMediaResolvers, Ut as createShadertoyRendererResolver, ze as isIkonUiCategoryMatch, rr as loadAuthSession, ot as loadBaseModule, Dt as loadMediaModule, Gt as loadShadertoyModule, xr as parseOAuthCallback, Tr as parseOAuthError, T as randomUuid, st as registerBaseModule, Ot as registerMediaModule, Kt as registerShadertoyModule, je as renderChildren, vn as renderMotionLetters, q as saveAuthSession, yr as sendLoginCode, J as sessionToUser, ei as useAuth, hi as useAuthGuard, ti as useAuthOptional, oa as useI18n, Ni as useIkonApp, Gi as useIkonDebug, Ii as useIkonReactive, un as useIkonStyles, fn as useIkonUiStores, Li as useReactive, Fi as useToasts, I as useUiNode, Ie as useUiStore, br as verifyLoginCode };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikonai/sdk-react-ui",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",