Skip to content

Commit c240fa2

Browse files
authored
Merge pull request #125 from chirag729/app_uri_handler_support
Add support for extension windows.appUriHandler
2 parents d758ce8 + 37b9196 commit c240fa2

File tree

5 files changed

+32
-2
lines changed

5 files changed

+32
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 3.6.0
4+
5+
- added [apps for websites](https://docs.microsoft.com/en-us/windows/uwp/launch-resume/web-to-app-linking) ([#125](https://github.com/YehudaKremer/msix/pull/125))
6+
37
## 3.5.1
48

59
- added two new command `msix:build` and `msix:pack` for [unsupported features](https://github.com/YehudaKremer/msix#heavy_exclamation_mark-unsupported-features) ([#120](https://github.com/YehudaKremer/msix/issues/120))

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ See [Configurations Examples And Use Cases].
7171
| `languages` | `--languages` | Declares the language resources contained in the package. | `en-us, ja-jp` |
7272
| `file_extension` | `--file-extension` `-f` | File extensions that the app may be registered to open. | `.picture, .image` |
7373
| `protocol_activation` | `--protocol-activation` | [Protocols activation] that will activate the app. | `http,https` |
74+
| `app_uri_handler_hosts` | `--app-uri-handler-hosts` | Enable [apps for websites] using app URI handlers app. | `test.com, test2.info` |
7475
| `execution_alias` | `--execution-alias` | [Execution alias] command (cmd) that will activate the app. | `myapp` |
7576
| `enable_at_startup` | `--enable-at-startup` | App start at startup or user log-in. | `true` |
7677
| `store` | `--store` | Generate a MSIX file for publishing to the Microsoft Store. | `false` |
@@ -219,4 +220,5 @@ Tags: `msi` `windows` `win10` `win11` `windows10` `windows11` `windows store` `w
219220
[self signed]: https://docs.microsoft.com/en-us/windows/msix/package/create-certificate-package-signing#create-a-self-signed-certificate
220221
[Configurations Examples And Use Cases]: https://pub.dev/packages/msix/example
221222
[see how the msix version is determined]: https://github.com/YehudaKremer/msix/blob/main/doc/msix_version.md
222-
[Toast Notifications configuration]: https://github.com/YehudaKremer/msix/blob/main/doc/toast_notifications_configuration.md
223+
[Toast Notifications configuration]: https://github.com/YehudaKremer/msix/blob/main/doc/toast_notifications_configuration.md
224+
[apps for websites]: https://docs.microsoft.com/en-us/windows/uwp/launch-resume/web-to-app-linking

lib/src/appx_manifest.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,16 @@ class AppxManifest {
8585
_config.protocolActivation.isNotEmpty ||
8686
!_config.fileExtension.isNull ||
8787
!_config.toastActivatorCLSID.isNull ||
88+
(_config.appUriHandlerHosts != null &&
89+
_config.appUriHandlerHosts!.isNotEmpty) ||
8890
_config.enableAtStartup) {
8991
return '''<Extensions>
9092
${!_config.executionAlias.isNull ? _getExecutionAliasExtension() : ''}
9193
${_config.protocolActivation.isNotEmpty ? _getProtocolActivationExtension() : ''}
9294
${!_config.fileExtension.isNull ? _getFileAssociationsExtension() : ''}
9395
${!_config.toastActivatorCLSID.isNull ? _getToastNotificationActivationExtension() : ''}
9496
${_config.enableAtStartup ? _getStartupTaskExtension() : ''}
97+
${_config.appUriHandlerHosts != null && _config.appUriHandlerHosts!.isNotEmpty ? _getAppUriHandlerHostExtension() : ''}
9598
</Extensions>''';
9699
} else {
97100
return '';
@@ -154,6 +157,16 @@ class AppxManifest {
154157
</desktop:Extension>''';
155158
}
156159

160+
String _getAppUriHandlerHostExtension() {
161+
return ''' <uap3:Extension Category="windows.appUriHandler">
162+
<uap3:AppUriHandler>
163+
${_config.appUriHandlerHosts!.map((hostName) {
164+
return '<uap3:Host Name="$hostName" />';
165+
}).toList().join('\n ')}
166+
</uap3:AppUriHandler>
167+
</uap3:Extension>''';
168+
}
169+
157170
String _normalizeCapability(String capability) {
158171
capability = capability.trim();
159172
var firstLetter = capability.substring(0, 1).toLowerCase();

lib/src/configuration.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class Configuration {
5151
bool trimLogo = true;
5252
bool createWithDebugBuildFiles = false;
5353
bool enableAtStartup = false;
54+
Iterable<String>? appUriHandlerHosts;
5455
Iterable<String>? languages;
5556
String get defaultsIconsFolderPath => '$msixAssetsPath/icons';
5657
String get msixToolkitPath => '$msixAssetsPath/MSIX-Toolkit';
@@ -121,6 +122,7 @@ class Configuration {
121122
architecture = _args['architecture'] ?? yaml['architecture'];
122123
capabilities = _args['capabilities'] ?? yaml['capabilities'];
123124
languages = _getLanguages(yaml);
125+
appUriHandlerHosts = _getAppUriHandlerHosts(yaml);
124126
enableAtStartup = _args.wasParsed('enable-at-startup') ||
125127
yaml['enable_at_startup']?.toString().toLowerCase() == 'true';
126128

@@ -286,6 +288,7 @@ class Configuration {
286288
..addOption('publish-folder-path')
287289
..addOption('hours-between-update-checks')
288290
..addOption('build-windows')
291+
..addOption('app-uri-handler-hosts')
289292
..addFlag('store')
290293
..addFlag('enable-at-startup')
291294
..addFlag('debug')
@@ -362,6 +365,14 @@ class Configuration {
362365
.map((e) => e.trim())
363366
.where((element) => element.isNotEmpty);
364367

368+
/// Get the app uri handler hosts list
369+
Iterable<String>? _getAppUriHandlerHosts(dynamic config) =>
370+
((_args['app-uri-handler-hosts'] ?? config['app_uri_handler_hosts'])
371+
as String?)
372+
?.split(',')
373+
.map((e) => e.trim())
374+
.where((element) => element.isNotEmpty);
375+
365376
/// Get the protocol activation list
366377
Iterable<String> _getProtocolsActivation(dynamic config) =>
367378
((_args['protocol-activation'] ?? config['protocol_activation'])

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: msix
22
description: A command-line tool that create Msix installer from your flutter windows-build files.
3-
version: 3.5.1
3+
version: 3.6.0
44
maintainer: Yehuda Kremer (yehudakremer@gmail.com)
55
homepage: https://github.com/YehudaKremer/msix
66

0 commit comments

Comments
 (0)