You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/09/19 00:49:41 UTC
[06/27] moving stuff around
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/node_modules/shelljs/src/ls.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/node_modules/shelljs/src/ls.js b/wp8/template/cordova/node_modules/shelljs/src/ls.js
deleted file mode 100644
index 3345db4..0000000
--- a/wp8/template/cordova/node_modules/shelljs/src/ls.js
+++ /dev/null
@@ -1,126 +0,0 @@
-var path = require('path');
-var fs = require('fs');
-var common = require('./common');
-var _cd = require('./cd');
-var _pwd = require('./pwd');
-
-//@
-//@ ### ls([options ,] path [,path ...])
-//@ ### ls([options ,] path_array)
-//@ Available options:
-//@
-//@ + `-R`: recursive
-//@ + `-A`: all files (include files beginning with `.`, except for `.` and `..`)
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ ls('projs/*.js');
-//@ ls('-R', '/users/me', '/tmp');
-//@ ls('-R', ['/users/me', '/tmp']); // same as above
-//@ ```
-//@
-//@ Returns array of files in the given path, or in current directory if no path provided.
-function _ls(options, paths) {
- options = common.parseOptions(options, {
- 'R': 'recursive',
- 'A': 'all',
- 'a': 'all_deprecated'
- });
-
- if (options.all_deprecated) {
- // We won't support the -a option as it's hard to image why it's useful
- // (it includes '.' and '..' in addition to '.*' files)
- // For backwards compatibility we'll dump a deprecated message and proceed as before
- common.log('ls: Option -a is deprecated. Use -A instead');
- options.all = true;
- }
-
- if (!paths)
- paths = ['.'];
- else if (typeof paths === 'object')
- paths = paths; // assume array
- else if (typeof paths === 'string')
- paths = [].slice.call(arguments, 1);
-
- var list = [];
-
- // Conditionally pushes file to list - returns true if pushed, false otherwise
- // (e.g. prevents hidden files to be included unless explicitly told so)
- function pushFile(file, query) {
- // hidden file?
- if (path.basename(file)[0] === '.') {
- // not explicitly asking for hidden files?
- if (!options.all && !(path.basename(query)[0] === '.' && path.basename(query).length > 1))
- return false;
- }
-
- if (common.platform === 'win')
- file = file.replace(/\\/g, '/');
-
- list.push(file);
- return true;
- }
-
- paths.forEach(function(p) {
- if (fs.existsSync(p)) {
- var stats = fs.statSync(p);
- // Simple file?
- if (stats.isFile()) {
- pushFile(p, p);
- return; // continue
- }
-
- // Simple dir?
- if (stats.isDirectory()) {
- // Iterate over p contents
- fs.readdirSync(p).forEach(function(file) {
- if (!pushFile(file, p))
- return;
-
- // Recursive?
- if (options.recursive) {
- var oldDir = _pwd();
- _cd('', p);
- if (fs.statSync(file).isDirectory())
- list = list.concat(_ls('-R'+(options.all?'A':''), file+'/*'));
- _cd('', oldDir);
- }
- });
- return; // continue
- }
- }
-
- // p does not exist - possible wildcard present
-
- var basename = path.basename(p);
- var dirname = path.dirname(p);
- // Wildcard present on an existing dir? (e.g. '/tmp/*.js')
- if (basename.search(/\*/) > -1 && fs.existsSync(dirname) && fs.statSync(dirname).isDirectory) {
- // Escape special regular expression chars
- var regexp = basename.replace(/(\^|\$|\(|\)|<|>|\[|\]|\{|\}|\.|\+|\?)/g, '\\$1');
- // Translates wildcard into regex
- regexp = '^' + regexp.replace(/\*/g, '.*') + '$';
- // Iterate over directory contents
- fs.readdirSync(dirname).forEach(function(file) {
- if (file.match(new RegExp(regexp))) {
- if (!pushFile(path.normalize(dirname+'/'+file), basename))
- return;
-
- // Recursive?
- if (options.recursive) {
- var pp = dirname + '/' + file;
- if (fs.lstatSync(pp).isDirectory())
- list = list.concat(_ls('-R'+(options.all?'A':''), pp+'/*'));
- } // recursive
- } // if file matches
- }); // forEach
- return;
- }
-
- common.error('no such file or directory: ' + p, true);
- });
-
- return list;
-}
-module.exports = _ls;
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/node_modules/shelljs/src/mkdir.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/node_modules/shelljs/src/mkdir.js b/wp8/template/cordova/node_modules/shelljs/src/mkdir.js
deleted file mode 100644
index 5a7088f..0000000
--- a/wp8/template/cordova/node_modules/shelljs/src/mkdir.js
+++ /dev/null
@@ -1,68 +0,0 @@
-var common = require('./common');
-var fs = require('fs');
-var path = require('path');
-
-// Recursively creates 'dir'
-function mkdirSyncRecursive(dir) {
- var baseDir = path.dirname(dir);
-
- // Base dir exists, no recursion necessary
- if (fs.existsSync(baseDir)) {
- fs.mkdirSync(dir, parseInt('0777', 8));
- return;
- }
-
- // Base dir does not exist, go recursive
- mkdirSyncRecursive(baseDir);
-
- // Base dir created, can create dir
- fs.mkdirSync(dir, parseInt('0777', 8));
-}
-
-//@
-//@ ### mkdir([options ,] dir [, dir ...])
-//@ ### mkdir([options ,] dir_array)
-//@ Available options:
-//@
-//@ + `p`: full path (will create intermediate dirs if necessary)
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ mkdir('-p', '/tmp/a/b/c/d', '/tmp/e/f/g');
-//@ mkdir('-p', ['/tmp/a/b/c/d', '/tmp/e/f/g']); // same as above
-//@ ```
-//@
-//@ Creates directories.
-function _mkdir(options, dirs) {
- options = common.parseOptions(options, {
- 'p': 'fullpath'
- });
- if (!dirs)
- common.error('no paths given');
-
- if (typeof dirs === 'string')
- dirs = [].slice.call(arguments, 1);
- // if it's array leave it as it is
-
- dirs.forEach(function(dir) {
- if (fs.existsSync(dir)) {
- if (!options.fullpath)
- common.error('path already exists: ' + dir, true);
- return; // skip dir
- }
-
- // Base dir does not exist, and no -p option given
- var baseDir = path.dirname(dir);
- if (!fs.existsSync(baseDir) && !options.fullpath) {
- common.error('no such file or directory: ' + baseDir, true);
- return; // skip dir
- }
-
- if (options.fullpath)
- mkdirSyncRecursive(dir);
- else
- fs.mkdirSync(dir, parseInt('0777', 8));
- });
-} // mkdir
-module.exports = _mkdir;
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/node_modules/shelljs/src/mv.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/node_modules/shelljs/src/mv.js b/wp8/template/cordova/node_modules/shelljs/src/mv.js
deleted file mode 100644
index 11f9607..0000000
--- a/wp8/template/cordova/node_modules/shelljs/src/mv.js
+++ /dev/null
@@ -1,80 +0,0 @@
-var fs = require('fs');
-var path = require('path');
-var common = require('./common');
-
-//@
-//@ ### mv(source [, source ...], dest')
-//@ ### mv(source_array, dest')
-//@ Available options:
-//@
-//@ + `f`: force
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ mv('-f', 'file', 'dir/');
-//@ mv('file1', 'file2', 'dir/');
-//@ mv(['file1', 'file2'], 'dir/'); // same as above
-//@ ```
-//@
-//@ Moves files. The wildcard `*` is accepted.
-function _mv(options, sources, dest) {
- options = common.parseOptions(options, {
- 'f': 'force'
- });
-
- // Get sources, dest
- if (arguments.length < 3) {
- common.error('missing <source> and/or <dest>');
- } else if (arguments.length > 3) {
- sources = [].slice.call(arguments, 1, arguments.length - 1);
- dest = arguments[arguments.length - 1];
- } else if (typeof sources === 'string') {
- sources = [sources];
- } else if ('length' in sources) {
- sources = sources; // no-op for array
- } else {
- common.error('invalid arguments');
- }
-
- sources = common.expand(sources);
-
- var exists = fs.existsSync(dest),
- stats = exists && fs.statSync(dest);
-
- // Dest is not existing dir, but multiple sources given
- if ((!exists || !stats.isDirectory()) && sources.length > 1)
- common.error('dest is not a directory (too many sources)');
-
- // Dest is an existing file, but no -f given
- if (exists && stats.isFile() && !options.force)
- common.error('dest file already exists: ' + dest);
-
- sources.forEach(function(src) {
- if (!fs.existsSync(src)) {
- common.error('no such file or directory: '+src, true);
- return; // skip file
- }
-
- // If here, src exists
-
- // When copying to '/path/dir':
- // thisDest = '/path/dir/file1'
- var thisDest = dest;
- if (fs.existsSync(dest) && fs.statSync(dest).isDirectory())
- thisDest = path.normalize(dest + '/' + path.basename(src));
-
- if (fs.existsSync(thisDest) && !options.force) {
- common.error('dest file already exists: ' + thisDest, true);
- return; // skip file
- }
-
- if (path.resolve(src) === path.dirname(path.resolve(thisDest))) {
- common.error('cannot move to self: '+src, true);
- return; // skip file
- }
-
- fs.renameSync(src, thisDest);
- }); // forEach(src)
-} // mv
-module.exports = _mv;
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/node_modules/shelljs/src/popd.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/node_modules/shelljs/src/popd.js b/wp8/template/cordova/node_modules/shelljs/src/popd.js
deleted file mode 100644
index 11ea24f..0000000
--- a/wp8/template/cordova/node_modules/shelljs/src/popd.js
+++ /dev/null
@@ -1 +0,0 @@
-// see dirs.js
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/node_modules/shelljs/src/pushd.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/node_modules/shelljs/src/pushd.js b/wp8/template/cordova/node_modules/shelljs/src/pushd.js
deleted file mode 100644
index 11ea24f..0000000
--- a/wp8/template/cordova/node_modules/shelljs/src/pushd.js
+++ /dev/null
@@ -1 +0,0 @@
-// see dirs.js
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/node_modules/shelljs/src/pwd.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/node_modules/shelljs/src/pwd.js b/wp8/template/cordova/node_modules/shelljs/src/pwd.js
deleted file mode 100644
index 41727bb..0000000
--- a/wp8/template/cordova/node_modules/shelljs/src/pwd.js
+++ /dev/null
@@ -1,11 +0,0 @@
-var path = require('path');
-var common = require('./common');
-
-//@
-//@ ### pwd()
-//@ Returns the current directory.
-function _pwd(options) {
- var pwd = path.resolve(process.cwd());
- return common.ShellString(pwd);
-}
-module.exports = _pwd;
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/node_modules/shelljs/src/rm.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/node_modules/shelljs/src/rm.js b/wp8/template/cordova/node_modules/shelljs/src/rm.js
deleted file mode 100644
index 3abe6e1..0000000
--- a/wp8/template/cordova/node_modules/shelljs/src/rm.js
+++ /dev/null
@@ -1,145 +0,0 @@
-var common = require('./common');
-var fs = require('fs');
-
-// Recursively removes 'dir'
-// Adapted from https://github.com/ryanmcgrath/wrench-js
-//
-// Copyright (c) 2010 Ryan McGrath
-// Copyright (c) 2012 Artur Adib
-//
-// Licensed under the MIT License
-// http://www.opensource.org/licenses/mit-license.php
-function rmdirSyncRecursive(dir, force) {
- var files;
-
- files = fs.readdirSync(dir);
-
- // Loop through and delete everything in the sub-tree after checking it
- for(var i = 0; i < files.length; i++) {
- var file = dir + "/" + files[i],
- currFile = fs.lstatSync(file);
-
- if(currFile.isDirectory()) { // Recursive function back to the beginning
- rmdirSyncRecursive(file, force);
- }
-
- else if(currFile.isSymbolicLink()) { // Unlink symlinks
- if (force || isWriteable(file)) {
- try {
- common.unlinkSync(file);
- } catch (e) {
- common.error('could not remove file (code '+e.code+'): ' + file, true);
- }
- }
- }
-
- else // Assume it's a file - perhaps a try/catch belongs here?
- if (force || isWriteable(file)) {
- try {
- common.unlinkSync(file);
- } catch (e) {
- common.error('could not remove file (code '+e.code+'): ' + file, true);
- }
- }
- }
-
- // Now that we know everything in the sub-tree has been deleted, we can delete the main directory.
- // Huzzah for the shopkeep.
-
- var result;
- try {
- result = fs.rmdirSync(dir);
- } catch(e) {
- common.error('could not remove directory (code '+e.code+'): ' + dir, true);
- }
-
- return result;
-} // rmdirSyncRecursive
-
-// Hack to determine if file has write permissions for current user
-// Avoids having to check user, group, etc, but it's probably slow
-function isWriteable(file) {
- var writePermission = true;
- try {
- var __fd = fs.openSync(file, 'a');
- fs.closeSync(__fd);
- } catch(e) {
- writePermission = false;
- }
-
- return writePermission;
-}
-
-//@
-//@ ### rm([options ,] file [, file ...])
-//@ ### rm([options ,] file_array)
-//@ Available options:
-//@
-//@ + `-f`: force
-//@ + `-r, -R`: recursive
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ rm('-rf', '/tmp/*');
-//@ rm('some_file.txt', 'another_file.txt');
-//@ rm(['some_file.txt', 'another_file.txt']); // same as above
-//@ ```
-//@
-//@ Removes files. The wildcard `*` is accepted.
-function _rm(options, files) {
- options = common.parseOptions(options, {
- 'f': 'force',
- 'r': 'recursive',
- 'R': 'recursive'
- });
- if (!files)
- common.error('no paths given');
-
- if (typeof files === 'string')
- files = [].slice.call(arguments, 1);
- // if it's array leave it as it is
-
- files = common.expand(files);
-
- files.forEach(function(file) {
- if (!fs.existsSync(file)) {
- // Path does not exist, no force flag given
- if (!options.force)
- common.error('no such file or directory: '+file, true);
-
- return; // skip file
- }
-
- // If here, path exists
-
- var stats = fs.lstatSync(file);
- if (stats.isFile() || stats.isSymbolicLink()) {
-
- // Do not check for file writing permissions
- if (options.force) {
- common.unlinkSync(file);
- return;
- }
-
- if (isWriteable(file))
- common.unlinkSync(file);
- else
- common.error('permission denied: '+file, true);
-
- return;
- } // simple file
-
- // Path is an existing directory, but no -r flag given
- if (stats.isDirectory() && !options.recursive) {
- common.error('path is a directory', true);
- return; // skip path
- }
-
- // Recursively remove existing directory
- if (stats.isDirectory() && options.recursive) {
- rmdirSyncRecursive(file, options.force);
- }
- }); // forEach(file)
-} // rm
-module.exports = _rm;
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/node_modules/shelljs/src/sed.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/node_modules/shelljs/src/sed.js b/wp8/template/cordova/node_modules/shelljs/src/sed.js
deleted file mode 100644
index 65f7cb4..0000000
--- a/wp8/template/cordova/node_modules/shelljs/src/sed.js
+++ /dev/null
@@ -1,43 +0,0 @@
-var common = require('./common');
-var fs = require('fs');
-
-//@
-//@ ### sed([options ,] search_regex, replacement, file)
-//@ Available options:
-//@
-//@ + `-i`: Replace contents of 'file' in-place. _Note that no backups will be created!_
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ sed('-i', 'PROGRAM_VERSION', 'v0.1.3', 'source.js');
-//@ sed(/.*DELETE_THIS_LINE.*\n/, '', 'source.js');
-//@ ```
-//@
-//@ Reads an input string from `file` and performs a JavaScript `replace()` on the input
-//@ using the given search regex and replacement string or function. Returns the new string after replacement.
-function _sed(options, regex, replacement, file) {
- options = common.parseOptions(options, {
- 'i': 'inplace'
- });
-
- if (typeof replacement === 'string' || typeof replacement === 'function')
- replacement = replacement; // no-op
- else if (typeof replacement === 'number')
- replacement = replacement.toString(); // fallback
- else
- common.error('invalid replacement string');
-
- if (!file)
- common.error('no file given');
-
- if (!fs.existsSync(file))
- common.error('no such file or directory: ' + file);
-
- var result = fs.readFileSync(file, 'utf8').replace(regex, replacement);
- if (options.inplace)
- fs.writeFileSync(file, result, 'utf8');
-
- return common.ShellString(result);
-}
-module.exports = _sed;
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/node_modules/shelljs/src/tempdir.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/node_modules/shelljs/src/tempdir.js b/wp8/template/cordova/node_modules/shelljs/src/tempdir.js
deleted file mode 100644
index 45953c2..0000000
--- a/wp8/template/cordova/node_modules/shelljs/src/tempdir.js
+++ /dev/null
@@ -1,56 +0,0 @@
-var common = require('./common');
-var os = require('os');
-var fs = require('fs');
-
-// Returns false if 'dir' is not a writeable directory, 'dir' otherwise
-function writeableDir(dir) {
- if (!dir || !fs.existsSync(dir))
- return false;
-
- if (!fs.statSync(dir).isDirectory())
- return false;
-
- var testFile = dir+'/'+common.randomFileName();
- try {
- fs.writeFileSync(testFile, ' ');
- common.unlinkSync(testFile);
- return dir;
- } catch (e) {
- return false;
- }
-}
-
-
-//@
-//@ ### tempdir()
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ var tmp = tempdir(); // "/tmp" for most *nix platforms
-//@ ```
-//@
-//@ Searches and returns string containing a writeable, platform-dependent temporary directory.
-//@ Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir).
-function _tempDir() {
- var state = common.state;
- if (state.tempDir)
- return state.tempDir; // from cache
-
- state.tempDir = writeableDir(os.tempDir && os.tempDir()) || // node 0.8+
- writeableDir(process.env['TMPDIR']) ||
- writeableDir(process.env['TEMP']) ||
- writeableDir(process.env['TMP']) ||
- writeableDir(process.env['Wimp$ScrapDir']) || // RiscOS
- writeableDir('C:\\TEMP') || // Windows
- writeableDir('C:\\TMP') || // Windows
- writeableDir('\\TEMP') || // Windows
- writeableDir('\\TMP') || // Windows
- writeableDir('/tmp') ||
- writeableDir('/var/tmp') ||
- writeableDir('/usr/tmp') ||
- writeableDir('.'); // last resort
-
- return state.tempDir;
-}
-module.exports = _tempDir;
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/node_modules/shelljs/src/test.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/node_modules/shelljs/src/test.js b/wp8/template/cordova/node_modules/shelljs/src/test.js
deleted file mode 100644
index 8a4ac7d..0000000
--- a/wp8/template/cordova/node_modules/shelljs/src/test.js
+++ /dev/null
@@ -1,85 +0,0 @@
-var common = require('./common');
-var fs = require('fs');
-
-//@
-//@ ### test(expression)
-//@ Available expression primaries:
-//@
-//@ + `'-b', 'path'`: true if path is a block device
-//@ + `'-c', 'path'`: true if path is a character device
-//@ + `'-d', 'path'`: true if path is a directory
-//@ + `'-e', 'path'`: true if path exists
-//@ + `'-f', 'path'`: true if path is a regular file
-//@ + `'-L', 'path'`: true if path is a symboilc link
-//@ + `'-p', 'path'`: true if path is a pipe (FIFO)
-//@ + `'-S', 'path'`: true if path is a socket
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ if (test('-d', path)) { /* do something with dir */ };
-//@ if (!test('-f', path)) continue; // skip if it's a regular file
-//@ ```
-//@
-//@ Evaluates expression using the available primaries and returns corresponding value.
-function _test(options, path) {
- if (!path)
- common.error('no path given');
-
- // hack - only works with unary primaries
- options = common.parseOptions(options, {
- 'b': 'block',
- 'c': 'character',
- 'd': 'directory',
- 'e': 'exists',
- 'f': 'file',
- 'L': 'link',
- 'p': 'pipe',
- 'S': 'socket'
- });
-
- var canInterpret = false;
- for (var key in options)
- if (options[key] === true) {
- canInterpret = true;
- break;
- }
-
- if (!canInterpret)
- common.error('could not interpret expression');
-
- if (options.link) {
- try {
- return fs.lstatSync(path).isSymbolicLink();
- } catch(e) {
- return false;
- }
- }
-
- if (!fs.existsSync(path))
- return false;
-
- if (options.exists)
- return true;
-
- var stats = fs.statSync(path);
-
- if (options.block)
- return stats.isBlockDevice();
-
- if (options.character)
- return stats.isCharacterDevice();
-
- if (options.directory)
- return stats.isDirectory();
-
- if (options.file)
- return stats.isFile();
-
- if (options.pipe)
- return stats.isFIFO();
-
- if (options.socket)
- return stats.isSocket();
-} // test
-module.exports = _test;
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/node_modules/shelljs/src/to.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/node_modules/shelljs/src/to.js b/wp8/template/cordova/node_modules/shelljs/src/to.js
deleted file mode 100644
index f029999..0000000
--- a/wp8/template/cordova/node_modules/shelljs/src/to.js
+++ /dev/null
@@ -1,29 +0,0 @@
-var common = require('./common');
-var fs = require('fs');
-var path = require('path');
-
-//@
-//@ ### 'string'.to(file)
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ cat('input.txt').to('output.txt');
-//@ ```
-//@
-//@ Analogous to the redirection operator `>` in Unix, but works with JavaScript strings (such as
-//@ those returned by `cat`, `grep`, etc). _Like Unix redirections, `to()` will overwrite any existing file!_
-function _to(options, file) {
- if (!file)
- common.error('wrong arguments');
-
- if (!fs.existsSync( path.dirname(file) ))
- common.error('no such file or directory: ' + path.dirname(file));
-
- try {
- fs.writeFileSync(file, this.toString(), 'utf8');
- } catch(e) {
- common.error('could not write to file (code '+e.code+'): '+file, true);
- }
-}
-module.exports = _to;
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/node_modules/shelljs/src/toEnd.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/node_modules/shelljs/src/toEnd.js b/wp8/template/cordova/node_modules/shelljs/src/toEnd.js
deleted file mode 100644
index f6d099d..0000000
--- a/wp8/template/cordova/node_modules/shelljs/src/toEnd.js
+++ /dev/null
@@ -1,29 +0,0 @@
-var common = require('./common');
-var fs = require('fs');
-var path = require('path');
-
-//@
-//@ ### 'string'.toEnd(file)
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ cat('input.txt').toEnd('output.txt');
-//@ ```
-//@
-//@ Analogous to the redirect-and-append operator `>>` in Unix, but works with JavaScript strings (such as
-//@ those returned by `cat`, `grep`, etc).
-function _toEnd(options, file) {
- if (!file)
- common.error('wrong arguments');
-
- if (!fs.existsSync( path.dirname(file) ))
- common.error('no such file or directory: ' + path.dirname(file));
-
- try {
- fs.appendFileSync(file, this.toString(), 'utf8');
- } catch(e) {
- common.error('could not append to file (code '+e.code+'): '+file, true);
- }
-}
-module.exports = _toEnd;
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/node_modules/shelljs/src/which.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/node_modules/shelljs/src/which.js b/wp8/template/cordova/node_modules/shelljs/src/which.js
deleted file mode 100644
index 2822ecf..0000000
--- a/wp8/template/cordova/node_modules/shelljs/src/which.js
+++ /dev/null
@@ -1,83 +0,0 @@
-var common = require('./common');
-var fs = require('fs');
-var path = require('path');
-
-// Cross-platform method for splitting environment PATH variables
-function splitPath(p) {
- for (i=1;i<2;i++) {}
-
- if (!p)
- return [];
-
- if (common.platform === 'win')
- return p.split(';');
- else
- return p.split(':');
-}
-
-function checkPath(path) {
- return fs.existsSync(path) && fs.statSync(path).isDirectory() == false;
-}
-
-//@
-//@ ### which(command)
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ var nodeExec = which('node');
-//@ ```
-//@
-//@ Searches for `command` in the system's PATH. On Windows looks for `.exe`, `.cmd`, and `.bat` extensions.
-//@ Returns string containing the absolute path to the command.
-function _which(options, cmd) {
- if (!cmd)
- common.error('must specify command');
-
- var pathEnv = process.env.path || process.env.Path || process.env.PATH,
- pathArray = splitPath(pathEnv),
- where = null;
-
- // No relative/absolute paths provided?
- if (cmd.search(/\//) === -1) {
- // Search for command in PATH
- pathArray.forEach(function(dir) {
- if (where)
- return; // already found it
-
- var attempt = path.resolve(dir + '/' + cmd);
- if (checkPath(attempt)) {
- where = attempt;
- return;
- }
-
- if (common.platform === 'win') {
- var baseAttempt = attempt;
- attempt = baseAttempt + '.exe';
- if (checkPath(attempt)) {
- where = attempt;
- return;
- }
- attempt = baseAttempt + '.cmd';
- if (checkPath(attempt)) {
- where = attempt;
- return;
- }
- attempt = baseAttempt + '.bat';
- if (checkPath(attempt)) {
- where = attempt;
- return;
- }
- } // if 'win'
- });
- }
-
- // Command not found anywhere?
- if (!checkPath(cmd) && !where)
- return null;
-
- where = where || path.resolve(cmd);
-
- return common.ShellString(where);
-}
-module.exports = _which;
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/run
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/run b/wp8/template/cordova/run
deleted file mode 100644
index 48c77d5..0000000
--- a/wp8/template/cordova/run
+++ /dev/null
@@ -1,34 +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.
-*/
-
-var args = process.argv,
- run = require('./lib/run');
-
-// Handle help flag
-if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(args[2]) > -1) {
- run.help();
-} else {
- run.run(args).done(null, function (err) {
- var errorMessage = (err && err.stack) ? err.stack : err;
- console.error('ERROR: ' + errorMessage);
- process.exit(2);
- });
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/run.bat
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/run.bat b/wp8/template/cordova/run.bat
deleted file mode 100644
index 68ed160..0000000
--- a/wp8/template/cordova/run.bat
+++ /dev/null
@@ -1,30 +0,0 @@
-@ECHO OFF
-goto endheader
-#
-# 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.
-#
-:endheader
-
-SET script_path="%~dp0run"
-IF EXIST %script_path% (
- node %script_path% %*
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'run' in cordova, aborting...>&2
- EXIT /B 1
-)
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/version.bat
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/version.bat b/wp8/template/cordova/version.bat
deleted file mode 100644
index fb4a129..0000000
--- a/wp8/template/cordova/version.bat
+++ /dev/null
@@ -1,31 +0,0 @@
-@ECHO OFF
-goto endheader
-#
-# 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.
-#
-:endheader
-
-@ECHO OFF
-SET script_path="%~dp0..\VERSION"
-IF EXIST %script_path% (
- type %script_path%
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find file VERSION in project folder, path tried was %script_path% >&2
- EXIT /B 1
-)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/win_os_version.bat
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/win_os_version.bat b/wp8/template/cordova/win_os_version.bat
deleted file mode 100644
index 97a69c9..0000000
--- a/wp8/template/cordova/win_os_version.bat
+++ /dev/null
@@ -1,30 +0,0 @@
-@ECHO OFF
-goto endheader
-#
-# 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.
-#
-:endheader
-
-SET script_path="%~dp0lib\win_os_version.js"
-IF EXIST %script_path% (
- node %script_path% %*
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'win_os_version.js' in 'bin' folder, aborting...>&2
- EXIT /B 1
-)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordova/win_sdk_version.bat
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/win_sdk_version.bat b/wp8/template/cordova/win_sdk_version.bat
deleted file mode 100644
index 0a1a2ca..0000000
--- a/wp8/template/cordova/win_sdk_version.bat
+++ /dev/null
@@ -1,30 +0,0 @@
-@ECHO OFF
-goto endheader
-#
-# 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.
-#
-:endheader
-
-SET script_path="%~dp0lib\win_sdk_version.js"
-IF EXIST %script_path% (
- node %script_path% %*
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'win_sdk_version.js' in 'bin' folder, aborting...>&2
- EXIT /B 1
-)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordovalib/BrowserMouseHelper.cs
----------------------------------------------------------------------
diff --git a/wp8/template/cordovalib/BrowserMouseHelper.cs b/wp8/template/cordovalib/BrowserMouseHelper.cs
deleted file mode 100644
index fc83e03..0000000
--- a/wp8/template/cordovalib/BrowserMouseHelper.cs
+++ /dev/null
@@ -1,162 +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.
- */
-using System.Linq;
-using System.Windows;
-using System.Windows.Controls;
-using Microsoft.Phone.Controls;
-using System.Windows.Input;
-using System.Diagnostics;
-using System.Windows.Media;
-using System;
-using System.Collections.Generic;
-
-namespace WPCordovaClassLib
-{
-
- /// <summary>
- /// Suppresses pinch zoom and optionally scrolling of the WebBrowser control
- /// </summary>
- public class BrowserMouseHelper
- {
- private WebBrowser _browser;
-
- /// <summary>
- /// Gets or sets whether to suppress the scrolling of
- /// the WebBrowser control;
- /// </summary>
- public bool ScrollDisabled {
- get;
- set;
- }
-
- private bool userScalable = true;
- private double maxScale = 2.0;
- private double minScale = 0.5;
- protected Border border;
-
- /// <summary>
- /// Represent min delta value to consider event as a mouse move. Experimental calculated.
- /// </summary>
- private const int MouseMoveDeltaThreshold = 10;
-
- public BrowserMouseHelper(ref WebBrowser browser)
- {
- _browser = browser;
- browser.Loaded += new RoutedEventHandler(browser_Loaded);
- }
-
- private void browser_Loaded(object sender, RoutedEventArgs e)
- {
- var border0 = VisualTreeHelper.GetChild(_browser, 0);
- var border1 = VisualTreeHelper.GetChild(border0, 0);
- var panZoom = VisualTreeHelper.GetChild(border1, 0);
- var grid = VisualTreeHelper.GetChild(panZoom, 0);
- var grid2 = VisualTreeHelper.GetChild(grid, 0);
- border = VisualTreeHelper.GetChild(grid2, 0) as Border;
-
- if (border != null)
- {
- border.ManipulationDelta += Border_ManipulationDelta;
- border.ManipulationCompleted += Border_ManipulationCompleted;
- }
-
- _browser.LoadCompleted += Browser_LoadCompleted;
-
- }
-
- void ParseViewportMeta()
- {
- string metaScript = "(function() { return document.querySelector('meta[name=viewport]').content; })()";
-
- try
- {
- string metaContent = _browser.InvokeScript("eval", new string[] { metaScript }) as string;
- string[] arr = metaContent.Split(new[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
- Dictionary<string, string> metaDictionary = new Dictionary<string, string>();
- foreach (string val in arr)
- {
- string[] keyVal = val.Split('=');
- metaDictionary.Add(keyVal[0], keyVal[1]);
- }
-
- this.userScalable = false; // reset to default
- if (metaDictionary.ContainsKey("user-scalable"))
- {
- this.userScalable = metaDictionary["user-scalable"] == "yes";
- }
-
- this.maxScale = 2.0;// reset to default
- if (metaDictionary.ContainsKey("maximum-scale"))
- {
- this.maxScale = double.Parse(metaDictionary["maximum-scale"]);
- }
-
- this.minScale = 0.5;// reset to default
- if (metaDictionary.ContainsKey("minimum-scale"))
- {
- this.minScale = double.Parse(metaDictionary["minimum-scale"]);
- }
- }
- catch (Exception)
- {
-
- }
- }
-
- void Browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
- {
- ParseViewportMeta();
- }
-
- #region ManipulationEvents
-
- private void Border_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
- {
- //Debug.WriteLine("Border_ManipulationDelta");
- // optionally suppress zoom
- if ((ScrollDisabled || !userScalable) && (e.DeltaManipulation.Scale.X != 0.0 || e.DeltaManipulation.Scale.Y != 0.0))
- {
- e.Handled = true;
- }
- // optionally suppress scrolling
- if (ScrollDisabled && (e.DeltaManipulation.Translation.X != 0.0 || e.DeltaManipulation.Translation.Y != 0.0))
- {
- e.Handled = true;
- }
- }
-
- private void Border_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
- {
- //Debug.WriteLine("Border_ManipulationCompleted");
- // suppress zoom
- if (!userScalable && e.FinalVelocities != null)
- {
- if (e.FinalVelocities.ExpansionVelocity.X != 0.0 ||
- e.FinalVelocities.ExpansionVelocity.Y != 0.0)
- {
- e.Handled = true;
- }
- }
- }
-
-
- #endregion
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordovalib/CommandFactory.cs
----------------------------------------------------------------------
diff --git a/wp8/template/cordovalib/CommandFactory.cs b/wp8/template/cordovalib/CommandFactory.cs
deleted file mode 100644
index 4bd5a09..0000000
--- a/wp8/template/cordovalib/CommandFactory.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- Licensed 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.
-*/
-
-using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-using System.Collections.Generic;
-using WPCordovaClassLib.Cordova.Commands;
-using System.Reflection;
-using System.Diagnostics;
-
-namespace WPCordovaClassLib.Cordova
-{
- /// <summary>
- /// Provides functionality to create Cordova command by name.
- /// </summary>
- public static class CommandFactory
- {
- /// <summary>
- /// Represents predefined namespace name for custom plugins
- /// </summary>
- private static readonly string CustomPluginNamespacePrefix = "Cordova.Extension.Commands.";
-
- private static readonly string BaseCommandNamespacePrefix = "WPCordovaClassLib.Cordova.Commands.";
-
- /// <summary>
- /// Cache instantiated commands in a map.
- /// </summary>
-
- private static Dictionary<string, BaseCommand> commandMap = new Dictionary<string, BaseCommand>();
-
- /// <summary>
- /// Creates command using command class name. Returns null for unknown commands.
- /// </summary>
- /// <param name="service">Command class name, for example Device or Notification</param>
- /// <returns>Command class instance or null</returns>
- /// alias can be used as a namespace which is resolved + service
- /// or it can be the fully qualified classname
- /// or the classname in the current assembly
- public static BaseCommand CreateByServiceName(string service, string alias="")
- {
-
- if (string.IsNullOrEmpty(service))
- {
- throw new ArgumentNullException("service", "service to create can't be null");
- }
-
- if (!commandMap.ContainsKey(service))
- {
- Type t = Type.GetType(BaseCommandNamespacePrefix + service);
-
- if (t == null && !string.IsNullOrEmpty(alias))
- {
- t = Type.GetType(alias);
-
- if (t == null)
- {
- t = Type.GetType(BaseCommandNamespacePrefix + alias);
- }
-
- if (t == null)
- {
- t = Type.GetType(alias + "." + service);
- }
- }
-
- // custom plugin could be defined in own namespace and assembly
- if (t == null)
- {
- string serviceFullName = service.Contains(".") ? service : CustomPluginNamespacePrefix + service;
-
- foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
- {
- // in this case service name represents full type name including namespace
- t = a.GetType(serviceFullName);
-
- if (t == null) // try the Commands Namespace
- {
- t = a.GetType(BaseCommandNamespacePrefix + service);
- }
-
- if (t != null)
- {
- break;
- }
- }
- }
-
- // unknown command, still didn't find it
- if (t == null)
- {
- Debug.WriteLine("Unable to locate command :: " + service);
- return null;
- }
-
- commandMap[service] = Activator.CreateInstance(t) as BaseCommand;
- }
-
- return commandMap[service];
- }
-
- public static void ResetAllCommands()
- {
- foreach (BaseCommand bc in commandMap.Values)
- {
- bc.OnReset();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordovalib/Commands/BaseCommand.cs
----------------------------------------------------------------------
diff --git a/wp8/template/cordovalib/Commands/BaseCommand.cs b/wp8/template/cordovalib/Commands/BaseCommand.cs
deleted file mode 100644
index 3e2e690..0000000
--- a/wp8/template/cordovalib/Commands/BaseCommand.cs
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- Licensed 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.
-*/
-
-using System;
-using System.Reflection;
-using Microsoft.Phone.Shell;
-using System.Diagnostics;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace WPCordovaClassLib.Cordova.Commands
-{
- public abstract class BaseCommand : IDisposable
- {
- /*
- * All commands + plugins must extend BaseCommand, because they are dealt with as BaseCommands in CordovaView.xaml.cs
- *
- **/
-
- public event EventHandler<PluginResult> OnCommandResult;
-
- public event EventHandler<ScriptCallback> OnCustomScript;
-
- public string CurrentCommandCallbackId { get; set; }
-
- public BaseCommand()
- {
- ResultHandlers = new Dictionary<string, EventHandler<PluginResult>>();
- PhoneApplicationService service = PhoneApplicationService.Current;
- service.Activated += this.OnResume;
- service.Deactivated += this.OnPause;
- }
-
- protected Dictionary<string, EventHandler<PluginResult>> ResultHandlers;
- public void AddResultHandler(string callbackId, EventHandler<PluginResult> handler)
- {
- ResultHandlers.Add(callbackId, handler);
- }
- public bool RemoveResultHandler(string callbackId)
- {
- return ResultHandlers.Remove(callbackId);
- }
-
- /*
- * InvokeMethodNamed will call the named method of a BaseCommand subclass if it exists and pass the variable arguments list along.
- **/
-
- public object InvokeMethodNamed(string callbackId, string methodName, params object[] args)
- {
- //Debug.WriteLine(string.Format("InvokeMethodNamed:{0} callbackId:{1}",methodName,callbackId));
- this.CurrentCommandCallbackId = callbackId;
- return InvokeMethodNamed(methodName, args);
- }
-
- public object InvokeMethodNamed(string methodName, params object[] args)
- {
- MethodInfo mInfo = this.GetType().GetMethod(methodName);
-
- if (mInfo != null)
- {
- // every function handles DispatchCommandResult by itself
- return mInfo.Invoke(this, args);
- }
-
- // actually methodName could refer to a property
- if (args == null || args.Length == 0 ||
- (args.Length == 1 && "undefined".Equals(args[0])))
- {
- PropertyInfo pInfo = this.GetType().GetProperty(methodName);
- if (pInfo != null)
- {
- object res = pInfo.GetValue(this, null);
-
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, res));
-
- return res;
- }
- }
-
- throw new MissingMethodException(methodName);
-
- }
-
- [Obsolete]
- public void InvokeCustomScript(ScriptCallback script, bool removeHandler)
- {
- if (this.OnCustomScript != null)
- {
- this.OnCustomScript(this, script);
- if (removeHandler)
- {
- this.OnCustomScript = null;
- }
- }
- }
-
- public void DispatchCommandResult()
- {
- this.DispatchCommandResult(new PluginResult(PluginResult.Status.NO_RESULT));
- }
-
- public void DispatchCommandResult(PluginResult result,string callbackId="")
- {
- if (!string.IsNullOrEmpty(callbackId))
- {
- result.CallbackId = callbackId;
- }
- else
- {
- result.CallbackId = this.CurrentCommandCallbackId;
- }
-
- if (ResultHandlers.ContainsKey(result.CallbackId))
- {
- ResultHandlers[result.CallbackId](this, result);
- }
- else if (this.OnCommandResult != null)
- {
- OnCommandResult(this, result);
- }
- else
- {
- Debug.WriteLine("Failed to locate callback for id : " + result.CallbackId);
- }
-
- if (!result.KeepCallback)
- {
- this.Dispose();
- }
-
- }
-
-
- /// <summary>
- /// Occurs when the application is being deactivated.
- /// </summary>
- public virtual void OnReset() {}
-
- /// <summary>
- /// Occurs when the application is being loaded, and the config.xml has an autoload entry
- /// </summary>
- public virtual void OnInit() {}
-
-
- /// <summary>
- /// Occurs when the application is being deactivated.
- /// </summary>
- public virtual void OnPause(object sender, DeactivatedEventArgs e) {}
-
- /// <summary>
- /// Occurs when the application is being made active after previously being put
- /// into a dormant state or tombstoned.
- /// </summary>
- public virtual void OnResume(object sender, Microsoft.Phone.Shell.ActivatedEventArgs e) {}
-
- public void Dispose()
- {
- PhoneApplicationService service = PhoneApplicationService.Current;
- service.Activated -= this.OnResume;
- service.Deactivated -= this.OnPause;
- this.OnCommandResult = null;
- }
-
- public void DetachHandlers()
- {
- this.OnCommandResult = null;
- this.OnCustomScript = null;
- foreach (string callbackId in new List<string>(ResultHandlers.Keys))
- {
- RemoveResultHandler(callbackId);
- }
- }
-
- public static string GetBaseURL()
- {
-#if CORDOVA_CLASSLIB
- return "/WPCordovaClassLib;component/";
-#else
- return "./";
-#endif
- }
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordovalib/ConfigHandler.cs
----------------------------------------------------------------------
diff --git a/wp8/template/cordovalib/ConfigHandler.cs b/wp8/template/cordovalib/ConfigHandler.cs
deleted file mode 100644
index e2575f7..0000000
--- a/wp8/template/cordovalib/ConfigHandler.cs
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- Licensed 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.
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Windows;
-using System.Windows.Resources;
-using System.Xml.Linq;
-
-namespace WPCordovaClassLib.CordovaLib
-{
- class ConfigHandler
- {
- public class PluginConfig
- {
- public PluginConfig(string name, bool autoLoad = false, string className = "")
- {
- Name = name;
- isAutoLoad = autoLoad;
- ClassName = className;
- }
- public string Name;
- public bool isAutoLoad;
- public string ClassName;
- }
-
- protected Dictionary<string, PluginConfig> AllowedPlugins;
- protected List<string> AllowedDomains;
- protected Dictionary<string, string> Preferences;
-
- public string ContentSrc { get; private set; }
-
- protected bool AllowAllDomains = false;
- protected bool AllowAllPlugins = false;
-
- public ConfigHandler()
- {
- AllowedPlugins = new Dictionary<string, PluginConfig>();
- AllowedDomains = new List<string>();
- Preferences = new Dictionary<string, string>();
- }
-
- public string GetPreference(string key)
- {
- return Preferences.ContainsKey(key.ToLowerInvariant()) ? Preferences[key.ToLowerInvariant()] : null;
- }
-
- protected static string[] AllowedSchemes = { "http", "https", "ftp", "ftps" };
- protected bool SchemeIsAllowed(string scheme)
- {
- return AllowedSchemes.Contains(scheme);
- }
-
- protected void AddWhiteListEntry(string origin, bool allowSubdomains)
- {
-
- if (origin == "*")
- {
- AllowAllDomains = true;
- }
-
- if (AllowAllDomains)
- {
- return;
- }
-
- string hostMatchingRegex = "";
- string hostName;
-
- try
- {
-
- Uri uri = new Uri(origin.Replace("*", "replaced-text"), UriKind.Absolute);
-
- string tempHostName = uri.Host.Replace("replaced-text", "*");
- //if (uri.HostNameType == UriHostNameType.Dns){}
- // starts with wildcard match - we make the first '.' optional (so '*.org.apache.cordova' will match 'org.apache.cordova')
- if (tempHostName.StartsWith("*."))
- { //"(\\s{0}|*.)"
- hostName = @"\w*.*" + tempHostName.Substring(2).Replace(".", @"\.").Replace("*", @"\w*");
- }
- else
- {
- hostName = tempHostName.Replace(".", @"\.").Replace("*", @"\w*");
- }
- // "^https?://"
- hostMatchingRegex = uri.Scheme + "://" + hostName + uri.PathAndQuery;
- //Debug.WriteLine("Adding regex :: " + hostMatchingRegex);
- AllowedDomains.Add(hostMatchingRegex);
-
- }
- catch (Exception)
- {
- Debug.WriteLine("Invalid Whitelist entry (probably missing the protocol):: " + origin);
- }
-
- }
-
- /**
-
- An access request is granted for a given URI if there exists an item inside the access-request list such that:
-
- - The URI's scheme component is the same as scheme; and
- - if subdomains is false or if the URI's host component is not a domain name (as defined in [RFC1034]), the URI's host component is the same as host; or
- - if subdomains is true, the URI's host component is either the same as host, or is a subdomain of host (as defined in [RFC1034]); and
- - the URI's port component is the same as port.
-
- **/
-
- public bool URLIsAllowed(string url)
- {
- // easy case first
- if (this.AllowAllDomains)
- {
- return true;
- }
- else
- {
- // start simple
- Uri uri = new Uri(url, UriKind.RelativeOrAbsolute);
- if (uri.IsAbsoluteUri)
- {
- if (this.SchemeIsAllowed(uri.Scheme))
- {
- // additional test because our pattern will always have a trailing '/'
- string matchUrl = url;
- if (uri.PathAndQuery == "/")
- {
- matchUrl = url + "/";
- }
- foreach (string pattern in AllowedDomains)
- {
- if (Regex.IsMatch(matchUrl, pattern))
- {
- // make sure it is at the start, and not part of the query string
- // special case :: http://some.other.domain/page.html?x=1&g=http://build.apache.org/
- if (Regex.IsMatch(uri.Scheme + "://" + uri.Host + "/", pattern) ||
- (!Regex.IsMatch(uri.PathAndQuery, pattern)))
- {
- return true;
- }
- }
- }
- }
- }
- else
- {
- return true;
- }
- }
- return false;
- }
-
- public string GetNamespaceForCommand(string key)
- {
- if(AllowedPlugins.Keys.Contains(key))
- {
- return AllowedPlugins[key].Name;
- }
-
- return "";
- }
-
- public bool IsPluginAllowed(string key)
- {
- return AllowAllPlugins || AllowedPlugins.Keys.Contains(key);
- }
-
- public string[] AutoloadPlugins
- {
- get
- {
- // TODO:
- var res = from results in AllowedPlugins.TakeWhile(p => p.Value.isAutoLoad)
- select results.Value.Name;
-
- return res.ToArray<string>();
- }
- }
-
- private void LoadPluginFeatures(XDocument document)
- {
- var features = from feats in document.Descendants()
- where feats.Name.LocalName == "feature"
- select feats;
-
- foreach (var feature in features)
- {
- string name = (string)feature.Attribute("name");
- var value = (from results in feature.Descendants()
- where results.Name.LocalName == "param" && ((string)results.Attribute("name") == "wp-package")
- select results).FirstOrDefault();
-
- var autoloadNode = (from results in feature.Descendants()
- where results.Name.LocalName == "param" && ((string)results.Attribute("name") == "onload")
- select results).FirstOrDefault();
- bool isAutoLoad = false;
- if (autoloadNode != null)
- {
- isAutoLoad = ((string)autoloadNode.Attribute("value") == "true");
- }
-
- if (value != null)
- {
- string key = (string)value.Attribute("value");
- Debug.WriteLine("Adding feature.value=" + key);
- PluginConfig pConfig = new PluginConfig(key, isAutoLoad);
- AllowedPlugins[name] = pConfig;
-
-
- }
-
-
- }
- }
-
- public void LoadAppPackageConfig()
- {
- StreamResourceInfo streamInfo = Application.GetResourceStream(new Uri("config.xml", UriKind.Relative));
-
- if (streamInfo != null)
- {
- StreamReader sr = new StreamReader(streamInfo.Stream);
- //This will Read Keys Collection for the xml file
- XDocument document = XDocument.Parse(sr.ReadToEnd());
-
- LoadPluginFeatures(document);
-
- var preferences = from results in document.Descendants()
- where results.Name.LocalName == "preference"
- select new
- {
- name = (string)results.Attribute("name"),
- value = (string)results.Attribute("value")
- };
-
- foreach (var pref in preferences)
- {
- Preferences[pref.name.ToLowerInvariant()] = pref.value;
- }
-
- var accessList = from results in document.Descendants()
- where results.Name.LocalName == "access"
- select new
- {
- origin = (string)results.Attribute("origin"),
- subdomains = (string)results.Attribute("subdomains") == "true"
- };
-
- foreach (var accessElem in accessList)
- {
- AddWhiteListEntry(accessElem.origin, accessElem.subdomains);
- }
-
- var contentsTag = (from results in document.Descendants()
- where results.Name.LocalName == "content"
- select results).FirstOrDefault();
-
- if (contentsTag != null)
- {
- var src = contentsTag.Attribute("src");
- ContentSrc = (string)src.Value;
- }
- }
- else
- {
- // no config.xml, allow all
- AllowAllDomains = true;
- AllowAllPlugins = true;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordovalib/ConsoleHelper.cs
----------------------------------------------------------------------
diff --git a/wp8/template/cordovalib/ConsoleHelper.cs b/wp8/template/cordovalib/ConsoleHelper.cs
deleted file mode 100644
index 3443821..0000000
--- a/wp8/template/cordovalib/ConsoleHelper.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- Licensed 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.
-*/
-using Microsoft.Phone.Controls;
-using Microsoft.Phone.Shell;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.IO.IsolatedStorage;
-using System.Linq;
-using System.Text;
-
-namespace WPCordovaClassLib.CordovaLib
-{
- class ConsoleHelper : IBrowserDecorator
- {
-
- public WebBrowser Browser { get; set; }
-
- protected bool hasListener = false;
-
-
-
- public void InjectScript()
- {
- using(IsolatedStorageFileStream file = new IsolatedStorageFileStream("debugOutput.txt", FileMode.Create, FileAccess.Write, IsolatedStorageFile.GetUserStoreForApplication()))
- {
- }
-
- if (!hasListener)
- {
- PhoneApplicationService.Current.Closing += OnServiceClosing;
- hasListener = true;
- }
-
-
- string script = @"(function(win) {
- function exec(msg) { window.external.Notify('ConsoleLog/' + msg); }
- var cons = win.console = win.console || {};
- cons.log = exec;
- cons.debug = cons.debug || cons.log;
- cons.info = cons.info || function(msg) { exec('INFO:' + msg ); };
- cons.warn = cons.warn || function(msg) { exec('WARN:' + msg ); };
- cons.error = cons.error || function(msg) { exec('ERROR:' + msg ); };
- })(window);";
-
- Browser.InvokeScript("eval", new string[] { script });
- }
-
- void OnServiceClosing(object sender, ClosingEventArgs e)
- {
- using (IsolatedStorageFileStream file = new IsolatedStorageFileStream("debugOutput.txt", FileMode.Append, FileAccess.Write, IsolatedStorageFile.GetUserStoreForApplication()))
- {
- using (StreamWriter writeFile = new StreamWriter(file))
- {
- writeFile.WriteLine("EXIT");
- writeFile.Close();
- }
- file.Close();
- }
- }
-
- public void DetachHandler()
- {
- if (hasListener)
- {
- PhoneApplicationService.Current.Closing -= OnServiceClosing;
- hasListener = false;
- }
- }
-
- public bool HandleCommand(string commandStr)
- {
- string output = commandStr.Substring("ConsoleLog/".Length);
- Debug.WriteLine(output);
- using (IsolatedStorageFileStream file = new IsolatedStorageFileStream("debugOutput.txt", FileMode.Append, FileAccess.Write, IsolatedStorageFile.GetUserStoreForApplication()))
- {
- using (StreamWriter writeFile = new StreamWriter(file))
- {
- writeFile.WriteLine(output);
- writeFile.Close();
- }
- file.Close();
- }
- return true;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordovalib/CordovaCommandCall.cs
----------------------------------------------------------------------
diff --git a/wp8/template/cordovalib/CordovaCommandCall.cs b/wp8/template/cordovalib/CordovaCommandCall.cs
deleted file mode 100644
index 7b9ee0c..0000000
--- a/wp8/template/cordovalib/CordovaCommandCall.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- Licensed 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.
-*/
-
-using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-using System.Linq;
-using System.Collections.Generic;
-
-namespace WPCordovaClassLib.Cordova
-{
- /// <summary>
- /// Represents Cordova native command call: action callback, etc
- /// </summary>
- public class CordovaCommandCall
- {
- public String Service { get; private set; }
- public String Action { get; private set; }
- public String CallbackId { get; private set; }
- public String Args { get; private set; }
- public String Namespace { get; set; }
-
- /// <summary>
- /// Retrieves command call parameters and creates wrapper for them
- /// </summary>
- /// <param name="commandStr">Command string in the form 'service/action/callback/args'</param>
- /// <returns>New class instance or null of string does not represent Cordova command</returns>
- public static CordovaCommandCall Parse(string commandStr)
- {
- //System.Diagnostics.Debug.WriteLine("CommandString : " + commandStr);
- if (string.IsNullOrEmpty(commandStr))
- {
- return null;
- }
-
- string[] split = commandStr.Split('/');
- if (split.Length < 3)
- {
- return null;
- }
-
- CordovaCommandCall commandCallParameters = new CordovaCommandCall();
- commandCallParameters.Service = split[0];
- commandCallParameters.Action = split[1];
- commandCallParameters.CallbackId = split[2];
- commandCallParameters.Namespace = String.Empty;
-
- try
- {
- string arg = split.Length <= 3 ? "[]" : String.Join("/", split.Skip(3));
- if (!arg.StartsWith("[")) // save the exception
- {
- arg = string.Format("[{0}]", arg);
- }
- List<string> args = JSON.JsonHelper.Deserialize<List<string>>(arg);
- args.Add(commandCallParameters.CallbackId);
- commandCallParameters.Args = JSON.JsonHelper.Serialize(args.ToArray());
- }
- catch (Exception)
- {
- return null;
- }
- // sanity check for illegal names
- // was failing with ::
- // CordovaCommandResult :: 1, Device1, {"status":1,"message":"{\"name\":\"XD.....
- if (commandCallParameters.Service.IndexOfAny(new char[] { '@', ':', ',', '!', ' ' }) > -1)
- {
- return null;
- }
-
- return commandCallParameters;
- }
-
-
- /// <summary>
- /// Private ctr to disable class creation.
- /// New class instance must be initialized via CordovaCommandCall.Parse static method.
- /// </summary>
- private CordovaCommandCall() { }
-
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c74fdafa/wp8/template/cordovalib/CordovaView.xaml
----------------------------------------------------------------------
diff --git a/wp8/template/cordovalib/CordovaView.xaml b/wp8/template/cordovalib/CordovaView.xaml
deleted file mode 100644
index fce54bb..0000000
--- a/wp8/template/cordovalib/CordovaView.xaml
+++ /dev/null
@@ -1,63 +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.
--->
-<UserControl x:Class="WPCordovaClassLib.CordovaView"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- mc:Ignorable="d"
- FontFamily="{StaticResource PhoneFontFamilyNormal}"
- FontSize="{StaticResource PhoneFontSizeNormal}"
- Foreground="{StaticResource PhoneForegroundBrush}"
- d:DesignHeight="480" d:DesignWidth="480"
- xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone">
-
- <Grid x:Name="LayoutRoot" Background="Transparent">
-
- <phone:WebBrowser x:Name="CordovaBrowser"
- Opacity="0.0"
- HorizontalAlignment="Stretch"
- VerticalAlignment="Stretch"
- IsScriptEnabled="True"
- Foreground="White"
- Background="Black"
- Navigated="CordovaBrowser_Navigated"
- Loaded="CordovaBrowser_Loaded"
- Unloaded="CordovaBrowser_Unloaded"
- ScriptNotify="CordovaBrowser_ScriptNotify"
- LoadCompleted="CordovaBrowser_LoadCompleted"
- Navigating="CordovaBrowser_Navigating"
- NavigationFailed="CordovaBrowser_NavigationFailed"
- IsGeolocationEnabled="True">
-
- <phone:WebBrowser.Resources>
- <Storyboard x:Name="FadeIn">
- <DoubleAnimation Duration="0:0:0.6"
- To="1.0"
- Storyboard.TargetName="CordovaBrowser"
- Storyboard.TargetProperty="Opacity"/>
- </Storyboard>
- </phone:WebBrowser.Resources>
-
- </phone:WebBrowser>
-
- </Grid>
-</UserControl>
-
-