Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #189 from manifoldjs/v0.4.3-development
Browse files Browse the repository at this point in the history
V0.4.3 development
  • Loading branch information
msrodri committed Nov 26, 2015
2 parents d734deb + dc30aa3 commit 510145f
Show file tree
Hide file tree
Showing 28 changed files with 943 additions and 104 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ coverage.html
*.njsproj
*.suo
*.sln
.settings
.settings
launch.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ grunt
## Supported Input Manifests

- [W3C Web App](http://www.w3.org/TR/appmanifest/)
- [Chrome Hosted Apps](https://developers.google.com/chrome/apps/docs/developers_guide)

We plan to support the following manifest files in the future:

- [Web App Template](http://wat-docs.azurewebsites.net/JsonWindows)
- [Chrome Hosted Apps](https://developers.google.com/chrome/apps/docs/developers_guide)
- [Firefox Open Web Apps](https://developer.mozilla.org/Apps/Build/Manifest)

## Navigation Scope
Expand Down
13 changes: 13 additions & 0 deletions lib/common/utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 26 additions & 1 deletion lib/manifestTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var fs = require('fs'),
c = require('./manifestTools/constants'),
validationConstants = require('./manifestTools/validationConstants'),
log = require('loglevel'),
chromeToW3c = require('./platformUtils/chromeToW3c.js'),
Q = require('q'),
// Request settings taken from https://github.com/InternetExplorer/modern.IE-static-code-scan/blob/master/app.js
request = request.defaults({
Expand Down Expand Up @@ -104,6 +105,18 @@ function downloadManifestFromUrl(manifestUrl, callback) {
// assume that it's a W3C manifest
detectedFormat = c.BASE_MANIFEST_FORMAT;
}

// If the detected format is ChromeOS, we attempt to convert it to W3C Manifest format.
if (detectedFormat === c.CHROME_MANIFEST_FORMAT) {
log.info('Found a ' + detectedFormat.toUpperCase() + ' manifest. Attempting to convert to W3C Manifest format...');
manifestObj = chromeToW3c.chromeToW3CManifest(manifestObj);

// Assuming conversion was successful, running the manifest JSON through the detector again will return the W3C format type.
detectedFormat = manifestTypeDetector.detect(manifestObj);
if (detectedFormat === c.BASE_MANIFEST_FORMAT) {
log.info('Conversion to W3C Manifest format successful.');
}
}

var manifestInfo = {
content: manifestObj,
Expand Down Expand Up @@ -171,6 +184,18 @@ function getManifestFromFile(filePath, callback) {
}

var detectedFormat = manifestTypeDetector.detect(manifestObj);

// If the detected format is ChromeOS, we attempt to convert it to W3C Manifest format.
if (detectedFormat === c.CHROME_MANIFEST_FORMAT) {
log.info('Found a ' + detectedFormat.toUpperCase() + ' manifest. Attempting to convert to W3C Manifest format...');
manifestObj = chromeToW3c.chromeToW3CManifest(manifestObj);

// Assuming conversion was successful, running the manifest JSON through the detector again will return the W3C format type.
detectedFormat = manifestTypeDetector.detect(manifestObj);
if (detectedFormat === c.BASE_MANIFEST_FORMAT) {
log.info('Conversion to W3C Manifest format successful.');
}
}

if (!detectedFormat) {
return callback(new Error('Invalid manifest format.'));
Expand All @@ -196,7 +221,7 @@ function validateManifest(manifestInfo, targetPlatforms, callback) {
if (!manifestInfo || !manifestInfo.content) {
return callback(new Error('Manifest content is empty or invalid.'));
}

if (manifestInfo.format !== c.BASE_MANIFEST_FORMAT) {
return callback(new Error('The manifest passed as argument is not a W3C manifest.'));
}
Expand Down
77 changes: 75 additions & 2 deletions lib/manifestTools/assets/web-manifest-extended.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,43 @@
"items": {
"$ref": "#/definitions/mjs_access_whitelist_rule"
}
}
},
"mjs_extended_scope": {
"description": "The mjs_extended_scope member is an array of rules that define the navigation scope of this web application's application context.",
"type": "array",
"items": {
"type": "string", "format": "uri"
}
},
"mjs_api_access": {
"description": "The mjs_api_whitelist member is an array of rules that indicates the type of access to the runtime API the URLs matching the rule should have.",
"type": "array",
"items": {
"$ref": "#/definitions/mjs_api_access_rule"
}
},
"mjs_import_scripts": {
"description": "The mjs_import_scripts member is an array of script files that will be loaded into the application.",
"type": "array",
"items": {
"$ref": "#/definitions/mjs_import_scripts_rule"
}
},
"mjs_cordova": {
"description": "Specify how to load the Cordova and plugin JavaScript files.",
"type": "object",
"properties": {
"plugin_mode" : {
"description" : "Defines where the Cordova and plugin JavaScript files are injected from.",
"enum" : [ "client", "server" ]
},
"base_url" : {
"description": "When pluginMode is configured as “server”, this property specifies the exact location in the server of the Cordova and plugin JavaScript files.",
"type" : "string",
"format" : "uri"
}
}
}
},

"definitions": {
Expand All @@ -25,7 +61,44 @@
},
"apiAccess" : {
"description": "A string that defines the type of access to the runtime API where the application is running.",
"enum": [ "none", "all", "AllowForWebOnly" ]
"enum": [ "none", "all", "allowForWebOnly" ]
}
}
},
"mjs_api_access_rule": {
"type": "object",
"properties": {
"match": {
"description": "A string or array of strings that represent the URL pattern(s) for which the rule should be applied to.",
"oneOf": [
{ "type": "string", "format": "uri" },
{ "type": "array", "items": { "type": "string", "format": "uri" } }
]
},
"platform" : {
"description": "Specifies the platforms for which the rule should be applied to.",
"type": "string"
},
"access" : {
"description": "Defines the type of access to the runtime API where the application is running. Could be extended in the future to accept other types for platforms with different access requirements.",
"type": "string"
}
}
},
"mjs_import_scripts_rule": {
"type": "object",
"properties": {
"src" : {
"description": "The URL where the custom script file is located. The source can be specified as a path of the script file in the app package, or as a full URL to retrieve the file from the server.",
"type": "string",
"format": "uri"
},
"match": {
"description": "A string or array of strings that represent the URL pattern(s) for which the script file should be loaded.",
"oneOf": [
{ "type": "string", "format": "uri" },
{ "type": "array", "items": { "type": "string", "format": "uri" } }
]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/manifestTools/assets/windows10/msapp-error.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<title>Navigation Error</title>
Expand Down
Loading

0 comments on commit 510145f

Please sign in to comment.