You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/04/18 21:23:31 UTC
[1/2] ios commit: Update JS snapshot
Updated Branches:
refs/heads/master 75ed2bb89 -> cce2cdda0
Update JS snapshot
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/c8f31c34
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/c8f31c34
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/c8f31c34
Branch: refs/heads/master
Commit: c8f31c34f8b401f7b197113ee134541a685c172c
Parents: 75ed2bb
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Apr 18 15:13:39 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Apr 18 15:13:39 2013 -0400
----------------------------------------------------------------------
CordovaLib/cordova.ios.js | 226 +++++++++++++++++++++++-----------------
1 files changed, 132 insertions(+), 94 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/c8f31c34/CordovaLib/cordova.ios.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.ios.js b/CordovaLib/cordova.ios.js
index 6e559cc..d9a67bd 100644
--- a/CordovaLib/cordova.ios.js
+++ b/CordovaLib/cordova.ios.js
@@ -1,8 +1,8 @@
// Platform: ios
-// commit 57816c7dce8a955f8a018ddef4077564510de3ad
+// commit d0ffb852378ff018bac2f3b12c38098a19b8ce00
-// File generated at :: Thu Apr 11 2013 13:06:59 GMT-0700 (PDT)
+// File generated at :: Thu Apr 18 2013 15:10:54 GMT-0400 (EDT)
/*
Licensed to the Apache Software Foundation (ASF) under one
@@ -219,6 +219,10 @@ var cordova = {
}
else {
setTimeout(function() {
+ // Fire deviceready on listeners that were registered before cordova.js was loaded.
+ if (type == 'deviceready') {
+ document.dispatchEvent(evt);
+ }
documentEventHandlers[type].fire(evt);
}, 0);
}
@@ -742,6 +746,7 @@ channel.createSticky('onDestroy');
// Channels that must fire before "deviceready" is fired.
channel.waitForInitialization('onCordovaReady');
channel.waitForInitialization('onCordovaConnectionReady');
+channel.waitForInitialization('onDOMContentLoaded');
module.exports = channel;
@@ -4301,7 +4306,7 @@ console.debug = function() {
console.assert = function(expression) {
if (expression) return;
- var message = utils.vformat(arguments[1], [].slice.call(arguments, 2));
+ var message = logger.format.apply(logger.format, [].slice.call(arguments, 1));
console.log("ASSERT: " + message);
};
@@ -5554,10 +5559,10 @@ function logWithArgs(level, args) {
* Parameters passed after message are used applied to
* the message with utils.format()
*/
-logger.logLevel = function(level, message /* , ... */) {
+logger.logLevel = function(level /* , ... */) {
// format the message with the parameters
- var formatArgs = [].slice.call(arguments, 2);
- message = utils.vformat(message, formatArgs);
+ var formatArgs = [].slice.call(arguments, 1);
+ var message = logger.format.apply(logger.format, formatArgs);
if (LevelsMap[level] === null) {
throw new Error("invalid logging level: " + level);
@@ -5592,6 +5597,92 @@ logger.logLevel = function(level, message /* , ... */) {
}
};
+
+/**
+ * Formats a string and arguments following it ala console.log()
+ *
+ * Any remaining arguments will be appended to the formatted string.
+ *
+ * for rationale, see FireBug's Console API:
+ * http://getfirebug.com/wiki/index.php/Console_API
+ */
+logger.format = function(formatString, args) {
+ return __format(arguments[0], [].slice.call(arguments,1)).join(' ');
+};
+
+
+//------------------------------------------------------------------------------
+/**
+ * Formats a string and arguments following it ala vsprintf()
+ *
+ * format chars:
+ * %j - format arg as JSON
+ * %o - format arg as JSON
+ * %c - format arg as ''
+ * %% - replace with '%'
+ * any other char following % will format it's
+ * arg via toString().
+ *
+ * Returns an array containing the formatted string and any remaining
+ * arguments.
+ */
+function __format(formatString, args) {
+ if (formatString === null || formatString === undefined) return [""];
+ if (arguments.length == 1) return [formatString.toString()];
+
+ if (typeof formatString != "string")
+ formatString = formatString.toString();
+
+ var pattern = /(.*?)%(.)(.*)/;
+ var rest = formatString;
+ var result = [];
+
+ while (args.length) {
+ var match = pattern.exec(rest);
+ if (!match) break;
+
+ var arg = args.shift();
+ rest = match[3];
+ result.push(match[1]);
+
+ if (match[2] == '%') {
+ result.push('%');
+ args.unshift(arg);
+ continue;
+ }
+
+ result.push(__formatted(arg, match[2]));
+ }
+
+ result.push(rest);
+
+ var remainingArgs = [].slice.call(args);
+ remainingArgs.unshift(result.join(''));
+ return remainingArgs;
+}
+
+function __formatted(object, formatChar) {
+
+ try {
+ switch(formatChar) {
+ case 'j':
+ case 'o': return JSON.stringify(object);
+ case 'c': return '';
+ }
+ }
+ catch (e) {
+ return "error JSON.stringify()ing argument: " + e;
+ }
+
+ if ((object === null) || (object === undefined)) {
+ return Object.prototype.toString.call(object);
+ }
+
+ return object.toString();
+}
+
+
+//------------------------------------------------------------------------------
// when deviceready fires, log queued messages
logger.__onDeviceReady = function() {
if (DeviceReady) return;
@@ -5760,13 +5851,13 @@ module.exports = {
console.log("Notification.confirm(string, function, string, string) is deprecated. Use Notification.confirm(string, function, string, array).");
}
- // Android and iOS take an array of button label names.
+ // Some platforms take an array of button label names.
// Other platforms take a comma separated list.
// For compatibility, we convert to the desired type based on the platform.
- if (platform.id == "android" || platform.id == "ios") {
+ if (platform.id == "android" || platform.id == "ios" || platform.id == "windowsphone") {
if (typeof _buttonLabels === 'string') {
var buttonLabelString = _buttonLabels;
- _buttonLabels = buttonLabelString.split(",");
+ _buttonLabels = _buttonLabels.split(","); // not crazy about changing the var type here
}
} else {
if (Array.isArray(_buttonLabels)) {
@@ -6117,62 +6208,6 @@ utils.alert = function(msg) {
}
};
-/**
- * Formats a string and arguments following it ala sprintf()
- *
- * see utils.vformat() for more information
- */
-utils.format = function(formatString /* ,... */) {
- var args = [].slice.call(arguments, 1);
- return utils.vformat(formatString, args);
-};
-
-/**
- * Formats a string and arguments following it ala vsprintf()
- *
- * format chars:
- * %j - format arg as JSON
- * %o - format arg as JSON
- * %c - format arg as ''
- * %% - replace with '%'
- * any other char following % will format it's
- * arg via toString().
- *
- * for rationale, see FireBug's Console API:
- * http://getfirebug.com/wiki/index.php/Console_API
- */
-utils.vformat = function(formatString, args) {
- if (formatString === null || formatString === undefined) return "";
- if (arguments.length == 1) return formatString.toString();
- if (typeof formatString != "string") return formatString.toString();
-
- var pattern = /(.*?)%(.)(.*)/;
- var rest = formatString;
- var result = [];
-
- while (args.length) {
- var arg = args.shift();
- var match = pattern.exec(rest);
-
- if (!match) break;
-
- rest = match[3];
-
- result.push(match[1]);
-
- if (match[2] == '%') {
- result.push('%');
- args.unshift(arg);
- continue;
- }
-
- result.push(formatted(arg, match[2]));
- }
-
- result.push(rest);
-
- return result.join('');
-};
//------------------------------------------------------------------------------
function UUIDcreatePart(length) {
@@ -6187,26 +6222,6 @@ function UUIDcreatePart(length) {
return uuidpart;
}
-//------------------------------------------------------------------------------
-function formatted(object, formatChar) {
-
- try {
- switch(formatChar) {
- case 'j':
- case 'o': return JSON.stringify(object);
- case 'c': return '';
- }
- }
- catch (e) {
- return "error JSON.stringify()ing argument: " + e;
- }
-
- if ((object === null) || (object === undefined)) {
- return Object.prototype.toString.call(object);
- }
-
- return object.toString();
-}
});
@@ -6216,6 +6231,25 @@ window.cordova = require('cordova');
// file: lib/scripts/bootstrap.js
(function (context) {
+ var channel = require('cordova/channel');
+ var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
+
+ function logUnfiredChannels(arr) {
+ for (var i = 0; i < arr.length; ++i) {
+ if (arr[i].state != 2) {
+ console.log('Channel not fired: ' + arr[i].type);
+ }
+ }
+ }
+
+ window.setTimeout(function() {
+ if (channel.onDeviceReady.state != 2) {
+ console.log('deviceready has not fired after 5 seconds.');
+ logUnfiredChannels(platformInitChannelsArray);
+ logUnfiredChannels(channel.deviceReadyChannelsArray);
+ }
+ }, 5000);
+
// Replace navigator before any modules are required(), to ensure it happens as soon as possible.
// We replace it so that properties that can't be clobbered can instead be overridden.
function replaceNavigator(origNavigator) {
@@ -6237,8 +6271,6 @@ window.cordova = require('cordova');
context.navigator = replaceNavigator(context.navigator);
}
- var channel = require("cordova/channel");
-
// _nativeReady is global variable that the native side can set
// to signify that the native code is ready. It is a global since
// it may be called before any cordova JS is ready.
@@ -6247,27 +6279,33 @@ window.cordova = require('cordova');
}
/**
- * Create all cordova objects once page has fully loaded and native side is ready.
+ * Create all cordova objects once native side is ready.
*/
channel.join(function() {
- var platform = require('cordova/platform');
-
// Call the platform-specific initialization
- platform.initialize();
+ require('cordova/platform').initialize();
// Fire event to notify that all objects are created
channel.onCordovaReady.fire();
- // Fire onDeviceReady event once all constructors have run and
- // cordova info has been received from native side.
+ // Fire onDeviceReady event once page has fully loaded, all
+ // constructors have run and cordova info has been received from native
+ // side.
+ // This join call is deliberately made after platform.initialize() in
+ // order that plugins may manipulate channel.deviceReadyChannelsArray
+ // if necessary.
channel.join(function() {
require('cordova').fireDocumentEvent('deviceready');
}, channel.deviceReadyChannelsArray);
- }, [ channel.onDOMContentLoaded, channel.onNativeReady, channel.onPluginsReady ]);
+ }, platformInitChannelsArray);
}(window));
+// file: lib/scripts/bootstrap-ios.js
+
+require('cordova/channel').onNativeReady.fire();
+
// file: lib/scripts/plugin_loader.js
// Tries to load all plugins' js-modules.
[2/2] ios commit: Fix FileTransfer unit test. HTTP Method was being
set to null.
Posted by ag...@apache.org.
Fix FileTransfer unit test. HTTP Method was being set to null.
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/cce2cdda
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/cce2cdda
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/cce2cdda
Branch: refs/heads/master
Commit: cce2cdda0af91000cf6fb46d5c7ad890a5357080
Parents: c8f31c3
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Apr 18 15:22:46 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Apr 18 15:22:46 2013 -0400
----------------------------------------------------------------------
CordovaLib/Classes/CDVFileTransfer.m | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cce2cdda/CordovaLib/Classes/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.m b/CordovaLib/Classes/CDVFileTransfer.m
index 4df9219..5536715 100644
--- a/CordovaLib/Classes/CDVFileTransfer.m
+++ b/CordovaLib/Classes/CDVFileTransfer.m
@@ -126,20 +126,19 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
// arguments order from js: [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode]
// however, params is a JavaScript object and during marshalling is put into the options dict,
// thus debug and chunkedMode are the 6th and 7th arguments
- NSArray* arguments = command.arguments;
- NSString* target = (NSString*)[arguments objectAtIndex:0];
- NSString* server = (NSString*)[arguments objectAtIndex:1];
- NSString* fileKey = [arguments objectAtIndex:2 withDefault:@"file"];
- NSString* fileName = [arguments objectAtIndex:3 withDefault:@"no-filename"];
- NSString* mimeType = [arguments objectAtIndex:4 withDefault:nil];
- NSDictionary* options = [arguments objectAtIndex:5 withDefault:nil];
+ NSString* target = [command argumentAtIndex:0];
+ NSString* server = [command argumentAtIndex:1];
+ NSString* fileKey = [command argumentAtIndex:2 withDefault:@"file"];
+ NSString* fileName = [command argumentAtIndex:3 withDefault:@"no-filename"];
+ NSString* mimeType = [command argumentAtIndex:4 withDefault:nil];
+ NSDictionary* options = [command argumentAtIndex:5 withDefault:nil];
// BOOL trustAllHosts = [[arguments objectAtIndex:6 withDefault:[NSNumber numberWithBool:YES]] boolValue]; // allow self-signed certs
- BOOL chunkedMode = [[arguments objectAtIndex:7 withDefault:[NSNumber numberWithBool:YES]] boolValue];
- NSDictionary* headers = [arguments objectAtIndex:8 withDefault:nil];
+ BOOL chunkedMode = [[command argumentAtIndex:7 withDefault:[NSNumber numberWithBool:YES]] boolValue];
+ NSDictionary* headers = [command argumentAtIndex:8 withDefault:nil];
// Allow alternative http method, default to POST. JS side checks
// for allowed methods, currently PUT or POST (forces POST for
// unrecognised values)
- NSString* httpMethod = [arguments objectAtIndex:10 withDefault:@"POST"];
+ NSString* httpMethod = [command argumentAtIndex:10 withDefault:@"POST"];
CDVPluginResult* result = nil;
CDVFileTransferError errorCode = 0;