Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8C4BC91B0 for ; Wed, 24 Oct 2012 19:56:40 +0000 (UTC) Received: (qmail 87125 invoked by uid 500); 24 Oct 2012 19:56:40 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 87051 invoked by uid 500); 24 Oct 2012 19:56:39 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 86926 invoked by uid 99); 24 Oct 2012 19:56:39 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Oct 2012 19:56:39 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 6305C4EF5D; Wed, 24 Oct 2012 19:56:39 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: anis@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [6/6] bumping version number Message-Id: <20121024195639.6305C4EF5D@tyr.zones.apache.org> Date: Wed, 24 Oct 2012 19:56:39 +0000 (UTC) http://git-wip-us.apache.org/repos/asf/incubator-cordova-tizen/blob/bb7d71eb/js/cordova.tizen.js ---------------------------------------------------------------------- diff --git a/js/cordova.tizen.js b/js/cordova.tizen.js index fda2690..41e600b 100644 --- a/js/cordova.tizen.js +++ b/js/cordova.tizen.js @@ -1,6 +1,6 @@ -// commit 2aa46aa0eef2ba641cf91793735152d7fb5b6998 +// commit 337b1f443491f3fdb816dc32f70e5378e0e1967c -// File generated at :: Mon Sep 03 2012 19:33:13 GMT-0700 (PDT) +// File generated at :: Mon Oct 15 2012 17:23:41 GMT-0700 (PDT) /* Licensed to the Apache Software Foundation (ASF) under one @@ -24,11 +24,16 @@ ;(function() { // file: lib/scripts/require.js + var require, define; (function () { var modules = {}; + // Stack of moduleIds currently being built. + var requireStack = []; + // Map of module ID -> index into requireStack of modules currently being built. + var inProgressModules = {}; function build(module) { var factory = module.factory; @@ -41,8 +46,21 @@ var require, require = function (id) { if (!modules[id]) { throw "module " + id + " not found"; + } else if (id in inProgressModules) { + var cycle = requireStack.slice(inProgressModules[id]).join('->') + '->' + id; + throw "Cycle in require graph: " + cycle; + } + if (modules[id].factory) { + try { + inProgressModules[id] = requireStack.length; + requireStack.push(id); + return build(modules[id]); + } finally { + delete inProgressModules[id]; + requireStack.pop(); + } } - return modules[id].factory ? build(modules[id]) : modules[id].exports; + return modules[id].exports; }; define = function (id, factory) { @@ -67,8 +85,11 @@ if (typeof module === "object" && typeof require === "function") { module.exports.require = require; module.exports.define = define; } + // file: lib/cordova.js define("cordova", function(require, exports, module) { + + var channel = require('cordova/channel'); /** @@ -99,11 +120,7 @@ var documentEventHandlers = {}, document.addEventListener = function(evt, handler, capture) { var e = evt.toLowerCase(); if (typeof documentEventHandlers[e] != 'undefined') { - if (evt === 'deviceready') { - documentEventHandlers[e].subscribeOnce(handler); - } else { - documentEventHandlers[e].subscribe(handler); - } + documentEventHandlers[e].subscribe(handler); } else { m_document_addEventListener.call(document, evt, handler, capture); } @@ -120,7 +137,7 @@ window.addEventListener = function(evt, handler, capture) { document.removeEventListener = function(evt, handler, capture) { var e = evt.toLowerCase(); - // If unsubcribing from an event that is handled by a plugin + // If unsubscribing from an event that is handled by a plugin if (typeof documentEventHandlers[e] != "undefined") { documentEventHandlers[e].unsubscribe(handler); } else { @@ -130,7 +147,7 @@ document.removeEventListener = function(evt, handler, capture) { window.removeEventListener = function(evt, handler, capture) { var e = evt.toLowerCase(); - // If unsubcribing from an event that is handled by a plugin + // If unsubscribing from an event that is handled by a plugin if (typeof windowEventHandlers[e] != "undefined") { windowEventHandlers[e].unsubscribe(handler); } else { @@ -163,11 +180,14 @@ var cordova = { /** * Methods to add/remove your own addEventListener hijacking on document + window. */ - addWindowEventHandler:function(event, opts) { - return (windowEventHandlers[event] = channel.create(event, opts)); + addWindowEventHandler:function(event) { + return (windowEventHandlers[event] = channel.create(event)); + }, + addStickyDocumentEventHandler:function(event) { + return (documentEventHandlers[event] = channel.createSticky(event)); }, - addDocumentEventHandler:function(event, opts) { - return (documentEventHandlers[event] = channel.create(event, opts)); + addDocumentEventHandler:function(event) { + return (documentEventHandlers[event] = channel.create(event)); }, removeWindowEventHandler:function(event) { delete windowEventHandlers[event]; @@ -176,7 +196,7 @@ var cordova = { delete documentEventHandlers[event]; }, /** - * Retreive original event handlers that were replaced by Cordova + * Retrieve original event handlers that were replaced by Cordova * * @return object */ @@ -186,13 +206,19 @@ var cordova = { }, /** * Method to fire event from native code + * bNoDetach is required for events which cause an exception which needs to be caught in native code */ - fireDocumentEvent: function(type, data) { + fireDocumentEvent: function(type, data, bNoDetach) { var evt = createEvent(type, data); if (typeof documentEventHandlers[type] != 'undefined') { - setTimeout(function() { - documentEventHandlers[type].fire(evt); - }, 0); + if( bNoDetach ) { + documentEventHandlers[type].fire(evt); + } + else { + setTimeout(function() { + documentEventHandlers[type].fire(evt); + }, 0); + } } else { document.dispatchEvent(evt); } @@ -208,18 +234,12 @@ var cordova = { } }, - // TODO: iOS only - // This queue holds the currently executing command and all pending - // commands executed with cordova.exec(). - commandQueue:[], - // Indicates if we're currently in the middle of flushing the command - // queue on the native side. - commandQueueFlushing:false, - // END TODO /** * Plugin callback mechanism. */ - callbackId: 0, + // Randomize the starting callbackId to avoid collisions after refreshing or navigating. + // This way, it's very unlikely that any new callback would get the same callbackId as an old callback. + callbackId: Math.floor(Math.random() * 2000000000), callbacks: {}, callbackStatus: { NO_RESULT: 0, @@ -236,57 +256,48 @@ var cordova = { /** * Called by native code when returning successful result from an action. - * - * @param callbackId - * @param args */ callbackSuccess: function(callbackId, args) { - if (cordova.callbacks[callbackId]) { - - // If result is to be sent to callback - if (args.status == cordova.callbackStatus.OK) { - try { - if (cordova.callbacks[callbackId].success) { - cordova.callbacks[callbackId].success(args.message); - } - } - catch (e) { - console.log("Error in success callback: "+callbackId+" = "+e); - } - } - - // Clear callback if not expecting any more results - if (!args.keepCallback) { - delete cordova.callbacks[callbackId]; - } + try { + cordova.callbackFromNative(callbackId, true, args.status, args.message, args.keepCallback); + } catch (e) { + console.log("Error in error callback: " + callbackId + " = "+e); } }, /** * Called by native code when returning error result from an action. - * - * @param callbackId - * @param args */ callbackError: function(callbackId, args) { - if (cordova.callbacks[callbackId]) { - try { - if (cordova.callbacks[callbackId].fail) { - cordova.callbacks[callbackId].fail(args.message); - } - } - catch (e) { - console.log("Error in error callback: "+callbackId+" = "+e); + // 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); + } + }, + + /** + * Called by native code when returning the result from an action. + */ + callbackFromNative: function(callbackId, success, status, message, keepCallback) { + var callback = cordova.callbacks[callbackId]; + if (callback) { + if (success && status == cordova.callbackStatus.OK) { + callback.success && callback.success(message); + } else if (!success) { + callback.fail && callback.fail(message); } // Clear callback if not expecting any more results - if (!args.keepCallback) { + if (!keepCallback) { delete cordova.callbacks[callbackId]; } } }, addConstructor: function(func) { - channel.onCordovaReady.subscribeOnce(function() { + channel.onCordovaReady.subscribe(function() { try { func(); } catch(e) { @@ -299,7 +310,7 @@ var cordova = { // Register pause, resume and deviceready channels as events on document. channel.onPause = cordova.addDocumentEventHandler('pause'); channel.onResume = cordova.addDocumentEventHandler('resume'); -channel.onDeviceReady = cordova.addDocumentEventHandler('deviceready'); +channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready'); module.exports = cordova; @@ -307,6 +318,7 @@ module.exports = cordova; // file: lib/common/builder.js define("cordova/builder", function(require, exports, module) { + var utils = require('cordova/utils'); function each(objects, func, context) { @@ -317,6 +329,17 @@ function each(objects, func, context) { } } +function assignOrWrapInDeprecateGetter(obj, key, value, message) { + if (message) { + utils.defineGetter(obj, key, function() { + window.console && console.log(message); + return value; + }); + } else { + obj[key] = value; + } +} + function include(parent, objects, clobber, merge) { each(objects, function (obj, key) { try { @@ -325,20 +348,20 @@ function include(parent, objects, clobber, merge) { if (clobber) { // Clobber if it doesn't exist. if (typeof parent[key] === 'undefined') { - parent[key] = result; + assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated); } else if (typeof obj.path !== 'undefined') { // If merging, merge properties onto parent, otherwise, clobber. if (merge) { recursiveMerge(parent[key], result); } else { - parent[key] = result; + assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated); } } result = parent[key]; } else { // Overwrite if not currently defined. if (typeof parent[key] == 'undefined') { - parent[key] = result; + assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated); } else if (merge && typeof obj.path !== 'undefined') { // If merging, merge parent onto result recursiveMerge(result, parent[key]); @@ -383,7 +406,7 @@ function recursiveMerge(target, src) { module.exports = { build: function (objects) { return { - intoButDontClobber: function (target) { + intoButDoNotClobber: function (target) { include(target, objects, false, false); }, intoAndClobber: function(target) { @@ -400,25 +423,29 @@ module.exports = { // file: lib/common/channel.js define("cordova/channel", function(require, exports, module) { + var utils = require('cordova/utils'), nextGuid = 1; /** * Custom pub-sub "channel" that can have functions subscribed to it * This object is used to define and control firing of events for - * cordova initialization. + * cordova initialization, as well as for custom events thereafter. * * The order of events during page load and Cordova startup is as follows: * - * onDOMContentLoaded Internal event that is received when the web page is loaded and parsed. - * onNativeReady Internal event that indicates the Cordova native side is ready. - * onCordovaReady Internal event fired when all Cordova JavaScript objects have been created. - * onCordovaInfoReady Internal event fired when device properties are available. - * onCordovaConnectionReady Internal event fired when the connection property has been set. - * onDeviceReady User event fired to indicate that Cordova is ready - * onResume User event fired to indicate a start/resume lifecycle event - * onPause User event fired to indicate a pause lifecycle event - * onDestroy Internal event fired when app is being destroyed (User should use window.onunload event, not this one). + * onDOMContentLoaded* Internal event that is received when the web page is loaded and parsed. + * onNativeReady* Internal event that indicates the Cordova native side is ready. + * onCordovaReady* Internal event fired when all Cordova JavaScript objects have been created. + * onCordovaInfoReady* Internal event fired when device properties are available. + * onCordovaConnectionReady* Internal event fired when the connection property has been set. + * onDeviceReady* User event fired to indicate that Cordova is ready + * onResume User event fired to indicate a start/resume lifecycle event + * onPause User event fired to indicate a pause lifecycle event + * onDestroy* Internal event fired when app is being destroyed (User should use window.onunload event, not this one). + * + * The events marked with an * are sticky. Once they have fired, they will stay in the fired state. + * All listeners that subscribe after the event is fired will be executed right away. * * The only Cordova events that user code should register for are: * deviceready Cordova native code is initialized and Cordova APIs can be called from JavaScript @@ -440,49 +467,45 @@ var utils = require('cordova/utils'), * Channel * @constructor * @param type String the channel name - * @param opts Object options to pass into the channel, currently - * supports: - * onSubscribe: callback that fires when - * something subscribes to the Channel. Sets - * context to the Channel. - * onUnsubscribe: callback that fires when - * something unsubscribes to the Channel. Sets - * context to the Channel. - */ -var Channel = function(type, opts) { + */ +var Channel = function(type, sticky) { this.type = type; + // Map of guid -> function. this.handlers = {}; + // 0 = Non-sticky, 1 = Sticky non-fired, 2 = Sticky fired. + this.state = sticky ? 1 : 0; + // Used in sticky mode to remember args passed to fire(). + this.fireArgs = null; + // Used by onHasSubscribersChange to know if there are any listeners. this.numHandlers = 0; - this.fired = false; - this.enabled = true; - this.events = { - onSubscribe:null, - onUnsubscribe:null - }; - if (opts) { - if (opts.onSubscribe) this.events.onSubscribe = opts.onSubscribe; - if (opts.onUnsubscribe) this.events.onUnsubscribe = opts.onUnsubscribe; - } + // Function that is called when the first listener is subscribed, or when + // the last listener is unsubscribed. + this.onHasSubscribersChange = null; }, channel = { /** * Calls the provided function only after all of the channels specified - * have been fired. + * have been fired. All channels must be sticky channels. */ - join: function (h, c) { - var i = c.length; - var len = i; - var f = function() { - if (!(--i)) h(); - }; + join: function(h, c) { + var len = c.length, + i = len, + f = function() { + if (!(--i)) h(); + }; for (var j=0; j