@pontive/pontkit-react 1.5.1 → 1.6.0
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/auth.d.ts +1 -1
- package/dist/coexistence-CEqhGd4-.js +170 -0
- package/dist/coexistence-CEqhGd4-.js.map +1 -0
- package/dist/coexistence-dvfn_5A6.cjs +2 -0
- package/dist/coexistence-dvfn_5A6.cjs.map +1 -0
- package/dist/coexistence.d.ts +19 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +53 -180
- package/dist/index.js.map +1 -1
- package/dist/pont2/elements.generated.d.ts +81 -0
- package/dist/pont2/index.d.ts +18 -0
- package/dist/pont2/provider.d.ts +71 -0
- package/dist/pont2/types.d.ts +118 -0
- package/dist/pont2.cjs +2 -0
- package/dist/pont2.cjs.map +1 -0
- package/dist/pont2.js +181 -0
- package/dist/pont2.js.map +1 -0
- package/dist/wrap.d.ts +24 -1
- package/package.json +9 -4
package/dist/index.js
CHANGED
|
@@ -1,198 +1,71 @@
|
|
|
1
|
-
import { forwardRef as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return C((e, o) => {
|
|
8
|
-
const r = y(null), l = y({}), [a, i] = w(null), { fallback: c, children: d, ...O } = e, P = {}, E = {};
|
|
9
|
-
for (const [s, f] of Object.entries(O))
|
|
10
|
-
(z.has(s) ? P : E)[s] = f;
|
|
11
|
-
m(() => {
|
|
12
|
-
n && j().catch(console.error);
|
|
13
|
-
}, []), k(() => {
|
|
14
|
-
const s = r.current;
|
|
15
|
-
if (!s) return;
|
|
16
|
-
let f = !1;
|
|
17
|
-
function b() {
|
|
18
|
-
if (!(f || !s)) {
|
|
19
|
-
for (const [A, g] of Object.entries(E))
|
|
20
|
-
if (l.current[A] !== g)
|
|
21
|
-
try {
|
|
22
|
-
s[A] = g, l.current[A] = g;
|
|
23
|
-
} catch {
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return customElements.get(t) ? b() : customElements.whenDefined(t).then(b), () => {
|
|
28
|
-
f = !0;
|
|
29
|
-
};
|
|
30
|
-
}), k(() => {
|
|
31
|
-
const s = r.current;
|
|
32
|
-
if (!s || c == null) return;
|
|
33
|
-
const f = document.createElement("div");
|
|
34
|
-
return f.setAttribute("part", "fallback"), s.prepend(f), i(f), () => {
|
|
35
|
-
f.remove(), i(null);
|
|
36
|
-
};
|
|
37
|
-
}, [c == null]);
|
|
38
|
-
function I(s) {
|
|
39
|
-
r.current = s, typeof o == "function" ? o(s) : o && (o.current = s);
|
|
40
|
-
}
|
|
41
|
-
return v(
|
|
42
|
-
t,
|
|
43
|
-
{ ...P, ref: I },
|
|
44
|
-
d ?? null,
|
|
45
|
-
a ? x(c, a) : null
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
const H = /* @__PURE__ */ u("pont-provider"), G = /* @__PURE__ */ u("pont-preview"), J = /* @__PURE__ */ u("pont-layout"), Q = /* @__PURE__ */ u("pont-signin"), R = /* @__PURE__ */ u("pont-signup"), T = /* @__PURE__ */ u("pont-account-settings"), X = /* @__PURE__ */ u("pont-member-management"), Y = /* @__PURE__ */ u("pont-account-menu"), Z = /* @__PURE__ */ u("pont-organization-switcher"), N = /* @__PURE__ */ u("pont-account-info"), tt = /* @__PURE__ */ u("pont-location-info"), nt = /* @__PURE__ */ u("pont-urls-info"), et = /* @__PURE__ */ u("pont-personal-info"), K = { isAuthenticated: !1, resolved: !1 }, L = D(
|
|
50
|
-
void 0
|
|
51
|
-
);
|
|
52
|
-
function M(t) {
|
|
53
|
-
const n = W(L);
|
|
54
|
-
if (n === void 0)
|
|
55
|
-
throw new Error(
|
|
56
|
-
`${t} was called outside <Provider>. Wrap your app in the Provider from @pontive/pontkit-react/react — the same component that configures \`env\`.`
|
|
57
|
-
);
|
|
58
|
-
return n;
|
|
59
|
-
}
|
|
60
|
-
function S() {
|
|
61
|
-
return M("useAuthState").auth;
|
|
62
|
-
}
|
|
63
|
-
function ot() {
|
|
64
|
-
return M("useEnvConfig").env;
|
|
65
|
-
}
|
|
66
|
-
function V(t, n) {
|
|
67
|
-
const [e, o] = w(K);
|
|
68
|
-
return m(() => {
|
|
69
|
-
if (!t) return;
|
|
70
|
-
let r = !1;
|
|
71
|
-
function l(c) {
|
|
72
|
-
r || !c || o(
|
|
73
|
-
(d) => d.isAuthenticated === c.isAuthenticated && d.resolved === c.resolved ? d : { isAuthenticated: !!c.isAuthenticated, resolved: !!c.resolved }
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
function a(c) {
|
|
77
|
-
l(c.detail);
|
|
78
|
-
}
|
|
79
|
-
t.addEventListener("pont:auth-changed", a);
|
|
80
|
-
function i() {
|
|
81
|
-
l(t?.auth);
|
|
82
|
-
}
|
|
83
|
-
return i(), customElements.whenDefined(n).then(i), () => {
|
|
84
|
-
r = !0, t.removeEventListener("pont:auth-changed", a);
|
|
85
|
-
};
|
|
86
|
-
}, [t, n]), e;
|
|
87
|
-
}
|
|
88
|
-
function F({
|
|
89
|
-
value: t,
|
|
90
|
-
children: n
|
|
91
|
-
}) {
|
|
92
|
-
return v(L.Provider, { value: t }, n);
|
|
93
|
-
}
|
|
94
|
-
function rt({
|
|
95
|
-
children: t,
|
|
96
|
-
fallback: n = null
|
|
97
|
-
}) {
|
|
98
|
-
const { isAuthenticated: e, resolved: o } = S();
|
|
99
|
-
return o ? e ? t : null : n;
|
|
100
|
-
}
|
|
101
|
-
function ct({
|
|
102
|
-
children: t,
|
|
103
|
-
fallback: n = null
|
|
104
|
-
}) {
|
|
105
|
-
const { isAuthenticated: e, resolved: o } = S();
|
|
106
|
-
return o ? e ? null : t : n;
|
|
107
|
-
}
|
|
108
|
-
function st({
|
|
109
|
-
children: t,
|
|
110
|
-
fallback: n = null
|
|
111
|
-
}) {
|
|
112
|
-
const { resolved: e } = S();
|
|
113
|
-
return e ? t : n;
|
|
114
|
-
}
|
|
115
|
-
function ut({
|
|
116
|
-
children: t,
|
|
117
|
-
loading: n = null,
|
|
118
|
-
redirectUrl: e,
|
|
119
|
-
onRedirect: o
|
|
120
|
-
}) {
|
|
121
|
-
const { auth: r, env: l } = M("Authenticated"), a = y(!1), i = e || l?.signinUrl;
|
|
122
|
-
return m(() => {
|
|
123
|
-
if (!(!r.resolved || r.isAuthenticated) && !a.current) {
|
|
124
|
-
if (!i) {
|
|
125
|
-
console.error(
|
|
126
|
-
"[pontive] <Authenticated> has nobody to redirect to: pass `redirectUrl`, or give the Provider an `env.signinUrl`."
|
|
127
|
-
);
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
a.current = !0, o ? o(i) : window.location.href = i;
|
|
131
|
-
}
|
|
132
|
-
}, [r.resolved, r.isAuthenticated, i, o]), r.resolved ? r.isAuthenticated ? t : null : n;
|
|
133
|
-
}
|
|
134
|
-
function p() {
|
|
1
|
+
import { forwardRef as m, useState as g, useMemo as A, createElement as r } from "react";
|
|
2
|
+
import { ensureCoreSdkLoaded as o } from "@pontive/pontkit-loader";
|
|
3
|
+
import { w as n, u as M, a as S, A as v } from "./coexistence-CEqhGd4-.js";
|
|
4
|
+
import { b as K, c as N, S as Q, d as R, e as T, f as X } from "./coexistence-CEqhGd4-.js";
|
|
5
|
+
const w = /* @__PURE__ */ n("pont-provider"), b = /* @__PURE__ */ n("pont-preview"), k = /* @__PURE__ */ n("pont-layout"), I = /* @__PURE__ */ n("pont-signin"), L = /* @__PURE__ */ n("pont-signup"), C = /* @__PURE__ */ n("pont-account-settings"), E = /* @__PURE__ */ n("pont-member-management"), x = /* @__PURE__ */ n("pont-account-menu"), z = /* @__PURE__ */ n("pont-organization-switcher"), O = /* @__PURE__ */ n("pont-account-info"), _ = /* @__PURE__ */ n("pont-location-info"), U = /* @__PURE__ */ n("pont-urls-info"), V = /* @__PURE__ */ n("pont-personal-info");
|
|
6
|
+
function e() {
|
|
135
7
|
return typeof window > "u" ? void 0 : window.__pontCoreSdk;
|
|
136
8
|
}
|
|
137
|
-
async function
|
|
138
|
-
await
|
|
9
|
+
async function W() {
|
|
10
|
+
await o(), e()?.openAccountSettingsModal?.();
|
|
139
11
|
}
|
|
140
|
-
async function
|
|
141
|
-
await
|
|
12
|
+
async function j() {
|
|
13
|
+
await o(), e()?.closeAccountSettingsModal?.();
|
|
142
14
|
}
|
|
143
|
-
async function
|
|
144
|
-
await
|
|
15
|
+
async function q() {
|
|
16
|
+
await o(), e()?.openMemberManagementModal?.();
|
|
145
17
|
}
|
|
146
|
-
async function
|
|
147
|
-
await
|
|
18
|
+
async function B() {
|
|
19
|
+
await o(), e()?.closeMemberManagementModal?.();
|
|
148
20
|
}
|
|
149
|
-
async function
|
|
150
|
-
await
|
|
21
|
+
async function D(t) {
|
|
22
|
+
await o(), e()?.setLocales?.(t);
|
|
151
23
|
}
|
|
152
|
-
function
|
|
153
|
-
const t =
|
|
24
|
+
function F() {
|
|
25
|
+
const t = e();
|
|
154
26
|
return typeof window > "u" ? null : t?.Auth ? t.Auth : (console.warn(
|
|
155
27
|
"Auth is not loaded yet! Make sure loadWebComponents() has completed."
|
|
156
28
|
), null);
|
|
157
29
|
}
|
|
158
|
-
const
|
|
159
|
-
({ children: t, ...
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
30
|
+
const G = m(
|
|
31
|
+
({ children: t, ...s }, c) => {
|
|
32
|
+
M("legacy");
|
|
33
|
+
const [l, p] = g(null), i = S(l, "pont-provider"), u = s.env ?? null, d = A(() => ({ auth: i, env: u }), [i, u]);
|
|
34
|
+
function f(a) {
|
|
35
|
+
p(a), typeof c == "function" ? c(a) : c && (c.current = a);
|
|
163
36
|
}
|
|
164
|
-
return
|
|
165
|
-
|
|
166
|
-
{ ...
|
|
167
|
-
v
|
|
37
|
+
return r(
|
|
38
|
+
w,
|
|
39
|
+
{ ...s, ref: f },
|
|
40
|
+
r(v, { value: d }, t)
|
|
168
41
|
);
|
|
169
42
|
}
|
|
170
43
|
);
|
|
171
44
|
export {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
45
|
+
O as AccountInfo,
|
|
46
|
+
x as AccountMenu,
|
|
47
|
+
C as AccountSettings,
|
|
48
|
+
K as AuthResolved,
|
|
49
|
+
N as Authenticated,
|
|
50
|
+
k as Layout,
|
|
51
|
+
_ as LocationInfo,
|
|
52
|
+
E as MemberManagement,
|
|
53
|
+
z as OrganizationSwitcher,
|
|
54
|
+
V as PersonalInfo,
|
|
55
|
+
b as Preview,
|
|
56
|
+
G as Provider,
|
|
57
|
+
Q as SignedIn,
|
|
58
|
+
R as SignedOut,
|
|
59
|
+
I as Signin,
|
|
60
|
+
L as Signup,
|
|
61
|
+
U as UrlsInfo,
|
|
62
|
+
j as closeAccountSettingsModalAsync,
|
|
63
|
+
B as closeMemberManagementModalAsync,
|
|
64
|
+
q as opeMemberManagementModalAsync,
|
|
65
|
+
W as openAccountSettingsModalAsync,
|
|
66
|
+
D as setLocales,
|
|
67
|
+
F as useAuthProvider,
|
|
68
|
+
T as useAuthState,
|
|
69
|
+
X as useEnvConfig
|
|
197
70
|
};
|
|
198
71
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/wrap.ts","../src/elements.generated.ts","../src/auth.ts","../src/index.ts"],"sourcesContent":["import React, {\n createElement,\n forwardRef,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { loadWebComponents } from \"@pontive/pontkit-loader\";\nimport type { ProviderProps as ReactProviderProps } from \"./types\";\n\n/**\n * React components over the custom elements the core SDK defines.\n *\n * One rule holds this file together, and every bug it used to have was a\n * violation of it: **React owns the tag, the element owns everything inside it,\n * and React never reconciles a node the element touches.**\n *\n * The version this replaces built `<pont-provider>` with `document.createElement`\n * and then spliced it into the page by hand:\n *\n * parent.replaceChild(providerEl, container);\n * providerEl.appendChild(container);\n *\n * That moves a div React rendered, and owns, underneath an element React has\n * never heard of. React keeps its own picture of the DOM and does not re-read\n * it, so from that moment its picture said the container was a child of\n * `<body>` while the browser said it was a child of `<pont-provider>`. The two\n * disagreed silently until React next placed a node against that container:\n *\n * NotFoundError: Failed to execute 'insertBefore' on 'Node': the node\n * before which the new node is to be inserted is not a child of this node.\n *\n * The throw lands in React's commit phase, which has no recovery — the tree is\n * abandoned mid-commit and the application disappears from the page. In a\n * Next.js app it fired on the first client-side navigation, so signing in\n * appeared to work and then left a blank document behind.\n *\n * Rendering the tag is both the fix and the simpler thing. A custom element is\n * inert until its definition arrives and upgrades in place when it does, so\n * there is nothing to wait for and nothing to move; the `sdkReady` gate that\n * used to hold every widget back until the CDN answered bought nothing and is\n * gone with it. Widgets now server-render as empty tags and fill themselves in\n * on upgrade, which is what a custom element is for.\n */\n\n/**\n * Props React sets itself, because they are ordinary DOM attributes rather than\n * component inputs. Everything else is assigned as a property — see below for\n * why that distinction cannot be left to React.\n */\nconst DOM_PROPS = new Set([\"className\", \"style\", \"id\", \"slot\"]);\n\ntype UnknownProps = Record<string, unknown>;\n\n/**\n * Everything here has to be in place before the element's first update, and a\n * passive effect is not.\n *\n * Lit schedules its update as a microtask when the element connects, which is\n * during React's commit; passive effects are flushed in a later task. On a cold\n * load nobody notices, because the element is waiting on the CDN and a network\n * round trip. On a client-side navigation, where the provider has already\n * resolved the session, the element updates and goes looking for its\n * placeholder immediately — and a placeholder created in a passive effect does\n * not exist yet, so the element never removes it and it stays on screen over\n * the finished widget. A layout effect runs synchronously in the commit, before\n * the stack unwinds and Lit's microtask gets its turn.\n *\n * On a server there is no layout to read, and React warns about useLayoutEffect\n * for that reason. useEffect is the same no-op without the noise.\n */\nconst useIsomorphicLayoutEffect =\n typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\nexport function wrap<T extends HTMLElement, P = {}>(tagName: string) {\n type Props = P &\n React.RefAttributes<T> &\n (P extends ReactProviderProps\n ? { children?: React.ReactNode }\n : {\n children?: React.ReactNode;\n fallback?: React.ReactNode | null;\n });\n\n const isProvider = tagName === \"pont-provider\";\n\n return forwardRef<T, Props>((props, forwardedRef) => {\n const elementRef = useRef<T | null>(null);\n const assigned = useRef<UnknownProps>({});\n const [fallbackHost, setFallbackHost] = useState<HTMLElement | null>(null);\n\n const { fallback, children, ...rest } = props as UnknownProps & {\n fallback?: React.ReactNode;\n children?: React.ReactNode;\n };\n\n const domProps: UnknownProps = {};\n const elementProps: UnknownProps = {};\n\n for (const [key, value] of Object.entries(rest)) {\n (DOM_PROPS.has(key) ? domProps : elementProps)[key] = value;\n }\n\n // The provider is the one component every app mounts, which makes it the\n // honest place to start the CDN fetch. Importing the root entry also kicks\n // it off, but the React entry can be imported on its own.\n useEffect(() => {\n if (!isProvider) return;\n loadWebComponents().catch(console.error);\n }, []);\n\n /**\n * Component inputs are assigned as DOM properties, once the tag is defined.\n *\n * Both halves of that matter. An attribute can only ever hold a string, so\n * `env` and `menuItems` cannot travel as one — and React 19's own custom\n * element support does not save us here, because it chooses between\n * property and attribute by testing `'env' in element`. The definitions\n * arrive from a CDN long after React first renders, so that test runs\n * against an un-upgraded element, finds no property, and writes the\n * attribute `env=\"[object Object]\"` for Lit to try to parse.\n *\n * Waiting for the definition is the other half. Assigning to an element\n * that has not upgraded writes an own property, and Lit's accessor — added\n * to the prototype at upgrade — is then shadowed by it for good: the value\n * sits on the element in plain sight and the component never observes it.\n */\n useIsomorphicLayoutEffect(() => {\n const el = elementRef.current;\n if (!el) return;\n\n let cancelled = false;\n\n function assign() {\n if (cancelled || !el) return;\n\n for (const [key, value] of Object.entries(elementProps)) {\n // Re-assigning an unchanged value would still mark the property\n // dirty and re-render the element on every React render.\n if (assigned.current[key] === value) continue;\n\n try {\n (el as unknown as UnknownProps)[key] = value;\n assigned.current[key] = value;\n } catch {\n // A read-only property on the element is the element's business.\n }\n }\n }\n\n if (customElements.get(tagName)) assign();\n else void customElements.whenDefined(tagName).then(assign);\n\n return () => {\n cancelled = true;\n };\n });\n\n /**\n * The fallback is rendered through a portal into a node built by hand.\n *\n * Every widget looks for a `[part=\"fallback\"]` child once it has something\n * real to show, and removes it — that is the placeholder's whole contract,\n * and `[pont-signin] fallback not found yet` on repeat is that search coming\n * up empty. But a React child that something else deletes is the same\n * desynchronised DOM described at the top of this file, so React cannot own\n * the node it hands over.\n *\n * A portal splits the difference: the host div is ours to give away, while\n * the content inside it stays an ordinary part of the React tree. When the\n * element deletes the host, React's nodes go with it into a detached\n * subtree it can still unmount from safely.\n *\n * The host is built after mount rather than during render, and that is not\n * a stylistic choice. Building it during render means branching on\n * `typeof document`, so the server renders no portal and the client's\n * hydration render does — React compares the two and reports\n *\n * Hydration failed because the server rendered HTML didn't match the\n * client\n *\n * naming the placeholder as the extra node. Creating it here keeps the\n * first client render identical to the server's; the state update below is\n * flushed synchronously before paint, so the placeholder still lands ahead\n * of the element's first update.\n *\n * The cost is that the placeholder does not server-render. The window it\n * covers is the CDN fetch, which is far longer than the one before\n * hydration, so this is nearly all of what the placeholder was for.\n */\n useIsomorphicLayoutEffect(() => {\n const el = elementRef.current;\n if (!el || fallback == null) return;\n\n const host = document.createElement(\"div\");\n host.setAttribute(\"part\", \"fallback\");\n el.prepend(host);\n setFallbackHost(host);\n\n return () => {\n // A no-op once the element has removed it, which is the ordinary case.\n host.remove();\n setFallbackHost(null);\n };\n }, [fallback == null]);\n\n function setRef(el: T | null) {\n elementRef.current = el;\n\n if (typeof forwardedRef === \"function\") forwardedRef(el);\n else if (forwardedRef) forwardedRef.current = el;\n }\n\n return createElement(\n tagName,\n { ...domProps, ref: setRef },\n children ?? null,\n fallbackHost ? createPortal(fallback, fallbackHost) : null,\n );\n });\n}\n","// GENERATED by tools/gen-wrappers — do not edit.\n//\n// Source: @pontive/pontkit-core@1.5.0 custom-elements.json.\n// Which elements are wrapped, and under what name, is in\n// tools/gen-wrappers/elements.config.mjs.\n//\n// The element classes are imported as TYPES only. This package must never\n// bundle core: the loader fetches it from the CDN at a release the platform\n// decides, so a value import here would ship a second, pinned copy.\nimport type {\n PontProvider,\n PreviewComponent as PontPreview,\n PontKitLayout as PontLayout,\n PontSignIn as PontSignin,\n PontSignUp as PontSignup,\n PontAccountSettings,\n PontMemberManagement,\n PontAccountMenu,\n PontOrganizationSwitcher,\n PontAccountInfo,\n PontLocationInfo,\n PontUrlsInfo,\n PontPersonalInfo,\n} from \"@pontive/pontkit-core\";\n\nimport { wrap } from \"./wrap\";\nimport type {\n ProviderProps,\n PreviewProps,\n LayoutProps,\n SignInProps,\n SignUpProps,\n AccountSettingsProps,\n MemberManagementProps,\n AccountMenuProps,\n OrganizationSwitcherProps,\n AccountInfoProps,\n LocationInfoProps,\n UrlsInfoProps,\n PersonalInfoProps,\n} from \"./types\";\n\nexport const ProviderElement = /* @__PURE__ */ wrap<PontProvider, ProviderProps>(\"pont-provider\");\nexport const Preview = /* @__PURE__ */ wrap<PontPreview, PreviewProps>(\"pont-preview\");\nexport const Layout = /* @__PURE__ */ wrap<PontLayout, LayoutProps>(\"pont-layout\");\nexport const Signin = /* @__PURE__ */ wrap<PontSignin, SignInProps>(\"pont-signin\");\nexport const Signup = /* @__PURE__ */ wrap<PontSignup, SignUpProps>(\"pont-signup\");\nexport const AccountSettings = /* @__PURE__ */ wrap<PontAccountSettings, AccountSettingsProps>(\"pont-account-settings\");\nexport const MemberManagement = /* @__PURE__ */ wrap<PontMemberManagement, MemberManagementProps>(\"pont-member-management\");\nexport const AccountMenu = /* @__PURE__ */ wrap<PontAccountMenu, AccountMenuProps>(\"pont-account-menu\");\nexport const OrganizationSwitcher = /* @__PURE__ */ wrap<PontOrganizationSwitcher, OrganizationSwitcherProps>(\"pont-organization-switcher\");\nexport const AccountInfo = /* @__PURE__ */ wrap<PontAccountInfo, AccountInfoProps>(\"pont-account-info\");\nexport const LocationInfo = /* @__PURE__ */ wrap<PontLocationInfo, LocationInfoProps>(\"pont-location-info\");\nexport const UrlsInfo = /* @__PURE__ */ wrap<PontUrlsInfo, UrlsInfoProps>(\"pont-urls-info\");\nexport const PersonalInfo = /* @__PURE__ */ wrap<PontPersonalInfo, PersonalInfoProps>(\"pont-personal-info\");\n","import React, {\n createContext,\n createElement,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport type { AuthState, EnvConfig } from \"@pontive/pontkit-core\";\n\n/**\n * The session, as React sees it.\n *\n * `<SignedIn>` and `<SignedOut>` used to be `<pont-signed-in>` and\n * `<pont-signed-out>`: custom elements that cached their child nodes on connect,\n * removed them, and re-rendered them inside a `<div>` of their own once the\n * session resolved. React went on believing those children were where it had\n * put them. Static children survived it; a child React later wanted to update\n * or remove was one it could no longer find — the same defect as the\n * `insertBefore` crash in `wrap()`, one level down.\n *\n * A control component has no business owning DOM at all. It is a question about\n * the session and a branch on the answer, so here it is a hook and a\n * conditional, and React keeps every node.\n *\n * The one thing that needs building is a way for React to see the session.\n * `pont-provider` publishes it on a Lit context, which nothing outside the custom\n * element tree can read, and `Auth` cannot answer instead: `resolved` means\n * \"restoreSession() has come back\", which is the provider's knowledge, not the\n * SDK's. So the provider also dispatches `pont:auth-changed`, and this file turns\n * that into React context.\n */\n\nconst UNRESOLVED: AuthState = { isAuthenticated: false, resolved: false };\n\ninterface PontKitContextValue {\n auth: AuthState;\n /**\n * Carried alongside the session because `<Authenticated>` needs it: its\n * default redirect target is `env.signinUrl`, which the element read from the\n * provider's Lit `envContext`. React has the same need and no way into that\n * context, and the Provider already holds `env` as a prop.\n */\n env: EnvConfig | null;\n}\n\n/**\n * `undefined` rather than a default value, so \"no Provider above me\" is a state\n * the hooks can tell apart from \"not resolved yet\". Defaulting to UNRESOLVED\n * would make a missing Provider look like a session that never resolves, and\n * every control component below it would render nothing forever without saying\n * why.\n */\nconst PontKitContext = createContext<PontKitContextValue | undefined>(\n undefined,\n);\n\nfunction usePontKitContext(caller: string): PontKitContextValue {\n const value = useContext(PontKitContext);\n\n if (value === undefined) {\n throw new Error(\n `${caller} was called outside <Provider>. Wrap your app in the Provider ` +\n \"from @pontive/pontkit-react/react — the same component that \" +\n \"configures `env`.\",\n );\n }\n\n return value;\n}\n\n/**\n * The current session state.\n *\n * Throws when there is no `<Provider>` above the caller, which is always a\n * wiring mistake rather than a state to handle.\n */\nexport function useAuthState(): AuthState {\n return usePontKitContext(\"useAuthState\").auth;\n}\n\n/** The `env` the nearest `<Provider>` was configured with. */\nexport function useEnvConfig(): EnvConfig | null {\n return usePontKitContext(\"useEnvConfig\").env;\n}\n\n/**\n * Tracks the session by listening to the provider element.\n *\n * Subscribing is not enough on its own: the provider resolves after a network\n * round trip, but nothing guarantees that happens *after* this listener is\n * attached — a Provider mounted into an application that is already running has\n * missed the event entirely. So the element's own `auth` property is read as a\n * seed, both immediately and once the definition has arrived, since before the\n * upgrade there is no property to read.\n */\nexport function useProviderAuthState(\n element: HTMLElement | null,\n tagName: string,\n): AuthState {\n const [auth, setAuth] = useState<AuthState>(UNRESOLVED);\n\n useEffect(() => {\n if (!element) return;\n\n let cancelled = false;\n\n function accept(next: AuthState | undefined) {\n if (cancelled || !next) return;\n\n setAuth((current) =>\n current.isAuthenticated === next.isAuthenticated &&\n current.resolved === next.resolved\n ? current\n : { isAuthenticated: !!next.isAuthenticated, resolved: !!next.resolved },\n );\n }\n\n function onAuthChanged(event: Event) {\n accept((event as CustomEvent<AuthState>).detail);\n }\n\n element.addEventListener(\"pont:auth-changed\", onAuthChanged);\n\n function seed() {\n accept((element as unknown as { auth?: AuthState } | null)?.auth);\n }\n\n seed();\n void customElements.whenDefined(tagName).then(seed);\n\n return () => {\n cancelled = true;\n element.removeEventListener(\"pont:auth-changed\", onAuthChanged);\n };\n }, [element, tagName]);\n\n return auth;\n}\n\nexport function AuthStateProvider({\n value,\n children,\n}: {\n value: PontKitContextValue;\n children?: React.ReactNode;\n}) {\n return createElement(PontKitContext.Provider, { value }, children);\n}\n\nexport interface ControlProps {\n children?: React.ReactNode;\n /**\n * What to render while the session is still being resolved.\n *\n * Both components render nothing during that window by default, because the\n * interim answer is \"signed out\" and showing the signed-out branch to a\n * signed-in user is the flash this is here to avoid.\n */\n fallback?: React.ReactNode | null;\n}\n\nexport function SignedIn({\n children,\n fallback = null,\n}: ControlProps): React.ReactNode {\n const { isAuthenticated, resolved } = useAuthState();\n\n if (!resolved) return fallback;\n\n return isAuthenticated ? children : null;\n}\n\nexport function SignedOut({\n children,\n fallback = null,\n}: ControlProps): React.ReactNode {\n const { isAuthenticated, resolved } = useAuthState();\n\n if (!resolved) return fallback;\n\n return isAuthenticated ? null : children;\n}\n\n/**\n * Renders its children once the session is known, and a placeholder until then.\n *\n * This replaces `<pont-auth-state>`, whose real job was pruning: it removed\n * whichever of `<pont-signed-in>` / `<pont-signed-out>` did not apply, permanently,\n * with `querySelectorAll(...).forEach(el => el.remove())`. Those tags are React\n * components now and never reach the DOM, so the search finds nothing — the\n * element still runs, and quietly does nothing at all.\n *\n * What is left is the half that was always worth having: one placeholder for a\n * group, instead of a `fallback` on every child. `<SignedIn>` and `<SignedOut>`\n * each gate on `resolved` themselves, so this is only about what fills the space\n * while the answer is in flight.\n *\n * Named for the flag it gates on rather than inheriting the element's name,\n * which described a state rather than a behaviour — and which collided with the\n * `AuthState` type.\n */\nexport function AuthResolved({\n children,\n fallback = null,\n}: ControlProps): React.ReactNode {\n const { resolved } = useAuthState();\n\n return resolved ? children : fallback;\n}\n\nexport interface AuthenticatedProps {\n children?: React.ReactNode;\n /**\n * Rendered while the session is being resolved.\n *\n * The element spelled this `slot=\"loading\"` and partitioned the children on\n * capture, because it stayed in the light DOM and so had no real `<slot>` to\n * use. A prop says the same thing without the machinery.\n */\n loading?: React.ReactNode;\n /** Where to send an unauthenticated visitor. Defaults to `env.signinUrl`. */\n redirectUrl?: string;\n /**\n * Hand the navigation to the host's router instead of loading a new document.\n *\n * The default is a full page load, which is what the element did. In a single\n * page application that throws away the router's state and everything else in\n * memory, so a host with a router should pass its own navigate here —\n * `(url) => navigate(url)` for React Router, `router.push` for Next.\n */\n onRedirect?: (url: string) => void;\n}\n\n/**\n * Renders its children only for a signed-in visitor, and sends everyone else to\n * the sign-in page.\n *\n * The redirect runs in an effect, which is the substantive change from the\n * element this replaces. That one assigned `window.location.href` from inside\n * `render()` — a side effect in a method the framework may call whenever it\n * likes, and which React would call twice in StrictMode. An effect fires once,\n * after the commit, on a transition that actually happened.\n */\nexport function Authenticated({\n children,\n loading = null,\n redirectUrl,\n onRedirect,\n}: AuthenticatedProps): React.ReactNode {\n const { auth, env } = usePontKitContext(\"Authenticated\");\n const redirected = useRef(false);\n\n const target = redirectUrl || env?.signinUrl;\n\n useEffect(() => {\n // Never on the interim answer. On a fresh page an app using HttpOnly cookie\n // delivery holds no session locally, so `isAuthenticated` is false for a\n // signed-in user right up until the cookie has been tried — redirecting on\n // that sends every reload and every post-sign-in return to the sign-in page.\n if (!auth.resolved || auth.isAuthenticated) return;\n\n // A redirect is not idempotent, and a re-render before the browser has\n // navigated would otherwise fire it again.\n if (redirected.current) return;\n\n if (!target) {\n console.error(\n \"[pontive] <Authenticated> has nobody to redirect to: pass \" +\n \"`redirectUrl`, or give the Provider an `env.signinUrl`.\",\n );\n return;\n }\n\n redirected.current = true;\n\n if (onRedirect) onRedirect(target);\n else window.location.href = target;\n }, [auth.resolved, auth.isAuthenticated, target, onRedirect]);\n\n if (!auth.resolved) return loading;\n\n // Nothing for the visitor being redirected. The navigation is in flight and\n // this content is not theirs to see.\n return auth.isAuthenticated ? children : null;\n}\n","import {\n AccountInfoProps,\n LayoutProps,\n LocationInfoProps,\n PersonalInfoProps,\n PreviewProps,\n ProviderProps,\n SignInProps,\n SignUpProps,\n UrlsInfoProps,\n AccountMenuProps,\n OrganizationSwitcherProps,\n OrganizationChangedDetail,\n AccountSettingsProps,\n MemberManagementProps,\n} from \"./types\";\nimport { createElement, forwardRef, useMemo, useState } from \"react\";\nimport { ensureCoreSdkLoaded } from \"@pontive/pontkit-loader\";\nimport { wrap } from \"./wrap\";\nimport type { PontProvider } from \"@pontive/pontkit-core\";\n\n// Re-exported for consumers. A host constructing the `env` object needs\n// EnvConfig, and useAuthState returns AuthState — without these the only way to\n// name either type is to install @pontive/pontkit-core, which is exactly what\n// this package exists to avoid: core is fetched from the CDN at a release the\n// platform picks, not installed and bundled by the app.\nexport type { EnvConfig, AuthState } from \"@pontive/pontkit-core\";\n\n// The element wrappers, generated from core's custom-elements.json by\n// tools/gen-wrappers. `npm run gen` rewrites it; `npm run gen -- --check`\n// fails when it has drifted from the installed core.\nexport {\n Preview,\n Layout,\n Signin,\n Signup,\n AccountSettings,\n MemberManagement,\n AccountMenu,\n OrganizationSwitcher,\n AccountInfo,\n LocationInfo,\n UrlsInfo,\n PersonalInfo,\n} from \"./elements.generated\";\nimport { ProviderElement } from \"./elements.generated\";\nimport { AuthStateProvider, useProviderAuthState } from \"./auth\";\n// The element classes, for typing only. `import type` matters: this package\n// must never BUNDLE core — the loader fetches it from the CDN at a release the\n// platform picks, so a value import here would ship a second, pinned copy.\nimport type { AuthService } from \"@pontive/oidc-client\";\n\n/**\n * The loaded SDK, or undefined when there is no browser to have loaded it.\n *\n * `ensureCoreSdkLoaded()` returns early on a server, but returning is not the\n * same as making the next line safe: reading `window.__pontCoreSdk` after it\n * still throws. Optional chaining does not help — `?.` guards the property, not\n * the undeclared identifier it hangs off.\n */\n/**\n * What this package uses off the loaded SDK.\n *\n * Deliberately NOT `Window[\"__pontCoreSdk\"]`. @pontive/pontkit-core declares\n * that global as five modal helpers, which is narrower than what is actually\n * there — the loader assigns the whole core module plus a wrapped `Auth`.\n * Reading the declared type therefore loses `Auth`, and widening core's\n * declaration to describe an entire module is not worth the coupling. This\n * states what the bindings need and nothing else.\n */\ntype CoreSdk = {\n Auth?: AuthService;\n setLocales?: (locales: string) => void;\n openAccountSettingsModal?: () => void;\n closeAccountSettingsModal?: () => void;\n openMemberManagementModal?: () => void;\n closeMemberManagementModal?: () => void;\n};\n\nfunction coreSdk(): CoreSdk | undefined {\n return typeof window === \"undefined\"\n ? undefined\n : (window as unknown as { __pontCoreSdk?: CoreSdk }).__pontCoreSdk;\n}\n\nexport async function openAccountSettingsModalAsync() {\n await ensureCoreSdkLoaded();\n coreSdk()?.openAccountSettingsModal?.();\n}\n\nexport async function closeAccountSettingsModalAsync() {\n await ensureCoreSdkLoaded();\n coreSdk()?.closeAccountSettingsModal?.();\n}\n\nexport async function opeMemberManagementModalAsync() {\n await ensureCoreSdkLoaded();\n coreSdk()?.openMemberManagementModal?.();\n}\n\nexport async function closeMemberManagementModalAsync() {\n await ensureCoreSdkLoaded();\n coreSdk()?.closeMemberManagementModal?.();\n}\n\nexport async function setLocales(locales: string) {\n await ensureCoreSdkLoaded();\n coreSdk()?.setLocales?.(locales);\n}\n\nexport function useAuthProvider() {\n const sdk = coreSdk();\n\n // Silent on a server. The warning below is for a browser that asked too\n // early, which is actionable; on a server there is no SDK to wait for and the\n // message would fire on every render while describing nothing wrong.\n if (typeof window === \"undefined\") {\n return null;\n }\n\n if (!sdk?.Auth) {\n console.warn(\n \"Auth is not loaded yet! Make sure loadWebComponents() has completed.\",\n );\n return null;\n }\n\n return sdk.Auth;\n}\n\n/**\n * Configures the SDK, and publishes the session to React.\n *\n * The element half is unchanged — `env` still travels to `<pont-provider>` through\n * `wrap()`, and the widgets still read everything they need from its Lit\n * contexts. What is added is the second audience: `<SignedIn>` and\n * `<SignedOut>` are ordinary React components now, so they need the session as\n * React context rather than as a Lit context only custom elements can see.\n *\n * Both come from the same value. The provider dispatches `pont:auth-changed`\n * whenever it writes its auth state, and this listens on the element it just\n * rendered.\n */\nexport const Provider = forwardRef<PontProvider, ProviderProps>(\n ({ children, ...props }, forwardedRef) => {\n const [element, setElement] = useState<PontProvider | null>(null);\n const auth = useProviderAuthState(element, \"pont-provider\");\n const env = (props as ProviderProps).env ?? null;\n const contextValue = useMemo(() => ({ auth, env }), [auth, env]);\n\n // State rather than a ref, because the subscription has to re-run when the\n // element arrives and a ref mutation does not re-render.\n function captureRef(el: PontProvider | null) {\n setElement(el);\n\n if (typeof forwardedRef === \"function\") forwardedRef(el);\n else if (forwardedRef) forwardedRef.current = el;\n }\n\n return createElement(\n ProviderElement,\n { ...(props as ProviderProps), ref: captureRef },\n createElement(AuthStateProvider, { value: contextValue }, children),\n );\n },\n);\n\n\n\n\n/**\n * `<SignedIn>` and `<SignedOut>` are React components rather than wrappers over\n * `<pont-signed-in>` / `<pont-signed-out>`, which cached their children on connect\n * and re-rendered them inside a `<div>` of their own — DOM React believed it\n * still owned. See ./auth.ts. The elements remain for the web-components entry.\n */\nexport {\n Authenticated,\n AuthResolved,\n SignedIn,\n SignedOut,\n useAuthState,\n useEnvConfig,\n} from \"./auth\";\nexport type { AuthenticatedProps, ControlProps } from \"./auth\";\n"],"names":["DOM_PROPS","useIsomorphicLayoutEffect","useLayoutEffect","useEffect","wrap","tagName","isProvider","forwardRef","props","forwardedRef","elementRef","useRef","assigned","fallbackHost","setFallbackHost","useState","fallback","children","rest","domProps","elementProps","key","value","loadWebComponents","el","cancelled","assign","host","setRef","createElement","createPortal","ProviderElement","Preview","Layout","Signin","Signup","AccountSettings","MemberManagement","AccountMenu","OrganizationSwitcher","AccountInfo","LocationInfo","UrlsInfo","PersonalInfo","UNRESOLVED","PontKitContext","createContext","usePontKitContext","caller","useContext","useAuthState","useEnvConfig","useProviderAuthState","element","auth","setAuth","accept","next","current","onAuthChanged","event","seed","AuthStateProvider","SignedIn","isAuthenticated","resolved","SignedOut","AuthResolved","Authenticated","loading","redirectUrl","onRedirect","env","redirected","target","coreSdk","openAccountSettingsModalAsync","ensureCoreSdkLoaded","closeAccountSettingsModalAsync","opeMemberManagementModalAsync","closeMemberManagementModalAsync","setLocales","locales","useAuthProvider","sdk","Provider","setElement","contextValue","useMemo","captureRef"],"mappings":";;;AAoDA,MAAMA,wBAAgB,IAAI,CAAC,aAAa,SAAS,MAAM,MAAM,CAAC,GAqBxDC,IACJ,OAAO,SAAW,MAAcC,IAAkBC;AAE7C,SAASC,EAAoCC,GAAiB;AAUnE,QAAMC,IAAaD,MAAY;AAE/B,SAAOE,EAAqB,CAACC,GAAOC,MAAiB;AACnD,UAAMC,IAAaC,EAAiB,IAAI,GAClCC,IAAWD,EAAqB,EAAE,GAClC,CAACE,GAAcC,CAAe,IAAIC,EAA6B,IAAI,GAEnE,EAAE,UAAAC,GAAU,UAAAC,GAAU,GAAGC,MAASV,GAKlCW,IAAyB,CAAA,GACzBC,IAA6B,CAAA;AAEnC,eAAW,CAACC,GAAKC,CAAK,KAAK,OAAO,QAAQJ,CAAI;AAC5C,OAAClB,EAAU,IAAIqB,CAAG,IAAIF,IAAWC,GAAcC,CAAG,IAAIC;AAMxD,IAAAnB,EAAU,MAAM;AACd,MAAKG,KACLiB,IAAoB,MAAM,QAAQ,KAAK;AAAA,IACzC,GAAG,CAAA,CAAE,GAkBLtB,EAA0B,MAAM;AAC9B,YAAMuB,IAAKd,EAAW;AACtB,UAAI,CAACc,EAAI;AAET,UAAIC,IAAY;AAEhB,eAASC,IAAS;AAChB,YAAI,EAAAD,KAAa,CAACD;AAElB,qBAAW,CAACH,GAAKC,CAAK,KAAK,OAAO,QAAQF,CAAY;AAGpD,gBAAIR,EAAS,QAAQS,CAAG,MAAMC;AAE9B,kBAAI;AACD,gBAAAE,EAA+BH,CAAG,IAAIC,GACvCV,EAAS,QAAQS,CAAG,IAAIC;AAAA,cAC1B,QAAQ;AAAA,cAER;AAAA;AAAA,MAEJ;AAEA,aAAI,eAAe,IAAIjB,CAAO,IAAGqB,EAAA,IACvB,eAAe,YAAYrB,CAAO,EAAE,KAAKqB,CAAM,GAElD,MA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pD,QAAMF,EAAA,GACNF,EAAA,GAAW,4BAAA;AACb;AAEA,eAAsBK,KAAkC;AACtD,QAAMH,EAAA,GACNF,EAAA,GAAW,6BAAA;AACb;AAEA,eAAsBM,GAAWC,GAAiB;AAChD,QAAML,EAAA,GACNF,EAAA,GAAW,aAAaO,CAAO;AACjC;AAEO,SAASC,KAAkB;AAChC,QAAMC,IAAMT,EAAA;AAKZ,SAAI,OAAO,SAAW,MACb,OAGJS,GAAK,OAOHA,EAAI,QANT,QAAQ;AAAA,IACN;AAAA,EAAA,GAEK;AAIX;AAeO,MAAMC,KAAW9E;AAAA,EACpB,CAAC,EAAE,UAAAU,GAAU,GAAGT,EAAA,GAASC,MAAiB;AAC1C,UAAM,CAAC4C,GAASiC,CAAU,IAAIvE,EAA8B,IAAI,GAC1DuC,IAAOF,EAAqBC,GAAS,eAAe,GACpDmB,IAAOhE,EAAwB,OAAO,MACtC+E,IAAeC,EAAQ,OAAO,EAAE,MAAAlC,GAAM,KAAAkB,MAAQ,CAAClB,GAAMkB,CAAG,CAAC;AAI/D,aAASiB,EAAWjE,GAAyB;AAC3C,MAAA8D,EAAW9D,CAAE,GAET,OAAOf,KAAiB,aAAYA,EAAae,CAAE,IAC9Cf,QAA2B,UAAUe;AAAA,IAChD;AAEA,WAAOK;AAAA,MACLE;AAAA,MACA,EAAE,GAAIvB,GAAyB,KAAKiF,EAAA;AAAA,MACpC5D,EAAciC,GAAmB,EAAE,OAAOyB,EAAA,GAAgBtE,CAAQ;AAAA,IAAA;AAAA,EAEtE;AACF;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/elements.generated.ts","../src/index.ts"],"sourcesContent":["// GENERATED by tools/gen-wrappers — do not edit.\n//\n// Source: @pontive/pontkit-core@1.41.0 custom-elements.json.\n// Which elements are wrapped, and under what name, is in\n// tools/gen-wrappers/elements.config.mjs.\n//\n// The element classes are imported as TYPES only. This package must never\n// bundle core: the loader fetches it from the CDN at a release the platform\n// decides, so a value import here would ship a second, pinned copy.\nimport type {\n PontProvider,\n PreviewComponent as PontPreview,\n PontKitLayout as PontLayout,\n PontSignIn as PontSignin,\n PontSignUp as PontSignup,\n PontAccountSettings,\n PontMemberManagement,\n PontAccountMenu,\n PontOrganizationSwitcher,\n PontAccountInfo,\n PontLocationInfo,\n PontUrlsInfo,\n PontPersonalInfo,\n} from \"@pontive/pontkit-core\";\n\nimport { wrap } from \"./wrap\";\nimport type {\n ProviderProps,\n PreviewProps,\n LayoutProps,\n SignInProps,\n SignUpProps,\n AccountSettingsProps,\n MemberManagementProps,\n AccountMenuProps,\n OrganizationSwitcherProps,\n AccountInfoProps,\n LocationInfoProps,\n UrlsInfoProps,\n PersonalInfoProps,\n} from \"./types\";\n\nexport const ProviderElement = /* @__PURE__ */ wrap<PontProvider, ProviderProps>(\"pont-provider\");\nexport const Preview = /* @__PURE__ */ wrap<PontPreview, PreviewProps>(\"pont-preview\");\nexport const Layout = /* @__PURE__ */ wrap<PontLayout, LayoutProps>(\"pont-layout\");\nexport const Signin = /* @__PURE__ */ wrap<PontSignin, SignInProps>(\"pont-signin\");\nexport const Signup = /* @__PURE__ */ wrap<PontSignup, SignUpProps>(\"pont-signup\");\nexport const AccountSettings = /* @__PURE__ */ wrap<PontAccountSettings, AccountSettingsProps>(\"pont-account-settings\");\nexport const MemberManagement = /* @__PURE__ */ wrap<PontMemberManagement, MemberManagementProps>(\"pont-member-management\");\nexport const AccountMenu = /* @__PURE__ */ wrap<PontAccountMenu, AccountMenuProps>(\"pont-account-menu\");\nexport const OrganizationSwitcher = /* @__PURE__ */ wrap<PontOrganizationSwitcher, OrganizationSwitcherProps>(\"pont-organization-switcher\");\nexport const AccountInfo = /* @__PURE__ */ wrap<PontAccountInfo, AccountInfoProps>(\"pont-account-info\");\nexport const LocationInfo = /* @__PURE__ */ wrap<PontLocationInfo, LocationInfoProps>(\"pont-location-info\");\nexport const UrlsInfo = /* @__PURE__ */ wrap<PontUrlsInfo, UrlsInfoProps>(\"pont-urls-info\");\nexport const PersonalInfo = /* @__PURE__ */ wrap<PontPersonalInfo, PersonalInfoProps>(\"pont-personal-info\");\n","import {\n AccountInfoProps,\n LayoutProps,\n LocationInfoProps,\n PersonalInfoProps,\n PreviewProps,\n ProviderProps,\n SignInProps,\n SignUpProps,\n UrlsInfoProps,\n AccountMenuProps,\n OrganizationSwitcherProps,\n OrganizationChangedDetail,\n AccountSettingsProps,\n MemberManagementProps,\n} from \"./types\";\nimport { createElement, forwardRef, useMemo, useState } from \"react\";\nimport { ensureCoreSdkLoaded } from \"@pontive/pontkit-loader\";\nimport { wrap } from \"./wrap\";\nimport type { PontProvider } from \"@pontive/pontkit-core\";\n\n// Re-exported for consumers. A host constructing the `env` object needs\n// EnvConfig, and useAuthState returns AuthState — without these the only way to\n// name either type is to install @pontive/pontkit-core, which is exactly what\n// this package exists to avoid: core is fetched from the CDN at a release the\n// platform picks, not installed and bundled by the app.\nexport type { EnvConfig, AuthState } from \"@pontive/pontkit-core\";\n\n// The element wrappers, generated from core's custom-elements.json by\n// tools/gen-wrappers. `npm run gen` rewrites it; `npm run gen -- --check`\n// fails when it has drifted from the installed core.\nexport {\n Preview,\n Layout,\n Signin,\n Signup,\n AccountSettings,\n MemberManagement,\n AccountMenu,\n OrganizationSwitcher,\n AccountInfo,\n LocationInfo,\n UrlsInfo,\n PersonalInfo,\n} from \"./elements.generated\";\nimport { ProviderElement } from \"./elements.generated\";\nimport { AuthStateProvider, useProviderAuthState } from \"./auth\";\nimport { useProviderPresence } from \"./coexistence\";\n// The element classes, for typing only. `import type` matters: this package\n// must never BUNDLE core — the loader fetches it from the CDN at a release the\n// platform picks, so a value import here would ship a second, pinned copy.\nimport type { AuthService } from \"@pontive/oidc-client\";\n\n/**\n * The loaded SDK, or undefined when there is no browser to have loaded it.\n *\n * `ensureCoreSdkLoaded()` returns early on a server, but returning is not the\n * same as making the next line safe: reading `window.__pontCoreSdk` after it\n * still throws. Optional chaining does not help — `?.` guards the property, not\n * the undeclared identifier it hangs off.\n */\n/**\n * What this package uses off the loaded SDK.\n *\n * Deliberately NOT `Window[\"__pontCoreSdk\"]`. @pontive/pontkit-core declares\n * that global as five modal helpers, which is narrower than what is actually\n * there — the loader assigns the whole core module plus a wrapped `Auth`.\n * Reading the declared type therefore loses `Auth`, and widening core's\n * declaration to describe an entire module is not worth the coupling. This\n * states what the bindings need and nothing else.\n */\ntype CoreSdk = {\n Auth?: AuthService;\n setLocales?: (locales: string) => void;\n openAccountSettingsModal?: () => void;\n closeAccountSettingsModal?: () => void;\n openMemberManagementModal?: () => void;\n closeMemberManagementModal?: () => void;\n};\n\nfunction coreSdk(): CoreSdk | undefined {\n return typeof window === \"undefined\"\n ? undefined\n : (window as unknown as { __pontCoreSdk?: CoreSdk }).__pontCoreSdk;\n}\n\nexport async function openAccountSettingsModalAsync() {\n await ensureCoreSdkLoaded();\n coreSdk()?.openAccountSettingsModal?.();\n}\n\nexport async function closeAccountSettingsModalAsync() {\n await ensureCoreSdkLoaded();\n coreSdk()?.closeAccountSettingsModal?.();\n}\n\nexport async function opeMemberManagementModalAsync() {\n await ensureCoreSdkLoaded();\n coreSdk()?.openMemberManagementModal?.();\n}\n\nexport async function closeMemberManagementModalAsync() {\n await ensureCoreSdkLoaded();\n coreSdk()?.closeMemberManagementModal?.();\n}\n\nexport async function setLocales(locales: string) {\n await ensureCoreSdkLoaded();\n coreSdk()?.setLocales?.(locales);\n}\n\nexport function useAuthProvider() {\n const sdk = coreSdk();\n\n // Silent on a server. The warning below is for a browser that asked too\n // early, which is actionable; on a server there is no SDK to wait for and the\n // message would fire on every render while describing nothing wrong.\n if (typeof window === \"undefined\") {\n return null;\n }\n\n if (!sdk?.Auth) {\n console.warn(\n \"Auth is not loaded yet! Make sure loadWebComponents() has completed.\",\n );\n return null;\n }\n\n return sdk.Auth;\n}\n\n/**\n * Configures the SDK, and publishes the session to React.\n *\n * The element half is unchanged — `env` still travels to `<pont-provider>` through\n * `wrap()`, and the widgets still read everything they need from its Lit\n * contexts. What is added is the second audience: `<SignedIn>` and\n * `<SignedOut>` are ordinary React components now, so they need the session as\n * React context rather than as a Lit context only custom elements can see.\n *\n * Both come from the same value. The provider dispatches `pont:auth-changed`\n * whenever it writes its auth state, and this listens on the element it just\n * rendered.\n */\nexport const Provider = forwardRef<PontProvider, ProviderProps>(\n ({ children, ...props }, forwardedRef) => {\n useProviderPresence(\"legacy\");\n const [element, setElement] = useState<PontProvider | null>(null);\n const auth = useProviderAuthState(element, \"pont-provider\");\n const env = (props as ProviderProps).env ?? null;\n const contextValue = useMemo(() => ({ auth, env }), [auth, env]);\n\n // State rather than a ref, because the subscription has to re-run when the\n // element arrives and a ref mutation does not re-render.\n function captureRef(el: PontProvider | null) {\n setElement(el);\n\n if (typeof forwardedRef === \"function\") forwardedRef(el);\n else if (forwardedRef) forwardedRef.current = el;\n }\n\n return createElement(\n ProviderElement,\n { ...(props as ProviderProps), ref: captureRef },\n createElement(AuthStateProvider, { value: contextValue }, children),\n );\n },\n);\n\n\n\n\n/**\n * `<SignedIn>` and `<SignedOut>` are React components rather than wrappers over\n * `<pont-signed-in>` / `<pont-signed-out>`, which cached their children on connect\n * and re-rendered them inside a `<div>` of their own — DOM React believed it\n * still owned. See ./auth.ts. The elements remain for the web-components entry.\n */\nexport {\n Authenticated,\n AuthResolved,\n SignedIn,\n SignedOut,\n useAuthState,\n useEnvConfig,\n} from \"./auth\";\nexport type { AuthenticatedProps, ControlProps } from \"./auth\";\n"],"names":["ProviderElement","Preview","Layout","Signin","Signup","AccountSettings","MemberManagement","AccountMenu","OrganizationSwitcher","AccountInfo","LocationInfo","UrlsInfo","PersonalInfo","coreSdk","openAccountSettingsModalAsync","ensureCoreSdkLoaded","closeAccountSettingsModalAsync","opeMemberManagementModalAsync","closeMemberManagementModalAsync","setLocales","locales","useAuthProvider","sdk","Provider","forwardRef","children","props","forwardedRef","useProviderPresence","element","setElement","useState","auth","useProviderAuthState","env","contextValue","useMemo","captureRef","el","createElement","AuthStateProvider"],"mappings":";;;;AA0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,GAAyB;AAC3C,MAAAR,EAAWQ,CAAE,GAET,OAAOX,KAAiB,aAAYA,EAAaW,CAAE,IAC9CX,QAA2B,UAAUW;AAAA,IAChD;AAEA,WAAOC;AAAA,MACLvC;AAAA,MACA,EAAE,GAAI0B,GAAyB,KAAKW,EAAA;AAAA,MACpCE,EAAcC,GAAmB,EAAE,OAAOL,EAAA,GAAgBV,CAAQ;AAAA,IAAA;AAAA,EAEtE;AACF;"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Provider as Pont2ProviderElement, SignIn as Pont2SigninElement, SignUp as Pont2SignupElement, Invitation as Pont2InvitationElement, Consent as Pont2ConsentElement, AccountMenu as Pont2AccountMenuElement, OrganizationSwitcher as Pont2OrganizationSwitcherElement, AccountSettings as Pont2AccountSettingsElement, MemberManagement as Pont2MemberManagementElement } from '@pontive/pontkit-core/pont2';
|
|
2
|
+
import { Pont2Event, ProviderElementProps, FlowWidgetProps, ConsentProps, AccountMenuProps, OrganizationSwitcherProps, AccountSettingsProps, MemberManagementProps } from './types';
|
|
3
|
+
export type { Pont2ProviderElement, Pont2SigninElement, Pont2SignupElement, Pont2InvitationElement, Pont2ConsentElement, Pont2AccountMenuElement, Pont2OrganizationSwitcherElement, Pont2AccountSettingsElement, Pont2MemberManagementElement, };
|
|
4
|
+
/** The `pont2-provider` events, as callback props. */
|
|
5
|
+
export interface ProviderElementEvents {
|
|
6
|
+
/** `pont2-auth-changed`: `AuthState` (a copy), whenever it changes */
|
|
7
|
+
onAuthChanged?: (event: Pont2Event<"pont2-auth-changed">) => void;
|
|
8
|
+
/** `pont2-locale-changed`: `{ locales }`, whenever the configured locales change */
|
|
9
|
+
onLocaleChanged?: (event: Pont2Event<"pont2-locale-changed">) => void;
|
|
10
|
+
/** `pont2-session-changed`: `{ reason, source, isAuthenticated, organizationId }`, on every SDK session change, here or in another tab (no tokens) */
|
|
11
|
+
onSessionChanged?: (event: Pont2Event<"pont2-session-changed">) => void;
|
|
12
|
+
/** `pont2-redirect`: `{ url }`, cancelable, before a post-sign-in navigation */
|
|
13
|
+
onRedirect?: (event: Pont2Event<"pont2-redirect">) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare const ProviderElement: import('react').ForwardRefExoticComponent<ProviderElementProps & ProviderElementEvents & import('react').RefAttributes<Pont2ProviderElement>>;
|
|
16
|
+
/** The `pont2-signin` events, as callback props. */
|
|
17
|
+
export interface SigninEvents {
|
|
18
|
+
/** `pont2-flow-response`: (from the layout) after every successful request */
|
|
19
|
+
onFlowResponse?: (event: Pont2Event<"pont2-flow-response">) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare const Signin: import('react').ForwardRefExoticComponent<FlowWidgetProps & SigninEvents & import('react').RefAttributes<Pont2SigninElement>>;
|
|
22
|
+
/** The `pont2-signup` events, as callback props. */
|
|
23
|
+
export interface SignupEvents {
|
|
24
|
+
/** `pont2-flow-response`: (from the layout) after every successful request */
|
|
25
|
+
onFlowResponse?: (event: Pont2Event<"pont2-flow-response">) => void;
|
|
26
|
+
}
|
|
27
|
+
export declare const Signup: import('react').ForwardRefExoticComponent<FlowWidgetProps & SignupEvents & import('react').RefAttributes<Pont2SignupElement>>;
|
|
28
|
+
/** The `pont2-invitation` events, as callback props. */
|
|
29
|
+
export interface InvitationEvents {
|
|
30
|
+
/** `pont2-flow-response`: (from the layout) after every successful request */
|
|
31
|
+
onFlowResponse?: (event: Pont2Event<"pont2-flow-response">) => void;
|
|
32
|
+
}
|
|
33
|
+
export declare const Invitation: import('react').ForwardRefExoticComponent<FlowWidgetProps & InvitationEvents & import('react').RefAttributes<Pont2InvitationElement>>;
|
|
34
|
+
/** The `pont2-consent` events, as callback props. */
|
|
35
|
+
export interface ConsentEvents {
|
|
36
|
+
}
|
|
37
|
+
export declare const Consent: import('react').ForwardRefExoticComponent<ConsentProps & ConsentEvents & import('react').RefAttributes<Pont2ConsentElement>>;
|
|
38
|
+
/** The `pont2-account-menu` events, as callback props. */
|
|
39
|
+
export interface AccountMenuEvents {
|
|
40
|
+
/** `pont2-account-settings`: cancelable, `{}`: "Account settings" was chosen */
|
|
41
|
+
onAccountSettings?: (event: Pont2Event<"pont2-account-settings">) => void;
|
|
42
|
+
/** `pont2-logout`: cancelable, `{}`: "Log out" was chosen */
|
|
43
|
+
onLogout?: (event: Pont2Event<"pont2-logout">) => void;
|
|
44
|
+
/** `pont2-menu-item-click`: cancelable `{ item, checked?, value? }`: one of `items` was chosen */
|
|
45
|
+
onMenuItemClick?: (event: Pont2Event<"pont2-menu-item-click">) => void;
|
|
46
|
+
/** `pont2-open-change`: cancelable `{ open, reason }` (the menu's) */
|
|
47
|
+
onOpenChange?: (event: Pont2Event<"pont2-open-change">) => void;
|
|
48
|
+
}
|
|
49
|
+
export declare const AccountMenu: import('react').ForwardRefExoticComponent<AccountMenuProps & AccountMenuEvents & import('react').RefAttributes<Pont2AccountMenuElement>>;
|
|
50
|
+
/** The `pont2-organization-switcher` events, as callback props. */
|
|
51
|
+
export interface OrganizationSwitcherEvents {
|
|
52
|
+
/** `pont2-organization-changed`: `{ organizationId, roles, permissions }`, after a switch */
|
|
53
|
+
onOrganizationChanged?: (event: Pont2Event<"pont2-organization-changed">) => void;
|
|
54
|
+
/** `pont2-organization-switch-failed`: `{ organizationId, error }`, when a switch is refused */
|
|
55
|
+
onOrganizationSwitchFailed?: (event: Pont2Event<"pont2-organization-switch-failed">) => void;
|
|
56
|
+
/** `pont2-open-change`: cancelable `{ open, reason }` (the menu's) */
|
|
57
|
+
onOpenChange?: (event: Pont2Event<"pont2-open-change">) => void;
|
|
58
|
+
}
|
|
59
|
+
export declare const OrganizationSwitcher: import('react').ForwardRefExoticComponent<OrganizationSwitcherProps & OrganizationSwitcherEvents & import('react').RefAttributes<Pont2OrganizationSwitcherElement>>;
|
|
60
|
+
/** The `pont2-account-settings` events, as callback props. */
|
|
61
|
+
export interface AccountSettingsEvents {
|
|
62
|
+
/** `pont2-profile-updated`: `{ section, profile }`, after a section was saved */
|
|
63
|
+
onProfileUpdated?: (event: Pont2Event<"pont2-profile-updated">) => void;
|
|
64
|
+
/** `pont2-open-change`: modal mode: cancelable `{ open, reason }` (the dialog's) */
|
|
65
|
+
onOpenChange?: (event: Pont2Event<"pont2-open-change">) => void;
|
|
66
|
+
}
|
|
67
|
+
export declare const AccountSettings: import('react').ForwardRefExoticComponent<AccountSettingsProps & AccountSettingsEvents & import('react').RefAttributes<Pont2AccountSettingsElement>>;
|
|
68
|
+
/** The `pont2-member-management` events, as callback props. */
|
|
69
|
+
export interface MemberManagementEvents {
|
|
70
|
+
/** `pont2-members-invited`: `{ organizationId, emails, roles, invitations }` */
|
|
71
|
+
onMembersInvited?: (event: Pont2Event<"pont2-members-invited">) => void;
|
|
72
|
+
/** `pont2-member-roles-updated`: `{ organizationId, userId, roles }` */
|
|
73
|
+
onMemberRolesUpdated?: (event: Pont2Event<"pont2-member-roles-updated">) => void;
|
|
74
|
+
/** `pont2-member-removed`: `{ organizationId, userId }` */
|
|
75
|
+
onMemberRemoved?: (event: Pont2Event<"pont2-member-removed">) => void;
|
|
76
|
+
/** `pont2-invitation-resent`: `{ organizationId, invitationId, email }` */
|
|
77
|
+
onInvitationResent?: (event: Pont2Event<"pont2-invitation-resent">) => void;
|
|
78
|
+
/** `pont2-invitation-revoked`: `{ organizationId, invitationId, email, notifyInvitee }` */
|
|
79
|
+
onInvitationRevoked?: (event: Pont2Event<"pont2-invitation-revoked">) => void;
|
|
80
|
+
}
|
|
81
|
+
export declare const MemberManagement: import('react').ForwardRefExoticComponent<MemberManagementProps & MemberManagementEvents & import('react').RefAttributes<Pont2MemberManagementElement>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@pontive/pontkit-react/pont2`: React components over the pont2 elements
|
|
3
|
+
* (`pont2-*`), beside the legacy ones at the package root.
|
|
4
|
+
*
|
|
5
|
+
* Mount one provider per page: this `Pont2Provider` or the root's `Provider`,
|
|
6
|
+
* never both (pontkit-core tracker W-15). At S7 pont2 is renamed `pont-` and
|
|
7
|
+
* this subpath becomes the root (bindings 2.0.0).
|
|
8
|
+
*
|
|
9
|
+
* Generated: the element wrappers and their `on…` event props
|
|
10
|
+
* (./elements.generated.ts, from core's pont2/custom-elements.json).
|
|
11
|
+
* Hand-written: the props (./types.ts), `Pont2Provider`, the hooks and the
|
|
12
|
+
* control components (./provider.ts).
|
|
13
|
+
*/
|
|
14
|
+
export { Signin, Signup, Invitation, Consent, AccountMenu, OrganizationSwitcher, AccountSettings, MemberManagement, } from './elements.generated';
|
|
15
|
+
export type { ProviderElementEvents as Pont2ProviderEvents, SigninEvents, SignupEvents, InvitationEvents, ConsentEvents, AccountMenuEvents, OrganizationSwitcherEvents, AccountSettingsEvents, MemberManagementEvents, Pont2ProviderElement, Pont2SigninElement, Pont2SignupElement, Pont2InvitationElement, Pont2ConsentElement, Pont2AccountMenuElement, Pont2OrganizationSwitcherElement, Pont2AccountSettingsElement, Pont2MemberManagementElement, } from './elements.generated';
|
|
16
|
+
export { Pont2Provider, usePont2Auth, usePont2Session, usePont2Sdk, SignedIn, SignedOut, AuthResolved, Authenticated, } from './provider';
|
|
17
|
+
export type { Pont2ProviderProps, ControlProps, AuthenticatedProps, } from './provider';
|
|
18
|
+
export type { Pont2Event, ProviderInputProps, FlowWidgetProps, ConsentProps, AccountMenuProps, OrganizationSwitcherProps, AccountSettingsProps, MemberManagementProps, AccountClient, AccountMenuItem, AuthState, ProviderSdk, SessionChange, WidgetClient, } from './types';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Pont2ProviderElement, ProviderElementEvents } from './elements.generated';
|
|
3
|
+
import { AuthState, ProviderInputProps, ProviderSdk, SessionChange } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* `<Pont2Provider>`: `<pont2-provider>` for React.
|
|
6
|
+
*
|
|
7
|
+
* What the element can't do for itself is get the SDK: pont2 never imports
|
|
8
|
+
* `Auth`, it is injected (`provider.sdk = Auth`, pontkit-core
|
|
9
|
+
* pont2/docs/kit/provider.md). This injects it, and turns the element's
|
|
10
|
+
* `pont2-auth-changed` / `pont2-session-changed` into React context, the way
|
|
11
|
+
* the legacy `<Provider>` turns `pont:auth-changed` into it.
|
|
12
|
+
*
|
|
13
|
+
* **Which `Auth`.** By default the one the loaded bundle carries
|
|
14
|
+
* (`window.__pontCoreSdk.Auth`, which the loader wraps so calls made before
|
|
15
|
+
* `configure()` wait for it). That is the SDK release the platform picked with
|
|
16
|
+
* the elements, and the only copy on the page, so nothing here bundles a
|
|
17
|
+
* second one. An app that installs `@pontive/oidc-client` itself can pass
|
|
18
|
+
* `sdk={Auth}` instead; then the provider configures without waiting for the
|
|
19
|
+
* CDN.
|
|
20
|
+
*/
|
|
21
|
+
export interface Pont2ProviderProps extends ProviderInputProps, ProviderElementEvents {
|
|
22
|
+
children?: React.ReactNode;
|
|
23
|
+
/** The auth SDK. Default: the loaded bundle's `Auth`. */
|
|
24
|
+
sdk?: ProviderSdk;
|
|
25
|
+
}
|
|
26
|
+
export declare const Pont2Provider: React.ForwardRefExoticComponent<Pont2ProviderProps & React.RefAttributes<Pont2ProviderElement>>;
|
|
27
|
+
/**
|
|
28
|
+
* The session as the nearest `<Pont2Provider>` knows it. `resolved` is false
|
|
29
|
+
* until `restoreSession()` has come back; act on nothing before it.
|
|
30
|
+
*/
|
|
31
|
+
export declare function usePont2Auth(): AuthState;
|
|
32
|
+
/**
|
|
33
|
+
* The last session change (`reason`: `signed-in`, `restored`, `refreshed`,
|
|
34
|
+
* `organization-changed`, `signed-out`, `expired`), here or in another tab.
|
|
35
|
+
* Null before the first. Use it to reload what depends on the organization.
|
|
36
|
+
*/
|
|
37
|
+
export declare function usePont2Session(): SessionChange | null;
|
|
38
|
+
/**
|
|
39
|
+
* The SDK the provider injected, for the calls the widgets don't make
|
|
40
|
+
* (`signOut()`, `getManagementToken()` …). Null until the bundle has loaded.
|
|
41
|
+
*/
|
|
42
|
+
export declare function usePont2Sdk(): ProviderSdk | null;
|
|
43
|
+
export interface ControlProps {
|
|
44
|
+
children?: React.ReactNode;
|
|
45
|
+
/** Rendered until the session is known (default: nothing). */
|
|
46
|
+
fallback?: React.ReactNode | null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Children for a signed-in user. A React component rather than a wrapper over
|
|
50
|
+
* `<pont2-signed-in>`, which detaches its children: nodes React must keep
|
|
51
|
+
* owning (provider.md: framework hosts branch on `pont2-auth-changed`).
|
|
52
|
+
*/
|
|
53
|
+
export declare function SignedIn({ children, fallback }: ControlProps): React.ReactNode;
|
|
54
|
+
/** Children for everyone else, once the session is known. */
|
|
55
|
+
export declare function SignedOut({ children, fallback }: ControlProps): React.ReactNode;
|
|
56
|
+
/** Children once the session is known; `fallback` until then. */
|
|
57
|
+
export declare function AuthResolved({ children, fallback }: ControlProps): React.ReactNode;
|
|
58
|
+
export interface AuthenticatedProps {
|
|
59
|
+
children?: React.ReactNode;
|
|
60
|
+
/** Rendered while the session is being resolved. */
|
|
61
|
+
loading?: React.ReactNode;
|
|
62
|
+
/** Where to send a signed-out visitor. Default: the provider's `signinUrl`. */
|
|
63
|
+
redirectUrl?: string;
|
|
64
|
+
/** Navigate with the app's router (`router.push`) instead of a page load. */
|
|
65
|
+
onRedirect?: (url: string) => void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Children for a signed-in user; everyone else is sent to the sign-in page,
|
|
69
|
+
* once the session has resolved (never on the interim "signed out").
|
|
70
|
+
*/
|
|
71
|
+
export declare function Authenticated({ children, loading, redirectUrl, onRedirect, }: AuthenticatedProps): React.ReactNode;
|