From 4f804c0a0b7487b6f11f6d46a8f7d4c20bdd8ada Mon Sep 17 00:00:00 2001 From: chirag729 Date: Tue, 3 May 2022 18:45:18 +0100 Subject: [PATCH 1/4] add support for configuring windows.appUriHandler --- lib/src/appx_manifest.dart | 9 +++++++++ lib/src/configuration.dart | 2 ++ 2 files changed, 11 insertions(+) diff --git a/lib/src/appx_manifest.dart b/lib/src/appx_manifest.dart index 6cff770..e85dc46 100644 --- a/lib/src/appx_manifest.dart +++ b/lib/src/appx_manifest.dart @@ -92,6 +92,7 @@ class AppxManifest { ${!_config.fileExtension.isNull ? _getFileAssociationsExtension() : ''} ${!_config.toastActivatorCLSID.isNull ? _getToastNotificationActivationExtension() : ''} ${_config.enableAtStartup ? _getStartupTaskExtension() : ''} + ${!_config.appUriHandlerHost.isNull ? _getAppUriHandlerHostExtension() : ''} '''; } else { return ''; @@ -154,6 +155,14 @@ class AppxManifest { '''; } + String _getAppUriHandlerHostExtension() { + return ''' + + + + '''; + } + String _normalizeCapability(String capability) { capability = capability.trim(); var firstLetter = capability.substring(0, 1).toLowerCase(); diff --git a/lib/src/configuration.dart b/lib/src/configuration.dart index 37b377d..34ea497 100644 --- a/lib/src/configuration.dart +++ b/lib/src/configuration.dart @@ -51,6 +51,7 @@ class Configuration { bool trimLogo = true; bool createWithDebugBuildFiles = false; bool enableAtStartup = false; + String? appUriHandlerHost; Iterable? languages; String get defaultsIconsFolderPath => '$msixAssetsPath/icons'; String get msixToolkitPath => '$msixAssetsPath/MSIX-Toolkit'; @@ -123,6 +124,7 @@ class Configuration { languages = _getLanguages(yaml); enableAtStartup = _args.wasParsed('enable-at-startup') || yaml['enable_at_startup']?.toString().toLowerCase() == 'true'; + appUriHandlerHost = _args['app-uri-handler-host'] ?? yaml['app_uri_handler_host']; // toast activator configurations var toastActivatorYaml = yaml['toast_activator'] ?? YamlMap(); From 0e133b399e34618fc688db8890b01b362a670d57 Mon Sep 17 00:00:00 2001 From: chirag729 Date: Tue, 3 May 2022 18:09:15 +0100 Subject: [PATCH 2/4] =?UTF-8?q?add=20arg=20option=20=C2=96app-uri-handler-?= =?UTF-8?q?host?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/configuration.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/configuration.dart b/lib/src/configuration.dart index 34ea497..34e1922 100644 --- a/lib/src/configuration.dart +++ b/lib/src/configuration.dart @@ -124,7 +124,8 @@ class Configuration { languages = _getLanguages(yaml); enableAtStartup = _args.wasParsed('enable-at-startup') || yaml['enable_at_startup']?.toString().toLowerCase() == 'true'; - appUriHandlerHost = _args['app-uri-handler-host'] ?? yaml['app_uri_handler_host']; + appUriHandlerHost = + _args['app-uri-handler-host'] ?? yaml['app_uri_handler_host']; // toast activator configurations var toastActivatorYaml = yaml['toast_activator'] ?? YamlMap(); @@ -288,6 +289,7 @@ class Configuration { ..addOption('publish-folder-path') ..addOption('hours-between-update-checks') ..addOption('build-windows') + ..addOption('app-uri-handler-host') ..addFlag('store') ..addFlag('enable-at-startup') ..addFlag('debug') From 6055bc933e0e95990b0aa1da84dd7cad82f12582 Mon Sep 17 00:00:00 2001 From: chirag729 Date: Tue, 3 May 2022 18:09:56 +0100 Subject: [PATCH 3/4] check for appUriHandlerHost config when creating extensions --- lib/src/appx_manifest.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/appx_manifest.dart b/lib/src/appx_manifest.dart index e85dc46..7b6a34c 100644 --- a/lib/src/appx_manifest.dart +++ b/lib/src/appx_manifest.dart @@ -85,6 +85,7 @@ class AppxManifest { _config.protocolActivation.isNotEmpty || !_config.fileExtension.isNull || !_config.toastActivatorCLSID.isNull || + !_config.appUriHandlerHost.isNull || _config.enableAtStartup) { return ''' ${!_config.executionAlias.isNull ? _getExecutionAliasExtension() : ''} From 37b9196f88b43915265364f5d8fc6261ea6695f4 Mon Sep 17 00:00:00 2001 From: Yehuda Kremer Date: Wed, 4 May 2022 17:45:09 +0300 Subject: [PATCH 4/4] added option for multiple sites, and documentation --- CHANGELOG.md | 4 ++++ README.md | 4 +++- lib/src/appx_manifest.dart | 9 ++++++--- lib/src/configuration.dart | 15 +++++++++++---- pubspec.yaml | 2 +- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 430f49e..991a96a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/README.md b/README.md index 7bc3624..3fc8dda 100644 --- a/README.md +++ b/README.md @@ -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` | @@ -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 \ No newline at end of file +[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 \ No newline at end of file diff --git a/lib/src/appx_manifest.dart b/lib/src/appx_manifest.dart index 7b6a34c..1cbefa7 100644 --- a/lib/src/appx_manifest.dart +++ b/lib/src/appx_manifest.dart @@ -85,7 +85,8 @@ class AppxManifest { _config.protocolActivation.isNotEmpty || !_config.fileExtension.isNull || !_config.toastActivatorCLSID.isNull || - !_config.appUriHandlerHost.isNull || + (_config.appUriHandlerHosts != null && + _config.appUriHandlerHosts!.isNotEmpty) || _config.enableAtStartup) { return ''' ${!_config.executionAlias.isNull ? _getExecutionAliasExtension() : ''} @@ -93,7 +94,7 @@ class AppxManifest { ${!_config.fileExtension.isNull ? _getFileAssociationsExtension() : ''} ${!_config.toastActivatorCLSID.isNull ? _getToastNotificationActivationExtension() : ''} ${_config.enableAtStartup ? _getStartupTaskExtension() : ''} - ${!_config.appUriHandlerHost.isNull ? _getAppUriHandlerHostExtension() : ''} + ${_config.appUriHandlerHosts != null && _config.appUriHandlerHosts!.isNotEmpty ? _getAppUriHandlerHostExtension() : ''} '''; } else { return ''; @@ -159,7 +160,9 @@ class AppxManifest { String _getAppUriHandlerHostExtension() { return ''' - + ${_config.appUriHandlerHosts!.map((hostName) { + return ''; + }).toList().join('\n ')} '''; } diff --git a/lib/src/configuration.dart b/lib/src/configuration.dart index 34e1922..8b00828 100644 --- a/lib/src/configuration.dart +++ b/lib/src/configuration.dart @@ -51,7 +51,7 @@ class Configuration { bool trimLogo = true; bool createWithDebugBuildFiles = false; bool enableAtStartup = false; - String? appUriHandlerHost; + Iterable? appUriHandlerHosts; Iterable? languages; String get defaultsIconsFolderPath => '$msixAssetsPath/icons'; String get msixToolkitPath => '$msixAssetsPath/MSIX-Toolkit'; @@ -122,10 +122,9 @@ 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'; - appUriHandlerHost = - _args['app-uri-handler-host'] ?? yaml['app_uri_handler_host']; // toast activator configurations var toastActivatorYaml = yaml['toast_activator'] ?? YamlMap(); @@ -289,7 +288,7 @@ class Configuration { ..addOption('publish-folder-path') ..addOption('hours-between-update-checks') ..addOption('build-windows') - ..addOption('app-uri-handler-host') + ..addOption('app-uri-handler-hosts') ..addFlag('store') ..addFlag('enable-at-startup') ..addFlag('debug') @@ -366,6 +365,14 @@ class Configuration { .map((e) => e.trim()) .where((element) => element.isNotEmpty); + /// Get the app uri handler hosts list + Iterable? _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 _getProtocolsActivation(dynamic config) => ((_args['protocol-activation'] ?? config['protocol_activation']) diff --git a/pubspec.yaml b/pubspec.yaml index f20e22f..425fe43 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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