@zohodesk/client_build_tool 0.0.11-exp.15.4 → 0.0.11-exp.16.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/README.md +102 -0
- package/README_backup.md +100 -0
- package/docs/DYNAMIC_TEMPLATE_EXAMPLE.md +129 -0
- package/docs/I18N_SINGLE_FILE_MODE.md +126 -0
- package/example-single-file-config.js +59 -0
- package/lib/allCommandsConfigs.js +2 -7
- package/lib/commands/build/commandExecutor.js +1 -5
- package/lib/commands/build/config.js +2 -3
- package/lib/commands/build/optionsProcessor.js +2 -5
- package/lib/commands/build/preProcessor.js +0 -2
- package/lib/commands/buildEs/commandExecutor.js +0 -5
- package/lib/commands/buildEs/config.js +2 -3
- package/lib/commands/buildEs/preProcessor.js +0 -2
- package/lib/commands/buildLib/commandExecutor.js +0 -5
- package/lib/commands/buildLib/config.js +2 -3
- package/lib/commands/buildLib/preProcessor.js +0 -2
- package/lib/commands/mockserver/commandExecutor.js +2 -9
- package/lib/commands/mockserver/config.js +2 -3
- package/lib/commands/pre_process/commandExecutor.js +0 -2
- package/lib/commands/pre_process/config.js +2 -3
- package/lib/commands/start/commandExecutor.js +0 -2
- package/lib/commands/start/config.js +2 -3
- package/lib/commands/start/optionsProcessor.js +2 -4
- package/lib/commands/start/preProcessor.js +0 -2
- package/lib/commands/template/commandExecutor.js +0 -7
- package/lib/commands/template/config.js +2 -3
- package/lib/commands/version/commandExecutor.js +0 -3
- package/lib/commands/version/config.js +2 -3
- package/lib/commandsRouter.js +5 -21
- package/lib/index.js +0 -2
- package/lib/logger.js +0 -5
- package/lib/schemas/applyValuesToSchema/index.js +0 -8
- package/lib/schemas/applyValuesToSchema/isObject.js +0 -1
- package/lib/schemas/applyValuesToSchema/isValid.js +0 -2
- package/lib/schemas/cliArgsToObject.js +2 -6
- package/lib/schemas/defaultConfigValues.js +21 -12
- package/lib/schemas/defaultConfigValuesOnly.js +4 -7
- package/lib/schemas/deprecatedOptionsHandler.js +7 -16
- package/lib/schemas/getNpmVersion.js +0 -5
- package/lib/schemas/giveDefaultValue.js +0 -3
- package/lib/schemas/npmConfigToObject.js +2 -5
- package/lib/schemas/readOptions.js +10 -30
- package/lib/schemas/readOptionsForConfigFile.js +2 -12
- package/lib/shared/babel/addDefaultPlugins.js +0 -2
- package/lib/shared/babel/babelWebConfig.js +1 -10
- package/lib/shared/babel/babel_plugins/removeAttributesPlugin.js +0 -4
- package/lib/shared/babel/getBabelPlugin.js +2 -7
- package/lib/shared/babel/runBabelForJSFile.js +1 -4
- package/lib/shared/babel/runBabelForTsFile.js +1 -5
- package/lib/shared/bundler/webpack/common/decidePublicPath.js +0 -5
- package/lib/shared/bundler/webpack/common/libAlias.js +3 -3
- package/lib/shared/bundler/webpack/common/modeUtils.js +0 -5
- package/lib/shared/bundler/webpack/common/nameTemplates.js +11 -18
- package/lib/shared/bundler/webpack/common/resourceBasedPublicPath.js +2 -3
- package/lib/shared/bundler/webpack/configCustomLoaders.js +0 -1
- package/lib/shared/bundler/webpack/cssLoaders.js +0 -2
- package/lib/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/index.js +1 -20
- package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin/index.js +20 -25
- package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin/webpackCustomJsUrlLoader.js +4 -9
- package/lib/shared/bundler/webpack/custom_plugins/CustomScriptLoadingPlugin.js +3 -23
- package/lib/shared/bundler/webpack/custom_plugins/EFCTemplatePlugin.js +8 -19
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nGroupRuntimeModule.js +2 -6
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexHtmlInjectorPlugin.js +81 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +135 -60
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/utils/i18nDataLoader.js +20 -26
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nFilesEmitPlugin.js +5 -26
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +13 -16
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nRuntimeDealerPlugin.js +19 -53
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/LocaleChunkAssetsStore.js +2 -17
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ModulesI18nKeysStore.js +0 -13
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +11 -21
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +0 -4
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +4 -14
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +3 -13
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/iterateModulesInChunk.js +3 -12
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +2 -7
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +0 -2
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +2 -3
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +2 -4
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +8 -13
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -14
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/getChunkModules.js +0 -1
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +1 -3
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +0 -4
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +5 -25
- package/lib/shared/bundler/webpack/custom_plugins/InitialHtmlPlugin.js +3 -10
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/addFilesNamesToManifestJson.js +1 -6
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createInitialEntries.js +1 -6
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createManifestJson.js +0 -6
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/findInitialFileNames.js +0 -1
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/index.js +0 -7
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/removeHashFromFileName.js +0 -1
- package/lib/shared/bundler/webpack/custom_plugins/ResourceHintsPlugin.js +13 -17
- package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +6 -15
- package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +4 -13
- package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +4 -6
- package/lib/shared/bundler/webpack/custom_plugins/RuntimeResourceCleanup/index.js +0 -10
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/classHandling.js +0 -3
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/index.js +4 -20
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/selectorWeightPrefixAdder.js +10 -12
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/windowsModification.js +2 -3
- package/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +7 -20
- package/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPluginUtils.js +0 -1
- package/lib/shared/bundler/webpack/custom_plugins/SourceMapPlugin/index.js +7 -10
- package/lib/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/addHashToFilePath.js +1 -6
- package/lib/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/index.js +1 -16
- package/lib/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin/index.js.js +4 -11
- package/lib/shared/bundler/webpack/custom_plugins/VariableConversionCollector/ErrorHandler.js +3 -10
- package/lib/shared/bundler/webpack/custom_plugins/VariableConversionCollector/index.js +27 -62
- package/lib/shared/bundler/webpack/custom_plugins/custom_attribute_plugin/index.js +3 -15
- package/lib/shared/bundler/webpack/custom_plugins/emitAsset.js +0 -1
- package/lib/shared/bundler/webpack/custom_plugins/getInitialAssetsFuncTemplate.js +2 -12
- package/lib/shared/bundler/webpack/custom_plugins/getInitialI18nAssetsArrayStr.js +2 -7
- package/lib/shared/bundler/webpack/defaultVendorPatternList.js +2 -6
- package/lib/shared/bundler/webpack/devtoolConfig.js +0 -1
- package/lib/shared/bundler/webpack/entryConfig.js +0 -4
- package/lib/shared/bundler/webpack/externals.js +0 -1
- package/lib/shared/bundler/webpack/getCSSLoaders.js +1 -6
- package/lib/shared/bundler/webpack/getFilenameFromModule.js +1 -5
- package/lib/shared/bundler/webpack/jsLoaders.js +6 -10
- package/lib/shared/bundler/webpack/loaderConfigs/assetLoaders.js +0 -2
- package/lib/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +2 -3
- package/lib/shared/bundler/webpack/loaderConfigs/checkIsPatternsMatchFilename.js +3 -12
- package/lib/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +0 -1
- package/lib/shared/bundler/webpack/loaderConfigs/configPostCssLoader.js +2 -10
- package/lib/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +0 -2
- package/lib/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +0 -12
- package/lib/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +1 -15
- package/lib/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +1 -4
- package/lib/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +8 -16
- package/lib/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +22 -29
- package/lib/shared/bundler/webpack/loaders/miniCssFallBackLoader.js +2 -2
- package/lib/shared/bundler/webpack/loaders/workerLoader.js +8 -19
- package/lib/shared/bundler/webpack/optimizationConfig.js +5 -13
- package/lib/shared/bundler/webpack/outputConfig.js +1 -9
- package/lib/shared/bundler/webpack/pluginConfigs/configBundleAnalyzer.js +5 -9
- package/lib/shared/bundler/webpack/pluginConfigs/configBundleIntegrityReport.js +0 -5
- package/lib/shared/bundler/webpack/pluginConfigs/configCSSMinifierPlugin.js +4 -9
- package/lib/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +3 -8
- package/lib/shared/bundler/webpack/pluginConfigs/configCopyPublicFolders.js +1 -16
- package/lib/shared/bundler/webpack/pluginConfigs/configCustomAttributesPlugin.js +0 -4
- package/lib/shared/bundler/webpack/pluginConfigs/configCustomScriptLoadingStrategyPlugin.js +0 -16
- package/lib/shared/bundler/webpack/pluginConfigs/configEFCTemplatePlugin.js +0 -5
- package/lib/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +0 -5
- package/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +2 -8
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nIndexingPlugin.js +5 -9
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericHtmlInjector.js +19 -25
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +92 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +3 -9
- package/lib/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +0 -2
- package/lib/shared/bundler/webpack/pluginConfigs/configManifestJsonPlugin.js +0 -7
- package/lib/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +3 -7
- package/lib/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +1 -5
- package/lib/shared/bundler/webpack/pluginConfigs/configResourceHintsPlugin.js +1 -4
- package/lib/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +0 -4
- package/lib/shared/bundler/webpack/pluginConfigs/configRuntimeResourceCleanup.js +3 -8
- package/lib/shared/bundler/webpack/pluginConfigs/configSelectorWeightPlugin.js +1 -6
- package/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +3 -8
- package/lib/shared/bundler/webpack/pluginConfigs/configSourceMapPlugin.js +0 -4
- package/lib/shared/bundler/webpack/pluginConfigs/configTPHashMappingPlugin.js +1 -8
- package/lib/shared/bundler/webpack/pluginConfigs/configVariableConversionPlugin.js +1 -6
- package/lib/shared/bundler/webpack/plugins.js +3 -30
- package/lib/shared/bundler/webpack/resolvers.js +3 -17
- package/lib/shared/bundler/webpack/splitChunksConfig.js +2 -15
- package/lib/shared/bundler/webpack/statsConfig.js +2 -5
- package/lib/shared/bundler/webpack/tsLoaders.js +2 -4
- package/lib/shared/bundler/webpack/utils/index.js +1 -12
- package/lib/shared/bundler/webpack/utils/object-manipulation.js +2 -16
- package/lib/shared/bundler/webpack/utils/updateArrayWithDefault.js +0 -7
- package/lib/shared/bundler/webpack/webpackBuild.js +1 -8
- package/lib/shared/bundler/webpack/webpackConfig.js +0 -17
- package/lib/shared/commands-utils/doBasicRequirementCheck.js +0 -3
- package/lib/shared/commands-utils/getCliPath.js +5 -9
- package/lib/shared/commands-utils/index.js +0 -3
- package/lib/shared/commands-utils/log.js +0 -2
- package/lib/shared/commands-utils/readArgsFormCommandLine.js +0 -1
- package/lib/shared/commands-utils/readOptionFormCommandLine.js +0 -1
- package/lib/shared/commands-utils/spawnSyncIO.js +5 -13
- package/lib/shared/constants.js +9 -29
- package/lib/shared/fileUtils/copyFile.js +1 -8
- package/lib/shared/fileUtils/directoryIterator.js +0 -4
- package/lib/shared/fileUtils/watchRun.js +3 -24
- package/lib/shared/postcss/custom_postcss_plugins/EmptyPlugin.js +1 -6
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/constants.js +2 -3
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/handleIgnores.js +6 -13
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/index.js +6 -26
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/insertBefore.js +6 -9
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/isPreviouslyProcessed.js +0 -3
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/replaceUtils.js +2 -7
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/separateHoveredSelectorAndNormalSelector.js +0 -2
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/specialCases.js +4 -9
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/typeCheckUtils.js +0 -10
- package/lib/shared/postcss/custom_postcss_plugins/RTLSplitPlugin.js +16 -29
- package/lib/shared/postcss/custom_postcss_plugins/SelectorReplace.js +0 -17
- package/lib/shared/postcss/custom_postcss_plugins/ValueReplacer.js +4 -9
- package/lib/shared/postcss/custom_postcss_plugins/VariableModificationPlugin/index.js +27 -63
- package/lib/shared/postcss/filterPluginsAllowedForSpecficFile.js +5 -13
- package/lib/shared/postcss/getAllowedPostCssPlugins.js +0 -3
- package/lib/shared/postcss/getSpecificPostCssPlugin.js +7 -17
- package/lib/shared/postcss/runPostCssForCssFile.js +1 -9
- package/lib/shared/pre_process/runPreProcess.js +0 -11
- package/lib/shared/server/configWebpackDevMiddleware.js +1 -8
- package/lib/shared/server/corsHandling.js +2 -6
- package/lib/shared/server/getIp.js +1 -7
- package/lib/shared/server/getServerURL.js +0 -6
- package/lib/shared/server/httpsOptions.js +0 -11
- package/lib/shared/server/initExpressApp.js +1 -4
- package/lib/shared/server/initialHTMLHandling.js +7 -16
- package/lib/shared/server/mockApiHandler.js +8 -16
- package/lib/shared/server/mockServer.js +0 -7
- package/lib/shared/server/serveContextFiles.js +1 -5
- package/lib/shared/server/serverBywebpackDevMiddleware.js +4 -9
- package/lib/shared/server/startHttpServer.js +0 -3
- package/lib/shared/server/startHttpsServer.js +1 -9
- package/lib/shared/server/unwanted/addHttp2Server.js +2 -7
- package/lib/shared/server/unwanted/configWebpackDevMiddleware.js +1 -8
- package/lib/shared/server/unwanted/mockApiSupport.js +0 -2
- package/lib/shared/server/unwanted/websocketMockSetup.js +1 -7
- package/lib/shared/server/urlConcat.js +3 -8
- package/lib/shared/utils/requireLocalOrGlobal.js +10 -25
- package/lib/shared/utils/versionPrint.js +1 -6
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/packages/client_build_tool/test-i18n-config.js +22 -0
|
@@ -4,14 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.doBasicRequirementCheck = doBasicRequirementCheck;
|
|
7
|
-
|
|
8
7
|
/* eslint-disable no-throw-literal */
|
|
9
8
|
function doBasicRequirementCheck() {
|
|
10
9
|
const majorV = Number(process.version.slice(1, 4));
|
|
11
|
-
|
|
12
10
|
if (majorV >= 14 && majorV <= 18) {
|
|
13
11
|
return true;
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
throw `your node version not compatible with this cli please update node version to 14 - 18, and your current version is ${process.version}`;
|
|
17
14
|
}
|
|
@@ -4,17 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getCliPath = getCliPath;
|
|
7
|
-
|
|
8
7
|
var _os = require("os");
|
|
9
|
-
|
|
10
8
|
var _fs = require("fs");
|
|
11
|
-
|
|
12
9
|
var _path = require("path");
|
|
13
|
-
|
|
14
10
|
var _constants = require("../constants");
|
|
15
|
-
|
|
16
11
|
const isWindows = (0, _os.platform)().toLowerCase() === 'win32';
|
|
17
|
-
const suffixExt = isWindows ? '.cmd' : '';
|
|
12
|
+
const suffixExt = isWindows ? '.cmd' : '';
|
|
13
|
+
|
|
14
|
+
// function searchForCommandPath(commandName) {
|
|
18
15
|
// let pathFolders = __dirname.split(sep);
|
|
19
16
|
// let cliPath;
|
|
20
17
|
// while (pathFolders.pop()) {
|
|
@@ -28,12 +25,11 @@ const suffixExt = isWindows ? '.cmd' : ''; // function searchForCommandPath(comm
|
|
|
28
25
|
// }
|
|
29
26
|
|
|
30
27
|
function searchForCommandPath(libName) {
|
|
31
|
-
const commandPath = (0, _path.join)(_constants.cliNodeModulesPath, '.bin', libName);
|
|
28
|
+
const commandPath = (0, _path.join)(_constants.cliNodeModulesPath, '.bin', libName);
|
|
29
|
+
// TODO: need to check for windows machine reason command with ext added,
|
|
32
30
|
// when we use global react-cli package (executable) working or not
|
|
33
|
-
|
|
34
31
|
return (0, _fs.existsSync)(commandPath) ? commandPath : libName;
|
|
35
32
|
}
|
|
36
|
-
|
|
37
33
|
function getCliPath(commandName) {
|
|
38
34
|
return searchForCommandPath(commandName + suffixExt);
|
|
39
35
|
}
|
|
@@ -21,9 +21,6 @@ Object.defineProperty(exports, "readOptionFormCommandLine", {
|
|
|
21
21
|
return _readOptionFormCommandLine.readOptionFormCommandLine;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
|
|
25
24
|
var _readArgsFormCommandLine = require("./readArgsFormCommandLine");
|
|
26
|
-
|
|
27
25
|
var _readOptionFormCommandLine = require("./readOptionFormCommandLine");
|
|
28
|
-
|
|
29
26
|
var _doBasicRequirementCheck = require("./doBasicRequirementCheck");
|
|
@@ -6,33 +6,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.defaultSpawnSyncOptions = void 0;
|
|
7
7
|
exports.spawnIO = spawnIO;
|
|
8
8
|
exports.spawnSyncIO = spawnSyncIO;
|
|
9
|
-
|
|
10
9
|
var _child_process = require("child_process");
|
|
11
|
-
|
|
12
10
|
var _logger = require("../../logger");
|
|
13
|
-
|
|
14
11
|
var _getCliPath = require("./getCliPath");
|
|
15
|
-
|
|
16
|
-
const defaultSpawnSyncOptions = {
|
|
12
|
+
const defaultSpawnSyncOptions = exports.defaultSpawnSyncOptions = {
|
|
17
13
|
stdio: 'inherit'
|
|
18
14
|
};
|
|
19
|
-
exports.defaultSpawnSyncOptions = defaultSpawnSyncOptions;
|
|
20
|
-
|
|
21
15
|
function spawnSyncIO(commandName, args, spawnSyncOptions = defaultSpawnSyncOptions) {
|
|
22
16
|
const command = (0, _getCliPath.getCliPath)(commandName);
|
|
23
17
|
const result = (0, _child_process.spawnSync)(command, args, spawnSyncOptions);
|
|
24
|
-
|
|
25
18
|
if (result.error || result.stderr) {
|
|
26
19
|
(0, _logger.errorLogger)(result.error || result.stderr);
|
|
27
20
|
}
|
|
28
|
-
|
|
29
21
|
return result;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
function spawnIO(commandName, args, cb) {
|
|
33
|
-
const command = (0, _getCliPath.getCliPath)(commandName);
|
|
34
|
-
|
|
24
|
+
const command = (0, _getCliPath.getCliPath)(commandName);
|
|
25
|
+
// const result =
|
|
35
26
|
return (0, _child_process.spawn)(command, args, {
|
|
36
27
|
stdio: 'inherit'
|
|
37
|
-
}, cb);
|
|
28
|
+
}, cb);
|
|
29
|
+
// process.exit(result.status);
|
|
38
30
|
}
|
package/lib/shared/constants.js
CHANGED
|
@@ -7,41 +7,21 @@ exports.cliRootPath = exports.cliNodeModulesPath = exports.babelrcPath = exports
|
|
|
7
7
|
exports.getTemplatePath = getTemplatePath;
|
|
8
8
|
exports.joinWithAppPath = joinWithAppPath;
|
|
9
9
|
exports.templatesPath = void 0;
|
|
10
|
-
|
|
11
10
|
var _path = _interopRequireWildcard(require("path"));
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
exports.
|
|
19
|
-
|
|
20
|
-
const cliRootPath = _path.default.resolve(__dirname, '..', '..');
|
|
21
|
-
|
|
22
|
-
exports.cliRootPath = cliRootPath;
|
|
23
|
-
const CONFIG_ROOT = 'client-build-config';
|
|
24
|
-
exports.CONFIG_ROOT = CONFIG_ROOT;
|
|
25
|
-
|
|
26
|
-
const cliNodeModulesPath = _path.default.resolve(cliRootPath, 'node_modules');
|
|
27
|
-
|
|
28
|
-
exports.cliNodeModulesPath = cliNodeModulesPath;
|
|
29
|
-
const babelrcPath = (0, _path.join)(cliRootPath, '.babelrc');
|
|
30
|
-
exports.babelrcPath = babelrcPath;
|
|
31
|
-
const appPath = process.cwd();
|
|
32
|
-
exports.appPath = appPath;
|
|
33
|
-
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
|
+
const BASE_CONFIG_KEY = exports.BASE_CONFIG_KEY = 'react-cli';
|
|
13
|
+
const cliRootPath = exports.cliRootPath = _path.default.resolve(__dirname, '..', '..');
|
|
14
|
+
const CONFIG_ROOT = exports.CONFIG_ROOT = 'client-build-config';
|
|
15
|
+
const cliNodeModulesPath = exports.cliNodeModulesPath = _path.default.resolve(cliRootPath, 'node_modules');
|
|
16
|
+
const babelrcPath = exports.babelrcPath = (0, _path.join)(cliRootPath, '.babelrc');
|
|
17
|
+
const appPath = exports.appPath = process.cwd();
|
|
34
18
|
function joinWithAppPath(filePath) {
|
|
35
19
|
// TODO: test in windows
|
|
36
20
|
return (0, _path.join)(appPath, filePath);
|
|
37
21
|
}
|
|
38
|
-
|
|
39
22
|
;
|
|
40
|
-
const appNodeModules = joinWithAppPath('node_modules');
|
|
41
|
-
exports.
|
|
42
|
-
const templatesPath = (0, _path.join)(__dirname, '..', '..', 'templates');
|
|
43
|
-
exports.templatesPath = templatesPath;
|
|
44
|
-
|
|
23
|
+
const appNodeModules = exports.appNodeModules = joinWithAppPath('node_modules');
|
|
24
|
+
const templatesPath = exports.templatesPath = (0, _path.join)(__dirname, '..', '..', 'templates');
|
|
45
25
|
function getTemplatePath(...filePath) {
|
|
46
26
|
// TODO: test in windows
|
|
47
27
|
return (0, _path.join)(templatesPath, ...filePath);
|
|
@@ -6,32 +6,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.copyFile = copyFile;
|
|
7
7
|
exports.createParentDir = createParentDir;
|
|
8
8
|
exports.writeFile = writeFile;
|
|
9
|
-
|
|
10
9
|
var _fs = require("fs");
|
|
11
|
-
|
|
12
10
|
var _path = _interopRequireDefault(require("path"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
12
|
function createParentDir(filename) {
|
|
17
13
|
const {
|
|
18
14
|
dir
|
|
19
15
|
} = _path.default.parse(filename);
|
|
20
|
-
|
|
21
16
|
if (!(0, _fs.existsSync)(dir)) {
|
|
22
17
|
(0, _fs.mkdirSync)(dir, {
|
|
23
18
|
recursive: true
|
|
24
19
|
});
|
|
25
20
|
}
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
function copyFile(filename, outputFile) {
|
|
29
23
|
createParentDir(outputFile);
|
|
30
24
|
const readStream = (0, _fs.createReadStream)(filename);
|
|
31
25
|
const writeStream = (0, _fs.createWriteStream)(outputFile);
|
|
32
26
|
return readStream.pipe(writeStream);
|
|
33
27
|
}
|
|
34
|
-
|
|
35
28
|
function writeFile(filename, data) {
|
|
36
29
|
createParentDir(filename);
|
|
37
30
|
return (0, _fs.writeFileSync)(filename, data);
|
|
@@ -4,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.directoryIterator = directoryIterator;
|
|
7
|
-
|
|
8
7
|
var _fs = require("fs");
|
|
9
|
-
|
|
10
8
|
var _path = require("path");
|
|
11
|
-
|
|
12
9
|
function directoryIterator(filename, callback) {
|
|
13
10
|
if (!(0, _fs.statSync)(filename).isDirectory()) {
|
|
14
11
|
callback(filename);
|
|
15
12
|
return;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
(0, _fs.readdirSync)(filename).forEach(fileOrDir => {
|
|
19
15
|
directoryIterator((0, _path.join)(filename, fileOrDir), callback);
|
|
20
16
|
});
|
|
@@ -4,31 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.watchRun = watchRun;
|
|
7
|
-
|
|
8
7
|
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
8
|
var _watcher = _interopRequireDefault(require("watcher"));
|
|
11
|
-
|
|
12
9
|
var _runBabelForJSFile = require("../babel/runBabelForJSFile");
|
|
13
|
-
|
|
14
10
|
var _runBabelForTsFile = require("../babel/runBabelForTsFile");
|
|
15
|
-
|
|
16
11
|
var _runPostCssForCssFile = require("../postcss/runPostCssForCssFile");
|
|
17
|
-
|
|
18
12
|
var _directoryIterator = require("./directoryIterator");
|
|
19
|
-
|
|
20
13
|
var _copyFile = require("./copyFile");
|
|
21
|
-
|
|
22
14
|
var _logger = require("../../logger");
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
26
16
|
const isJs = ext => ext === '.js';
|
|
27
|
-
|
|
28
17
|
const isTs = ext => ext === '.ts' || ext === '.tsx';
|
|
29
|
-
|
|
30
18
|
const isCss = ext => ext === '.css';
|
|
31
|
-
|
|
32
19
|
function watchRun({
|
|
33
20
|
options,
|
|
34
21
|
src,
|
|
@@ -37,14 +24,11 @@ function watchRun({
|
|
|
37
24
|
mode
|
|
38
25
|
}) {
|
|
39
26
|
let updatedFileCount = 0;
|
|
40
|
-
|
|
41
27
|
function doWorkForSeparateFile(filename) {
|
|
42
28
|
const outputFile = filename.replace(src, target);
|
|
43
|
-
|
|
44
29
|
const {
|
|
45
30
|
ext
|
|
46
31
|
} = _path.default.parse(filename);
|
|
47
|
-
|
|
48
32
|
if (isJs(ext)) {
|
|
49
33
|
(0, _runBabelForJSFile.runBabelForJSFile)({
|
|
50
34
|
filename,
|
|
@@ -68,10 +52,8 @@ function watchRun({
|
|
|
68
52
|
} else {
|
|
69
53
|
(0, _copyFile.copyFile)(filename, outputFile);
|
|
70
54
|
}
|
|
71
|
-
|
|
72
55
|
updatedFileCount++;
|
|
73
56
|
}
|
|
74
|
-
|
|
75
57
|
function doWork(foldername) {
|
|
76
58
|
updatedFileCount = 0;
|
|
77
59
|
const startTime = Date.now();
|
|
@@ -85,22 +67,19 @@ function watchRun({
|
|
|
85
67
|
});
|
|
86
68
|
(0, _logger.messageLogger)(`Successfully compiled ${updatedFileCount} files with Babel and Post-CSS (${Date.now() - startTime}ms).`);
|
|
87
69
|
}
|
|
88
|
-
|
|
89
70
|
doWork(src);
|
|
90
|
-
|
|
91
71
|
if (canWatch) {
|
|
92
72
|
const watcher = new _watcher.default(src, {
|
|
93
73
|
recursive: true,
|
|
94
74
|
ignoreInitial: true,
|
|
95
75
|
ignore: filename => filename.indexOf('__tests__') !== -1 // remove the test cases
|
|
96
|
-
|
|
97
76
|
});
|
|
98
77
|
watcher.on('all', (event, filename) => {
|
|
99
78
|
if (event === 'unlink' || event === 'unlinkDir') {
|
|
100
79
|
return;
|
|
101
80
|
}
|
|
102
|
-
|
|
103
|
-
|
|
81
|
+
doWork(filename);
|
|
82
|
+
// This is what the library does internally when you pass it a handler directly
|
|
104
83
|
// arguments [0] (event); // => could be any target event: 'add', 'addDir', 'change', 'rename', 'renameDir', 'unlink' or 'unlinkDir'
|
|
105
84
|
// arguments [1] (filename); // => the file system path where the event took place, this is always provided
|
|
106
85
|
// arguments [2] (targetPathNext); // => the file system path "targetPath" got renamed to, this is only provided on 'rename'/'renameDir' events
|
|
@@ -4,18 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
// eslint-disable-next-line no-unused-vars
|
|
9
8
|
const EmptyPlugin = (opts = {}) => ({
|
|
10
9
|
postcssPlugin: 'postcss-empty',
|
|
11
|
-
|
|
12
10
|
// eslint-disable-next-line no-unused-vars
|
|
13
11
|
Once(root, {
|
|
14
12
|
result
|
|
15
13
|
}) {}
|
|
16
|
-
|
|
17
14
|
});
|
|
18
|
-
|
|
19
15
|
EmptyPlugin.postcss = true;
|
|
20
|
-
var _default = EmptyPlugin;
|
|
21
|
-
exports.default = _default;
|
|
16
|
+
var _default = exports.default = EmptyPlugin;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.HOVER_NOTATION = void 0;
|
|
7
|
-
|
|
8
7
|
/* eslint-disable no-use-before-define */
|
|
9
|
-
|
|
10
|
-
exports.HOVER_NOTATION =
|
|
8
|
+
|
|
9
|
+
const HOVER_NOTATION = exports.HOVER_NOTATION = ':hover';
|
|
@@ -4,13 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.handleIgnores = handleIgnores;
|
|
7
|
-
|
|
8
7
|
var _typeCheckUtils = require("./typeCheckUtils");
|
|
9
|
-
|
|
10
8
|
const hoverIgnoreQuery = 'Hover:ignore';
|
|
11
9
|
const activeIgnoreQuery = 'Active:ignore';
|
|
12
10
|
const hoverActiveIgnoreQuery = 'HoverActive:ignore';
|
|
13
|
-
|
|
14
11
|
function handleIgnore() {
|
|
15
12
|
let isIgnored = false;
|
|
16
13
|
return {
|
|
@@ -22,20 +19,17 @@ function handleIgnore() {
|
|
|
22
19
|
isIgnored = false;
|
|
23
20
|
}
|
|
24
21
|
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
}
|
|
23
|
+
// eslint-disable-next-line no-unused-vars
|
|
28
24
|
function handleIgnores(options) {
|
|
29
25
|
const hoverHandler = handleIgnore();
|
|
30
26
|
const activeHandler = handleIgnore();
|
|
31
|
-
|
|
32
27
|
function generateReturnValue() {
|
|
33
28
|
return {
|
|
34
29
|
hoverIgnored: hoverHandler.isIgnored(),
|
|
35
30
|
activeIgnored: activeHandler.isIgnored()
|
|
36
31
|
};
|
|
37
32
|
}
|
|
38
|
-
|
|
39
33
|
const ignoreCommentMap = {
|
|
40
34
|
[hoverIgnoreQuery]: () => {
|
|
41
35
|
hoverHandler.update(true);
|
|
@@ -51,13 +45,12 @@ function handleIgnores(options) {
|
|
|
51
45
|
return node => {
|
|
52
46
|
if ((0, _typeCheckUtils.isComment)(node)) {
|
|
53
47
|
const commentText = node.text.trim();
|
|
54
|
-
ignoreCommentMap[commentText] && ignoreCommentMap[commentText]();
|
|
55
|
-
|
|
48
|
+
ignoreCommentMap[commentText] && ignoreCommentMap[commentText]();
|
|
49
|
+
// NOTE: we return here because this is just comment we can skip it.
|
|
56
50
|
return generateReturnValue();
|
|
57
|
-
}
|
|
51
|
+
}
|
|
52
|
+
// NOTE: we get the here. But return after resetting for next. Because these comment Only works for once.
|
|
58
53
|
// Even If we support multiple line Skip we must do it in reset or separate method.
|
|
59
|
-
|
|
60
|
-
|
|
61
54
|
const returnValue = generateReturnValue();
|
|
62
55
|
hoverHandler.reset();
|
|
63
56
|
activeHandler.reset();
|
|
@@ -4,72 +4,58 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _handleIgnores = require("./handleIgnores");
|
|
9
|
-
|
|
10
8
|
var _typeCheckUtils = require("./typeCheckUtils");
|
|
11
|
-
|
|
12
9
|
var _isPreviouslyProcessed = require("./isPreviouslyProcessed");
|
|
13
|
-
|
|
14
10
|
var _insertBefore = require("./insertBefore");
|
|
15
|
-
|
|
16
11
|
var _separateHoveredSelectorAndNormalSelector = require("./separateHoveredSelectorAndNormalSelector");
|
|
17
|
-
|
|
18
12
|
var _replaceUtils = require("./replaceUtils");
|
|
19
|
-
|
|
20
13
|
var _specialCases = require("./specialCases");
|
|
21
|
-
|
|
22
14
|
var _default = config => {
|
|
23
15
|
const hoverMedQuerySuffix = config.hover;
|
|
24
16
|
const activeMedQuerySuffix = config.active;
|
|
25
17
|
return {
|
|
26
18
|
postcssPlugin: 'postcss-mobile-hover',
|
|
27
19
|
Once: function Once(root, params) {
|
|
28
|
-
const getIgnoreStatus = (0, _handleIgnores.handleIgnores)();
|
|
20
|
+
const getIgnoreStatus = (0, _handleIgnores.handleIgnores)();
|
|
29
21
|
|
|
22
|
+
// eslint-disable-next-line no-use-before-define
|
|
30
23
|
const mediaRuleCreatorMap = getMediaRuleMap(params, hoverMedQuerySuffix, activeMedQuerySuffix);
|
|
31
24
|
root.walk(node => {
|
|
32
25
|
const ignoreStatus = getIgnoreStatus(node);
|
|
33
|
-
|
|
34
26
|
if ((0, _typeCheckUtils.isRule)(node) === false) {
|
|
35
27
|
return;
|
|
36
28
|
}
|
|
37
|
-
|
|
38
29
|
if ((0, _typeCheckUtils.isAtRule)(node.parent) && !(0, _typeCheckUtils.isMediaQuery)(node.parent)) {
|
|
39
30
|
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
}
|
|
32
|
+
// NOTE: after previous return we expect rule that are only normal rule or rules that inside media query
|
|
43
33
|
const rule = node;
|
|
44
|
-
|
|
45
34
|
if ((0, _isPreviouslyProcessed.isPreviouslyProcessed)(rule, {
|
|
46
35
|
hoverMedQuerySuffix,
|
|
47
36
|
activeMedQuerySuffix
|
|
48
37
|
})) {
|
|
49
38
|
return;
|
|
50
39
|
}
|
|
51
|
-
|
|
52
40
|
const {
|
|
53
41
|
hoveredSelectors,
|
|
54
42
|
normalSelectors
|
|
55
|
-
} = (0, _separateHoveredSelectorAndNormalSelector.separateHoveredSelectorAndNormalSelector)(rule.selector);
|
|
43
|
+
} = (0, _separateHoveredSelectorAndNormalSelector.separateHoveredSelectorAndNormalSelector)(rule.selector);
|
|
56
44
|
|
|
45
|
+
// NOTE: this if will remove rule if the rule has no normal selectors. and return So be aware.
|
|
57
46
|
if (hoveredSelectors.length === 0) {
|
|
58
47
|
// || isRuleHasHover(rule) === false
|
|
59
48
|
return;
|
|
60
49
|
}
|
|
61
|
-
|
|
62
50
|
let newHoverMediaQuery = null;
|
|
63
51
|
let newActiveMediaQuery = null;
|
|
64
52
|
let prefix = '';
|
|
65
|
-
|
|
66
53
|
if ((0, _typeCheckUtils.isAtRule)(rule.parent)) {
|
|
67
54
|
prefix = rule.parent.params;
|
|
68
55
|
} else {
|
|
69
56
|
// NOTE: for usual rules we don't need prefix, So use prefix as empty string
|
|
70
57
|
prefix = '';
|
|
71
58
|
}
|
|
72
|
-
|
|
73
59
|
if (!ignoreStatus.hoverIgnored) {
|
|
74
60
|
newHoverMediaQuery = mediaRuleCreatorMap.hoverRule({
|
|
75
61
|
rule,
|
|
@@ -77,7 +63,6 @@ var _default = config => {
|
|
|
77
63
|
prefix
|
|
78
64
|
}, params);
|
|
79
65
|
}
|
|
80
|
-
|
|
81
66
|
if (!ignoreStatus.activeIgnored) {
|
|
82
67
|
newActiveMediaQuery = mediaRuleCreatorMap.activeRule({
|
|
83
68
|
rule,
|
|
@@ -85,7 +70,6 @@ var _default = config => {
|
|
|
85
70
|
prefix
|
|
86
71
|
}, params);
|
|
87
72
|
}
|
|
88
|
-
|
|
89
73
|
(0, _insertBefore.insertNearBy)(rule, newHoverMediaQuery);
|
|
90
74
|
(0, _insertBefore.insertNearBy)(rule, newActiveMediaQuery);
|
|
91
75
|
(0, _specialCases.hackForComposes)(rule, hoveredSelectors, params);
|
|
@@ -94,9 +78,7 @@ var _default = config => {
|
|
|
94
78
|
}
|
|
95
79
|
};
|
|
96
80
|
};
|
|
97
|
-
|
|
98
81
|
exports.default = _default;
|
|
99
|
-
|
|
100
82
|
function getMediaRuleMap(params, hoverMedQuerySuffix, activeMedQuerySuffix) {
|
|
101
83
|
const {
|
|
102
84
|
AtRule
|
|
@@ -116,7 +98,6 @@ function getMediaRuleMap(params, hoverMedQuerySuffix, activeMedQuerySuffix) {
|
|
|
116
98
|
newMediaQuery.append(clonedRule);
|
|
117
99
|
return newMediaQuery;
|
|
118
100
|
},
|
|
119
|
-
|
|
120
101
|
activeRule({
|
|
121
102
|
rule,
|
|
122
103
|
hoveredSelectors,
|
|
@@ -131,6 +112,5 @@ function getMediaRuleMap(params, hoverMedQuerySuffix, activeMedQuerySuffix) {
|
|
|
131
112
|
newMediaQuery.append(clonedRule);
|
|
132
113
|
return newMediaQuery;
|
|
133
114
|
}
|
|
134
|
-
|
|
135
115
|
};
|
|
136
116
|
}
|
|
@@ -5,28 +5,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.insertBefore = insertBefore;
|
|
7
7
|
exports.insertNearBy = insertNearBy;
|
|
8
|
-
|
|
9
8
|
var _typeCheckUtils = require("./typeCheckUtils");
|
|
10
|
-
|
|
11
9
|
function insertBefore(node, newNode) {
|
|
12
10
|
newNode && node.parent.insertBefore(node, newNode);
|
|
13
11
|
return newNode;
|
|
14
|
-
}
|
|
12
|
+
}
|
|
13
|
+
// function insertAfter(node, newNode) {
|
|
15
14
|
// newNode && node.parent.insertAfter(node, newNode);
|
|
16
15
|
// return newNode;
|
|
17
16
|
// }
|
|
18
17
|
|
|
19
|
-
|
|
20
18
|
function insertNearBy(node, newNode) {
|
|
21
19
|
if (!newNode) {
|
|
22
20
|
return newNode;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
}
|
|
22
|
+
// we use insertBefore Because we wouldn't end up recursive (repeated) check and creation
|
|
26
23
|
if ((0, _typeCheckUtils.isParentAtRule)(node) && (0, _typeCheckUtils.isAtRule)(newNode)) {
|
|
27
24
|
return insertNearBy(node.parent, newNode);
|
|
28
25
|
}
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
return insertBefore(node, newNode);
|
|
27
|
+
// return insertAfter(node, newNode);
|
|
31
28
|
// return newNode;
|
|
32
29
|
}
|
package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/isPreviouslyProcessed.js
CHANGED
|
@@ -5,13 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.concatMediaParams = concatMediaParams;
|
|
7
7
|
exports.isPreviouslyProcessed = isPreviouslyProcessed;
|
|
8
|
-
|
|
9
8
|
var _typeCheckUtils = require("./typeCheckUtils");
|
|
10
|
-
|
|
11
9
|
function concatMediaParams(prefix, suffix) {
|
|
12
10
|
return prefix ? `${prefix} and ${suffix}` : `${suffix}`;
|
|
13
11
|
}
|
|
14
|
-
|
|
15
12
|
function isPreviouslyProcessed(rule, {
|
|
16
13
|
hoverMedQuerySuffix,
|
|
17
14
|
activeMedQuerySuffix
|
|
@@ -4,17 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.replaceHoverToActiveInSelector = exports.removeHoverFromSelector = void 0;
|
|
7
|
-
|
|
8
7
|
var _constants = require("./constants");
|
|
9
|
-
|
|
10
8
|
// function isRuleHasHover(rule) {
|
|
11
9
|
// return isSelectorHasHover(rule.selector);
|
|
12
10
|
// }
|
|
13
11
|
function generateReplacer(baseStr, replaceStr) {
|
|
14
12
|
return (inputStr = '') => inputStr.replaceAll(baseStr, replaceStr);
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
exports.removeHoverFromSelector = removeHoverFromSelector;
|
|
19
|
-
const replaceHoverToActiveInSelector = generateReplacer(_constants.HOVER_NOTATION, ':active');
|
|
20
|
-
exports.replaceHoverToActiveInSelector = replaceHoverToActiveInSelector;
|
|
14
|
+
const removeHoverFromSelector = exports.removeHoverFromSelector = generateReplacer(_constants.HOVER_NOTATION, '');
|
|
15
|
+
const replaceHoverToActiveInSelector = exports.replaceHoverToActiveInSelector = generateReplacer(_constants.HOVER_NOTATION, ':active');
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.separateHoveredSelectorAndNormalSelector = separateHoveredSelectorAndNormalSelector;
|
|
7
|
-
|
|
8
7
|
var _typeCheckUtils = require("./typeCheckUtils");
|
|
9
|
-
|
|
10
8
|
function separateHoveredSelectorAndNormalSelector(fullselector = '') {
|
|
11
9
|
const hoveredSelectors = [];
|
|
12
10
|
const normalSelectors = [];
|
|
@@ -5,33 +5,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.hackForComposes = hackForComposes;
|
|
7
7
|
exports.removeRuleIfNoNormalSelectors = removeRuleIfNoNormalSelectors;
|
|
8
|
-
|
|
9
8
|
var _insertBefore = require("./insertBefore");
|
|
10
|
-
|
|
11
9
|
var _replaceUtils = require("./replaceUtils");
|
|
12
|
-
|
|
13
10
|
function hackForComposes(rule, hoveredSelectors, params) {
|
|
14
11
|
const {
|
|
15
12
|
Rule
|
|
16
13
|
} = params;
|
|
17
|
-
|
|
18
14
|
if (hoveredSelectors.length === 0) {
|
|
19
15
|
return;
|
|
20
|
-
}
|
|
21
|
-
// Reason: when composes looking for selector it most be at least empty rule other wise composes will throw error.
|
|
22
|
-
|
|
16
|
+
}
|
|
23
17
|
|
|
18
|
+
// NOTE: we create Empty Rule with hovered selectors that :hover removed from hover selector
|
|
19
|
+
// Reason: when composes looking for selector it most be at least empty rule other wise composes will throw error.
|
|
24
20
|
(0, _insertBefore.insertBefore)(rule, new Rule({
|
|
25
21
|
selector: hoveredSelectors.map(_replaceUtils.removeHoverFromSelector).join(',')
|
|
26
22
|
}));
|
|
27
23
|
}
|
|
24
|
+
|
|
28
25
|
/**
|
|
29
26
|
* NOTE: this function will remove rule if the rule has no normal selectors.
|
|
30
27
|
* @param {Rule} rule
|
|
31
28
|
* @returns
|
|
32
29
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
30
|
function removeRuleIfNoNormalSelectors(normalSelectors, rule) {
|
|
36
31
|
if (normalSelectors.length) {
|
|
37
32
|
// NOTE: removed hovered selectors
|