|
| 1 | +export interface MaterialExportAsNameData { |
| 2 | + /** The exportAs name to replace. */ |
| 3 | + replace: string; |
| 4 | + /** The new exportAs name. */ |
| 5 | + replaceWith: string; |
| 6 | +} |
| 7 | + |
| 8 | +export interface MaterialElementSelectorData { |
| 9 | + /** The element name to replace. */ |
| 10 | + replace: string; |
| 11 | + /** The new name for the element. */ |
| 12 | + replaceWith: string; |
| 13 | +} |
| 14 | + |
| 15 | +export interface MaterialCssNameData { |
| 16 | + /** The CSS name to replace. */ |
| 17 | + replace: string; |
| 18 | + /** The new CSS name. */ |
| 19 | + replaceWith: string; |
| 20 | + /** Whitelist where this replacement is made. If omitted it is made in all files. */ |
| 21 | + whitelist: { |
| 22 | + /** Replace this name in CSS files. */ |
| 23 | + css?: boolean, |
| 24 | + /** Replace this name in HTML files. */ |
| 25 | + html?: boolean, |
| 26 | + /** Replace this name in TypeScript strings. */ |
| 27 | + strings?: boolean |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +export interface MaterialAttributeSelectorData { |
| 32 | + /** The attribute name to replace. */ |
| 33 | + replace: string; |
| 34 | + /** The new name for the attribute. */ |
| 35 | + replaceWith: string; |
| 36 | +} |
| 37 | + |
| 38 | +export interface MaterialPropertyNameData { |
| 39 | + /** The property name to replace. */ |
| 40 | + replace: string; |
| 41 | + /** The new name for the property. */ |
| 42 | + replaceWith: string; |
| 43 | + /** Whitelist where this replacement is made. If omitted it is made for all Classes. */ |
| 44 | + whitelist: { |
| 45 | + /** Replace the property only when its type is one of the given Classes. */ |
| 46 | + classes?: string[]; |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +export interface MaterialClassNameData { |
| 51 | + /** The Class name to replace. */ |
| 52 | + replace: string; |
| 53 | + /** The new name for the Class. */ |
| 54 | + replaceWith: string; |
| 55 | +} |
| 56 | + |
| 57 | +export interface MaterialInputNameData { |
| 58 | + /** The @Input() name to replace. */ |
| 59 | + replace: string; |
| 60 | + /** The new name for the @Input(). */ |
| 61 | + replaceWith: string; |
| 62 | + /** Whitelist where this replacement is made. If omitted it is made in all HTML & CSS */ |
| 63 | + whitelist?: { |
| 64 | + /** Limit to elements with any of these element tags. */ |
| 65 | + elements?: string[], |
| 66 | + /** Limit to elements with any of these attributes. */ |
| 67 | + attributes?: string[], |
| 68 | + /** Whether to ignore CSS attribute selectors when doing this replacement. */ |
| 69 | + css?: boolean, |
| 70 | + } |
| 71 | +} |
| 72 | + |
| 73 | +export interface MaterialOutputNameData { |
| 74 | + /** The @Output() name to replace. */ |
| 75 | + replace: string; |
| 76 | + /** The new name for the @Output(). */ |
| 77 | + replaceWith: string; |
| 78 | + /** Whitelist where this replacement is made. If omitted it is made in all HTML & CSS */ |
| 79 | + whitelist?: { |
| 80 | + /** Limit to elements with any of these element tags. */ |
| 81 | + elements?: string[], |
| 82 | + /** Limit to elements with any of these attributes. */ |
| 83 | + attributes?: string[], |
| 84 | + /** Whether to ignore CSS attribute selectors when doing this replacement. */ |
| 85 | + css?: boolean, |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | +export interface MaterialMethodCallData { |
| 90 | + className: string; |
| 91 | + method: string; |
| 92 | + invalidArgCounts: { |
| 93 | + count: number, |
| 94 | + message: string |
| 95 | + }[] |
| 96 | +} |
| 97 | + |
| 98 | +type Changes<T> = { |
| 99 | + pr: string; |
| 100 | + changes: T[] |
| 101 | +} |
| 102 | + |
| 103 | +function getChanges<T>(allChanges: Changes<T>[]): T[] { |
| 104 | + return allChanges.reduce((result, changes) => result.concat(changes.changes), []); |
| 105 | +} |
| 106 | + |
| 107 | +/** Export the class name data as part of a module. This means that the data is cached. */ |
| 108 | +export const classNames = getChanges<MaterialClassNameData>(require('./data/class-names.json')); |
| 109 | + |
| 110 | +/** Export the input names data as part of a module. This means that the data is cached. */ |
| 111 | +export const inputNames = getChanges<MaterialInputNameData>(require('./data/input-names.json')); |
| 112 | + |
| 113 | +/** Export the output names data as part of a module. This means that the data is cached. */ |
| 114 | +export const outputNames = getChanges<MaterialOutputNameData>(require('./data/output-names.json')); |
| 115 | + |
| 116 | +/** Export the element selectors data as part of a module. This means that the data is cached. */ |
| 117 | +export const elementSelectors = |
| 118 | + getChanges<MaterialElementSelectorData>(require('./data/element-selectors.json')); |
| 119 | + |
| 120 | +/** Export the attribute selectors data as part of a module. This means that the data is cached. */ |
| 121 | +export const exportAsNames = |
| 122 | + getChanges<MaterialExportAsNameData>(require('./data/export-as-names.json')); |
| 123 | + |
| 124 | +/** Export the attribute selectors data as part of a module. This means that the data is cached. */ |
| 125 | +export const attributeSelectors = |
| 126 | + getChanges<MaterialAttributeSelectorData>(require('./data/attribute-selectors.json')); |
| 127 | + |
| 128 | +/** Export the property names as part of a module. This means that the data is cached. */ |
| 129 | +export const propertyNames = |
| 130 | + getChanges<MaterialPropertyNameData>(require('./data/property-names.json')); |
| 131 | + |
| 132 | +export const methodCallChecks = |
| 133 | + getChanges<MaterialMethodCallData>(require('./data/method-call-checks.json')); |
| 134 | + |
| 135 | +export const cssNames = getChanges<MaterialCssNameData>(require('./data/css-names.json')); |
0 commit comments