@fastr-pro/global-header 1.0.14 → 1.0.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.js CHANGED
@@ -3397,7 +3397,8 @@ function Ht(e) {
3397
3397
  return e;
3398
3398
  }
3399
3399
  }
3400
- function Ut({ config: e, authApiUrl: t, authRedirectUrl: l, redirectOnInvalidSession: d, profileGetter: f, uiTheme: m, apps: h, user: g, logout: _, theme: v, setTheme: x, onThemeChange: S, currentApp: C, navigate: w, onNavigate: T, urls: E = {}, logo: re, onLogoClick: O, categoryData: k = [], chartingCallbacks: oe = {}, products: se, extraRightContent: ce, className: le }) {
3400
+ var Ut = null, Wt = null;
3401
+ function Gt({ config: e, authApiUrl: t, authRedirectUrl: l, redirectOnInvalidSession: d, profileGetter: f, uiTheme: m, apps: h, user: g, logout: _, theme: v, setTheme: x, onThemeChange: S, currentApp: C, navigate: w, onNavigate: T, urls: E = {}, logo: re, onLogoClick: O, categoryData: k = [], chartingCallbacks: oe = {}, products: se, extraRightContent: ce, className: le }) {
3401
3402
  let P = i(() => {
3402
3403
  let n = {
3403
3404
  ...t ? { authApiUrl: t } : {},
@@ -3434,8 +3435,8 @@ function Ut({ config: e, authApiUrl: t, authRedirectUrl: l, redirectOnInvalidSes
3434
3435
  if (g !== void 0 || P.user !== void 0) return;
3435
3436
  let e = () => {
3436
3437
  if (ge(null), ue && typeof window < "u" && L) {
3437
- let e = window.location.href;
3438
- window.location.assign(`${L}/login?redirect=${encodeURIComponent(e)}`);
3438
+ let e = window.location.href, t = encodeURIComponent(e), n = `${L}/login?app_id=${encodeURIComponent(F || "")}&p_screen=${t}&redirect=${t}`;
3439
+ window.location.assign(n);
3439
3440
  }
3440
3441
  };
3441
3442
  if (typeof R == "function") _e(!0), Promise.resolve(R()).then((t) => {
@@ -3464,48 +3465,53 @@ function Ut({ config: e, authApiUrl: t, authRedirectUrl: l, redirectOnInvalidSes
3464
3465
  R,
3465
3466
  I,
3466
3467
  L,
3467
- ue
3468
+ ue,
3469
+ F
3468
3470
  ]);
3469
- let B = g === void 0 ? P.user === void 0 ? me : P.user : g, [ye, V] = o(() => Array.isArray(k) && k.length > 0 ? k : Pt);
3471
+ let B = g === void 0 ? P.user === void 0 ? me : P.user : g, [ye, V] = o(() => Array.isArray(k) && k.length > 0 ? k : Ut || Pt);
3470
3472
  r(() => {
3471
3473
  if (Array.isArray(k) && k.length > 0) {
3472
3474
  V(k);
3473
3475
  return;
3474
3476
  }
3475
- let e = !0;
3476
- return typeof window < "u" && (async () => {
3477
- try {
3478
- let t = P.apps?.macro?.categoriesApiUrl || "https://macropulse-pro-api.datatokenapi.com/api/categories", n = await fetch(t, { credentials: "include" });
3479
- if (n.ok) {
3480
- let t = await n.json(), r = Array.isArray(t) ? t : t?.data || t?.categories || [];
3481
- if (Array.isArray(r) && r.length > 0) {
3482
- let t = r.map((e) => {
3483
- let t = e.id || e._id || e.slug || (e.name || "").toLowerCase().replace(/\s+/g, "_"), n = e.id || e._id || t, r = e.name || e.title || e.label || t, i = Pt.find((e) => e.id === t || e.dbId === n || e.label?.toLowerCase() === r.toLowerCase() || e.value?.toLowerCase() === r.toLowerCase()), a = (e.indicators || e.items || e.sections || i?.items || []).map((e, t) => ({
3484
- id: e.id || e.slug || `indicator_${t}`,
3485
- title: e.title || e.name || e.label || "Indicator",
3486
- desc: e.desc || e.description || e.subtitle || "Lorem ipsum dolor sit amet , consectetuer adipiscing elit...",
3487
- route: `/${n}`,
3488
- queryParams: e.id || e.slug ? { indicator: e.id || e.slug } : void 0
3489
- }));
3490
- return {
3491
- id: t,
3492
- label: r,
3493
- value: r,
3494
- dbId: n,
3495
- route: `/${n}`,
3496
- icon: i?.icon || ie,
3497
- description: e.description || e.desc || i?.description || "",
3498
- items: a
3499
- };
3500
- });
3501
- e && t.length > 0 && V(t);
3502
- }
3477
+ if (Ut) {
3478
+ V(Ut);
3479
+ return;
3480
+ }
3481
+ let e = !0, t = P.apps?.macro?.categoriesApiUrl || "https://macropulse-pro-api.datatokenapi.com/api/categories";
3482
+ return Wt ||= fetch(t, { credentials: "include" }).then(async (e) => {
3483
+ if (e.ok) {
3484
+ let t = await e.json(), n = Array.isArray(t) ? t : t?.data || t?.categories || [];
3485
+ if (Array.isArray(n) && n.length > 0) {
3486
+ let e = n.map((e) => {
3487
+ let t = e.id || e._id || e.slug || (e.name || "").toLowerCase().replace(/\s+/g, "_"), n = e.id || e._id || t, r = e.name || e.title || e.label || t, i = Pt.find((e) => e.id === t || e.dbId === n || e.label?.toLowerCase() === r.toLowerCase() || e.value?.toLowerCase() === r.toLowerCase()), a = (e.indicators || e.items || e.sections || i?.items || []).map((e, t) => ({
3488
+ id: e.id || e.slug || `indicator_${t}`,
3489
+ title: e.title || e.name || e.label || "Indicator",
3490
+ desc: e.desc || e.description || e.subtitle || "Lorem ipsum dolor sit amet , consectetuer adipiscing elit...",
3491
+ route: `/${n}`,
3492
+ queryParams: e.id || e.slug ? { indicator: e.id || e.slug } : void 0
3493
+ }));
3494
+ return {
3495
+ id: t,
3496
+ label: r,
3497
+ value: r,
3498
+ dbId: n,
3499
+ route: `/${n}`,
3500
+ icon: i?.icon || ie,
3501
+ description: e.description || e.desc || i?.description || "",
3502
+ items: a
3503
+ };
3504
+ });
3505
+ if (e.length > 0) return Ut = e, e;
3503
3506
  }
3504
- } catch {}
3505
- })(), () => {
3507
+ }
3508
+ return null;
3509
+ }).catch((e) => (console.warn("[GlobalHeader] fetchMacroCategories error:", e), null)), Wt.then((t) => {
3510
+ e && t && t.length > 0 && V(t);
3511
+ }), () => {
3506
3512
  e = !1;
3507
3513
  };
3508
- }, [k, P.apps?.macro?.categoriesApiUrl]);
3514
+ }, []);
3509
3515
  let be = (e) => {
3510
3516
  let t = B?.all_apps || B?.apps || [], n = (e || "").toLowerCase().replace(/[^a-z0-9]/g, "");
3511
3517
  return t.find((t) => {
@@ -3610,9 +3616,35 @@ function Ut({ config: e, authApiUrl: t, authRedirectUrl: l, redirectOnInvalidSes
3610
3616
  return null;
3611
3617
  }, [B, F]), Ue = n((e, t, n) => {
3612
3618
  T ? T(e, t, n) : w && typeof e == "string" && !e.startsWith("http://") && !e.startsWith("https://") ? w(e) : window.location.assign(e);
3613
- }, [T, w]), We = () => {
3619
+ }, [T, w]), We = async () => {
3614
3620
  let e = _ || P.logout;
3615
- e ? e() : window.location.assign(`${L}/logout`);
3621
+ if (typeof e == "function") try {
3622
+ await Promise.resolve(e());
3623
+ } catch (e) {
3624
+ console.warn("[GlobalHeader] custom logout error:", e);
3625
+ }
3626
+ if (I && typeof window < "u") {
3627
+ let e = I.endsWith("/api") ? `${I}/auth/logout` : `${I}/api/auth/logout`;
3628
+ try {
3629
+ await fetch(e, {
3630
+ method: "POST",
3631
+ credentials: "include",
3632
+ headers: { "Content-Type": "application/json" }
3633
+ }).catch(async () => fetch(e, {
3634
+ method: "GET",
3635
+ credentials: "include"
3636
+ }));
3637
+ } catch (e) {
3638
+ console.warn("[GlobalHeader] SSO logout API error:", e);
3639
+ }
3640
+ }
3641
+ if (typeof window < "u") {
3642
+ try {
3643
+ localStorage.removeItem("user"), localStorage.removeItem("token"), localStorage.removeItem("auth_token"), sessionStorage.removeItem("user"), sessionStorage.removeItem("token"), sessionStorage.removeItem("auth_token");
3644
+ } catch {}
3645
+ let e = window.location.href, t = encodeURIComponent(e), n = `${L}/logout?app_id=${encodeURIComponent(F || "")}&p_screen=${t}&redirect=${t}`;
3646
+ window.location.assign(n);
3647
+ }
3616
3648
  }, Ge = i(() => {
3617
3649
  if (se) return se;
3618
3650
  let t = P.apps || {};
@@ -4270,8 +4302,8 @@ function Ut({ config: e, authApiUrl: t, authRedirectUrl: l, redirectOnInvalidSes
4270
4302
  }
4271
4303
  //#endregion
4272
4304
  //#region src/index.js
4273
- var Wt = Ut;
4305
+ var Kt = Gt;
4274
4306
  //#endregion
4275
- export { nt as DropdownMenu, at as DropdownMenuContent, ot as DropdownMenuGroup, Q as DropdownMenuItem, st as DropdownMenuLabel, rt as DropdownMenuPortal, ct as DropdownMenuSeparator, it as DropdownMenuTrigger, ve as FasterProLogo, Ut as GlobalHeader, Vt as GlobalMegaMenu, $ as NavigationMenu, pt as NavigationMenuContent, gt as NavigationMenuIndicator, ut as NavigationMenuItem, ht as NavigationMenuLink, lt as NavigationMenuList, mt as NavigationMenuPositioner, ft as NavigationMenuTrigger, _t as Popover, yt as PopoverContent, St as PopoverDescription, bt as PopoverHeader, xt as PopoverTitle, vt as PopoverTrigger, kt as appBannerImages, zt as buildItemUrl, Mt as chartingCategories, Z as cn, Lt as createHeaderConfig, Wt as default, It as defaultHeaderConfig, Ft as derivativesCategories, At as getBannerImage, Pt as macroPulseCategories, dt as navigationMenuTriggerStyle, Rt as renderIcon, Nt as scannerCategories, jt as stockXRayCategories, Bt as withThemeParam };
4307
+ export { nt as DropdownMenu, at as DropdownMenuContent, ot as DropdownMenuGroup, Q as DropdownMenuItem, st as DropdownMenuLabel, rt as DropdownMenuPortal, ct as DropdownMenuSeparator, it as DropdownMenuTrigger, ve as FasterProLogo, Gt as GlobalHeader, Vt as GlobalMegaMenu, $ as NavigationMenu, pt as NavigationMenuContent, gt as NavigationMenuIndicator, ut as NavigationMenuItem, ht as NavigationMenuLink, lt as NavigationMenuList, mt as NavigationMenuPositioner, ft as NavigationMenuTrigger, _t as Popover, yt as PopoverContent, St as PopoverDescription, bt as PopoverHeader, xt as PopoverTitle, vt as PopoverTrigger, kt as appBannerImages, zt as buildItemUrl, Mt as chartingCategories, Z as cn, Lt as createHeaderConfig, Kt as default, It as defaultHeaderConfig, Ft as derivativesCategories, At as getBannerImage, Pt as macroPulseCategories, dt as navigationMenuTriggerStyle, Rt as renderIcon, Nt as scannerCategories, jt as stockXRayCategories, Bt as withThemeParam };
4276
4308
 
4277
4309
  //# sourceMappingURL=index.js.map