You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pm...@apache.org on 2012/03/21 20:00:22 UTC

[1/4] git commit: initial pass at reorganizing the lib directory

Updated Branches:
  refs/heads/CB-280 [created] f3acff6d3


initial pass at reorganizing the lib directory

This is not the final version, but a preview version.

You will see both the old lib/ directory and the new
lib-common/, lib-platforms/, and lib-scripts/ here.
The lib/ directory only remains as something for
you to look at.  The build now operates against
the three new directories.

Another transient piece is the build/split-cordova.sh
file, which is used to actually split the files.  Won't
be in the final commit, but it means I can rebase
this commit and split again safely.

We now also build 'debug' versions of the cordova.js
files.  These can be used in debuggers to provide a
better user experience. See [1] for more info.  Note
that this includes the test runner, running in node,
which provides better diagnostics when bad things
happen.

Changes besides the remix of the directories:

- all new build/packager.js

- Jakefile now calls packager.generate() instead of packager.write()

- test/runner.js changes - it was previously using a special 'build'
  of the lib tree, now it uses a new 'platform' called 'test'.  This
  simplified things a little, and now means the tests are running
  against the same structure as the real libraries, instead of a
  special-purpose-built version.  Also did a few cleanup things
  in runner.js and the associated test/suite.html.

- removed the first test in test.network.js, since it no longer
  passes.  See the comment in the test.

[1] http://pmuellr.blogspot.com/2011/11/debugging-concatenated-javascript-files.html
    scroll down to "cheating with eval() and //@sourceurl"


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

Branch: refs/heads/CB-280
Commit: f3acff6d34ffa980c24c714320b2d426a720824c
Parents: 3ac086e
Author: Patrick Mueller <pm...@apache.org>
Authored: Wed Mar 21 14:48:18 2012 -0400
Committer: Patrick Mueller <pm...@apache.org>
Committed: Wed Mar 21 14:48:18 2012 -0400

----------------------------------------------------------------------
 Jakefile                                           |   13 +-
 build/packager.js                                  |  274 ++++++-----
 build/split-cordova.sh                             |   80 +++
 lib-common/cordova.js                              |  232 +++++++++
 lib-common/cordova/builder.js                      |   86 ++++
 lib-common/cordova/channel.js                      |  207 ++++++++
 lib-common/cordova/common.js                       |  180 +++++++
 lib-common/cordova/exec.js                         |    1 +
 lib-common/cordova/platform.js                     |    1 +
 lib-common/cordova/plugin/Acceleration.js          |    8 +
 lib-common/cordova/plugin/Camera.js                |   84 ++++
 lib-common/cordova/plugin/CameraConstants.js       |   20 +
 lib-common/cordova/plugin/CaptureAudioOptions.js   |   13 +
 lib-common/cordova/plugin/CaptureError.js          |   19 +
 lib-common/cordova/plugin/CaptureImageOptions.js   |   11 +
 lib-common/cordova/plugin/CaptureVideoOptions.js   |   13 +
 lib-common/cordova/plugin/CompassError.js          |   13 +
 lib-common/cordova/plugin/CompassHeading.js        |    8 +
 lib-common/cordova/plugin/ConfigurationData.js     |   15 +
 lib-common/cordova/plugin/Connection.js            |   12 +
 lib-common/cordova/plugin/Contact.js               |  177 +++++++
 lib-common/cordova/plugin/ContactAddress.js        |   25 +
 lib-common/cordova/plugin/ContactError.js          |   21 +
 lib-common/cordova/plugin/ContactField.js          |   16 +
 lib-common/cordova/plugin/ContactFindOptions.js    |   13 +
 lib-common/cordova/plugin/ContactName.js           |   20 +
 lib-common/cordova/plugin/ContactOrganization.js   |   23 +
 lib-common/cordova/plugin/Coordinates.js           |   43 ++
 lib-common/cordova/plugin/DirectoryEntry.js        |   80 +++
 lib-common/cordova/plugin/DirectoryReader.js       |   41 ++
 lib-common/cordova/plugin/Entry.js                 |  198 ++++++++
 lib-common/cordova/plugin/File.js                  |   18 +
 lib-common/cordova/plugin/FileEntry.js             |   63 +++
 lib-common/cordova/plugin/FileError.js             |   25 +
 lib-common/cordova/plugin/FileReader.js            |  249 ++++++++++
 lib-common/cordova/plugin/FileSystem.js            |   17 +
 lib-common/cordova/plugin/FileTransfer.js          |   68 +++
 lib-common/cordova/plugin/FileTransferError.js     |   13 +
 lib-common/cordova/plugin/FileUploadOptions.js     |   16 +
 lib-common/cordova/plugin/FileUploadResult.js      |   11 +
 lib-common/cordova/plugin/FileWriter.js            |  253 ++++++++++
 lib-common/cordova/plugin/Flags.js                 |   15 +
 lib-common/cordova/plugin/LocalFileSystem.js       |   13 +
 lib-common/cordova/plugin/Media.js                 |  186 +++++++
 lib-common/cordova/plugin/MediaError.js            |   16 +
 lib-common/cordova/plugin/MediaFile.js             |   56 +++
 lib-common/cordova/plugin/MediaFileData.js         |   18 +
 lib-common/cordova/plugin/Metadata.js              |   10 +
 lib-common/cordova/plugin/Position.js              |    8 +
 lib-common/cordova/plugin/PositionError.js         |   17 +
 lib-common/cordova/plugin/ProgressEvent.js         |   46 ++
 lib-common/cordova/plugin/accelerometer.js         |   95 ++++
 lib-common/cordova/plugin/battery.js               |   87 ++++
 lib-common/cordova/plugin/capture.js               |   72 +++
 lib-common/cordova/plugin/compass.js               |   90 ++++
 lib-common/cordova/plugin/contacts.js              |   57 +++
 lib-common/cordova/plugin/geolocation.js           |   94 ++++
 lib-common/cordova/plugin/network.js               |   59 +++
 lib-common/cordova/plugin/notification.js          |   56 +++
 lib-common/cordova/plugin/requestFileSystem.js     |   40 ++
 .../cordova/plugin/resolveLocalFileSystemURI.js    |   41 ++
 lib-common/cordova/utils.js                        |   94 ++++
 lib-platforms/android/cordova/exec.js              |   82 ++++
 lib-platforms/android/cordova/platform.js          |  131 +++++
 .../android/cordova/plugin/android/app.js          |   71 +++
 .../android/cordova/plugin/android/callback.js     |   85 ++++
 .../android/cordova/plugin/android/device.js       |   92 ++++
 .../android/cordova/plugin/android/polling.js      |   33 ++
 .../android/cordova/plugin/android/storage.js      |  377 +++++++++++++++
 lib-platforms/blackberry/cordova/exec.js           |   56 +++
 lib-platforms/blackberry/cordova/platform.js       |  173 +++++++
 .../cordova/plugin/blackberry/DirectoryEntry.js    |  239 +++++++++
 .../blackberry/cordova/plugin/blackberry/Entry.js  |   87 ++++
 .../blackberry/cordova/plugin/blackberry/app.js    |   51 ++
 .../blackberry/cordova/plugin/blackberry/device.js |   23 +
 .../cordova/plugin/blackberry/manager.js           |   87 ++++
 .../cordova/plugin/blackberry/notification.js      |   53 ++
 lib-platforms/errgen/cordova/exec.js               |  107 ++++
 lib-platforms/errgen/cordova/platform.js           |   28 ++
 .../errgen/cordova/plugin/errgen/device.js         |   42 ++
 lib-platforms/ios/cordova/exec.js                  |   93 ++++
 lib-platforms/ios/cordova/platform.js              |   41 ++
 lib-platforms/ios/cordova/plugin/ios/Entry.js      |    7 +
 lib-platforms/ios/cordova/plugin/ios/FileReader.js |   87 ++++
 lib-platforms/ios/cordova/plugin/ios/console.js    |  102 ++++
 lib-platforms/ios/cordova/plugin/ios/device.js     |   30 ++
 lib-platforms/ios/cordova/plugin/ios/nativecomm.js |   10 +
 .../ios/cordova/plugin/ios/notification.js         |    7 +
 lib-platforms/playbook/cordova/exec.js             |   56 +++
 lib-platforms/playbook/cordova/platform.js         |   16 +
 .../playbook/cordova/plugin/playbook/device.js     |   23 +
 .../playbook/cordova/plugin/playbook/manager.js    |  285 +++++++++++
 lib-platforms/test/cordova/exec.js                 |    1 +
 .../webworks/cordova/plugin/webworks/manager.js    |   14 +
 lib-platforms/wp7/cordova/exec.js                  |   57 +++
 lib-platforms/wp7/cordova/platform.js              |   16 +
 lib-platforms/wp7/cordova/plugin/wp7/device.js     |   26 +
 lib-scripts/bootstrap-errgen.js                    |   20 +
 lib-scripts/bootstrap-playbook.js                  |    1 +
 lib-scripts/bootstrap.js                           |   69 +++
 lib-scripts/require.js                             |   43 ++
 test/errgen/index-debug.html                       |   75 +++
 test/runner.js                                     |   17 +-
 test/suite.html                                    |    8 +-
 test/test.network.js                               |   24 +-
 105 files changed, 6655 insertions(+), 140 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/Jakefile
----------------------------------------------------------------------
diff --git a/Jakefile b/Jakefile
index af05af6..3f962dc 100644
--- a/Jakefile
+++ b/Jakefile
@@ -22,12 +22,13 @@ task('build', ['clean'], function () {
 
     var packager = require("./build/packager");
 
-    packager.write("blackberry");
-    packager.write("playbook");
-    packager.write("ios");
-    packager.write("wp7");
-    packager.write("android");
-    packager.write("errgen");
+    packager.generate("blackberry");
+    packager.generate("playbook");
+    packager.generate("ios");
+    packager.generate("wp7");
+    packager.generate("android");
+    packager.generate("test");
+    packager.generate("errgen");
 
 });
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/build/packager.js
----------------------------------------------------------------------
diff --git a/build/packager.js b/build/packager.js
index 39a9704..ab1fb71 100644
--- a/build/packager.js
+++ b/build/packager.js
@@ -1,135 +1,179 @@
-var util = require('util'),
-    debug = false,
-    fs = require('fs');
-
-// (Recursively) list contents of a directory
-function walk(dir, doRecursive) {
-    var results = [];
-    try {
-        var list = fs.readdirSync(dir);
-        for (var i = 0, l = list.length; i < l; i++) {
-            var file = list[i];
-            file = dir + '/' + file;
-            var stat = fs.statSync(file);
-            if (stat && doRecursive && stat.isDirectory()) {
-                results = results.concat(walk(file,doRecursive));
-            } else {
-                if (list[i] != ".DS_Store") {
-                    results.push(file);
-                }
-            }
-        }
-    } catch (e) {
-        //do nothing
-    }
-    return results;
-}
-
-// Simply inline includes the specified file(s) with an optional transform function.
-function include(files, transform) {
-    files = files.map ? files : [files];
-    return files.map(function (file) {
-        try {
-            var str = fs.readFileSync(file, "utf-8") + "\n";
-            str = transform ? transform(str, file) : str;
-            str = debug ? "try {" + str + "} catch (e) { alert('" + file + ":' + e);}" : str;
-            return str;
-        } catch (e) {
-            //do nothing
-        }
-    }).join('\n');
+var fs    = require('fs')
+var util  = require('util')
+var path  = require('path')
+
+var packager = module.exports
+
+//------------------------------------------------------------------------------
+packager.generate = function(platform) {
+    var time = new Date().valueOf()
+    
+    var libraryRelease = packager.bundle(platform, false)
+    var libraryDebug   = packager.bundle(platform, true)
+    
+    time = new Date().valueOf() - time
+    
+    var outFile
+    
+    outFile = path.join('pkg', 'cordova.' + platform + '.js')
+    fs.writeFileSync(outFile, libraryRelease, 'utf8')
+    
+    outFile = path.join('pkg', 'cordova.' + platform + '-debug.js')
+    fs.writeFileSync(outFile, libraryDebug, 'utf8')
+    
+    console.log('generated platform: ' + platform + ' in ' + time + 'ms')
 }
 
-// Includes the specified file(s) with optional overriding id
-// Wraps the specified file(s) in a define statement which implicitly
-// creates a closure as well.
-function drop(files, id) {
-    return include(files, function(file, path) {
-        var define_id = (typeof id != 'undefined' && id.length > 0 ? id : path.replace(/lib\//, "cordova/").replace(/\.js$/, ''));
-        return "define('" + define_id + "', function(require, exports, module) {\n" + file + "});\n";
-    });
-}
-
-module.exports = {
-    modules: function (platform) {
-        var baseFiles = [
-                "lib/utils.js",
-                "lib/builder.js"
-            ],
-            platformFiles = walk('lib/plugin/' + platform, true),
-            output = "";
-
-        //HACK: ummm .... we really need to figure out this webworks common file stuff
-        if (platform === "blackberry" || platform === "playbook") {
-            platformFiles = platformFiles.concat(walk('lib/plugin/webworks', true));
-        }
-
-        //include all common platform files that are under lib/plugin
-        baseFiles = baseFiles.concat(walk('lib/plugin'));
-
-        //include require
-        output += include("lib/require.js");
-
-        //include channel
-        output += drop('lib/channel.js', 'cordova/channel');
+//------------------------------------------------------------------------------
+packager.bundle = function(platform, debug) {
+    var modules = collectFiles('lib-common')
+    var scripts = collectFiles('lib-scripts')
+    
+    if (['playbook', 'blackberry'].indexOf(platform) > -1) {
+        copyProps(modules, collectFiles(path.join('lib-platforms', 'webworks')))
+    }
+    
+    copyProps(modules, collectFiles(path.join('lib-platforms', platform)))
+
+    var output = []
+
+    // write header     
+    output.push('/*\n' + getContents('LICENSE-for-js-file.txt') + '\n*/')
+    output.push('\n;(function() {\n')
+    
+    // write initial scripts
+    if (!scripts['require']) {
+        throw new Error("didn't find a script for 'require'")
+    }
+    
+    writeScript(output, scripts['require'], debug)
+
+    // write modules
+    var moduleIds = Object.keys(modules)
+    moduleIds.sort()
+    
+    for (var i=0; i<moduleIds.length; i++) {
+        var moduleId = moduleIds[i];
+        
+        writeModule(output, modules[moduleId], moduleId, debug)
+        
+    }
 
-        //include cordova
-        output += drop('lib/cordova.js', 'cordova');
+    output.push("\nwindow.cordova = require('cordova');\n")
 
-        //include exec
-        output += drop('lib/exec/' + platform + '.js', 'cordova/exec');
+    // write final scripts
+    if (!scripts['bootstrap']) {
+        throw new Error("didn't find a script for 'bootstrap'")
+    }
+    
+    writeScript(output, scripts['bootstrap'], debug)
+    
+    var bootstrapPlatform = 'bootstrap-' + platform
+    if (scripts[bootstrapPlatform]) {
+        writeScript(output, scripts[bootstrapPlatform], debug)
+    }
 
-        //include common platform defn 
-        output += drop('lib/platform/common.js', 'cordova/common');
+    // write trailer
+    output.push('\n})();')
 
-        //include platform defn
-        output += drop('lib/platform/' + platform + '.js', 'cordova/platform');
+    return output.join('\n')
+}
 
-        //include common modules
-        output += drop(baseFiles);
+//------------------------------------------------------------------------------
+var CollectedFiles = {}
 
-        //include platform specific modules
-        output += drop(platformFiles);
+function collectFiles(dir, id) {
+    if (!id) id = ''
+    
+    if (CollectedFiles[dir]) {
+        return copyProps({}, CollectedFiles[dir])
+    }
 
-        return output;
-    },
+    var result = {}    
+    
+    var entries = fs.readdirSync(dir)
+    
+    entries = entries.filter(function(entry) {
+        if (entry.match(/\.js$/)) return true
+        
+        var stat = fs.statSync(path.join(dir, entry))
+        if (stat.isDirectory())  return true
+    })
 
-    bundle: function (platform) {
-        console.log("building platform: " + platform);
+    entries.forEach(function(entry) {
+        var moduleId = path.join(id,  entry)
+        var fileName = path.join(dir, entry)
         
-        var output = "";
+        var stat = fs.statSync(fileName)
+        if (stat.isDirectory()) {
+            copyProps(result, collectFiles(fileName, moduleId))
+        }
+        else {
+            moduleId         = getModuleId(moduleId)
+            result[moduleId] = fileName
+        }
+    })
+    
+    CollectedFiles[dir] = result
+    
+    return copyProps({}, result)
+}
+
+//------------------------------------------------------------------------------
+function writeScript(oFile, fileName, debug) {
+    var contents = getContents(fileName, 'utf8')
+    
+    writeContents(oFile, fileName, contents, debug)    
+}
 
-        //include LICENSE
-        output += include("LICENSE-for-js-file.txt", function (file) {
-            return "/*\n" + file + "*/\n";
-        });
+//------------------------------------------------------------------------------
+function writeModule(oFile, fileName, moduleId, debug) {
+    var contents = getContents(fileName, 'utf8')
+    
+    contents = 'define("' + moduleId + '", function(require, exports, module) {\n' + contents + '\n})\n'
 
-        // wrap the entire thing in one more closure
-        // closure closure closure
-        output += "(function() {\n";
+    writeContents(oFile, fileName, contents, debug)    
+}
 
-        //include modules
-        output += this.modules(platform);
+//------------------------------------------------------------------------------
+var FileContents = {}
 
-        // HACK: this gets done in bootstrap.js anyways, once native side is ready + domcontentloaded is fired.
-        // TODO: Do we need it?
-        output += "window.cordova = require('cordova');\n"; 
+function getContents(file) {
+    if (!FileContents.hasOwnProperty(file)) {
+        FileContents[file] = fs.readFileSync(file, 'utf8')
+    }
+    
+    return FileContents[file]
+}
 
-        //include bootstrap
-        output += include('lib/bootstrap.js');
+//------------------------------------------------------------------------------
+function writeContents(oFile, fileName, contents, debug) {
+    
+    if (debug) {
+        contents += '\n//@ sourceURL=' + fileName
+        
+        contents = 'eval(' + JSON.stringify(contents) + ')'
+    }
+    
+    else {
+        contents = '// file: ' + fileName + '\n' + contents    
+    }
 
-        // TODO/HACK: we don't need platform-specific bootstrap.
-        // those can go into the init function inside the platform/*.js
-        // files
-        output += include('lib/bootstrap/' + platform + '.js');
+    oFile.push(contents)
+}
 
-        // closing the closure har har
-        output += "})();";
+//------------------------------------------------------------------------------
+function getModuleId(fileName) {
+    return fileName.match(/(.*)\.js$/)[1]
+}
 
-        return output;
-    },
-    write: function (platform) {
-        var output = this.bundle(platform);
-        fs.writeFileSync(__dirname + "/../pkg/cordova." + platform + ".js", output);
+//------------------------------------------------------------------------------
+function copyProps(target, source) {
+    for (var key in source) {
+        if (!source.hasOwnProperty(key)) continue
+        
+        target[key] = source[key]
     }
-};
+    
+    return target
+}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/build/split-cordova.sh
----------------------------------------------------------------------
diff --git a/build/split-cordova.sh b/build/split-cordova.sh
new file mode 100755
index 0000000..dfbd6e4
--- /dev/null
+++ b/build/split-cordova.sh
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+#---------------------------------------------
+# the only purpose of this script is to convert
+# a lib/ -based cordova-js tree to the new
+# lib-*/ -based one.  should not be in the
+# final commit, just transient till the
+# new framework is committed.
+#---------------------------------------------
+
+
+rm -rf lib-common lib-platforms lib-scripts
+
+#---------------------------------------------
+mkdir lib-common
+mkdir lib-common/cordova
+cp -R lib/* lib-common/cordova
+mv lib-common/cordova/cordova.js lib-common/cordova.js
+
+echo "throw new Error('should have been replaced at build time with platform implementation')" > lib-common/cordova/exec.js
+echo "throw new Error('should have been replaced at build time with platform implementation')" > lib-common/cordova/platform.js
+
+#---------------------------------------------
+mkdir -p lib-platforms/android/cordova/plugin/android
+mkdir -p lib-platforms/blackberry/cordova/plugin/blackberry
+mkdir -p lib-platforms/errgen/cordova/plugin/errgen
+mkdir -p lib-platforms/ios/cordova/plugin/ios
+mkdir -p lib-platforms/playbook/cordova/plugin/playbook
+mkdir -p lib-platforms/test/cordova/plugin/test
+mkdir -p lib-platforms/webworks/cordova/plugin/webworks
+mkdir -p lib-platforms/wp7/cordova/plugin/wp7
+
+#---------------------------------------------
+mv lib-common/cordova/exec/android.js    lib-platforms/android/cordova/exec.js
+mv lib-common/cordova/exec/blackberry.js lib-platforms/blackberry/cordova/exec.js
+mv lib-common/cordova/exec/errgen.js     lib-platforms/errgen/cordova/exec.js
+mv lib-common/cordova/exec/ios.js        lib-platforms/ios/cordova/exec.js
+mv lib-common/cordova/exec/playbook.js   lib-platforms/playbook/cordova/exec.js
+mv lib-common/cordova/exec/test.js       lib-platforms/test/cordova/exec.js
+mv lib-common/cordova/exec/wp7.js        lib-platforms/wp7/cordova/exec.js
+
+rmdir lib-common/cordova/exec
+
+#---------------------------------------------
+mv lib-common/cordova/platform/android.js    lib-platforms/android/cordova/platform.js
+mv lib-common/cordova/platform/blackberry.js lib-platforms/blackberry/cordova/platform.js
+mv lib-common/cordova/platform/errgen.js     lib-platforms/errgen/cordova/platform.js
+mv lib-common/cordova/platform/ios.js        lib-platforms/ios/cordova/platform.js
+mv lib-common/cordova/platform/playbook.js   lib-platforms/playbook/cordova/platform.js
+mv lib-common/cordova/platform/wp7.js        lib-platforms/wp7/cordova/platform.js
+mv lib-common/cordova/platform/common.js     lib-common/cordova/common.js
+
+rmdir lib-common/cordova/platform
+
+#---------------------------------------------
+mv lib-common/cordova/plugin/android/*.js       lib-platforms/android/cordova/plugin/android
+mv lib-common/cordova/plugin/blackberry/*.js    lib-platforms/blackberry/cordova/plugin/blackberry
+mv lib-common/cordova/plugin/errgen/*.js        lib-platforms/errgen/cordova/plugin/errgen
+mv lib-common/cordova/plugin/ios/*.js           lib-platforms/ios/cordova/plugin/ios
+mv lib-common/cordova/plugin/playbook/*.js      lib-platforms/playbook/cordova/plugin/playbook
+mv lib-common/cordova/plugin/webworks/*.js      lib-platforms/webworks/cordova/plugin/webworks
+mv lib-common/cordova/plugin/wp7/*.js           lib-platforms/wp7/cordova/plugin/wp7
+
+rmdir lib-common/cordova/plugin/android
+rmdir lib-common/cordova/plugin/blackberry
+rmdir lib-common/cordova/plugin/errgen
+rmdir lib-common/cordova/plugin/ios
+rmdir lib-common/cordova/plugin/playbook
+rmdir lib-common/cordova/plugin/webworks
+rmdir lib-common/cordova/plugin/wp7
+
+#---------------------------------------------
+mkdir lib-scripts
+mv lib-common/cordova/bootstrap.js lib-scripts
+mv lib-common/cordova/require.js   lib-scripts
+
+mv lib-common/cordova/bootstrap/errgen.js   lib-scripts/bootstrap-errgen.js
+mv lib-common/cordova/bootstrap/playbook.js lib-scripts/bootstrap-playbook.js
+
+rm -rf lib-common/cordova/bootstrap

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova.js b/lib-common/cordova.js
new file mode 100644
index 0000000..3d5b2a5
--- /dev/null
+++ b/lib-common/cordova.js
@@ -0,0 +1,232 @@
+var channel = require('cordova/channel');
+/**
+ * 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 (e == 'deviceready') {
+        channel.onDeviceReady.subscribeOnce(handler);
+    } else if (e == 'resume') {
+      channel.onResume.subscribe(handler);
+      // if subscribing listener after event has already fired, invoke the handler
+      if (channel.onResume.fired && handler instanceof Function) {
+          handler();
+      }
+    } else if (e == 'pause') {
+      channel.onPause.subscribe(handler);
+    } else 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 unsubcribing 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 unsubcribing 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 = {
+    define:define,
+    require:require,
+    /**
+     * Methods to add/remove your own addEventListener hijacking on document + window.
+     */
+    addWindowEventHandler:function(event, opts) {
+      return (windowEventHandlers[event] = channel.create(event, opts));
+    },
+    addDocumentEventHandler:function(event, opts) {
+      return (documentEventHandlers[event] = channel.create(event, opts));
+    },
+    removeWindowEventHandler:function(event) {
+      delete windowEventHandlers[event];
+    },
+    removeDocumentEventHandler:function(event) {
+      delete documentEventHandlers[event];
+    },
+    /**
+     * Method to fire event from native code
+     */
+    fireDocumentEvent: function(type, data) {
+      var evt = createEvent(type, data);
+      if (typeof documentEventHandlers[type] != 'undefined') {
+        documentEventHandlers[type].fire(evt);
+      } else {
+        document.dispatchEvent(evt);
+      }
+    },
+    fireWindowEvent: function(type, data) {
+      var evt = createEvent(type,data);
+      if (typeof windowEventHandlers[type] != 'undefined') {
+        windowEventHandlers[type].fire(evt);
+      } else {
+        window.dispatchEvent(evt);
+      }
+    },
+    // TODO: this is Android only; think about how to do this better
+    shuttingDown:false,
+    UsePolling:false,
+    // END TODO
+
+    // TODO: iOS only
+    // This queue holds the currently executing command and all pending
+    // commands executed with cordova.exec().
+    commandQueue:[],
+    // Indicates if we're currently in the middle of flushing the command
+    // queue on the native side.
+    commandQueueFlushing:false,
+    // END TODO
+    /**
+     * Plugin callback mechanism.
+     */
+    callbackId: 0,
+    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.
+     *
+     * @param callbackId
+     * @param args
+     */
+    callbackSuccess: function(callbackId, args) {
+        if (cordova.callbacks[callbackId]) {
+
+            // If result is to be sent to callback
+            if (args.status == cordova.callbackStatus.OK) {
+                try {
+                    if (cordova.callbacks[callbackId].success) {
+                        cordova.callbacks[callbackId].success(args.message);
+                    }
+                }
+                catch (e) {
+                    console.log("Error in success callback: "+callbackId+" = "+e);
+                }
+            }
+
+            // Clear callback if not expecting any more results
+            if (!args.keepCallback) {
+                delete cordova.callbacks[callbackId];
+            }
+        }
+    },
+
+    /**
+     * Called by native code when returning error result from an action.
+     *
+     * @param callbackId
+     * @param args
+     */
+    callbackError: function(callbackId, args) {
+        if (cordova.callbacks[callbackId]) {
+            try {
+                if (cordova.callbacks[callbackId].fail) {
+                    cordova.callbacks[callbackId].fail(args.message);
+                }
+            }
+            catch (e) {
+                console.log("Error in error callback: "+callbackId+" = "+e);
+            }
+
+            // Clear callback if not expecting any more results
+            if (!args.keepCallback) {
+                delete cordova.callbacks[callbackId];
+            }
+        }
+    },
+    
+    addPlugin: function(name, obj) {
+        if (!window.plugins[name]) {
+            window.plugins[name] = obj;
+        }
+        else {
+            console.log("Error: Plugin "+name+" already exists.");
+        }
+    },
+    
+    addConstructor: function(func) {
+        channel.onCordovaReady.subscribeOnce(function() {
+            try {
+                func();
+            } catch(e) {
+                console.log("Failed to run constructor: " + e);
+            }
+        });
+    }
+};
+
+/** 
+ * Legacy variable for plugin support
+ */
+if (!window.PhoneGap) {
+    window.PhoneGap = cordova;
+}
+
+/**
+ * Plugins object
+ */
+if (!window.plugins) {
+    window.plugins = {};
+}
+
+module.exports = cordova;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/builder.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/builder.js b/lib-common/cordova/builder.js
new file mode 100644
index 0000000..0ff2f73
--- /dev/null
+++ b/lib-common/cordova/builder.js
@@ -0,0 +1,86 @@
+function each(objects, func, context) {
+    for (var prop in objects) {
+        if (objects.hasOwnProperty(prop)) {
+            func.apply(context, [objects[prop], prop]);
+        }
+    }
+}
+
+function include(parent, objects, clobber, merge) {
+    each(objects, function (obj, key) {
+        try {
+          var result = obj.path ? require(obj.path) : {};
+
+          if (clobber) {
+              // Clobber if it doesn't exist.
+              if (typeof parent[key] === 'undefined') {
+                  parent[key] = result;
+              } else if (typeof obj.path !== 'undefined') {
+                  // If merging, merge properties onto parent, otherwise, clobber.
+                  if (merge) {
+                      recursiveMerge(parent[key], result);
+                  } else {
+                      parent[key] = result;
+                  }
+              }
+              result = parent[key];
+          } else {
+            // Overwrite if not currently defined.
+            if (typeof parent[key] == 'undefined') {
+              parent[key] = result;
+            } else if (merge && typeof obj.path !== 'undefined') {
+              // If merging, merge parent onto result
+              recursiveMerge(result, parent[key]);
+              parent[key] = result;
+            } else {
+              // Set result to what already exists, so we can build children into it if they exist.
+              result = parent[key];
+            }
+          }
+
+          if (obj.children) {
+            include(result, obj.children, clobber, merge);
+          }
+        } catch(e) {
+          alert('Exception building cordova JS globals: ' + e + ' for key "' + key + '"');
+        }
+    });
+}
+
+/**
+ * Merge properties from one object onto another recursively.  Properties from
+ * the src object will overwrite existing target property.
+ *
+ * @param target Object to merge properties into.
+ * @param src Object to merge properties from.
+ */
+function recursiveMerge(target, src) {
+    for (var prop in src) {
+        if (src.hasOwnProperty(prop)) {
+            if (typeof target.prototype !== 'undefined' && target.prototype.constructor === target) {
+                // If the target object is a constructor override off prototype.
+                target.prototype[prop] = src[prop];
+            } else {
+                target[prop] = typeof src[prop] === 'object' ? recursiveMerge(
+                        target[prop], src[prop]) : src[prop];
+            }
+        }
+    }
+    return target;
+}
+
+module.exports = {
+    build: function (objects) {
+        return {
+            intoButDontClobber: function (target) {
+                include(target, objects, false, false);
+            },
+            intoAndClobber: function(target) {
+                include(target, objects, true, false);
+            },
+            intoAndMerge: function(target) {
+                include(target, objects, true, true);
+            }
+        };
+    }
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/channel.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/channel.js b/lib-common/cordova/channel.js
new file mode 100755
index 0000000..baf08b6
--- /dev/null
+++ b/lib-common/cordova/channel.js
@@ -0,0 +1,207 @@
+/**
+ * Custom pub-sub channel that can have functions subscribed to it
+ * @constructor
+ * @param type  String the channel name
+ * @param opts  Object options to pass into the channel, currently
+ *                     supports:
+ *                     onSubscribe: callback that fires when
+ *                       something subscribes to the Channel. Sets
+ *                       context to the Channel.
+ *                     onUnsubscribe: callback that fires when
+ *                       something unsubscribes to the Channel. Sets
+ *                       context to the Channel.
+ */
+var Channel = function(type, opts) {
+        this.type = type;
+        this.handlers = {};
+        this.numHandlers = 0;
+        this.guid = 0;
+        this.fired = false;
+        this.enabled = true;
+        this.events = {
+          onSubscribe:null,
+          onUnsubscribe:null
+        };
+        if (opts) {
+          if (opts.onSubscribe) this.events.onSubscribe = opts.onSubscribe;
+          if (opts.onUnsubscribe) this.events.onUnsubscribe = opts.onUnsubscribe;
+        }
+    },
+    channel = {
+        /**
+         * Calls the provided function only after all of the channels specified
+         * have been fired.
+         */
+        join: function (h, c) {
+            var i = c.length;
+            var len = i;
+            var f = function() {
+                if (!(--i)) h();
+            };
+            for (var j=0; j<len; j++) {
+                !c[j].fired?c[j].subscribeOnce(f):i--;
+            }
+            if (!i) h();
+        },
+        create: function (type, opts) {
+            channel[type] = new Channel(type, opts);
+            return channel[type];
+        },
+
+        /**
+         * cordova Channels that must fire before "deviceready" is fired.
+         */ 
+        deviceReadyChannelsArray: [],
+        deviceReadyChannelsMap: {},
+        
+        /**
+         * Indicate that a feature needs to be initialized before it is ready to be used.
+         * This holds up Cordova's "deviceready" event until the feature has been initialized
+         * and Cordova.initComplete(feature) is called.
+         *
+         * @param feature {String}     The unique feature name
+         */
+        waitForInitialization: function(feature) {
+            if (feature) {
+                var c = null;
+                if (this[feature]) {
+                    c = this[feature];
+                }
+                else {
+                    c = this.create(feature);
+                }
+                this.deviceReadyChannelsMap[feature] = c;
+                this.deviceReadyChannelsArray.push(c);
+            }
+        },
+
+        /**
+         * Indicate that initialization code has completed and the feature is ready to be used.
+         *
+         * @param feature {String}     The unique feature name
+         */
+        initializationComplete: function(feature) {
+            var c = this.deviceReadyChannelsMap[feature];
+            if (c) {
+                c.fire();
+            }
+        }
+    },
+    utils = require('cordova/utils');
+
+/**
+ * Subscribes the given function to the channel. Any time that 
+ * Channel.fire is called so too will the function.
+ * Optionally specify an execution context for the function
+ * and a guid that can be used to stop subscribing to the channel.
+ * Returns the guid.
+ */
+Channel.prototype.subscribe = function(f, c, g) {
+    // need a function to call
+    if (f === null || f === undefined) { return; }
+
+    var func = f;
+    if (typeof c == "object" && f instanceof Function) { func = utils.close(c, f); }
+
+    g = g || func.observer_guid || f.observer_guid || this.guid++;
+    func.observer_guid = g;
+    f.observer_guid = g;
+    this.handlers[g] = func;
+    this.numHandlers++;
+    if (this.events.onSubscribe) this.events.onSubscribe.call(this);
+    return g;
+};
+
+/**
+ * Like subscribe but the function is only called once and then it
+ * auto-unsubscribes itself.
+ */
+Channel.prototype.subscribeOnce = function(f, c) {
+    // need a function to call
+    if (f === null || f === undefined) { return; }
+
+    var g = null;
+    var _this = this;
+    var m = function() {
+        f.apply(c || null, arguments);
+        _this.unsubscribe(g);
+    };
+    if (this.fired) {
+        if (typeof c == "object" && f instanceof Function) { f = utils.close(c, f); }
+        f.apply(this, this.fireArgs);
+    } else {
+        g = this.subscribe(m);
+    }
+    return g;
+};
+
+/** 
+ * Unsubscribes the function with the given guid from the channel.
+ */
+Channel.prototype.unsubscribe = function(g) {
+    // need a function to unsubscribe
+    if (g === null || g === undefined) { return; }
+
+    if (g instanceof Function) { g = g.observer_guid; }
+    this.handlers[g] = null;
+    delete this.handlers[g];
+    this.numHandlers--;
+    if (this.events.onUnsubscribe) this.events.onUnsubscribe.call(this);
+};
+
+/** 
+ * Calls all functions subscribed to this channel.
+ */
+Channel.prototype.fire = function(e) {
+    if (this.enabled) {
+        var fail = false;
+        this.fired = true;
+        for (var item in this.handlers) {
+            var handler = this.handlers[item];
+            if (handler instanceof Function) {
+                var rv = (handler.apply(this, arguments)===false);
+                fail = fail || rv;
+            }
+        }
+        this.fireArgs = arguments;
+        return !fail;
+    }
+    return true;
+};
+
+//HACK: defining them here so they are ready super fast!
+
+// DOM event that is received when the web page is loaded and parsed.
+channel.create('onDOMContentLoaded');
+
+// Event to indicate the Cordova native side is ready.
+channel.create('onNativeReady');
+
+// Event to indicate that all Cordova JavaScript objects have been created
+// and it's time to run plugin constructors.
+channel.create('onCordovaReady');
+
+// Event to indicate that device properties are available
+channel.create('onCordovaInfoReady');
+
+// Event to indicate that the connection property has been set.
+channel.create('onCordovaConnectionReady');
+
+// Event to indicate that Cordova is ready
+channel.create('onDeviceReady');
+
+// Event to indicate a resume lifecycle event
+channel.create('onResume');
+
+// Event to indicate a pause lifecycle event
+channel.create('onPause');
+
+// Event to indicate a destroy lifecycle event
+channel.create('onDestroy');
+
+// Channels that must fire before "deviceready" is fired.
+channel.waitForInitialization('onCordovaReady');
+channel.waitForInitialization('onCordovaInfoReady');
+channel.waitForInitialization('onCordovaConnectionReady');
+
+module.exports = channel;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/common.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/common.js b/lib-common/cordova/common.js
new file mode 100644
index 0000000..e07bf03
--- /dev/null
+++ b/lib-common/cordova/common.js
@@ -0,0 +1,180 @@
+module.exports = {
+    objects: {
+        cordova: {
+            path: 'cordova',
+            children: {
+                exec: {
+                    path: 'cordova/exec'
+                }
+            }
+        },
+        navigator: {
+            children: {
+                notification: {
+                    path: 'cordova/plugin/notification'
+                },
+                accelerometer: {
+                    path: 'cordova/plugin/accelerometer'
+                },
+                battery: {
+                    path: 'cordova/plugin/battery'
+                },
+                camera:{
+                    path: 'cordova/plugin/Camera'
+                },
+                compass:{
+                    path: 'cordova/plugin/compass'
+                },
+                contacts: {
+                    path: 'cordova/plugin/contacts'
+                },
+                device:{
+                    children:{
+                        capture: {
+                            path: 'cordova/plugin/capture'
+                        }
+                    }
+                },
+                geolocation: {
+                    path: 'cordova/plugin/geolocation'
+                },
+                network: {
+                    children: {
+                        connection: {
+                            path: 'cordova/plugin/network'
+                        }
+                    }
+                }
+            }
+        },
+        Acceleration: {
+            path: 'cordova/plugin/Acceleration'
+        },
+        Camera:{
+            path: 'cordova/plugin/CameraConstants'
+        },
+        CaptureError: {
+            path: 'cordova/plugin/CaptureError'
+        },
+        CaptureAudioOptions:{
+            path: 'cordova/plugin/CaptureAudioOptions'
+        },
+        CaptureImageOptions: {
+            path: 'cordova/plugin/CaptureImageOptions'
+        },
+        CaptureVideoOptions: {
+            path: 'cordova/plugin/CaptureVideoOptions'
+        },
+        CompassHeading:{
+            path: 'cordova/plugin/CompassHeading'
+        },
+        CompassError:{
+            path: 'cordova/plugin/CompassError'
+        },
+        ConfigurationData: {
+            path: 'cordova/plugin/ConfigurationData'
+        },
+        Connection: {
+            path: 'cordova/plugin/Connection'
+        },
+        Contact: {
+            path: 'cordova/plugin/Contact'
+        },
+        ContactAddress: {
+            path: 'cordova/plugin/ContactAddress'
+        },
+        ContactError: {
+            path: 'cordova/plugin/ContactError'
+        },
+        ContactField: {
+            path: 'cordova/plugin/ContactField'
+        },
+        ContactFindOptions: {
+            path: 'cordova/plugin/ContactFindOptions'
+        },
+        ContactName: {
+            path: 'cordova/plugin/ContactName'
+        },
+        ContactOrganization: {
+            path: 'cordova/plugin/ContactOrganization'
+        },
+        Coordinates: {
+            path: 'cordova/plugin/Coordinates'
+        },
+        DirectoryEntry: {
+            path: 'cordova/plugin/DirectoryEntry'
+        },
+        DirectoryReader: {
+            path: 'cordova/plugin/DirectoryReader'
+        },
+        Entry: {
+            path: 'cordova/plugin/Entry'
+        },
+        File: {
+            path: 'cordova/plugin/File'
+        },
+        FileEntry: {
+            path: 'cordova/plugin/FileEntry'
+        },
+        FileError: {
+            path: 'cordova/plugin/FileError'
+        },
+        FileReader: {
+            path: 'cordova/plugin/FileReader'
+        },
+        FileSystem: {
+            path: 'cordova/plugin/FileSystem'
+        },
+        FileTransfer: {
+            path: 'cordova/plugin/FileTransfer'
+        },
+        FileTransferError: {
+            path: 'cordova/plugin/FileTransferError'
+        },
+        FileUploadOptions: {
+            path: 'cordova/plugin/FileUploadOptions'
+        },
+        FileUploadResult: {
+            path: 'cordova/plugin/FileUploadResult'
+        },
+        FileWriter: {
+            path: 'cordova/plugin/FileWriter'
+        },
+        Flags: {
+            path: 'cordova/plugin/Flags'
+        },
+        LocalFileSystem: {
+            path: 'cordova/plugin/LocalFileSystem'
+        },
+        Media: {
+            path: 'cordova/plugin/Media'
+        },
+        MediaError: {
+            path: 'cordova/plugin/MediaError'
+        },
+        MediaFile: {
+            path: 'cordova/plugin/MediaFile'
+        },
+        MediaFileData:{
+            path: 'cordova/plugin/MediaFileData'
+        },
+        Metadata:{
+            path: 'cordova/plugin/Metadata'
+        },
+        Position: {
+            path: 'cordova/plugin/Position'
+        },
+        PositionError: {
+            path: 'cordova/plugin/PositionError'
+        },
+        ProgressEvent: {
+            path: 'cordova/plugin/ProgressEvent'
+        },
+        requestFileSystem:{
+            path: 'cordova/plugin/requestFileSystem'
+        },
+        resolveLocalFileSystemURI:{
+            path: 'cordova/plugin/resolveLocalFileSystemURI'
+        }
+    }
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/exec.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/exec.js b/lib-common/cordova/exec.js
new file mode 100644
index 0000000..b236903
--- /dev/null
+++ b/lib-common/cordova/exec.js
@@ -0,0 +1 @@
+throw new Error('should have been replaced at build time with platform implementation')

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/platform.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/platform.js b/lib-common/cordova/platform.js
new file mode 100644
index 0000000..b236903
--- /dev/null
+++ b/lib-common/cordova/platform.js
@@ -0,0 +1 @@
+throw new Error('should have been replaced at build time with platform implementation')

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/Acceleration.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/Acceleration.js b/lib-common/cordova/plugin/Acceleration.js
new file mode 100644
index 0000000..f02d24b
--- /dev/null
+++ b/lib-common/cordova/plugin/Acceleration.js
@@ -0,0 +1,8 @@
+var Acceleration = function(x, y, z) {
+  this.x = x;
+  this.y = y;
+  this.z = z;
+  this.timestamp = new Date().getTime();
+};
+
+module.exports = Acceleration;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/Camera.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/Camera.js b/lib-common/cordova/plugin/Camera.js
new file mode 100644
index 0000000..5e58af8
--- /dev/null
+++ b/lib-common/cordova/plugin/Camera.js
@@ -0,0 +1,84 @@
+var exec = require('cordova/exec'),
+    Camera = require('cordova/plugin/CameraConstants');
+
+var cameraExport = {};
+
+// Tack on the Camera Constants to the base camera plugin.
+for (var key in Camera) {
+    cameraExport[key] = Camera[key];
+}
+
+/**
+ * Gets a picture from source defined by "options.sourceType", and returns the
+ * image as defined by the "options.destinationType" option.
+
+ * The defaults are sourceType=CAMERA and destinationType=FILE_URL.
+ *
+ * @param {Function} successCallback
+ * @param {Function} errorCallback
+ * @param {Object} options
+ */
+cameraExport.getPicture = function(successCallback, errorCallback, options) {
+    // successCallback required
+    if (typeof successCallback != "function") {
+        console.log("Camera Error: successCallback is not a function");
+        return;
+    }
+
+    // errorCallback optional
+    if (errorCallback && (typeof errorCallback != "function")) {
+        console.log("Camera Error: errorCallback is not a function");
+        return;
+    }
+
+    var quality = 50;
+    if (options && typeof options.quality == "number") {
+        quality = options.quality;
+    } else if (options && typeof options.quality == "string") {
+        var qlity = parseInt(options.quality, 10);
+        if (isNaN(qlity) === false) {
+            quality = qlity.valueOf();
+        }
+    }
+
+    var destinationType = Camera.DestinationType.FILE_URI;
+    if (typeof options.destinationType == "number") {
+        destinationType = options.destinationType;
+    }
+
+    var sourceType = Camera.PictureSourceType.CAMERA;
+    if (typeof options.sourceType == "number") {
+        sourceType = options.sourceType;
+    }
+
+    var targetWidth = -1;
+    if (typeof options.targetWidth == "number") {
+        targetWidth = options.targetWidth;
+    } else if (typeof options.targetWidth == "string") {
+        var width = parseInt(options.targetWidth, 10);
+        if (isNaN(width) === false) {
+            targetWidth = width.valueOf();
+        }
+    }
+
+    var targetHeight = -1;
+    if (typeof options.targetHeight == "number") {
+        targetHeight = options.targetHeight;
+    } else if (typeof options.targetHeight == "string") {
+        var height = parseInt(options.targetHeight, 10);
+        if (isNaN(height) === false) {
+            targetHeight = height.valueOf();
+        }
+    }
+
+    var encodingType = Camera.EncodingType.JPEG;
+    if (typeof options.encodingType == "number") {
+        encodingType = options.encodingType;
+    }
+    // TODO: parse MediaType
+    // TODO: enable allow edit?
+
+    exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType]);
+}
+
+module.exports = cameraExport;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/CameraConstants.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/CameraConstants.js b/lib-common/cordova/plugin/CameraConstants.js
new file mode 100644
index 0000000..b379234
--- /dev/null
+++ b/lib-common/cordova/plugin/CameraConstants.js
@@ -0,0 +1,20 @@
+module.exports = {
+  DestinationType:{
+    DATA_URL: 0,         // Return base64 encoded string
+    FILE_URI: 1          // Return file uri (content://media/external/images/media/2 for Android)
+  },
+  EncodingType:{
+    JPEG: 0,             // Return JPEG encoded image
+    PNG: 1               // Return PNG encoded image
+  },
+  MediaType:{
+    PICTURE: 0,          // allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType
+    VIDEO: 1,            // allow selection of video only, ONLY RETURNS URL
+    ALLMEDIA : 2         // allow selection from all media types
+  },
+  PictureSourceType:{
+    PHOTOLIBRARY : 0,    // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
+    CAMERA : 1,          // Take picture from camera
+    SAVEDPHOTOALBUM : 2  // Choose image from picture library (same as PHOTOLIBRARY for Android)
+  }
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/CaptureAudioOptions.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/CaptureAudioOptions.js b/lib-common/cordova/plugin/CaptureAudioOptions.js
new file mode 100644
index 0000000..ee07932
--- /dev/null
+++ b/lib-common/cordova/plugin/CaptureAudioOptions.js
@@ -0,0 +1,13 @@
+/**
+ * Encapsulates all audio capture operation configuration options.
+ */
+var CaptureAudioOptions = function(){
+	// Upper limit of sound clips user can record. Value must be equal or greater than 1.
+	this.limit = 1;
+	// Maximum duration of a single sound clip in seconds.
+	this.duration = 0;
+	// The selected audio mode. Must match with one of the elements in supportedAudioModes array.
+	this.mode = null;
+};
+
+module.exports = CaptureAudioOptions;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/CaptureError.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/CaptureError.js b/lib-common/cordova/plugin/CaptureError.js
new file mode 100644
index 0000000..b217ae4
--- /dev/null
+++ b/lib-common/cordova/plugin/CaptureError.js
@@ -0,0 +1,19 @@
+/**
+ * The CaptureError interface encapsulates all errors in the Capture API.
+ */
+var CaptureError = function(c) {
+   this.code = c || null;
+};
+
+// Camera or microphone failed to capture image or sound. 
+CaptureError.CAPTURE_INTERNAL_ERR = 0;
+// Camera application or audio capture application is currently serving other capture request.
+CaptureError.CAPTURE_APPLICATION_BUSY = 1;
+// Invalid use of the API (e.g. limit parameter has value less than one).
+CaptureError.CAPTURE_INVALID_ARGUMENT = 2;
+// User exited camera application or audio capture application before capturing anything.
+CaptureError.CAPTURE_NO_MEDIA_FILES = 3;
+// The requested capture operation is not supported.
+CaptureError.CAPTURE_NOT_SUPPORTED = 20;
+
+module.exports = CaptureError;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/CaptureImageOptions.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/CaptureImageOptions.js b/lib-common/cordova/plugin/CaptureImageOptions.js
new file mode 100644
index 0000000..c90e8d4
--- /dev/null
+++ b/lib-common/cordova/plugin/CaptureImageOptions.js
@@ -0,0 +1,11 @@
+/**
+ * Encapsulates all image capture operation configuration options.
+ */
+var CaptureImageOptions = function(){
+	// Upper limit of images user can take. Value must be equal or greater than 1.
+	this.limit = 1;
+	// The selected image mode. Must match with one of the elements in supportedImageModes array.
+	this.mode = null;
+};
+
+module.exports = CaptureImageOptions;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/CaptureVideoOptions.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/CaptureVideoOptions.js b/lib-common/cordova/plugin/CaptureVideoOptions.js
new file mode 100644
index 0000000..5583ddb
--- /dev/null
+++ b/lib-common/cordova/plugin/CaptureVideoOptions.js
@@ -0,0 +1,13 @@
+/**
+ * Encapsulates all video capture operation configuration options.
+ */
+var CaptureVideoOptions = function(){
+	// Upper limit of videos user can record. Value must be equal or greater than 1.
+	this.limit = 1;
+	// Maximum duration of a single video clip in seconds.
+	this.duration = 0;
+	// The selected video mode. Must match with one of the elements in supportedVideoModes array.
+	this.mode = null;
+};
+
+module.exports = CaptureVideoOptions;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/CompassError.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/CompassError.js b/lib-common/cordova/plugin/CompassError.js
new file mode 100644
index 0000000..baba76d
--- /dev/null
+++ b/lib-common/cordova/plugin/CompassError.js
@@ -0,0 +1,13 @@
+/**
+ *  CompassError.
+ *  An error code assigned by an implementation when an error has occured
+ * @constructor
+ */
+var CompassError = function(err) {
+    this.code = (err !== undefined ? err : null);
+};
+
+CompassError.COMPASS_INTERNAL_ERR = 0;
+CompassError.COMPASS_NOT_SUPPORTED = 20;
+
+module.exports = CompassError;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/CompassHeading.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/CompassHeading.js b/lib-common/cordova/plugin/CompassHeading.js
new file mode 100644
index 0000000..2336beb
--- /dev/null
+++ b/lib-common/cordova/plugin/CompassHeading.js
@@ -0,0 +1,8 @@
+var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) {
+  this.magneticHeading = (magneticHeading !== undefined ? magneticHeading : null);
+  this.trueHeading = (trueHeading !== undefined ? trueHeading : null);
+  this.headingAccuracy = (headingAccuracy !== undefined ? headingAccuracy : null);
+  this.timestamp = (timestamp !== undefined ? new Date(timestamp) : new Date());
+};
+
+module.exports = CompassHeading;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/ConfigurationData.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/ConfigurationData.js b/lib-common/cordova/plugin/ConfigurationData.js
new file mode 100644
index 0000000..838c87c
--- /dev/null
+++ b/lib-common/cordova/plugin/ConfigurationData.js
@@ -0,0 +1,15 @@
+/**
+ * Encapsulates a set of parameters that the capture device supports.
+ */
+function ConfigurationData() {
+    // The ASCII-encoded string in lower case representing the media type. 
+    this.type = null; 
+    // The height attribute represents height of the image or video in pixels. 
+    // In the case of a sound clip this attribute has value 0. 
+    this.height = 0;
+    // The width attribute represents width of the image or video in pixels. 
+    // In the case of a sound clip this attribute has value 0
+    this.width = 0;
+}
+
+module.exports = ConfigurationData;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/Connection.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/Connection.js b/lib-common/cordova/plugin/Connection.js
new file mode 100644
index 0000000..1a7fea8
--- /dev/null
+++ b/lib-common/cordova/plugin/Connection.js
@@ -0,0 +1,12 @@
+/**
+ * Network status
+ */
+module.exports = {
+		UNKNOWN: "unknown",
+		ETHERNET: "ethernet",
+		WIFI: "wifi",
+		CELL_2G: "2g",
+		CELL_3G: "3g",
+		CELL_4G: "4g",
+		NONE: "none"
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/Contact.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/Contact.js b/lib-common/cordova/plugin/Contact.js
new file mode 100644
index 0000000..261bb12
--- /dev/null
+++ b/lib-common/cordova/plugin/Contact.js
@@ -0,0 +1,177 @@
+var exec = require('cordova/exec'),
+    ContactError = require('cordova/plugin/ContactError'),
+    utils = require('cordova/utils');
+
+/**
+* Converts primitives into Complex Object
+* Currently only used for Date fields
+*/
+function convertIn(contact) {
+    var value = contact.birthday;
+    try {
+      contact.birthday = new Date(parseFloat(value));
+    } catch (exception){
+      console.log("Cordova Contact convertIn error: exception creating date.");
+    }
+    return contact;
+};
+
+/**
+* Converts Complex objects into primitives
+* Only conversion at present is for Dates.
+**/
+
+function convertOut(contact) {
+    var value = contact.birthday;
+    if (value != null) {
+        // try to make it a Date object if it is not already
+        if (!value instanceof Date){
+            try {
+                value = new Date(value);
+            } catch(exception){
+                value = null;
+            }
+        }
+        if (value instanceof Date){
+            value = value.valueOf(); // convert to milliseconds
+        }
+        contact.birthday = value;
+    }
+    return contact;
+};
+
+/**
+* Contains information about a single contact.
+* @constructor
+* @param {DOMString} id unique identifier
+* @param {DOMString} displayName
+* @param {ContactName} name
+* @param {DOMString} nickname
+* @param {Array.<ContactField>} phoneNumbers array of phone numbers
+* @param {Array.<ContactField>} emails array of email addresses
+* @param {Array.<ContactAddress>} addresses array of addresses
+* @param {Array.<ContactField>} ims instant messaging user ids
+* @param {Array.<ContactOrganization>} organizations
+* @param {DOMString} birthday contact's birthday
+* @param {DOMString} note user notes about contact
+* @param {Array.<ContactField>} photos
+* @param {Array.<ContactField>} categories
+* @param {Array.<ContactField>} urls contact's web sites
+*/
+var Contact = function (id, displayName, name, nickname, phoneNumbers, emails, addresses,
+    ims, organizations, birthday, note, photos, categories, urls) {
+    this.id = id || null;
+    this.rawId = null;
+    this.displayName = displayName || null;
+    this.name = name || null; // ContactName
+    this.nickname = nickname || null;
+    this.phoneNumbers = phoneNumbers || null; // ContactField[]
+    this.emails = emails || null; // ContactField[]
+    this.addresses = addresses || null; // ContactAddress[]
+    this.ims = ims || null; // ContactField[]
+    this.organizations = organizations || null; // ContactOrganization[]
+    this.birthday = birthday || null;
+    this.note = note || null;
+    this.photos = photos || null; // ContactField[]
+    this.categories = categories || null; // ContactField[]
+    this.urls = urls || null; // ContactField[]
+};
+
+/**
+* Removes contact from device storage.
+* @param successCB success callback
+* @param errorCB error callback
+*/
+Contact.prototype.remove = function(successCB, errorCB) {
+    var fail = function(code) {
+        errorCB(new ContactError(code));
+    };
+    if (this.id === null) {
+        fail(ContactError.UNKNOWN_ERROR);
+    }
+    else {
+        exec(successCB, fail, "Contacts", "remove", [this.id]);
+    }
+};
+
+/**
+* Creates a deep copy of this Contact.
+* With the contact ID set to null.
+* @return copy of this Contact
+*/
+Contact.prototype.clone = function() {
+    var clonedContact = utils.clone(this);
+    var i;
+    clonedContact.id = null;
+    clonedContact.rawId = null;
+    // Loop through and clear out any id's in phones, emails, etc.
+    if (clonedContact.phoneNumbers) {
+        for (i = 0; i < clonedContact.phoneNumbers.length; i++) {
+            clonedContact.phoneNumbers[i].id = null;
+        }
+    }
+    if (clonedContact.emails) {
+        for (i = 0; i < clonedContact.emails.length; i++) {
+            clonedContact.emails[i].id = null;
+        }
+    }
+    if (clonedContact.addresses) {
+        for (i = 0; i < clonedContact.addresses.length; i++) {
+            clonedContact.addresses[i].id = null;
+        }
+    }
+    if (clonedContact.ims) {
+        for (i = 0; i < clonedContact.ims.length; i++) {
+            clonedContact.ims[i].id = null;
+        }
+    }
+    if (clonedContact.organizations) {
+        for (i = 0; i < clonedContact.organizations.length; i++) {
+            clonedContact.organizations[i].id = null;
+        }
+    }
+    if (clonedContact.categories) {
+        for (i = 0; i < clonedContact.categories.length; i++) {
+            clonedContact.categories[i].id = null;
+        }
+    }
+    if (clonedContact.photos) {
+        for (i = 0; i < clonedContact.photos.length; i++) {
+            clonedContact.photos[i].id = null;
+        }
+    }
+    if (clonedContact.urls) {
+        for (i = 0; i < clonedContact.urls.length; i++) {
+            clonedContact.urls[i].id = null;
+        }
+    }
+    return clonedContact;
+};
+
+/**
+* Persists contact to device storage.
+* @param successCB success callback
+* @param errorCB error callback
+*/
+Contact.prototype.save = function(successCB, errorCB) {
+  var fail = function(code) {
+      errorCB(new ContactError(code));
+  };
+	var success = function(result) {
+      if (result) {
+          if (typeof successCB === 'function') {
+              var fullContact = require('cordova/plugin/contacts').create(result);
+              successCB(convertIn(fullContact));
+          }
+      }
+      else {
+          // no Entry object returned
+          fail(ContactError.UNKNOWN_ERROR);
+      }
+  };
+	var dupContact = convertOut(utils.clone(this));
+	exec(success, fail, "Contacts", "save", [dupContact]);
+};
+
+
+module.exports = Contact;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/ContactAddress.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/ContactAddress.js b/lib-common/cordova/plugin/ContactAddress.js
new file mode 100644
index 0000000..9fa3605
--- /dev/null
+++ b/lib-common/cordova/plugin/ContactAddress.js
@@ -0,0 +1,25 @@
+/**
+* Contact address.
+* @constructor
+* @param {DOMString} id unique identifier, should only be set by native code
+* @param formatted // NOTE: not a W3C standard
+* @param streetAddress
+* @param locality
+* @param region
+* @param postalCode
+* @param country
+*/
+
+var ContactAddress = function(pref, type, formatted, streetAddress, locality, region, postalCode, country) {
+    this.id = null;
+    this.pref = (typeof pref != 'undefined' ? pref : false);
+    this.type = type || null;
+    this.formatted = formatted || null;
+    this.streetAddress = streetAddress || null;
+    this.locality = locality || null;
+    this.region = region || null;
+    this.postalCode = postalCode || null;
+    this.country = country || null;
+};
+
+module.exports = ContactAddress;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/ContactError.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/ContactError.js b/lib-common/cordova/plugin/ContactError.js
new file mode 100644
index 0000000..324a0cf
--- /dev/null
+++ b/lib-common/cordova/plugin/ContactError.js
@@ -0,0 +1,21 @@
+/**
+ *  ContactError.
+ *  An error code assigned by an implementation when an error has occured
+ * @constructor
+ */
+var ContactError = function(err) {
+    this.code = (typeof err != 'undefined' ? err : null);
+};
+
+/**
+ * Error codes
+ */
+ContactError.UNKNOWN_ERROR = 0;
+ContactError.INVALID_ARGUMENT_ERROR = 1;
+ContactError.TIMEOUT_ERROR = 2;
+ContactError.PENDING_OPERATION_ERROR = 3;
+ContactError.IO_ERROR = 4;
+ContactError.NOT_SUPPORTED_ERROR = 5;
+ContactError.PERMISSION_DENIED_ERROR = 20;
+
+module.exports = ContactError;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/ContactField.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/ContactField.js b/lib-common/cordova/plugin/ContactField.js
new file mode 100644
index 0000000..c2a8ac1
--- /dev/null
+++ b/lib-common/cordova/plugin/ContactField.js
@@ -0,0 +1,16 @@
+/**
+* Generic contact field.
+* @constructor
+* @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
+* @param type
+* @param value
+* @param pref
+*/
+var ContactField = function(type, value, pref) {
+    this.id = null;
+    this.type = type || null;
+    this.value = value || null;
+    this.pref = (typeof pref != 'undefined' ? pref : false);
+};
+
+module.exports = ContactField;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/ContactFindOptions.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/ContactFindOptions.js b/lib-common/cordova/plugin/ContactFindOptions.js
new file mode 100644
index 0000000..036c4c6
--- /dev/null
+++ b/lib-common/cordova/plugin/ContactFindOptions.js
@@ -0,0 +1,13 @@
+/**
+ * ContactFindOptions.
+ * @constructor
+ * @param filter used to match contacts against
+ * @param multiple boolean used to determine if more than one contact should be returned
+ */
+
+var ContactFindOptions = function(filter, multiple) {
+    this.filter = filter || '';
+    this.multiple = (typeof multiple != 'undefined' ? multiple : false);
+};
+
+module.exports = ContactFindOptions;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/ContactName.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/ContactName.js b/lib-common/cordova/plugin/ContactName.js
new file mode 100644
index 0000000..5434e74
--- /dev/null
+++ b/lib-common/cordova/plugin/ContactName.js
@@ -0,0 +1,20 @@
+/**
+* Contact name.
+* @constructor
+* @param formatted // NOTE: not part of W3C standard
+* @param familyName
+* @param givenName
+* @param middle
+* @param prefix
+* @param suffix
+*/
+var ContactName = function(formatted, familyName, givenName, middle, prefix, suffix) {
+    this.formatted = formatted || null;
+    this.familyName = familyName || null;
+    this.givenName = givenName || null;
+    this.middleName = middle || null;
+    this.honorificPrefix = prefix || null;
+    this.honorificSuffix = suffix || null;
+};
+
+module.exports = ContactName;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/ContactOrganization.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/ContactOrganization.js b/lib-common/cordova/plugin/ContactOrganization.js
new file mode 100644
index 0000000..32ec462
--- /dev/null
+++ b/lib-common/cordova/plugin/ContactOrganization.js
@@ -0,0 +1,23 @@
+/**
+* Contact organization.
+* @constructor
+* @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
+* @param name
+* @param dept
+* @param title
+* @param startDate
+* @param endDate
+* @param location
+* @param desc
+*/
+
+var ContactOrganization = function(pref, type, name, dept, title) {
+    this.id = null;
+    this.pref = (typeof pref != 'undefined' ? pref : false);
+    this.type = type || null;
+    this.name = name || null;
+    this.department = dept || null;
+    this.title = title || null;
+};
+
+module.exports = ContactOrganization;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/Coordinates.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/Coordinates.js b/lib-common/cordova/plugin/Coordinates.js
new file mode 100644
index 0000000..d783e1c
--- /dev/null
+++ b/lib-common/cordova/plugin/Coordinates.js
@@ -0,0 +1,43 @@
+/**
+ * This class contains position information.
+ * @param {Object} lat
+ * @param {Object} lng
+ * @param {Object} alt
+ * @param {Object} acc
+ * @param {Object} head
+ * @param {Object} vel
+ * @param {Object} altacc
+ * @constructor
+ */
+var Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
+    /**
+     * The latitude of the position.
+     */
+    this.latitude = lat;
+    /**
+     * The longitude of the position,
+     */
+    this.longitude = lng;
+    /**
+     * The accuracy of the position.
+     */
+    this.accuracy = acc;
+    /**
+     * The altitude of the position.
+     */
+    this.altitude = alt;
+    /**
+     * The direction the device is moving at the position.
+     */
+    this.heading = head;
+    /**
+     * The velocity with which the device is moving at the position.
+     */
+    this.speed = vel;
+    /**
+     * The altitude accuracy of the position.
+     */
+    this.altitudeAccuracy = (altacc !== undefined) ? altacc : null;
+};
+
+module.exports = Coordinates;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/DirectoryEntry.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/DirectoryEntry.js b/lib-common/cordova/plugin/DirectoryEntry.js
new file mode 100644
index 0000000..e9949d0
--- /dev/null
+++ b/lib-common/cordova/plugin/DirectoryEntry.js
@@ -0,0 +1,80 @@
+var utils = require('cordova/utils'),
+    exec = require('cordova/exec'),
+    Entry = require('cordova/plugin/Entry'),
+    DirectoryReader = require('cordova/plugin/DirectoryReader');
+
+/**
+ * An interface representing a directory on the file system.
+ *
+ * {boolean} isFile always false (readonly)
+ * {boolean} isDirectory always true (readonly)
+ * {DOMString} name of the directory, excluding the path leading to it (readonly)
+ * {DOMString} fullPath the absolute full path to the directory (readonly)
+ * {FileSystem} filesystem on which the directory resides (readonly)
+ */
+var DirectoryEntry = function(name, fullPath) {
+     DirectoryEntry.__super__.constructor.apply(this, [false, true, name, fullPath]);
+};
+
+utils.extend(DirectoryEntry, Entry);
+
+/**
+ * Creates a new DirectoryReader to read entries from this directory
+ */
+DirectoryEntry.prototype.createReader = function() {
+    return new DirectoryReader(this.fullPath);
+};
+
+/**
+ * Creates or looks up a directory
+ *
+ * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory
+ * @param {Flags} options to create or excluively create the directory
+ * @param {Function} successCallback is called with the new entry
+ * @param {Function} errorCallback is called with a FileError
+ */
+DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) {
+    var win = typeof successCallback !== 'function' ? null : function(result) {
+        var entry = new DirectoryEntry(result.name, result.fullPath);
+        successCallback(entry);
+    };
+    var fail = typeof errorCallback !== 'function' ? null : function(code) {
+        errorCallback(new FileError(code));
+    };
+    exec(win, fail, "File", "getDirectory", [this.fullPath, path, options]);
+};
+
+/**
+ * Deletes a directory and all of it's contents
+ *
+ * @param {Function} successCallback is called with no parameters
+ * @param {Function} errorCallback is called with a FileError
+ */
+DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
+    var fail = typeof errorCallback !== 'function' ? null : function(code) {
+        errorCallback(new FileError(code));
+    };
+    exec(successCallback, fail, "File", "removeRecursively", [this.fullPath]);
+};
+
+/**
+ * Creates or looks up a file
+ *
+ * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file
+ * @param {Flags} options to create or excluively create the file
+ * @param {Function} successCallback is called with the new entry
+ * @param {Function} errorCallback is called with a FileError
+ */
+DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
+    var win = typeof successCallback !== 'function' ? null : function(result) {
+        var FileEntry = require('cordova/plugin/FileEntry');
+        var entry = new FileEntry(result.name, result.fullPath);
+        successCallback(entry);
+    };
+    var fail = typeof errorCallback !== 'function' ? null : function(code) {
+        errorCallback(new FileError(code));
+    };
+    exec(win, fail, "File", "getFile", [this.fullPath, path, options]);
+};
+
+module.exports = DirectoryEntry;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/DirectoryReader.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/DirectoryReader.js b/lib-common/cordova/plugin/DirectoryReader.js
new file mode 100644
index 0000000..90e67a4
--- /dev/null
+++ b/lib-common/cordova/plugin/DirectoryReader.js
@@ -0,0 +1,41 @@
+var exec = require('cordova/exec');
+
+/**
+ * An interface that lists the files and directories in a directory.
+ */
+function DirectoryReader(path) {
+    this.path = path || null;
+}
+
+/**
+ * Returns a list of entries from a directory.
+ *
+ * @param {Function} successCallback is called with a list of entries
+ * @param {Function} errorCallback is called with a FileError
+ */
+DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
+    var win = typeof successCallback !== 'function' ? null : function(result) {
+        var retVal = [];
+        for (var i=0; i<result.length; i++) {
+            var entry = null;
+            if (result[i].isDirectory) {
+                entry = new DirectoryEntry();
+            }
+            else if (result[i].isFile) {
+                entry = new FileEntry();
+            }
+            entry.isDirectory = result[i].isDirectory;
+            entry.isFile = result[i].isFile;
+            entry.name = result[i].name;
+            entry.fullPath = result[i].fullPath;
+            retVal.push(entry);
+        }
+        successCallback(retVal);
+    };
+    var fail = typeof errorCallback !== 'function' ? null : function(code) {
+        errorCallback(new FileError(code));
+    };
+    exec(win, fail, "File", "readEntries", [this.path]);
+};
+
+module.exports = DirectoryReader;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/Entry.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/Entry.js b/lib-common/cordova/plugin/Entry.js
new file mode 100644
index 0000000..f748dcc
--- /dev/null
+++ b/lib-common/cordova/plugin/Entry.js
@@ -0,0 +1,198 @@
+var exec = require('cordova/exec'),
+    FileError = require('cordova/plugin/FileError'),
+    Metadata = require('cordova/plugin/Metadata');
+
+/**
+ * Represents a file or directory on the local file system.
+ *
+ * @param isFile
+ *            {boolean} true if Entry is a file (readonly)
+ * @param isDirectory
+ *            {boolean} true if Entry is a directory (readonly)
+ * @param name
+ *            {DOMString} name of the file or directory, excluding the path
+ *            leading to it (readonly)
+ * @param fullPath
+ *            {DOMString} the absolute full path to the file or directory
+ *            (readonly)
+ */
+function Entry(isFile, isDirectory, name, fullPath, fileSystem) {
+    this.isFile = (typeof isFile != 'undefined'?isFile:false);
+    this.isDirectory = (typeof isDirectory != 'undefined'?isDirectory:false);
+    this.name = name || '';
+    this.fullPath = fullPath || '';
+    this.filesystem = fileSystem || null;
+}
+
+/**
+ * Look up the metadata of the entry.
+ *
+ * @param successCallback
+ *            {Function} is called with a Metadata object
+ * @param errorCallback
+ *            {Function} is called with a FileError
+ */
+Entry.prototype.getMetadata = function(successCallback, errorCallback) {
+  var success = typeof successCallback !== 'function' ? null : function(lastModified) {
+      var metadata = new Metadata(lastModified);
+      successCallback(metadata);
+  };
+  var fail = typeof errorCallback !== 'function' ? null : function(code) {
+      errorCallback(new FileError(code));
+  };
+
+  exec(success, fail, "File", "getMetadata", [this.fullPath]);
+};
+
+/**
+ * Move a file or directory to a new location.
+ *
+ * @param parent
+ *            {DirectoryEntry} the directory to which to move this entry
+ * @param newName
+ *            {DOMString} new name of the entry, defaults to the current name
+ * @param successCallback
+ *            {Function} called with the new DirectoryEntry object
+ * @param errorCallback
+ *            {Function} called with a FileError
+ */
+Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
+    var fail = function(code) {
+        if (typeof errorCallback === 'function') {
+            errorCallback(new FileError(code));
+        }
+    };
+    // user must specify parent Entry
+    if (!parent) {
+        fail(FileError.NOT_FOUND_ERR);
+        return;
+    }
+    // source path
+    var srcPath = this.fullPath,
+        // entry name
+        name = newName || this.name,
+        success = function(entry) {
+            if (entry) {
+                if (typeof successCallback === 'function') {
+                    // create appropriate Entry object
+                    var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
+                    try {
+                        successCallback(result);
+                    }
+                    catch (e) {
+                        console.log('Error invoking callback: ' + e);
+                    }
+                }
+            }
+            else {
+                // no Entry object returned
+                fail(FileError.NOT_FOUND_ERR);
+            }
+        };
+
+    // copy
+    exec(success, fail, "File", "moveTo", [srcPath, parent.fullPath, name]);
+};
+
+/**
+ * Copy a directory to a different location.
+ *
+ * @param parent
+ *            {DirectoryEntry} the directory to which to copy the entry
+ * @param newName
+ *            {DOMString} new name of the entry, defaults to the current name
+ * @param successCallback
+ *            {Function} called with the new Entry object
+ * @param errorCallback
+ *            {Function} called with a FileError
+ */
+Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
+    var fail = function(code) {
+        if (typeof errorCallback === 'function') {
+            errorCallback(new FileError(code));
+        }
+    };
+
+    // user must specify parent Entry
+    if (!parent) {
+        fail(FileError.NOT_FOUND_ERR);
+        return;
+    }
+
+        // source path
+    var srcPath = this.fullPath,
+        // entry name
+        name = newName || this.name,
+        // success callback
+        success = function(entry) {
+            if (entry) {
+                if (typeof successCallback === 'function') {
+                    // create appropriate Entry object
+                    var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
+                    try {
+                        successCallback(result);
+                    }
+                    catch (e) {
+                        console.log('Error invoking callback: ' + e);
+                    }
+                }
+            }
+            else {
+                // no Entry object returned
+                fail(FileError.NOT_FOUND_ERR);
+            }
+        };
+
+    // copy
+    exec(success, fail, "File", "copyTo", [srcPath, parent.fullPath, name]);
+};
+
+/**
+ * Return a URL that can be used to identify this entry.
+ */
+Entry.prototype.toURL = function() {
+    // fullPath attribute contains the full URL
+    return this.fullPath;
+};
+
+/**
+ * Returns a URI that can be used to identify this entry.
+ *
+ * @param {DOMString} mimeType for a FileEntry, the mime type to be used to interpret the file, when loaded through this URI.
+ * @return uri
+ */
+Entry.prototype.toURI = function(mimeType) {
+    console.log("DEPRECATED: Update your code to use 'toURL'");
+    // fullPath attribute contains the full URI
+    return this.fullPath;
+};
+
+/**
+ * Remove a file or directory. It is an error to attempt to delete a
+ * directory that is not empty. It is an error to attempt to delete a
+ * root directory of a file system.
+ *
+ * @param successCallback {Function} called with no parameters
+ * @param errorCallback {Function} called with a FileError
+ */
+Entry.prototype.remove = function(successCallback, errorCallback) {
+    var fail = typeof errorCallback !== 'function' ? null : function(code) {
+        errorCallback(new FileError(code));
+    };
+    exec(successCallback, fail, "File", "remove", [this.fullPath]);
+};
+
+/**
+ * Look up the parent DirectoryEntry of this entry.
+ *
+ * @param successCallback {Function} called with the parent DirectoryEntry object
+ * @param errorCallback {Function} called with a FileError
+ */
+Entry.prototype.getParent = function(successCallback, errorCallback) {
+    var fail = typeof errorCallback !== 'function' ? null : function(code) {
+        errorCallback(new FileError(code));
+    };
+    exec(successCallback, fail, "File", "getParent", [this.fullPath]);
+};
+
+module.exports = Entry;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f3acff6d/lib-common/cordova/plugin/File.js
----------------------------------------------------------------------
diff --git a/lib-common/cordova/plugin/File.js b/lib-common/cordova/plugin/File.js
new file mode 100644
index 0000000..96de0d7
--- /dev/null
+++ b/lib-common/cordova/plugin/File.js
@@ -0,0 +1,18 @@
+/**
+ * Constructor.
+ * name {DOMString} name of the file, without path information
+ * fullPath {DOMString} the full path of the file, including the name
+ * type {DOMString} mime type
+ * lastModifiedDate {Date} last modified date
+ * size {Number} size of the file in bytes
+ */
+
+var File = function(name, fullPath, type, lastModifiedDate, size){
+	this.name = name || '';
+	this.fullPath = fullPath || null;
+	this.type = type || null;
+	this.lastModifiedDate = lastModifiedDate || null;
+	this.size = size || 0;
+};
+
+module.exports = File;