jk-vue-comps 0.1.0

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.
@@ -0,0 +1,8 @@
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
+ };
@@ -0,0 +1,34 @@
1
+ var i = Object.defineProperty;
2
+ var l = (c, a, o) => a in c ? i(c, a, { enumerable: !0, configurable: !0, writable: !0, value: o }) : c[a] = o;
3
+ var s = (c, a, o) => (l(c, typeof a != "symbol" ? a + "" : a, o), o);
4
+ import * as n from "vue-types";
5
+ const { createTypes: u, toValidableType: r } = n, t = void 0, y = {
6
+ func: t,
7
+ bool: t,
8
+ string: t,
9
+ number: t,
10
+ object: t,
11
+ integer: t
12
+ };
13
+ class e extends u(y) {
14
+ static get style() {
15
+ return r("style", {
16
+ type: [String, Object],
17
+ default: t
18
+ });
19
+ }
20
+ static get vueNode() {
21
+ return r("vueNode", { default: t });
22
+ }
23
+ }
24
+ s(e, "vueTypes", n), s(e, "anyType", n.any), s(e, "stringType", n.string), s(e, "boolType", n.bool), s(e, "numberType", n.number), s(e, "funcType", n.func);
25
+ const b = e, p = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
26
+ __proto__: null,
27
+ default: e,
28
+ propTypes: b
29
+ }, Symbol.toStringTag, { value: "Module" }));
30
+ export {
31
+ e as V,
32
+ p as a,
33
+ b as p
34
+ };
@@ -0,0 +1,14 @@
1
+ function r(t, l) {
2
+ const e = t;
3
+ return e.install = (o) => {
4
+ o.component(e.name || e.displayName, t), l && (o.config.globalProperties[l] = t);
5
+ }, t;
6
+ }
7
+ const a = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8
+ __proto__: null,
9
+ withInstall: r
10
+ }, Symbol.toStringTag, { value: "Module" }));
11
+ export {
12
+ a,
13
+ r as w
14
+ };
@@ -0,0 +1,81 @@
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)
8
+ 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;
11
+ }
12
+ const b = /* @__PURE__ */ p({
13
+ name: "GoogleAuth",
14
+ toGoogleAuth: _,
15
+ props: {
16
+ clientId: u.string,
17
+ redirectUri: u.string
18
+ },
19
+ emits: {
20
+ callback: (t) => !0,
21
+ rejectCallback: (t) => !0
22
+ },
23
+ slots: Object,
24
+ setup(t, {
25
+ emit: c
26
+ }) {
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;
30
+ };
31
+ function d() {
32
+ var r, e, s;
33
+ (s = (e = (r = n()) == null ? void 0 : r({
34
+ client_id: t.clientId,
35
+ 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);
40
+ }
41
+ })) == null ? void 0 : e.requestCode) == null || s.call(e);
42
+ }
43
+ function a() {
44
+ if (!(window != null && window.document) || n()) {
45
+ n() && (o.value = !1);
46
+ return;
47
+ }
48
+ const r = document.getElementById(i);
49
+ if (!r)
50
+ return;
51
+ 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);
54
+ };
55
+ }
56
+ return f(a), {
57
+ domId: i,
58
+ isHidden: o,
59
+ startCheck: d
60
+ };
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
+ }
76
+ }), G = w(b);
77
+ export {
78
+ G as GoogleAuth,
79
+ G as default,
80
+ _ as toGoogleAuth
81
+ };
@@ -0,0 +1,99 @@
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) {
8
+ if (!r || !o)
9
+ 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;
12
+ }
13
+ function I() {
14
+ const r = /[#\?\&]tgAuthResult=([A-Za-z0-9\-_=]*)$/;
15
+ try {
16
+ const o = window.location.hash.toString(), e = o.match(r);
17
+ if (!e)
18
+ return !1;
19
+ 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;
23
+ } catch {
24
+ return !1;
25
+ }
26
+ }
27
+ const _ = /* @__PURE__ */ p({
28
+ name: "TelegramAuth",
29
+ toTelegramAuth: m,
30
+ getTelegramAuthUrlParams: I,
31
+ props: {
32
+ botId: u.number,
33
+ toPath: u.string
34
+ },
35
+ emits: {
36
+ callback: (r) => !0,
37
+ rejectCallback: () => !0
38
+ },
39
+ slots: Object,
40
+ setup(r, {
41
+ emit: o
42
+ }) {
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;
46
+ };
47
+ function s() {
48
+ const {
49
+ botId: n,
50
+ toPath: a
51
+ } = r;
52
+ if (!n)
53
+ return;
54
+ const c = t();
55
+ if (l() || !c) {
56
+ m(n, a);
57
+ return;
58
+ }
59
+ c == null || c({
60
+ bot_id: n,
61
+ request_access: !0
62
+ }, (i) => {
63
+ i ? o("callback", i) : o("rejectCallback");
64
+ });
65
+ }
66
+ function d() {
67
+ if (!(window != null && window.document) || t() || l())
68
+ 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);
74
+ }
75
+ return f(d), {
76
+ domId: e,
77
+ startCheck: s
78
+ };
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
+ }
93
+ }), B = b(_);
94
+ export {
95
+ B as TelegramAuth,
96
+ B as default,
97
+ I as getTelegramAuthUrlParams,
98
+ m as toTelegramAuth
99
+ };
@@ -0,0 +1,9 @@
1
+ import { GoogleAuth as t, toGoogleAuth as r } from "./GoogleAuth.js";
2
+ import { TelegramAuth as l, getTelegramAuthUrlParams as m, toTelegramAuth as a } from "./TelegramAuth.js";
3
+ export {
4
+ t as GoogleAuth,
5
+ l as TelegramAuth,
6
+ m as getTelegramAuthUrlParams,
7
+ r as toGoogleAuth,
8
+ a as toTelegramAuth
9
+ };
package/dist/index.js ADDED
@@ -0,0 +1,63 @@
1
+ import { c as s } from "./chunks/index-BP9Q78TM.js";
2
+ import { u as a, U as e } from "./chunks/index-CA5i_Cgq.js";
3
+ import { e as m, f as n, g as p, b as u, a as f, r as g } from "./chunks/index-CA5i_Cgq.js";
4
+ import { GoogleAuth as U, toGoogleAuth as h } from "./components/GoogleAuth.js";
5
+ import { TelegramAuth as A, getTelegramAuthUrlParams as b, toTelegramAuth as c } from "./components/TelegramAuth.js";
6
+ import { i as D, n as E, l as N, v as P, d as I, a as y, C as B, s as C, y as S, o as T, k as v, D as H, A as O, x as j, t as k, e as F, f as G, g as L, h as M, c as R, p as V, q as W, m as Z, u as q, j as z, b as J, w as K, z as Q, r as X, B as Y } from "./chunks/is-bvgc5qxU.js";
7
+ import { p as $ } from "./chunks/vuePropTypes-zy5Iwonj.js";
8
+ import { t as as } from "./chunks/timeZone-CYGfhbdm.js";
9
+ import { w as rs } from "./chunks/withInstall-b5j1glXj.js";
10
+ const t = {
11
+ ...s,
12
+ ...a,
13
+ Utils: e,
14
+ Comps: s
15
+ };
16
+ export {
17
+ U as GoogleAuth,
18
+ A as TelegramAuth,
19
+ e as Utils,
20
+ t as default,
21
+ m as evalPro,
22
+ n as filterInputNum,
23
+ p as generateHandleInputFn,
24
+ u as getRouterParams,
25
+ b as getTelegramAuthUrlParams,
26
+ f as getWebsiteUrl,
27
+ D as is,
28
+ E as isArray,
29
+ N as isBoolean,
30
+ P as isClient,
31
+ I as isDate,
32
+ y as isDef,
33
+ B as isEdgeBrowser,
34
+ C as isElement,
35
+ S as isEmail,
36
+ T as isEmpty,
37
+ v as isFunction,
38
+ H as isHtmlStr,
39
+ O as isInMobileBrowser,
40
+ j as isIp,
41
+ k as isMap,
42
+ F as isNull,
43
+ G as isNullAndUnDef,
44
+ L as isNullOrUnDef,
45
+ M as isNumber,
46
+ R as isObject,
47
+ V as isPromise,
48
+ W as isPromiseLink,
49
+ Z as isRegExp,
50
+ q as isServer,
51
+ z as isString,
52
+ J as isUnDef,
53
+ K as isUrl,
54
+ Q as isValidPhoneNumber,
55
+ X as isWindow,
56
+ Y as isZhLang,
57
+ $ as propTypes,
58
+ g as renderHtmlStr,
59
+ as as timeZoneOptions,
60
+ h as toGoogleAuth,
61
+ c as toTelegramAuth,
62
+ rs as withInstall
63
+ };
@@ -0,0 +1,107 @@
1
+ import { type SlotsType } from 'vue';
2
+ /** 跳转谷歌身份检查 */
3
+ export declare function toGoogleAuth(clientId: string, redirectUri: string): void;
4
+ /** 谷歌身份检查 */
5
+ export declare const GoogleAuth: {
6
+ new (...args: any[]): import("vue").CreateComponentPublicInstance<Readonly<import("vue").ExtractPropTypes<{
7
+ clientId: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
8
+ default: string;
9
+ };
10
+ redirectUri: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
11
+ default: string;
12
+ };
13
+ }>> & {
14
+ onCallback?: ((_data: {
15
+ code: string;
16
+ }) => any) | undefined;
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, {
23
+ callback: (_data: {
24
+ code: string;
25
+ }) => true;
26
+ rejectCallback: (_data: any) => true;
27
+ }, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<import("vue").ExtractPropTypes<{
28
+ clientId: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
29
+ default: string;
30
+ };
31
+ redirectUri: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
32
+ default: string;
33
+ };
34
+ }>> & {
35
+ onCallback?: ((_data: {
36
+ code: string;
37
+ }) => any) | undefined;
38
+ onRejectCallback?: ((_data: any) => any) | undefined;
39
+ }, {
40
+ clientId: string;
41
+ redirectUri: string;
42
+ }, true, {}, SlotsType<{
43
+ default: {
44
+ startCheck: () => void;
45
+ };
46
+ }>, {
47
+ P: {};
48
+ B: {};
49
+ D: {};
50
+ C: {};
51
+ M: {};
52
+ Defaults: {};
53
+ }, Readonly<import("vue").ExtractPropTypes<{
54
+ clientId: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
55
+ default: string;
56
+ };
57
+ redirectUri: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
58
+ default: string;
59
+ };
60
+ }>> & {
61
+ onCallback?: ((_data: {
62
+ code: string;
63
+ }) => any) | undefined;
64
+ onRejectCallback?: ((_data: any) => any) | undefined;
65
+ }, {
66
+ domId: string;
67
+ isHidden: import("vue").Ref<boolean>;
68
+ startCheck: () => void;
69
+ }, {}, {}, {}, {
70
+ clientId: string;
71
+ redirectUri: string;
72
+ }>;
73
+ __isFragment?: undefined;
74
+ __isTeleport?: undefined;
75
+ __isSuspense?: undefined;
76
+ } & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
77
+ clientId: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
78
+ default: string;
79
+ };
80
+ redirectUri: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
81
+ default: string;
82
+ };
83
+ }>> & {
84
+ onCallback?: ((_data: {
85
+ code: string;
86
+ }) => any) | undefined;
87
+ 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, {
93
+ callback: (_data: {
94
+ code: string;
95
+ }) => true;
96
+ rejectCallback: (_data: any) => true;
97
+ }, string, {
98
+ clientId: string;
99
+ redirectUri: string;
100
+ }, {}, string, SlotsType<{
101
+ default: {
102
+ startCheck: () => void;
103
+ };
104
+ }>> & (import("vue").VNodeProps & (import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & ({
105
+ readonly toGoogleAuth: typeof toGoogleAuth;
106
+ } & import("vue").Plugin)));
107
+ export default GoogleAuth;
@@ -0,0 +1,105 @@
1
+ import { type SlotsType } from 'vue';
2
+ /** tg用户信息 */
3
+ export type TgUserData = {
4
+ auth_date: number;
5
+ first_name: string;
6
+ hash: string;
7
+ id: number;
8
+ last_name: string;
9
+ photo_url: string;
10
+ username: string;
11
+ };
12
+ /** 跳转Telegram身份检查 */
13
+ export declare function toTelegramAuth(botId: number, toPath: string): void;
14
+ /** 获取路由中的Telegram身份检查回调参数 */
15
+ export declare function getTelegramAuthUrlParams(): any;
16
+ /** Telegram身份检查 */
17
+ export declare const TelegramAuth: {
18
+ new (...args: any[]): import("vue").CreateComponentPublicInstance<Readonly<import("vue").ExtractPropTypes<{
19
+ botId: import("vue-types").VueTypeValidableDef<number, import("node_modules/vue-types/dist/types").ValidatorFunction<number>> & {
20
+ default: number;
21
+ };
22
+ toPath: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
23
+ default: string;
24
+ };
25
+ }>> & {
26
+ onCallback?: ((_user: TgUserData) => any) | undefined;
27
+ onRejectCallback?: (() => any) | undefined;
28
+ }, {
29
+ domId: string;
30
+ startCheck: () => void;
31
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
32
+ callback: (_user: TgUserData) => true;
33
+ rejectCallback: () => true;
34
+ }, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<import("vue").ExtractPropTypes<{
35
+ botId: import("vue-types").VueTypeValidableDef<number, import("node_modules/vue-types/dist/types").ValidatorFunction<number>> & {
36
+ default: number;
37
+ };
38
+ toPath: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
39
+ default: string;
40
+ };
41
+ }>> & {
42
+ onCallback?: ((_user: TgUserData) => any) | undefined;
43
+ onRejectCallback?: (() => any) | undefined;
44
+ }, {
45
+ botId: number;
46
+ toPath: string;
47
+ }, true, {}, SlotsType<{
48
+ default: {
49
+ startCheck: () => void;
50
+ };
51
+ }>, {
52
+ P: {};
53
+ B: {};
54
+ D: {};
55
+ C: {};
56
+ M: {};
57
+ Defaults: {};
58
+ }, Readonly<import("vue").ExtractPropTypes<{
59
+ botId: import("vue-types").VueTypeValidableDef<number, import("node_modules/vue-types/dist/types").ValidatorFunction<number>> & {
60
+ default: number;
61
+ };
62
+ toPath: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
63
+ default: string;
64
+ };
65
+ }>> & {
66
+ onCallback?: ((_user: TgUserData) => any) | undefined;
67
+ onRejectCallback?: (() => any) | undefined;
68
+ }, {
69
+ domId: string;
70
+ startCheck: () => void;
71
+ }, {}, {}, {}, {
72
+ botId: number;
73
+ toPath: string;
74
+ }>;
75
+ __isFragment?: undefined;
76
+ __isTeleport?: undefined;
77
+ __isSuspense?: undefined;
78
+ } & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
79
+ botId: import("vue-types").VueTypeValidableDef<number, import("node_modules/vue-types/dist/types").ValidatorFunction<number>> & {
80
+ default: number;
81
+ };
82
+ toPath: import("vue-types").VueTypeValidableDef<string, import("node_modules/vue-types/dist/types").ValidatorFunction<string>> & {
83
+ default: string;
84
+ };
85
+ }>> & {
86
+ onCallback?: ((_user: TgUserData) => any) | undefined;
87
+ onRejectCallback?: (() => any) | undefined;
88
+ }, {
89
+ domId: string;
90
+ startCheck: () => void;
91
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
92
+ callback: (_user: TgUserData) => true;
93
+ rejectCallback: () => true;
94
+ }, string, {
95
+ botId: number;
96
+ toPath: string;
97
+ }, {}, string, SlotsType<{
98
+ default: {
99
+ startCheck: () => void;
100
+ };
101
+ }>> & (import("vue").VNodeProps & (import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & ({
102
+ readonly toTelegramAuth: typeof toTelegramAuth;
103
+ readonly getTelegramAuthUrlParams: typeof getTelegramAuthUrlParams;
104
+ } & import("vue").Plugin)));
105
+ export default TelegramAuth;
@@ -0,0 +1,2 @@
1
+ export * from './GoogleAuth';
2
+ export * from './TelegramAuth';
@@ -0,0 +1 @@
1
+ export declare function useDomId(idName: string): string;