CB-12546: emulator specs.

This commit is contained in:
filmaj 2017-03-14 13:12:57 -07:00
parent eb6ada8091
commit 6395eda0c8
24 changed files with 655 additions and 446 deletions

View File

@ -27,7 +27,7 @@ var path = require('path');
var Adb = require('./Adb'); var Adb = require('./Adb');
var AndroidManifest = require('./AndroidManifest'); var AndroidManifest = require('./AndroidManifest');
var events = require('cordova-common').events; var events = require('cordova-common').events;
var spawn = require('cordova-common').superspawn.spawn; var superspawn = require('cordova-common').superspawn;
var CordovaError = require('cordova-common').CordovaError; var CordovaError = require('cordova-common').CordovaError;
var shelljs = require('shelljs'); var shelljs = require('shelljs');
var android_sdk = require('./android_sdk'); var android_sdk = require('./android_sdk');
@ -54,7 +54,7 @@ function forgivingWhichSync(cmd) {
} }
module.exports.list_images_using_avdmanager = function () { module.exports.list_images_using_avdmanager = function () {
return spawn('avdmanager', ['list', 'avd']) return superspawn.spawn('avdmanager', ['list', 'avd'])
.then(function(output) { .then(function(output) {
var response = output.split('\n'); var response = output.split('\n');
var emulator_list = []; var emulator_list = [];
@ -114,10 +114,55 @@ module.exports.list_images_using_avdmanager = function () {
}); });
}; };
module.exports.list_images_using_android = function() {
return superspawn.spawn('android', ['list', 'avds'])
.then(function(output) {
var response = output.split('\n');
var emulator_list = [];
for (var i = 1; i < response.length; i++) {
// To return more detailed information use img_obj
var img_obj = {};
if (response[i].match(/Name:\s/)) {
img_obj['name'] = response[i].split('Name: ')[1].replace('\r', '');
if (response[i + 1].match(/Device:\s/)) {
i++;
img_obj['device'] = response[i].split('Device: ')[1].replace('\r', '');
}
if (response[i + 1].match(/Path:\s/)) {
i++;
img_obj['path'] = response[i].split('Path: ')[1].replace('\r', '');
}
if (response[i + 1].match(/\(API\slevel\s/) || (response[i + 2] && response[i + 2].match(/\(API\slevel\s/))) {
i++;
var secondLine = response[i + 1].match(/\(API\slevel\s/) ? response[i + 1] : '';
img_obj['target'] = (response[i] + secondLine).split('Target: ')[1].replace('\r', '');
}
if (response[i + 1].match(/ABI:\s/)) {
i++;
img_obj['abi'] = response[i].split('ABI: ')[1].replace('\r', '');
}
if (response[i + 1].match(/Skin:\s/)) {
i++;
img_obj['skin'] = response[i].split('Skin: ')[1].replace('\r', '');
}
emulator_list.push(img_obj);
}
/* To just return a list of names use this
if (response[i].match(/Name:\s/)) {
emulator_list.push(response[i].split('Name: ')[1].replace('\r', '');
}*/
}
return emulator_list;
});
};
/** /**
* Returns a Promise for a list of emulator images in the form of objects * Returns a Promise for a list of emulator images in the form of objects
* { * {
name : <emulator_name>, name : <emulator_name>,
device : <device>,
path : <path_to_emulator_image>, path : <path_to_emulator_image>,
target : <api_target>, target : <api_target>,
abi : <cpu>, abi : <cpu>,
@ -126,47 +171,8 @@ module.exports.list_images_using_avdmanager = function () {
*/ */
module.exports.list_images = function() { module.exports.list_images = function() {
if (forgivingWhichSync('android')) { if (forgivingWhichSync('android')) {
return spawn('android', ['list', 'avds']) return module.exports.list_images_using_android()
.then(function(output) { .catch(function(err) {
var response = output.split('\n');
var emulator_list = [];
for (var i = 1; i < response.length; i++) {
// To return more detailed information use img_obj
var img_obj = {};
if (response[i].match(/Name:\s/)) {
img_obj['name'] = response[i].split('Name: ')[1].replace('\r', '');
if (response[i + 1].match(/Device:\s/)) {
i++;
img_obj['device'] = response[i].split('Device: ')[1].replace('\r', '');
}
if (response[i + 1].match(/Path:\s/)) {
i++;
img_obj['path'] = response[i].split('Path: ')[1].replace('\r', '');
}
if (response[i + 1].match(/\(API\slevel\s/) || (response[i + 2] && response[i + 2].match(/\(API\slevel\s/))) {
i++;
var secondLine = response[i + 1].match(/\(API\slevel\s/) ? response[i + 1] : '';
img_obj['target'] = (response[i] + secondLine).split('Target: ')[1].replace('\r', '');
}
if (response[i + 1].match(/ABI:\s/)) {
i++;
img_obj['abi'] = response[i].split('ABI: ')[1].replace('\r', '');
}
if (response[i + 1].match(/Skin:\s/)) {
i++;
img_obj['skin'] = response[i].split('Skin: ')[1].replace('\r', '');
}
emulator_list.push(img_obj);
}
/* To just return a list of names use this
if (response[i].match(/Name:\s/)) {
emulator_list.push(response[i].split('Name: ')[1].replace('\r', '');
}*/
}
return emulator_list;
}).catch(function(err) {
// try to use `avdmanager` in case `android` has problems // try to use `avdmanager` in case `android` has problems
// this likely means the target machine is using a newer version of // this likely means the target machine is using a newer version of
// the android sdk, and possibly `avdmanager` is available. // the android sdk, and possibly `avdmanager` is available.
@ -219,7 +225,7 @@ module.exports.list_started = function() {
// Returns a promise. // Returns a promise.
module.exports.list_targets = function() { module.exports.list_targets = function() {
return spawn('android', ['list', 'targets'], {cwd: os.tmpdir()}) return superspawn.spawn('android', ['list', 'targets'], {cwd: os.tmpdir()})
.then(function(output) { .then(function(output) {
var target_out = output.split('\n'); var target_out = output.split('\n');
var targets = []; var targets = [];
@ -382,7 +388,7 @@ module.exports.wait_for_boot = function(emulator_id, time_remaining) {
module.exports.create_image = function(name, target) { module.exports.create_image = function(name, target) {
console.log('Creating new avd named ' + name); console.log('Creating new avd named ' + name);
if (target) { if (target) {
return spawn('android', ['create', 'avd', '--name', name, '--target', target]) return superspawn.spawn('android', ['create', 'avd', '--name', name, '--target', target])
.then(null, function(error) { .then(null, function(error) {
console.error('ERROR : Failed to create emulator image : '); console.error('ERROR : Failed to create emulator image : ');
console.error(' Do you have the latest android targets including ' + target + '?'); console.error(' Do you have the latest android targets including ' + target + '?');
@ -390,7 +396,7 @@ module.exports.create_image = function(name, target) {
}); });
} else { } else {
console.log('WARNING : Project target not found, creating avd with a different target but the project may fail to install.'); console.log('WARNING : Project target not found, creating avd with a different target but the project may fail to install.');
return spawn('android', ['create', 'avd', '--name', name, '--target', this.list_targets()[0]]) return superspawn.spawn('android', ['create', 'avd', '--name', name, '--target', this.list_targets()[0]])
.then(function() { .then(function() {
// TODO: This seems like another error case, even though it always happens. // TODO: This seems like another error case, even though it always happens.
console.error('ERROR : Unable to create an avd emulator, no targets found.'); console.error('ERROR : Unable to create an avd emulator, no targets found.');

17
node_modules/big-integer/.npmignore generated vendored
View File

@ -1,17 +0,0 @@
/.travis.yml
/.npmignore
/.gitignore
/spec
/benchmark
/big-integer*.tgz
/my.conf.js
/node_modules
/*.csproj*
/*.sh
/*.suo
/bin
/coverage
/*.bat
/obj
/Properties
/Web.*

View File

@ -833,6 +833,7 @@ var bigInt = (function (undefined) {
newT = lastT.subtract(q.multiply(newT)); newT = lastT.subtract(q.multiply(newT));
newR = lastR.subtract(q.multiply(newR)); newR = lastR.subtract(q.multiply(newR));
} }
if (!r.equals(1)) throw new Error(this.toString() + " and " + n.toString() + " are not co-prime");
if (t.compare(0) === -1) { if (t.compare(0) === -1) {
t = t.add(n); t = t.add(n);
} }

File diff suppressed because one or more lines are too long

View File

@ -10,18 +10,17 @@
"spec": ">=1.6.7 <2.0.0", "spec": ">=1.6.7 <2.0.0",
"type": "range" "type": "range"
}, },
"/Users/steveng/repo/cordova/cordova-android/node_modules/bplist-parser" "/Users/maj/src/cordova-android/node_modules/bplist-parser"
] ]
], ],
"_from": "big-integer@>=1.6.7 <2.0.0", "_from": "big-integer@>=1.6.7 <2.0.0",
"_id": "big-integer@1.6.16", "_id": "big-integer@1.6.17",
"_inCache": true, "_inCache": true,
"_installable": true,
"_location": "/big-integer", "_location": "/big-integer",
"_nodeVersion": "4.4.5", "_nodeVersion": "4.4.5",
"_npmOperationalInternal": { "_npmOperationalInternal": {
"host": "packages-16-east.internal.npmjs.com", "host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/big-integer-1.6.16.tgz_1473665148825_0.5824211346916854" "tmp": "tmp/big-integer-1.6.17.tgz_1478721202721_0.8068355675786734"
}, },
"_npmUser": { "_npmUser": {
"name": "peterolson", "name": "peterolson",
@ -41,11 +40,11 @@
"_requiredBy": [ "_requiredBy": [
"/bplist-parser" "/bplist-parser"
], ],
"_resolved": "http://registry.npmjs.org/big-integer/-/big-integer-1.6.16.tgz", "_resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.17.tgz",
"_shasum": "0ca30b58013db46b10084a09242ca1d8954724cc", "_shasum": "f0dcf5109a949e42a993ee3e8fb2070452817b51",
"_shrinkwrap": null, "_shrinkwrap": null,
"_spec": "big-integer@^1.6.7", "_spec": "big-integer@^1.6.7",
"_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/bplist-parser", "_where": "/Users/maj/src/cordova-android/node_modules/bplist-parser",
"author": { "author": {
"name": "Peter Olson", "name": "Peter Olson",
"email": "peter.e.c.olson+npm@gmail.com" "email": "peter.e.c.olson+npm@gmail.com"
@ -68,13 +67,13 @@
}, },
"directories": {}, "directories": {},
"dist": { "dist": {
"shasum": "0ca30b58013db46b10084a09242ca1d8954724cc", "shasum": "f0dcf5109a949e42a993ee3e8fb2070452817b51",
"tarball": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.16.tgz" "tarball": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.17.tgz"
}, },
"engines": { "engines": {
"node": ">=0.6" "node": ">=0.6"
}, },
"gitHead": "09b50ab4e701a2ec4d403fa3ecf12ae327227190", "gitHead": "d25d0bfcd96f31001ec8572c8d01de4770d99e63",
"homepage": "https://github.com/peterolson/BigInteger.js#readme", "homepage": "https://github.com/peterolson/BigInteger.js#readme",
"keywords": [ "keywords": [
"math", "math",
@ -105,5 +104,5 @@
"scripts": { "scripts": {
"test": "karma start my.conf.js" "test": "karma start my.conf.js"
}, },
"version": "1.6.16" "version": "1.6.17"
} }

View File

@ -1,2 +1,3 @@
fixtures fixtures
coverage coverage
jasmine.json

View File

@ -20,6 +20,16 @@
--> -->
# Cordova-common Release Notes # Cordova-common Release Notes
### 2.0.1 (Mar 09, 2017)
* [CB-12557](https://issues.apache.org/jira/browse/CB-12557) add both stdout and stderr properties to the error object passed to superspawn reject handler.
### 2.0.0 (Jan 17, 2017)
* [CB-8978](https://issues.apache.org/jira/browse/CB-8978) Add `resource-file` parsing to `config.xml`
* [CB-12018](https://issues.apache.org/jira/browse/CB-12018): updated `jshint` and updated tests to work with `jasmine@2` instead of `jasmine-node`
* [CB-12163](https://issues.apache.org/jira/browse/CB-12163) Add reference attrib to `resource-file` for **Windows**
* Move windows-specific logic to `cordova-windows`
* [CB-12189](https://issues.apache.org/jira/browse/CB-12189) Add implementation attribute to framework
### 1.5.1 (Oct 12, 2016) ### 1.5.1 (Oct 12, 2016)
* [CB-12002](https://issues.apache.org/jira/browse/CB-12002) Add `getAllowIntents()` to `ConfigParser` * [CB-12002](https://issues.apache.org/jira/browse/CB-12002) Add `getAllowIntents()` to `ConfigParser`
* [CB-11998](https://issues.apache.org/jira/browse/CB-11998) `cordova platform add` error with `cordova-common@1.5.0` * [CB-11998](https://issues.apache.org/jira/browse/CB-11998) `cordova platform add` error with `cordova-common@1.5.0`

View File

@ -2,50 +2,49 @@
"_args": [ "_args": [
[ [
{ {
"raw": "cordova-common@^1.5.0", "raw": "cordova-common@^2.0.1",
"scope": null, "scope": null,
"escapedName": "cordova-common", "escapedName": "cordova-common",
"name": "cordova-common", "name": "cordova-common",
"rawSpec": "^1.5.0", "rawSpec": "^2.0.1",
"spec": ">=1.5.0 <2.0.0", "spec": ">=2.0.1 <3.0.0",
"type": "range" "type": "range"
}, },
"/Users/steveng/repo/cordova/cordova-android" "/Users/maj/src/cordova-android"
] ]
], ],
"_from": "cordova-common@>=1.5.0 <2.0.0", "_from": "cordova-common@>=2.0.1 <3.0.0",
"_id": "cordova-common@1.5.1", "_id": "cordova-common@2.0.1",
"_inCache": true, "_inCache": true,
"_installable": true,
"_location": "/cordova-common", "_location": "/cordova-common",
"_nodeVersion": "6.6.0", "_nodeVersion": "6.9.4",
"_npmOperationalInternal": { "_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com", "host": "packages-18-east.internal.npmjs.com",
"tmp": "tmp/cordova-common-1.5.1.tgz_1476725179180_0.39604957425035536" "tmp": "tmp/cordova-common-2.0.1.tgz_1489432932737_0.5238456283695996"
}, },
"_npmUser": { "_npmUser": {
"name": "stevegill", "name": "filmaj",
"email": "stevengill97@gmail.com" "email": "maj.fil@gmail.com"
}, },
"_npmVersion": "3.10.3", "_npmVersion": "3.10.10",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"raw": "cordova-common@^1.5.0", "raw": "cordova-common@^2.0.1",
"scope": null, "scope": null,
"escapedName": "cordova-common", "escapedName": "cordova-common",
"name": "cordova-common", "name": "cordova-common",
"rawSpec": "^1.5.0", "rawSpec": "^2.0.1",
"spec": ">=1.5.0 <2.0.0", "spec": ">=2.0.1 <3.0.0",
"type": "range" "type": "range"
}, },
"_requiredBy": [ "_requiredBy": [
"/" "/"
], ],
"_resolved": "file:cordova-dist/tools/cordova-common-1.5.1.tgz", "_resolved": "file:tools/cordova-common-2.0.1.tgz",
"_shasum": "6770de0d6200ad6f94a1abe8939b5bd9ece139e3", "_shasum": "99af318d7cb8988047cfe37bb9f25ea881d52815",
"_shrinkwrap": null, "_shrinkwrap": null,
"_spec": "cordova-common@^1.5.0", "_spec": "cordova-common@^2.0.1",
"_where": "/Users/steveng/repo/cordova/cordova-android", "_where": "/Users/maj/src/cordova-android",
"author": { "author": {
"name": "Apache Software Foundation" "name": "Apache Software Foundation"
}, },
@ -71,18 +70,17 @@
}, },
"description": "Apache Cordova tools and platforms shared routines", "description": "Apache Cordova tools and platforms shared routines",
"devDependencies": { "devDependencies": {
"istanbul": "^0.3.17", "istanbul": "^0.4.5",
"jasmine-node": "^1.14.5", "jasmine": "^2.5.2",
"jshint": "^2.8.0", "jshint": "^2.8.0",
"promise-matchers": "^0.9.6", "promise-matchers": "^0.9.6",
"rewire": "^2.5.1" "rewire": "^2.5.1"
}, },
"directories": {}, "directories": {},
"dist": { "dist": {
"shasum": "6770de0d6200ad6f94a1abe8939b5bd9ece139e3", "shasum": "99af318d7cb8988047cfe37bb9f25ea881d52815",
"tarball": "https://registry.npmjs.org/cordova-common/-/cordova-common-1.5.1.tgz" "tarball": "https://registry.npmjs.org/cordova-common/-/cordova-common-2.0.1.tgz"
}, },
"engineStrict": true,
"engines": { "engines": {
"node": ">=0.9.9" "node": ">=0.9.9"
}, },
@ -93,6 +91,10 @@
"name": "bowserj", "name": "bowserj",
"email": "bowserj@apache.org" "email": "bowserj@apache.org"
}, },
{
"name": "filmaj",
"email": "maj.fil@gmail.com"
},
{ {
"name": "kotikov.vladimir", "name": "kotikov.vladimir",
"email": "kotikov.vladimir@gmail.com" "email": "kotikov.vladimir@gmail.com"
@ -122,10 +124,10 @@
"url": "git://git-wip-us.apache.org/repos/asf/cordova-common.git" "url": "git://git-wip-us.apache.org/repos/asf/cordova-common.git"
}, },
"scripts": { "scripts": {
"cover": "node node_modules/istanbul/lib/cli.js cover --root src --print detail node_modules/jasmine-node/bin/jasmine-node -- spec", "cover": "istanbul cover --root src --print detail jasmine",
"jasmine": "node node_modules/jasmine-node/bin/jasmine-node --captureExceptions --color spec", "jasmine": "jasmine --captureExceptions --color",
"jshint": "node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint spec", "jshint": "jshint src && jshint spec",
"test": "npm run jshint && npm run jasmine" "test": "npm run jshint && npm run jasmine"
}, },
"version": "1.5.1" "version": "2.0.1"
} }

View File

@ -1,21 +1,21 @@
/* /**
* Licensed to the Apache Software Foundation (ASF) under one
* Copyright 2013 Anis Kadri or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* Licensed under the Apache License, Version 2.0 (the "License"); regarding copyright ownership. The ASF licenses this file
* you may not use this file except in compliance with the License. to you under the Apache License, Version 2.0 (the
* You may obtain a copy of the License at "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
* 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 Unless required by applicable law or agreed to in writing,
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY software distributed under the License is distributed on an
* KIND, either express or implied. See the License for the "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* specific language governing permissions and limitations KIND, either express or implied. See the License for the
* under the License. specific language governing permissions and limitations
* under the License.
*/ */
/* /*
* This module deals with shared configuration / dependency "stuff". That is: * This module deals with shared configuration / dependency "stuff". That is:
@ -31,11 +31,8 @@
/* jshint sub:true */ /* jshint sub:true */
var fs = require('fs'), var path = require('path'),
path = require('path'),
et = require('elementtree'), et = require('elementtree'),
semver = require('semver'),
events = require('../events'),
ConfigKeeper = require('./ConfigKeeper'), ConfigKeeper = require('./ConfigKeeper'),
CordovaLogger = require('../CordovaLogger'); CordovaLogger = require('../CordovaLogger');
@ -109,18 +106,6 @@ function remove_plugin_changes(pluginInfo, is_top_level) {
var munge = mungeutil.decrement_munge(global_munge, config_munge); var munge = mungeutil.decrement_munge(global_munge, config_munge);
for (var file in munge.files) { for (var file in munge.files) {
// CB-6976 Windows Universal Apps. Compatibility fix for existing plugins.
if (self.platform == 'windows' && file == 'package.appxmanifest' &&
!fs.existsSync(path.join(self.project_dir, 'package.appxmanifest'))) {
// New windows template separate manifest files for Windows10, Windows8.1 and WP8.1
var substs = ['package.phone.appxmanifest', 'package.windows.appxmanifest', 'package.windows10.appxmanifest'];
/* jshint loopfunc:true */
substs.forEach(function(subst) {
events.emit('verbose', 'Applying munge to ' + subst);
self.apply_file_munge(subst, munge.files[file], true);
});
/* jshint loopfunc:false */
}
self.apply_file_munge(file, munge.files[file], /* remove = */ true); self.apply_file_munge(file, munge.files[file], /* remove = */ true);
} }
@ -250,18 +235,6 @@ function munge_helper(should_increment, self, platform_config, config_munge) {
} }
for (var file in munge.files) { for (var file in munge.files) {
// CB-6976 Windows Universal Apps. Compatibility fix for existing plugins.
if (self.platform == 'windows' && file == 'package.appxmanifest' &&
!fs.existsSync(path.join(self.project_dir, 'package.appxmanifest'))) {
var substs = ['package.phone.appxmanifest', 'package.windows.appxmanifest', 'package.windows10.appxmanifest'];
/* jshint loopfunc:true */
substs.forEach(function(subst) {
events.emit('verbose', 'Applying munge to ' + subst);
self.apply_file_munge(subst, munge.files[file]);
});
/* jshint loopfunc:false */
}
self.apply_file_munge(file, munge.files[file]); self.apply_file_munge(file, munge.files[file]);
} }
@ -333,92 +306,6 @@ function generate_plugin_config_munge(pluginInfo, vars, edit_config_changes) {
Array.prototype.push.apply(changes, edit_config_changes); Array.prototype.push.apply(changes, edit_config_changes);
} }
// Demux 'package.appxmanifest' into relevant platform-specific appx manifests.
// Only spend the cycles if there are version-specific plugin settings
if (self.platform === 'windows' &&
changes.some(function(change) {
return ((typeof change.versions !== 'undefined') ||
(typeof change.deviceTarget !== 'undefined'));
}))
{
var manifests = {
'windows': {
'8.1.0': 'package.windows.appxmanifest',
'10.0.0': 'package.windows10.appxmanifest'
},
'phone': {
'8.1.0': 'package.phone.appxmanifest',
'10.0.0': 'package.windows10.appxmanifest'
},
'all': {
'8.1.0': ['package.windows.appxmanifest', 'package.phone.appxmanifest'],
'10.0.0': 'package.windows10.appxmanifest'
}
};
var oldChanges = changes;
changes = [];
oldChanges.forEach(function(change, changeIndex) {
// Only support semver/device-target demux for package.appxmanifest
// Pass through in case something downstream wants to use it
if (change.target !== 'package.appxmanifest') {
changes.push(change);
return;
}
var hasVersion = (typeof change.versions !== 'undefined');
var hasTargets = (typeof change.deviceTarget !== 'undefined');
// No semver/device-target for this config-file, pass it through
if (!(hasVersion || hasTargets)) {
changes.push(change);
return;
}
var targetDeviceSet = hasTargets ? change.deviceTarget : 'all';
if (['windows', 'phone', 'all'].indexOf(targetDeviceSet) === -1) {
// target-device couldn't be resolved, fix it up here to a valid value
targetDeviceSet = 'all';
}
var knownWindowsVersionsForTargetDeviceSet = Object.keys(manifests[targetDeviceSet]);
// at this point, 'change' targets package.appxmanifest and has a version attribute
knownWindowsVersionsForTargetDeviceSet.forEach(function(winver) {
// This is a local function that creates the new replacement representing the
// mutation. Used to save code further down.
var createReplacement = function(manifestFile, originalChange) {
var replacement = {
target: manifestFile,
parent: originalChange.parent,
after: originalChange.after,
xmls: originalChange.xmls,
versions: originalChange.versions,
deviceTarget: originalChange.deviceTarget
};
return replacement;
};
// version doesn't satisfy, so skip
if (hasVersion && !semver.satisfies(winver, change.versions)) {
return;
}
var versionSpecificManifests = manifests[targetDeviceSet][winver];
if (versionSpecificManifests.constructor === Array) {
// e.g. all['8.1.0'] === ['pkg.windows.appxmanifest', 'pkg.phone.appxmanifest']
versionSpecificManifests.forEach(function(manifestFile) {
changes.push(createReplacement(manifestFile, change));
});
}
else {
// versionSpecificManifests is actually a single string
changes.push(createReplacement(versionSpecificManifests, change));
}
});
});
}
changes.forEach(function(change) { changes.forEach(function(change) {
change.xmls.forEach(function(xml) { change.xmls.forEach(function(xml) {
// 1. stringify each xml // 1. stringify each xml

View File

@ -256,6 +256,30 @@ ConfigParser.prototype = {
return this.getStaticResources(platform, 'splash'); return this.getStaticResources(platform, 'splash');
}, },
/**
* Returns all resource-files for a specific platform.
* @param {string} platform Platform name
* @return {Resource[]} Array of resource file objects.
*/
getFileResources: function(platform) {
var fileResources = [];
if (platform) { // platform specific resources
fileResources = this.doc.findall('platform[@name=\'' + platform + '\']/resource-file').map(function(tag) {
return {
platform: platform,
src: tag.attrib.src,
target: tag.attrib.target,
versions: tag.attrib.versions,
deviceTarget: tag.attrib['device-target'],
arch: tag.attrib.arch
};
});
}
return fileResources;
},
/** /**
* Returns all hook scripts for the hook type specified. * Returns all hook scripts for the hook type specified.
* @param {String} hook The hook type. * @param {String} hook The hook type.

View File

@ -225,7 +225,8 @@ function PluginInfo(dirname) {
target: tag.attrib.target, target: tag.attrib.target,
versions: tag.attrib.versions, versions: tag.attrib.versions,
deviceTarget: tag.attrib['device-target'], deviceTarget: tag.attrib['device-target'],
arch: tag.attrib.arch arch: tag.attrib.arch,
reference: tag.attrib.reference
}; };
}); });
return resourceFiles; return resourceFiles;
@ -323,7 +324,8 @@ function PluginInfo(dirname) {
versions: el.attrib.versions, versions: el.attrib.versions,
targetDir: el.attrib['target-dir'], targetDir: el.attrib['target-dir'],
deviceTarget: el.attrib['device-target'] || el.attrib.target, deviceTarget: el.attrib['device-target'] || el.attrib.target,
arch: el.attrib.arch arch: el.attrib.arch,
implementation: el.attrib.implementation
}; };
return ret; return ret;
}); });

View File

@ -167,6 +167,12 @@ exports.spawn = function(cmd, args, opts) {
errMsg += ' Error output:\n' + capturedErr.trim(); errMsg += ' Error output:\n' + capturedErr.trim();
} }
var err = new Error(errMsg); var err = new Error(errMsg);
if (capturedErr) {
err.stderr = capturedErr;
}
if (capturedOut) {
err.stdout = capturedOut;
}
err.code = code; err.code = code;
d.reject(err); d.reject(err);
} }

View File

@ -1,21 +1,21 @@
/* /**
* Licensed to the Apache Software Foundation (ASF) under one
* Copyright 2013 Brett Rudd or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* Licensed under the Apache License, Version 2.0 (the "License"); regarding copyright ownership. The ASF licenses this file
* you may not use this file except in compliance with the License. to you under the Apache License, Version 2.0 (the
* You may obtain a copy of the License at "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
* 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 Unless required by applicable law or agreed to in writing,
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY software distributed under the License is distributed on an
* KIND, either express or implied. See the License for the "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* specific language governing permissions and limitations KIND, either express or implied. See the License for the
* under the License. specific language governing permissions and limitations
* under the License.
*/ */
// contains PLIST utility functions // contains PLIST utility functions
var __ = require('underscore'); var __ = require('underscore');

View File

@ -1,21 +1,21 @@
/* /**
* Licensed to the Apache Software Foundation (ASF) under one
* Copyright 2013 Anis Kadri or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* Licensed under the Apache License, Version 2.0 (the "License"); regarding copyright ownership. The ASF licenses this file
* you may not use this file except in compliance with the License. to you under the Apache License, Version 2.0 (the
* You may obtain a copy of the License at "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
* 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 Unless required by applicable law or agreed to in writing,
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY software distributed under the License is distributed on an
* KIND, either express or implied. See the License for the "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* specific language governing permissions and limitations KIND, either express or implied. See the License for the
* under the License. specific language governing permissions and limitations
* under the License.
*/ */
/* jshint sub:true, laxcomma:true */ /* jshint sub:true, laxcomma:true */

31
node_modules/osenv/package.json generated vendored
View File

@ -10,20 +10,23 @@
"spec": ">=0.1.3 <0.2.0", "spec": ">=0.1.3 <0.2.0",
"type": "range" "type": "range"
}, },
"/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common" "/Users/maj/src/cordova-android/node_modules/cordova-common"
] ]
], ],
"_from": "osenv@>=0.1.3 <0.2.0", "_from": "osenv@>=0.1.3 <0.2.0",
"_id": "osenv@0.1.3", "_id": "osenv@0.1.4",
"_inCache": true, "_inCache": true,
"_installable": true,
"_location": "/osenv", "_location": "/osenv",
"_nodeVersion": "2.2.1", "_nodeVersion": "6.5.0",
"_npmOperationalInternal": {
"host": "packages-18-east.internal.npmjs.com",
"tmp": "tmp/osenv-0.1.4.tgz_1481655889868_0.3980878754518926"
},
"_npmUser": { "_npmUser": {
"name": "isaacs", "name": "isaacs",
"email": "isaacs@npmjs.com" "email": "i@izs.me"
}, },
"_npmVersion": "3.0.0", "_npmVersion": "3.10.9",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"raw": "osenv@^0.1.3", "raw": "osenv@^0.1.3",
@ -37,11 +40,11 @@
"_requiredBy": [ "_requiredBy": [
"/cordova-common" "/cordova-common"
], ],
"_resolved": "http://registry.npmjs.org/osenv/-/osenv-0.1.3.tgz", "_resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.4.tgz",
"_shasum": "83cf05c6d6458fc4d5ac6362ea325d92f2754217", "_shasum": "42fe6d5953df06c8064be6f176c3d05aaaa34644",
"_shrinkwrap": null, "_shrinkwrap": null,
"_spec": "osenv@^0.1.3", "_spec": "osenv@^0.1.3",
"_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/cordova-common", "_where": "/Users/maj/src/cordova-android/node_modules/cordova-common",
"author": { "author": {
"name": "Isaac Z. Schlueter", "name": "Isaac Z. Schlueter",
"email": "i@izs.me", "email": "i@izs.me",
@ -56,16 +59,16 @@
}, },
"description": "Look up environment settings specific to different operating systems", "description": "Look up environment settings specific to different operating systems",
"devDependencies": { "devDependencies": {
"tap": "^1.2.0" "tap": "^8.0.1"
}, },
"directories": { "directories": {
"test": "test" "test": "test"
}, },
"dist": { "dist": {
"shasum": "83cf05c6d6458fc4d5ac6362ea325d92f2754217", "shasum": "42fe6d5953df06c8064be6f176c3d05aaaa34644",
"tarball": "https://registry.npmjs.org/osenv/-/osenv-0.1.3.tgz" "tarball": "https://registry.npmjs.org/osenv/-/osenv-0.1.4.tgz"
}, },
"gitHead": "f746b3405d8f9e28054d11b97e1436f6a15016c4", "gitHead": "ef718f0d20e38d45ec452b7faeefc692d3cd1062",
"homepage": "https://github.com/npm/osenv#readme", "homepage": "https://github.com/npm/osenv#readme",
"keywords": [ "keywords": [
"environment", "environment",
@ -106,5 +109,5 @@
"scripts": { "scripts": {
"test": "tap test/*.js" "test": "tap test/*.js"
}, },
"version": "0.1.3" "version": "0.1.4"
} }

12
node_modules/osenv/test/unix.js generated vendored
View File

@ -2,14 +2,14 @@
// pretending to be another platform is too hacky, since it breaks // pretending to be another platform is too hacky, since it breaks
// how the underlying system looks up module paths and runs // how the underlying system looks up module paths and runs
// child processes, and all that stuff is cached. // child processes, and all that stuff is cached.
if (process.platform === 'win32') {
console.log('TAP Version 13\n' +
'1..0\n' +
'# Skip unix tests, this is not unix\n')
return
}
var tap = require('tap') var tap = require('tap')
if (process.platform === 'win32') {
tap.plan(0, 'Skip unix tests, this is not unix')
process.exit(0)
}
// like unix, but funny // like unix, but funny
process.env.USER = 'sirUser' process.env.USER = 'sirUser'
process.env.HOME = '/home/sirUser' process.env.HOME = '/home/sirUser'

46
node_modules/xmldom/dom-parser.js generated vendored
View File

@ -2,7 +2,7 @@ function DOMParser(options){
this.options = options ||{locator:{}}; this.options = options ||{locator:{}};
} }
DOMParser.prototype.parseFromString = function(source,mimeType){ DOMParser.prototype.parseFromString = function(source,mimeType){
var options = this.options; var options = this.options;
var sax = new XMLReader(); var sax = new XMLReader();
var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler
@ -25,9 +25,9 @@ DOMParser.prototype.parseFromString = function(source,mimeType){
if(source){ if(source){
sax.parse(source,defaultNSMap,entityMap); sax.parse(source,defaultNSMap,entityMap);
}else{ }else{
sax.errorHandler.error("invalid document source"); sax.errorHandler.error("invalid doc source");
} }
return domBuilder.document; return domBuilder.doc;
} }
function buildErrorHandler(errorImpl,domBuilder,locator){ function buildErrorHandler(errorImpl,domBuilder,locator){
if(!errorImpl){ if(!errorImpl){
@ -77,13 +77,13 @@ function position(locator,node){
*/ */
DOMHandler.prototype = { DOMHandler.prototype = {
startDocument : function() { startDocument : function() {
this.document = new DOMImplementation().createDocument(null, null, null); this.doc = new DOMImplementation().createDocument(null, null, null);
if (this.locator) { if (this.locator) {
this.document.documentURI = this.locator.systemId; this.doc.documentURI = this.locator.systemId;
} }
}, },
startElement:function(namespaceURI, localName, qName, attrs) { startElement:function(namespaceURI, localName, qName, attrs) {
var doc = this.document; var doc = this.doc;
var el = doc.createElementNS(namespaceURI, qName||localName); var el = doc.createElementNS(namespaceURI, qName||localName);
var len = attrs.length; var len = attrs.length;
appendElement(this, el); appendElement(this, el);
@ -95,24 +95,22 @@ DOMHandler.prototype = {
var value = attrs.getValue(i); var value = attrs.getValue(i);
var qName = attrs.getQName(i); var qName = attrs.getQName(i);
var attr = doc.createAttributeNS(namespaceURI, qName); var attr = doc.createAttributeNS(namespaceURI, qName);
if( attr.getOffset){ this.locator &&position(attrs.getLocator(i),attr);
position(attr.getOffset(1),attr)
}
attr.value = attr.nodeValue = value; attr.value = attr.nodeValue = value;
el.setAttributeNode(attr) el.setAttributeNode(attr)
} }
}, },
endElement:function(namespaceURI, localName, qName) { endElement:function(namespaceURI, localName, qName) {
var current = this.currentElement var current = this.currentElement
var tagName = current.tagName; var tagName = current.tagName;
this.currentElement = current.parentNode; this.currentElement = current.parentNode;
}, },
startPrefixMapping:function(prefix, uri) { startPrefixMapping:function(prefix, uri) {
}, },
endPrefixMapping:function(prefix) { endPrefixMapping:function(prefix) {
}, },
processingInstruction:function(target, data) { processingInstruction:function(target, data) {
var ins = this.document.createProcessingInstruction(target, data); var ins = this.doc.createProcessingInstruction(target, data);
this.locator && position(this.locator,ins) this.locator && position(this.locator,ins)
appendElement(this, ins); appendElement(this, ins);
}, },
@ -121,13 +119,17 @@ DOMHandler.prototype = {
characters:function(chars, start, length) { characters:function(chars, start, length) {
chars = _toString.apply(this,arguments) chars = _toString.apply(this,arguments)
//console.log(chars) //console.log(chars)
if(this.currentElement && chars){ if(chars){
if (this.cdata) { if (this.cdata) {
var charNode = this.document.createCDATASection(chars); var charNode = this.doc.createCDATASection(chars);
this.currentElement.appendChild(charNode);
} else { } else {
var charNode = this.document.createTextNode(chars); var charNode = this.doc.createTextNode(chars);
}
if(this.currentElement){
this.currentElement.appendChild(charNode); this.currentElement.appendChild(charNode);
}else if(/^\s*$/.test(chars)){
this.doc.appendChild(charNode);
//process xml
} }
this.locator && position(this.locator,charNode) this.locator && position(this.locator,charNode)
} }
@ -135,7 +137,7 @@ DOMHandler.prototype = {
skippedEntity:function(name) { skippedEntity:function(name) {
}, },
endDocument:function() { endDocument:function() {
this.document.normalize(); this.doc.normalize();
}, },
setDocumentLocator:function (locator) { setDocumentLocator:function (locator) {
if(this.locator = locator){// && !('lineNumber' in locator)){ if(this.locator = locator){// && !('lineNumber' in locator)){
@ -145,7 +147,7 @@ DOMHandler.prototype = {
//LexicalHandler //LexicalHandler
comment:function(chars, start, length) { comment:function(chars, start, length) {
chars = _toString.apply(this,arguments) chars = _toString.apply(this,arguments)
var comm = this.document.createComment(chars); var comm = this.doc.createComment(chars);
this.locator && position(this.locator,comm) this.locator && position(this.locator,comm)
appendElement(this, comm); appendElement(this, comm);
}, },
@ -159,7 +161,7 @@ DOMHandler.prototype = {
}, },
startDTD:function(name, publicId, systemId) { startDTD:function(name, publicId, systemId) {
var impl = this.document.implementation; var impl = this.doc.implementation;
if (impl && impl.createDocumentType) { if (impl && impl.createDocumentType) {
var dt = impl.createDocumentType(name, publicId, systemId); var dt = impl.createDocumentType(name, publicId, systemId);
this.locator && position(this.locator,dt) this.locator && position(this.locator,dt)
@ -235,15 +237,15 @@ function _toString(chars,start,length){
/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */ /* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
function appendElement (hander,node) { function appendElement (hander,node) {
if (!hander.currentElement) { if (!hander.currentElement) {
hander.document.appendChild(node); hander.doc.appendChild(node);
} else { } else {
hander.currentElement.appendChild(node); hander.currentElement.appendChild(node);
} }
}//appendChild and setAttributeNS are preformance key }//appendChild and setAttributeNS are preformance key
if(typeof require == 'function'){ //if(typeof require == 'function'){
var XMLReader = require('./sax').XMLReader; var XMLReader = require('./sax').XMLReader;
var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation; var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation;
exports.XMLSerializer = require('./dom').XMLSerializer ; exports.XMLSerializer = require('./dom').XMLSerializer ;
exports.DOMParser = DOMParser; exports.DOMParser = DOMParser;
} //}

163
node_modules/xmldom/dom.js generated vendored
View File

@ -110,9 +110,9 @@ NodeList.prototype = {
item: function(index) { item: function(index) {
return this[index] || null; return this[index] || null;
}, },
toString:function(){ toString:function(isHTML,nodeFilter){
for(var buf = [], i = 0;i<this.length;i++){ for(var buf = [], i = 0;i<this.length;i++){
serializeToString(this[i],buf); serializeToString(this[i],buf,isHTML,nodeFilter);
} }
return buf.join(''); return buf.join('');
} }
@ -170,6 +170,7 @@ function _addNamedNode(el,list,newAttr,oldAttr){
} }
} }
function _removeNamedNode(el,list,attr){ function _removeNamedNode(el,list,attr){
//console.log('remove attr:'+attr)
var i = _findNodeIndex(list,attr); var i = _findNodeIndex(list,attr);
if(i>=0){ if(i>=0){
var lastIndex = list.length-1 var lastIndex = list.length-1
@ -185,7 +186,7 @@ function _removeNamedNode(el,list,attr){
} }
} }
}else{ }else{
throw DOMException(NOT_FOUND_ERR,new Error()) throw DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr))
} }
} }
NamedNodeMap.prototype = { NamedNodeMap.prototype = {
@ -195,9 +196,11 @@ NamedNodeMap.prototype = {
// if(key.indexOf(':')>0 || key == 'xmlns'){ // if(key.indexOf(':')>0 || key == 'xmlns'){
// return null; // return null;
// } // }
//console.log()
var i = this.length; var i = this.length;
while(i--){ while(i--){
var attr = this[i]; var attr = this[i];
//console.log(attr.nodeName,key)
if(attr.nodeName == key){ if(attr.nodeName == key){
return attr; return attr;
} }
@ -379,7 +382,7 @@ Node.prototype = {
} }
} }
} }
el = el.nodeType == 2?el.ownerDocument : el.parentNode; el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
} }
return null; return null;
}, },
@ -394,7 +397,7 @@ Node.prototype = {
return map[prefix] ; return map[prefix] ;
} }
} }
el = el.nodeType == 2?el.ownerDocument : el.parentNode; el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
} }
return null; return null;
}, },
@ -579,7 +582,7 @@ Document.prototype = {
} }
return newChild; return newChild;
} }
if(this.documentElement == null && newChild.nodeType == 1){ if(this.documentElement == null && newChild.nodeType == ELEMENT_NODE){
this.documentElement = newChild; this.documentElement = newChild;
} }
@ -599,7 +602,7 @@ Document.prototype = {
getElementById : function(id){ getElementById : function(id){
var rtv = null; var rtv = null;
_visitNode(this.documentElement,function(node){ _visitNode(this.documentElement,function(node){
if(node.nodeType == 1){ if(node.nodeType == ELEMENT_NODE){
if(node.getAttribute('id') == id){ if(node.getAttribute('id') == id){
rtv = node; rtv = node;
return true; return true;
@ -748,6 +751,7 @@ Element.prototype = {
return this.attributes.setNamedItemNS(newAttr); return this.attributes.setNamedItemNS(newAttr);
}, },
removeAttributeNode : function(oldAttr){ removeAttributeNode : function(oldAttr){
//console.log(this == oldAttr.ownerElement)
return this.attributes.removeNamedItem(oldAttr.nodeName); return this.attributes.removeNamedItem(oldAttr.nodeName);
}, },
//get real attribute name,and remove it by removeAttributeNode //get real attribute name,and remove it by removeAttributeNode
@ -792,6 +796,7 @@ Element.prototype = {
} }
}); });
return ls; return ls;
}); });
} }
}; };
@ -823,10 +828,7 @@ CharacterData.prototype = {
}, },
appendChild:function(newChild){ appendChild:function(newChild){
//if(!(newChild instanceof CharacterData)){ throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])
throw new Error(ExceptionMessage[3])
//}
return Node.prototype.appendChild.apply(this,arguments)
}, },
deleteData: function(offset, count) { deleteData: function(offset, count) {
this.replaceData(offset,count,""); this.replaceData(offset,count,"");
@ -908,39 +910,132 @@ function ProcessingInstruction() {
ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE; ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
_extends(ProcessingInstruction,Node); _extends(ProcessingInstruction,Node);
function XMLSerializer(){} function XMLSerializer(){}
XMLSerializer.prototype.serializeToString = function(node,attributeSorter){ XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){
return node.toString(attributeSorter); return nodeSerializeToString.call(node,isHtml,nodeFilter);
} }
Node.prototype.toString =function(attributeSorter){ Node.prototype.toString = nodeSerializeToString;
function nodeSerializeToString(isHtml,nodeFilter){
var buf = []; var buf = [];
serializeToString(this,buf,attributeSorter); var refNode = this.nodeType == 9?this.documentElement:this;
var prefix = refNode.prefix;
var uri = refNode.namespaceURI;
if(uri && prefix == null){
//console.log(prefix)
var prefix = refNode.lookupPrefix(uri);
if(prefix == null){
//isHTML = true;
var visibleNamespaces=[
{namespace:uri,prefix:null}
//{namespace:uri,prefix:''}
]
}
}
serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces);
//console.log('###',this.nodeType,uri,prefix,buf.join(''))
return buf.join(''); return buf.join('');
} }
function serializeToString(node,buf,attributeSorter,isHTML){ function needNamespaceDefine(node,isHTML, visibleNamespaces) {
var prefix = node.prefix||'';
var uri = node.namespaceURI;
if (!prefix && !uri){
return false;
}
if (prefix === "xml" && uri === "http://www.w3.org/XML/1998/namespace"
|| uri == 'http://www.w3.org/2000/xmlns/'){
return false;
}
var i = visibleNamespaces.length
//console.log('@@@@',node.tagName,prefix,uri,visibleNamespaces)
while (i--) {
var ns = visibleNamespaces[i];
// get namespace prefix
//console.log(node.nodeType,node.tagName,ns.prefix,prefix)
if (ns.prefix == prefix){
return ns.namespace != uri;
}
}
//console.log(isHTML,uri,prefix=='')
//if(isHTML && prefix ==null && uri == 'http://www.w3.org/1999/xhtml'){
// return false;
//}
//node.flag = '11111'
//console.error(3,true,node.flag,node.prefix,node.namespaceURI)
return true;
}
function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
if(nodeFilter){
node = nodeFilter(node);
if(node){
if(typeof node == 'string'){
buf.push(node);
return;
}
}else{
return;
}
//buf.sort.apply(attrs, attributeSorter);
}
switch(node.nodeType){ switch(node.nodeType){
case ELEMENT_NODE: case ELEMENT_NODE:
if (!visibleNamespaces) visibleNamespaces = [];
var startVisibleNamespaces = visibleNamespaces.length;
var attrs = node.attributes; var attrs = node.attributes;
var len = attrs.length; var len = attrs.length;
var child = node.firstChild; var child = node.firstChild;
var nodeName = node.tagName; var nodeName = node.tagName;
isHTML = (htmlns === node.namespaceURI) ||isHTML isHTML = (htmlns === node.namespaceURI) ||isHTML
buf.push('<',nodeName); buf.push('<',nodeName);
if(attributeSorter){
buf.sort.apply(attrs, attributeSorter);
for(var i=0;i<len;i++){
// add namespaces for attributes
var attr = attrs.item(i);
if (attr.prefix == 'xmlns') {
visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
}else if(attr.nodeName == 'xmlns'){
visibleNamespaces.push({ prefix: '', namespace: attr.value });
}
} }
for(var i=0;i<len;i++){ for(var i=0;i<len;i++){
serializeToString(attrs.item(i),buf,attributeSorter,isHTML); var attr = attrs.item(i);
if (needNamespaceDefine(attr,isHTML, visibleNamespaces)) {
var prefix = attr.prefix||'';
var uri = attr.namespaceURI;
var ns = prefix ? ' xmlns:' + prefix : " xmlns";
buf.push(ns, '="' , uri , '"');
visibleNamespaces.push({ prefix: prefix, namespace:uri });
}
serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
} }
if(child || isHTML && !/^(?:meta|link|img|br|hr|input|button)$/i.test(nodeName)){ // add namespace for current node
if (needNamespaceDefine(node,isHTML, visibleNamespaces)) {
var prefix = node.prefix||'';
var uri = node.namespaceURI;
var ns = prefix ? ' xmlns:' + prefix : " xmlns";
buf.push(ns, '="' , uri , '"');
visibleNamespaces.push({ prefix: prefix, namespace:uri });
}
if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
buf.push('>'); buf.push('>');
//if is cdata child node //if is cdata child node
if(isHTML && /^script$/i.test(nodeName)){ if(isHTML && /^script$/i.test(nodeName)){
if(child){
buf.push(child.data);
}
}else{
while(child){ while(child){
serializeToString(child,buf,attributeSorter,isHTML); if(child.data){
buf.push(child.data);
}else{
serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
}
child = child.nextSibling;
}
}else
{
while(child){
serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
child = child.nextSibling; child = child.nextSibling;
} }
} }
@ -948,12 +1043,14 @@ function serializeToString(node,buf,attributeSorter,isHTML){
}else{ }else{
buf.push('/>'); buf.push('/>');
} }
// remove added visible namespaces
//visibleNamespaces.length = startVisibleNamespaces;
return; return;
case DOCUMENT_NODE: case DOCUMENT_NODE:
case DOCUMENT_FRAGMENT_NODE: case DOCUMENT_FRAGMENT_NODE:
var child = node.firstChild; var child = node.firstChild;
while(child){ while(child){
serializeToString(child,buf,attributeSorter,isHTML); serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
child = child.nextSibling; child = child.nextSibling;
} }
return; return;
@ -1098,8 +1195,8 @@ try{
}, },
set:function(data){ set:function(data){
switch(this.nodeType){ switch(this.nodeType){
case 1: case ELEMENT_NODE:
case 11: case DOCUMENT_FRAGMENT_NODE:
while(this.firstChild){ while(this.firstChild){
this.removeChild(this.firstChild); this.removeChild(this.firstChild);
} }
@ -1110,7 +1207,7 @@ try{
default: default:
//TODO: //TODO:
this.data = data; this.data = data;
this.value = value; this.value = data;
this.nodeValue = data; this.nodeValue = data;
} }
} }
@ -1118,8 +1215,8 @@ try{
function getTextContent(node){ function getTextContent(node){
switch(node.nodeType){ switch(node.nodeType){
case 1: case ELEMENT_NODE:
case 11: case DOCUMENT_FRAGMENT_NODE:
var buf = []; var buf = [];
node = node.firstChild; node = node.firstChild;
while(node){ while(node){
@ -1141,7 +1238,7 @@ try{
}catch(e){//ie8 }catch(e){//ie8
} }
if(typeof require == 'function'){ //if(typeof require == 'function'){
exports.DOMImplementation = DOMImplementation; exports.DOMImplementation = DOMImplementation;
exports.XMLSerializer = XMLSerializer; exports.XMLSerializer = XMLSerializer;
} //}

23
node_modules/xmldom/package.json generated vendored
View File

@ -10,15 +10,18 @@
"spec": ">=0.1.0 <0.2.0", "spec": ">=0.1.0 <0.2.0",
"type": "range" "type": "range"
}, },
"/Users/steveng/repo/cordova/cordova-android/node_modules/plist" "/Users/maj/src/cordova-android/node_modules/plist"
] ]
], ],
"_from": "xmldom@>=0.1.0 <0.2.0", "_from": "xmldom@>=0.1.0 <0.2.0",
"_id": "xmldom@0.1.22", "_id": "xmldom@0.1.27",
"_inCache": true, "_inCache": true,
"_installable": true,
"_location": "/xmldom", "_location": "/xmldom",
"_nodeVersion": "5.5.0", "_nodeVersion": "5.5.0",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/xmldom-0.1.27.tgz_1480305406093_0.9070004557725042"
},
"_npmUser": { "_npmUser": {
"name": "jindw", "name": "jindw",
"email": "jindw@xidea.org" "email": "jindw@xidea.org"
@ -37,11 +40,11 @@
"_requiredBy": [ "_requiredBy": [
"/plist" "/plist"
], ],
"_resolved": "http://registry.npmjs.org/xmldom/-/xmldom-0.1.22.tgz", "_resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.27.tgz",
"_shasum": "10de4e5e964981f03c8cc72fadc08d14b6c3aa26", "_shasum": "d501f97b3bdb403af8ef9ecc20573187aadac0e9",
"_shrinkwrap": null, "_shrinkwrap": null,
"_spec": "xmldom@0.1.x", "_spec": "xmldom@0.1.x",
"_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/plist", "_where": "/Users/maj/src/cordova-android/node_modules/plist",
"author": { "author": {
"name": "jindw", "name": "jindw",
"email": "jindw@xidea.org", "email": "jindw@xidea.org",
@ -75,13 +78,13 @@
}, },
"directories": {}, "directories": {},
"dist": { "dist": {
"shasum": "10de4e5e964981f03c8cc72fadc08d14b6c3aa26", "shasum": "d501f97b3bdb403af8ef9ecc20573187aadac0e9",
"tarball": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.22.tgz" "tarball": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.27.tgz"
}, },
"engines": { "engines": {
"node": ">=0.1" "node": ">=0.1"
}, },
"gitHead": "29a83b315aef56c156602286b2d884a3b4c2521f", "gitHead": "b53aa82a36160d85faab394035dcd1784764537f",
"homepage": "https://github.com/jindw/xmldom", "homepage": "https://github.com/jindw/xmldom",
"keywords": [ "keywords": [
"w3c", "w3c",
@ -132,5 +135,5 @@
"scripts": { "scripts": {
"test": "proof platform win32 && proof test */*/*.t.js || t/test" "test": "proof platform win32 && proof test */*/*.t.js || t/test"
}, },
"version": "0.1.22" "version": "0.1.27"
} }

217
node_modules/xmldom/sax.js generated vendored
View File

@ -2,21 +2,21 @@
//[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040] //[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
//[5] Name ::= NameStartChar (NameChar)* //[5] Name ::= NameStartChar (NameChar)*
var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]///\u10000-\uEFFFF var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]///\u10000-\uEFFFF
var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\u00B7\u0300-\u036F\\u203F-\u2040]"); var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$'); var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
//var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/ //var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
//var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',') //var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')
//S_TAG, S_ATTR, S_EQ, S_V //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
//S_ATTR_S, S_E, S_S, S_C //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
var S_TAG = 0;//tag name offerring var S_TAG = 0;//tag name offerring
var S_ATTR = 1;//attr name offerring var S_ATTR = 1;//attr name offerring
var S_ATTR_S=2;//attr name end and space offer var S_ATTR_SPACE=2;//attr name end and space offer
var S_EQ = 3;//=space? var S_EQ = 3;//=space?
var S_V = 4;//attr value(no quot value only) var S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only)
var S_E = 5;//attr value end and no space(quot end) var S_ATTR_END = 5;//attr value end and no space(quot end)
var S_S = 6;//(attr value end || tag end ) && (space offer) var S_TAG_SPACE = 6;//(attr value end || tag end ) && (space offer)
var S_C = 7;//closed el<el /> var S_TAG_CLOSE = 7;//closed el<el />
function XMLReader(){ function XMLReader(){
@ -33,7 +33,7 @@ XMLReader.prototype = {
} }
} }
function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
function fixedFromCharCode(code) { function fixedFromCharCode(code) {
// String.prototype.fromCharCode does not supports // String.prototype.fromCharCode does not supports
// > 2 bytes unicode chars directly // > 2 bytes unicode chars directly
if (code > 0xffff) { if (code > 0xffff) {
@ -76,7 +76,7 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
} }
var lineStart = 0; var lineStart = 0;
var lineEnd = 0; var lineEnd = 0;
var linePattern = /.+(?:\r\n?|\n)|.*$/g var linePattern = /.*(?:\r\n?|\n)|.*$/g
var locator = domBuilder.locator; var locator = domBuilder.locator;
var parseStack = [{currentNSMap:defaultNSMapCopy}] var parseStack = [{currentNSMap:defaultNSMapCopy}]
@ -87,7 +87,7 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
var tagStart = source.indexOf('<',start); var tagStart = source.indexOf('<',start);
if(tagStart<0){ if(tagStart<0){
if(!source.substr(start).match(/^\s*$/)){ if(!source.substr(start).match(/^\s*$/)){
var doc = domBuilder.document; var doc = domBuilder.doc;
var text = doc.createTextNode(source.substr(start)); var text = doc.createTextNode(source.substr(start));
doc.appendChild(text); doc.appendChild(text);
domBuilder.currentElement = text; domBuilder.currentElement = text;
@ -102,16 +102,36 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
var end = source.indexOf('>',tagStart+3); var end = source.indexOf('>',tagStart+3);
var tagName = source.substring(tagStart+2,end); var tagName = source.substring(tagStart+2,end);
var config = parseStack.pop(); var config = parseStack.pop();
var localNSMap = config.localNSMap; if(end<0){
if(config.tagName != tagName){
errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName ); tagName = source.substring(tagStart+2).replace(/[\s<].*/,'');
} //console.error('#@@@@@@'+tagName)
domBuilder.endElement(config.uri,config.localName,tagName); errorHandler.error("end tag name: "+tagName+' is not complete:'+config.tagName);
if(localNSMap){ end = tagStart+1+tagName.length;
for(var prefix in localNSMap){ }else if(tagName.match(/\s</)){
domBuilder.endPrefixMapping(prefix) ; tagName = tagName.replace(/[\s<].*/,'');
} errorHandler.error("end tag name: "+tagName+' maybe not complete');
end = tagStart+1+tagName.length;
} }
//console.error(parseStack.length,parseStack)
//console.error(config);
var localNSMap = config.localNSMap;
var endMatch = config.tagName == tagName;
var endIgnoreCaseMach = endMatch || config.tagName&&config.tagName.toLowerCase() == tagName.toLowerCase()
if(endIgnoreCaseMach){
domBuilder.endElement(config.uri,config.localName,tagName);
if(localNSMap){
for(var prefix in localNSMap){
domBuilder.endPrefixMapping(prefix) ;
}
}
if(!endMatch){
errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName );
}
}else{
parseStack.push(config)
}
end++; end++;
break; break;
// end elment // end elment
@ -124,33 +144,40 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
end = parseDCC(source,tagStart,domBuilder,errorHandler); end = parseDCC(source,tagStart,domBuilder,errorHandler);
break; break;
default: default:
locator&&position(tagStart); locator&&position(tagStart);
var el = new ElementAttributes(); var el = new ElementAttributes();
var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
//elStartEnd //elStartEnd
var end = parseElementStartPart(source,tagStart,el,entityReplacer,errorHandler); var end = parseElementStartPart(source,tagStart,el,currentNSMap,entityReplacer,errorHandler);
var len = el.length; var len = el.length;
if(locator){
if(len){
//attribute position fixed
for(var i = 0;i<len;i++){
var a = el[i];
position(a.offset);
a.offset = copyLocator(locator,{});
}
}
position(end);
}
if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){ if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){
el.closed = true; el.closed = true;
if(!entityMap.nbsp){ if(!entityMap.nbsp){
errorHandler.warning('unclosed xml attribute'); errorHandler.warning('unclosed xml attribute');
} }
} }
appendElement(el,domBuilder,parseStack); if(locator && len){
var locator2 = copyLocator(locator,{});
//try{//attribute position fixed
for(var i = 0;i<len;i++){
var a = el[i];
position(a.offset);
a.locator = copyLocator(locator,{});
}
//}catch(e){console.error('@@@@@'+e)}
domBuilder.locator = locator2
if(appendElement(el,domBuilder,currentNSMap)){
parseStack.push(el)
}
domBuilder.locator = locator;
}else{
if(appendElement(el,domBuilder,currentNSMap)){
parseStack.push(el)
}
}
if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){ if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){
@ -160,8 +187,10 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
} }
} }
}catch(e){ }catch(e){
errorHandler.error('element parse error: '+e); errorHandler.error('element parse error: '+e)
//errorHandler.error('element parse error: '+e);
end = -1; end = -1;
//throw e;
} }
if(end>start){ if(end>start){
start = end; start = end;
@ -181,7 +210,7 @@ function copyLocator(f,t){
* @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack); * @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack);
* @return end of the elementStartPart(end of elementEndPart for selfClosed el) * @return end of the elementStartPart(end of elementEndPart for selfClosed el)
*/ */
function parseElementStartPart(source,start,el,entityReplacer,errorHandler){ function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){
var attrName; var attrName;
var value; var value;
var p = ++start; var p = ++start;
@ -193,7 +222,7 @@ function parseElementStartPart(source,start,el,entityReplacer,errorHandler){
if(s === S_ATTR){//attrName if(s === S_ATTR){//attrName
attrName = source.slice(start,p); attrName = source.slice(start,p);
s = S_EQ; s = S_EQ;
}else if(s === S_ATTR_S){ }else if(s === S_ATTR_SPACE){
s = S_EQ; s = S_EQ;
}else{ }else{
//fatalError: equal must after attrName or space after attrName //fatalError: equal must after attrName or space after attrName
@ -202,25 +231,30 @@ function parseElementStartPart(source,start,el,entityReplacer,errorHandler){
break; break;
case '\'': case '\'':
case '"': case '"':
if(s === S_EQ){//equal if(s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE
){//equal
if(s === S_ATTR){
errorHandler.warning('attribute value must after "="')
attrName = source.slice(start,p)
}
start = p+1; start = p+1;
p = source.indexOf(c,start) p = source.indexOf(c,start)
if(p>0){ if(p>0){
value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer); value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
el.add(attrName,value,start-1); el.add(attrName,value,start-1);
s = S_E; s = S_ATTR_END;
}else{ }else{
//fatalError: no end quot match //fatalError: no end quot match
throw new Error('attribute value no end \''+c+'\' match'); throw new Error('attribute value no end \''+c+'\' match');
} }
}else if(s == S_V){ }else if(s == S_ATTR_NOQUOT_VALUE){
value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer); value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
//console.log(attrName,value,start,p) //console.log(attrName,value,start,p)
el.add(attrName,value,start); el.add(attrName,value,start);
//console.dir(el) //console.dir(el)
errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!'); errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!');
start = p+1; start = p+1;
s = S_E s = S_ATTR_END
}else{ }else{
//fatalError: no equal before //fatalError: no equal before
throw new Error('attribute value must after "="'); throw new Error('attribute value must after "="');
@ -230,14 +264,14 @@ function parseElementStartPart(source,start,el,entityReplacer,errorHandler){
switch(s){ switch(s){
case S_TAG: case S_TAG:
el.setTagName(source.slice(start,p)); el.setTagName(source.slice(start,p));
case S_E: case S_ATTR_END:
case S_S: case S_TAG_SPACE:
case S_C: case S_TAG_CLOSE:
s = S_C; s =S_TAG_CLOSE;
el.closed = true; el.closed = true;
case S_V: case S_ATTR_NOQUOT_VALUE:
case S_ATTR: case S_ATTR:
case S_ATTR_S: case S_ATTR_SPACE:
break; break;
//case S_EQ: //case S_EQ:
default: default:
@ -247,30 +281,36 @@ function parseElementStartPart(source,start,el,entityReplacer,errorHandler){
case ''://end document case ''://end document
//throw new Error('unexpected end of input') //throw new Error('unexpected end of input')
errorHandler.error('unexpected end of input'); errorHandler.error('unexpected end of input');
if(s == S_TAG){
el.setTagName(source.slice(start,p));
}
return p;
case '>': case '>':
switch(s){ switch(s){
case S_TAG: case S_TAG:
el.setTagName(source.slice(start,p)); el.setTagName(source.slice(start,p));
case S_E: case S_ATTR_END:
case S_S: case S_TAG_SPACE:
case S_C: case S_TAG_CLOSE:
break;//normal break;//normal
case S_V://Compatible state case S_ATTR_NOQUOT_VALUE://Compatible state
case S_ATTR: case S_ATTR:
value = source.slice(start,p); value = source.slice(start,p);
if(value.slice(-1) === '/'){ if(value.slice(-1) === '/'){
el.closed = true; el.closed = true;
value = value.slice(0,-1) value = value.slice(0,-1)
} }
case S_ATTR_S: case S_ATTR_SPACE:
if(s === S_ATTR_S){ if(s === S_ATTR_SPACE){
value = attrName; value = attrName;
} }
if(s == S_V){ if(s == S_ATTR_NOQUOT_VALUE){
errorHandler.warning('attribute "'+value+'" missed quot(")!!'); errorHandler.warning('attribute "'+value+'" missed quot(")!!');
el.add(attrName,value.replace(/&#?\w+;/g,entityReplacer),start) el.add(attrName,value.replace(/&#?\w+;/g,entityReplacer),start)
}else{ }else{
errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!') if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !value.match(/^(?:disabled|checked|selected)$/i)){
errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!')
}
el.add(value,value,start) el.add(value,value,start)
} }
break; break;
@ -287,64 +327,68 @@ function parseElementStartPart(source,start,el,entityReplacer,errorHandler){
switch(s){ switch(s){
case S_TAG: case S_TAG:
el.setTagName(source.slice(start,p));//tagName el.setTagName(source.slice(start,p));//tagName
s = S_S; s = S_TAG_SPACE;
break; break;
case S_ATTR: case S_ATTR:
attrName = source.slice(start,p) attrName = source.slice(start,p)
s = S_ATTR_S; s = S_ATTR_SPACE;
break; break;
case S_V: case S_ATTR_NOQUOT_VALUE:
var value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer); var value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
errorHandler.warning('attribute "'+value+'" missed quot(")!!'); errorHandler.warning('attribute "'+value+'" missed quot(")!!');
el.add(attrName,value,start) el.add(attrName,value,start)
case S_E: case S_ATTR_END:
s = S_S; s = S_TAG_SPACE;
break; break;
//case S_S: //case S_TAG_SPACE:
//case S_EQ: //case S_EQ:
//case S_ATTR_S: //case S_ATTR_SPACE:
// void();break; // void();break;
//case S_C: //case S_TAG_CLOSE:
//ignore warning //ignore warning
} }
}else{//not space }else{//not space
//S_TAG, S_ATTR, S_EQ, S_V //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
//S_ATTR_S, S_E, S_S, S_C //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
switch(s){ switch(s){
//case S_TAG:void();break; //case S_TAG:void();break;
//case S_ATTR:void();break; //case S_ATTR:void();break;
//case S_V:void();break; //case S_ATTR_NOQUOT_VALUE:void();break;
case S_ATTR_S: case S_ATTR_SPACE:
errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead!!') var tagName = el.tagName;
if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !attrName.match(/^(?:disabled|checked|selected)$/i)){
errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!')
}
el.add(attrName,attrName,start); el.add(attrName,attrName,start);
start = p; start = p;
s = S_ATTR; s = S_ATTR;
break; break;
case S_E: case S_ATTR_END:
errorHandler.warning('attribute space is required"'+attrName+'"!!') errorHandler.warning('attribute space is required"'+attrName+'"!!')
case S_S: case S_TAG_SPACE:
s = S_ATTR; s = S_ATTR;
start = p; start = p;
break; break;
case S_EQ: case S_EQ:
s = S_V; s = S_ATTR_NOQUOT_VALUE;
start = p; start = p;
break; break;
case S_C: case S_TAG_CLOSE:
throw new Error("elements closed character '/' and '>' must be connected to"); throw new Error("elements closed character '/' and '>' must be connected to");
} }
} }
} }//end outer switch
//console.log('p++',p)
p++; p++;
} }
} }
/** /**
* @return end of the elementStartPart(end of elementEndPart for selfClosed el) * @return true if has new namespace define
*/ */
function appendElement(el,domBuilder,parseStack){ function appendElement(el,domBuilder,currentNSMap){
var tagName = el.tagName; var tagName = el.tagName;
var localNSMap = null; var localNSMap = null;
var currentNSMap = parseStack[parseStack.length-1].currentNSMap; //var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
var i = el.length; var i = el.length;
while(i--){ while(i--){
var a = el[i]; var a = el[i];
@ -383,7 +427,7 @@ function appendElement(el,domBuilder,parseStack){
if(prefix === 'xml'){ if(prefix === 'xml'){
a.uri = 'http://www.w3.org/XML/1998/namespace'; a.uri = 'http://www.w3.org/XML/1998/namespace';
}if(prefix !== 'xmlns'){ }if(prefix !== 'xmlns'){
a.uri = currentNSMap[prefix] a.uri = currentNSMap[prefix || '']
//{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)} //{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}
} }
@ -412,7 +456,8 @@ function appendElement(el,domBuilder,parseStack){
}else{ }else{
el.currentNSMap = currentNSMap; el.currentNSMap = currentNSMap;
el.localNSMap = localNSMap; el.localNSMap = localNSMap;
parseStack.push(el); //parseStack.push(el);
return true;
} }
} }
function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){ function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){
@ -442,7 +487,11 @@ function fixSelfClosed(source,elStartEnd,tagName,closeMap){
var pos = closeMap[tagName]; var pos = closeMap[tagName];
if(pos == null){ if(pos == null){
//console.log(tagName) //console.log(tagName)
pos = closeMap[tagName] = source.lastIndexOf('</'+tagName+'>') pos = source.lastIndexOf('</'+tagName+'>')
if(pos<elStartEnd){//忘记闭合
pos = source.lastIndexOf('</'+tagName)
}
closeMap[tagName] =pos
} }
return pos<elStartEnd; return pos<elStartEnd;
//} //}
@ -533,7 +582,7 @@ ElementAttributes.prototype = {
}, },
length:0, length:0,
getLocalName:function(i){return this[i].localName}, getLocalName:function(i){return this[i].localName},
getOffset:function(i){return this[i].offset}, getLocator:function(i){return this[i].locator},
getQName:function(i){return this[i].qName}, getQName:function(i){return this[i].qName},
getURI:function(i){return this[i].uri}, getURI:function(i){return this[i].uri},
getValue:function(i){return this[i].value} getValue:function(i){return this[i].value}
@ -580,7 +629,5 @@ function split(source,start){
} }
} }
if(typeof require == 'function'){ exports.XMLReader = XMLReader;
exports.XMLReader = XMLReader;
}

View File

@ -24,7 +24,7 @@
"author": "Apache Software Foundation", "author": "Apache Software Foundation",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"cordova-common": "^1.5.0", "cordova-common": "^2.0.1",
"elementtree": "^0.1.6", "elementtree": "^0.1.6",
"nopt": "^3.0.1", "nopt": "^3.0.1",
"properties-parser": "^0.2.3", "properties-parser": "^0.2.3",

7
spec/fixtures/android_list_avd.txt vendored Normal file
View File

@ -0,0 +1,7 @@
Available Android Virtual Devices:
Name: QWR
Device: Nexus 5 (Google)
Path: /Users/shazron/.android/avd/QWR.avd
Target: Android 7.1.1 (API level 25)
Tag/ABI: google_apis/x86_64
Skin: 1080x1920

22
spec/fixtures/avdmanager_list_avd.txt vendored Normal file
View File

@ -0,0 +1,22 @@
Available Android Virtual Devices:
Name: nexus5-5.1
Device: Nexus 5 (Google)
Path: /Users/maj/.android/avd/nexus5-5.1.avd
Target: Google APIs
Based on: Android 5.1 (Lollipop) Tag/ABI: google_apis/x86_64
Skin: 1080x1920
Sdcard: 128M
---------
Name: Pixel_API_25
Device: pixel (Google)
Path: /Users/maj/.android/avd/Pixel_API_25.avd
Target: Google APIs
Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86_64
Skin: pixel
Sdcard: 100M
---------
Name: stock51
Path: /Users/maj/.android/avd/stock51.avd
Target: Default
Based on: Android 5.1 (Lollipop) Tag/ABI: default/x86_64
Sdcard: 128M

107
spec/unit/emulator.spec.js Normal file
View File

@ -0,0 +1,107 @@
/**
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 cc = require("cordova-common");
var emu = require("../../bin/templates/cordova/lib/emulator");
var Q = require("q");
var fs = require("fs");
var path = require("path");
var shelljs = require("shelljs");
describe("emulator", function () {
describe("list_images_using_avdmanager", function() {
it("should properly parse details of SDK Tools 25.3.1 `avdmanager` output", function(done) {
var deferred = Q.defer();
spyOn(cc.superspawn, "spawn").and.returnValue(deferred.promise);
deferred.resolve(fs.readFileSync(path.join("spec", "fixtures", "avdmanager_list_avd.txt"), "utf-8"));
return emu.list_images_using_avdmanager()
.then(function(list) {
expect(list).toBeDefined();
expect(list[0].name).toEqual("nexus5-5.1");
expect(list[0].target).toEqual("Android 5.1 (API level 22)");
expect(list[1].device).toEqual("pixel (Google)");
expect(list[2].abi).toEqual("default/x86_64");
}).fail(function(err) {
expect(err).toBeUndefined();
}).fin(function() {
done();
});
});
});
describe("list_images_using_android", function() {
it("should properly parse details of SDK Tools pre-25.3.1 `android list avd` output", function(done) {
var deferred = Q.defer();
spyOn(cc.superspawn, "spawn").and.returnValue(deferred.promise);
deferred.resolve(fs.readFileSync(path.join("spec", "fixtures", "android_list_avd.txt"), "utf-8"));
return emu.list_images_using_android()
.then(function(list) {
expect(list).toBeDefined();
expect(list[0].name).toEqual("QWR");
expect(list[0].device).toEqual("Nexus 5 (Google)");
expect(list[0].path).toEqual("/Users/shazron/.android/avd/QWR.avd");
expect(list[0].target).toEqual("Android 7.1.1 (API level 25)");
expect(list[0].abi).toEqual("google_apis/x86_64");
expect(list[0].skin).toEqual("1080x1920");
}).fail(function(err) {
expect(err).toBeUndefined();
}).fin(function() {
done();
});
});
});
describe("list_images", function() {
beforeEach(function() {
spyOn(fs, "realpathSync").and.callFake(function(cmd) {
return cmd;
});
});
it("should try to parse AVD information using `android`", function() {
spyOn(shelljs, "which").and.callFake(function(cmd) {
if (cmd == "android") {
return true;
} else {
return false;
}
});
var android_spy = spyOn(emu, "list_images_using_android").and.returnValue({catch:function(){}});
emu.list_images();
expect(android_spy).toHaveBeenCalled();
});
it("should catch if `android` exits with non-zero code and specific stdout, and delegate to `avdmanager` if it can find it", function() {
spyOn(shelljs, "which").and.callFake(function(cmd) {
if (cmd == "avdmanager") {
return true;
} else {
return false;
}
});
var avdmanager_spy = spyOn(emu, "list_images_using_avdmanager");
emu.list_images();
expect(avdmanager_spy).toHaveBeenCalled();
});
it("should throw an error if neither `avdmanager` nor `android` are able to be found", function(done) {
spyOn(shelljs, "which").and.returnValue(false);
return emu.list_images()
.catch(function(err) {
expect(err).toBeDefined();
expect(err.message).toContain("Could not find either `android` or `avdmanager`");
done();
});
});
});
});