A few more reports on this version:
Overall, it is triply faster than v0.7, with the support of resources and plists, the editor does not hang with a big plist anymore. It’s more responsive when saving scenes and scripts.
Got the following error when trying on simulator:
Simulator .CocosCreator/simulator/mac/Simulator.app/Contents/Resources/src/project.dev.js:16:ReferenceError: navigator is not defined
Also, since we’re using API with authentication and could not find a way to add authentication headers and payload to an XMLRequest using cc.loader so we made an extension of it, could you see if it benefits to add similar codes for others, if they would need headers and payload.
cc.loader.loadTxtWithHeaders = function (url, cb, headers) {
if (!cc._isNodeJs) {
var xhr = cc.loader.getXMLHttpRequest(),
errInfo = "load " + url + " failed!";
xhr.open("GET", url, true);
for (var key in headers) {
xhr.setRequestHeader(key, headers[key]);
}
if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) {
// IE-specific logic here
xhr.setRequestHeader("Accept-Charset", "utf-8");
xhr.onreadystatechange = function () {
if(xhr.readyState === 4)
xhr.status === 200 ? cb(null, xhr.responseText) : cb({status:xhr.status, errorMessage:errInfo}, null);
};
} else {
if (xhr.overrideMimeType) xhr.overrideMimeType("text\/plain; charset=utf-8");
xhr.onload = function () {
if(xhr.readyState === 4)
xhr.status === 200 ? cb(null, xhr.responseText) : cb({status:xhr.status, errorMessage:errInfo}, null);
};
xhr.onerror = function(){
cb({status:xhr.status, errorMessage:errInfo}, null);
};
}
xhr.send(null);
} else {
var fs = require("fs");
fs.readFile(url, function (err, data) {
err ? cb(err) : cb(null, data.toString());
});
}
};
cc.loader.loadTxtSyncWithHeaders = function (url, headers) {
if (!cc._isNodeJs) {
var xhr = cc.loader.getXMLHttpRequest();
xhr.open("GET", url, false);
for (var key in headers) {
xhr.setRequestHeader(key, headers[key]);
}
if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) {
// IE-specific logic here
xhr.setRequestHeader("Accept-Charset", "utf-8");
} else {
if (xhr.overrideMimeType) xhr.overrideMimeType("text\/plain; charset=utf-8");
}
xhr.send(null);
if (!xhr.readyState === 4 || xhr.status !== 200) {
return null;
}
return xhr.responseText;
} else {
var fs = require("fs");
return fs.readFileSync(url).toString();
}
};
cc.loader.loadJsonWithHeaders = function (url, cb, headers, isSync) {
isSync = isSync || false;
if (isSync) {
var text = cc.loader.loadTxtSyncWithHeaders(url, headers).replace(/^\)]}'/, '');
cb(null, JSON.parse(text));
} else {
cc.loader.loadTxtWithHeaders(url, function (err, txt) {
if (err) {
cb(err);
}
else {
try {
var text = txt.replace(/^\)]}'/, '');
var result = JSON.parse(text);
}
catch (e) {
throw new Error("parse json [" + url + "] failed : " + e);
return;
}
cb(null, result);
}
}, headers);
}
};