@zohodesk/react-cli 0.0.1-exp.175.1 → 0.0.1-exp.176.11
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +35 -40
- package/docs/SelectorWeight.md +6 -0
- package/docs/VariableConversion.md +33 -1
- package/lib/babel/cmjs-plugins-presets.js +4 -0
- package/lib/babel/es-plugins-presets.js +4 -0
- package/lib/common/getEntries.js +10 -0
- package/lib/common/getPublicPathConfig.js +6 -0
- package/lib/common/index.js +5 -0
- package/lib/common/splitChunks.js +13 -2
- package/lib/common/sslcertUpdater.js +17 -6
- package/lib/common/templateParameters.js +2 -0
- package/lib/common/testPattern.js +21 -10
- package/lib/common/valueReplacer.js +15 -0
- package/lib/configs/jest.config.js +9 -0
- package/lib/configs/libAlias.js +2 -4
- package/lib/configs/webpack.component.umd.config.js +5 -0
- package/lib/configs/webpack.css.umd.config.js +13 -5
- package/lib/configs/webpack.dev.config.js +36 -2
- package/lib/configs/webpack.docs.config.js +21 -1
- package/lib/configs/webpack.impact.config.js +19 -1
- package/lib/configs/webpack.prod.config.js +37 -3
- package/lib/hooks/docsProptypeHook.js +7 -3
- package/lib/jest/commitedFilesResult.js +45 -3
- package/lib/jest/coverageCollector.js +11 -0
- package/lib/jest/jsonMaker.js +6 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +8 -0
- package/lib/jest/preProcessors/jsPreprocessor.js +2 -0
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +3 -0
- package/lib/jest/result.js +22 -0
- package/lib/jest/run.js +17 -6
- package/lib/jest/setup.js +57 -5
- package/lib/loaderUtils/configsAssetsLoaders.js +11 -1
- package/lib/loaderUtils/getCSSLoaders.js +35 -20
- package/lib/loaderUtils/getDevJsLoaders.js +8 -0
- package/lib/loaderUtils/index.js +3 -0
- package/lib/loaderUtils/windowsModification.js +11 -0
- package/lib/loaders/docsLoader.js +7 -0
- package/lib/loaders/docsPropsLoader.js +7 -3
- package/lib/loaders/fileBountryLoader.js +2 -0
- package/lib/loaders/fileLoader.js +22 -11
- package/lib/loaders/scriptInstrumentLoader.js +13 -5
- package/lib/loaders/selectorMappingLoader.js +25 -7
- package/lib/loaders/workerLoader.js +20 -4
- package/lib/middlewares/HMRMiddleware.js +26 -13
- package/lib/middlewares/SSTMiddleware.js +3 -0
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +9 -3
- package/lib/pluginUtils/getDevPlugins.js +63 -17
- package/lib/pluginUtils/getDocsPlugins.js +10 -1
- package/lib/pluginUtils/getLibraryImactPlugins.js +5 -4
- package/lib/pluginUtils/getLibraryPlugins.js +5 -0
- package/lib/pluginUtils/getProdPlugins.js +72 -23
- package/lib/pluginUtils/getServerPlugins.js +5 -0
- package/lib/pluginUtils/getUMDCSSPlugins.js +7 -0
- package/lib/pluginUtils/getUMDComponentPlugins.js +7 -0
- package/lib/pluginUtils/index.js +8 -0
- package/lib/plugins/CdnChangePlugin.js +14 -0
- package/lib/plugins/CleanupStatsPlugin.js +5 -0
- package/lib/plugins/EFCPlugin.js +34 -23
- package/lib/plugins/EFCTemplatePlugin.js +32 -23
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +34 -8
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +17 -12
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +39 -8
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +29 -14
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +22 -13
- package/lib/plugins/I18nSplitPlugin/index.js +23 -13
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +12 -2
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +1 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +5 -0
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +6 -0
- package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -2
- package/lib/plugins/ManifestPlugin.js +17 -0
- package/lib/plugins/ModuleStatsPlugin.js +23 -0
- package/lib/plugins/OptimizeJSPlugin.js +7 -0
- package/lib/plugins/PublicPathCallbackPlugin.js +10 -0
- package/lib/plugins/PublicPathChangePlugin.js +36 -4
- package/lib/plugins/ReportGeneratePlugin.js +30 -4
- package/lib/plugins/RequireVariablePublicPlugin.js +6 -0
- package/lib/plugins/ResourceHintsPlugin.js +10 -3
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +16 -9
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
- package/lib/plugins/ScriptInstrumentPlugin.js +7 -0
- package/lib/plugins/SelectorPlugin.js +97 -0
- package/lib/plugins/ServiceWorkerPlugin.js +20 -4
- package/lib/plugins/ShadowDOMSupportPlugin.js +40 -3
- package/lib/plugins/SourceMapHookPlugin.js +9 -0
- package/lib/plugins/TPHashMappingPlugin.js +15 -1
- package/lib/plugins/UglifyCSSPlugin.js +9 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +35 -2
- package/lib/plugins/VariableConversionCollector.js +252 -0
- package/lib/plugins/composeCommonPlugin.js +30 -0
- package/lib/plugins/index.js +19 -0
- package/lib/plugins/libraryImpactPlugin.js +32 -0
- package/lib/plugins/webpackwatchrunplugin.js +5 -0
- package/lib/postcss-plugins/ExcludePlugin.js +4 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +27 -14
- package/lib/postcss-plugins/ValueReplacer.js +6 -9
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
- package/lib/postcss-plugins/hoverActivePlugin.js +66 -30
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +40 -13
- package/lib/postcss-plugins/variableModificationPlugin/index.js +215 -141
- package/lib/postcss-plugins/variableModifier.js +20 -13
- package/lib/schemas/index.js +23 -4
- package/lib/servers/clusterHubServer.js +10 -0
- package/lib/servers/devBuild.js +24 -13
- package/lib/servers/docsServer.js +2 -0
- package/lib/servers/docsServerCore.js +21 -0
- package/lib/servers/getCliPath.js +9 -0
- package/lib/servers/helpServer.js +5 -0
- package/lib/servers/httpsOptions.js +4 -0
- package/lib/servers/impactServer.js +34 -2
- package/lib/servers/mockserver.js +9 -0
- package/lib/servers/nowatchserver.js +34 -12
- package/lib/servers/scrServer.js +20 -13
- package/lib/servers/server.js +35 -7
- package/lib/servers/ssServer.js +16 -0
- package/lib/templates/CoverageScriptTemplate.js +14 -0
- package/lib/templates/WMSTemplate.js +12 -6
- package/lib/utils/babelPresets.js +2 -0
- package/lib/utils/clean.js +8 -2
- package/lib/utils/copy.js +6 -0
- package/lib/utils/copyTimezones.js +8 -0
- package/lib/utils/createEventStream.js +4 -0
- package/lib/utils/cssClassNameGenerate.js +19 -3
- package/lib/utils/cssURLReplacer.js +50 -38
- package/lib/utils/dependencyPostPublish.js +9 -0
- package/lib/utils/fileUtils.js +26 -0
- package/lib/utils/folderIterator.js +10 -0
- package/lib/utils/getComponents.js +21 -0
- package/lib/utils/getCurrentBranch.js +5 -0
- package/lib/utils/getDependenciesImpactList.js +21 -0
- package/lib/utils/getFileType.js +49 -0
- package/lib/utils/getHash.js +7 -0
- package/lib/utils/getIp.js +2 -0
- package/lib/utils/getOptions.js +39 -14
- package/lib/utils/getServerURL.js +7 -0
- package/lib/utils/index.js +47 -2
- package/lib/utils/init.js +1 -0
- package/lib/utils/initPreCommitHook.js +29 -6
- package/lib/utils/jsonHelper.js +19 -2
- package/lib/utils/libraryImpactConfig.js +2 -0
- package/lib/utils/lint/addScripts.js +5 -2
- package/lib/utils/lint/checkExistingConfig.js +12 -3
- package/lib/utils/lint/copyConfigs.js +3 -0
- package/lib/utils/lint/index.js +9 -0
- package/lib/utils/lint/lintScripts.js +1 -0
- package/lib/utils/lint/lintSetup.js +4 -3
- package/lib/utils/lint/lintStagedPreCommitHook.js +1 -0
- package/lib/utils/lint/question.js +7 -0
- package/lib/utils/lintReporter.js +20 -0
- package/lib/utils/mailSender.js +7 -0
- package/lib/utils/pullOrigin.js +4 -0
- package/lib/utils/reinstallDependencies.js +28 -0
- package/lib/utils/removeAttributes.js +7 -0
- package/lib/utils/repoClone.js +27 -2
- package/lib/utils/request.js +12 -0
- package/lib/utils/rtl.js +16 -4
- package/lib/utils/setEnvVariables.js +2 -0
- package/lib/utils/ssTestHack.js +10 -0
- package/lib/utils/switchBranch.js +4 -0
- package/lib/utils/urlConcat.js +4 -0
- package/lib/utils/useExitCleanup.js +10 -9
- package/package.json +10 -9
@@ -1,7 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _postcss = _interopRequireDefault(require("postcss"));
|
4
|
+
|
4
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6
|
+
|
5
7
|
// module.exports = postcss.plugin('postcss-value-replacer', opts => {
|
6
8
|
// const { plugins } = opts;
|
7
9
|
// return (root, result) => {
|
@@ -17,8 +19,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
17
19
|
// };
|
18
20
|
// });
|
19
21
|
// export default
|
20
|
-
module.exports = _postcss.default.plugin('postcss-value-replacer', (valueReplacer = {}) =>
|
21
|
-
// Work with options here
|
22
|
+
module.exports = _postcss.default.plugin('postcss-value-replacer', (valueReplacer = {}) => // Work with options here
|
22
23
|
root => {
|
23
24
|
root.walkDecls(decl => {
|
24
25
|
valueReplacer.forEach(obj => {
|
@@ -26,15 +27,11 @@ root => {
|
|
26
27
|
let ks = Object.keys(obj.values).sort((a, b) => b.length - a.length);
|
27
28
|
ks.forEach(k => {
|
28
29
|
decl.value = decl.value.replace(k, obj.values[k]);
|
29
|
-
});
|
30
|
-
//decl.value = obj.values[decl.value];
|
30
|
+
}); //decl.value = obj.values[decl.value];
|
31
31
|
}
|
32
|
-
});
|
33
|
-
//console.log({root, roots:root+""}, root+"")
|
32
|
+
}); //console.log({root, roots:root+""}, root+"")
|
34
33
|
// Transform CSS AST here
|
35
|
-
});
|
36
|
-
|
37
|
-
// root.walkDecls(decl => {
|
34
|
+
}); // root.walkDecls(decl => {
|
38
35
|
// valueReplacer.forEach(obj => {
|
39
36
|
// if (
|
40
37
|
// obj.props.indexOf(decl.prop) !== -1 &&
|
@@ -1,7 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
const fs = require('fs');
|
4
|
+
|
4
5
|
const postcss = require('postcss');
|
6
|
+
|
5
7
|
function expectRunPostCss(inputFile, outputfile, cb) {
|
6
8
|
const inputStr = fs.readFileSync(inputFile, 'utf-8');
|
7
9
|
postcss(plugins).process(inputStr, {
|
@@ -12,6 +14,7 @@ function expectRunPostCss(inputFile, outputfile, cb) {
|
|
12
14
|
cb();
|
13
15
|
});
|
14
16
|
}
|
17
|
+
|
15
18
|
describe('To Check Hover active postcss Plugin ', () => {
|
16
19
|
test('should handle normal rule hover', cb => {
|
17
20
|
expectRunPostCss('test1Input.css', 'test1Output.css', cb);
|
@@ -1,24 +1,28 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _postcss = _interopRequireDefault(require("postcss"));
|
4
|
+
|
4
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6
|
+
|
5
7
|
/**
|
6
8
|
* we have give support for ignore(exclude) comments
|
7
9
|
* These are the comments' keyword
|
8
10
|
*/
|
9
11
|
const hoverIgnoreQuery = 'Hover:ignore',
|
10
|
-
|
11
|
-
|
12
|
+
activeIgnoreQuery = 'Active:ignore',
|
13
|
+
hoverActiveIgnoreQuery = 'HoverActive:ignore';
|
12
14
|
const medHoverIgnoreQuery = 'MedHover:ignore',
|
13
|
-
|
14
|
-
|
15
|
+
medActiveIgnoreQuery = 'MedActive:ignore',
|
16
|
+
medHoverActiveIgnoreQuery = 'MedHoverActive:ignore';
|
15
17
|
let hoverMedQuerySuffix = '';
|
16
18
|
let hoverNoneMedQuerySuffix = '';
|
17
19
|
const ruleIgnoreCommentRegex = /(Hover:ignore|Active:ignore|HoverActive:ignore)/g;
|
18
20
|
const mediaQueryIgnoreCommentRegex = /(MedHover:ignore|MedActive:ignore|MedHoverActive:ignore)/g;
|
21
|
+
|
19
22
|
function isComment(node) {
|
20
23
|
return node && node.type === 'comment' && node.text !== undefined;
|
21
24
|
}
|
25
|
+
|
22
26
|
function isHoverPresent(atrule) {
|
23
27
|
let hoverPresent = false;
|
24
28
|
atrule.walkRules(rule => {
|
@@ -28,6 +32,7 @@ function isHoverPresent(atrule) {
|
|
28
32
|
});
|
29
33
|
return hoverPresent;
|
30
34
|
}
|
35
|
+
|
31
36
|
function checkForUsualClass(root, sel) {
|
32
37
|
let present = false;
|
33
38
|
sel.split(',').forEach(value => {
|
@@ -42,24 +47,31 @@ function checkForUsualClass(root, sel) {
|
|
42
47
|
});
|
43
48
|
return present;
|
44
49
|
}
|
50
|
+
|
45
51
|
module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHoverActiveString => rootOriginal => {
|
46
52
|
const hoverRules = [];
|
47
53
|
const positionsObj = {};
|
48
54
|
hoverMedQuerySuffix = mediaQueryHoverActiveString.hover;
|
49
55
|
hoverNoneMedQuerySuffix = mediaQueryHoverActiveString.none;
|
56
|
+
|
50
57
|
function isRuleHasIgnoreComment(index, type) {
|
51
58
|
const prevNode = rootOriginal.nodes[index - 1];
|
59
|
+
|
52
60
|
if (isComment(prevNode)) {
|
53
61
|
return prevNode.text === type;
|
54
62
|
}
|
63
|
+
|
55
64
|
return false;
|
56
65
|
}
|
66
|
+
|
57
67
|
function isMediaQueryHasIgnoreComment(node, type) {
|
58
68
|
if (isComment(node)) {
|
59
69
|
return node.text === type;
|
60
70
|
}
|
71
|
+
|
61
72
|
return false;
|
62
73
|
}
|
74
|
+
|
63
75
|
function hasIgnoreComment({
|
64
76
|
index,
|
65
77
|
atrule,
|
@@ -68,11 +80,14 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
68
80
|
if (type.match(mediaQueryIgnoreCommentRegex)) {
|
69
81
|
return isMediaQueryHasIgnoreComment(atrule.nodes[index - 1], type.slice(3));
|
70
82
|
}
|
83
|
+
|
71
84
|
if (type.match(ruleIgnoreCommentRegex)) {
|
72
85
|
return isRuleHasIgnoreComment(index, type);
|
73
86
|
}
|
87
|
+
|
74
88
|
return false;
|
75
89
|
}
|
90
|
+
|
76
91
|
function getPositionsOfHoverAndActiveMedQueries(parent) {
|
77
92
|
const allNodes = rootOriginal.nodes;
|
78
93
|
const hoverMediaQuery = `${parent.params} and ${hoverMedQuerySuffix}`;
|
@@ -83,6 +98,7 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
83
98
|
};
|
84
99
|
return positions;
|
85
100
|
}
|
101
|
+
|
86
102
|
function handleMedHoverAndHoverActiveIgnore(atrule, index) {
|
87
103
|
return !hasIgnoreComment({
|
88
104
|
atrule,
|
@@ -94,6 +110,7 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
94
110
|
type: medHoverActiveIgnoreQuery
|
95
111
|
});
|
96
112
|
}
|
113
|
+
|
97
114
|
function handleMedActiveAndHoverActiveIgnore(atrule, index) {
|
98
115
|
return !hasIgnoreComment({
|
99
116
|
atrule,
|
@@ -105,6 +122,7 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
105
122
|
type: medHoverActiveIgnoreQuery
|
106
123
|
});
|
107
124
|
}
|
125
|
+
|
108
126
|
function handleHoverAndHoverActiveIgnore(index) {
|
109
127
|
return !hasIgnoreComment({
|
110
128
|
index,
|
@@ -114,6 +132,7 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
114
132
|
type: hoverActiveIgnoreQuery
|
115
133
|
});
|
116
134
|
}
|
135
|
+
|
117
136
|
function handleActiveAndHoverActiveIgnore(index) {
|
118
137
|
return !hasIgnoreComment({
|
119
138
|
index,
|
@@ -123,6 +142,7 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
123
142
|
type: hoverActiveIgnoreQuery
|
124
143
|
});
|
125
144
|
}
|
145
|
+
|
126
146
|
function handleAllIgnoreCases(index) {
|
127
147
|
return !hasIgnoreComment({
|
128
148
|
index,
|
@@ -135,6 +155,7 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
135
155
|
type: hoverActiveIgnoreQuery
|
136
156
|
});
|
137
157
|
}
|
158
|
+
|
138
159
|
function mediaCommaQuery(rule, index) {
|
139
160
|
if (rule.parent.params !== undefined && !rule.parent.params.includes('hover')) {
|
140
161
|
//console.log(hovMed, actMed);
|
@@ -147,12 +168,16 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
147
168
|
const actQueries = [];
|
148
169
|
rule.selector.split(/\s*,\s*/).forEach(_subrule => {
|
149
170
|
const subrule = _subrule.trim();
|
171
|
+
|
150
172
|
const clone = rule.clone();
|
173
|
+
|
151
174
|
if (subrule.includes('hover')) {
|
152
175
|
clone.selector = subrule;
|
176
|
+
|
153
177
|
if (handleMedHoverAndHoverActiveIgnore(rule.parent, index)) {
|
154
178
|
hovQueries.push(subrule);
|
155
179
|
}
|
180
|
+
|
156
181
|
if (handleMedActiveAndHoverActiveIgnore(rule.parent, index)) {
|
157
182
|
actQueries.push(subrule);
|
158
183
|
}
|
@@ -160,11 +185,13 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
160
185
|
newSelector += `${subrule}, `;
|
161
186
|
}
|
162
187
|
});
|
188
|
+
|
163
189
|
if (hovQueries.length > 0) {
|
164
190
|
const clone = rule.clone();
|
165
191
|
clone.selector = hovQueries.join(',');
|
166
192
|
hovMed.append(clone);
|
167
193
|
}
|
194
|
+
|
168
195
|
if (actQueries.length > 0) {
|
169
196
|
const clone = rule.clone();
|
170
197
|
clone.selector = actQueries.join(',');
|
@@ -172,24 +199,29 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
172
199
|
selector: clone.selector.replace(/:hover/gi, ':active')
|
173
200
|
}));
|
174
201
|
}
|
202
|
+
|
175
203
|
if (handleMedHoverAndHoverActiveIgnore(rule.parent, index)) {
|
176
204
|
rule.selector = newSelector.substring(0, newSelector.length - 2);
|
177
205
|
}
|
206
|
+
|
178
207
|
if (rule.selector === '') {
|
179
208
|
rule.remove();
|
180
209
|
}
|
181
210
|
}
|
182
211
|
}
|
212
|
+
|
183
213
|
function mediaQuery(rule, index) {
|
184
214
|
if (rule.parent.params !== undefined && !rule.parent.params.includes('hover')) {
|
185
215
|
const {
|
186
216
|
hovMed,
|
187
217
|
actMed
|
188
218
|
} = getPositionsOfHoverAndActiveMedQueries(rule.parent);
|
219
|
+
|
189
220
|
if (rule.selector.includes('hover') && hovMed !== undefined && rule.parent.type === 'atrule') {
|
190
221
|
if (handleMedHoverAndHoverActiveIgnore(rule.parent, index)) {
|
191
222
|
hovMed.append(rule);
|
192
223
|
}
|
224
|
+
|
193
225
|
if (handleMedActiveAndHoverActiveIgnore(rule.parent, index)) {
|
194
226
|
actMed.append(rule.clone({
|
195
227
|
selector: rule.selector.replace(/:hover/gi, ':active')
|
@@ -198,12 +230,14 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
198
230
|
}
|
199
231
|
}
|
200
232
|
}
|
233
|
+
|
201
234
|
function commaQuery(rule, index) {
|
202
235
|
//console.log("comma" , rule.selector.split('\n'));
|
203
236
|
let newSelector = '';
|
204
237
|
const hovQueries = [];
|
205
238
|
rule.selector.split(/\s*,\s*/).forEach(_subrule => {
|
206
239
|
const subrule = _subrule.trim();
|
240
|
+
|
207
241
|
if (subrule.includes('hover')) {
|
208
242
|
// hoverRules.push({ rule: clone, index });
|
209
243
|
hovQueries.push(subrule);
|
@@ -211,6 +245,7 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
211
245
|
newSelector += `${subrule}, `;
|
212
246
|
}
|
213
247
|
});
|
248
|
+
|
214
249
|
if (hovQueries.length > 0) {
|
215
250
|
const clone = rule.clone();
|
216
251
|
clone.selector = hovQueries.join(',');
|
@@ -219,20 +254,23 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
219
254
|
index
|
220
255
|
});
|
221
256
|
}
|
257
|
+
|
222
258
|
if (handleHoverAndHoverActiveIgnore(index)) {
|
223
259
|
if (checkForUsualClass(rootOriginal, rule.selector)) {
|
224
260
|
rule.selector = newSelector.substring(0, newSelector.length - 2).trim();
|
225
261
|
}
|
226
262
|
}
|
263
|
+
|
227
264
|
if (rule.selector === '') {
|
228
265
|
rule.remove();
|
229
266
|
}
|
230
|
-
}
|
267
|
+
} // Start by identifying all :hover rules
|
268
|
+
|
231
269
|
|
232
|
-
// Start by identifying all :hover rules
|
233
270
|
rootOriginal.walkAtRules(atrule => {
|
234
271
|
const hoverQuery = `${atrule.params} and ${hoverMedQuerySuffix}`;
|
235
272
|
const activeQuery = `${atrule.params} and ${hoverNoneMedQuerySuffix}`;
|
273
|
+
|
236
274
|
if (isHoverPresent(atrule)) {
|
237
275
|
if (!positionsObj[hoverQuery] && !positionsObj[activeQuery]) {
|
238
276
|
rootOriginal.append({
|
@@ -258,17 +296,17 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
258
296
|
// plus, space and other media queries
|
259
297
|
//console.log("media", rule.selector)
|
260
298
|
mediaQuery(rule, index);
|
261
|
-
}
|
299
|
+
} // usual hover query
|
300
|
+
|
262
301
|
|
263
|
-
// usual hover query
|
264
302
|
if (!rule.selector.match(/,+| +|\++/g) && rule.parent !== undefined && rule.parent.name === undefined) {
|
265
303
|
hoverRules.push({
|
266
304
|
rule,
|
267
305
|
index
|
268
306
|
});
|
269
|
-
}
|
307
|
+
} //usual hover query with ',' ' ' '+'
|
308
|
+
|
270
309
|
|
271
|
-
//usual hover query with ',' ' ' '+'
|
272
310
|
if (rule.selector.match(/,+| +|\++/g) && rule.parent.name === undefined) {
|
273
311
|
if (rule.selector.includes(',')) {
|
274
312
|
commaQuery(rule, index);
|
@@ -278,69 +316,66 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
278
316
|
hoverRules.push({
|
279
317
|
rule,
|
280
318
|
index
|
281
|
-
});
|
282
|
-
//rule.remove();
|
319
|
+
}); //rule.remove();
|
283
320
|
}
|
284
321
|
}
|
285
322
|
}
|
286
|
-
});
|
287
|
-
// If there are any :hover rules in the input, then create media queries
|
323
|
+
}); // If there are any :hover rules in the input, then create media queries
|
288
324
|
// to automatically translate it into :active on touch-based devices
|
325
|
+
|
289
326
|
if (hoverRules.length > 0) {
|
290
327
|
// Create a media query targetting devices that actually support
|
291
328
|
// hover
|
292
329
|
const hoverQuery = rootOriginal.append({
|
293
330
|
name: 'media',
|
294
331
|
params: `${hoverMedQuerySuffix}`
|
295
|
-
}).last;
|
296
|
-
// Create a media query targetting devices that don't support hover
|
332
|
+
}).last; // Create a media query targetting devices that don't support hover
|
297
333
|
// (ie. devices where we should fall back to :active instead)
|
334
|
+
|
298
335
|
const activeQuery = rootOriginal.append({
|
299
336
|
name: 'media',
|
300
337
|
params: `${hoverNoneMedQuerySuffix}`
|
301
|
-
}).last;
|
302
|
-
|
303
|
-
// Loop through the hover rules and apply them to each of the media
|
338
|
+
}).last; // Loop through the hover rules and apply them to each of the media
|
304
339
|
// queries
|
305
340
|
// eslint-disable-next-line no-labels
|
341
|
+
|
306
342
|
outerLoop: for (const hoverRule of hoverRules) {
|
307
343
|
// determine if the rule has been nested inside another media
|
308
344
|
// query; in that case bail out as we have no way of reliably
|
309
345
|
// nesting these queries
|
310
346
|
let parentRule = hoverRule.rule.parent;
|
347
|
+
|
311
348
|
while (parentRule) {
|
312
349
|
if (parentRule.type === 'atrule' && parentRule.name === 'media') {
|
313
350
|
// eslint-disable-next-line no-labels
|
314
351
|
continue outerLoop;
|
315
352
|
}
|
316
|
-
parentRule = parentRule.parent;
|
317
|
-
}
|
318
353
|
|
319
|
-
|
354
|
+
parentRule = parentRule.parent;
|
355
|
+
} // Push a clone of the :hover rule 'as is' to queries where we
|
320
356
|
// expect the user's device to support hover
|
321
357
|
// ieQuery.append(hoverRule.clone());
|
322
358
|
|
359
|
+
|
323
360
|
if (handleHoverAndHoverActiveIgnore(hoverRule.index)) {
|
324
361
|
hoverQuery.append(hoverRule.rule.clone());
|
325
|
-
}
|
326
|
-
|
327
|
-
// Push a clone of the :hover rule, where we transform the
|
362
|
+
} // Push a clone of the :hover rule, where we transform the
|
328
363
|
// selector to :active to the query targetting devices that
|
329
364
|
// don't support hover
|
365
|
+
|
366
|
+
|
330
367
|
if (handleActiveAndHoverActiveIgnore(hoverRule.index)) {
|
331
368
|
activeQuery.append(hoverRule.rule.clone({
|
332
369
|
selector: hoverRule.rule.selector.replace(/:hover/gi, ':active')
|
333
370
|
}));
|
334
|
-
}
|
371
|
+
} // remove legacy rule from output
|
372
|
+
|
335
373
|
|
336
|
-
// remove legacy rule from output
|
337
374
|
if (handleAllIgnoreCases(hoverRule.index)) {
|
338
375
|
hoverRule.rule.remove();
|
339
376
|
}
|
340
377
|
}
|
341
|
-
}
|
342
|
-
|
343
|
-
// rootOriginal.walkAtRules(atrule => {
|
378
|
+
} // rootOriginal.walkAtRules(atrule => {
|
344
379
|
// if (
|
345
380
|
// (atrule !== undefined &&
|
346
381
|
// atrule.nodes !== undefined &&
|
@@ -350,4 +385,5 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
350
385
|
// atrule.remove();
|
351
386
|
// }
|
352
387
|
// });
|
388
|
+
|
353
389
|
});
|
@@ -4,28 +4,55 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.ErrorHandler = void 0;
|
7
|
+
|
7
8
|
class ErrorHandler {
|
8
9
|
constructor(allowedErrs) {
|
9
10
|
this.errors = [];
|
11
|
+
this.errorTable = [];
|
10
12
|
this.allowedErrs = allowedErrs;
|
13
|
+
Object.assign(this, {
|
14
|
+
DECLARATION_IGNORED: errObj => this.addError(` prop: ${errObj.decl.prop} ,\n value : ${errObj.decl.value} ,\n filename : ${errObj.filename} ,\n filepath : ${errObj.path} ,\n line : ${errObj.decl.source.start.line} ,\n message : Declaration Ignored`),
|
15
|
+
DECIMAL_CHECK: errObj => this.addError(` prop: ${errObj.decl.prop} ,\n value : ${errObj.decl.value} ,\n filename : ${errObj.filename} ,\n filepath : ${errObj.path} ,\n line : ${errObj.decl.source.start.line} ,\n unit : ${errObj.unitErrorVal} ,\n message : ${errObj.message}`),
|
16
|
+
DECIMAL_REJECT: errObj => this.addError(` prop: ${errObj.decl.prop} ,\n value : ${errObj.decl.value} ,\n filename : ${errObj.filename} ,\n filepath : ${errObj.path} ,\n line : ${errObj.decl.source.start.line} ,\n unit : ${errObj.unitErrorVal} ,\n message : ${errObj.message}`),
|
17
|
+
UNIT_ERROR: errObj => this.addError(` prop: ${errObj.decl.prop} ,\n value : ${errObj.decl.value} ,\n filename : ${errObj.filename} ,\n filepath : ${errObj.path} ,\n line : ${errObj.decl.source.start.line} ,\n unit : ${errObj.unitErrorVal} ,\n message : ${errObj.message}`),
|
18
|
+
RANGE_ERROR: errObj => this.addError(` prop: ${errObj.decl.prop} ,\n value : ${errObj.decl.value} ,\n filename : ${errObj.filename} ,\n filepath : ${errObj.path} ,\n line : ${errObj.decl.source.start.line} ,\n message : ${errObj.message}\r`),
|
19
|
+
VARIABLE_PRESENT: errObj => this.addError(` prop: ${errObj.decl.prop} ,\n value : ${errObj.decl.value} ,\n filename : ${errObj.filename} ,\n filepath : ${errObj.path} ,\n line : ${errObj.decl.source.start.line} ,\n message : ${errObj.message}`)
|
20
|
+
});
|
21
|
+
}
|
22
|
+
|
23
|
+
setAllowedErrs(allErrs) {
|
24
|
+
this.allowedErrs = allErrs;
|
25
|
+
['DECLARATION_IGNORED', 'DECIMAL_CHECK', 'DECIMAL_REJECT', 'UNIT_ERROR', 'RANGE_ERROR', 'VARIABLE_PRESENT'].forEach(err => {
|
26
|
+
if (!this.allowedErrs[err]) {
|
27
|
+
this[err] = () => null;
|
28
|
+
}
|
29
|
+
});
|
11
30
|
}
|
31
|
+
|
12
32
|
addError(errstr) {
|
13
33
|
this.errors.push(`{\n${errstr}\n}\n`);
|
14
34
|
}
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
} = this;
|
20
|
-
if (type === 'DECLARATION_IGNORED' && allowedErrs.DECLARATION_IGNORED) {
|
21
|
-
addError(errStr);
|
22
|
-
} else if (type === 'UNIT_ERROR' && allowedErrs.UNIT_ERROR) {
|
23
|
-
addError(errStr);
|
24
|
-
} else if (type === 'RANGE_ERROR' && allowedErrs.RANGE_ERROR) {
|
25
|
-
addError(errStr);
|
26
|
-
} else if (type === 'VARIABLE_PRESENT' && allowedErrs.VARIABLE_PRESENT) {
|
27
|
-
addError(errStr);
|
35
|
+
|
36
|
+
errorFunction(errObj) {
|
37
|
+
if (errObj.type && this.allowedErrs[errObj.type] && errObj.decl.prop && errObj.decl.value) {
|
38
|
+
this[errObj.type](errObj);
|
28
39
|
}
|
29
40
|
}
|
41
|
+
|
42
|
+
printError(errObj) {
|
43
|
+
console.log('{');
|
44
|
+
Object.keys(errObj).sort().forEach(key => {
|
45
|
+
if (key !== 'decl') {
|
46
|
+
console.log(`${key} : ${errObj[key]}`);
|
47
|
+
} else {
|
48
|
+
console.log(`prop : ${errObj.decl.prop}`);
|
49
|
+
console.log(`value : ${errObj.decl.value}`);
|
50
|
+
console.log(`linenum : ${errObj.decl.source.start.line}`);
|
51
|
+
}
|
52
|
+
});
|
53
|
+
console.log('}\n');
|
54
|
+
}
|
55
|
+
|
30
56
|
}
|
57
|
+
|
31
58
|
exports.ErrorHandler = ErrorHandler;
|