@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.
Files changed (245) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -179
  3. package/.prettierrc +6 -6
  4. package/README.md +1028 -951
  5. package/bin/cli.js +483 -483
  6. package/cert/Tsicsezwild-22-23.crt +37 -37
  7. package/cert/Tsicsezwild-22-23.key +27 -27
  8. package/docs/CustomChunks.md +26 -26
  9. package/docs/DevStart.md +18 -18
  10. package/docs/HoverActive.md +12 -12
  11. package/docs/InstallNode.md +28 -28
  12. package/docs/TODOS.md +10 -10
  13. package/docs/ValueReplacer.md +60 -60
  14. package/docs/VariableConversion.md +678 -0
  15. package/docs/warnings_while_install.txt +35 -35
  16. package/files/eslintrc.js +62 -62
  17. package/files/prettierrc.js +3 -3
  18. package/lib/babel/cmjs-plugins-presets.js +0 -4
  19. package/lib/babel/es-plugins-presets.js +0 -4
  20. package/lib/common/getEntries.js +0 -10
  21. package/lib/common/getPublicPathConfig.js +0 -6
  22. package/lib/common/index.js +0 -5
  23. package/lib/common/splitChunks.js +2 -13
  24. package/lib/common/sslcertUpdater.js +6 -17
  25. package/lib/common/templateParameters.js +0 -2
  26. package/lib/common/testPattern.js +10 -21
  27. package/lib/common/valueReplacer.js +0 -15
  28. package/lib/configs/jest.config.js +8 -21
  29. package/lib/configs/libAlias.js +11 -2
  30. package/lib/configs/webpack.component.umd.config.js +0 -5
  31. package/lib/configs/webpack.css.umd.config.js +5 -13
  32. package/lib/configs/webpack.dev.config.js +13 -24
  33. package/lib/configs/webpack.docs.config.js +6 -12
  34. package/lib/configs/webpack.impact.config.js +6 -10
  35. package/lib/configs/webpack.prod.config.js +15 -26
  36. package/lib/hooks/docsProptypeHook.js +3 -7
  37. package/lib/jest/commitedFilesResult.js +3 -45
  38. package/lib/jest/coverageCollector.js +0 -11
  39. package/lib/jest/jsonMaker.js +0 -6
  40. package/lib/jest/preProcessors/cssPreprocessor.js +14 -13
  41. package/lib/jest/preProcessors/jsPreprocessor.js +0 -2
  42. package/lib/jest/preProcessors/otherFilesPreprocessor.js +0 -3
  43. package/lib/jest/result.js +0 -22
  44. package/lib/jest/run.js +6 -17
  45. package/lib/jest/setup.js +5 -57
  46. package/lib/loaderUtils/configsAssetsLoaders.js +34 -44
  47. package/lib/loaderUtils/getCSSLoaders.js +41 -28
  48. package/lib/loaderUtils/getDevJsLoaders.js +0 -8
  49. package/lib/loaderUtils/index.js +0 -3
  50. package/lib/loaders/docsLoader.js +0 -7
  51. package/lib/loaders/docsPropsLoader.js +3 -7
  52. package/lib/loaders/fileBountryLoader.js +0 -2
  53. package/lib/loaders/fileLoader.js +11 -22
  54. package/lib/loaders/scriptInstrumentLoader.js +5 -13
  55. package/lib/loaders/selectorMappingLoader.js +7 -25
  56. package/lib/loaders/workerLoader.js +13 -29
  57. package/lib/middlewares/HMRMiddleware.js +13 -26
  58. package/lib/middlewares/SSTMiddleware.js +0 -3
  59. package/lib/pluginUtils/configHtmlWebpackPlugins.js +53 -0
  60. package/lib/pluginUtils/getDevPlugins.js +20 -64
  61. package/lib/pluginUtils/getDocsPlugins.js +1 -10
  62. package/lib/pluginUtils/getLibraryImactPlugins.js +4 -5
  63. package/lib/pluginUtils/getLibraryPlugins.js +0 -5
  64. package/lib/pluginUtils/getProdPlugins.js +32 -78
  65. package/lib/pluginUtils/getServerPlugins.js +0 -5
  66. package/lib/pluginUtils/getUMDCSSPlugins.js +0 -7
  67. package/lib/pluginUtils/getUMDComponentPlugins.js +0 -7
  68. package/lib/pluginUtils/index.js +0 -8
  69. package/lib/plugins/CdnChangePlugin.js +0 -14
  70. package/lib/plugins/CleanupStatsPlugin.js +0 -5
  71. package/lib/plugins/EFCPlugin.js +23 -34
  72. package/lib/plugins/EFCPlugin.md +6 -6
  73. package/lib/plugins/EFCTemplatePlugin.js +23 -32
  74. package/lib/plugins/I18NInjectIntoIndexPlugin.js +12 -38
  75. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +12 -17
  76. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +4 -10
  77. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +46 -77
  78. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +44 -59
  79. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +21 -30
  80. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  81. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  82. package/lib/plugins/I18nSplitPlugin/index.js +70 -80
  83. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -12
  84. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +0 -1
  85. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +0 -5
  86. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +0 -6
  87. package/lib/plugins/I18nSplitPlugin/utils/index.js +0 -4
  88. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +2 -20
  89. package/lib/plugins/ManifestPlugin.js +0 -17
  90. package/lib/plugins/ModuleStatsPlugin.js +0 -23
  91. package/lib/plugins/OptimizeJSPlugin.js +0 -7
  92. package/lib/plugins/PublicPathCallbackPlugin.js +0 -10
  93. package/lib/plugins/PublicPathChangePlugin.js +4 -36
  94. package/lib/plugins/ReportGeneratePlugin.js +4 -30
  95. package/lib/plugins/RequireVariablePublicPlugin.js +0 -6
  96. package/lib/plugins/ResourceHintsPlugin.js +20 -27
  97. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +12 -17
  98. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +23 -38
  99. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  100. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +2 -5
  101. package/lib/plugins/ScriptInstrumentPlugin.js +0 -7
  102. package/lib/plugins/ServiceWorkerPlugin.js +13 -29
  103. package/lib/plugins/ShadowDOMSupportPlugin.js +3 -40
  104. package/lib/plugins/SourceMapHookPlugin.js +0 -9
  105. package/lib/plugins/TPHashMappingPlugin.js +5 -19
  106. package/lib/plugins/UglifyCSSPlugin.js +0 -9
  107. package/lib/plugins/UnusedFilesFindPlugin.js +2 -35
  108. package/lib/plugins/index.js +0 -19
  109. package/lib/plugins/libraryImpactPlugin.js +0 -32
  110. package/lib/plugins/webpackwatchrunplugin.js +0 -5
  111. package/lib/postcss-plugins/ExcludePlugin.js +0 -4
  112. package/lib/postcss-plugins/RTLSplitPlugin.js +24 -37
  113. package/lib/postcss-plugins/ValueReplacer.js +9 -6
  114. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +0 -3
  115. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  116. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  117. package/lib/postcss-plugins/hoverActivePlugin.js +80 -92
  118. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +31 -0
  119. package/lib/postcss-plugins/variableModificationPlugin/index.js +232 -0
  120. package/lib/postcss-plugins/variableModifier.js +14 -20
  121. package/lib/schemas/index.js +28 -13
  122. package/lib/servers/clusterHubServer.js +0 -10
  123. package/lib/servers/devBuild.js +13 -24
  124. package/lib/servers/docsServer.js +0 -2
  125. package/lib/servers/docsServerCore.js +0 -21
  126. package/lib/servers/getCliPath.js +1 -10
  127. package/lib/servers/helpServer.js +0 -5
  128. package/lib/servers/httpsOptions.js +0 -4
  129. package/lib/servers/impactServer.js +2 -34
  130. package/lib/servers/mockserver.js +0 -9
  131. package/lib/servers/nowatchserver.js +12 -34
  132. package/lib/servers/scrServer.js +13 -20
  133. package/lib/servers/server.js +7 -35
  134. package/lib/servers/ssServer.js +0 -16
  135. package/lib/sh/pre-commit.sh +34 -34
  136. package/lib/sh/reportPublish.sh +45 -45
  137. package/lib/templates/CoverageScriptTemplate.js +0 -14
  138. package/lib/templates/WMSTemplate.js +6 -12
  139. package/lib/utils/babelPresets.js +0 -2
  140. package/lib/utils/buildstats.html +148 -148
  141. package/lib/utils/clean.js +2 -8
  142. package/lib/utils/copy.js +0 -6
  143. package/lib/utils/copyTimezones.js +0 -8
  144. package/lib/utils/createEventStream.js +0 -4
  145. package/lib/utils/cssClassNameGenerate.js +3 -19
  146. package/lib/utils/cssURLReplacer.js +0 -25
  147. package/lib/utils/dependencyPostPublish.js +0 -9
  148. package/lib/utils/fileUtils.js +0 -26
  149. package/lib/utils/folderIterator.js +0 -10
  150. package/lib/utils/getComponents.js +0 -21
  151. package/lib/utils/getCurrentBranch.js +0 -5
  152. package/lib/utils/getDependenciesImpactList.js +0 -21
  153. package/lib/utils/getHash.js +0 -7
  154. package/lib/utils/getIp.js +0 -2
  155. package/lib/utils/getOptions.js +38 -35
  156. package/lib/utils/getServerURL.js +0 -7
  157. package/lib/utils/index.js +2 -47
  158. package/lib/utils/init.js +0 -1
  159. package/lib/utils/initPreCommitHook.js +6 -29
  160. package/lib/utils/jsonHelper.js +2 -19
  161. package/lib/utils/libraryImpactConfig.js +0 -2
  162. package/lib/utils/lint/addScripts.js +2 -5
  163. package/lib/utils/lint/checkExistingConfig.js +3 -12
  164. package/lib/utils/lint/copyConfigs.js +0 -3
  165. package/lib/utils/lint/index.js +0 -9
  166. package/lib/utils/lint/lintScripts.js +0 -1
  167. package/lib/utils/lint/lintSetup.js +3 -4
  168. package/lib/utils/lint/lintStagedPreCommitHook.js +0 -1
  169. package/lib/utils/lint/question.js +0 -7
  170. package/lib/utils/lintReporter.js +0 -20
  171. package/lib/utils/mailSender.js +0 -7
  172. package/lib/utils/pullOrigin.js +0 -4
  173. package/lib/utils/reinstallDependencies.js +0 -28
  174. package/lib/utils/removeAttributes.js +0 -7
  175. package/lib/utils/repoClone.js +2 -27
  176. package/lib/utils/request.js +0 -12
  177. package/lib/utils/resultSchema.json +73 -73
  178. package/lib/utils/rtl.js +4 -16
  179. package/lib/utils/setEnvVariables.js +0 -2
  180. package/lib/utils/ssTestHack.js +0 -10
  181. package/lib/utils/switchBranch.js +0 -4
  182. package/lib/utils/urlConcat.js +0 -4
  183. package/lib/utils/useExitCleanup.js +9 -10
  184. package/npm8.md +9 -9
  185. package/package.json +146 -148
  186. package/postpublish.js +6 -6
  187. package/templates/app/.eslintrc.js +140 -140
  188. package/templates/app/README.md +12 -12
  189. package/templates/app/app/index.html +24 -24
  190. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  191. package/templates/app/app/properties/i18nkeys.json +3 -3
  192. package/templates/app/docs/all.html +69 -69
  193. package/templates/app/mockapi/index.js +18 -18
  194. package/templates/app/package.json +37 -37
  195. package/templates/app/src/actions/SampleActions/index.js +37 -37
  196. package/templates/app/src/actions/index.js +65 -65
  197. package/templates/app/src/appUrls.js +19 -19
  198. package/templates/app/src/components/Alert/Alert.js +134 -134
  199. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  200. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  201. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  202. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  203. package/templates/app/src/components/Sample/SampleList.js +61 -61
  204. package/templates/app/src/components/Slider/Slider.css +41 -41
  205. package/templates/app/src/components/Slider/Slider.js +55 -55
  206. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  207. package/templates/app/src/containers/AppContainer/index.js +96 -96
  208. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  209. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  210. package/templates/app/src/containers/DevTools/index.js +10 -10
  211. package/templates/app/src/containers/Header/index.js +67 -67
  212. package/templates/app/src/containers/Header/index.module.css +43 -43
  213. package/templates/app/src/containers/Redirect/index.js +63 -63
  214. package/templates/app/src/containers/Redirector/index.js +47 -47
  215. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  216. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  217. package/templates/app/src/historyChange.js +5 -5
  218. package/templates/app/src/index.html +10 -10
  219. package/templates/app/src/index.js +24 -24
  220. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  221. package/templates/app/src/reducers/alertData.js +11 -11
  222. package/templates/app/src/reducers/index.js +6 -6
  223. package/templates/app/src/reducers/samples.js +19 -19
  224. package/templates/app/src/store/configureStore.dev.js +51 -51
  225. package/templates/app/src/store/configureStore.js +5 -5
  226. package/templates/app/src/store/configureStore.prod.js +26 -26
  227. package/templates/app/src/util/Common.js +5 -5
  228. package/templates/app/src/util/RequestAPI.js +132 -132
  229. package/templates/docs/all.html +249 -249
  230. package/templates/docs/component.html +178 -178
  231. package/templates/docs/components.html +221 -221
  232. package/templates/docs/css/b.min.css +6 -6
  233. package/templates/docs/css/component.css +42 -42
  234. package/templates/docs/css/componentTest.css +6 -6
  235. package/templates/docs/css/hopscotch.css +585 -585
  236. package/templates/docs/css/style.css +1022 -1022
  237. package/templates/docs/impactReportTemplate.html +154 -154
  238. package/templates/docs/index.html +1501 -1493
  239. package/templates/docs/js/active-line.js +72 -72
  240. package/templates/docs/js/b.min.js +7 -7
  241. package/templates/docs/js/codemirror.js +9680 -9680
  242. package/templates/docs/js/designTokens.js +334 -334
  243. package/templates/docs/js/j.min.js +4 -4
  244. package/templates/docs/js/javascript.js +874 -874
  245. 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
- * we have give support for ignore(exclude) comments
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
- activeIgnoreQuery = 'Active:ignore',
13
- hoverActiveIgnoreQuery = 'HoverActive:ignore';
10
+ activeIgnoreQuery = 'Active:ignore',
11
+ hoverActiveIgnoreQuery = 'HoverActive:ignore';
14
12
  const medHoverIgnoreQuery = 'MedHover:ignore',
15
- medActiveIgnoreQuery = 'MedActive:ignore',
16
- medHoverActiveIgnoreQuery = 'MedHoverActive:ignore';
17
- const hoverMedQuerySuffix = '(min--moz-device-pixel-ratio:0) and (hover: hover), (hover: hover)';
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
- module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOriginal => {
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
- let positionsObj = {};
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 all and ${hoverMedQuerySuffix}`;
76
- const hoverNoneMediaQuery = `${parent.params} and (hover: none)`;
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
- let {
142
+ const {
146
143
  hovMed,
147
144
  actMed
148
145
  } = getPositionsOfHoverAndActiveMedQueries(rule.parent);
149
- let hovQueries = [];
150
- let actQueries = [];
146
+ const hovQueries = [];
147
+ const actQueries = [];
151
148
  rule.selector.split(/\s*,\s*/).forEach(_subrule => {
152
- let subrule = _subrule.trim();
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
- let clone = rule.clone();
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
- let clone = rule.clone();
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
- let {
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
- let hovQueries = [];
204
+ const hovQueries = [];
220
205
  rule.selector.split(/\s*,\s*/).forEach(_subrule => {
221
- let subrule = _subrule.trim();
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
- let clone = rule.clone();
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
- rule.selector = newSelector.substring(0, newSelector.length - 2).trim();
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
- } // Start by identifying all :hover rules
248
-
230
+ }
249
231
 
232
+ // Start by identifying all :hover rules
250
233
  rootOriginal.walkAtRules(atrule => {
251
- const hoverQuery = `${atrule.params} and all and ${hoverMedQuerySuffix}`;
252
- const activeQuery = `${atrule.params} and (hover: none)`;
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
- } // usual hover query
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
- } //usual hover query with ',' ' ' '+'
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
- }); //rule.remove();
281
+ });
282
+ //rule.remove();
300
283
  }
301
284
  }
302
285
  }
303
- }); // If there are any :hover rules in the input, then create media queries
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: `all and ${hoverMedQuerySuffix}`
312
- }).last; // Create a media query targetting devices that don't support hover
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: '(hover: none)'
318
- }).last; // Loop through the hover rules and apply them to each of the media
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
- } // Push a clone of the :hover rule 'as is' to queries where we
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
- } // Push a clone of the :hover rule, where we transform the
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
- } // remove legacy rule from output
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
- if (atrule !== undefined && atrule.nodes !== undefined && atrule.nodes.length === 0 || atrule.nodes === undefined) {
362
- atrule.remove();
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;