import type * as d from '../../declarations' ; export const getStyleId = ( cmp , modeName , isScopedStyles ) => { return `${ cmp . tagName }${ modeName }${ isScopedStyles ? '.sc' : '' }` ; } ; export const escapeCssForJs = ( style ) => { if ( typeof style === 'string' ) { return style . replace ( /\\[\D0-7]/g , ( v ) => '\\' + v ) . replace ( /\r\n|\r|\n/g , `\\n` ) . replace ( /\"/g , `\\"` ) . replace ( /\'/g , `\\'` ) . replace ( /\@/g , `\\@` ) ; } return style ; } ; export const requiresScopedStyles = ( encapsulation , commentOriginalSelector ) => { return encapsulation === 'scoped' || ( encapsulation === 'shadow' && commentOriginalSelector ) ; } ; export const PLUGIN_HELPERS = [ { pluginName : 'PostCSS' , pluginId : 'postcss' , pluginExts : [ 'pcss' ] , } , { pluginName : 'Sass' , pluginId : 'sass' , pluginExts : [ 'scss' , 'sass' ] , } , { pluginName : 'Stylus' , pluginId : 'stylus' , pluginExts : [ 'styl' , 'stylus' ] , } , { pluginName : 'Less' , pluginId : 'less' , pluginExts : [ 'less' ] , } , ] ; export const stripCssComments = ( input ) => { let isInsideString = null ; let currentCharacter = '' ; let returnValue = '' ; for ( let i = 0 ; i < input . length ; i ++ ) { currentCharacter = input [ i ] ; if ( input [ i - 1 ] !== '\\' ) { if ( currentCharacter === '"' || currentCharacter === "'" ) { if ( isInsideString === currentCharacter ) { isInsideString = null ; } else if ( ! isInsideString ) { isInsideString = currentCharacter ; } } } if ( ! isInsideString && currentCharacter === '/' && input [ i + 1 ] === '*' ) { let j = i + 2 ; for ( ; j < input . length ; j ++ ) { if ( input [ j ] === '*' && input [ j + 1 ] === '/' ) { break ; } } i = j + 1 ; continue ; } returnValue += currentCharacter ; } return returnValue ; } ;