@ts-graphviz/ast 0.0.0-pr956-20240225073457 → 0.0.0-pr956-20240225091623
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/CHANGELOG.md +2 -2
- package/package.json +42 -23
- package/src/ast.ts +0 -8
- package/src/builder/__snapshots__/create-element.test.ts.snap +0 -166
- package/src/builder/builder.test.ts +0 -36
- package/src/builder/builder.ts +0 -44
- package/src/builder/create-element.test.ts +0 -110
- package/src/builder/create-element.ts +0 -13
- package/src/builder/index.ts +0 -3
- package/src/builder/types.ts +0 -226
- package/src/dot-shim/index.ts +0 -2
- package/src/dot-shim/parser/__snapshots__/parse.test.ts.snap +0 -2613
- package/src/dot-shim/parser/dot.peggy +0 -396
- package/src/dot-shim/parser/index.ts +0 -1
- package/src/dot-shim/parser/parse.test.ts +0 -263
- package/src/dot-shim/parser/parse.ts +0 -121
- package/src/dot-shim/parser/peggy.options.json +0 -15
- package/src/dot-shim/printer/index.ts +0 -6
- package/src/dot-shim/printer/plugins/AttributeListPrintPlugin.ts +0 -22
- package/src/dot-shim/printer/plugins/AttributePrintPlugin.ts +0 -11
- package/src/dot-shim/printer/plugins/CommentPrintPlugin.ts +0 -40
- package/src/dot-shim/printer/plugins/DotPrintPlugin.ts +0 -12
- package/src/dot-shim/printer/plugins/EdgePrintPlugin.ts +0 -27
- package/src/dot-shim/printer/plugins/GraphPrintPlugin.ts +0 -32
- package/src/dot-shim/printer/plugins/LiteralPrintPlugin.ts +0 -24
- package/src/dot-shim/printer/plugins/NodePrintPlugin.ts +0 -24
- package/src/dot-shim/printer/plugins/NodeRefGroupPrintPlugin.ts +0 -17
- package/src/dot-shim/printer/plugins/NodeRefPrintPlugin.ts +0 -18
- package/src/dot-shim/printer/plugins/SubgraphPrintPlugin.ts +0 -27
- package/src/dot-shim/printer/plugins/index.ts +0 -26
- package/src/dot-shim/printer/plugins/utils/index.ts +0 -1
- package/src/dot-shim/printer/plugins/utils/tokens.ts +0 -51
- package/src/dot-shim/printer/printer.ts +0 -46
- package/src/dot-shim/printer/stringify.test.ts +0 -823
- package/src/dot-shim/printer/stringify.ts +0 -19
- package/src/dot-shim/printer/types.ts +0 -74
- package/src/model-shim/from-model/converter.ts +0 -43
- package/src/model-shim/from-model/from-model.ts +0 -19
- package/src/model-shim/from-model/index.ts +0 -3
- package/src/model-shim/from-model/plugins/AttributeListPlugin.ts +0 -19
- package/src/model-shim/from-model/plugins/EdgePlugin.ts +0 -140
- package/src/model-shim/from-model/plugins/GraphPlugin.ts +0 -36
- package/src/model-shim/from-model/plugins/NodePlugin.ts +0 -33
- package/src/model-shim/from-model/plugins/SubraphPlugin.ts +0 -28
- package/src/model-shim/from-model/plugins/index.ts +0 -13
- package/src/model-shim/from-model/plugins/utils/convert-attribute.ts +0 -47
- package/src/model-shim/from-model/plugins/utils/convert-cluster-children.ts +0 -44
- package/src/model-shim/from-model/plugins/utils/convert-comment.ts +0 -16
- package/src/model-shim/from-model/plugins/utils/index.ts +0 -3
- package/src/model-shim/from-model/types.ts +0 -62
- package/src/model-shim/index.ts +0 -2
- package/src/model-shim/to-model/converter.ts +0 -42
- package/src/model-shim/to-model/index.ts +0 -3
- package/src/model-shim/to-model/plugins/DotPlugin.ts +0 -25
- package/src/model-shim/to-model/plugins/EdgePlugin.ts +0 -26
- package/src/model-shim/to-model/plugins/GraphPlugin.ts +0 -15
- package/src/model-shim/to-model/plugins/NodePlugin.ts +0 -25
- package/src/model-shim/to-model/plugins/SubgraphPlugin.ts +0 -14
- package/src/model-shim/to-model/plugins/index.ts +0 -13
- package/src/model-shim/to-model/plugins/utils/apply-statments.ts +0 -96
- package/src/model-shim/to-model/plugins/utils/comment-holder.ts +0 -31
- package/src/model-shim/to-model/plugins/utils/convert-to-edge-target-tuple.ts +0 -21
- package/src/model-shim/to-model/to-model.test.ts +0 -34
- package/src/model-shim/to-model/to-model.ts +0 -16
- package/src/model-shim/to-model/types.ts +0 -71
- package/src/types.ts +0 -370
- package/tsconfig.json +0 -8
- package/typedoc.json +0 -4
- package/vite.config.ts +0 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @ts-graphviz/ast
|
|
2
2
|
|
|
3
|
-
## 0.0.0-pr956-
|
|
3
|
+
## 0.0.0-pr956-20240225091623
|
|
4
4
|
|
|
5
5
|
### Major Changes
|
|
6
6
|
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
### Patch Changes
|
|
10
10
|
|
|
11
11
|
- Updated dependencies [[`6b2f0e8`](https://github.com/ts-graphviz/ts-graphviz/commit/6b2f0e8349605b4fe0dd950147ba3a8285b24b24)]:
|
|
12
|
-
- @ts-graphviz/common@0.0.0-pr956-
|
|
12
|
+
- @ts-graphviz/common@0.0.0-pr956-20240225091623
|
package/package.json
CHANGED
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-graphviz/ast",
|
|
3
|
-
"version": "0.0.0-pr956-
|
|
3
|
+
"version": "0.0.0-pr956-20240225091623",
|
|
4
4
|
"description": "",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"homepage": "https://github.com/ts-graphviz/ts-graphviz#readme",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/ts-graphviz/ts-graphviz/issues"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/ts-graphviz/ts-graphviz.git",
|
|
13
|
+
"directory": "packages/ast"
|
|
14
|
+
},
|
|
15
|
+
"funding": [
|
|
16
|
+
{
|
|
17
|
+
"type": "github",
|
|
18
|
+
"url": "https://github.com/sponsors/ts-graphviz"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"type": "opencollective",
|
|
22
|
+
"url": "https://opencollective.com/ts-graphviz"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"license": "NIT",
|
|
26
|
+
"author": "",
|
|
5
27
|
"type": "module",
|
|
6
|
-
"main": "lib/ast.cjs",
|
|
7
|
-
"module": "lib/ast.js",
|
|
8
|
-
"types": "lib/ast.d.ts",
|
|
9
28
|
"exports": {
|
|
10
29
|
".": {
|
|
11
30
|
"require": {
|
|
@@ -19,24 +38,17 @@
|
|
|
19
38
|
},
|
|
20
39
|
"./package.json": "./package.json"
|
|
21
40
|
},
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
"keywords": [],
|
|
32
|
-
"author": "",
|
|
33
|
-
"license": "NIT",
|
|
34
|
-
"bugs": {
|
|
35
|
-
"url": "https://github.com/ts-graphviz/ts-graphviz/issues"
|
|
36
|
-
},
|
|
37
|
-
"homepage": "https://github.com/ts-graphviz/ts-graphviz#readme",
|
|
41
|
+
"main": "lib/ast.cjs",
|
|
42
|
+
"module": "lib/ast.js",
|
|
43
|
+
"types": "lib/ast.d.ts",
|
|
44
|
+
"files": [
|
|
45
|
+
"lib",
|
|
46
|
+
"README.md",
|
|
47
|
+
"CHANGELOG.md",
|
|
48
|
+
"LICENSE"
|
|
49
|
+
],
|
|
38
50
|
"dependencies": {
|
|
39
|
-
"@ts-graphviz/common": "^0.0.0-pr956-
|
|
51
|
+
"@ts-graphviz/common": "^0.0.0-pr956-20240225091623"
|
|
40
52
|
},
|
|
41
53
|
"devDependencies": {
|
|
42
54
|
"peggy": "^3.0.2",
|
|
@@ -45,8 +57,15 @@
|
|
|
45
57
|
"vite": "^5.1.3",
|
|
46
58
|
"vite-plugin-dts": "^3.7.2"
|
|
47
59
|
},
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=18"
|
|
62
|
+
},
|
|
63
|
+
"publishConfig": {
|
|
64
|
+
"access": "public",
|
|
65
|
+
"provenance": true
|
|
66
|
+
},
|
|
48
67
|
"scripts": {
|
|
49
|
-
"
|
|
50
|
-
"
|
|
68
|
+
"build": "vite build",
|
|
69
|
+
"codegen": "peggy --plugin ts-pegjs --extra-options-file src/dot-shim/parser/peggy.options.json -o src/dot-shim/parser/_parse.ts src/dot-shim/parser/dot.peggy"
|
|
51
70
|
}
|
|
52
71
|
}
|
package/src/ast.ts
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`createElement > Attribute 1`] = `
|
|
4
|
-
{
|
|
5
|
-
"children": [],
|
|
6
|
-
"key": {
|
|
7
|
-
"children": [],
|
|
8
|
-
"location": null,
|
|
9
|
-
"quoted": false,
|
|
10
|
-
"type": "Literal",
|
|
11
|
-
"value": "color",
|
|
12
|
-
},
|
|
13
|
-
"location": null,
|
|
14
|
-
"type": "Attribute",
|
|
15
|
-
"value": {
|
|
16
|
-
"children": [],
|
|
17
|
-
"location": null,
|
|
18
|
-
"quoted": false,
|
|
19
|
-
"type": "Literal",
|
|
20
|
-
"value": "red",
|
|
21
|
-
},
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
|
-
exports[`createElement > Coment 1`] = `
|
|
26
|
-
{
|
|
27
|
-
"children": [],
|
|
28
|
-
"kind": "Macro",
|
|
29
|
-
"location": null,
|
|
30
|
-
"type": "Comment",
|
|
31
|
-
"value": "This is comment",
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
exports[`createElement > Dot 1`] = `
|
|
36
|
-
{
|
|
37
|
-
"children": [],
|
|
38
|
-
"location": null,
|
|
39
|
-
"type": "Dot",
|
|
40
|
-
}
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
exports[`createElement > Edge 1`] = `
|
|
44
|
-
{
|
|
45
|
-
"children": [],
|
|
46
|
-
"location": null,
|
|
47
|
-
"targets": [
|
|
48
|
-
{
|
|
49
|
-
"children": [],
|
|
50
|
-
"id": {
|
|
51
|
-
"children": [],
|
|
52
|
-
"location": null,
|
|
53
|
-
"quoted": true,
|
|
54
|
-
"type": "Literal",
|
|
55
|
-
"value": "a",
|
|
56
|
-
},
|
|
57
|
-
"location": null,
|
|
58
|
-
"type": "NodeRef",
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
"children": [],
|
|
62
|
-
"id": {
|
|
63
|
-
"children": [],
|
|
64
|
-
"location": null,
|
|
65
|
-
"quoted": true,
|
|
66
|
-
"type": "Literal",
|
|
67
|
-
"value": "b",
|
|
68
|
-
},
|
|
69
|
-
"location": null,
|
|
70
|
-
"type": "NodeRef",
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
"type": "Edge",
|
|
74
|
-
}
|
|
75
|
-
`;
|
|
76
|
-
|
|
77
|
-
exports[`createElement > Graph 1`] = `
|
|
78
|
-
{
|
|
79
|
-
"children": [],
|
|
80
|
-
"directed": true,
|
|
81
|
-
"location": null,
|
|
82
|
-
"strict": false,
|
|
83
|
-
"type": "Graph",
|
|
84
|
-
}
|
|
85
|
-
`;
|
|
86
|
-
|
|
87
|
-
exports[`createElement > Literal 1`] = `
|
|
88
|
-
{
|
|
89
|
-
"children": [],
|
|
90
|
-
"location": null,
|
|
91
|
-
"quoted": true,
|
|
92
|
-
"type": "Literal",
|
|
93
|
-
"value": "literal value",
|
|
94
|
-
}
|
|
95
|
-
`;
|
|
96
|
-
|
|
97
|
-
exports[`createElement > Node 1`] = `
|
|
98
|
-
{
|
|
99
|
-
"children": [],
|
|
100
|
-
"id": {
|
|
101
|
-
"children": [],
|
|
102
|
-
"location": null,
|
|
103
|
-
"quoted": false,
|
|
104
|
-
"type": "Literal",
|
|
105
|
-
"value": "node_id",
|
|
106
|
-
},
|
|
107
|
-
"location": null,
|
|
108
|
-
"type": "Node",
|
|
109
|
-
}
|
|
110
|
-
`;
|
|
111
|
-
|
|
112
|
-
exports[`createElement > NodeRef 1`] = `
|
|
113
|
-
{
|
|
114
|
-
"children": [],
|
|
115
|
-
"id": {
|
|
116
|
-
"children": [],
|
|
117
|
-
"location": null,
|
|
118
|
-
"quoted": true,
|
|
119
|
-
"type": "Literal",
|
|
120
|
-
"value": "b",
|
|
121
|
-
},
|
|
122
|
-
"location": null,
|
|
123
|
-
"type": "NodeRef",
|
|
124
|
-
}
|
|
125
|
-
`;
|
|
126
|
-
|
|
127
|
-
exports[`createElement > NodeRefGroup 1`] = `
|
|
128
|
-
{
|
|
129
|
-
"children": [
|
|
130
|
-
{
|
|
131
|
-
"children": [],
|
|
132
|
-
"id": {
|
|
133
|
-
"children": [],
|
|
134
|
-
"location": null,
|
|
135
|
-
"quoted": true,
|
|
136
|
-
"type": "Literal",
|
|
137
|
-
"value": "a",
|
|
138
|
-
},
|
|
139
|
-
"location": null,
|
|
140
|
-
"type": "NodeRef",
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
"children": [],
|
|
144
|
-
"id": {
|
|
145
|
-
"children": [],
|
|
146
|
-
"location": null,
|
|
147
|
-
"quoted": true,
|
|
148
|
-
"type": "Literal",
|
|
149
|
-
"value": "b",
|
|
150
|
-
},
|
|
151
|
-
"location": null,
|
|
152
|
-
"type": "NodeRef",
|
|
153
|
-
},
|
|
154
|
-
],
|
|
155
|
-
"location": null,
|
|
156
|
-
"type": "NodeRefGroup",
|
|
157
|
-
}
|
|
158
|
-
`;
|
|
159
|
-
|
|
160
|
-
exports[`createElement > Subgraph 1`] = `
|
|
161
|
-
{
|
|
162
|
-
"children": [],
|
|
163
|
-
"location": null,
|
|
164
|
-
"type": "Subgraph",
|
|
165
|
-
}
|
|
166
|
-
`;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { Builder } from './builder.js';
|
|
3
|
-
|
|
4
|
-
describe('Builder', () => {
|
|
5
|
-
test('should create an ASTNode with specified properties', () => {
|
|
6
|
-
const location = {
|
|
7
|
-
start: {
|
|
8
|
-
offset: 0,
|
|
9
|
-
line: 1,
|
|
10
|
-
column: 1,
|
|
11
|
-
},
|
|
12
|
-
end: {
|
|
13
|
-
offset: 3,
|
|
14
|
-
line: 1,
|
|
15
|
-
column: 3,
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
const builder = new Builder({
|
|
19
|
-
locationFunction: () => location,
|
|
20
|
-
});
|
|
21
|
-
const type = 'TestType' as any;
|
|
22
|
-
const props = { prop1: 'test1', prop2: 'test2' };
|
|
23
|
-
const children = [
|
|
24
|
-
{ type: 'TestType', props: { prop1: 'test1', prop2: 'test2' } },
|
|
25
|
-
] as any[];
|
|
26
|
-
const expectedResult = {
|
|
27
|
-
type,
|
|
28
|
-
...props,
|
|
29
|
-
children,
|
|
30
|
-
location,
|
|
31
|
-
};
|
|
32
|
-
expect(builder.createElement(type, props, children)).toStrictEqual(
|
|
33
|
-
expectedResult,
|
|
34
|
-
);
|
|
35
|
-
});
|
|
36
|
-
});
|
package/src/builder/builder.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { ASTChildNode, ASTNode, FileRange } from '../types.js';
|
|
2
|
-
import { ASTBuilder, BuilderOptions } from './types.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Builder is an ASTBuilder that provides a method to create an ASTNode.
|
|
6
|
-
*
|
|
7
|
-
* @group Create AST
|
|
8
|
-
*/
|
|
9
|
-
export class Builder implements ASTBuilder {
|
|
10
|
-
/**
|
|
11
|
-
* Get the current file range or null
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
private getLocation(): FileRange | null {
|
|
15
|
-
return this.options?.locationFunction?.() ?? null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Constructor of Builder
|
|
20
|
-
* @param options - Options to initialize Builder
|
|
21
|
-
*/
|
|
22
|
-
constructor(private options?: Partial<BuilderOptions>) {}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Create an {@link ASTNode} of the specified type
|
|
26
|
-
*
|
|
27
|
-
* @param type - Type of the {@link ASTNode}
|
|
28
|
-
* @param props - Properties of the {@link ASTNode}
|
|
29
|
-
* @param children - Children of the {@link ASTNode}
|
|
30
|
-
* @returns An {@link ASTNode}
|
|
31
|
-
*/
|
|
32
|
-
public createElement<T extends ASTNode>(
|
|
33
|
-
type: T['type'],
|
|
34
|
-
props: any,
|
|
35
|
-
children: ASTChildNode<T>[] = [],
|
|
36
|
-
): T {
|
|
37
|
-
return {
|
|
38
|
-
location: this.getLocation(),
|
|
39
|
-
...props,
|
|
40
|
-
type,
|
|
41
|
-
children,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { createElement } from './create-element.js';
|
|
3
|
-
|
|
4
|
-
describe('createElement', () => {
|
|
5
|
-
test('Dot', () => {
|
|
6
|
-
const ast = createElement('Dot', {}, []);
|
|
7
|
-
expect(ast).toMatchSnapshot();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
test('Graph', () => {
|
|
11
|
-
const ast = createElement('Graph', {
|
|
12
|
-
strict: false,
|
|
13
|
-
directed: true,
|
|
14
|
-
});
|
|
15
|
-
expect(ast).toMatchSnapshot();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test('Node', () => {
|
|
19
|
-
const ast = createElement('Node', {
|
|
20
|
-
id: createElement('Literal', {
|
|
21
|
-
value: 'node_id',
|
|
22
|
-
quoted: false,
|
|
23
|
-
}),
|
|
24
|
-
});
|
|
25
|
-
expect(ast).toMatchSnapshot();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test('Edge', () => {
|
|
29
|
-
const ast = createElement('Edge', {
|
|
30
|
-
targets: [
|
|
31
|
-
createElement('NodeRef', {
|
|
32
|
-
id: createElement('Literal', {
|
|
33
|
-
value: 'a',
|
|
34
|
-
quoted: true,
|
|
35
|
-
}),
|
|
36
|
-
}),
|
|
37
|
-
createElement('NodeRef', {
|
|
38
|
-
id: createElement('Literal', {
|
|
39
|
-
value: 'b',
|
|
40
|
-
quoted: true,
|
|
41
|
-
}),
|
|
42
|
-
}),
|
|
43
|
-
],
|
|
44
|
-
});
|
|
45
|
-
expect(ast).toMatchSnapshot();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('NodeRef', () => {
|
|
49
|
-
const ast = createElement('NodeRef', {
|
|
50
|
-
id: createElement('Literal', {
|
|
51
|
-
value: 'b',
|
|
52
|
-
quoted: true,
|
|
53
|
-
}),
|
|
54
|
-
});
|
|
55
|
-
expect(ast).toMatchSnapshot();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test('NodeRefGroup', () => {
|
|
59
|
-
const ast = createElement('NodeRefGroup', {}, [
|
|
60
|
-
createElement('NodeRef', {
|
|
61
|
-
id: createElement('Literal', {
|
|
62
|
-
value: 'a',
|
|
63
|
-
quoted: true,
|
|
64
|
-
}),
|
|
65
|
-
}),
|
|
66
|
-
createElement('NodeRef', {
|
|
67
|
-
id: createElement('Literal', {
|
|
68
|
-
value: 'b',
|
|
69
|
-
quoted: true,
|
|
70
|
-
}),
|
|
71
|
-
}),
|
|
72
|
-
]);
|
|
73
|
-
expect(ast).toMatchSnapshot();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test('Subgraph', () => {
|
|
77
|
-
const ast = createElement('Subgraph', {}, []);
|
|
78
|
-
expect(ast).toMatchSnapshot();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test('Literal', () => {
|
|
82
|
-
const ast = createElement('Literal', {
|
|
83
|
-
value: 'literal value',
|
|
84
|
-
quoted: true,
|
|
85
|
-
});
|
|
86
|
-
expect(ast).toMatchSnapshot();
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test('Coment', () => {
|
|
90
|
-
const ast = createElement('Comment', {
|
|
91
|
-
kind: 'Macro',
|
|
92
|
-
value: 'This is comment',
|
|
93
|
-
});
|
|
94
|
-
expect(ast).toMatchSnapshot();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
test('Attribute', () => {
|
|
98
|
-
const ast = createElement('Attribute', {
|
|
99
|
-
key: createElement('Literal', {
|
|
100
|
-
value: 'color',
|
|
101
|
-
quoted: false,
|
|
102
|
-
}),
|
|
103
|
-
value: createElement('Literal', {
|
|
104
|
-
value: 'red',
|
|
105
|
-
quoted: false,
|
|
106
|
-
}),
|
|
107
|
-
});
|
|
108
|
-
expect(ast).toMatchSnapshot();
|
|
109
|
-
});
|
|
110
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Builder } from './builder.js';
|
|
2
|
-
import { CreateElement } from './types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Create an {@link ASTNode} of the specified type
|
|
5
|
-
*
|
|
6
|
-
* @param type - Type of the {@link ASTNode}
|
|
7
|
-
* @param props - Properties of the {@link ASTNode}
|
|
8
|
-
* @param children - Children of the {@link ASTNode}
|
|
9
|
-
* @group Create AST
|
|
10
|
-
* @returns An {@link ASTNode}
|
|
11
|
-
*/
|
|
12
|
-
export const createElement: CreateElement =
|
|
13
|
-
Builder.prototype.createElement.bind(new Builder());
|
package/src/builder/index.ts
DELETED