@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.
- package/dist/shared/providers/shell/ActiveContextProvider.d.ts +34 -0
- package/dist/shared/providers/shell/ActiveContextProvider.d.ts.map +1 -1
- package/dist/shared/providers/shell/ActiveContextProvider.js +127 -113
- 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
|
*/
|
|
@@ -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;
|
|
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,oC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;;;;;;;;;;;;;;;;;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,
|
|
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
|
|
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
|
|
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
|
|
30
|
+
function C(e, t, n, r) {
|
|
31
31
|
if (t.current === n) return !1;
|
|
32
|
-
if (r < t.suppressUntil) return
|
|
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,
|
|
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
|
|
37
|
-
|
|
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
|
|
44
|
-
let [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
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
|
-
}), [
|
|
70
|
-
if (typeof window > "u") return
|
|
71
|
-
if (
|
|
72
|
-
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);
|
|
73
94
|
if (e) return e;
|
|
74
95
|
}
|
|
75
|
-
return s("
|
|
76
|
-
}),
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
98
|
-
|
|
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:
|
|
104
|
-
workspaceId:
|
|
105
|
-
projectId:
|
|
106
|
-
tenantId:
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
[
|
|
118
|
-
[
|
|
119
|
-
[
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
139
|
+
I,
|
|
140
|
+
T,
|
|
141
|
+
O
|
|
142
|
+
]), h(() => {
|
|
143
|
+
if (!T) return;
|
|
130
144
|
let e = () => {
|
|
131
|
-
let e = o(
|
|
132
|
-
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);
|
|
133
147
|
};
|
|
134
148
|
return window.addEventListener("popstate", e), () => window.removeEventListener("popstate", e);
|
|
135
149
|
}, [
|
|
136
|
-
|
|
137
|
-
D,
|
|
150
|
+
T,
|
|
138
151
|
O,
|
|
139
152
|
A,
|
|
140
153
|
M,
|
|
141
|
-
P
|
|
154
|
+
P,
|
|
155
|
+
I
|
|
142
156
|
]);
|
|
143
|
-
let
|
|
144
|
-
if (!
|
|
145
|
-
|
|
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
|
-
}, []),
|
|
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
|
-
|
|
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" &&
|
|
164
|
-
}, [
|
|
165
|
-
|
|
166
|
-
}, [
|
|
167
|
-
|
|
168
|
-
}, [
|
|
169
|
-
|
|
170
|
-
}, [
|
|
171
|
-
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);
|
|
172
186
|
}, [
|
|
173
|
-
B,
|
|
174
187
|
H,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
}, [
|
|
182
|
-
organizationId:
|
|
183
|
-
workspaceId:
|
|
184
|
-
projectId:
|
|
185
|
-
tenantId:
|
|
186
|
-
setOrganization:
|
|
187
|
-
setWorkspace:
|
|
188
|
-
setProject:
|
|
189
|
-
setTenant:
|
|
190
|
-
setContext:
|
|
191
|
-
clearContext:
|
|
192
|
-
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
|
|
193
207
|
}), [
|
|
194
|
-
O,
|
|
195
208
|
A,
|
|
196
209
|
M,
|
|
197
210
|
P,
|
|
198
|
-
|
|
211
|
+
I,
|
|
199
212
|
H,
|
|
200
|
-
U,
|
|
201
213
|
W,
|
|
202
214
|
G,
|
|
203
215
|
K,
|
|
204
|
-
|
|
216
|
+
q,
|
|
217
|
+
J,
|
|
218
|
+
T
|
|
205
219
|
]);
|
|
206
|
-
return /* @__PURE__ */
|
|
207
|
-
value:
|
|
208
|
-
children:
|
|
220
|
+
return /* @__PURE__ */ y(b.Provider, {
|
|
221
|
+
value: Y,
|
|
222
|
+
children: c
|
|
209
223
|
});
|
|
210
224
|
}
|
|
211
|
-
function
|
|
212
|
-
let e =
|
|
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 {
|
|
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,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,wBAA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qB,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 };
|