@zohodesk/react-cli 0.0.1-exp.169.2 → 0.0.1-exp.175.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +7 -7
- package/.eslintrc.js +180 -179
- package/.prettierrc +6 -6
- package/{CHANGELOG.md → CHANGELOG-fz.md} +0 -0
- package/Changelog.md +1019 -0
- package/README.md +27 -951
- package/bin/cli.js +483 -483
- package/docs/CustomChunks.md +26 -26
- package/docs/DevStart.md +18 -18
- package/docs/HoverActive.md +12 -12
- package/docs/InstallNode.md +28 -28
- package/docs/TODOS.md +10 -10
- package/docs/ValueReplacer.md +60 -60
- package/docs/VariableConversion.md +678 -0
- package/docs/warnings_while_install.txt +35 -35
- package/files/eslintrc.js +62 -62
- package/files/prettierrc.js +3 -3
- package/lib/configs/jest.config.js +8 -12
- package/lib/configs/libAlias.js +10 -3
- package/lib/configs/resolvers.js +38 -0
- package/lib/configs/webpack.css.umd.config.js +4 -4
- package/lib/configs/webpack.dev.config.js +17 -22
- package/lib/configs/webpack.docs.config.js +10 -15
- package/lib/configs/webpack.impact.config.js +11 -11
- package/lib/configs/webpack.prod.config.js +22 -24
- package/lib/constants.js +31 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -7
- package/lib/loaderUtils/configsAssetsLoaders.js +33 -33
- package/lib/loaderUtils/getCSSLoaders.js +42 -22
- package/lib/loaders/workerLoader.js +9 -9
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +59 -0
- package/lib/pluginUtils/getDevPlugins.js +19 -39
- package/lib/pluginUtils/getProdPlugins.js +29 -47
- package/lib/plugins/EFCPlugin.md +6 -6
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +4 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +8 -8
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
- package/lib/plugins/I18nSplitPlugin/README.md +25 -25
- package/lib/plugins/I18nSplitPlugin/index.js +57 -57
- package/lib/plugins/ResourceHintsPlugin.js +17 -17
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +16 -24
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
- package/lib/plugins/ServiceWorkerPlugin.js +9 -9
- package/lib/plugins/TPHashMappingPlugin.js +4 -4
- package/lib/postcss-plugins/RTLSplitPlugin.js +10 -10
- package/lib/postcss-plugins/__test__/test1Input.css +38 -38
- package/lib/postcss-plugins/__test__/test1Output.css +38 -38
- package/lib/postcss-plugins/hoverActivePlugin.js +54 -30
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +37 -0
- package/lib/postcss-plugins/variableModificationPlugin/index.js +248 -0
- package/lib/postcss-plugins/variableModifier.js +1 -0
- package/lib/schemas/index.js +36 -8
- package/lib/servers/docsServerCore.js +13 -12
- package/lib/servers/getCliPath.js +1 -1
- package/lib/servers/httpsOptions.js +40 -9
- package/lib/servers/nowatchserver.js +12 -11
- package/lib/servers/server.js +14 -13
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -45
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/getOptions.js +42 -14
- package/lib/utils/resultSchema.json +73 -73
- package/npm8.md +9 -9
- package/package.json +119 -148
- package/postpublish.js +8 -6
- package/templates/app/.eslintrc.js +140 -140
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -24
- package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
- package/templates/app/app/properties/i18nkeys.json +3 -3
- package/templates/app/docs/all.html +69 -69
- package/templates/app/mockapi/index.js +18 -18
- package/templates/app/package.json +37 -37
- package/templates/app/src/actions/SampleActions/index.js +37 -37
- package/templates/app/src/actions/index.js +65 -65
- package/templates/app/src/appUrls.js +19 -19
- package/templates/app/src/components/Alert/Alert.js +134 -134
- package/templates/app/src/components/Alert/Alert.module.css +79 -79
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
- package/templates/app/src/components/Sample/Sample.module.css +11 -11
- package/templates/app/src/components/Sample/SampleList.js +61 -61
- package/templates/app/src/components/Slider/Slider.css +41 -41
- package/templates/app/src/components/Slider/Slider.js +55 -55
- package/templates/app/src/containers/AlertContainer/index.js +15 -15
- package/templates/app/src/containers/AppContainer/index.js +96 -96
- package/templates/app/src/containers/AppContainer/index.module.css +27 -27
- package/templates/app/src/containers/CustomMatch/index.js +65 -65
- package/templates/app/src/containers/DevTools/index.js +10 -10
- package/templates/app/src/containers/Header/index.js +67 -67
- package/templates/app/src/containers/Header/index.module.css +43 -43
- package/templates/app/src/containers/Redirect/index.js +63 -63
- package/templates/app/src/containers/Redirector/index.js +47 -47
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
- package/templates/app/src/historyChange.js +5 -5
- package/templates/app/src/index.html +10 -10
- package/templates/app/src/index.js +24 -24
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
- package/templates/app/src/reducers/alertData.js +11 -11
- package/templates/app/src/reducers/index.js +6 -6
- package/templates/app/src/reducers/samples.js +19 -19
- package/templates/app/src/store/configureStore.dev.js +51 -51
- package/templates/app/src/store/configureStore.js +5 -5
- package/templates/app/src/store/configureStore.prod.js +26 -26
- package/templates/app/src/util/Common.js +5 -5
- package/templates/app/src/util/RequestAPI.js +132 -132
- package/templates/docs/all.html +249 -249
- package/templates/docs/component.html +178 -178
- package/templates/docs/components.html +221 -221
- package/templates/docs/css/b.min.css +6 -6
- package/templates/docs/css/component.css +42 -42
- package/templates/docs/css/componentTest.css +6 -6
- package/templates/docs/css/hopscotch.css +585 -585
- package/templates/docs/css/style.css +1022 -1022
- package/templates/docs/impactReportTemplate.html +154 -154
- package/templates/docs/index.html +1501 -1493
- package/templates/docs/js/active-line.js +72 -72
- package/templates/docs/js/b.min.js +7 -7
- package/templates/docs/js/codemirror.js +9680 -9680
- package/templates/docs/js/designTokens.js +334 -334
- package/templates/docs/js/j.min.js +4 -4
- package/templates/docs/js/javascript.js +874 -874
- package/templates/docs/js/matchbrackets.js +145 -145
- package/cert/Tsicsezwild-22-23.crt +0 -37
- package/cert/Tsicsezwild-22-23.key +0 -27
|
@@ -24,12 +24,12 @@ const isCss = filename => _path.default.extname(filename) === '.css'; // this p
|
|
|
24
24
|
|
|
25
25
|
class RtlCssPlugin {
|
|
26
26
|
constructor(options = {}) {
|
|
27
|
-
/**
|
|
28
|
-
* @typedef {Object} Options
|
|
29
|
-
* @property {String} filename [not used]
|
|
30
|
-
* @property {String} dirVarName
|
|
31
|
-
* @property {Boolean} sourcemap
|
|
32
|
-
* @property {Object} config
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {Object} Options
|
|
29
|
+
* @property {String} filename [not used]
|
|
30
|
+
* @property {String} dirVarName
|
|
31
|
+
* @property {Boolean} sourcemap
|
|
32
|
+
* @property {Object} config
|
|
33
33
|
*/
|
|
34
34
|
this.options = {
|
|
35
35
|
filename: options.filename || '[name].rtl.css',
|
|
@@ -60,24 +60,16 @@ class RtlCssPlugin {
|
|
|
60
60
|
chunk.files.filter(isCss).forEach(chunkFilename => {
|
|
61
61
|
const asset = compilation.assets[chunkFilename];
|
|
62
62
|
const sourceStr = asset.source();
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
compilation.assets[chunkFilename] = new _webpackSources.RawSource(ltr);
|
|
74
|
-
compilation.assets[assetFilename] = new _webpackSources.RawSource(rtl);
|
|
75
|
-
} catch (error) {
|
|
76
|
-
let arr = Array.from(chunk.modulesIterable).map(x => x.resource).filter(x => /\.css$/.test(x));
|
|
77
|
-
console.log(chunkFilename); // console.log(arr);
|
|
78
|
-
|
|
79
|
-
console.log(arr.length);
|
|
80
|
-
}
|
|
63
|
+
const {
|
|
64
|
+
ltr,
|
|
65
|
+
rtl
|
|
66
|
+
} = (0, _RTLSplitPlugin.separateRtlAndLtr)(sourceStr, this.rtlSplitOptions); // const result = rtlcss
|
|
67
|
+
// .configure(config)
|
|
68
|
+
// .process(asset.source(), postcssOptions);
|
|
69
|
+
|
|
70
|
+
const assetFilename = chunkFilename.replace('.ltr.', '.rtl.');
|
|
71
|
+
compilation.assets[chunkFilename] = new _webpackSources.RawSource(ltr);
|
|
72
|
+
compilation.assets[assetFilename] = new _webpackSources.RawSource(rtl);
|
|
81
73
|
});
|
|
82
74
|
});
|
|
83
75
|
callback();
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
# RTL Split
|
|
2
|
-
|
|
3
|
-
we are doing in build time generating rtl related css code by using @zohodesk/postcss-rt npm.
|
|
4
|
-
It was automated, That postcss plugin create rtl reacted css and put them into same file, with css selector [dir=rtl] and ltr realted css with [dir=ltr].
|
|
5
|
-
Here is problem mostly no one need rtl and ltr related css at the same time in browser,
|
|
6
|
-
we are try to split them by [dir] and load which type of css is needed.
|
|
7
|
-
For this purpose we created RTL Split Plugin
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
# To Try it out rtl-ltr split
|
|
11
|
-
### how to use this feature?
|
|
12
|
-
|
|
13
|
-
to use this feature use have give the below oprtions
|
|
14
|
-
`package.json`
|
|
15
|
-
```json
|
|
16
|
-
{
|
|
17
|
-
/// ...some things
|
|
18
|
-
"react-cli": {
|
|
19
|
-
// ...some things
|
|
20
|
-
"css": {
|
|
21
|
-
"enableRTLSplit": true,
|
|
22
|
-
"templateLabel": "{{--dir}}",// this is for html template css file path dir template
|
|
23
|
-
"disableMiniFiySelector": false,
|
|
24
|
-
"dirVarName": "document.dir" // this will be used for download css based on dir
|
|
25
|
-
},
|
|
26
|
-
// ...some things
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
```
|
|
30
|
-
|
|
1
|
+
# RTL Split
|
|
2
|
+
|
|
3
|
+
we are doing in build time generating rtl related css code by using @zohodesk/postcss-rt npm.
|
|
4
|
+
It was automated, That postcss plugin create rtl reacted css and put them into same file, with css selector [dir=rtl] and ltr realted css with [dir=ltr].
|
|
5
|
+
Here is problem mostly no one need rtl and ltr related css at the same time in browser,
|
|
6
|
+
we are try to split them by [dir] and load which type of css is needed.
|
|
7
|
+
For this purpose we created RTL Split Plugin
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# To Try it out rtl-ltr split
|
|
11
|
+
### how to use this feature?
|
|
12
|
+
|
|
13
|
+
to use this feature use have give the below oprtions
|
|
14
|
+
`package.json`
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
/// ...some things
|
|
18
|
+
"react-cli": {
|
|
19
|
+
// ...some things
|
|
20
|
+
"css": {
|
|
21
|
+
"enableRTLSplit": true,
|
|
22
|
+
"templateLabel": "{{--dir}}",// this is for html template css file path dir template
|
|
23
|
+
"disableMiniFiySelector": false,
|
|
24
|
+
"dirVarName": "document.dir" // this will be used for download css based on dir
|
|
25
|
+
},
|
|
26
|
+
// ...some things
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
@@ -51,11 +51,11 @@ class ServiceWorkerPlugin {
|
|
|
51
51
|
if (err) {
|
|
52
52
|
throw new Error(err);
|
|
53
53
|
} else {
|
|
54
|
-
/* const extractedChunks = compilation.chunks.filter(chunk => {
|
|
55
|
-
if ('canBeInitial' in chunk) {
|
|
56
|
-
return chunk.canBeInitial();
|
|
57
|
-
}
|
|
58
|
-
return chunk.isInitial();
|
|
54
|
+
/* const extractedChunks = compilation.chunks.filter(chunk => {
|
|
55
|
+
if ('canBeInitial' in chunk) {
|
|
56
|
+
return chunk.canBeInitial();
|
|
57
|
+
}
|
|
58
|
+
return chunk.isInitial();
|
|
59
59
|
}); */
|
|
60
60
|
// let [js, css, , , i18nPublicPath] = this.publicPaths;
|
|
61
61
|
// let initialChunkUrls = [];
|
|
@@ -64,10 +64,10 @@ class ServiceWorkerPlugin {
|
|
|
64
64
|
let entrypoint = compilation.entrypoints.get('main');
|
|
65
65
|
let initialChunkUrls = entrypoint.getFiles();
|
|
66
66
|
const cssDirTemplate = '@dir@';
|
|
67
|
-
/**
|
|
68
|
-
* NOTE:
|
|
69
|
-
* if chunkSplitEnable is false means,
|
|
70
|
-
* serviceWorker will get i18n files path for html
|
|
67
|
+
/**
|
|
68
|
+
* NOTE:
|
|
69
|
+
* if chunkSplitEnable is false means,
|
|
70
|
+
* serviceWorker will get i18n files path for html
|
|
71
71
|
*/
|
|
72
72
|
|
|
73
73
|
let initalI18nAssets = chunkSplitEnable ? entrypoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@')) : [];
|
|
@@ -15,10 +15,10 @@ var _crypto = _interopRequireDefault(require("crypto"));
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Plugin that generates hash for the provided list of third party files
|
|
20
|
-
* Map the provided key with the file hash and add it to the list of exisiting global constants.
|
|
21
|
-
* Plugin in turn uses the defineplugin to generate global constants.
|
|
18
|
+
/**
|
|
19
|
+
* Plugin that generates hash for the provided list of third party files
|
|
20
|
+
* Map the provided key with the file hash and add it to the list of exisiting global constants.
|
|
21
|
+
* Plugin in turn uses the defineplugin to generate global constants.
|
|
22
22
|
*/
|
|
23
23
|
class TPHashMappingPlugin {
|
|
24
24
|
constructor(options) {
|
|
@@ -38,11 +38,11 @@ function selectorMinifySameDir(selector, direction) {
|
|
|
38
38
|
const regex = getRegex(direction);
|
|
39
39
|
return selector.replace(regex, '').trim();
|
|
40
40
|
}
|
|
41
|
-
/**
|
|
42
|
-
* this funtion will remove given rule,
|
|
43
|
-
* if given selector and it's previous sibiling rule selector are same
|
|
44
|
-
* current rule properties will move to previous sibiling rule.
|
|
45
|
-
* @param {Rule} rule current rule
|
|
41
|
+
/**
|
|
42
|
+
* this funtion will remove given rule,
|
|
43
|
+
* if given selector and it's previous sibiling rule selector are same
|
|
44
|
+
* current rule properties will move to previous sibiling rule.
|
|
45
|
+
* @param {Rule} rule current rule
|
|
46
46
|
*/
|
|
47
47
|
|
|
48
48
|
|
|
@@ -57,11 +57,11 @@ function mergeIfSameSelector(rule) {
|
|
|
57
57
|
rule.remove();
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
/**
|
|
61
|
-
* this funtion will remove given rule,
|
|
62
|
-
* if given selector and it's previous sibiling rule selector are same
|
|
63
|
-
* current rule properties will move to previous sibiling rule.
|
|
64
|
-
* @param {Rule} rule current rule
|
|
60
|
+
/**
|
|
61
|
+
* this funtion will remove given rule,
|
|
62
|
+
* if given selector and it's previous sibiling rule selector are same
|
|
63
|
+
* current rule properties will move to previous sibiling rule.
|
|
64
|
+
* @param {Rule} rule current rule
|
|
65
65
|
*/
|
|
66
66
|
|
|
67
67
|
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
/*Hover_active:ignore*/
|
|
2
|
-
g,a:hover{
|
|
3
|
-
color : red
|
|
4
|
-
}
|
|
5
|
-
/*Hover:ignore*/
|
|
6
|
-
h:hover{
|
|
7
|
-
background : yellow
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/* Hover_active:ignore */
|
|
11
|
-
g,d+e:hover{
|
|
12
|
-
color : black
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
g,d e:hover{
|
|
16
|
-
color : black
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@media screen and (max-width:61.25em){
|
|
20
|
-
/* Hover_active:ignore */
|
|
21
|
-
a,b,a:hover, b:hover{
|
|
22
|
-
background-color : blue
|
|
23
|
-
}
|
|
24
|
-
a + b,a:hover + b:hover{
|
|
25
|
-
background-color : blue
|
|
26
|
-
}
|
|
27
|
-
a b:hover{
|
|
28
|
-
background-color : blue
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.cc:hover {
|
|
32
|
-
color: red;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
c:hover{
|
|
36
|
-
color : red
|
|
37
|
-
}
|
|
38
|
-
|
|
1
|
+
/*Hover_active:ignore*/
|
|
2
|
+
g,a:hover{
|
|
3
|
+
color : red
|
|
4
|
+
}
|
|
5
|
+
/*Hover:ignore*/
|
|
6
|
+
h:hover{
|
|
7
|
+
background : yellow
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* Hover_active:ignore */
|
|
11
|
+
g,d+e:hover{
|
|
12
|
+
color : black
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
g,d e:hover{
|
|
16
|
+
color : black
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@media screen and (max-width:61.25em){
|
|
20
|
+
/* Hover_active:ignore */
|
|
21
|
+
a,b,a:hover, b:hover{
|
|
22
|
+
background-color : blue
|
|
23
|
+
}
|
|
24
|
+
a + b,a:hover + b:hover{
|
|
25
|
+
background-color : blue
|
|
26
|
+
}
|
|
27
|
+
a b:hover{
|
|
28
|
+
background-color : blue
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.cc:hover {
|
|
32
|
+
color: red;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
c:hover{
|
|
36
|
+
color : red
|
|
37
|
+
}
|
|
38
|
+
|
|
39
39
|
}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
/*Hover_active:ignore*/
|
|
2
|
-
g,a:hover{
|
|
3
|
-
color : red
|
|
4
|
-
}
|
|
5
|
-
/*Hover:ignore*/
|
|
6
|
-
h:hover{
|
|
7
|
-
background : yellow
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/* Hover_active:ignore */
|
|
11
|
-
g,d+e:hover{
|
|
12
|
-
color : black
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
g,d e:hover{
|
|
16
|
-
color : black
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@media screen and (max-width:61.25em){
|
|
20
|
-
/* Hover_active:ignore */
|
|
21
|
-
a,b,a:hover, b:hover{
|
|
22
|
-
background-color : blue
|
|
23
|
-
}
|
|
24
|
-
a + b,a:hover + b:hover{
|
|
25
|
-
background-color : blue
|
|
26
|
-
}
|
|
27
|
-
a b:hover{
|
|
28
|
-
background-color : blue
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.cc:hover {
|
|
32
|
-
color: red;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
c:hover{
|
|
36
|
-
color : red
|
|
37
|
-
}
|
|
38
|
-
|
|
1
|
+
/*Hover_active:ignore*/
|
|
2
|
+
g,a:hover{
|
|
3
|
+
color : red
|
|
4
|
+
}
|
|
5
|
+
/*Hover:ignore*/
|
|
6
|
+
h:hover{
|
|
7
|
+
background : yellow
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* Hover_active:ignore */
|
|
11
|
+
g,d+e:hover{
|
|
12
|
+
color : black
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
g,d e:hover{
|
|
16
|
+
color : black
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@media screen and (max-width:61.25em){
|
|
20
|
+
/* Hover_active:ignore */
|
|
21
|
+
a,b,a:hover, b:hover{
|
|
22
|
+
background-color : blue
|
|
23
|
+
}
|
|
24
|
+
a + b,a:hover + b:hover{
|
|
25
|
+
background-color : blue
|
|
26
|
+
}
|
|
27
|
+
a b:hover{
|
|
28
|
+
background-color : blue
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.cc:hover {
|
|
32
|
+
color: red;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
c:hover{
|
|
36
|
+
color : red
|
|
37
|
+
}
|
|
38
|
+
|
|
39
39
|
}
|
|
@@ -4,9 +4,9 @@ var _postcss = _interopRequireDefault(require("postcss"));
|
|
|
4
4
|
|
|
5
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* we have give support for ignore(exclude) comments
|
|
9
|
-
* These are the comments' keyword
|
|
7
|
+
/**
|
|
8
|
+
* we have give support for ignore(exclude) comments
|
|
9
|
+
* These are the comments' keyword
|
|
10
10
|
*/
|
|
11
11
|
const hoverIgnoreQuery = 'Hover:ignore',
|
|
12
12
|
activeIgnoreQuery = 'Active:ignore',
|
|
@@ -14,7 +14,8 @@ const hoverIgnoreQuery = 'Hover:ignore',
|
|
|
14
14
|
const medHoverIgnoreQuery = 'MedHover:ignore',
|
|
15
15
|
medActiveIgnoreQuery = 'MedActive:ignore',
|
|
16
16
|
medHoverActiveIgnoreQuery = 'MedHoverActive:ignore';
|
|
17
|
-
|
|
17
|
+
let hoverMedQuerySuffix = '';
|
|
18
|
+
let hoverNoneMedQuerySuffix = '';
|
|
18
19
|
const ruleIgnoreCommentRegex = /(Hover:ignore|Active:ignore|HoverActive:ignore)/g;
|
|
19
20
|
const mediaQueryIgnoreCommentRegex = /(MedHover:ignore|MedActive:ignore|MedHoverActive:ignore)/g;
|
|
20
21
|
|
|
@@ -32,9 +33,26 @@ function isHoverPresent(atrule) {
|
|
|
32
33
|
return hoverPresent;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
function checkForUsualClass(root, sel) {
|
|
37
|
+
let present = false;
|
|
38
|
+
sel.split(',').forEach(value => {
|
|
39
|
+
if (value.includes('hover')) {
|
|
40
|
+
const valueNoHover = value.replace(':hover', '').trim();
|
|
41
|
+
root.walkRules(rule => {
|
|
42
|
+
if (rule.selector === valueNoHover) {
|
|
43
|
+
present = true;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return present;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHoverActiveString => rootOriginal => {
|
|
36
52
|
const hoverRules = [];
|
|
37
|
-
|
|
53
|
+
const positionsObj = {};
|
|
54
|
+
hoverMedQuerySuffix = mediaQueryHoverActiveString.hover;
|
|
55
|
+
hoverNoneMedQuerySuffix = mediaQueryHoverActiveString.none;
|
|
38
56
|
|
|
39
57
|
function isRuleHasIgnoreComment(index, type) {
|
|
40
58
|
const prevNode = rootOriginal.nodes[index - 1];
|
|
@@ -72,8 +90,8 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
|
72
90
|
|
|
73
91
|
function getPositionsOfHoverAndActiveMedQueries(parent) {
|
|
74
92
|
const allNodes = rootOriginal.nodes;
|
|
75
|
-
const hoverMediaQuery = `${parent.params} and
|
|
76
|
-
const hoverNoneMediaQuery = `${parent.params} and
|
|
93
|
+
const hoverMediaQuery = `${parent.params} and ${hoverMedQuerySuffix}`;
|
|
94
|
+
const hoverNoneMediaQuery = `${parent.params} and ${hoverNoneMedQuerySuffix}`;
|
|
77
95
|
const positions = {
|
|
78
96
|
hovMed: allNodes[positionsObj[hoverMediaQuery]],
|
|
79
97
|
actMed: allNodes[positionsObj[hoverNoneMediaQuery]]
|
|
@@ -142,16 +160,16 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
|
142
160
|
if (rule.parent.params !== undefined && !rule.parent.params.includes('hover')) {
|
|
143
161
|
//console.log(hovMed, actMed);
|
|
144
162
|
let newSelector = '';
|
|
145
|
-
|
|
163
|
+
const {
|
|
146
164
|
hovMed,
|
|
147
165
|
actMed
|
|
148
166
|
} = getPositionsOfHoverAndActiveMedQueries(rule.parent);
|
|
149
|
-
|
|
150
|
-
|
|
167
|
+
const hovQueries = [];
|
|
168
|
+
const actQueries = [];
|
|
151
169
|
rule.selector.split(/\s*,\s*/).forEach(_subrule => {
|
|
152
|
-
|
|
170
|
+
const subrule = _subrule.trim();
|
|
153
171
|
|
|
154
|
-
|
|
172
|
+
const clone = rule.clone();
|
|
155
173
|
|
|
156
174
|
if (subrule.includes('hover')) {
|
|
157
175
|
clone.selector = subrule;
|
|
@@ -169,13 +187,13 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
|
169
187
|
});
|
|
170
188
|
|
|
171
189
|
if (hovQueries.length > 0) {
|
|
172
|
-
|
|
190
|
+
const clone = rule.clone();
|
|
173
191
|
clone.selector = hovQueries.join(',');
|
|
174
192
|
hovMed.append(clone);
|
|
175
193
|
}
|
|
176
194
|
|
|
177
195
|
if (actQueries.length > 0) {
|
|
178
|
-
|
|
196
|
+
const clone = rule.clone();
|
|
179
197
|
clone.selector = actQueries.join(',');
|
|
180
198
|
actMed.append(clone.clone({
|
|
181
199
|
selector: clone.selector.replace(/:hover/gi, ':active')
|
|
@@ -194,7 +212,7 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
|
194
212
|
|
|
195
213
|
function mediaQuery(rule, index) {
|
|
196
214
|
if (rule.parent.params !== undefined && !rule.parent.params.includes('hover')) {
|
|
197
|
-
|
|
215
|
+
const {
|
|
198
216
|
hovMed,
|
|
199
217
|
actMed
|
|
200
218
|
} = getPositionsOfHoverAndActiveMedQueries(rule.parent);
|
|
@@ -216,9 +234,9 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
|
216
234
|
function commaQuery(rule, index) {
|
|
217
235
|
//console.log("comma" , rule.selector.split('\n'));
|
|
218
236
|
let newSelector = '';
|
|
219
|
-
|
|
237
|
+
const hovQueries = [];
|
|
220
238
|
rule.selector.split(/\s*,\s*/).forEach(_subrule => {
|
|
221
|
-
|
|
239
|
+
const subrule = _subrule.trim();
|
|
222
240
|
|
|
223
241
|
if (subrule.includes('hover')) {
|
|
224
242
|
// hoverRules.push({ rule: clone, index });
|
|
@@ -229,7 +247,7 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
|
229
247
|
});
|
|
230
248
|
|
|
231
249
|
if (hovQueries.length > 0) {
|
|
232
|
-
|
|
250
|
+
const clone = rule.clone();
|
|
233
251
|
clone.selector = hovQueries.join(',');
|
|
234
252
|
hoverRules.push({
|
|
235
253
|
rule: clone,
|
|
@@ -238,7 +256,9 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
|
238
256
|
}
|
|
239
257
|
|
|
240
258
|
if (handleHoverAndHoverActiveIgnore(index)) {
|
|
241
|
-
|
|
259
|
+
if (checkForUsualClass(rootOriginal, rule.selector)) {
|
|
260
|
+
rule.selector = newSelector.substring(0, newSelector.length - 2).trim();
|
|
261
|
+
}
|
|
242
262
|
}
|
|
243
263
|
|
|
244
264
|
if (rule.selector === '') {
|
|
@@ -248,8 +268,8 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
|
248
268
|
|
|
249
269
|
|
|
250
270
|
rootOriginal.walkAtRules(atrule => {
|
|
251
|
-
const hoverQuery = `${atrule.params} and
|
|
252
|
-
const activeQuery = `${atrule.params} and
|
|
271
|
+
const hoverQuery = `${atrule.params} and ${hoverMedQuerySuffix}`;
|
|
272
|
+
const activeQuery = `${atrule.params} and ${hoverNoneMedQuerySuffix}`;
|
|
253
273
|
|
|
254
274
|
if (isHoverPresent(atrule)) {
|
|
255
275
|
if (!positionsObj[hoverQuery] && !positionsObj[activeQuery]) {
|
|
@@ -308,13 +328,13 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
|
308
328
|
// hover
|
|
309
329
|
const hoverQuery = rootOriginal.append({
|
|
310
330
|
name: 'media',
|
|
311
|
-
params:
|
|
331
|
+
params: `${hoverMedQuerySuffix}`
|
|
312
332
|
}).last; // Create a media query targetting devices that don't support hover
|
|
313
333
|
// (ie. devices where we should fall back to :active instead)
|
|
314
334
|
|
|
315
335
|
const activeQuery = rootOriginal.append({
|
|
316
336
|
name: 'media',
|
|
317
|
-
params:
|
|
337
|
+
params: `${hoverNoneMedQuerySuffix}`
|
|
318
338
|
}).last; // Loop through the hover rules and apply them to each of the media
|
|
319
339
|
// queries
|
|
320
340
|
// eslint-disable-next-line no-labels
|
|
@@ -355,11 +375,15 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', opts => rootOri
|
|
|
355
375
|
hoverRule.rule.remove();
|
|
356
376
|
}
|
|
357
377
|
}
|
|
358
|
-
}
|
|
378
|
+
} // rootOriginal.walkAtRules(atrule => {
|
|
379
|
+
// if (
|
|
380
|
+
// (atrule !== undefined &&
|
|
381
|
+
// atrule.nodes !== undefined &&
|
|
382
|
+
// atrule.nodes.length === 0) ||
|
|
383
|
+
// atrule.nodes === undefined
|
|
384
|
+
// ) {
|
|
385
|
+
// atrule.remove();
|
|
386
|
+
// }
|
|
387
|
+
// });
|
|
359
388
|
|
|
360
|
-
rootOriginal.walkAtRules(atrule => {
|
|
361
|
-
if (atrule !== undefined && atrule.nodes !== undefined && atrule.nodes.length === 0 || atrule.nodes === undefined) {
|
|
362
|
-
atrule.remove();
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
389
|
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ErrorHandler = void 0;
|
|
7
|
+
|
|
8
|
+
class ErrorHandler {
|
|
9
|
+
constructor(allowedErrs) {
|
|
10
|
+
this.errors = [];
|
|
11
|
+
this.allowedErrs = allowedErrs;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
addError(errstr) {
|
|
15
|
+
this.errors.push(`{\n${errstr}\n}\n`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
errorFunction(errStr, type) {
|
|
19
|
+
const {
|
|
20
|
+
addError,
|
|
21
|
+
allowedErrs
|
|
22
|
+
} = this;
|
|
23
|
+
|
|
24
|
+
if (type === 'DECLARATION_IGNORED' && allowedErrs.DECLARATION_IGNORED) {
|
|
25
|
+
addError(errStr);
|
|
26
|
+
} else if (type === 'UNIT_ERROR' && allowedErrs.UNIT_ERROR) {
|
|
27
|
+
addError(errStr);
|
|
28
|
+
} else if (type === 'RANGE_ERROR' && allowedErrs.RANGE_ERROR) {
|
|
29
|
+
addError(errStr);
|
|
30
|
+
} else if (type === 'VARIABLE_PRESENT' && allowedErrs.VARIABLE_PRESENT) {
|
|
31
|
+
addError(errStr);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exports.ErrorHandler = ErrorHandler;
|