@cbjwwwcode/common 0.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.
Files changed (83) hide show
  1. package/dist/es/api.d.mts +14 -0
  2. package/dist/es/api.mjs +26 -0
  3. package/dist/es/common.d.mts +20 -0
  4. package/dist/es/common.mjs +112 -0
  5. package/dist/es/crypto.d.mts +5 -0
  6. package/dist/es/crypto.mjs +7 -0
  7. package/dist/es/dayjs.d.mts +7 -0
  8. package/dist/es/dayjs.mjs +47 -0
  9. package/dist/es/es-toolkit.d.mts +3 -0
  10. package/dist/es/es-toolkit.mjs +3 -0
  11. package/dist/es/idb-keyval.d.mts +16 -0
  12. package/dist/es/idb-keyval.mjs +63 -0
  13. package/dist/es/index.d.mts +21 -0
  14. package/dist/es/index.mjs +21 -0
  15. package/dist/es/loader.d.mts +6 -0
  16. package/dist/es/loader.mjs +44 -0
  17. package/dist/es/lowlight/common.mjs +81 -0
  18. package/dist/es/lowlight/hljs.d.mts +2 -0
  19. package/dist/es/lowlight/hljs.mjs +9 -0
  20. package/dist/es/lowlight/index.d.mts +159 -0
  21. package/dist/es/lowlight/index.mjs +16 -0
  22. package/dist/es/lowlight/lowlights.d.mts +66 -0
  23. package/dist/es/lowlight/lowlights.mjs +153 -0
  24. package/dist/es/nprogress.d.mts +5 -0
  25. package/dist/es/nprogress.mjs +16 -0
  26. package/dist/es/toastify.d.mts +7 -0
  27. package/dist/es/toastify.mjs +13 -0
  28. package/dist/es/vee-validate.d.mts +2 -0
  29. package/dist/es/vee-validate.mjs +2 -0
  30. package/dist/es/vtj/index.d.mts +3 -0
  31. package/dist/es/vtj/index.mjs +3 -0
  32. package/dist/es/vtj/node.d.mts +33 -0
  33. package/dist/es/vtj/node.mjs +70 -0
  34. package/dist/es/vtj/provider.d.mts +32 -0
  35. package/dist/es/vtj/provider.mjs +65 -0
  36. package/dist/es/vtj/request.d.mts +2 -0
  37. package/dist/es/vtj/request.mjs +22 -0
  38. package/dist/es/vtj/service.mjs +63 -0
  39. package/dist/es/vtj/stores.d.mts +11 -0
  40. package/dist/es/vtj/stores.mjs +103 -0
  41. package/dist/es/vue-router.d.mts +2 -0
  42. package/dist/es/vue-router.mjs +2 -0
  43. package/dist/es/vue.d.mts +2 -0
  44. package/dist/es/vue.mjs +2 -0
  45. package/dist/es/vueuse.d.mts +3 -0
  46. package/dist/es/vueuse.mjs +3 -0
  47. package/dist/es/window.d.mts +6 -0
  48. package/dist/es/window.mjs +39 -0
  49. package/dist/es/zod.d.mts +2 -0
  50. package/dist/es/zod.mjs +2 -0
  51. package/dist/umd/common.min.js +371 -0
  52. package/dist/umd/common.min.js.map +1 -0
  53. package/dist/umd/style.css +59 -0
  54. package/package.json +89 -0
  55. package/src/api.ts +83 -0
  56. package/src/common.ts +201 -0
  57. package/src/crypto.ts +7 -0
  58. package/src/dayjs.ts +60 -0
  59. package/src/es-toolkit.ts +4 -0
  60. package/src/highlight.ts +0 -0
  61. package/src/idb-keyval.ts +115 -0
  62. package/src/index.ts +20 -0
  63. package/src/loader.ts +62 -0
  64. package/src/lowlight/common.ts +79 -0
  65. package/src/lowlight/hljs.ts +11 -0
  66. package/src/lowlight/index.ts +22 -0
  67. package/src/lowlight/lowlights.ts +231 -0
  68. package/src/nprogress.ts +20 -0
  69. package/src/sortablejs.ts +1 -0
  70. package/src/tippy.ts +3 -0
  71. package/src/toastify.ts +19 -0
  72. package/src/vee-validate.ts +1 -0
  73. package/src/vtj/index.ts +2 -0
  74. package/src/vtj/node.ts +158 -0
  75. package/src/vtj/provider.ts +113 -0
  76. package/src/vtj/request.ts +34 -0
  77. package/src/vtj/service.ts +93 -0
  78. package/src/vtj/stores.ts +144 -0
  79. package/src/vue-router.ts +1 -0
  80. package/src/vue.ts +3 -0
  81. package/src/vueuse.ts +13 -0
  82. package/src/window.ts +60 -0
  83. package/src/zod.ts +1 -0
@@ -0,0 +1,14 @@
1
+ import { AlovaOptions } from "alova";
2
+ import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
3
+ import { createClientTokenAuthentication, useCaptcha, useRequest, useUploader } from "alova/client";
4
+ //#region src/api.d.ts
5
+ export type AlovaAxiosRequestConfig = Omit<AxiosRequestConfig, 'url' | 'method' | 'baseURL' | 'headers' | 'params' | 'data' | 'timeout' | 'cancelToken' | 'signal' | 'onUploadProgress' | 'onDownloadProgress'>;
6
+ export interface ApiConfig {
7
+ alovaOptions?: Partial<AlovaOptions<any>>;
8
+ init?: (axiosInst: AxiosInstance) => void;
9
+ options?: AxiosRequestConfig;
10
+ }
11
+ export declare function setupRequest(baseUrl: string, config?: ApiConfig): import("alova").Alova<import("alova").AlovaGenerics<any, any, import("@alova/adapter-axios").AlovaAxiosRequestConfig, AxiosResponse<any, any, {}, any>, import("axios").AxiosResponseHeaders, any, any, any>>;
12
+ export declare const $http: import("alova").Alova<import("alova").AlovaGenerics<any, any, import("@alova/adapter-axios").AlovaAxiosRequestConfig, AxiosResponse<any, any, {}, any>, import("axios").AxiosResponseHeaders, any, any, any>>;
13
+ //#endregion
14
+ export { createClientTokenAuthentication, useCaptcha, useRequest, useUploader };
@@ -0,0 +1,26 @@
1
+ import { axiosRequestAdapter } from "@alova/adapter-axios";
2
+ import { createAlova } from "alova";
3
+ import VueHook from "alova/vue";
4
+ import axios from "axios";
5
+ import { createClientTokenAuthentication, useCaptcha, useRequest, useUploader } from "alova/client";
6
+ //#region src/api.ts
7
+ function setupRequest(baseUrl, config) {
8
+ const axiosInst = axios.create(config?.options);
9
+ return createAlova({
10
+ baseURL: baseUrl,
11
+ statesHook: VueHook,
12
+ requestAdapter: axiosRequestAdapter({ axios: axiosInst }),
13
+ ...config?.alovaOptions
14
+ });
15
+ }
16
+ const $http = setupRequest(window.appConfig.baseApi || "admin", { alovaOptions: {
17
+ id: "api",
18
+ responded(response) {
19
+ return response.data;
20
+ },
21
+ beforeRequest(method) {
22
+ method.config.headers.token = localStorage.getItem("token") || "";
23
+ }
24
+ } });
25
+ //#endregion
26
+ export { $http, axios, createClientTokenAuthentication, setupRequest, useCaptcha, useRequest, useUploader };
@@ -0,0 +1,20 @@
1
+ import { AsyncComponentLoader, AsyncComponentOptions, Component, ComponentPublicInstance } from "vue";
2
+ //#region src/common.d.ts
3
+ export declare function makeRawComponent<T extends Component = {
4
+ new (): ComponentPublicInstance;
5
+ }>(source: AsyncComponentLoader<T> | AsyncComponentOptions<T>): import("vue").Raw<T>;
6
+ export declare function isComponentRegistered(name: string): boolean;
7
+ export declare function randomId(length?: number): string;
8
+ export declare function hasProperty<T extends object>(target: T, key: string): boolean;
9
+ export declare function mergeOmitBy<T extends Record<string, any> = object, E extends keyof T = string>(props: T, excludes: E[]): Omit<T, E>;
10
+ export declare function mergePropsOmitBy<T extends Record<string, any> = any, E extends string = string>(props: T, attrs: T, excludes?: E[]): Omit<T, E>;
11
+ export declare function mergeUrlWithParams(baseUrl: string, params: Record<string, any>): string;
12
+ export declare function keepProps<T extends Record<string, any> = any, K extends keyof T = string, R extends T = any>(object: T, keys?: K[], rest?: R): Pick<T, K & keyof T> & R;
13
+ export declare function isStringNumber(str: any): boolean;
14
+ export declare function transformPx(field: number | string | undefined): string | number | undefined;
15
+ export declare const determineTextColor: (hexColor: string) => "black" | "white";
16
+ export declare function makeUuid(): string;
17
+ export declare function createFunction<T extends object = any>(code: string, scope: T): any;
18
+ export declare function makeVueId(prefix?: string, suffix?: string): string;
19
+ export declare function isHttpUrl<T extends string>(str: T): boolean;
20
+ //#endregion
@@ -0,0 +1,112 @@
1
+ import { defineAsyncComponent, markRaw, mergeProps, resolveComponent, useId } from "vue";
2
+ import { isNil, isPlainObject, omitBy } from "es-toolkit/compat";
3
+ //#region src/common.ts
4
+ function makeRawComponent(source) {
5
+ return markRaw(defineAsyncComponent(source));
6
+ }
7
+ function isComponentRegistered(name) {
8
+ try {
9
+ return resolveComponent(name) !== name;
10
+ } catch {
11
+ return false;
12
+ }
13
+ }
14
+ function randomId(length = 8) {
15
+ let result = "";
16
+ const characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
17
+ const charactersLength = 62;
18
+ for (let i = 0; i < length; i++) result += characters.charAt(Math.floor(Math.random() * charactersLength));
19
+ return result;
20
+ }
21
+ function hasProperty(target, key) {
22
+ return target && Reflect.has(target, key);
23
+ }
24
+ function mergeOmitBy(props, excludes) {
25
+ return omitBy(props, (value, key) => isNil(value) || excludes.includes(key));
26
+ }
27
+ function mergePropsOmitBy(props, attrs, excludes = []) {
28
+ return mergeOmitBy(mergeProps(props, attrs), excludes);
29
+ }
30
+ function mergeUrlWithParams(baseUrl, params) {
31
+ const query = [];
32
+ Object.entries(params).forEach(([key, value]) => {
33
+ if (value !== void 0 && value !== null) {
34
+ if (isPlainObject(value) || Array.isArray(value)) query.push(`${key}=${JSON.stringify(value)}`);
35
+ else query.push(`${key}=${value.toString()}`);
36
+ }
37
+ });
38
+ if (query.length > 0) {
39
+ if (baseUrl.includes("?")) return `${baseUrl}&${query.join("&")}`;
40
+ return `${baseUrl}?${query.join("&")}`;
41
+ } else return baseUrl;
42
+ }
43
+ function keepProps(object, keys = [], rest = {}) {
44
+ return mergeProps(omitBy(object, (_value, key) => !keys.includes(key)), rest);
45
+ }
46
+ const fixToPx = (field, key) => {
47
+ return field.toString().includes(key);
48
+ };
49
+ function isStringNumber(str) {
50
+ if (typeof str === "number") return true;
51
+ if (typeof str !== "string") return false;
52
+ if (str.trim() === "") return false;
53
+ return !isNaN(Number(str));
54
+ }
55
+ function transformPx(field) {
56
+ if (field === void 0) return field;
57
+ if (fixToPx(field, "px") || fixToPx(field, "rem") || fixToPx(field, "em") || fixToPx(field, "vh") || fixToPx(field, "vw") || fixToPx(field, "pt") || fixToPx(field, "%") || fixToPx(field, "auto") || fixToPx(field, "calc")) return field.toString();
58
+ return isStringNumber(field) ? `${field}px` : field;
59
+ }
60
+ /**
61
+ * 把十六进制颜色值转成 rgba 颜色值
62
+ *
63
+ * @param {string} hex
64
+ * @returns {string} rgba 颜色值
65
+ */
66
+ const hexToRgba = (hex) => {
67
+ if (hex && hex.includes("rgb")) return hex;
68
+ const rgba = [];
69
+ hex = hex.replace("#", "").padEnd(8, "F");
70
+ for (let i = 0; i < hex.length; i += 2) rgba.push(Number.parseInt(hex.slice(i, i + 2), 16));
71
+ return `${rgba.reduce((prev, item, index) => {
72
+ return prev += index >= rgba.length - 1 ? Number((item / 255).toFixed(2)) : `${item}, `;
73
+ }, "rgba(")})`;
74
+ };
75
+ /**
76
+ * 计算文本颜色值
77
+ *
78
+ * @param {string} hexColor
79
+ * @returns {'black' | 'white'} 文本颜色值
80
+ */
81
+ const determineTextColor = (hexColor) => {
82
+ const [r, g, b, a] = (hexToRgba(hexColor).match(/\d+(\.\d+)?/g) || []).map(Number);
83
+ return (Number(r || 0) * 299 + Number(g || 0) * 587 + Number(b || 0) * 114) / 1e3 > 125 ? "black" : Number(a || 0) < .4 ? "black" : "white";
84
+ };
85
+ function makeUuid() {
86
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/g, (c) => {
87
+ const r = Math.random() * 16 | 0;
88
+ return (c === "x" ? r : r & 3 | 8).toString(16);
89
+ });
90
+ }
91
+ function createFunction(code, scope) {
92
+ return new Function("__scope__", `with(__scope__){ return ${code};}`)(scope);
93
+ }
94
+ function makeVueId(prefix = "", suffix = "") {
95
+ return (prefix ? `${prefix}-` : "") + useId() + (suffix ? `-${suffix}` : "");
96
+ }
97
+ /**
98
+ * 判断是否是 http / https 链接
99
+ * @param {string} str
100
+ * @returns {boolean}
101
+ */
102
+ function isHttpUrl(str) {
103
+ if (typeof str !== "string") return false;
104
+ try {
105
+ const url = new URL(str);
106
+ return url.protocol === "http:" || url.protocol === "https:";
107
+ } catch {
108
+ return false;
109
+ }
110
+ }
111
+ //#endregion
112
+ export { createFunction, determineTextColor, hasProperty, isComponentRegistered, isHttpUrl, isStringNumber, keepProps, makeRawComponent, makeUuid, makeVueId, mergeOmitBy, mergePropsOmitBy, mergeUrlWithParams, randomId, transformPx };
@@ -0,0 +1,5 @@
1
+ import CryptoJS$1 from "crypto-js";
2
+ //#region src/crypto.d.ts
3
+ export declare function md5(value: CryptoJS.lib.WordArray | string, cfg?: object): string;
4
+ //#endregion
5
+ export { CryptoJS$1 as CryptoJS };
@@ -0,0 +1,7 @@
1
+ import CryptoJS, { MD5 } from "crypto-js";
2
+ //#region src/crypto.ts
3
+ function md5(value, cfg) {
4
+ return MD5(value, cfg).toString();
5
+ }
6
+ //#endregion
7
+ export { CryptoJS, md5 };
@@ -0,0 +1,7 @@
1
+ import dayjs from "dayjs";
2
+ import "dayjs/locale/en";
3
+ import "dayjs/locale/zh-cn";
4
+ //#region src/dayjs.d.ts
5
+ export declare const setDayjsLocale: (locale: string, object?: Partial<ILocale>, isLocal?: boolean) => void;
6
+ //#endregion
7
+ export { dayjs };
@@ -0,0 +1,47 @@
1
+ import { registerWindow } from "./window.mjs";
2
+ import dayjs from "dayjs";
3
+ import utc from "dayjs/plugin/utc";
4
+ import advancedFormat from "dayjs/plugin/advancedFormat";
5
+ import customParseFormat from "dayjs/plugin/customParseFormat";
6
+ import localeData from "dayjs/plugin/localeData";
7
+ import weekday from "dayjs/plugin/weekday";
8
+ import weekOfYear from "dayjs/plugin/weekOfYear";
9
+ import weekYear from "dayjs/plugin/weekYear";
10
+ import relativeTime from "dayjs/plugin/relativeTime";
11
+ import timezone from "dayjs/plugin/timezone";
12
+ import quarterOfYear from "dayjs/plugin/quarterOfYear";
13
+ import dayjsEnUS from "dayjs/locale/en";
14
+ import dayjsZhCN from "dayjs/locale/zh-cn";
15
+ //#region src/dayjs.ts
16
+ dayjs.extend(utc);
17
+ dayjs.extend(advancedFormat);
18
+ dayjs.extend(customParseFormat);
19
+ dayjs.extend(localeData);
20
+ dayjs.extend(weekday);
21
+ dayjs.extend(weekOfYear);
22
+ dayjs.extend(weekYear);
23
+ dayjs.extend(relativeTime);
24
+ dayjs.extend(timezone);
25
+ dayjs.extend(quarterOfYear);
26
+ registerWindow("dayjs_plugin_customParseFormat", customParseFormat);
27
+ registerWindow("dayjs_plugin_weekday", weekday);
28
+ registerWindow("dayjs_plugin_localeData", localeData);
29
+ registerWindow("dayjs_plugin_weekOfYear", weekOfYear);
30
+ registerWindow("dayjs_plugin_weekYear", weekYear);
31
+ registerWindow("dayjs_plugin_advancedFormat", advancedFormat);
32
+ registerWindow("dayjs_plugin_quarterOfYear", quarterOfYear);
33
+ registerWindow("dayjs_plugin_relativeTime", relativeTime);
34
+ registerWindow("dayjs_plugin_timezone", timezone);
35
+ registerWindow("dayjs_plugin_utc", utc);
36
+ registerWindow("dayjs_locale_zh_cn", dayjsZhCN);
37
+ registerWindow("dayjs_locale_en", dayjsEnUS);
38
+ const locales = {
39
+ en: "en",
40
+ "zh-CN": "zh-cn"
41
+ };
42
+ const setDayjsLocale = (locale, object, isLocal) => {
43
+ dayjs.locale(locales[locale] || locale, object, isLocal);
44
+ };
45
+ registerWindow("dayjs", dayjs);
46
+ //#endregion
47
+ export { dayjs, setDayjsLocale };
@@ -0,0 +1,3 @@
1
+ import * as Toolkit from "es-toolkit/compat";
2
+ import { isNotNil as isNotNil$1, isPromise } from "es-toolkit";
3
+ export { Toolkit, isNotNil$1 as isNotNil, isPromise };
@@ -0,0 +1,3 @@
1
+ import * as Toolkit from "es-toolkit/compat";
2
+ import { isNotNil as isNotNil$1, isPromise } from "es-toolkit";
3
+ export { Toolkit, isNotNil$1 as isNotNil, isPromise };
@@ -0,0 +1,16 @@
1
+ import { MaybeRefOrGetter } from "vue";
2
+ import * as idb from "idb-keyval";
3
+ import { UseStore } from "idb-keyval";
4
+ import { UseIDBKeyvalReturn, UseIDBOptions } from "@vueuse/integrations/useIDBKeyval";
5
+ //#region src/idb-keyval.d.ts
6
+ export declare function createNaiveStore(storeName: string): idb.UseStore;
7
+ export declare function loadJsStore(key: IDBValidKey, callback: (idb: any) => Promise<any>): Promise<any>;
8
+ export declare interface IDBOptions extends UseIDBOptions<any> {
9
+ storeName?: string;
10
+ }
11
+ export declare interface IDBKeyValReturn<T> extends UseIDBKeyvalReturn<T> {
12
+ idb: typeof idb;
13
+ }
14
+ export declare function useIdb<T = any>(key: IDBValidKey, initialValue: MaybeRefOrGetter<T>, options: IDBOptions): IDBKeyValReturn<T>;
15
+ //#endregion
16
+ export { type UseStore, idb };
@@ -0,0 +1,63 @@
1
+ import { ref, shallowRef, toRaw, toValue, watch } from "vue";
2
+ import { isNotNil } from "es-toolkit";
3
+ import * as idb from "idb-keyval";
4
+ //#region src/idb-keyval.ts
5
+ function createNaiveStore(storeName) {
6
+ return idb.createStore("naive-admin", storeName);
7
+ }
8
+ async function loadJsStore(key, callback) {
9
+ const customJsStore = createNaiveStore("remove-js-store");
10
+ let content = await idb.get(key, customJsStore);
11
+ if (!content) {
12
+ content = await callback(idb);
13
+ await idb.set(key, content, customJsStore);
14
+ }
15
+ return content;
16
+ }
17
+ function useIdb(key, initialValue, options) {
18
+ const { storeName = "base-store", flush = "pre", deep = true, shallow = false, onError = (e) => {
19
+ console.error(e);
20
+ }, writeDefaults = true } = options;
21
+ const store = createNaiveStore(storeName);
22
+ const isFinished = ref(false);
23
+ const data = (shallow ? shallowRef : ref)(initialValue);
24
+ const rawInit = toValue(initialValue);
25
+ async function read() {
26
+ try {
27
+ const rawValue = await idb.get(key, store);
28
+ if (rawValue === void 0) {
29
+ if (isNotNil(rawInit) && writeDefaults) await idb.set(key, rawInit, store);
30
+ } else data.value = rawValue;
31
+ } catch (error) {
32
+ onError(error);
33
+ }
34
+ isFinished.value = true;
35
+ }
36
+ read();
37
+ async function write() {
38
+ try {
39
+ if (data.value === null) await idb.del(key, store);
40
+ else await idb.update(key, () => toRaw(data.value), store);
41
+ } catch (error) {
42
+ onError(error);
43
+ }
44
+ }
45
+ const { pause: pauseWatch, resume: resumeWatch } = watch(data, () => write(), {
46
+ flush,
47
+ deep
48
+ });
49
+ async function setData(value) {
50
+ pauseWatch();
51
+ data.value = value;
52
+ await write();
53
+ resumeWatch();
54
+ }
55
+ return {
56
+ set: setData,
57
+ isFinished,
58
+ data,
59
+ idb
60
+ };
61
+ }
62
+ //#endregion
63
+ export { createNaiveStore, idb, loadJsStore, useIdb };
@@ -0,0 +1,21 @@
1
+ import { $http, AlovaAxiosRequestConfig, ApiConfig, createClientTokenAuthentication, setupRequest, useCaptcha, useRequest, useUploader } from "./api.mjs";
2
+ import { createFunction, determineTextColor, hasProperty, isComponentRegistered, isHttpUrl, isStringNumber, keepProps, makeRawComponent, makeUuid, makeVueId, mergeOmitBy, mergePropsOmitBy, mergeUrlWithParams, randomId, transformPx } from "./common.mjs";
3
+ import { CryptoJS, md5 } from "./crypto.mjs";
4
+ import { dayjs, setDayjsLocale } from "./dayjs.mjs";
5
+ import { Toolkit, isNotNil, isPromise } from "./es-toolkit.mjs";
6
+ import { IDBKeyValReturn, IDBOptions, UseStore, createNaiveStore, idb, loadJsStore, useIdb } from "./idb-keyval.mjs";
7
+ import { loadRemoteModule, loaderScript, useStyleLink } from "./loader.mjs";
8
+ import { NProgress, NProgressOptions, useProgress } from "./nprogress.mjs";
9
+ import { Toast, ToastApi, ToastOptions, setupToast, toast } from "./toastify.mjs";
10
+ import { VeeValidate } from "./vee-validate.mjs";
11
+ import { Vue } from "./vue.mjs";
12
+ import { VueRouter } from "./vue-router.mjs";
13
+ import { VueUse, createGlobalState, createReusableTemplate, onClickOutside, useClipboard, useScriptTag, useStorage, useStyleTag, useToggle } from "./vueuse.mjs";
14
+ import { $mitt, isModuleObject, registerWindow } from "./window.mjs";
15
+ import { zod } from "./zod.mjs";
16
+ import { JsonNodeProps, setupJsonNode, useJsonNode } from "./vtj/node.mjs";
17
+ import { BlockSchema, ContextMode, initProvider, useGlobalProvider, vtjSymbol } from "./vtj/provider.mjs";
18
+ import "./vtj/index.mjs";
19
+ import hljs from "./lowlight/hljs.mjs";
20
+ import { Lowlight, VueLowlight, highlightLanguages, lowlight } from "./lowlight/index.mjs";
21
+ export { $http, $mitt, AlovaAxiosRequestConfig, ApiConfig, type BlockSchema, ContextMode, CryptoJS, IDBKeyValReturn, IDBOptions, JsonNodeProps, Lowlight, type NProgress, type NProgressOptions, type Toast, ToastApi, type ToastOptions, Toolkit, type UseStore, VeeValidate, Vue, VueLowlight, VueRouter, VueUse, createClientTokenAuthentication, createFunction, createGlobalState, createNaiveStore, createReusableTemplate, dayjs, determineTextColor, hasProperty, highlightLanguages, hljs, idb, initProvider, isComponentRegistered, isHttpUrl, isModuleObject, isNotNil, isPromise, isStringNumber, keepProps, loadJsStore, loadRemoteModule, loaderScript, lowlight, makeRawComponent, makeUuid, makeVueId, md5, mergeOmitBy, mergePropsOmitBy, mergeUrlWithParams, onClickOutside, randomId, registerWindow, setDayjsLocale, setupJsonNode, setupRequest, setupToast, toast, transformPx, useCaptcha, useClipboard, useGlobalProvider, useIdb, useJsonNode, useProgress, useRequest, useScriptTag, useStorage, useStyleLink, useStyleTag, useToggle, useUploader, vtjSymbol, zod };
@@ -0,0 +1,21 @@
1
+ import { $http, createClientTokenAuthentication, setupRequest, useCaptcha, useRequest, useUploader } from "./api.mjs";
2
+ import { createFunction, determineTextColor, hasProperty, isComponentRegistered, isHttpUrl, isStringNumber, keepProps, makeRawComponent, makeUuid, makeVueId, mergeOmitBy, mergePropsOmitBy, mergeUrlWithParams, randomId, transformPx } from "./common.mjs";
3
+ import { CryptoJS, md5 } from "./crypto.mjs";
4
+ import { Vue } from "./vue.mjs";
5
+ import { VueRouter } from "./vue-router.mjs";
6
+ import { VueUse, createGlobalState, createReusableTemplate, onClickOutside, useClipboard, useScriptTag, useStorage, useStyleTag, useToggle } from "./vueuse.mjs";
7
+ import { zod } from "./zod.mjs";
8
+ import hljs_default from "./lowlight/hljs.mjs";
9
+ import { VueLowlight, highlightLanguages, lowlight } from "./lowlight/index.mjs";
10
+ import { $mitt, isModuleObject, registerWindow } from "./window.mjs";
11
+ import { dayjs, setDayjsLocale } from "./dayjs.mjs";
12
+ import { Toolkit, isNotNil, isPromise } from "./es-toolkit.mjs";
13
+ import { createNaiveStore, idb, loadJsStore, useIdb } from "./idb-keyval.mjs";
14
+ import { loadRemoteModule, loaderScript, useStyleLink } from "./loader.mjs";
15
+ import { useProgress } from "./nprogress.mjs";
16
+ import { ToastApi, setupToast, toast } from "./toastify.mjs";
17
+ import { VeeValidate } from "./vee-validate.mjs";
18
+ import { ContextMode, initProvider, useGlobalProvider, vtjSymbol } from "./vtj/provider.mjs";
19
+ import { setupJsonNode, useJsonNode } from "./vtj/node.mjs";
20
+ import "./vtj/index.mjs";
21
+ export { $http, $mitt, ContextMode, CryptoJS, ToastApi, Toolkit, VeeValidate, Vue, VueLowlight, VueRouter, VueUse, createClientTokenAuthentication, createFunction, createGlobalState, createNaiveStore, createReusableTemplate, dayjs, determineTextColor, hasProperty, highlightLanguages, hljs_default as hljs, idb, initProvider, isComponentRegistered, isHttpUrl, isModuleObject, isNotNil, isPromise, isStringNumber, keepProps, loadJsStore, loadRemoteModule, loaderScript, lowlight, makeRawComponent, makeUuid, makeVueId, md5, mergeOmitBy, mergePropsOmitBy, mergeUrlWithParams, onClickOutside, randomId, registerWindow, setDayjsLocale, setupJsonNode, setupRequest, setupToast, toast, transformPx, useCaptcha, useClipboard, useGlobalProvider, useIdb, useJsonNode, useProgress, useRequest, useScriptTag, useStorage, useStyleLink, useStyleTag, useToggle, useUploader, vtjSymbol, zod };
@@ -0,0 +1,6 @@
1
+ import { UseScriptTagOptions } from "@vueuse/core";
2
+ //#region src/loader.d.ts
3
+ export declare function loaderScript(cdnUrl: string, onLoaded?: (el: HTMLScriptElement) => void, options?: UseScriptTagOptions): Promise<void>;
4
+ export declare function useStyleLink(link: string, onLoaded?: (el: Element) => void): Promise<unknown>;
5
+ export declare function loadRemoteModule(moduleName: string, url: string): Promise<any>;
6
+ //#endregion
@@ -0,0 +1,44 @@
1
+ import { md5 } from "./crypto.mjs";
2
+ import { loadJsStore } from "./idb-keyval.mjs";
3
+ import { useScriptTag } from "@vueuse/core";
4
+ //#region src/loader.ts
5
+ async function loaderScript(cdnUrl, onLoaded, options) {
6
+ const { load } = useScriptTag(cdnUrl, onLoaded, {
7
+ attrs: { id: `remoteJs-${md5(cdnUrl)}` },
8
+ immediate: false,
9
+ ...options
10
+ });
11
+ await load();
12
+ }
13
+ async function useStyleLink(link, onLoaded) {
14
+ return new Promise((resolve, reject) => {
15
+ const linkId = `remoteCss-${md5(link)}`;
16
+ let el = document.querySelector(`#${linkId}`);
17
+ let shouldAppend = false;
18
+ if (!el) {
19
+ el = document.createElement("link");
20
+ el.setAttribute("rel", "stylesheet");
21
+ el.setAttribute("id", linkId);
22
+ el.setAttribute("href", link);
23
+ shouldAppend = true;
24
+ }
25
+ el.addEventListener("error", (event) => reject(event));
26
+ el.addEventListener("abort", (event) => reject(event));
27
+ el.addEventListener("load", () => {
28
+ onLoaded?.(el);
29
+ resolve(el);
30
+ });
31
+ if (shouldAppend) document.head.append(el);
32
+ });
33
+ }
34
+ async function loadRemoteModule(moduleName, url) {
35
+ const cacheId = `${moduleName}-${md5(url)}`;
36
+ const content = await loadJsStore(cacheId, async () => {
37
+ const response = await fetch(url);
38
+ if (!response.ok) throw new Error(`无法加载远程模块: ${response.statusText}`);
39
+ return await response.text();
40
+ });
41
+ return new Function("module", "exports", `${content}\nreturn exports;`)({ exports: {} }, {});
42
+ }
43
+ //#endregion
44
+ export { loadRemoteModule, loaderScript, useStyleLink };
@@ -0,0 +1,81 @@
1
+ import arduino from "highlight.js/lib/languages/arduino";
2
+ import bash from "highlight.js/lib/languages/bash";
3
+ import c from "highlight.js/lib/languages/c";
4
+ import cpp from "highlight.js/lib/languages/cpp";
5
+ import csharp from "highlight.js/lib/languages/csharp";
6
+ import css from "highlight.js/lib/languages/css";
7
+ import diff from "highlight.js/lib/languages/diff";
8
+ import go from "highlight.js/lib/languages/go";
9
+ import graphql from "highlight.js/lib/languages/graphql";
10
+ import ini from "highlight.js/lib/languages/ini";
11
+ import java from "highlight.js/lib/languages/java";
12
+ import javascript from "highlight.js/lib/languages/javascript";
13
+ import json from "highlight.js/lib/languages/json";
14
+ import kotlin from "highlight.js/lib/languages/kotlin";
15
+ import less from "highlight.js/lib/languages/less";
16
+ import lua from "highlight.js/lib/languages/lua";
17
+ import makefile from "highlight.js/lib/languages/makefile";
18
+ import markdown from "highlight.js/lib/languages/markdown";
19
+ import objectivec from "highlight.js/lib/languages/objectivec";
20
+ import perl from "highlight.js/lib/languages/perl";
21
+ import php from "highlight.js/lib/languages/php";
22
+ import phpTemplate from "highlight.js/lib/languages/php-template";
23
+ import plaintext from "highlight.js/lib/languages/plaintext";
24
+ import python from "highlight.js/lib/languages/python";
25
+ import pythonRepl from "highlight.js/lib/languages/python-repl";
26
+ import r from "highlight.js/lib/languages/r";
27
+ import ruby from "highlight.js/lib/languages/ruby";
28
+ import rust from "highlight.js/lib/languages/rust";
29
+ import scss from "highlight.js/lib/languages/scss";
30
+ import shell from "highlight.js/lib/languages/shell";
31
+ import sql from "highlight.js/lib/languages/sql";
32
+ import swift from "highlight.js/lib/languages/swift";
33
+ import typescript from "highlight.js/lib/languages/typescript";
34
+ import vbnet from "highlight.js/lib/languages/vbnet";
35
+ import wasm from "highlight.js/lib/languages/wasm";
36
+ import xml from "highlight.js/lib/languages/xml";
37
+ import yaml from "highlight.js/lib/languages/yaml";
38
+ //#region src/lowlight/common.ts
39
+ const grammars = {
40
+ arduino,
41
+ bash,
42
+ c,
43
+ cpp,
44
+ csharp,
45
+ css,
46
+ diff,
47
+ go,
48
+ graphql,
49
+ html: xml,
50
+ ini,
51
+ java,
52
+ javascript,
53
+ json,
54
+ kotlin,
55
+ less,
56
+ lua,
57
+ makefile,
58
+ markdown,
59
+ objectivec,
60
+ perl,
61
+ php,
62
+ "php-template": phpTemplate,
63
+ plaintext,
64
+ text: plaintext,
65
+ python,
66
+ "python-repl": pythonRepl,
67
+ r,
68
+ ruby,
69
+ rust,
70
+ scss,
71
+ shell,
72
+ sql,
73
+ swift,
74
+ typescript,
75
+ vbnet,
76
+ wasm,
77
+ xml,
78
+ yaml
79
+ };
80
+ //#endregion
81
+ export { grammars };
@@ -0,0 +1,2 @@
1
+ import hljs$1 from "highlight.js/lib/core";
2
+ export { hljs$1 as default };
@@ -0,0 +1,9 @@
1
+ import { grammars } from "./common.mjs";
2
+ import hljs from "highlight.js/lib/core";
3
+ //#region src/lowlight/hljs.ts
4
+ Object.entries(grammars).forEach(([lang, languageFn]) => {
5
+ if (Reflect.has(grammars, lang)) hljs.registerLanguage(lang, languageFn);
6
+ });
7
+ var hljs_default = hljs;
8
+ //#endregion
9
+ export { hljs_default as default };