public class MinimizeJSManager extends AbstractMinimizeManager implements Component
Modifier and Type | Field and Description |
---|---|
private static Pattern |
__SOURCEMAP_FILE_NAME |
static String |
ROLE
The avalon ROLE
|
_proxiedContextPathProvider, _resolver, _sourceMapCache
Constructor and Description |
---|
MinimizeJSManager() |
Modifier and Type | Method and Description |
---|---|
private com.google.javascript.jscomp.Compiler |
_minimizeJS(String code,
String fileName,
boolean withSourceMap) |
protected void |
addSourceMap(com.google.debugging.sourcemap.SourceMapGeneratorV3 sourceMapGenerator,
int lineCount,
String fileContent,
String fileUri,
String sourceMapUri)
Aggregate the source map of the single file with the others
|
protected String |
formatSourceMappingURL(String sourceMapName)
Format a source mapping URL to be added at the end of a minimized file
|
String |
generateJSSourceMap(String code,
String location,
String sourceMapKey,
Long lastModified)
Minimize a JS string and return the source map
|
protected String |
getMinimizedContent(String uri,
String nestedParentFilesName)
Get the minimized content at the specified URI
|
protected String |
getSourceMappingURL(String line)
Get the source mapping URL value from the line
|
protected boolean |
isSourceMappingURLLine(String line)
Test if the line contains a source mapping URL
|
String |
minimizeJS(String code,
String location)
Minimize a JS string
|
String |
minimizeJS(String code,
String location,
String sourceMapKey,
Long lastModified)
Minimize a JS string
|
protected String |
removeSourceMappingURLLine(String content)
Remove the source mapping url from the content
|
void |
service(ServiceManager manager) |
applyMediaToContent, convertSourceMapURIs, minimizeAndAggregateURIs, validateAndOutputMinimizedFile
getLogger, setLogger
private static final Pattern __SOURCEMAP_FILE_NAME
public MinimizeJSManager()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
service
in class AbstractMinimizeManager
ServiceException
public String minimizeJS(String code, String location) throws ProcessingException, IOException
code
- The JS codelocation
- The JS locationProcessingException
- If an error occurred during minimizationIOException
- If an error occurred while retrieving the source mappublic String minimizeJS(String code, String location, String sourceMapKey, Long lastModified) throws IOException, ProcessingException
code
- The JS codelocation
- The JS locationsourceMapKey
- The key to store the source map in cache. Can be null to prevent source map generationlastModified
- The last modified date of the code, used to assert validity of the source map cache. Can be nullProcessingException
- If an error occurred during minimizationIOException
- If an error occurred while retrieving the source mappublic String generateJSSourceMap(String code, String location, String sourceMapKey, Long lastModified) throws ProcessingException, IOException
code
- The JS codelocation
- The JS locationsourceMapKey
- The key to store the source map in cachelastModified
- The last modified date of the code, used to assert validity of the source map cacheProcessingException
- If an error occurred during minimizationIOException
- If an error occurred while retrieving the source mapprivate com.google.javascript.jscomp.Compiler _minimizeJS(String code, String fileName, boolean withSourceMap) throws ProcessingException
ProcessingException
protected void addSourceMap(com.google.debugging.sourcemap.SourceMapGeneratorV3 sourceMapGenerator, int lineCount, String fileContent, String fileUri, String sourceMapUri)
AbstractMinimizeManager
addSourceMap
in class AbstractMinimizeManager
sourceMapGenerator
- The aggregator helperlineCount
- The current line countfileContent
- The content of the filefileUri
- The uri of the filesourceMapUri
- The sourceMappingURL found at the end of the file contentprotected String getMinimizedContent(String uri, String nestedParentFilesName)
AbstractMinimizeManager
getMinimizedContent
in class AbstractMinimizeManager
uri
- The urinestedParentFilesName
- The parents file name, can be an empty string if there are no parentsprotected boolean isSourceMappingURLLine(String line)
AbstractMinimizeManager
isSourceMappingURLLine
in class AbstractMinimizeManager
line
- The lineprotected String getSourceMappingURL(String line)
AbstractMinimizeManager
getSourceMappingURL
in class AbstractMinimizeManager
line
- The lineprotected String removeSourceMappingURLLine(String content)
AbstractMinimizeManager
removeSourceMappingURLLine
in class AbstractMinimizeManager
content
- The contentprotected String formatSourceMappingURL(String sourceMapName)
AbstractMinimizeManager
formatSourceMappingURL
in class AbstractMinimizeManager
sourceMapName
- The map name