@burdenoff/fe-libs 2026.725.1 → 2026.725.2

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.
@@ -1,4 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
+ import { ActiveContextUrlParams, AuthStoreContextSnapshot } from './ActiveContextStorage';
2
3
  /**
3
4
  * Context value interface for organization/workspace/project selection
4
5
  */
@@ -71,6 +72,39 @@ export declare function createContextFieldThrashState(initial: string | null): C
71
72
  * value — the ping-pong signature described above.
72
73
  */
73
74
  export declare function shouldApplyContextFieldWrite(fieldName: string, state: ContextFieldThrashState, nextValue: string | null, now: number): boolean;
75
+ export interface ActiveContextBootstrapFields {
76
+ organizationId: string | null;
77
+ workspaceId: string | null;
78
+ projectId: string | null;
79
+ }
80
+ /**
81
+ * Fill-only merge of the persisted auth-store context into the values already
82
+ * resolved from the URL / ActiveContext's own storage.
83
+ *
84
+ * Fill rules (mirroring microfe-auth's `useActiveContextBootstrapMirror`):
85
+ * - a value already resolved from the URL or own storage always wins;
86
+ * - a child axis is filled from the store only when its parent axis provably
87
+ * matches the parent the stored child belongs to — the workspace only when
88
+ * the resolved organization IS the store's organization, the project only
89
+ * when the resolved workspace IS the store's workspace. Without that guard a
90
+ * stale `?org=` deep link would be paired with a workspace from a different
91
+ * organization, which is worse than no workspace at all.
92
+ * - a child is never filled under an empty parent, for the same reason.
93
+ *
94
+ * Exported so this can be unit-tested directly: it is pure, while the provider
95
+ * around it needs a DOM.
96
+ */
97
+ export declare function applyAuthStoreContextFallback(resolved: ActiveContextBootstrapFields, authStore: AuthStoreContextSnapshot): ActiveContextBootstrapFields;
98
+ /**
99
+ * Resolve the organization / workspace / project the provider should start
100
+ * from: URL (when synced) > ActiveContext's own storage > persisted auth store.
101
+ * Defaults are applied by the caller, after this.
102
+ */
103
+ export declare function resolveInitialActiveContext(options: {
104
+ storageKey: string;
105
+ syncToUrl: boolean;
106
+ urlParams: ActiveContextUrlParams;
107
+ }): ActiveContextBootstrapFields;
74
108
  /**
75
109
  * ActiveContextProvider
76
110
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ActiveContextProvider.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/shell/ActiveContextProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAiBf;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,yCAAyC;IACzC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,sCAAsC;IACtC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,oCAAoC;IACpC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,mCAAmC;IACnC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAExB,kCAAkC;IAClC,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAChD,+BAA+B;IAC/B,YAAY,EAAE,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACnD,6BAA6B;IAC7B,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC/C,4BAA4B;IAC5B,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAE7C,qCAAqC;IACrC,UAAU,EAAE,CACV,OAAO,EAAE,OAAO,CAAC;QACf,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;KACzB,CAAC,KACC,IAAI,CAAC;IAEV,+BAA+B;IAC/B,YAAY,EAAE,MAAM,IAAI,CAAC;IAEzB,kCAAkC;IAClC,cAAc,EAAE,OAAO,CAAC;CACzB;AAID,MAAM,WAAW,0BA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C5B,kBAAyB,EACzB,gBAAuB,EACvB,eAAsB,EACtB,UAAuC,EACvC,SAAiB,EACjB,SAA6C,GAC9C,EAAE,0BAA0B,2CA0X5B;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,uBAM/B"}
1
+ {"version":3,"file":"ActiveContextProvider.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/shell/ActiveContextProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAMf,OAAO,EASL,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC9B,MAAM,wBAAwB,CAAC;AAGhC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,yCAAyC;IACzC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,sCAAsC;IACtC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,oCAAoC;IACpC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,mCAAmC;IACnC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAExB,kCAAkC;IAClC,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAChD,+BAA+B;IAC/B,YAAY,EAAE,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACnD,6BAA6B;IAC7B,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC/C,4BAA4B;IAC5B,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAE7C,qCAAqC;IACrC,UAAU,EAAE,CACV,OAAO,EAAE,OAAO,CAAC;QACf,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,QAAQ,EAAE,MAAM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C9B,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,GAAG,EAAE,MAAM,GACV,OAAO,CAsCT;AAsBD,MAAM,WAAW,4BAA4B;IAC3C,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,4BAA4B,EACtC,SAAS,EAAE,wBAAwB,GAClC,4BAA4B,CAY9B;AAgBD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,sBAAsB,CAAC;CACnC,GAAG,4BAA4B,CAsC/B;AAiCD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,qBAA4B,EAC5B,kBAAyB,EACzB,gBAAuB,EACvB,eAAsB,EACtB,UAAuC,EACvC,SAAiB,EACjB,SAA6C,GAC9C,EAAE,0BAA0B,2CAgX5B;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,uBAM/B"}
@@ -1,11 +1,11 @@
1
1
  import { getProfileContext as e, resolveActiveProfileId as t, setProfileContext as n } from "./ProfileStorageManager.js";
2
- import { ACTIVE_CONTEXT_STORAGE_KEY as r, DEFAULT_ACTIVE_CONTEXT_URL_PARAMS as i, clearActiveContextStorage as a, getUrlParam as o, readActiveContextStorageValue as s, writeActiveContextFallback as c, writeActiveContextStorageValue as l } from "./ActiveContextStorage.js";
3
- import { isSsoNavigationPending as u } from "../../utils/ssoDeposit.js";
4
- import { createContext as d, use as f, useCallback as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
5
- import { jsx as v } from "react/jsx-runtime";
2
+ import { ACTIVE_CONTEXT_STORAGE_KEY as r, DEFAULT_ACTIVE_CONTEXT_URL_PARAMS as i, clearActiveContextStorage as a, getUrlParam as o, readActiveContextStorageValue as s, readAuthStoreContext as c, writeActiveContextFallback as l, writeActiveContextStorageValue as u } from "./ActiveContextStorage.js";
3
+ import { isSsoNavigationPending as d } from "../../utils/ssoDeposit.js";
4
+ import { createContext as f, use as p, useCallback as m, useEffect as h, useMemo as g, useRef as _, useState as v } from "react";
5
+ import { jsx as y } from "react/jsx-runtime";
6
6
  //#region src/shared/providers/shell/ActiveContextProvider.tsx
7
- var y = d(null);
8
- function b(e) {
7
+ var b = f(null);
8
+ function x(e) {
9
9
  return {
10
10
  current: e,
11
11
  previous: null,
@@ -14,7 +14,7 @@ function b(e) {
14
14
  suppressUntil: 0
15
15
  };
16
16
  }
17
- function x() {
17
+ function S() {
18
18
  try {
19
19
  return !!{
20
20
  BASE_URL: "/",
@@ -27,34 +27,55 @@ function x() {
27
27
  return !1;
28
28
  }
29
29
  }
30
- function S(e, t, n, r) {
30
+ function C(e, t, n, r) {
31
31
  if (t.current === n) return !1;
32
- if (r < t.suppressUntil) return x() && console.warn(`[ActiveContext] Suppressing rapid ${e} change to avoid a render loop (BOFF-5395): holding at ${JSON.stringify(t.current)}, refused ${JSON.stringify(n)}.`), !1;
32
+ if (r < t.suppressUntil) return S() && console.warn(`[ActiveContext] Suppressing rapid ${e} change to avoid a render loop (BOFF-5395): holding at ${JSON.stringify(t.current)}, refused ${JSON.stringify(n)}.`), !1;
33
33
  let i = n === t.previous, a = r - t.windowStart < 500;
34
- return i && a ? t.flips += 1 : (t.flips = 1, t.windowStart = r), t.flips >= 3 ? (t.suppressUntil = r + 500, t.flips = 0, x() && console.warn(`[ActiveContext] Detected ${e} ping-pong between ${JSON.stringify(t.current)} and ${JSON.stringify(n)} (BOFF-5395) — holding at the current value instead of looping.`), !1) : (t.previous = t.current, t.current = n, !0);
34
+ return i && a ? t.flips += 1 : (t.flips = 1, t.windowStart = r), t.flips >= 3 ? (t.suppressUntil = r + 500, t.flips = 0, S() && console.warn(`[ActiveContext] Detected ${e} ping-pong between ${JSON.stringify(t.current)} and ${JSON.stringify(n)} (BOFF-5395) — holding at the current value instead of looping.`), !1) : (t.previous = t.current, t.current = n, !0);
35
35
  }
36
- function C(e) {
37
- if (typeof window > "u" || u() || window.location.pathname.startsWith("/auth/")) return;
36
+ function w(e, t) {
37
+ let n = e.organizationId ?? t.organizationId, r = n !== null && n === t.organizationId, i = e.workspaceId ?? (r ? t.workspaceId : null), a = i !== null && i === t.workspaceId;
38
+ return {
39
+ organizationId: n,
40
+ workspaceId: i,
41
+ projectId: e.projectId ?? (a ? t.projectId : null)
42
+ };
43
+ }
44
+ function T(e, t, n, r) {
45
+ if (n) {
46
+ let e = o(t);
47
+ if (e) return e;
48
+ }
49
+ return s(e, r) || null;
50
+ }
51
+ function E(e) {
52
+ if (typeof window > "u") return {
53
+ organizationId: null,
54
+ workspaceId: null,
55
+ projectId: null
56
+ };
57
+ let { storageKey: t, syncToUrl: n, urlParams: r } = e, a = {
58
+ organizationId: T("organization", r.organization ?? i.organization, n, t),
59
+ workspaceId: T("workspace", r.workspace ?? i.workspace, n, t),
60
+ projectId: T("project", r.project ?? i.project, n, t)
61
+ };
62
+ return a.organizationId !== null && a.workspaceId !== null && a.projectId !== null ? a : w(a, c());
63
+ }
64
+ function D(e) {
65
+ if (typeof window > "u" || d() || window.location.pathname.startsWith("/auth/")) return;
38
66
  let t = new URL(window.location.href);
39
67
  Object.entries(e).forEach(([e, n]) => {
40
68
  n ? t.searchParams.set(e, n) : t.searchParams.delete(e);
41
69
  }), window.history.replaceState({}, "", t.toString());
42
70
  }
43
- function w({ children: u, defaultOrganizationId: d = null, defaultWorkspaceId: f = null, defaultProjectId: x = null, defaultTenantId: w = null, storageKey: T = r, syncToUrl: E = !1, urlParams: D = i }) {
44
- let [O, k] = _(() => {
45
- if (typeof window > "u") return d;
46
- if (E) {
47
- let e = o(D.organization);
48
- if (e) return e;
49
- }
50
- return s("organization", T) || d;
51
- }), [A, j] = _(() => {
71
+ function O({ children: c, defaultOrganizationId: d = null, defaultWorkspaceId: f = null, defaultProjectId: p = null, defaultTenantId: S = null, storageKey: w = r, syncToUrl: T = !1, urlParams: O = i }) {
72
+ let [k] = v(() => E({
73
+ storageKey: w,
74
+ syncToUrl: T,
75
+ urlParams: O
76
+ })), [A, j] = v(() => typeof window > "u" ? d : k.organizationId ?? d), [M, N] = v(() => {
52
77
  if (typeof window > "u") return f;
53
- if (E) {
54
- let e = o(D.workspace);
55
- if (e) return e;
56
- }
57
- let r = s("workspace", T) || f;
78
+ let r = k.workspaceId ?? f;
58
79
  if (r) {
59
80
  let i = t();
60
81
  if (i) {
@@ -66,152 +87,145 @@ function w({ children: u, defaultOrganizationId: d = null, defaultWorkspaceId: f
66
87
  }
67
88
  }
68
89
  return r;
69
- }), [M, N] = _(() => {
70
- if (typeof window > "u") return x;
71
- if (E) {
72
- let e = o(D.project);
90
+ }), [P, F] = v(() => typeof window > "u" ? p : k.projectId ?? p), [I, L] = v(() => {
91
+ if (typeof window > "u") return S;
92
+ if (T) {
93
+ let e = o(O.tenant);
73
94
  if (e) return e;
74
95
  }
75
- return s("project", T) || x;
76
- }), [P, F] = _(() => {
77
- if (typeof window > "u") return w;
78
- if (E) {
79
- let e = o(D.tenant);
80
- if (e) return e;
81
- }
82
- return s("tenant", T) || w;
83
- }), I = g(null);
84
- I.current === null && (I.current = b(O));
85
- let L = g(null);
86
- L.current === null && (L.current = b(A));
87
- let R = g(null);
88
- R.current === null && (R.current = b(M));
89
- let z = g(null);
90
- z.current === null && (z.current = b(P)), m(() => {
91
- l("organization", O, T), l("workspace", A, T), l("project", M, T), l("tenant", P, T);
96
+ return s("tenant", w) || S;
97
+ }), R = _(null);
98
+ R.current === null && (R.current = x(A));
99
+ let z = _(null);
100
+ z.current === null && (z.current = x(M));
101
+ let B = _(null);
102
+ B.current === null && (B.current = x(P));
103
+ let V = _(null);
104
+ V.current === null && (V.current = x(I)), h(() => {
105
+ u("organization", A, w), u("workspace", M, w), u("project", P, w), u("tenant", I, w);
92
106
  }, [
93
- O,
94
107
  A,
95
108
  M,
96
109
  P,
97
- T
98
- ]), m(() => {
110
+ I,
111
+ w
112
+ ]), h(() => {
99
113
  let r = t();
100
114
  if (!r) return;
101
115
  let i = e(r), a = {
102
116
  ...i,
103
- organizationId: O,
104
- workspaceId: A,
105
- projectId: M,
106
- tenantId: P
117
+ organizationId: A,
118
+ workspaceId: M,
119
+ projectId: P,
120
+ tenantId: I
107
121
  };
108
122
  i?.organizationId === a.organizationId && i?.workspaceId === a.workspaceId && i?.projectId === a.projectId && i?.tenantId === a.tenantId || n(r, a);
109
123
  }, [
110
- O,
111
124
  A,
112
125
  M,
113
- P
114
- ]), m(() => {
115
- E && C({
116
- [D.organization]: O,
117
- [D.workspace]: A,
118
- [D.project]: M,
119
- [D.tenant]: P
126
+ P,
127
+ I
128
+ ]), h(() => {
129
+ T && D({
130
+ [O.organization]: A,
131
+ [O.workspace]: M,
132
+ [O.project]: P,
133
+ [O.tenant]: I
120
134
  });
121
135
  }, [
122
- O,
123
136
  A,
124
137
  M,
125
138
  P,
126
- E,
127
- D
128
- ]), m(() => {
129
- if (!E) return;
139
+ I,
140
+ T,
141
+ O
142
+ ]), h(() => {
143
+ if (!T) return;
130
144
  let e = () => {
131
- let e = o(D.organization), t = o(D.workspace), n = o(D.project), r = o(D.tenant);
132
- e !== O && (k(e), I.current.previous = I.current.current, I.current.current = e), t !== A && (j(t), L.current.previous = L.current.current, L.current.current = t), n !== M && (N(n), R.current.previous = R.current.current, R.current.current = n), r !== P && (F(r), z.current.previous = z.current.current, z.current.current = r);
145
+ let e = o(O.organization), t = o(O.workspace), n = o(O.project), r = o(O.tenant);
146
+ e !== A && (j(e), R.current.previous = R.current.current, R.current.current = e), t !== M && (N(t), z.current.previous = z.current.current, z.current.current = t), n !== P && (F(n), B.current.previous = B.current.current, B.current.current = n), r !== I && (L(r), V.current.previous = V.current.current, V.current.current = r);
133
147
  };
134
148
  return window.addEventListener("popstate", e), () => window.removeEventListener("popstate", e);
135
149
  }, [
136
- E,
137
- D,
150
+ T,
138
151
  O,
139
152
  A,
140
153
  M,
141
- P
154
+ P,
155
+ I
142
156
  ]);
143
- let B = p((r) => {
144
- if (!S("organizationId", I.current, r, Date.now())) return;
145
- k(r);
157
+ let H = m((r) => {
158
+ if (!C("organizationId", R.current, r, Date.now())) return;
159
+ j(r);
146
160
  let i = t();
147
161
  i && n(i, {
148
162
  ...e(i),
149
163
  organizationId: r
150
164
  }), typeof window < "u" && window.dispatchEvent(new CustomEvent("burdenoff:organization-changed", { detail: { organizationId: r } }));
151
- }, []), V = p((r, i) => {
165
+ }, []), U = m((r, i) => {
152
166
  let a = {
153
167
  organization: "organizationId",
154
168
  workspace: "workspaceId",
155
169
  project: "projectId",
156
170
  tenant: "tenantId"
157
171
  };
158
- l(r, i, T);
172
+ u(r, i, w);
159
173
  let o = t();
160
174
  o ? n(o, {
161
175
  ...e(o),
162
176
  [a[r]]: i
163
- }) : typeof window < "u" && c(r, i, T);
164
- }, [T]), H = p((e) => {
165
- S("workspaceId", L.current, e, Date.now()) && (j(e), V("workspace", e), typeof window < "u" && window.dispatchEvent(new CustomEvent("burdenoff:workspace-changed", { detail: { workspaceId: e } })));
166
- }, [V]), U = p((e) => {
167
- S("projectId", R.current, e, Date.now()) && (N(e), V("project", e), typeof window < "u" && window.dispatchEvent(new CustomEvent("burdenoff:project-changed", { detail: { projectId: e } })));
168
- }, [V]), W = p((e) => {
169
- S("tenantId", z.current, e, Date.now()) && (F(e), V("tenant", e));
170
- }, [V]), G = p((e) => {
171
- e.organizationId !== void 0 && B(e.organizationId), e.workspaceId !== void 0 && H(e.workspaceId), e.projectId !== void 0 && U(e.projectId), e.tenantId !== void 0 && W(e.tenantId);
177
+ }) : typeof window < "u" && l(r, i, w);
178
+ }, [w]), W = m((e) => {
179
+ C("workspaceId", z.current, e, Date.now()) && (N(e), U("workspace", e), typeof window < "u" && window.dispatchEvent(new CustomEvent("burdenoff:workspace-changed", { detail: { workspaceId: e } })));
180
+ }, [U]), G = m((e) => {
181
+ C("projectId", B.current, e, Date.now()) && (F(e), U("project", e), typeof window < "u" && window.dispatchEvent(new CustomEvent("burdenoff:project-changed", { detail: { projectId: e } })));
182
+ }, [U]), K = m((e) => {
183
+ C("tenantId", V.current, e, Date.now()) && (L(e), U("tenant", e));
184
+ }, [U]), q = m((e) => {
185
+ e.organizationId !== void 0 && H(e.organizationId), e.workspaceId !== void 0 && W(e.workspaceId), e.projectId !== void 0 && G(e.projectId), e.tenantId !== void 0 && K(e.tenantId);
172
186
  }, [
173
- B,
174
187
  H,
175
- U,
176
- W
177
- ]), K = p(() => {
178
- k(null), j(null), N(null), F(null), I.current = b(null), L.current = b(null), R.current = b(null), z.current = b(null), a(T);
188
+ W,
189
+ G,
190
+ K
191
+ ]), J = m(() => {
192
+ j(null), N(null), F(null), L(null), R.current = x(null), z.current = x(null), B.current = x(null), V.current = x(null), a(w);
179
193
  let e = t();
180
194
  e && n(e, {});
181
- }, [T]), q = h(() => ({
182
- organizationId: O,
183
- workspaceId: A,
184
- projectId: M,
185
- tenantId: P,
186
- setOrganization: B,
187
- setWorkspace: H,
188
- setProject: U,
189
- setTenant: W,
190
- setContext: G,
191
- clearContext: K,
192
- urlSyncEnabled: E
195
+ }, [w]), Y = g(() => ({
196
+ organizationId: A,
197
+ workspaceId: M,
198
+ projectId: P,
199
+ tenantId: I,
200
+ setOrganization: H,
201
+ setWorkspace: W,
202
+ setProject: G,
203
+ setTenant: K,
204
+ setContext: q,
205
+ clearContext: J,
206
+ urlSyncEnabled: T
193
207
  }), [
194
- O,
195
208
  A,
196
209
  M,
197
210
  P,
198
- B,
211
+ I,
199
212
  H,
200
- U,
201
213
  W,
202
214
  G,
203
215
  K,
204
- E
216
+ q,
217
+ J,
218
+ T
205
219
  ]);
206
- return /* @__PURE__ */ v(y.Provider, {
207
- value: q,
208
- children: u
220
+ return /* @__PURE__ */ y(b.Provider, {
221
+ value: Y,
222
+ children: c
209
223
  });
210
224
  }
211
- function T() {
212
- let e = f(y);
225
+ function k() {
226
+ let e = p(b);
213
227
  if (!e) throw Error("useActiveContext must be used within an ActiveContextProvider");
214
228
  return e;
215
229
  }
216
230
  //#endregion
217
- export { w as ActiveContextProvider, T as useActiveContext };
231
+ export { O as ActiveContextProvider, k as useActiveContext };
@@ -37,6 +37,31 @@ export declare function writeActiveContextStorageValue(field: ActiveContextStora
37
37
  */
38
38
  export declare function writeActiveContextFallback(field: ActiveContextStorageField, value: string | null, storageKey?: string): void;
39
39
  export declare function clearActiveContextStorage(storageKey?: string): void;
40
+ /** zustand `persist` name used by the microfe-auth store. */
41
+ export declare const AUTH_STORE_PERSIST_NAME = "auth-storage";
42
+ /** The subset of the persisted auth store usable as an ActiveContext fallback. */
43
+ export interface AuthStoreContextSnapshot {
44
+ organizationId: string | null;
45
+ workspaceId: string | null;
46
+ projectId: string | null;
47
+ }
48
+ /** localStorage key the microfe-auth store persists to for a given profile. */
49
+ export declare function getAuthStoreStorageKey(profileId: string): string;
50
+ /**
51
+ * Tolerantly parse a persisted auth-store payload. Any shape this does not
52
+ * recognise yields an all-null snapshot ("no fallback available"); it never
53
+ * throws.
54
+ */
55
+ export declare function parseAuthStoreContext(raw: string | null): AuthStoreContextSnapshot;
56
+ /**
57
+ * Read the persisted auth-store context for the active profile.
58
+ *
59
+ * Purely a read: unlike `readActiveContextStorageValue`, this never seeds
60
+ * sessionStorage or the profile context with what it finds. Profile
61
+ * resolution uses `resolveActiveProfileId()` — the same scheme the rest of
62
+ * this module uses — so the fallback can never come from another account.
63
+ */
64
+ export declare function readAuthStoreContext(): AuthStoreContextSnapshot;
40
65
  export declare function readActiveContextValueWithUrlPrecedence(field: ActiveContextStorageField, options?: {
41
66
  storageKey?: string;
42
67
  urlParam?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ActiveContextStorage.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/shell/ActiveContextStorage.ts"],"names":[],"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AC;CACnB,GACA,MAAM,GAAG,IAAI,CAOf;AAED,wBAAgB,yBAAyB,CACvC,UAAU,SAA6B,EACvC,SAAS,GAAE,sBAA0D,GACpE,qBAAqB,CAmBvB"}
1
+ {"version":3,"file":"ActiveContextStorage.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/shell/ActiveContextStorage.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,0BAA0B,6BAA6B,CAAC;AAErE,MAAM,MAAM,yBAAyB,GAAG,cAAc,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE5F,MAAM,WAAW,sBAAsB;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,sBAAsB,CAK9E,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AA6BD,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAO5D;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,yBAAyB,EAChC,UAAU,SAA6B,GACtC,MAAM,GAAG,IAAI,CAyBf;AAED,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,yBAAyB,EAChC,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,UAAU,SAA6B,GACtC,IAAI,CAaN;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,yBAAyB,EAChC,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,UAAU,SAA6B,GACtC,IAAI,CAWN;AAED,wBAAgB,yBAAyB,CAAC,UAAU,SAA6B,GAAG,IAAI,CAUvF;AAsBD,6DAA6D;AAC7D,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AAItD,kFAAkF;AAClF,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAeD,+EAA+E;AAC/E,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,wBAAwB,CAqBlF;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,IAAI,wBAAwB,CAe/D;AAED,wBAAgB,uCAAuC,CACrD,KAAK,EAAE,yBAAyB,EAChC,OAAO,CAAC,EAAE;IACR,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GACA,MAAM,GAAG,IAAI,CAOf;AAED,wBAAgB,yBAAyB,CACvC,UAAU,SAA6B,EACvC,SAAS,GAAE,sBAA0D,GACpE,qBAAqB,CAmBvB"}
@@ -54,8 +54,49 @@ function u(e = n) {
54
54
  sessionStorage.removeItem(n), localStorage.removeItem(n);
55
55
  }
56
56
  }
57
- function d(e, t) {
57
+ var d = "auth-storage", f = "bf-p";
58
+ function p() {
59
+ return {
60
+ organizationId: null,
61
+ workspaceId: null,
62
+ projectId: null
63
+ };
64
+ }
65
+ function m(e) {
66
+ return typeof e == "object" && !!e;
67
+ }
68
+ function h(e, t) {
69
+ let n = e[t];
70
+ return typeof n == "string" && n.length > 0 ? n : null;
71
+ }
72
+ function g(e) {
73
+ return `${f}-${e}-${d}`;
74
+ }
75
+ function _(e) {
76
+ if (!e) return p();
77
+ let t;
78
+ try {
79
+ t = JSON.parse(e);
80
+ } catch {
81
+ return p();
82
+ }
83
+ return !m(t) || !m(t.state) ? p() : {
84
+ organizationId: h(t.state, "currentOrganizationId"),
85
+ workspaceId: h(t.state, "currentWorkspaceId"),
86
+ projectId: h(t.state, "currentProjectId")
87
+ };
88
+ }
89
+ function v() {
90
+ if (typeof window > "u") return p();
91
+ try {
92
+ let e = t();
93
+ return e ? _(localStorage.getItem(g(e))) : p();
94
+ } catch {
95
+ return p();
96
+ }
97
+ }
98
+ function y(e, t) {
58
99
  return o(t?.urlParam ?? r[e]) || s(e, t?.storageKey ?? "burdenoff-active-context");
59
100
  }
60
101
  //#endregion
61
- export { n as ACTIVE_CONTEXT_STORAGE_KEY, r as DEFAULT_ACTIVE_CONTEXT_URL_PARAMS, u as clearActiveContextStorage, o as getUrlParam, s as readActiveContextStorageValue, d as readActiveContextValueWithUrlPrecedence, l as writeActiveContextFallback, c as writeActiveContextStorageValue };
102
+ export { n as ACTIVE_CONTEXT_STORAGE_KEY, r as DEFAULT_ACTIVE_CONTEXT_URL_PARAMS, u as clearActiveContextStorage, o as getUrlParam, s as readActiveContextStorageValue, y as readActiveContextValueWithUrlPrecedence, v as readAuthStoreContext, l as writeActiveContextFallback, c as writeActiveContextStorageValue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/fe-libs",
3
- "version": "2026.725.1",
3
+ "version": "2026.725.2",
4
4
  "description": "Burdenoff frontend primitives and domain libraries",
5
5
  "type": "module",
6
6
  "imports": {