You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2014/04/24 23:10:46 UTC

[01/45] js commit: adding required libraries to browserify

Repository: cordova-js
Updated Branches:
  refs/heads/master 5a38908fb -> 58812ae8f


adding required libraries to browserify


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

Branch: refs/heads/master
Commit: c925386ae1dc255cca5198fa8f75184f20579ff1
Parents: 8f301f8
Author: Anis Kadri <an...@apache.org>
Authored: Mon Feb 3 22:14:10 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Mon Feb 3 22:14:10 2014 -0800

----------------------------------------------------------------------
 package.json | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c925386a/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index cc25b9a..b0c6225 100644
--- a/package.json
+++ b/package.json
@@ -42,7 +42,7 @@
     },
     {
       "name": "Anis Kadri",
-      "email": ""
+      "email": "anis@apache.org"
     },
     {
       "name": "Dan Silivestru",
@@ -55,7 +55,10 @@
   ],
   "dependencies": {
     "jsdom": "0.8.2",
-    "connect": "1.8.5"
+    "connect": "1.8.5",
+    "uglify-js": "2.4.x",
+    "browserify": "3.2.0",
+    "through": "2.3.4"
   },
   "devDependencies": {
     "grunt": "~0.4.1",


[45/45] js commit: Merge branch 'master' into browserify

Posted by an...@apache.org.
Merge branch 'master' into browserify


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

Branch: refs/heads/master
Commit: 58812ae8f105c98392c687d0e51efd050bebd59c
Parents: bcd2ae8 5a38908
Author: Anis Kadri <an...@apache.org>
Authored: Thu Apr 24 11:27:35 2014 -0700
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Apr 24 11:27:35 2014 -0700

----------------------------------------------------------------------
 src/common/base64.js     | 10 +++++
 src/ios/exec.js          | 99 ++++++++++++++++++++++++-------------------
 src/ubuntu/platform.js   |  2 +
 src/windows8/platform.js |  6 +--
 src/windowsphone/exec.js |  2 +-
 test/test.base64.js      | 14 ++++++
 6 files changed, 85 insertions(+), 48 deletions(-)
----------------------------------------------------------------------



[40/45] js commit: adding cordova.require fake wrapper

Posted by an...@apache.org.
adding cordova.require fake wrapper


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

Branch: refs/heads/master
Commit: 82d62c894b4459c6b17a9aedf8174db3226a5fa4
Parents: b03d19e
Author: Anis Kadri <an...@apache.org>
Authored: Thu Mar 27 15:04:34 2014 +0100
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:22 2014 +0100

----------------------------------------------------------------------
 src/cordova_b.js | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/82d62c89/src/cordova_b.js
----------------------------------------------------------------------
diff --git a/src/cordova_b.js b/src/cordova_b.js
index f4c781e..a00423c 100644
--- a/src/cordova_b.js
+++ b/src/cordova_b.js
@@ -226,4 +226,14 @@ var cordova = {
         });
     }
 };
+
+// FIXME hack: cordova iOS calls cordova.require()
+cordova.require = function(module) {
+  if(module === "cordova/exec") {
+    return cordova.exec;
+  }
+
+  return undefined;
+}
+
 window.cordova = module.exports = cordova;


[05/45] js commit: adding browserify compile task

Posted by an...@apache.org.
adding browserify compile task


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

Branch: refs/heads/master
Commit: bc7843ef79565c5b9748a6cea11cbccd2895b5ce
Parents: 42621ce
Author: Anis Kadri <an...@apache.org>
Authored: Mon Feb 3 22:21:53 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Mon Feb 3 22:21:53 2014 -0800

----------------------------------------------------------------------
 tasks/compile-browserify.js | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/bc7843ef/tasks/compile-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/compile-browserify.js b/tasks/compile-browserify.js
new file mode 100644
index 0000000..1d28510
--- /dev/null
+++ b/tasks/compile-browserify.js
@@ -0,0 +1,29 @@
+/*
+ * 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 generate = require('./lib/packager-browserify');
+
+module.exports = function(grunt) {
+    grunt.registerMultiTask('compile-browserify', 'Packages cordova.js browserify style', function() {
+
+        var done = this.async();
+        var platformName = this.target;
+        var useWindowsLineEndings = this.data.useWindowsLineEndings;
+        generate(platformName, useWindowsLineEndings, done);
+    });
+}


[16/45] js commit: moving license writing to other module

Posted by an...@apache.org.
moving license writing to other module


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

Branch: refs/heads/master
Commit: 1b58859437c022d23bef546868e71746528d84a9
Parents: ef6f9b9
Author: Anis Kadri <an...@apache.org>
Authored: Fri Mar 14 16:41:44 2014 -0700
Committer: Anis Kadri <an...@apache.org>
Committed: Fri Mar 14 16:41:44 2014 -0700

----------------------------------------------------------------------
 tasks/lib/packager-browserify.js  | 24 ++++++++----------------
 tasks/lib/write-license-header.js | 16 ++++++++++++++++
 2 files changed, 24 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/1b588594/tasks/lib/packager-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/packager-browserify.js b/tasks/lib/packager-browserify.js
index 07d7774..ecc3f5f 100644
--- a/tasks/lib/packager-browserify.js
+++ b/tasks/lib/packager-browserify.js
@@ -16,13 +16,12 @@
  * specific language governing permissions and lim
  * under the License.
  */
-var fs              = require('fs');
-var path            = require('path');
-var util            = require('util');
-var bundle          = require('./bundle-browserify');
-var computeCommitId = require('./compute-commit-id');
-var licensePath     = path.join(__dirname, '..', 'templates', 'LICENSE-for-js-file.txt');
-var require_tr   = require('./require-tr');
+var fs                 = require('fs');
+var path               = require('path');
+var util               = require('util');
+var bundle             = require('./bundle-browserify');
+var computeCommitId    = require('./compute-commit-id');
+var writeLicenseHeader = require('./write-license-header');
 
 
 module.exports = function generate(platform, useWindowsLineEndings, done) {
@@ -49,17 +48,10 @@ module.exports = function generate(platform, useWindowsLineEndings, done) {
         outReleaseFile = path.join('pkg', 'cordova.' + platform + '.js');
         outReleaseFileStream = fs.createWriteStream(outReleaseFile);
         
-        // some poppycock 
-        var licenseText = util.format("/*\n *%s\n */\n", fs.readFileSync(licensePath, 'utf8').replace(/\n/g, "\n *"));
+        // write license header
+        writeLicenseHeader(outReleaseFileStream, platform, commitId);
 
-        outReleaseFileStream.write("// Platform: " + platform + "\n", 'utf8');
-        outReleaseFileStream.write("// "  + commitId + "\n", 'utf8');
-        outReleaseFileStream.write(licenseText, 'utf8');
-        outReleaseFileStream.write("var CORDOVA_JS_BUILD_LABEL = '"  + commitId + "';\n", 'utf8');
-        outReleaseFileStream.write("var define = {moduleMap: []};\n", 'utf8');
-        
         releaseBundle = libraryRelease.bundle();
-        //console.log(libraryRelease.deps());
 
         releaseBundle.pipe(outReleaseFileStream);
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/1b588594/tasks/lib/write-license-header.js
----------------------------------------------------------------------
diff --git a/tasks/lib/write-license-header.js b/tasks/lib/write-license-header.js
new file mode 100644
index 0000000..8b33cbd
--- /dev/null
+++ b/tasks/lib/write-license-header.js
@@ -0,0 +1,16 @@
+var path        = require('path');
+var util        = require('util');
+var fs          = require('fs');
+var licensePath = path.join(__dirname, '..', 'templates', 'LICENSE-for-js-file.txt');
+
+module.exports = function(outStream, platform, commitId) {
+  // some poppycock 
+  var licenseText = util.format("/*\n *%s\n */\n", fs.readFileSync(licensePath, 'utf8').replace(/\n/g, "\n *"));
+
+  outStream.write("// Platform: " + platform + "\n", 'utf8');
+  outStream.write("// "  + commitId + "\n", 'utf8');
+  outStream.write(licenseText, 'utf8');
+  outStream.write("var CORDOVA_JS_BUILD_LABEL = '"  + commitId + "';\n", 'utf8');
+  outStream.write("var define = {moduleMap: []};\n", 'utf8');
+
+}


[24/45] js commit: adding browserify require transform

Posted by an...@apache.org.
adding browserify require transform


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

Branch: refs/heads/master
Commit: 064497125c63f826e08f71b1aafa74da7e5f5244
Parents: 78da184
Author: Anis Kadri <an...@apache.org>
Authored: Mon Feb 3 22:15:19 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:21 2014 +0100

----------------------------------------------------------------------
 tasks/lib/require-tr.js | 81 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/06449712/tasks/lib/require-tr.js
----------------------------------------------------------------------
diff --git a/tasks/lib/require-tr.js b/tasks/lib/require-tr.js
new file mode 100644
index 0000000..4459fda
--- /dev/null
+++ b/tasks/lib/require-tr.js
@@ -0,0 +1,81 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * This probably should live in plugman/cli world
+ * Transoforms old require calls to new node-style require calls
+ */
+
+var fs = require('fs');
+var path = require('path');
+var through = require('through');
+var UglifyJS = require('uglify-js');
+var root = fs.realpathSync(path.join(__dirname, '..', '..'));
+
+function _updateRequires(code) {
+  
+  var ast = UglifyJS.parse(code);
+
+  var walker = new UglifyJS.TreeWalker(function(node) {
+    // check all function calls
+    if(node instanceof UglifyJS.AST_Call) {
+      // check if function call is a require('module') call
+      if(node.expression.name === "require") {
+        // make sure require only has one argument and that it starts with cordova (old style require.js) 
+        //fs.appendFileSync('/tmp/foo', JSON.stringify(node.args[0]) + "###\n");
+        if(node.args.length === 1 && 
+           node.args[0].value !== undefined &&
+           node.args[0].value.indexOf("cordova") === 0){
+          if(node.args[0].value === "cordova") {
+            node.args[0].value = path.join(root, "src", "cordova");
+          } else if(node.args[0].value.match(/cordova\/(.+)/)) {
+            node.args[0].value = node.args[0].value.replace(/cordova\/(.+)/, path.join(root, "src", "common", "$1"));
+          }
+        }
+      }
+    }
+  });
+
+  ast.walk(walker);
+
+  var stream = UglifyJS.OutputStream({beautify:true});
+
+  ast.print(stream);
+
+  return stream.toString();
+}
+
+
+module.exports = function(file) {
+  var data = '';
+
+  function write(buf) {
+    data += buf;
+  }
+
+  function end() {
+    //fs.appendFileSync('/tmp/foo', _updateRequires(data));
+    this.queue(_updateRequires(data));
+    this.queue(null);
+  }
+ 
+  return through(write, end);
+}


[23/45] js commit: adding required libraries to browserify

Posted by an...@apache.org.
adding required libraries to browserify


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

Branch: refs/heads/master
Commit: 78da184181f75cdfc1fd96443c305989101bedc8
Parents: 607ca9d
Author: Anis Kadri <an...@apache.org>
Authored: Mon Feb 3 22:14:10 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:21 2014 +0100

----------------------------------------------------------------------
 package.json | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/78da1841/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 94236c0..290da1d 100644
--- a/package.json
+++ b/package.json
@@ -42,7 +42,7 @@
     },
     {
       "name": "Anis Kadri",
-      "email": ""
+      "email": "anis@apache.org"
     },
     {
       "name": "Dan Silivestru",
@@ -53,11 +53,14 @@
       "email": "shazron@apache.org"
     }
   ],
-  "devDependencies": {
+  "dependencies": {
     "jsdom-nogyp": "0.8.3",
     "connect": "1.8.5",
     "grunt": "~0.4.1",
     "grunt-contrib-clean": "~0.4.1",
-    "grunt-contrib-jshint": "~0.6.0"
+    "grunt-contrib-jshint": "~0.6.0",
+    "uglify-js": "2.4.x",
+    "browserify": "3.2.0",
+    "through": "2.3.4"
   }
 }


[36/45] js commit: exec was set in the wrong file

Posted by an...@apache.org.
exec was set in the wrong file


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

Branch: refs/heads/master
Commit: b03d19ef289c26862160dda47133b1f7c0361102
Parents: df0e082
Author: Anis Kadri <an...@apache.org>
Authored: Wed Mar 26 17:28:11 2014 +0100
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:22 2014 +0100

----------------------------------------------------------------------
 src/cordova_b.js | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/b03d19ef/src/cordova_b.js
----------------------------------------------------------------------
diff --git a/src/cordova_b.js b/src/cordova_b.js
index 1d2d36e..f4c781e 100644
--- a/src/cordova_b.js
+++ b/src/cordova_b.js
@@ -226,6 +226,4 @@ var cordova = {
         });
     }
 };
-window.cordova = cordova; 
-window.cordova.exec = require('cordova/exec');
-module.exports = cordova;
+window.cordova = module.exports = cordova;


[29/45] js commit: adding other platforms

Posted by an...@apache.org.
adding other platforms


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

Branch: refs/heads/master
Commit: db8b15d1ffd9b9a96bc6f4f671aa447cfa2c3479
Parents: 4a9fe17
Author: Anis Kadri <an...@apache.org>
Authored: Wed Feb 5 18:21:38 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:21 2014 +0100

----------------------------------------------------------------------
 Gruntfile.js                     | 10 +++++++++-
 tasks/lib/packager-browserify.js |  6 +++---
 2 files changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/db8b15d1/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index ffd4064..5182572 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -36,7 +36,15 @@ module.exports = function(grunt) {
         "compile-browserify": {
             "amazon-fireos": {},
             "android": {},
-            "ios": {}
+            "blackberry10": {},
+            "ios": {},
+            "osx": {},
+            //"test": {},
+            "windows8": { useWindowsLineEndings: true },
+            "windowsphone": { useWindowsLineEndings: true },
+            "firefoxos": {},
+            "ubuntu": {},
+            "browser": {}
         },
         clean: ['pkg'],
         jshint: {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/db8b15d1/tasks/lib/packager-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/packager-browserify.js b/tasks/lib/packager-browserify.js
index 299bf89..e3407cf 100644
--- a/tasks/lib/packager-browserify.js
+++ b/tasks/lib/packager-browserify.js
@@ -29,9 +29,9 @@ module.exports = function generate(platform, useWindowsLineEndings, callback) {
 
         var libraryRelease = bundle(platform, false, commitId);
         // if we are using windows line endings, we will also add the BOM
-        if(useWindowsLineEndings) {
-            libraryRelease = "\ufeff" + libraryRelease.split(/\r?\n/).join("\r\n");
-        }
+       // if(useWindowsLineEndings) {
+       //     libraryRelease = "\ufeff" + libraryRelease.split(/\r?\n/).join("\r\n");
+       // }
         //var libraryDebug   = bundle(platform, true, commitId);
 
         time = new Date().valueOf() - time;


[17/45] js commit: fixing weird outputstream problem

Posted by an...@apache.org.
fixing weird outputstream problem


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

Branch: refs/heads/master
Commit: 0dc876da3179903f93fd03e54cee4de809c92e2c
Parents: 1b58859
Author: Anis Kadri <an...@apache.org>
Authored: Wed Mar 26 17:25:58 2014 +0100
Committer: Anis Kadri <an...@apache.org>
Committed: Wed Mar 26 17:25:58 2014 +0100

----------------------------------------------------------------------
 tasks/lib/packager-browserify.js | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/0dc876da/tasks/lib/packager-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/packager-browserify.js b/tasks/lib/packager-browserify.js
index ecc3f5f..3e718c6 100644
--- a/tasks/lib/packager-browserify.js
+++ b/tasks/lib/packager-browserify.js
@@ -32,18 +32,18 @@ module.exports = function generate(platform, useWindowsLineEndings, done) {
         var time = new Date().valueOf();
 
         var libraryRelease = bundle(platform, false, commitId);
-        // if we are using windows line endings, we will also add the BOM
+       // if we are using windows line endings, we will also add the BOM
        // if(useWindowsLineEndings) {
        //     libraryRelease = "\ufeff" + libraryRelease.split(/\r?\n/).join("\r\n");
        // }
-        var libraryDebug   = bundle(platform, true, commitId);
+       // var libraryDebug   = bundle(platform, true, commitId);
 
         if (!fs.existsSync('pkg')) {
             fs.mkdirSync('pkg');
         }
-        if(!fs.existsSync('pkg/debug')) {
-            fs.mkdirSync('pkg/debug');
-        }
+       // if(!fs.existsSync('pkg/debug')) {
+       //     fs.mkdirSync('pkg/debug');
+       // }
 
         outReleaseFile = path.join('pkg', 'cordova.' + platform + '.js');
         outReleaseFileStream = fs.createWriteStream(outReleaseFile);
@@ -55,20 +55,20 @@ module.exports = function generate(platform, useWindowsLineEndings, done) {
 
         releaseBundle.pipe(outReleaseFileStream);
 
-        releaseBundle.on('end', function() {
+        outReleaseFileStream.on('finish', function() {
           var newtime = new Date().valueOf() - time;
           console.log('generated cordova.' + platform + '.js @ ' + commitId + ' in ' + newtime + 'ms');
           done();
         });
 
-        outDebugFile = path.join('pkg', 'debug', 'cordova.' + platform + '-debug.js');
-        outDebugFileStream = fs.createWriteStream(outDebugFile);
-        debugBundle = libraryDebug.bundle();
-        debugBundle.pipe(outDebugFileStream);
+       // outDebugFile = path.join('pkg', 'debug', 'cordova.' + platform + '-debug.js');
+       // outDebugFileStream = fs.createWriteStream(outDebugFile);
+       // debugBundle = libraryDebug.bundle();
+       // debugBundle.pipe(outDebugFileStream);
 
-        outDebugFileStream.on('end', function() {
-          var newtime = new Date().valueOf() - time;
-          console.log('generated cordova.' + platform + '-debug.js @ ' + commitId + ' in ' + newtime + 'ms');
-        });
+       // outDebugFileStream.on('end', function() {
+       //   var newtime = new Date().valueOf() - time;
+       //   console.log('generated cordova.' + platform + '-debug.js @ ' + commitId + ' in ' + newtime + 'ms');
+       // });
     });
 }


[22/45] js commit: adding debug flag to support sourcemaps

Posted by an...@apache.org.
adding debug flag to support sourcemaps


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

Branch: refs/heads/master
Commit: 061d7d21090fffe78d2ddef4247867c917aaeafb
Parents: db8b15d
Author: Anis Kadri <an...@apache.org>
Authored: Wed Feb 5 19:16:23 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:21 2014 +0100

----------------------------------------------------------------------
 tasks/lib/bundle-browserify.js   |  2 +-
 tasks/lib/packager-browserify.js | 32 ++++++++++++++++++--------------
 2 files changed, 19 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/061d7d21/tasks/lib/bundle-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/bundle-browserify.js b/tasks/lib/bundle-browserify.js
index e678bcf..0dda5d3 100644
--- a/tasks/lib/bundle-browserify.js
+++ b/tasks/lib/bundle-browserify.js
@@ -26,7 +26,7 @@ var root         = path.join(__dirname, '..', '..')
 
 module.exports = function bundle(platform, debug, commitId) {
     // FIXME: need to find a way to void ignore missing
-    var b = browserify();
+    var b = browserify({debug: debug});
     // XXX plugin_list is not present at this stage 
     b.ignore(path.join(root, 'src', 'common', 'plugin_list'));
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/061d7d21/tasks/lib/packager-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/packager-browserify.js b/tasks/lib/packager-browserify.js
index e3407cf..04b982d 100644
--- a/tasks/lib/packager-browserify.js
+++ b/tasks/lib/packager-browserify.js
@@ -24,7 +24,8 @@ var computeCommitId = require('./compute-commit-id');
 
 module.exports = function generate(platform, useWindowsLineEndings, callback) {
     computeCommitId(function(commitId) {
-        var outFile, outFileStream;
+        var outReleaseFile, outReleaseFileStream,
+            outDebugFile, outDebugFileStream;
         var time = new Date().valueOf();
 
         var libraryRelease = bundle(platform, false, commitId);
@@ -32,28 +33,31 @@ module.exports = function generate(platform, useWindowsLineEndings, callback) {
        // if(useWindowsLineEndings) {
        //     libraryRelease = "\ufeff" + libraryRelease.split(/\r?\n/).join("\r\n");
        // }
-        //var libraryDebug   = bundle(platform, true, commitId);
+        var libraryDebug   = bundle(platform, true, commitId);
 
-        time = new Date().valueOf() - time;
         if (!fs.existsSync('pkg')) {
             fs.mkdirSync('pkg');
         }
-       // if(!fs.existsSync('pkg/debug')) {
-       //     fs.mkdirSync('pkg/debug');
-       // }
-        //libraryRelease.bundle().pipe(process.stdout);
+        if(!fs.existsSync('pkg/debug')) {
+            fs.mkdirSync('pkg/debug');
+        }
 
-        outFile = path.join('pkg', 'cordova.' + platform + '.js');
-        outFileStream = fs.createWriteStream(outFile);
-        libraryRelease.bundle().pipe(outFileStream);
+        outReleaseFile = path.join('pkg', 'cordova.' + platform + '.js');
+        outReleaseFileStream = fs.createWriteStream(outReleaseFile);
+        libraryRelease.bundle().pipe(outReleaseFileStream);
 
         libraryRelease.bundle().on('end', function() {
-          console.log('generated cordova.' + platform + '.js @ ' + commitId + ' in ' + time + 'ms');
+          var newtime = new Date().valueOf() - time;
+          console.log('generated cordova.' + platform + '.js @ ' + commitId + ' in ' + newtime + 'ms');
           callback();
         });
 
-       // outFile = path.join('pkg', 'debug', 'cordova.' + platform + '-debug.js');
-       // outFileStream = fs.createWriteStream(outFile);
-       // libraryDebug.bundle().pipe(outFileStream);
+        outDebugFile = path.join('pkg', 'debug', 'cordova.' + platform + '-debug.js');
+        outDebugFileStream = fs.createWriteStream(outDebugFile);
+        libraryDebug.bundle().on('end', function() {
+          var newtime = new Date().valueOf() - time;
+          console.log('generated cordova.' + platform + '-debug.js @ ' + commitId + ' in ' + newtime + 'ms');
+          callback();
+        });
     });
 }


[43/45] js commit: adding case for org.apache.cordova.* modules

Posted by an...@apache.org.
adding case for org.apache.cordova.* modules


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

Branch: refs/heads/master
Commit: 7d1233f870c3050a71d2b0e9648bffc82cc02a7a
Parents: 40c4ab4
Author: Anis Kadri <an...@apache.org>
Authored: Sat Mar 29 21:15:06 2014 +0100
Committer: Anis Kadri <an...@apache.org>
Committed: Sat Mar 29 21:15:06 2014 +0100

----------------------------------------------------------------------
 tasks/lib/require-tr.js | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/7d1233f8/tasks/lib/require-tr.js
----------------------------------------------------------------------
diff --git a/tasks/lib/require-tr.js b/tasks/lib/require-tr.js
index 7bde0f6..8964aee 100644
--- a/tasks/lib/require-tr.js
+++ b/tasks/lib/require-tr.js
@@ -51,15 +51,22 @@ var requireTr = {
    
     return through(write, end);
   },
-  getSymbolList: function() {
-    return this.symbolList;
+  getModules: function() {
+    return this.modules;
+  },
+  addModule: function(module) {
+    if(!module || !module.symbol || !module.path) {
+      throw new Error("Can't add module without a symbol and a path");
+    }
+    this.modules.push(module);
   },
   platform: null,
-  symbolList: []
+  modules: []
+    
 }
 
 /*
- * visits AST and modifies all the require('cordova/*')
+ * visits AST and modifies all the require('cordova/*') and require('org.apache.cordova.*')
  */
 function _updateRequires(code) {
   
@@ -84,11 +91,11 @@ function _updateRequires(code) {
           // require('cordova') -> cordova.js
           if(module === "cordova") {
             node.args[0].value = path.join(root, "src", "cordova_b");
-          // android and amazon-fireos have some special require's
+          // require('cordova/init') -> common/init
           }  else if(module.match(/cordova\/init/)) {
             node.args[0].value = module.replace(/cordova\/init/,
                                     path.join(root, "src", "common", "init_b"));
-          // require('cordova/exec') and require('cordova/platform') -> platform's exec/platform
+          // android and amazon-fireos have some special require's
           } else if(module.match(/cordova\/(android|amazon-fireos)\/(.+)/)) {
             node.args[0].value = module.replace(/cordova\/(android|amazon-fireos)\/(.+)/,
                                     path.join(root, "src", "$1", "android", "$2"));
@@ -101,6 +108,14 @@ function _updateRequires(code) {
             node.args[0].value = module.replace(/cordova\/(.+)/,
                                     path.join(root, "src", "common", "$1"));
           }
+        } else if(module !== undefined && module.indexOf("org.apache.cordova") !== -1 ) {
+          var modules = requireTr.getModules();
+          for(var i = 0, j = modules.length ; i < j ; i++) {
+            if(module.match(modules[i].symbol)) {
+              node.args[0].value = modules[i].path;
+              break;
+            }
+          }
         }
       }
     }


[09/45] js commit: adding debug flag to support sourcemaps

Posted by an...@apache.org.
adding debug flag to support sourcemaps


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

Branch: refs/heads/master
Commit: 4e674c34422fb529fd2f553af8fb1c38deb9de74
Parents: 15b0952
Author: Anis Kadri <an...@apache.org>
Authored: Wed Feb 5 19:16:23 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Wed Feb 5 19:16:23 2014 -0800

----------------------------------------------------------------------
 tasks/lib/bundle-browserify.js   |  2 +-
 tasks/lib/packager-browserify.js | 32 ++++++++++++++++++--------------
 2 files changed, 19 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/4e674c34/tasks/lib/bundle-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/bundle-browserify.js b/tasks/lib/bundle-browserify.js
index e678bcf..0dda5d3 100644
--- a/tasks/lib/bundle-browserify.js
+++ b/tasks/lib/bundle-browserify.js
@@ -26,7 +26,7 @@ var root         = path.join(__dirname, '..', '..')
 
 module.exports = function bundle(platform, debug, commitId) {
     // FIXME: need to find a way to void ignore missing
-    var b = browserify();
+    var b = browserify({debug: debug});
     // XXX plugin_list is not present at this stage 
     b.ignore(path.join(root, 'src', 'common', 'plugin_list'));
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/4e674c34/tasks/lib/packager-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/packager-browserify.js b/tasks/lib/packager-browserify.js
index e3407cf..04b982d 100644
--- a/tasks/lib/packager-browserify.js
+++ b/tasks/lib/packager-browserify.js
@@ -24,7 +24,8 @@ var computeCommitId = require('./compute-commit-id');
 
 module.exports = function generate(platform, useWindowsLineEndings, callback) {
     computeCommitId(function(commitId) {
-        var outFile, outFileStream;
+        var outReleaseFile, outReleaseFileStream,
+            outDebugFile, outDebugFileStream;
         var time = new Date().valueOf();
 
         var libraryRelease = bundle(platform, false, commitId);
@@ -32,28 +33,31 @@ module.exports = function generate(platform, useWindowsLineEndings, callback) {
        // if(useWindowsLineEndings) {
        //     libraryRelease = "\ufeff" + libraryRelease.split(/\r?\n/).join("\r\n");
        // }
-        //var libraryDebug   = bundle(platform, true, commitId);
+        var libraryDebug   = bundle(platform, true, commitId);
 
-        time = new Date().valueOf() - time;
         if (!fs.existsSync('pkg')) {
             fs.mkdirSync('pkg');
         }
-       // if(!fs.existsSync('pkg/debug')) {
-       //     fs.mkdirSync('pkg/debug');
-       // }
-        //libraryRelease.bundle().pipe(process.stdout);
+        if(!fs.existsSync('pkg/debug')) {
+            fs.mkdirSync('pkg/debug');
+        }
 
-        outFile = path.join('pkg', 'cordova.' + platform + '.js');
-        outFileStream = fs.createWriteStream(outFile);
-        libraryRelease.bundle().pipe(outFileStream);
+        outReleaseFile = path.join('pkg', 'cordova.' + platform + '.js');
+        outReleaseFileStream = fs.createWriteStream(outReleaseFile);
+        libraryRelease.bundle().pipe(outReleaseFileStream);
 
         libraryRelease.bundle().on('end', function() {
-          console.log('generated cordova.' + platform + '.js @ ' + commitId + ' in ' + time + 'ms');
+          var newtime = new Date().valueOf() - time;
+          console.log('generated cordova.' + platform + '.js @ ' + commitId + ' in ' + newtime + 'ms');
           callback();
         });
 
-       // outFile = path.join('pkg', 'debug', 'cordova.' + platform + '-debug.js');
-       // outFileStream = fs.createWriteStream(outFile);
-       // libraryDebug.bundle().pipe(outFileStream);
+        outDebugFile = path.join('pkg', 'debug', 'cordova.' + platform + '-debug.js');
+        outDebugFileStream = fs.createWriteStream(outDebugFile);
+        libraryDebug.bundle().on('end', function() {
+          var newtime = new Date().valueOf() - time;
+          console.log('generated cordova.' + platform + '-debug.js @ ' + commitId + ' in ' + newtime + 'ms');
+          callback();
+        });
     });
 }


[44/45] js commit: adding channel pre deviceready

Posted by an...@apache.org.
adding channel pre deviceready


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

Branch: refs/heads/master
Commit: bcd2ae819e54716f3599d1aacd1b859595e90a2e
Parents: 7d1233f
Author: Anis Kadri <an...@apache.org>
Authored: Thu Apr 24 11:13:18 2014 -0700
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Apr 24 11:13:18 2014 -0700

----------------------------------------------------------------------
 src/common/init_b.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/bcd2ae81/src/common/init_b.js
----------------------------------------------------------------------
diff --git a/src/common/init_b.js b/src/common/init_b.js
index 288c5a5..32c2068 100644
--- a/src/common/init_b.js
+++ b/src/common/init_b.js
@@ -23,7 +23,7 @@ var channel = require('cordova/channel');
 var cordova = require('cordova');
 var platform = require('cordova/platform');
 
-var platformInitChannelsArray = [channel.onNativeReady];
+var platformInitChannelsArray = [channel.onDOMContentLoaded, channel.onNativeReady];
 
 // setting exec
 cordova.exec = require('cordova/exec');


[34/45] js commit: updating transform/bundler/packager

Posted by an...@apache.org.
updating transform/bundler/packager


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

Branch: refs/heads/master
Commit: 0990b5d9a8f2e192c1792e3e0f86bf61d9f5af73
Parents: 2c300fd
Author: Anis Kadri <an...@apache.org>
Authored: Mon Mar 3 16:12:23 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:22 2014 +0100

----------------------------------------------------------------------
 tasks/lib/bundle-browserify.js   |  1 -
 tasks/lib/packager-browserify.js | 15 ++++++
 tasks/lib/require-tr.js          | 97 ++++++++++++++++++++---------------
 3 files changed, 72 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/0990b5d9/tasks/lib/bundle-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/bundle-browserify.js b/tasks/lib/bundle-browserify.js
index 85da8dd..1d948fa 100644
--- a/tasks/lib/bundle-browserify.js
+++ b/tasks/lib/bundle-browserify.js
@@ -20,7 +20,6 @@ var fs           = require('fs');
 var path         = require('path');
 var browserify   = require('browserify');
 var require_tr   = require('./require-tr');
-var licensePath  = path.join(__dirname, '..', 'templates', 'LICENSE-for-js-file.txt');
 var root         = path.join(__dirname, '..', '..')
 
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/0990b5d9/tasks/lib/packager-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/packager-browserify.js b/tasks/lib/packager-browserify.js
index ecc8e9d..07d7774 100644
--- a/tasks/lib/packager-browserify.js
+++ b/tasks/lib/packager-browserify.js
@@ -18,8 +18,11 @@
  */
 var fs              = require('fs');
 var path            = require('path');
+var util            = require('util');
 var bundle          = require('./bundle-browserify');
 var computeCommitId = require('./compute-commit-id');
+var licensePath     = path.join(__dirname, '..', 'templates', 'LICENSE-for-js-file.txt');
+var require_tr   = require('./require-tr');
 
 
 module.exports = function generate(platform, useWindowsLineEndings, done) {
@@ -45,7 +48,19 @@ module.exports = function generate(platform, useWindowsLineEndings, done) {
 
         outReleaseFile = path.join('pkg', 'cordova.' + platform + '.js');
         outReleaseFileStream = fs.createWriteStream(outReleaseFile);
+        
+        // some poppycock 
+        var licenseText = util.format("/*\n *%s\n */\n", fs.readFileSync(licensePath, 'utf8').replace(/\n/g, "\n *"));
+
+        outReleaseFileStream.write("// Platform: " + platform + "\n", 'utf8');
+        outReleaseFileStream.write("// "  + commitId + "\n", 'utf8');
+        outReleaseFileStream.write(licenseText, 'utf8');
+        outReleaseFileStream.write("var CORDOVA_JS_BUILD_LABEL = '"  + commitId + "';\n", 'utf8');
+        outReleaseFileStream.write("var define = {moduleMap: []};\n", 'utf8');
+        
         releaseBundle = libraryRelease.bundle();
+        //console.log(libraryRelease.deps());
+
         releaseBundle.pipe(outReleaseFileStream);
 
         releaseBundle.on('end', function() {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/0990b5d9/tasks/lib/require-tr.js
----------------------------------------------------------------------
diff --git a/tasks/lib/require-tr.js b/tasks/lib/require-tr.js
index 5629e80..2c347a3 100644
--- a/tasks/lib/require-tr.js
+++ b/tasks/lib/require-tr.js
@@ -30,6 +30,37 @@ var through = require('through');
 var UglifyJS = require('uglify-js');
 var root = fs.realpathSync(path.join(__dirname, '..', '..'));
 
+
+var requireTr = {
+
+  transform: function(file) {
+    var data = '';
+
+    function write(buf) {
+      data += buf;
+    }
+
+    function end() {
+      // getting rid of define and require properties of cordova
+     // if(file.match(/cordova.js$/)) {
+     //   data = data.replace(/ *(define:define|require:require),\n/, '');
+     // }
+      this.queue(_updateRequires(data));
+      this.queue(null);
+    }
+   
+    return through(write, end);
+  },
+  getSymbolList: function() {
+    return this.symbolList;
+  },
+  platform: null,
+  symbolList: []
+}
+
+/*
+ * visits AST and modifies all the require('cordova/*')
+ */
 function _updateRequires(code) {
   
   var ast = UglifyJS.parse(code);
@@ -39,28 +70,32 @@ function _updateRequires(code) {
     // check all function calls
     if(node instanceof UglifyJS.AST_Call) {
       // check if function call is a require('module') call
-      if(node.expression.name === "require") {
+      if(node.expression.name === "require" && node.args.length === 1) {
+        var module = node.args[0].value;
         // make sure require only has one argument and that it starts with cordova (old style require.js) 
-        if(node.args.length === 1 && 
-           node.args[0].value !== undefined &&
-           node.args[0].value.indexOf("cordova") === 0) {
-          //fs.appendFileSync('/tmp/foo', JSON.stringify(node.args[0].value) + "\n###\n");
-          // cordova.js
-          if(node.args[0].value === "cordova") {
-            node.args[0].value = path.join(root, "src", "cordova");
-          // android and amazon-fireos
-          } else if(node.args[0].value.match(/cordova\/(android|amazon-fireos)\/(.+)/)) {
-            node.args[0].value = node.args[0].value.replace(/cordova\/(android|amazon-fireos)\/(.+)/,
-                                 path.join(root, "src", "$1", "android", "$2"));
-          // replace common exec/platform with the platform's exec/platform
-          } else if(node.args[0].value.match(/cordova\/(platform|exec)$/)) {
-            //fs.appendFileSync('/tmp/foo', node.args[0].value + "\n" +module.exports.platform + "\n");
-            node.args[0].value = node.args[0].value.replace(/cordova\/(platform|exec)/,
-                                 path.join(root, "src", module.exports.platform, "$1"));
-          // everything else
-          } else if(node.args[0].value.match(/cordova\/(.+)/)) {
-            node.args[0].value = node.args[0].value.replace(/cordova\/(.+)/,
-                                 path.join(root, "src", "common", "$1"));
+        if(module !== undefined &&
+           module.indexOf("cordova") === 0) {
+          
+          // adding symbolList bullcrap
+          if(requireTr.symbolList && requireTr.symbolList.indexOf(module) === -1) {
+            requireTr.symbolList.push(module);
+          }
+
+          // require('cordova') -> cordova.js
+          if(module === "cordova") {
+            node.args[0].value = path.join(root, "src", "cordova_b");
+          // android and amazon-fireos have some special require's
+          } else if(module.match(/cordova\/(android|amazon-fireos)\/(.+)/)) {
+            node.args[0].value = module.replace(/cordova\/(android|amazon-fireos)\/(.+)/,
+                                    path.join(root, "src", "$1", "android", "$2"));
+          // require('cordova/exec') and require('cordova/platform') -> platform's exec/platform
+          } else if(module.match(/cordova\/(platform|exec)$/)) {
+            node.args[0].value = module.replace(/cordova\/(platform|exec)/,
+                                                path.join(root, "src", requireTr.platform, "$1"));
+          // require('cordova/anything') should be under common/
+          } else if(module.match(/cordova\/(.+)/)) {
+            node.args[0].value = module.replace(/cordova\/(.+)/,
+                                    path.join(root, "src", "common", "$1"));
           }
         }
       }
@@ -77,22 +112,4 @@ function _updateRequires(code) {
 }
 
 
-module.exports = {
-
-  transform: function(file) {
-    var data = '';
-
-    function write(buf) {
-      data += buf;
-    }
-
-    function end() {
-      //fs.appendFileSync('/tmp/foo', _updateRequires(data));
-      this.queue(_updateRequires(data));
-      this.queue(null);
-    }
-   
-    return through(write, end);
-  },
-  platform: ""
-}
+module.exports = requireTr; 


[37/45] js commit: replacing cordova.js and init.js with their browserify-compatible equivalents

Posted by an...@apache.org.
replacing cordova.js and init.js with their browserify-compatible equivalents


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

Branch: refs/heads/master
Commit: 75860ddbe0597c545c23c382f4f979c4a4812d6f
Parents: 16419e4
Author: Anis Kadri <an...@apache.org>
Authored: Wed Mar 5 16:21:44 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:22 2014 +0100

----------------------------------------------------------------------
 src/common/init_b.js | 129 ++++++++++++++++++++++++++
 src/cordova_b.js     | 231 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 360 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/75860ddb/src/common/init_b.js
----------------------------------------------------------------------
diff --git a/src/common/init_b.js b/src/common/init_b.js
new file mode 100644
index 0000000..efcb6cf
--- /dev/null
+++ b/src/common/init_b.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/75860ddb/src/cordova_b.js
----------------------------------------------------------------------
diff --git a/src/cordova_b.js b/src/cordova_b.js
new file mode 100644
index 0000000..1d2d36e
--- /dev/null
+++ b/src/cordova_b.js
@@ -0,0 +1,231 @@
+/*
+ *
+ * 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 platform = require('cordova/platform');
+
+/**
+ * Intercept calls to addEventListener + removeEventListener and handle deviceready,
+ * resume, and pause events.
+ */
+var m_document_addEventListener = document.addEventListener;
+var m_document_removeEventListener = document.removeEventListener;
+var m_window_addEventListener = window.addEventListener;
+var m_window_removeEventListener = window.removeEventListener;
+
+/**
+ * Houses custom event handlers to intercept on document + window event listeners.
+ */
+var documentEventHandlers = {},
+    windowEventHandlers = {};
+
+document.addEventListener = function(evt, handler, capture) {
+    var e = evt.toLowerCase();
+    if (typeof documentEventHandlers[e] != 'undefined') {
+        documentEventHandlers[e].subscribe(handler);
+    } else {
+        m_document_addEventListener.call(document, evt, handler, capture);
+    }
+};
+
+window.addEventListener = function(evt, handler, capture) {
+    var e = evt.toLowerCase();
+    if (typeof windowEventHandlers[e] != 'undefined') {
+        windowEventHandlers[e].subscribe(handler);
+    } else {
+        m_window_addEventListener.call(window, evt, handler, capture);
+    }
+};
+
+document.removeEventListener = function(evt, handler, capture) {
+    var e = evt.toLowerCase();
+    // If unsubscribing from an event that is handled by a plugin
+    if (typeof documentEventHandlers[e] != "undefined") {
+        documentEventHandlers[e].unsubscribe(handler);
+    } else {
+        m_document_removeEventListener.call(document, evt, handler, capture);
+    }
+};
+
+window.removeEventListener = function(evt, handler, capture) {
+    var e = evt.toLowerCase();
+    // If unsubscribing from an event that is handled by a plugin
+    if (typeof windowEventHandlers[e] != "undefined") {
+        windowEventHandlers[e].unsubscribe(handler);
+    } else {
+        m_window_removeEventListener.call(window, evt, handler, capture);
+    }
+};
+
+function createEvent(type, data) {
+    var event = document.createEvent('Events');
+    event.initEvent(type, false, false);
+    if (data) {
+        for (var i in data) {
+            if (data.hasOwnProperty(i)) {
+                event[i] = data[i];
+            }
+        }
+    }
+    return event;
+}
+
+
+var cordova = {
+    version:CORDOVA_JS_BUILD_LABEL,
+    platformId:platform.id,
+    /**
+     * Methods to add/remove your own addEventListener hijacking on document + window.
+     */
+    addWindowEventHandler:function(event) {
+        return (windowEventHandlers[event] = channel.create(event));
+    },
+    addStickyDocumentEventHandler:function(event) {
+        return (documentEventHandlers[event] = channel.createSticky(event));
+    },
+    addDocumentEventHandler:function(event) {
+        return (documentEventHandlers[event] = channel.create(event));
+    },
+    removeWindowEventHandler:function(event) {
+        delete windowEventHandlers[event];
+    },
+    removeDocumentEventHandler:function(event) {
+        delete documentEventHandlers[event];
+    },
+    /**
+     * Retrieve original event handlers that were replaced by Cordova
+     *
+     * @return object
+     */
+    getOriginalHandlers: function() {
+        return {'document': {'addEventListener': m_document_addEventListener, 'removeEventListener': m_document_removeEventListener},
+        'window': {'addEventListener': m_window_addEventListener, 'removeEventListener': m_window_removeEventListener}};
+    },
+    /**
+     * 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, bNoDetach) {
+        var evt = createEvent(type, data);
+        if (typeof documentEventHandlers[type] != 'undefined') {
+            if( bNoDetach ) {
+                documentEventHandlers[type].fire(evt);
+            }
+            else {
+                setTimeout(function() {
+                    // Fire deviceready on listeners that were registered before cordova.js was loaded.
+                    if (type == 'deviceready') {
+                        document.dispatchEvent(evt);
+                    }
+                    documentEventHandlers[type].fire(evt);
+                }, 0);
+            }
+        } else {
+            document.dispatchEvent(evt);
+        }
+    },
+    fireWindowEvent: function(type, data) {
+        var evt = createEvent(type,data);
+        if (typeof windowEventHandlers[type] != 'undefined') {
+            setTimeout(function() {
+                windowEventHandlers[type].fire(evt);
+            }, 0);
+        } else {
+            window.dispatchEvent(evt);
+        }
+    },
+
+    /**
+     * Plugin callback mechanism.
+     */
+    // 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,
+        OK: 1,
+        CLASS_NOT_FOUND_EXCEPTION: 2,
+        ILLEGAL_ACCESS_EXCEPTION: 3,
+        INSTANTIATION_EXCEPTION: 4,
+        MALFORMED_URL_EXCEPTION: 5,
+        IO_EXCEPTION: 6,
+        INVALID_ACTION: 7,
+        JSON_EXCEPTION: 8,
+        ERROR: 9
+    },
+
+    /**
+     * Called by native code when returning successful result from an action.
+     */
+    callbackSuccess: function(callbackId, args) {
+        try {
+            cordova.callbackFromNative(callbackId, true, args.status, [args.message], args.keepCallback);
+        } catch (e) {
+            console.log("Error in error callback: " + callbackId + " = "+e);
+        }
+    },
+
+    /**
+     * Called by native code when returning error result from an action.
+     */
+    callbackError: function(callbackId, args) {
+        // TODO: Deprecate callbackSuccess and callbackError in favour of callbackFromNative.
+        // Derive success from status.
+        try {
+            cordova.callbackFromNative(callbackId, false, args.status, [args.message], args.keepCallback);
+        } catch (e) {
+            console.log("Error in error callback: " + callbackId + " = "+e);
+        }
+    },
+
+    /**
+     * Called by native code when returning the result from an action.
+     */
+    callbackFromNative: function(callbackId, success, status, args, keepCallback) {
+        var callback = cordova.callbacks[callbackId];
+        if (callback) {
+            if (success && status == cordova.callbackStatus.OK) {
+                callback.success && callback.success.apply(null, args);
+            } else if (!success) {
+                callback.fail && callback.fail.apply(null, args);
+            }
+
+            // Clear callback if not expecting any more results
+            if (!keepCallback) {
+                delete cordova.callbacks[callbackId];
+            }
+        }
+    },
+    addConstructor: function(func) {
+        channel.onCordovaReady.subscribe(function() {
+            try {
+                func();
+            } catch(e) {
+                console.log("Failed to run constructor: " + e);
+            }
+        });
+    }
+};
+window.cordova = cordova; 
+window.cordova.exec = require('cordova/exec');
+module.exports = cordova;


[20/45] js commit: exec was set in the wrong file

Posted by an...@apache.org.
exec was set in the wrong file


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

Branch: refs/heads/master
Commit: a7e3969934cf10df58c09e0234979429b8928aca
Parents: 94a1185
Author: Anis Kadri <an...@apache.org>
Authored: Wed Mar 26 17:28:11 2014 +0100
Committer: Anis Kadri <an...@apache.org>
Committed: Wed Mar 26 17:28:11 2014 +0100

----------------------------------------------------------------------
 src/cordova_b.js | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/a7e39699/src/cordova_b.js
----------------------------------------------------------------------
diff --git a/src/cordova_b.js b/src/cordova_b.js
index 1d2d36e..f4c781e 100644
--- a/src/cordova_b.js
+++ b/src/cordova_b.js
@@ -226,6 +226,4 @@ var cordova = {
         });
     }
 };
-window.cordova = cordova; 
-window.cordova.exec = require('cordova/exec');
-module.exports = cordova;
+window.cordova = module.exports = cordova;


[39/45] js commit: updating version

Posted by an...@apache.org.
updating version


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

Branch: refs/heads/master
Commit: 77fbf3a254a28d3d47404ee8f1c271ea741b046f
Parents: d1cd6ec
Author: Anis Kadri <an...@apache.org>
Authored: Wed Mar 26 17:26:39 2014 +0100
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:22 2014 +0100

----------------------------------------------------------------------
 package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/77fbf3a2/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 290da1d..3d51876 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
   "author": "Gord Tanner <gt...@gmail.com> (http://github.com/gtanner)",
   "name": "cordova-js",
   "description": "Cordova JavaScript: a unified JavaScript layer for the Cordova suite of projects enabling cross-platform native mobile development of applications using HTML, CSS and JavaScript.",
-  "version": "3.1.0",
+  "version": "3.5.0",
   "homepage": "http://cordova.apache.org",
   "repository": {
     "type": "git",


[28/45] js commit: Adding compile-browserify grunt task

Posted by an...@apache.org.
Adding compile-browserify grunt task


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

Branch: refs/heads/master
Commit: 0d10f5f0c3a52fabb304a7980b021170e951fd05
Parents: b10197c
Author: Anis Kadri <an...@apache.org>
Authored: Mon Feb 3 22:22:14 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:21 2014 +0100

----------------------------------------------------------------------
 Gruntfile.js | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/0d10f5f0/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index a419aa0..d49a097 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -33,6 +33,9 @@ module.exports = function(grunt) {
             "ubuntu": {},
             "browser": {}
         },
+        "compile-browserify": {
+            "ios": {}
+        },
         clean: ['pkg'],
         jshint: {
             options: {


[10/45] js commit: Merge branch 'master' into browserify

Posted by an...@apache.org.
Merge branch 'master' into browserify


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

Branch: refs/heads/master
Commit: 8ff104b6f09576db6cf7bab7b3e7b851a45178b9
Parents: 4e674c3 7d02fb8
Author: Anis Kadri <an...@apache.org>
Authored: Wed Feb 5 19:24:55 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Wed Feb 5 19:24:55 2014 -0800

----------------------------------------------------------------------
 Gruntfile.js             |  2 +-
 VERSION                  |  2 +-
 src/blackberry10/exec.js | 38 ++++++++++++++++++++++++++++++++++++--
 src/windows8/exec.js     | 27 +++++++++++++++++----------
 4 files changed, 55 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/8ff104b6/Gruntfile.js
----------------------------------------------------------------------


[27/45] js commit: adding browserify bundle

Posted by an...@apache.org.
adding browserify bundle


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

Branch: refs/heads/master
Commit: eed80cbc74095ea19664071e15cf3313d721a8a5
Parents: dec9627
Author: Anis Kadri <an...@apache.org>
Authored: Mon Feb 3 22:21:28 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:21 2014 +0100

----------------------------------------------------------------------
 tasks/lib/bundle-browserify.js | 62 +++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/eed80cbc/tasks/lib/bundle-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/bundle-browserify.js b/tasks/lib/bundle-browserify.js
new file mode 100644
index 0000000..3d91e42
--- /dev/null
+++ b/tasks/lib/bundle-browserify.js
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF
+ * or more contributor license agreements.  See th
+ * distributed with this work for additional infor
+ * regarding copyright ownership.  The ASF license
+ * to you under the Apache License, Version 2.0 (t
+ * "License"); you may not use this file except in
+ * with the License.  You may obtain a copy of the
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to 
+ * software distributed under the License is distr
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ * KIND, either express or implied.  See the Licen
+ * specific language governing permissions and lim
+ * under the License.
+ */
+var fs           = require('fs');
+var path         = require('path');
+var browserify   = require('browserify');
+var require_tr   = require('./require-tr');
+var licensePath  = path.join(__dirname, '..', 'templates', 'LICENSE-for-js-file.txt');
+var root         = path.join(__dirname, '..', '..')
+
+
+module.exports = function bundle(platform, debug, commitId) {
+    // FIXME: need to find a way to void ignore missing
+    var b = browserify();
+    // XXX plugin_list is not present at this stage 
+    b.ignore(path.join(root, 'src', 'common', 'plugin_list'));
+
+   // if (platform === 'test') {
+   //     // FIXME why does 'test' resolve a bunch of android stuff?! 
+   //     var testFilesPath = path.join('src', 'android', 'android');
+   //     copyProps(modules, collectFiles(testFilesPath, 'android/'));
+   // }
+
+   // var output = [];
+	
+   // output.push("// Platform: " + platform);
+   // output.push("// "  + commitId);
+
+   // // write header
+   // output.push('/*', fs.readFileSync(licensePath, 'utf8'), '*/');
+   // output.push(';(function() {');
+   // output.push("var CORDOVA_JS_BUILD_LABEL = '"  + commitId + "';");
+
+   // // write initial scripts
+   // if (!scripts['require']) {
+   //     throw new Error("didn't find a script for 'require'")
+   // }
+    
+   // writeScript(output, scripts['require'], debug)
+    b.transform(require_tr);
+
+    b.add(path.join(root, 'src', platform, 'exec.js'));
+
+    b.add(path.join(root, 'src', 'scripts', 'bootstrap.js'));
+
+    return b;
+}


[04/45] js commit: adding browserify bundle

Posted by an...@apache.org.
adding browserify bundle


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

Branch: refs/heads/master
Commit: 42621ce868692caa13308120fd9e0ecf92d5c211
Parents: 565c6be
Author: Anis Kadri <an...@apache.org>
Authored: Mon Feb 3 22:21:28 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Mon Feb 3 22:21:28 2014 -0800

----------------------------------------------------------------------
 tasks/lib/bundle-browserify.js | 62 +++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/42621ce8/tasks/lib/bundle-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/bundle-browserify.js b/tasks/lib/bundle-browserify.js
new file mode 100644
index 0000000..3d91e42
--- /dev/null
+++ b/tasks/lib/bundle-browserify.js
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF
+ * or more contributor license agreements.  See th
+ * distributed with this work for additional infor
+ * regarding copyright ownership.  The ASF license
+ * to you under the Apache License, Version 2.0 (t
+ * "License"); you may not use this file except in
+ * with the License.  You may obtain a copy of the
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to 
+ * software distributed under the License is distr
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ * KIND, either express or implied.  See the Licen
+ * specific language governing permissions and lim
+ * under the License.
+ */
+var fs           = require('fs');
+var path         = require('path');
+var browserify   = require('browserify');
+var require_tr   = require('./require-tr');
+var licensePath  = path.join(__dirname, '..', 'templates', 'LICENSE-for-js-file.txt');
+var root         = path.join(__dirname, '..', '..')
+
+
+module.exports = function bundle(platform, debug, commitId) {
+    // FIXME: need to find a way to void ignore missing
+    var b = browserify();
+    // XXX plugin_list is not present at this stage 
+    b.ignore(path.join(root, 'src', 'common', 'plugin_list'));
+
+   // if (platform === 'test') {
+   //     // FIXME why does 'test' resolve a bunch of android stuff?! 
+   //     var testFilesPath = path.join('src', 'android', 'android');
+   //     copyProps(modules, collectFiles(testFilesPath, 'android/'));
+   // }
+
+   // var output = [];
+	
+   // output.push("// Platform: " + platform);
+   // output.push("// "  + commitId);
+
+   // // write header
+   // output.push('/*', fs.readFileSync(licensePath, 'utf8'), '*/');
+   // output.push(';(function() {');
+   // output.push("var CORDOVA_JS_BUILD_LABEL = '"  + commitId + "';");
+
+   // // write initial scripts
+   // if (!scripts['require']) {
+   //     throw new Error("didn't find a script for 'require'")
+   // }
+    
+   // writeScript(output, scripts['require'], debug)
+    b.transform(require_tr);
+
+    b.add(path.join(root, 'src', platform, 'exec.js'));
+
+    b.add(path.join(root, 'src', 'scripts', 'bootstrap.js'));
+
+    return b;
+}


[25/45] js commit: adding browserify packager

Posted by an...@apache.org.
adding browserify packager


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

Branch: refs/heads/master
Commit: dec96272458c8457436c47484275a023e3d7abe5
Parents: 0644971
Author: Anis Kadri <an...@apache.org>
Authored: Mon Feb 3 22:21:01 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:21 2014 +0100

----------------------------------------------------------------------
 tasks/lib/packager-browserify.js | 59 +++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/dec96272/tasks/lib/packager-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/packager-browserify.js b/tasks/lib/packager-browserify.js
new file mode 100644
index 0000000..299bf89
--- /dev/null
+++ b/tasks/lib/packager-browserify.js
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF
+ * or more contributor license agreements.  See th
+ * distributed with this work for additional infor
+ * regarding copyright ownership.  The ASF license
+ * to you under the Apache License, Version 2.0 (t
+ * "License"); you may not use this file except in
+ * with the License.  You may obtain a copy of the
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to 
+ * software distributed under the License is distr
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ * KIND, either express or implied.  See the Licen
+ * specific language governing permissions and lim
+ * under the License.
+ */
+var fs              = require('fs');
+var path            = require('path');
+var bundle          = require('./bundle-browserify');
+var computeCommitId = require('./compute-commit-id');
+
+
+module.exports = function generate(platform, useWindowsLineEndings, callback) {
+    computeCommitId(function(commitId) {
+        var outFile, outFileStream;
+        var time = new Date().valueOf();
+
+        var libraryRelease = bundle(platform, false, commitId);
+        // if we are using windows line endings, we will also add the BOM
+        if(useWindowsLineEndings) {
+            libraryRelease = "\ufeff" + libraryRelease.split(/\r?\n/).join("\r\n");
+        }
+        //var libraryDebug   = bundle(platform, true, commitId);
+
+        time = new Date().valueOf() - time;
+        if (!fs.existsSync('pkg')) {
+            fs.mkdirSync('pkg');
+        }
+       // if(!fs.existsSync('pkg/debug')) {
+       //     fs.mkdirSync('pkg/debug');
+       // }
+        //libraryRelease.bundle().pipe(process.stdout);
+
+        outFile = path.join('pkg', 'cordova.' + platform + '.js');
+        outFileStream = fs.createWriteStream(outFile);
+        libraryRelease.bundle().pipe(outFileStream);
+
+        libraryRelease.bundle().on('end', function() {
+          console.log('generated cordova.' + platform + '.js @ ' + commitId + ' in ' + time + 'ms');
+          callback();
+        });
+
+       // outFile = path.join('pkg', 'debug', 'cordova.' + platform + '-debug.js');
+       // outFileStream = fs.createWriteStream(outFile);
+       // libraryDebug.bundle().pipe(outFileStream);
+    });
+}


[12/45] js commit: replacing platform/exec

Posted by an...@apache.org.
replacing platform/exec


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

Branch: refs/heads/master
Commit: 26a9f98a347f5510fbd838ac8eeb008d44bf952c
Parents: b1de593
Author: Anis Kadri <an...@apache.org>
Authored: Mon Feb 24 19:46:57 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Mon Feb 24 19:46:57 2014 -0800

----------------------------------------------------------------------
 tasks/lib/bundle-browserify.js | 25 ++-----------------------
 tasks/lib/require-tr.js        | 36 +++++++++++++++++++++++-------------
 2 files changed, 25 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/26a9f98a/tasks/lib/bundle-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/bundle-browserify.js b/tasks/lib/bundle-browserify.js
index 0dda5d3..85da8dd 100644
--- a/tasks/lib/bundle-browserify.js
+++ b/tasks/lib/bundle-browserify.js
@@ -25,34 +25,13 @@ var root         = path.join(__dirname, '..', '..')
 
 
 module.exports = function bundle(platform, debug, commitId) {
+    require_tr.platform = platform;
     // FIXME: need to find a way to void ignore missing
     var b = browserify({debug: debug});
     // XXX plugin_list is not present at this stage 
     b.ignore(path.join(root, 'src', 'common', 'plugin_list'));
 
-   // if (platform === 'test') {
-   //     // FIXME why does 'test' resolve a bunch of android stuff?! 
-   //     var testFilesPath = path.join('src', 'android', 'android');
-   //     copyProps(modules, collectFiles(testFilesPath, 'android/'));
-   // }
-
-   // var output = [];
-	
-   // output.push("// Platform: " + platform);
-   // output.push("// "  + commitId);
-
-   // // write header
-   // output.push('/*', fs.readFileSync(licensePath, 'utf8'), '*/');
-   // output.push(';(function() {');
-   // output.push("var CORDOVA_JS_BUILD_LABEL = '"  + commitId + "';");
-
-   // // write initial scripts
-   // if (!scripts['require']) {
-   //     throw new Error("didn't find a script for 'require'")
-   // }
-    
-   // writeScript(output, scripts['require'], debug)
-    b.transform(require_tr);
+    b.transform(require_tr.transform);
 
     b.add(path.join(root, 'src', platform, 'exec.js'));
     

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/26a9f98a/tasks/lib/require-tr.js
----------------------------------------------------------------------
diff --git a/tasks/lib/require-tr.js b/tasks/lib/require-tr.js
index ba8bd53..5629e80 100644
--- a/tasks/lib/require-tr.js
+++ b/tasks/lib/require-tr.js
@@ -35,15 +35,16 @@ function _updateRequires(code) {
   var ast = UglifyJS.parse(code);
 
   var walker = new UglifyJS.TreeWalker(function(node) {
+
     // check all function calls
     if(node instanceof UglifyJS.AST_Call) {
       // check if function call is a require('module') call
       if(node.expression.name === "require") {
         // make sure require only has one argument and that it starts with cordova (old style require.js) 
-        //fs.appendFileSync('/tmp/foo', JSON.stringify(node.args[0]) + "###\n");
         if(node.args.length === 1 && 
            node.args[0].value !== undefined &&
            node.args[0].value.indexOf("cordova") === 0) {
+          //fs.appendFileSync('/tmp/foo', JSON.stringify(node.args[0].value) + "\n###\n");
           // cordova.js
           if(node.args[0].value === "cordova") {
             node.args[0].value = path.join(root, "src", "cordova");
@@ -51,6 +52,11 @@ function _updateRequires(code) {
           } else if(node.args[0].value.match(/cordova\/(android|amazon-fireos)\/(.+)/)) {
             node.args[0].value = node.args[0].value.replace(/cordova\/(android|amazon-fireos)\/(.+)/,
                                  path.join(root, "src", "$1", "android", "$2"));
+          // replace common exec/platform with the platform's exec/platform
+          } else if(node.args[0].value.match(/cordova\/(platform|exec)$/)) {
+            //fs.appendFileSync('/tmp/foo', node.args[0].value + "\n" +module.exports.platform + "\n");
+            node.args[0].value = node.args[0].value.replace(/cordova\/(platform|exec)/,
+                                 path.join(root, "src", module.exports.platform, "$1"));
           // everything else
           } else if(node.args[0].value.match(/cordova\/(.+)/)) {
             node.args[0].value = node.args[0].value.replace(/cordova\/(.+)/,
@@ -71,18 +77,22 @@ function _updateRequires(code) {
 }
 
 
-module.exports = function(file) {
-  var data = '';
+module.exports = {
+
+  transform: function(file) {
+    var data = '';
 
-  function write(buf) {
-    data += buf;
-  }
+    function write(buf) {
+      data += buf;
+    }
 
-  function end() {
-    //fs.appendFileSync('/tmp/foo', _updateRequires(data));
-    this.queue(_updateRequires(data));
-    this.queue(null);
-  }
- 
-  return through(write, end);
+    function end() {
+      //fs.appendFileSync('/tmp/foo', _updateRequires(data));
+      this.queue(_updateRequires(data));
+      this.queue(null);
+    }
+   
+    return through(write, end);
+  },
+  platform: ""
 }


[08/45] js commit: adding other platforms

Posted by an...@apache.org.
adding other platforms


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

Branch: refs/heads/master
Commit: 15b0952ea66f0776f8fc0110a5598d6469da9e9a
Parents: 74c53ef
Author: Anis Kadri <an...@apache.org>
Authored: Wed Feb 5 18:21:38 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Wed Feb 5 18:21:38 2014 -0800

----------------------------------------------------------------------
 Gruntfile.js                     | 10 +++++++++-
 tasks/lib/packager-browserify.js |  6 +++---
 2 files changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/15b0952e/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index 3da4d43..69af034 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -36,7 +36,15 @@ module.exports = function(grunt) {
         "compile-browserify": {
             "amazon-fireos": {},
             "android": {},
-            "ios": {}
+            "blackberry10": {},
+            "ios": {},
+            "osx": {},
+            //"test": {},
+            "windows8": { useWindowsLineEndings: true },
+            "windowsphone": { useWindowsLineEndings: true },
+            "firefoxos": {},
+            "ubuntu": {},
+            "browser": {}
         },
         clean: ['pkg'],
         jshint: {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/15b0952e/tasks/lib/packager-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/packager-browserify.js b/tasks/lib/packager-browserify.js
index 299bf89..e3407cf 100644
--- a/tasks/lib/packager-browserify.js
+++ b/tasks/lib/packager-browserify.js
@@ -29,9 +29,9 @@ module.exports = function generate(platform, useWindowsLineEndings, callback) {
 
         var libraryRelease = bundle(platform, false, commitId);
         // if we are using windows line endings, we will also add the BOM
-        if(useWindowsLineEndings) {
-            libraryRelease = "\ufeff" + libraryRelease.split(/\r?\n/).join("\r\n");
-        }
+       // if(useWindowsLineEndings) {
+       //     libraryRelease = "\ufeff" + libraryRelease.split(/\r?\n/).join("\r\n");
+       // }
         //var libraryDebug   = bundle(platform, true, commitId);
 
         time = new Date().valueOf() - time;


[03/45] js commit: adding browserify packager

Posted by an...@apache.org.
adding browserify packager


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

Branch: refs/heads/master
Commit: 565c6bee06441255492fd2030d70acccb5b9ec33
Parents: beeb953
Author: Anis Kadri <an...@apache.org>
Authored: Mon Feb 3 22:21:01 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Mon Feb 3 22:21:01 2014 -0800

----------------------------------------------------------------------
 tasks/lib/packager-browserify.js | 59 +++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/565c6bee/tasks/lib/packager-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/packager-browserify.js b/tasks/lib/packager-browserify.js
new file mode 100644
index 0000000..299bf89
--- /dev/null
+++ b/tasks/lib/packager-browserify.js
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF
+ * or more contributor license agreements.  See th
+ * distributed with this work for additional infor
+ * regarding copyright ownership.  The ASF license
+ * to you under the Apache License, Version 2.0 (t
+ * "License"); you may not use this file except in
+ * with the License.  You may obtain a copy of the
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to 
+ * software distributed under the License is distr
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ * KIND, either express or implied.  See the Licen
+ * specific language governing permissions and lim
+ * under the License.
+ */
+var fs              = require('fs');
+var path            = require('path');
+var bundle          = require('./bundle-browserify');
+var computeCommitId = require('./compute-commit-id');
+
+
+module.exports = function generate(platform, useWindowsLineEndings, callback) {
+    computeCommitId(function(commitId) {
+        var outFile, outFileStream;
+        var time = new Date().valueOf();
+
+        var libraryRelease = bundle(platform, false, commitId);
+        // if we are using windows line endings, we will also add the BOM
+        if(useWindowsLineEndings) {
+            libraryRelease = "\ufeff" + libraryRelease.split(/\r?\n/).join("\r\n");
+        }
+        //var libraryDebug   = bundle(platform, true, commitId);
+
+        time = new Date().valueOf() - time;
+        if (!fs.existsSync('pkg')) {
+            fs.mkdirSync('pkg');
+        }
+       // if(!fs.existsSync('pkg/debug')) {
+       //     fs.mkdirSync('pkg/debug');
+       // }
+        //libraryRelease.bundle().pipe(process.stdout);
+
+        outFile = path.join('pkg', 'cordova.' + platform + '.js');
+        outFileStream = fs.createWriteStream(outFile);
+        libraryRelease.bundle().pipe(outFileStream);
+
+        libraryRelease.bundle().on('end', function() {
+          console.log('generated cordova.' + platform + '.js @ ' + commitId + ' in ' + time + 'ms');
+          callback();
+        });
+
+       // outFile = path.join('pkg', 'debug', 'cordova.' + platform + '-debug.js');
+       // outFileStream = fs.createWriteStream(outFile);
+       // libraryDebug.bundle().pipe(outFileStream);
+    });
+}


[42/45] js commit: Merge branch 'browserify' of https://git-wip-us.apache.org/repos/asf/cordova-js into browserify

Posted by an...@apache.org.
Merge branch 'browserify' of https://git-wip-us.apache.org/repos/asf/cordova-js into browserify

Conflicts:
	package.json


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

Branch: refs/heads/master
Commit: 40c4ab4ad434df733fa048bc2caf29e2cb3a0084
Parents: 82d62c8 f4f5bb6
Author: Anis Kadri <an...@apache.org>
Authored: Thu Mar 27 15:21:54 2014 +0100
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:21:54 2014 +0100

----------------------------------------------------------------------

----------------------------------------------------------------------



[19/45] js commit: removing onPluginsReady and setting platform exec

Posted by an...@apache.org.
removing onPluginsReady and setting platform exec


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

Branch: refs/heads/master
Commit: 94a1185390485015db1b164706788968f0661e59
Parents: 2a6941c
Author: Anis Kadri <an...@apache.org>
Authored: Wed Mar 26 17:27:30 2014 +0100
Committer: Anis Kadri <an...@apache.org>
Committed: Wed Mar 26 17:27:30 2014 +0100

----------------------------------------------------------------------
 src/common/channel.js |  1 +
 src/common/init_b.js  | 19 +++++--------------
 2 files changed, 6 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/94a11853/src/common/channel.js
----------------------------------------------------------------------
diff --git a/src/common/channel.js b/src/common/channel.js
index 653af15..f3d83df 100644
--- a/src/common/channel.js
+++ b/src/common/channel.js
@@ -235,6 +235,7 @@ channel.createSticky('onNativeReady');
 channel.createSticky('onCordovaReady');
 
 // Event to indicate that all automatically loaded JS plugins are loaded and ready.
+// FIXME remove this
 channel.createSticky('onPluginsReady');
 
 // Event to indicate that Cordova is ready

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/94a11853/src/common/init_b.js
----------------------------------------------------------------------
diff --git a/src/common/init_b.js b/src/common/init_b.js
index efcb6cf..288c5a5 100644
--- a/src/common/init_b.js
+++ b/src/common/init_b.js
@@ -21,11 +21,12 @@
 
 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];
+var platformInitChannelsArray = [channel.onNativeReady];
+
+// setting exec
+cordova.exec = require('cordova/exec');
 
 function logUnfiredChannels(arr) {
     for (var i = 0; i < arr.length; ++i) {
@@ -96,23 +97,14 @@ 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
@@ -126,4 +118,3 @@ channel.join(function() {
     }, channel.deviceReadyChannelsArray);
 
 }, platformInitChannelsArray);
-


[14/45] js commit: replacing init with init_b

Posted by an...@apache.org.
replacing init with init_b


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

Branch: refs/heads/master
Commit: 7d368f42204b1c55caba2ed8c79156fed6688530
Parents: f6931d6
Author: Anis Kadri <an...@apache.org>
Authored: Wed Mar 5 16:20:22 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Wed Mar 5 16:20:22 2014 -0800

----------------------------------------------------------------------
 tasks/lib/require-tr.js | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/7d368f42/tasks/lib/require-tr.js
----------------------------------------------------------------------
diff --git a/tasks/lib/require-tr.js b/tasks/lib/require-tr.js
index 2c347a3..7bde0f6 100644
--- a/tasks/lib/require-tr.js
+++ b/tasks/lib/require-tr.js
@@ -85,6 +85,10 @@ function _updateRequires(code) {
           if(module === "cordova") {
             node.args[0].value = path.join(root, "src", "cordova_b");
           // android and amazon-fireos have some special require's
+          }  else if(module.match(/cordova\/init/)) {
+            node.args[0].value = module.replace(/cordova\/init/,
+                                    path.join(root, "src", "common", "init_b"));
+          // require('cordova/exec') and require('cordova/platform') -> platform's exec/platform
           } else if(module.match(/cordova\/(android|amazon-fireos)\/(.+)/)) {
             node.args[0].value = module.replace(/cordova\/(android|amazon-fireos)\/(.+)/,
                                     path.join(root, "src", "$1", "android", "$2"));


[31/45] js commit: files were not properly generated

Posted by an...@apache.org.
files were not properly generated


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

Branch: refs/heads/master
Commit: 202b92fb1e2023a547d7c6f654d377f8e8c06852
Parents: 061d7d2
Author: Anis Kadri <an...@apache.org>
Authored: Wed Feb 19 16:53:45 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:22 2014 +0100

----------------------------------------------------------------------
 tasks/lib/packager-browserify.js | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/202b92fb/tasks/lib/packager-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/packager-browserify.js b/tasks/lib/packager-browserify.js
index 04b982d..ecc8e9d 100644
--- a/tasks/lib/packager-browserify.js
+++ b/tasks/lib/packager-browserify.js
@@ -22,10 +22,11 @@ var bundle          = require('./bundle-browserify');
 var computeCommitId = require('./compute-commit-id');
 
 
-module.exports = function generate(platform, useWindowsLineEndings, callback) {
+module.exports = function generate(platform, useWindowsLineEndings, done) {
     computeCommitId(function(commitId) {
         var outReleaseFile, outReleaseFileStream,
-            outDebugFile, outDebugFileStream;
+            outDebugFile, outDebugFileStream,
+            releaseBundle, debugBundle;
         var time = new Date().valueOf();
 
         var libraryRelease = bundle(platform, false, commitId);
@@ -44,20 +45,23 @@ module.exports = function generate(platform, useWindowsLineEndings, callback) {
 
         outReleaseFile = path.join('pkg', 'cordova.' + platform + '.js');
         outReleaseFileStream = fs.createWriteStream(outReleaseFile);
-        libraryRelease.bundle().pipe(outReleaseFileStream);
+        releaseBundle = libraryRelease.bundle();
+        releaseBundle.pipe(outReleaseFileStream);
 
-        libraryRelease.bundle().on('end', function() {
+        releaseBundle.on('end', function() {
           var newtime = new Date().valueOf() - time;
           console.log('generated cordova.' + platform + '.js @ ' + commitId + ' in ' + newtime + 'ms');
-          callback();
+          done();
         });
 
         outDebugFile = path.join('pkg', 'debug', 'cordova.' + platform + '-debug.js');
         outDebugFileStream = fs.createWriteStream(outDebugFile);
-        libraryDebug.bundle().on('end', function() {
+        debugBundle = libraryDebug.bundle();
+        debugBundle.pipe(outDebugFileStream);
+
+        outDebugFileStream.on('end', function() {
           var newtime = new Date().valueOf() - time;
           console.log('generated cordova.' + platform + '-debug.js @ ' + commitId + ' in ' + newtime + 'ms');
-          callback();
         });
     });
 }


[11/45] js commit: files were not properly generated

Posted by an...@apache.org.
files were not properly generated


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

Branch: refs/heads/master
Commit: b1de593a5f67ed6417e16679cd7b9e2dc5877736
Parents: 8ff104b
Author: Anis Kadri <an...@apache.org>
Authored: Wed Feb 19 16:53:45 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Wed Feb 19 16:53:45 2014 -0800

----------------------------------------------------------------------
 tasks/lib/packager-browserify.js | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/b1de593a/tasks/lib/packager-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/packager-browserify.js b/tasks/lib/packager-browserify.js
index 04b982d..ecc8e9d 100644
--- a/tasks/lib/packager-browserify.js
+++ b/tasks/lib/packager-browserify.js
@@ -22,10 +22,11 @@ var bundle          = require('./bundle-browserify');
 var computeCommitId = require('./compute-commit-id');
 
 
-module.exports = function generate(platform, useWindowsLineEndings, callback) {
+module.exports = function generate(platform, useWindowsLineEndings, done) {
     computeCommitId(function(commitId) {
         var outReleaseFile, outReleaseFileStream,
-            outDebugFile, outDebugFileStream;
+            outDebugFile, outDebugFileStream,
+            releaseBundle, debugBundle;
         var time = new Date().valueOf();
 
         var libraryRelease = bundle(platform, false, commitId);
@@ -44,20 +45,23 @@ module.exports = function generate(platform, useWindowsLineEndings, callback) {
 
         outReleaseFile = path.join('pkg', 'cordova.' + platform + '.js');
         outReleaseFileStream = fs.createWriteStream(outReleaseFile);
-        libraryRelease.bundle().pipe(outReleaseFileStream);
+        releaseBundle = libraryRelease.bundle();
+        releaseBundle.pipe(outReleaseFileStream);
 
-        libraryRelease.bundle().on('end', function() {
+        releaseBundle.on('end', function() {
           var newtime = new Date().valueOf() - time;
           console.log('generated cordova.' + platform + '.js @ ' + commitId + ' in ' + newtime + 'ms');
-          callback();
+          done();
         });
 
         outDebugFile = path.join('pkg', 'debug', 'cordova.' + platform + '-debug.js');
         outDebugFileStream = fs.createWriteStream(outDebugFile);
-        libraryDebug.bundle().on('end', function() {
+        debugBundle = libraryDebug.bundle();
+        debugBundle.pipe(outDebugFileStream);
+
+        outDebugFileStream.on('end', function() {
           var newtime = new Date().valueOf() - time;
           console.log('generated cordova.' + platform + '-debug.js @ ' + commitId + ' in ' + newtime + 'ms');
-          callback();
         });
     });
 }


[26/45] js commit: adding browserify compile task

Posted by an...@apache.org.
adding browserify compile task


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

Branch: refs/heads/master
Commit: b10197c51f2f9e5cf29741c0f93662f4d26c979b
Parents: eed80cb
Author: Anis Kadri <an...@apache.org>
Authored: Mon Feb 3 22:21:53 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:21 2014 +0100

----------------------------------------------------------------------
 tasks/compile-browserify.js | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/b10197c5/tasks/compile-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/compile-browserify.js b/tasks/compile-browserify.js
new file mode 100644
index 0000000..1d28510
--- /dev/null
+++ b/tasks/compile-browserify.js
@@ -0,0 +1,29 @@
+/*
+ * 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 generate = require('./lib/packager-browserify');
+
+module.exports = function(grunt) {
+    grunt.registerMultiTask('compile-browserify', 'Packages cordova.js browserify style', function() {
+
+        var done = this.async();
+        var platformName = this.target;
+        var useWindowsLineEndings = this.data.useWindowsLineEndings;
+        generate(platformName, useWindowsLineEndings, done);
+    });
+}


[18/45] js commit: updating version

Posted by an...@apache.org.
updating version


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

Branch: refs/heads/master
Commit: 2a6941c2956cf36d2e33fa8323cd05b6fff11e37
Parents: 0dc876d
Author: Anis Kadri <an...@apache.org>
Authored: Wed Mar 26 17:26:39 2014 +0100
Committer: Anis Kadri <an...@apache.org>
Committed: Wed Mar 26 17:26:39 2014 +0100

----------------------------------------------------------------------
 package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/2a6941c2/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index b0c6225..fdafd26 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
   "author": "Gord Tanner <gt...@gmail.com> (http://github.com/gtanner)",
   "name": "cordova-js",
   "description": "Cordova JavaScript: a unified JavaScript layer for the Cordova suite of projects enabling cross-platform native mobile development of applications using HTML, CSS and JavaScript.",
-  "version": "3.1.0",
+  "version": "3.5.0",
   "homepage": "http://cordova.apache.org",
   "repository": {
     "type": "git",


[33/45] js commit: replacing platform/exec

Posted by an...@apache.org.
replacing platform/exec


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

Branch: refs/heads/master
Commit: 2c300fdd19c1bc3ee121c329aa4efb8c249b7bfb
Parents: 202b92f
Author: Anis Kadri <an...@apache.org>
Authored: Mon Feb 24 19:46:57 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:22 2014 +0100

----------------------------------------------------------------------
 tasks/lib/bundle-browserify.js | 25 ++-----------------------
 tasks/lib/require-tr.js        | 36 +++++++++++++++++++++++-------------
 2 files changed, 25 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/2c300fdd/tasks/lib/bundle-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/bundle-browserify.js b/tasks/lib/bundle-browserify.js
index 0dda5d3..85da8dd 100644
--- a/tasks/lib/bundle-browserify.js
+++ b/tasks/lib/bundle-browserify.js
@@ -25,34 +25,13 @@ var root         = path.join(__dirname, '..', '..')
 
 
 module.exports = function bundle(platform, debug, commitId) {
+    require_tr.platform = platform;
     // FIXME: need to find a way to void ignore missing
     var b = browserify({debug: debug});
     // XXX plugin_list is not present at this stage 
     b.ignore(path.join(root, 'src', 'common', 'plugin_list'));
 
-   // if (platform === 'test') {
-   //     // FIXME why does 'test' resolve a bunch of android stuff?! 
-   //     var testFilesPath = path.join('src', 'android', 'android');
-   //     copyProps(modules, collectFiles(testFilesPath, 'android/'));
-   // }
-
-   // var output = [];
-	
-   // output.push("// Platform: " + platform);
-   // output.push("// "  + commitId);
-
-   // // write header
-   // output.push('/*', fs.readFileSync(licensePath, 'utf8'), '*/');
-   // output.push(';(function() {');
-   // output.push("var CORDOVA_JS_BUILD_LABEL = '"  + commitId + "';");
-
-   // // write initial scripts
-   // if (!scripts['require']) {
-   //     throw new Error("didn't find a script for 'require'")
-   // }
-    
-   // writeScript(output, scripts['require'], debug)
-    b.transform(require_tr);
+    b.transform(require_tr.transform);
 
     b.add(path.join(root, 'src', platform, 'exec.js'));
     

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/2c300fdd/tasks/lib/require-tr.js
----------------------------------------------------------------------
diff --git a/tasks/lib/require-tr.js b/tasks/lib/require-tr.js
index ba8bd53..5629e80 100644
--- a/tasks/lib/require-tr.js
+++ b/tasks/lib/require-tr.js
@@ -35,15 +35,16 @@ function _updateRequires(code) {
   var ast = UglifyJS.parse(code);
 
   var walker = new UglifyJS.TreeWalker(function(node) {
+
     // check all function calls
     if(node instanceof UglifyJS.AST_Call) {
       // check if function call is a require('module') call
       if(node.expression.name === "require") {
         // make sure require only has one argument and that it starts with cordova (old style require.js) 
-        //fs.appendFileSync('/tmp/foo', JSON.stringify(node.args[0]) + "###\n");
         if(node.args.length === 1 && 
            node.args[0].value !== undefined &&
            node.args[0].value.indexOf("cordova") === 0) {
+          //fs.appendFileSync('/tmp/foo', JSON.stringify(node.args[0].value) + "\n###\n");
           // cordova.js
           if(node.args[0].value === "cordova") {
             node.args[0].value = path.join(root, "src", "cordova");
@@ -51,6 +52,11 @@ function _updateRequires(code) {
           } else if(node.args[0].value.match(/cordova\/(android|amazon-fireos)\/(.+)/)) {
             node.args[0].value = node.args[0].value.replace(/cordova\/(android|amazon-fireos)\/(.+)/,
                                  path.join(root, "src", "$1", "android", "$2"));
+          // replace common exec/platform with the platform's exec/platform
+          } else if(node.args[0].value.match(/cordova\/(platform|exec)$/)) {
+            //fs.appendFileSync('/tmp/foo', node.args[0].value + "\n" +module.exports.platform + "\n");
+            node.args[0].value = node.args[0].value.replace(/cordova\/(platform|exec)/,
+                                 path.join(root, "src", module.exports.platform, "$1"));
           // everything else
           } else if(node.args[0].value.match(/cordova\/(.+)/)) {
             node.args[0].value = node.args[0].value.replace(/cordova\/(.+)/,
@@ -71,18 +77,22 @@ function _updateRequires(code) {
 }
 
 
-module.exports = function(file) {
-  var data = '';
+module.exports = {
+
+  transform: function(file) {
+    var data = '';
 
-  function write(buf) {
-    data += buf;
-  }
+    function write(buf) {
+      data += buf;
+    }
 
-  function end() {
-    //fs.appendFileSync('/tmp/foo', _updateRequires(data));
-    this.queue(_updateRequires(data));
-    this.queue(null);
-  }
- 
-  return through(write, end);
+    function end() {
+      //fs.appendFileSync('/tmp/foo', _updateRequires(data));
+      this.queue(_updateRequires(data));
+      this.queue(null);
+    }
+   
+    return through(write, end);
+  },
+  platform: ""
 }


[21/45] js commit: adding cordova.require fake wrapper

Posted by an...@apache.org.
adding cordova.require fake wrapper


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

Branch: refs/heads/master
Commit: f4f5bb605f1611913e378f0ac6998c44bef3e530
Parents: a7e3969
Author: Anis Kadri <an...@apache.org>
Authored: Thu Mar 27 15:04:34 2014 +0100
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:04:34 2014 +0100

----------------------------------------------------------------------
 src/cordova_b.js | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f4f5bb60/src/cordova_b.js
----------------------------------------------------------------------
diff --git a/src/cordova_b.js b/src/cordova_b.js
index f4c781e..a00423c 100644
--- a/src/cordova_b.js
+++ b/src/cordova_b.js
@@ -226,4 +226,14 @@ var cordova = {
         });
     }
 };
+
+// FIXME hack: cordova iOS calls cordova.require()
+cordova.require = function(module) {
+  if(module === "cordova/exec") {
+    return cordova.exec;
+  }
+
+  return undefined;
+}
+
 window.cordova = module.exports = cordova;


[32/45] js commit: removing onPluginsReady and setting platform exec

Posted by an...@apache.org.
removing onPluginsReady and setting platform exec


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

Branch: refs/heads/master
Commit: df0e08236b4b177bfe13316c83ab3e5d66249bed
Parents: 77fbf3a
Author: Anis Kadri <an...@apache.org>
Authored: Wed Mar 26 17:27:30 2014 +0100
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:22 2014 +0100

----------------------------------------------------------------------
 src/common/channel.js |  1 +
 src/common/init_b.js  | 19 +++++--------------
 2 files changed, 6 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/df0e0823/src/common/channel.js
----------------------------------------------------------------------
diff --git a/src/common/channel.js b/src/common/channel.js
index 653af15..f3d83df 100644
--- a/src/common/channel.js
+++ b/src/common/channel.js
@@ -235,6 +235,7 @@ channel.createSticky('onNativeReady');
 channel.createSticky('onCordovaReady');
 
 // Event to indicate that all automatically loaded JS plugins are loaded and ready.
+// FIXME remove this
 channel.createSticky('onPluginsReady');
 
 // Event to indicate that Cordova is ready

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/df0e0823/src/common/init_b.js
----------------------------------------------------------------------
diff --git a/src/common/init_b.js b/src/common/init_b.js
index efcb6cf..288c5a5 100644
--- a/src/common/init_b.js
+++ b/src/common/init_b.js
@@ -21,11 +21,12 @@
 
 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];
+var platformInitChannelsArray = [channel.onNativeReady];
+
+// setting exec
+cordova.exec = require('cordova/exec');
 
 function logUnfiredChannels(arr) {
     for (var i = 0; i < arr.length; ++i) {
@@ -96,23 +97,14 @@ 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
@@ -126,4 +118,3 @@ channel.join(function() {
     }, channel.deviceReadyChannelsArray);
 
 }, platformInitChannelsArray);
-


[38/45] js commit: moving license writing to other module

Posted by an...@apache.org.
moving license writing to other module


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

Branch: refs/heads/master
Commit: ec5e490039f90cc09bd04b4f086a363f586efaa4
Parents: 75860dd
Author: Anis Kadri <an...@apache.org>
Authored: Fri Mar 14 16:41:44 2014 -0700
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:22 2014 +0100

----------------------------------------------------------------------
 tasks/lib/packager-browserify.js  | 24 ++++++++----------------
 tasks/lib/write-license-header.js | 16 ++++++++++++++++
 2 files changed, 24 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/ec5e4900/tasks/lib/packager-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/packager-browserify.js b/tasks/lib/packager-browserify.js
index 07d7774..ecc3f5f 100644
--- a/tasks/lib/packager-browserify.js
+++ b/tasks/lib/packager-browserify.js
@@ -16,13 +16,12 @@
  * specific language governing permissions and lim
  * under the License.
  */
-var fs              = require('fs');
-var path            = require('path');
-var util            = require('util');
-var bundle          = require('./bundle-browserify');
-var computeCommitId = require('./compute-commit-id');
-var licensePath     = path.join(__dirname, '..', 'templates', 'LICENSE-for-js-file.txt');
-var require_tr   = require('./require-tr');
+var fs                 = require('fs');
+var path               = require('path');
+var util               = require('util');
+var bundle             = require('./bundle-browserify');
+var computeCommitId    = require('./compute-commit-id');
+var writeLicenseHeader = require('./write-license-header');
 
 
 module.exports = function generate(platform, useWindowsLineEndings, done) {
@@ -49,17 +48,10 @@ module.exports = function generate(platform, useWindowsLineEndings, done) {
         outReleaseFile = path.join('pkg', 'cordova.' + platform + '.js');
         outReleaseFileStream = fs.createWriteStream(outReleaseFile);
         
-        // some poppycock 
-        var licenseText = util.format("/*\n *%s\n */\n", fs.readFileSync(licensePath, 'utf8').replace(/\n/g, "\n *"));
+        // write license header
+        writeLicenseHeader(outReleaseFileStream, platform, commitId);
 
-        outReleaseFileStream.write("// Platform: " + platform + "\n", 'utf8');
-        outReleaseFileStream.write("// "  + commitId + "\n", 'utf8');
-        outReleaseFileStream.write(licenseText, 'utf8');
-        outReleaseFileStream.write("var CORDOVA_JS_BUILD_LABEL = '"  + commitId + "';\n", 'utf8');
-        outReleaseFileStream.write("var define = {moduleMap: []};\n", 'utf8');
-        
         releaseBundle = libraryRelease.bundle();
-        //console.log(libraryRelease.deps());
 
         releaseBundle.pipe(outReleaseFileStream);
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/ec5e4900/tasks/lib/write-license-header.js
----------------------------------------------------------------------
diff --git a/tasks/lib/write-license-header.js b/tasks/lib/write-license-header.js
new file mode 100644
index 0000000..8b33cbd
--- /dev/null
+++ b/tasks/lib/write-license-header.js
@@ -0,0 +1,16 @@
+var path        = require('path');
+var util        = require('util');
+var fs          = require('fs');
+var licensePath = path.join(__dirname, '..', 'templates', 'LICENSE-for-js-file.txt');
+
+module.exports = function(outStream, platform, commitId) {
+  // some poppycock 
+  var licenseText = util.format("/*\n *%s\n */\n", fs.readFileSync(licensePath, 'utf8').replace(/\n/g, "\n *"));
+
+  outStream.write("// Platform: " + platform + "\n", 'utf8');
+  outStream.write("// "  + commitId + "\n", 'utf8');
+  outStream.write(licenseText, 'utf8');
+  outStream.write("var CORDOVA_JS_BUILD_LABEL = '"  + commitId + "';\n", 'utf8');
+  outStream.write("var define = {moduleMap: []};\n", 'utf8');
+
+}


[07/45] js commit: adding android and amazon-fireos

Posted by an...@apache.org.
adding android and amazon-fireos


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

Branch: refs/heads/master
Commit: 74c53effabe640c8cf8aa035dd2f81de68ae6bc9
Parents: c08165e
Author: Anis Kadri <an...@apache.org>
Authored: Tue Feb 4 16:07:00 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Tue Feb 4 16:07:00 2014 -0800

----------------------------------------------------------------------
 Gruntfile.js                   |  2 ++
 tasks/lib/bundle-browserify.js |  2 ++
 tasks/lib/require-tr.js        | 11 +++++++++--
 3 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/74c53eff/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index ed153bd..3da4d43 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -34,6 +34,8 @@ module.exports = function(grunt) {
             "browser": {}
         },
         "compile-browserify": {
+            "amazon-fireos": {},
+            "android": {},
             "ios": {}
         },
         clean: ['pkg'],

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/74c53eff/tasks/lib/bundle-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/bundle-browserify.js b/tasks/lib/bundle-browserify.js
index 3d91e42..e678bcf 100644
--- a/tasks/lib/bundle-browserify.js
+++ b/tasks/lib/bundle-browserify.js
@@ -55,6 +55,8 @@ module.exports = function bundle(platform, debug, commitId) {
     b.transform(require_tr);
 
     b.add(path.join(root, 'src', platform, 'exec.js'));
+    
+    b.add(path.join(root, 'src', platform, 'platform.js'));
 
     b.add(path.join(root, 'src', 'scripts', 'bootstrap.js'));
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/74c53eff/tasks/lib/require-tr.js
----------------------------------------------------------------------
diff --git a/tasks/lib/require-tr.js b/tasks/lib/require-tr.js
index 4459fda..ba8bd53 100644
--- a/tasks/lib/require-tr.js
+++ b/tasks/lib/require-tr.js
@@ -43,11 +43,18 @@ function _updateRequires(code) {
         //fs.appendFileSync('/tmp/foo', JSON.stringify(node.args[0]) + "###\n");
         if(node.args.length === 1 && 
            node.args[0].value !== undefined &&
-           node.args[0].value.indexOf("cordova") === 0){
+           node.args[0].value.indexOf("cordova") === 0) {
+          // cordova.js
           if(node.args[0].value === "cordova") {
             node.args[0].value = path.join(root, "src", "cordova");
+          // android and amazon-fireos
+          } else if(node.args[0].value.match(/cordova\/(android|amazon-fireos)\/(.+)/)) {
+            node.args[0].value = node.args[0].value.replace(/cordova\/(android|amazon-fireos)\/(.+)/,
+                                 path.join(root, "src", "$1", "android", "$2"));
+          // everything else
           } else if(node.args[0].value.match(/cordova\/(.+)/)) {
-            node.args[0].value = node.args[0].value.replace(/cordova\/(.+)/, path.join(root, "src", "common", "$1"));
+            node.args[0].value = node.args[0].value.replace(/cordova\/(.+)/,
+                                 path.join(root, "src", "common", "$1"));
           }
         }
       }


[41/45] js commit: fixing weird outputstream problem

Posted by an...@apache.org.
fixing weird outputstream problem


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

Branch: refs/heads/master
Commit: d1cd6ecffd571801ddee2307f6baf7e1c6199b60
Parents: ec5e490
Author: Anis Kadri <an...@apache.org>
Authored: Wed Mar 26 17:25:58 2014 +0100
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:22 2014 +0100

----------------------------------------------------------------------
 tasks/lib/packager-browserify.js | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d1cd6ecf/tasks/lib/packager-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/packager-browserify.js b/tasks/lib/packager-browserify.js
index ecc3f5f..3e718c6 100644
--- a/tasks/lib/packager-browserify.js
+++ b/tasks/lib/packager-browserify.js
@@ -32,18 +32,18 @@ module.exports = function generate(platform, useWindowsLineEndings, done) {
         var time = new Date().valueOf();
 
         var libraryRelease = bundle(platform, false, commitId);
-        // if we are using windows line endings, we will also add the BOM
+       // if we are using windows line endings, we will also add the BOM
        // if(useWindowsLineEndings) {
        //     libraryRelease = "\ufeff" + libraryRelease.split(/\r?\n/).join("\r\n");
        // }
-        var libraryDebug   = bundle(platform, true, commitId);
+       // var libraryDebug   = bundle(platform, true, commitId);
 
         if (!fs.existsSync('pkg')) {
             fs.mkdirSync('pkg');
         }
-        if(!fs.existsSync('pkg/debug')) {
-            fs.mkdirSync('pkg/debug');
-        }
+       // if(!fs.existsSync('pkg/debug')) {
+       //     fs.mkdirSync('pkg/debug');
+       // }
 
         outReleaseFile = path.join('pkg', 'cordova.' + platform + '.js');
         outReleaseFileStream = fs.createWriteStream(outReleaseFile);
@@ -55,20 +55,20 @@ module.exports = function generate(platform, useWindowsLineEndings, done) {
 
         releaseBundle.pipe(outReleaseFileStream);
 
-        releaseBundle.on('end', function() {
+        outReleaseFileStream.on('finish', function() {
           var newtime = new Date().valueOf() - time;
           console.log('generated cordova.' + platform + '.js @ ' + commitId + ' in ' + newtime + 'ms');
           done();
         });
 
-        outDebugFile = path.join('pkg', 'debug', 'cordova.' + platform + '-debug.js');
-        outDebugFileStream = fs.createWriteStream(outDebugFile);
-        debugBundle = libraryDebug.bundle();
-        debugBundle.pipe(outDebugFileStream);
+       // outDebugFile = path.join('pkg', 'debug', 'cordova.' + platform + '-debug.js');
+       // outDebugFileStream = fs.createWriteStream(outDebugFile);
+       // debugBundle = libraryDebug.bundle();
+       // debugBundle.pipe(outDebugFileStream);
 
-        outDebugFileStream.on('end', function() {
-          var newtime = new Date().valueOf() - time;
-          console.log('generated cordova.' + platform + '-debug.js @ ' + commitId + ' in ' + newtime + 'ms');
-        });
+       // outDebugFileStream.on('end', function() {
+       //   var newtime = new Date().valueOf() - time;
+       //   console.log('generated cordova.' + platform + '-debug.js @ ' + commitId + ' in ' + newtime + 'ms');
+       // });
     });
 }


[06/45] js commit: Adding compile-browserify grunt task

Posted by an...@apache.org.
Adding compile-browserify grunt task


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

Branch: refs/heads/master
Commit: c08165e77eab64f48d1f1a363072adfecdbe040e
Parents: bc7843e
Author: Anis Kadri <an...@apache.org>
Authored: Mon Feb 3 22:22:14 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Mon Feb 3 22:22:14 2014 -0800

----------------------------------------------------------------------
 Gruntfile.js | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c08165e7/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index 683c9de..ed153bd 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -33,6 +33,9 @@ module.exports = function(grunt) {
             "ubuntu": {},
             "browser": {}
         },
+        "compile-browserify": {
+            "ios": {}
+        },
         clean: ['pkg'],
         jshint: {
             options: {


[15/45] js commit: replacing cordova.js and init.js with their browserify-compatible equivalents

Posted by an...@apache.org.
replacing cordova.js and init.js with their browserify-compatible equivalents


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

Branch: refs/heads/master
Commit: ef6f9b9fecac087a909a01de50d7f1dd9ae64a53
Parents: 7d368f4
Author: Anis Kadri <an...@apache.org>
Authored: Wed Mar 5 16:21:44 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Wed Mar 5 16:21:44 2014 -0800

----------------------------------------------------------------------
 src/common/init_b.js | 129 ++++++++++++++++++++++++++
 src/cordova_b.js     | 231 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 360 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/ef6f9b9f/src/common/init_b.js
----------------------------------------------------------------------
diff --git a/src/common/init_b.js b/src/common/init_b.js
new file mode 100644
index 0000000..efcb6cf
--- /dev/null
+++ b/src/common/init_b.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/ef6f9b9f/src/cordova_b.js
----------------------------------------------------------------------
diff --git a/src/cordova_b.js b/src/cordova_b.js
new file mode 100644
index 0000000..1d2d36e
--- /dev/null
+++ b/src/cordova_b.js
@@ -0,0 +1,231 @@
+/*
+ *
+ * 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 platform = require('cordova/platform');
+
+/**
+ * Intercept calls to addEventListener + removeEventListener and handle deviceready,
+ * resume, and pause events.
+ */
+var m_document_addEventListener = document.addEventListener;
+var m_document_removeEventListener = document.removeEventListener;
+var m_window_addEventListener = window.addEventListener;
+var m_window_removeEventListener = window.removeEventListener;
+
+/**
+ * Houses custom event handlers to intercept on document + window event listeners.
+ */
+var documentEventHandlers = {},
+    windowEventHandlers = {};
+
+document.addEventListener = function(evt, handler, capture) {
+    var e = evt.toLowerCase();
+    if (typeof documentEventHandlers[e] != 'undefined') {
+        documentEventHandlers[e].subscribe(handler);
+    } else {
+        m_document_addEventListener.call(document, evt, handler, capture);
+    }
+};
+
+window.addEventListener = function(evt, handler, capture) {
+    var e = evt.toLowerCase();
+    if (typeof windowEventHandlers[e] != 'undefined') {
+        windowEventHandlers[e].subscribe(handler);
+    } else {
+        m_window_addEventListener.call(window, evt, handler, capture);
+    }
+};
+
+document.removeEventListener = function(evt, handler, capture) {
+    var e = evt.toLowerCase();
+    // If unsubscribing from an event that is handled by a plugin
+    if (typeof documentEventHandlers[e] != "undefined") {
+        documentEventHandlers[e].unsubscribe(handler);
+    } else {
+        m_document_removeEventListener.call(document, evt, handler, capture);
+    }
+};
+
+window.removeEventListener = function(evt, handler, capture) {
+    var e = evt.toLowerCase();
+    // If unsubscribing from an event that is handled by a plugin
+    if (typeof windowEventHandlers[e] != "undefined") {
+        windowEventHandlers[e].unsubscribe(handler);
+    } else {
+        m_window_removeEventListener.call(window, evt, handler, capture);
+    }
+};
+
+function createEvent(type, data) {
+    var event = document.createEvent('Events');
+    event.initEvent(type, false, false);
+    if (data) {
+        for (var i in data) {
+            if (data.hasOwnProperty(i)) {
+                event[i] = data[i];
+            }
+        }
+    }
+    return event;
+}
+
+
+var cordova = {
+    version:CORDOVA_JS_BUILD_LABEL,
+    platformId:platform.id,
+    /**
+     * Methods to add/remove your own addEventListener hijacking on document + window.
+     */
+    addWindowEventHandler:function(event) {
+        return (windowEventHandlers[event] = channel.create(event));
+    },
+    addStickyDocumentEventHandler:function(event) {
+        return (documentEventHandlers[event] = channel.createSticky(event));
+    },
+    addDocumentEventHandler:function(event) {
+        return (documentEventHandlers[event] = channel.create(event));
+    },
+    removeWindowEventHandler:function(event) {
+        delete windowEventHandlers[event];
+    },
+    removeDocumentEventHandler:function(event) {
+        delete documentEventHandlers[event];
+    },
+    /**
+     * Retrieve original event handlers that were replaced by Cordova
+     *
+     * @return object
+     */
+    getOriginalHandlers: function() {
+        return {'document': {'addEventListener': m_document_addEventListener, 'removeEventListener': m_document_removeEventListener},
+        'window': {'addEventListener': m_window_addEventListener, 'removeEventListener': m_window_removeEventListener}};
+    },
+    /**
+     * 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, bNoDetach) {
+        var evt = createEvent(type, data);
+        if (typeof documentEventHandlers[type] != 'undefined') {
+            if( bNoDetach ) {
+                documentEventHandlers[type].fire(evt);
+            }
+            else {
+                setTimeout(function() {
+                    // Fire deviceready on listeners that were registered before cordova.js was loaded.
+                    if (type == 'deviceready') {
+                        document.dispatchEvent(evt);
+                    }
+                    documentEventHandlers[type].fire(evt);
+                }, 0);
+            }
+        } else {
+            document.dispatchEvent(evt);
+        }
+    },
+    fireWindowEvent: function(type, data) {
+        var evt = createEvent(type,data);
+        if (typeof windowEventHandlers[type] != 'undefined') {
+            setTimeout(function() {
+                windowEventHandlers[type].fire(evt);
+            }, 0);
+        } else {
+            window.dispatchEvent(evt);
+        }
+    },
+
+    /**
+     * Plugin callback mechanism.
+     */
+    // 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,
+        OK: 1,
+        CLASS_NOT_FOUND_EXCEPTION: 2,
+        ILLEGAL_ACCESS_EXCEPTION: 3,
+        INSTANTIATION_EXCEPTION: 4,
+        MALFORMED_URL_EXCEPTION: 5,
+        IO_EXCEPTION: 6,
+        INVALID_ACTION: 7,
+        JSON_EXCEPTION: 8,
+        ERROR: 9
+    },
+
+    /**
+     * Called by native code when returning successful result from an action.
+     */
+    callbackSuccess: function(callbackId, args) {
+        try {
+            cordova.callbackFromNative(callbackId, true, args.status, [args.message], args.keepCallback);
+        } catch (e) {
+            console.log("Error in error callback: " + callbackId + " = "+e);
+        }
+    },
+
+    /**
+     * Called by native code when returning error result from an action.
+     */
+    callbackError: function(callbackId, args) {
+        // TODO: Deprecate callbackSuccess and callbackError in favour of callbackFromNative.
+        // Derive success from status.
+        try {
+            cordova.callbackFromNative(callbackId, false, args.status, [args.message], args.keepCallback);
+        } catch (e) {
+            console.log("Error in error callback: " + callbackId + " = "+e);
+        }
+    },
+
+    /**
+     * Called by native code when returning the result from an action.
+     */
+    callbackFromNative: function(callbackId, success, status, args, keepCallback) {
+        var callback = cordova.callbacks[callbackId];
+        if (callback) {
+            if (success && status == cordova.callbackStatus.OK) {
+                callback.success && callback.success.apply(null, args);
+            } else if (!success) {
+                callback.fail && callback.fail.apply(null, args);
+            }
+
+            // Clear callback if not expecting any more results
+            if (!keepCallback) {
+                delete cordova.callbacks[callbackId];
+            }
+        }
+    },
+    addConstructor: function(func) {
+        channel.onCordovaReady.subscribe(function() {
+            try {
+                func();
+            } catch(e) {
+                console.log("Failed to run constructor: " + e);
+            }
+        });
+    }
+};
+window.cordova = cordova; 
+window.cordova.exec = require('cordova/exec');
+module.exports = cordova;


[35/45] js commit: replacing init with init_b

Posted by an...@apache.org.
replacing init with init_b


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

Branch: refs/heads/master
Commit: 16419e437d86b789fc378fd6d67fbec4b887edc1
Parents: 0990b5d
Author: Anis Kadri <an...@apache.org>
Authored: Wed Mar 5 16:20:22 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:22 2014 +0100

----------------------------------------------------------------------
 tasks/lib/require-tr.js | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/16419e43/tasks/lib/require-tr.js
----------------------------------------------------------------------
diff --git a/tasks/lib/require-tr.js b/tasks/lib/require-tr.js
index 2c347a3..7bde0f6 100644
--- a/tasks/lib/require-tr.js
+++ b/tasks/lib/require-tr.js
@@ -85,6 +85,10 @@ function _updateRequires(code) {
           if(module === "cordova") {
             node.args[0].value = path.join(root, "src", "cordova_b");
           // android and amazon-fireos have some special require's
+          }  else if(module.match(/cordova\/init/)) {
+            node.args[0].value = module.replace(/cordova\/init/,
+                                    path.join(root, "src", "common", "init_b"));
+          // require('cordova/exec') and require('cordova/platform') -> platform's exec/platform
           } else if(module.match(/cordova\/(android|amazon-fireos)\/(.+)/)) {
             node.args[0].value = module.replace(/cordova\/(android|amazon-fireos)\/(.+)/,
                                     path.join(root, "src", "$1", "android", "$2"));


[30/45] js commit: adding android and amazon-fireos

Posted by an...@apache.org.
adding android and amazon-fireos


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

Branch: refs/heads/master
Commit: 4a9fe178d23a49cd801172c106ce6cdbe35fceb6
Parents: 0d10f5f
Author: Anis Kadri <an...@apache.org>
Authored: Tue Feb 4 16:07:00 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:21 2014 +0100

----------------------------------------------------------------------
 Gruntfile.js                   |  2 ++
 tasks/lib/bundle-browserify.js |  2 ++
 tasks/lib/require-tr.js        | 11 +++++++++--
 3 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/4a9fe178/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index d49a097..ffd4064 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -34,6 +34,8 @@ module.exports = function(grunt) {
             "browser": {}
         },
         "compile-browserify": {
+            "amazon-fireos": {},
+            "android": {},
             "ios": {}
         },
         clean: ['pkg'],

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/4a9fe178/tasks/lib/bundle-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/bundle-browserify.js b/tasks/lib/bundle-browserify.js
index 3d91e42..e678bcf 100644
--- a/tasks/lib/bundle-browserify.js
+++ b/tasks/lib/bundle-browserify.js
@@ -55,6 +55,8 @@ module.exports = function bundle(platform, debug, commitId) {
     b.transform(require_tr);
 
     b.add(path.join(root, 'src', platform, 'exec.js'));
+    
+    b.add(path.join(root, 'src', platform, 'platform.js'));
 
     b.add(path.join(root, 'src', 'scripts', 'bootstrap.js'));
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/4a9fe178/tasks/lib/require-tr.js
----------------------------------------------------------------------
diff --git a/tasks/lib/require-tr.js b/tasks/lib/require-tr.js
index 4459fda..ba8bd53 100644
--- a/tasks/lib/require-tr.js
+++ b/tasks/lib/require-tr.js
@@ -43,11 +43,18 @@ function _updateRequires(code) {
         //fs.appendFileSync('/tmp/foo', JSON.stringify(node.args[0]) + "###\n");
         if(node.args.length === 1 && 
            node.args[0].value !== undefined &&
-           node.args[0].value.indexOf("cordova") === 0){
+           node.args[0].value.indexOf("cordova") === 0) {
+          // cordova.js
           if(node.args[0].value === "cordova") {
             node.args[0].value = path.join(root, "src", "cordova");
+          // android and amazon-fireos
+          } else if(node.args[0].value.match(/cordova\/(android|amazon-fireos)\/(.+)/)) {
+            node.args[0].value = node.args[0].value.replace(/cordova\/(android|amazon-fireos)\/(.+)/,
+                                 path.join(root, "src", "$1", "android", "$2"));
+          // everything else
           } else if(node.args[0].value.match(/cordova\/(.+)/)) {
-            node.args[0].value = node.args[0].value.replace(/cordova\/(.+)/, path.join(root, "src", "common", "$1"));
+            node.args[0].value = node.args[0].value.replace(/cordova\/(.+)/,
+                                 path.join(root, "src", "common", "$1"));
           }
         }
       }


[13/45] js commit: updating transform/bundler/packager

Posted by an...@apache.org.
updating transform/bundler/packager


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

Branch: refs/heads/master
Commit: f6931d64be723f58bf0aa7a7741430189f57f669
Parents: 26a9f98
Author: Anis Kadri <an...@apache.org>
Authored: Mon Mar 3 16:12:23 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Mon Mar 3 16:12:23 2014 -0800

----------------------------------------------------------------------
 tasks/lib/bundle-browserify.js   |  1 -
 tasks/lib/packager-browserify.js | 15 ++++++
 tasks/lib/require-tr.js          | 97 ++++++++++++++++++++---------------
 3 files changed, 72 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f6931d64/tasks/lib/bundle-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/bundle-browserify.js b/tasks/lib/bundle-browserify.js
index 85da8dd..1d948fa 100644
--- a/tasks/lib/bundle-browserify.js
+++ b/tasks/lib/bundle-browserify.js
@@ -20,7 +20,6 @@ var fs           = require('fs');
 var path         = require('path');
 var browserify   = require('browserify');
 var require_tr   = require('./require-tr');
-var licensePath  = path.join(__dirname, '..', 'templates', 'LICENSE-for-js-file.txt');
 var root         = path.join(__dirname, '..', '..')
 
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f6931d64/tasks/lib/packager-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/packager-browserify.js b/tasks/lib/packager-browserify.js
index ecc8e9d..07d7774 100644
--- a/tasks/lib/packager-browserify.js
+++ b/tasks/lib/packager-browserify.js
@@ -18,8 +18,11 @@
  */
 var fs              = require('fs');
 var path            = require('path');
+var util            = require('util');
 var bundle          = require('./bundle-browserify');
 var computeCommitId = require('./compute-commit-id');
+var licensePath     = path.join(__dirname, '..', 'templates', 'LICENSE-for-js-file.txt');
+var require_tr   = require('./require-tr');
 
 
 module.exports = function generate(platform, useWindowsLineEndings, done) {
@@ -45,7 +48,19 @@ module.exports = function generate(platform, useWindowsLineEndings, done) {
 
         outReleaseFile = path.join('pkg', 'cordova.' + platform + '.js');
         outReleaseFileStream = fs.createWriteStream(outReleaseFile);
+        
+        // some poppycock 
+        var licenseText = util.format("/*\n *%s\n */\n", fs.readFileSync(licensePath, 'utf8').replace(/\n/g, "\n *"));
+
+        outReleaseFileStream.write("// Platform: " + platform + "\n", 'utf8');
+        outReleaseFileStream.write("// "  + commitId + "\n", 'utf8');
+        outReleaseFileStream.write(licenseText, 'utf8');
+        outReleaseFileStream.write("var CORDOVA_JS_BUILD_LABEL = '"  + commitId + "';\n", 'utf8');
+        outReleaseFileStream.write("var define = {moduleMap: []};\n", 'utf8');
+        
         releaseBundle = libraryRelease.bundle();
+        //console.log(libraryRelease.deps());
+
         releaseBundle.pipe(outReleaseFileStream);
 
         releaseBundle.on('end', function() {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f6931d64/tasks/lib/require-tr.js
----------------------------------------------------------------------
diff --git a/tasks/lib/require-tr.js b/tasks/lib/require-tr.js
index 5629e80..2c347a3 100644
--- a/tasks/lib/require-tr.js
+++ b/tasks/lib/require-tr.js
@@ -30,6 +30,37 @@ var through = require('through');
 var UglifyJS = require('uglify-js');
 var root = fs.realpathSync(path.join(__dirname, '..', '..'));
 
+
+var requireTr = {
+
+  transform: function(file) {
+    var data = '';
+
+    function write(buf) {
+      data += buf;
+    }
+
+    function end() {
+      // getting rid of define and require properties of cordova
+     // if(file.match(/cordova.js$/)) {
+     //   data = data.replace(/ *(define:define|require:require),\n/, '');
+     // }
+      this.queue(_updateRequires(data));
+      this.queue(null);
+    }
+   
+    return through(write, end);
+  },
+  getSymbolList: function() {
+    return this.symbolList;
+  },
+  platform: null,
+  symbolList: []
+}
+
+/*
+ * visits AST and modifies all the require('cordova/*')
+ */
 function _updateRequires(code) {
   
   var ast = UglifyJS.parse(code);
@@ -39,28 +70,32 @@ function _updateRequires(code) {
     // check all function calls
     if(node instanceof UglifyJS.AST_Call) {
       // check if function call is a require('module') call
-      if(node.expression.name === "require") {
+      if(node.expression.name === "require" && node.args.length === 1) {
+        var module = node.args[0].value;
         // make sure require only has one argument and that it starts with cordova (old style require.js) 
-        if(node.args.length === 1 && 
-           node.args[0].value !== undefined &&
-           node.args[0].value.indexOf("cordova") === 0) {
-          //fs.appendFileSync('/tmp/foo', JSON.stringify(node.args[0].value) + "\n###\n");
-          // cordova.js
-          if(node.args[0].value === "cordova") {
-            node.args[0].value = path.join(root, "src", "cordova");
-          // android and amazon-fireos
-          } else if(node.args[0].value.match(/cordova\/(android|amazon-fireos)\/(.+)/)) {
-            node.args[0].value = node.args[0].value.replace(/cordova\/(android|amazon-fireos)\/(.+)/,
-                                 path.join(root, "src", "$1", "android", "$2"));
-          // replace common exec/platform with the platform's exec/platform
-          } else if(node.args[0].value.match(/cordova\/(platform|exec)$/)) {
-            //fs.appendFileSync('/tmp/foo', node.args[0].value + "\n" +module.exports.platform + "\n");
-            node.args[0].value = node.args[0].value.replace(/cordova\/(platform|exec)/,
-                                 path.join(root, "src", module.exports.platform, "$1"));
-          // everything else
-          } else if(node.args[0].value.match(/cordova\/(.+)/)) {
-            node.args[0].value = node.args[0].value.replace(/cordova\/(.+)/,
-                                 path.join(root, "src", "common", "$1"));
+        if(module !== undefined &&
+           module.indexOf("cordova") === 0) {
+          
+          // adding symbolList bullcrap
+          if(requireTr.symbolList && requireTr.symbolList.indexOf(module) === -1) {
+            requireTr.symbolList.push(module);
+          }
+
+          // require('cordova') -> cordova.js
+          if(module === "cordova") {
+            node.args[0].value = path.join(root, "src", "cordova_b");
+          // android and amazon-fireos have some special require's
+          } else if(module.match(/cordova\/(android|amazon-fireos)\/(.+)/)) {
+            node.args[0].value = module.replace(/cordova\/(android|amazon-fireos)\/(.+)/,
+                                    path.join(root, "src", "$1", "android", "$2"));
+          // require('cordova/exec') and require('cordova/platform') -> platform's exec/platform
+          } else if(module.match(/cordova\/(platform|exec)$/)) {
+            node.args[0].value = module.replace(/cordova\/(platform|exec)/,
+                                                path.join(root, "src", requireTr.platform, "$1"));
+          // require('cordova/anything') should be under common/
+          } else if(module.match(/cordova\/(.+)/)) {
+            node.args[0].value = module.replace(/cordova\/(.+)/,
+                                    path.join(root, "src", "common", "$1"));
           }
         }
       }
@@ -77,22 +112,4 @@ function _updateRequires(code) {
 }
 
 
-module.exports = {
-
-  transform: function(file) {
-    var data = '';
-
-    function write(buf) {
-      data += buf;
-    }
-
-    function end() {
-      //fs.appendFileSync('/tmp/foo', _updateRequires(data));
-      this.queue(_updateRequires(data));
-      this.queue(null);
-    }
-   
-    return through(write, end);
-  },
-  platform: ""
-}
+module.exports = requireTr; 


[02/45] js commit: adding browserify require transform

Posted by an...@apache.org.
adding browserify require transform


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

Branch: refs/heads/master
Commit: beeb953e1f285f3653578ad68ea39fb00e31dbf0
Parents: c925386
Author: Anis Kadri <an...@apache.org>
Authored: Mon Feb 3 22:15:19 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Mon Feb 3 22:15:19 2014 -0800

----------------------------------------------------------------------
 tasks/lib/require-tr.js | 81 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/beeb953e/tasks/lib/require-tr.js
----------------------------------------------------------------------
diff --git a/tasks/lib/require-tr.js b/tasks/lib/require-tr.js
new file mode 100644
index 0000000..4459fda
--- /dev/null
+++ b/tasks/lib/require-tr.js
@@ -0,0 +1,81 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/*
+ * This probably should live in plugman/cli world
+ * Transoforms old require calls to new node-style require calls
+ */
+
+var fs = require('fs');
+var path = require('path');
+var through = require('through');
+var UglifyJS = require('uglify-js');
+var root = fs.realpathSync(path.join(__dirname, '..', '..'));
+
+function _updateRequires(code) {
+  
+  var ast = UglifyJS.parse(code);
+
+  var walker = new UglifyJS.TreeWalker(function(node) {
+    // check all function calls
+    if(node instanceof UglifyJS.AST_Call) {
+      // check if function call is a require('module') call
+      if(node.expression.name === "require") {
+        // make sure require only has one argument and that it starts with cordova (old style require.js) 
+        //fs.appendFileSync('/tmp/foo', JSON.stringify(node.args[0]) + "###\n");
+        if(node.args.length === 1 && 
+           node.args[0].value !== undefined &&
+           node.args[0].value.indexOf("cordova") === 0){
+          if(node.args[0].value === "cordova") {
+            node.args[0].value = path.join(root, "src", "cordova");
+          } else if(node.args[0].value.match(/cordova\/(.+)/)) {
+            node.args[0].value = node.args[0].value.replace(/cordova\/(.+)/, path.join(root, "src", "common", "$1"));
+          }
+        }
+      }
+    }
+  });
+
+  ast.walk(walker);
+
+  var stream = UglifyJS.OutputStream({beautify:true});
+
+  ast.print(stream);
+
+  return stream.toString();
+}
+
+
+module.exports = function(file) {
+  var data = '';
+
+  function write(buf) {
+    data += buf;
+  }
+
+  function end() {
+    //fs.appendFileSync('/tmp/foo', _updateRequires(data));
+    this.queue(_updateRequires(data));
+    this.queue(null);
+  }
+ 
+  return through(write, end);
+}