|
1 | | -import * as ts from 'typescript'; |
2 | 1 | import { CodeWithSourceMap } from './metadata'; |
3 | 2 |
|
4 | | -export interface UrlResolver { |
5 | | - (url: string, d: ts.Decorator): string; |
| 3 | +export interface StyleTransformer { |
| 4 | + (style: string, url?: string): CodeWithSourceMap; |
6 | 5 | } |
7 | 6 |
|
8 | 7 | export interface TemplateTransformer { |
9 | | - (template: string, url: string, d: ts.Decorator): CodeWithSourceMap; |
| 8 | + (template: string, url?: string): CodeWithSourceMap; |
10 | 9 | } |
11 | 10 |
|
12 | | -export interface StyleTransformer { |
13 | | - (style: string, url: string, d: ts.Decorator): CodeWithSourceMap; |
| 11 | +export interface UrlResolver { |
| 12 | + (url: string | null): string | null; |
14 | 13 | } |
15 | 14 |
|
16 | | -export const LogLevel = { |
17 | | - None: 0, |
18 | | - Error: 0b001, |
19 | | - Info: 0b011, |
20 | | - Debug: 0b111 |
21 | | -}; |
| 15 | +export const LogLevel = { Debug: 0b111, Error: 0b001, Info: 0b011, None: 0 }; |
22 | 16 |
|
23 | 17 | export interface Config { |
24 | 18 | interpolation: [string, string]; |
| 19 | + logLevel: number; |
| 20 | + predefinedDirectives: DirectiveDeclaration[]; |
25 | 21 | resolveUrl: UrlResolver; |
26 | | - transformTemplate: TemplateTransformer; |
27 | 22 | transformStyle: StyleTransformer; |
28 | | - predefinedDirectives: DirectiveDeclaration[]; |
29 | | - logLevel: number; |
| 23 | + transformTemplate: TemplateTransformer; |
30 | 24 | } |
31 | 25 |
|
32 | 26 | export interface DirectiveDeclaration { |
33 | | - selector: string; |
34 | 27 | exportAs?: string; |
35 | | - inputs?: string[]; |
36 | | - outputs?: string[]; |
37 | | - hostProperties?: string[]; |
38 | 28 | hostAttributes?: string[]; |
39 | 29 | hostListeners?: string[]; |
| 30 | + hostProperties?: string[]; |
| 31 | + inputs?: string[]; |
| 32 | + outputs?: string[]; |
| 33 | + selector: string; |
40 | 34 | } |
41 | 35 |
|
42 | 36 | let BUILD_TYPE = '<%= BUILD_TYPE %>'; |
43 | 37 |
|
44 | 38 | export const Config: Config = { |
45 | 39 | interpolation: ['{{', '}}'], |
46 | 40 |
|
47 | | - resolveUrl(url: string, d: ts.Decorator) { |
48 | | - return url; |
49 | | - }, |
50 | | - |
51 | | - transformTemplate(code: string, url: string, d: ts.Decorator) { |
52 | | - if (!url || url.endsWith('.html')) { |
53 | | - return { code, url }; |
54 | | - } |
55 | | - return { code: '', url }; |
56 | | - }, |
57 | | - |
58 | | - transformStyle(code: string, url: string, d: ts.Decorator) { |
59 | | - if (!url || url.endsWith('.css')) { |
60 | | - return { code, url }; |
61 | | - } |
62 | | - return { code: '', url }; |
63 | | - }, |
| 41 | + logLevel: BUILD_TYPE === 'dev' ? LogLevel.Debug : LogLevel.None, |
64 | 42 |
|
65 | 43 | predefinedDirectives: [ |
66 | 44 | { selector: 'form:not([ngNoForm]):not([formGroup]), ngForm, [ngForm]', exportAs: 'ngForm' }, |
@@ -89,7 +67,25 @@ export const Config: Config = { |
89 | 67 | { selector: 'md-select', exportAs: 'mdSelect' } |
90 | 68 | ], |
91 | 69 |
|
92 | | - logLevel: BUILD_TYPE === 'dev' ? LogLevel.Debug : LogLevel.None |
| 70 | + resolveUrl(url: string | null) { |
| 71 | + return url; |
| 72 | + }, |
| 73 | + |
| 74 | + transformStyle(code: string, url?: string) { |
| 75 | + if (!url || url.endsWith('.css')) { |
| 76 | + return { code, url }; |
| 77 | + } |
| 78 | + |
| 79 | + return { code: '', url }; |
| 80 | + }, |
| 81 | + |
| 82 | + transformTemplate(code: string, url?: string) { |
| 83 | + if (!url || url.endsWith('.html')) { |
| 84 | + return { code, url }; |
| 85 | + } |
| 86 | + |
| 87 | + return { code: '', url }; |
| 88 | + } |
93 | 89 | }; |
94 | 90 |
|
95 | 91 | try { |
|
0 commit comments