@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.
- package/README.md +18 -0
- package/lib/babel/babel-option-utils/babel-preset-react-option.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +13 -2
- package/lib/babel/es-plugins-presets.js +14 -3
- package/lib/common/buildEs.js +0 -1
- package/lib/common/getEntries.js +13 -2
- package/lib/common/getPublicPathConfig.js +6 -0
- package/lib/common/index.js +6 -1
- package/lib/common/runPreProcess.js +15 -6
- package/lib/common/splitChunks.js +21 -2
- package/lib/common/sslcertUpdater.js +18 -7
- package/lib/common/templateParameters.js +2 -0
- package/lib/common/testPattern.js +21 -10
- package/lib/common/valueReplacer.js +16 -1
- package/lib/configs/jest.config.js +11 -2
- package/lib/configs/libAlias.js +16 -10
- package/lib/configs/resolvers.js +16 -6
- package/lib/configs/webpack.component.umd.config.js +6 -1
- package/lib/configs/webpack.css.umd.config.js +14 -6
- package/lib/configs/webpack.dev.config.js +14 -1
- package/lib/configs/webpack.docs.config.js +9 -1
- package/lib/configs/webpack.impact.config.js +8 -1
- package/lib/configs/webpack.prod.config.js +17 -4
- package/lib/constants.js +18 -9
- package/lib/deprecationLogger.js +7 -0
- package/lib/hooks/docsProptypeHook.js +8 -4
- package/lib/jest/commitedFilesResult.js +46 -4
- package/lib/jest/coverageCollector.js +12 -1
- package/lib/jest/jsonMaker.js +6 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +9 -1
- package/lib/jest/preProcessors/jsPreprocessor.js +11 -2
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +4 -1
- package/lib/jest/result.js +23 -1
- package/lib/jest/run.js +18 -7
- package/lib/jest/setup.js +60 -8
- package/lib/loaderUtils/configsAssetsLoaders.js +12 -2
- package/lib/loaderUtils/getCSSLoaders.js +22 -10
- package/lib/loaderUtils/getDevJsLoaders.js +13 -4
- package/lib/loaderUtils/index.js +4 -1
- package/lib/loaderUtils/tests/windowsModification.test.js +1 -0
- package/lib/loaderUtils/windowsModification.js +3 -2
- package/lib/loaders/__test__/markdownLoader.spec.js +1 -0
- package/lib/loaders/composeLoader.js +37 -13
- package/lib/loaders/docsLoader.js +12 -1
- package/lib/loaders/docsPropsLoader.js +8 -4
- package/lib/loaders/enhancedReactLiveConverter.js +23 -2
- package/lib/loaders/fileBountryLoader.js +3 -1
- package/lib/loaders/fileLoader.js +23 -12
- package/lib/loaders/markdownLoader.js +19 -14
- package/lib/loaders/reactLiveConvertor.js +15 -5
- package/lib/loaders/scriptInstrumentLoader.js +16 -7
- package/lib/loaders/selectorMappingLoader.js +26 -7
- package/lib/loaders/workerLoader.js +24 -9
- package/lib/logger.js +4 -0
- package/lib/middlewares/HMRMiddleware.js +27 -13
- package/lib/middlewares/SSTMiddleware.js +5 -1
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +24 -1
- package/lib/pluginUtils/getDevPlugins.js +42 -9
- package/lib/pluginUtils/getDocsPlugins.js +13 -3
- package/lib/pluginUtils/getLibraryImactPlugins.js +6 -5
- package/lib/pluginUtils/getLibraryPlugins.js +8 -2
- package/lib/pluginUtils/getProdPlugins.js +47 -8
- package/lib/pluginUtils/getServerPlugins.js +8 -2
- package/lib/pluginUtils/getUMDCSSPlugins.js +10 -2
- package/lib/pluginUtils/getUMDComponentPlugins.js +10 -2
- package/lib/pluginUtils/index.js +9 -1
- package/lib/plugins/CdnChangePlugin.js +18 -2
- package/lib/plugins/CleanupStatsPlugin.js +5 -0
- package/lib/plugins/CssOrderControlPlugin.js +6 -3
- package/lib/plugins/CustomAttributePlugin.js +19 -14
- package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +23 -3
- package/lib/plugins/EFCPlugin.js +34 -20
- package/lib/plugins/EFCTemplatePlugin.js +30 -19
- package/lib/plugins/EfcResourceCleanupPlugin.js +3 -0
- package/lib/plugins/EventsHandlingPlugin.js +4 -2
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +37 -14
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +15 -10
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +155 -78
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +81 -198
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +23 -12
- package/lib/plugins/I18nSplitPlugin/index.js +24 -13
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +12 -2
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +1 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +5 -0
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +8 -1
- package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -0
- package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +1 -0
- package/lib/plugins/ManifestPlugin.js +18 -1
- package/lib/plugins/MinifyPlugin.js +10 -1
- package/lib/plugins/ModuleStatsPlugin.js +24 -1
- package/lib/plugins/OptimizeJSPlugin.js +10 -2
- package/lib/plugins/PublicPathCallbackPlugin.js +12 -1
- package/lib/plugins/PublicPathChangePlugin.js +39 -6
- package/lib/plugins/ReportGeneratePlugin.js +32 -5
- package/lib/plugins/RequireVariablePublicPlugin.js +8 -1
- package/lib/plugins/ResourceHintsPlugin.js +13 -4
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +17 -10
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
- package/lib/plugins/ScriptInstrumentPlugin.js +8 -1
- package/lib/plugins/SelectorPlugin.js +32 -6
- package/lib/plugins/ServiceWorkerPlugin.js +22 -5
- package/lib/plugins/ShadowDOMSupportPlugin.js +41 -4
- package/lib/plugins/SourceMapHookPlugin.js +12 -2
- package/lib/plugins/StatsPlugin.js +14 -0
- package/lib/plugins/TPHashMappingPlugin.js +18 -3
- package/lib/plugins/UnusedFilesFindPlugin.js +39 -4
- package/lib/plugins/VariableConversionCollector.js +42 -15
- package/lib/plugins/index.js +20 -1
- package/lib/plugins/libraryImpactPlugin.js +33 -1
- package/lib/plugins/utils/classHandling.js +6 -0
- package/lib/plugins/utils/fileHandling.js +15 -6
- package/lib/plugins/utils/tests/fileHandling.test.js +4 -0
- package/lib/plugins/variableConvertorUtils.js +29 -14
- package/lib/plugins/webpackwatchrunplugin.js +5 -0
- package/lib/postcss-plugins/EmptyPlugin.js +4 -3
- package/lib/postcss-plugins/ExcludePlugin.js +5 -1
- package/lib/postcss-plugins/IncludePlugin.js +5 -1
- package/lib/postcss-plugins/RTLSplitPlugin.js +27 -14
- package/lib/postcss-plugins/SelectorReplace.js +16 -1
- package/lib/postcss-plugins/ValueReplacer.js +6 -7
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
- package/lib/postcss-plugins/__test__/selectorReplace.test.js +3 -6
- package/lib/postcss-plugins/__test__/valueReplacer.spec.js +5 -2
- package/lib/postcss-plugins/hoverActivePlugin.js +67 -31
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +7 -0
- package/lib/postcss-plugins/variableModificationPlugin/index.js +49 -28
- package/lib/schemas/index.js +10 -3
- package/lib/servers/clusterHubServer.js +11 -1
- package/lib/servers/devBuild.js +26 -14
- package/lib/servers/docsServer.js +3 -1
- package/lib/servers/docsServerCore.js +22 -1
- package/lib/servers/getCliPath.js +9 -0
- package/lib/servers/helpServer.js +6 -1
- package/lib/servers/httpsOptions.js +8 -2
- package/lib/servers/impactServer.js +35 -3
- package/lib/servers/mockserver.js +10 -1
- package/lib/servers/nowatchserver.js +37 -12
- package/lib/servers/requireLocalOrGlobal.js +17 -6
- package/lib/servers/scrServer.js +21 -14
- package/lib/servers/server.js +36 -6
- package/lib/servers/ssServer.js +17 -1
- package/lib/templates/CoverageScriptTemplate.js +14 -0
- package/lib/templates/WMSTemplate.js +13 -7
- package/lib/templates/linterConstant.js +4 -2
- package/lib/utils/babelPresets.js +7 -3
- package/lib/utils/clean.js +9 -3
- package/lib/utils/copy.js +7 -1
- package/lib/utils/copyTimezones.js +9 -1
- package/lib/utils/createEventStream.js +6 -1
- package/lib/utils/cssClassNameGenerate.js +30 -10
- package/lib/utils/cssURLReplacer.js +22 -1
- package/lib/utils/dependencyPostPublish.js +10 -1
- package/lib/utils/deprecationSupport.js +32 -7
- package/lib/utils/fileUtils.js +28 -1
- package/lib/utils/folderIterator.js +13 -2
- package/lib/utils/getComponents.js +21 -0
- package/lib/utils/getCurrentBranch.js +5 -0
- package/lib/utils/getDependenciesImpactList.js +22 -1
- package/lib/utils/getFileType.js +10 -2
- package/lib/utils/getHash.js +8 -1
- package/lib/utils/getIp.js +2 -0
- package/lib/utils/getOptions.js +53 -16
- package/lib/utils/getServerURL.js +10 -1
- package/lib/utils/index.js +51 -4
- package/lib/utils/init.js +1 -0
- package/lib/utils/initPreCommitHook.js +30 -7
- package/lib/utils/jsonHelper.js +22 -3
- package/lib/utils/libraryImpactConfig.js +5 -2
- package/lib/utils/lint/addScripts.js +5 -2
- package/lib/utils/lint/checkExistingConfig.js +12 -3
- package/lib/utils/lint/copyConfigs.js +3 -0
- package/lib/utils/lint/index.js +9 -0
- package/lib/utils/lint/lintScripts.js +1 -0
- package/lib/utils/lint/lintSetup.js +4 -3
- package/lib/utils/lint/lintStagedPreCommitHook.js +1 -0
- package/lib/utils/lint/question.js +7 -0
- package/lib/utils/lintReporter.js +20 -0
- package/lib/utils/log.js +1 -0
- package/lib/utils/mailSender.js +8 -1
- package/lib/utils/object-manipulation.js +17 -1
- package/lib/utils/pullOrigin.js +4 -0
- package/lib/utils/reinstallDependencies.js +29 -1
- package/lib/utils/removeAttributes.js +8 -1
- package/lib/utils/repoClone.js +28 -3
- package/lib/utils/request.js +12 -0
- package/lib/utils/rtl.js +17 -5
- package/lib/utils/selectorReplacer.js +16 -10
- package/lib/utils/setEnvVariables.js +2 -0
- package/lib/utils/ssTestHack.js +11 -1
- package/lib/utils/switchBranch.js +5 -0
- package/lib/utils/typeCheck.js +1 -0
- package/lib/utils/urlConcat.js +4 -0
- package/lib/utils/useExitCleanup.js +10 -9
- package/lib/utils/variableConverter.js +31 -22
- package/{package-lock.json → npm-shrinkwrap.json} +2333 -2101
- package/package.json +3 -2
- package/lib/plugins/I18nSplitPlugin/utils/applyMetaManifest.js +0 -279
- package/lib/plugins/I18nSplitPlugin/utils/createMetaManifest.js +0 -51
- package/lib/plugins/I18nSplitPlugin/utils/createRegularManifest.js +0 -48
- package/lib/plugins/newi18nsplitplugin/18nPlugin1.js +0 -306
- package/lib/plugins/newi18nsplitplugin/18nPlugin2.js +0 -363
- package/lib/plugins/newi18nsplitplugin/18nPlugin3.js +0 -694
- package/lib/plugins/newi18nsplitplugin/18nPlugin_hashed.js +0 -1258
- package/lib/plugins/newi18nsplitplugin/18nPlugin_working.js +0 -542
- package/lib/plugins/newi18nsplitplugin/18nplugin.js +0 -974
- package/lib/plugins/newi18nsplitplugin/ChunkManager.js +0 -131
- package/lib/plugins/newi18nsplitplugin/GenerateModuleIdToKeysMapPlugin.js +0 -59
- package/lib/plugins/newi18nsplitplugin/I18nDiffPlugin.js +0 -262
- package/lib/plugins/newi18nsplitplugin/I18nDownloadLogic.js +0 -166
- package/lib/plugins/newi18nsplitplugin/I18nPropertiesPlugin.js +0 -111
- package/lib/plugins/newi18nsplitplugin/KeyCollector.js +0 -163
- package/lib/plugins/newi18nsplitplugin/ManifestGenerator.js +0 -88
- package/lib/plugins/newi18nsplitplugin/UnicodeConversionPlugin.js +0 -101
- package/lib/plugins/newi18nsplitplugin/constants.js +0 -162
- package/lib/plugins/newi18nsplitplugin/utils/I18nKeyHasher.js +0 -78
- package/lib/plugins/newi18nsplitplugin/utils/getJsResourceKeys.js +0 -22
- package/lib/plugins/newi18nsplitplugin/utils/i18nChunkUtils.js +0 -18
- package/lib/plugins/newi18nsplitplugin/utils/manifestGenerator.js +0 -580
- package/lib/plugins/newi18nsplitplugin/utils/propertiesUtils.js +0 -54
@@ -1,24 +1,28 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _postcss = _interopRequireDefault(require("postcss"));
|
4
|
-
|
4
|
+
|
5
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6
|
+
|
5
7
|
/**
|
6
8
|
* we have give support for ignore(exclude) comments
|
7
9
|
* These are the comments' keyword
|
8
10
|
*/
|
9
11
|
const hoverIgnoreQuery = 'Hover:ignore',
|
10
|
-
|
11
|
-
|
12
|
+
activeIgnoreQuery = 'Active:ignore',
|
13
|
+
hoverActiveIgnoreQuery = 'HoverActive:ignore';
|
12
14
|
const medHoverIgnoreQuery = 'MedHover:ignore',
|
13
|
-
|
14
|
-
|
15
|
+
medActiveIgnoreQuery = 'MedActive:ignore',
|
16
|
+
medHoverActiveIgnoreQuery = 'MedHoverActive:ignore';
|
15
17
|
let hoverMedQuerySuffix = '';
|
16
18
|
let hoverNoneMedQuerySuffix = '';
|
17
19
|
const ruleIgnoreCommentRegex = /(Hover:ignore|Active:ignore|HoverActive:ignore)/g;
|
18
20
|
const mediaQueryIgnoreCommentRegex = /(MedHover:ignore|MedActive:ignore|MedHoverActive:ignore)/g;
|
21
|
+
|
19
22
|
function isComment(node) {
|
20
23
|
return node && node.type === 'comment' && node.text !== undefined;
|
21
24
|
}
|
25
|
+
|
22
26
|
function isHoverPresent(atrule) {
|
23
27
|
let hoverPresent = false;
|
24
28
|
atrule.walkRules(rule => {
|
@@ -28,6 +32,7 @@ function isHoverPresent(atrule) {
|
|
28
32
|
});
|
29
33
|
return hoverPresent;
|
30
34
|
}
|
35
|
+
|
31
36
|
function checkForUsualClass(root, sel) {
|
32
37
|
let present = false;
|
33
38
|
sel.split(',').forEach(value => {
|
@@ -42,24 +47,31 @@ function checkForUsualClass(root, sel) {
|
|
42
47
|
});
|
43
48
|
return present;
|
44
49
|
}
|
50
|
+
|
45
51
|
module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHoverActiveString => rootOriginal => {
|
46
52
|
const hoverRules = [];
|
47
53
|
const positionsObj = {};
|
48
54
|
hoverMedQuerySuffix = mediaQueryHoverActiveString.hover;
|
49
55
|
hoverNoneMedQuerySuffix = mediaQueryHoverActiveString.none;
|
56
|
+
|
50
57
|
function isRuleHasIgnoreComment(index, type) {
|
51
58
|
const prevNode = rootOriginal.nodes[index - 1];
|
59
|
+
|
52
60
|
if (isComment(prevNode)) {
|
53
61
|
return prevNode.text === type;
|
54
62
|
}
|
63
|
+
|
55
64
|
return false;
|
56
65
|
}
|
66
|
+
|
57
67
|
function isMediaQueryHasIgnoreComment(node, type) {
|
58
68
|
if (isComment(node)) {
|
59
69
|
return node.text === type;
|
60
70
|
}
|
71
|
+
|
61
72
|
return false;
|
62
73
|
}
|
74
|
+
|
63
75
|
function hasIgnoreComment({
|
64
76
|
index,
|
65
77
|
atrule,
|
@@ -68,11 +80,14 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
68
80
|
if (type.match(mediaQueryIgnoreCommentRegex)) {
|
69
81
|
return isMediaQueryHasIgnoreComment(atrule.nodes[index - 1], type.slice(3));
|
70
82
|
}
|
83
|
+
|
71
84
|
if (type.match(ruleIgnoreCommentRegex)) {
|
72
85
|
return isRuleHasIgnoreComment(index, type);
|
73
86
|
}
|
87
|
+
|
74
88
|
return false;
|
75
89
|
}
|
90
|
+
|
76
91
|
function getPositionsOfHoverAndActiveMedQueries(parent) {
|
77
92
|
const allNodes = rootOriginal.nodes;
|
78
93
|
const hoverMediaQuery = `${parent.params} and ${hoverMedQuerySuffix}`;
|
@@ -83,6 +98,7 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
83
98
|
};
|
84
99
|
return positions;
|
85
100
|
}
|
101
|
+
|
86
102
|
function handleMedHoverAndHoverActiveIgnore(atrule, index) {
|
87
103
|
return !hasIgnoreComment({
|
88
104
|
atrule,
|
@@ -94,6 +110,7 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
94
110
|
type: medHoverActiveIgnoreQuery
|
95
111
|
});
|
96
112
|
}
|
113
|
+
|
97
114
|
function handleMedActiveAndHoverActiveIgnore(atrule, index) {
|
98
115
|
return !hasIgnoreComment({
|
99
116
|
atrule,
|
@@ -105,6 +122,7 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
105
122
|
type: medHoverActiveIgnoreQuery
|
106
123
|
});
|
107
124
|
}
|
125
|
+
|
108
126
|
function handleHoverAndHoverActiveIgnore(index) {
|
109
127
|
return !hasIgnoreComment({
|
110
128
|
index,
|
@@ -114,6 +132,7 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
114
132
|
type: hoverActiveIgnoreQuery
|
115
133
|
});
|
116
134
|
}
|
135
|
+
|
117
136
|
function handleActiveAndHoverActiveIgnore(index) {
|
118
137
|
return !hasIgnoreComment({
|
119
138
|
index,
|
@@ -123,6 +142,7 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
123
142
|
type: hoverActiveIgnoreQuery
|
124
143
|
});
|
125
144
|
}
|
145
|
+
|
126
146
|
function handleAllIgnoreCases(index) {
|
127
147
|
return !hasIgnoreComment({
|
128
148
|
index,
|
@@ -135,6 +155,7 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
135
155
|
type: hoverActiveIgnoreQuery
|
136
156
|
});
|
137
157
|
}
|
158
|
+
|
138
159
|
function mediaCommaQuery(rule, index) {
|
139
160
|
if (rule.parent.params !== undefined && !rule.parent.params.includes('hover')) {
|
140
161
|
let newSelector = '';
|
@@ -146,12 +167,16 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
146
167
|
const actQueries = [];
|
147
168
|
rule.selector.split(/\s*,\s*/).forEach(_subrule => {
|
148
169
|
const subrule = _subrule.trim();
|
170
|
+
|
149
171
|
const clone = rule.clone();
|
172
|
+
|
150
173
|
if (subrule.includes('hover')) {
|
151
174
|
clone.selector = subrule;
|
175
|
+
|
152
176
|
if (handleMedHoverAndHoverActiveIgnore(rule.parent, index)) {
|
153
177
|
hovQueries.push(subrule);
|
154
178
|
}
|
179
|
+
|
155
180
|
if (handleMedActiveAndHoverActiveIgnore(rule.parent, index)) {
|
156
181
|
actQueries.push(subrule);
|
157
182
|
}
|
@@ -159,11 +184,13 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
159
184
|
newSelector += `${subrule}, `;
|
160
185
|
}
|
161
186
|
});
|
187
|
+
|
162
188
|
if (hovQueries.length > 0) {
|
163
189
|
const clone = rule.clone();
|
164
190
|
clone.selector = hovQueries.join(',');
|
165
191
|
hovMed.append(clone);
|
166
192
|
}
|
193
|
+
|
167
194
|
if (actQueries.length > 0) {
|
168
195
|
const clone = rule.clone();
|
169
196
|
clone.selector = actQueries.join(',');
|
@@ -171,24 +198,29 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
171
198
|
selector: clone.selector.replace(/:hover/gi, ':active')
|
172
199
|
}));
|
173
200
|
}
|
201
|
+
|
174
202
|
if (handleMedHoverAndHoverActiveIgnore(rule.parent, index)) {
|
175
203
|
rule.selector = newSelector.substring(0, newSelector.length - 2);
|
176
204
|
}
|
205
|
+
|
177
206
|
if (rule.selector === '') {
|
178
207
|
rule.remove();
|
179
208
|
}
|
180
209
|
}
|
181
210
|
}
|
211
|
+
|
182
212
|
function mediaQuery(rule, index) {
|
183
213
|
if (rule.parent.params !== undefined && !rule.parent.params.includes('hover')) {
|
184
214
|
const {
|
185
215
|
hovMed,
|
186
216
|
actMed
|
187
217
|
} = getPositionsOfHoverAndActiveMedQueries(rule.parent);
|
218
|
+
|
188
219
|
if (rule.selector.includes('hover') && hovMed !== undefined && rule.parent.type === 'atrule') {
|
189
220
|
if (handleMedHoverAndHoverActiveIgnore(rule.parent, index)) {
|
190
221
|
hovMed.append(rule);
|
191
222
|
}
|
223
|
+
|
192
224
|
if (handleMedActiveAndHoverActiveIgnore(rule.parent, index)) {
|
193
225
|
actMed.append(rule.clone({
|
194
226
|
selector: rule.selector.replace(/:hover/gi, ':active')
|
@@ -197,11 +229,13 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
197
229
|
}
|
198
230
|
}
|
199
231
|
}
|
232
|
+
|
200
233
|
function commaQuery(rule, index) {
|
201
234
|
let newSelector = '';
|
202
235
|
const hovQueries = [];
|
203
236
|
rule.selector.split(/\s*,\s*/).forEach(_subrule => {
|
204
237
|
const subrule = _subrule.trim();
|
238
|
+
|
205
239
|
if (subrule.includes('hover')) {
|
206
240
|
// hoverRules.push({ rule: clone, index });
|
207
241
|
hovQueries.push(subrule);
|
@@ -209,6 +243,7 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
209
243
|
newSelector += `${subrule}, `;
|
210
244
|
}
|
211
245
|
});
|
246
|
+
|
212
247
|
if (hovQueries.length > 0) {
|
213
248
|
const clone = rule.clone();
|
214
249
|
clone.selector = hovQueries.join(',');
|
@@ -217,20 +252,23 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
217
252
|
index
|
218
253
|
});
|
219
254
|
}
|
255
|
+
|
220
256
|
if (handleHoverAndHoverActiveIgnore(index)) {
|
221
257
|
if (checkForUsualClass(rootOriginal, rule.selector)) {
|
222
258
|
rule.selector = newSelector.substring(0, newSelector.length - 2).trim();
|
223
259
|
}
|
224
260
|
}
|
261
|
+
|
225
262
|
if (rule.selector === '') {
|
226
263
|
rule.remove();
|
227
264
|
}
|
228
|
-
}
|
265
|
+
} // Start by identifying all :hover rules
|
266
|
+
|
229
267
|
|
230
|
-
// Start by identifying all :hover rules
|
231
268
|
rootOriginal.walkAtRules(atrule => {
|
232
269
|
const hoverQuery = `${atrule.params} and ${hoverMedQuerySuffix}`;
|
233
270
|
const activeQuery = `${atrule.params} and ${hoverNoneMedQuerySuffix}`;
|
271
|
+
|
234
272
|
if (isHoverPresent(atrule)) {
|
235
273
|
if (!positionsObj[hoverQuery] && !positionsObj[activeQuery]) {
|
236
274
|
rootOriginal.append({
|
@@ -253,17 +291,17 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
253
291
|
} else {
|
254
292
|
// plus, space and other media queries
|
255
293
|
mediaQuery(rule, index);
|
256
|
-
}
|
294
|
+
} // usual hover query
|
295
|
+
|
257
296
|
|
258
|
-
// usual hover query
|
259
297
|
if (!rule.selector.match(/,+| +|\++/g) && rule.parent !== undefined && rule.parent.name === undefined) {
|
260
298
|
hoverRules.push({
|
261
299
|
rule,
|
262
300
|
index
|
263
301
|
});
|
264
|
-
}
|
302
|
+
} //usual hover query with ',' ' ' '+'
|
303
|
+
|
265
304
|
|
266
|
-
//usual hover query with ',' ' ' '+'
|
267
305
|
if (rule.selector.match(/,+| +|\++/g) && rule.parent.name === undefined) {
|
268
306
|
if (rule.selector.includes(',')) {
|
269
307
|
commaQuery(rule, index);
|
@@ -272,69 +310,66 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
272
310
|
hoverRules.push({
|
273
311
|
rule,
|
274
312
|
index
|
275
|
-
});
|
276
|
-
//rule.remove();
|
313
|
+
}); //rule.remove();
|
277
314
|
}
|
278
315
|
}
|
279
316
|
}
|
280
|
-
});
|
281
|
-
// If there are any :hover rules in the input, then create media queries
|
317
|
+
}); // If there are any :hover rules in the input, then create media queries
|
282
318
|
// to automatically translate it into :active on touch-based devices
|
319
|
+
|
283
320
|
if (hoverRules.length > 0) {
|
284
321
|
// Create a media query targetting devices that actually support
|
285
322
|
// hover
|
286
323
|
const hoverQuery = rootOriginal.append({
|
287
324
|
name: 'media',
|
288
325
|
params: `${hoverMedQuerySuffix}`
|
289
|
-
}).last;
|
290
|
-
// Create a media query targetting devices that don't support hover
|
326
|
+
}).last; // Create a media query targetting devices that don't support hover
|
291
327
|
// (ie. devices where we should fall back to :active instead)
|
328
|
+
|
292
329
|
const activeQuery = rootOriginal.append({
|
293
330
|
name: 'media',
|
294
331
|
params: `${hoverNoneMedQuerySuffix}`
|
295
|
-
}).last;
|
296
|
-
|
297
|
-
// Loop through the hover rules and apply them to each of the media
|
332
|
+
}).last; // Loop through the hover rules and apply them to each of the media
|
298
333
|
// queries
|
299
334
|
// eslint-disable-next-line no-labels
|
335
|
+
|
300
336
|
outerLoop: for (const hoverRule of hoverRules) {
|
301
337
|
// determine if the rule has been nested inside another media
|
302
338
|
// query; in that case bail out as we have no way of reliably
|
303
339
|
// nesting these queries
|
304
340
|
let parentRule = hoverRule.rule.parent;
|
341
|
+
|
305
342
|
while (parentRule) {
|
306
343
|
if (parentRule.type === 'atrule' && parentRule.name === 'media') {
|
307
344
|
// eslint-disable-next-line no-labels
|
308
345
|
continue outerLoop;
|
309
346
|
}
|
310
|
-
parentRule = parentRule.parent;
|
311
|
-
}
|
312
347
|
|
313
|
-
|
348
|
+
parentRule = parentRule.parent;
|
349
|
+
} // Push a clone of the :hover rule 'as is' to queries where we
|
314
350
|
// expect the user's device to support hover
|
315
351
|
// ieQuery.append(hoverRule.clone());
|
316
352
|
|
353
|
+
|
317
354
|
if (handleHoverAndHoverActiveIgnore(hoverRule.index)) {
|
318
355
|
hoverQuery.append(hoverRule.rule.clone());
|
319
|
-
}
|
320
|
-
|
321
|
-
// Push a clone of the :hover rule, where we transform the
|
356
|
+
} // Push a clone of the :hover rule, where we transform the
|
322
357
|
// selector to :active to the query targetting devices that
|
323
358
|
// don't support hover
|
359
|
+
|
360
|
+
|
324
361
|
if (handleActiveAndHoverActiveIgnore(hoverRule.index)) {
|
325
362
|
activeQuery.append(hoverRule.rule.clone({
|
326
363
|
selector: hoverRule.rule.selector.replace(/:hover/gi, ':active')
|
327
364
|
}));
|
328
|
-
}
|
365
|
+
} // remove legacy rule from output
|
366
|
+
|
329
367
|
|
330
|
-
// remove legacy rule from output
|
331
368
|
if (handleAllIgnoreCases(hoverRule.index)) {
|
332
369
|
hoverRule.rule.remove();
|
333
370
|
}
|
334
371
|
}
|
335
|
-
}
|
336
|
-
|
337
|
-
// rootOriginal.walkAtRules(atrule => {
|
372
|
+
} // rootOriginal.walkAtRules(atrule => {
|
338
373
|
// if (
|
339
374
|
// (atrule !== undefined &&
|
340
375
|
// atrule.nodes !== undefined &&
|
@@ -344,4 +379,5 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
344
379
|
// atrule.remove();
|
345
380
|
// }
|
346
381
|
// });
|
382
|
+
|
347
383
|
});
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.ErrorHandler = void 0;
|
7
|
+
|
7
8
|
class ErrorHandler {
|
8
9
|
constructor(allowedErrs) {
|
9
10
|
this.errors = [];
|
@@ -19,6 +20,7 @@ class ErrorHandler {
|
|
19
20
|
MULTIPLE_OCCURANCES: errObj => this.addError(` prop: ${errObj.decl.prop} ,\n value : ${errObj.decl.value} ,\n filename : ${errObj.filename} ,\n filepath : ${errObj.path} ,\n line : ${errObj.decl.source.start.line} ,\n message : ${errObj.message}`)
|
20
21
|
});
|
21
22
|
}
|
23
|
+
|
22
24
|
setAllowedErrs(allErrs) {
|
23
25
|
this.allowedErrs = allErrs;
|
24
26
|
['DECLARATION_IGNORED', 'DECIMAL_CHECK', 'DECIMAL_REJECT', 'UNIT_ERROR', 'RANGE_ERROR', 'VARIABLE_PRESENT', 'MULTIPLE_OCCURANCES'].forEach(err => {
|
@@ -27,14 +29,17 @@ class ErrorHandler {
|
|
27
29
|
}
|
28
30
|
});
|
29
31
|
}
|
32
|
+
|
30
33
|
addError(errstr) {
|
31
34
|
this.errors.push(`{\n${errstr}\n}\n`);
|
32
35
|
}
|
36
|
+
|
33
37
|
errorFunction(errObj) {
|
34
38
|
if (errObj.type && this.allowedErrs[errObj.type] && errObj.decl.prop && errObj.decl.value) {
|
35
39
|
this[errObj.type](errObj);
|
36
40
|
}
|
37
41
|
}
|
42
|
+
|
38
43
|
printError(errObj) {
|
39
44
|
console.log('{');
|
40
45
|
Object.keys(errObj).sort().forEach(key => {
|
@@ -48,5 +53,7 @@ class ErrorHandler {
|
|
48
53
|
});
|
49
54
|
console.log('}\n');
|
50
55
|
}
|
56
|
+
|
51
57
|
}
|
58
|
+
|
52
59
|
exports.ErrorHandler = ErrorHandler;
|
@@ -1,11 +1,15 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
const postcss = require('postcss');
|
4
|
+
|
4
5
|
const fs = require('fs');
|
6
|
+
|
5
7
|
const path = require('path');
|
8
|
+
|
6
9
|
const {
|
7
10
|
ErrorHandler
|
8
11
|
} = require('./ErrorHandler');
|
12
|
+
|
9
13
|
const errHandler = new ErrorHandler();
|
10
14
|
const convertableProps = {
|
11
15
|
'font-size': true,
|
@@ -51,30 +55,35 @@ const constantValues = {
|
|
51
55
|
center: true,
|
52
56
|
right: true
|
53
57
|
};
|
58
|
+
|
54
59
|
function getNumericValue(value) {
|
55
60
|
if (value.includes('var')) {
|
56
61
|
return parseInt(value.replace(/var\(--zd_size(\d+)\)/gi, '$1').replace(/var\(--zd_font_size(\d+)\)/gi, '$1'));
|
57
62
|
}
|
63
|
+
|
58
64
|
if (value.includes('rect')) {
|
59
65
|
return parseInt(value.replace('rect(', '').replace(')', '').replace(',', ''));
|
60
|
-
}
|
61
|
-
// Not need for this dum loop
|
66
|
+
} // Not need for this dum loop
|
62
67
|
// allowed.forEach(alwdUnit => {
|
63
68
|
// if (value.includes(alwdUnit)) {
|
64
69
|
// return parseInt(value);
|
65
70
|
// }
|
66
71
|
// });
|
67
72
|
|
73
|
+
|
68
74
|
if (constantValues[value.toLowerCase()]) {
|
69
75
|
return 1;
|
70
76
|
}
|
77
|
+
|
71
78
|
return parseInt(value);
|
72
79
|
}
|
80
|
+
|
73
81
|
function pxToCalc(value) {
|
74
82
|
const arr = value.split(' ');
|
75
83
|
arr.forEach((val, index) => {
|
76
84
|
['px'].forEach(unit => {
|
77
85
|
const valWithUnit = new RegExp(`(\\d+)${unit}`, 'gi');
|
86
|
+
|
78
87
|
if (valWithUnit.test(val)) {
|
79
88
|
arr[index] = val.replace(valWithUnit, '(var(--zd_size$1))');
|
80
89
|
}
|
@@ -82,6 +91,7 @@ function pxToCalc(value) {
|
|
82
91
|
});
|
83
92
|
return arr.join(' ');
|
84
93
|
}
|
94
|
+
|
85
95
|
const singleConvertor = ({
|
86
96
|
value,
|
87
97
|
changeVal,
|
@@ -94,28 +104,35 @@ const singleConvertor = ({
|
|
94
104
|
filename,
|
95
105
|
decl
|
96
106
|
} = details;
|
107
|
+
|
97
108
|
if (decl.prop === 'background-position') {
|
98
109
|
if (isNaN(parseInt(value))) {
|
99
110
|
// console.log(`${value} skipped`);
|
100
111
|
return;
|
101
112
|
}
|
102
113
|
}
|
114
|
+
|
103
115
|
if (allowed && allowed.includes(decl.value) && decl.value.toString() !== '0') {
|
104
116
|
return decl.value;
|
105
117
|
}
|
118
|
+
|
106
119
|
if (getNumericValue(value) >= range.start && getNumericValue(value) <= range.end || getNumericValue(value) === 0) {
|
107
120
|
if (value.trim() === '0px') {
|
108
121
|
return '0';
|
109
122
|
}
|
123
|
+
|
110
124
|
let retVal = value.replace(/(\d+)px/gi, changeVal.replace('$$', '$1'));
|
125
|
+
|
111
126
|
if (/^-var/.test(retVal)) {
|
112
127
|
retVal = `calc( ${retVal.substring(1)} * -1 )`;
|
113
128
|
}
|
129
|
+
|
114
130
|
return retVal;
|
115
|
-
}
|
116
|
-
// if (!value.includes('rect')) {
|
131
|
+
} // if (!value.includes('rect')) {
|
117
132
|
// if(unitErrorVal && unitErrorVal != '0' ){
|
118
133
|
// console.log(value, 'not within range')
|
134
|
+
|
135
|
+
|
119
136
|
const errObj = {
|
120
137
|
decl,
|
121
138
|
type: 'RANGE_ERROR',
|
@@ -127,17 +144,18 @@ const singleConvertor = ({
|
|
127
144
|
errHandler.errorFunction(errObj);
|
128
145
|
return;
|
129
146
|
};
|
147
|
+
|
130
148
|
module.exports = {
|
131
149
|
plugin: postcss.plugin('postcss-variable-report', cssVariableReplacementConfig => {
|
132
150
|
const rawdata = fs.readFileSync(cssVariableReplacementConfig);
|
133
151
|
const data = JSON.parse(rawdata);
|
134
152
|
const {
|
135
153
|
errorsAllowed,
|
136
|
-
settings: settingsObject
|
137
|
-
// errorLog: errorLogStatus,
|
154
|
+
settings: settingsObject // errorLog: errorLogStatus,
|
138
155
|
// errorInConsole: errorConsoleStatus
|
139
|
-
|
140
|
-
// const keys = Object.keys(settingsObject);
|
156
|
+
|
157
|
+
} = data; // const keys = Object.keys(settingsObject);
|
158
|
+
|
141
159
|
errHandler.setAllowedErrs(errorsAllowed);
|
142
160
|
const replacementArray = [];
|
143
161
|
Object.keys(settingsObject).forEach(key => {
|
@@ -165,12 +183,12 @@ module.exports = {
|
|
165
183
|
// case font-size
|
166
184
|
const commentStr = 'variable:ignore';
|
167
185
|
const prevNode = rule.nodes[position - 1];
|
168
|
-
const fromPath = rootOriginal.source.input.from;
|
169
|
-
// this will be problem for linux and mac use require('path').sep
|
186
|
+
const fromPath = rootOriginal.source.input.from; // this will be problem for linux and mac use require('path').sep
|
170
187
|
// split not need use slice and lastIndexOf less memory
|
171
|
-
|
172
|
-
// if(filename.includes('AddFormResponsive.module.css'){
|
188
|
+
|
189
|
+
const filename = fromPath.split(path.sep).pop(); // if(filename.includes('AddFormResponsive.module.css'){
|
173
190
|
// }
|
191
|
+
|
174
192
|
if (prevNode && prevNode.type === 'comment' && prevNode.text.toLowerCase().includes(commentStr)) {
|
175
193
|
const errObj = {
|
176
194
|
decl,
|
@@ -183,29 +201,28 @@ module.exports = {
|
|
183
201
|
errHandler.DECLARATION_IGNORED(errObj);
|
184
202
|
return;
|
185
203
|
}
|
204
|
+
|
186
205
|
if (settingsObject[decl.prop] && !decl.value.includes('var(--')) {
|
187
206
|
const settings = settingsObject[decl.prop];
|
188
207
|
const {
|
189
208
|
allowed,
|
190
209
|
range
|
191
|
-
} = settings;
|
192
|
-
// suggestion filter !decl.value.includes('calc')
|
210
|
+
} = settings; // suggestion filter !decl.value.includes('calc')
|
193
211
|
// Reason below some of logic happen based on this
|
194
|
-
|
195
|
-
// no need round braket since you do not need group for less memory
|
196
|
-
.replace(/\d+/gi, '').replace('var(--zd_size)', 'px').replace('var(--zd_font_size)', 'px').replace('rect(', '').replace(')', '').replace('px,', 'px').replace(',', '').split(' ').filter(x => x !== '');
|
197
|
-
// unit = unit.replace(unit, unit.replace('-',''))
|
212
|
+
|
213
|
+
const unit = decl.value.toString() // no need round braket since you do not need group for less memory
|
214
|
+
.replace(/\d+/gi, '').replace('var(--zd_size)', 'px').replace('var(--zd_font_size)', 'px').replace('rect(', '').replace(')', '').replace('px,', 'px').replace(',', '').split(' ').filter(x => x !== ''); // unit = unit.replace(unit, unit.replace('-',''))
|
198
215
|
// console.log('unit : ');
|
199
216
|
// console.log(unit);
|
200
217
|
// if (decl.prop === 'height') {
|
201
218
|
// console.log(decl.prop, unit, 'case 1');
|
202
219
|
// }
|
220
|
+
|
203
221
|
unit.forEach((val, index) => {
|
204
222
|
allowed.forEach(alwdVal => {
|
205
223
|
if (val.includes(alwdVal)) {
|
206
224
|
// ## for what purpose
|
207
|
-
unit[index] = val
|
208
|
-
// .replace(new RegExp('(\\d+).(\\d+)(\\w+)', 'gi'), '$3')
|
225
|
+
unit[index] = val // .replace(new RegExp('(\\d+).(\\d+)(\\w+)', 'gi'), '$3')
|
209
226
|
.replace(`-${alwdVal}`, `${alwdVal}`).replace(`-.${alwdVal}`, `${alwdVal}`).replace(`${alwdVal},`, `${alwdVal}`);
|
210
227
|
}
|
211
228
|
});
|
@@ -219,27 +236,29 @@ module.exports = {
|
|
219
236
|
unitErrorVal = val;
|
220
237
|
}
|
221
238
|
}
|
222
|
-
});
|
223
|
-
// if (decl.prop === 'height') {
|
239
|
+
}); // if (decl.prop === 'height') {
|
224
240
|
// console.log(decl.prop, unitErrorVal, unitError, unit, 'case 2');
|
225
241
|
// }
|
226
242
|
// console.log(allowed, replacements, range)
|
243
|
+
|
227
244
|
if (!unitError) {
|
228
245
|
let calcValue = false;
|
246
|
+
|
229
247
|
if (decl.value.includes('calc')) {
|
230
248
|
decl.value = pxToCalc(decl.value);
|
231
249
|
calcValue = true;
|
232
|
-
}
|
233
|
-
|
250
|
+
} // use variable decl.value.split(' ')
|
251
|
+
|
252
|
+
|
234
253
|
if (range && !calcValue) {
|
235
254
|
// console.log('multiple :', decl.value)
|
236
|
-
const tempVal = decl.value;
|
237
|
-
// if (decl.prop === 'height') {
|
255
|
+
const tempVal = decl.value; // if (decl.prop === 'height') {
|
238
256
|
// console.log(decl.prop, tempVal, decl.value, allowed, 'case 3');
|
239
257
|
// }
|
240
258
|
// if (decl.prop === 'height') {
|
241
259
|
// console.log('allowed!', decl.prop, decl.value, allowed);
|
242
260
|
// }
|
261
|
+
|
243
262
|
let newVal = '';
|
244
263
|
let splitValues = decl.value.split(' ');
|
245
264
|
splitValues = splitValues.filter(val => val.trim() !== '');
|
@@ -257,8 +276,7 @@ module.exports = {
|
|
257
276
|
allowed
|
258
277
|
})} `;
|
259
278
|
});
|
260
|
-
decl.value = newVal;
|
261
|
-
// if (decl.prop === 'height') {
|
279
|
+
decl.value = newVal; // if (decl.prop === 'height') {
|
262
280
|
// console.log(decl.prop, tempVal, newVal, 'case 4');
|
263
281
|
// }
|
264
282
|
}
|
@@ -271,6 +289,7 @@ module.exports = {
|
|
271
289
|
unitErrorVal: unitErrorVal,
|
272
290
|
path: fromPath
|
273
291
|
};
|
292
|
+
|
274
293
|
if (unitErrorVal.trim() === '.') {
|
275
294
|
errObj.type = 'DECIMAL_CHECK';
|
276
295
|
errObj.message = `${unitErrorVal} (Decimal Value) Please check`;
|
@@ -316,10 +335,12 @@ module.exports = {
|
|
316
335
|
});
|
317
336
|
return convertedVal ? convertedVal : val;
|
318
337
|
}
|
338
|
+
|
319
339
|
return val;
|
320
340
|
});
|
321
341
|
decl.value = convertedVals.join(' ');
|
322
342
|
}
|
343
|
+
|
323
344
|
if (decl.prop && decl.value && !decl.prop.includes('--') && valRegex.test(decl.value) && (settingsObject[decl.prop] || convertableProps[decl.prop]) && decl.value.includes('var') && !decl.value.includes('calc')) {
|
324
345
|
const errObj = {
|
325
346
|
decl,
|
package/lib/schemas/index.js
CHANGED
@@ -4,12 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
+
|
7
8
|
var _os = require("os");
|
9
|
+
|
8
10
|
var _getIp = _interopRequireDefault(require("../utils/getIp"));
|
11
|
+
|
9
12
|
var _getCurrentBranch = _interopRequireDefault(require("../utils/getCurrentBranch"));
|
10
|
-
|
13
|
+
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
+
|
11
16
|
// TODO move deprecated options to separate file and manage seperately
|
12
|
-
var _default =
|
17
|
+
var _default = {
|
13
18
|
alias: null,
|
14
19
|
unstableDepsInverse: {
|
15
20
|
value: false,
|
@@ -227,6 +232,7 @@ var _default = exports.default = {
|
|
227
232
|
none: '(hover: none)'
|
228
233
|
},
|
229
234
|
disableES5Transpile: false,
|
235
|
+
disableES5Import: false,
|
230
236
|
isReactMig: false,
|
231
237
|
hasWidget: false,
|
232
238
|
hasEFC: {
|
@@ -758,4 +764,5 @@ var _default = exports.default = {
|
|
758
764
|
value: false,
|
759
765
|
cli: 'enable_typescript'
|
760
766
|
}
|
761
|
-
};
|
767
|
+
};
|
768
|
+
exports.default = _default;
|