Skip to content

Commit

Permalink
Merge pull request #125 from chirag729/app_uri_handler_support
Browse files Browse the repository at this point in the history
Add support for extension windows.appUriHandler
  • Loading branch information
YehudaKremer committed May 4, 2022
2 parents d758ce8 + 37b9196 commit c240fa2
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.6.0

- 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))

## 3.5.1

- 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))
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ See [Configurations Examples And Use Cases].
| `languages` | `--languages` | Declares the language resources contained in the package. | `en-us, ja-jp` |
| `file_extension` | `--file-extension` `-f` | File extensions that the app may be registered to open. | `.picture, .image` |
| `protocol_activation` | `--protocol-activation` | [Protocols activation] that will activate the app. | `http,https` |
| `app_uri_handler_hosts` | `--app-uri-handler-hosts` | Enable [apps for websites] using app URI handlers app. | `test.com, test2.info` |
| `execution_alias` | `--execution-alias` | [Execution alias] command (cmd) that will activate the app. | `myapp` |
| `enable_at_startup` | `--enable-at-startup` | App start at startup or user log-in. | `true` |
| `store` | `--store` | Generate a MSIX file for publishing to the Microsoft Store. | `false` |
Expand Down Expand Up @@ -219,4 +220,5 @@ Tags: `msi` `windows` `win10` `win11` `windows10` `windows11` `windows store` `w
[self signed]: https://docs.microsoft.com/en-us/windows/msix/package/create-certificate-package-signing#create-a-self-signed-certificate
[Configurations Examples And Use Cases]: https://pub.dev/packages/msix/example
[see how the msix version is determined]: https://github.com/YehudaKremer/msix/blob/main/doc/msix_version.md
[Toast Notifications configuration]: https://github.com/YehudaKremer/msix/blob/main/doc/toast_notifications_configuration.md
[Toast Notifications configuration]: https://github.com/YehudaKremer/msix/blob/main/doc/toast_notifications_configuration.md
[apps for websites]: https://docs.microsoft.com/en-us/windows/uwp/launch-resume/web-to-app-linking
13 changes: 13 additions & 0 deletions lib/src/appx_manifest.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,16 @@ class AppxManifest {
_config.protocolActivation.isNotEmpty ||
!_config.fileExtension.isNull ||
!_config.toastActivatorCLSID.isNull ||
(_config.appUriHandlerHosts != null &&
_config.appUriHandlerHosts!.isNotEmpty) ||
_config.enableAtStartup) {
return '''<Extensions>
${!_config.executionAlias.isNull ? _getExecutionAliasExtension() : ''}
${_config.protocolActivation.isNotEmpty ? _getProtocolActivationExtension() : ''}
${!_config.fileExtension.isNull ? _getFileAssociationsExtension() : ''}
${!_config.toastActivatorCLSID.isNull ? _getToastNotificationActivationExtension() : ''}
${_config.enableAtStartup ? _getStartupTaskExtension() : ''}
${_config.appUriHandlerHosts != null && _config.appUriHandlerHosts!.isNotEmpty ? _getAppUriHandlerHostExtension() : ''}
</Extensions>''';
} else {
return '';
Expand Down Expand Up @@ -154,6 +157,16 @@ class AppxManifest {
</desktop:Extension>''';
}

String _getAppUriHandlerHostExtension() {
return ''' <uap3:Extension Category="windows.appUriHandler">
<uap3:AppUriHandler>
${_config.appUriHandlerHosts!.map((hostName) {
return '<uap3:Host Name="$hostName" />';
}).toList().join('\n ')}
</uap3:AppUriHandler>
</uap3:Extension>''';
}

String _normalizeCapability(String capability) {
capability = capability.trim();
var firstLetter = capability.substring(0, 1).toLowerCase();
Expand Down
11 changes: 11 additions & 0 deletions lib/src/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Configuration {
bool trimLogo = true;
bool createWithDebugBuildFiles = false;
bool enableAtStartup = false;
Iterable<String>? appUriHandlerHosts;
Iterable<String>? languages;
String get defaultsIconsFolderPath => '$msixAssetsPath/icons';
String get msixToolkitPath => '$msixAssetsPath/MSIX-Toolkit';
Expand Down Expand Up @@ -121,6 +122,7 @@ class Configuration {
architecture = _args['architecture'] ?? yaml['architecture'];
capabilities = _args['capabilities'] ?? yaml['capabilities'];
languages = _getLanguages(yaml);
appUriHandlerHosts = _getAppUriHandlerHosts(yaml);
enableAtStartup = _args.wasParsed('enable-at-startup') ||
yaml['enable_at_startup']?.toString().toLowerCase() == 'true';

Expand Down Expand Up @@ -286,6 +288,7 @@ class Configuration {
..addOption('publish-folder-path')
..addOption('hours-between-update-checks')
..addOption('build-windows')
..addOption('app-uri-handler-hosts')
..addFlag('store')
..addFlag('enable-at-startup')
..addFlag('debug')
Expand Down Expand Up @@ -362,6 +365,14 @@ class Configuration {
.map((e) => e.trim())
.where((element) => element.isNotEmpty);

/// Get the app uri handler hosts list
Iterable<String>? _getAppUriHandlerHosts(dynamic config) =>
((_args['app-uri-handler-hosts'] ?? config['app_uri_handler_hosts'])
as String?)
?.split(',')
.map((e) => e.trim())
.where((element) => element.isNotEmpty);

/// Get the protocol activation list
Iterable<String> _getProtocolsActivation(dynamic config) =>
((_args['protocol-activation'] ?? config['protocol_activation'])
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: msix
description: A command-line tool that create Msix installer from your flutter windows-build files.
version: 3.5.1
version: 3.6.0
maintainer: Yehuda Kremer (yehudakremer@gmail.com)
homepage: https://github.com/YehudaKremer/msix

Expand Down

0 comments on commit c240fa2

Please sign in to comment.