You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by br...@apache.org on 2013/12/11 22:54:27 UTC
[08/15] js commit: refactoring to small modules
refactoring to small 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/d9a3dced
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/d9a3dced
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/d9a3dced
Branch: refs/heads/master
Commit: d9a3dced745aaa0b8d59fc6edf5e2a2c377d44bb
Parents: f9a743a
Author: brianleroux <b...@brian.io>
Authored: Wed Dec 11 08:51:18 2013 +1000
Committer: brianleroux <b...@brian.io>
Committed: Wed Dec 11 08:51:18 2013 +1000
----------------------------------------------------------------------
Gruntfile.js | 146 +-
LICENSE-for-js-file.txt | 16 -
build/gv-requires.js | 133 -
build/packager.js | 291 --
lib/amazon-fireos/android/nativeapiprovider.js | 36 -
.../android/promptbasednativeapi.js | 35 -
lib/amazon-fireos/exec.js | 252 --
lib/amazon-fireos/platform.js | 56 -
lib/amazon-fireos/plugin/android/app.js | 92 -
lib/android/android/nativeapiprovider.js | 36 -
lib/android/android/promptbasednativeapi.js | 35 -
lib/android/exec.js | 252 --
lib/android/platform.js | 56 -
lib/android/plugin/android/app.js | 92 -
lib/blackberry10/exec.js | 103 -
lib/blackberry10/platform.js | 57 -
lib/blackberry10/plugin/.gitkeep | 0
lib/browser/exec.js | 48 -
lib/browser/platform.js | 50 -
lib/common/argscheck.js | 81 -
lib/common/base64.js | 71 -
lib/common/builder.js | 128 -
lib/common/channel.js | 256 --
lib/common/exec.js | 22 -
lib/common/exec/proxy.js | 46 -
lib/common/init.js | 129 -
lib/common/modulemapper.js | 115 -
lib/common/platform.js | 22 -
lib/common/pluginloader.js | 134 -
lib/common/urlutil.js | 41 -
lib/common/utils.js | 185 --
lib/cordova.js | 233 --
lib/firefoxos/exec.js | 44 -
lib/firefoxos/firefoxos/commandProxy.js | 23 -
lib/firefoxos/init.js | 142 -
lib/firefoxos/platform.js | 30 -
lib/ios/exec.js | 247 --
lib/ios/platform.js | 28 -
lib/osx/exec.js | 117 -
lib/osx/platform.js | 27 -
lib/osx/plugin/osx/.gitignore | 0
lib/scripts/bootstrap.js | 22 -
lib/scripts/require.js | 96 -
lib/test/androidexec.js | 1 -
lib/test/exec.js | 22 -
lib/test/iosexec.js | 1 -
lib/test/mockxhr.js | 123 -
lib/test/modulereplacer.js | 33 -
lib/test/platform.js | 36 -
lib/test/propertyreplacer.js | 48 -
lib/test/testmodule.js | 27 -
lib/ubuntu/exec.js | 77 -
lib/ubuntu/platform.js | 31 -
lib/windows8/exec.js | 80 -
lib/windows8/platform.js | 62 -
lib/windows8/windows8/commandProxy.js | 23 -
lib/windowsphone/exec.js | 68 -
lib/windowsphone/platform.js | 34 -
src/amazon-fireos/android/nativeapiprovider.js | 36 +
.../android/promptbasednativeapi.js | 35 +
src/amazon-fireos/exec.js | 252 ++
src/amazon-fireos/platform.js | 56 +
src/amazon-fireos/plugin/android/app.js | 92 +
src/android/android/nativeapiprovider.js | 36 +
src/android/android/promptbasednativeapi.js | 35 +
src/android/exec.js | 252 ++
src/android/platform.js | 56 +
src/android/plugin/android/app.js | 92 +
src/blackberry10/exec.js | 103 +
src/blackberry10/platform.js | 57 +
src/browser/exec.js | 48 +
src/browser/platform.js | 50 +
src/common/argscheck.js | 81 +
src/common/base64.js | 71 +
src/common/builder.js | 128 +
src/common/channel.js | 256 ++
src/common/exec.js | 22 +
src/common/exec/proxy.js | 46 +
src/common/init.js | 129 +
src/common/modulemapper.js | 115 +
src/common/platform.js | 22 +
src/common/pluginloader.js | 134 +
src/common/urlutil.js | 41 +
src/common/utils.js | 185 ++
src/cordova.js | 233 ++
src/firefoxos/exec.js | 44 +
src/firefoxos/firefoxos/commandProxy.js | 23 +
src/firefoxos/init.js | 142 +
src/firefoxos/platform.js | 30 +
src/ios/exec.js | 247 ++
src/ios/platform.js | 28 +
src/osx/exec.js | 117 +
src/osx/platform.js | 27 +
src/osx/plugin/osx/.gitignore | 0
src/scripts/bootstrap.js | 22 +
src/scripts/require.js | 96 +
src/test/androidexec.js | 1 +
src/test/exec.js | 22 +
src/test/iosexec.js | 1 +
src/test/mockxhr.js | 123 +
src/test/modulereplacer.js | 33 +
src/test/platform.js | 36 +
src/test/propertyreplacer.js | 48 +
src/test/testmodule.js | 27 +
src/ubuntu/exec.js | 77 +
src/ubuntu/platform.js | 31 +
src/windows8/exec.js | 80 +
src/windows8/platform.js | 62 +
src/windows8/windows8/commandProxy.js | 23 +
src/windowsphone/exec.js | 68 +
src/windowsphone/platform.js | 34 +
tasks/compile.js | 30 +
tasks/lib/LICENSE-for-js-file.txt | 16 +
tasks/lib/collect-file.js | 15 +
tasks/lib/collect-files.js | 28 +
tasks/lib/copy-props.js | 10 +
tasks/lib/get-module-id.js | 4 +
tasks/lib/gv-requires.js | 133 +
tasks/lib/packager.js | 180 ++
tasks/lib/process-white-space.js | 66 +
tasks/lib/strip-header.js | 19 +
tasks/lib/write-contents.js | 22 +
tasks/lib/write-module.js | 16 +
tasks/lib/write-script.js | 8 +
tasks/test.js | 29 +
tasks/vendor/commonjs-tests/README.txt | 9 +
.../commonjs-tests/modules/1.0/absolute/b.js | 1 +
.../modules/1.0/absolute/program.js | 5 +
.../modules/1.0/absolute/submodule/a.js | 3 +
.../commonjs-tests/modules/1.0/absolute/test.js | 15 +
.../commonjs-tests/modules/1.0/cyclic/a.js | 4 +
.../commonjs-tests/modules/1.0/cyclic/b.js | 4 +
.../modules/1.0/cyclic/program.js | 10 +
.../commonjs-tests/modules/1.0/cyclic/test.js | 15 +
.../modules/1.0/determinism/program.js | 3 +
.../modules/1.0/determinism/submodule/a.js | 9 +
.../modules/1.0/determinism/submodule/b.js | 2 +
.../modules/1.0/determinism/test.js | 15 +
.../modules/1.0/exactExports/a.js | 3 +
.../modules/1.0/exactExports/program.js | 4 +
.../modules/1.0/exactExports/test.js | 15 +
.../1.0/hasOwnProperty/hasOwnProperty.js | 0
.../modules/1.0/hasOwnProperty/program.js | 4 +
.../modules/1.0/hasOwnProperty/test.js | 15 +
.../modules/1.0/hasOwnProperty/toString.js | 0
.../commonjs-tests/modules/1.0/method/a.js | 12 +
.../modules/1.0/method/program.js | 8 +
.../commonjs-tests/modules/1.0/method/test.js | 15 +
.../modules/1.0/missing/program.js | 8 +
.../commonjs-tests/modules/1.0/missing/test.js | 15 +
.../commonjs-tests/modules/1.0/monkeys/a.js | 1 +
.../modules/1.0/monkeys/program.js | 4 +
.../commonjs-tests/modules/1.0/monkeys/test.js | 15 +
.../modules/1.0/nested/a/b/c/d.js | 3 +
.../modules/1.0/nested/program.js | 3 +
.../commonjs-tests/modules/1.0/nested/test.js | 15 +
.../modules/1.0/relative/program.js | 5 +
.../modules/1.0/relative/submodule/a.js | 1 +
.../modules/1.0/relative/submodule/b.js | 2 +
.../commonjs-tests/modules/1.0/relative/test.js | 15 +
.../commonjs-tests/modules/1.0/transitive/a.js | 1 +
.../commonjs-tests/modules/1.0/transitive/b.js | 1 +
.../commonjs-tests/modules/1.0/transitive/c.js | 3 +
.../modules/1.0/transitive/program.js | 3 +
.../modules/1.0/transitive/test.js | 15 +
tasks/vendor/jasmine/MIT.LICENSE | 20 +
tasks/vendor/jasmine/jasmine-html.js | 190 ++
tasks/vendor/jasmine/jasmine.css | 166 ++
tasks/vendor/jasmine/jasmine.js | 2476 ++++++++++++++++++
tasks/vendor/jasmine/jasmine_favicon.png | Bin 0 -> 905 bytes
tasks/whitespace.js | 47 +
thirdparty/commonjs-tests/README.txt | 9 -
.../commonjs-tests/modules/1.0/absolute/b.js | 1 -
.../modules/1.0/absolute/program.js | 5 -
.../modules/1.0/absolute/submodule/a.js | 3 -
.../commonjs-tests/modules/1.0/absolute/test.js | 15 -
.../commonjs-tests/modules/1.0/cyclic/a.js | 4 -
.../commonjs-tests/modules/1.0/cyclic/b.js | 4 -
.../modules/1.0/cyclic/program.js | 10 -
.../commonjs-tests/modules/1.0/cyclic/test.js | 15 -
.../modules/1.0/determinism/program.js | 3 -
.../modules/1.0/determinism/submodule/a.js | 9 -
.../modules/1.0/determinism/submodule/b.js | 2 -
.../modules/1.0/determinism/test.js | 15 -
.../modules/1.0/exactExports/a.js | 3 -
.../modules/1.0/exactExports/program.js | 4 -
.../modules/1.0/exactExports/test.js | 15 -
.../1.0/hasOwnProperty/hasOwnProperty.js | 0
.../modules/1.0/hasOwnProperty/program.js | 4 -
.../modules/1.0/hasOwnProperty/test.js | 15 -
.../modules/1.0/hasOwnProperty/toString.js | 0
.../commonjs-tests/modules/1.0/method/a.js | 12 -
.../modules/1.0/method/program.js | 8 -
.../commonjs-tests/modules/1.0/method/test.js | 15 -
.../modules/1.0/missing/program.js | 8 -
.../commonjs-tests/modules/1.0/missing/test.js | 15 -
.../commonjs-tests/modules/1.0/monkeys/a.js | 1 -
.../modules/1.0/monkeys/program.js | 4 -
.../commonjs-tests/modules/1.0/monkeys/test.js | 15 -
.../modules/1.0/nested/a/b/c/d.js | 3 -
.../modules/1.0/nested/program.js | 3 -
.../commonjs-tests/modules/1.0/nested/test.js | 15 -
.../modules/1.0/relative/program.js | 5 -
.../modules/1.0/relative/submodule/a.js | 1 -
.../modules/1.0/relative/submodule/b.js | 2 -
.../commonjs-tests/modules/1.0/relative/test.js | 15 -
.../commonjs-tests/modules/1.0/transitive/a.js | 1 -
.../commonjs-tests/modules/1.0/transitive/b.js | 1 -
.../commonjs-tests/modules/1.0/transitive/c.js | 3 -
.../modules/1.0/transitive/program.js | 3 -
.../modules/1.0/transitive/test.js | 15 -
thirdparty/jasmine/MIT.LICENSE | 20 -
thirdparty/jasmine/jasmine-html.js | 190 --
thirdparty/jasmine/jasmine.css | 166 --
thirdparty/jasmine/jasmine.js | 2476 ------------------
thirdparty/jasmine/jasmine_favicon.png | Bin 905 -> 0 bytes
216 files changed, 7881 insertions(+), 7804 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index cd86689..cced79f 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -17,25 +17,21 @@
* under the License.
*/
module.exports = function(grunt) {
- var childProcess = require('child_process');
- var fs = require('fs');
- var path = require('path');
- // Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
- cordovajs: {
- "amazon-fireos": {},
- "android": {},
- "blackberry10": {},
- "ios": {},
- "osx": {},
- "test": {},
- "windows8": { useWindowsLineEndings: true },
- "windowsphone": { useWindowsLineEndings: true },
- "firefoxos": {},
- "ubuntu": {},
- "browser": {}
+ compile: {
+ "amazon-fireos": {},
+ "android": {},
+ "blackberry10": {},
+ "ios": {},
+ "osx": {},
+ "test": {},
+ "windows8": { useWindowsLineEndings: true },
+ "windowsphone": { useWindowsLineEndings: true },
+ "firefoxos": {},
+ "ubuntu": {},
+ "browser": {}
},
clean: ['pkg'],
jshint: {
@@ -46,117 +42,15 @@ module.exports = function(grunt) {
},
});
- // Iterates over a directory
- function forEachFile(root, cbFile, cbDone) {
- var count = 0;
-
- function scan(name) {
- ++count;
-
- fs.stat(name, function (err, stats) {
- if (err) cbFile(err);
-
- if (stats.isDirectory()) {
- fs.readdir(name, function (err, files) {
- if (err) cbFile(err);
-
- files.forEach(function (file) {
- scan(path.join(name, file));
- });
- done();
- });
- } else if (stats.isFile()) {
- cbFile(null, name, stats, done);
- } else {
- done();
- }
- });
- }
-
- function done() {
- --count;
- if (count === 0 && cbDone) cbDone();
- }
-
- scan(root);
- }
-
- function processWhiteSpace(processor, callback) {
- var rexp_minified = new RegExp("\\.min\\.js$");
- var rexp_src = new RegExp('\\.js$');
- forEachFile('lib', function(err, file, stats, cbDone) {
- //if (err) throw err;
- if (rexp_minified.test(file) || !rexp_src.test(file)) {
- cbDone();
- } else {
- var origsrc = src = fs.readFileSync(file, 'utf8');
-
- // tabs -> four spaces
- if (src.indexOf('\t') >= 0) {
- src = src.split('\t').join(' ');
- }
-
- // eliminate trailing white space
- src = src.replace(/ +\n/g, '\n');
-
- if (origsrc !== src) {
- // write it out yo
- processor(file, src);
- }
- cbDone();
- }
- }, callback);
- }
-
- grunt.registerMultiTask('cordovajs', 'Packages cordova.js', function() {
- var packager = require("./build/packager");
- var done = this.async();
- var platformName = this.target;
- var useWindowsLineEndings = this.data.useWindowsLineEndings;
- packager.generate(platformName, useWindowsLineEndings, done);
- });
-
- grunt.registerTask('_test', 'Runs test in node', function() {
- var done = this.async();
- require('./test/runner').node(done);
- });
-
- grunt.registerTask('_btest', 'Runs tests in the browser', function() {
- require('./test/runner').browser();
- this.async(); // never finish.
- });
-
- grunt.registerTask('_complainwhitespace', 'Complain about what fixwhitespace would fix', function() {
- var done = this.async();
- var complainedAboutWhitespace = false;
- processWhiteSpace(function(file, newSource) {
- if (!complainedAboutWhitespace) {
- grunt.log.writeln("files with whitespace issues: (to fix: `grunt fixwhitespace`)");
- complainedAboutWhitespace = true;
- }
- grunt.log.writeln(" " + file);
- }, done);
- });
-
- grunt.registerTask('_fixwhitespace', 'Converts tabs to four spaces, eliminates trailing white space, converts newlines to proper form - enforcing style guide ftw!', function() {
- var done = this.async();
- var complainedAboutWhitespace = false;
- processWhiteSpace(function(file, newSource) {
- if (!complainedAboutWhitespace) {
- grunt.log.writeln("Fixed whitespace issues in:");
- complainedAboutWhitespace = true;
- }
- fs.writeFileSync(file, newSource, 'utf8');
- grunt.log.writeln(" " + file);
- }, done);
- });
-
+ // external tasks
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-jshint');
- // Default task(s).
- grunt.registerTask('build', ['cordovajs', 'jshint', '_complainwhitespace']);
- grunt.registerTask('default', ['build', '_test']);
- grunt.registerTask('test', ['build', '_test']);
- grunt.registerTask('btest', ['build', '_btest']);
+ // custom tasks
+ grunt.loadTasks('tasks');
+
+ // defaults
+ grunt.registerTask('default', ['build', 'test']);
+ grunt.registerTask('build', ['compile', 'jshint', 'whitespace-check']);
+ grunt.registerTask('test', ['_test', '_btest']);
};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/LICENSE-for-js-file.txt
----------------------------------------------------------------------
diff --git a/LICENSE-for-js-file.txt b/LICENSE-for-js-file.txt
deleted file mode 100644
index 20f533b..0000000
--- a/LICENSE-for-js-file.txt
+++ /dev/null
@@ -1,16 +0,0 @@
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/build/gv-requires.js
----------------------------------------------------------------------
diff --git a/build/gv-requires.js b/build/gv-requires.js
deleted file mode 100755
index fb7684d..0000000
--- a/build/gv-requires.js
+++ /dev/null
@@ -1,133 +0,0 @@
-#!/usr/bin/env node
-
-/*
- * 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.
- */
-
-fs = require('fs')
-path = require('path')
-
-//------------------------------------------------------------------------------
-process.chdir(path.join(__dirname, ".."))
-
-var platforms = getPlatforms()
-
-console.log("//-------------------------------------------------------")
-console.log("// graphviz .dot file for Cordova requires by platform")
-console.log("// http://www.graphviz.org/")
-console.log("// ")
-console.log("// - ./build/gv-requires.js > ~/tmp/requires.dot")
-console.log("// - [edit dot file to leave just one digraph]")
-console.log("// - dot -Tsvg ~/tmp/requires.dot > ~/tmp/requires.svg")
-console.log("// - [open svg file in a browser]")
-console.log("//-------------------------------------------------------")
-console.log("")
-
-for (var i=0; i<platforms.length; i++) {
- var platform = platforms[i]
-
- generateGraph(platform)
-}
-
-//------------------------------------------------------------------------------
-function getPlatforms() {
- var entries = fs.readdirSync("pkg")
-
- var platforms = []
-
- for (var i=0; i<entries.length; i++) {
- var entry = entries[i]
-
- var match = entry.match(/^cordova\.(.*)\.js$/)
- if (match)
- platforms.push(match[1])
- }
-
- return platforms
-}
-
-//------------------------------------------------------------------------------
-function generateGraph(platform) {
- var modules = {}
-
- var jsFile = path.join("pkg", "cordova." + platform + ".js")
-
- contents = fs.readFileSync(jsFile, 'utf-8')
- contents = contents.replace(/\n/g, ' ')
-
- modulesSource = contents.split(/define\(/)
-
- console.log("//--------------------------------------------------")
- console.log("// graphviz .dot file for " + platform)
- console.log("//--------------------------------------------------")
- console.log("digraph G {")
-
- for (var i=0; i< modulesSource.length; i++) {
- var moduleSource = modulesSource[i];
-
- var match = moduleSource.match(/'(.*?)'(.*)/)
- if (!match) continue
-
- var moduleName = match[1]
- moduleSource = match[2]
-
- if (moduleName.match(/\s/)) continue
- if (moduleName == "") continue
- if (moduleSource == "") continue
-
- modules[moduleName] = modules[moduleName] || []
- // console.log(" found module " + moduleName)
-
- var requires = getRequires(moduleSource, modules[moduleName])
-
- for (var j=0; j < requires.length; j++) {
- var gvModule = moduleName.replace(/\//g, '\\n')
- var gvRequire = requires[j].replace(/\//g, '\\n')
-
- console.log(' "' + gvModule + '" -> "' + gvRequire + '";')
- }
-
- }
-
- console.log("}")
- console.log("")
-}
-
-//------------------------------------------------------------------------------
-function getRequires(moduleSource, requires) {
- var pattern = /.*?require\((.*?)\)(.*)/
-
- var result = []
-// console.log(moduleSource)
-
- var match = moduleSource.match(pattern)
-
- while (match) {
- var require = match[1]
- moduleSource = match[2]
-
- require = require.replace(/'|"/g, '')
- result.push(require)
-
- match = moduleSource.match(pattern)
- }
-
- return result
-}
-
-
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/build/packager.js
----------------------------------------------------------------------
diff --git a/build/packager.js b/build/packager.js
deleted file mode 100644
index 39bfcce..0000000
--- a/build/packager.js
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * 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 childProcess = require('child_process');
-var fs = require('fs')
-var util = require('util')
-var path = require('path')
-
-var packager = module.exports
-
-var cachedGitVersion = null;
-packager.computeCommitId = function(callback) {
- if (cachedGitVersion) {
- callback(cachedGitVersion);
- return;
- }
- var versionFileId = fs.readFileSync('VERSION', { encoding: 'utf8' }).trim();
- if (/-dev$/.test(versionFileId) && fs.existsSync('.git')) {
- var gitPath = 'git';
- var args = 'rev-list HEAD --max-count=1 --abbrev-commit';
- childProcess.exec(gitPath + ' ' + args, function(err, stdout, stderr) {
- var isWindows = process.platform.slice(0, 3) == 'win';
- if (err && isWindows) {
- gitPath = '"' + path.join(process.env['ProgramFiles'], 'Git', 'bin', 'git.exe') + '"';
- childProcess.exec(gitPath + ' ' + args, function(err, stdout, stderr) {
- if (err) {
- error(err);
- } else {
- done(versionFileId + '-' + stdout);
- }
- });
- } else if (err) {
- error(err);
- } else {
- done(versionFileId + '-' + stdout);
- }
- });
- } else {
- done(fs.readFileSync('VERSION', { encoding: 'utf8' }));
- }
-
- function error(err) {
- throw new Error(err);
- }
-
- function done(stdout) {
- var version = stdout.trim();
- cachedGitVersion = version;
- callback(version);
- };
-}
-
-//------------------------------------------------------------------------------
-packager.generate = function(platform, useWindowsLineEndings, callback) {
- packager.computeCommitId(function(commitId) {
- var outFile;
- var time = new Date().valueOf();
-
- var libraryRelease = packager.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 = packager.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');
- }
-
- outFile = path.join('pkg', 'cordova.' + platform + '.js');
- fs.writeFileSync(outFile, libraryRelease, 'utf8');
-
- outFile = path.join('pkg', 'debug', 'cordova.' + platform + '-debug.js');
- fs.writeFileSync(outFile, libraryDebug, 'utf8');
-
- console.log('generated cordova.' + platform + '.js @ ' + commitId + ' in ' + time + 'ms');
- callback();
- });
-}
-
-//------------------------------------------------------------------------------
-packager.bundle = function(platform, debug, commitId) {
- var modules = collectFiles('lib/common')
- var scripts = collectFiles('lib/scripts')
-
- modules[''] = 'lib/cordova.js'
- copyProps(modules, collectFiles(path.join('lib', platform)));
-
- if (platform === 'test') {
- copyProps(modules, collectFiles(path.join('lib', 'android', 'android'), 'android/'));
- }
-
- var output = [];
-
- output.push("// Platform: " + platform);
- output.push("// " + commitId);
-
- // write header
- output.push('/*', getContents('LICENSE-for-js-file.txt'), '*/')
- 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)
-
- // 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)
- }
-
- output.push("window.cordova = require('cordova');")
-
- // 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)
- }
-
- // write trailer
- output.push('})();')
-
- return output.join('\n')
-}
-
-//------------------------------------------------------------------------------
-
-function collectFile(dir, id, entry) {
- if (!id) id = ''
- var moduleId = path.join(id, entry)
- var fileName = path.join(dir, entry)
-
- var stat = fs.statSync(fileName)
-
- var result = {};
-
- moduleId = getModuleId(moduleId)
- result[moduleId] = fileName
-
- return copyProps({}, result)
-}
-
-function collectFiles(dir, id) {
- if (!id) id = ''
-
- 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
- })
-
- entries.forEach(function(entry) {
- var moduleId = path.join(id, entry)
- var fileName = path.join(dir, entry)
-
- var stat = fs.statSync(fileName)
- if (stat.isDirectory()) {
- copyProps(result, collectFiles(fileName, moduleId))
- }
- else {
- moduleId = getModuleId(moduleId)
- result[moduleId] = fileName
- }
- })
- return copyProps({}, result)
-}
-
-//------------------------------------------------------------------------------
-function writeScript(oFile, fileName, debug) {
- var contents = getContents(fileName, 'utf8')
-
- contents = stripHeader(contents, fileName);
- writeContents(oFile, fileName, contents, debug);
-}
-
-//------------------------------------------------------------------------------
-function writeModule(oFile, fileName, moduleId, debug) {
- var contents = getContents(fileName, 'utf8')
-
- contents = '\n' + stripHeader(contents, fileName) + '\n'
-
- // Windows fix, '\' is an escape, but defining requires '/' -jm
- moduleId = path.join('cordova', moduleId).split("\\").join("/");
-
- var signature = 'function(require, exports, module)';
-
- contents = 'define("' + moduleId + '", ' + signature + ' {' + contents + '});\n'
-
- writeContents(oFile, fileName, contents, debug)
-}
-
-//------------------------------------------------------------------------------
-function getContents(file) {
- return fs.readFileSync(file, 'utf8');
-}
-
-//------------------------------------------------------------------------------
-function writeContents(oFile, fileName, contents, debug) {
-
- if (debug) {
- contents += '\n//@ sourceURL=' + fileName
-
- contents = 'eval(' + JSON.stringify(contents) + ')'
-
- // this bit makes it easier to identify modules
- // with syntax errors in them
- var handler = 'console.log("exception: in ' + fileName + ': " + e);'
- handler += 'console.log(e.stack);'
-
- contents = 'try {' + contents + '} catch(e) {' + handler + '}'
- }
-
- else {
- contents = '// file: ' + fileName.split("\\").join("/") + '\n' + contents;
- }
-
- oFile.push(contents)
-}
-
-//------------------------------------------------------------------------------
-function getModuleId(fileName) {
- return fileName.match(/(.*)\.js$/)[1]
-}
-
-//------------------------------------------------------------------------------
-function copyProps(target, source) {
- for (var key in source) {
- if (!source.hasOwnProperty(key)) continue
-
- target[key] = source[key]
- }
-
- return target
-}
-//-----------------------------------------------------------------------------
-// Strips the license header. Basically only the first multi-line comment up to to the closing */
-function stripHeader(contents, fileName) {
- var ls = contents.split(/\r?\n/);
- while (ls[0]) {
- if (ls[0].match(/^\s*\/\*/) || ls[0].match(/^\s*\*/)) {
- ls.shift();
- }
- else if (ls[0].match(/^\s*\*\//)) {
- ls.shift();
- break;
- }
- else {
- console.log("WARNING: file name " + fileName + " is missing the license header");
- break;
- }
- }
- return ls.join('\n');
-}
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/lib/amazon-fireos/android/nativeapiprovider.js
----------------------------------------------------------------------
diff --git a/lib/amazon-fireos/android/nativeapiprovider.js b/lib/amazon-fireos/android/nativeapiprovider.js
deleted file mode 100644
index 2e9aa67..0000000
--- a/lib/amazon-fireos/android/nativeapiprovider.js
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
-*/
-
-/**
- * Exports the ExposedJsApi.java object if available, otherwise exports the PromptBasedNativeApi.
- */
-
-var nativeApi = this._cordovaNative || require('cordova/android/promptbasednativeapi');
-var currentApi = nativeApi;
-
-module.exports = {
- get: function() { return currentApi; },
- setPreferPrompt: function(value) {
- currentApi = value ? require('cordova/android/promptbasednativeapi') : nativeApi;
- },
- // Used only by tests.
- set: function(value) {
- currentApi = value;
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/lib/amazon-fireos/android/promptbasednativeapi.js
----------------------------------------------------------------------
diff --git a/lib/amazon-fireos/android/promptbasednativeapi.js b/lib/amazon-fireos/android/promptbasednativeapi.js
deleted file mode 100644
index c12f46e..0000000
--- a/lib/amazon-fireos/android/promptbasednativeapi.js
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
-*/
-
-/**
- * Implements the API of ExposedJsApi.java, but uses prompt() to communicate.
- * This is used only on the 2.3 simulator, where addJavascriptInterface() is broken.
- */
-
-module.exports = {
- exec: function(service, action, callbackId, argsJson) {
- return prompt(argsJson, 'gap:'+JSON.stringify([service, action, callbackId]));
- },
- setNativeToJsBridgeMode: function(value) {
- prompt(value, 'gap_bridge_mode:');
- },
- retrieveJsMessages: function(fromOnlineEvent) {
- return prompt(+fromOnlineEvent, 'gap_poll:');
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/lib/amazon-fireos/exec.js
----------------------------------------------------------------------
diff --git a/lib/amazon-fireos/exec.js b/lib/amazon-fireos/exec.js
deleted file mode 100644
index 0d35ff1..0000000
--- a/lib/amazon-fireos/exec.js
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-/**
- * Execute a cordova command. It is up to the native side whether this action
- * is synchronous or asynchronous. The native side can return:
- * Synchronous: PluginResult object as a JSON string
- * Asynchronous: Empty string ""
- * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
- * depending upon the result of the action.
- *
- * @param {Function} success The success callback
- * @param {Function} fail The fail callback
- * @param {String} service The name of the service to use
- * @param {String} action Action to be run in cordova
- * @param {String[]} [args] Zero or more arguments to pass to the method
- */
-var cordova = require('cordova'),
- nativeApiProvider = require('cordova/android/nativeapiprovider'),
- utils = require('cordova/utils'),
- base64 = require('cordova/base64'),
- jsToNativeModes = {
- PROMPT: 0,
- JS_OBJECT: 1,
- // This mode is currently for benchmarking purposes only. It must be enabled
- // on the native side through the ENABLE_LOCATION_CHANGE_EXEC_MODE
- // constant within CordovaWebViewClient.java before it will work.
- LOCATION_CHANGE: 2
- },
- nativeToJsModes = {
- // Polls for messages using the JS->Native bridge.
- POLLING: 0,
- // For LOAD_URL to be viable, it would need to have a work-around for
- // the bug where the soft-keyboard gets dismissed when a message is sent.
- LOAD_URL: 1,
- // For the ONLINE_EVENT to be viable, it would need to intercept all event
- // listeners (both through addEventListener and window.ononline) as well
- // as set the navigator property itself.
- ONLINE_EVENT: 2,
- // Uses reflection to access private APIs of the WebView that can send JS
- // to be executed.
- // Requires Android 3.2.4 or above.
- PRIVATE_API: 3
- },
- jsToNativeBridgeMode, // Set lazily.
- nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT,
- pollEnabled = false,
- messagesFromNative = [];
-
-function androidExec(success, fail, service, action, args) {
- // Set default bridge modes if they have not already been set.
- // By default, we use the failsafe, since addJavascriptInterface breaks too often
- if (jsToNativeBridgeMode === undefined) {
- androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
- }
-
- // Process any ArrayBuffers in the args into a string.
- for (var i = 0; i < args.length; i++) {
- if (utils.typeName(args[i]) == 'ArrayBuffer') {
- args[i] = base64.fromArrayBuffer(args[i]);
- }
- }
-
- var callbackId = service + cordova.callbackId++,
- argsJson = JSON.stringify(args);
-
- if (success || fail) {
- cordova.callbacks[callbackId] = {success:success, fail:fail};
- }
-
- if (jsToNativeBridgeMode == jsToNativeModes.LOCATION_CHANGE) {
- window.location = 'http://cdv_exec/' + service + '#' + action + '#' + callbackId + '#' + argsJson;
- } else {
- var messages = nativeApiProvider.get().exec(service, action, callbackId, argsJson);
- // If argsJson was received by Java as null, try again with the PROMPT bridge mode.
- // This happens in rare circumstances, such as when certain Unicode characters are passed over the bridge on a Galaxy S2. See CB-2666.
- if (jsToNativeBridgeMode == jsToNativeModes.JS_OBJECT && messages === "@Null arguments.") {
- androidExec.setJsToNativeBridgeMode(jsToNativeModes.PROMPT);
- androidExec(success, fail, service, action, args);
- androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
- return;
- } else {
- androidExec.processMessages(messages);
- }
- }
-}
-
-function pollOnceFromOnlineEvent() {
- pollOnce(true);
-}
-
-function pollOnce(opt_fromOnlineEvent) {
- var msg = nativeApiProvider.get().retrieveJsMessages(!!opt_fromOnlineEvent);
- androidExec.processMessages(msg);
-}
-
-function pollingTimerFunc() {
- if (pollEnabled) {
- pollOnce();
- setTimeout(pollingTimerFunc, 50);
- }
-}
-
-function hookOnlineApis() {
- function proxyEvent(e) {
- cordova.fireWindowEvent(e.type);
- }
- // The network module takes care of firing online and offline events.
- // It currently fires them only on document though, so we bridge them
- // to window here (while first listening for exec()-releated online/offline
- // events).
- window.addEventListener('online', pollOnceFromOnlineEvent, false);
- window.addEventListener('offline', pollOnceFromOnlineEvent, false);
- cordova.addWindowEventHandler('online');
- cordova.addWindowEventHandler('offline');
- document.addEventListener('online', proxyEvent, false);
- document.addEventListener('offline', proxyEvent, false);
-}
-
-hookOnlineApis();
-
-androidExec.jsToNativeModes = jsToNativeModes;
-androidExec.nativeToJsModes = nativeToJsModes;
-
-androidExec.setJsToNativeBridgeMode = function(mode) {
- if (mode == jsToNativeModes.JS_OBJECT && !window._cordovaNative) {
- console.log('Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only.');
- mode = jsToNativeModes.PROMPT;
- }
- nativeApiProvider.setPreferPrompt(mode == jsToNativeModes.PROMPT);
- jsToNativeBridgeMode = mode;
-};
-
-androidExec.setNativeToJsBridgeMode = function(mode) {
- if (mode == nativeToJsBridgeMode) {
- return;
- }
- if (nativeToJsBridgeMode == nativeToJsModes.POLLING) {
- pollEnabled = false;
- }
-
- nativeToJsBridgeMode = mode;
- // Tell the native side to switch modes.
- nativeApiProvider.get().setNativeToJsBridgeMode(mode);
-
- if (mode == nativeToJsModes.POLLING) {
- pollEnabled = true;
- setTimeout(pollingTimerFunc, 1);
- }
-};
-
-// Processes a single message, as encoded by NativeToJsMessageQueue.java.
-function processMessage(message) {
- try {
- var firstChar = message.charAt(0);
- if (firstChar == 'J') {
- eval(message.slice(1));
- } else if (firstChar == 'S' || firstChar == 'F') {
- var success = firstChar == 'S';
- var keepCallback = message.charAt(1) == '1';
- var spaceIdx = message.indexOf(' ', 2);
- var status = +message.slice(2, spaceIdx);
- var nextSpaceIdx = message.indexOf(' ', spaceIdx + 1);
- var callbackId = message.slice(spaceIdx + 1, nextSpaceIdx);
- var payloadKind = message.charAt(nextSpaceIdx + 1);
- var payload;
- if (payloadKind == 's') {
- payload = message.slice(nextSpaceIdx + 2);
- } else if (payloadKind == 't') {
- payload = true;
- } else if (payloadKind == 'f') {
- payload = false;
- } else if (payloadKind == 'N') {
- payload = null;
- } else if (payloadKind == 'n') {
- payload = +message.slice(nextSpaceIdx + 2);
- } else if (payloadKind == 'A') {
- var data = message.slice(nextSpaceIdx + 2);
- var bytes = window.atob(data);
- var arraybuffer = new Uint8Array(bytes.length);
- for (var i = 0; i < bytes.length; i++) {
- arraybuffer[i] = bytes.charCodeAt(i);
- }
- payload = arraybuffer.buffer;
- } else if (payloadKind == 'S') {
- payload = window.atob(message.slice(nextSpaceIdx + 2));
- } else {
- payload = JSON.parse(message.slice(nextSpaceIdx + 1));
- }
- cordova.callbackFromNative(callbackId, success, status, [payload], keepCallback);
- } else {
- console.log("processMessage failed: invalid message:" + message);
- }
- } catch (e) {
- console.log("processMessage failed: Message: " + message);
- console.log("processMessage failed: Error: " + e);
- console.log("processMessage failed: Stack: " + e.stack);
- }
-}
-
-// This is called from the NativeToJsMessageQueue.java.
-androidExec.processMessages = function(messages) {
- if (messages) {
- messagesFromNative.push(messages);
- // Check for the reentrant case, and enqueue the message if that's the case.
- if (messagesFromNative.length > 1) {
- return;
- }
- while (messagesFromNative.length) {
- // Don't unshift until the end so that reentrancy can be detected.
- messages = messagesFromNative[0];
- // The Java side can send a * message to indicate that it
- // still has messages waiting to be retrieved.
- if (messages == '*') {
- messagesFromNative.shift();
- window.setTimeout(pollOnce, 0);
- return;
- }
-
- var spaceIdx = messages.indexOf(' ');
- var msgLen = +messages.slice(0, spaceIdx);
- var message = messages.substr(spaceIdx + 1, msgLen);
- messages = messages.slice(spaceIdx + msgLen + 1);
- processMessage(message);
- if (messages) {
- messagesFromNative[0] = messages;
- } else {
- messagesFromNative.shift();
- }
- }
- }
-};
-
-module.exports = androidExec;
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/lib/amazon-fireos/platform.js
----------------------------------------------------------------------
diff --git a/lib/amazon-fireos/platform.js b/lib/amazon-fireos/platform.js
deleted file mode 100644
index 768b39b..0000000
--- a/lib/amazon-fireos/platform.js
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-module.exports = {
- id: 'amazon-fireos',
- bootstrap: function() {
- var channel = require('cordova/channel'),
- cordova = require('cordova'),
- exec = require('cordova/exec'),
- modulemapper = require('cordova/modulemapper');
-
- // Tell the native code that a page change has occurred.
- exec(null, null, 'PluginManager', 'startup', []);
- // Tell the JS that the native side is ready.
- channel.onNativeReady.fire();
-
- // TODO: Extract this as a proper plugin.
- modulemapper.clobbers('cordova/plugin/android/app', 'navigator.app');
-
- // Inject a listener for the backbutton on the document.
- var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
- backButtonChannel.onHasSubscribersChange = function() {
- // If we just attached the first handler or detached the last handler,
- // let native know we need to override the back button.
- exec(null, null, "App", "overrideBackbutton", [this.numHandlers == 1]);
- };
-
- // Add hardware MENU and SEARCH button handlers
- cordova.addDocumentEventHandler('menubutton');
- cordova.addDocumentEventHandler('searchbutton');
-
- // Let native code know we are all done on the JS side.
- // Native code will then un-hide the WebView.
- channel.onCordovaReady.subscribe(function() {
- exec(null, null, "App", "show", []);
- });
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/lib/amazon-fireos/plugin/android/app.js
----------------------------------------------------------------------
diff --git a/lib/amazon-fireos/plugin/android/app.js b/lib/amazon-fireos/plugin/android/app.js
deleted file mode 100644
index c2a4df5..0000000
--- a/lib/amazon-fireos/plugin/android/app.js
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var exec = require('cordova/exec');
-
-module.exports = {
- /**
- * Clear the resource cache.
- */
- clearCache:function() {
- exec(null, null, "App", "clearCache", []);
- },
-
- /**
- * Load the url into the webview or into new browser instance.
- *
- * @param url The URL to load
- * @param props Properties that can be passed in to the activity:
- * wait: int => wait msec before loading URL
- * loadingDialog: "Title,Message" => display a native loading dialog
- * loadUrlTimeoutValue: int => time in msec to wait before triggering a timeout error
- * clearHistory: boolean => clear webview history (default=false)
- * openExternal: boolean => open in a new browser (default=false)
- *
- * Example:
- * navigator.app.loadUrl("http://server/myapp/index.html", {wait:2000, loadingDialog:"Wait,Loading App", loadUrlTimeoutValue: 60000});
- */
- loadUrl:function(url, props) {
- exec(null, null, "App", "loadUrl", [url, props]);
- },
-
- /**
- * Cancel loadUrl that is waiting to be loaded.
- */
- cancelLoadUrl:function() {
- exec(null, null, "App", "cancelLoadUrl", []);
- },
-
- /**
- * Clear web history in this web view.
- * Instead of BACK button loading the previous web page, it will exit the app.
- */
- clearHistory:function() {
- exec(null, null, "App", "clearHistory", []);
- },
-
- /**
- * Go to previous page displayed.
- * This is the same as pressing the backbutton on Android device.
- */
- backHistory:function() {
- exec(null, null, "App", "backHistory", []);
- },
-
- /**
- * Override the default behavior of the Android back button.
- * If overridden, when the back button is pressed, the "backKeyDown" JavaScript event will be fired.
- *
- * Note: The user should not have to call this method. Instead, when the user
- * registers for the "backbutton" event, this is automatically done.
- *
- * @param override T=override, F=cancel override
- */
- overrideBackbutton:function(override) {
- exec(null, null, "App", "overrideBackbutton", [override]);
- },
-
- /**
- * Exit and terminate the application.
- */
- exitApp:function() {
- return exec(null, null, "App", "exitApp", []);
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/lib/android/android/nativeapiprovider.js
----------------------------------------------------------------------
diff --git a/lib/android/android/nativeapiprovider.js b/lib/android/android/nativeapiprovider.js
deleted file mode 100644
index 2e9aa67..0000000
--- a/lib/android/android/nativeapiprovider.js
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
-*/
-
-/**
- * Exports the ExposedJsApi.java object if available, otherwise exports the PromptBasedNativeApi.
- */
-
-var nativeApi = this._cordovaNative || require('cordova/android/promptbasednativeapi');
-var currentApi = nativeApi;
-
-module.exports = {
- get: function() { return currentApi; },
- setPreferPrompt: function(value) {
- currentApi = value ? require('cordova/android/promptbasednativeapi') : nativeApi;
- },
- // Used only by tests.
- set: function(value) {
- currentApi = value;
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/lib/android/android/promptbasednativeapi.js
----------------------------------------------------------------------
diff --git a/lib/android/android/promptbasednativeapi.js b/lib/android/android/promptbasednativeapi.js
deleted file mode 100644
index c12f46e..0000000
--- a/lib/android/android/promptbasednativeapi.js
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
-*/
-
-/**
- * Implements the API of ExposedJsApi.java, but uses prompt() to communicate.
- * This is used only on the 2.3 simulator, where addJavascriptInterface() is broken.
- */
-
-module.exports = {
- exec: function(service, action, callbackId, argsJson) {
- return prompt(argsJson, 'gap:'+JSON.stringify([service, action, callbackId]));
- },
- setNativeToJsBridgeMode: function(value) {
- prompt(value, 'gap_bridge_mode:');
- },
- retrieveJsMessages: function(fromOnlineEvent) {
- return prompt(+fromOnlineEvent, 'gap_poll:');
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/lib/android/exec.js
----------------------------------------------------------------------
diff --git a/lib/android/exec.js b/lib/android/exec.js
deleted file mode 100644
index 0d35ff1..0000000
--- a/lib/android/exec.js
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-/**
- * Execute a cordova command. It is up to the native side whether this action
- * is synchronous or asynchronous. The native side can return:
- * Synchronous: PluginResult object as a JSON string
- * Asynchronous: Empty string ""
- * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
- * depending upon the result of the action.
- *
- * @param {Function} success The success callback
- * @param {Function} fail The fail callback
- * @param {String} service The name of the service to use
- * @param {String} action Action to be run in cordova
- * @param {String[]} [args] Zero or more arguments to pass to the method
- */
-var cordova = require('cordova'),
- nativeApiProvider = require('cordova/android/nativeapiprovider'),
- utils = require('cordova/utils'),
- base64 = require('cordova/base64'),
- jsToNativeModes = {
- PROMPT: 0,
- JS_OBJECT: 1,
- // This mode is currently for benchmarking purposes only. It must be enabled
- // on the native side through the ENABLE_LOCATION_CHANGE_EXEC_MODE
- // constant within CordovaWebViewClient.java before it will work.
- LOCATION_CHANGE: 2
- },
- nativeToJsModes = {
- // Polls for messages using the JS->Native bridge.
- POLLING: 0,
- // For LOAD_URL to be viable, it would need to have a work-around for
- // the bug where the soft-keyboard gets dismissed when a message is sent.
- LOAD_URL: 1,
- // For the ONLINE_EVENT to be viable, it would need to intercept all event
- // listeners (both through addEventListener and window.ononline) as well
- // as set the navigator property itself.
- ONLINE_EVENT: 2,
- // Uses reflection to access private APIs of the WebView that can send JS
- // to be executed.
- // Requires Android 3.2.4 or above.
- PRIVATE_API: 3
- },
- jsToNativeBridgeMode, // Set lazily.
- nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT,
- pollEnabled = false,
- messagesFromNative = [];
-
-function androidExec(success, fail, service, action, args) {
- // Set default bridge modes if they have not already been set.
- // By default, we use the failsafe, since addJavascriptInterface breaks too often
- if (jsToNativeBridgeMode === undefined) {
- androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
- }
-
- // Process any ArrayBuffers in the args into a string.
- for (var i = 0; i < args.length; i++) {
- if (utils.typeName(args[i]) == 'ArrayBuffer') {
- args[i] = base64.fromArrayBuffer(args[i]);
- }
- }
-
- var callbackId = service + cordova.callbackId++,
- argsJson = JSON.stringify(args);
-
- if (success || fail) {
- cordova.callbacks[callbackId] = {success:success, fail:fail};
- }
-
- if (jsToNativeBridgeMode == jsToNativeModes.LOCATION_CHANGE) {
- window.location = 'http://cdv_exec/' + service + '#' + action + '#' + callbackId + '#' + argsJson;
- } else {
- var messages = nativeApiProvider.get().exec(service, action, callbackId, argsJson);
- // If argsJson was received by Java as null, try again with the PROMPT bridge mode.
- // This happens in rare circumstances, such as when certain Unicode characters are passed over the bridge on a Galaxy S2. See CB-2666.
- if (jsToNativeBridgeMode == jsToNativeModes.JS_OBJECT && messages === "@Null arguments.") {
- androidExec.setJsToNativeBridgeMode(jsToNativeModes.PROMPT);
- androidExec(success, fail, service, action, args);
- androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
- return;
- } else {
- androidExec.processMessages(messages);
- }
- }
-}
-
-function pollOnceFromOnlineEvent() {
- pollOnce(true);
-}
-
-function pollOnce(opt_fromOnlineEvent) {
- var msg = nativeApiProvider.get().retrieveJsMessages(!!opt_fromOnlineEvent);
- androidExec.processMessages(msg);
-}
-
-function pollingTimerFunc() {
- if (pollEnabled) {
- pollOnce();
- setTimeout(pollingTimerFunc, 50);
- }
-}
-
-function hookOnlineApis() {
- function proxyEvent(e) {
- cordova.fireWindowEvent(e.type);
- }
- // The network module takes care of firing online and offline events.
- // It currently fires them only on document though, so we bridge them
- // to window here (while first listening for exec()-releated online/offline
- // events).
- window.addEventListener('online', pollOnceFromOnlineEvent, false);
- window.addEventListener('offline', pollOnceFromOnlineEvent, false);
- cordova.addWindowEventHandler('online');
- cordova.addWindowEventHandler('offline');
- document.addEventListener('online', proxyEvent, false);
- document.addEventListener('offline', proxyEvent, false);
-}
-
-hookOnlineApis();
-
-androidExec.jsToNativeModes = jsToNativeModes;
-androidExec.nativeToJsModes = nativeToJsModes;
-
-androidExec.setJsToNativeBridgeMode = function(mode) {
- if (mode == jsToNativeModes.JS_OBJECT && !window._cordovaNative) {
- console.log('Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only.');
- mode = jsToNativeModes.PROMPT;
- }
- nativeApiProvider.setPreferPrompt(mode == jsToNativeModes.PROMPT);
- jsToNativeBridgeMode = mode;
-};
-
-androidExec.setNativeToJsBridgeMode = function(mode) {
- if (mode == nativeToJsBridgeMode) {
- return;
- }
- if (nativeToJsBridgeMode == nativeToJsModes.POLLING) {
- pollEnabled = false;
- }
-
- nativeToJsBridgeMode = mode;
- // Tell the native side to switch modes.
- nativeApiProvider.get().setNativeToJsBridgeMode(mode);
-
- if (mode == nativeToJsModes.POLLING) {
- pollEnabled = true;
- setTimeout(pollingTimerFunc, 1);
- }
-};
-
-// Processes a single message, as encoded by NativeToJsMessageQueue.java.
-function processMessage(message) {
- try {
- var firstChar = message.charAt(0);
- if (firstChar == 'J') {
- eval(message.slice(1));
- } else if (firstChar == 'S' || firstChar == 'F') {
- var success = firstChar == 'S';
- var keepCallback = message.charAt(1) == '1';
- var spaceIdx = message.indexOf(' ', 2);
- var status = +message.slice(2, spaceIdx);
- var nextSpaceIdx = message.indexOf(' ', spaceIdx + 1);
- var callbackId = message.slice(spaceIdx + 1, nextSpaceIdx);
- var payloadKind = message.charAt(nextSpaceIdx + 1);
- var payload;
- if (payloadKind == 's') {
- payload = message.slice(nextSpaceIdx + 2);
- } else if (payloadKind == 't') {
- payload = true;
- } else if (payloadKind == 'f') {
- payload = false;
- } else if (payloadKind == 'N') {
- payload = null;
- } else if (payloadKind == 'n') {
- payload = +message.slice(nextSpaceIdx + 2);
- } else if (payloadKind == 'A') {
- var data = message.slice(nextSpaceIdx + 2);
- var bytes = window.atob(data);
- var arraybuffer = new Uint8Array(bytes.length);
- for (var i = 0; i < bytes.length; i++) {
- arraybuffer[i] = bytes.charCodeAt(i);
- }
- payload = arraybuffer.buffer;
- } else if (payloadKind == 'S') {
- payload = window.atob(message.slice(nextSpaceIdx + 2));
- } else {
- payload = JSON.parse(message.slice(nextSpaceIdx + 1));
- }
- cordova.callbackFromNative(callbackId, success, status, [payload], keepCallback);
- } else {
- console.log("processMessage failed: invalid message:" + message);
- }
- } catch (e) {
- console.log("processMessage failed: Message: " + message);
- console.log("processMessage failed: Error: " + e);
- console.log("processMessage failed: Stack: " + e.stack);
- }
-}
-
-// This is called from the NativeToJsMessageQueue.java.
-androidExec.processMessages = function(messages) {
- if (messages) {
- messagesFromNative.push(messages);
- // Check for the reentrant case, and enqueue the message if that's the case.
- if (messagesFromNative.length > 1) {
- return;
- }
- while (messagesFromNative.length) {
- // Don't unshift until the end so that reentrancy can be detected.
- messages = messagesFromNative[0];
- // The Java side can send a * message to indicate that it
- // still has messages waiting to be retrieved.
- if (messages == '*') {
- messagesFromNative.shift();
- window.setTimeout(pollOnce, 0);
- return;
- }
-
- var spaceIdx = messages.indexOf(' ');
- var msgLen = +messages.slice(0, spaceIdx);
- var message = messages.substr(spaceIdx + 1, msgLen);
- messages = messages.slice(spaceIdx + msgLen + 1);
- processMessage(message);
- if (messages) {
- messagesFromNative[0] = messages;
- } else {
- messagesFromNative.shift();
- }
- }
- }
-};
-
-module.exports = androidExec;
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/lib/android/platform.js
----------------------------------------------------------------------
diff --git a/lib/android/platform.js b/lib/android/platform.js
deleted file mode 100644
index bf966c0..0000000
--- a/lib/android/platform.js
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-module.exports = {
- id: 'android',
- bootstrap: function() {
- var channel = require('cordova/channel'),
- cordova = require('cordova'),
- exec = require('cordova/exec'),
- modulemapper = require('cordova/modulemapper');
-
- // Tell the native code that a page change has occurred.
- exec(null, null, 'PluginManager', 'startup', []);
- // Tell the JS that the native side is ready.
- channel.onNativeReady.fire();
-
- // TODO: Extract this as a proper plugin.
- modulemapper.clobbers('cordova/plugin/android/app', 'navigator.app');
-
- // Inject a listener for the backbutton on the document.
- var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
- backButtonChannel.onHasSubscribersChange = function() {
- // If we just attached the first handler or detached the last handler,
- // let native know we need to override the back button.
- exec(null, null, "App", "overrideBackbutton", [this.numHandlers == 1]);
- };
-
- // Add hardware MENU and SEARCH button handlers
- cordova.addDocumentEventHandler('menubutton');
- cordova.addDocumentEventHandler('searchbutton');
-
- // Let native code know we are all done on the JS side.
- // Native code will then un-hide the WebView.
- channel.onCordovaReady.subscribe(function() {
- exec(null, null, "App", "show", []);
- });
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/lib/android/plugin/android/app.js
----------------------------------------------------------------------
diff --git a/lib/android/plugin/android/app.js b/lib/android/plugin/android/app.js
deleted file mode 100644
index c2a4df5..0000000
--- a/lib/android/plugin/android/app.js
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var exec = require('cordova/exec');
-
-module.exports = {
- /**
- * Clear the resource cache.
- */
- clearCache:function() {
- exec(null, null, "App", "clearCache", []);
- },
-
- /**
- * Load the url into the webview or into new browser instance.
- *
- * @param url The URL to load
- * @param props Properties that can be passed in to the activity:
- * wait: int => wait msec before loading URL
- * loadingDialog: "Title,Message" => display a native loading dialog
- * loadUrlTimeoutValue: int => time in msec to wait before triggering a timeout error
- * clearHistory: boolean => clear webview history (default=false)
- * openExternal: boolean => open in a new browser (default=false)
- *
- * Example:
- * navigator.app.loadUrl("http://server/myapp/index.html", {wait:2000, loadingDialog:"Wait,Loading App", loadUrlTimeoutValue: 60000});
- */
- loadUrl:function(url, props) {
- exec(null, null, "App", "loadUrl", [url, props]);
- },
-
- /**
- * Cancel loadUrl that is waiting to be loaded.
- */
- cancelLoadUrl:function() {
- exec(null, null, "App", "cancelLoadUrl", []);
- },
-
- /**
- * Clear web history in this web view.
- * Instead of BACK button loading the previous web page, it will exit the app.
- */
- clearHistory:function() {
- exec(null, null, "App", "clearHistory", []);
- },
-
- /**
- * Go to previous page displayed.
- * This is the same as pressing the backbutton on Android device.
- */
- backHistory:function() {
- exec(null, null, "App", "backHistory", []);
- },
-
- /**
- * Override the default behavior of the Android back button.
- * If overridden, when the back button is pressed, the "backKeyDown" JavaScript event will be fired.
- *
- * Note: The user should not have to call this method. Instead, when the user
- * registers for the "backbutton" event, this is automatically done.
- *
- * @param override T=override, F=cancel override
- */
- overrideBackbutton:function(override) {
- exec(null, null, "App", "overrideBackbutton", [override]);
- },
-
- /**
- * Exit and terminate the application.
- */
- exitApp:function() {
- return exec(null, null, "App", "exitApp", []);
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/lib/blackberry10/exec.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/exec.js b/lib/blackberry10/exec.js
deleted file mode 100644
index 6e896f4..0000000
--- a/lib/blackberry10/exec.js
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var cordova = require('cordova'),
- execProxy = require('cordova/exec/proxy');
-
-function RemoteFunctionCall(functionUri) {
- var params = {};
-
- function composeUri() {
- return "http://localhost:8472/" + functionUri;
- }
-
- function createXhrRequest(uri, isAsync) {
- var request = new XMLHttpRequest();
- request.open("POST", uri, isAsync);
- request.setRequestHeader("Content-Type", "application/json");
- return request;
- }
-
- this.addParam = function (name, value) {
- params[name] = encodeURIComponent(JSON.stringify(value));
- };
-
- this.makeSyncCall = function () {
- var requestUri = composeUri(),
- request = createXhrRequest(requestUri, false),
- response;
- request.send(JSON.stringify(params));
- response = JSON.parse(decodeURIComponent(request.responseText) || "null");
- return response;
- };
-
-}
-
-module.exports = function (success, fail, service, action, args) {
- var uri = service + "/" + action,
- request = new RemoteFunctionCall(uri),
- callbackId = service + cordova.callbackId++,
- proxy,
- response,
- name,
- didSucceed;
-
- cordova.callbacks[callbackId] = {
- success: success,
- fail: fail
- };
-
- proxy = execProxy.get(service, action);
-
- if (proxy) {
- proxy(success, fail, args);
- }
-
- else {
-
- request.addParam("callbackId", callbackId);
-
- for (name in args) {
- if (Object.hasOwnProperty.call(args, name)) {
- request.addParam(name, args[name]);
- }
- }
-
- response = request.makeSyncCall();
-
- if (response.code < 0) {
- if (fail) {
- fail(response.msg, response);
- }
- delete cordova.callbacks[callbackId];
- } else {
- didSucceed = response.code === cordova.callbackStatus.OK || response.code === cordova.callbackStatus.NO_RESULT;
- cordova.callbackFromNative(
- callbackId,
- didSucceed,
- response.code,
- [ didSucceed ? response.data : response.msg ],
- !!response.keepCallback
- );
- }
- }
-
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/lib/blackberry10/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/platform.js b/lib/blackberry10/platform.js
deleted file mode 100644
index 9fcbda0..0000000
--- a/lib/blackberry10/platform.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-module.exports = {
-
- id: "blackberry10",
-
- bootstrap: function() {
-
- var channel = require('cordova/channel'),
- addEventListener = document.addEventListener;
-
- //ready as soon as the plugins are
- channel.onPluginsReady.subscribe(function () {
- channel.onNativeReady.fire();
- });
-
- //pass document online/offline event listeners to window
- document.addEventListener = function (type) {
- if (type === "online" || type === "offline") {
- window.addEventListener.apply(window, arguments);
- } else {
- addEventListener.apply(document, arguments);
- }
- };
-
- //map blackberry.event to document
- if (!window.blackberry) {
- window.blackberry = {};
- }
- window.blackberry.event =
- {
- addEventListener: document.addEventListener,
- removeEventListener: document.removeEventListener
- };
-
- }
-
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/lib/blackberry10/plugin/.gitkeep
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/.gitkeep b/lib/blackberry10/plugin/.gitkeep
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/lib/browser/exec.js
----------------------------------------------------------------------
diff --git a/lib/browser/exec.js b/lib/browser/exec.js
deleted file mode 100644
index 130edb9..0000000
--- a/lib/browser/exec.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var cordova = require('cordova');
-var execProxy = require('cordova/exec/proxy');
-
-module.exports = function(success, fail, service, action, args) {
-
- var proxy = execProxy.get(service, action);
-
- if (proxy) {
- var callbackId = service + cordova.callbackId++;
-
- if (typeof success == "function" || typeof fail == "function") {
- cordova.callbacks[callbackId] = {success:success, fail:fail};
- }
-
- try {
- proxy(success, fail, args);
- }
- catch(e) {
- // TODO throw maybe?
- var msg = "Exception calling :: " + service + " :: " + action + " ::exception=" + e;
- console.log(msg);
- }
- }
- else {
- fail && fail("Missing Command Error");
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/lib/browser/platform.js
----------------------------------------------------------------------
diff --git a/lib/browser/platform.js b/lib/browser/platform.js
deleted file mode 100644
index fb30eea..0000000
--- a/lib/browser/platform.js
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-module.exports = {
- id: 'browser',
- cordovaVersion: '3.4.0',
-
- bootstrap: function() {
-
- var moduleMapper = require('cordova/modulemapper');
- var channel = require('cordova/channel');
-
- moduleMapper.clobbers('cordova/exec/proxy', 'cordova.commandProxy');
-
- channel.onPluginsReady.subscribe(function () {
- channel.onNativeReady.fire();
- });
-
- // FIXME is this the right place to clobber pause/resume? I am guessing not
- // FIXME pause/resume should be deprecated IN CORDOVA for pagevisiblity api
- document.addEventListener('webkitvisibilitychange', function() {
- if (document.webkitHidden) {
- channel.onPause.fire();
- }
- else {
- channel.onResume.fire();
- }
- }, false);
-
- // End of bootstrap
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d9a3dced/lib/common/argscheck.js
----------------------------------------------------------------------
diff --git a/lib/common/argscheck.js b/lib/common/argscheck.js
deleted file mode 100644
index 104739a..0000000
--- a/lib/common/argscheck.js
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var exec = require('cordova/exec');
-var utils = require('cordova/utils');
-
-var moduleExports = module.exports;
-
-var typeMap = {
- 'A': 'Array',
- 'D': 'Date',
- 'N': 'Number',
- 'S': 'String',
- 'F': 'Function',
- 'O': 'Object'
-};
-
-function extractParamName(callee, argIndex) {
- return (/.*?\((.*?)\)/).exec(callee)[1].split(', ')[argIndex];
-}
-
-function checkArgs(spec, functionName, args, opt_callee) {
- if (!moduleExports.enableChecks) {
- return;
- }
- var errMsg = null;
- var typeName;
- for (var i = 0; i < spec.length; ++i) {
- var c = spec.charAt(i),
- cUpper = c.toUpperCase(),
- arg = args[i];
- // Asterix means allow anything.
- if (c == '*') {
- continue;
- }
- typeName = utils.typeName(arg);
- if ((arg === null || arg === undefined) && c == cUpper) {
- continue;
- }
- if (typeName != typeMap[cUpper]) {
- errMsg = 'Expected ' + typeMap[cUpper];
- break;
- }
- }
- if (errMsg) {
- errMsg += ', but got ' + typeName + '.';
- errMsg = 'Wrong type for parameter "' + extractParamName(opt_callee || args.callee, i) + '" of ' + functionName + ': ' + errMsg;
- // Don't log when running unit tests.
- if (typeof jasmine == 'undefined') {
- console.error(errMsg);
- }
- throw TypeError(errMsg);
- }
-}
-
-function getValue(value, defaultValue) {
- return value === undefined ? defaultValue : value;
-}
-
-moduleExports.checkArgs = checkArgs;
-moduleExports.getValue = getValue;
-moduleExports.enableChecks = true;
-