@handlebars/parser 1.0.0 → 1.1.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/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## v1.1.0 (2020-09-18)
2
+
3
+ #### :rocket: Enhancement
4
+ * [#2](https://github.com/handlebars-lang/handlebars-parser/pull/2) [FEAT] Adds types ([@pzuraq](https://github.com/pzuraq))
5
+
6
+ #### Committers: 1
7
+ - Chris Garrett ([@pzuraq](https://github.com/pzuraq))
8
+
9
+
1
10
  ## v1.0.0 (2020-09-14)
2
11
 
3
12
  #### :rocket: Enhancement
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@handlebars/parser",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "The parser for the Handlebars language",
5
5
  "homepage": "https://github.com/handlebars-lang/handlebars-parser#readme",
6
6
  "bugs": {
@@ -14,6 +14,7 @@
14
14
  "author": "",
15
15
  "main": "dist/cjs/index.js",
16
16
  "module": "dist/esm/index.js",
17
+ "types": "types/index.d.ts",
17
18
  "scripts": {
18
19
  "lint": "eslint .",
19
20
  "prepublishOnly": "npm run build",
package/types/ast.d.ts ADDED
@@ -0,0 +1,144 @@
1
+ export interface Node {
2
+ type: string;
3
+ loc: SourceLocation;
4
+ }
5
+
6
+ export interface SourceLocation {
7
+ source: string;
8
+ start: Position;
9
+ end: Position;
10
+ }
11
+
12
+ export interface Position {
13
+ line: number;
14
+ column: number;
15
+ }
16
+
17
+ export interface Program extends Node {
18
+ body: Statement[];
19
+ blockParams: string[];
20
+ }
21
+
22
+ export interface Statement extends Node {}
23
+
24
+ export interface MustacheStatement extends Statement {
25
+ type: 'MustacheStatement';
26
+ path: PathExpression | Literal;
27
+ params: Expression[];
28
+ hash: Hash;
29
+ escaped: boolean;
30
+ strip: StripFlags;
31
+ }
32
+
33
+ export interface Decorator extends MustacheStatement { }
34
+
35
+ export interface BlockStatement extends Statement {
36
+ type: 'BlockStatement';
37
+ path: PathExpression;
38
+ params: Expression[];
39
+ hash: Hash;
40
+ program: Program;
41
+ inverse: Program;
42
+ openStrip: StripFlags;
43
+ inverseStrip: StripFlags;
44
+ closeStrip: StripFlags;
45
+ }
46
+
47
+ export interface DecoratorBlock extends BlockStatement { }
48
+
49
+ export interface PartialStatement extends Statement {
50
+ type: 'PartialStatement';
51
+ name: PathExpression | SubExpression;
52
+ params: Expression[];
53
+ hash: Hash;
54
+ indent: string;
55
+ strip: StripFlags;
56
+ }
57
+
58
+ export interface PartialBlockStatement extends Statement {
59
+ type: 'PartialBlockStatement';
60
+ name: PathExpression | SubExpression;
61
+ params: Expression[];
62
+ hash: Hash;
63
+ program: Program;
64
+ openStrip: StripFlags;
65
+ closeStrip: StripFlags;
66
+ }
67
+
68
+ export interface ContentStatement extends Statement {
69
+ type: 'ContentStatement';
70
+ value: string;
71
+ original: StripFlags;
72
+ }
73
+
74
+ export interface CommentStatement extends Statement {
75
+ type: 'CommentStatement';
76
+ value: string;
77
+ strip: StripFlags;
78
+ }
79
+
80
+ export interface Expression extends Node {}
81
+
82
+ export interface SubExpression extends Expression {
83
+ type: 'SubExpression';
84
+ path: PathExpression;
85
+ params: Expression[];
86
+ hash: Hash;
87
+ }
88
+
89
+ export interface PathExpression extends Expression {
90
+ type: 'PathExpression';
91
+ data: boolean;
92
+ depth: number;
93
+ parts: string[];
94
+ original: string;
95
+ }
96
+
97
+ export interface Literal extends Expression {}
98
+ export interface StringLiteral extends Literal {
99
+ type: 'StringLiteral';
100
+ value: string;
101
+ original: string;
102
+ }
103
+
104
+ export interface BooleanLiteral extends Literal {
105
+ type: 'BooleanLiteral';
106
+ value: boolean;
107
+ original: boolean;
108
+ }
109
+
110
+ export interface NumberLiteral extends Literal {
111
+ type: 'NumberLiteral';
112
+ value: number;
113
+ original: number;
114
+ }
115
+
116
+ export interface UndefinedLiteral extends Literal {
117
+ type: 'UndefinedLiteral';
118
+ }
119
+
120
+ export interface NullLiteral extends Literal {
121
+ type: 'NullLiteral';
122
+ }
123
+
124
+ export interface Hash extends Node {
125
+ type: 'Hash';
126
+ pairs: HashPair[];
127
+ }
128
+
129
+ export interface HashPair extends Node {
130
+ type: 'HashPair';
131
+ key: string;
132
+ value: Expression;
133
+ }
134
+
135
+ export interface StripFlags {
136
+ open: boolean;
137
+ close: boolean;
138
+ }
139
+
140
+ export interface helpers {
141
+ helperExpression(node: Node): boolean;
142
+ scopeId(path: PathExpression): boolean;
143
+ simpleId(path: PathExpression): boolean;
144
+ }
@@ -0,0 +1,11 @@
1
+ import * as AST from './ast';
2
+
3
+ export { AST };
4
+
5
+ export interface ParseOptions {
6
+ srcName?: string;
7
+ ignoreStandalone?: boolean;
8
+ }
9
+
10
+ export function parse(input: string, options?: ParseOptions): AST.Program;
11
+ export function parseWithoutProcessing(input: string, options?: ParseOptions): AST.Program;