devextreme-themebuilder 19.1.14 → 19.1.16

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.
@@ -60789,4 +60789,4 @@ ios7_default_metadata: [
60789
60789
  "IsLastSubGroupItem": false
60790
60790
  }
60791
60791
  ],
60792
- _metadata_version: "19.1.14",}
60792
+ _metadata_version: "19.1.16",}
@@ -1,16 +1,10 @@
1
1
  const MetadataLoader = require('./metadata-loader.js');
2
-
3
2
  const MetadataRepository = require('./metadata-repository.js');
4
-
5
3
  const LessTemplateLoader = require('./less-template-loader.js');
6
-
7
4
  const themes = require('./themes.js');
8
-
9
5
  const normalize = require('./config-normalizer');
10
-
11
6
  const processTheme = (config, metadata, version) => {
12
7
  const lessTemplateLoader = new LessTemplateLoader(config, version);
13
-
14
8
  if (config.isBootstrap) {
15
9
  const bootstrapMetadata = config.bootstrapVersion === 3 ? require('../data/bootstrap-metadata/bootstrap-metadata.js') : require('../data/bootstrap-metadata/bootstrap4-metadata.js');
16
10
  return lessTemplateLoader.analyzeBootstrapTheme(config.themeName, config.colorScheme, metadata, bootstrapMetadata, config.data, config.bootstrapVersion);
@@ -18,7 +12,6 @@ const processTheme = (config, metadata, version) => {
18
12
  return lessTemplateLoader.load(config.themeName, config.colorScheme, metadata, config.items);
19
13
  }
20
14
  };
21
-
22
15
  const buildTheme = config => {
23
16
  normalize(config);
24
17
  const metadataRepository = new MetadataRepository(new MetadataLoader());
@@ -32,7 +25,6 @@ const buildTheme = config => {
32
25
  return processTheme(config, metadata, version);
33
26
  });
34
27
  };
35
-
36
28
  module.exports = {
37
29
  buildTheme: buildTheme
38
30
  };
@@ -1,19 +1,14 @@
1
1
  /* global console */
2
-
3
2
  /* eslint no-console: 0 */
4
- const commands = require('./commands');
5
3
 
4
+ const commands = require('./commands');
6
5
  const themes = require('./themes');
7
-
8
6
  const DEFAULT_OUT_COLOR_SCHEME = 'custom-scheme';
9
-
10
7
  const extname = filename => filename.substring(filename.lastIndexOf('.'));
11
-
12
8
  const getBootstrapConfig = fileName => {
13
9
  const extension = extname(fileName);
14
10
  let bootstrap = false;
15
11
  let version = 0;
16
-
17
12
  if (extension === '.scss') {
18
13
  bootstrap = true;
19
14
  version = 4;
@@ -21,47 +16,39 @@ const getBootstrapConfig = fileName => {
21
16
  bootstrap = true;
22
17
  version = 3;
23
18
  }
24
-
25
19
  return {
26
20
  isBootstrap: bootstrap,
27
21
  bootstrapVersion: version
28
22
  };
29
23
  };
30
-
31
24
  const getOutParameters = (command, themeName, config) => {
32
25
  let outputFile = config.outputFile || '';
33
26
  let outColorScheme = config.outputColorScheme || '';
34
27
  let fileFormat = config.outputFormat || extname(outputFile).substr(1);
35
28
  const makeSwatch = !!config.makeSwatch;
36
29
  const base = !!config.base;
37
-
38
30
  if (!outColorScheme) {
39
31
  outColorScheme = DEFAULT_OUT_COLOR_SCHEME;
40
32
  } else if (!/^[\w\-.]+$/.test(outColorScheme)) {
41
33
  console.log(`'--output-color-scheme' is not valid. '${DEFAULT_OUT_COLOR_SCHEME}' will be used.`);
42
34
  outColorScheme = DEFAULT_OUT_COLOR_SCHEME;
43
35
  }
44
-
45
36
  if (!fileFormat) {
46
37
  switch (command) {
47
38
  case commands.BUILD_THEME:
48
39
  fileFormat = 'css';
49
40
  break;
50
-
51
41
  case commands.BUILD_VARS:
52
42
  fileFormat = 'less';
53
43
  break;
54
-
55
44
  case commands.BUILD_META:
56
45
  fileFormat = 'json';
57
46
  break;
58
47
  }
59
48
  }
60
-
61
49
  if (!outputFile) {
62
50
  outputFile = 'dx.' + themeName + '.' + outColorScheme + '.' + fileFormat;
63
51
  }
64
-
65
52
  return {
66
53
  outputFile: outputFile,
67
54
  fileFormat: fileFormat,
@@ -70,43 +57,35 @@ const getOutParameters = (command, themeName, config) => {
70
57
  base: base
71
58
  };
72
59
  };
73
-
74
60
  const getThemeAndColorScheme = config => {
75
61
  let themeName = 'generic';
76
62
  let colorScheme = 'light';
77
63
  let foundTheme = null;
78
-
79
64
  if (config.baseTheme) {
80
65
  const dotIndex = config.baseTheme.indexOf('.');
81
66
  const passedThemeName = config.baseTheme.substr(0, dotIndex);
82
67
  const passedColorScheme = config.baseTheme.substr(dotIndex + 1).replace(/\./g, '-');
83
68
  console.log(passedThemeName, passedColorScheme);
84
69
  foundTheme = themes.find(t => t.name === passedThemeName && t.colorScheme === passedColorScheme);
85
-
86
70
  if (!foundTheme) {
87
71
  console.log(`The base theme with name ${config.baseTheme} does not exist.`);
88
72
  }
89
73
  } else if (config.themeId) {
90
74
  foundTheme = themes.find(t => t.themeId === parseInt(config.themeId));
91
-
92
75
  if (!foundTheme) {
93
76
  console.log(`The theme with ID ${config.themeId} does not exist.`);
94
77
  }
95
78
  }
96
-
97
79
  if (foundTheme) {
98
80
  themeName = foundTheme.name;
99
81
  colorScheme = foundTheme.colorScheme;
100
82
  }
101
-
102
83
  return {
103
84
  themeName: themeName,
104
85
  colorScheme: colorScheme
105
86
  };
106
87
  };
107
-
108
88
  const normalizePath = path => path + (path[path.length - 1] !== '/' ? '/' : '');
109
-
110
89
  const parseConfig = config => {
111
90
  const command = config.command;
112
91
  const metadataFilePath = config.inputFile || '';
@@ -119,15 +98,12 @@ const parseConfig = config => {
119
98
  delete config.outputFile;
120
99
  delete config.inputFile;
121
100
  delete config.themeId;
122
-
123
101
  if (config.lessPath) {
124
102
  config.lessPath = normalizePath(config.lessPath);
125
103
  }
126
-
127
104
  if (config.scssPath) {
128
105
  config.scssPath = normalizePath(config.scssPath);
129
106
  }
130
-
131
107
  Object.assign(config, {
132
108
  data: config.data !== undefined ? config.data : {},
133
109
  fileFormat: output.fileFormat,
@@ -141,5 +117,4 @@ const parseConfig = config => {
141
117
  base: output.base
142
118
  });
143
119
  };
144
-
145
120
  module.exports = parseConfig;
@@ -1,79 +1,62 @@
1
1
  const LessPluginAutoPrefix = require('less-plugin-autoprefix');
2
-
3
2
  const BOOTSTRAP_SCSS_PATH = 'bootstrap/scss/';
4
3
  const THEMEBUILDER_LESS_PATH = 'devextreme-themebuilder/data/less/';
5
4
  const SWATCH_SELECTOR_PREFIX = '.dx-swatch-';
6
-
7
5
  const createModifyVars = modifyVars => {
8
6
  let result = '';
9
-
10
7
  for (const key in modifyVars) {
11
8
  if (Object.prototype.hasOwnProperty.call(modifyVars, key)) {
12
9
  result += `@${key}: ${modifyVars[key]};`;
13
10
  }
14
11
  }
15
-
16
12
  return result;
17
13
  };
18
-
19
14
  const addSwatchClass = (less, swatchSelector, modifyVars) => {
20
15
  if (!swatchSelector) return less;
21
16
  return swatchSelector + '{' + less + createModifyVars(modifyVars) + '}';
22
17
  };
23
-
24
18
  class LessFontPlugin {
25
19
  process(css) {
26
20
  return css.replace(/(\f)(\d+)/g, '\\f$2');
27
21
  }
28
-
29
22
  }
30
-
31
23
  class LessMetadataPreCompilerPlugin {
32
24
  constructor(metadata, swatchSelector, modifyVars) {
33
25
  this._metadata = metadata;
34
26
  this.swatchSelector = swatchSelector;
35
27
  this.modifyVars = modifyVars;
36
28
  }
37
-
38
29
  process(less, context) {
39
30
  if (context && context.fileInfo.filename !== 'input') {
40
31
  return less;
41
32
  }
42
-
43
33
  less += '#devexpress-metadata-compiler{';
44
-
45
34
  for (const key in this._metadata) {
46
35
  if (Object.prototype.hasOwnProperty.call(this._metadata, key)) {
47
36
  const value = this._metadata[key];
48
37
  less += key + ': ' + value + ';';
49
38
  }
50
39
  }
51
-
52
40
  less += '}';
53
41
  return addSwatchClass(less, this.swatchSelector, this.modifyVars);
54
42
  }
55
-
56
43
  }
57
-
58
44
  class LessMetadataPostCompilerPlugin {
59
45
  constructor(compiledMetadata, swatchSelector, colorScheme) {
60
46
  this._metadata = compiledMetadata;
61
47
  this.swatchSelector = swatchSelector;
62
48
  this.colorScheme = colorScheme;
63
49
  }
64
-
65
50
  process(css) {
66
51
  const metadataRegex = new RegExp('(?:' + this.swatchSelector + '\\s*)?\\s*#devexpress-metadata-compiler\\s*\\{((.|\\n|\\r)*?)\\}');
67
52
  metadataRegex.exec(css)[1].split(';').forEach(item => {
68
53
  const rule = getCompiledRule(item);
69
-
70
54
  for (const key in rule) {
71
55
  if (Object.prototype.hasOwnProperty.call(rule, key)) {
72
56
  this._metadata[key] = rule[key];
73
57
  }
74
58
  }
75
59
  });
76
-
77
60
  if (this.swatchSelector) {
78
61
  const escapedSelector = this.swatchSelector.replace('.', '\\.');
79
62
  const customStylesDuplicateRegex = new RegExp(`\\s+${escapedSelector}\\s+\\.dx-theme-.*?-typography\\s+\\.dx-theme-.*?{[\\s\\S]*?}[\\r\\n]*?`, 'g');
@@ -81,26 +64,20 @@ class LessMetadataPostCompilerPlugin {
81
64
  const themeMarkerRegex = /(\.dx-theme-marker\s*{\s*font-family:\s*['"]dx\..*?\.)(.*)(['"])/g;
82
65
  css = css.replace(swatchOrderRegex, '$1$3$2$4').replace(customStylesDuplicateRegex, '').replace(/\s\.dx-theme-.*?-typography/g, '').replace(themeMarkerRegex, '$1' + this.colorScheme + '$3');
83
66
  }
84
-
85
67
  return css.replace(metadataRegex, '');
86
68
  }
87
-
88
69
  }
89
-
90
70
  const getCompiledRule = cssString => {
91
71
  let result = {};
92
72
  const ruleRegex = /([-\w\d]*)\s*:\s*(.*)\s*/;
93
73
  const matches = ruleRegex.exec(cssString);
94
-
95
74
  if (matches) {
96
75
  result['@' + matches[1]] = matches[2];
97
76
  } else {
98
77
  result = null;
99
78
  }
100
-
101
79
  return result;
102
80
  };
103
-
104
81
  class LessTemplateLoader {
105
82
  constructor(config, version) {
106
83
  this.readFile = config.reader;
@@ -112,36 +89,31 @@ class LessTemplateLoader {
112
89
  this.outColorScheme = config.outColorScheme;
113
90
  this.version = version;
114
91
  }
115
-
116
92
  load(theme, colorScheme, metadata, modifiedItems) {
117
93
  return this._loadLess(theme, colorScheme).then(less => {
118
94
  const modifyVars = {};
119
95
  const metadataVariables = {};
120
-
121
96
  if (Array.isArray(modifiedItems)) {
122
97
  modifiedItems.forEach(item => {
123
98
  modifyVars[item.key.replace('@', '')] = item.value;
124
99
  });
125
100
  }
126
-
127
101
  metadata.forEach(metaItem => {
128
102
  metadataVariables[metaItem.Key.replace('@', '')] = metaItem.Key;
129
103
  });
130
104
  return this.compileLess(less, modifyVars, metadataVariables);
131
105
  });
132
106
  }
133
-
134
107
  compileLess(less, modifyVars, metadata) {
135
108
  return new Promise((resolve, reject) => {
136
109
  const browsersList = require('../package.json').browserslist;
137
-
138
110
  const compiledMetadata = {};
139
- const options = {}; // while using `less/lib/less-browser`, the global options are not passed to the `render` method, lets do it by ourselves
111
+ const options = {};
140
112
 
113
+ // while using `less/lib/less-browser`, the global options are not passed to the `render` method, lets do it by ourselves
141
114
  if (this.lessCompiler.options && typeof this.lessCompiler.options === 'object') {
142
115
  Object.assign(options, this.lessCompiler.options);
143
116
  }
144
-
145
117
  const customOptions = {
146
118
  modifyVars: modifyVars,
147
119
  plugins: [new LessPluginAutoPrefix({
@@ -173,7 +145,6 @@ class LessTemplateLoader {
173
145
  });
174
146
  });
175
147
  }
176
-
177
148
  compileScss(less, metadata) {
178
149
  return new Promise((resolve, reject) => {
179
150
  const compiledMetadata = {};
@@ -191,31 +162,25 @@ class LessTemplateLoader {
191
162
  });
192
163
  });
193
164
  }
194
-
195
165
  analyzeBootstrapTheme(theme, colorScheme, metadata, bootstrapMetadata, customLessContent, version) {
196
166
  let metadataVariables = '';
197
-
198
167
  for (const key in bootstrapMetadata) {
199
168
  if (Object.prototype.hasOwnProperty.call(bootstrapMetadata, key)) {
200
169
  metadataVariables += bootstrapMetadata[key] + ': dx-empty' + (version === 4 ? ' !default' : '') + ';';
201
170
  }
202
171
  }
203
-
204
172
  return new Promise(resolve => {
205
173
  const processDxTheme = data => {
206
174
  const compiledMetadata = data.compiledMetadata;
207
175
  const modifyVars = {};
208
-
209
176
  for (const key in compiledMetadata) {
210
177
  if (Object.prototype.hasOwnProperty.call(compiledMetadata, key)) {
211
178
  const value = compiledMetadata[key];
212
-
213
179
  if (value !== 'dx-empty') {
214
180
  modifyVars[key] = value;
215
181
  }
216
182
  }
217
183
  }
218
-
219
184
  this._loadLess(theme, colorScheme).then(less => {
220
185
  const metadataVariables = {};
221
186
  metadata.forEach(metaItem => {
@@ -230,12 +195,11 @@ class LessTemplateLoader {
230
195
  });
231
196
  });
232
197
  };
233
-
234
198
  if (version === 3) {
235
199
  this.compileLess(metadataVariables + customLessContent, {}, bootstrapMetadata).then(processDxTheme);
236
200
  } else if (version === 4) {
237
201
  const defaultBootstrapVariablesUrl = this.bootstrapScssPath + '_variables.scss',
238
- defaultBootstrapFunctionsUrl = this.bootstrapScssPath + '_functions.scss';
202
+ defaultBootstrapFunctionsUrl = this.bootstrapScssPath + '_functions.scss';
239
203
  Promise.all([this.readFile(defaultBootstrapFunctionsUrl), this.readFile(defaultBootstrapVariablesUrl)]).then(files => {
240
204
  this.compileScss(files[0] + customLessContent + files[1] + metadataVariables, bootstrapMetadata).then(processDxTheme);
241
205
  }, () => {
@@ -244,23 +208,18 @@ class LessTemplateLoader {
244
208
  }
245
209
  });
246
210
  }
247
-
248
211
  _loadLess(theme, colorScheme) {
249
212
  const themeName = theme ? theme + '-' : '';
250
213
  return this._loadLessByFileName('theme-builder-' + themeName + colorScheme + '.less');
251
214
  }
252
-
253
215
  _loadLessByFileName(fileName) {
254
216
  return this.readFile(this.themeBuilderLessPath + fileName);
255
217
  }
256
-
257
218
  _makeInfoHeader() {
258
219
  const generatedBy = '* Generated by the DevExpress ThemeBuilder';
259
220
  const versionString = '* Version: ' + this.version;
260
221
  const link = '* http://js.devexpress.com/ThemeBuilder/';
261
222
  return ['/*', generatedBy, versionString, link, '*/'].join('\n') + '\n\n';
262
223
  }
263
-
264
224
  }
265
-
266
225
  module.exports = LessTemplateLoader;
@@ -1,15 +1,12 @@
1
1
  const semver = require('semver');
2
-
3
2
  class MetadataLoader {
4
3
  constructor() {
5
4
  this.fullMetadata = require('../data/metadata/dx-theme-builder-metadata');
6
5
  this.migrationMetadata = require('../data/migration-metadata/migration-metadata');
7
6
  }
8
-
9
7
  load(theme, colorScheme) {
10
8
  return new Promise(resolve => {
11
9
  const metadata = this.fullMetadata[theme + '_' + colorScheme.replace(/-/g, '_') + '_metadata'];
12
-
13
10
  if (semver.gte(this.version(), '18.2.8') && this.migrationMetadata[theme]) {
14
11
  this.migrationMetadata[theme].forEach(value => {
15
12
  metadata.push({
@@ -17,15 +14,11 @@ class MetadataLoader {
17
14
  });
18
15
  });
19
16
  }
20
-
21
17
  resolve(metadata);
22
18
  });
23
19
  }
24
-
25
20
  version() {
26
21
  return this.fullMetadata['_metadata_version'];
27
22
  }
28
-
29
23
  }
30
-
31
24
  module.exports = MetadataLoader;
@@ -3,21 +3,17 @@ class MetadataRepository {
3
3
  this.repositoryData = {};
4
4
  this.metadataLoader = metadataLoader;
5
5
  }
6
-
7
6
  getDataItemByKey(key, theme) {
8
7
  let result = null;
9
8
  const themeData = this.repositoryData[theme.name + '-' + theme.colorScheme];
10
-
11
9
  for (let i = 0; i < themeData.length; i++) {
12
10
  if (themeData[i].Key === key) {
13
11
  result = themeData[i];
14
12
  break;
15
13
  }
16
14
  }
17
-
18
15
  return result;
19
16
  }
20
-
21
17
  init(themes) {
22
18
  const promises = [];
23
19
  themes.forEach(theme => {
@@ -30,23 +26,18 @@ class MetadataRepository {
30
26
  });
31
27
  return Promise.all(promises);
32
28
  }
33
-
34
29
  getData(theme) {
35
30
  if (!theme) return this.repositoryData;
36
31
  return this.repositoryData[theme.name + '-' + theme.colorScheme];
37
32
  }
38
-
39
33
  updateData(data, theme) {
40
34
  data.forEach(item => {
41
35
  const dataItem = this.getDataItemByKey(item.key, theme);
42
36
  if (item) dataItem.Value = item.value;
43
37
  });
44
38
  }
45
-
46
39
  getVersion() {
47
40
  return this.metadataLoader.version();
48
41
  }
49
-
50
42
  }
51
-
52
43
  module.exports = MetadataRepository;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devextreme-themebuilder",
3
- "version": "19.1.14",
3
+ "version": "19.1.16",
4
4
  "description": "DevExtreme ThemeBuilder",
5
5
  "keywords": ["devextreme", "devexpress"],
6
6
  "main": "modules/builder.js",