@fluffjs/cli 0.0.8 → 0.1.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/BabelHelpers.d.ts +26 -0
- package/BabelHelpers.js +65 -0
- package/Cli.d.ts +7 -10
- package/Cli.js +139 -52
- package/CodeGenerator.d.ts +53 -39
- package/CodeGenerator.js +330 -725
- package/ComponentCompiler.d.ts +14 -16
- package/ComponentCompiler.js +193 -257
- package/DomPreProcessor.d.ts +36 -0
- package/DomPreProcessor.js +645 -0
- package/ErrorHelpers.d.ts +5 -0
- package/ErrorHelpers.js +8 -0
- package/ExpressionTransformer.d.ts +38 -28
- package/ExpressionTransformer.js +558 -230
- package/Generator.d.ts +1 -5
- package/Generator.js +128 -67
- package/GetterDependencyExtractor.d.ts +4 -0
- package/GetterDependencyExtractor.js +73 -0
- package/IndexHtmlTransformer.d.ts +6 -7
- package/IndexHtmlTransformer.js +82 -88
- package/Parse5Helpers.d.ts +17 -0
- package/Parse5Helpers.js +95 -0
- package/TemplateParser.d.ts +39 -21
- package/TemplateParser.js +462 -268
- package/Typeguards.d.ts +24 -0
- package/Typeguards.js +30 -0
- package/babel-plugin-class-transform.d.ts +3 -18
- package/babel-plugin-class-transform.js +3 -11
- package/babel-plugin-component.d.ts +4 -13
- package/babel-plugin-component.js +7 -0
- package/babel-plugin-imports.d.ts +3 -11
- package/babel-plugin-imports.js +5 -31
- package/babel-plugin-reactive.d.ts +2 -19
- package/babel-plugin-reactive.js +21 -76
- package/bin.js +2 -2
- package/fluff-esbuild-plugin.d.ts +2 -5
- package/fluff-esbuild-plugin.js +4 -1
- package/index.d.ts +6 -2
- package/index.js +1 -1
- package/interfaces/BabelPluginClassTransformState.d.ts +5 -0
- package/interfaces/BabelPluginComponentState.d.ts +4 -0
- package/interfaces/BabelPluginComponentState.js +1 -0
- package/interfaces/BabelPluginImportsState.d.ts +5 -0
- package/interfaces/BabelPluginImportsState.js +1 -0
- package/interfaces/BabelPluginReactiveState.d.ts +13 -0
- package/interfaces/BabelPluginReactiveState.js +1 -0
- package/interfaces/BabelPluginReactiveWatchCallInfo.d.ts +7 -0
- package/interfaces/BabelPluginReactiveWatchCallInfo.js +1 -0
- package/interfaces/BabelPluginReactiveWatchInfo.d.ts +5 -0
- package/interfaces/BabelPluginReactiveWatchInfo.js +1 -0
- package/interfaces/BabelToken.d.ts +8 -0
- package/interfaces/BabelToken.js +1 -0
- package/interfaces/BindingInfo.d.ts +12 -0
- package/interfaces/BindingInfo.js +1 -0
- package/interfaces/BreakMarkerConfig.d.ts +4 -0
- package/interfaces/BreakMarkerConfig.js +1 -0
- package/interfaces/BreakNode.d.ts +4 -0
- package/interfaces/BreakNode.js +1 -0
- package/interfaces/BundleOptions.d.ts +9 -0
- package/interfaces/BundleOptions.js +1 -0
- package/interfaces/ClassTransformOptions.d.ts +10 -0
- package/interfaces/ClassTransformOptions.js +1 -0
- package/interfaces/CliOptions.d.ts +8 -0
- package/interfaces/CliOptions.js +1 -0
- package/interfaces/CommentNode.d.ts +5 -0
- package/interfaces/CommentNode.js +1 -0
- package/interfaces/CompileResult.d.ts +6 -0
- package/interfaces/CompileResult.js +1 -0
- package/interfaces/CompilerOptions.d.ts +6 -0
- package/interfaces/CompilerOptions.js +1 -0
- package/interfaces/ComponentInfo.d.ts +8 -0
- package/interfaces/ComponentInfo.js +1 -0
- package/interfaces/ComponentMetadata.d.ts +9 -0
- package/interfaces/ComponentMetadata.js +1 -0
- package/interfaces/ControlFlow.d.ts +19 -0
- package/interfaces/ControlFlow.js +1 -0
- package/interfaces/ControlFlowNode.d.ts +6 -0
- package/interfaces/ControlFlowNode.js +1 -0
- package/interfaces/ControlFlowParseResult.d.ts +10 -0
- package/interfaces/ControlFlowParseResult.js +1 -0
- package/interfaces/ElementNode.d.ts +11 -0
- package/interfaces/ElementNode.js +1 -0
- package/interfaces/FluffConfigInterface.d.ts +7 -0
- package/interfaces/FluffConfigInterface.js +1 -0
- package/interfaces/FluffPluginOptions.d.ts +9 -0
- package/interfaces/FluffPluginOptions.js +1 -0
- package/interfaces/FluffTarget.d.ts +15 -0
- package/interfaces/FluffTarget.js +1 -0
- package/interfaces/ForMarkerConfig.d.ts +9 -0
- package/interfaces/ForMarkerConfig.js +1 -0
- package/interfaces/ForNode.d.ts +13 -0
- package/interfaces/ForNode.js +1 -0
- package/interfaces/GeneratorOptions.d.ts +5 -0
- package/interfaces/GeneratorOptions.js +1 -0
- package/interfaces/HtmlTransformOptions.d.ts +10 -0
- package/interfaces/HtmlTransformOptions.js +1 -0
- package/interfaces/IfBranch.d.ts +8 -0
- package/interfaces/IfBranch.js +1 -0
- package/interfaces/IfMarkerConfig.d.ts +8 -0
- package/interfaces/IfMarkerConfig.js +1 -0
- package/interfaces/IfNode.d.ts +7 -0
- package/interfaces/IfNode.js +1 -0
- package/interfaces/ImportTransformOptions.d.ts +7 -0
- package/interfaces/ImportTransformOptions.js +1 -0
- package/interfaces/InterpolationNode.d.ts +12 -0
- package/interfaces/InterpolationNode.js +1 -0
- package/interfaces/ParsedTemplate.d.ts +6 -0
- package/interfaces/ParsedTemplate.js +1 -0
- package/interfaces/ParsedTemplateOld.d.ts +9 -0
- package/interfaces/ParsedTemplateOld.js +1 -0
- package/interfaces/PropertyChain.d.ts +2 -0
- package/interfaces/PropertyChain.js +1 -0
- package/interfaces/Scope.d.ts +5 -0
- package/interfaces/Scope.js +1 -0
- package/interfaces/ServeOptions.d.ts +5 -0
- package/interfaces/ServeOptions.js +1 -0
- package/interfaces/SwitchCase.d.ts +8 -0
- package/interfaces/SwitchCase.js +1 -0
- package/interfaces/SwitchMarkerConfig.d.ts +11 -0
- package/interfaces/SwitchMarkerConfig.js +1 -0
- package/interfaces/SwitchNode.d.ts +10 -0
- package/interfaces/SwitchNode.js +1 -0
- package/interfaces/TemplateBinding.d.ts +10 -0
- package/interfaces/TemplateBinding.js +1 -0
- package/interfaces/TemplateNode.d.ts +7 -0
- package/interfaces/TemplateNode.js +1 -0
- package/interfaces/TextMarkerConfig.d.ts +10 -0
- package/interfaces/TextMarkerConfig.js +1 -0
- package/interfaces/TextNode.d.ts +5 -0
- package/interfaces/TextNode.js +1 -0
- package/interfaces/TokenizeResult.d.ts +6 -0
- package/interfaces/TokenizeResult.js +1 -0
- package/interfaces/TransformOptions.d.ts +11 -0
- package/interfaces/TransformOptions.js +1 -0
- package/interfaces/index.d.ts +34 -0
- package/interfaces/index.js +1 -0
- package/package.json +9 -1
- package/types/FluffConfig.d.ts +5 -27
- package/ControlFlowParser.d.ts +0 -55
- package/ControlFlowParser.js +0 -279
- package/types.d.ts +0 -46
- /package/{types.js → interfaces/BabelPluginClassTransformState.js} +0 -0
package/ControlFlowParser.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export interface IfBlock {
|
|
2
|
-
type: 'if';
|
|
3
|
-
condition: string;
|
|
4
|
-
ifContent: string;
|
|
5
|
-
elseContent: string;
|
|
6
|
-
start: number;
|
|
7
|
-
end: number;
|
|
8
|
-
}
|
|
9
|
-
export interface ForBlock {
|
|
10
|
-
type: 'for';
|
|
11
|
-
iterator: string;
|
|
12
|
-
iterable: string;
|
|
13
|
-
trackBy?: string;
|
|
14
|
-
content: string;
|
|
15
|
-
start: number;
|
|
16
|
-
end: number;
|
|
17
|
-
}
|
|
18
|
-
export interface SwitchCase {
|
|
19
|
-
value: string | null;
|
|
20
|
-
content: string;
|
|
21
|
-
fallthrough: boolean;
|
|
22
|
-
}
|
|
23
|
-
export interface SwitchBlock {
|
|
24
|
-
type: 'switch';
|
|
25
|
-
expression: string;
|
|
26
|
-
cases: SwitchCase[];
|
|
27
|
-
start: number;
|
|
28
|
-
end: number;
|
|
29
|
-
}
|
|
30
|
-
export type ControlFlowBlock = IfBlock | ForBlock | SwitchBlock;
|
|
31
|
-
export declare class ControlFlowParser {
|
|
32
|
-
parseAll(input: string): {
|
|
33
|
-
result: string;
|
|
34
|
-
blocks: ControlFlowBlock[];
|
|
35
|
-
};
|
|
36
|
-
private findMatchingDelimiter;
|
|
37
|
-
private findMatchingBrace;
|
|
38
|
-
private extractParenContent;
|
|
39
|
-
private parseForExpression;
|
|
40
|
-
private parseBlockStructure;
|
|
41
|
-
parseSwitchBlocks(input: string): {
|
|
42
|
-
result: string;
|
|
43
|
-
blocks: SwitchBlock[];
|
|
44
|
-
};
|
|
45
|
-
private parseSwitchCases;
|
|
46
|
-
parseForBlocks(input: string): {
|
|
47
|
-
result: string;
|
|
48
|
-
blocks: ForBlock[];
|
|
49
|
-
};
|
|
50
|
-
parseIfBlocks(input: string): {
|
|
51
|
-
result: string;
|
|
52
|
-
blocks: IfBlock[];
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=ControlFlowParser.d.ts.map
|
package/ControlFlowParser.js
DELETED
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import { parse } from '@babel/parser';
|
|
2
|
-
import * as t from '@babel/types';
|
|
3
|
-
const OPENING_BRACE_PATTERN = /^\s*\{/;
|
|
4
|
-
const OPENING_BRACE_WITH_PAREN_PATTERN = /^\)?\s*\{/;
|
|
5
|
-
const FALLTHROUGH_PATTERN = /@fallthrough\s*$/;
|
|
6
|
-
export class ControlFlowParser {
|
|
7
|
-
parseAll(input) {
|
|
8
|
-
let result = input;
|
|
9
|
-
const allBlocks = [];
|
|
10
|
-
const switchResult = this.parseSwitchBlocks(result);
|
|
11
|
-
({ result } = switchResult);
|
|
12
|
-
allBlocks.push(...switchResult.blocks);
|
|
13
|
-
const forResult = this.parseForBlocks(result);
|
|
14
|
-
({ result } = forResult);
|
|
15
|
-
allBlocks.push(...forResult.blocks);
|
|
16
|
-
const ifResult = this.parseIfBlocks(result);
|
|
17
|
-
({ result } = ifResult);
|
|
18
|
-
allBlocks.push(...ifResult.blocks);
|
|
19
|
-
return { result, blocks: allBlocks };
|
|
20
|
-
}
|
|
21
|
-
findMatchingDelimiter(str, openIdx, openChar, closeChar) {
|
|
22
|
-
let depth = 1;
|
|
23
|
-
let inString = false;
|
|
24
|
-
let i = openIdx + 1;
|
|
25
|
-
while (i < str.length && depth > 0) {
|
|
26
|
-
const char = str[i];
|
|
27
|
-
const prevChar = str[i - 1];
|
|
28
|
-
if (prevChar === '\\' && inString) {
|
|
29
|
-
i++;
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (!inString) {
|
|
33
|
-
if (char === '"' || char === '\'' || char === '`') {
|
|
34
|
-
inString = char;
|
|
35
|
-
}
|
|
36
|
-
else if (char === openChar) {
|
|
37
|
-
depth++;
|
|
38
|
-
}
|
|
39
|
-
else if (char === closeChar) {
|
|
40
|
-
depth--;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
if (char === inString) {
|
|
45
|
-
inString = false;
|
|
46
|
-
}
|
|
47
|
-
else if (inString === '`' && char === '$' && str[i + 1] === '{') {
|
|
48
|
-
i += 2;
|
|
49
|
-
let templateDepth = 1;
|
|
50
|
-
while (i < str.length && templateDepth > 0) {
|
|
51
|
-
const tc = str[i];
|
|
52
|
-
if (tc === '{')
|
|
53
|
-
templateDepth++;
|
|
54
|
-
else if (tc === '}')
|
|
55
|
-
templateDepth--;
|
|
56
|
-
else if (tc === '`') {
|
|
57
|
-
i++;
|
|
58
|
-
while (i < str.length && str[i] !== '`') {
|
|
59
|
-
if (str[i] === '\\')
|
|
60
|
-
i++;
|
|
61
|
-
i++;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
i++;
|
|
65
|
-
}
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
i++;
|
|
70
|
-
}
|
|
71
|
-
return depth === 0 ? i - 1 : -1;
|
|
72
|
-
}
|
|
73
|
-
findMatchingBrace(str, openIdx) {
|
|
74
|
-
return this.findMatchingDelimiter(str, openIdx, '{', '}');
|
|
75
|
-
}
|
|
76
|
-
extractParenContent(str, startIdx) {
|
|
77
|
-
if (str[startIdx] !== '(')
|
|
78
|
-
return null;
|
|
79
|
-
const endIdx = this.findMatchingDelimiter(str, startIdx, '(', ')');
|
|
80
|
-
if (endIdx === -1)
|
|
81
|
-
return null;
|
|
82
|
-
return {
|
|
83
|
-
content: str.slice(startIdx + 1, endIdx), endIdx
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
parseForExpression(expr) {
|
|
87
|
-
let mainExpr = expr;
|
|
88
|
-
let trackBy = undefined;
|
|
89
|
-
const trackIndex = expr.indexOf('; track ');
|
|
90
|
-
if (trackIndex !== -1) {
|
|
91
|
-
mainExpr = expr.slice(0, trackIndex);
|
|
92
|
-
trackBy = expr.slice(trackIndex + 8)
|
|
93
|
-
.trim();
|
|
94
|
-
}
|
|
95
|
-
try {
|
|
96
|
-
const wrappedCode = `for (const ${mainExpr}) {}`;
|
|
97
|
-
const ast = parse(wrappedCode, { sourceType: 'module' });
|
|
98
|
-
const [stmt] = ast.program.body;
|
|
99
|
-
if (!t.isForOfStatement(stmt))
|
|
100
|
-
return null;
|
|
101
|
-
const { left } = stmt;
|
|
102
|
-
let iterator = '';
|
|
103
|
-
if (t.isVariableDeclaration(left) && left.declarations.length === 1) {
|
|
104
|
-
const [decl] = left.declarations;
|
|
105
|
-
if (t.isIdentifier(decl.id)) {
|
|
106
|
-
iterator = decl.id.name;
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
iterator = mainExpr.slice(0, mainExpr.indexOf(' of '))
|
|
110
|
-
.trim();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
const ofIndex = mainExpr.indexOf(' of ');
|
|
117
|
-
if (ofIndex === -1)
|
|
118
|
-
return null;
|
|
119
|
-
const iterable = mainExpr.slice(ofIndex + 4)
|
|
120
|
-
.trim();
|
|
121
|
-
return { iterator, iterable, trackBy };
|
|
122
|
-
}
|
|
123
|
-
catch {
|
|
124
|
-
const ofIndex = mainExpr.indexOf(' of ');
|
|
125
|
-
if (ofIndex === -1)
|
|
126
|
-
return null;
|
|
127
|
-
const fallbackIterator = mainExpr.slice(0, ofIndex)
|
|
128
|
-
.trim();
|
|
129
|
-
const iterable = mainExpr.slice(ofIndex + 4)
|
|
130
|
-
.trim();
|
|
131
|
-
return { iterator: fallbackIterator, iterable, trackBy };
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
parseBlockStructure(input, match) {
|
|
135
|
-
const parenStart = match.index + match[0].length - 1;
|
|
136
|
-
const exprResult = this.extractParenContent(input, parenStart);
|
|
137
|
-
if (!exprResult)
|
|
138
|
-
return null;
|
|
139
|
-
const afterExpr = input.slice(exprResult.endIdx + 1);
|
|
140
|
-
const braceMatch = OPENING_BRACE_PATTERN.exec(afterExpr);
|
|
141
|
-
if (!braceMatch)
|
|
142
|
-
return null;
|
|
143
|
-
const braceStart = exprResult.endIdx + 1 + braceMatch[0].length - 1;
|
|
144
|
-
const braceEnd = this.findMatchingBrace(input, braceStart);
|
|
145
|
-
if (braceEnd === -1)
|
|
146
|
-
return null;
|
|
147
|
-
return {
|
|
148
|
-
expr: exprResult.content.trim(),
|
|
149
|
-
content: input.slice(braceStart + 1, braceEnd)
|
|
150
|
-
.trim(),
|
|
151
|
-
braceEnd
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
parseSwitchBlocks(input) {
|
|
155
|
-
const blocks = [];
|
|
156
|
-
let result = input;
|
|
157
|
-
const switchRegex = /@switch\s*\(/g;
|
|
158
|
-
let match = null;
|
|
159
|
-
while ((match = switchRegex.exec(result)) !== null) {
|
|
160
|
-
const startIdx = match.index;
|
|
161
|
-
const parsed = this.parseBlockStructure(result, match);
|
|
162
|
-
if (!parsed)
|
|
163
|
-
continue;
|
|
164
|
-
const cases = this.parseSwitchCases(parsed.content);
|
|
165
|
-
blocks.push({
|
|
166
|
-
type: 'switch', expression: parsed.expr, cases, start: startIdx, end: parsed.braceEnd
|
|
167
|
-
});
|
|
168
|
-
const placeholder = `__SWITCH_BLOCK_${blocks.length - 1}`;
|
|
169
|
-
result = result.slice(0, startIdx) + placeholder + result.slice(parsed.braceEnd + 1);
|
|
170
|
-
switchRegex.lastIndex = startIdx + placeholder.length;
|
|
171
|
-
}
|
|
172
|
-
return { result, blocks };
|
|
173
|
-
}
|
|
174
|
-
parseSwitchCases(switchBody) {
|
|
175
|
-
const cases = [];
|
|
176
|
-
const caseRegex = /@(case|default)\s*\(?/g;
|
|
177
|
-
let match = null;
|
|
178
|
-
while ((match = caseRegex.exec(switchBody)) !== null) {
|
|
179
|
-
const [, caseType] = match;
|
|
180
|
-
let value = null;
|
|
181
|
-
let contentStart = 0;
|
|
182
|
-
if (caseType === 'case') {
|
|
183
|
-
const parenIdx = switchBody.indexOf('(', match.index);
|
|
184
|
-
if (parenIdx === -1)
|
|
185
|
-
continue;
|
|
186
|
-
const valueResult = this.extractParenContent(switchBody, parenIdx);
|
|
187
|
-
if (!valueResult)
|
|
188
|
-
continue;
|
|
189
|
-
value = valueResult.content.trim();
|
|
190
|
-
const afterValue = switchBody.slice(valueResult.endIdx + 1);
|
|
191
|
-
const braceMatch = OPENING_BRACE_PATTERN.exec(afterValue);
|
|
192
|
-
if (!braceMatch)
|
|
193
|
-
continue;
|
|
194
|
-
contentStart = valueResult.endIdx + 1 + braceMatch[0].length;
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
const afterDefault = switchBody.slice(match.index + match[0].length);
|
|
198
|
-
const braceMatch = OPENING_BRACE_WITH_PAREN_PATTERN.exec(afterDefault);
|
|
199
|
-
if (!braceMatch)
|
|
200
|
-
continue;
|
|
201
|
-
contentStart = match.index + match[0].length + braceMatch[0].length;
|
|
202
|
-
}
|
|
203
|
-
const contentEnd = this.findMatchingBrace(switchBody, contentStart - 1);
|
|
204
|
-
if (contentEnd === -1)
|
|
205
|
-
continue;
|
|
206
|
-
let content = switchBody.slice(contentStart, contentEnd);
|
|
207
|
-
const fallthrough = FALLTHROUGH_PATTERN.test(content.trim());
|
|
208
|
-
if (fallthrough) {
|
|
209
|
-
content = content.replace(FALLTHROUGH_PATTERN, '')
|
|
210
|
-
.trim();
|
|
211
|
-
}
|
|
212
|
-
cases.push({
|
|
213
|
-
value, content: content.trim(), fallthrough
|
|
214
|
-
});
|
|
215
|
-
caseRegex.lastIndex = contentEnd + 1;
|
|
216
|
-
}
|
|
217
|
-
return cases;
|
|
218
|
-
}
|
|
219
|
-
parseForBlocks(input) {
|
|
220
|
-
const blocks = [];
|
|
221
|
-
let result = input;
|
|
222
|
-
const forRegex = /@for\s*\(/g;
|
|
223
|
-
let match = null;
|
|
224
|
-
while ((match = forRegex.exec(result)) !== null) {
|
|
225
|
-
const startIdx = match.index;
|
|
226
|
-
const parsed = this.parseBlockStructure(result, match);
|
|
227
|
-
if (!parsed)
|
|
228
|
-
continue;
|
|
229
|
-
const forParts = this.parseForExpression(parsed.expr);
|
|
230
|
-
if (!forParts)
|
|
231
|
-
continue;
|
|
232
|
-
const { iterator, iterable, trackBy } = forParts;
|
|
233
|
-
blocks.push({
|
|
234
|
-
type: 'for', iterator, iterable, trackBy, content: parsed.content, start: startIdx, end: parsed.braceEnd
|
|
235
|
-
});
|
|
236
|
-
const placeholder = `__FOR_BLOCK_${blocks.length - 1}__`;
|
|
237
|
-
result = result.slice(0, startIdx) + placeholder + result.slice(parsed.braceEnd + 1);
|
|
238
|
-
forRegex.lastIndex = startIdx + placeholder.length;
|
|
239
|
-
}
|
|
240
|
-
return { result, blocks };
|
|
241
|
-
}
|
|
242
|
-
parseIfBlocks(input) {
|
|
243
|
-
const blocks = [];
|
|
244
|
-
let result = input;
|
|
245
|
-
const ifRegex = /@if\s*\(/g;
|
|
246
|
-
let match = null;
|
|
247
|
-
while ((match = ifRegex.exec(result)) !== null) {
|
|
248
|
-
const startIdx = match.index;
|
|
249
|
-
const parsed = this.parseBlockStructure(result, match);
|
|
250
|
-
if (!parsed)
|
|
251
|
-
continue;
|
|
252
|
-
let elseContent = '';
|
|
253
|
-
let totalEnd = parsed.braceEnd;
|
|
254
|
-
const afterIf = result.slice(parsed.braceEnd + 1);
|
|
255
|
-
const elseMatch = /^\s*@else\s*\{/.exec(afterIf);
|
|
256
|
-
if (elseMatch) {
|
|
257
|
-
const elseBraceStart = parsed.braceEnd + 1 + elseMatch[0].length - 1;
|
|
258
|
-
const elseBraceEnd = this.findMatchingBrace(result, elseBraceStart);
|
|
259
|
-
if (elseBraceEnd !== -1) {
|
|
260
|
-
elseContent = result.slice(elseBraceStart + 1, elseBraceEnd)
|
|
261
|
-
.trim();
|
|
262
|
-
totalEnd = elseBraceEnd;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
blocks.push({
|
|
266
|
-
type: 'if',
|
|
267
|
-
condition: parsed.expr,
|
|
268
|
-
ifContent: parsed.content,
|
|
269
|
-
elseContent,
|
|
270
|
-
start: startIdx,
|
|
271
|
-
end: totalEnd
|
|
272
|
-
});
|
|
273
|
-
const placeholder = `__IF_BLOCK_${blocks.length - 1}__`;
|
|
274
|
-
result = result.slice(0, startIdx) + placeholder + result.slice(totalEnd + 1);
|
|
275
|
-
ifRegex.lastIndex = startIdx + placeholder.length;
|
|
276
|
-
}
|
|
277
|
-
return { result, blocks };
|
|
278
|
-
}
|
|
279
|
-
}
|
package/types.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export interface ComponentInfo {
|
|
2
|
-
className: string;
|
|
3
|
-
selector: string;
|
|
4
|
-
templatePath: string;
|
|
5
|
-
stylePath?: string;
|
|
6
|
-
filePath: string;
|
|
7
|
-
}
|
|
8
|
-
export interface TemplateBinding {
|
|
9
|
-
id: string;
|
|
10
|
-
type: 'text' | 'property' | 'event' | 'class' | 'style';
|
|
11
|
-
expression: string;
|
|
12
|
-
target?: string;
|
|
13
|
-
eventName?: string;
|
|
14
|
-
className?: string;
|
|
15
|
-
styleProp?: string;
|
|
16
|
-
}
|
|
17
|
-
export interface SwitchCase {
|
|
18
|
-
value: string | null;
|
|
19
|
-
content: string;
|
|
20
|
-
fallthrough: boolean;
|
|
21
|
-
}
|
|
22
|
-
export interface ControlFlow {
|
|
23
|
-
id: string;
|
|
24
|
-
type: 'if' | 'for' | 'switch';
|
|
25
|
-
condition?: string;
|
|
26
|
-
ifContent?: string;
|
|
27
|
-
elseContent?: string;
|
|
28
|
-
iterator?: string;
|
|
29
|
-
iterable?: string;
|
|
30
|
-
trackBy?: string;
|
|
31
|
-
content?: string;
|
|
32
|
-
expression?: string;
|
|
33
|
-
cases?: SwitchCase[];
|
|
34
|
-
}
|
|
35
|
-
export interface ParsedTemplate {
|
|
36
|
-
html: string;
|
|
37
|
-
bindings: TemplateBinding[];
|
|
38
|
-
controlFlows: ControlFlow[];
|
|
39
|
-
templateRefs: string[];
|
|
40
|
-
}
|
|
41
|
-
export interface CompilerOptions {
|
|
42
|
-
srcDir: string;
|
|
43
|
-
distDir: string;
|
|
44
|
-
componentSelectors: Set<string>;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=types.d.ts.map
|
|
File without changes
|