mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-02 19:22:58 +00:00
Fixed various press bugs.
This commit is contained in:
1 parent
26b7d5fa8b
commit
a45869be49
1 file changed
+31
-24
+31
-24
@@ -1,6 +1,6 @@
|
||||
import <Foundation/Foundation.j>
|
||||
@import <Foundation/Foundation.j>
|
||||
|
||||
import "objj-analysis-tools.j"
|
||||
@import "objj-analysis-tools.j"
|
||||
|
||||
var defaultMain = "main.j",
|
||||
defaultFrameworks = "Frameworks";
|
||||
@@ -107,6 +107,7 @@ function main()
|
||||
{
|
||||
var xmlOutput = new Packages.java.io.ByteArrayOutputStream();
|
||||
outputTransformer(xmlOutput, aResponse.xml, "UTF-8");
|
||||
//__fakeResponse.xml = String(xmlOutput.toString());
|
||||
__fakeResponse.text = CPPropertyListCreate280NorthData(CPPropertyListCreateFromXMLData({ string:String(xmlOutput.toString())})).string;
|
||||
//CPLog.trace("SERIALIZED: " + __fakeResponse.xml.substring(0,100));
|
||||
}
|
||||
@@ -117,13 +118,15 @@ function main()
|
||||
}
|
||||
|
||||
// phase 1: get global defines
|
||||
CPLog.info("Loading application...");
|
||||
CPLog.error("PHASE 1: Loading application...");
|
||||
|
||||
var globals = findGlobalDefines(cx, scope, mainPath, evaledFragments);
|
||||
|
||||
// coalesce the results
|
||||
var dependencies = coalesceGlobalDefines(globals);
|
||||
|
||||
// phase 2: walk the dependency tree (both imports and references) to determine exactly which files need to be included
|
||||
CPLog.error("PHASE 2: Walk dependency tree...");
|
||||
|
||||
var requiredFiles = {};
|
||||
|
||||
@@ -191,7 +194,7 @@ function main()
|
||||
if (flatten)
|
||||
{
|
||||
// phase 3a: build single Application.js file (and modified index.html)
|
||||
CPLog.info("Flattening...");
|
||||
CPLog.error("PHASE 3a: Flattening...");
|
||||
|
||||
var applicationJS = [],
|
||||
indexHTML = readFile(rootDirectory + "/index.html");
|
||||
@@ -208,6 +211,7 @@ function main()
|
||||
var data = new objj_data();
|
||||
data.string = aResponse.text;
|
||||
bundle.info = CPPropertyListCreateFrom280NorthData(data);
|
||||
//bundle.info = CPPropertyListCreateFromXMLData({ string : aResponse.xml });
|
||||
}
|
||||
else
|
||||
bundle.info = new objj_dictionary();
|
||||
@@ -244,18 +248,11 @@ function main()
|
||||
window.attachEvent('onload', main);"
|
||||
);
|
||||
|
||||
// comment out any OBJJ_MAIN_FILE defintions or objj_import() calls
|
||||
indexHTML = indexHTML.replace(/(\bOBJJ_MAIN_FILE\s*=|\bobjj_import\s*\()/g, '//$&');
|
||||
|
||||
// do a little regex magic to remove the objj_import and put in a script tag for Application.js
|
||||
var matches = indexHTML.match(/<script[^>]*>(?:.|\n)*?<\/script>/g);
|
||||
for (var i = 0; i < matches.length; i++)
|
||||
{
|
||||
if (/\bobjj_import\s*\(/.test(matches[i]))
|
||||
{
|
||||
CPLog.warn("Replacing objj_import with script tag.");
|
||||
var replacement = '<script src = "Application.js" type = "text/javascript"></script>\n' + matches[i].replace("objj_import", "//objj_import");
|
||||
indexHTML = indexHTML.replace(matches[i], replacement);
|
||||
}
|
||||
}
|
||||
// add a script tag for Application.js at the very end of the <head> block
|
||||
indexHTML = indexHTML.replace(/([ \t]*)(<\/head>)/, '$1 <script src = "Application.js" type = "text/javascript"></script>\n$1$2');
|
||||
|
||||
// output Application.js and index.html
|
||||
outputFiles[rootDirectory + "/Application.js"] = applicationJS.join("\n");
|
||||
@@ -264,6 +261,7 @@ function main()
|
||||
else
|
||||
{
|
||||
// phase 3b: rebuild .sj files with correct imports, copy .j files
|
||||
CPLog.error("PHASE 3b: Rebuild .sj");
|
||||
|
||||
var bundles = {};
|
||||
|
||||
@@ -356,30 +354,39 @@ function main()
|
||||
}
|
||||
|
||||
// phase 3.5: fix bundle plists
|
||||
CPLog.error("PHASE 3.5: fix bundle plists");
|
||||
|
||||
for (var path in bundles)
|
||||
{
|
||||
var bundle = bundles[path];
|
||||
CPLog.info("Bundle: " + path);
|
||||
|
||||
var dict = file.bundle.info,
|
||||
var directory = dirname(path),
|
||||
dict = bundles[path].info,
|
||||
replacedFiles = [dict objectForKey:"CPBundleReplacedFiles"];
|
||||
|
||||
if (replacedFiles)
|
||||
{
|
||||
var newReplacedFiles = [];
|
||||
[dict setObject:newReplacedFiles forKey:"CPBundleReplacedFiles"];
|
||||
|
||||
for (var i = 0; i < replacedFiles.length; i++)
|
||||
{
|
||||
if (!requiredFiles[replacedFiles[i]])
|
||||
var replacedFilePath = directory + "/" + replacedFiles[i]
|
||||
if (!requiredFiles[replacedFilePath])
|
||||
{
|
||||
CPLog.info("Removing: " + replacedFiles[i]);
|
||||
replacedFiles.splice(i, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//CPLog.info("Keeping: " + replacedFiles[i]);
|
||||
newReplacedFiles.push(replacedFiles[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outputFiles[path] = CPPropertyListCreateXMLData(bundle.info).string;
|
||||
outputFiles[path] = CPPropertyListCreateXMLData(dict).string;
|
||||
}
|
||||
}
|
||||
|
||||
// phase 4: copy everything and write out the new files
|
||||
CPLog.error("PHASE 4: copy to output");
|
||||
|
||||
var rootDirectoryFile = new Packages.java.io.File(rootDirectory),
|
||||
outputDirectoryFile = new Packages.java.io.File(outputDirectory);
|
||||
@@ -543,7 +550,7 @@ function outputTransformer(os, document, encoding, standalone)
|
||||
if (standalone)
|
||||
serializer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.STANDALONE, (standalone ? "yes" : "no"));
|
||||
|
||||
serializer.transform(domSource, streamResult);
|
||||
String(serializer.transform(domSource, streamResult));
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in new issue
Block a user