@clerk/clerk-react
Advanced tools
Comparing version 2.1.1-staging.3 to 2.2.0
@@ -91,3 +91,3 @@ 'use strict'; | ||
var version = "2.1.1-staging.3"; | ||
var version = "2.2.0"; | ||
@@ -94,0 +94,0 @@ var FAILED_TO_LOAD_ERROR = 'Clerk: Failed to load Clerk'; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("react"),r=(e=n)&&"object"==typeof e&&"default"in e?e.default:e;function t(){return(t=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e}).apply(this,arguments)}function o(e,n){if(null==e)return{};var r,t,o={},i=Object.keys(e);for(t=0;t<i.length;t++)n.indexOf(r=i[t])>=0||(o[r]=e[r]);return o}function i(){return"undefined"!=typeof window}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var u=new Map;function s(e,n,o){var i=function(i){return function(e,n,t){void 0===t&&(t=1),r.useEffect((function(){var r=u.get(e)||0;if(r==t)throw new Error(n);return u.set(e,r+1),function(){u.set(e,(u.get(e)||1)-1)}}),[])}(n,o),r.createElement(e,t({},i))};return i.displayName="withMaxAllowedInstancesGuard("+(e.displayName||e.name||n||"Component")+")",i}var l=function(){function e(e,n,r){var t=this,o=this,u=this,s=this;void 0===n&&(n={}),void 0===r&&(r=null),this.mode=void 0,this.frontendApi=void 0,this.options=void 0,this.Clerk=void 0,this.clerkjs=null,this.preopenSignIn=null,this.preopenSignUp=null,this.premountSignInNodes=new Map,this.premountSignUpNodes=new Map,this.premountUserProfileNodes=new Map,this.premountUserButtonNodes=new Map,this.premountMethodCalls=new Map,this._loaded=!1,this.ssrData=null,this.ssrClient=void 0,this.ssrSession=void 0,this.hydrateClerkJS=function(e){try{if(!e)throw new Error("Failed to hydrate latest Clerk JS");return o.clerkjs=e,o.premountMethodCalls.forEach((function(e){return e()})),null!==o.preopenSignIn&&e.openSignIn(o.preopenSignIn),null!==o.preopenSignUp&&e.openSignUp(o.preopenSignUp),o.premountSignInNodes.forEach((function(n,r){e.mountSignIn(r,n)})),o.premountSignUpNodes.forEach((function(n,r){e.mountSignUp(r,n)})),o.premountUserProfileNodes.forEach((function(n,r){e.mountUserProfile(r,n)})),o.premountUserButtonNodes.forEach((function(n,r){e.mountUserButton(r,n)})),o._loaded=!0,Promise.resolve(o.clerkjs)}catch(e){return Promise.reject(e)}},this.setSession=function(e,n){return t.clerkjs?t.clerkjs.setSession(e,n):Promise.reject()},this.openSignIn=function(e){t.clerkjs&&t._loaded?t.clerkjs.openSignIn(e):t.preopenSignIn=e},this.closeSignIn=function(){t.clerkjs&&t._loaded?t.clerkjs.closeSignIn():t.preopenSignIn=null},this.openSignUp=function(e){t.clerkjs&&t._loaded?t.clerkjs.openSignUp(e):t.preopenSignUp=e},this.closeSignUp=function(){t.clerkjs&&t._loaded?t.clerkjs.closeSignUp():t.preopenSignUp=null},this.mountSignIn=function(e,n){t.clerkjs&&t._loaded?t.clerkjs.mountSignIn(e,n):t.premountSignInNodes.set(e,n)},this.unmountSignIn=function(e){t.clerkjs&&t._loaded?t.clerkjs.unmountSignIn(e):t.premountSignInNodes.delete(e)},this.mountSignUp=function(e,n){t.clerkjs&&t._loaded?t.clerkjs.mountSignUp(e,n):t.premountSignUpNodes.set(e,n)},this.unmountSignUp=function(e){t.clerkjs&&t._loaded?t.clerkjs.unmountSignUp(e):t.premountSignUpNodes.delete(e)},this.mountUserProfile=function(e,n){t.clerkjs&&t._loaded?t.clerkjs.mountUserProfile(e,n):t.premountUserProfileNodes.set(e,n)},this.unmountUserProfile=function(e){t.clerkjs&&t._loaded?t.clerkjs.unmountUserProfile(e):t.premountUserProfileNodes.delete(e)},this.mountUserButton=function(e,n){t.clerkjs&&t._loaded?t.clerkjs.mountUserButton(e,n):t.premountUserButtonNodes.set(e,n)},this.unmountUserButton=function(e){t.clerkjs&&t._loaded?t.clerkjs.unmountUserButton(e):t.premountUserButtonNodes.delete(e)},this.addListener=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.addListener(e)};t.clerkjs?n():t.premountMethodCalls.set("addListener",n)},this.loadFromServer=function(e){"browser"===t.mode&&t.throwError("loadFromServer cannot be called in a browser context."),t.ssrData=JSON.stringify({client:t.client,session:t.session,token:e})},this.navigate=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.navigate(e)};t.clerkjs&&t._loaded?n():t.premountMethodCalls.set("navigate",n)},this.redirectToSignIn=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.redirectToSignIn(e)};t.clerkjs&&t._loaded?n():t.premountMethodCalls.set("redirectToSignIn",n)},this.redirectToSignUp=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.redirectToSignUp(e)};t.clerkjs&&t._loaded?n():t.premountMethodCalls.set("redirectToSignUp",n)},this.redirectToUserProfile=function(){var e=function(){var e;return null===(e=t.clerkjs)||void 0===e?void 0:e.redirectToUserProfile()};t.clerkjs&&t._loaded?e():t.premountMethodCalls.set("redirectToUserProfile",e)},this.handleRedirectCallback=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.handleRedirectCallback(e)};t.clerkjs&&t._loaded?n():t.premountMethodCalls.set("handleRedirectCallback",n)},this.signOut=function(e){try{var n=function(){var n;return null===(n=u.clerkjs)||void 0===n?void 0:n.signOut(e)};return u.clerkjs&&u._loaded?Promise.resolve(n()):(u.premountMethodCalls.set("signOut",n),Promise.resolve())}catch(e){return Promise.reject(e)}},this.signOutOne=function(e){try{var n=function(){var n;return null===(n=s.clerkjs)||void 0===n?void 0:n.signOutOne(e)};return s.clerkjs&&s._loaded?Promise.resolve(n()):(s.premountMethodCalls.set("signOutOne",n),Promise.resolve())}catch(e){return Promise.reject(e)}},this.frontendApi=e,this.options=n,this.Clerk=r,this.mode=i()?"browser":"server"}var n,r=e.prototype;return r.loadClerkJS=function(){try{var e=this;return e.frontendApi||e.throwError("Clerk: You must add the frontendApi prop to your <ClerkProvider>"),Promise.resolve(function(n,r){try{var t=function(){function n(n){return e.hydrateClerkJS(global.Clerk)}var r=function(){if(e.Clerk){var n,r=function(){global.Clerk=n},t=function(){if("function"==typeof e.Clerk)return n=new e.Clerk(e.frontendApi),Promise.resolve(n.load(e.options)).then((function(){}));n=e.Clerk;var r=function(){if(!n.isReady())return Promise.resolve(n.load(e.options)).then((function(){}))}();return r&&r.then?r.then((function(){})):void 0}();return t&&t.then?t.then(r):r()}return Promise.resolve((o=e.frontendApi,i=e.options.scriptUrl,new Promise((function(e,n){global.Clerk&&e(null),o||n("Clerk: Missing provider");var r=document.createElement("script"),t=function(e,n){if(n)return n;var r=function(e){return e.endsWith(".lclstage.dev")||e.endsWith(".stgstage.dev")||e.endsWith(".clerkstage.dev")}(e)?"staging":parseInt("2.1.1-staging.3".split(".")[0],10);return"https://"+e+"/npm/@clerk/clerk-js@"+r+"/dist/clerk.browser.js"}(o,i);r.setAttribute("data-clerk-frontend-api",o),r.setAttribute("crossorigin","anonymous"),r.async=!0,document.body||n("Clerk: Missing <body> element."),r.addEventListener("load",(function(){return e(r)})),r.addEventListener("error",(function(){return n("Clerk: Failed to load Clerk")})),r.src=t,document.body.appendChild(r)})))).then((function(){if(!global.Clerk)throw new Error("Failed to download latest ClerkJS. Contact support@clerk.dev.");return Promise.resolve(global.Clerk.load(e.options)).then((function(){}))}));var o,i}();return r&&r.then?r.then(n):n()}()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(0,(function(n){var r;r=n instanceof Error?n.message:String(n),e.throwError(r)})))}catch(e){return Promise.reject(e)}},r.throwError=function(e){throw console.error(e),new Error(e)},(n=[{key:"version",get:function(){var e;return null===(e=this.clerkjs)||void 0===e?void 0:e.version}},{key:"client",get:function(){return this.clerkjs?this.clerkjs.client:void 0}},{key:"session",get:function(){return this.clerkjs?this.clerkjs.session:void 0}},{key:"user",get:function(){return this.clerkjs?this.clerkjs.user:void 0}},{key:"__unstable__environment",get:function(){return this.clerkjs?this.clerkjs.__unstable__environment:void 0}}])&&function(e,n){for(var r=0;r<n.length;r++){var t=n[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}(e.prototype,n),e}();function a(e){if(!e)throw new Error("Clerk: You must wrap your application in a <ClerkProvider> component.")}function c(e,n){if(!e)throw new Error(function(e){return"Clerk: You're calling "+e+" before there's a guarantee the client has been loaded. Call "+e+" from a child of <SignedIn>, <SignedOut>, or <ClerkLoaded>, or use the withClerk() HOC."}(n))}function d(e,n){if(!e)throw new Error(function(e){return"Clerk: You're calling "+e+" before there's a guarantee there's an active user. Call "+e+" from a child of <SignedIn> or use the withUser() HOC."}(n))}var f=Object.freeze({noGuarantees:Object.freeze({guaranteedLoaded:!1,guaranteedUser:!1}),guaranteedLoaded:Object.freeze({guaranteedLoaded:!0,guaranteedUser:!1}),guaranteedAll:Object.freeze({guaranteedLoaded:!0,guaranteedUser:!0})}),p=r.createContext(void 0);p.displayName="StructureContext";var v=r.createContext(void 0);v.displayName="IsomorphicClerkContext";var m=function(e,o){e.displayName=o=o||e.displayName||e.name||"Component";var u=function(o){var u=n.useContext(p),s=n.useContext(v);if(!i())return null;a(u),a(s);var l=s.value;return l?u.guaranteedLoaded?r.createElement(e,t({},o,{clerk:l})):l.client?r.createElement(p.Provider,{value:f.guaranteedLoaded},r.createElement(e,t({},o,{clerk:l}))):null:null};return u.displayName="withClerk("+o+")",u},h=r.createContext(void 0);h.displayName="ClientContext";var g=r.createContext(void 0);g.displayName="SessionContext";var k=r.createContext(void 0);function C(){var e=n.useContext(k);return a(e),e}k.displayName="UserContext";var S=function(e,o){e.displayName=o=o||e.displayName||e.name||"Component";var u=function(o){var u=n.useContext(p),s=n.useContext(k);if(!i())return null;a(u),a(s);var l=s.value;return u.guaranteedUser&&l?r.createElement(e,t({},o,{user:l})):l?r.createElement(p.Provider,{value:f.guaranteedAll},r.createElement(e,t({},o,{user:l}))):null};return u.displayName="withUser("+o+")",u};function U(e){var n=e.children,o=e.clerkLoaded,i=e.isomorphicClerk,u=r.useState({client:i.client,session:i.session,user:i.user}),s=u[0],l=u[1];r.useEffect((function(){return i.addListener((function(e){return l(t({},e))}))}),[]);var a=s.client,c=s.session,d=s.user,f=r.useMemo((function(){return{value:i}}),[o]),p=r.useMemo((function(){return{value:a}}),[a]),m=r.useMemo((function(){return{value:c}}),[c]),C=r.useMemo((function(){return{value:d}}),[d]);return r.createElement(v.Provider,{value:f},r.createElement(h.Provider,{value:p},r.createElement(g.Provider,{value:m},r.createElement(k.Provider,{value:C},r.createElement(r.Fragment,{key:c?c.id:"no-users"},n)))))}function y(e){var t=n.useMemo((function(){var n=e.frontendApi,r=void 0===n?"":n,t=e.Clerk,i=o(e,["frontendApi","Clerk"]);return new l(r,i,t)}),[]),i=n.useState(!1),u=i[0],s=i[1];return n.useEffect((function(){t.loadClerkJS().then((function(){return s(!0)}))}),[]),r.createElement(p.Provider,{value:f.noGuarantees},t instanceof l&&t.ssrData&&r.createElement("script",{type:"application/json","data-clerk":"SSR",dangerouslySetInnerHTML:{__html:t.ssrData}}),r.createElement(U,{isomorphicClerk:t,clerkLoaded:u},e.children))}var j=s(y,"ClerkProvider","Clerk: You've added multiple <ClerkProvider> components in your React component tree. Wrap your components in a single <ClerkProvider>."),E=function(e){var n,t;function o(){for(var n,t=arguments.length,o=new Array(t),i=0;i<t;i++)o[i]=arguments[i];return(n=e.call.apply(e,[this].concat(o))||this).portalRef=r.createRef(),n}t=e,(n=o).prototype=Object.create(t.prototype),n.prototype.constructor=n,n.__proto__=t;var i=o.prototype;return i.componentDidMount=function(){this.portalRef.current&&this.props.mount(this.portalRef.current,this.props.props)},i.componentWillUnmount=function(){this.portalRef.current&&this.props.unmount(this.portalRef.current)},i.render=function(){return r.createElement("div",{ref:this.portalRef})},o}(r.PureComponent),w=m((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.createElement(E,{mount:n.mountSignIn,unmount:n.unmountSignIn,props:t})}),"SignIn"),x=m((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.createElement(E,{mount:n.mountSignUp,unmount:n.unmountSignUp,props:t})}),"SignUp"),P=m((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.createElement(E,{mount:n.mountUserProfile,unmount:n.unmountUserProfile,props:t})}),"UserProfile"),b=m((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.createElement(E,{mount:n.mountUserButton,unmount:n.unmountUserButton,props:t})}),"UserButton"),I=S((function(e){return r.createElement(r.Fragment,null,e.children)}),"SignedIn"),_=m((function(e){var n=e.children;return null===C().value?r.createElement(r.Fragment,null,n):null}),"SignedOut"),N=m((function(e){return r.createElement(r.Fragment,null,e.children)}),"ClerkLoaded"),O=m((function(e){var n=e.clerk,t=e.returnBack,o=n.client,i=n.session,u=n.__unstable__environment,s=o.activeSessions&&o.activeSessions.length>0;return r.useEffect((function(){null===i&&s&&u?n.navigate(u.displayConfig.afterSignOutOneUrl):n.redirectToSignIn(t)}),[]),null}),"RedirectToSignIn"),L=m((function(e){var n=e.clerk,t=e.returnBack;return r.useEffect((function(){n.redirectToSignUp(t)}),[]),null}),"RedirectToSignUp"),M=m((function(e){var n=e.clerk;return r.useEffect((function(){n.redirectToUserProfile()}),[]),null}),"RedirectToUserProfile");exports.AuthenticateWithRedirectCallback=m((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.useEffect((function(){n.handleRedirectCallback(t)}),[]),null}),"AuthenticateWithRedirectCallback"),exports.ClerkLoaded=N,exports.ClerkLoading=function(e){var n=e.children;return void 0===C().value?r.createElement(r.Fragment,null,n):null},exports.ClerkProvider=j,exports.RedirectToSignIn=O,exports.RedirectToSignUp=L,exports.RedirectToUserProfile=M,exports.SignIn=w,exports.SignUp=x,exports.SignedIn=I,exports.SignedOut=_,exports.UserButton=b,exports.UserProfile=P,exports.WithClerk=function(e){var n=e.children;return r.createElement(p.Consumer,null,(function(e){return r.createElement(v.Consumer,null,(function(t){if("function"!=typeof n)throw new Error("Clerk: Child of WithClerk must be a function.");a(e),a(t);var o=t.value;return o?e.guaranteedLoaded?n(o):o.client?r.createElement(p.Provider,{value:f.guaranteedLoaded},n(o)):null:null}))}))},exports.WithSession=function(e){var n=e.children;return r.createElement(p.Consumer,null,(function(e){return r.createElement(g.Consumer,null,(function(t){if("function"!=typeof n)throw new Error("Clerk: Child of WithClerk must be a function.");a(e),a(t);var o=t.value;return e.guaranteedUser&&o?n(o):o?r.createElement(p.Provider,{value:f.guaranteedAll},n(o)):null}))}))},exports.WithUser=function(e){var n=e.children;return r.createElement(p.Consumer,null,(function(e){return r.createElement(k.Consumer,null,(function(t){if("function"!=typeof n)throw new Error("Clerk: Child of WithClerk must be a function.");a(e),a(t);var o=t.value;return e.guaranteedUser&&o?n(o):o?r.createElement(p.Provider,{value:f.guaranteedAll},n(o)):null}))}))},exports.useClerk=function(){var e=n.useContext(p),r=n.useContext(v);return a(e),a(r),c(e.guaranteedLoaded,"useClerk()"),c(r.value,"useClerk()"),r.value},exports.useSession=function(e){var r=t({},e);r.withAssertions=r.withAssertions||!1;var o=n.useContext(p),i=function(){var e=n.useContext(g);return a(e),e}();return r.withAssertions?t({session:i.value},{isLoading:function(e){return void 0===e},isSignedOut:function(e){return null===e},isSignedIn:function(e){return null!=e}}):(a(o),d(o.guaranteedUser,"useSession()"),d(i.value,"useSession()"),i.value)},exports.useSessionList=function(){var e=n.useContext(p),t=r.useContext(h);return a(t),a(e),c(e.guaranteedLoaded,"useSessionList()"),t.value.sessions},exports.useSignIn=function(){var e=n.useContext(p),t=r.useContext(h);return a(t),a(e),c(e.guaranteedLoaded,"useSignIn()"),t.value.signIn},exports.useSignUp=function(){var e=n.useContext(p),t=r.useContext(h);return a(t),a(e),c(e.guaranteedLoaded,"useSignUp()"),t.value.signUp},exports.useUser=function(e){var r=t({},e);r.withAssertions=r.withAssertions||!1;var o=n.useContext(p),i=C();return r.withAssertions?t({user:i.value},{isLoading:function(e){return void 0===e},isSignedOut:function(e){return null===e},isSignedIn:function(e){return!!e}}):(a(o),d(o.guaranteedUser,"useUser()"),d(i.value,"useUser()"),i.value)},exports.withClerk=m,exports.withSession=function(e,o){e.displayName=o=o||e.displayName||e.name||"Component";var u=function(o){var u=n.useContext(p),s=n.useContext(g);if(!i())return null;a(u),a(s);var l=s.value;return u.guaranteedUser&&l?r.createElement(e,t({},o,{session:l})):l?r.createElement(p.Provider,{value:f.guaranteedAll},r.createElement(e,t({},o,{session:l}))):null};return u.displayName="withSession("+o+")",u},exports.withUser=S; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("react"),r=(e=n)&&"object"==typeof e&&"default"in e?e.default:e;function t(){return(t=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e}).apply(this,arguments)}function o(e,n){if(null==e)return{};var r,t,o={},i=Object.keys(e);for(t=0;t<i.length;t++)n.indexOf(r=i[t])>=0||(o[r]=e[r]);return o}function i(){return"undefined"!=typeof window}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var u=new Map;function s(e,n,o){var i=function(i){return function(e,n,t){void 0===t&&(t=1),r.useEffect((function(){var r=u.get(e)||0;if(r==t)throw new Error(n);return u.set(e,r+1),function(){u.set(e,(u.get(e)||1)-1)}}),[])}(n,o),r.createElement(e,t({},i))};return i.displayName="withMaxAllowedInstancesGuard("+(e.displayName||e.name||n||"Component")+")",i}var l=function(){function e(e,n,r){var t=this,o=this,u=this,s=this;void 0===n&&(n={}),void 0===r&&(r=null),this.mode=void 0,this.frontendApi=void 0,this.options=void 0,this.Clerk=void 0,this.clerkjs=null,this.preopenSignIn=null,this.preopenSignUp=null,this.premountSignInNodes=new Map,this.premountSignUpNodes=new Map,this.premountUserProfileNodes=new Map,this.premountUserButtonNodes=new Map,this.premountMethodCalls=new Map,this._loaded=!1,this.ssrData=null,this.ssrClient=void 0,this.ssrSession=void 0,this.hydrateClerkJS=function(e){try{if(!e)throw new Error("Failed to hydrate latest Clerk JS");return o.clerkjs=e,o.premountMethodCalls.forEach((function(e){return e()})),null!==o.preopenSignIn&&e.openSignIn(o.preopenSignIn),null!==o.preopenSignUp&&e.openSignUp(o.preopenSignUp),o.premountSignInNodes.forEach((function(n,r){e.mountSignIn(r,n)})),o.premountSignUpNodes.forEach((function(n,r){e.mountSignUp(r,n)})),o.premountUserProfileNodes.forEach((function(n,r){e.mountUserProfile(r,n)})),o.premountUserButtonNodes.forEach((function(n,r){e.mountUserButton(r,n)})),o._loaded=!0,Promise.resolve(o.clerkjs)}catch(e){return Promise.reject(e)}},this.setSession=function(e,n){return t.clerkjs?t.clerkjs.setSession(e,n):Promise.reject()},this.openSignIn=function(e){t.clerkjs&&t._loaded?t.clerkjs.openSignIn(e):t.preopenSignIn=e},this.closeSignIn=function(){t.clerkjs&&t._loaded?t.clerkjs.closeSignIn():t.preopenSignIn=null},this.openSignUp=function(e){t.clerkjs&&t._loaded?t.clerkjs.openSignUp(e):t.preopenSignUp=e},this.closeSignUp=function(){t.clerkjs&&t._loaded?t.clerkjs.closeSignUp():t.preopenSignUp=null},this.mountSignIn=function(e,n){t.clerkjs&&t._loaded?t.clerkjs.mountSignIn(e,n):t.premountSignInNodes.set(e,n)},this.unmountSignIn=function(e){t.clerkjs&&t._loaded?t.clerkjs.unmountSignIn(e):t.premountSignInNodes.delete(e)},this.mountSignUp=function(e,n){t.clerkjs&&t._loaded?t.clerkjs.mountSignUp(e,n):t.premountSignUpNodes.set(e,n)},this.unmountSignUp=function(e){t.clerkjs&&t._loaded?t.clerkjs.unmountSignUp(e):t.premountSignUpNodes.delete(e)},this.mountUserProfile=function(e,n){t.clerkjs&&t._loaded?t.clerkjs.mountUserProfile(e,n):t.premountUserProfileNodes.set(e,n)},this.unmountUserProfile=function(e){t.clerkjs&&t._loaded?t.clerkjs.unmountUserProfile(e):t.premountUserProfileNodes.delete(e)},this.mountUserButton=function(e,n){t.clerkjs&&t._loaded?t.clerkjs.mountUserButton(e,n):t.premountUserButtonNodes.set(e,n)},this.unmountUserButton=function(e){t.clerkjs&&t._loaded?t.clerkjs.unmountUserButton(e):t.premountUserButtonNodes.delete(e)},this.addListener=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.addListener(e)};t.clerkjs?n():t.premountMethodCalls.set("addListener",n)},this.loadFromServer=function(e){"browser"===t.mode&&t.throwError("loadFromServer cannot be called in a browser context."),t.ssrData=JSON.stringify({client:t.client,session:t.session,token:e})},this.navigate=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.navigate(e)};t.clerkjs&&t._loaded?n():t.premountMethodCalls.set("navigate",n)},this.redirectToSignIn=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.redirectToSignIn(e)};t.clerkjs&&t._loaded?n():t.premountMethodCalls.set("redirectToSignIn",n)},this.redirectToSignUp=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.redirectToSignUp(e)};t.clerkjs&&t._loaded?n():t.premountMethodCalls.set("redirectToSignUp",n)},this.redirectToUserProfile=function(){var e=function(){var e;return null===(e=t.clerkjs)||void 0===e?void 0:e.redirectToUserProfile()};t.clerkjs&&t._loaded?e():t.premountMethodCalls.set("redirectToUserProfile",e)},this.handleRedirectCallback=function(e){var n=function(){var n;return null===(n=t.clerkjs)||void 0===n?void 0:n.handleRedirectCallback(e)};t.clerkjs&&t._loaded?n():t.premountMethodCalls.set("handleRedirectCallback",n)},this.signOut=function(e){try{var n=function(){var n;return null===(n=u.clerkjs)||void 0===n?void 0:n.signOut(e)};return u.clerkjs&&u._loaded?Promise.resolve(n()):(u.premountMethodCalls.set("signOut",n),Promise.resolve())}catch(e){return Promise.reject(e)}},this.signOutOne=function(e){try{var n=function(){var n;return null===(n=s.clerkjs)||void 0===n?void 0:n.signOutOne(e)};return s.clerkjs&&s._loaded?Promise.resolve(n()):(s.premountMethodCalls.set("signOutOne",n),Promise.resolve())}catch(e){return Promise.reject(e)}},this.frontendApi=e,this.options=n,this.Clerk=r,this.mode=i()?"browser":"server"}var n,r=e.prototype;return r.loadClerkJS=function(){try{var e=this;return e.frontendApi||e.throwError("Clerk: You must add the frontendApi prop to your <ClerkProvider>"),Promise.resolve(function(n,r){try{var t=function(){function n(n){return e.hydrateClerkJS(global.Clerk)}var r=function(){if(e.Clerk){var n,r=function(){global.Clerk=n},t=function(){if("function"==typeof e.Clerk)return n=new e.Clerk(e.frontendApi),Promise.resolve(n.load(e.options)).then((function(){}));n=e.Clerk;var r=function(){if(!n.isReady())return Promise.resolve(n.load(e.options)).then((function(){}))}();return r&&r.then?r.then((function(){})):void 0}();return t&&t.then?t.then(r):r()}return Promise.resolve((o=e.frontendApi,i=e.options.scriptUrl,new Promise((function(e,n){global.Clerk&&e(null),o||n("Clerk: Missing provider");var r=document.createElement("script"),t=function(e,n){if(n)return n;var r=function(e){return e.endsWith(".lclstage.dev")||e.endsWith(".stgstage.dev")||e.endsWith(".clerkstage.dev")}(e)?"staging":parseInt("2.2.0".split(".")[0],10);return"https://"+e+"/npm/@clerk/clerk-js@"+r+"/dist/clerk.browser.js"}(o,i);r.setAttribute("data-clerk-frontend-api",o),r.setAttribute("crossorigin","anonymous"),r.async=!0,document.body||n("Clerk: Missing <body> element."),r.addEventListener("load",(function(){return e(r)})),r.addEventListener("error",(function(){return n("Clerk: Failed to load Clerk")})),r.src=t,document.body.appendChild(r)})))).then((function(){if(!global.Clerk)throw new Error("Failed to download latest ClerkJS. Contact support@clerk.dev.");return Promise.resolve(global.Clerk.load(e.options)).then((function(){}))}));var o,i}();return r&&r.then?r.then(n):n()}()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(0,(function(n){var r;r=n instanceof Error?n.message:String(n),e.throwError(r)})))}catch(e){return Promise.reject(e)}},r.throwError=function(e){throw console.error(e),new Error(e)},(n=[{key:"version",get:function(){var e;return null===(e=this.clerkjs)||void 0===e?void 0:e.version}},{key:"client",get:function(){return this.clerkjs?this.clerkjs.client:void 0}},{key:"session",get:function(){return this.clerkjs?this.clerkjs.session:void 0}},{key:"user",get:function(){return this.clerkjs?this.clerkjs.user:void 0}},{key:"__unstable__environment",get:function(){return this.clerkjs?this.clerkjs.__unstable__environment:void 0}}])&&function(e,n){for(var r=0;r<n.length;r++){var t=n[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}(e.prototype,n),e}();function a(e){if(!e)throw new Error("Clerk: You must wrap your application in a <ClerkProvider> component.")}function c(e,n){if(!e)throw new Error(function(e){return"Clerk: You're calling "+e+" before there's a guarantee the client has been loaded. Call "+e+" from a child of <SignedIn>, <SignedOut>, or <ClerkLoaded>, or use the withClerk() HOC."}(n))}function d(e,n){if(!e)throw new Error(function(e){return"Clerk: You're calling "+e+" before there's a guarantee there's an active user. Call "+e+" from a child of <SignedIn> or use the withUser() HOC."}(n))}var f=Object.freeze({noGuarantees:Object.freeze({guaranteedLoaded:!1,guaranteedUser:!1}),guaranteedLoaded:Object.freeze({guaranteedLoaded:!0,guaranteedUser:!1}),guaranteedAll:Object.freeze({guaranteedLoaded:!0,guaranteedUser:!0})}),p=r.createContext(void 0);p.displayName="StructureContext";var v=r.createContext(void 0);v.displayName="IsomorphicClerkContext";var m=function(e,o){e.displayName=o=o||e.displayName||e.name||"Component";var u=function(o){var u=n.useContext(p),s=n.useContext(v);if(!i())return null;a(u),a(s);var l=s.value;return l?u.guaranteedLoaded?r.createElement(e,t({},o,{clerk:l})):l.client?r.createElement(p.Provider,{value:f.guaranteedLoaded},r.createElement(e,t({},o,{clerk:l}))):null:null};return u.displayName="withClerk("+o+")",u},h=r.createContext(void 0);h.displayName="ClientContext";var g=r.createContext(void 0);g.displayName="SessionContext";var k=r.createContext(void 0);function C(){var e=n.useContext(k);return a(e),e}k.displayName="UserContext";var S=function(e,o){e.displayName=o=o||e.displayName||e.name||"Component";var u=function(o){var u=n.useContext(p),s=n.useContext(k);if(!i())return null;a(u),a(s);var l=s.value;return u.guaranteedUser&&l?r.createElement(e,t({},o,{user:l})):l?r.createElement(p.Provider,{value:f.guaranteedAll},r.createElement(e,t({},o,{user:l}))):null};return u.displayName="withUser("+o+")",u};function U(e){var n=e.children,o=e.clerkLoaded,i=e.isomorphicClerk,u=r.useState({client:i.client,session:i.session,user:i.user}),s=u[0],l=u[1];r.useEffect((function(){return i.addListener((function(e){return l(t({},e))}))}),[]);var a=s.client,c=s.session,d=s.user,f=r.useMemo((function(){return{value:i}}),[o]),p=r.useMemo((function(){return{value:a}}),[a]),m=r.useMemo((function(){return{value:c}}),[c]),C=r.useMemo((function(){return{value:d}}),[d]);return r.createElement(v.Provider,{value:f},r.createElement(h.Provider,{value:p},r.createElement(g.Provider,{value:m},r.createElement(k.Provider,{value:C},r.createElement(r.Fragment,{key:c?c.id:"no-users"},n)))))}function y(e){var t=n.useMemo((function(){var n=e.frontendApi,r=void 0===n?"":n,t=e.Clerk,i=o(e,["frontendApi","Clerk"]);return new l(r,i,t)}),[]),i=n.useState(!1),u=i[0],s=i[1];return n.useEffect((function(){t.loadClerkJS().then((function(){return s(!0)}))}),[]),r.createElement(p.Provider,{value:f.noGuarantees},t instanceof l&&t.ssrData&&r.createElement("script",{type:"application/json","data-clerk":"SSR",dangerouslySetInnerHTML:{__html:t.ssrData}}),r.createElement(U,{isomorphicClerk:t,clerkLoaded:u},e.children))}var j=s(y,"ClerkProvider","Clerk: You've added multiple <ClerkProvider> components in your React component tree. Wrap your components in a single <ClerkProvider>."),E=function(e){var n,t;function o(){for(var n,t=arguments.length,o=new Array(t),i=0;i<t;i++)o[i]=arguments[i];return(n=e.call.apply(e,[this].concat(o))||this).portalRef=r.createRef(),n}t=e,(n=o).prototype=Object.create(t.prototype),n.prototype.constructor=n,n.__proto__=t;var i=o.prototype;return i.componentDidMount=function(){this.portalRef.current&&this.props.mount(this.portalRef.current,this.props.props)},i.componentWillUnmount=function(){this.portalRef.current&&this.props.unmount(this.portalRef.current)},i.render=function(){return r.createElement("div",{ref:this.portalRef})},o}(r.PureComponent),w=m((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.createElement(E,{mount:n.mountSignIn,unmount:n.unmountSignIn,props:t})}),"SignIn"),x=m((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.createElement(E,{mount:n.mountSignUp,unmount:n.unmountSignUp,props:t})}),"SignUp"),P=m((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.createElement(E,{mount:n.mountUserProfile,unmount:n.unmountUserProfile,props:t})}),"UserProfile"),b=m((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.createElement(E,{mount:n.mountUserButton,unmount:n.unmountUserButton,props:t})}),"UserButton"),I=S((function(e){return r.createElement(r.Fragment,null,e.children)}),"SignedIn"),_=m((function(e){var n=e.children;return null===C().value?r.createElement(r.Fragment,null,n):null}),"SignedOut"),N=m((function(e){return r.createElement(r.Fragment,null,e.children)}),"ClerkLoaded"),O=m((function(e){var n=e.clerk,t=e.returnBack,o=n.client,i=n.session,u=n.__unstable__environment,s=o.activeSessions&&o.activeSessions.length>0;return r.useEffect((function(){null===i&&s&&u?n.navigate(u.displayConfig.afterSignOutOneUrl):n.redirectToSignIn(t)}),[]),null}),"RedirectToSignIn"),L=m((function(e){var n=e.clerk,t=e.returnBack;return r.useEffect((function(){n.redirectToSignUp(t)}),[]),null}),"RedirectToSignUp"),M=m((function(e){var n=e.clerk;return r.useEffect((function(){n.redirectToUserProfile()}),[]),null}),"RedirectToUserProfile");exports.AuthenticateWithRedirectCallback=m((function(e){var n=e.clerk,t=o(e,["clerk"]);return r.useEffect((function(){n.handleRedirectCallback(t)}),[]),null}),"AuthenticateWithRedirectCallback"),exports.ClerkLoaded=N,exports.ClerkLoading=function(e){var n=e.children;return void 0===C().value?r.createElement(r.Fragment,null,n):null},exports.ClerkProvider=j,exports.RedirectToSignIn=O,exports.RedirectToSignUp=L,exports.RedirectToUserProfile=M,exports.SignIn=w,exports.SignUp=x,exports.SignedIn=I,exports.SignedOut=_,exports.UserButton=b,exports.UserProfile=P,exports.WithClerk=function(e){var n=e.children;return r.createElement(p.Consumer,null,(function(e){return r.createElement(v.Consumer,null,(function(t){if("function"!=typeof n)throw new Error("Clerk: Child of WithClerk must be a function.");a(e),a(t);var o=t.value;return o?e.guaranteedLoaded?n(o):o.client?r.createElement(p.Provider,{value:f.guaranteedLoaded},n(o)):null:null}))}))},exports.WithSession=function(e){var n=e.children;return r.createElement(p.Consumer,null,(function(e){return r.createElement(g.Consumer,null,(function(t){if("function"!=typeof n)throw new Error("Clerk: Child of WithClerk must be a function.");a(e),a(t);var o=t.value;return e.guaranteedUser&&o?n(o):o?r.createElement(p.Provider,{value:f.guaranteedAll},n(o)):null}))}))},exports.WithUser=function(e){var n=e.children;return r.createElement(p.Consumer,null,(function(e){return r.createElement(k.Consumer,null,(function(t){if("function"!=typeof n)throw new Error("Clerk: Child of WithClerk must be a function.");a(e),a(t);var o=t.value;return e.guaranteedUser&&o?n(o):o?r.createElement(p.Provider,{value:f.guaranteedAll},n(o)):null}))}))},exports.useClerk=function(){var e=n.useContext(p),r=n.useContext(v);return a(e),a(r),c(e.guaranteedLoaded,"useClerk()"),c(r.value,"useClerk()"),r.value},exports.useSession=function(e){var r=t({},e);r.withAssertions=r.withAssertions||!1;var o=n.useContext(p),i=function(){var e=n.useContext(g);return a(e),e}();return r.withAssertions?t({session:i.value},{isLoading:function(e){return void 0===e},isSignedOut:function(e){return null===e},isSignedIn:function(e){return null!=e}}):(a(o),d(o.guaranteedUser,"useSession()"),d(i.value,"useSession()"),i.value)},exports.useSessionList=function(){var e=n.useContext(p),t=r.useContext(h);return a(t),a(e),c(e.guaranteedLoaded,"useSessionList()"),t.value.sessions},exports.useSignIn=function(){var e=n.useContext(p),t=r.useContext(h);return a(t),a(e),c(e.guaranteedLoaded,"useSignIn()"),t.value.signIn},exports.useSignUp=function(){var e=n.useContext(p),t=r.useContext(h);return a(t),a(e),c(e.guaranteedLoaded,"useSignUp()"),t.value.signUp},exports.useUser=function(e){var r=t({},e);r.withAssertions=r.withAssertions||!1;var o=n.useContext(p),i=C();return r.withAssertions?t({user:i.value},{isLoading:function(e){return void 0===e},isSignedOut:function(e){return null===e},isSignedIn:function(e){return!!e}}):(a(o),d(o.guaranteedUser,"useUser()"),d(i.value,"useUser()"),i.value)},exports.withClerk=m,exports.withSession=function(e,o){e.displayName=o=o||e.displayName||e.name||"Component";var u=function(o){var u=n.useContext(p),s=n.useContext(g);if(!i())return null;a(u),a(s);var l=s.value;return u.guaranteedUser&&l?r.createElement(e,t({},o,{session:l})):l?r.createElement(p.Provider,{value:f.guaranteedAll},r.createElement(e,t({},o,{session:l}))):null};return u.displayName="withSession("+o+")",u},exports.withUser=S; | ||
//# sourceMappingURL=clerk-react.cjs.production.min.js.map |
@@ -84,3 +84,3 @@ import React, { useContext, useMemo, useState, useEffect } from 'react'; | ||
var version = "2.1.1-staging.3"; | ||
var version = "2.2.0"; | ||
@@ -87,0 +87,0 @@ var FAILED_TO_LOAD_ERROR = 'Clerk: Failed to load Clerk'; |
{ | ||
"name": "@clerk/clerk-react", | ||
"version": "2.1.1-staging.3", | ||
"version": "2.2.0", | ||
"license": "MIT", | ||
@@ -37,3 +37,3 @@ "description": "Clerk.dev React library", | ||
"dependencies": { | ||
"@clerk/types": "1.16.1-staging.1" | ||
"@clerk/types": "1.17.0" | ||
}, | ||
@@ -40,0 +40,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
374113
+ Added@clerk/types@1.17.0(transitive)
- Removed@clerk/types@1.16.1-staging.1(transitive)
Updated@clerk/types@1.17.0