@vtj/renderer 0.7.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.
- package/LICENSE +21 -0
- package/dist/index.cjs +10 -0
- package/dist/index.mjs +1130 -0
- package/package.json +42 -0
- package/types/constants.d.ts +32 -0
- package/types/hooks/index.d.ts +1 -0
- package/types/hooks/mask.d.ts +7 -0
- package/types/index.d.ts +7 -0
- package/types/provider/apis.d.ts +5 -0
- package/types/provider/defaults.d.ts +2 -0
- package/types/provider/index.d.ts +2 -0
- package/types/provider/page.d.ts +10 -0
- package/types/provider/provider.d.ts +53 -0
- package/types/render/block.d.ts +20 -0
- package/types/render/context.d.ts +46 -0
- package/types/render/index.d.ts +4 -0
- package/types/render/loader.d.ts +10 -0
- package/types/render/node.d.ts +6 -0
- package/types/services/base.d.ts +20 -0
- package/types/services/index.d.ts +4 -0
- package/types/services/local.d.ts +16 -0
- package/types/services/memory.d.ts +22 -0
- package/types/services/storage.d.ts +16 -0
- package/types/utils/deps.d.ts +15 -0
- package/types/utils/index.d.ts +4 -0
- package/types/utils/logger.d.ts +7 -0
- package/types/utils/parser.d.ts +7 -0
- package/types/utils/util.d.ts +5 -0
- package/types/version.d.ts +8 -0
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vtj/renderer",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.7.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "vue-tsc && vite build",
|
|
8
|
+
"test": "vitest run",
|
|
9
|
+
"vitest": "vitest",
|
|
10
|
+
"coverage": "vitest run --coverage"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@vtj/core": "^0.7.0",
|
|
14
|
+
"@vtj/icons": "^0.7.0",
|
|
15
|
+
"@vtj/ui": "^0.7.0",
|
|
16
|
+
"@vtj/utils": "^0.7.0",
|
|
17
|
+
"zen-logger": "~1.1.4"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@vtj/cli": "^0.7.0",
|
|
21
|
+
"vue": "~3.4.14",
|
|
22
|
+
"vue-router": "~4.2.5"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./types/index.d.ts",
|
|
27
|
+
"import": "./dist/index.mjs",
|
|
28
|
+
"require": "./dist/index.cjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"main": "./dist/index.cjs",
|
|
32
|
+
"module": "./dist/index.mjs",
|
|
33
|
+
"types": "./types/index.d.ts",
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"types"
|
|
37
|
+
],
|
|
38
|
+
"gitHead": "b65d1b19322cbd0721173d094db1b5ece018d980",
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type BlockPropDataType } from '@vtj/core';
|
|
2
|
+
export declare enum ContextMode {
|
|
3
|
+
/**
|
|
4
|
+
* 运行时
|
|
5
|
+
*/
|
|
6
|
+
Runtime = "Runtime",
|
|
7
|
+
/**
|
|
8
|
+
* 设计模式
|
|
9
|
+
*/
|
|
10
|
+
Design = "Design",
|
|
11
|
+
/**
|
|
12
|
+
* 源码模式
|
|
13
|
+
*/
|
|
14
|
+
Raw = "Raw",
|
|
15
|
+
/**
|
|
16
|
+
* 虚拟节点
|
|
17
|
+
*/
|
|
18
|
+
VNode = "VNode"
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* vue 组件实例提供的属性名
|
|
22
|
+
*/
|
|
23
|
+
export declare const CONTEXT_HOST: string[];
|
|
24
|
+
export declare const LIFE_CYCLES_LIST: string[];
|
|
25
|
+
/**
|
|
26
|
+
* 内置指令
|
|
27
|
+
*/
|
|
28
|
+
export declare const BUILDIN_DIRECTIVES: string[];
|
|
29
|
+
/**
|
|
30
|
+
* 数据类型
|
|
31
|
+
*/
|
|
32
|
+
export declare const DATA_TYPES: Record<BlockPropDataType, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './mask';
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ApiSchema } from '@vtj/core';
|
|
2
|
+
import { type IRequestConfig } from '@vtj/utils';
|
|
3
|
+
import { type ProvideAdapter } from './provider';
|
|
4
|
+
export declare function createSchemaApi(schema: ApiSchema, adapter: ProvideAdapter): ((query?: Record<string, any>) => Promise<any>) | ((data: any, opts?: IRequestConfig) => Promise<any>);
|
|
5
|
+
export declare function createSchemaApis(schema: ApiSchema[] | undefined, adapter: ProvideAdapter): Record<string, any>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LocationQuery } from 'vue-router';
|
|
2
|
+
import { PageFile } from '@vtj/core';
|
|
3
|
+
import { Provider } from './provider';
|
|
4
|
+
import { DefineComponent, ComponentOptionsMixin, PublicProps, ExtractPropTypes } from 'vue';
|
|
5
|
+
export declare const PageContainer: DefineComponent<{}, {
|
|
6
|
+
provider: Provider;
|
|
7
|
+
component: any;
|
|
8
|
+
file: PageFile | null;
|
|
9
|
+
query: LocationQuery;
|
|
10
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<{}>>, {}, {}>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type App, type InjectionKey } from 'vue';
|
|
2
|
+
import { type Router } from 'vue-router';
|
|
3
|
+
import { type ProjectSchema, type PageFile, type BlockFile, type Service, type BlockSchema, Base } from '@vtj/core';
|
|
4
|
+
import { type IStaticRequest, type Jsonp } from '@vtj/utils';
|
|
5
|
+
import { ContextMode } from '../constants';
|
|
6
|
+
export declare const providerKey: InjectionKey<Provider>;
|
|
7
|
+
export interface ProviderOptions {
|
|
8
|
+
service: Service;
|
|
9
|
+
project?: Partial<ProjectSchema>;
|
|
10
|
+
modules?: Record<string, () => Promise<any>>;
|
|
11
|
+
mode?: ContextMode;
|
|
12
|
+
adapter?: Partial<ProvideAdapter>;
|
|
13
|
+
router?: Router;
|
|
14
|
+
dependencies?: Record<string, () => Promise<any>>;
|
|
15
|
+
materials?: Record<string, () => Promise<any>>;
|
|
16
|
+
globals?: Record<string, any>;
|
|
17
|
+
}
|
|
18
|
+
export interface ProvideAdapter {
|
|
19
|
+
request: IStaticRequest;
|
|
20
|
+
jsonp: Jsonp;
|
|
21
|
+
}
|
|
22
|
+
export declare class Provider extends Base {
|
|
23
|
+
mode: ContextMode;
|
|
24
|
+
globals: Record<string, any>;
|
|
25
|
+
modules: Record<string, () => Promise<any>>;
|
|
26
|
+
adapter: ProvideAdapter;
|
|
27
|
+
apis: Record<string, (...args: any[]) => Promise<any>>;
|
|
28
|
+
dependencies: Record<string, () => Promise<any>>;
|
|
29
|
+
materials: Record<string, () => Promise<any>>;
|
|
30
|
+
library: Record<string, any>;
|
|
31
|
+
service: Service;
|
|
32
|
+
project: ProjectSchema | null;
|
|
33
|
+
components: Record<string, any>;
|
|
34
|
+
private router;
|
|
35
|
+
constructor(options: ProviderOptions);
|
|
36
|
+
load(project: ProjectSchema): Promise<void>;
|
|
37
|
+
private initRouter;
|
|
38
|
+
install(app: App): void;
|
|
39
|
+
getFile(id: string): PageFile | BlockFile | null;
|
|
40
|
+
getPage(id: string): PageFile | null;
|
|
41
|
+
getHomepage(): PageFile | null;
|
|
42
|
+
getDsl(id: string): Promise<BlockSchema | null>;
|
|
43
|
+
getRenderComponent(id: string): Promise<any>;
|
|
44
|
+
}
|
|
45
|
+
export declare function createProvider(options: ProviderOptions): {
|
|
46
|
+
provider: Provider;
|
|
47
|
+
onReady: (callback: () => void) => void;
|
|
48
|
+
};
|
|
49
|
+
export interface UseProviderOptions {
|
|
50
|
+
id?: string;
|
|
51
|
+
version?: string;
|
|
52
|
+
}
|
|
53
|
+
export declare function useProvider(options?: UseProviderOptions): Provider;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type BlockSchema, type DataSourceSchema } from '@vtj/core';
|
|
2
|
+
import { ContextMode } from '../constants';
|
|
3
|
+
import { Context } from './context';
|
|
4
|
+
import { type BlockLoader } from './loader';
|
|
5
|
+
export type DataSourceHandler = (...args: any[]) => Promise<any>;
|
|
6
|
+
export interface CreateRendererOptions {
|
|
7
|
+
Vue?: any;
|
|
8
|
+
mode?: ContextMode;
|
|
9
|
+
dsl?: BlockSchema;
|
|
10
|
+
components?: Record<string, any>;
|
|
11
|
+
libs?: Record<string, any>;
|
|
12
|
+
apis?: Record<string, any>;
|
|
13
|
+
loader?: BlockLoader;
|
|
14
|
+
window?: Window;
|
|
15
|
+
}
|
|
16
|
+
export declare function createRenderer(options: CreateRendererOptions): {
|
|
17
|
+
renderer: any;
|
|
18
|
+
context: Context;
|
|
19
|
+
};
|
|
20
|
+
export declare function createDataSources(dataSources: Record<string, DataSourceSchema>, context: Context): Record<string, DataSourceHandler>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ContextMode } from '../constants';
|
|
2
|
+
import { type BlockSchema, type JSFunction, type JSExpression } from '@vtj/core';
|
|
3
|
+
export interface ContextOptions {
|
|
4
|
+
mode: ContextMode;
|
|
5
|
+
dsl?: BlockSchema;
|
|
6
|
+
attrs?: ContextAttrs;
|
|
7
|
+
}
|
|
8
|
+
export interface ContextAttrs {
|
|
9
|
+
$components?: Record<string, any>;
|
|
10
|
+
$libs?: Record<string, any>;
|
|
11
|
+
$apis?: Record<string, any>;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}
|
|
14
|
+
export declare class Context {
|
|
15
|
+
__id: string | null;
|
|
16
|
+
__mode: ContextMode;
|
|
17
|
+
__instance: any | null;
|
|
18
|
+
__contextRefs: Record<string, Context>;
|
|
19
|
+
__refs: Record<string, any>;
|
|
20
|
+
context: Record<string, any>;
|
|
21
|
+
state: Record<string, any>;
|
|
22
|
+
$props: Record<string, any>;
|
|
23
|
+
$refs: Record<string, any>;
|
|
24
|
+
$el: any;
|
|
25
|
+
$emit: any;
|
|
26
|
+
$nextTick: any;
|
|
27
|
+
$parent: any;
|
|
28
|
+
$root: any;
|
|
29
|
+
$attrs: any;
|
|
30
|
+
$slots: any;
|
|
31
|
+
$watch: any;
|
|
32
|
+
$options: any;
|
|
33
|
+
$forceUpdate: any;
|
|
34
|
+
$components: Record<string, any>;
|
|
35
|
+
$libs: Record<string, any>;
|
|
36
|
+
$apis: Record<string, any>;
|
|
37
|
+
private __transform;
|
|
38
|
+
constructor(options: ContextOptions);
|
|
39
|
+
setup(attrs: Record<string, any>, Vue?: any): void;
|
|
40
|
+
private __proxy;
|
|
41
|
+
private __cleanup;
|
|
42
|
+
__parseFunction(code?: JSFunction): Function | undefined;
|
|
43
|
+
__parseExpression(code?: JSExpression | JSFunction): any;
|
|
44
|
+
__ref(id?: string | null, ref?: string | Function): ((el: any) => any) | undefined;
|
|
45
|
+
__clone(context?: Record<string, any>): Context;
|
|
46
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DefineComponent } from 'vue';
|
|
2
|
+
import type { NodeFrom, BlockSchema } from '@vtj/core';
|
|
3
|
+
import { type CreateRendererOptions } from './block';
|
|
4
|
+
export type BlockLoader = (name: string, from?: NodeFrom, Vue?: any) => string | DefineComponent;
|
|
5
|
+
export declare const defaultLoader: BlockLoader;
|
|
6
|
+
export interface CreateLoaderOptions {
|
|
7
|
+
getDsl: (id: string) => Promise<BlockSchema | null>;
|
|
8
|
+
options: Partial<CreateRendererOptions>;
|
|
9
|
+
}
|
|
10
|
+
export declare function createLoader(opts: CreateLoaderOptions): BlockLoader;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { VNode } from 'vue';
|
|
2
|
+
import { type NodeSchema, type NodeModifiers } from '@vtj/core';
|
|
3
|
+
import { type Context } from './context';
|
|
4
|
+
import { type BlockLoader } from './loader';
|
|
5
|
+
export declare function nodeRender(dsl: NodeSchema, context: Context, Vue?: any, loader?: BlockLoader): VNode | VNode[] | null;
|
|
6
|
+
export declare function getModifiers(modifiers?: NodeModifiers, isToString?: boolean): string[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ProjectSchema, type PageFile, type BlockFile, type BlockSchema, type MaterialDescription, type HistorySchema, type HistoryItem, type Service } from '@vtj/core';
|
|
2
|
+
export declare class BaseService implements Service {
|
|
3
|
+
protected api: (type: string, data: any) => Promise<any>;
|
|
4
|
+
constructor();
|
|
5
|
+
init(project: ProjectSchema): Promise<ProjectSchema>;
|
|
6
|
+
saveProject(project: ProjectSchema): Promise<boolean>;
|
|
7
|
+
saveMaterials(project: ProjectSchema, materials: Map<string, MaterialDescription>): Promise<boolean>;
|
|
8
|
+
saveFile(file: BlockSchema): Promise<boolean>;
|
|
9
|
+
getFile(id: string): Promise<BlockSchema>;
|
|
10
|
+
removeFile(id: string): Promise<boolean>;
|
|
11
|
+
saveHistory(history: HistorySchema): Promise<boolean>;
|
|
12
|
+
removeHistory(id: string): Promise<boolean>;
|
|
13
|
+
getHistory(id: string): Promise<HistorySchema>;
|
|
14
|
+
getHistoryItem(fId: string, id: string): Promise<HistoryItem>;
|
|
15
|
+
saveHistoryItem(fId: string, item: HistoryItem): Promise<boolean>;
|
|
16
|
+
removeHistoryItem(fId: string, ids: string[]): Promise<boolean>;
|
|
17
|
+
publish(project: ProjectSchema): Promise<boolean>;
|
|
18
|
+
publishFile(project: ProjectSchema, file: PageFile | BlockFile): Promise<boolean>;
|
|
19
|
+
getRaw(project: ProjectSchema, dsl: BlockSchema): Promise<string>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ProjectSchema, type BlockSchema, type HistorySchema, type HistoryItem, type MaterialDescription } from '@vtj/core';
|
|
2
|
+
import { BaseService } from './base';
|
|
3
|
+
export declare class LocalService extends BaseService {
|
|
4
|
+
init(project: ProjectSchema): Promise<ProjectSchema>;
|
|
5
|
+
saveProject(project: ProjectSchema): Promise<boolean>;
|
|
6
|
+
saveMaterials(project: ProjectSchema, materials: Map<string, MaterialDescription>): Promise<boolean>;
|
|
7
|
+
saveFile(file: BlockSchema): Promise<boolean>;
|
|
8
|
+
getFile(id: string): Promise<BlockSchema>;
|
|
9
|
+
removeFile(id: string): Promise<boolean>;
|
|
10
|
+
saveHistory(history: HistorySchema): Promise<boolean>;
|
|
11
|
+
removeHistory(id: string): Promise<boolean>;
|
|
12
|
+
getHistory(id: string): Promise<HistorySchema>;
|
|
13
|
+
getHistoryItem(fId: string, id: string): Promise<HistoryItem>;
|
|
14
|
+
saveHistoryItem(fId: string, item: HistoryItem): Promise<boolean>;
|
|
15
|
+
removeHistoryItem(fId: string, ids: string[]): Promise<boolean>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ProjectSchema, type BlockSchema, type HistorySchema, type HistoryItem, type MaterialDescription } from '@vtj/core';
|
|
2
|
+
import { BaseService } from './base';
|
|
3
|
+
export declare class MemoryService extends BaseService {
|
|
4
|
+
private projects;
|
|
5
|
+
private materials;
|
|
6
|
+
private files;
|
|
7
|
+
private histories;
|
|
8
|
+
private historyItems;
|
|
9
|
+
init(project: ProjectSchema): Promise<ProjectSchema>;
|
|
10
|
+
saveProject(project: ProjectSchema): Promise<boolean>;
|
|
11
|
+
saveMaterials(project: ProjectSchema, materials: Map<string, MaterialDescription>): Promise<boolean>;
|
|
12
|
+
saveFile(file: BlockSchema): Promise<boolean>;
|
|
13
|
+
getFile(id: string): Promise<BlockSchema>;
|
|
14
|
+
removeFile(id: string): Promise<boolean>;
|
|
15
|
+
saveHistory(history: HistorySchema): Promise<boolean>;
|
|
16
|
+
removeHistory(id: string): Promise<boolean>;
|
|
17
|
+
getHistory(id: string): Promise<HistorySchema>;
|
|
18
|
+
getHistoryItem(fId: string, id: string): Promise<HistoryItem>;
|
|
19
|
+
saveHistoryItem(fId: string, item: HistoryItem): Promise<boolean>;
|
|
20
|
+
removeHistoryItem(fId: string, ids: string[]): Promise<boolean>;
|
|
21
|
+
}
|
|
22
|
+
export declare function createMemoryService(): MemoryService;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ProjectSchema, type BlockSchema, type HistorySchema, type HistoryItem, type MaterialDescription } from '@vtj/core';
|
|
2
|
+
import { BaseService } from './base';
|
|
3
|
+
export declare class StorageService extends BaseService {
|
|
4
|
+
init(project: ProjectSchema): Promise<ProjectSchema>;
|
|
5
|
+
saveProject(project: ProjectSchema): Promise<boolean>;
|
|
6
|
+
saveMaterials(project: ProjectSchema, materials: Map<string, MaterialDescription>): Promise<boolean>;
|
|
7
|
+
saveFile(file: BlockSchema): Promise<boolean>;
|
|
8
|
+
getFile(id: string): Promise<BlockSchema>;
|
|
9
|
+
removeFile(id: string): Promise<boolean>;
|
|
10
|
+
saveHistory(history: HistorySchema): Promise<boolean>;
|
|
11
|
+
removeHistory(id: string): Promise<boolean>;
|
|
12
|
+
getHistory(id: string): Promise<HistorySchema>;
|
|
13
|
+
getHistoryItem(fId: string, id: string): Promise<HistoryItem>;
|
|
14
|
+
saveHistoryItem(fId: string, item: HistoryItem): Promise<boolean>;
|
|
15
|
+
removeHistoryItem(fId: string, ids: string[]): Promise<boolean>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Dependencie, MaterialDescription } from '@vtj/core';
|
|
2
|
+
export declare function isCSSUrl(url: string): boolean;
|
|
3
|
+
export declare function isJSUrl(url: string): boolean;
|
|
4
|
+
export declare function createAssetScripts(scripts: string[]): string;
|
|
5
|
+
export declare function createAssetsCss(css?: string[]): string;
|
|
6
|
+
export declare function parseDeps(deps: Dependencie[]): {
|
|
7
|
+
scripts: string[];
|
|
8
|
+
css: string[];
|
|
9
|
+
materials: string[];
|
|
10
|
+
libraryExports: string[];
|
|
11
|
+
materialExports: string[];
|
|
12
|
+
materialMapLibrary: Record<string, string>;
|
|
13
|
+
libraryMap: Record<string, string[]>;
|
|
14
|
+
};
|
|
15
|
+
export declare function getRawComponent(desc: MaterialDescription, lib: any): any;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { JSExpression, JSFunction } from '@vtj/core';
|
|
2
|
+
export declare function parseExpression(str: JSExpression | JSFunction, self: any, thisRequired?: boolean, throwError?: boolean): any;
|
|
3
|
+
export declare function parseFunction(str: JSFunction, self: any, thisRequired?: boolean, throwError?: boolean): Function;
|
|
4
|
+
export declare function isJSExpression(data: any): data is JSExpression;
|
|
5
|
+
export declare function isJSFunction(x: any): x is JSFunction;
|
|
6
|
+
export declare function isJSCode(data: unknown): data is JSExpression | JSFunction;
|
|
7
|
+
export declare function JSCodeToString(data: unknown): string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Plugin } from 'vue';
|
|
2
|
+
export declare function toString(value: any): string;
|
|
3
|
+
export declare function adoptedStyleSheets(global: Window, id: string, css: string): void;
|
|
4
|
+
export declare function loadCss(id: string, url: string): Promise<void>;
|
|
5
|
+
export declare function isVuePlugin(value: unknown): value is Plugin;
|