Update JS snapshot and VERSION to 2.9.1-dev

This commit is contained in:
Andrew Grieve 2013-10-22 15:45:38 -04:00
parent a88b8de820
commit bdecdea568
3 changed files with 372 additions and 293 deletions

View File

@ -1 +1 @@
2.9.0
2.9.1-dev

View File

@ -1,5 +1,5 @@
// Platform: android
// 2.9.0-0-g83dc4bd
// 2.9.1-dev-af4bcf4
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@ -19,7 +19,7 @@
under the License.
*/
;(function() {
var CORDOVA_JS_BUILD_LABEL = '2.9.0-0-g83dc4bd';
var CORDOVA_JS_BUILD_LABEL = '2.9.1-dev-af4bcf4';
// file: lib/scripts/require.js
var require,
@ -100,6 +100,7 @@ define("cordova", function(require, exports, module) {
var channel = require('cordova/channel');
var platform = require('cordova/platform');
/**
* Listen for DOMContentLoaded and notify our channel subscribers.
@ -182,10 +183,18 @@ if(typeof window.console === "undefined") {
log:function(){}
};
}
// there are places in the framework where we call `warn` also, so we should make sure it exists
if(typeof window.console.warn === "undefined") {
window.console.warn = function(msg) {
this.log("warn: " + msg);
};
}
var cordova = {
define:define,
require:require,
version:CORDOVA_JS_BUILD_LABEL,
platformId:platform.id,
/**
* Methods to add/remove your own addEventListener hijacking on document + window.
*/
@ -376,7 +385,7 @@ function checkArgs(spec, functionName, args, opt_callee) {
if (errMsg) {
errMsg += ', but got ' + typeName + '.';
errMsg = 'Wrong type for parameter "' + extractParamName(opt_callee || args.callee, i) + '" of ' + functionName + ': ' + errMsg;
// Don't log when running jake test.
// Don't log when running unit tests.
if (typeof jasmine == 'undefined') {
console.error(errMsg);
}
@ -393,6 +402,62 @@ moduleExports.getValue = getValue;
moduleExports.enableChecks = true;
});
// file: lib/common/base64.js
define("cordova/base64", function(require, exports, module) {
var base64 = exports;
base64.fromArrayBuffer = function(arrayBuffer) {
var array = new Uint8Array(arrayBuffer);
return uint8ToBase64(array);
};
//------------------------------------------------------------------------------
/* This code is based on the performance tests at http://jsperf.com/b64tests
* This 12-bit-at-a-time algorithm was the best performing version on all
* platforms tested.
*/
var b64_6bit = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var b64_12bit;
var b64_12bitTable = function() {
b64_12bit = [];
for (var i=0; i<64; i++) {
for (var j=0; j<64; j++) {
b64_12bit[i*64+j] = b64_6bit[i] + b64_6bit[j];
}
}
b64_12bitTable = function() { return b64_12bit; };
return b64_12bit;
};
function uint8ToBase64(rawData) {
var numBytes = rawData.byteLength;
var output="";
var segment;
var table = b64_12bitTable();
for (var i=0;i<numBytes-2;i+=3) {
segment = (rawData[i] << 16) + (rawData[i+1] << 8) + rawData[i+2];
output += table[segment >> 12];
output += table[segment & 0xfff];
}
if (numBytes - i == 2) {
segment = (rawData[i] << 16) + (rawData[i+1] << 8);
output += table[segment >> 12];
output += b64_6bit[(segment & 0xfff) >> 6];
output += '=';
} else if (numBytes - i == 1) {
segment = (rawData[i] << 16);
output += table[segment >> 12];
output += '==';
}
return output;
}
});
// file: lib/common/builder.js
@ -808,6 +873,7 @@ define("cordova/exec", function(require, exports, module) {
var cordova = require('cordova'),
nativeApiProvider = require('cordova/plugin/android/nativeapiprovider'),
utils = require('cordova/utils'),
base64 = require('cordova/base64'),
jsToNativeModes = {
PROMPT: 0,
JS_OBJECT: 1,
@ -846,7 +912,7 @@ function androidExec(success, fail, service, action, args) {
// Process any ArrayBuffers in the args into a string.
for (var i = 0; i < args.length; i++) {
if (utils.typeName(args[i]) == 'ArrayBuffer') {
args[i] = window.btoa(String.fromCharCode.apply(null, new Uint8Array(args[i])));
args[i] = base64.fromArrayBuffer(args[i]);
}
}
@ -874,8 +940,12 @@ function androidExec(success, fail, service, action, args) {
}
}
function pollOnce() {
var msg = nativeApiProvider.get().retrieveJsMessages();
function pollOnceFromOnlineEvent() {
pollOnce(true);
}
function pollOnce(opt_fromOnlineEvent) {
var msg = nativeApiProvider.get().retrieveJsMessages(!!opt_fromOnlineEvent);
androidExec.processMessages(msg);
}
@ -894,8 +964,8 @@ function hookOnlineApis() {
// It currently fires them only on document though, so we bridge them
// to window here (while first listening for exec()-releated online/offline
// events).
window.addEventListener('online', pollOnce, false);
window.addEventListener('offline', pollOnce, false);
window.addEventListener('online', pollOnceFromOnlineEvent, false);
window.addEventListener('offline', pollOnceFromOnlineEvent, false);
cordova.addWindowEventHandler('online');
cordova.addWindowEventHandler('offline');
document.addEventListener('online', proxyEvent, false);
@ -1056,6 +1126,10 @@ exports.defaults = function(moduleName, symbolPath, opt_deprecationMessage) {
addEntry('d', moduleName, symbolPath, opt_deprecationMessage);
};
exports.runs = function(moduleName) {
addEntry('r', moduleName, null);
};
function prepareNamespace(symbolPath, context) {
if (!symbolPath) {
return context;
@ -1074,12 +1148,16 @@ exports.mapModules = function(context) {
for (var i = 0, len = symbolList.length; i < len; i += 3) {
var strategy = symbolList[i];
var moduleName = symbolList[i + 1];
var module = require(moduleName);
// <runs/>
if (strategy == 'r') {
continue;
}
var symbolPath = symbolList[i + 2];
var lastDot = symbolPath.lastIndexOf('.');
var namespace = symbolPath.substr(0, lastDot);
var lastName = symbolPath.substr(lastDot + 1);
var module = require(moduleName);
var deprecationMsg = symbolPath in deprecationMap ? 'Access made to deprecated symbol: ' + symbolPath + '. ' + deprecationMsg : null;
var parentObj = prepareNamespace(namespace, context);
var target = parentObj[lastName];
@ -1928,6 +2006,7 @@ var exec = require('cordova/exec'),
*/
function DirectoryReader(path) {
this.path = path || null;
this.hasReadEntries = false;
}
/**
@ -1937,6 +2016,12 @@ function DirectoryReader(path) {
* @param {Function} errorCallback is called with a FileError
*/
DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
// If we've already read and passed on this directory's entries, return an empty list.
if (this.hasReadEntries) {
successCallback([]);
return;
}
var reader = this;
var win = typeof successCallback !== 'function' ? null : function(result) {
var retVal = [];
for (var i=0; i<result.length; i++) {
@ -1953,6 +2038,7 @@ DirectoryReader.prototype.readEntries = function(successCallback, errorCallback)
entry.fullPath = result[i].fullPath;
retVal.push(entry);
}
reader.hasReadEntries = true;
successCallback(retVal);
};
var fail = typeof errorCallback !== 'function' ? null : function(code) {
@ -3063,26 +3149,27 @@ FileWriter.prototype.abort = function() {
*/
FileWriter.prototype.write = function(data) {
var isBinary = false;
// If we don't have Blob or ArrayBuffer support, don't bother.
if (typeof window.Blob !== 'undefined' && typeof window.ArrayBuffer !== 'undefined') {
var that=this;
var supportsBinary = (typeof window.Blob !== 'undefined' && typeof window.ArrayBuffer !== 'undefined');
var isBinary;
// Check to see if the incoming data is a blob
if (data instanceof Blob) {
var that=this;
if (data instanceof File || (supportsBinary && data instanceof Blob)) {
var fileReader = new FileReader();
fileReader.onload = function() {
// Call this method again, with the arraybuffer as argument
FileWriter.prototype.write.call(that, this.result);
};
if (supportsBinary) {
fileReader.readAsArrayBuffer(data);
} else {
fileReader.readAsText(data);
}
return;
}
// Mark data type for safer transport over the binary bridge
isBinary = (data instanceof ArrayBuffer);
}
isBinary = supportsBinary && (data instanceof ArrayBuffer);
// Throw an exception if we are already writing a file
if (this.readyState === FileWriter.WRITING) {
@ -3316,6 +3403,7 @@ define("cordova/plugin/InAppBrowser", function(require, exports, module) {
var exec = require('cordova/exec');
var channel = require('cordova/channel');
var modulemapper = require('cordova/modulemapper');
var urlutil = require('cordova/urlutil');
function InAppBrowser() {
this.channels = {
@ -3324,6 +3412,7 @@ function InAppBrowser() {
'loaderror' : channel.create('loaderror'),
'exit' : channel.create('exit')
};
this._alive = true;
}
InAppBrowser.prototype = {
@ -3333,7 +3422,10 @@ InAppBrowser.prototype = {
}
},
close: function (eventname) {
if (this._alive) {
this._alive = false;
exec(null, null, "InAppBrowser", "close", []);
}
},
show: function (eventname) {
exec(null, null, "InAppBrowser", "show", []);
@ -3371,17 +3463,18 @@ InAppBrowser.prototype = {
};
module.exports = function(strUrl, strWindowName, strWindowFeatures) {
var iab = new InAppBrowser();
var cb = function(eventname) {
iab._eventHandler(eventname);
};
// Don't catch calls that write to existing frames (e.g. named iframes).
if (window.frames && window.frames[strWindowName]) {
var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
return origOpenFunc.apply(window, arguments);
}
strUrl = urlutil.makeAbsolute(strUrl);
var iab = new InAppBrowser();
var cb = function(eventname) {
iab._eventHandler(eventname);
};
exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
return iab;
};
@ -4186,8 +4279,8 @@ module.exports = {
setNativeToJsBridgeMode: function(value) {
prompt(value, 'gap_bridge_mode:');
},
retrieveJsMessages: function() {
return prompt('', 'gap_poll:');
retrieveJsMessages: function(fromOnlineEvent) {
return prompt(+fromOnlineEvent, 'gap_poll:');
}
};
@ -6515,6 +6608,127 @@ var modulemapper = require('cordova/modulemapper');
modulemapper.clobbers('cordova/plugin/splashscreen', 'navigator.splashscreen');
});
// file: lib/common/pluginloader.js
define("cordova/pluginloader", function(require, exports, module) {
var channel = require('cordova/channel');
var modulemapper = require('cordova/modulemapper');
// Helper function to inject a <script> tag.
function injectScript(url, onload, onerror) {
var script = document.createElement("script");
// onload fires even when script fails loads with an error.
script.onload = onload;
script.onerror = onerror || onload;
script.src = url;
document.head.appendChild(script);
}
function onScriptLoadingComplete(moduleList) {
// Loop through all the plugins and then through their clobbers and merges.
for (var i = 0, module; module = moduleList[i]; i++) {
if (module) {
try {
if (module.clobbers && module.clobbers.length) {
for (var j = 0; j < module.clobbers.length; j++) {
modulemapper.clobbers(module.id, module.clobbers[j]);
}
}
if (module.merges && module.merges.length) {
for (var k = 0; k < module.merges.length; k++) {
modulemapper.merges(module.id, module.merges[k]);
}
}
// Finally, if runs is truthy we want to simply require() the module.
// This can be skipped if it had any merges or clobbers, though,
// since the mapper will already have required the module.
if (module.runs && !(module.clobbers && module.clobbers.length) && !(module.merges && module.merges.length)) {
modulemapper.runs(module.id);
}
}
catch(err) {
// error with module, most likely clobbers, should we continue?
}
}
}
finishPluginLoading();
}
// Called when:
// * There are plugins defined and all plugins are finished loading.
// * There are no plugins to load.
function finishPluginLoading() {
channel.onPluginsReady.fire();
}
// Handler for the cordova_plugins.js content.
// See plugman's plugin_loader.js for the details of this object.
// This function is only called if the really is a plugins array that isn't empty.
// Otherwise the onerror response handler will just call finishPluginLoading().
function handlePluginsObject(path, moduleList) {
// Now inject the scripts.
var scriptCounter = moduleList.length;
if (!scriptCounter) {
finishPluginLoading();
return;
}
function scriptLoadedCallback() {
if (!--scriptCounter) {
onScriptLoadingComplete(moduleList);
}
}
for (var i = 0; i < moduleList.length; i++) {
injectScript(path + moduleList[i].file, scriptLoadedCallback);
}
}
function injectPluginScript(pathPrefix) {
injectScript(pathPrefix + 'cordova_plugins.js', function(){
try {
var moduleList = require("cordova/plugin_list");
handlePluginsObject(pathPrefix, moduleList);
} catch (e) {
// Error loading cordova_plugins.js, file not found or something
// this is an acceptable error, pre-3.0.0, so we just move on.
finishPluginLoading();
}
},finishPluginLoading); // also, add script load error handler for file not found
}
function findCordovaPath() {
var path = null;
var scripts = document.getElementsByTagName('script');
var term = 'cordova.js';
for (var n = scripts.length-1; n>-1; n--) {
var src = scripts[n].src;
if (src.indexOf(term) == (src.length - term.length)) {
path = src.substring(0, src.length - term.length);
break;
}
}
return path;
}
// Tries to load all plugins' js-modules.
// This is an async process, but onDeviceReady is blocked on onPluginsReady.
// onPluginsReady is fired when there are no plugins to load, or they are all done.
exports.load = function() {
var pathPrefix = findCordovaPath();
if (pathPrefix === null) {
console.log('Could not find cordova.js script tag. Plugin loading may fail.');
pathPrefix = '';
}
injectPluginScript(pathPrefix);
};
});
// file: lib/common/symbols.js
@ -6530,6 +6744,23 @@ modulemapper.clobbers('cordova/exec', 'Cordova.exec');
});
// file: lib/common/urlutil.js
define("cordova/urlutil", function(require, exports, module) {
var urlutil = exports;
var anchorEl = document.createElement('a');
/**
* For already absolute URLs, returns what is passed in.
* For relative URLs, converts them to absolute ones.
*/
urlutil.makeAbsolute = function(url) {
anchorEl.href = url;
return anchorEl.href;
};
});
// file: lib/common/utils.js
define("cordova/utils", function(require, exports, module) {
@ -6710,6 +6941,8 @@ window.cordova = require('cordova');
context._cordovaJsLoaded = true;
var channel = require('cordova/channel');
var pluginloader = require('cordova/pluginloader');
var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
function logUnfiredChannels(arr) {
@ -6778,170 +7011,16 @@ window.cordova = require('cordova');
}, platformInitChannelsArray);
// Don't attempt to load when running unit tests.
if (typeof XMLHttpRequest != 'undefined') {
pluginloader.load();
}
}(window));
// file: lib/scripts/bootstrap-android.js
// Tell the native code that a page change has occurred.
require('cordova/exec')(null, null, 'PluginManager', 'startup', []);
require('cordova/channel').onNativeReady.fire();
// file: lib/scripts/plugin_loader.js
// Tries to load all plugins' js-modules.
// This is an async process, but onDeviceReady is blocked on onPluginsReady.
// onPluginsReady is fired when there are no plugins to load, or they are all done.
(function (context) {
// To be populated with the handler by handlePluginsObject.
var onScriptLoadingComplete;
var scriptCounter = 0;
function scriptLoadedCallback() {
scriptCounter--;
if (scriptCounter === 0) {
onScriptLoadingComplete && onScriptLoadingComplete();
}
}
function scriptErrorCallback(err) {
// Open Question: If a script path specified in cordova_plugins.js does not exist, do we fail for all?
// this is currently just continuing.
scriptCounter--;
if (scriptCounter === 0) {
onScriptLoadingComplete && onScriptLoadingComplete();
}
}
// Helper function to inject a <script> tag.
function injectScript(path) {
scriptCounter++;
var script = document.createElement("script");
script.onload = scriptLoadedCallback;
script.onerror = scriptErrorCallback;
script.src = path;
document.head.appendChild(script);
}
// Called when:
// * There are plugins defined and all plugins are finished loading.
// * There are no plugins to load.
function finishPluginLoading() {
context.cordova.require('cordova/channel').onPluginsReady.fire();
}
// Handler for the cordova_plugins.js content.
// See plugman's plugin_loader.js for the details of this object.
// This function is only called if the really is a plugins array that isn't empty.
// Otherwise the onerror response handler will just call finishPluginLoading().
function handlePluginsObject(modules, path) {
// First create the callback for when all plugins are loaded.
var mapper = context.cordova.require('cordova/modulemapper');
onScriptLoadingComplete = function() {
// Loop through all the plugins and then through their clobbers and merges.
for (var i = 0; i < modules.length; i++) {
var module = modules[i];
if (module) {
try {
if (module.clobbers && module.clobbers.length) {
for (var j = 0; j < module.clobbers.length; j++) {
mapper.clobbers(module.id, module.clobbers[j]);
}
}
if (module.merges && module.merges.length) {
for (var k = 0; k < module.merges.length; k++) {
mapper.merges(module.id, module.merges[k]);
}
}
// Finally, if runs is truthy we want to simply require() the module.
// This can be skipped if it had any merges or clobbers, though,
// since the mapper will already have required the module.
if (module.runs && !(module.clobbers && module.clobbers.length) && !(module.merges && module.merges.length)) {
context.cordova.require(module.id);
}
}
catch(err) {
// error with module, most likely clobbers, should we continue?
}
}
}
finishPluginLoading();
};
// Now inject the scripts.
for (var i = 0; i < modules.length; i++) {
injectScript(path + modules[i].file);
}
}
// Find the root of the app
var path = '';
var scripts = document.getElementsByTagName('script');
var term = 'cordova.js';
for (var n = scripts.length-1; n>-1; n--) {
var src = scripts[n].src;
if (src.indexOf(term) == (src.length - term.length)) {
path = src.substring(0, src.length - term.length);
break;
}
}
var plugins_json = path + 'cordova_plugins.json';
var plugins_js = path + 'cordova_plugins.js';
// One some phones (Windows) this xhr.open throws an Access Denied exception
// So lets keep trying, but with a script tag injection technique instead of XHR
var injectPluginScript = function injectPluginScript() {
try {
var script = document.createElement("script");
script.onload = function(){
var list = cordova.require("cordova/plugin_list");
handlePluginsObject(list,path);
};
script.onerror = function() {
// Error loading cordova_plugins.js, file not found or something
// this is an acceptable error, pre-3.0.0, so we just move on.
finishPluginLoading();
};
script.src = plugins_js;
document.head.appendChild(script);
} catch(err){
finishPluginLoading();
}
}
// Try to XHR the cordova_plugins.json file asynchronously.
var xhr = new XMLHttpRequest();
xhr.onload = function() {
// If the response is a JSON string which composes an array, call handlePluginsObject.
// If the request fails, or the response is not a JSON array, just call finishPluginLoading.
var obj;
try {
obj = (this.status == 0 || this.status == 200) && this.responseText && JSON.parse(this.responseText);
} catch (err) {
// obj will be undefined.
}
if (Array.isArray(obj) && obj.length > 0) {
handlePluginsObject(obj, path);
} else {
finishPluginLoading();
}
};
xhr.onerror = function() {
// In this case, the json file was not present, but XHR was allowed,
// so we should still try the script injection technique with the js file
// in case that is there.
injectPluginScript();
};
try { // we commented we were going to try, so let us actually try and catch
xhr.open('GET', plugins_json, true); // Async
xhr.send();
} catch(err){
injectPluginScript();
}
}(window));
})();

View File

@ -38,7 +38,7 @@ import android.telephony.TelephonyManager;
public class Device extends CordovaPlugin {
public static final String TAG = "Device";
public static String cordovaVersion = "2.9.0"; // Cordova version
public static String cordovaVersion = "2.9.1-dev"; // Cordova version
public static String platform = "Android"; // Device OS
public static String uuid; // Device UUID