@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,159 @@
1
+ import { createLowlight } from "./lowlights.mjs";
2
+ import hljs from "./hljs.mjs";
3
+ import "highlight.js/styles/atom-one-dark.min.css";
4
+ //#region src/lowlight/index.d.ts
5
+ export declare const highlightLanguages: string[];
6
+ export declare const lowlight: {
7
+ highlight: (language: any, value: any, options: any) => any;
8
+ highlightAuto: (value: any, options: any) => any;
9
+ listLanguages: () => string[];
10
+ register: (grammarsOrName: any, grammar?: any) => void;
11
+ registerAlias: (aliasesOrName: any, alias: any) => void;
12
+ registered: (aliasOrName: any) => boolean;
13
+ highlightBlock: (element: HTMLElement) => void;
14
+ highlightElement: (element: HTMLElement) => void;
15
+ configure: (options: Partial<import("highlight.js").HLJSOptions>) => void;
16
+ initHighlighting: () => void;
17
+ initHighlightingOnLoad: () => void;
18
+ highlightAll: () => void;
19
+ registerLanguage: (languageName: string, language: import("highlight.js").LanguageFn) => void;
20
+ unregisterLanguage: (languageName: string) => void;
21
+ registerAliases: (aliasList: string | string[], { languageName }: {
22
+ languageName: string;
23
+ }) => void;
24
+ getLanguage: (languageName: string) => import("highlight.js").Language | undefined;
25
+ autoDetection: (languageName: string) => boolean;
26
+ inherit: <T>(original: T, ...args: Record<string, any>[]) => T;
27
+ addPlugin: (plugin: import("highlight.js").HLJSPlugin) => void;
28
+ removePlugin: (plugin: import("highlight.js").HLJSPlugin) => void;
29
+ debugMode: () => void;
30
+ safeMode: () => void;
31
+ versionString: string;
32
+ vuePlugin: () => import("highlight.js").VuePlugin;
33
+ regex: {
34
+ concat: (...args: (RegExp | string)[]) => string;
35
+ lookahead: (re: RegExp | string) => string;
36
+ either: (...args: (RegExp | string)[] | [...(RegExp | string)[], {
37
+ capture?: boolean;
38
+ }]) => string;
39
+ optional: (re: RegExp | string) => string;
40
+ anyNumberOfTimes: (re: RegExp | string) => string;
41
+ };
42
+ newInstance: () => import("highlight.js").HLJSApi;
43
+ SHEBANG: (mode?: Partial<import("highlight.js").Mode> & {
44
+ binary?: string | RegExp;
45
+ }) => import("highlight.js").Mode;
46
+ BACKSLASH_ESCAPE: import("highlight.js").Mode;
47
+ QUOTE_STRING_MODE: import("highlight.js").Mode;
48
+ APOS_STRING_MODE: import("highlight.js").Mode;
49
+ PHRASAL_WORDS_MODE: import("highlight.js").Mode;
50
+ COMMENT: (begin: string | RegExp, end: string | RegExp, modeOpts?: import("highlight.js").Mode | {}) => import("highlight.js").Mode;
51
+ C_LINE_COMMENT_MODE: import("highlight.js").Mode;
52
+ C_BLOCK_COMMENT_MODE: import("highlight.js").Mode;
53
+ HASH_COMMENT_MODE: import("highlight.js").Mode;
54
+ NUMBER_MODE: import("highlight.js").Mode;
55
+ C_NUMBER_MODE: import("highlight.js").Mode;
56
+ BINARY_NUMBER_MODE: import("highlight.js").Mode;
57
+ REGEXP_MODE: import("highlight.js").Mode;
58
+ TITLE_MODE: import("highlight.js").Mode;
59
+ UNDERSCORE_TITLE_MODE: import("highlight.js").Mode;
60
+ METHOD_GUARD: import("highlight.js").Mode;
61
+ END_SAME_AS_BEGIN: (mode: import("highlight.js").Mode) => import("highlight.js").Mode;
62
+ IDENT_RE: string;
63
+ UNDERSCORE_IDENT_RE: string;
64
+ MATCH_NOTHING_RE: string;
65
+ NUMBER_RE: string;
66
+ C_NUMBER_RE: string;
67
+ BINARY_NUMBER_RE: string;
68
+ RE_STARTERS_RE: string;
69
+ };
70
+ export declare const VueLowlight: {
71
+ hljs: import("highlight.js").HLJSApi;
72
+ common: {
73
+ arduino: import("highlight.js").LanguageFn;
74
+ bash: import("highlight.js").LanguageFn;
75
+ c: import("highlight.js").LanguageFn;
76
+ cpp: import("highlight.js").LanguageFn;
77
+ csharp: import("highlight.js").LanguageFn;
78
+ css: import("highlight.js").LanguageFn;
79
+ diff: import("highlight.js").LanguageFn;
80
+ go: import("highlight.js").LanguageFn;
81
+ graphql: import("highlight.js").LanguageFn;
82
+ html: import("highlight.js").LanguageFn;
83
+ ini: import("highlight.js").LanguageFn;
84
+ java: import("highlight.js").LanguageFn;
85
+ javascript: import("highlight.js").LanguageFn;
86
+ json: import("highlight.js").LanguageFn;
87
+ kotlin: import("highlight.js").LanguageFn;
88
+ less: import("highlight.js").LanguageFn;
89
+ lua: import("highlight.js").LanguageFn;
90
+ makefile: import("highlight.js").LanguageFn;
91
+ markdown: import("highlight.js").LanguageFn;
92
+ objectivec: import("highlight.js").LanguageFn;
93
+ perl: import("highlight.js").LanguageFn;
94
+ php: import("highlight.js").LanguageFn;
95
+ 'php-template': import("highlight.js").LanguageFn;
96
+ plaintext: import("highlight.js").LanguageFn;
97
+ text: import("highlight.js").LanguageFn;
98
+ python: import("highlight.js").LanguageFn;
99
+ 'python-repl': import("highlight.js").LanguageFn;
100
+ r: import("highlight.js").LanguageFn;
101
+ ruby: import("highlight.js").LanguageFn;
102
+ rust: import("highlight.js").LanguageFn;
103
+ scss: import("highlight.js").LanguageFn;
104
+ shell: import("highlight.js").LanguageFn;
105
+ sql: import("highlight.js").LanguageFn;
106
+ swift: import("highlight.js").LanguageFn;
107
+ typescript: import("highlight.js").LanguageFn;
108
+ vbnet: import("highlight.js").LanguageFn;
109
+ wasm: import("highlight.js").LanguageFn;
110
+ xml: import("highlight.js").LanguageFn;
111
+ yaml: import("highlight.js").LanguageFn;
112
+ };
113
+ all: {
114
+ arduino: import("highlight.js").LanguageFn;
115
+ bash: import("highlight.js").LanguageFn;
116
+ c: import("highlight.js").LanguageFn;
117
+ cpp: import("highlight.js").LanguageFn;
118
+ csharp: import("highlight.js").LanguageFn;
119
+ css: import("highlight.js").LanguageFn;
120
+ diff: import("highlight.js").LanguageFn;
121
+ go: import("highlight.js").LanguageFn;
122
+ graphql: import("highlight.js").LanguageFn;
123
+ html: import("highlight.js").LanguageFn;
124
+ ini: import("highlight.js").LanguageFn;
125
+ java: import("highlight.js").LanguageFn;
126
+ javascript: import("highlight.js").LanguageFn;
127
+ json: import("highlight.js").LanguageFn;
128
+ kotlin: import("highlight.js").LanguageFn;
129
+ less: import("highlight.js").LanguageFn;
130
+ lua: import("highlight.js").LanguageFn;
131
+ makefile: import("highlight.js").LanguageFn;
132
+ markdown: import("highlight.js").LanguageFn;
133
+ objectivec: import("highlight.js").LanguageFn;
134
+ perl: import("highlight.js").LanguageFn;
135
+ php: import("highlight.js").LanguageFn;
136
+ 'php-template': import("highlight.js").LanguageFn;
137
+ plaintext: import("highlight.js").LanguageFn;
138
+ text: import("highlight.js").LanguageFn;
139
+ python: import("highlight.js").LanguageFn;
140
+ 'python-repl': import("highlight.js").LanguageFn;
141
+ r: import("highlight.js").LanguageFn;
142
+ ruby: import("highlight.js").LanguageFn;
143
+ rust: import("highlight.js").LanguageFn;
144
+ scss: import("highlight.js").LanguageFn;
145
+ shell: import("highlight.js").LanguageFn;
146
+ sql: import("highlight.js").LanguageFn;
147
+ swift: import("highlight.js").LanguageFn;
148
+ typescript: import("highlight.js").LanguageFn;
149
+ vbnet: import("highlight.js").LanguageFn;
150
+ wasm: import("highlight.js").LanguageFn;
151
+ xml: import("highlight.js").LanguageFn;
152
+ yaml: import("highlight.js").LanguageFn;
153
+ };
154
+ createLowlight: typeof createLowlight;
155
+ highlightLanguages: string[];
156
+ };
157
+ export type Lowlight = typeof lowlight;
158
+ //#endregion
159
+ export { hljs };
@@ -0,0 +1,16 @@
1
+ import { grammars } from "./common.mjs";
2
+ import hljs_default from "./hljs.mjs";
3
+ import { createLowlight } from "./lowlights.mjs";
4
+ import "highlight.js/styles/atom-one-dark.min.css";
5
+ //#region src/lowlight/index.ts
6
+ const highlightLanguages = Object.keys(grammars);
7
+ const lowlight = createLowlight(grammars);
8
+ const VueLowlight = {
9
+ hljs: hljs_default,
10
+ common: grammars,
11
+ all: grammars,
12
+ createLowlight,
13
+ highlightLanguages
14
+ };
15
+ //#endregion
16
+ export { VueLowlight, highlightLanguages, hljs_default as hljs, lowlight };
@@ -0,0 +1,66 @@
1
+ //#region src/lowlight/lowlights.d.ts
2
+ export declare function createLowlight(grammars: any): {
3
+ highlight: (language: any, value: any, options: any) => any;
4
+ highlightAuto: (value: any, options: any) => any;
5
+ listLanguages: () => string[];
6
+ register: (grammarsOrName: any, grammar?: any) => void;
7
+ registerAlias: (aliasesOrName: any, alias: any) => void;
8
+ registered: (aliasOrName: any) => boolean;
9
+ highlightBlock: (element: HTMLElement) => void;
10
+ highlightElement: (element: HTMLElement) => void;
11
+ configure: (options: Partial<import("highlight.js").HLJSOptions>) => void;
12
+ initHighlighting: () => void;
13
+ initHighlightingOnLoad: () => void;
14
+ highlightAll: () => void;
15
+ registerLanguage: (languageName: string, language: import("highlight.js").LanguageFn) => void;
16
+ unregisterLanguage: (languageName: string) => void;
17
+ registerAliases: (aliasList: string | string[], { languageName }: {
18
+ languageName: string;
19
+ }) => void;
20
+ getLanguage: (languageName: string) => import("highlight.js").Language | undefined;
21
+ autoDetection: (languageName: string) => boolean;
22
+ inherit: <T>(original: T, ...args: Record<string, any>[]) => T;
23
+ addPlugin: (plugin: import("highlight.js").HLJSPlugin) => void;
24
+ removePlugin: (plugin: import("highlight.js").HLJSPlugin) => void;
25
+ debugMode: () => void;
26
+ safeMode: () => void;
27
+ versionString: string;
28
+ vuePlugin: () => import("highlight.js").VuePlugin;
29
+ regex: {
30
+ concat: (...args: (RegExp | string)[]) => string;
31
+ lookahead: (re: RegExp | string) => string;
32
+ either: (...args: (RegExp | string)[] | [...(RegExp | string)[], {
33
+ capture?: boolean;
34
+ }]) => string;
35
+ optional: (re: RegExp | string) => string;
36
+ anyNumberOfTimes: (re: RegExp | string) => string;
37
+ };
38
+ newInstance: () => import("highlight.js").HLJSApi;
39
+ SHEBANG: (mode?: Partial<import("highlight.js").Mode> & {
40
+ binary?: string | RegExp;
41
+ }) => import("highlight.js").Mode;
42
+ BACKSLASH_ESCAPE: import("highlight.js").Mode;
43
+ QUOTE_STRING_MODE: import("highlight.js").Mode;
44
+ APOS_STRING_MODE: import("highlight.js").Mode;
45
+ PHRASAL_WORDS_MODE: import("highlight.js").Mode;
46
+ COMMENT: (begin: string | RegExp, end: string | RegExp, modeOpts?: import("highlight.js").Mode | {}) => import("highlight.js").Mode;
47
+ C_LINE_COMMENT_MODE: import("highlight.js").Mode;
48
+ C_BLOCK_COMMENT_MODE: import("highlight.js").Mode;
49
+ HASH_COMMENT_MODE: import("highlight.js").Mode;
50
+ NUMBER_MODE: import("highlight.js").Mode;
51
+ C_NUMBER_MODE: import("highlight.js").Mode;
52
+ BINARY_NUMBER_MODE: import("highlight.js").Mode;
53
+ REGEXP_MODE: import("highlight.js").Mode;
54
+ TITLE_MODE: import("highlight.js").Mode;
55
+ UNDERSCORE_TITLE_MODE: import("highlight.js").Mode;
56
+ METHOD_GUARD: import("highlight.js").Mode;
57
+ END_SAME_AS_BEGIN: (mode: import("highlight.js").Mode) => import("highlight.js").Mode;
58
+ IDENT_RE: string;
59
+ UNDERSCORE_IDENT_RE: string;
60
+ MATCH_NOTHING_RE: string;
61
+ NUMBER_RE: string;
62
+ C_NUMBER_RE: string;
63
+ BINARY_NUMBER_RE: string;
64
+ RE_STARTERS_RE: string;
65
+ };
66
+ //#endregion
@@ -0,0 +1,153 @@
1
+ import hljs_default from "./hljs.mjs";
2
+ //#region src/lowlight/lowlights.ts
3
+ const emptyOptions = {};
4
+ const defaultPrefix = "hljs-";
5
+ function createLowlight(grammars) {
6
+ const high = hljs_default.newInstance();
7
+ if (grammars) register(grammars);
8
+ function highlight(language, value, options) {
9
+ const settings = options || emptyOptions;
10
+ const prefix = typeof settings.prefix === "string" ? settings.prefix : defaultPrefix;
11
+ if (!high.getLanguage(language)) throw new Error(`Unknown language: \`${language}\` is not registered`);
12
+ high.configure({
13
+ __emitter: HastEmitter,
14
+ classPrefix: prefix
15
+ });
16
+ const result = high.highlight(value, {
17
+ ignoreIllegals: true,
18
+ language
19
+ });
20
+ /* c8 ignore next 5 */
21
+ if (result.errorRaised) throw new Error("Could not highlight with `Highlight.js`", { cause: result.errorRaised });
22
+ const root = result._emitter.root;
23
+ const data = root.data;
24
+ data.language = result.language;
25
+ data.relevance = result.relevance;
26
+ return root;
27
+ }
28
+ function highlightAuto(value, options) {
29
+ const subset = (options || emptyOptions).subset || listLanguages();
30
+ let index = -1;
31
+ let relevance = 0;
32
+ /** @type {Root | undefined} */
33
+ let result;
34
+ while (++index < subset.length) {
35
+ const name = subset[index];
36
+ if (!high.getLanguage(name)) continue;
37
+ const current = highlight(name, value, options);
38
+ if (current.data && current.data.relevance !== void 0 && current.data.relevance > relevance) {
39
+ relevance = current.data.relevance;
40
+ result = current;
41
+ }
42
+ }
43
+ return result || {
44
+ type: "root",
45
+ children: [],
46
+ data: {
47
+ language: void 0,
48
+ relevance
49
+ }
50
+ };
51
+ }
52
+ function listLanguages() {
53
+ return high.listLanguages();
54
+ }
55
+ function register(grammarsOrName, grammar) {
56
+ if (typeof grammarsOrName === "string") high.registerLanguage(grammarsOrName, grammar);
57
+ else {
58
+ /** @type {string} */
59
+ let name;
60
+ for (name in grammarsOrName) if (grammarsOrName[name]) high.registerLanguage(name, grammarsOrName[name]);
61
+ }
62
+ }
63
+ function registerAlias(aliasesOrName, alias) {
64
+ if (typeof aliasesOrName === "string") high.registerAliases(typeof alias === "string" ? alias : [...alias], { languageName: aliasesOrName });
65
+ else {
66
+ /** @type {string} */
67
+ let key;
68
+ for (key in aliasesOrName) if (aliasesOrName[key]) {
69
+ const aliases = aliasesOrName[key];
70
+ high.registerAliases(typeof aliases === "string" ? aliases : [...aliases], { languageName: key });
71
+ }
72
+ }
73
+ }
74
+ function registered(aliasOrName) {
75
+ return Boolean(high.getLanguage(aliasOrName));
76
+ }
77
+ return {
78
+ ...high,
79
+ highlight,
80
+ highlightAuto,
81
+ listLanguages,
82
+ register,
83
+ registerAlias,
84
+ registered
85
+ };
86
+ }
87
+ var HastEmitter = class {
88
+ options;
89
+ root;
90
+ stack = [];
91
+ constructor(options) {
92
+ this.options = options;
93
+ this.root = {
94
+ type: "root",
95
+ children: [],
96
+ data: {
97
+ language: void 0,
98
+ relevance: 0
99
+ }
100
+ };
101
+ this.stack = [this.root];
102
+ }
103
+ __addSublanguage(other, name) {
104
+ const current = this.stack[this.stack.length - 1];
105
+ const results = other.root.children;
106
+ if (name) current.children.push({
107
+ type: "element",
108
+ tagName: "span",
109
+ properties: { className: [name] },
110
+ children: results
111
+ });
112
+ else current.children.push(...results);
113
+ }
114
+ addText(value) {
115
+ if (value === "") return;
116
+ const current = this.stack[this.stack.length - 1];
117
+ const tail = current.children[current.children.length - 1];
118
+ if (tail && tail.type === "text") tail.value += value;
119
+ else current.children.push({
120
+ type: "text",
121
+ value
122
+ });
123
+ }
124
+ closeNode() {
125
+ this.stack.pop();
126
+ }
127
+ endScope() {
128
+ this.closeNode();
129
+ }
130
+ finalize() {}
131
+ openNode(name) {
132
+ const className = name.split(".").map((d, i) => {
133
+ return i ? d + "_".repeat(i) : this.options.classPrefix + d;
134
+ });
135
+ const current = this.stack[this.stack.length - 1];
136
+ const child = {
137
+ type: "element",
138
+ tagName: "span",
139
+ properties: { className },
140
+ children: []
141
+ };
142
+ current.children.push(child);
143
+ this.stack.push(child);
144
+ }
145
+ startScope(rawName) {
146
+ this.openNode(String(rawName));
147
+ }
148
+ toHTML() {
149
+ return "";
150
+ }
151
+ };
152
+ //#endregion
153
+ export { createLowlight };
@@ -0,0 +1,5 @@
1
+ import nProgress, { NProgress, NProgressOptions, NProgressOptions as NProgressOptions$1 } from "nprogress";
2
+ //#region src/nprogress.d.ts
3
+ export declare function useProgress(options?: Partial<NProgressOptions>): nProgress.NProgress;
4
+ //#endregion
5
+ export type { NProgress, NProgressOptions$1 as NProgressOptions };
@@ -0,0 +1,16 @@
1
+ import nProgress from "nprogress";
2
+ //#region src/nprogress.ts
3
+ const progress = nProgress.configure({
4
+ minimum: .1,
5
+ showSpinner: false,
6
+ speed: 300,
7
+ trickle: true,
8
+ trickleRate: .02,
9
+ trickleSpeed: 800
10
+ });
11
+ function useProgress(options) {
12
+ if (options) progress.configure(options);
13
+ return progress;
14
+ }
15
+ //#endregion
16
+ export { useProgress };
@@ -0,0 +1,7 @@
1
+ import { App } from "vue";
2
+ import * as ToastApi from "vue3-toastify";
3
+ import { Toast, ToastOptions, toast } from "vue3-toastify";
4
+ //#region src/toastify.d.ts
5
+ export declare function setupToast(app: App, useHandler?: (app: App) => void): void;
6
+ //#endregion
7
+ export { type Toast, ToastApi, type ToastOptions, toast };
@@ -0,0 +1,13 @@
1
+ import * as ToastApi from "vue3-toastify";
2
+ import Toastify, { toast } from "vue3-toastify";
3
+ //#region src/toastify.ts
4
+ function setupToast(app, useHandler) {
5
+ app.use(Toastify, {
6
+ theme: "colored",
7
+ autoClose: 2e3,
8
+ useHandler
9
+ });
10
+ app.provide("toast", toast);
11
+ }
12
+ //#endregion
13
+ export { ToastApi, setupToast, toast };
@@ -0,0 +1,2 @@
1
+ import * as VeeValidate from "vee-validate";
2
+ export { VeeValidate };
@@ -0,0 +1,2 @@
1
+ import * as VeeValidate from "vee-validate";
2
+ export { VeeValidate };
@@ -0,0 +1,3 @@
1
+ import { JsonNodeProps, setupJsonNode, useJsonNode } from "./node.mjs";
2
+ import { BlockSchema, ContextMode, initProvider, useGlobalProvider, vtjSymbol } from "./provider.mjs";
3
+ export { type BlockSchema, ContextMode, JsonNodeProps, initProvider, setupJsonNode, useGlobalProvider, useJsonNode, vtjSymbol };
@@ -0,0 +1,3 @@
1
+ import { ContextMode, initProvider, useGlobalProvider, vtjSymbol } from "./provider.mjs";
2
+ import { setupJsonNode, useJsonNode } from "./node.mjs";
3
+ export { ContextMode, initProvider, setupJsonNode, useGlobalProvider, useJsonNode, vtjSymbol };
@@ -0,0 +1,33 @@
1
+ import { ApiSchema, BlockSchema, Dependencie, MetaSchema, ProjectSchema } from "@vtj/core";
2
+ //#region src/vtj/node.d.ts
3
+ export interface JsonNodeProps {
4
+ apis?: ApiSchema[];
5
+ assets?: {
6
+ css: string[];
7
+ js: string[];
8
+ script: string[];
9
+ };
10
+ blocks?: BlockSchema[];
11
+ dependencies?: Dependencie[];
12
+ id?: string;
13
+ meta?: MetaSchema[];
14
+ mock?: boolean;
15
+ mode?: 'Design' | 'Raw' | 'Runtime' | 'VNode';
16
+ refreshKey?: string;
17
+ schema?: BlockSchema;
18
+ url?: string;
19
+ sources?: string;
20
+ project?: Partial<ProjectSchema>;
21
+ }
22
+ export declare const setupJsonNode: (props: JsonNodeProps) => {
23
+ schema: import("vue").ShallowRef<{}, {}>;
24
+ renderer: import("vue").ComputedRef<any>;
25
+ cacheNodes: any;
26
+ provider: import("@vtj/renderer").Provider;
27
+ loading: import("vue").Ref<boolean, boolean>;
28
+ cacheId: import("vue").ComputedRef<string>;
29
+ refreshKey: import("vue").Ref<number, number>;
30
+ };
31
+ declare type JsonNodeType = ReturnType<typeof setupJsonNode>;
32
+ export declare const useJsonNode: () => JsonNodeType;
33
+ //#endregion
@@ -0,0 +1,70 @@
1
+ import { createFunction } from "../common.mjs";
2
+ import { md5 } from "../crypto.mjs";
3
+ import { loaderScript, useStyleLink } from "../loader.mjs";
4
+ import { useGlobalProvider } from "./provider.mjs";
5
+ import "../index.mjs";
6
+ import { computed, getCurrentInstance, inject, onBeforeUnmount, onMounted, provide, ref, shallowReactive, shallowRef } from "vue";
7
+ //#region src/vtj/node.ts
8
+ const setupJsonNode = function(props) {
9
+ const schema = shallowRef({});
10
+ const { proxy } = getCurrentInstance();
11
+ const cacheId = computed(() => md5(JSON.stringify(props)));
12
+ const refreshKey = ref(0);
13
+ const dsl = shallowRef(props.schema || null);
14
+ const loading = ref(false);
15
+ const { cacheNodes, provider, initProject } = useGlobalProvider();
16
+ const renderer = computed(() => schema.value?.renderer || null);
17
+ const assets = shallowReactive({
18
+ css: [],
19
+ js: [],
20
+ script: [],
21
+ ...props.assets
22
+ });
23
+ const removes = ref([]);
24
+ const loadAssets = async () => {
25
+ const promiseList = [];
26
+ if (assets.css && assets.css.length > 0) for (const link of assets.css) promiseList.push(useStyleLink(link, (el) => {
27
+ removes.value.push(el);
28
+ }));
29
+ if (assets.js && assets.js.length > 0) for (const link of assets.js) promiseList.push(loaderScript(link));
30
+ if (assets.script && assets.script.length > 0) for (const script of assets.script) {
31
+ const fnRes = createFunction(`return async ()=>{ ${script} }`, { proxy });
32
+ if (fnRes) promiseList.push(fnRes.call({ proxy }));
33
+ }
34
+ if (promiseList.length > 0) await Promise.all(promiseList);
35
+ };
36
+ onMounted(async () => {
37
+ await initProject(props);
38
+ loading.value = true;
39
+ await loadAssets();
40
+ if (cacheNodes[cacheId.value]) schema.value = cacheNodes[cacheId.value];
41
+ else {
42
+ if (props.url && !dsl.value) dsl.value = await provider.getDslByUrl(props.url);
43
+ if (dsl.value) schema.value = provider.createDslRenderer(dsl.value);
44
+ cacheNodes[cacheId.value] = schema.value;
45
+ }
46
+ refreshKey.value++;
47
+ loading.value = false;
48
+ });
49
+ onBeforeUnmount(() => {
50
+ if (removes.value.length > 0) removes.value.forEach((el) => {
51
+ el.remove();
52
+ });
53
+ });
54
+ const store = {
55
+ schema,
56
+ renderer,
57
+ cacheNodes,
58
+ provider,
59
+ loading,
60
+ cacheId,
61
+ refreshKey
62
+ };
63
+ provide("JsonNode", store);
64
+ return store;
65
+ };
66
+ const useJsonNode = () => {
67
+ return inject("JsonNode", null);
68
+ };
69
+ //#endregion
70
+ export { setupJsonNode, useJsonNode };
@@ -0,0 +1,32 @@
1
+ import { JsonNodeProps } from "./node.mjs";
2
+ import { IRequestOptions, IStaticRequest } from "./request.mjs";
3
+ import { UseStoreServiceReturn } from "./stores.mjs";
4
+ import { App } from "vue";
5
+ import { ContextMode, Provider, ProviderOptions } from "@vtj/renderer";
6
+ import { BlockSchema as BlockSchema$1 } from "@vtj/core";
7
+ //#region src/vtj/provider.d.ts
8
+ declare interface VTJConfig {
9
+ id?: string;
10
+ name?: string;
11
+ onInst?: (provider: Provider) => void;
12
+ onReady?: () => void;
13
+ providerOptions?: Partial<ProviderOptions>;
14
+ requestInst?: (request: IStaticRequest) => void;
15
+ requestOptions?: IRequestOptions;
16
+ storage?: UseStoreServiceReturn;
17
+ }
18
+ export declare const vtjSymbol: unique symbol;
19
+ export declare function initProvider(app: App, config?: VTJConfig): {
20
+ provider: Provider;
21
+ updateBlocks: (blocks?: BlockSchema$1[]) => Promise<void>;
22
+ cacheNodes: any;
23
+ initProject: (props: JsonNodeProps) => Promise<Provider>;
24
+ };
25
+ export declare function useGlobalProvider(): {
26
+ provider: Provider;
27
+ updateBlocks: (blocks?: BlockSchema$1[]) => Promise<void>;
28
+ cacheNodes: any;
29
+ initProject: (props: JsonNodeProps) => Promise<Provider>;
30
+ };
31
+ //#endregion
32
+ export { type BlockSchema$1 as BlockSchema, ContextMode };
@@ -0,0 +1,65 @@
1
+ import { makeUuid } from "../common.mjs";
2
+ import { createNodeRequest } from "./request.mjs";
3
+ import { NodeService } from "./service.mjs";
4
+ import { inject, reactive } from "vue";
5
+ import { ContextMode, createProvider } from "@vtj/renderer";
6
+ //#region src/vtj/provider.ts
7
+ const vtjSymbol = Symbol("vtj-provider");
8
+ function initProvider(app, config) {
9
+ const cacheNodes = reactive({});
10
+ const service = new NodeService(config?.storage);
11
+ const { provider, onReady } = createProvider({
12
+ service,
13
+ dependencies: { Vue: () => import("vue") },
14
+ ...config?.providerOptions
15
+ });
16
+ provider.adapter.request = createNodeRequest(config?.requestOptions, config?.requestInst);
17
+ if (config?.onInst && typeof config?.onInst === "function") config.onInst(provider);
18
+ if (config?.onReady && typeof config?.onReady === "function") onReady(config.onReady);
19
+ const updateBlocks = async (blocks) => {
20
+ blocks?.forEach((block) => {
21
+ service.publishFile(project, block);
22
+ });
23
+ };
24
+ const project = reactive({
25
+ id: config?.id || makeUuid(),
26
+ name: config?.name || "VTJAdmin",
27
+ platform: "web",
28
+ config: { themeSwitchable: false }
29
+ });
30
+ async function initProject(props) {
31
+ Object.assign(project, {
32
+ apis: props.apis || [],
33
+ meta: props.meta || [],
34
+ dependencies: props.dependencies || [{
35
+ package: "common",
36
+ version: "latest",
37
+ library: "Vue",
38
+ urls: ["libs/common.min.js"],
39
+ assetsLibrary: "VueMaterial",
40
+ required: true,
41
+ official: true,
42
+ enabled: true,
43
+ platform: ["web", "h5"]
44
+ }]
45
+ });
46
+ await service.saveProject(project);
47
+ await provider.load(project);
48
+ await updateBlocks(props.blocks);
49
+ provider.mode = ContextMode[props.mode || "Runtime"];
50
+ return provider;
51
+ }
52
+ const stores = {
53
+ provider,
54
+ updateBlocks,
55
+ cacheNodes,
56
+ initProject
57
+ };
58
+ app.provide(vtjSymbol, stores);
59
+ return stores;
60
+ }
61
+ function useGlobalProvider() {
62
+ return inject(vtjSymbol, {});
63
+ }
64
+ //#endregion
65
+ export { ContextMode, initProvider, useGlobalProvider, vtjSymbol };
@@ -0,0 +1,2 @@
1
+ import { IRequestOptions, IStaticRequest } from "@vtj/utils";
2
+ export type { IRequestOptions, IStaticRequest };