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/07/30 20:58:08 UTC

[01/13] js commit: [CB-4419] Remove non-CLI bootstrap files from cordova-js.

Updated Branches:
  refs/heads/master ad7234568 -> 732c9e914


[CB-4419] Remove non-CLI bootstrap files from cordova-js.


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/853a5fc9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/853a5fc9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/853a5fc9

Branch: refs/heads/master
Commit: 853a5fc916358bf26f58486693ec8c26db67293b
Parents: ad72345
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon Jul 29 22:25:05 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jul 29 22:25:05 2013 -0400

----------------------------------------------------------------------
 lib/scripts/bootstrap-b2g.js        | 22 ----------------------
 lib/scripts/bootstrap-bada.js       | 22 ----------------------
 lib/scripts/bootstrap-blackberry.js | 26 --------------------------
 lib/scripts/bootstrap-errgen.js     | 20 --------------------
 lib/scripts/bootstrap-tizen.js      | 22 ----------------------
 lib/scripts/bootstrap-webos.js      | 22 ----------------------
 6 files changed, 134 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/853a5fc9/lib/scripts/bootstrap-b2g.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-b2g.js b/lib/scripts/bootstrap-b2g.js
deleted file mode 100644
index 91a6f71..0000000
--- a/lib/scripts/bootstrap-b2g.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-require('cordova/channel').onNativeReady.fire();

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/853a5fc9/lib/scripts/bootstrap-bada.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-bada.js b/lib/scripts/bootstrap-bada.js
deleted file mode 100644
index 91a6f71..0000000
--- a/lib/scripts/bootstrap-bada.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-require('cordova/channel').onNativeReady.fire();

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/853a5fc9/lib/scripts/bootstrap-blackberry.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-blackberry.js b/lib/scripts/bootstrap-blackberry.js
deleted file mode 100644
index 8f3c0bc..0000000
--- a/lib/scripts/bootstrap-blackberry.js
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-document.addEventListener("DOMContentLoaded", function () {
-    if (require('cordova/platform').runtime() === 'air') {
-        require('cordova/channel').onNativeReady.fire();
-    }
-});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/853a5fc9/lib/scripts/bootstrap-errgen.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-errgen.js b/lib/scripts/bootstrap-errgen.js
deleted file mode 100644
index cdfe9fc..0000000
--- a/lib/scripts/bootstrap-errgen.js
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-require('cordova/channel').onNativeReady.fire();
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/853a5fc9/lib/scripts/bootstrap-tizen.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-tizen.js b/lib/scripts/bootstrap-tizen.js
deleted file mode 100644
index 91a6f71..0000000
--- a/lib/scripts/bootstrap-tizen.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-require('cordova/channel').onNativeReady.fire();

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/853a5fc9/lib/scripts/bootstrap-webos.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-webos.js b/lib/scripts/bootstrap-webos.js
deleted file mode 100644
index 91a6f71..0000000
--- a/lib/scripts/bootstrap-webos.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-require('cordova/channel').onNativeReady.fire();


[03/13] js commit: [CB-4428] Delete Android storage plugin from cordova-js

Posted by ag...@apache.org.
[CB-4428] Delete Android storage plugin from cordova-js

It will be moved into cordova-labs


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/0ec3a5f8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/0ec3a5f8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/0ec3a5f8

Branch: refs/heads/master
Commit: 0ec3a5f871704d24cd07079a09de7e50874fd4d0
Parents: b248abf
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jul 30 09:55:41 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jul 30 09:55:41 2013 -0400

----------------------------------------------------------------------
 lib/android/plugin/android/storage.js           | 311 -------------------
 .../plugin/android/storage/openDatabase.js      |  47 ---
 lib/android/plugin/android/storage/symbols.js   |  25 --
 3 files changed, 383 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/0ec3a5f8/lib/android/plugin/android/storage.js
----------------------------------------------------------------------
diff --git a/lib/android/plugin/android/storage.js b/lib/android/plugin/android/storage.js
deleted file mode 100644
index e615ebc..0000000
--- a/lib/android/plugin/android/storage.js
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var utils = require('cordova/utils'),
-    exec = require('cordova/exec'),
-    channel = require('cordova/channel');
-
-var queryQueue = {};
-
-/**
- * SQL result set object
- * PRIVATE METHOD
- * @constructor
- */
-var DroidDB_Rows = function() {
-    this.resultSet = [];    // results array
-    this.length = 0;        // number of rows
-};
-
-/**
- * Get item from SQL result set
- *
- * @param row           The row number to return
- * @return              The row object
- */
-DroidDB_Rows.prototype.item = function(row) {
-    return this.resultSet[row];
-};
-
-/**
- * SQL result set that is returned to user.
- * PRIVATE METHOD
- * @constructor
- */
-var DroidDB_Result = function() {
-    this.rows = new DroidDB_Rows();
-};
-
-/**
- * Callback from native code when query is complete.
- * PRIVATE METHOD
- *
- * @param id   Query id
- */
-function completeQuery(id, data) {
-    var query = queryQueue[id];
-    if (query) {
-        try {
-            delete queryQueue[id];
-
-            // Get transaction
-            var tx = query.tx;
-
-            // If transaction hasn't failed
-            // Note: We ignore all query results if previous query
-            //       in the same transaction failed.
-            if (tx && tx.queryList[id]) {
-
-                // Save query results
-                var r = new DroidDB_Result();
-                r.rows.resultSet = data;
-                r.rows.length = data.length;
-                try {
-                    if (typeof query.successCallback === 'function') {
-                        query.successCallback(query.tx, r);
-                    }
-                } catch (ex) {
-                    console.log("executeSql error calling user success callback: "+ex);
-                }
-
-                tx.queryComplete(id);
-            }
-        } catch (e) {
-            console.log("executeSql error: "+e);
-        }
-    }
-}
-
-/**
- * Callback from native code when query fails
- * PRIVATE METHOD
- *
- * @param reason            Error message
- * @param id                Query id
- */
-function failQuery(reason, id) {
-    var query = queryQueue[id];
-    if (query) {
-        try {
-            delete queryQueue[id];
-
-            // Get transaction
-            var tx = query.tx;
-
-            // If transaction hasn't failed
-            // Note: We ignore all query results if previous query
-            //       in the same transaction failed.
-            if (tx && tx.queryList[id]) {
-                tx.queryList = {};
-
-                try {
-                    if (typeof query.errorCallback === 'function') {
-                        query.errorCallback(query.tx, reason);
-                    }
-                } catch (ex) {
-                    console.log("executeSql error calling user error callback: "+ex);
-                }
-
-                tx.queryFailed(id, reason);
-            }
-
-        } catch (e) {
-            console.log("executeSql error: "+e);
-        }
-    }
-}
-
-/**
- * SQL query object
- * PRIVATE METHOD
- *
- * @constructor
- * @param tx                The transaction object that this query belongs to
- */
-var DroidDB_Query = function(tx) {
-
-    // Set the id of the query
-    this.id = utils.createUUID();
-
-    // Add this query to the queue
-    queryQueue[this.id] = this;
-
-    // Init result
-    this.resultSet = [];
-
-    // Set transaction that this query belongs to
-    this.tx = tx;
-
-    // Add this query to transaction list
-    this.tx.queryList[this.id] = this;
-
-    // Callbacks
-    this.successCallback = null;
-    this.errorCallback = null;
-
-};
-
-/**
- * Transaction object
- * PRIVATE METHOD
- * @constructor
- */
-var DroidDB_Tx = function() {
-
-    // Set the id of the transaction
-    this.id = utils.createUUID();
-
-    // Callbacks
-    this.successCallback = null;
-    this.errorCallback = null;
-
-    // Query list
-    this.queryList = {};
-};
-
-/**
- * Mark query in transaction as complete.
- * If all queries are complete, call the user's transaction success callback.
- *
- * @param id                Query id
- */
-DroidDB_Tx.prototype.queryComplete = function(id) {
-    delete this.queryList[id];
-
-    // If no more outstanding queries, then fire transaction success
-    if (this.successCallback) {
-        var count = 0;
-        var i;
-        for (i in this.queryList) {
-            if (this.queryList.hasOwnProperty(i)) {
-                count++;
-            }
-        }
-        if (count === 0) {
-            try {
-                this.successCallback();
-            } catch(e) {
-                console.log("Transaction error calling user success callback: " + e);
-            }
-        }
-    }
-};
-
-/**
- * Mark query in transaction as failed.
- *
- * @param id                Query id
- * @param reason            Error message
- */
-DroidDB_Tx.prototype.queryFailed = function(id, reason) {
-
-    // The sql queries in this transaction have already been run, since
-    // we really don't have a real transaction implemented in native code.
-    // However, the user callbacks for the remaining sql queries in transaction
-    // will not be called.
-    this.queryList = {};
-
-    if (this.errorCallback) {
-        try {
-            this.errorCallback(reason);
-        } catch(e) {
-            console.log("Transaction error calling user error callback: " + e);
-        }
-    }
-};
-
-/**
- * Execute SQL statement
- *
- * @param sql                   SQL statement to execute
- * @param params                Statement parameters
- * @param successCallback       Success callback
- * @param errorCallback         Error callback
- */
-DroidDB_Tx.prototype.executeSql = function(sql, params, successCallback, errorCallback) {
-
-    // Init params array
-    if (typeof params === 'undefined') {
-        params = [];
-    }
-
-    // Create query and add to queue
-    var query = new DroidDB_Query(this);
-    queryQueue[query.id] = query;
-
-    // Save callbacks
-    query.successCallback = successCallback;
-    query.errorCallback = errorCallback;
-
-    // Call native code
-    exec(null, null, "Storage", "executeSql", [sql, params, query.id]);
-};
-
-var DatabaseShell = function() {
-};
-
-/**
- * Start a transaction.
- * Does not support rollback in event of failure.
- *
- * @param process {Function}            The transaction function
- * @param successCallback {Function}
- * @param errorCallback {Function}
- */
-DatabaseShell.prototype.transaction = function(process, errorCallback, successCallback) {
-    var tx = new DroidDB_Tx();
-    tx.successCallback = successCallback;
-    tx.errorCallback = errorCallback;
-    try {
-        process(tx);
-    } catch (e) {
-        console.log("Transaction error: "+e);
-        if (tx.errorCallback) {
-            try {
-                tx.errorCallback(e);
-            } catch (ex) {
-                console.log("Transaction error calling user error callback: "+e);
-            }
-        }
-    }
-};
-
-/**
- * Open database
- *
- * @param name              Database name
- * @param version           Database version
- * @param display_name      Database display name
- * @param size              Database size in bytes
- * @return                  Database object
- */
-var DroidDB_openDatabase = function(name, version, display_name, size) {
-    exec(null, null, "Storage", "openDatabase", [name, version, display_name, size]);
-    var db = new DatabaseShell();
-    return db;
-};
-
-
-module.exports = {
-    openDatabase:DroidDB_openDatabase,
-    failQuery:failQuery,
-    completeQuery:completeQuery
-};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/0ec3a5f8/lib/android/plugin/android/storage/openDatabase.js
----------------------------------------------------------------------
diff --git a/lib/android/plugin/android/storage/openDatabase.js b/lib/android/plugin/android/storage/openDatabase.js
deleted file mode 100644
index 137cfa1..0000000
--- a/lib/android/plugin/android/storage/openDatabase.js
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-
-var modulemapper = require('cordova/modulemapper'),
-    storage = require('cordova/plugin/android/storage');
-
-var originalOpenDatabase = modulemapper.getOriginalSymbol(window, 'openDatabase');
-
-module.exports = function(name, version, desc, size) {
-    // First patch WebSQL if necessary
-    if (!originalOpenDatabase) {
-        // Not defined, create an openDatabase function for all to use!
-        return storage.openDatabase.apply(this, arguments);
-    }
-
-    // Defined, but some Android devices will throw a SECURITY_ERR -
-    // so we wrap the whole thing in a try-catch and shim in our own
-    // if the device has Android bug 16175.
-    try {
-        return originalOpenDatabase(name, version, desc, size);
-    } catch (ex) {
-        if (ex.code !== 18) {
-            throw ex;
-        }
-    }
-    return storage.openDatabase(name, version, desc, size);
-};
-
-

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/0ec3a5f8/lib/android/plugin/android/storage/symbols.js
----------------------------------------------------------------------
diff --git a/lib/android/plugin/android/storage/symbols.js b/lib/android/plugin/android/storage/symbols.js
deleted file mode 100644
index c575207..0000000
--- a/lib/android/plugin/android/storage/symbols.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/android/storage/openDatabase', 'openDatabase');
-


[13/13] js commit: [win8] Move code from bootstrap-windows8.js into windows8/platform.js

Posted by ag...@apache.org.
[win8] Move code from bootstrap-windows8.js into windows8/platform.js


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/732c9e91
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/732c9e91
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/732c9e91

Branch: refs/heads/master
Commit: 732c9e914eb2d3f01d9f614f41c0af809ce97e46
Parents: 2e988b0
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jul 30 14:55:24 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jul 30 14:55:24 2013 -0400

----------------------------------------------------------------------
 lib/scripts/bootstrap-windows8.js | 24 ------------------------
 lib/windows8/platform.js          | 15 +++++++++------
 2 files changed, 9 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/732c9e91/lib/scripts/bootstrap-windows8.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-windows8.js b/lib/scripts/bootstrap-windows8.js
deleted file mode 100644
index 5606b36..0000000
--- a/lib/scripts/bootstrap-windows8.js
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-require('cordova/modulemapper').clobbers('cordova/windows8/commandProxy', 'cordova.commandProxy');
-require('cordova/channel').onNativeReady.fire();
-

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/732c9e91/lib/windows8/platform.js
----------------------------------------------------------------------
diff --git a/lib/windows8/platform.js b/lib/windows8/platform.js
index 11dce28..09bc8ad 100755
--- a/lib/windows8/platform.js
+++ b/lib/windows8/platform.js
@@ -19,13 +19,16 @@
  *
 */
 
-var cordova = require('cordova'),
-    exec = require('cordova/exec'),
-    channel = cordova.require("cordova/channel");
-
 module.exports = {
-    id: "windows8",
-    initialize:function() {
+    id: 'windows8',
+    bootstrap:function() {
+        var cordova = require('cordova'),
+            exec = require('cordova/exec'),
+            channel = cordova.require('cordova/channel'),
+            modulemapper = require('cordova/modulemapper');
+
+        modulemapper.clobbers('cordova/windows8/commandProxy', 'cordova.commandProxy');
+        channel.onNativeReady.fire();
 
         var onWinJSReady = function () {
             var app = WinJS.Application;


[10/13] js commit: [bb10] Move code from bootstrap-blackberry10.js into blackberry10/platform.js

Posted by ag...@apache.org.
[bb10] Move code from bootstrap-blackberry10.js into blackberry10/platform.js


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/08da18a7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/08da18a7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/08da18a7

Branch: refs/heads/master
Commit: 08da18a75e206f732a475dd63f92c2c4d461e6c3
Parents: 5965f92
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jul 30 11:49:00 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jul 30 11:49:00 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/platform.js          | 107 ++++++++++++++++++++++-
 lib/scripts/bootstrap-blackberry10.js | 135 -----------------------------
 2 files changed, 105 insertions(+), 137 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/08da18a7/lib/blackberry10/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/platform.js b/lib/blackberry10/platform.js
index eb7fd12..73a322f 100644
--- a/lib/blackberry10/platform.js
+++ b/lib/blackberry10/platform.js
@@ -21,9 +21,13 @@
 
 module.exports = {
     id: "blackberry10",
-    initialize: function() {
+    bootstrap: function() {
         var cordova = require('cordova'),
-            addDocumentEventListener = document.addEventListener;
+            channel = require('cordova/channel'),
+            addDocumentEventListener = document.addEventListener,
+            webworksReady = false,
+            alreadyFired = false,
+            listenerRegistered = false;
 
         //override to pass online/offline events to window
         document.addEventListener = function (type) {
@@ -31,6 +35,105 @@ module.exports = {
                 window.addEventListener.apply(window, arguments);
             } else {
                 addDocumentEventListener.apply(document, arguments);
+                //Trapping when users add listeners to the webworks ready event
+                //This way we can make sure not to fire the event before there is a listener
+                if (event.toLowerCase() === 'webworksready') {
+                    listenerRegistered = true;
+                    fireWebworksReadyEvent();
+                }
+            }
+        };
+
+        channel.onPluginsReady.subscribe(function () {
+            webworksReady = true;
+            fireWebworksReadyEvent();
+        });
+
+        //Only fire the webworks event when both webworks is ready and a listener is registered
+        function fireWebworksReadyEvent() {
+            var evt;
+            if (listenerRegistered && webworksReady && !alreadyFired) {
+                alreadyFired = true;
+                evt = document.createEvent('Events');
+                evt.initEvent('webworksready', true, true);
+                document.dispatchEvent(evt);
+                channel.onNativeReady.fire();
+            }
+        }
+
+        function RemoteFunctionCall(functionUri) {
+            var params = {};
+
+            function composeUri() {
+                return "http://localhost:8472/" + functionUri;
+            }
+
+            function createXhrRequest(uri, isAsync) {
+                var request = new XMLHttpRequest();
+                request.open("POST", uri, isAsync);
+                request.setRequestHeader("Content-Type", "application/json");
+                return request;
+            }
+
+            this.addParam = function (name, value) {
+                params[name] = encodeURIComponent(JSON.stringify(value));
+            };
+
+            this.makeSyncCall = function (success, error) {
+                var requestUri = composeUri(),
+                request = createXhrRequest(requestUri, false),
+                response,
+                errored,
+                cb,
+                data;
+
+                request.send(JSON.stringify(params));
+                response = JSON.parse(decodeURIComponent(request.responseText) || "null");
+                return response;
+            };
+        }
+
+        window.webworks = {
+            exec: function (success, fail, service, action, args) {
+                var uri = service + "/" + action,
+                request = new RemoteFunctionCall(uri),
+                callbackId = service + cordova.callbackId++,
+                response,
+                name,
+                didSucceed;
+
+                for (name in args) {
+                    if (Object.hasOwnProperty.call(args, name)) {
+                        request.addParam(name, args[name]);
+                    }
+                }
+
+                cordova.callbacks[callbackId] = {success:success, fail:fail};
+                request.addParam("callbackId", callbackId);
+
+                response = request.makeSyncCall();
+
+                //Old WebWorks Extension success
+                if (response.code === 42) {
+                    if (success) {
+                        success(response.data, response);
+                    }
+                    delete cordova.callbacks[callbackId];
+                } else if (response.code < 0) {
+                    if (fail) {
+                        fail(response.msg, response);
+                    }
+                    delete cordova.callbacks[callbackId];
+                } else {
+                    didSucceed = response.code === cordova.callbackStatus.OK || response.code === cordova.callbackStatus.NO_RESULT;
+                    cordova.callbackFromNative(callbackId, didSucceed, response.code, [ didSucceed ? response.data : response.msg ], !!response.keepCallback);
+                }
+            },
+            defineReadOnlyField: function (obj, field, value) {
+                Object.defineProperty(obj, field, {
+                    "value": value,
+                    "writable": false
+                });
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/08da18a7/lib/scripts/bootstrap-blackberry10.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-blackberry10.js b/lib/scripts/bootstrap-blackberry10.js
deleted file mode 100644
index 691faf0..0000000
--- a/lib/scripts/bootstrap-blackberry10.js
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-/*global cordova*/
-(function () {
-    var docAddEventListener = document.addEventListener,
-        webworksReady = false,
-        alreadyFired = false,
-        listenerRegistered = false;
-
-    //Only fire the webworks event when both webworks is ready and a listener is registered
-    function fireWebworksReadyEvent() {
-        var evt;
-        if (listenerRegistered && webworksReady && !alreadyFired) {
-            alreadyFired = true;
-            evt = document.createEvent('Events');
-            evt.initEvent('webworksready', true, true);
-            document.dispatchEvent(evt);
-        }
-    }
-
-    //Trapping when users add listeners to the webworks ready event
-    //This way we can make sure not to fire the event before there is a listener
-    document.addEventListener = function (event, callback, capture) {
-        docAddEventListener.call(document, event, callback, capture);
-        if (event.toLowerCase() === 'webworksready') {
-            listenerRegistered = true;
-            fireWebworksReadyEvent();
-        }
-    };
-
-    function RemoteFunctionCall(functionUri) {
-        var params = {};
-
-        function composeUri() {
-            return "http://localhost:8472/" + functionUri;
-        }
-
-        function createXhrRequest(uri, isAsync) {
-            var request = new XMLHttpRequest();
-            request.open("POST", uri, isAsync);
-            request.setRequestHeader("Content-Type", "application/json");
-            return request;
-        }
-
-        this.addParam = function (name, value) {
-            params[name] = encodeURIComponent(JSON.stringify(value));
-        };
-
-        this.makeSyncCall = function (success, error) {
-            var requestUri = composeUri(),
-            request = createXhrRequest(requestUri, false),
-            response,
-            errored,
-            cb,
-            data;
-
-            request.send(JSON.stringify(params));
-            response = JSON.parse(decodeURIComponent(request.responseText) || "null");
-            return response;
-        };
-    }
-
-    window.webworks = {
-        exec: function (success, fail, service, action, args) {
-            var uri = service + "/" + action,
-            request = new RemoteFunctionCall(uri),
-            callbackId = service + cordova.callbackId++,
-            response,
-            name,
-            didSucceed;
-
-            for (name in args) {
-                if (Object.hasOwnProperty.call(args, name)) {
-                    request.addParam(name, args[name]);
-                }
-            }
-
-            cordova.callbacks[callbackId] = {success:success, fail:fail};
-            request.addParam("callbackId", callbackId);
-
-            response = request.makeSyncCall();
-
-            //Old WebWorks Extension success
-            if (response.code === 42) {
-                if (success) {
-                    success(response.data, response);
-                }
-                delete cordova.callbacks[callbackId];
-            } else if (response.code < 0) {
-                if (fail) {
-                    fail(response.msg, response);
-                }
-                delete cordova.callbacks[callbackId];
-            } else {
-                didSucceed = response.code === cordova.callbackStatus.OK || response.code === cordova.callbackStatus.NO_RESULT;
-                cordova.callbackFromNative(callbackId, didSucceed, response.code, [ didSucceed ? response.data : response.msg ], !!response.keepCallback);
-            }
-        },
-        defineReadOnlyField: function (obj, field, value) {
-            Object.defineProperty(obj, field, {
-                "value": value,
-                "writable": false
-            });
-        }
-    };
-
-    require("cordova/channel").onPluginsReady.subscribe(function () {
-        webworksReady = true;
-        fireWebworksReadyEvent();
-    });
-}());
-
-document.addEventListener("DOMContentLoaded", function () {
-    document.addEventListener("webworksready", function () {
-        require('cordova/channel').onNativeReady.fire();
-    });
-});


[11/13] js commit: [ios] Move code from bootstrap-ios.js into ios/platform.js

Posted by ag...@apache.org.
[ios] Move code from bootstrap-ios.js into ios/platform.js


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/c4459231
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/c4459231
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/c4459231

Branch: refs/heads/master
Commit: c4459231dcea2247e579697e237b98b9f3917595
Parents: 08da18a
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jul 30 11:51:02 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jul 30 11:51:02 2013 -0400

----------------------------------------------------------------------
 lib/ios/platform.js          |  5 +++--
 lib/scripts/bootstrap-ios.js | 22 ----------------------
 2 files changed, 3 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c4459231/lib/ios/platform.js
----------------------------------------------------------------------
diff --git a/lib/ios/platform.js b/lib/ios/platform.js
index 7d6216f..36529ba 100644
--- a/lib/ios/platform.js
+++ b/lib/ios/platform.js
@@ -20,8 +20,9 @@
 */
 
 module.exports = {
-    id: "ios",
-    initialize:function() {
+    id: 'ios',
+    bootstrap: function() {
+        require('cordova/channel').onNativeReady.fire();
     }
 };
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c4459231/lib/scripts/bootstrap-ios.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-ios.js b/lib/scripts/bootstrap-ios.js
deleted file mode 100644
index 91a6f71..0000000
--- a/lib/scripts/bootstrap-ios.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-require('cordova/channel').onNativeReady.fire();


[09/13] js commit: [android] Move code from bootstrap-android.js into android/platform.js

Posted by ag...@apache.org.
[android] Move code from bootstrap-android.js into android/platform.js


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/5965f923
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/5965f923
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/5965f923

Branch: refs/heads/master
Commit: 5965f9234f5437717f533719fa57e7da16fe7bd3
Parents: f1d3b0b
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jul 30 11:47:37 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jul 30 11:47:37 2013 -0400

----------------------------------------------------------------------
 lib/android/platform.js          | 21 +++++++++++++++------
 lib/scripts/bootstrap-android.js | 29 -----------------------------
 2 files changed, 15 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/5965f923/lib/android/platform.js
----------------------------------------------------------------------
diff --git a/lib/android/platform.js b/lib/android/platform.js
index 231df7a..bf966c0 100644
--- a/lib/android/platform.js
+++ b/lib/android/platform.js
@@ -20,11 +20,20 @@
 */
 
 module.exports = {
-    id: "android",
-    initialize:function() {
-        var channel = require("cordova/channel"),
+    id: 'android',
+    bootstrap: function() {
+        var channel = require('cordova/channel'),
             cordova = require('cordova'),
-            exec = require('cordova/exec');
+            exec = require('cordova/exec'),
+            modulemapper = require('cordova/modulemapper');
+
+        // Tell the native code that a page change has occurred.
+        exec(null, null, 'PluginManager', 'startup', []);
+        // Tell the JS that the native side is ready.
+        channel.onNativeReady.fire();
+
+        // TODO: Extract this as a proper plugin.
+        modulemapper.clobbers('cordova/plugin/android/app', 'navigator.app');
 
         // Inject a listener for the backbutton on the document.
         var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
@@ -40,8 +49,8 @@ module.exports = {
 
         // Let native code know we are all done on the JS side.
         // Native code will then un-hide the WebView.
-        channel.join(function() {
+        channel.onCordovaReady.subscribe(function() {
             exec(null, null, "App", "show", []);
-        }, [channel.onCordovaReady]);
+        });
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/5965f923/lib/scripts/bootstrap-android.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-android.js b/lib/scripts/bootstrap-android.js
deleted file mode 100644
index 6cf1d80..0000000
--- a/lib/scripts/bootstrap-android.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-// Wire up the "App" plugin.
-// TODO: Extract this as a proper plugin.
-require('cordova/modulemapper').clobbers('cordova/plugin/android/app', 'navigator.app');
-// Tell the native code that a page change has occurred.
-require('cordova/exec')(null, null, 'PluginManager', 'startup', []);
-// Tell the JS that the native side is ready.
-require('cordova/channel').onNativeReady.fire();
-


[07/13] js commit: [CB-4418] Delete loadMatchingModules() and move modulemapping call into bootstrap.js (from platform.js)

Posted by ag...@apache.org.
[CB-4418] Delete loadMatchingModules() and move modulemapping call into bootstrap.js (from platform.js)


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/6e4bd92f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/6e4bd92f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/6e4bd92f

Branch: refs/heads/master
Commit: 6e4bd92f45c02972b3a59cd0f115f31fdda9f2cc
Parents: d82ed34
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jul 30 10:32:13 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jul 30 10:34:02 2013 -0400

----------------------------------------------------------------------
 lib/android/platform.js           |  8 +-------
 lib/blackberry10/platform.js      |  7 +------
 lib/common/modulemapper.js        |  8 --------
 lib/ios/platform.js               |  6 ------
 lib/osx/platform.js               |  6 ------
 lib/scripts/bootstrap-android.js  |  5 +++++
 lib/scripts/bootstrap-windows8.js |  2 ++
 lib/scripts/bootstrap.js          |  2 ++
 lib/test/platform.js              |  1 -
 lib/windows8/platform.js          | 15 +--------------
 lib/windowsphone/platform.js      |  8 --------
 test/test.modulemapper.js         | 23 -----------------------
 12 files changed, 12 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/android/platform.js
----------------------------------------------------------------------
diff --git a/lib/android/platform.js b/lib/android/platform.js
index 0b2c411..231df7a 100644
--- a/lib/android/platform.js
+++ b/lib/android/platform.js
@@ -24,13 +24,7 @@ module.exports = {
     initialize:function() {
         var channel = require("cordova/channel"),
             cordova = require('cordova'),
-            exec = require('cordova/exec'),
-            modulemapper = require('cordova/modulemapper');
-
-        modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
-        modulemapper.clobbers('cordova/plugin/android/app', 'navigator.app');
-
-        modulemapper.mapModules(window);
+            exec = require('cordova/exec');
 
         // Inject a listener for the backbutton on the document.
         var backButtonChannel = cordova.addDocumentEventHandler('backbutton');

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/blackberry10/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/platform.js b/lib/blackberry10/platform.js
index 007c06e..eb7fd12 100644
--- a/lib/blackberry10/platform.js
+++ b/lib/blackberry10/platform.js
@@ -22,14 +22,9 @@
 module.exports = {
     id: "blackberry10",
     initialize: function() {
-        var modulemapper = require('cordova/modulemapper'),
-            cordova = require('cordova'),
+        var cordova = require('cordova'),
             addDocumentEventListener = document.addEventListener;
 
-        modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
-        modulemapper.loadMatchingModules(new RegExp('cordova/blackberry10/.*bbsymbols$'));
-        modulemapper.mapModules(window);
-
         //override to pass online/offline events to window
         document.addEventListener = function (type) {
             if (type === "online" || type === "offline") {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/common/modulemapper.js
----------------------------------------------------------------------
diff --git a/lib/common/modulemapper.js b/lib/common/modulemapper.js
index 208fbcb..ea14c2a 100644
--- a/lib/common/modulemapper.js
+++ b/lib/common/modulemapper.js
@@ -111,13 +111,5 @@ exports.getOriginalSymbol = function(context, symbolPath) {
     return obj;
 };
 
-exports.loadMatchingModules = function(matchingRegExp) {
-    for (var k in moduleMap) {
-        if (matchingRegExp.exec(k)) {
-            require(k);
-        }
-    }
-};
-
 exports.reset();
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/ios/platform.js
----------------------------------------------------------------------
diff --git a/lib/ios/platform.js b/lib/ios/platform.js
index 83c02cf..7d6216f 100644
--- a/lib/ios/platform.js
+++ b/lib/ios/platform.js
@@ -22,12 +22,6 @@
 module.exports = {
     id: "ios",
     initialize:function() {
-        var modulemapper = require('cordova/modulemapper');
-
-        modulemapper.loadMatchingModules(/cordova.*\/plugininit$/);
-
-        modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
-        modulemapper.mapModules(window);
     }
 };
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/osx/platform.js
----------------------------------------------------------------------
diff --git a/lib/osx/platform.js b/lib/osx/platform.js
index be40bf5..c74c2be 100644
--- a/lib/osx/platform.js
+++ b/lib/osx/platform.js
@@ -22,12 +22,6 @@
 module.exports = {
     id: "osx",
     initialize:function() {
-        var modulemapper = require('cordova/modulemapper');
-
-        modulemapper.loadMatchingModules(/cordova.*\/plugininit$/);
-
-        modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
-        modulemapper.mapModules(window);
     }
 };
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/scripts/bootstrap-android.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-android.js b/lib/scripts/bootstrap-android.js
index aa1ef0a..6cf1d80 100644
--- a/lib/scripts/bootstrap-android.js
+++ b/lib/scripts/bootstrap-android.js
@@ -19,6 +19,11 @@
  *
 */
 
+// Wire up the "App" plugin.
+// TODO: Extract this as a proper plugin.
+require('cordova/modulemapper').clobbers('cordova/plugin/android/app', 'navigator.app');
 // Tell the native code that a page change has occurred.
 require('cordova/exec')(null, null, 'PluginManager', 'startup', []);
+// Tell the JS that the native side is ready.
 require('cordova/channel').onNativeReady.fire();
+

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/scripts/bootstrap-windows8.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-windows8.js b/lib/scripts/bootstrap-windows8.js
index 91a6f71..5606b36 100644
--- a/lib/scripts/bootstrap-windows8.js
+++ b/lib/scripts/bootstrap-windows8.js
@@ -19,4 +19,6 @@
  *
 */
 
+require('cordova/modulemapper').clobbers('cordova/windows8/commandProxy', 'cordova.commandProxy');
 require('cordova/channel').onNativeReady.fire();
+

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/scripts/bootstrap.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap.js b/lib/scripts/bootstrap.js
index 3a2481e..4a8bb87 100644
--- a/lib/scripts/bootstrap.js
+++ b/lib/scripts/bootstrap.js
@@ -27,6 +27,7 @@
 
     var channel = require('cordova/channel');
     var cordova = require('cordova');
+    var modulemapper = require('cordova/modulemapper');
     var pluginloader = require('cordova/pluginloader');
 
     var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
@@ -114,6 +115,7 @@
     channel.join(function() {
         // Call the platform-specific initialization
         require('cordova/platform').initialize();
+        modulemapper.mapModules(window);
 
         // Fire event to notify that all objects are created
         channel.onCordovaReady.fire();

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/test/platform.js
----------------------------------------------------------------------
diff --git a/lib/test/platform.js b/lib/test/platform.js
index 4315d8a..da71794 100644
--- a/lib/test/platform.js
+++ b/lib/test/platform.js
@@ -21,6 +21,5 @@
 
 module.exports = {
     id: "test platform",
-    runtime: function () {},
     initialize: function () {}
 };

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/windows8/platform.js
----------------------------------------------------------------------
diff --git a/lib/windows8/platform.js b/lib/windows8/platform.js
index 7e3766f..11dce28 100755
--- a/lib/windows8/platform.js
+++ b/lib/windows8/platform.js
@@ -21,25 +21,12 @@
 
 var cordova = require('cordova'),
     exec = require('cordova/exec'),
-    channel = cordova.require("cordova/channel"),
-    modulemapper = require('cordova/modulemapper');
-
-/*
- * Define native implementations ( there is no native layer, so need to make sure the proxies are there )
- */
-modulemapper.loadMatchingModules(/cordova.*\/windows8\/.*Proxy$/);
+    channel = cordova.require("cordova/channel");
 
 module.exports = {
     id: "windows8",
     initialize:function() {
 
-        modulemapper.loadMatchingModules(/cordova.*\/plugininit$/);
-
-        modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
-        modulemapper.clobbers('cordova/windows8/commandProxy', 'cordova.commandProxy');
-
-        modulemapper.mapModules(window);
-
         var onWinJSReady = function () {
             var app = WinJS.Application;
             var checkpointHandler = function checkpointHandler() {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/lib/windowsphone/platform.js
----------------------------------------------------------------------
diff --git a/lib/windowsphone/platform.js b/lib/windowsphone/platform.js
index 851ef09..c3725dc 100644
--- a/lib/windowsphone/platform.js
+++ b/lib/windowsphone/platform.js
@@ -25,14 +25,6 @@ var cordova = require('cordova'),
 module.exports = {
     id: "windowsphone",
     initialize:function() {
-        var modulemapper = require('cordova/modulemapper');
-
-        modulemapper.loadMatchingModules(/cordova.*\/plugininit$/);
-
-        modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
-
-        modulemapper.mapModules(window);
-
         // Inject a listener for the backbutton, and tell native to override the flag (true/false) when we have 1 or more, or 0, listeners
         var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
         backButtonChannel.onHasSubscribersChange = function() {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6e4bd92f/test/test.modulemapper.js
----------------------------------------------------------------------
diff --git a/test/test.modulemapper.js b/test/test.modulemapper.js
index 726b6eb..d4c2806 100644
--- a/test/test.modulemapper.js
+++ b/test/test.modulemapper.js
@@ -166,29 +166,6 @@ describe('modulemapper', function() {
         expect(modulemapper.getOriginalSymbol(context, 'obj')).toBe(context.obj);
         expect(modulemapper.getOriginalSymbol(context, 'obj.str')).toBe(context.obj.str);
     });
-    it('should load modules with loadMatchingModules', function() {
-        var spyModules = {};
-        this.after(function() {
-            Object.keys(spyModules).forEach(define.remove);
-        });
-        function addModule(name) {
-            spyModules[name] = jasmine.createSpy(name);
-            define(name, spyModules[name]);
-        }
-        function expectCalled(names) {
-            for (var k in spyModules) {
-                expect(spyModules[k].wasCalled).toBe(names.indexOf(k) != -1, 'for module:' + k);
-            }
-        }
-        addModule('foo/a');
-        addModule('foo/b');
-        addModule('foo/symbols1');
-        addModule('foo/symbols');
-        addModule('foo/bar/symbols');
-        addModule('baz/symbols');
-        modulemapper.loadMatchingModules(/^foo.*\/symbols$/);
-        expectCalled(['foo/symbols', 'foo/bar/symbols']);
-    });
     it('should log about deprecated property access', function() {
         var origConsoleLog = console.log;
         console.log = jasmine.createSpy('console.log');


[08/13] js commit: Move bootstrap.js logic into a proper module "init.js"

Posted by ag...@apache.org.
Move bootstrap.js logic into a proper module "init.js"


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/f1d3b0bd
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/f1d3b0bd
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/f1d3b0bd

Branch: refs/heads/master
Commit: f1d3b0bda42c0493385ed1885492221fe47af482
Parents: 6e4bd92
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jul 30 10:58:39 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jul 30 10:58:39 2013 -0400

----------------------------------------------------------------------
 lib/common/init.js       | 129 ++++++++++++++++++++++++++++++++++++++++++
 lib/scripts/bootstrap.js | 115 +------------------------------------
 2 files changed, 130 insertions(+), 114 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f1d3b0bd/lib/common/init.js
----------------------------------------------------------------------
diff --git a/lib/common/init.js b/lib/common/init.js
new file mode 100644
index 0000000..65c6380
--- /dev/null
+++ b/lib/common/init.js
@@ -0,0 +1,129 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var channel = require('cordova/channel');
+var cordova = require('cordova');
+var modulemapper = require('cordova/modulemapper');
+var platform = require('cordova/platform');
+var pluginloader = require('cordova/pluginloader');
+
+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) {
+    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);
+            }
+        }
+    }
+    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();
+}
+
+modulemapper.clobbers('cordova', 'cordova');
+modulemapper.clobbers('cordova/exec', 'cordova.exec');
+modulemapper.clobbers('cordova/exec', 'Cordova.exec');
+
+// Call the platform-specific initialization.
+platform.bootstrap && platform.bootstrap();
+
+pluginloader.load(function() {
+    channel.onPluginsReady.fire();
+});
+
+/**
+ * Create all cordova objects once native side is ready.
+ */
+channel.join(function() {
+    modulemapper.mapModules(window);
+
+    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);
+

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f1d3b0bd/lib/scripts/bootstrap.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap.js b/lib/scripts/bootstrap.js
index 4a8bb87..275d691 100644
--- a/lib/scripts/bootstrap.js
+++ b/lib/scripts/bootstrap.js
@@ -19,117 +19,4 @@
  *
 */
 
-(function (context) {
-    if (context._cordovaJsLoaded) {
-        throw new Error('cordova.js included multiple times.');
-    }
-    context._cordovaJsLoaded = true;
-
-    var channel = require('cordova/channel');
-    var cordova = require('cordova');
-    var modulemapper = require('cordova/modulemapper');
-    var pluginloader = require('cordova/pluginloader');
-
-    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) {
-        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);
-                }
-            }
-        }
-        return newNavigator;
-    }
-    if (context.navigator) {
-        context.navigator = replaceNavigator(context.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();
-    }
-
-    modulemapper.clobbers('cordova', 'cordova');
-    modulemapper.clobbers('cordova/exec', 'cordova.exec');
-    modulemapper.clobbers('cordova/exec', 'Cordova.exec');
-
-    pluginloader.load(function() {
-        channel.onPluginsReady.fire();
-    });
-
-    /**
-     * Create all cordova objects once native side is ready.
-     */
-    channel.join(function() {
-        // Call the platform-specific initialization
-        require('cordova/platform').initialize();
-        modulemapper.mapModules(window);
-
-        // 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.
-        // 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);
-
-    }, platformInitChannelsArray);
-
-}(window));
+require('cordova/init');


[04/13] js commit: [win8] Move commandProxy.js into windows8/

Posted by ag...@apache.org.
[win8] Move commandProxy.js into windows8/

Doesn't look to be used by any other platform.


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/c7839aed
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/c7839aed
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/c7839aed

Branch: refs/heads/master
Commit: c7839aed7ac9201bdfb8add89668cb6b8217958d
Parents: 0ec3a5f
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jul 30 10:20:25 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jul 30 10:20:25 2013 -0400

----------------------------------------------------------------------
 lib/common/commandProxy.js            | 46 ------------------------------
 lib/windows8/exec.js                  |  2 +-
 lib/windows8/platform.js              |  2 +-
 lib/windows8/windows8/commandProxy.js | 46 ++++++++++++++++++++++++++++++
 4 files changed, 48 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c7839aed/lib/common/commandProxy.js
----------------------------------------------------------------------
diff --git a/lib/common/commandProxy.js b/lib/common/commandProxy.js
deleted file mode 100644
index e640003..0000000
--- a/lib/common/commandProxy.js
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-
-// internal map of proxy function
-var CommandProxyMap = {};
-
-module.exports = {
-
-    // example: cordova.commandProxy.add("Accelerometer",{getCurrentAcceleration: function(successCallback, errorCallback, options) {...},...);
-    add:function(id,proxyObj) {
-        console.log("adding proxy for " + id);
-        CommandProxyMap[id] = proxyObj;
-        return proxyObj;
-    },
-
-    // cordova.commandProxy.remove("Accelerometer");
-    remove:function(id) {
-        var proxy = CommandProxyMap[id];
-        delete CommandProxyMap[id];
-        CommandProxyMap[id] = null;
-        return proxy;
-    },
-
-    get:function(service,action) {
-        return ( CommandProxyMap[service] ? CommandProxyMap[service][action] : null );
-    }
-};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c7839aed/lib/windows8/exec.js
----------------------------------------------------------------------
diff --git a/lib/windows8/exec.js b/lib/windows8/exec.js
index 46343bd..4583594 100644
--- a/lib/windows8/exec.js
+++ b/lib/windows8/exec.js
@@ -20,7 +20,7 @@
 */
 
 var cordova = require('cordova');
-var commandProxy = require('cordova/commandProxy');
+var commandProxy = require('cordova/windows8/commandProxy');
 
 /**
  * Execute a cordova command.  It is up to the native side whether this action

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c7839aed/lib/windows8/platform.js
----------------------------------------------------------------------
diff --git a/lib/windows8/platform.js b/lib/windows8/platform.js
index 2e3618e..7e3766f 100755
--- a/lib/windows8/platform.js
+++ b/lib/windows8/platform.js
@@ -36,7 +36,7 @@ module.exports = {
         modulemapper.loadMatchingModules(/cordova.*\/plugininit$/);
 
         modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
-        modulemapper.clobbers('cordova/commandProxy', 'cordova.commandProxy');
+        modulemapper.clobbers('cordova/windows8/commandProxy', 'cordova.commandProxy');
 
         modulemapper.mapModules(window);
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c7839aed/lib/windows8/windows8/commandProxy.js
----------------------------------------------------------------------
diff --git a/lib/windows8/windows8/commandProxy.js b/lib/windows8/windows8/commandProxy.js
new file mode 100644
index 0000000..e640003
--- /dev/null
+++ b/lib/windows8/windows8/commandProxy.js
@@ -0,0 +1,46 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+
+// internal map of proxy function
+var CommandProxyMap = {};
+
+module.exports = {
+
+    // example: cordova.commandProxy.add("Accelerometer",{getCurrentAcceleration: function(successCallback, errorCallback, options) {...},...);
+    add:function(id,proxyObj) {
+        console.log("adding proxy for " + id);
+        CommandProxyMap[id] = proxyObj;
+        return proxyObj;
+    },
+
+    // cordova.commandProxy.remove("Accelerometer");
+    remove:function(id) {
+        var proxy = CommandProxyMap[id];
+        delete CommandProxyMap[id];
+        CommandProxyMap[id] = null;
+        return proxy;
+    },
+
+    get:function(service,action) {
+        return ( CommandProxyMap[service] ? CommandProxyMap[service][action] : null );
+    }
+};
\ No newline at end of file


[05/13] js commit: [all] Make pluginloader call a callback instead of firing a channel.

Posted by ag...@apache.org.
[all] Make pluginloader call a callback instead of firing a channel.


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/0df3426f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/0df3426f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/0df3426f

Branch: refs/heads/master
Commit: 0df3426f2bbfd7e919eec82776d8400665a1660e
Parents: c7839ae
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jul 30 10:24:11 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jul 30 10:24:11 2013 -0400

----------------------------------------------------------------------
 lib/common/pluginloader.js | 24 ++++++++----------------
 lib/scripts/bootstrap.js   |  5 ++++-
 2 files changed, 12 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/0df3426f/lib/common/pluginloader.js
----------------------------------------------------------------------
diff --git a/lib/common/pluginloader.js b/lib/common/pluginloader.js
index 19f84bb..18e9a0b 100644
--- a/lib/common/pluginloader.js
+++ b/lib/common/pluginloader.js
@@ -19,7 +19,6 @@
  *
 */
 
-var channel = require('cordova/channel');
 var modulemapper = require('cordova/modulemapper');
 
 // Helper function to inject a <script> tag.
@@ -32,7 +31,7 @@ function injectScript(url, onload, onerror) {
     document.head.appendChild(script);
 }
 
-function onScriptLoadingComplete(moduleList) {
+function onScriptLoadingComplete(moduleList, finishPluginLoading) {
     // Loop through all the plugins and then through their clobbers and merges.
     for (var i = 0, module; module = moduleList[i]; i++) {
         if (module) {
@@ -65,18 +64,11 @@ function onScriptLoadingComplete(moduleList) {
     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) {
+function handlePluginsObject(path, moduleList, finishPluginLoading) {
     // Now inject the scripts.
     var scriptCounter = moduleList.length;
 
@@ -86,7 +78,7 @@ function handlePluginsObject(path, moduleList) {
     }
     function scriptLoadedCallback() {
         if (!--scriptCounter) {
-            onScriptLoadingComplete(moduleList);
+            onScriptLoadingComplete(moduleList, finishPluginLoading);
         }
     }
 
@@ -95,17 +87,17 @@ function handlePluginsObject(path, moduleList) {
     }
 }
 
-function injectPluginScript(pathPrefix) {
+function injectPluginScript(pathPrefix, finishPluginLoading) {
     injectScript(pathPrefix + 'cordova_plugins.js', function(){
         try {
             var moduleList = require("cordova/plugin_list");
-            handlePluginsObject(pathPrefix, moduleList);
+            handlePluginsObject(pathPrefix, moduleList, finishPluginLoading);
         } 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
+    }, finishPluginLoading); // also, add script load error handler for file not found
 }
 
 function findCordovaPath() {
@@ -125,12 +117,12 @@ function findCordovaPath() {
 // 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() {
+exports.load = function(callback) {
     var pathPrefix = findCordovaPath();
     if (pathPrefix === null) {
         console.log('Could not find cordova.js script tag. Plugin loading may fail.');
         pathPrefix = '';
     }
-    injectPluginScript(pathPrefix);
+    injectPluginScript(pathPrefix, callback);
 };
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/0df3426f/lib/scripts/bootstrap.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap.js b/lib/scripts/bootstrap.js
index 197816d..1d797e9 100644
--- a/lib/scripts/bootstrap.js
+++ b/lib/scripts/bootstrap.js
@@ -100,6 +100,10 @@
         channel.onNativeReady.fire();
     }
 
+    pluginloader.load(function() {
+        channel.onPluginsReady.fire();
+    });
+
     /**
      * Create all cordova objects once native side is ready.
      */
@@ -122,5 +126,4 @@
 
     }, platformInitChannelsArray);
 
-    pluginloader.load();
 }(window));


[02/13] js commit: [all] Move some start-up logic from cordova.js -> bootstrap.js

Posted by ag...@apache.org.
[all] Move some start-up logic from cordova.js -> bootstrap.js


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/b248abfe
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/b248abfe
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/b248abfe

Branch: refs/heads/master
Commit: b248abfe980c3a452d28e17227bbe112eddbdef4
Parents: 853a5fc
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon Jul 29 22:39:32 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jul 29 22:39:32 2013 -0400

----------------------------------------------------------------------
 lib/cordova.js           | 25 -------------------------
 lib/scripts/bootstrap.js | 31 +++++++++++++++++++++++++++----
 2 files changed, 27 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/b248abfe/lib/cordova.js
----------------------------------------------------------------------
diff --git a/lib/cordova.js b/lib/cordova.js
index c6a37fd..77a1d23 100644
--- a/lib/cordova.js
+++ b/lib/cordova.js
@@ -23,16 +23,6 @@
 var channel = require('cordova/channel');
 
 /**
- * Listen for DOMContentLoaded and notify our channel subscribers.
- */
-document.addEventListener('DOMContentLoaded', function() {
-    channel.onDOMContentLoaded.fire();
-}, false);
-if (document.readyState == 'complete' || document.readyState == 'interactive') {
-    channel.onDOMContentLoaded.fire();
-}
-
-/**
  * Intercept calls to addEventListener + removeEventListener and handle deviceready,
  * resume, and pause events.
  */
@@ -98,17 +88,6 @@ function createEvent(type, data) {
     return event;
 }
 
-if(typeof window.console === "undefined") {
-    window.console = {
-        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,
@@ -247,9 +226,5 @@ 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.addStickyDocumentEventHandler('deviceready');
 
 module.exports = cordova;

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/b248abfe/lib/scripts/bootstrap.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap.js b/lib/scripts/bootstrap.js
index 27d653c..197816d 100644
--- a/lib/scripts/bootstrap.js
+++ b/lib/scripts/bootstrap.js
@@ -26,6 +26,7 @@
     context._cordovaJsLoaded = true;
 
     var channel = require('cordova/channel');
+    var cordova = require('cordova');
     var pluginloader = require('cordova/pluginloader');
 
     var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
@@ -67,6 +68,31 @@
         context.navigator = replaceNavigator(context.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.
@@ -96,8 +122,5 @@
 
     }, platformInitChannelsArray);
 
-    // Don't attempt to load when running unit tests.
-    if (typeof XMLHttpRequest != 'undefined') {
-        pluginloader.load();
-    }
+    pluginloader.load();
 }(window));


[12/13] js commit: [test] Move code from bootstrap-test.js into test/platform.js

Posted by ag...@apache.org.
[test] Move code from bootstrap-test.js into test/platform.js


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/2e988b03
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/2e988b03
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/2e988b03

Branch: refs/heads/master
Commit: 2e988b030f3d6e56a1a96aa9f1af0bcdc0640285
Parents: c445923
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jul 30 11:52:37 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jul 30 11:52:37 2013 -0400

----------------------------------------------------------------------
 lib/scripts/bootstrap-test.js | 30 ------------------------------
 lib/test/platform.js          | 15 +++++++++++++--
 2 files changed, 13 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/2e988b03/lib/scripts/bootstrap-test.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-test.js b/lib/scripts/bootstrap-test.js
deleted file mode 100644
index 531ea4a..0000000
--- a/lib/scripts/bootstrap-test.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-var propertyreplacer = require('cordova/propertyreplacer');
-
-require('cordova/builder').replaceHookForTesting = function(obj, key) {
-    // This doesn't clean up non-clobbering assignments, nor does it work for
-    // getters. It does work to un-clobber clobbered / merged symbols, which
-    // is generally good enough for tests.
-    if (obj[key]) {
-        propertyreplacer.stub(obj, key);
-    }
-};
-

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/2e988b03/lib/test/platform.js
----------------------------------------------------------------------
diff --git a/lib/test/platform.js b/lib/test/platform.js
index da71794..fcc31ae 100644
--- a/lib/test/platform.js
+++ b/lib/test/platform.js
@@ -20,6 +20,17 @@
 */
 
 module.exports = {
-    id: "test platform",
-    initialize: function () {}
+    id: 'test platform',
+    bootstrap: function() {
+        var propertyreplacer = require('cordova/propertyreplacer');
+
+        require('cordova/builder').replaceHookForTesting = function(obj, key) {
+            // This doesn't clean up non-clobbering assignments, nor does it work for
+            // getters. It does work to un-clobber clobbered / merged symbols, which
+            // is generally good enough for tests.
+            if (obj[key]) {
+                propertyreplacer.stub(obj, key);
+            }
+        };
+    }
 };


[06/13] js commit: [CB-4418] Remove final symbols.js file by folding it into bootstrap.

Posted by ag...@apache.org.
[CB-4418] Remove final symbols.js file by folding it into bootstrap.


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/d82ed344
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/d82ed344
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/d82ed344

Branch: refs/heads/master
Commit: d82ed344241be042b7e159cfc161783016fccfce
Parents: 0df3426
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jul 30 10:28:53 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jul 30 10:28:53 2013 -0400

----------------------------------------------------------------------
 lib/common/symbols.js    | 27 ---------------------------
 lib/scripts/bootstrap.js |  4 ++++
 2 files changed, 4 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d82ed344/lib/common/symbols.js
----------------------------------------------------------------------
diff --git a/lib/common/symbols.js b/lib/common/symbols.js
deleted file mode 100644
index 573b7e9..0000000
--- a/lib/common/symbols.js
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var modulemapper = require('cordova/modulemapper');
-
-// Use merges here in case others symbols files depend on this running first,
-// but fail to declare the dependency with a require().
-modulemapper.merges('cordova', 'cordova');
-modulemapper.clobbers('cordova/exec', 'cordova.exec');
-modulemapper.clobbers('cordova/exec', 'Cordova.exec');

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d82ed344/lib/scripts/bootstrap.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap.js b/lib/scripts/bootstrap.js
index 1d797e9..3a2481e 100644
--- a/lib/scripts/bootstrap.js
+++ b/lib/scripts/bootstrap.js
@@ -100,6 +100,10 @@
         channel.onNativeReady.fire();
     }
 
+    modulemapper.clobbers('cordova', 'cordova');
+    modulemapper.clobbers('cordova/exec', 'cordova.exec');
+    modulemapper.clobbers('cordova/exec', 'Cordova.exec');
+
     pluginloader.load(function() {
         channel.onPluginsReady.fire();
     });