@pontive/pontkit-react 1.0.0 → 1.0.1
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/elements.generated.d.ts +49 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -46
- package/dist/index.js +43 -43
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { PontProvider, PreviewComponent as PontPreview, PontKitLayout as PontLayout, PontSignIn as PontSignin, PontSignUp as PontSignup, PontAccountSettings, PontMemberManagement, PontNavUser, PontAccountInfo, PontLocationInfo, PontUrlsInfo, PontPersonalInfo } from '@pontive/pontkit-core';
|
|
2
|
+
import { ProviderProps, PreviewProps, LayoutProps, SignInProps, SignUpProps, AccountSettingsProps, MemberManagementProps, NavUserProps, AccountInfoProps, LocationInfoProps, UrlsInfoProps, PersonalInfoProps } from './types';
|
|
3
|
+
export declare const ProviderElement: import('react').ForwardRefExoticComponent<Omit<ProviderProps & import('react').RefAttributes<PontProvider> & {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
}, "ref"> & import('react').RefAttributes<PontProvider>>;
|
|
6
|
+
export declare const Preview: import('react').ForwardRefExoticComponent<Omit<PreviewProps & import('react').RefAttributes<PontPreview> & {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
fallback?: React.ReactNode | null;
|
|
9
|
+
}, "ref"> & import('react').RefAttributes<PontPreview>>;
|
|
10
|
+
export declare const Layout: import('react').ForwardRefExoticComponent<Omit<LayoutProps & import('react').RefAttributes<PontLayout> & {
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
fallback?: React.ReactNode | null;
|
|
13
|
+
}, "ref"> & import('react').RefAttributes<PontLayout>>;
|
|
14
|
+
export declare const Signin: import('react').ForwardRefExoticComponent<Omit<SignInProps & import('react').RefAttributes<PontSignin> & {
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
fallback?: React.ReactNode | null;
|
|
17
|
+
}, "ref"> & import('react').RefAttributes<PontSignin>>;
|
|
18
|
+
export declare const Signup: import('react').ForwardRefExoticComponent<Omit<SignUpProps & import('react').RefAttributes<PontSignup> & {
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
fallback?: React.ReactNode | null;
|
|
21
|
+
}, "ref"> & import('react').RefAttributes<PontSignup>>;
|
|
22
|
+
export declare const AccountSettings: import('react').ForwardRefExoticComponent<Omit<AccountSettingsProps & import('react').RefAttributes<PontAccountSettings> & {
|
|
23
|
+
children?: React.ReactNode;
|
|
24
|
+
fallback?: React.ReactNode | null;
|
|
25
|
+
}, "ref"> & import('react').RefAttributes<PontAccountSettings>>;
|
|
26
|
+
export declare const MemberManagement: import('react').ForwardRefExoticComponent<Omit<MemberManagementProps & import('react').RefAttributes<PontMemberManagement> & {
|
|
27
|
+
children?: React.ReactNode;
|
|
28
|
+
fallback?: React.ReactNode | null;
|
|
29
|
+
}, "ref"> & import('react').RefAttributes<PontMemberManagement>>;
|
|
30
|
+
export declare const NavUser: import('react').ForwardRefExoticComponent<Omit<NavUserProps & import('react').RefAttributes<PontNavUser> & {
|
|
31
|
+
children?: React.ReactNode;
|
|
32
|
+
fallback?: React.ReactNode | null;
|
|
33
|
+
}, "ref"> & import('react').RefAttributes<PontNavUser>>;
|
|
34
|
+
export declare const AccountInfo: import('react').ForwardRefExoticComponent<Omit<AccountInfoProps & import('react').RefAttributes<PontAccountInfo> & {
|
|
35
|
+
children?: React.ReactNode;
|
|
36
|
+
fallback?: React.ReactNode | null;
|
|
37
|
+
}, "ref"> & import('react').RefAttributes<PontAccountInfo>>;
|
|
38
|
+
export declare const LocationInfo: import('react').ForwardRefExoticComponent<Omit<LocationInfoProps & import('react').RefAttributes<PontLocationInfo> & {
|
|
39
|
+
children?: React.ReactNode;
|
|
40
|
+
fallback?: React.ReactNode | null;
|
|
41
|
+
}, "ref"> & import('react').RefAttributes<PontLocationInfo>>;
|
|
42
|
+
export declare const UrlsInfo: import('react').ForwardRefExoticComponent<Omit<UrlsInfoProps & import('react').RefAttributes<PontUrlsInfo> & {
|
|
43
|
+
children?: React.ReactNode;
|
|
44
|
+
fallback?: React.ReactNode | null;
|
|
45
|
+
}, "ref"> & import('react').RefAttributes<PontUrlsInfo>>;
|
|
46
|
+
export declare const PersonalInfo: import('react').ForwardRefExoticComponent<Omit<PersonalInfoProps & import('react').RefAttributes<PontPersonalInfo> & {
|
|
47
|
+
children?: React.ReactNode;
|
|
48
|
+
fallback?: React.ReactNode | null;
|
|
49
|
+
}, "ref"> & import('react').RefAttributes<PontPersonalInfo>>;
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),h=require("@pontive/pontkit-loader"),k=require("react-dom"),C=new Set(["className","style","id","slot"]),P=typeof window<"u"?n.useLayoutEffect:n.useEffect;function a(e){const t=e==="pont-provider";return n.forwardRef((o,r)=>{const s=n.useRef(null),d=n.useRef({}),[l,i]=n.useState(null),{fallback:c,children:f,...b}=o,y={},M={};for(const[u,v]of Object.entries(b))(C.has(u)?y:M)[u]=v;n.useEffect(()=>{t&&h.loadWebComponents().catch(console.error)},[]),P(()=>{const u=s.current;if(!u)return;let v=!1;function E(){if(!(v||!u)){for(const[m,g]of Object.entries(M))if(d.current[m]!==g)try{u[m]=g,d.current[m]=g}catch{}}}return customElements.get(e)?E():customElements.whenDefined(e).then(E),()=>{v=!0}}),P(()=>{const u=s.current;if(!u||c==null)return;const v=document.createElement("div");return v.setAttribute("part","fallback"),u.prepend(v),i(v),()=>{v.remove(),i(null)}},[c==null]);function L(u){s.current=u,typeof r=="function"?r(u):r&&(r.current=u)}return n.createElement(e,{...y,ref:L},f??null,l?k.createPortal(c,l):null)})}const I={isAuthenticated:!1,resolved:!1},w=n.createContext(void 0);function S(e){const t=n.useContext(w);if(t===void 0)throw new Error(`${e} was called outside <Provider>. Wrap your app in the Provider from @pontive/pontkit-react/react — the same component that configures \`env\`.`);return t}function A(){return S("useAuthState").auth}function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),h=require("@pontive/pontkit-loader"),k=require("react-dom"),C=new Set(["className","style","id","slot"]),P=typeof window<"u"?n.useLayoutEffect:n.useEffect;function a(e){const t=e==="pont-provider";return n.forwardRef((o,r)=>{const s=n.useRef(null),d=n.useRef({}),[l,i]=n.useState(null),{fallback:c,children:f,...b}=o,y={},M={};for(const[u,v]of Object.entries(b))(C.has(u)?y:M)[u]=v;n.useEffect(()=>{t&&h.loadWebComponents().catch(console.error)},[]),P(()=>{const u=s.current;if(!u)return;let v=!1;function E(){if(!(v||!u)){for(const[m,g]of Object.entries(M))if(d.current[m]!==g)try{u[m]=g,d.current[m]=g}catch{}}}return customElements.get(e)?E():customElements.whenDefined(e).then(E),()=>{v=!0}}),P(()=>{const u=s.current;if(!u||c==null)return;const v=document.createElement("div");return v.setAttribute("part","fallback"),u.prepend(v),i(v),()=>{v.remove(),i(null)}},[c==null]);function L(u){s.current=u,typeof r=="function"?r(u):r&&(r.current=u)}return n.createElement(e,{...y,ref:L},f??null,l?k.createPortal(c,l):null)})}const I=a("pont-provider"),O=a("pont-preview"),U=a("pont-layout"),D=a("pont-signin"),R=a("pont-signup"),j=a("pont-account-settings"),q=a("pont-member-management"),W=a("pont-nav-user"),_=a("pont-account-info"),H=a("pont-location-info"),K=a("pont-urls-info"),V=a("pont-personal-info"),x={isAuthenticated:!1,resolved:!1},w=n.createContext(void 0);function S(e){const t=n.useContext(w);if(t===void 0)throw new Error(`${e} was called outside <Provider>. Wrap your app in the Provider from @pontive/pontkit-react/react — the same component that configures \`env\`.`);return t}function A(){return S("useAuthState").auth}function F(){return S("useEnvConfig").env}function T(e,t){const[o,r]=n.useState(x);return n.useEffect(()=>{if(!e)return;let s=!1;function d(c){s||!c||r(f=>f.isAuthenticated===c.isAuthenticated&&f.resolved===c.resolved?f:{isAuthenticated:!!c.isAuthenticated,resolved:!!c.resolved})}function l(c){d(c.detail)}e.addEventListener("pont:auth-changed",l);function i(){d(e?.auth)}return i(),customElements.whenDefined(t).then(i),()=>{s=!0,e.removeEventListener("pont:auth-changed",l)}},[e,t]),o}function $({value:e,children:t}){return n.createElement(w.Provider,{value:e},t)}function z({children:e,fallback:t=null}){const{isAuthenticated:o,resolved:r}=A();return r?o?e:null:t}function B({children:e,fallback:t=null}){const{isAuthenticated:o,resolved:r}=A();return r?o?null:e:t}function G({children:e,fallback:t=null}){const{resolved:o}=A();return o?e:t}function J({children:e,loading:t=null,redirectUrl:o,onRedirect:r}){const{auth:s,env:d}=S("Authenticated"),l=n.useRef(!1),i=o||d?.signinUrl;return n.useEffect(()=>{if(!(!s.resolved||s.isAuthenticated)&&!l.current){if(!i){console.error("[pontive] <Authenticated> has nobody to redirect to: pass `redirectUrl`, or give the Provider an `env.signinUrl`.");return}l.current=!0,r?r(i):window.location.href=i}},[s.resolved,s.isAuthenticated,i,r]),s.resolved?s.isAuthenticated?e:null:t}function p(){return typeof window>"u"?void 0:window.__pontCoreSdk}async function N(){await h.ensureCoreSdkLoaded(),p()?.openAccountSettingsModal?.()}async function Q(){await h.ensureCoreSdkLoaded(),p()?.closeAccountSettingsModal?.()}async function X(){await h.ensureCoreSdkLoaded(),p()?.openMemberManagementModal?.()}async function Y(){await h.ensureCoreSdkLoaded(),p()?.closeMemberManagementModal?.()}async function Z(e){await h.ensureCoreSdkLoaded(),p()?.setLocales?.(e)}function ee(){const e=p();return typeof window>"u"?null:e?.Auth?e.Auth:(console.warn("Auth is not loaded yet! Make sure loadWebComponents() has completed."),null)}const te=n.forwardRef(({children:e,...t},o)=>{const[r,s]=n.useState(null),d=T(r,"pont-provider"),l=t.env??null,i=n.useMemo(()=>({auth:d,env:l}),[d,l]);function c(f){s(f),typeof o=="function"?o(f):o&&(o.current=f)}return n.createElement(I,{...t,ref:c},n.createElement($,{value:i},e))});exports.AccountInfo=_;exports.AccountSettings=j;exports.AuthResolved=G;exports.Authenticated=J;exports.Layout=U;exports.LocationInfo=H;exports.MemberManagement=q;exports.NavUser=W;exports.PersonalInfo=V;exports.Preview=O;exports.Provider=te;exports.SignedIn=z;exports.SignedOut=B;exports.Signin=D;exports.Signup=R;exports.UrlsInfo=K;exports.closeAccountSettingsModalAsync=Q;exports.closeMemberManagementModalAsync=Y;exports.opeMemberManagementModalAsync=X;exports.openAccountSettingsModalAsync=N;exports.setLocales=Z;exports.useAuthProvider=ee;exports.useAuthState=A;exports.useEnvConfig=F;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/wrap.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","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 NavUserProps,\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 { 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\nimport type {\n PontProvider,\n PreviewComponent as PontPreview,\n PontKitLayout as PontLayout,\n PontAccountSettings,\n PontSignUp,\n PontSignIn,\n PontAccountInfo,\n PontLocationInfo,\n PontUrlsInfo,\n PontPersonalInfo,\n PontNavUser,\n PontMemberManagement,\n} from \"@pontive/pontkit-core\";\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\nconst ProviderElement = wrap<PontProvider, ProviderProps>(\"pont-provider\");\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\nexport const Preview = wrap<PontPreview, PreviewProps>(\"pont-preview\");\nexport const Layout = wrap<PontLayout, LayoutProps>(\"pont-layout\");\nexport const Signin = wrap<PontSignIn, SignInProps>(\"pont-signin\");\nexport const Signup = wrap<PontSignUp, SignUpProps>(\"pont-signup\");\nexport const AccountSettings = wrap<PontAccountSettings, AccountSettingsProps>(\"pont-account-settings\");\n\nexport const MemberManagement = wrap<PontMemberManagement, MemberManagementProps>(\"pont-member-management\");\n\nexport const NavUser = wrap<PontNavUser, NavUserProps>(\"pont-nav-user\");\nexport const AccountInfo = wrap<PontAccountInfo, AccountInfoProps>(\"pont-account-info\");\nexport const LocationInfo = wrap<PontLocationInfo, LocationInfoProps>(\"pont-location-info\");\nexport const UrlsInfo = wrap<PontUrlsInfo, UrlsInfoProps>(\"pont-urls-info\");\nexport const PersonalInfo = wrap<PontPersonalInfo, PersonalInfoProps>(\"pont-personal-info\");\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","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","ProviderElement","Provider","setElement","contextValue","useMemo","captureRef","Preview","Layout","Signin","Signup","AccountSettings","MemberManagement","NavUser","AccountInfo","LocationInfo","UrlsInfo","PersonalInfo"],"mappings":"qKAoDMA,MAAgB,IAAI,CAAC,YAAa,QAAS,KAAM,MAAM,CAAC,EAqBxDC,EACJ,OAAO,OAAW,IAAcC,EAAAA,gBAAkBC,EAAAA,UAE7C,SAASC,EAAoCC,EAAiB,CAUnE,MAAMC,EAAaD,IAAY,gBAE/B,OAAOE,EAAAA,WAAqB,CAACC,EAAOC,IAAiB,CACnD,MAAMC,EAAaC,EAAAA,OAAiB,IAAI,EAClCC,EAAWD,EAAAA,OAAqB,EAAE,EAClC,CAACE,EAAcC,CAAe,EAAIC,EAAAA,SAA6B,IAAI,EAEnE,CAAE,SAAAC,EAAU,SAAAC,EAAU,GAAGC,GAASV,EAKlCW,EAAyB,CAAA,EACzBC,EAA6B,CAAA,EAEnC,SAAW,CAACC,EAAKC,CAAK,IAAK,OAAO,QAAQJ,CAAI,GAC3ClB,EAAU,IAAIqB,CAAG,E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,mBAAmB,EACzEkF,EAAelF,EAA0C,oBAAoB,EAC7EmF,GAAWnF,EAAkC,gBAAgB,EAC7DoF,GAAepF,EAA0C,oBAAoB"}
|
|
1
|
+
{"version":3,"file":"index.cjs","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.1.1 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 PontNavUser,\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 NavUserProps,\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 NavUser = /* @__PURE__ */ wrap<PontNavUser, NavUserProps>(\"pont-nav-user\");\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 NavUserProps,\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// 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 NavUser,\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","NavUser","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"],"m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,CAAC,CAAE,SAAAU,EAAU,GAAGT,CAAA,EAASC,IAAiB,CAC1C,KAAM,CAAC2C,EAASiC,CAAU,EAAItE,EAAAA,SAA8B,IAAI,EAC1DsC,EAAOF,EAAqBC,EAAS,eAAe,EACpDmB,EAAO/D,EAAwB,KAAO,KACtC8E,EAAeC,UAAQ,KAAO,CAAE,KAAAlC,EAAM,IAAAkB,IAAQ,CAAClB,EAAMkB,CAAG,CAAC,EAI/D,SAASiB,EAAWhE,EAAyB,CAC3C6D,EAAW7D,CAAE,EAET,OAAOf,GAAiB,WAAYA,EAAae,CAAE,EAC9Cf,MAA2B,QAAUe,EAChD,CAEA,OAAOK,EAAAA,cACLE,EACA,CAAE,GAAIvB,EAAyB,IAAKgF,CAAA,EACpC3D,EAAAA,cAAcgC,EAAmB,CAAE,MAAOyB,CAAA,EAAgBrE,CAAQ,CAAA,CAEtE,CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProviderProps } from './types';
|
|
2
|
+
import { PontProvider } from '@pontive/pontkit-core';
|
|
2
3
|
import { AuthService } from '@pontive/oidc-client';
|
|
3
|
-
|
|
4
|
+
export { Preview, Layout, Signin, Signup, AccountSettings, MemberManagement, NavUser, AccountInfo, LocationInfo, UrlsInfo, PersonalInfo, } from './elements.generated';
|
|
4
5
|
export declare function openAccountSettingsModalAsync(): Promise<void>;
|
|
5
6
|
export declare function closeAccountSettingsModalAsync(): Promise<void>;
|
|
6
7
|
export declare function opeMemberManagementModalAsync(): Promise<void>;
|
|
@@ -21,50 +22,6 @@ export declare function useAuthProvider(): AuthService | null;
|
|
|
21
22
|
* rendered.
|
|
22
23
|
*/
|
|
23
24
|
export declare const Provider: import('react').ForwardRefExoticComponent<ProviderProps & import('react').RefAttributes<PontProvider>>;
|
|
24
|
-
export declare const Preview: import('react').ForwardRefExoticComponent<Omit<PreviewProps & import('react').RefAttributes<PontPreview> & {
|
|
25
|
-
children?: React.ReactNode;
|
|
26
|
-
fallback?: React.ReactNode | null;
|
|
27
|
-
}, "ref"> & import('react').RefAttributes<PontPreview>>;
|
|
28
|
-
export declare const Layout: import('react').ForwardRefExoticComponent<Omit<LayoutProps & import('react').RefAttributes<PontLayout> & {
|
|
29
|
-
children?: React.ReactNode;
|
|
30
|
-
fallback?: React.ReactNode | null;
|
|
31
|
-
}, "ref"> & import('react').RefAttributes<PontLayout>>;
|
|
32
|
-
export declare const Signin: import('react').ForwardRefExoticComponent<Omit<SignInProps & import('react').RefAttributes<PontSignIn> & {
|
|
33
|
-
children?: React.ReactNode;
|
|
34
|
-
fallback?: React.ReactNode | null;
|
|
35
|
-
}, "ref"> & import('react').RefAttributes<PontSignIn>>;
|
|
36
|
-
export declare const Signup: import('react').ForwardRefExoticComponent<Omit<SignUpProps & import('react').RefAttributes<PontSignUp> & {
|
|
37
|
-
children?: React.ReactNode;
|
|
38
|
-
fallback?: React.ReactNode | null;
|
|
39
|
-
}, "ref"> & import('react').RefAttributes<PontSignUp>>;
|
|
40
|
-
export declare const AccountSettings: import('react').ForwardRefExoticComponent<Omit<AccountSettingsProps & import('react').RefAttributes<PontAccountSettings> & {
|
|
41
|
-
children?: React.ReactNode;
|
|
42
|
-
fallback?: React.ReactNode | null;
|
|
43
|
-
}, "ref"> & import('react').RefAttributes<PontAccountSettings>>;
|
|
44
|
-
export declare const MemberManagement: import('react').ForwardRefExoticComponent<Omit<MemberManagementProps & import('react').RefAttributes<PontMemberManagement> & {
|
|
45
|
-
children?: React.ReactNode;
|
|
46
|
-
fallback?: React.ReactNode | null;
|
|
47
|
-
}, "ref"> & import('react').RefAttributes<PontMemberManagement>>;
|
|
48
|
-
export declare const NavUser: import('react').ForwardRefExoticComponent<Omit<NavUserProps & import('react').RefAttributes<PontNavUser> & {
|
|
49
|
-
children?: React.ReactNode;
|
|
50
|
-
fallback?: React.ReactNode | null;
|
|
51
|
-
}, "ref"> & import('react').RefAttributes<PontNavUser>>;
|
|
52
|
-
export declare const AccountInfo: import('react').ForwardRefExoticComponent<Omit<AccountInfoProps & import('react').RefAttributes<PontAccountInfo> & {
|
|
53
|
-
children?: React.ReactNode;
|
|
54
|
-
fallback?: React.ReactNode | null;
|
|
55
|
-
}, "ref"> & import('react').RefAttributes<PontAccountInfo>>;
|
|
56
|
-
export declare const LocationInfo: import('react').ForwardRefExoticComponent<Omit<LocationInfoProps & import('react').RefAttributes<PontLocationInfo> & {
|
|
57
|
-
children?: React.ReactNode;
|
|
58
|
-
fallback?: React.ReactNode | null;
|
|
59
|
-
}, "ref"> & import('react').RefAttributes<PontLocationInfo>>;
|
|
60
|
-
export declare const UrlsInfo: import('react').ForwardRefExoticComponent<Omit<UrlsInfoProps & import('react').RefAttributes<PontUrlsInfo> & {
|
|
61
|
-
children?: React.ReactNode;
|
|
62
|
-
fallback?: React.ReactNode | null;
|
|
63
|
-
}, "ref"> & import('react').RefAttributes<PontUrlsInfo>>;
|
|
64
|
-
export declare const PersonalInfo: import('react').ForwardRefExoticComponent<Omit<PersonalInfoProps & import('react').RefAttributes<PontPersonalInfo> & {
|
|
65
|
-
children?: React.ReactNode;
|
|
66
|
-
fallback?: React.ReactNode | null;
|
|
67
|
-
}, "ref"> & import('react').RefAttributes<PontPersonalInfo>>;
|
|
68
25
|
/**
|
|
69
26
|
* `<SignedIn>` and `<SignedOut>` are React components rather than wrappers over
|
|
70
27
|
* `<pont-signed-in>` / `<pont-signed-out>`, which cached their children on connect
|
package/dist/index.js
CHANGED
|
@@ -46,7 +46,7 @@ function i(t) {
|
|
|
46
46
|
);
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
const K = { isAuthenticated: !1, resolved: !1 }, L = D(
|
|
49
|
+
const K = /* @__PURE__ */ i("pont-provider"), G = /* @__PURE__ */ i("pont-preview"), J = /* @__PURE__ */ i("pont-layout"), Q = /* @__PURE__ */ i("pont-signin"), R = /* @__PURE__ */ i("pont-signup"), T = /* @__PURE__ */ i("pont-account-settings"), X = /* @__PURE__ */ i("pont-member-management"), Y = /* @__PURE__ */ i("pont-nav-user"), Z = /* @__PURE__ */ i("pont-account-info"), N = /* @__PURE__ */ i("pont-location-info"), tt = /* @__PURE__ */ i("pont-urls-info"), et = /* @__PURE__ */ i("pont-personal-info"), V = { isAuthenticated: !1, resolved: !1 }, L = D(
|
|
50
50
|
void 0
|
|
51
51
|
);
|
|
52
52
|
function w(t) {
|
|
@@ -60,11 +60,11 @@ function w(t) {
|
|
|
60
60
|
function S() {
|
|
61
61
|
return w("useAuthState").auth;
|
|
62
62
|
}
|
|
63
|
-
function
|
|
63
|
+
function nt() {
|
|
64
64
|
return w("useEnvConfig").env;
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
const [n, o] = M(
|
|
66
|
+
function F(t, e) {
|
|
67
|
+
const [n, o] = M(V);
|
|
68
68
|
return m(() => {
|
|
69
69
|
if (!t) return;
|
|
70
70
|
let r = !1;
|
|
@@ -85,34 +85,34 @@ function V(t, e) {
|
|
|
85
85
|
};
|
|
86
86
|
}, [t, e]), n;
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function $({
|
|
89
89
|
value: t,
|
|
90
90
|
children: e
|
|
91
91
|
}) {
|
|
92
92
|
return h(L.Provider, { value: t }, e);
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function ot({
|
|
95
95
|
children: t,
|
|
96
96
|
fallback: e = null
|
|
97
97
|
}) {
|
|
98
98
|
const { isAuthenticated: n, resolved: o } = S();
|
|
99
99
|
return o ? n ? t : null : e;
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function rt({
|
|
102
102
|
children: t,
|
|
103
103
|
fallback: e = null
|
|
104
104
|
}) {
|
|
105
105
|
const { isAuthenticated: n, resolved: o } = S();
|
|
106
106
|
return o ? n ? null : t : e;
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function st({
|
|
109
109
|
children: t,
|
|
110
110
|
fallback: e = null
|
|
111
111
|
}) {
|
|
112
112
|
const { resolved: n } = S();
|
|
113
113
|
return n ? t : e;
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function ct({
|
|
116
116
|
children: t,
|
|
117
117
|
loading: e = null,
|
|
118
118
|
redirectUrl: n,
|
|
@@ -134,64 +134,64 @@ function T({
|
|
|
134
134
|
function p() {
|
|
135
135
|
return typeof window > "u" ? void 0 : window.__pontCoreSdk;
|
|
136
136
|
}
|
|
137
|
-
async function
|
|
137
|
+
async function ut() {
|
|
138
138
|
await v(), p()?.openAccountSettingsModal?.();
|
|
139
139
|
}
|
|
140
|
-
async function
|
|
140
|
+
async function it() {
|
|
141
141
|
await v(), p()?.closeAccountSettingsModal?.();
|
|
142
142
|
}
|
|
143
|
-
async function
|
|
143
|
+
async function at() {
|
|
144
144
|
await v(), p()?.openMemberManagementModal?.();
|
|
145
145
|
}
|
|
146
|
-
async function
|
|
146
|
+
async function lt() {
|
|
147
147
|
await v(), p()?.closeMemberManagementModal?.();
|
|
148
148
|
}
|
|
149
|
-
async function
|
|
149
|
+
async function dt(t) {
|
|
150
150
|
await v(), p()?.setLocales?.(t);
|
|
151
151
|
}
|
|
152
|
-
function
|
|
152
|
+
function ft() {
|
|
153
153
|
const t = p();
|
|
154
154
|
return typeof window > "u" ? null : t?.Auth ? t.Auth : (console.warn(
|
|
155
155
|
"Auth is not loaded yet! Make sure loadWebComponents() has completed."
|
|
156
156
|
), null);
|
|
157
157
|
}
|
|
158
|
-
const
|
|
158
|
+
const pt = C(
|
|
159
159
|
({ children: t, ...e }, n) => {
|
|
160
|
-
const [o, r] = M(null), l =
|
|
160
|
+
const [o, r] = M(null), l = F(o, "pont-provider"), a = e.env ?? null, u = _(() => ({ auth: l, env: a }), [l, a]);
|
|
161
161
|
function s(d) {
|
|
162
162
|
r(d), typeof n == "function" ? n(d) : n && (n.current = d);
|
|
163
163
|
}
|
|
164
164
|
return h(
|
|
165
|
-
|
|
165
|
+
K,
|
|
166
166
|
{ ...e, ref: s },
|
|
167
|
-
h(
|
|
167
|
+
h($, { value: u }, t)
|
|
168
168
|
);
|
|
169
169
|
}
|
|
170
|
-
)
|
|
170
|
+
);
|
|
171
171
|
export {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
172
|
+
Z as AccountInfo,
|
|
173
|
+
T as AccountSettings,
|
|
174
|
+
st as AuthResolved,
|
|
175
|
+
ct as Authenticated,
|
|
176
|
+
J as Layout,
|
|
177
|
+
N as LocationInfo,
|
|
178
|
+
X as MemberManagement,
|
|
179
|
+
Y as NavUser,
|
|
180
|
+
et as PersonalInfo,
|
|
181
|
+
G as Preview,
|
|
182
|
+
pt as Provider,
|
|
183
|
+
ot as SignedIn,
|
|
184
|
+
rt as SignedOut,
|
|
185
|
+
Q as Signin,
|
|
186
|
+
R as Signup,
|
|
187
|
+
tt as UrlsInfo,
|
|
188
|
+
it as closeAccountSettingsModalAsync,
|
|
189
|
+
lt as closeMemberManagementModalAsync,
|
|
190
|
+
at as opeMemberManagementModalAsync,
|
|
191
|
+
ut as openAccountSettingsModalAsync,
|
|
192
|
+
dt as setLocales,
|
|
193
|
+
ft as useAuthProvider,
|
|
194
194
|
S as useAuthState,
|
|
195
|
-
|
|
195
|
+
nt as useEnvConfig
|
|
196
196
|
};
|
|
197
197
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/wrap.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","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 NavUserProps,\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 { 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\nimport type {\n PontProvider,\n PreviewComponent as PontPreview,\n PontKitLayout as PontLayout,\n PontAccountSettings,\n PontSignUp,\n PontSignIn,\n PontAccountInfo,\n PontLocationInfo,\n PontUrlsInfo,\n PontPersonalInfo,\n PontNavUser,\n PontMemberManagement,\n} from \"@pontive/pontkit-core\";\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\nconst ProviderElement = wrap<PontProvider, ProviderProps>(\"pont-provider\");\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\nexport const Preview = wrap<PontPreview, PreviewProps>(\"pont-preview\");\nexport const Layout = wrap<PontLayout, LayoutProps>(\"pont-layout\");\nexport const Signin = wrap<PontSignIn, SignInProps>(\"pont-signin\");\nexport const Signup = wrap<PontSignUp, SignUpProps>(\"pont-signup\");\nexport const AccountSettings = wrap<PontAccountSettings, AccountSettingsProps>(\"pont-account-settings\");\n\nexport const MemberManagement = wrap<PontMemberManagement, MemberManagementProps>(\"pont-member-management\");\n\nexport const NavUser = wrap<PontNavUser, NavUserProps>(\"pont-nav-user\");\nexport const AccountInfo = wrap<PontAccountInfo, AccountInfoProps>(\"pont-account-info\");\nexport const LocationInfo = wrap<PontLocationInfo, LocationInfoProps>(\"pont-location-info\");\nexport const UrlsInfo = wrap<PontUrlsInfo, UrlsInfoProps>(\"pont-urls-info\");\nexport const PersonalInfo = wrap<PontPersonalInfo, PersonalInfoProps>(\"pont-personal-info\");\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","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","ProviderElement","Provider","setElement","contextValue","useMemo","captureRef","Preview","Layout","Signin","Signup","AccountSettings","MemberManagement","NavUser","AccountInfo","LocationInfo","UrlsInfo","PersonalInfo"],"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,MAAM;AACX,QAAAD,I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AIX;AAEA,MAAMC,IAAkBpE,EAAkC,eAAe,GAe5DqE,KAAWlE;AAAA,EACpB,CAAC,EAAE,UAAAU,GAAU,GAAGT,EAAA,GAASC,MAAiB;AAC1C,UAAM,CAAC+B,GAASkC,CAAU,IAAI3D,EAA8B,IAAI,GAC1D0B,IAAOF,EAAqBC,GAAS,eAAe,GACpDmB,IAAOnD,EAAwB,OAAO,MACtCmE,IAAeC,EAAQ,OAAO,EAAE,MAAAnC,GAAM,KAAAkB,MAAQ,CAAClB,GAAMkB,CAAG,CAAC;AAI/D,aAASkB,EAAWrD,GAAyB;AAC3C,MAAAkD,EAAWlD,CAAE,GAET,OAAOf,KAAiB,aAAYA,EAAae,CAAE,IAC9Cf,QAA2B,UAAUe;AAAA,IAChD;AAEA,WAAOK;AAAA,MACL2C;AAAA,MACA,EAAE,GAAIhE,GAAyB,KAAKqE,EAAA;AAAA,MACpChD,EAAcoB,GAAmB,EAAE,OAAO0B,EAAA,GAAgB1D,CAAQ;AAAA,IAAA;AAAA,EAEtE;AACF,GAEa6D,KAAU1E,EAAgC,cAAc,GACxD2E,KAAS3E,EAA8B,aAAa,GACpD4E,KAAS5E,EAA8B,aAAa,GACpD6E,KAAS7E,EAA8B,aAAa,GACpD8E,KAAkB9E,EAAgD,uBAAuB,GAEzF+E,KAAmB/E,EAAkD,wBAAwB,GAE7FgF,KAAUhF,EAAgC,eAAe,GACzDiF,KAAcjF,EAAwC,mBAAmB,GACzEkF,KAAelF,EAA0C,oBAAoB,GAC7EmF,KAAWnF,EAAkC,gBAAgB,GAC7DoF,KAAepF,EAA0C,oBAAoB;"}
|
|
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.1.1 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 PontNavUser,\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 NavUserProps,\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 NavUser = /* @__PURE__ */ wrap<PontNavUser, NavUserProps>(\"pont-nav-user\");\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 NavUserProps,\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// 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 NavUser,\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","NavUser","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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EAA8B,IAAI,GAC1DsC,IAAOF,EAAqBC,GAAS,eAAe,GACpDmB,IAAO/D,EAAwB,OAAO,MACtC8E,IAAeC,EAAQ,OAAO,EAAE,MAAAlC,GAAM,KAAAkB,MAAQ,CAAClB,GAAMkB,CAAG,CAAC;AAI/D,aAASiB,EAAWhE,GAAyB;AAC3C,MAAA6D,EAAW7D,CAAE,GAET,OAAOf,KAAiB,aAAYA,EAAae,CAAE,IAC9Cf,QAA2B,UAAUe;AAAA,IAChD;AAEA,WAAOK;AAAA,MACLE;AAAA,MACA,EAAE,GAAIvB,GAAyB,KAAKgF,EAAA;AAAA,MACpC3D,EAAcgC,GAAmB,EAAE,OAAOyB,EAAA,GAAgBrE,CAAQ;AAAA,IAAA;AAAA,EAEtE;AACF;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pontive/pontkit-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React components over the pont-* custom elements.",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"react-dom": "^18 || ^19"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@pontive/pontkit-loader": "^1.0.
|
|
34
|
+
"@pontive/pontkit-loader": "^1.0.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@pontive/oidc-client": "^1.0.0",
|