arui-scripts 18.5.0 → 18.6.0
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.
- package/.turbo/turbo-lint.log +6 -2
- package/.turbo/turbo-test.log +11 -8
- package/CHANGELOG.md +29 -0
- package/build/configs/postcss.config.d.ts +12 -4
- package/build/configs/postcss.config.js +13 -6
- package/build/configs/postcss.d.ts +1 -1
- package/build/configs/postcss.js +3 -1
- package/build/plugins/postcss-global-variables/postcss-global-variables.d.ts +6 -0
- package/build/plugins/postcss-global-variables/postcss-global-variables.js +38 -0
- package/build/plugins/postcss-global-variables/utils/utils.d.ts +7 -0
- package/build/plugins/postcss-global-variables/utils/utils.js +77 -0
- package/build/tsconfig-local.tsbuildinfo +1 -1
- package/package.json +1 -2
package/.turbo/turbo-lint.log
CHANGED
|
@@ -76,8 +76,12 @@
|
|
|
76
76
|
35:5 warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion
|
|
77
77
|
126:54 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
78
78
|
|
|
79
|
+
/home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/postcss.config.ts
|
|
80
|
+
10:49 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
81
|
+
11:88 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
82
|
+
|
|
79
83
|
/home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/postcss.ts
|
|
80
|
-
|
|
84
|
+
13:8 warning Prefer named exports import/no-default-export
|
|
81
85
|
|
|
82
86
|
/home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/process-assets-plugin-output.ts
|
|
83
87
|
5:8 warning Using exported name 'configs' as identifier for default export import/no-named-as-default
|
|
@@ -170,6 +174,6 @@
|
|
|
170
174
|
/home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/types.d.ts
|
|
171
175
|
4:12 warning Prefer named exports import/no-default-export
|
|
172
176
|
|
|
173
|
-
✖
|
|
177
|
+
✖ 79 problems (0 errors, 79 warnings)
|
|
174
178
|
0 errors and 2 warnings potentially fixable with the `--fix` option.
|
|
175
179
|
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -5,20 +5,23 @@ ts-jest[versions] (WARN) Version 29.7.0 of jest installed has not been tested wi
|
|
|
5
5
|
ts-jest[versions] (WARN) Version 5.6.3 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <5.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
|
|
6
6
|
ts-jest[versions] (WARN) Version 5.6.3 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <5.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
|
|
7
7
|
ts-jest[versions] (WARN) Version 5.6.3 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <5.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
|
|
8
|
-
PASS src/configs/
|
|
9
|
-
PASS src/configs/util/__tests__/
|
|
8
|
+
PASS src/configs/app-configs/__tests__/update-with-presets.tests.ts (18.153 s)
|
|
9
|
+
PASS src/configs/util/__tests__/get-polyfills.tests.ts
|
|
10
|
+
PASS src/plugins/postcss-global-variables/utils/__tests__/add-global-variable.tests.ts (18.679 s)
|
|
10
11
|
PASS src/configs/app-configs/__tests__/update-with-env.tests.ts
|
|
11
|
-
PASS src/configs/
|
|
12
|
-
PASS src/
|
|
12
|
+
PASS src/configs/util/__tests__/apply-overrides.tests.ts
|
|
13
|
+
PASS src/plugins/postcss-global-variables/utils/__tests__/parse-variables.tests.ts
|
|
13
14
|
PASS src/configs/app-configs/__tests__/update-with-package.tests.ts
|
|
15
|
+
PASS src/configs/app-configs/__tests__/validate-settings-keys.tests.ts
|
|
16
|
+
PASS src/plugins/postcss-global-variables/utils/__tests__/get-media-query-name.tests.ts
|
|
14
17
|
Failed to load /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/tsconfig.json: Missing baseUrl in compilerOptions
|
|
15
18
|
Failed to load /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/tsconfig.json: Missing baseUrl in compilerOptions
|
|
16
19
|
Failed to load /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/tsconfig.json: Missing baseUrl in compilerOptions
|
|
17
20
|
Failed to load /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/tsconfig.json: Missing baseUrl in compilerOptions
|
|
18
|
-
PASS src/configs/util/__tests__/find-plugin.tests.ts (
|
|
21
|
+
PASS src/configs/util/__tests__/find-plugin.tests.ts (23.652 s)
|
|
19
22
|
|
|
20
|
-
Test Suites:
|
|
21
|
-
Tests:
|
|
23
|
+
Test Suites: 10 passed, 10 total
|
|
24
|
+
Tests: 27 passed, 27 total
|
|
22
25
|
Snapshots: 0 total
|
|
23
|
-
Time:
|
|
26
|
+
Time: 24.826 s
|
|
24
27
|
Ran all test suites.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# [15.3.0](https://github.com/core-ds/arui-scripts/compare/v15.2.0...v15.3.0) (2023-06-30)
|
|
2
2
|
|
|
3
|
+
## 18.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#287](https://github.com/core-ds/arui-scripts/pull/287) [`fb3b80d`](https://github.com/core-ds/arui-scripts/commit/fb3b80db242978d88eb6c0eac382498b3aa04459) Thanks [@VladislavNsk](https://github.com/VladislavNsk)! - Добавлен кастомный плагин postcss-global-variables, для оптимизации времени обработки глобальных переменных.
|
|
8
|
+
@csstools/postcss-global-data _удален_
|
|
9
|
+
|
|
10
|
+
Проекты, которые использовали в оверрайдах кастомные настройки для плагина @csstools/postcss-global-data, должны перейти на использование postcss-global-variables следующим образом
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
postcss: (config) => {
|
|
14
|
+
const overrideConfig = config.map((plugin) => {
|
|
15
|
+
if (plugin.name === 'postCssGlobalVariables') {
|
|
16
|
+
return {
|
|
17
|
+
...plugin,
|
|
18
|
+
options: plugin.options.concat([
|
|
19
|
+
// ваши файлы
|
|
20
|
+
])
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return plugin;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return overrideConfig;
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Плагин работает только с глобальными переменными, если вам надо вставить что-то другое, отличное от глобальных переменных, вам нужно будет добавить @csstools/postcss-global-data в свой проект самостоятельно
|
|
31
|
+
|
|
3
32
|
## 18.5.0
|
|
4
33
|
|
|
5
34
|
### Minor Changes
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
+
import type { PluginCreator } from 'postcss';
|
|
2
|
+
type PostCssPluginName = string | PluginCreator<any>;
|
|
3
|
+
type PostcssPlugin = string | [string, unknown] | {
|
|
4
|
+
name: string;
|
|
5
|
+
plugin: PluginCreator<any>;
|
|
6
|
+
options?: unknown;
|
|
7
|
+
};
|
|
1
8
|
/**
|
|
2
9
|
* Функция для создания конфигурационного файла postcss
|
|
3
|
-
* @param {
|
|
10
|
+
* @param {PostCssPluginName[]} plugins список плагинов
|
|
4
11
|
* @param {Object} options коллекция конфигураций плагинов, где ключ - название плагина, а значение - аргумент для инициализации
|
|
5
12
|
* @returns {*}
|
|
6
13
|
*/
|
|
7
|
-
export declare function createPostcssConfig(plugins:
|
|
8
|
-
export declare const postcssPlugins:
|
|
14
|
+
export declare function createPostcssConfig(plugins: PostCssPluginName[], options: Record<string, unknown>): PostcssPlugin[];
|
|
15
|
+
export declare const postcssPlugins: PostCssPluginName[];
|
|
9
16
|
export declare const postcssPluginsOptions: {
|
|
10
17
|
'postcss-import': {
|
|
11
18
|
path: string[];
|
|
12
19
|
};
|
|
13
|
-
|
|
20
|
+
postCssGlobalVariables: {
|
|
14
21
|
files: string[];
|
|
15
22
|
};
|
|
16
23
|
'postcss-url': {
|
|
@@ -26,3 +33,4 @@ export declare const postcssPluginsOptions: {
|
|
|
26
33
|
overrideBrowserslist: string[];
|
|
27
34
|
};
|
|
28
35
|
};
|
|
36
|
+
export {};
|
|
@@ -6,20 +6,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.postcssPluginsOptions = exports.postcssPlugins = void 0;
|
|
7
7
|
exports.createPostcssConfig = createPostcssConfig;
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const postcss_global_variables_1 = require("../plugins/postcss-global-variables/postcss-global-variables");
|
|
9
10
|
const app_configs_1 = __importDefault(require("./app-configs"));
|
|
10
11
|
const supporting_browsers_1 = __importDefault(require("./supporting-browsers"));
|
|
11
12
|
/**
|
|
12
13
|
* Функция для создания конфигурационного файла postcss
|
|
13
|
-
* @param {
|
|
14
|
+
* @param {PostCssPluginName[]} plugins список плагинов
|
|
14
15
|
* @param {Object} options коллекция конфигураций плагинов, где ключ - название плагина, а значение - аргумент для инициализации
|
|
15
16
|
* @returns {*}
|
|
16
17
|
*/
|
|
17
18
|
function createPostcssConfig(plugins, options) {
|
|
18
19
|
return plugins.map((pluginName) => {
|
|
19
|
-
if (pluginName
|
|
20
|
-
return
|
|
20
|
+
if (typeof pluginName === 'string') {
|
|
21
|
+
return pluginName in options
|
|
22
|
+
? [pluginName, options[pluginName]]
|
|
23
|
+
: pluginName;
|
|
21
24
|
}
|
|
22
|
-
return
|
|
25
|
+
return {
|
|
26
|
+
name: pluginName.name,
|
|
27
|
+
plugin: pluginName,
|
|
28
|
+
options: options[pluginName.name]
|
|
29
|
+
};
|
|
23
30
|
});
|
|
24
31
|
}
|
|
25
32
|
exports.postcssPlugins = [
|
|
@@ -29,7 +36,7 @@ exports.postcssPlugins = [
|
|
|
29
36
|
'postcss-mixins',
|
|
30
37
|
'postcss-for',
|
|
31
38
|
'postcss-each',
|
|
32
|
-
|
|
39
|
+
postcss_global_variables_1.postCssGlobalVariables,
|
|
33
40
|
'postcss-custom-media',
|
|
34
41
|
'postcss-color-mod-function',
|
|
35
42
|
!app_configs_1.default.keepCssVars && 'postcss-custom-properties',
|
|
@@ -46,7 +53,7 @@ exports.postcssPluginsOptions = {
|
|
|
46
53
|
'postcss-import': {
|
|
47
54
|
path: ['./src'],
|
|
48
55
|
},
|
|
49
|
-
'
|
|
56
|
+
'postCssGlobalVariables': {
|
|
50
57
|
files: [path_1.default.join(__dirname, 'mq.css'), app_configs_1.default.componentsTheme].filter(Boolean),
|
|
51
58
|
},
|
|
52
59
|
'postcss-url': {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const postcssConfig: string
|
|
1
|
+
declare const postcssConfig: (string | import("postcss").Processor | import("postcss").Plugin | [string, unknown])[];
|
|
2
2
|
export default postcssConfig;
|
package/build/configs/postcss.js
CHANGED
|
@@ -5,5 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
|
|
7
7
|
const postcss_config_1 = require("./postcss.config");
|
|
8
|
-
const postcssConfig = (0, apply_overrides_1.default)('postcss', (0, postcss_config_1.createPostcssConfig)(postcss_config_1.postcssPlugins, postcss_config_1.postcssPluginsOptions))
|
|
8
|
+
const postcssConfig = (0, apply_overrides_1.default)('postcss', (0, postcss_config_1.createPostcssConfig)(postcss_config_1.postcssPlugins, postcss_config_1.postcssPluginsOptions)).map((plugin) => typeof plugin === 'string' || Array.isArray(plugin)
|
|
9
|
+
? plugin
|
|
10
|
+
: plugin.plugin(plugin.options));
|
|
9
11
|
exports.default = postcssConfig;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.postCssGlobalVariables = void 0;
|
|
4
|
+
const utils_1 = require("./utils/utils");
|
|
5
|
+
const postCssGlobalVariables = (opts) => {
|
|
6
|
+
const options = Object.assign({ files: [] }, opts);
|
|
7
|
+
const parsedVariables = {};
|
|
8
|
+
const parsedCustomMedia = {};
|
|
9
|
+
let rulesSelectors = new Set();
|
|
10
|
+
return {
|
|
11
|
+
postcssPlugin: '@alfalab/postcss-global-variables',
|
|
12
|
+
prepare() {
|
|
13
|
+
return {
|
|
14
|
+
postcssPlugin: '@alfalab/postcss-global-variables',
|
|
15
|
+
Once(root, postcssHelpers) {
|
|
16
|
+
if (!Object.keys(parsedVariables).length) {
|
|
17
|
+
options.files.forEach((filePath) => {
|
|
18
|
+
const importedCss = (0, utils_1.parseImport)(root, postcssHelpers, filePath);
|
|
19
|
+
(0, utils_1.parseVariables)(importedCss, parsedVariables);
|
|
20
|
+
(0, utils_1.parseMediaQuery)(importedCss, parsedCustomMedia);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const rootRule = (0, utils_1.insertParsedCss)(root, parsedVariables, parsedCustomMedia);
|
|
24
|
+
root.append(rootRule);
|
|
25
|
+
rulesSelectors.add(rootRule);
|
|
26
|
+
},
|
|
27
|
+
OnceExit() {
|
|
28
|
+
rulesSelectors.forEach((rule) => {
|
|
29
|
+
rule.remove();
|
|
30
|
+
});
|
|
31
|
+
rulesSelectors = new Set();
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
exports.postCssGlobalVariables = postCssGlobalVariables;
|
|
38
|
+
postCssGlobalVariables.postcss = true;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AtRule, Helpers, Root, Rule } from 'postcss';
|
|
2
|
+
export declare const getMediaQueryName: (rule: AtRule) => string;
|
|
3
|
+
export declare function parseImport(root: Root, postcssHelpers: Helpers, filePath: string): Root;
|
|
4
|
+
export declare const parseVariables: (importedFile: Root, parsedVariables: Record<string, string>) => void;
|
|
5
|
+
export declare const parseMediaQuery: (importedFile: Root, parsedCustomMedia: Record<string, AtRule>) => void;
|
|
6
|
+
export declare function addGlobalVariable(cssValue: string, rootSelector: Rule, parsedVariables: Record<string, string>): void;
|
|
7
|
+
export declare const insertParsedCss: (root: Root, parsedVariables: Record<string, string>, parsedCustomMedia: Record<string, AtRule>) => Rule;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.insertParsedCss = exports.parseMediaQuery = exports.parseVariables = exports.getMediaQueryName = void 0;
|
|
7
|
+
exports.parseImport = parseImport;
|
|
8
|
+
exports.addGlobalVariable = addGlobalVariable;
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const postcss_1 = require("postcss");
|
|
12
|
+
const getMediaQueryName = (rule) => rule.params.split(' ')[0];
|
|
13
|
+
exports.getMediaQueryName = getMediaQueryName;
|
|
14
|
+
function parseImport(root, postcssHelpers, filePath) {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
let resolvedPath = '';
|
|
17
|
+
try {
|
|
18
|
+
resolvedPath = path_1.default.resolve(filePath);
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
throw new Error(`Failed to read ${filePath} with error ${(err instanceof Error) ? err.message : err}`);
|
|
22
|
+
}
|
|
23
|
+
postcssHelpers.result.messages.push({
|
|
24
|
+
type: 'dependency',
|
|
25
|
+
plugin: 'postcss-global-environments',
|
|
26
|
+
file: resolvedPath,
|
|
27
|
+
parent: (_b = (_a = root.source) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.file,
|
|
28
|
+
});
|
|
29
|
+
const fileContents = fs_1.default.readFileSync(resolvedPath, 'utf8');
|
|
30
|
+
return postcssHelpers.postcss.parse(fileContents, { from: resolvedPath });
|
|
31
|
+
}
|
|
32
|
+
const parseVariables = (importedFile, parsedVariables) => {
|
|
33
|
+
importedFile.walkDecls((decl) => {
|
|
34
|
+
// eslint-disable-next-line no-param-reassign
|
|
35
|
+
parsedVariables[decl.prop] = decl.value;
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
exports.parseVariables = parseVariables;
|
|
39
|
+
const parseMediaQuery = (importedFile, parsedCustomMedia) => {
|
|
40
|
+
importedFile.walkAtRules('custom-media', (mediaRule) => {
|
|
41
|
+
const mediaName = (0, exports.getMediaQueryName)(mediaRule);
|
|
42
|
+
// eslint-disable-next-line no-param-reassign
|
|
43
|
+
parsedCustomMedia[mediaName] = mediaRule;
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
exports.parseMediaQuery = parseMediaQuery;
|
|
47
|
+
function addGlobalVariable(cssValue, rootSelector, parsedVariables) {
|
|
48
|
+
const variableMatches = cssValue.match(/var\(\s*--([^)]+)\s*\)/g);
|
|
49
|
+
if (variableMatches) {
|
|
50
|
+
variableMatches.forEach((match) => {
|
|
51
|
+
// var(--gap-24) => --gap-24
|
|
52
|
+
const variableName = match.slice(4, -1).trim();
|
|
53
|
+
if (parsedVariables[variableName]) {
|
|
54
|
+
rootSelector.append(new postcss_1.Declaration({ prop: variableName, value: parsedVariables[variableName] }));
|
|
55
|
+
// Рекурсивно проходимся по значениям css, там тоже могут использоваться переменные
|
|
56
|
+
addGlobalVariable(parsedVariables[variableName], rootSelector, parsedVariables);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const insertParsedCss = (root, parsedVariables, parsedCustomMedia) => {
|
|
62
|
+
const rootRule = new postcss_1.Rule({ selector: ':root' });
|
|
63
|
+
root.walkDecls((decl) => {
|
|
64
|
+
addGlobalVariable(decl.value, rootRule, parsedVariables);
|
|
65
|
+
});
|
|
66
|
+
root.walkAtRules('media', (rule) => {
|
|
67
|
+
const mediaFullName = (0, exports.getMediaQueryName)(rule);
|
|
68
|
+
if (mediaFullName.startsWith('(--')) {
|
|
69
|
+
const mediaName = mediaFullName.slice(1, -1);
|
|
70
|
+
if (parsedCustomMedia[mediaName]) {
|
|
71
|
+
root.append(parsedCustomMedia[mediaName]);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return rootRule;
|
|
76
|
+
};
|
|
77
|
+
exports.insertParsedCss = insertParsedCss;
|