@seayoo-web/captcha 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/index.js +30 -35
- package/package.json +8 -7
- package/types/src/tencent.d.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -1,59 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
let s;
|
|
7
|
-
async function i() {
|
|
8
|
-
return "TencentCaptcha" in window && window.TencentCaptcha ? window.TencentCaptcha : s ? await s : (s = u("https://turing.captcha.qcloud.com/TJCaptcha.js").then(() => window.TencentCaptcha ?? null), await s);
|
|
1
|
+
import { useConsole as r, EventBus as c, usePromise as d, loadJS as h } from "@seayoo-web/utils";
|
|
2
|
+
const p = r("CaptchaSDK");
|
|
3
|
+
let e;
|
|
4
|
+
async function s() {
|
|
5
|
+
return "TencentCaptcha" in window && window.TencentCaptcha ? window.TencentCaptcha : e ? await e : (e = h("https://turing.captcha.qcloud.com/TJCaptcha.js").then(() => window.TencentCaptcha ?? null), await e);
|
|
9
6
|
}
|
|
10
|
-
class
|
|
7
|
+
class u {
|
|
8
|
+
sdk = null;
|
|
9
|
+
isReady = !1;
|
|
10
|
+
event = new c();
|
|
11
|
+
/** 提前加载腾讯 js sdk */
|
|
12
|
+
static preloadSDK() {
|
|
13
|
+
s();
|
|
14
|
+
}
|
|
11
15
|
/**
|
|
12
16
|
* 创建验证码实例,创建后立即开始加载腾讯天御 SDK
|
|
13
17
|
*/
|
|
14
|
-
constructor(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
i().then((e) => {
|
|
19
|
-
if (!e)
|
|
20
|
-
y.error("Load TencentCaptcha Error!");
|
|
18
|
+
constructor(a) {
|
|
19
|
+
s().then((t) => {
|
|
20
|
+
if (!t)
|
|
21
|
+
p.error("Load TencentCaptcha Error!");
|
|
21
22
|
else {
|
|
22
|
-
const { captchaAppId:
|
|
23
|
-
this.sdk = new
|
|
24
|
-
|
|
25
|
-
(
|
|
26
|
-
this.event.emit("done",
|
|
23
|
+
const { captchaAppId: o, ...i } = a;
|
|
24
|
+
this.sdk = new t(
|
|
25
|
+
o,
|
|
26
|
+
(n) => {
|
|
27
|
+
this.event.emit("done", n);
|
|
27
28
|
},
|
|
28
29
|
{
|
|
29
|
-
...
|
|
30
|
-
ready: (
|
|
31
|
-
this.isReady = !0, this.event.emit("ready",
|
|
30
|
+
...i,
|
|
31
|
+
ready: (n) => {
|
|
32
|
+
this.isReady = !0, this.event.emit("ready", n);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
);
|
|
35
36
|
}
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
|
-
/** 提前加载腾讯 js sdk */
|
|
39
|
-
static preloadSDK() {
|
|
40
|
-
i();
|
|
41
|
-
}
|
|
42
39
|
async ready() {
|
|
43
40
|
if (this.isReady)
|
|
44
41
|
return;
|
|
45
|
-
const { promise:
|
|
46
|
-
this.event.once("ready",
|
|
42
|
+
const { promise: a, resolve: t } = d();
|
|
43
|
+
this.event.once("ready", t), await a;
|
|
47
44
|
}
|
|
48
45
|
async show() {
|
|
49
|
-
|
|
50
|
-
await this.ready(), (t = this.sdk) == null || t.show();
|
|
46
|
+
await this.ready(), this.sdk?.show();
|
|
51
47
|
}
|
|
52
48
|
async destroy() {
|
|
53
|
-
|
|
54
|
-
await this.ready(), (t = this.sdk) == null || t.destroy();
|
|
49
|
+
await this.ready(), this.sdk?.destroy();
|
|
55
50
|
}
|
|
56
51
|
}
|
|
57
52
|
export {
|
|
58
|
-
|
|
53
|
+
u as TencentCaptchaAgent
|
|
59
54
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seayoo-web/captcha",
|
|
3
3
|
"description": "captcha agent",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
19
|
-
"node": ">=
|
|
19
|
+
"node": ">=22"
|
|
20
20
|
},
|
|
21
21
|
"keywords": [
|
|
22
22
|
"captcha"
|
|
@@ -24,18 +24,19 @@
|
|
|
24
24
|
"author": "web@seayoo.com",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@seayoo-web/scripts": "^
|
|
28
|
-
"@seayoo-web/tsconfig": "^1.0.
|
|
29
|
-
"@seayoo-web/utils": "^
|
|
27
|
+
"@seayoo-web/scripts": "^3.0.0",
|
|
28
|
+
"@seayoo-web/tsconfig": "^1.0.5",
|
|
29
|
+
"@seayoo-web/utils": "^4.0.2"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@seayoo-web/utils": "^
|
|
32
|
+
"@seayoo-web/utils": "^4.0.2"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
+
"prebuild": "pnpm -F utils build",
|
|
35
36
|
"build": "vite build && tsc --emitDeclarationOnly",
|
|
36
37
|
"type-check": "tsc --noEmit",
|
|
37
38
|
"lint": "eslint ./src/**/*.ts",
|
|
38
|
-
"lint:fix": "eslint
|
|
39
|
+
"lint:fix": "eslint \"./src/**/*.{ts,js}\" --fix",
|
|
39
40
|
"prepublish": "pnpm lint:fix && pnpm build"
|
|
40
41
|
}
|
|
41
42
|
}
|
package/types/src/tencent.d.ts
CHANGED