UNPKG

caplib

Version:

Credentialless Authentication Protocol Library for Web Applications

45 lines (44 loc) 975 B
import { CapAuth } from "../chunk-RYE5TPNM.mjs"; // src/vue/components/CapAuth.ts import { createRoot } from "react-dom/client"; import { createElement } from "react"; function mountCapAuth(element, options) { const root = createRoot(element); root.render( createElement(CapAuth, { config: options.config, onAuthenticated: options.onAuthenticated, onError: options.onError }) ); return () => { root.unmount(); }; } var CapAuth_default = { /** * Mount CapAuth into an element */ mount: mountCapAuth, /** * Vue directive (for use with v-capauth) */ directive: { mounted(el, binding) { const cleanup = mountCapAuth(el, binding.value); el.__capauth_cleanup = cleanup; }, unmounted(el) { const cleanup = el.__capauth_cleanup; if (typeof cleanup === "function") { cleanup(); } } } }; export { CapAuth_default as VueCapAuth }; //# sourceMappingURL=index.mjs.map