@burdenoff/fe-libs 2026.723.5 → 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.
- package/dist/shared/providers/shell/ActiveContextProvider.d.ts +52 -0
- package/dist/shared/providers/shell/ActiveContextProvider.d.ts.map +1 -1
- package/dist/shared/providers/shell/ActiveContextProvider.js +166 -117
- package/dist/shared/providers/shell/ActiveContextStorage.d.ts +25 -0
- package/dist/shared/providers/shell/ActiveContextStorage.d.ts.map +1 -1
- package/dist/shared/providers/shell/ActiveContextStorage.js +43 -2
- package/package.json +1 -1
|
@@ -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
|
*/
|
|
@@ -53,6 +54,57 @@ export interface ActiveContextProviderProps {
|
|
|
53
54
|
tenant?: string;
|
|
54
55
|
};
|
|
55
56
|
}
|
|
57
|
+
export declare const CONTEXT_THRASH_WINDOW_MS = 500;
|
|
58
|
+
export declare const CONTEXT_THRASH_MAX_FLIPS = 3;
|
|
59
|
+
export interface ContextFieldThrashState {
|
|
60
|
+
current: string | null;
|
|
61
|
+
previous: string | null;
|
|
62
|
+
flips: number;
|
|
63
|
+
windowStart: number;
|
|
64
|
+
suppressUntil: number;
|
|
65
|
+
}
|
|
66
|
+
export declare function createContextFieldThrashState(initial: string | null): ContextFieldThrashState;
|
|
67
|
+
/**
|
|
68
|
+
* Decides whether `nextValue` should be applied to a context field, mutating
|
|
69
|
+
* `state` to reflect the decision. Returns `false` for a true no-op (value
|
|
70
|
+
* unchanged), while an active suppression window is in effect, or when this
|
|
71
|
+
* write is detected as the Nth rapid alternation back to the field's prior
|
|
72
|
+
* value — the ping-pong signature described above.
|
|
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;
|
|
56
108
|
/**
|
|
57
109
|
* ActiveContextProvider
|
|
58
110
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActiveContextProvider.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/shell/ActiveContextProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,GAAG,IAAI,CAAC;KACzB,CAAC,KACC,IAAI,CAAC;IAEV,+BAA+B;IAC/B,YAAY,EA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AsBD,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,32 +1,81 @@
|
|
|
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,
|
|
3
|
-
import { isSsoNavigationPending as
|
|
4
|
-
import { createContext as
|
|
5
|
-
import { jsx as
|
|
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
|
|
8
|
-
function
|
|
9
|
-
|
|
7
|
+
var b = f(null);
|
|
8
|
+
function x(e) {
|
|
9
|
+
return {
|
|
10
|
+
current: e,
|
|
11
|
+
previous: null,
|
|
12
|
+
flips: 0,
|
|
13
|
+
windowStart: 0,
|
|
14
|
+
suppressUntil: 0
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function S() {
|
|
18
|
+
try {
|
|
19
|
+
return !!{
|
|
20
|
+
BASE_URL: "/",
|
|
21
|
+
DEV: !1,
|
|
22
|
+
MODE: "production",
|
|
23
|
+
PROD: !0,
|
|
24
|
+
SSR: !1
|
|
25
|
+
}?.DEV;
|
|
26
|
+
} catch {
|
|
27
|
+
return !1;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function C(e, t, n, r) {
|
|
31
|
+
if (t.current === n) return !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
|
+
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, 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
|
+
}
|
|
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;
|
|
10
66
|
let t = new URL(window.location.href);
|
|
11
67
|
Object.entries(e).forEach(([e, n]) => {
|
|
12
68
|
n ? t.searchParams.set(e, n) : t.searchParams.delete(e);
|
|
13
69
|
}), window.history.replaceState({}, "", t.toString());
|
|
14
70
|
}
|
|
15
|
-
function
|
|
16
|
-
let [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
return s("organization", S) || d;
|
|
23
|
-
}), [D, O] = g(() => {
|
|
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(() => {
|
|
24
77
|
if (typeof window > "u") return f;
|
|
25
|
-
|
|
26
|
-
let e = o(w.workspace);
|
|
27
|
-
if (e) return e;
|
|
28
|
-
}
|
|
29
|
-
let r = s("workspace", S) || f;
|
|
78
|
+
let r = k.workspaceId ?? f;
|
|
30
79
|
if (r) {
|
|
31
80
|
let i = t();
|
|
32
81
|
if (i) {
|
|
@@ -38,145 +87,145 @@ function b({ children: u, defaultOrganizationId: d = null, defaultWorkspaceId: f
|
|
|
38
87
|
}
|
|
39
88
|
}
|
|
40
89
|
return r;
|
|
41
|
-
}), [k,
|
|
42
|
-
if (typeof window > "u") return
|
|
43
|
-
if (
|
|
44
|
-
let e = o(
|
|
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);
|
|
45
94
|
if (e) return e;
|
|
46
95
|
}
|
|
47
|
-
return s("
|
|
48
|
-
}),
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
l("organization", T, S), l("workspace", D, S), l("project", k, S), l("tenant", j, S);
|
|
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);
|
|
58
106
|
}, [
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
]),
|
|
107
|
+
A,
|
|
108
|
+
M,
|
|
109
|
+
P,
|
|
110
|
+
I,
|
|
111
|
+
w
|
|
112
|
+
]), h(() => {
|
|
65
113
|
let r = t();
|
|
66
114
|
if (!r) return;
|
|
67
115
|
let i = e(r), a = {
|
|
68
116
|
...i,
|
|
69
|
-
organizationId:
|
|
70
|
-
workspaceId:
|
|
71
|
-
projectId:
|
|
72
|
-
tenantId:
|
|
117
|
+
organizationId: A,
|
|
118
|
+
workspaceId: M,
|
|
119
|
+
projectId: P,
|
|
120
|
+
tenantId: I
|
|
73
121
|
};
|
|
74
122
|
i?.organizationId === a.organizationId && i?.workspaceId === a.workspaceId && i?.projectId === a.projectId && i?.tenantId === a.tenantId || n(r, a);
|
|
75
123
|
}, [
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
]),
|
|
81
|
-
|
|
82
|
-
[
|
|
83
|
-
[
|
|
84
|
-
[
|
|
85
|
-
[
|
|
124
|
+
A,
|
|
125
|
+
M,
|
|
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
|
|
86
134
|
});
|
|
87
135
|
}, [
|
|
136
|
+
A,
|
|
137
|
+
M,
|
|
138
|
+
P,
|
|
139
|
+
I,
|
|
88
140
|
T,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
C,
|
|
93
|
-
w
|
|
94
|
-
]), m(() => {
|
|
95
|
-
if (!C) return;
|
|
141
|
+
O
|
|
142
|
+
]), h(() => {
|
|
143
|
+
if (!T) return;
|
|
96
144
|
let e = () => {
|
|
97
|
-
let e = o(
|
|
98
|
-
e !==
|
|
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);
|
|
99
147
|
};
|
|
100
148
|
return window.addEventListener("popstate", e), () => window.removeEventListener("popstate", e);
|
|
101
149
|
}, [
|
|
102
|
-
C,
|
|
103
|
-
w,
|
|
104
150
|
T,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
151
|
+
O,
|
|
152
|
+
A,
|
|
153
|
+
M,
|
|
154
|
+
P,
|
|
155
|
+
I
|
|
108
156
|
]);
|
|
109
|
-
let
|
|
110
|
-
|
|
157
|
+
let H = m((r) => {
|
|
158
|
+
if (!C("organizationId", R.current, r, Date.now())) return;
|
|
159
|
+
j(r);
|
|
111
160
|
let i = t();
|
|
112
161
|
i && n(i, {
|
|
113
162
|
...e(i),
|
|
114
163
|
organizationId: r
|
|
115
164
|
}), typeof window < "u" && window.dispatchEvent(new CustomEvent("burdenoff:organization-changed", { detail: { organizationId: r } }));
|
|
116
|
-
}, []),
|
|
165
|
+
}, []), U = m((r, i) => {
|
|
117
166
|
let a = {
|
|
118
167
|
organization: "organizationId",
|
|
119
168
|
workspace: "workspaceId",
|
|
120
169
|
project: "projectId",
|
|
121
170
|
tenant: "tenantId"
|
|
122
171
|
};
|
|
123
|
-
|
|
172
|
+
u(r, i, w);
|
|
124
173
|
let o = t();
|
|
125
174
|
o ? n(o, {
|
|
126
175
|
...e(o),
|
|
127
176
|
[a[r]]: i
|
|
128
|
-
}) : typeof window < "u" &&
|
|
129
|
-
}, [
|
|
130
|
-
|
|
131
|
-
}, [
|
|
132
|
-
|
|
133
|
-
}, [
|
|
134
|
-
|
|
135
|
-
}, [
|
|
136
|
-
e.organizationId !== void 0 &&
|
|
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);
|
|
137
186
|
}, [
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
]),
|
|
143
|
-
|
|
187
|
+
H,
|
|
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);
|
|
144
193
|
let e = t();
|
|
145
194
|
e && n(e, {});
|
|
146
|
-
}, [
|
|
147
|
-
organizationId:
|
|
148
|
-
workspaceId:
|
|
149
|
-
projectId:
|
|
150
|
-
tenantId:
|
|
151
|
-
setOrganization:
|
|
152
|
-
setWorkspace:
|
|
153
|
-
setProject:
|
|
154
|
-
setTenant:
|
|
155
|
-
setContext:
|
|
156
|
-
clearContext:
|
|
157
|
-
urlSyncEnabled:
|
|
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
|
|
158
207
|
}), [
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
j,
|
|
163
|
-
N,
|
|
164
|
-
F,
|
|
208
|
+
A,
|
|
209
|
+
M,
|
|
210
|
+
P,
|
|
165
211
|
I,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
212
|
+
H,
|
|
213
|
+
W,
|
|
214
|
+
G,
|
|
215
|
+
K,
|
|
216
|
+
q,
|
|
217
|
+
J,
|
|
218
|
+
T
|
|
170
219
|
]);
|
|
171
|
-
return /* @__PURE__ */
|
|
172
|
-
value:
|
|
173
|
-
children:
|
|
220
|
+
return /* @__PURE__ */ y(b.Provider, {
|
|
221
|
+
value: Y,
|
|
222
|
+
children: c
|
|
174
223
|
});
|
|
175
224
|
}
|
|
176
|
-
function
|
|
177
|
-
let e =
|
|
225
|
+
function k() {
|
|
226
|
+
let e = p(b);
|
|
178
227
|
if (!e) throw Error("useActiveContext must be used within an ActiveContextProvider");
|
|
179
228
|
return e;
|
|
180
229
|
}
|
|
181
230
|
//#endregion
|
|
182
|
-
export {
|
|
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":[],"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;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"}
|
|
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,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C,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
|
-
|
|
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,
|
|
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 };
|