From f7014f14dfe48b26600897af856db815e643b784 Mon Sep 17 00:00:00 2001 From: Ian Clelland Date: Tue, 9 Jul 2013 16:45:25 -0400 Subject: [PATCH] Update cordova.js -- includes new Binary bridge, supporting Android 4.0 --- framework/assets/www/cordova.js | 388 ++++++++++++++++++-------------- 1 file changed, 224 insertions(+), 164 deletions(-) diff --git a/framework/assets/www/cordova.js b/framework/assets/www/cordova.js index a7a1b386..e13278e8 100644 --- a/framework/assets/www/cordova.js +++ b/framework/assets/www/cordova.js @@ -1,5 +1,5 @@ // Platform: android -// 2.7.0rc1-154-g98a62ff +// 2.7.0rc1-161-g0c80083 /* 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.7.0rc1-154-g98a62ff'; +var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-161-g0c80083'; // file: lib/scripts/require.js var require, @@ -393,6 +393,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> 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 @@ -799,6 +855,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, @@ -837,7 +894,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]); } } @@ -1047,6 +1104,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; @@ -1065,12 +1126,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); + // + 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]; @@ -2160,6 +2225,155 @@ var modulemapper = require('cordova/modulemapper'); modulemapper.clobbers('cordova/plugin/logger', 'cordova.logger'); +}); + +// file: lib/common/pluginloader.js +define("cordova/pluginloader", function(require, exports, module) { + +var channel = require('cordova/channel'); +var modulemapper = require('cordova/modulemapper'); + +var scriptCounter = 0; +var moduleList = null; + +function scriptLoadedCallback() { + scriptCounter--; + if (scriptCounter === 0) { + onScriptLoadingComplete(); + } +} + +// Helper function to inject a