(data = {}, dark = false)
| 12 | const getForeground = (str) => typeof str === 'string' ? str : null; |
| 13 | |
| 14 | function format(data = {}, dark = false) { |
| 15 | const { colors = {}, tokenColors = [] } = data || {}; |
| 16 | const conf = { |
| 17 | // name: data.name, |
| 18 | // Layout |
| 19 | background: colors['activeBackground'] || colors['editor.background'], |
| 20 | foreground: colors['editor.foreground'] || colors['input.foreground'], |
| 21 | selection: colors['editor.wordHighlightBackground'] || colors['editor.selectionBackground'], |
| 22 | selectionMatch: colors['editor.wordHighlightStrongBackground'] || colors['editor.selectionBackground'], |
| 23 | cursor: colors['editorCursor.foreground'] || colors['foreground'], |
| 24 | dropdownBackground: colors['dropdown.background'], |
| 25 | dropdownBorder: colors['dropdown.border'] || colors['foreground'], |
| 26 | activeLine: colors['editor.lineHighlightBackground'] || colors['editor.background'], |
| 27 | matchingBracket: colors['editorBracketMatch.background'] || colors['editor.lineHighlightBackground'] || colors['editor.selectionBackground'], |
| 28 | // Syntax |
| 29 | keyword: null, |
| 30 | storage: null, |
| 31 | variable: null, |
| 32 | parameter: null, |
| 33 | function: null, |
| 34 | string: null, |
| 35 | constant: null, |
| 36 | type: null, |
| 37 | class: null, |
| 38 | number: null, |
| 39 | comment: null, |
| 40 | heading: null, |
| 41 | invalid: null, |
| 42 | regexp: null, |
| 43 | tag: null, |
| 44 | }; |
| 45 | tokenColors.forEach((item) => { |
| 46 | const keys = Object.keys(item).length; |
| 47 | if (keys === 1 && !conf.foreground && item.settings.foreground) { |
| 48 | conf.foreground = getForeground(item.settings.foreground); |
| 49 | } |
| 50 | |
| 51 | if (includes(item, "keyword")) { |
| 52 | conf.keyword = getForeground(item.settings.foreground); |
| 53 | } |
| 54 | if (includes(item, "entity.name.tag")) { |
| 55 | conf.tag = getForeground(item.settings.foreground); |
| 56 | } |
| 57 | if (includes(item, "storage", "keyword")) { |
| 58 | conf.storage = getForeground(item.settings.foreground); |
| 59 | } |
| 60 | if (includes(item, "variable", "variable.parameter", "variable.other", "variable.language", "foreground")) { |
| 61 | conf.variable = getForeground(item.settings.foreground); |
| 62 | } |
| 63 | if (includes(item, "variable.parameter", "variable.other", "variable")) { |
| 64 | conf.parameter = getForeground(item.settings.foreground); |
| 65 | } |
| 66 | if (includes(item, "entity.name.function", "support.function", "entity.name", "support")) { |
| 67 | conf.function = getForeground(item.settings.foreground); |
| 68 | } |
| 69 | if (includes(item, "string")) { |
| 70 | conf.string = getForeground(item.settings.foreground); |
| 71 | } |
no test coverage detected
searching dependent graphs…