@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.
- package/dist/es/api.d.mts +14 -0
- package/dist/es/api.mjs +26 -0
- package/dist/es/common.d.mts +20 -0
- package/dist/es/common.mjs +112 -0
- package/dist/es/crypto.d.mts +5 -0
- package/dist/es/crypto.mjs +7 -0
- package/dist/es/dayjs.d.mts +7 -0
- package/dist/es/dayjs.mjs +47 -0
- package/dist/es/es-toolkit.d.mts +3 -0
- package/dist/es/es-toolkit.mjs +3 -0
- package/dist/es/idb-keyval.d.mts +16 -0
- package/dist/es/idb-keyval.mjs +63 -0
- package/dist/es/index.d.mts +21 -0
- package/dist/es/index.mjs +21 -0
- package/dist/es/loader.d.mts +6 -0
- package/dist/es/loader.mjs +44 -0
- package/dist/es/lowlight/common.mjs +81 -0
- package/dist/es/lowlight/hljs.d.mts +2 -0
- package/dist/es/lowlight/hljs.mjs +9 -0
- package/dist/es/lowlight/index.d.mts +159 -0
- package/dist/es/lowlight/index.mjs +16 -0
- package/dist/es/lowlight/lowlights.d.mts +66 -0
- package/dist/es/lowlight/lowlights.mjs +153 -0
- package/dist/es/nprogress.d.mts +5 -0
- package/dist/es/nprogress.mjs +16 -0
- package/dist/es/toastify.d.mts +7 -0
- package/dist/es/toastify.mjs +13 -0
- package/dist/es/vee-validate.d.mts +2 -0
- package/dist/es/vee-validate.mjs +2 -0
- package/dist/es/vtj/index.d.mts +3 -0
- package/dist/es/vtj/index.mjs +3 -0
- package/dist/es/vtj/node.d.mts +33 -0
- package/dist/es/vtj/node.mjs +70 -0
- package/dist/es/vtj/provider.d.mts +32 -0
- package/dist/es/vtj/provider.mjs +65 -0
- package/dist/es/vtj/request.d.mts +2 -0
- package/dist/es/vtj/request.mjs +22 -0
- package/dist/es/vtj/service.mjs +63 -0
- package/dist/es/vtj/stores.d.mts +11 -0
- package/dist/es/vtj/stores.mjs +103 -0
- package/dist/es/vue-router.d.mts +2 -0
- package/dist/es/vue-router.mjs +2 -0
- package/dist/es/vue.d.mts +2 -0
- package/dist/es/vue.mjs +2 -0
- package/dist/es/vueuse.d.mts +3 -0
- package/dist/es/vueuse.mjs +3 -0
- package/dist/es/window.d.mts +6 -0
- package/dist/es/window.mjs +39 -0
- package/dist/es/zod.d.mts +2 -0
- package/dist/es/zod.mjs +2 -0
- package/dist/umd/common.min.js +371 -0
- package/dist/umd/common.min.js.map +1 -0
- package/dist/umd/style.css +59 -0
- package/package.json +89 -0
- package/src/api.ts +83 -0
- package/src/common.ts +201 -0
- package/src/crypto.ts +7 -0
- package/src/dayjs.ts +60 -0
- package/src/es-toolkit.ts +4 -0
- package/src/highlight.ts +0 -0
- package/src/idb-keyval.ts +115 -0
- package/src/index.ts +20 -0
- package/src/loader.ts +62 -0
- package/src/lowlight/common.ts +79 -0
- package/src/lowlight/hljs.ts +11 -0
- package/src/lowlight/index.ts +22 -0
- package/src/lowlight/lowlights.ts +231 -0
- package/src/nprogress.ts +20 -0
- package/src/sortablejs.ts +1 -0
- package/src/tippy.ts +3 -0
- package/src/toastify.ts +19 -0
- package/src/vee-validate.ts +1 -0
- package/src/vtj/index.ts +2 -0
- package/src/vtj/node.ts +158 -0
- package/src/vtj/provider.ts +113 -0
- package/src/vtj/request.ts +34 -0
- package/src/vtj/service.ts +93 -0
- package/src/vtj/stores.ts +144 -0
- package/src/vue-router.ts +1 -0
- package/src/vue.ts +3 -0
- package/src/vueuse.ts +13 -0
- package/src/window.ts +60 -0
- package/src/zod.ts +1 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { BlockSchema, ProjectSchema } from '@vtj/core';
|
|
2
|
+
import type { Provider, ProviderOptions } from '@vtj/renderer';
|
|
3
|
+
|
|
4
|
+
import type { App } from 'vue';
|
|
5
|
+
|
|
6
|
+
import type { JsonNodeProps } from './node';
|
|
7
|
+
import type { IRequestOptions, IStaticRequest } from './request';
|
|
8
|
+
import type { UseStoreServiceReturn } from './stores';
|
|
9
|
+
|
|
10
|
+
import { inject, reactive } from 'vue';
|
|
11
|
+
|
|
12
|
+
import { makeUuid } from '../common';
|
|
13
|
+
import { ContextMode, createProvider } from '@vtj/renderer';
|
|
14
|
+
|
|
15
|
+
import { createNodeRequest } from './request';
|
|
16
|
+
import { NodeService } from './service';
|
|
17
|
+
|
|
18
|
+
export type { BlockSchema };
|
|
19
|
+
export { ContextMode };
|
|
20
|
+
|
|
21
|
+
declare interface VTJConfig {
|
|
22
|
+
id?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
onInst?: (provider: Provider) => void;
|
|
25
|
+
onReady?: () => void;
|
|
26
|
+
providerOptions?: Partial<ProviderOptions>;
|
|
27
|
+
requestInst?: (request: IStaticRequest) => void;
|
|
28
|
+
requestOptions?: IRequestOptions;
|
|
29
|
+
storage?: UseStoreServiceReturn;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const vtjSymbol = Symbol('vtj-provider');
|
|
33
|
+
|
|
34
|
+
export function initProvider(app: App, config?: VTJConfig) {
|
|
35
|
+
const cacheNodes = reactive<any>({});
|
|
36
|
+
const service = new NodeService(config?.storage);
|
|
37
|
+
const { provider, onReady } = createProvider({
|
|
38
|
+
service,
|
|
39
|
+
dependencies: {
|
|
40
|
+
Vue: ()=> import('vue')
|
|
41
|
+
},
|
|
42
|
+
...config?.providerOptions,
|
|
43
|
+
});
|
|
44
|
+
provider.adapter.request = createNodeRequest(
|
|
45
|
+
config?.requestOptions,
|
|
46
|
+
config?.requestInst,
|
|
47
|
+
);
|
|
48
|
+
if (config?.onInst && typeof config?.onInst === 'function') {
|
|
49
|
+
config.onInst(provider);
|
|
50
|
+
}
|
|
51
|
+
if (config?.onReady && typeof config?.onReady === 'function') {
|
|
52
|
+
onReady(config.onReady);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const updateBlocks = async (blocks?: BlockSchema[]) => {
|
|
56
|
+
blocks?.forEach((block: BlockSchema) => {
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
service.publishFile(project, block);
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const project = reactive<ProjectSchema>({
|
|
63
|
+
id: config?.id || makeUuid(),
|
|
64
|
+
name: config?.name || 'VTJAdmin',
|
|
65
|
+
platform: 'web',
|
|
66
|
+
config: {
|
|
67
|
+
themeSwitchable: false,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
async function initProject(props: JsonNodeProps) {
|
|
72
|
+
Object.assign(project, {
|
|
73
|
+
apis: props.apis || [],
|
|
74
|
+
meta: props.meta || [],
|
|
75
|
+
dependencies: props.dependencies || [
|
|
76
|
+
{
|
|
77
|
+
package: 'common',
|
|
78
|
+
version: 'latest',
|
|
79
|
+
library: 'Vue',
|
|
80
|
+
urls: ['libs/common.min.js'],
|
|
81
|
+
assetsLibrary: 'VueMaterial',
|
|
82
|
+
required: true,
|
|
83
|
+
official: true,
|
|
84
|
+
enabled: true,
|
|
85
|
+
platform: ['web', 'h5']
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
});
|
|
89
|
+
await service.saveProject(project as ProjectSchema);
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
await provider.load(project);
|
|
92
|
+
await updateBlocks(props.blocks);
|
|
93
|
+
provider.mode = ContextMode[props.mode || 'Runtime'];
|
|
94
|
+
return provider;
|
|
95
|
+
}
|
|
96
|
+
// app.use(provider);
|
|
97
|
+
// provider.install(app);
|
|
98
|
+
|
|
99
|
+
const stores = {
|
|
100
|
+
provider,
|
|
101
|
+
updateBlocks,
|
|
102
|
+
cacheNodes,
|
|
103
|
+
initProject,
|
|
104
|
+
};
|
|
105
|
+
app.provide(vtjSymbol, stores);
|
|
106
|
+
return stores;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
declare type ProviderStore = ReturnType<typeof initProvider>;
|
|
110
|
+
|
|
111
|
+
export function useGlobalProvider() {
|
|
112
|
+
return inject(vtjSymbol, {} as ProviderStore);
|
|
113
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { IRequestOptions, IStaticRequest } from '@vtj/utils';
|
|
2
|
+
|
|
3
|
+
import { createRequest } from '@vtj/utils';
|
|
4
|
+
|
|
5
|
+
export type { IRequestOptions, IStaticRequest };
|
|
6
|
+
|
|
7
|
+
export function createNodeRequest(
|
|
8
|
+
options?: IRequestOptions,
|
|
9
|
+
requestInst?: (request: IStaticRequest) => void,
|
|
10
|
+
) {
|
|
11
|
+
const request = createRequest({
|
|
12
|
+
...options,
|
|
13
|
+
settings: {
|
|
14
|
+
type: 'form',
|
|
15
|
+
validSuccess: false,
|
|
16
|
+
originResponse: false,
|
|
17
|
+
loading: true,
|
|
18
|
+
failMessage: false,
|
|
19
|
+
...options?.settings,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
request.useRequest(async (config: any) => {
|
|
24
|
+
// const accessStore = useAccessStore();
|
|
25
|
+
// config.headers.Authorization = formatToken(accessStore.accessToken);
|
|
26
|
+
// config.headers['Accept-Language'] = preferences.app.locale;
|
|
27
|
+
return config;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
if (requestInst && typeof requestInst === 'function') {
|
|
31
|
+
requestInst(request);
|
|
32
|
+
}
|
|
33
|
+
return request;
|
|
34
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BlockFile,
|
|
3
|
+
BlockSchema,
|
|
4
|
+
MaterialDescription,
|
|
5
|
+
NodeFromPlugin,
|
|
6
|
+
PageFile,
|
|
7
|
+
ProjectSchema,
|
|
8
|
+
StaticFileInfo,
|
|
9
|
+
} from '@vtj/core';
|
|
10
|
+
|
|
11
|
+
import { StoresService } from './stores';
|
|
12
|
+
|
|
13
|
+
const notification = {
|
|
14
|
+
warning: (options: any) => {
|
|
15
|
+
console.warn(options);
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export class NodeService extends StoresService {
|
|
20
|
+
override async createRawPage(_file: PageFile): Promise<boolean> {
|
|
21
|
+
notification.warning({
|
|
22
|
+
title: '提示',
|
|
23
|
+
content: '在线演示版本不支持源码模式页面,如需体验请下载本地版本。',
|
|
24
|
+
});
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
override genVueContent(
|
|
28
|
+
_project: ProjectSchema,
|
|
29
|
+
_dsl: BlockSchema,
|
|
30
|
+
): Promise<string> {
|
|
31
|
+
notification.warning({
|
|
32
|
+
title: '提示',
|
|
33
|
+
content: '在线演示版本不支持源码生成功能,如需体验请下载本地版本。',
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return Promise.resolve('');
|
|
37
|
+
}
|
|
38
|
+
override async getPluginMaterial(
|
|
39
|
+
_from: NodeFromPlugin,
|
|
40
|
+
): Promise<MaterialDescription | null> {
|
|
41
|
+
notification.warning({
|
|
42
|
+
title: '提示',
|
|
43
|
+
content: '在线演示版本不支持引用和插件,如需体验请下载本地版本。',
|
|
44
|
+
});
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
override async getStaticFiles(_projectId: string): Promise<StaticFileInfo[]> {
|
|
48
|
+
notification.warning({
|
|
49
|
+
title: '提示',
|
|
50
|
+
content: '在线演示版本不支持文件上传,如需体验请下载本地版本。',
|
|
51
|
+
});
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
override publish(_project: ProjectSchema): Promise<boolean> {
|
|
56
|
+
notification.warning({
|
|
57
|
+
title: '提示',
|
|
58
|
+
content: '在线演示版本不支持发布功能,如需体验请下载本地版本。',
|
|
59
|
+
});
|
|
60
|
+
return Promise.resolve(false);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
override publishFile(
|
|
64
|
+
_project: ProjectSchema,
|
|
65
|
+
_file: BlockFile | BlockSchema | PageFile,
|
|
66
|
+
): Promise<boolean> {
|
|
67
|
+
if ('dsl' in _file) {
|
|
68
|
+
_file.dsl && this.saveFile(_file.dsl);
|
|
69
|
+
} else {
|
|
70
|
+
_file && this.saveFile(_file);
|
|
71
|
+
}
|
|
72
|
+
return Promise.resolve(false);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
override async removeRawPage(_id: string): Promise<boolean> {
|
|
76
|
+
notification.warning({
|
|
77
|
+
title: '提示',
|
|
78
|
+
content: '在线演示版本不支持源码模式页面,如需体验请下载本地版本。',
|
|
79
|
+
});
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
override async uploadStaticFile(
|
|
84
|
+
_file: File,
|
|
85
|
+
_rojectId: string,
|
|
86
|
+
): Promise<null | StaticFileInfo> {
|
|
87
|
+
notification.warning({
|
|
88
|
+
title: '提示',
|
|
89
|
+
content: '在线演示版本不支持文件上传,如需体验请下载本地版本。',
|
|
90
|
+
});
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BlockSchema,
|
|
3
|
+
HistoryItem,
|
|
4
|
+
HistorySchema,
|
|
5
|
+
MaterialDescription,
|
|
6
|
+
ProjectSchema,
|
|
7
|
+
} from '@vtj/core';
|
|
8
|
+
|
|
9
|
+
import { reactive } from 'vue';
|
|
10
|
+
|
|
11
|
+
import { HistoryModel, ProjectModel } from '@vtj/core';
|
|
12
|
+
import { BaseService } from '@vtj/renderer';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Map转键值对
|
|
16
|
+
*
|
|
17
|
+
* @param map
|
|
18
|
+
*/
|
|
19
|
+
export function mapToObject<V = any>(map: Map<any, V>) {
|
|
20
|
+
return [...map.entries()].reduce(
|
|
21
|
+
(obj, [key, value]) => {
|
|
22
|
+
obj[key] = value;
|
|
23
|
+
return obj;
|
|
24
|
+
},
|
|
25
|
+
{} as Record<any, V>,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const useStoreService = () => {
|
|
30
|
+
return {
|
|
31
|
+
storage: reactive<Record<string, any>>({}),
|
|
32
|
+
save(id: string, value: any) {
|
|
33
|
+
this.storage[id] = value;
|
|
34
|
+
},
|
|
35
|
+
get(id: string) {
|
|
36
|
+
return this.storage[id] || null;
|
|
37
|
+
},
|
|
38
|
+
remove(id: string) {
|
|
39
|
+
if (this.storage[id] !== undefined) {
|
|
40
|
+
delete this.storage[id];
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export declare type UseStoreServiceReturn = typeof useStoreService;
|
|
47
|
+
|
|
48
|
+
export class StoresService extends BaseService {
|
|
49
|
+
protected stores: any;
|
|
50
|
+
constructor(stores?: UseStoreServiceReturn) {
|
|
51
|
+
super();
|
|
52
|
+
this.stores = stores ? stores() : useStoreService();
|
|
53
|
+
}
|
|
54
|
+
public override getFile(id: string): Promise<BlockSchema> {
|
|
55
|
+
const dsl = this.stores.get(`file_${id}`);
|
|
56
|
+
return dsl ? Promise.resolve(dsl as BlockSchema) : Promise.reject(null);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public override getHistory(id: string): Promise<HistorySchema> {
|
|
60
|
+
const dsl = this.stores.get(`history_${id}`);
|
|
61
|
+
const history = new HistoryModel(dsl || { id });
|
|
62
|
+
return Promise.resolve(history.toDsl());
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public override getHistoryItem(
|
|
66
|
+
fId: string,
|
|
67
|
+
id: string,
|
|
68
|
+
): Promise<HistoryItem> {
|
|
69
|
+
const item = this.stores.get(`history_${fId}_${id}`);
|
|
70
|
+
return Promise.resolve(item);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public override init(project: ProjectSchema): Promise<ProjectSchema> {
|
|
74
|
+
const model = new ProjectModel(project);
|
|
75
|
+
const match = this.stores.get(`project_${model.id}`);
|
|
76
|
+
const dsl = Object.assign(model.toDsl(), match || {});
|
|
77
|
+
this.stores.save(`project_${model.id}`, dsl);
|
|
78
|
+
return Promise.resolve(dsl);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public override removeFile(id: string): Promise<boolean> {
|
|
82
|
+
this.stores.remove(`file_${id}`);
|
|
83
|
+
return Promise.resolve(true);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public override async removeHistory(id: string): Promise<boolean> {
|
|
87
|
+
const history = this.stores.get(`history_${id}`) as HistorySchema;
|
|
88
|
+
if (history) {
|
|
89
|
+
const items = history.items || [];
|
|
90
|
+
const ids = items.map((item) => item.id);
|
|
91
|
+
await this.removeHistoryItem(id, ids);
|
|
92
|
+
this.stores.remove(`history_${id}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return Promise.resolve(true);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @param fId
|
|
100
|
+
* @param ids
|
|
101
|
+
* @override
|
|
102
|
+
*/
|
|
103
|
+
public override removeHistoryItem(
|
|
104
|
+
fId: string,
|
|
105
|
+
ids: string[],
|
|
106
|
+
): Promise<boolean> {
|
|
107
|
+
ids.forEach((id) => {
|
|
108
|
+
this.stores.remove(`history_${fId}_${id}`);
|
|
109
|
+
});
|
|
110
|
+
return Promise.resolve(true);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public override saveFile(file: BlockSchema): Promise<boolean> {
|
|
114
|
+
this.stores.save(`file_${file.id}`, file);
|
|
115
|
+
return Promise.resolve(true);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public override saveHistory(history: HistorySchema): Promise<boolean> {
|
|
119
|
+
this.stores.save(`history_${history.id}`, history);
|
|
120
|
+
return Promise.resolve(true);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public override saveHistoryItem(
|
|
124
|
+
fId: string,
|
|
125
|
+
item: HistoryItem,
|
|
126
|
+
): Promise<boolean> {
|
|
127
|
+
this.stores.save(`history_${fId}_${item.id}`, item);
|
|
128
|
+
return Promise.resolve(true);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public override saveMaterials(
|
|
132
|
+
project: ProjectSchema,
|
|
133
|
+
materials: Map<string, MaterialDescription>,
|
|
134
|
+
): Promise<boolean> {
|
|
135
|
+
this.stores.save(`materials_${project.id}`, mapToObject(materials));
|
|
136
|
+
return Promise.resolve(true);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
public override saveProject(project: ProjectSchema): Promise<boolean> {
|
|
140
|
+
const model = new ProjectModel(project);
|
|
141
|
+
this.stores.save(`project_${model.id}`, model.toDsl());
|
|
142
|
+
return Promise.resolve(true);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as VueRouter from 'vue-router';
|
package/src/vue.ts
ADDED
package/src/vueuse.ts
ADDED
package/src/window.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
import mitt from 'mitt';
|
|
6
|
+
|
|
7
|
+
import { CryptoJS } from './crypto';
|
|
8
|
+
// import { Sortable } from './sortablejs';
|
|
9
|
+
import { Vue } from './vue';
|
|
10
|
+
import { VueRouter } from './vue-router';
|
|
11
|
+
import { VueUse } from './vueuse';
|
|
12
|
+
import { zod } from './zod';
|
|
13
|
+
import { VueLowlight, hljs } from './lowlight';
|
|
14
|
+
import { isPlainObject } from 'es-toolkit/compat';
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export const $mitt = mitt();
|
|
18
|
+
|
|
19
|
+
export { axios };
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 判断是否是 ES Module 命名空间对象 import * as xxx from 'xxx'
|
|
23
|
+
*/
|
|
24
|
+
export function isModuleObject(value: unknown): value is Record<string, any> {
|
|
25
|
+
if (value && isPlainObject(value)){
|
|
26
|
+
const tag = (value as any)[Symbol.toStringTag];
|
|
27
|
+
return tag === 'Module';
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function registerWindow<T extends any>(key: string, value: T) {
|
|
33
|
+
if (typeof window !== 'undefined' && !Reflect.has(window, key)) {
|
|
34
|
+
Object.defineProperty(window, key, {
|
|
35
|
+
get: () => value,
|
|
36
|
+
enumerable: true,
|
|
37
|
+
});
|
|
38
|
+
if (!isModuleObject(window[key])){
|
|
39
|
+
Object.defineProperty(window[key], '__esModule', { value: true });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
registerWindow('zod', zod);
|
|
45
|
+
registerWindow('Vue', Vue);
|
|
46
|
+
registerWindow('VueUse', VueUse);
|
|
47
|
+
// registerWindow('VueDemi', VueDemi);
|
|
48
|
+
registerWindow('VueRouter', VueRouter);
|
|
49
|
+
registerWindow('axios', axios);
|
|
50
|
+
registerWindow('CryptoJS', CryptoJS);
|
|
51
|
+
registerWindow('VueLowlight', VueLowlight);
|
|
52
|
+
registerWindow('hljs', hljs);
|
|
53
|
+
// registerWindow('Sortable', Sortable);
|
|
54
|
+
registerWindow('process', {
|
|
55
|
+
env: {
|
|
56
|
+
NODE_ENV: 'production',
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
|
package/src/zod.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as zod from 'zod';
|