@zohodesk/client_build_tool 0.0.22-exp.3 → 0.0.22-exp.5

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 (242) hide show
  1. package/README.md +0 -723
  2. package/README_backup.md +0 -723
  3. package/app/README.MD +30 -0
  4. package/app/es/test.js +47 -0
  5. package/app/package.json +12 -0
  6. package/lib/schemas/defaultConfigValues.js +2 -2
  7. package/lib/schemas/defaultConfigValuesOnly.js +0 -5
  8. package/lib/shared/babel/babelWebConfig.js +2 -1
  9. package/lib/shared/bundler/webpack/configCustomLoaders.js +1 -4
  10. package/lib/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/utils.js +15 -0
  11. package/lib/shared/bundler/webpack/entryConfig.js +2 -3
  12. package/lib/shared/bundler/webpack/moduleConcatenationConfig.js +18 -0
  13. package/lib/shared/bundler/webpack/optimizationConfig.js +4 -9
  14. package/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +1 -1
  15. package/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +1 -1
  16. package/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +1 -1
  17. package/package.json +1 -1
  18. package/es/allCommandsConfigs.js +0 -15
  19. package/es/commands/build/commandExecutor.js +0 -6
  20. package/es/commands/build/config.js +0 -5
  21. package/es/commands/build/optionsProcessor.js +0 -25
  22. package/es/commands/build/preProcessor.js +0 -4
  23. package/es/commands/buildEs/commandExecutor.js +0 -29
  24. package/es/commands/buildEs/config.js +0 -5
  25. package/es/commands/buildEs/preProcessor.js +0 -9
  26. package/es/commands/buildLib/commandExecutor.js +0 -24
  27. package/es/commands/buildLib/config.js +0 -5
  28. package/es/commands/buildLib/preProcessor.js +0 -9
  29. package/es/commands/mockserver/commandExecutor.js +0 -32
  30. package/es/commands/mockserver/config.js +0 -5
  31. package/es/commands/pre_process/commandExecutor.js +0 -10
  32. package/es/commands/pre_process/config.js +0 -5
  33. package/es/commands/start/commandExecutor.js +0 -4
  34. package/es/commands/start/config.js +0 -5
  35. package/es/commands/start/optionsProcessor.js +0 -21
  36. package/es/commands/start/preProcessor.js +0 -4
  37. package/es/commands/template/commandExecutor.js +0 -17
  38. package/es/commands/template/config.js +0 -5
  39. package/es/commands/version/commandExecutor.js +0 -5
  40. package/es/commands/version/config.js +0 -5
  41. package/es/commandsRouter.js +0 -58
  42. package/es/index.js +0 -4
  43. package/es/logger.js +0 -23
  44. package/es/schemas/applyValuesToSchema/index.js +0 -25
  45. package/es/schemas/applyValuesToSchema/isObject.js +0 -3
  46. package/es/schemas/applyValuesToSchema/isValid.js +0 -7
  47. package/es/schemas/cliArgsToObject.js +0 -32
  48. package/es/schemas/defaultConfigValues.js +0 -394
  49. package/es/schemas/defaultConfigValuesOnly.js +0 -196
  50. package/es/schemas/deprecatedOptionsHandler.js +0 -60
  51. package/es/schemas/getNpmVersion.js +0 -13
  52. package/es/schemas/giveDefaultValue.js +0 -11
  53. package/es/schemas/npmConfigToObject.js +0 -27
  54. package/es/schemas/readOptions.js +0 -67
  55. package/es/schemas/readOptionsForConfigFile.js +0 -28
  56. package/es/shared/babel/addDefaultPlugins.js +0 -8
  57. package/es/shared/babel/babelWebConfig.js +0 -43
  58. package/es/shared/babel/babel_plugins/removeAttributesPlugin.js +0 -21
  59. package/es/shared/babel/getBabelPlugin.js +0 -36
  60. package/es/shared/babel/runBabelForJSFile.js +0 -15
  61. package/es/shared/babel/runBabelForTsFile.js +0 -34
  62. package/es/shared/bundler/webpack/common/decidePublicPath.js +0 -45
  63. package/es/shared/bundler/webpack/common/libAlias.js +0 -24
  64. package/es/shared/bundler/webpack/common/modeUtils.js +0 -24
  65. package/es/shared/bundler/webpack/common/nameTemplates.js +0 -95
  66. package/es/shared/bundler/webpack/common/resourceBasedPublicPath.js +0 -12
  67. package/es/shared/bundler/webpack/configCustomLoaders.js +0 -3
  68. package/es/shared/bundler/webpack/cssLoaders.js +0 -8
  69. package/es/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/index.js +0 -76
  70. package/es/shared/bundler/webpack/custom_plugins/CdnChangePlugin/index.js +0 -102
  71. package/es/shared/bundler/webpack/custom_plugins/CdnChangePlugin/webpackCustomJsUrlLoader.js +0 -36
  72. package/es/shared/bundler/webpack/custom_plugins/ChunkHierarchyPlugin.js +0 -65
  73. package/es/shared/bundler/webpack/custom_plugins/CssCustomOrderPlugin.js +0 -37
  74. package/es/shared/bundler/webpack/custom_plugins/CustomScriptLoadingPlugin.js +0 -97
  75. package/es/shared/bundler/webpack/custom_plugins/EFCTemplatePlugin.js +0 -98
  76. package/es/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +0 -211
  77. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ContributionGuide.md +0 -11
  78. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nFilesEmitPlugin.js +0 -160
  79. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +0 -66
  80. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nRuntimeDealerPlugin.js +0 -201
  81. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nSplit.md +0 -95
  82. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/LocaleChunkAssetsStore.js +0 -59
  83. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ModulesI18nKeysStore.js +0 -82
  84. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/README.md +0 -25
  85. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +0 -13
  86. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +0 -15
  87. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +0 -72
  88. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +0 -23
  89. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/iterateModulesInChunk.js +0 -40
  90. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +0 -59
  91. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +0 -15
  92. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +0 -22
  93. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +0 -35
  94. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +0 -70
  95. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +0 -56
  96. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/getChunkModules.js +0 -6
  97. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +0 -10
  98. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +0 -2
  99. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +0 -121
  100. package/es/shared/bundler/webpack/custom_plugins/InitialHtmlPlugin.js +0 -85
  101. package/es/shared/bundler/webpack/custom_plugins/InjectChunkGraphPlugin.js +0 -47
  102. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/addFilesNamesToManifestJson.js +0 -20
  103. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createInitialEntries.js +0 -11
  104. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createManifestJson.js +0 -26
  105. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/findInitialFileNames.js +0 -11
  106. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/index.js +0 -34
  107. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/removeHashFromFileName.js +0 -11
  108. package/es/shared/bundler/webpack/custom_plugins/MurphyInjectorPlugin/index.js +0 -79
  109. package/es/shared/bundler/webpack/custom_plugins/RTLSplitPlugin.js +0 -0
  110. package/es/shared/bundler/webpack/custom_plugins/ResourceHintsPlugin.js +0 -185
  111. package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +0 -47
  112. package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +0 -70
  113. package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtrSplit.md +0 -34
  114. package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +0 -14
  115. package/es/shared/bundler/webpack/custom_plugins/RuntimeResourceCleanup/index.js +0 -63
  116. package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/classHandling.js +0 -9
  117. package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/index.js +0 -63
  118. package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/selectorWeightPrefixAdder.js +0 -43
  119. package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/windowsModification.js +0 -7
  120. package/es/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +0 -104
  121. package/es/shared/bundler/webpack/custom_plugins/ServiceWorkerPluginUtils.js +0 -6
  122. package/es/shared/bundler/webpack/custom_plugins/SourceMapPlugin/index.js +0 -74
  123. package/es/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/addHashToFilePath.js +0 -10
  124. package/es/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/index.js +0 -36
  125. package/es/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin/index.js.js +0 -35
  126. package/es/shared/bundler/webpack/custom_plugins/VariableConversionCollector/ErrorHandler.js +0 -52
  127. package/es/shared/bundler/webpack/custom_plugins/VariableConversionCollector/index.js +0 -341
  128. package/es/shared/bundler/webpack/custom_plugins/custom_attribute_plugin/index.js +0 -67
  129. package/es/shared/bundler/webpack/custom_plugins/emitAsset.js +0 -7
  130. package/es/shared/bundler/webpack/custom_plugins/getInitialAssetsFuncTemplate.js +0 -43
  131. package/es/shared/bundler/webpack/custom_plugins/getInitialI18nAssetsArrayStr.js +0 -79
  132. package/es/shared/bundler/webpack/defaultVendorPatternList.js +0 -3
  133. package/es/shared/bundler/webpack/devtoolConfig.js +0 -6
  134. package/es/shared/bundler/webpack/entryConfig.js +0 -25
  135. package/es/shared/bundler/webpack/externals.js +0 -10
  136. package/es/shared/bundler/webpack/getCSSLoaders.js +0 -17
  137. package/es/shared/bundler/webpack/getFilenameFromModule.js +0 -15
  138. package/es/shared/bundler/webpack/jsLoaders.js +0 -16
  139. package/es/shared/bundler/webpack/loaderConfigs/assetLoaders.js +0 -4
  140. package/es/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +0 -10
  141. package/es/shared/bundler/webpack/loaderConfigs/checkIsPatternsMatchFilename.js +0 -45
  142. package/es/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +0 -11
  143. package/es/shared/bundler/webpack/loaderConfigs/configPostCssLoader.js +0 -23
  144. package/es/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +0 -13
  145. package/es/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +0 -71
  146. package/es/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +0 -56
  147. package/es/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +0 -11
  148. package/es/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +0 -40
  149. package/es/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +0 -116
  150. package/es/shared/bundler/webpack/loaders/miniCssFallBackLoader.js +0 -5
  151. package/es/shared/bundler/webpack/loaders/workerLoader.js +0 -121
  152. package/es/shared/bundler/webpack/optimizationConfig.js +0 -42
  153. package/es/shared/bundler/webpack/outputConfig.js +0 -35
  154. package/es/shared/bundler/webpack/pluginConfigs/configBundleAnalyzer.js +0 -30
  155. package/es/shared/bundler/webpack/pluginConfigs/configBundleIntegrityReport.js +0 -27
  156. package/es/shared/bundler/webpack/pluginConfigs/configCSSMinifierPlugin.js +0 -17
  157. package/es/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +0 -16
  158. package/es/shared/bundler/webpack/pluginConfigs/configChunkHierarchyPlugin.js +0 -10
  159. package/es/shared/bundler/webpack/pluginConfigs/configCopyPublicFolders.js +0 -50
  160. package/es/shared/bundler/webpack/pluginConfigs/configCssCustomOrderPlugin.js +0 -8
  161. package/es/shared/bundler/webpack/pluginConfigs/configCustomAttributesPlugin.js +0 -12
  162. package/es/shared/bundler/webpack/pluginConfigs/configCustomScriptLoadingStrategyPlugin.js +0 -67
  163. package/es/shared/bundler/webpack/pluginConfigs/configEFCTemplatePlugin.js +0 -37
  164. package/es/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +0 -43
  165. package/es/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +0 -52
  166. package/es/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +0 -17
  167. package/es/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +0 -29
  168. package/es/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +0 -8
  169. package/es/shared/bundler/webpack/pluginConfigs/configInjectChunkGraphPlugin.js +0 -12
  170. package/es/shared/bundler/webpack/pluginConfigs/configManifestJsonPlugin.js +0 -36
  171. package/es/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +0 -13
  172. package/es/shared/bundler/webpack/pluginConfigs/configMurphyInjectorPlugin.js +0 -19
  173. package/es/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +0 -18
  174. package/es/shared/bundler/webpack/pluginConfigs/configResourceHintsPlugin.js +0 -11
  175. package/es/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +0 -19
  176. package/es/shared/bundler/webpack/pluginConfigs/configRuntimeResourceCleanup.js +0 -20
  177. package/es/shared/bundler/webpack/pluginConfigs/configSelectorWeightPlugin.js +0 -18
  178. package/es/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +0 -29
  179. package/es/shared/bundler/webpack/pluginConfigs/configSourceMapPlugin.js +0 -12
  180. package/es/shared/bundler/webpack/pluginConfigs/configTPHashMappingPlugin.js +0 -20
  181. package/es/shared/bundler/webpack/pluginConfigs/configVariableConversionPlugin.js +0 -15
  182. package/es/shared/bundler/webpack/plugins.js +0 -33
  183. package/es/shared/bundler/webpack/resolvers.js +0 -70
  184. package/es/shared/bundler/webpack/splitChunksConfig.js +0 -106
  185. package/es/shared/bundler/webpack/statsConfig.js +0 -23
  186. package/es/shared/bundler/webpack/tsLoaders.js +0 -16
  187. package/es/shared/bundler/webpack/utils/index.js +0 -8
  188. package/es/shared/bundler/webpack/utils/object-manipulation.js +0 -82
  189. package/es/shared/bundler/webpack/utils/updateArrayWithDefault.js +0 -29
  190. package/es/shared/bundler/webpack/webpackBuild.js +0 -14
  191. package/es/shared/bundler/webpack/webpackConfig.js +0 -35
  192. package/es/shared/commands-utils/doBasicRequirementCheck.js +0 -10
  193. package/es/shared/commands-utils/getCliPath.js +0 -28
  194. package/es/shared/commands-utils/index.js +0 -3
  195. package/es/shared/commands-utils/log.js +0 -4
  196. package/es/shared/commands-utils/readArgsFormCommandLine.js +0 -4
  197. package/es/shared/commands-utils/readOptionFormCommandLine.js +0 -4
  198. package/es/shared/commands-utils/spawnSyncIO.js +0 -24
  199. package/es/shared/constants.js +0 -22
  200. package/es/shared/fileUtils/copyFile.js +0 -23
  201. package/es/shared/fileUtils/directoryIterator.js +0 -12
  202. package/es/shared/fileUtils/watchRun.js +0 -96
  203. package/es/shared/postcss/custom_postcss_plugins/EmptyPlugin.js +0 -18
  204. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/constants.js +0 -2
  205. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/handleIgnores.js +0 -58
  206. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/index.js +0 -122
  207. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/insertBefore.js +0 -22
  208. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/isPreviouslyProcessed.js +0 -11
  209. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/replaceUtils.js +0 -13
  210. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/separateHoveredSelectorAndNormalSelector.js +0 -17
  211. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/specialCases.js +0 -32
  212. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/typeCheckUtils.js +0 -28
  213. package/es/shared/postcss/custom_postcss_plugins/RTLSplitPlugin.js +0 -125
  214. package/es/shared/postcss/custom_postcss_plugins/SelectorReplace.js +0 -82
  215. package/es/shared/postcss/custom_postcss_plugins/ValueReplacer.js +0 -50
  216. package/es/shared/postcss/custom_postcss_plugins/VariableModificationPlugin/index.js +0 -318
  217. package/es/shared/postcss/filterPluginsAllowedForSpecficFile.js +0 -41
  218. package/es/shared/postcss/getAllowedPostCssPlugins.js +0 -20
  219. package/es/shared/postcss/getSpecificPostCssPlugin.js +0 -38
  220. package/es/shared/postcss/runPostCssForCssFile.js +0 -25
  221. package/es/shared/pre_process/runPreProcess.js +0 -47
  222. package/es/shared/server/configWebpackDevMiddleware.js +0 -26
  223. package/es/shared/server/corsHandling.js +0 -23
  224. package/es/shared/server/getIp.js +0 -18
  225. package/es/shared/server/getServerURL.js +0 -28
  226. package/es/shared/server/httpsOptions.js +0 -36
  227. package/es/shared/server/initExpressApp.js +0 -9
  228. package/es/shared/server/initialHTMLHandling.js +0 -92
  229. package/es/shared/server/mockApiHandler.js +0 -53
  230. package/es/shared/server/mockServer.js +0 -34
  231. package/es/shared/server/serveContextFiles.js +0 -17
  232. package/es/shared/server/serverBywebpackDevMiddleware.js +0 -21
  233. package/es/shared/server/startHttpServer.js +0 -18
  234. package/es/shared/server/startHttpsServer.js +0 -26
  235. package/es/shared/server/unwanted/addHttp2Server.js +0 -32
  236. package/es/shared/server/unwanted/configWebpackDevMiddleware.js +0 -35
  237. package/es/shared/server/unwanted/mockApiSupport.js +0 -11
  238. package/es/shared/server/unwanted/websocketMockSetup.js +0 -36
  239. package/es/shared/server/urlConcat.js +0 -35
  240. package/es/shared/utils/requireLocalOrGlobal.js +0 -57
  241. package/es/shared/utils/utils.js +0 -0
  242. package/es/shared/utils/versionPrint.js +0 -9
@@ -1,58 +0,0 @@
1
- import { isComment } from "./typeCheckUtils";
2
- const hoverIgnoreQuery = 'Hover:ignore';
3
- const activeIgnoreQuery = 'Active:ignore';
4
- const hoverActiveIgnoreQuery = 'HoverActive:ignore';
5
-
6
- function handleIgnore() {
7
- let isIgnored = false;
8
- return {
9
- isIgnored: () => isIgnored,
10
- update: isGoingTobeIgnored => {
11
- isIgnored = isGoingTobeIgnored;
12
- },
13
- reset: () => {
14
- isIgnored = false;
15
- }
16
- };
17
- } // eslint-disable-next-line no-unused-vars
18
-
19
-
20
- export function handleIgnores(options) {
21
- const hoverHandler = handleIgnore();
22
- const activeHandler = handleIgnore();
23
-
24
- function generateReturnValue() {
25
- return {
26
- hoverIgnored: hoverHandler.isIgnored(),
27
- activeIgnored: activeHandler.isIgnored()
28
- };
29
- }
30
-
31
- const ignoreCommentMap = {
32
- [hoverIgnoreQuery]: () => {
33
- hoverHandler.update(true);
34
- },
35
- [activeIgnoreQuery]: () => {
36
- activeHandler.update(true);
37
- },
38
- [hoverActiveIgnoreQuery]: () => {
39
- hoverHandler.update(true);
40
- activeHandler.update(true);
41
- }
42
- };
43
- return node => {
44
- if (isComment(node)) {
45
- const commentText = node.text.trim();
46
- ignoreCommentMap[commentText] && ignoreCommentMap[commentText](); // NOTE: we return here because this is just comment we can skip it.
47
-
48
- return generateReturnValue();
49
- } // NOTE: we get the here. But return after resetting for next. Because these comment Only works for once.
50
- // Even If we support multiple line Skip we must do it in reset or separate method.
51
-
52
-
53
- const returnValue = generateReturnValue();
54
- hoverHandler.reset();
55
- activeHandler.reset();
56
- return returnValue;
57
- };
58
- }
@@ -1,122 +0,0 @@
1
- import { handleIgnores } from "./handleIgnores";
2
- import { isRule, isAtRule, isMediaQuery } from "./typeCheckUtils";
3
- import { isPreviouslyProcessed, concatMediaParams } from "./isPreviouslyProcessed";
4
- import { insertNearBy } from "./insertBefore";
5
- import { separateHoveredSelectorAndNormalSelector } from "./separateHoveredSelectorAndNormalSelector";
6
- import { replaceHoverToActiveInSelector } from "./replaceUtils";
7
- import { hackForComposes, removeRuleIfNoNormalSelectors } from "./specialCases";
8
- export default (config => {
9
- const hoverMedQuerySuffix = config.hover;
10
- const activeMedQuerySuffix = config.active;
11
- return {
12
- postcssPlugin: 'postcss-mobile-hover',
13
- Once: function Once(root, params) {
14
- const getIgnoreStatus = handleIgnores(); // eslint-disable-next-line no-use-before-define
15
-
16
- const mediaRuleCreatorMap = getMediaRuleMap(params, hoverMedQuerySuffix, activeMedQuerySuffix);
17
- root.walk(node => {
18
- const ignoreStatus = getIgnoreStatus(node);
19
-
20
- if (isRule(node) === false) {
21
- return;
22
- }
23
-
24
- if (isAtRule(node.parent) && !isMediaQuery(node.parent)) {
25
- return;
26
- } // NOTE: after previous return we expect rule that are only normal rule or rules that inside media query
27
-
28
-
29
- const rule = node;
30
-
31
- if (isPreviouslyProcessed(rule, {
32
- hoverMedQuerySuffix,
33
- activeMedQuerySuffix
34
- })) {
35
- return;
36
- }
37
-
38
- const {
39
- hoveredSelectors,
40
- normalSelectors
41
- } = separateHoveredSelectorAndNormalSelector(rule.selector); // NOTE: this if will remove rule if the rule has no normal selectors. and return So be aware.
42
-
43
- if (hoveredSelectors.length === 0) {
44
- // || isRuleHasHover(rule) === false
45
- return;
46
- }
47
-
48
- let newHoverMediaQuery = null;
49
- let newActiveMediaQuery = null;
50
- let prefix = '';
51
-
52
- if (isAtRule(rule.parent)) {
53
- prefix = rule.parent.params;
54
- } else {
55
- // NOTE: for usual rules we don't need prefix, So use prefix as empty string
56
- prefix = '';
57
- }
58
-
59
- if (!ignoreStatus.hoverIgnored) {
60
- newHoverMediaQuery = mediaRuleCreatorMap.hoverRule({
61
- rule,
62
- hoveredSelectors,
63
- prefix
64
- }, params);
65
- }
66
-
67
- if (!ignoreStatus.activeIgnored) {
68
- newActiveMediaQuery = mediaRuleCreatorMap.activeRule({
69
- rule,
70
- hoveredSelectors,
71
- prefix
72
- }, params);
73
- }
74
-
75
- insertNearBy(rule, newHoverMediaQuery);
76
- insertNearBy(rule, newActiveMediaQuery);
77
- hackForComposes(rule, hoveredSelectors, params);
78
- removeRuleIfNoNormalSelectors(normalSelectors, rule);
79
- });
80
- }
81
- };
82
- });
83
-
84
- function getMediaRuleMap(params, hoverMedQuerySuffix, activeMedQuerySuffix) {
85
- const {
86
- AtRule
87
- } = params;
88
- return {
89
- hoverRule(_ref) {
90
- let {
91
- rule,
92
- hoveredSelectors,
93
- prefix
94
- } = _ref;
95
- const newMediaQuery = new AtRule({
96
- name: 'media',
97
- params: concatMediaParams(prefix, hoverMedQuerySuffix)
98
- });
99
- const clonedRule = rule.clone();
100
- clonedRule.selector = hoveredSelectors.join(',');
101
- newMediaQuery.append(clonedRule);
102
- return newMediaQuery;
103
- },
104
-
105
- activeRule(_ref2) {
106
- let {
107
- rule,
108
- hoveredSelectors,
109
- prefix
110
- } = _ref2;
111
- const newMediaQuery = new AtRule({
112
- name: 'media',
113
- params: concatMediaParams(prefix, activeMedQuerySuffix)
114
- });
115
- const clonedRule = rule.clone();
116
- clonedRule.selector = hoveredSelectors.map(replaceHoverToActiveInSelector).join(',');
117
- newMediaQuery.append(clonedRule);
118
- return newMediaQuery;
119
- }
120
-
121
- };
122
- }
@@ -1,22 +0,0 @@
1
- import { isAtRule, isParentAtRule } from "./typeCheckUtils";
2
- export function insertBefore(node, newNode) {
3
- newNode && node.parent.insertBefore(node, newNode);
4
- return newNode;
5
- } // function insertAfter(node, newNode) {
6
- // newNode && node.parent.insertAfter(node, newNode);
7
- // return newNode;
8
- // }
9
-
10
- export function insertNearBy(node, newNode) {
11
- if (!newNode) {
12
- return newNode;
13
- } // we use insertBefore Because we wouldn't end up recursive (repeated) check and creation
14
-
15
-
16
- if (isParentAtRule(node) && isAtRule(newNode)) {
17
- return insertNearBy(node.parent, newNode);
18
- }
19
-
20
- return insertBefore(node, newNode); // return insertAfter(node, newNode);
21
- // return newNode;
22
- }
@@ -1,11 +0,0 @@
1
- import { isParentAtRule, isParentAtRuleContainsParam } from "./typeCheckUtils";
2
- export function concatMediaParams(prefix, suffix) {
3
- return prefix ? `${prefix} and ${suffix}` : `${suffix}`;
4
- }
5
- export function isPreviouslyProcessed(rule, _ref) {
6
- let {
7
- hoverMedQuerySuffix,
8
- activeMedQuerySuffix
9
- } = _ref;
10
- return isParentAtRule(rule) && (isParentAtRuleContainsParam(rule, hoverMedQuerySuffix) || isParentAtRuleContainsParam(rule, activeMedQuerySuffix));
11
- }
@@ -1,13 +0,0 @@
1
- import { HOVER_NOTATION } from "./constants"; // function isRuleHasHover(rule) {
2
- // return isSelectorHasHover(rule.selector);
3
- // }
4
-
5
- function generateReplacer(baseStr, replaceStr) {
6
- return function () {
7
- let inputStr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
8
- return inputStr.replaceAll(baseStr, replaceStr);
9
- };
10
- }
11
-
12
- export const removeHoverFromSelector = generateReplacer(HOVER_NOTATION, '');
13
- export const replaceHoverToActiveInSelector = generateReplacer(HOVER_NOTATION, ':active');
@@ -1,17 +0,0 @@
1
- import { isSelectorHasHover } from "./typeCheckUtils";
2
- export function separateHoveredSelectorAndNormalSelector() {
3
- let fullselector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
4
- const hoveredSelectors = [];
5
- const normalSelectors = [];
6
- fullselector.split(/\s*,\s*/).forEach(selector => {
7
- if (isSelectorHasHover(selector)) {
8
- hoveredSelectors.push(selector);
9
- } else {
10
- normalSelectors.push(selector);
11
- }
12
- });
13
- return {
14
- hoveredSelectors,
15
- normalSelectors
16
- };
17
- }
@@ -1,32 +0,0 @@
1
- import { insertBefore } from "./insertBefore";
2
- import { removeHoverFromSelector } from "./replaceUtils";
3
- export function hackForComposes(rule, hoveredSelectors, params) {
4
- const {
5
- Rule
6
- } = params;
7
-
8
- if (hoveredSelectors.length === 0) {
9
- return;
10
- } // NOTE: we create Empty Rule with hovered selectors that :hover removed from hover selector
11
- // Reason: when composes looking for selector it most be at least empty rule other wise composes will throw error.
12
-
13
-
14
- insertBefore(rule, new Rule({
15
- selector: hoveredSelectors.map(removeHoverFromSelector).join(',')
16
- }));
17
- }
18
- /**
19
- * NOTE: this function will remove rule if the rule has no normal selectors.
20
- * @param {Rule} rule
21
- * @returns
22
- */
23
-
24
- export function removeRuleIfNoNormalSelectors(normalSelectors, rule) {
25
- if (normalSelectors.length) {
26
- // NOTE: removed hovered selectors
27
- // eslint-disable-next-line no-param-reassign
28
- rule.selector = normalSelectors.join(',');
29
- } else {
30
- rule.remove();
31
- }
32
- }
@@ -1,28 +0,0 @@
1
- import { HOVER_NOTATION } from "./constants";
2
- export function isComment(node) {
3
- return node.type === 'comment';
4
- }
5
- export function isRule(node) {
6
- return node.type === 'rule';
7
- }
8
- export function isMediaQuery(node) {
9
- return node.name === 'media';
10
- }
11
- export function isAtRule(node) {
12
- return node.type === 'atrule';
13
- }
14
- export function isAtRuleContainsParam(atRule, content) {
15
- return atRule.params.includes(content);
16
- }
17
- export function isParentAtRuleContainsParam(rule, content) {
18
- return isAtRuleContainsParam(rule.parent, content);
19
- }
20
- export function isParentAtRule(rule) {
21
- return isAtRule(rule.parent);
22
- }
23
- export function isRuleNotInsideAtRule(node) {
24
- return isRule(node) && node && !isAtRule(node.parent);
25
- }
26
- export function isSelectorHasHover(selector) {
27
- return selector.indexOf(HOVER_NOTATION) !== -1;
28
- }
@@ -1,125 +0,0 @@
1
- /* eslint-disable no-param-reassign */
2
- import * as postcss from 'postcss';
3
- const oppositeDir = {
4
- ltr: 'rtl',
5
- rtl: 'ltr'
6
- };
7
-
8
- function compareSelector(selector1, selector2) {
9
- // console.log({ selector1, selector2 }, selector1 === selector2);
10
- return selector1 === selector2;
11
- }
12
-
13
- const directionRegexs = {
14
- ltr: /\[dir=ltr\]/,
15
- rtl: /\[dir=rtl\]/
16
- };
17
-
18
- const getRegex = dir => directionRegexs[dir];
19
-
20
- const getOppositeRegex = dir => getRegex(oppositeDir[dir]);
21
-
22
- function selectorMinifySameDir(selector, direction) {
23
- // NOTE: if this rule is same dir as current need
24
- // then we can just remove that [dir=ltr] or [dir=rtl]
25
- // it just for minimaze selector
26
- const regex = getRegex(direction);
27
- return selector.replace(regex, '').trim();
28
- }
29
- /**
30
- * this funtion will remove given rule,
31
- * if given selector and it's previous sibiling rule selector are same
32
- * current rule properties will move to previous sibiling rule.
33
- * @param {Rule} rule current rule
34
- */
35
-
36
-
37
- function mergeIfSameSelector(rule) {
38
- // NOTE: to merge dublicate selector rules
39
- const prev = rule.prev();
40
-
41
- if (prev && compareSelector(prev.selector, rule.selector)) {
42
- rule.each(decl => {
43
- prev.append(decl);
44
- });
45
- rule.remove();
46
- }
47
- }
48
- /**
49
- * this funtion will remove given rule,
50
- * if given selector and it's previous sibiling rule selector are same
51
- * current rule properties will move to previous sibiling rule.
52
- * @param {Rule} rule current rule
53
- */
54
-
55
-
56
- function removeIfOppsiteDirRule(rule, direction, rootOptions) {
57
- // console.log({ rule, type: rule.type });
58
- const selectors = rule.selector.split(/\s*,\s*/); // NOTE: if we use opposite dir selector as custom override reason,
59
- // and compain normal selector with it, In this case
60
- // we just a have to remove that selector only not full rule
61
-
62
- const oppositeDirRegex = getOppositeRegex(direction);
63
- let remainingSelectors = selectors.filter(selector => !oppositeDirRegex.test(selector));
64
-
65
- if (!rootOptions.disableMinifySelector) {
66
- remainingSelectors = remainingSelectors.map(selector => selectorMinifySameDir(selector, direction));
67
- }
68
-
69
- if (remainingSelectors.length) {
70
- rule.selector = remainingSelectors.join(', ');
71
- } else {
72
- // NOTE: every selector is opposite dir then we have to remove the rule
73
- rule.remove();
74
- }
75
- }
76
-
77
- function removeIfOppsiteDirKeyframe(rule, direction) {
78
- const name = rule.params;
79
- const keyFrameDirName = name.slice(name.lastIndexOf('-') + 1);
80
-
81
- if (keyFrameDirName === oppositeDir[direction]) {
82
- // console.log({ m: 'removed', keyFrameName: rule.params });
83
- rule.remove();
84
- }
85
- }
86
-
87
- export function separateSingleDir(root, direction, rootOptions) {
88
- root.walkRules(rule => {
89
- removeIfOppsiteDirRule(rule, direction, rootOptions);
90
- mergeIfSameSelector(rule);
91
- });
92
- root.walkAtRules(rule => {
93
- removeIfOppsiteDirKeyframe(rule, direction);
94
- });
95
- return root;
96
- }
97
- export function separateRtlAndLtr(css, rootOptions) {
98
- // let processor = postcss([]).process(css);
99
- const root = postcss.parse(css); // let { root } = processor;
100
- // console.log(processor, root);
101
- // NOTE: I did first rtl then ltr , Because for ltr I use original root ref
102
-
103
- const rtlRoot = separateSingleDir(root.clone(), 'rtl', rootOptions); // console.log('############################');
104
-
105
- const ltrRoot = separateSingleDir(root, 'ltr', rootOptions);
106
- return {
107
- ltrRoot,
108
- rtlRoot,
109
- ltr: ltrRoot.toString(),
110
- rtl: rtlRoot.toString()
111
- };
112
- } // NOTE: to test in https://astexplorer.net/
113
- // you can test with sample input https://astexplorer.net/#/gist/a892a509eb585099355ef53ef094f836/1ca70d5f7af3b88ca4910296e12f118e9712c874
114
- // export default postcss.plugin('postcss-rtl-remove', (options = {}) =>
115
- // // Work with options here
116
- // root => {
117
- // const rtlRoot = separateSingleDir(root.clone(), 'rtl');
118
- // const ltrRoot = separateSingleDir(root, 'ltr');
119
- // // root.append(postcss.comment({ text: 'comment' }));
120
- // root.append(postcss.comment({ text: 'this is spliting part ' }));
121
- // root.append(rtlRoot);
122
- // //console.log({root, roots:root+""}, root+"")
123
- // // Transform CSS AST here
124
- // }
125
- // );
@@ -1,82 +0,0 @@
1
- /* eslint-disable no-param-reassign */
2
- export default (function () {
3
- let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4
- // eslint-disable-next-line no-use-before-define
5
- validator(opts);
6
- const {
7
- before,
8
- after
9
- } = opts;
10
- return {
11
- postcssPlugin: 'postcss-selector-replace',
12
-
13
- Once(root) {
14
- root.walkRules(rule => {
15
- before.forEach((beforeOpt, idx) => {
16
- const afterOpt = after[idx];
17
-
18
- if (typeof beforeOpt === 'string') {
19
- rule.selector = rule.selector.split(beforeOpt).join(afterOpt);
20
- } else {
21
- rule.selector = rule.selector.replace(beforeOpt, afterOpt);
22
- }
23
- });
24
- });
25
- }
26
-
27
- };
28
- });
29
-
30
- function validator(opts) {
31
- if (!opts || typeof opts !== 'object') {
32
- throw new Error('Always requires argment');
33
- }
34
-
35
- const {
36
- before,
37
- after
38
- } = opts;
39
-
40
- if (!before || !after) {
41
- throw new Error('Be sure to have "before" and "after" object names');
42
- }
43
-
44
- if (!Array.isArray(before) || !Array.isArray(after)) {
45
- throw new Error('Objects "before" and "after" must be of type Array');
46
- }
47
-
48
- if (before.length !== after.length) {
49
- throw new Error('Length of before and after options must be the same');
50
- }
51
-
52
- if (before.length === 0) {
53
- throw new Error('Array length is 1 or more');
54
- }
55
-
56
- before.forEach((beforeOpt, idx) => {
57
- const afterOpt = after[idx];
58
-
59
- switch (true) {
60
- case typeof beforeOpt === 'string':
61
- {
62
- if (!typeof afterOpt === 'string') {
63
- 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`);
64
- }
65
-
66
- break;
67
- }
68
-
69
- case beforeOpt instanceof RegExp:
70
- {
71
- if (!typeof afterOpt === 'string' && !typeof afterOpt === 'function') {
72
- throw new Error(`The after option ${afterOpt} must be either a string, or a function`);
73
- }
74
-
75
- break;
76
- }
77
-
78
- default:
79
- throw new Error(`The before option ${beforeOpt} must be either a string, or a RegExp`);
80
- }
81
- });
82
- }
@@ -1,50 +0,0 @@
1
- const diffBasedOnStrLength = (a, b) => b.length - a.length;
2
- /**
3
- * @param {Array} valueReplacer
4
- * [
5
- {
6
- "props": ["color", "background-color"],
7
- "values" : {
8
- "zd-": "im-"
9
- }
10
- }
11
- ]
12
- */
13
-
14
-
15
- const PostcssValueReplacer = function () {
16
- let valueReplacer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
17
- const options = {};
18
- valueReplacer.forEach(obj => {
19
- obj.props.forEach(prop => {
20
- const valueKeys = Object.keys(obj.values);
21
- const propOptions = options[prop];
22
-
23
- if (options[prop]) {
24
- valueKeys.forEach(k => {
25
- propOptions.values[k] = obj.values[k];
26
- });
27
- propOptions.sortedKeys = propOptions.values.sort(diffBasedOnStrLength);
28
- } else {
29
- options[prop] = {
30
- sortedKeys: valueKeys.sort(diffBasedOnStrLength),
31
- values: obj.values
32
- };
33
- }
34
- });
35
- }); // Work with options here
36
-
37
- return {
38
- postcssPlugin: 'postcss-value-replacer',
39
- Declaration: decl => {
40
- const propOptions = options[decl.prop];
41
- propOptions?.sortedKeys.forEach(k => {
42
- // eslint-disable-next-line no-param-reassign
43
- decl.value = decl.value.replaceAll(new RegExp(k, 'g'), propOptions.values[k]);
44
- });
45
- }
46
- };
47
- };
48
-
49
- PostcssValueReplacer.postcss = true;
50
- export default PostcssValueReplacer;