@burdenoff/microfe-cosmicintersection 2026.1109.2 → 2026.1109.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CosmicIntersectionContext.d.ts","sourceRoot":"","sources":["../../../src/cosmicintersection/context/CosmicIntersectionContext.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAmD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CosmicIntersectionContext.d.ts","sourceRoot":"","sources":["../../../src/cosmicintersection/context/CosmicIntersectionContext.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAmD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAExF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAE5D,UAAU,8BAA8B;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,WAAW,EAAE,2BAA2B,CAAC,aAAa,CAAC,CAAC;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAID,UAAU,+BAA+B;IACvC,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,EAAE,2BAA2B,CAAC;CACpC;AAED,wBAAgB,0BAA0B,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,+BAA+B,+BA+E9F;AAED,wBAAgB,qBAAqB,mCAMpC;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,WA/G1B,MAAM,KAAK,IAAI,CA+HjC"}
|
|
@@ -1,51 +1,70 @@
|
|
|
1
1
|
import { createContext as e, useCallback as t, useContext as n, useMemo as r } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { appendContextToPath as i } from "@burdenoff/fe-libs/shared/hooks";
|
|
3
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
3
4
|
//#region src/cosmicintersection/context/CosmicIntersectionContext.tsx
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
let { basePath:
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
var o = e(null);
|
|
6
|
+
function s({ children: e, props: n }) {
|
|
7
|
+
let { basePath: s = "", navigate: c, currentUser: l, workspaceId: u, tenantId: d, organizationId: f, projectId: p, apiGatewayUrl: m, authToken: h } = n, g = s.endsWith("/") ? s.slice(0, -1) : s, _ = r(() => {
|
|
8
|
+
let e = new URLSearchParams(), t = [
|
|
9
|
+
["org", f],
|
|
10
|
+
["workspace", u],
|
|
11
|
+
["project", p],
|
|
12
|
+
["tenant", d]
|
|
13
|
+
];
|
|
14
|
+
for (let [n, r] of t) r && e.set(n, r);
|
|
15
|
+
return e;
|
|
16
|
+
}, [
|
|
17
|
+
f,
|
|
18
|
+
u,
|
|
19
|
+
p,
|
|
20
|
+
d
|
|
21
|
+
]), v = t((e) => {
|
|
22
|
+
if (!g || g === "/") {
|
|
23
|
+
c(i(e, _));
|
|
9
24
|
return;
|
|
10
25
|
}
|
|
11
|
-
if (e.startsWith(
|
|
12
|
-
|
|
26
|
+
if (e.startsWith(g)) {
|
|
27
|
+
c(i(e, _));
|
|
13
28
|
return;
|
|
14
29
|
}
|
|
15
|
-
let t = e.startsWith("/") ? `${
|
|
16
|
-
|
|
17
|
-
}, [
|
|
18
|
-
basePath: h,
|
|
19
|
-
navigate: g,
|
|
20
|
-
currentUser: c,
|
|
21
|
-
workspaceId: l,
|
|
22
|
-
tenantId: u,
|
|
23
|
-
organizationId: d,
|
|
24
|
-
projectId: f,
|
|
25
|
-
apiGatewayUrl: p || "",
|
|
26
|
-
authToken: m || ""
|
|
27
|
-
}), [
|
|
28
|
-
h,
|
|
30
|
+
let t = e.startsWith("/") ? `${g}${e}` : `${g}/${e}`;
|
|
31
|
+
c(i(t, _));
|
|
32
|
+
}, [
|
|
29
33
|
g,
|
|
30
34
|
c,
|
|
35
|
+
_
|
|
36
|
+
]), y = r(() => ({
|
|
37
|
+
basePath: g,
|
|
38
|
+
navigate: v,
|
|
39
|
+
currentUser: l,
|
|
40
|
+
workspaceId: u,
|
|
41
|
+
tenantId: d,
|
|
42
|
+
organizationId: f,
|
|
43
|
+
projectId: p,
|
|
44
|
+
apiGatewayUrl: m || "",
|
|
45
|
+
authToken: h || ""
|
|
46
|
+
}), [
|
|
47
|
+
g,
|
|
48
|
+
v,
|
|
31
49
|
l,
|
|
32
50
|
u,
|
|
33
51
|
d,
|
|
34
52
|
f,
|
|
35
53
|
p,
|
|
36
|
-
m
|
|
54
|
+
m,
|
|
55
|
+
h
|
|
37
56
|
]);
|
|
38
|
-
return /* @__PURE__ */
|
|
39
|
-
value:
|
|
57
|
+
return /* @__PURE__ */ a(o.Provider, {
|
|
58
|
+
value: y,
|
|
40
59
|
children: e
|
|
41
60
|
});
|
|
42
61
|
}
|
|
43
|
-
function
|
|
44
|
-
let e = n(
|
|
62
|
+
function c() {
|
|
63
|
+
let e = n(o);
|
|
45
64
|
if (!e) throw Error("useCosmicIntersection must be used within a CosmicIntersectionProvider");
|
|
46
65
|
return e;
|
|
47
66
|
}
|
|
48
67
|
//#endregion
|
|
49
|
-
export {
|
|
68
|
+
export { s as CosmicIntersectionProvider, c as useCosmicIntersection };
|
|
50
69
|
|
|
51
70
|
//# sourceMappingURL=CosmicIntersectionContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CosmicIntersectionContext.js","names":[],"sources":["../../../src/cosmicintersection/context/CosmicIntersectionContext.tsx"],"sourcesContent":["/**\n * CosmicIntersectionContext\n *\n * Provides basePath-aware navigation and shared props throughout the\n * CosmicIntersection microfrontend. Uses the `navigate` function injected by the\n * host app shell — no react-router hooks are needed here, so the same tree works\n * whether the shell drives routing or the local dev harness does.\n */\n\nimport { createContext, useCallback, useContext, useMemo, type ReactNode } from 'react';\nimport type { CosmicIntersectionRootProps } from '../types';\n\ninterface CosmicIntersectionContextValue {\n basePath: string;\n navigate: (path: string) => void;\n currentUser: CosmicIntersectionRootProps['currentUser'];\n workspaceId?: string;\n tenantId?: string;\n organizationId?: string;\n projectId?: string;\n apiGatewayUrl: string;\n authToken: string;\n}\n\nconst CosmicIntersectionContext = createContext<CosmicIntersectionContextValue | null>(null);\n\ninterface CosmicIntersectionProviderProps {\n children: ReactNode;\n props: CosmicIntersectionRootProps;\n}\n\nexport function CosmicIntersectionProvider({ children, props }: CosmicIntersectionProviderProps) {\n const {\n basePath = '',\n navigate: hostNavigate,\n currentUser,\n workspaceId,\n tenantId,\n organizationId,\n projectId,\n apiGatewayUrl,\n authToken,\n } = props;\n\n // Normalize basePath (strip trailing slash) so joins never produce `//`.\n const normalizedBasePath = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;\n\n
|
|
1
|
+
{"version":3,"file":"CosmicIntersectionContext.js","names":[],"sources":["../../../src/cosmicintersection/context/CosmicIntersectionContext.tsx"],"sourcesContent":["/**\n * CosmicIntersectionContext\n *\n * Provides basePath-aware navigation and shared props throughout the\n * CosmicIntersection microfrontend. Uses the `navigate` function injected by the\n * host app shell — no react-router hooks are needed here, so the same tree works\n * whether the shell drives routing or the local dev harness does.\n */\n\nimport { createContext, useCallback, useContext, useMemo, type ReactNode } from 'react';\nimport { appendContextToPath } from '@burdenoff/fe-libs/shared/hooks';\nimport type { CosmicIntersectionRootProps } from '../types';\n\ninterface CosmicIntersectionContextValue {\n basePath: string;\n navigate: (path: string) => void;\n currentUser: CosmicIntersectionRootProps['currentUser'];\n workspaceId?: string;\n tenantId?: string;\n organizationId?: string;\n projectId?: string;\n apiGatewayUrl: string;\n authToken: string;\n}\n\nconst CosmicIntersectionContext = createContext<CosmicIntersectionContextValue | null>(null);\n\ninterface CosmicIntersectionProviderProps {\n children: ReactNode;\n props: CosmicIntersectionRootProps;\n}\n\nexport function CosmicIntersectionProvider({ children, props }: CosmicIntersectionProviderProps) {\n const {\n basePath = '',\n navigate: hostNavigate,\n currentUser,\n workspaceId,\n tenantId,\n organizationId,\n projectId,\n apiGatewayUrl,\n authToken,\n } = props;\n\n // Normalize basePath (strip trailing slash) so joins never produce `//`.\n const normalizedBasePath = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;\n\n const contextParams = useMemo(() => {\n const params = new URLSearchParams();\n const pairs: Array<[string, string | undefined]> = [\n ['org', organizationId],\n ['workspace', workspaceId],\n ['project', projectId],\n ['tenant', tenantId],\n ];\n for (const [key, value] of pairs) {\n if (value) params.set(key, value);\n }\n return params;\n }, [organizationId, workspaceId, projectId, tenantId]);\n\n // Keep the host's captured context on the first navigation, before route sync.\n const navigate = useCallback(\n (path: string) => {\n if (!normalizedBasePath || normalizedBasePath === '/') {\n hostNavigate(appendContextToPath(path, contextParams));\n return;\n }\n if (path.startsWith(normalizedBasePath)) {\n hostNavigate(appendContextToPath(path, contextParams));\n return;\n }\n const fullPath = path.startsWith('/')\n ? `${normalizedBasePath}${path}`\n : `${normalizedBasePath}/${path}`;\n hostNavigate(appendContextToPath(fullPath, contextParams));\n },\n [normalizedBasePath, hostNavigate, contextParams]\n );\n\n const value = useMemo(\n () => ({\n basePath: normalizedBasePath,\n navigate,\n currentUser,\n workspaceId,\n tenantId,\n organizationId,\n projectId,\n apiGatewayUrl: apiGatewayUrl || '',\n authToken: authToken || '',\n }),\n [\n normalizedBasePath,\n navigate,\n currentUser,\n workspaceId,\n tenantId,\n organizationId,\n projectId,\n apiGatewayUrl,\n authToken,\n ]\n );\n\n return (\n <CosmicIntersectionContext.Provider value={value}>\n {children}\n </CosmicIntersectionContext.Provider>\n );\n}\n\nexport function useCosmicIntersection() {\n const context = useContext(CosmicIntersectionContext);\n if (!context) {\n throw new Error('useCosmicIntersection must be used within a CosmicIntersectionProvider');\n }\n return context;\n}\n\n/**\n * Hook for basePath-aware navigation. Returns a navigate function that\n * automatically prepends the microfrontend basePath. Falls back to a\n * `window.location`-based navigate if used outside the provider.\n */\nexport function useCosmicIntersectionNavigate() {\n const context = useContext(CosmicIntersectionContext);\n\n const fallbackNavigate = useCallback((path: string) => {\n const currentPath = window.location.pathname;\n const mfeMatch = currentPath.match(/^(\\/cosmicintersection)/);\n const basePath = mfeMatch ? mfeMatch[1] : '';\n\n let fullPath = path;\n if (basePath && !path.startsWith(basePath)) {\n fullPath = path.startsWith('/') ? `${basePath}${path}` : `${basePath}/${path}`;\n }\n window.location.href = fullPath;\n }, []);\n\n return context?.navigate ?? fallbackNavigate;\n}\n"],"mappings":";;;;AAyBA,IAAM,IAA4B,EAAqD,IAAI;AAO3F,SAAgB,EAA2B,EAAE,aAAU,YAA0C;CAC/F,IAAM,EACJ,cAAW,IACX,UAAU,GACV,gBACA,gBACA,aACA,mBACA,cACA,kBACA,iBACE,GAGE,IAAqB,EAAS,SAAS,GAAG,IAAI,EAAS,MAAM,GAAG,EAAE,IAAI,GAEtE,IAAgB,QAAc;EAClC,IAAM,IAAS,IAAI,gBAAgB,GAC7B,IAA6C;GACjD,CAAC,OAAO,CAAc;GACtB,CAAC,aAAa,CAAW;GACzB,CAAC,WAAW,CAAS;GACrB,CAAC,UAAU,CAAQ;EACrB;EACA,KAAK,IAAM,CAAC,GAAK,MAAU,GACzB,AAAI,KAAO,EAAO,IAAI,GAAK,CAAK;EAElC,OAAO;CACT,GAAG;EAAC;EAAgB;EAAa;EAAW;CAAQ,CAAC,GAG/C,IAAW,GACd,MAAiB;EAChB,IAAI,CAAC,KAAsB,MAAuB,KAAK;GACrD,EAAa,EAAoB,GAAM,CAAa,CAAC;GACrD;EACF;EACA,IAAI,EAAK,WAAW,CAAkB,GAAG;GACvC,EAAa,EAAoB,GAAM,CAAa,CAAC;GACrD;EACF;EACA,IAAM,IAAW,EAAK,WAAW,GAAG,IAChC,GAAG,IAAqB,MACxB,GAAG,EAAmB,GAAG;EAC7B,EAAa,EAAoB,GAAU,CAAa,CAAC;CAC3D,GACA;EAAC;EAAoB;EAAc;CAAa,CAClD,GAEM,IAAQ,SACL;EACL,UAAU;EACV;EACA;EACA;EACA;EACA;EACA;EACA,eAAe,KAAiB;EAChC,WAAW,KAAa;CAC1B,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,OACE,kBAAC,EAA0B,UAA3B;EAA2C;EACxC;CACiC,CAAA;AAExC;AAEA,SAAgB,IAAwB;CACtC,IAAM,IAAU,EAAW,CAAyB;CACpD,IAAI,CAAC,GACH,MAAU,MAAM,wEAAwE;CAE1F,OAAO;AACT"}
|