devextreme-themebuilder 24.1.2-beta → 24.1.3

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.
@@ -1,150 +1,150 @@
1
- "use strict";
2
- /* eslint no-param-reassign: ["error", { "props": false }] */
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const commands_1 = __importDefault(require("./commands"));
8
- const themes_1 = __importDefault(require("./themes"));
9
- const logger_1 = require("./logger");
10
- const DEFAULT_OUT_COLOR_SCHEME = 'custom-scheme';
11
- const extname = (filename) => filename.substring(filename.lastIndexOf('.'));
12
- const getBootstrapConfig = (fileName, configVersion) => {
13
- const extension = extname(fileName);
14
- let bootstrap = false;
15
- let version = 0;
16
- if (extension === '.scss') {
17
- bootstrap = true;
18
- version = 4;
19
- }
20
- else if (extension === '.less') {
21
- bootstrap = true;
22
- version = 3;
23
- }
24
- if (version === 4 && (configVersion === 4 || configVersion === 5)) {
25
- version = configVersion;
26
- }
27
- return { isBootstrap: bootstrap, bootstrapVersion: version };
28
- };
29
- const getOutParameters = (command, themeName, config) => {
30
- var _a, _b, _c;
31
- let outputFile = (_a = config.outputFile) !== null && _a !== void 0 ? _a : '';
32
- let outColorScheme = (_b = config.outputColorScheme) !== null && _b !== void 0 ? _b : '';
33
- let fileFormat = ((_c = config.outputFormat) !== null && _c !== void 0 ? _c : '') || extname(outputFile).substr(1);
34
- const makeSwatch = !!config.makeSwatch;
35
- const base = !!config.base;
36
- const isColorSchemeValid = outColorScheme && /^[\w\-.]+$/.test(outColorScheme);
37
- if (!isColorSchemeValid) {
38
- (0, logger_1.log)(`'--output-color-scheme' is not valid. '${DEFAULT_OUT_COLOR_SCHEME}' will be used.`);
39
- }
40
- if (!outColorScheme || !isColorSchemeValid) {
41
- outColorScheme = DEFAULT_OUT_COLOR_SCHEME;
42
- }
43
- if (!fileFormat) {
44
- switch (command) {
45
- case commands_1.default.BUILD_THEME:
46
- fileFormat = 'css';
47
- break;
48
- case commands_1.default.BUILD_VARS:
49
- fileFormat = 'less';
50
- break;
51
- case commands_1.default.BUILD_META:
52
- fileFormat = 'json';
53
- break;
54
- default:
55
- fileFormat = 'css';
56
- break;
57
- }
58
- }
59
- if (!outputFile) {
60
- outputFile = `dx.${themeName}.${outColorScheme}.${fileFormat}`;
61
- }
62
- return {
63
- outputFile,
64
- fileFormat,
65
- outColorScheme,
66
- makeSwatch,
67
- base,
68
- };
69
- };
70
- const getThemeAndColorScheme = (config) => {
71
- let themeName = 'generic';
72
- let colorScheme = 'light';
73
- let foundTheme = null;
74
- if (config.baseTheme) {
75
- const dotIndex = config.baseTheme.indexOf('.');
76
- const passedThemeName = config.baseTheme.substr(0, dotIndex);
77
- const passedColorScheme = config.baseTheme.substr(dotIndex + 1).replace(/\./g, '-');
78
- foundTheme = themes_1.default.find((t) => t.name === passedThemeName
79
- && t.colorScheme === passedColorScheme);
80
- if (!foundTheme) {
81
- (0, logger_1.log)(`The base theme with name ${config.baseTheme} does not exist.`);
82
- }
83
- }
84
- else if (config.themeId) {
85
- foundTheme = themes_1.default.find((t) => t.themeId === parseInt(config.themeId.toString(), 10));
86
- if (!foundTheme) {
87
- (0, logger_1.log)(`The theme with ID ${config.themeId} does not exist.`);
88
- }
89
- }
90
- if (foundTheme) {
91
- themeName = foundTheme.name;
92
- colorScheme = foundTheme.colorScheme;
93
- }
94
- return {
95
- themeName,
96
- colorScheme,
97
- };
98
- };
99
- const processItemKeys = (config, processor) => {
100
- var _a;
101
- if ((_a = config.items) === null || _a === void 0 ? void 0 : _a.length) {
102
- config.items.forEach((item) => {
103
- item.key = processor(item.key);
104
- });
105
- }
106
- };
107
- const normalizePath = (path) => path + (!path.endsWith('/') ? '/' : '');
108
- const parseConfig = (config) => {
109
- var _a;
110
- const { command } = config;
111
- const metadataFilePath = (_a = config.inputFile) !== null && _a !== void 0 ? _a : '';
112
- const themeInfo = getThemeAndColorScheme(config);
113
- const bootstrapConfig = getBootstrapConfig(metadataFilePath, config.bootstrapVersion);
114
- const output = getOutParameters(command, themeInfo.themeName, config);
115
- delete config.baseTheme;
116
- delete config.outputColorScheme;
117
- delete config.outputFormat;
118
- delete config.outputFile;
119
- delete config.inputFile;
120
- delete config.themeId;
121
- if (config.lessPath) {
122
- config.lessPath = normalizePath(config.lessPath);
123
- }
124
- if (config.scssPath) {
125
- config.scssPath = normalizePath(config.scssPath);
126
- }
127
- if (config.widgets) {
128
- config.widgets = config.widgets.map((w) => w.toLowerCase());
129
- }
130
- [
131
- (key) => key.replace(/@treelist/, '@datagrid'),
132
- (key) => key.replace(/@/, '$'),
133
- (key) => key.toLowerCase().replace(/_/g, '-'),
134
- ].forEach((processor) => {
135
- processItemKeys(config, processor);
136
- });
137
- Object.assign(config, {
138
- data: config.data !== undefined ? config.data : {},
139
- fileFormat: output.fileFormat,
140
- themeName: themeInfo.themeName,
141
- colorScheme: themeInfo.colorScheme,
142
- outColorScheme: output.outColorScheme,
143
- isBootstrap: bootstrapConfig.isBootstrap,
144
- bootstrapVersion: bootstrapConfig.bootstrapVersion,
145
- out: output.outputFile,
146
- makeSwatch: output.makeSwatch,
147
- base: output.base,
148
- });
149
- };
150
- exports.default = parseConfig;
1
+ "use strict";
2
+ /* eslint no-param-reassign: ["error", { "props": false }] */
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const commands_1 = __importDefault(require("./commands"));
8
+ const themes_1 = __importDefault(require("./themes"));
9
+ const logger_1 = require("./logger");
10
+ const DEFAULT_OUT_COLOR_SCHEME = 'custom-scheme';
11
+ const extname = (filename) => filename.substring(filename.lastIndexOf('.'));
12
+ const getBootstrapConfig = (fileName, configVersion) => {
13
+ const extension = extname(fileName);
14
+ let bootstrap = false;
15
+ let version = 0;
16
+ if (extension === '.scss') {
17
+ bootstrap = true;
18
+ version = 4;
19
+ }
20
+ else if (extension === '.less') {
21
+ bootstrap = true;
22
+ version = 3;
23
+ }
24
+ if (version === 4 && (configVersion === 4 || configVersion === 5)) {
25
+ version = configVersion;
26
+ }
27
+ return { isBootstrap: bootstrap, bootstrapVersion: version };
28
+ };
29
+ const getOutParameters = (command, themeName, config) => {
30
+ var _a, _b, _c;
31
+ let outputFile = (_a = config.outputFile) !== null && _a !== void 0 ? _a : '';
32
+ let outColorScheme = (_b = config.outputColorScheme) !== null && _b !== void 0 ? _b : '';
33
+ let fileFormat = ((_c = config.outputFormat) !== null && _c !== void 0 ? _c : '') || extname(outputFile).substr(1);
34
+ const makeSwatch = !!config.makeSwatch;
35
+ const base = !!config.base;
36
+ const isColorSchemeValid = outColorScheme && /^[\w\-.]+$/.test(outColorScheme);
37
+ if (!isColorSchemeValid) {
38
+ (0, logger_1.log)(`'--output-color-scheme' is not valid. '${DEFAULT_OUT_COLOR_SCHEME}' will be used.`);
39
+ }
40
+ if (!outColorScheme || !isColorSchemeValid) {
41
+ outColorScheme = DEFAULT_OUT_COLOR_SCHEME;
42
+ }
43
+ if (!fileFormat) {
44
+ switch (command) {
45
+ case commands_1.default.BUILD_THEME:
46
+ fileFormat = 'css';
47
+ break;
48
+ case commands_1.default.BUILD_VARS:
49
+ fileFormat = 'less';
50
+ break;
51
+ case commands_1.default.BUILD_META:
52
+ fileFormat = 'json';
53
+ break;
54
+ default:
55
+ fileFormat = 'css';
56
+ break;
57
+ }
58
+ }
59
+ if (!outputFile) {
60
+ outputFile = `dx.${themeName}.${outColorScheme}.${fileFormat}`;
61
+ }
62
+ return {
63
+ outputFile,
64
+ fileFormat,
65
+ outColorScheme,
66
+ makeSwatch,
67
+ base,
68
+ };
69
+ };
70
+ const getThemeAndColorScheme = (config) => {
71
+ let themeName = 'generic';
72
+ let colorScheme = 'light';
73
+ let foundTheme = null;
74
+ if (config.baseTheme) {
75
+ const dotIndex = config.baseTheme.indexOf('.');
76
+ const passedThemeName = config.baseTheme.substr(0, dotIndex);
77
+ const passedColorScheme = config.baseTheme.substr(dotIndex + 1).replace(/\./g, '-');
78
+ foundTheme = themes_1.default.find((t) => t.name === passedThemeName
79
+ && t.colorScheme === passedColorScheme);
80
+ if (!foundTheme) {
81
+ (0, logger_1.log)(`The base theme with name ${config.baseTheme} does not exist.`);
82
+ }
83
+ }
84
+ else if (config.themeId) {
85
+ foundTheme = themes_1.default.find((t) => t.themeId === parseInt(config.themeId.toString(), 10));
86
+ if (!foundTheme) {
87
+ (0, logger_1.log)(`The theme with ID ${config.themeId} does not exist.`);
88
+ }
89
+ }
90
+ if (foundTheme) {
91
+ themeName = foundTheme.name;
92
+ colorScheme = foundTheme.colorScheme;
93
+ }
94
+ return {
95
+ themeName,
96
+ colorScheme,
97
+ };
98
+ };
99
+ const processItemKeys = (config, processor) => {
100
+ var _a;
101
+ if ((_a = config.items) === null || _a === void 0 ? void 0 : _a.length) {
102
+ config.items.forEach((item) => {
103
+ item.key = processor(item.key);
104
+ });
105
+ }
106
+ };
107
+ const normalizePath = (path) => path + (!path.endsWith('/') ? '/' : '');
108
+ const parseConfig = (config) => {
109
+ var _a;
110
+ const { command } = config;
111
+ const metadataFilePath = (_a = config.inputFile) !== null && _a !== void 0 ? _a : '';
112
+ const themeInfo = getThemeAndColorScheme(config);
113
+ const bootstrapConfig = getBootstrapConfig(metadataFilePath, config.bootstrapVersion);
114
+ const output = getOutParameters(command, themeInfo.themeName, config);
115
+ delete config.baseTheme;
116
+ delete config.outputColorScheme;
117
+ delete config.outputFormat;
118
+ delete config.outputFile;
119
+ delete config.inputFile;
120
+ delete config.themeId;
121
+ if (config.lessPath) {
122
+ config.lessPath = normalizePath(config.lessPath);
123
+ }
124
+ if (config.scssPath) {
125
+ config.scssPath = normalizePath(config.scssPath);
126
+ }
127
+ if (config.widgets) {
128
+ config.widgets = config.widgets.map((w) => w.toLowerCase());
129
+ }
130
+ [
131
+ (key) => key.replace(/@treelist/, '@datagrid'),
132
+ (key) => key.replace(/@/, '$'),
133
+ (key) => key.toLowerCase().replace(/_/g, '-'),
134
+ ].forEach((processor) => {
135
+ processItemKeys(config, processor);
136
+ });
137
+ Object.assign(config, {
138
+ data: config.data !== undefined ? config.data : {},
139
+ fileFormat: output.fileFormat,
140
+ themeName: themeInfo.themeName,
141
+ colorScheme: themeInfo.colorScheme,
142
+ outColorScheme: output.outColorScheme,
143
+ isBootstrap: bootstrapConfig.isBootstrap,
144
+ bootstrapVersion: bootstrapConfig.bootstrapVersion,
145
+ out: output.outputFile,
146
+ makeSwatch: output.makeSwatch,
147
+ base: output.base,
148
+ });
149
+ };
150
+ exports.default = parseConfig;
package/modules/logger.js CHANGED
@@ -1,16 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.log = void 0;
4
- /* eslint no-console: 0 */
5
- function log(message, data = undefined) {
6
- const debugEnvVariableName = 'THEMEBUILDER_DEBUG';
7
- const needLog = typeof process !== 'undefined' && process.env && process.env[debugEnvVariableName] !== undefined;
8
- if (!needLog)
9
- return;
10
- let timedMessage = `${new Date().toISOString()}: ${message}`;
11
- if (data !== undefined) {
12
- timedMessage += `: ${JSON.stringify(data, null, 2).substr(0, 50)}`;
13
- }
14
- console.log(timedMessage);
15
- }
16
- exports.log = log;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.log = void 0;
4
+ /* eslint no-console: 0 */
5
+ function log(message, data = undefined) {
6
+ const debugEnvVariableName = 'THEMEBUILDER_DEBUG';
7
+ const needLog = typeof process !== 'undefined' && process.env && process.env[debugEnvVariableName] !== undefined;
8
+ if (!needLog)
9
+ return;
10
+ let timedMessage = `${new Date().toISOString()}: ${message}`;
11
+ if (data !== undefined) {
12
+ timedMessage += `: ${JSON.stringify(data, null, 2).substr(0, 50)}`;
13
+ }
14
+ console.log(timedMessage);
15
+ }
16
+ exports.log = log;
@@ -1,83 +1,83 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.parseString = exports.parse = exports.color = void 0;
27
- const sass = __importStar(require("sass-embedded"));
28
- const color = (value) => {
29
- const getHex = (colorValue) => colorValue.toString(16).padStart(2, '0');
30
- const alpha = Math.round(255 * value.alpha);
31
- if (alpha === 0) {
32
- return 'transparent';
33
- }
34
- const hexRed = getHex(value.red);
35
- const hexGreen = getHex(value.green);
36
- const hexBlue = getHex(value.blue);
37
- const hexAlpha = alpha === 255 ? '' : getHex(alpha);
38
- return `#${hexRed}${hexGreen}${hexBlue}${hexAlpha}`;
39
- };
40
- exports.color = color;
41
- const parse = (value) => {
42
- let result = value.toString();
43
- if (value instanceof sass.SassColor) {
44
- result = (0, exports.color)(value);
45
- }
46
- return result;
47
- };
48
- exports.parse = parse;
49
- /**
50
- * Parse a string as a Sass object
51
- * cribbed from davidkpiano/sassport
52
- *
53
- * @param {string} str
54
- * @return {Value}
55
- */
56
- const parseString = (str) => {
57
- // eslint-disable-next-line @typescript-eslint/init-declarations
58
- let result;
59
- try {
60
- sass.compileString(`$_: ___([${str}]);`, {
61
- functions: {
62
- '___($value)': ([listValue]) => {
63
- if (listValue.asList.size > 1) {
64
- result = new sass.SassList(listValue.asList, {
65
- brackets: false,
66
- separator: listValue.separator,
67
- });
68
- }
69
- else {
70
- result = listValue.get(0);
71
- }
72
- return result;
73
- },
74
- },
75
- });
76
- }
77
- catch (e) {
78
- // debugger;
79
- return new sass.SassString(str);
80
- }
81
- return result;
82
- };
83
- exports.parseString = parseString;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.parseString = exports.parse = exports.color = void 0;
27
+ const sass = __importStar(require("sass-embedded"));
28
+ const color = (value) => {
29
+ const getHex = (colorValue) => colorValue.toString(16).padStart(2, '0');
30
+ const alpha = Math.round(255 * value.alpha);
31
+ if (alpha === 0) {
32
+ return 'transparent';
33
+ }
34
+ const hexRed = getHex(value.red);
35
+ const hexGreen = getHex(value.green);
36
+ const hexBlue = getHex(value.blue);
37
+ const hexAlpha = alpha === 255 ? '' : getHex(alpha);
38
+ return `#${hexRed}${hexGreen}${hexBlue}${hexAlpha}`;
39
+ };
40
+ exports.color = color;
41
+ const parse = (value) => {
42
+ let result = value.toString();
43
+ if (value instanceof sass.SassColor) {
44
+ result = (0, exports.color)(value);
45
+ }
46
+ return result;
47
+ };
48
+ exports.parse = parse;
49
+ /**
50
+ * Parse a string as a Sass object
51
+ * cribbed from davidkpiano/sassport
52
+ *
53
+ * @param {string} str
54
+ * @return {Value}
55
+ */
56
+ const parseString = (str) => {
57
+ // eslint-disable-next-line @typescript-eslint/init-declarations
58
+ let result;
59
+ try {
60
+ sass.compileString(`$_: ___([${str}]);`, {
61
+ functions: {
62
+ '___($value)': ([listValue]) => {
63
+ if (listValue.asList.size > 1) {
64
+ result = new sass.SassList(listValue.asList, {
65
+ brackets: false,
66
+ separator: listValue.separator,
67
+ });
68
+ }
69
+ else {
70
+ result = listValue.get(0);
71
+ }
72
+ return result;
73
+ },
74
+ },
75
+ });
76
+ }
77
+ catch (e) {
78
+ // debugger;
79
+ return new sass.SassString(str);
80
+ }
81
+ return result;
82
+ };
83
+ exports.parseString = parseString;