Permalink
Browse files

Version 0.3.8

  • Loading branch information...
1 parent d73fda4 commit b5a2f7f0e7199dc2848ae597296459b5276b88f7 @rbackhouse rbackhouse committed Aug 12, 2012
Showing with 42 additions and 11 deletions.
  1. +1 −1 org.dojotoolkit.compressor.shrinksafe/META-INF/MANIFEST.MF
  2. BIN ...otoolkit.compressor.shrinksafe/org/dojotoolkit/compressor/shrinksafe/ShrinksafeJSCompressor.class
  3. +5 −1 ...olkit.compressor.shrinksafe/src/org/dojotoolkit/compressor/shrinksafe/ShrinksafeJSCompressor.java
  4. +1 −1 org.dojotoolkit.compressor/META-INF/MANIFEST.MF
  5. BIN org.dojotoolkit.compressor/org/dojotoolkit/compressor/JSCompressor.class
  6. BIN org.dojotoolkit.compressor/org/dojotoolkit/compressor/JSCompressorContentFilter.class
  7. +7 −1 org.dojotoolkit.compressor/src/org/dojotoolkit/compressor/JSCompressor.java
  8. +1 −1 org.dojotoolkit.compressor/src/org/dojotoolkit/compressor/JSCompressorContentFilter.java
  9. +1 −1 org.dojotoolkit.optimizer.amd/META-INF/MANIFEST.MF
  10. +5 −1 org.dojotoolkit.optimizer.amd/loader/amd/zazl.js
  11. BIN org.dojotoolkit.optimizer.servlet/org/dojotoolkit/optimizer/servlet/HTMLParser$HTMLWriter.class
  12. BIN org.dojotoolkit.optimizer.servlet/org/dojotoolkit/optimizer/servlet/HTMLParser.class
  13. BIN org.dojotoolkit.optimizer.servlet/org/dojotoolkit/optimizer/servlet/RhinoASTScriptAnalyzer.class
  14. BIN ...rg/dojotoolkit/optimizer/servlet/osgi/ZazlServicesTracker$JSCompressorFactoryServiceTracker.class
  15. BIN ...org/dojotoolkit/optimizer/servlet/osgi/ZazlServicesTracker$JSOptimizerFactoryServiceTracker.class
  16. BIN ...ptimizer.servlet/org/dojotoolkit/optimizer/servlet/osgi/ZazlServicesTracker$ResourceServlet.class
  17. +5 −2 org.dojotoolkit.optimizer.servlet/src/org/dojotoolkit/optimizer/servlet/HTMLParser.java
  18. +14 −2 org.dojotoolkit.optimizer.servlet/src/org/dojotoolkit/optimizer/servlet/RhinoASTScriptAnalyzer.java
  19. +2 −0 ...dojotoolkit.optimizer.servlet/src/org/dojotoolkit/optimizer/servlet/osgi/ZazlServicesTracker.java
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Shrinksafe
Bundle-SymbolicName: org.dojotoolkit.compressor.shrinksafe
-Bundle-Version: 0.3.2
+Bundle-Version: 0.3.8
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: org.dojotoolkit.compressor,
org.dojotoolkit.server.util.resource,
@@ -19,7 +19,7 @@
public ShrinksafeJSCompressor(ResourceLoader resourceLoader) {}
- public String compress(String src) throws IOException {
+ public String compress(String path, String src) throws IOException {
long start = System.currentTimeMillis();
Context ctx = null;
try {
@@ -33,4 +33,8 @@ public String compress(String src) throws IOException {
Context.exit();
}
}
+
+ public String getSourceMap(String path) {
+ throw new UnsupportedOperationException();
+ }
}
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Compressor
Bundle-SymbolicName: org.dojotoolkit.compressor
-Bundle-Version: 0.3.2
+Bundle-Version: 0.3.8
Import-Package: org.dojotoolkit.server.util.resource,
org.osgi.framework;version="1.3.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
@@ -13,9 +13,15 @@
*/
public interface JSCompressor {
/**
+ * @param path String value containing the path to the javascript source
* @param src String value containing the javascript source
* @return String containing compressed javascript source
* @throws IOException
*/
- String compress(String src) throws IOException;
+ String compress(String path, String src) throws IOException;
+ /**
+ * @param path String value containing the path to the javascript source
+ * @return String containing source map for the compressed javascript source
+ */
+ String getSourceMap(String path);
}
@@ -35,7 +35,7 @@ public JSCompressorContentFilter(JSCompressorFactory jsCompressorFactory, Resour
protected String _runFilter(String content, String path) {
if (doCompress(path)) {
try {
- return jsCompressor.compress(content);
+ return jsCompressor.compress(path, content);
} catch (IOException e) {
logger.logp(Level.SEVERE, getClass().getName(), "_runFilter", "Unable to compress ["+path+"]", e);
return content;
@@ -2,4 +2,4 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: AMD Optimizer
Bundle-SymbolicName: org.dojotoolkit.optimizer.amd;singleton:=true
-Bundle-Version: 0.3.7
+Bundle-Version: 0.3.8
@@ -337,7 +337,10 @@ var define;
}
};
req.toUrl = function(moduleResource) {
+ var savedStack = moduleStack;
+ moduleStack = [id];
var url = _idToUrl(_expand(moduleResource));
+ moduleStack = savedStack;
return url;
};
req.defined = function(moduleName) {
@@ -568,6 +571,7 @@ var define;
var resolvedId = _idToUrl(id);
var cacheValue = precache[id];
cache[resolvedId] = cacheValue;
+ cache["url:"+resolvedId] = cacheValue;
}
precache = {};
};
@@ -673,7 +677,7 @@ var define;
}
cbiterate(exports, itr);
} else {
- delete cblist[mid];
+ cblist[mid] = [];
}
};
for (mid in cblist) {
@@ -50,6 +50,7 @@
private Locale locale = null;
private String path = null;
private String contextRoot = null;
+ private Map<String, Object> config = null;
public HTMLParser(java.io.Writer out,
String encoding,
@@ -129,13 +130,15 @@ public void endElement(QName element, Augmentations augs) throws XNIException {
}
@SuppressWarnings("unchecked")
- private static String analyzeScript(String scriptContents, ResourceLoader resourceLoader, RhinoClassLoader rhinoClassLoader, JSURLGenerator urlGenerator) {
+ private String analyzeScript(String scriptContents, ResourceLoader resourceLoader, RhinoClassLoader rhinoClassLoader, JSURLGenerator urlGenerator) {
String url = null;
ScriptAnalyzer scriptAnalyzer = new RhinoASTScriptAnalyzer(resourceLoader, rhinoClassLoader);
try {
Map<String, Object> results = scriptAnalyzer.analyze(scriptContents);
List<String> depList = (List<String>)results.get("dependencies");
- Map<String, Object> config = (Map<String, Object>)results.get("config");
+ if (results.containsKey("config")) {
+ config = (Map<String, Object>)results.get("config");
+ }
if (depList.size() > 0) {
String[] deps = new String[depList.size()];
deps = depList.toArray(deps);
@@ -32,6 +32,8 @@
import org.mozilla.javascript.ast.ObjectLiteral;
import org.mozilla.javascript.ast.ObjectProperty;
import org.mozilla.javascript.ast.StringLiteral;
+import org.mozilla.javascript.ast.VariableDeclaration;
+import org.mozilla.javascript.ast.VariableInitializer;
public class RhinoASTScriptAnalyzer extends ScriptAnalyzer implements NodeVisitor {
private static Logger logger = Logger.getLogger("org.dojotoolkit.optimizer.servlet");
@@ -68,14 +70,24 @@ public RhinoASTScriptAnalyzer(ResourceLoader resourceLoader, RhinoClassLoader rh
}
public boolean visit(AstNode astNode) {
- if (astNode instanceof FunctionCall) {
+ if (astNode instanceof VariableDeclaration) {
+ VariableDeclaration vd = (VariableDeclaration)astNode;
+ for (VariableInitializer vi : vd.getVariables()) {
+ if (vi.getTarget().getType() == Token.NAME) {
+ Name name = (Name)vi.getTarget();
+ if (name.getIdentifier().equals("zazlConfig") && vi.getInitializer() instanceof ObjectLiteral) {
+ results.put("config", parseObject((ObjectLiteral)vi.getInitializer()));
+ }
+ }
+ }
+ } else if (astNode instanceof FunctionCall) {
FunctionCall functionCall = (FunctionCall)astNode;
AstNode target = functionCall.getTarget();
String callName = "";
if (target instanceof Name) {
callName = ((Name)target).getIdentifier();
}
- if (callName.equals("zazl")) {
+ if (callName.equals("zazl") || callName.equals("require")) {
List<AstNode> args = functionCall.getArguments();
if (args.get(0) instanceof ArrayLiteral) {
results.put("dependencies", getDependencies((ArrayLiteral)args.get(0)));
@@ -223,6 +223,8 @@ public Object addingService(ServiceReference reference) {
} else {
dojoServiceId = "RhinoUglifyJSCompressor";
}
+ } else {
+ dojoServiceId = compressorType;
}
}
if (dojoServiceId != null && reference.getProperty("dojoServiceId").equals(dojoServiceId)) {

0 comments on commit b5a2f7f

Please sign in to comment.