Skip to content

Commit 68ea5fb

Browse files
Merge pull request #162 from nuald/master
Windows 10 manifest support.
2 parents a6f0e92 + 442e7f7 commit 68ea5fb

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

plugin.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@
8484

8585
<!-- windows -->
8686
<platform name="windows">
87+
<hook type="before_prepare" src="src/windows/hooks/prepare-manifest.js" />
88+
<config-file target="package.windows10.appxmanifest" parent="/Package/Applications/Application/Extensions">
89+
<uap:Extension Category="windows.protocol" StartPage="www/index.html">
90+
<uap:Protocol Name="$URL_SCHEME" />
91+
</uap:Extension>
92+
</config-file>
8793
<config-file target="package.windows.appxmanifest" parent="/Package/Applications/Application/Extensions">
8894
<Extension Category="windows.protocol" StartPage="www/index.html">
8995
<Protocol Name="$URL_SCHEME" />
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module.exports = function(context) {
2+
var fs = context.requireCordovaModule('fs'),
3+
et = context.requireCordovaModule('elementtree'),
4+
path = context.requireCordovaModule('path'),
5+
xml= context.requireCordovaModule('cordova-common').xmlHelpers,
6+
projectRoot = path.join(context.opts.projectRoot, "platforms", "windows");
7+
8+
var MANIFEST_WINDOWS = 'package.windows.appxmanifest',
9+
MANIFEST_PHONE = 'package.phone.appxmanifest',
10+
MANIFEST_WINDOWS10 = 'package.windows10.appxmanifest',
11+
MANIFEST_WINDOWS80 = 'package.windows80.appxmanifest';
12+
13+
function updateManifestFile(manifestPath) {
14+
var doc = xml.parseElementtreeSync(manifestPath);
15+
var root = doc.getroot();
16+
var app = root.find('./Applications/Application');
17+
if (!app) {
18+
throw new Error(manifestPath + ' has incorrect XML structure.');
19+
}
20+
if (!app.find('./Extensions')) {
21+
app.append(new et.Element('Extensions'));
22+
}
23+
fs.writeFileSync(manifestPath, doc.write({indent: 4}), 'utf-8');
24+
}
25+
26+
[MANIFEST_PHONE, MANIFEST_WINDOWS80, MANIFEST_WINDOWS, MANIFEST_WINDOWS10]
27+
.forEach(function(manifestFile) {
28+
updateManifestFile(path.join(projectRoot, manifestFile));
29+
});
30+
}

0 commit comments

Comments
 (0)