jk-vue-comps 0.1.0 → 0.1.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.
@@ -15,11 +15,7 @@ export declare const GoogleAuth: {
15
15
  code: string;
16
16
  }) => any) | undefined;
17
17
  onRejectCallback?: ((_data: any) => any) | undefined;
18
- }, {
19
- domId: string;
20
- isHidden: import("vue").Ref<boolean>;
21
- startCheck: () => void;
22
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
18
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
23
19
  callback: (_data: {
24
20
  code: string;
25
21
  }) => true;
@@ -62,11 +58,7 @@ export declare const GoogleAuth: {
62
58
  code: string;
63
59
  }) => any) | undefined;
64
60
  onRejectCallback?: ((_data: any) => any) | undefined;
65
- }, {
66
- domId: string;
67
- isHidden: import("vue").Ref<boolean>;
68
- startCheck: () => void;
69
- }, {}, {}, {}, {
61
+ }, () => JSX.Element, {}, {}, {}, {
70
62
  clientId: string;
71
63
  redirectUri: string;
72
64
  }>;
@@ -85,11 +77,7 @@ export declare const GoogleAuth: {
85
77
  code: string;
86
78
  }) => any) | undefined;
87
79
  onRejectCallback?: ((_data: any) => any) | undefined;
88
- }, {
89
- domId: string;
90
- isHidden: import("vue").Ref<boolean>;
91
- startCheck: () => void;
92
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
80
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
93
81
  callback: (_data: {
94
82
  code: string;
95
83
  }) => true;
@@ -1,81 +1,70 @@
1
- import { defineComponent as p, ref as m, onMounted as f, createVNode as g } from "vue";
2
- import { p as u } from "../chunks/vuePropTypes-zy5Iwonj.js";
3
- import { C as h, A as C } from "../chunks/is-bvgc5qxU.js";
4
- import { w } from "../chunks/withInstall-b5j1glXj.js";
5
- import { u as I } from "../chunks/useDomId-D5qLoFSQ.js";
6
- function _(t, c) {
7
- if (!t || !c)
1
+ import { defineComponent as g, ref as p, onMounted as h, createVNode as C } from "vue";
2
+ import { p as f } from "../chunks/vuePropTypes-zy5Iwonj.js";
3
+ import { C as w, A as _ } from "../chunks/is-bvgc5qxU.js";
4
+ import { w as b } from "../chunks/withInstall-b5j1glXj.js";
5
+ function v(o, r) {
6
+ if (!o || !r)
8
7
  return;
9
- const i = encodeURIComponent(c), o = encodeURIComponent("email profile"), n = encodeURIComponent(t), d = `https://accounts.google.com/o/oauth2/v2/auth?response_type=code&redirect_uri=${i}&scope=${o}&client_id=${n}`;
10
- h() ? window.open(d, "_self") : window.location.href = d;
8
+ const c = encodeURIComponent(r), a = encodeURIComponent("email profile"), i = encodeURIComponent(o), n = `https://accounts.google.com/o/oauth2/v2/auth?response_type=code&redirect_uri=${c}&scope=${a}&client_id=${i}`;
9
+ w() ? window.open(n, "_self") : window.location.href = n;
11
10
  }
12
- const b = /* @__PURE__ */ p({
11
+ const I = /* @__PURE__ */ g({
13
12
  name: "GoogleAuth",
14
- toGoogleAuth: _,
13
+ toGoogleAuth: v,
15
14
  props: {
16
- clientId: u.string,
17
- redirectUri: u.string
15
+ clientId: f.string,
16
+ redirectUri: f.string
18
17
  },
19
18
  emits: {
20
- callback: (t) => !0,
21
- rejectCallback: (t) => !0
19
+ callback: (o) => !0,
20
+ rejectCallback: (o) => !0
22
21
  },
23
22
  slots: Object,
24
- setup(t, {
25
- emit: c
23
+ setup(o, {
24
+ emit: r,
25
+ slots: c,
26
+ expose: a
26
27
  }) {
27
- const i = I("google-auth"), o = m(!0), n = () => {
28
- var r, e, s;
29
- return (s = (e = (r = window == null ? void 0 : window.google) == null ? void 0 : r.accounts) == null ? void 0 : e.oauth2) == null ? void 0 : s.initCodeClient;
28
+ const i = p(null), n = p(!0), s = () => {
29
+ var e, t, l;
30
+ return (l = (t = (e = window == null ? void 0 : window.google) == null ? void 0 : e.accounts) == null ? void 0 : t.oauth2) == null ? void 0 : l.initCodeClient;
30
31
  };
31
32
  function d() {
32
- var r, e, s;
33
- (s = (e = (r = n()) == null ? void 0 : r({
34
- client_id: t.clientId,
33
+ var e, t, l;
34
+ (l = (t = (e = s()) == null ? void 0 : e({
35
+ client_id: o.clientId,
35
36
  scope: "email profile",
36
- redirect_uri: t.redirectUri,
37
- ux_mode: C() ? "redirect" : "popup",
38
- callback(l) {
39
- l.error ? c("rejectCallback", l) : c("callback", l);
37
+ redirect_uri: o.redirectUri,
38
+ ux_mode: _() ? "redirect" : "popup",
39
+ callback(u) {
40
+ u.error ? r("rejectCallback", u) : r("callback", u);
40
41
  }
41
- })) == null ? void 0 : e.requestCode) == null || s.call(e);
42
+ })) == null ? void 0 : t.requestCode) == null || l.call(t);
42
43
  }
43
- function a() {
44
- if (!(window != null && window.document) || n()) {
45
- n() && (o.value = !1);
44
+ function m() {
45
+ if (!(window != null && window.document) || s() || !i.value) {
46
+ s() && (n.value = !1);
46
47
  return;
47
48
  }
48
- const r = document.getElementById(i);
49
- if (!r)
50
- return;
51
49
  const e = document.createElement("script");
52
- e.async = !0, e.defer = !0, e.src = "https://accounts.google.com/gsi/client", r.appendChild(e), e.onload = () => {
53
- n() && (o.value = !1);
50
+ e.async = !0, e.defer = !0, e.src = "https://accounts.google.com/gsi/client", i.value.appendChild(e), e.onload = () => {
51
+ s() && (n.value = !1);
54
52
  };
55
53
  }
56
- return f(a), {
57
- domId: i,
58
- isHidden: o,
54
+ return h(m), a({
59
55
  startCheck: d
56
+ }), () => {
57
+ var e;
58
+ return C("div", {
59
+ ref: i
60
+ }, [!n.value && ((e = c.default) == null ? void 0 : e.call(c, {
61
+ startCheck: d
62
+ }))]);
60
63
  };
61
- },
62
- render() {
63
- var n;
64
- const {
65
- domId: t,
66
- isHidden: c,
67
- startCheck: i,
68
- $slots: o
69
- } = this;
70
- return g("div", {
71
- id: t
72
- }, [!c && ((n = o == null ? void 0 : o.default) == null ? void 0 : n.call(o, {
73
- startCheck: i
74
- }))]);
75
64
  }
76
- }), G = w(b);
65
+ }), R = b(I);
77
66
  export {
78
- G as GoogleAuth,
79
- G as default,
80
- _ as toGoogleAuth
67
+ R as GoogleAuth,
68
+ R as default,
69
+ v as toGoogleAuth
81
70
  };
@@ -12,7 +12,7 @@ export type TgUserData = {
12
12
  /** 跳转Telegram身份检查 */
13
13
  export declare function toTelegramAuth(botId: number, toPath: string): void;
14
14
  /** 获取路由中的Telegram身份检查回调参数 */
15
- export declare function getTelegramAuthUrlParams(): any;
15
+ export declare function getTelegramAuthUrlParams(): TgUserData | null;
16
16
  /** Telegram身份检查 */
17
17
  export declare const TelegramAuth: {
18
18
  new (...args: any[]): import("vue").CreateComponentPublicInstance<Readonly<import("vue").ExtractPropTypes<{
@@ -25,10 +25,7 @@ export declare const TelegramAuth: {
25
25
  }>> & {
26
26
  onCallback?: ((_user: TgUserData) => any) | undefined;
27
27
  onRejectCallback?: (() => any) | undefined;
28
- }, {
29
- domId: string;
30
- startCheck: () => void;
31
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
28
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
32
29
  callback: (_user: TgUserData) => true;
33
30
  rejectCallback: () => true;
34
31
  }, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<import("vue").ExtractPropTypes<{
@@ -65,10 +62,7 @@ export declare const TelegramAuth: {
65
62
  }>> & {
66
63
  onCallback?: ((_user: TgUserData) => any) | undefined;
67
64
  onRejectCallback?: (() => any) | undefined;
68
- }, {
69
- domId: string;
70
- startCheck: () => void;
71
- }, {}, {}, {}, {
65
+ }, () => JSX.Element, {}, {}, {}, {
72
66
  botId: number;
73
67
  toPath: string;
74
68
  }>;
@@ -85,10 +79,7 @@ export declare const TelegramAuth: {
85
79
  }>> & {
86
80
  onCallback?: ((_user: TgUserData) => any) | undefined;
87
81
  onRejectCallback?: (() => any) | undefined;
88
- }, {
89
- domId: string;
90
- startCheck: () => void;
91
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
82
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
92
83
  callback: (_user: TgUserData) => true;
93
84
  rejectCallback: () => true;
94
85
  }, string, {
@@ -1,36 +1,35 @@
1
- import { defineComponent as p, onMounted as f, createVNode as h } from "vue";
2
- import { p as u } from "../chunks/vuePropTypes-zy5Iwonj.js";
3
- import { a as g } from "../chunks/index-CA5i_Cgq.js";
4
- import { u as w } from "../chunks/useDomId-D5qLoFSQ.js";
5
- import { w as b } from "../chunks/withInstall-b5j1glXj.js";
6
- import { C, A as l } from "../chunks/is-bvgc5qxU.js";
7
- function m(r, o) {
1
+ import { defineComponent as h, ref as g, onMounted as w, createVNode as b } from "vue";
2
+ import { p as m } from "../chunks/vuePropTypes-zy5Iwonj.js";
3
+ import { a as A } from "../chunks/index-CA5i_Cgq.js";
4
+ import { w as C } from "../chunks/withInstall-b5j1glXj.js";
5
+ import { C as _, A as p } from "../chunks/is-bvgc5qxU.js";
6
+ function d(r, o) {
8
7
  if (!r || !o)
9
8
  return;
10
- const e = encodeURIComponent(g()), t = encodeURIComponent(o), s = `https://oauth.telegram.org/auth?bot_id=${r}&origin=${e}&embed=1&request_access=write&return_to=${e}${t}`;
11
- C() ? window.open(s, "_self") : window.location.href = s;
9
+ const t = encodeURIComponent(A()), n = encodeURIComponent(o), a = `https://oauth.telegram.org/auth?bot_id=${r}&origin=${t}&embed=1&request_access=write&return_to=${t}${n}`;
10
+ _() ? window.open(a, "_self") : window.location.href = a;
12
11
  }
13
- function I() {
12
+ function T() {
14
13
  const r = /[#\?\&]tgAuthResult=([A-Za-z0-9\-_=]*)$/;
15
14
  try {
16
- const o = window.location.hash.toString(), e = o.match(r);
17
- if (!e)
18
- return !1;
15
+ const o = window.location.hash.toString(), t = o.match(r);
16
+ if (!t)
17
+ return null;
19
18
  window.location.hash = o.replace(r, "");
20
- let t = e[1].replace(/-/g, "+").replace(/_/g, "/");
21
- const s = t.length % 4;
22
- return s > 1 && (t += new Array(5 - s).join("=")), t ? JSON.parse(window.atob(t)) : !1;
19
+ let n = t[1].replace(/-/g, "+").replace(/_/g, "/");
20
+ const a = n.length % 4;
21
+ return a > 1 && (n += new Array(5 - a).join("=")), n ? JSON.parse(window.atob(n)) : null;
23
22
  } catch {
24
- return !1;
23
+ return null;
25
24
  }
26
25
  }
27
- const _ = /* @__PURE__ */ p({
26
+ const j = /* @__PURE__ */ h({
28
27
  name: "TelegramAuth",
29
- toTelegramAuth: m,
30
- getTelegramAuthUrlParams: I,
28
+ toTelegramAuth: d,
29
+ getTelegramAuthUrlParams: T,
31
30
  props: {
32
- botId: u.number,
33
- toPath: u.string
31
+ botId: m.number,
32
+ toPath: m.string
34
33
  },
35
34
  emits: {
36
35
  callback: (r) => !0,
@@ -38,62 +37,55 @@ const _ = /* @__PURE__ */ p({
38
37
  },
39
38
  slots: Object,
40
39
  setup(r, {
41
- emit: o
40
+ emit: o,
41
+ slots: t,
42
+ expose: n
42
43
  }) {
43
- const e = w("telegram-auth"), t = () => {
44
- var n, a;
45
- return (a = (n = window == null ? void 0 : window.Telegram) == null ? void 0 : n.Login) == null ? void 0 : a.auth;
44
+ const a = g(null), i = () => {
45
+ var e, c;
46
+ return (c = (e = window == null ? void 0 : window.Telegram) == null ? void 0 : e.Login) == null ? void 0 : c.auth;
46
47
  };
47
- function s() {
48
+ function l() {
48
49
  const {
49
- botId: n,
50
- toPath: a
50
+ botId: e,
51
+ toPath: c
51
52
  } = r;
52
- if (!n)
53
+ if (!e)
53
54
  return;
54
- const c = t();
55
- if (l() || !c) {
56
- m(n, a);
55
+ const s = i();
56
+ if (p() || !s) {
57
+ d(e, c);
57
58
  return;
58
59
  }
59
- c == null || c({
60
- bot_id: n,
60
+ s == null || s({
61
+ bot_id: e,
61
62
  request_access: !0
62
- }, (i) => {
63
- i ? o("callback", i) : o("rejectCallback");
63
+ }, (u) => {
64
+ u ? o("callback", u) : o("rejectCallback");
64
65
  });
65
66
  }
66
- function d() {
67
- if (!(window != null && window.document) || t() || l())
67
+ function f() {
68
+ var c;
69
+ if (!(window != null && window.document) || i() || p())
68
70
  return;
69
- const n = document.getElementById(e);
70
- if (!n)
71
- return;
72
- const a = document.createElement("script");
73
- a.async = !0, a.defer = !0, a.src = "https://telegram.org/js/telegram-widget.js", n.appendChild(a);
71
+ const e = document.createElement("script");
72
+ e.async = !0, e.defer = !0, e.src = "https://telegram.org/js/telegram-widget.js", (c = a.value) == null || c.appendChild(e);
74
73
  }
75
- return f(d), {
76
- domId: e,
77
- startCheck: s
74
+ return w(f), n({
75
+ startCheck: l
76
+ }), () => {
77
+ var e;
78
+ return b("div", {
79
+ ref: a
80
+ }, [(e = t.default) == null ? void 0 : e.call(t, {
81
+ startCheck: l
82
+ })]);
78
83
  };
79
- },
80
- render() {
81
- var t;
82
- const {
83
- domId: r,
84
- startCheck: o,
85
- $slots: e
86
- } = this;
87
- return h("div", {
88
- id: r
89
- }, [(t = e == null ? void 0 : e.default) == null ? void 0 : t.call(e, {
90
- startCheck: o
91
- })]);
92
84
  }
93
- }), B = b(_);
85
+ }), R = C(j);
94
86
  export {
95
- B as TelegramAuth,
96
- B as default,
97
- I as getTelegramAuthUrlParams,
98
- m as toTelegramAuth
87
+ R as TelegramAuth,
88
+ R as default,
89
+ T as getTelegramAuthUrlParams,
90
+ d as toTelegramAuth
99
91
  };
@@ -65,11 +65,7 @@ declare const JKVUEComps: {
65
65
  code: string;
66
66
  }) => any) | undefined;
67
67
  onRejectCallback?: ((_data: any) => any) | undefined;
68
- }, {
69
- domId: string;
70
- isHidden: import("vue").Ref<boolean>;
71
- startCheck: () => void;
72
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
68
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
73
69
  callback: (_data: {
74
70
  code: string;
75
71
  }) => true;
@@ -112,11 +108,7 @@ declare const JKVUEComps: {
112
108
  code: string;
113
109
  }) => any) | undefined;
114
110
  onRejectCallback?: ((_data: any) => any) | undefined;
115
- }, {
116
- domId: string;
117
- isHidden: import("vue").Ref<boolean>;
118
- startCheck: () => void;
119
- }, {}, {}, {}, {
111
+ }, () => JSX.Element, {}, {}, {}, {
120
112
  clientId: string;
121
113
  redirectUri: string;
122
114
  }>;
@@ -135,11 +127,7 @@ declare const JKVUEComps: {
135
127
  code: string;
136
128
  }) => any) | undefined;
137
129
  onRejectCallback?: ((_data: any) => any) | undefined;
138
- }, {
139
- domId: string;
140
- isHidden: import("vue").Ref<boolean>;
141
- startCheck: () => void;
142
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
130
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
143
131
  callback: (_data: {
144
132
  code: string;
145
133
  }) => true;
@@ -155,7 +143,7 @@ declare const JKVUEComps: {
155
143
  readonly toGoogleAuth: typeof comps.toGoogleAuth;
156
144
  } & import("vue").Plugin)));
157
145
  toTelegramAuth(botId: number, toPath: string): void;
158
- getTelegramAuthUrlParams(): any;
146
+ getTelegramAuthUrlParams(): comps.TgUserData | null;
159
147
  TelegramAuth: {
160
148
  new (...args: any[]): import("vue").CreateComponentPublicInstance<Readonly<import("vue").ExtractPropTypes<{
161
149
  botId: import("vue-types").VueTypeValidableDef<number, import("node_modules/vue-types/dist/types").ValidatorFunction<number>> & {
@@ -167,10 +155,7 @@ declare const JKVUEComps: {
167
155
  }>> & {
168
156
  onCallback?: ((_user: comps.TgUserData) => any) | undefined;
169
157
  onRejectCallback?: (() => any) | undefined;
170
- }, {
171
- domId: string;
172
- startCheck: () => void;
173
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
158
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
174
159
  callback: (_user: comps.TgUserData) => true;
175
160
  rejectCallback: () => true;
176
161
  }, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<import("vue").ExtractPropTypes<{
@@ -207,10 +192,7 @@ declare const JKVUEComps: {
207
192
  }>> & {
208
193
  onCallback?: ((_user: comps.TgUserData) => any) | undefined;
209
194
  onRejectCallback?: (() => any) | undefined;
210
- }, {
211
- domId: string;
212
- startCheck: () => void;
213
- }, {}, {}, {}, {
195
+ }, () => JSX.Element, {}, {}, {}, {
214
196
  botId: number;
215
197
  toPath: string;
216
198
  }>;
@@ -227,10 +209,7 @@ declare const JKVUEComps: {
227
209
  }>> & {
228
210
  onCallback?: ((_user: comps.TgUserData) => any) | undefined;
229
211
  onRejectCallback?: (() => any) | undefined;
230
- }, {
231
- domId: string;
232
- startCheck: () => void;
233
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
212
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
234
213
  callback: (_user: comps.TgUserData) => true;
235
214
  rejectCallback: () => true;
236
215
  }, string, {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "jk-vue-comps",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "jk-vue-comps",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
8
- "types": "dist/types/index.d.ts",
8
+ "types": "dist/index.d.ts",
9
9
  "files": [
10
10
  "dist"
11
11
  ],
@@ -1,8 +0,0 @@
1
- function r(e) {
2
- if (!e)
3
- throw new TypeError("idName is undefined!");
4
- return `jk-vue-comps-${e}`;
5
- }
6
- export {
7
- r as u
8
- };
@@ -1 +0,0 @@
1
- export declare function useDomId(idName: string): string;
File without changes
File without changes
File without changes
File without changes
File without changes