vue3-smart-captcha
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -1,7 +0,7 @@ | ||
import { defineComponent as l, ref as p, onMounted as d, computed as h, openBlock as u, createElementBlock as m, normalizeClass as C } from "vue"; | ||
const b = "https://smartcaptcha.yandexcloud.net/captcha.js", w = /* @__PURE__ */ l({ | ||
import { defineComponent as h, ref as u, onMounted as m, computed as r, openBlock as C, createElementBlock as b, normalizeClass as w } from "vue"; | ||
const f = "https://smartcaptcha.yandexcloud.net/captcha.js", k = /* @__PURE__ */ h({ | ||
__name: "SmartCaptcha", | ||
props: { | ||
sitekey: {}, | ||
callback: { type: Function }, | ||
callback: {}, | ||
hl: {}, | ||
@@ -13,41 +13,47 @@ test: { type: Boolean }, | ||
hideShield: { type: Boolean }, | ||
onChallengeVisible: { type: Function }, | ||
onChallengeHidden: { type: Function }, | ||
onNetworkError: { type: Function }, | ||
onSuccess: { type: Function }, | ||
onTokenExpired: { type: Function } | ||
loadWidget: { type: Boolean, default: !0 }, | ||
onChallengeVisible: {}, | ||
onChallengeHidden: {}, | ||
onNetworkError: {}, | ||
onSuccess: {}, | ||
onTokenExpired: {} | ||
}, | ||
setup(n) { | ||
const o = p(), e = n; | ||
d(() => { | ||
i(), r(); | ||
const o = u(), e = n; | ||
m(() => { | ||
s.value && c(), l(); | ||
}); | ||
const c = h(() => e.invisible === !0), i = () => { | ||
const s = r(() => e.loadWidget), i = r(() => e.invisible === !0), c = () => { | ||
const t = document.createElement("script"); | ||
t.setAttribute("src", `${b}?render=onload`), t.setAttribute("defer", "true"), document.head.appendChild(t); | ||
}, r = () => { | ||
const t = setInterval(() => { | ||
t.setAttribute("src", `${f}?render=onload`), t.setAttribute("defer", "true"), document.head.appendChild(t); | ||
}, l = () => { | ||
let t = 0; | ||
const a = setInterval(() => { | ||
if (++t === 10) { | ||
clearInterval(a); | ||
return; | ||
} | ||
if (window.smartCaptcha !== void 0) { | ||
clearInterval(t); | ||
const a = window.smartCaptcha.render(o.value, e); | ||
s(a); | ||
clearInterval(a); | ||
const p = window.smartCaptcha.render(o.value, e); | ||
d(p); | ||
} | ||
}, 200); | ||
}, s = (t) => { | ||
}, d = (t) => { | ||
e.onChallengeHidden && window.smartCaptcha.subscribe(t, "challenge-hidden", e.onChallengeHidden), e.onChallengeVisible && window.smartCaptcha.subscribe(t, "challenge-visible", e.onChallengeVisible), e.onNetworkError && window.smartCaptcha.subscribe(t, "network-error", e.onNetworkError), e.onSuccess && window.smartCaptcha.subscribe(t, "success", e.onSuccess), e.onTokenExpired && window.smartCaptcha.subscribe(t, "token-expired", e.onTokenExpired); | ||
}; | ||
return (t, a) => (u(), m("div", { | ||
return (t, a) => (C(), b("div", { | ||
ref_key: "container", | ||
ref: o, | ||
class: C({ "smart-captcha": !c.value }) | ||
class: w({ "smart-captcha": !i.value }) | ||
}, null, 2)); | ||
} | ||
}), k = { | ||
}), S = { | ||
install: (n) => { | ||
n.component("SmartCaptcha", w); | ||
n.component("SmartCaptcha", k); | ||
} | ||
}; | ||
export { | ||
w as SmartCaptcha, | ||
k as SmartCaptchaPlugin | ||
k as SmartCaptcha, | ||
S as SmartCaptchaPlugin | ||
}; |
@@ -12,2 +12,6 @@ import { AllowedComponentProps } from 'vue'; | ||
declare type __VLS_Prettify<T> = { | ||
[K in keyof T]: T[K]; | ||
} & {}; | ||
declare type __VLS_TypePropsToRuntimeProps<T> = { | ||
@@ -22,2 +26,8 @@ [K in keyof T]-?: {} extends Pick<T, K> ? { | ||
declare type __VLS_WithDefaults<P, D> = { | ||
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & { | ||
default: D[K]; | ||
}> : P[K]; | ||
}; | ||
/** | ||
@@ -35,2 +45,3 @@ * @link https://cloud.yandex.ru/docs/smartcaptcha/concepts/widget-methods#render | ||
hideShield?: boolean, | ||
loadWidget?: boolean, | ||
} | ||
@@ -46,3 +57,9 @@ | ||
export declare const SmartCaptcha: DefineComponent<__VLS_TypePropsToRuntimeProps<RenderParams & Subscriptions>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<RenderParams & Subscriptions>>>, {}, {}>; | ||
export declare const SmartCaptcha: DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<RenderParams & Subscriptions>, { | ||
loadWidget: boolean; | ||
}>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<RenderParams & Subscriptions>, { | ||
loadWidget: boolean; | ||
}>>>, { | ||
loadWidget: boolean; | ||
}, {}>; | ||
@@ -49,0 +66,0 @@ export declare const SmartCaptchaPlugin: Plugin_2; |
@@ -12,3 +12,3 @@ { | ||
"license": "MIT", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"type": "module", | ||
@@ -15,0 +15,0 @@ "main": "./dist/index.cjs", |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
13076
138
0