@zohodesk/react-cli 0.0.1-exp.169.2 → 0.0.1-exp.175.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintignore +7 -7
- package/.eslintrc.js +180 -179
- package/.prettierrc +6 -6
- package/README.md +1028 -951
- package/bin/cli.js +483 -483
- package/cert/Tsicsezwild-22-23.crt +37 -37
- package/cert/Tsicsezwild-22-23.key +27 -27
- package/docs/CustomChunks.md +26 -26
- package/docs/DevStart.md +18 -18
- package/docs/HoverActive.md +12 -12
- package/docs/InstallNode.md +28 -28
- package/docs/TODOS.md +10 -10
- package/docs/ValueReplacer.md +60 -60
- package/docs/VariableConversion.md +678 -0
- package/docs/warnings_while_install.txt +35 -35
- package/files/eslintrc.js +62 -62
- package/files/prettierrc.js +3 -3
- package/lib/babel/cmjs-plugins-presets.js +0 -4
- package/lib/babel/es-plugins-presets.js +0 -4
- package/lib/common/getEntries.js +0 -10
- package/lib/common/getPublicPathConfig.js +0 -6
- package/lib/common/index.js +0 -5
- package/lib/common/splitChunks.js +2 -13
- package/lib/common/sslcertUpdater.js +6 -17
- package/lib/common/templateParameters.js +0 -2
- package/lib/common/testPattern.js +10 -21
- package/lib/common/valueReplacer.js +0 -15
- package/lib/configs/jest.config.js +8 -21
- package/lib/configs/libAlias.js +11 -2
- package/lib/configs/webpack.component.umd.config.js +0 -5
- package/lib/configs/webpack.css.umd.config.js +5 -13
- package/lib/configs/webpack.dev.config.js +13 -24
- package/lib/configs/webpack.docs.config.js +6 -12
- package/lib/configs/webpack.impact.config.js +6 -10
- package/lib/configs/webpack.prod.config.js +15 -26
- package/lib/hooks/docsProptypeHook.js +3 -7
- package/lib/jest/commitedFilesResult.js +3 -45
- package/lib/jest/coverageCollector.js +0 -11
- package/lib/jest/jsonMaker.js +0 -6
- package/lib/jest/preProcessors/cssPreprocessor.js +14 -13
- package/lib/jest/preProcessors/jsPreprocessor.js +0 -2
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +0 -3
- package/lib/jest/result.js +0 -22
- package/lib/jest/run.js +6 -17
- package/lib/jest/setup.js +5 -57
- package/lib/loaderUtils/configsAssetsLoaders.js +34 -44
- package/lib/loaderUtils/getCSSLoaders.js +41 -28
- package/lib/loaderUtils/getDevJsLoaders.js +0 -8
- package/lib/loaderUtils/index.js +0 -3
- package/lib/loaders/docsLoader.js +0 -7
- package/lib/loaders/docsPropsLoader.js +3 -7
- package/lib/loaders/fileBountryLoader.js +0 -2
- package/lib/loaders/fileLoader.js +11 -22
- package/lib/loaders/scriptInstrumentLoader.js +5 -13
- package/lib/loaders/selectorMappingLoader.js +7 -25
- package/lib/loaders/workerLoader.js +13 -29
- package/lib/middlewares/HMRMiddleware.js +13 -26
- package/lib/middlewares/SSTMiddleware.js +0 -3
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +53 -0
- package/lib/pluginUtils/getDevPlugins.js +20 -64
- package/lib/pluginUtils/getDocsPlugins.js +1 -10
- package/lib/pluginUtils/getLibraryImactPlugins.js +4 -5
- package/lib/pluginUtils/getLibraryPlugins.js +0 -5
- package/lib/pluginUtils/getProdPlugins.js +32 -78
- package/lib/pluginUtils/getServerPlugins.js +0 -5
- package/lib/pluginUtils/getUMDCSSPlugins.js +0 -7
- package/lib/pluginUtils/getUMDComponentPlugins.js +0 -7
- package/lib/pluginUtils/index.js +0 -8
- package/lib/plugins/CdnChangePlugin.js +0 -14
- package/lib/plugins/CleanupStatsPlugin.js +0 -5
- package/lib/plugins/EFCPlugin.js +23 -34
- package/lib/plugins/EFCPlugin.md +6 -6
- package/lib/plugins/EFCTemplatePlugin.js +23 -32
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +12 -38
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +12 -17
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +4 -10
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +46 -77
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +44 -59
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +21 -30
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
- package/lib/plugins/I18nSplitPlugin/README.md +25 -25
- package/lib/plugins/I18nSplitPlugin/index.js +70 -80
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -12
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +0 -1
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +0 -5
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +0 -6
- package/lib/plugins/I18nSplitPlugin/utils/index.js +0 -4
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +2 -20
- package/lib/plugins/ManifestPlugin.js +0 -17
- package/lib/plugins/ModuleStatsPlugin.js +0 -23
- package/lib/plugins/OptimizeJSPlugin.js +0 -7
- package/lib/plugins/PublicPathCallbackPlugin.js +0 -10
- package/lib/plugins/PublicPathChangePlugin.js +4 -36
- package/lib/plugins/ReportGeneratePlugin.js +4 -30
- package/lib/plugins/RequireVariablePublicPlugin.js +0 -6
- package/lib/plugins/ResourceHintsPlugin.js +20 -27
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +12 -17
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +23 -38
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +2 -5
- package/lib/plugins/ScriptInstrumentPlugin.js +0 -7
- package/lib/plugins/ServiceWorkerPlugin.js +13 -29
- package/lib/plugins/ShadowDOMSupportPlugin.js +3 -40
- package/lib/plugins/SourceMapHookPlugin.js +0 -9
- package/lib/plugins/TPHashMappingPlugin.js +5 -19
- package/lib/plugins/UglifyCSSPlugin.js +0 -9
- package/lib/plugins/UnusedFilesFindPlugin.js +2 -35
- package/lib/plugins/index.js +0 -19
- package/lib/plugins/libraryImpactPlugin.js +0 -32
- package/lib/plugins/webpackwatchrunplugin.js +0 -5
- package/lib/postcss-plugins/ExcludePlugin.js +0 -4
- package/lib/postcss-plugins/RTLSplitPlugin.js +24 -37
- package/lib/postcss-plugins/ValueReplacer.js +9 -6
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +0 -3
- package/lib/postcss-plugins/__test__/test1Input.css +38 -38
- package/lib/postcss-plugins/__test__/test1Output.css +38 -38
- package/lib/postcss-plugins/hoverActivePlugin.js +80 -92
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +31 -0
- package/lib/postcss-plugins/variableModificationPlugin/index.js +232 -0
- package/lib/postcss-plugins/variableModifier.js +14 -20
- package/lib/schemas/index.js +28 -13
- package/lib/servers/clusterHubServer.js +0 -10
- package/lib/servers/devBuild.js +13 -24
- package/lib/servers/docsServer.js +0 -2
- package/lib/servers/docsServerCore.js +0 -21
- package/lib/servers/getCliPath.js +1 -10
- package/lib/servers/helpServer.js +0 -5
- package/lib/servers/httpsOptions.js +0 -4
- package/lib/servers/impactServer.js +2 -34
- package/lib/servers/mockserver.js +0 -9
- package/lib/servers/nowatchserver.js +12 -34
- package/lib/servers/scrServer.js +13 -20
- package/lib/servers/server.js +7 -35
- package/lib/servers/ssServer.js +0 -16
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -45
- package/lib/templates/CoverageScriptTemplate.js +0 -14
- package/lib/templates/WMSTemplate.js +6 -12
- package/lib/utils/babelPresets.js +0 -2
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/clean.js +2 -8
- package/lib/utils/copy.js +0 -6
- package/lib/utils/copyTimezones.js +0 -8
- package/lib/utils/createEventStream.js +0 -4
- package/lib/utils/cssClassNameGenerate.js +3 -19
- package/lib/utils/cssURLReplacer.js +0 -25
- package/lib/utils/dependencyPostPublish.js +0 -9
- package/lib/utils/fileUtils.js +0 -26
- package/lib/utils/folderIterator.js +0 -10
- package/lib/utils/getComponents.js +0 -21
- package/lib/utils/getCurrentBranch.js +0 -5
- package/lib/utils/getDependenciesImpactList.js +0 -21
- package/lib/utils/getHash.js +0 -7
- package/lib/utils/getIp.js +0 -2
- package/lib/utils/getOptions.js +38 -35
- package/lib/utils/getServerURL.js +0 -7
- package/lib/utils/index.js +2 -47
- package/lib/utils/init.js +0 -1
- package/lib/utils/initPreCommitHook.js +6 -29
- package/lib/utils/jsonHelper.js +2 -19
- package/lib/utils/libraryImpactConfig.js +0 -2
- package/lib/utils/lint/addScripts.js +2 -5
- package/lib/utils/lint/checkExistingConfig.js +3 -12
- package/lib/utils/lint/copyConfigs.js +0 -3
- package/lib/utils/lint/index.js +0 -9
- package/lib/utils/lint/lintScripts.js +0 -1
- package/lib/utils/lint/lintSetup.js +3 -4
- package/lib/utils/lint/lintStagedPreCommitHook.js +0 -1
- package/lib/utils/lint/question.js +0 -7
- package/lib/utils/lintReporter.js +0 -20
- package/lib/utils/mailSender.js +0 -7
- package/lib/utils/pullOrigin.js +0 -4
- package/lib/utils/reinstallDependencies.js +0 -28
- package/lib/utils/removeAttributes.js +0 -7
- package/lib/utils/repoClone.js +2 -27
- package/lib/utils/request.js +0 -12
- package/lib/utils/resultSchema.json +73 -73
- package/lib/utils/rtl.js +4 -16
- package/lib/utils/setEnvVariables.js +0 -2
- package/lib/utils/ssTestHack.js +0 -10
- package/lib/utils/switchBranch.js +0 -4
- package/lib/utils/urlConcat.js +0 -4
- package/lib/utils/useExitCleanup.js +9 -10
- package/npm8.md +9 -9
- package/package.json +146 -148
- package/postpublish.js +6 -6
- package/templates/app/.eslintrc.js +140 -140
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -24
- package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
- package/templates/app/app/properties/i18nkeys.json +3 -3
- package/templates/app/docs/all.html +69 -69
- package/templates/app/mockapi/index.js +18 -18
- package/templates/app/package.json +37 -37
- package/templates/app/src/actions/SampleActions/index.js +37 -37
- package/templates/app/src/actions/index.js +65 -65
- package/templates/app/src/appUrls.js +19 -19
- package/templates/app/src/components/Alert/Alert.js +134 -134
- package/templates/app/src/components/Alert/Alert.module.css +79 -79
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
- package/templates/app/src/components/Sample/Sample.module.css +11 -11
- package/templates/app/src/components/Sample/SampleList.js +61 -61
- package/templates/app/src/components/Slider/Slider.css +41 -41
- package/templates/app/src/components/Slider/Slider.js +55 -55
- package/templates/app/src/containers/AlertContainer/index.js +15 -15
- package/templates/app/src/containers/AppContainer/index.js +96 -96
- package/templates/app/src/containers/AppContainer/index.module.css +27 -27
- package/templates/app/src/containers/CustomMatch/index.js +65 -65
- package/templates/app/src/containers/DevTools/index.js +10 -10
- package/templates/app/src/containers/Header/index.js +67 -67
- package/templates/app/src/containers/Header/index.module.css +43 -43
- package/templates/app/src/containers/Redirect/index.js +63 -63
- package/templates/app/src/containers/Redirector/index.js +47 -47
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
- package/templates/app/src/historyChange.js +5 -5
- package/templates/app/src/index.html +10 -10
- package/templates/app/src/index.js +24 -24
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
- package/templates/app/src/reducers/alertData.js +11 -11
- package/templates/app/src/reducers/index.js +6 -6
- package/templates/app/src/reducers/samples.js +19 -19
- package/templates/app/src/store/configureStore.dev.js +51 -51
- package/templates/app/src/store/configureStore.js +5 -5
- package/templates/app/src/store/configureStore.prod.js +26 -26
- package/templates/app/src/util/Common.js +5 -5
- package/templates/app/src/util/RequestAPI.js +132 -132
- package/templates/docs/all.html +249 -249
- package/templates/docs/component.html +178 -178
- package/templates/docs/components.html +221 -221
- package/templates/docs/css/b.min.css +6 -6
- package/templates/docs/css/component.css +42 -42
- package/templates/docs/css/componentTest.css +6 -6
- package/templates/docs/css/hopscotch.css +585 -585
- package/templates/docs/css/style.css +1022 -1022
- package/templates/docs/impactReportTemplate.html +154 -154
- package/templates/docs/index.html +1501 -1493
- package/templates/docs/js/active-line.js +72 -72
- package/templates/docs/js/b.min.js +7 -7
- package/templates/docs/js/codemirror.js +9680 -9680
- package/templates/docs/js/designTokens.js +334 -334
- package/templates/docs/js/j.min.js +4 -4
- package/templates/docs/js/javascript.js +874 -874
- package/templates/docs/js/matchbrackets.js +145 -145
@@ -1,39 +1,39 @@
|
|
1
|
-
/*Hover_active:ignore*/
|
2
|
-
g,a:hover{
|
3
|
-
color : red
|
4
|
-
}
|
5
|
-
/*Hover:ignore*/
|
6
|
-
h:hover{
|
7
|
-
background : yellow
|
8
|
-
}
|
9
|
-
|
10
|
-
/* Hover_active:ignore */
|
11
|
-
g,d+e:hover{
|
12
|
-
color : black
|
13
|
-
}
|
14
|
-
|
15
|
-
g,d e:hover{
|
16
|
-
color : black
|
17
|
-
}
|
18
|
-
|
19
|
-
@media screen and (max-width:61.25em){
|
20
|
-
/* Hover_active:ignore */
|
21
|
-
a,b,a:hover, b:hover{
|
22
|
-
background-color : blue
|
23
|
-
}
|
24
|
-
a + b,a:hover + b:hover{
|
25
|
-
background-color : blue
|
26
|
-
}
|
27
|
-
a b:hover{
|
28
|
-
background-color : blue
|
29
|
-
}
|
30
|
-
|
31
|
-
.cc:hover {
|
32
|
-
color: red;
|
33
|
-
}
|
34
|
-
|
35
|
-
c:hover{
|
36
|
-
color : red
|
37
|
-
}
|
38
|
-
|
1
|
+
/*Hover_active:ignore*/
|
2
|
+
g,a:hover{
|
3
|
+
color : red
|
4
|
+
}
|
5
|
+
/*Hover:ignore*/
|
6
|
+
h:hover{
|
7
|
+
background : yellow
|
8
|
+
}
|
9
|
+
|
10
|
+
/* Hover_active:ignore */
|
11
|
+
g,d+e:hover{
|
12
|
+
color : black
|
13
|
+
}
|
14
|
+
|
15
|
+
g,d e:hover{
|
16
|
+
color : black
|
17
|
+
}
|
18
|
+
|
19
|
+
@media screen and (max-width:61.25em){
|
20
|
+
/* Hover_active:ignore */
|
21
|
+
a,b,a:hover, b:hover{
|
22
|
+
background-color : blue
|
23
|
+
}
|
24
|
+
a + b,a:hover + b:hover{
|
25
|
+
background-color : blue
|
26
|
+
}
|
27
|
+
a b:hover{
|
28
|
+
background-color : blue
|
29
|
+
}
|
30
|
+
|
31
|
+
.cc:hover {
|
32
|
+
color: red;
|
33
|
+
}
|
34
|
+
|
35
|
+
c:hover{
|
36
|
+
color : red
|
37
|
+
}
|
38
|
+
|
39
39
|
}
|
@@ -1,27 +1,24 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _postcss = _interopRequireDefault(require("postcss"));
|
4
|
-
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6
|
-
|
7
|
-
|
8
|
-
*
|
9
|
-
* These are the comments' keyword
|
5
|
+
/**
|
6
|
+
* we have give support for ignore(exclude) comments
|
7
|
+
* These are the comments' keyword
|
10
8
|
*/
|
11
9
|
const hoverIgnoreQuery = 'Hover:ignore',
|
12
|
-
|
13
|
-
|
10
|
+
activeIgnoreQuery = 'Active:ignore',
|
11
|
+
hoverActiveIgnoreQuery = 'HoverActive:ignore';
|
14
12
|
const medHoverIgnoreQuery = 'MedHover:ignore',
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
medActiveIgnoreQuery = 'MedActive:ignore',
|
14
|
+
medHoverActiveIgnoreQuery = 'MedHoverActive:ignore';
|
15
|
+
let hoverMedQuerySuffix = '';
|
16
|
+
let hoverNoneMedQuerySuffix = '';
|
18
17
|
const ruleIgnoreCommentRegex = /(Hover:ignore|Active:ignore|HoverActive:ignore)/g;
|
19
18
|
const mediaQueryIgnoreCommentRegex = /(MedHover:ignore|MedActive:ignore|MedHoverActive:ignore)/g;
|
20
|
-
|
21
19
|
function isComment(node) {
|
22
20
|
return node && node.type === 'comment' && node.text !== undefined;
|
23
21
|
}
|
24
|
-
|
25
22
|
function isHoverPresent(atrule) {
|
26
23
|
let hoverPresent = false;
|
27
24
|
atrule.walkRules(rule => {
|
@@ -31,29 +28,38 @@ function isHoverPresent(atrule) {
|
|
31
28
|
});
|
32
29
|
return hoverPresent;
|
33
30
|
}
|
34
|
-
|
35
|
-
|
31
|
+
function checkForUsualClass(root, sel) {
|
32
|
+
let present = false;
|
33
|
+
sel.split(',').forEach(value => {
|
34
|
+
if (value.includes('hover')) {
|
35
|
+
const valueNoHover = value.replace(':hover', '').trim();
|
36
|
+
root.walkRules(rule => {
|
37
|
+
if (rule.selector === valueNoHover) {
|
38
|
+
present = true;
|
39
|
+
}
|
40
|
+
});
|
41
|
+
}
|
42
|
+
});
|
43
|
+
return present;
|
44
|
+
}
|
45
|
+
module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHoverActiveString => rootOriginal => {
|
36
46
|
const hoverRules = [];
|
37
|
-
|
38
|
-
|
47
|
+
const positionsObj = {};
|
48
|
+
hoverMedQuerySuffix = mediaQueryHoverActiveString.hover;
|
49
|
+
hoverNoneMedQuerySuffix = mediaQueryHoverActiveString.none;
|
39
50
|
function isRuleHasIgnoreComment(index, type) {
|
40
51
|
const prevNode = rootOriginal.nodes[index - 1];
|
41
|
-
|
42
52
|
if (isComment(prevNode)) {
|
43
53
|
return prevNode.text === type;
|
44
54
|
}
|
45
|
-
|
46
55
|
return false;
|
47
56
|
}
|
48
|
-
|
49
57
|
function isMediaQueryHasIgnoreComment(node, type) {
|
50
58
|
if (isComment(node)) {
|
51
59
|
return node.text === type;
|
52
60
|
}
|
53
|
-
|
54
61
|
return false;
|
55
62
|
}
|
56
|
-
|
57
63
|
function hasIgnoreComment({
|
58
64
|
index,
|
59
65
|
atrule,
|
@@ -62,25 +68,21 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
62
68
|
if (type.match(mediaQueryIgnoreCommentRegex)) {
|
63
69
|
return isMediaQueryHasIgnoreComment(atrule.nodes[index - 1], type.slice(3));
|
64
70
|
}
|
65
|
-
|
66
71
|
if (type.match(ruleIgnoreCommentRegex)) {
|
67
72
|
return isRuleHasIgnoreComment(index, type);
|
68
73
|
}
|
69
|
-
|
70
74
|
return false;
|
71
75
|
}
|
72
|
-
|
73
76
|
function getPositionsOfHoverAndActiveMedQueries(parent) {
|
74
77
|
const allNodes = rootOriginal.nodes;
|
75
|
-
const hoverMediaQuery = `${parent.params} and
|
76
|
-
const hoverNoneMediaQuery = `${parent.params} and
|
78
|
+
const hoverMediaQuery = `${parent.params} and ${hoverMedQuerySuffix}`;
|
79
|
+
const hoverNoneMediaQuery = `${parent.params} and ${hoverNoneMedQuerySuffix}`;
|
77
80
|
const positions = {
|
78
81
|
hovMed: allNodes[positionsObj[hoverMediaQuery]],
|
79
82
|
actMed: allNodes[positionsObj[hoverNoneMediaQuery]]
|
80
83
|
};
|
81
84
|
return positions;
|
82
85
|
}
|
83
|
-
|
84
86
|
function handleMedHoverAndHoverActiveIgnore(atrule, index) {
|
85
87
|
return !hasIgnoreComment({
|
86
88
|
atrule,
|
@@ -92,7 +94,6 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
92
94
|
type: medHoverActiveIgnoreQuery
|
93
95
|
});
|
94
96
|
}
|
95
|
-
|
96
97
|
function handleMedActiveAndHoverActiveIgnore(atrule, index) {
|
97
98
|
return !hasIgnoreComment({
|
98
99
|
atrule,
|
@@ -104,7 +105,6 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
104
105
|
type: medHoverActiveIgnoreQuery
|
105
106
|
});
|
106
107
|
}
|
107
|
-
|
108
108
|
function handleHoverAndHoverActiveIgnore(index) {
|
109
109
|
return !hasIgnoreComment({
|
110
110
|
index,
|
@@ -114,7 +114,6 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
114
114
|
type: hoverActiveIgnoreQuery
|
115
115
|
});
|
116
116
|
}
|
117
|
-
|
118
117
|
function handleActiveAndHoverActiveIgnore(index) {
|
119
118
|
return !hasIgnoreComment({
|
120
119
|
index,
|
@@ -124,7 +123,6 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
124
123
|
type: hoverActiveIgnoreQuery
|
125
124
|
});
|
126
125
|
}
|
127
|
-
|
128
126
|
function handleAllIgnoreCases(index) {
|
129
127
|
return !hasIgnoreComment({
|
130
128
|
index,
|
@@ -137,29 +135,24 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
137
135
|
type: hoverActiveIgnoreQuery
|
138
136
|
});
|
139
137
|
}
|
140
|
-
|
141
138
|
function mediaCommaQuery(rule, index) {
|
142
139
|
if (rule.parent.params !== undefined && !rule.parent.params.includes('hover')) {
|
143
140
|
//console.log(hovMed, actMed);
|
144
141
|
let newSelector = '';
|
145
|
-
|
142
|
+
const {
|
146
143
|
hovMed,
|
147
144
|
actMed
|
148
145
|
} = getPositionsOfHoverAndActiveMedQueries(rule.parent);
|
149
|
-
|
150
|
-
|
146
|
+
const hovQueries = [];
|
147
|
+
const actQueries = [];
|
151
148
|
rule.selector.split(/\s*,\s*/).forEach(_subrule => {
|
152
|
-
|
153
|
-
|
154
|
-
let clone = rule.clone();
|
155
|
-
|
149
|
+
const subrule = _subrule.trim();
|
150
|
+
const clone = rule.clone();
|
156
151
|
if (subrule.includes('hover')) {
|
157
152
|
clone.selector = subrule;
|
158
|
-
|
159
153
|
if (handleMedHoverAndHoverActiveIgnore(rule.parent, index)) {
|
160
154
|
hovQueries.push(subrule);
|
161
155
|
}
|
162
|
-
|
163
156
|
if (handleMedActiveAndHoverActiveIgnore(rule.parent, index)) {
|
164
157
|
actQueries.push(subrule);
|
165
158
|
}
|
@@ -167,43 +160,36 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
167
160
|
newSelector += `${subrule}, `;
|
168
161
|
}
|
169
162
|
});
|
170
|
-
|
171
163
|
if (hovQueries.length > 0) {
|
172
|
-
|
164
|
+
const clone = rule.clone();
|
173
165
|
clone.selector = hovQueries.join(',');
|
174
166
|
hovMed.append(clone);
|
175
167
|
}
|
176
|
-
|
177
168
|
if (actQueries.length > 0) {
|
178
|
-
|
169
|
+
const clone = rule.clone();
|
179
170
|
clone.selector = actQueries.join(',');
|
180
171
|
actMed.append(clone.clone({
|
181
172
|
selector: clone.selector.replace(/:hover/gi, ':active')
|
182
173
|
}));
|
183
174
|
}
|
184
|
-
|
185
175
|
if (handleMedHoverAndHoverActiveIgnore(rule.parent, index)) {
|
186
176
|
rule.selector = newSelector.substring(0, newSelector.length - 2);
|
187
177
|
}
|
188
|
-
|
189
178
|
if (rule.selector === '') {
|
190
179
|
rule.remove();
|
191
180
|
}
|
192
181
|
}
|
193
182
|
}
|
194
|
-
|
195
183
|
function mediaQuery(rule, index) {
|
196
184
|
if (rule.parent.params !== undefined && !rule.parent.params.includes('hover')) {
|
197
|
-
|
185
|
+
const {
|
198
186
|
hovMed,
|
199
187
|
actMed
|
200
188
|
} = getPositionsOfHoverAndActiveMedQueries(rule.parent);
|
201
|
-
|
202
189
|
if (rule.selector.includes('hover') && hovMed !== undefined && rule.parent.type === 'atrule') {
|
203
190
|
if (handleMedHoverAndHoverActiveIgnore(rule.parent, index)) {
|
204
191
|
hovMed.append(rule);
|
205
192
|
}
|
206
|
-
|
207
193
|
if (handleMedActiveAndHoverActiveIgnore(rule.parent, index)) {
|
208
194
|
actMed.append(rule.clone({
|
209
195
|
selector: rule.selector.replace(/:hover/gi, ':active')
|
@@ -212,14 +198,12 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
212
198
|
}
|
213
199
|
}
|
214
200
|
}
|
215
|
-
|
216
201
|
function commaQuery(rule, index) {
|
217
202
|
//console.log("comma" , rule.selector.split('\n'));
|
218
203
|
let newSelector = '';
|
219
|
-
|
204
|
+
const hovQueries = [];
|
220
205
|
rule.selector.split(/\s*,\s*/).forEach(_subrule => {
|
221
|
-
|
222
|
-
|
206
|
+
const subrule = _subrule.trim();
|
223
207
|
if (subrule.includes('hover')) {
|
224
208
|
// hoverRules.push({ rule: clone, index });
|
225
209
|
hovQueries.push(subrule);
|
@@ -227,30 +211,28 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
227
211
|
newSelector += `${subrule}, `;
|
228
212
|
}
|
229
213
|
});
|
230
|
-
|
231
214
|
if (hovQueries.length > 0) {
|
232
|
-
|
215
|
+
const clone = rule.clone();
|
233
216
|
clone.selector = hovQueries.join(',');
|
234
217
|
hoverRules.push({
|
235
218
|
rule: clone,
|
236
219
|
index
|
237
220
|
});
|
238
221
|
}
|
239
|
-
|
240
222
|
if (handleHoverAndHoverActiveIgnore(index)) {
|
241
|
-
|
223
|
+
if (checkForUsualClass(rootOriginal, rule.selector)) {
|
224
|
+
rule.selector = newSelector.substring(0, newSelector.length - 2).trim();
|
225
|
+
}
|
242
226
|
}
|
243
|
-
|
244
227
|
if (rule.selector === '') {
|
245
228
|
rule.remove();
|
246
229
|
}
|
247
|
-
}
|
248
|
-
|
230
|
+
}
|
249
231
|
|
232
|
+
// Start by identifying all :hover rules
|
250
233
|
rootOriginal.walkAtRules(atrule => {
|
251
|
-
const hoverQuery = `${atrule.params} and
|
252
|
-
const activeQuery = `${atrule.params} and
|
253
|
-
|
234
|
+
const hoverQuery = `${atrule.params} and ${hoverMedQuerySuffix}`;
|
235
|
+
const activeQuery = `${atrule.params} and ${hoverNoneMedQuerySuffix}`;
|
254
236
|
if (isHoverPresent(atrule)) {
|
255
237
|
if (!positionsObj[hoverQuery] && !positionsObj[activeQuery]) {
|
256
238
|
rootOriginal.append({
|
@@ -276,17 +258,17 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
276
258
|
// plus, space and other media queries
|
277
259
|
//console.log("media", rule.selector)
|
278
260
|
mediaQuery(rule, index);
|
279
|
-
}
|
280
|
-
|
261
|
+
}
|
281
262
|
|
263
|
+
// usual hover query
|
282
264
|
if (!rule.selector.match(/,+| +|\++/g) && rule.parent !== undefined && rule.parent.name === undefined) {
|
283
265
|
hoverRules.push({
|
284
266
|
rule,
|
285
267
|
index
|
286
268
|
});
|
287
|
-
}
|
288
|
-
|
269
|
+
}
|
289
270
|
|
271
|
+
//usual hover query with ',' ' ' '+'
|
290
272
|
if (rule.selector.match(/,+| +|\++/g) && rule.parent.name === undefined) {
|
291
273
|
if (rule.selector.includes(',')) {
|
292
274
|
commaQuery(rule, index);
|
@@ -296,70 +278,76 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
296
278
|
hoverRules.push({
|
297
279
|
rule,
|
298
280
|
index
|
299
|
-
});
|
281
|
+
});
|
282
|
+
//rule.remove();
|
300
283
|
}
|
301
284
|
}
|
302
285
|
}
|
303
|
-
});
|
286
|
+
});
|
287
|
+
// If there are any :hover rules in the input, then create media queries
|
304
288
|
// to automatically translate it into :active on touch-based devices
|
305
|
-
|
306
289
|
if (hoverRules.length > 0) {
|
307
290
|
// Create a media query targetting devices that actually support
|
308
291
|
// hover
|
309
292
|
const hoverQuery = rootOriginal.append({
|
310
293
|
name: 'media',
|
311
|
-
params:
|
312
|
-
}).last;
|
294
|
+
params: `${hoverMedQuerySuffix}`
|
295
|
+
}).last;
|
296
|
+
// Create a media query targetting devices that don't support hover
|
313
297
|
// (ie. devices where we should fall back to :active instead)
|
314
|
-
|
315
298
|
const activeQuery = rootOriginal.append({
|
316
299
|
name: 'media',
|
317
|
-
params:
|
318
|
-
}).last;
|
300
|
+
params: `${hoverNoneMedQuerySuffix}`
|
301
|
+
}).last;
|
302
|
+
|
303
|
+
// Loop through the hover rules and apply them to each of the media
|
319
304
|
// queries
|
320
305
|
// eslint-disable-next-line no-labels
|
321
|
-
|
322
306
|
outerLoop: for (const hoverRule of hoverRules) {
|
323
307
|
// determine if the rule has been nested inside another media
|
324
308
|
// query; in that case bail out as we have no way of reliably
|
325
309
|
// nesting these queries
|
326
310
|
let parentRule = hoverRule.rule.parent;
|
327
|
-
|
328
311
|
while (parentRule) {
|
329
312
|
if (parentRule.type === 'atrule' && parentRule.name === 'media') {
|
330
313
|
// eslint-disable-next-line no-labels
|
331
314
|
continue outerLoop;
|
332
315
|
}
|
333
|
-
|
334
316
|
parentRule = parentRule.parent;
|
335
|
-
}
|
317
|
+
}
|
318
|
+
|
319
|
+
// Push a clone of the :hover rule 'as is' to queries where we
|
336
320
|
// expect the user's device to support hover
|
337
321
|
// ieQuery.append(hoverRule.clone());
|
338
322
|
|
339
|
-
|
340
323
|
if (handleHoverAndHoverActiveIgnore(hoverRule.index)) {
|
341
324
|
hoverQuery.append(hoverRule.rule.clone());
|
342
|
-
}
|
325
|
+
}
|
326
|
+
|
327
|
+
// Push a clone of the :hover rule, where we transform the
|
343
328
|
// selector to :active to the query targetting devices that
|
344
329
|
// don't support hover
|
345
|
-
|
346
|
-
|
347
330
|
if (handleActiveAndHoverActiveIgnore(hoverRule.index)) {
|
348
331
|
activeQuery.append(hoverRule.rule.clone({
|
349
332
|
selector: hoverRule.rule.selector.replace(/:hover/gi, ':active')
|
350
333
|
}));
|
351
|
-
}
|
352
|
-
|
334
|
+
}
|
353
335
|
|
336
|
+
// remove legacy rule from output
|
354
337
|
if (handleAllIgnoreCases(hoverRule.index)) {
|
355
338
|
hoverRule.rule.remove();
|
356
339
|
}
|
357
340
|
}
|
358
341
|
}
|
359
342
|
|
360
|
-
rootOriginal.walkAtRules(atrule => {
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
343
|
+
// rootOriginal.walkAtRules(atrule => {
|
344
|
+
// if (
|
345
|
+
// (atrule !== undefined &&
|
346
|
+
// atrule.nodes !== undefined &&
|
347
|
+
// atrule.nodes.length === 0) ||
|
348
|
+
// atrule.nodes === undefined
|
349
|
+
// ) {
|
350
|
+
// atrule.remove();
|
351
|
+
// }
|
352
|
+
// });
|
365
353
|
});
|
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.ErrorHandler = void 0;
|
7
|
+
class ErrorHandler {
|
8
|
+
constructor(allowedErrs) {
|
9
|
+
this.errors = [];
|
10
|
+
this.allowedErrs = allowedErrs;
|
11
|
+
}
|
12
|
+
addError(errstr) {
|
13
|
+
this.errors.push(`{\n${errstr}\n}\n`);
|
14
|
+
}
|
15
|
+
errorFunction(errStr, type) {
|
16
|
+
const {
|
17
|
+
addError,
|
18
|
+
allowedErrs
|
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);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
exports.ErrorHandler = ErrorHandler;
|