@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,22 @@
1
+ import { createRequest } from "@vtj/utils";
2
+ //#region src/vtj/request.ts
3
+ function createNodeRequest(options, requestInst) {
4
+ const request = createRequest({
5
+ ...options,
6
+ settings: {
7
+ type: "form",
8
+ validSuccess: false,
9
+ originResponse: false,
10
+ loading: true,
11
+ failMessage: false,
12
+ ...options?.settings
13
+ }
14
+ });
15
+ request.useRequest(async (config) => {
16
+ return config;
17
+ });
18
+ if (requestInst && typeof requestInst === "function") requestInst(request);
19
+ return request;
20
+ }
21
+ //#endregion
22
+ export { createNodeRequest };
@@ -0,0 +1,63 @@
1
+ import { StoresService } from "./stores.mjs";
2
+ //#region src/vtj/service.ts
3
+ const notification = { warning: (options) => {
4
+ console.warn(options);
5
+ } };
6
+ var NodeService = class extends StoresService {
7
+ async createRawPage(_file) {
8
+ notification.warning({
9
+ title: "提示",
10
+ content: "在线演示版本不支持源码模式页面,如需体验请下载本地版本。"
11
+ });
12
+ return false;
13
+ }
14
+ genVueContent(_project, _dsl) {
15
+ notification.warning({
16
+ title: "提示",
17
+ content: "在线演示版本不支持源码生成功能,如需体验请下载本地版本。"
18
+ });
19
+ return Promise.resolve("");
20
+ }
21
+ async getPluginMaterial(_from) {
22
+ notification.warning({
23
+ title: "提示",
24
+ content: "在线演示版本不支持引用和插件,如需体验请下载本地版本。"
25
+ });
26
+ return null;
27
+ }
28
+ async getStaticFiles(_projectId) {
29
+ notification.warning({
30
+ title: "提示",
31
+ content: "在线演示版本不支持文件上传,如需体验请下载本地版本。"
32
+ });
33
+ return [];
34
+ }
35
+ publish(_project) {
36
+ notification.warning({
37
+ title: "提示",
38
+ content: "在线演示版本不支持发布功能,如需体验请下载本地版本。"
39
+ });
40
+ return Promise.resolve(false);
41
+ }
42
+ publishFile(_project, _file) {
43
+ if ("dsl" in _file) _file.dsl && this.saveFile(_file.dsl);
44
+ else _file && this.saveFile(_file);
45
+ return Promise.resolve(false);
46
+ }
47
+ async removeRawPage(_id) {
48
+ notification.warning({
49
+ title: "提示",
50
+ content: "在线演示版本不支持源码模式页面,如需体验请下载本地版本。"
51
+ });
52
+ return false;
53
+ }
54
+ async uploadStaticFile(_file, _rojectId) {
55
+ notification.warning({
56
+ title: "提示",
57
+ content: "在线演示版本不支持文件上传,如需体验请下载本地版本。"
58
+ });
59
+ return null;
60
+ }
61
+ };
62
+ //#endregion
63
+ export { NodeService };
@@ -0,0 +1,11 @@
1
+ import { BaseService } from "@vtj/renderer";
2
+ import { BlockSchema, ProjectSchema } from "@vtj/core";
3
+ //#region src/vtj/stores.d.ts
4
+ export declare const useStoreService: () => {
5
+ storage: Record<string, any>;
6
+ save(id: string, value: any): void;
7
+ get(id: string): any;
8
+ remove(id: string): void;
9
+ };
10
+ export declare type UseStoreServiceReturn = typeof useStoreService;
11
+ //#endregion
@@ -0,0 +1,103 @@
1
+ import { reactive } from "vue";
2
+ import { BaseService } from "@vtj/renderer";
3
+ import { HistoryModel, ProjectModel } from "@vtj/core";
4
+ //#region src/vtj/stores.ts
5
+ /**
6
+ * Map转键值对
7
+ *
8
+ * @param map
9
+ */
10
+ function mapToObject(map) {
11
+ return [...map.entries()].reduce((obj, [key, value]) => {
12
+ obj[key] = value;
13
+ return obj;
14
+ }, {});
15
+ }
16
+ const useStoreService = () => {
17
+ return {
18
+ storage: reactive({}),
19
+ save(id, value) {
20
+ this.storage[id] = value;
21
+ },
22
+ get(id) {
23
+ return this.storage[id] || null;
24
+ },
25
+ remove(id) {
26
+ if (this.storage[id] !== void 0) delete this.storage[id];
27
+ }
28
+ };
29
+ };
30
+ var StoresService = class extends BaseService {
31
+ stores;
32
+ constructor(stores) {
33
+ super();
34
+ this.stores = stores ? stores() : useStoreService();
35
+ }
36
+ getFile(id) {
37
+ const dsl = this.stores.get(`file_${id}`);
38
+ return dsl ? Promise.resolve(dsl) : Promise.reject(null);
39
+ }
40
+ getHistory(id) {
41
+ const dsl = this.stores.get(`history_${id}`);
42
+ const history = new HistoryModel(dsl || { id });
43
+ return Promise.resolve(history.toDsl());
44
+ }
45
+ getHistoryItem(fId, id) {
46
+ const item = this.stores.get(`history_${fId}_${id}`);
47
+ return Promise.resolve(item);
48
+ }
49
+ init(project) {
50
+ const model = new ProjectModel(project);
51
+ const match = this.stores.get(`project_${model.id}`);
52
+ const dsl = Object.assign(model.toDsl(), match || {});
53
+ this.stores.save(`project_${model.id}`, dsl);
54
+ return Promise.resolve(dsl);
55
+ }
56
+ removeFile(id) {
57
+ this.stores.remove(`file_${id}`);
58
+ return Promise.resolve(true);
59
+ }
60
+ async removeHistory(id) {
61
+ const history = this.stores.get(`history_${id}`);
62
+ if (history) {
63
+ const ids = (history.items || []).map((item) => item.id);
64
+ await this.removeHistoryItem(id, ids);
65
+ this.stores.remove(`history_${id}`);
66
+ }
67
+ return Promise.resolve(true);
68
+ }
69
+ /**
70
+ * @param fId
71
+ * @param ids
72
+ * @override
73
+ */
74
+ removeHistoryItem(fId, ids) {
75
+ ids.forEach((id) => {
76
+ this.stores.remove(`history_${fId}_${id}`);
77
+ });
78
+ return Promise.resolve(true);
79
+ }
80
+ saveFile(file) {
81
+ this.stores.save(`file_${file.id}`, file);
82
+ return Promise.resolve(true);
83
+ }
84
+ saveHistory(history) {
85
+ this.stores.save(`history_${history.id}`, history);
86
+ return Promise.resolve(true);
87
+ }
88
+ saveHistoryItem(fId, item) {
89
+ this.stores.save(`history_${fId}_${item.id}`, item);
90
+ return Promise.resolve(true);
91
+ }
92
+ saveMaterials(project, materials) {
93
+ this.stores.save(`materials_${project.id}`, mapToObject(materials));
94
+ return Promise.resolve(true);
95
+ }
96
+ saveProject(project) {
97
+ const model = new ProjectModel(project);
98
+ this.stores.save(`project_${model.id}`, model.toDsl());
99
+ return Promise.resolve(true);
100
+ }
101
+ };
102
+ //#endregion
103
+ export { StoresService, mapToObject, useStoreService };
@@ -0,0 +1,2 @@
1
+ import * as VueRouter from "vue-router";
2
+ export { VueRouter };
@@ -0,0 +1,2 @@
1
+ import * as VueRouter from "vue-router";
2
+ export { VueRouter };
@@ -0,0 +1,2 @@
1
+ import * as Vue from "vue";
2
+ export { Vue };
@@ -0,0 +1,2 @@
1
+ import * as Vue from "vue";
2
+ export { Vue };
@@ -0,0 +1,3 @@
1
+ import * as VueUse from "@vueuse/core";
2
+ import { createGlobalState, createReusableTemplate, onClickOutside, useClipboard, useScriptTag as useScriptTag$1, useStorage, useStyleTag, useToggle } from "@vueuse/core";
3
+ export { VueUse, createGlobalState, createReusableTemplate, onClickOutside, useClipboard, useScriptTag$1 as useScriptTag, useStorage, useStyleTag, useToggle };
@@ -0,0 +1,3 @@
1
+ import * as VueUse from "@vueuse/core";
2
+ import { createGlobalState, createReusableTemplate, onClickOutside, useClipboard, useScriptTag as useScriptTag$1, useStorage, useStyleTag, useToggle } from "@vueuse/core";
3
+ export { VueUse, createGlobalState, createReusableTemplate, onClickOutside, useClipboard, useScriptTag$1 as useScriptTag, useStorage, useStyleTag, useToggle };
@@ -0,0 +1,6 @@
1
+ import "axios";
2
+ //#region src/window.d.ts
3
+ export declare const $mitt: import("mitt").Emitter<Record<import("mitt").EventType, unknown>>;
4
+ export declare function isModuleObject(value: unknown): value is Record<string, any>;
5
+ export declare function registerWindow<T extends any>(key: string, value: T): void;
6
+ //#endregion
@@ -0,0 +1,39 @@
1
+ import { CryptoJS } from "./crypto.mjs";
2
+ import { Vue } from "./vue.mjs";
3
+ import { VueRouter } from "./vue-router.mjs";
4
+ import { VueUse } from "./vueuse.mjs";
5
+ import { zod } from "./zod.mjs";
6
+ import hljs_default from "./lowlight/hljs.mjs";
7
+ import { VueLowlight } from "./lowlight/index.mjs";
8
+ import axios from "axios";
9
+ import { isPlainObject } from "es-toolkit/compat";
10
+ import mitt from "mitt";
11
+ //#region src/window.ts
12
+ const $mitt = mitt();
13
+ /**
14
+ * 判断是否是 ES Module 命名空间对象 import * as xxx from 'xxx'
15
+ */
16
+ function isModuleObject(value) {
17
+ if (value && isPlainObject(value)) return value[Symbol.toStringTag] === "Module";
18
+ return false;
19
+ }
20
+ function registerWindow(key, value) {
21
+ if (typeof window !== "undefined" && !Reflect.has(window, key)) {
22
+ Object.defineProperty(window, key, {
23
+ get: () => value,
24
+ enumerable: true
25
+ });
26
+ if (!isModuleObject(window[key])) Object.defineProperty(window[key], "__esModule", { value: true });
27
+ }
28
+ }
29
+ registerWindow("zod", zod);
30
+ registerWindow("Vue", Vue);
31
+ registerWindow("VueUse", VueUse);
32
+ registerWindow("VueRouter", VueRouter);
33
+ registerWindow("axios", axios);
34
+ registerWindow("CryptoJS", CryptoJS);
35
+ registerWindow("VueLowlight", VueLowlight);
36
+ registerWindow("hljs", hljs_default);
37
+ registerWindow("process", { env: { NODE_ENV: "production" } });
38
+ //#endregion
39
+ export { $mitt, axios, isModuleObject, registerWindow };
@@ -0,0 +1,2 @@
1
+ import * as zod from "zod";
2
+ export { zod };
@@ -0,0 +1,2 @@
1
+ import * as zod from "zod";
2
+ export { zod };