"; };
@@ -191,6 +191,7 @@
888700D710922F56009987E8 /* Commands */ = {
isa = PBXGroup;
children = (
+ 7E22B88419E4C0210026F95E /* CDVAvailabilityDeprecated.h */,
EBFF4DBA16D3FE2E008F452B /* CDVWebViewDelegate.m */,
EBFF4DBB16D3FE2E008F452B /* CDVWebViewDelegate.h */,
301F2F2914F3C9CA003FE9FC /* CDV.h */,
@@ -204,7 +205,6 @@
30C684931407044A004C1A8E /* CDVURLProtocol.m */,
30C6847E1406CB38004C1A8E /* CDVWhitelist.h */,
1B701026177A61CF00AE11F4 /* CDVShared.h */,
- 1B701027177A61CF00AE11F4 /* CDVShared.m */,
30C6847F1406CB38004C1A8E /* CDVWhitelist.m */,
30E33AF013A7E24B00594D64 /* CDVPlugin.h */,
30E33AF113A7E24B00594D64 /* CDVPlugin.m */,
@@ -271,6 +271,7 @@
30F5EBAB14CA26E700987760 /* CDVCommandDelegate.h in Headers */,
301F2F2A14F3C9CA003FE9FC /* CDV.h in Headers */,
30392E4E14F4FCAB00B9E0B8 /* CDVAvailability.h in Headers */,
+ 7E22B88519E4C0210026F95E /* CDVAvailabilityDeprecated.h in Headers */,
3034979C1513D56A0090E688 /* CDVLocalStorage.h in Headers */,
3062D120151D0EDB000D9128 /* UIDevice+Extensions.h in Headers */,
EBA3557315ABD38C00F4DE24 /* NSArray+Comparisons.h in Headers */,
@@ -312,7 +313,7 @@
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0500;
+ LastUpgradeCheck = 0510;
};
buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "CordovaLib" */;
compatibilityVersion = "Xcode 3.2";
@@ -359,7 +360,6 @@
EB96673C16A8970A00D86CDF /* CDVUserAgentUtil.m in Sources */,
EBFF4DBC16D3FE2E008F452B /* CDVWebViewDelegate.m in Sources */,
7E14B5A91705050A0032169E /* CDVTimer.m in Sources */,
- 1B701029177A61CF00AE11F4 /* CDVShared.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -370,16 +370,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- "ARCHS[sdk=iphoneos*]" = armv7;
- "ARCHS[sdk=iphoneos6.*]" = (
- armv7,
- armv7s,
- );
- "ARCHS[sdk=iphoneos7.*]" = (
- armv7,
- armv7s,
- );
- "ARCHS[sdk=iphonesimulator*]" = i386;
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
DSTROOT = "/tmp/$(PROJECT_NAME).dst";
@@ -392,7 +382,7 @@
GCC_THUMB_SUPPORT = NO;
GCC_VERSION = "";
INSTALL_PATH = /usr/local/lib;
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = Cordova;
PUBLIC_HEADERS_FOLDER_PATH = include/Cordova;
SKIP_INSTALL = YES;
@@ -403,16 +393,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- "ARCHS[sdk=iphoneos*]" = armv7;
- "ARCHS[sdk=iphoneos6.*]" = (
- armv7,
- armv7s,
- );
- "ARCHS[sdk=iphoneos7.*]" = (
- armv7,
- armv7s,
- );
- "ARCHS[sdk=iphonesimulator*]" = i386;
CLANG_ENABLE_OBJC_ARC = YES;
DSTROOT = "/tmp/$(PROJECT_NAME).dst";
GCC_MODEL_TUNING = G5;
@@ -422,7 +402,7 @@
GCC_THUMB_SUPPORT = NO;
GCC_VERSION = "";
INSTALL_PATH = /usr/local/lib;
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = Cordova;
PUBLIC_HEADERS_FOLDER_PATH = include/Cordova;
SKIP_INSTALL = YES;
@@ -432,16 +412,6 @@
1DEB922308733DC00010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- "ARCHS[sdk=iphoneos*]" = armv7;
- "ARCHS[sdk=iphoneos6.*]" = (
- armv7,
- armv7s,
- );
- "ARCHS[sdk=iphoneos7.*]" = (
- armv7,
- armv7s,
- );
- "ARCHS[sdk=iphonesimulator*]" = i386;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
@@ -458,31 +428,20 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
- ONLY_ACTIVE_ARCH = NO;
+ IPHONEOS_DEPLOYMENT_TARGET = 6.0;
+ ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-DDEBUG";
PUBLIC_HEADERS_FOLDER_PATH = include/Cordova;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = "";
- VALID_ARCHS = "i386 armv7 armv7s";
};
name = Debug;
};
1DEB922408733DC00010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- "ARCHS[sdk=iphoneos*]" = armv7;
- "ARCHS[sdk=iphoneos6.*]" = (
- armv7,
- armv7s,
- );
- "ARCHS[sdk=iphoneos7.*]" = (
- armv7,
- armv7s,
- );
- "ARCHS[sdk=iphonesimulator*]" = i386;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
@@ -498,13 +457,12 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 6.0;
ONLY_ACTIVE_ARCH = NO;
PUBLIC_HEADERS_FOLDER_PATH = include/Cordova;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
- VALID_ARCHS = "i386 armv7 armv7s";
};
name = Release;
};
diff --git a/platforms/ios/CordovaLib/VERSION b/platforms/ios/CordovaLib/VERSION
index 15a2799..7c69a55 100644
--- a/platforms/ios/CordovaLib/VERSION
+++ b/platforms/ios/CordovaLib/VERSION
@@ -1 +1 @@
-3.3.0
+3.7.0
diff --git a/platforms/ios/CordovaLib/cordova.js b/platforms/ios/CordovaLib/cordova.js
index a26e7b1..84b7642 100644
--- a/platforms/ios/CordovaLib/cordova.js
+++ b/platforms/ios/CordovaLib/cordova.js
@@ -1,5 +1,5 @@
// Platform: ios
-// 3.3.0
+// 91157c2e1bf3eb098c7e2ab31404e895ccb0df2a
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -19,8 +19,8 @@
under the License.
*/
;(function() {
-var CORDOVA_JS_BUILD_LABEL = '3.3.0';
-// file: lib/scripts/require.js
+var PLATFORM_VERSION_BUILD_LABEL = '3.7.0';
+// file: src/scripts/require.js
/*jshint -W079 */
/*jshint -W020 */
@@ -98,7 +98,7 @@ if (typeof module === "object" && typeof require === "function") {
module.exports.define = define;
}
-// file: lib/cordova.js
+// file: src/cordova.js
define("cordova", function(require, exports, module) {
@@ -175,7 +175,8 @@ function createEvent(type, data) {
var cordova = {
define:define,
require:require,
- version:CORDOVA_JS_BUILD_LABEL,
+ version:PLATFORM_VERSION_BUILD_LABEL,
+ platformVersion:PLATFORM_VERSION_BUILD_LABEL,
platformId:platform.id,
/**
* Methods to add/remove your own addEventListener hijacking on document + window.
@@ -262,11 +263,7 @@ var cordova = {
* Called by native code when returning successful result from an action.
*/
callbackSuccess: function(callbackId, args) {
- try {
- cordova.callbackFromNative(callbackId, true, args.status, [args.message], args.keepCallback);
- } catch (e) {
- console.log("Error in error callback: " + callbackId + " = "+e);
- }
+ cordova.callbackFromNative(callbackId, true, args.status, [args.message], args.keepCallback);
},
/**
@@ -275,30 +272,34 @@ var cordova = {
callbackError: function(callbackId, args) {
// TODO: Deprecate callbackSuccess and callbackError in favour of callbackFromNative.
// Derive success from status.
- try {
- cordova.callbackFromNative(callbackId, false, args.status, [args.message], args.keepCallback);
- } catch (e) {
- console.log("Error in error callback: " + callbackId + " = "+e);
- }
+ cordova.callbackFromNative(callbackId, false, args.status, [args.message], args.keepCallback);
},
/**
* Called by native code when returning the result from an action.
*/
- callbackFromNative: function(callbackId, success, status, args, keepCallback) {
- var callback = cordova.callbacks[callbackId];
- if (callback) {
- if (success && status == cordova.callbackStatus.OK) {
- callback.success && callback.success.apply(null, args);
- } else if (!success) {
- callback.fail && callback.fail.apply(null, args);
- }
+ callbackFromNative: function(callbackId, isSuccess, status, args, keepCallback) {
+ try {
+ var callback = cordova.callbacks[callbackId];
+ if (callback) {
+ if (isSuccess && status == cordova.callbackStatus.OK) {
+ callback.success && callback.success.apply(null, args);
+ } else {
+ callback.fail && callback.fail.apply(null, args);
+ }
- // Clear callback if not expecting any more results
- if (!keepCallback) {
- delete cordova.callbacks[callbackId];
+ // Clear callback if not expecting any more results
+ if (!keepCallback) {
+ delete cordova.callbacks[callbackId];
+ }
}
}
+ catch (err) {
+ var msg = "Error in " + (isSuccess ? "Success" : "Error") + " callbackId: " + callbackId + " : " + err;
+ console && console.log && console.log(msg);
+ cordova.fireWindowEvent("cordovacallbackerror", { 'message': msg });
+ throw err;
+ }
},
addConstructor: function(func) {
channel.onCordovaReady.subscribe(function() {
@@ -316,7 +317,7 @@ module.exports = cordova;
});
-// file: lib/common/argscheck.js
+// file: src/common/argscheck.js
define("cordova/argscheck", function(require, exports, module) {
var exec = require('cordova/exec');
@@ -382,7 +383,7 @@ moduleExports.enableChecks = true;
});
-// file: lib/common/base64.js
+// file: src/common/base64.js
define("cordova/base64", function(require, exports, module) {
var base64 = exports;
@@ -392,6 +393,16 @@ base64.fromArrayBuffer = function(arrayBuffer) {
return uint8ToBase64(array);
};
+base64.toArrayBuffer = function(str) {
+ var decodedStr = typeof atob != 'undefined' ? atob(str) : new Buffer(str,'base64').toString('binary');
+ var arrayBuffer = new ArrayBuffer(decodedStr.length);
+ var array = new Uint8Array(arrayBuffer);
+ for (var i=0, len=decodedStr.length; i < len; i++) {
+ array[i] = decodedStr.charCodeAt(i);
+ }
+ return arrayBuffer;
+};
+
//------------------------------------------------------------------------------
/* This code is based on the performance tests at http://jsperf.com/b64tests
@@ -438,7 +449,7 @@ function uint8ToBase64(rawData) {
});
-// file: lib/common/builder.js
+// file: src/common/builder.js
define("cordova/builder", function(require, exports, module) {
var utils = require('cordova/utils');
@@ -551,7 +562,7 @@ exports.replaceHookForTesting = function() {};
});
-// file: lib/common/channel.js
+// file: src/common/channel.js
define("cordova/channel", function(require, exports, module) {
var utils = require('cordova/utils'),
@@ -770,6 +781,7 @@ channel.createSticky('onNativeReady');
channel.createSticky('onCordovaReady');
// Event to indicate that all automatically loaded JS plugins are loaded and ready.
+// FIXME remove this
channel.createSticky('onPluginsReady');
// Event to indicate that Cordova is ready
@@ -792,45 +804,66 @@ module.exports = channel;
});
-// file: lib/ios/exec.js
+// file: src/ios/exec.js
define("cordova/exec", function(require, exports, module) {
/**
* Creates a gap bridge iframe used to notify the native code about queued
* commands.
- *
- * @private
*/
var cordova = require('cordova'),
channel = require('cordova/channel'),
utils = require('cordova/utils'),
base64 = require('cordova/base64'),
+ // XHR mode does not work on iOS 4.2.
+ // XHR mode's main advantage is working around a bug in -webkit-scroll, which
+ // doesn't exist only on iOS 5.x devices.
+ // IFRAME_NAV is the fastest.
+ // IFRAME_HASH could be made to enable synchronous bridge calls if we wanted this feature.
jsToNativeModes = {
IFRAME_NAV: 0,
XHR_NO_PAYLOAD: 1,
XHR_WITH_PAYLOAD: 2,
- XHR_OPTIONAL_PAYLOAD: 3
+ XHR_OPTIONAL_PAYLOAD: 3,
+ IFRAME_HASH_NO_PAYLOAD: 4,
+ // Bundling the payload turns out to be slower. Probably since it has to be URI encoded / decoded.
+ IFRAME_HASH_WITH_PAYLOAD: 5,
+ WK_WEBVIEW_BINDING: 6
},
bridgeMode,
execIframe,
+ execHashIframe,
+ hashToggle = 1,
execXhr,
requestCount = 0,
vcHeaderValue = null,
commandQueue = [], // Contains pending JS->Native messages.
isInContextOfEvalJs = 0;
-function createExecIframe() {
+function createExecIframe(src, unloadListener) {
var iframe = document.createElement("iframe");
iframe.style.display = 'none';
+ // Both the unload listener and the src must be set before adding the iframe
+ // to the document in order to avoid race conditions. Callbacks from native
+ // can happen within the appendChild() call!
+ iframe.onunload = unloadListener;
+ iframe.src = src;
document.body.appendChild(iframe);
return iframe;
}
+function createHashIframe() {
+ var ret = createExecIframe('about:blank');
+ // Hash changes don't work on about:blank, so switch it to file:///.
+ ret.contentWindow.history.replaceState(null, null, 'file:///#');
+ return ret;
+}
+
function shouldBundleCommandJson() {
- if (bridgeMode == jsToNativeModes.XHR_WITH_PAYLOAD) {
+ if (bridgeMode === jsToNativeModes.XHR_WITH_PAYLOAD) {
return true;
}
- if (bridgeMode == jsToNativeModes.XHR_OPTIONAL_PAYLOAD) {
+ if (bridgeMode === jsToNativeModes.XHR_OPTIONAL_PAYLOAD) {
var payloadLength = 0;
for (var i = 0; i < commandQueue.length; ++i) {
payloadLength += commandQueue[i].length;
@@ -891,11 +924,12 @@ function convertMessageToArgsNativeToJs(message) {
}
function iOSExec() {
- // XHR mode does not work on iOS 4.2, so default to IFRAME_NAV for such devices.
- // XHR mode's main advantage is working around a bug in -webkit-scroll, which
- // doesn't exist in 4.X devices anyways.
if (bridgeMode === undefined) {
- bridgeMode = navigator.userAgent.indexOf(' 4_') == -1 ? jsToNativeModes.XHR_NO_PAYLOAD : jsToNativeModes.IFRAME_NAV;
+ bridgeMode = jsToNativeModes.IFRAME_NAV;
+ }
+
+ if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.cordova && window.webkit.messageHandlers.cordova.postMessage) {
+ bridgeMode = jsToNativeModes.WK_WEBVIEW_BINDING;
}
var successCallback, failCallback, service, action, actionArgs, splitCommand;
@@ -928,6 +962,9 @@ function iOSExec() {
} catch (e) {}
}
+ // If actionArgs is not provided, default to an empty array
+ actionArgs = actionArgs || [];
+
// Register the callbacks and add the callbackId to the positional
// arguments if given.
if (successCallback || failCallback) {
@@ -944,36 +981,85 @@ function iOSExec() {
// effectively clone the command arguments in case they are mutated before
// the command is executed.
commandQueue.push(JSON.stringify(command));
-
- // If we're in the context of a stringByEvaluatingJavaScriptFromString call,
- // then the queue will be flushed when it returns; no need for a poke.
- // Also, if there is already a command in the queue, then we've already
- // poked the native side, so there is no reason to do so again.
- if (!isInContextOfEvalJs && commandQueue.length == 1) {
- if (bridgeMode != jsToNativeModes.IFRAME_NAV) {
- // This prevents sending an XHR when there is already one being sent.
- // This should happen only in rare circumstances (refer to unit tests).
- if (execXhr && execXhr.readyState != 4) {
- execXhr = null;
- }
- // Re-using the XHR improves exec() performance by about 10%.
- execXhr = execXhr || new XMLHttpRequest();
- // Changing this to a GET will make the XHR reach the URIProtocol on 4.2.
- // For some reason it still doesn't work though...
- // Add a timestamp to the query param to prevent caching.
- execXhr.open('HEAD', "/!gap_exec?" + (+new Date()), true);
- if (!vcHeaderValue) {
- vcHeaderValue = /.*\((.*)\)/.exec(navigator.userAgent)[1];
- }
- execXhr.setRequestHeader('vc', vcHeaderValue);
- execXhr.setRequestHeader('rc', ++requestCount);
- if (shouldBundleCommandJson()) {
- execXhr.setRequestHeader('cmds', iOSExec.nativeFetchMessages());
+
+ if (bridgeMode === jsToNativeModes.WK_WEBVIEW_BINDING) {
+ window.webkit.messageHandlers.cordova.postMessage(command);
+ } else {
+ // If we're in the context of a stringByEvaluatingJavaScriptFromString call,
+ // then the queue will be flushed when it returns; no need for a poke.
+ // Also, if there is already a command in the queue, then we've already
+ // poked the native side, so there is no reason to do so again.
+ if (!isInContextOfEvalJs && commandQueue.length == 1) {
+ switch (bridgeMode) {
+ case jsToNativeModes.XHR_NO_PAYLOAD:
+ case jsToNativeModes.XHR_WITH_PAYLOAD:
+ case jsToNativeModes.XHR_OPTIONAL_PAYLOAD:
+ pokeNativeViaXhr();
+ break;
+ default: // iframe-based.
+ pokeNativeViaIframe();
}
- execXhr.send(null);
+ }
+ }
+}
+
+function pokeNativeViaXhr() {
+ // This prevents sending an XHR when there is already one being sent.
+ // This should happen only in rare circumstances (refer to unit tests).
+ if (execXhr && execXhr.readyState != 4) {
+ execXhr = null;
+ }
+ // Re-using the XHR improves exec() performance by about 10%.
+ execXhr = execXhr || new XMLHttpRequest();
+ // Changing this to a GET will make the XHR reach the URIProtocol on 4.2.
+ // For some reason it still doesn't work though...
+ // Add a timestamp to the query param to prevent caching.
+ execXhr.open('HEAD', "/!gap_exec?" + (+new Date()), true);
+ if (!vcHeaderValue) {
+ vcHeaderValue = /.*\((.*)\)$/.exec(navigator.userAgent)[1];
+ }
+ execXhr.setRequestHeader('vc', vcHeaderValue);
+ execXhr.setRequestHeader('rc', ++requestCount);
+ if (shouldBundleCommandJson()) {
+ execXhr.setRequestHeader('cmds', iOSExec.nativeFetchMessages());
+ }
+ execXhr.send(null);
+}
+
+function onIframeUnload() {
+ execIframe = null;
+ setTimeout(pokeNativeViaIframe, 0);
+}
+
+function pokeNativeViaIframe() {
+ // CB-5488 - Don't attempt to create iframe before document.body is available.
+ if (!document.body) {
+ setTimeout(pokeNativeViaIframe);
+ return;
+ }
+ if (bridgeMode === jsToNativeModes.IFRAME_HASH_NO_PAYLOAD || bridgeMode === jsToNativeModes.IFRAME_HASH_WITH_PAYLOAD) {
+ // TODO: This bridge mode doesn't properly support being removed from the DOM (CB-7735)
+ execHashIframe = execHashIframe || createHashIframe();
+ // Check if they've removed it from the DOM, and put it back if so.
+ if (!execHashIframe.contentWindow) {
+ execHashIframe = createHashIframe();
+ }
+ // The delegate method is called only when the hash changes, so toggle it back and forth.
+ hashToggle = hashToggle ^ 3;
+ var hashValue = '%0' + hashToggle;
+ if (bridgeMode === jsToNativeModes.IFRAME_HASH_WITH_PAYLOAD) {
+ hashValue += iOSExec.nativeFetchMessages();
+ }
+ execHashIframe.contentWindow.location.hash = hashValue;
+ } else {
+ // Check if they've removed it from the DOM, and put it back if so.
+ if (execIframe && execIframe.contentWindow) {
+ // Listen for unload, since it can happen (CB-7735) that the iframe gets
+ // removed from the DOM before it gets a chance to poke the native side.
+ execIframe.contentWindow.onunload = onIframeUnload;
+ execIframe.src = 'gap://ready';
} else {
- execIframe = execIframe || createExecIframe();
- execIframe.src = "gap://ready";
+ execIframe = createExecIframe('gap://ready', onIframeUnload);
}
}
}
@@ -992,6 +1078,10 @@ iOSExec.setJsToNativeBridgeMode = function(mode) {
};
iOSExec.nativeFetchMessages = function() {
+ // Stop listing for window detatch once native side confirms poke.
+ if (execIframe && execIframe.contentWindow) {
+ execIframe.contentWindow.onunload = null;
+ }
// Each entry in commandQueue is a JSON string already.
if (!commandQueue.length) {
return '';
@@ -1024,7 +1114,7 @@ module.exports = iOSExec;
});
-// file: lib/common/exec/proxy.js
+// file: src/common/exec/proxy.js
define("cordova/exec/proxy", function(require, exports, module) {
@@ -1054,7 +1144,7 @@ module.exports = {
};
});
-// file: lib/common/init.js
+// file: src/common/init.js
define("cordova/init", function(require, exports, module) {
var channel = require('cordova/channel');
@@ -1062,6 +1152,7 @@ var cordova = require('cordova');
var modulemapper = require('cordova/modulemapper');
var platform = require('cordova/platform');
var pluginloader = require('cordova/pluginloader');
+var utils = require('cordova/utils');
var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
@@ -1093,11 +1184,19 @@ function replaceNavigator(origNavigator) {
for (var key in origNavigator) {
if (typeof origNavigator[key] == 'function') {
newNavigator[key] = origNavigator[key].bind(origNavigator);
+ }
+ else {
+ (function(k) {
+ utils.defineGetterSetter(newNavigator,key,function() {
+ return origNavigator[k];
+ });
+ })(key);
}
}
}
return newNavigator;
}
+
if (window.navigator) {
window.navigator = replaceNavigator(window.navigator);
}
@@ -1141,9 +1240,13 @@ modulemapper.clobbers('cordova/exec', 'Cordova.exec');
// Call the platform-specific initialization.
platform.bootstrap && platform.bootstrap();
-pluginloader.load(function() {
- channel.onPluginsReady.fire();
-});
+// Wrap in a setTimeout to support the use-case of having plugin JS appended to cordova.js.
+// The delay allows the attached modules to be defined before the plugin loader looks for them.
+setTimeout(function() {
+ pluginloader.load(function() {
+ channel.onPluginsReady.fire();
+ });
+}, 0);
/**
* Create all cordova objects once native side is ready.
@@ -1168,7 +1271,120 @@ channel.join(function() {
});
-// file: lib/common/modulemapper.js
+// file: src/common/init_b.js
+define("cordova/init_b", function(require, exports, module) {
+
+var channel = require('cordova/channel');
+var cordova = require('cordova');
+var platform = require('cordova/platform');
+var utils = require('cordova/utils');
+
+var platformInitChannelsArray = [channel.onDOMContentLoaded, channel.onNativeReady];
+
+// setting exec
+cordova.exec = require('cordova/exec');
+
+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) {
+ var CordovaNavigator = function() {};
+ CordovaNavigator.prototype = origNavigator;
+ var newNavigator = new CordovaNavigator();
+ // This work-around really only applies to new APIs that are newer than Function.bind.
+ // Without it, APIs such as getGamepads() break.
+ if (CordovaNavigator.bind) {
+ for (var key in origNavigator) {
+ if (typeof origNavigator[key] == 'function') {
+ newNavigator[key] = origNavigator[key].bind(origNavigator);
+ }
+ else {
+ (function(k) {
+ utils.defineGetterSetter(newNavigator,key,function() {
+ return origNavigator[k];
+ });
+ })(key);
+ }
+ }
+ }
+ return newNavigator;
+}
+if (window.navigator) {
+ window.navigator = replaceNavigator(window.navigator);
+}
+
+if (!window.console) {
+ window.console = {
+ log: function(){}
+ };
+}
+if (!window.console.warn) {
+ window.console.warn = function(msg) {
+ this.log("warn: " + msg);
+ };
+}
+
+// Register pause, resume and deviceready channels as events on document.
+channel.onPause = cordova.addDocumentEventHandler('pause');
+channel.onResume = cordova.addDocumentEventHandler('resume');
+channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready');
+
+// Listen for DOMContentLoaded and notify our channel subscribers.
+if (document.readyState == 'complete' || document.readyState == 'interactive') {
+ channel.onDOMContentLoaded.fire();
+} else {
+ document.addEventListener('DOMContentLoaded', function() {
+ channel.onDOMContentLoaded.fire();
+ }, false);
+}
+
+// _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.
+if (window._nativeReady) {
+ channel.onNativeReady.fire();
+}
+
+// Call the platform-specific initialization.
+platform.bootstrap && platform.bootstrap();
+
+/**
+ * Create all cordova objects once native side is ready.
+ */
+channel.join(function() {
+
+ platform.initialize && platform.initialize();
+
+ // Fire event to notify that all objects are created
+ channel.onCordovaReady.fire();
+
+ // Fire onDeviceReady event once page has fully loaded, all
+ // constructors have run and cordova info has been received from native
+ // side.
+ channel.join(function() {
+ require('cordova').fireDocumentEvent('deviceready');
+ }, channel.deviceReadyChannelsArray);
+
+}, platformInitChannelsArray);
+
+});
+
+// file: src/common/modulemapper.js
define("cordova/modulemapper", function(require, exports, module) {
var builder = require('cordova/builder'),
@@ -1269,7 +1485,7 @@ exports.reset();
});
-// file: lib/ios/platform.js
+// file: src/ios/platform.js
define("cordova/platform", function(require, exports, module) {
module.exports = {
@@ -1282,49 +1498,58 @@ module.exports = {
});
-// file: lib/common/pluginloader.js
+// file: src/common/pluginloader.js
define("cordova/pluginloader", function(require, exports, module) {
var modulemapper = require('cordova/modulemapper');
+var urlutil = require('cordova/urlutil');
// Helper function to inject a
-
-
-
- Loading device properties...
-
-