This repository has been archived by the owner on Jan 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from manifoldjs/v0.1.1
v0.1.1
- Loading branch information
Showing
17 changed files
with
424 additions
and
68 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *"> | ||
<meta name="format-detection" content="telephone=no"> | ||
<meta name="msapplication-tap-highlight" content="no"> | ||
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> | ||
<link rel="stylesheet" type="text/css" href="css/wrapper.css"> | ||
<title>Hello World</title> | ||
</head> | ||
<body> | ||
<div id="extendedSplashScreen" class="extendedSplashScreen" style="background-color: #464646; height:100%"> | ||
<img class="extendedSplashImage" src="/images/SplashScreen.scale-100.png" alt="Launching..." /> | ||
<progress class="loading-progress"></progress> | ||
</div> | ||
|
||
<script type="text/javascript" src="cordova.js"></script> | ||
<script type="text/javascript" src="js/wrapper.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
var setupExtendedSplashScreen, updateSplashScreenPositioning, | ||
splashScreen, splashScreenEl, splashScreenImageEl, | ||
isWindows = navigator.appVersion.indexOf("Windows Phone 8.1") === -1; | ||
|
||
WinJS.Application.addEventListener("activated", function (e) { | ||
if (e.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) { | ||
splashScreen = e.detail.splashScreen; | ||
|
||
// Listen for window resize events to reposition the extended splash screen image accordingly. | ||
// This is important to ensure that the extended splash screen is formatted properly in response to snapping, unsnapping, rotation, etc... | ||
window.addEventListener("resize", updateSplashPositioning, false); | ||
|
||
var previousExecutionState = e.detail.previousExecutionState; | ||
var state = Windows.ApplicationModel.Activation.ApplicationExecutionState; | ||
if (previousExecutionState === state.notRunning | ||
|| previousExecutionState === state.terminated | ||
|| previousExecutionState === state.closedByUser) { | ||
setupExtendedSplashScreen(); | ||
} | ||
} | ||
}, false); | ||
|
||
setupExtendedSplashScreen = function () { | ||
splashScreenEl = document.getElementById("extendedSplashScreen"); | ||
splashScreenImageEl = (splashScreenEl && splashScreenEl.querySelector(".extendedSplashImage")); | ||
splashLoadingEl = (splashScreenEl && splashScreenEl.querySelector(".loading-progress")); | ||
|
||
if (!splashScreen || !splashScreenEl || !splashScreenImageEl) { return; } | ||
|
||
var imgSrc = "/images/splashScreenPhone.png" | ||
if (isWindows) { | ||
imgSrc = "/images/SplashScreen.png" | ||
} | ||
|
||
splashScreenImageEl.setAttribute("src", imgSrc); | ||
|
||
updateSplashPositioning(); | ||
|
||
// Once the extended splash screen is setup, apply the CSS style that will make the extended splash screen visible. | ||
splashScreenEl.style.display = "block"; | ||
}; | ||
|
||
updateSplashPositioning = function () { | ||
if (!splashScreen || !splashScreenImageEl) { return; } | ||
// Position the extended splash screen image in the same location as the system splash screen image. | ||
if (isWindows) { | ||
splashScreenImageEl.style.top = splashScreen.imageLocation.y + "px"; | ||
splashScreenImageEl.style.left = splashScreen.imageLocation.x + "px"; | ||
splashScreenImageEl.style.height = splashScreen.imageLocation.height + "px"; | ||
splashScreenImageEl.style.width = splashScreen.imageLocation.width + "px"; | ||
} else { | ||
var curOrientation = Windows.Devices.Sensors.SimpleOrientationSensor.getDefault().getCurrentOrientation(); | ||
if ((curOrientation == Windows.Devices.Sensors.SimpleOrientation.rotated270DegreesCounterclockwise || curOrientation == Windows.Devices.Sensors.SimpleOrientation.rotated90DegreesCounterclockwise) && | ||
Windows.Graphics.Display.DisplayInformation.autoRotationPreferences != Windows.Graphics.Display.DisplayOrientations.portrait) { | ||
splashScreenImageEl.src = "/images/splashscreen.png"; | ||
} else { | ||
splashScreenImageEl.src = "/images/splashScreenPhone.png"; | ||
} | ||
splashScreenImageEl.style.width = "100%"; | ||
splashScreenImageEl.style.height = "100%"; | ||
} | ||
|
||
if (splashLoadingEl) { | ||
if (isWindows) { | ||
splashLoadingEl.style.top = (splashScreen.imageLocation.y + splashScreen.imageLocation.height + 20) + "px"; | ||
} else { | ||
splashLoadingEl.style.top = (window.innerHeight * 0.8) + "px"; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
#!/usr/bin/env node | ||
|
||
var fs = require('fs'), | ||
path = require('path'), | ||
url = require('url'), | ||
etree, | ||
projectRoot; | ||
|
||
var logger = { | ||
log: function () { | ||
if (process.env.NODE_ENV !== 'test') { | ||
console.log.apply(this, arguments) | ||
} | ||
}, | ||
warn: function() { | ||
if (process.env.NODE_ENV !== 'test') { | ||
console.warn.apply(this, arguments) | ||
} | ||
} | ||
}; | ||
|
||
function copyFile(source, target, callback) { | ||
var cbCalled = false; | ||
|
||
function done(err) { | ||
if (!cbCalled) { | ||
callback(err); | ||
cbCalled = true; | ||
} | ||
} | ||
|
||
var rd = fs.createReadStream(source); | ||
rd.on('error', done); | ||
|
||
var wr = fs.createWriteStream(target); | ||
wr.on('error', done); | ||
wr.on('close', function() { | ||
done(); | ||
}); | ||
rd.pipe(wr); | ||
}; | ||
|
||
function updateManifestFile(manifestPath) { | ||
var contents = fs.readFileSync(manifestPath, 'utf-8'); | ||
if(contents) { | ||
//Windows is the BOM. Skip the Byte Order Mark. | ||
contents = contents.substring(contents.indexOf('<')); | ||
} | ||
|
||
var startPage = "www/wrapper.html"; | ||
var manifest = new etree.ElementTree(etree.XML(contents)); | ||
var appNode = manifest.find('.//Application'); | ||
|
||
appNode.attrib.StartPage = startPage; | ||
|
||
// Write out manifest | ||
fs.writeFileSync(manifestPath, manifest.write({indent: 4}), 'utf-8'); | ||
} | ||
|
||
function updateWindowsManifests() { | ||
var MANIFEST_WINDOWS8 = 'package.windows80.appxmanifest', | ||
MANIFEST_WINDOWS = 'package.windows.appxmanifest', | ||
MANIFEST_PHONE = 'package.phone.appxmanifest', | ||
MANIFEST_WINDOWS10 = 'package.windows10.appxmanifest'; | ||
|
||
// Apply appxmanifest changes | ||
[ MANIFEST_WINDOWS, | ||
MANIFEST_WINDOWS8, | ||
MANIFEST_PHONE, | ||
MANIFEST_WINDOWS10 ].forEach( | ||
function(manifestFile) { | ||
updateManifestFile(path.join(projectRoot, "platforms", "windows", manifestFile)); | ||
}); | ||
} | ||
|
||
module.exports = function (context) { | ||
projectRoot = context.opts.projectRoot; | ||
|
||
// if the windows folder does not exist, cancell the script | ||
var windowsPath = path.join(projectRoot, "platforms","windows"); | ||
if (!fs.existsSync(windowsPath)) { | ||
return; | ||
} | ||
|
||
etree = context.requireCordovaModule('cordova-lib/node_modules/elementtree'); | ||
|
||
// move contents of the assets folder to the windows platform dir | ||
var Q = context.requireCordovaModule('q'); | ||
|
||
var filename = "wrapper"; | ||
|
||
var sourcePath = path.resolve(__dirname, "..", "assets", "windows", "wrapper.html"); | ||
var destPath = path.join(projectRoot, "platforms","windows", "www", filename + ".html"); | ||
|
||
logger.log('Copying wrapper html file for the windows platform from '+ sourcePath + ' to ' + destPath + '.'); | ||
|
||
var task = Q.defer(); | ||
copyFile(sourcePath, destPath, function (err) { | ||
if (err) { | ||
console.error(err); | ||
return task.reject(err); | ||
} | ||
|
||
console.log("Finished copying wrapper html file for the windows platform."); | ||
|
||
var sourcePath = path.resolve(__dirname, "..", "assets", "windows", "wrapper.js"); | ||
var destPath = path.join(projectRoot, "platforms", "windows", "www", "js", filename +".js"); | ||
|
||
logger.log('Copying wrapper js file for the windows platform from '+ sourcePath + ' to ' + destPath + '.'); | ||
|
||
copyFile(sourcePath, destPath, function (err) { | ||
if (err) { | ||
console.error(err); | ||
return task.reject(err); | ||
} | ||
|
||
console.log("Finished copying wrapper js file for the windows platform."); | ||
|
||
var sourcePath = path.resolve(__dirname, "..", "assets", "windows", "wrapper.css"); | ||
var destPath = path.join(projectRoot, "platforms", "windows", "www", "css", filename + ".css"); | ||
|
||
logger.log('Copying wrapper css file for the windows platform from '+ sourcePath + ' to ' + destPath + '.'); | ||
|
||
copyFile(sourcePath, destPath, function (err) { | ||
if (err) { | ||
console.error(err); | ||
return task.reject(err); | ||
} | ||
|
||
console.log("Finished copying wrapper css file for the windows platform."); | ||
|
||
updateWindowsManifests(); | ||
|
||
task.resolve(); | ||
}); | ||
}); | ||
}); | ||
|
||
return task.promise; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/usr/bin/env node | ||
|
||
var createConfigParser = require('./createConfigParser'), | ||
fs = require('fs'), | ||
path = require('path'), | ||
url = require('url'), | ||
pendingTasks = [], | ||
Q, | ||
config, | ||
projectRoot, | ||
etree; | ||
|
||
var logger = { | ||
log: function () { | ||
if (process.env.NODE_ENV !== 'test') { | ||
console.log.apply(this, arguments) | ||
} | ||
}, | ||
warn: function() { | ||
if (process.env.NODE_ENV !== 'test') { | ||
console.warn.apply(this, arguments) | ||
} | ||
} | ||
}; | ||
|
||
function deleteFile(path) { | ||
var t = Q.defer(); | ||
pendingTasks.push(t); | ||
|
||
logger.log('Deleting ' + path + ' file for the windows platform.'); | ||
|
||
fs.unlink(path, function (err) { | ||
if (err) { | ||
console.log(err); | ||
return t.reject(); | ||
} | ||
|
||
t.resolve(); | ||
}); | ||
} | ||
|
||
// Configure Cordova configuration parser | ||
function configureParser(context) { | ||
var cordova_util = context.requireCordovaModule('cordova-lib/src/cordova/util'), | ||
ConfigParser = context.requireCordovaModule('cordova-lib/src/configparser/ConfigParser'); | ||
etree = context.requireCordovaModule('cordova-lib/node_modules/elementtree'); | ||
|
||
var xml = cordova_util.projectConfig(context.opts.projectRoot); | ||
config = createConfigParser(xml, etree, ConfigParser); | ||
} | ||
|
||
module.exports = function (context) { | ||
// If the plugin is not being removed, cancel the script | ||
if (context.opts.plugins.indexOf(context.opts.plugin.id) == -1) { | ||
return; | ||
} | ||
|
||
var projectRoot = context.opts.projectRoot; | ||
|
||
// if the windows folder does not exist, cancell the script | ||
var windowsPath = path.join(projectRoot, "platforms","windows"); | ||
if (!fs.existsSync(windowsPath)) { | ||
return; | ||
} | ||
|
||
Q = context.requireCordovaModule('q'); | ||
var task = Q.defer(); | ||
|
||
var destPath = path.join(projectRoot, "platforms", "windows", "www", "wrapper.html"); | ||
if (fs.existsSync(destPath)) { | ||
deleteFile(destPath); | ||
} | ||
|
||
destPath = path.join(projectRoot, "platforms", "windows", "www", "js", "wrapper.js"); | ||
|
||
if (fs.existsSync(destPath)) { | ||
deleteFile(destPath); | ||
} | ||
|
||
destPath = path.join(projectRoot, "platforms", "windows", "www", "css", "wrapper.css"); | ||
|
||
if (fs.existsSync(destPath)) { | ||
deleteFile(destPath); | ||
} | ||
|
||
Q.allSettled(pendingTasks).then(function (e) { | ||
console.log("Finished removing assets for the windows platform."); | ||
|
||
// restore content source to index.html in all platforms. | ||
configureParser(context); | ||
if (config) { | ||
console.log("Restoring content source value to index.html"); | ||
config.setAttribute('content', 'src', 'index.html'); | ||
config.write(); | ||
} | ||
else { | ||
console.log("could not load config.xml file"); | ||
} | ||
|
||
task.resolve(); | ||
}); | ||
|
||
return task.promise; | ||
}; |
Oops, something went wrong.