@zohodesk/react-cli 1.1.29-exp.2 → 1.1.29-exp.3

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.
Files changed (222) hide show
  1. package/README.md +18 -0
  2. package/lib/babel/babel-option-utils/babel-preset-react-option.js +3 -0
  3. package/lib/babel/cmjs-plugins-presets.js +13 -2
  4. package/lib/babel/es-plugins-presets.js +14 -3
  5. package/lib/common/buildEs.js +0 -1
  6. package/lib/common/getEntries.js +13 -2
  7. package/lib/common/getPublicPathConfig.js +6 -0
  8. package/lib/common/index.js +6 -1
  9. package/lib/common/runPreProcess.js +15 -6
  10. package/lib/common/splitChunks.js +21 -2
  11. package/lib/common/sslcertUpdater.js +18 -7
  12. package/lib/common/templateParameters.js +2 -0
  13. package/lib/common/testPattern.js +21 -10
  14. package/lib/common/valueReplacer.js +16 -1
  15. package/lib/configs/jest.config.js +11 -2
  16. package/lib/configs/libAlias.js +16 -10
  17. package/lib/configs/resolvers.js +16 -6
  18. package/lib/configs/webpack.component.umd.config.js +6 -1
  19. package/lib/configs/webpack.css.umd.config.js +14 -6
  20. package/lib/configs/webpack.dev.config.js +14 -1
  21. package/lib/configs/webpack.docs.config.js +9 -1
  22. package/lib/configs/webpack.impact.config.js +8 -1
  23. package/lib/configs/webpack.prod.config.js +17 -4
  24. package/lib/constants.js +18 -9
  25. package/lib/deprecationLogger.js +7 -0
  26. package/lib/hooks/docsProptypeHook.js +8 -4
  27. package/lib/jest/commitedFilesResult.js +46 -4
  28. package/lib/jest/coverageCollector.js +12 -1
  29. package/lib/jest/jsonMaker.js +6 -0
  30. package/lib/jest/preProcessors/cssPreprocessor.js +9 -1
  31. package/lib/jest/preProcessors/jsPreprocessor.js +11 -2
  32. package/lib/jest/preProcessors/otherFilesPreprocessor.js +4 -1
  33. package/lib/jest/result.js +23 -1
  34. package/lib/jest/run.js +18 -7
  35. package/lib/jest/setup.js +60 -8
  36. package/lib/loaderUtils/configsAssetsLoaders.js +12 -2
  37. package/lib/loaderUtils/getCSSLoaders.js +22 -10
  38. package/lib/loaderUtils/getDevJsLoaders.js +13 -4
  39. package/lib/loaderUtils/index.js +4 -1
  40. package/lib/loaderUtils/tests/windowsModification.test.js +1 -0
  41. package/lib/loaderUtils/windowsModification.js +3 -2
  42. package/lib/loaders/__test__/markdownLoader.spec.js +1 -0
  43. package/lib/loaders/composeLoader.js +37 -13
  44. package/lib/loaders/docsLoader.js +12 -1
  45. package/lib/loaders/docsPropsLoader.js +8 -4
  46. package/lib/loaders/enhancedReactLiveConverter.js +23 -2
  47. package/lib/loaders/fileBountryLoader.js +3 -1
  48. package/lib/loaders/fileLoader.js +23 -12
  49. package/lib/loaders/markdownLoader.js +19 -14
  50. package/lib/loaders/reactLiveConvertor.js +15 -5
  51. package/lib/loaders/scriptInstrumentLoader.js +16 -7
  52. package/lib/loaders/selectorMappingLoader.js +26 -7
  53. package/lib/loaders/workerLoader.js +24 -9
  54. package/lib/logger.js +4 -0
  55. package/lib/middlewares/HMRMiddleware.js +27 -13
  56. package/lib/middlewares/SSTMiddleware.js +5 -1
  57. package/lib/pluginUtils/configHtmlWebpackPlugins.js +24 -1
  58. package/lib/pluginUtils/getDevPlugins.js +42 -9
  59. package/lib/pluginUtils/getDocsPlugins.js +13 -3
  60. package/lib/pluginUtils/getLibraryImactPlugins.js +6 -5
  61. package/lib/pluginUtils/getLibraryPlugins.js +8 -2
  62. package/lib/pluginUtils/getProdPlugins.js +47 -8
  63. package/lib/pluginUtils/getServerPlugins.js +8 -2
  64. package/lib/pluginUtils/getUMDCSSPlugins.js +10 -2
  65. package/lib/pluginUtils/getUMDComponentPlugins.js +10 -2
  66. package/lib/pluginUtils/index.js +9 -1
  67. package/lib/plugins/CdnChangePlugin.js +18 -2
  68. package/lib/plugins/CleanupStatsPlugin.js +5 -0
  69. package/lib/plugins/CssOrderControlPlugin.js +6 -3
  70. package/lib/plugins/CustomAttributePlugin.js +19 -14
  71. package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +23 -3
  72. package/lib/plugins/EFCPlugin.js +34 -20
  73. package/lib/plugins/EFCTemplatePlugin.js +30 -19
  74. package/lib/plugins/EfcResourceCleanupPlugin.js +3 -0
  75. package/lib/plugins/EventsHandlingPlugin.js +4 -2
  76. package/lib/plugins/I18NInjectIntoIndexPlugin.js +37 -14
  77. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +15 -10
  78. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
  79. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +155 -78
  80. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +81 -198
  81. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +23 -12
  82. package/lib/plugins/I18nSplitPlugin/index.js +24 -13
  83. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +12 -2
  84. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +1 -0
  85. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +5 -0
  86. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +8 -1
  87. package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
  88. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -0
  89. package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +1 -0
  90. package/lib/plugins/ManifestPlugin.js +18 -1
  91. package/lib/plugins/MinifyPlugin.js +10 -1
  92. package/lib/plugins/ModuleStatsPlugin.js +24 -1
  93. package/lib/plugins/OptimizeJSPlugin.js +10 -2
  94. package/lib/plugins/PublicPathCallbackPlugin.js +12 -1
  95. package/lib/plugins/PublicPathChangePlugin.js +39 -6
  96. package/lib/plugins/ReportGeneratePlugin.js +32 -5
  97. package/lib/plugins/RequireVariablePublicPlugin.js +8 -1
  98. package/lib/plugins/ResourceHintsPlugin.js +13 -4
  99. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
  100. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +17 -10
  101. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
  102. package/lib/plugins/ScriptInstrumentPlugin.js +8 -1
  103. package/lib/plugins/SelectorPlugin.js +32 -6
  104. package/lib/plugins/ServiceWorkerPlugin.js +22 -5
  105. package/lib/plugins/ShadowDOMSupportPlugin.js +41 -4
  106. package/lib/plugins/SourceMapHookPlugin.js +12 -2
  107. package/lib/plugins/StatsPlugin.js +14 -0
  108. package/lib/plugins/TPHashMappingPlugin.js +18 -3
  109. package/lib/plugins/UnusedFilesFindPlugin.js +39 -4
  110. package/lib/plugins/VariableConversionCollector.js +42 -15
  111. package/lib/plugins/index.js +20 -1
  112. package/lib/plugins/libraryImpactPlugin.js +33 -1
  113. package/lib/plugins/utils/classHandling.js +6 -0
  114. package/lib/plugins/utils/fileHandling.js +15 -6
  115. package/lib/plugins/utils/tests/fileHandling.test.js +4 -0
  116. package/lib/plugins/variableConvertorUtils.js +29 -14
  117. package/lib/plugins/webpackwatchrunplugin.js +5 -0
  118. package/lib/postcss-plugins/EmptyPlugin.js +4 -3
  119. package/lib/postcss-plugins/ExcludePlugin.js +5 -1
  120. package/lib/postcss-plugins/IncludePlugin.js +5 -1
  121. package/lib/postcss-plugins/RTLSplitPlugin.js +27 -14
  122. package/lib/postcss-plugins/SelectorReplace.js +16 -1
  123. package/lib/postcss-plugins/ValueReplacer.js +6 -7
  124. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
  125. package/lib/postcss-plugins/__test__/selectorReplace.test.js +3 -6
  126. package/lib/postcss-plugins/__test__/valueReplacer.spec.js +5 -2
  127. package/lib/postcss-plugins/hoverActivePlugin.js +67 -31
  128. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +7 -0
  129. package/lib/postcss-plugins/variableModificationPlugin/index.js +49 -28
  130. package/lib/schemas/index.js +10 -3
  131. package/lib/servers/clusterHubServer.js +11 -1
  132. package/lib/servers/devBuild.js +26 -14
  133. package/lib/servers/docsServer.js +3 -1
  134. package/lib/servers/docsServerCore.js +22 -1
  135. package/lib/servers/getCliPath.js +9 -0
  136. package/lib/servers/helpServer.js +6 -1
  137. package/lib/servers/httpsOptions.js +8 -2
  138. package/lib/servers/impactServer.js +35 -3
  139. package/lib/servers/mockserver.js +10 -1
  140. package/lib/servers/nowatchserver.js +37 -12
  141. package/lib/servers/requireLocalOrGlobal.js +17 -6
  142. package/lib/servers/scrServer.js +21 -14
  143. package/lib/servers/server.js +36 -6
  144. package/lib/servers/ssServer.js +17 -1
  145. package/lib/templates/CoverageScriptTemplate.js +14 -0
  146. package/lib/templates/WMSTemplate.js +13 -7
  147. package/lib/templates/linterConstant.js +4 -2
  148. package/lib/utils/babelPresets.js +7 -3
  149. package/lib/utils/clean.js +9 -3
  150. package/lib/utils/copy.js +7 -1
  151. package/lib/utils/copyTimezones.js +9 -1
  152. package/lib/utils/createEventStream.js +6 -1
  153. package/lib/utils/cssClassNameGenerate.js +30 -10
  154. package/lib/utils/cssURLReplacer.js +22 -1
  155. package/lib/utils/dependencyPostPublish.js +10 -1
  156. package/lib/utils/deprecationSupport.js +32 -7
  157. package/lib/utils/fileUtils.js +28 -1
  158. package/lib/utils/folderIterator.js +13 -2
  159. package/lib/utils/getComponents.js +21 -0
  160. package/lib/utils/getCurrentBranch.js +5 -0
  161. package/lib/utils/getDependenciesImpactList.js +22 -1
  162. package/lib/utils/getFileType.js +10 -2
  163. package/lib/utils/getHash.js +8 -1
  164. package/lib/utils/getIp.js +2 -0
  165. package/lib/utils/getOptions.js +53 -16
  166. package/lib/utils/getServerURL.js +10 -1
  167. package/lib/utils/index.js +51 -4
  168. package/lib/utils/init.js +1 -0
  169. package/lib/utils/initPreCommitHook.js +30 -7
  170. package/lib/utils/jsonHelper.js +22 -3
  171. package/lib/utils/libraryImpactConfig.js +5 -2
  172. package/lib/utils/lint/addScripts.js +5 -2
  173. package/lib/utils/lint/checkExistingConfig.js +12 -3
  174. package/lib/utils/lint/copyConfigs.js +3 -0
  175. package/lib/utils/lint/index.js +9 -0
  176. package/lib/utils/lint/lintScripts.js +1 -0
  177. package/lib/utils/lint/lintSetup.js +4 -3
  178. package/lib/utils/lint/lintStagedPreCommitHook.js +1 -0
  179. package/lib/utils/lint/question.js +7 -0
  180. package/lib/utils/lintReporter.js +20 -0
  181. package/lib/utils/log.js +1 -0
  182. package/lib/utils/mailSender.js +8 -1
  183. package/lib/utils/object-manipulation.js +17 -1
  184. package/lib/utils/pullOrigin.js +4 -0
  185. package/lib/utils/reinstallDependencies.js +29 -1
  186. package/lib/utils/removeAttributes.js +8 -1
  187. package/lib/utils/repoClone.js +28 -3
  188. package/lib/utils/request.js +12 -0
  189. package/lib/utils/rtl.js +17 -5
  190. package/lib/utils/selectorReplacer.js +16 -10
  191. package/lib/utils/setEnvVariables.js +2 -0
  192. package/lib/utils/ssTestHack.js +11 -1
  193. package/lib/utils/switchBranch.js +5 -0
  194. package/lib/utils/typeCheck.js +1 -0
  195. package/lib/utils/urlConcat.js +4 -0
  196. package/lib/utils/useExitCleanup.js +10 -9
  197. package/lib/utils/variableConverter.js +31 -22
  198. package/{package-lock.json → npm-shrinkwrap.json} +2333 -2101
  199. package/package.json +3 -2
  200. package/lib/plugins/I18nSplitPlugin/utils/applyMetaManifest.js +0 -279
  201. package/lib/plugins/I18nSplitPlugin/utils/createMetaManifest.js +0 -51
  202. package/lib/plugins/I18nSplitPlugin/utils/createRegularManifest.js +0 -48
  203. package/lib/plugins/newi18nsplitplugin/18nPlugin1.js +0 -306
  204. package/lib/plugins/newi18nsplitplugin/18nPlugin2.js +0 -363
  205. package/lib/plugins/newi18nsplitplugin/18nPlugin3.js +0 -694
  206. package/lib/plugins/newi18nsplitplugin/18nPlugin_hashed.js +0 -1258
  207. package/lib/plugins/newi18nsplitplugin/18nPlugin_working.js +0 -542
  208. package/lib/plugins/newi18nsplitplugin/18nplugin.js +0 -974
  209. package/lib/plugins/newi18nsplitplugin/ChunkManager.js +0 -131
  210. package/lib/plugins/newi18nsplitplugin/GenerateModuleIdToKeysMapPlugin.js +0 -59
  211. package/lib/plugins/newi18nsplitplugin/I18nDiffPlugin.js +0 -262
  212. package/lib/plugins/newi18nsplitplugin/I18nDownloadLogic.js +0 -166
  213. package/lib/plugins/newi18nsplitplugin/I18nPropertiesPlugin.js +0 -111
  214. package/lib/plugins/newi18nsplitplugin/KeyCollector.js +0 -163
  215. package/lib/plugins/newi18nsplitplugin/ManifestGenerator.js +0 -88
  216. package/lib/plugins/newi18nsplitplugin/UnicodeConversionPlugin.js +0 -101
  217. package/lib/plugins/newi18nsplitplugin/constants.js +0 -162
  218. package/lib/plugins/newi18nsplitplugin/utils/I18nKeyHasher.js +0 -78
  219. package/lib/plugins/newi18nsplitplugin/utils/getJsResourceKeys.js +0 -22
  220. package/lib/plugins/newi18nsplitplugin/utils/i18nChunkUtils.js +0 -18
  221. package/lib/plugins/newi18nsplitplugin/utils/manifestGenerator.js +0 -580
  222. package/lib/plugins/newi18nsplitplugin/utils/propertiesUtils.js +0 -54
@@ -4,12 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _utils = require("../utils");
9
+
8
10
  class WebpackWatchRunPlugin {
9
11
  apply(compiler) {
10
12
  compiler.hooks.watchRun.tap('WatchRun', comp => {
11
13
  const changedTimes = comp.watchFileSystem.watcher.mtimes;
12
14
  const changedFiles = Object.keys(changedTimes).map(file => `\n ${file}`).join('');
15
+
13
16
  if (changedFiles.length) {
14
17
  (0, _utils.log)('====================================');
15
18
  (0, _utils.log)('NEW BUILD FILES CHANGED:', changedFiles);
@@ -17,5 +20,7 @@ class WebpackWatchRunPlugin {
17
20
  }
18
21
  });
19
22
  }
23
+
20
24
  }
25
+
21
26
  exports.default = WebpackWatchRunPlugin;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  var _postcss = _interopRequireDefault(require("postcss"));
4
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
5
- module.exports = _postcss.default.plugin('postcss-empty', () => (root, result) => {
6
- // console.log(root.source.input.from, result);
4
+
5
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+
7
+ module.exports = _postcss.default.plugin('postcss-empty', () => (root, result) => {// console.log(root.source.input.from, result);
7
8
  });
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  var _postcss = _interopRequireDefault(require("postcss"));
4
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
4
+
5
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+
5
7
  module.exports = _postcss.default.plugin('postcss-exclude-files', opts => {
6
8
  const {
7
9
  plugins
@@ -9,8 +11,10 @@ module.exports = _postcss.default.plugin('postcss-exclude-files', opts => {
9
11
  return (root, result) => {
10
12
  const inputFile = root.source.input.file;
11
13
  const isIgnoredFile = opts.ignore.some(file => inputFile.indexOf(file) !== -1);
14
+
12
15
  if (!isIgnoredFile) {
13
16
  const handler = response => response.messages.forEach(msg => result.messages.push(msg));
17
+
14
18
  return (0, _postcss.default)(plugins).process(root, {
15
19
  from: undefined
16
20
  }).then(handler);
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  var _postcss = _interopRequireDefault(require("postcss"));
4
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
4
+
5
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+
5
7
  module.exports = _postcss.default.plugin('postcss-include-files', opts => {
6
8
  const {
7
9
  plugins
@@ -9,8 +11,10 @@ module.exports = _postcss.default.plugin('postcss-include-files', opts => {
9
11
  return (root, result) => {
10
12
  const inputFile = root.source.input.file;
11
13
  const includeFile = opts.include.some(file => inputFile.indexOf(file) !== -1);
14
+
12
15
  if (includeFile) {
13
16
  const handler = response => response.messages.forEach(msg => result.messages.push(msg));
17
+
14
18
  return (0, _postcss.default)(plugins).process(root, {
15
19
  from: undefined
16
20
  }).then(handler);
@@ -5,22 +5,31 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.separateRtlAndLtr = separateRtlAndLtr;
7
7
  exports.separateSingleDir = separateSingleDir;
8
+
8
9
  var postcss = _interopRequireWildcard(require("postcss"));
9
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+
13
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
+
11
15
  const oppositeDir = {
12
16
  ltr: 'rtl',
13
17
  rtl: 'ltr'
14
18
  };
19
+
15
20
  function compareSelector(selector1, selector2) {
16
21
  return selector1 === selector2;
17
22
  }
23
+
18
24
  const directionRegexs = {
19
25
  ltr: /\[dir=ltr\]/,
20
26
  rtl: /\[dir=rtl\]/
21
27
  };
28
+
22
29
  const getRegex = dir => directionRegexs[dir];
30
+
23
31
  const getOppositeRegex = dir => getRegex(oppositeDir[dir]);
32
+
24
33
  function selectorMinifySameDir(selector, direction) {
25
34
  // NOTE: if this rule is same dir as current need
26
35
  // then we can just remove that [dir=ltr] or [dir=rtl]
@@ -28,16 +37,18 @@ function selectorMinifySameDir(selector, direction) {
28
37
  const regex = getRegex(direction);
29
38
  return selector.replace(regex, '').trim();
30
39
  }
31
-
32
40
  /**
33
41
  * this funtion will remove given rule,
34
42
  * if given selector and it's previous sibiling rule selector are same
35
43
  * current rule properties will move to previous sibiling rule.
36
44
  * @param {Rule} rule current rule
37
45
  */
46
+
47
+
38
48
  function mergeIfSameSelector(rule) {
39
49
  // NOTE: to merge dublicate selector rules
40
50
  const prev = rule.prev();
51
+
41
52
  if (prev && compareSelector(prev.selector, rule.selector)) {
42
53
  rule.each(decl => {
43
54
  prev.append(decl);
@@ -45,24 +56,26 @@ function mergeIfSameSelector(rule) {
45
56
  rule.remove();
46
57
  }
47
58
  }
48
-
49
59
  /**
50
60
  * this funtion will remove given rule,
51
61
  * if given selector and it's previous sibiling rule selector are same
52
62
  * current rule properties will move to previous sibiling rule.
53
63
  * @param {Rule} rule current rule
54
64
  */
55
- function removeIfOppsiteDirRule(rule, direction, rootOptions) {
56
- const selectors = rule.selector.split(/\s*,\s*/);
57
65
 
58
- // NOTE: if we use opposite dir selector as custom override reason,
66
+
67
+ function removeIfOppsiteDirRule(rule, direction, rootOptions) {
68
+ const selectors = rule.selector.split(/\s*,\s*/); // NOTE: if we use opposite dir selector as custom override reason,
59
69
  // and compain normal selector with it, In this case
60
70
  // we just a have to remove that selector only not full rule
71
+
61
72
  const oppositeDirRegex = getOppositeRegex(direction);
62
73
  let remainingSelectors = selectors.filter(selector => !oppositeDirRegex.test(selector));
74
+
63
75
  if (!rootOptions.disableMiniFiySelector) {
64
76
  remainingSelectors = remainingSelectors.map(selector => selectorMinifySameDir(selector, direction));
65
77
  }
78
+
66
79
  if (remainingSelectors.length) {
67
80
  rule.selector = remainingSelectors.join(', ');
68
81
  } else {
@@ -70,13 +83,16 @@ function removeIfOppsiteDirRule(rule, direction, rootOptions) {
70
83
  rule.remove();
71
84
  }
72
85
  }
86
+
73
87
  function removeIfOppsiteDirKeyframe(rule, direction) {
74
88
  const name = rule.params;
75
89
  const keyFrameDirName = name.slice(name.lastIndexOf('-') + 1);
90
+
76
91
  if (keyFrameDirName === oppositeDir[direction]) {
77
92
  rule.remove();
78
93
  }
79
94
  }
95
+
80
96
  function separateSingleDir(root, direction, rootOptions) {
81
97
  root.walkRules(rule => {
82
98
  removeIfOppsiteDirRule(rule, direction, rootOptions);
@@ -87,11 +103,12 @@ function separateSingleDir(root, direction, rootOptions) {
87
103
  });
88
104
  return root;
89
105
  }
106
+
90
107
  function separateRtlAndLtr(css, rootOptions) {
91
108
  // let processor = postcss([]).process(css);
92
- const root = postcss.parse(css);
93
- // let { root } = processor;
109
+ const root = postcss.parse(css); // let { root } = processor;
94
110
  // NOTE: I did first rtl then ltr , Because for ltr I use original root ref
111
+
95
112
  const rtlRoot = separateSingleDir(root.clone(), 'rtl', rootOptions);
96
113
  const ltrRoot = separateSingleDir(root, 'ltr', rootOptions);
97
114
  return {
@@ -100,11 +117,8 @@ function separateRtlAndLtr(css, rootOptions) {
100
117
  ltr: ltrRoot.toString(),
101
118
  rtl: rtlRoot.toString()
102
119
  };
103
- }
104
-
105
- // NOTE: to test in https://astexplorer.net/
120
+ } // NOTE: to test in https://astexplorer.net/
106
121
  // you can test with sample input https://astexplorer.net/#/gist/a892a509eb585099355ef53ef094f836/1ca70d5f7af3b88ca4910296e12f118e9712c874
107
-
108
122
  // export default postcss.plugin('postcss-rtl-remove', (options = {}) =>
109
123
  // // Work with options here
110
124
  // root => {
@@ -113,7 +127,6 @@ function separateRtlAndLtr(css, rootOptions) {
113
127
  // // root.append(postcss.comment({ text: 'comment' }));
114
128
  // root.append(postcss.comment({ text: 'this is spliting part ' }));
115
129
  // root.append(rtlRoot);
116
-
117
130
  // // Transform CSS AST here
118
131
  // }
119
132
  // );
@@ -1,49 +1,63 @@
1
1
  "use strict";
2
2
 
3
3
  var _postcss = _interopRequireDefault(require("postcss"));
4
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
4
+
5
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+
5
7
  function validator(opts) {
6
8
  if (!opts || typeof opts !== 'object') {
7
9
  throw new Error('Always requires argment');
8
10
  }
11
+
9
12
  const {
10
13
  before,
11
14
  after
12
15
  } = opts;
16
+
13
17
  if (!before || !after) {
14
18
  throw new Error('Be sure to have "before" and "after" object names');
15
19
  }
20
+
16
21
  if (!Array.isArray(before) || !Array.isArray(after)) {
17
22
  throw new Error('Objects "before" and "after" must be of type Array');
18
23
  }
24
+
19
25
  if (before.length !== after.length) {
20
26
  throw new Error('Length of before and after options must be the same');
21
27
  }
28
+
22
29
  if (before.length === 0) {
23
30
  throw new Error('Array length is 1 or more');
24
31
  }
32
+
25
33
  before.forEach((beforeOpt, idx) => {
26
34
  const afterOpt = after[idx];
35
+
27
36
  switch (true) {
28
37
  case typeof beforeOpt === 'string':
29
38
  {
30
39
  if (!typeof afterOpt === 'string') {
31
40
  throw new Error(`The after option ${afterOpt} must be a string. If you want to apply the replace callback function, then use a RegExp for the before option`);
32
41
  }
42
+
33
43
  break;
34
44
  }
45
+
35
46
  case beforeOpt instanceof RegExp:
36
47
  {
37
48
  if (!typeof afterOpt === 'string' && !typeof afterOpt === 'function') {
38
49
  throw new Error(`The after option ${afterOpt} must be either a string, or a function`);
39
50
  }
51
+
40
52
  break;
41
53
  }
54
+
42
55
  default:
43
56
  throw new Error(`The before option ${beforeOpt} must be either a string, or a RegExp`);
44
57
  }
45
58
  });
46
59
  }
60
+
47
61
  module.exports = _postcss.default.plugin('postcss-selector-replace-new', opts => {
48
62
  validator(opts);
49
63
  const {
@@ -54,6 +68,7 @@ module.exports = _postcss.default.plugin('postcss-selector-replace-new', opts =>
54
68
  root.walkRules(rule => {
55
69
  before.forEach((beforeOpt, idx) => {
56
70
  const afterOpt = after[idx];
71
+
57
72
  if (typeof beforeOpt === 'string') {
58
73
  rule.selector = rule.selector.split(beforeOpt).join(afterOpt);
59
74
  } else {
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
 
3
3
  var _postcss = _interopRequireDefault(require("postcss"));
4
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
5
- module.exports = _postcss.default.plugin('postcss-value-replacer', (valueReplacer = {}) =>
6
- // Work with options here
4
+
5
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+
7
+ module.exports = _postcss.default.plugin('postcss-value-replacer', (valueReplacer = {}) => // Work with options here
7
8
  root => {
8
9
  root.walkDecls(decl => {
9
10
  valueReplacer.forEach(obj => {
@@ -16,11 +17,9 @@ root => {
16
17
  } else {
17
18
  decl.value = decl.value.replace(k, obj.values[k]);
18
19
  }
19
- });
20
- //decl.value = obj.values[decl.value];
20
+ }); //decl.value = obj.values[decl.value];
21
21
  }
22
- });
23
- //console.log({root, roots:root+""}, root+"")
22
+ }); //console.log({root, roots:root+""}, root+"")
24
23
  // Transform CSS AST here
25
24
  });
26
25
  });
@@ -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);
@@ -11,21 +11,18 @@ let settings2 = {
11
11
  before: [':root', 'data-'],
12
12
  after: [':global .zohodesk_controlpanel,:global .wms-mainui,:global .wms-hysearch, :global .mcf1ee8b17_overlay,:global .wms-hvalign, :global .KB_Editor_UploadImage,:global .zdeskEditor_popup, :global .ze_dd, :global .__baseZC_Container__', 'test-']
13
13
  }
14
- };
14
+ }; //error case
15
15
 
16
- //error case
17
16
  let settings3 = {
18
17
  selectorReplace: {
19
18
  before: [':root', 'data-'],
20
19
  after: [':global .zohodesk_controlpanel,:global .wms-mainui,:global .wms-hysearch, :global .mcf1ee8b17_overlay,:global .wms-hvalign, :global .KB_Editor_UploadImage,:global .zdeskEditor_popup, :global .ze_dd, :global .__baseZC_Container__']
21
20
  }
22
- };
21
+ }; //error case
23
22
 
24
- //error case
25
23
  let settings4 = {
26
24
  selectorReplace: {
27
25
  before: [':root'],
28
26
  after: [':global .zohodesk_controlpanel,:global .wms-mainui,:global .wms-hysearch, :global .mcf1ee8b17_overlay,:global .wms-hvalign, :global .KB_Editor_UploadImage,:global .zdeskEditor_popup, :global .ze_dd, :global .__baseZC_Container__', 'test-']
29
27
  }
30
- };
31
- // here conversion happens for data from one index to another
28
+ }; // here conversion happens for data from one index to another
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  var _postcss = _interopRequireDefault(require("postcss"));
4
+
4
5
  var _ValueReplacer = _interopRequireDefault(require("../ValueReplacer"));
5
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
6
- /* eslint-disable no-use-before-define */
7
6
 
7
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+
9
+ /* eslint-disable no-use-before-define */
8
10
  describe('postcss value replacer tests', () => {
9
11
  it('is creating value replaced code', () => {
10
12
  const cssInputStr = `.abc{ cursor : text }`;
@@ -35,6 +37,7 @@ describe('postcss value replacer tests', () => {
35
37
  expect(result.css).toEqual(cssOutputStr);
36
38
  });
37
39
  });
40
+
38
41
  function runValueReplacerForCssString(cssInputStr, cssOptions) {
39
42
  return (0, _postcss.default)([(0, _ValueReplacer.default)(cssOptions)]).process(cssInputStr);
40
43
  }