@vtj/parser 0.15.0 → 0.15.2
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/index.cjs +15 -15
- package/dist/index.mjs +1032 -831
- package/package.json +3 -3
- package/types/version.d.ts +2 -2
- package/types/vue/scripts.d.ts +2 -1
- package/types/vue/template.d.ts +2 -1
- package/types/vue/utils.d.ts +9 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtj/parser",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.15.
|
|
4
|
+
"version": "0.15.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"低代码引擎",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"postcss": "~8.5.0",
|
|
32
32
|
"sass": "~1.97.1",
|
|
33
33
|
"@vtj/base": "~0.12.4",
|
|
34
|
-
"@vtj/coder": "~0.15.
|
|
35
|
-
"@vtj/core": "~0.15.
|
|
34
|
+
"@vtj/coder": "~0.15.2",
|
|
35
|
+
"@vtj/core": "~0.15.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@vtj/cli": "~0.12.18"
|
package/types/version.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2026, VTJ.PRO All rights reserved.
|
|
3
3
|
* @name @vtj/parser
|
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
5
|
-
* @version 0.
|
|
5
|
+
* @version 0.15.1
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
7
|
*/
|
|
8
|
-
export declare const version = "0.
|
|
8
|
+
export declare const version = "0.15.1";
|
package/types/vue/scripts.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlockState, JSFunction, BlockWatch, BlockProp, BlockEmit, BlockInject, DataSourceSchema, ProjectSchema } from '@vtj/core';
|
|
1
|
+
import { BlockState, JSFunction, BlockWatch, BlockProp, BlockEmit, BlockInject, DataSourceSchema, ProjectSchema, JSExpression } from '@vtj/core';
|
|
2
2
|
export interface ImportStatement {
|
|
3
3
|
from: string;
|
|
4
4
|
imports: string[] | string;
|
|
@@ -18,6 +18,7 @@ export interface ParseScriptsResult {
|
|
|
18
18
|
inject?: BlockInject[];
|
|
19
19
|
handlers?: Record<string, JSFunction>;
|
|
20
20
|
dataSources?: Record<string, DataSourceSchema>;
|
|
21
|
+
directives?: Record<string, JSExpression>;
|
|
21
22
|
errors: string[];
|
|
22
23
|
}
|
|
23
24
|
export declare function parseScripts(content: string, project: ProjectSchema): ParseScriptsResult;
|
package/types/vue/template.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodeSchema, BlockSlot, JSFunction, PlatformType } from '@vtj/core';
|
|
1
|
+
import { NodeSchema, JSExpression, BlockSlot, JSFunction, PlatformType } from '@vtj/core';
|
|
2
2
|
import { CSSRules } from './style';
|
|
3
3
|
import { ImportStatement } from './scripts';
|
|
4
4
|
export interface ParseTemplateOptions {
|
|
@@ -6,6 +6,7 @@ export interface ParseTemplateOptions {
|
|
|
6
6
|
imports?: ImportStatement[];
|
|
7
7
|
handlers?: Record<string, JSFunction>;
|
|
8
8
|
styles?: CSSRules;
|
|
9
|
+
directives?: Record<string, JSExpression>;
|
|
9
10
|
}
|
|
10
11
|
export declare function parseTemplate(id: string, name: string, content?: string, options?: ParseTemplateOptions): {
|
|
11
12
|
nodes: NodeSchema[];
|
package/types/vue/utils.d.ts
CHANGED
|
@@ -6,6 +6,15 @@ export interface ExpressionOptions {
|
|
|
6
6
|
libs: Record<string, string>;
|
|
7
7
|
members: string[];
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* 简化的字符串替换函数,遵循以下规则:
|
|
11
|
+
* 1. 字符串中的 key 不替换(包括模板字符串普通文本,但 ${key} 中的 key 要替换)
|
|
12
|
+
* 2. 对象属性访问 obj.key 不替换(. 前)
|
|
13
|
+
* 3. 变量声明(const/let/var/function 后)不替换
|
|
14
|
+
* 4. 对象属性名 {key: value} 或 {key} 不替换
|
|
15
|
+
* 5. 前后有单词字符(a-zA-Z0-9_$@-)不替换
|
|
16
|
+
* 6. 其他情况替换:赋值、函数调用、数组元素、模板表达式等
|
|
17
|
+
*/
|
|
9
18
|
export declare function replacer(content: string, key: string, to: string): string;
|
|
10
19
|
export declare function patchCode(content: string, id: string, options: ExpressionOptions): string;
|
|
11
20
|
export declare function getJSExpression(content: string): JSExpression;
|