@zohodesk/react-cli 0.0.1-exp.175.1 → 0.0.1-exp.176.1
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/.eslintignore +7 -7
- package/.eslintrc.js +180 -180
- package/.prettierrc +6 -6
- package/README.md +1025 -1028
- package/bin/cli.js +482 -482
- 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/SelectorWeight.md +6 -0
- package/docs/TODOS.md +10 -10
- package/docs/ValueReplacer.md +60 -60
- package/docs/VariableConversion.md +719 -678
- 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 +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 +44 -34
- 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 +29 -13
- 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 +68 -22
- 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 +77 -28
- 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/EFCPlugin.md +6 -6
- package/lib/plugins/EFCTemplatePlugin.js +32 -23
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +38 -12
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +17 -12
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +77 -46
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +59 -44
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +30 -21
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
- package/lib/plugins/I18nSplitPlugin/README.md +25 -25
- package/lib/plugins/I18nSplitPlugin/index.js +80 -70
- 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 +27 -20
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +22 -15
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
- 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 +29 -13
- package/lib/plugins/ShadowDOMSupportPlugin.js +40 -3
- package/lib/plugins/SourceMapHookPlugin.js +9 -0
- package/lib/plugins/TPHashMappingPlugin.js +19 -5
- package/lib/plugins/UglifyCSSPlugin.js +9 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +35 -2
- package/lib/plugins/VariableConversionCollector.js +322 -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 +37 -24
- package/lib/postcss-plugins/ValueReplacer.js +6 -9
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
- package/lib/postcss-plugins/__test__/test1Input.css +38 -38
- package/lib/postcss-plugins/__test__/test1Output.css +38 -38
- package/lib/postcss-plugins/hoverActivePlugin.js +69 -33
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +42 -13
- package/lib/postcss-plugins/variableModificationPlugin/index.js +216 -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/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -45
- package/lib/templates/CoverageScriptTemplate.js +14 -0
- package/lib/templates/WMSTemplate.js +12 -6
- package/lib/utils/babelPresets.js +2 -0
- package/lib/utils/buildstats.html +148 -148
- 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 +25 -0
- 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/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/resultSchema.json +73 -73
- 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/npm8.md +9 -9
- package/package.json +146 -146
- 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 -1501
- 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,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 }; }
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* we have give support for ignore(exclude) comments
|
|
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,57 @@ 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
|
+
MULTIPLE_OCCURANCES: 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}`)
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
setAllowedErrs(allErrs) {
|
|
25
|
+
this.allowedErrs = allErrs;
|
|
26
|
+
['DECLARATION_IGNORED', 'DECIMAL_CHECK', 'DECIMAL_REJECT', 'UNIT_ERROR', 'RANGE_ERROR', 'VARIABLE_PRESENT', 'MULTIPLE_OCCURANCES'].forEach(err => {
|
|
27
|
+
if (!this.allowedErrs[err]) {
|
|
28
|
+
this[err] = () => null;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
11
31
|
}
|
|
32
|
+
|
|
12
33
|
addError(errstr) {
|
|
13
34
|
this.errors.push(`{\n${errstr}\n}\n`);
|
|
14
35
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
allowedErrs
|
|
19
|
-
|
|
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);
|
|
36
|
+
|
|
37
|
+
errorFunction(errObj) {
|
|
38
|
+
if (errObj.type && this.allowedErrs[errObj.type] && errObj.decl.prop && errObj.decl.value) {
|
|
39
|
+
console.log(this.allowedErrs[errObj.type]);
|
|
40
|
+
this[errObj.type](errObj);
|
|
28
41
|
}
|
|
29
42
|
}
|
|
43
|
+
|
|
44
|
+
printError(errObj) {
|
|
45
|
+
console.log('{');
|
|
46
|
+
Object.keys(errObj).sort().forEach(key => {
|
|
47
|
+
if (key !== 'decl') {
|
|
48
|
+
console.log(`${key} : ${errObj[key]}`);
|
|
49
|
+
} else {
|
|
50
|
+
console.log(`prop : ${errObj.decl.prop}`);
|
|
51
|
+
console.log(`value : ${errObj.decl.value}`);
|
|
52
|
+
console.log(`linenum : ${errObj.decl.source.start.line}`);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
console.log('}\n');
|
|
56
|
+
}
|
|
57
|
+
|
|
30
58
|
}
|
|
59
|
+
|
|
31
60
|
exports.ErrorHandler = ErrorHandler;
|