@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 CHANGED
@@ -1,59 +1,54 @@
1
- var d = Object.defineProperty;
2
- var h = (a, t, e) => t in a ? d(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
- var n = (a, t, e) => h(a, typeof t != "symbol" ? t + "" : t, e);
4
- import { useConsole as p, EventBus as w, usePromise as l, loadJS as u } from "@seayoo-web/utils";
5
- const y = p("CaptchaSDK");
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 m {
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(t) {
15
- n(this, "sdk", null);
16
- n(this, "isReady", !1);
17
- n(this, "event", new w());
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: r, ...c } = t;
23
- this.sdk = new e(
24
- r,
25
- (o) => {
26
- this.event.emit("done", o);
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
- ...c,
30
- ready: (o) => {
31
- this.isReady = !0, this.event.emit("ready", o);
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: t, resolve: e } = l();
46
- this.event.once("ready", e), await t;
42
+ const { promise: a, resolve: t } = d();
43
+ this.event.once("ready", t), await a;
47
44
  }
48
45
  async show() {
49
- var t;
50
- await this.ready(), (t = this.sdk) == null || t.show();
46
+ await this.ready(), this.sdk?.show();
51
47
  }
52
48
  async destroy() {
53
- var t;
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
- m as TencentCaptchaAgent
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.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": ">=18"
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": "^1.0.6",
28
- "@seayoo-web/tsconfig": "^1.0.2",
29
- "@seayoo-web/utils": "^2.2.0"
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": "^2.2.0"
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 ./src/**/*.{ts,js} --fix",
39
+ "lint:fix": "eslint \"./src/**/*.{ts,js}\" --fix",
39
40
  "prepublish": "pnpm lint:fix && pnpm build"
40
41
  }
41
42
  }
@@ -1,3 +1,4 @@
1
+ /** spell-checker:ignore trerror_, randstr */
1
2
  /** 对腾讯的sdk做简单声明 */
2
3
  declare global {
3
4
  interface Window {