Skip to content

Commit

Permalink
Adds Windows10/11 Widgets, edge_side_panel, iarc_rating_id, scope_ext…
Browse files Browse the repository at this point in the history
…ensions and handle_links parameters
  • Loading branch information
Spomky committed Dec 30, 2023
1 parent a33fa68 commit fe2ef09
Show file tree
Hide file tree
Showing 2 changed files with 171 additions and 33 deletions.
188 changes: 155 additions & 33 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function getConfigTreeBuilder(): TreeBuilder
$this->setupRelatedApplications($rootNode);
$this->setupShortcuts($rootNode);
$this->setupSharedTarget($rootNode);
$this->setupWidgets($rootNode);
$this->setupServiceWorker($rootNode);

return $treeBuilder;
Expand Down Expand Up @@ -77,38 +78,7 @@ private function setupShortcuts(ArrayNodeDefinition $node): void
private function setupScreenshots(ArrayNodeDefinition $node): void
{
$node->children()
->arrayNode('screenshots')
->treatFalseLike([])
->treatTrueLike([])
->treatNullLike([])
->info('The screenshots of the application.')
->arrayPrototype()
->children()
->scalarNode('src')
->isRequired()
->info('The path to the screenshot.')
->example('screenshot/lowres.webp')
->end()
->scalarNode('form_factor')
->info('The form factor of the screenshot. Will guess the form factor if not set.')
->example(['wide', 'narrow'])
->end()
->scalarNode('label')
->info('The label of the screenshot.')
->example('Homescreen of Awesome App')
->end()
->scalarNode('platform')
->info('The platform of the screenshot.')
->example(
['android', 'windows', 'chromeos', 'ipados', 'ios', 'kaios', 'macos', 'windows', 'xbox']
)
->end()
->scalarNode('format')
->info('The format of the screenshot. Will convert the file if set.')
->example(['jpg', 'png', 'webp'])
->end()
->end()
->end()
->append($this->getScreenshotsNode())
;
}

Expand Down Expand Up @@ -371,7 +341,7 @@ private function setupSimpleOptions(ArrayNodeDefinition $node): void
->end()
->scalarNode('scope')
->info('The scope of the application.')
->example('/app/')
->example(['/app/', 'https://app.foo.com'])
->end()
->scalarNode('start_url')
->info('The start URL of the application.')
Expand All @@ -381,6 +351,37 @@ private function setupSimpleOptions(ArrayNodeDefinition $node): void
->info('The theme color of the application.')
->example('red')
->end()
->arrayNode('edge_side_panel')
->info('Specifies whether or not your app supports the side panel view in Microsoft Edge.')
->children()
->integerNode('preferred_width')
->info('Specifies the preferred width of the side panel view in Microsoft Edge.')
->end()
->end()
->end()
->scalarNode('iarc_rating_id')
->info(
'Specifies the International Age Rating Coalition (IARC) rating ID for the app. See https://www.globalratings.com/how-iarc-works.aspx for more information.'
)
->end()
->arrayNode('scope_extensions')
->info(
'Specifies a list of origin patterns to associate with. This allows for your app to control multiple subdomains and top-level domains as a single entity.'
)
->arrayPrototype()
->children()
->scalarNode('origin')
->isRequired()
->info('Specifies the origin pattern to associate with.')
->example('*.foo.com')
->end()
->end()
->end()
->end()
->scalarNode('handle_links')
->info('Specifies the default link handling for the web app.')
->example(['auto', 'preferred', 'not-preferred'])
->end()
->end()
;
}
Expand All @@ -391,6 +392,9 @@ private function getIconsNode(): ArrayNodeDefinition
$node = $treeBuilder->getRootNode();
assert($node instanceof ArrayNodeDefinition);
$node
->info(
'An array of icons to be used for the widget. If missing, the icons manifest member is used instead. Icons larger than 1024x1024 are ignored.'
)
->treatFalseLike([])
->treatTrueLike([])
->treatNullLike([])
Expand Down Expand Up @@ -423,6 +427,58 @@ private function getIconsNode(): ArrayNodeDefinition
return $node;
}

private function getScreenshotsNode(): ArrayNodeDefinition
{
$treeBuilder = new TreeBuilder('screenshots');
$node = $treeBuilder->getRootNode();
assert($node instanceof ArrayNodeDefinition);
$node
->treatFalseLike([])
->treatTrueLike([])
->treatNullLike([])
->arrayPrototype()
->children()
->scalarNode('src')
->isRequired()
->info('The path to the screenshot.')
->example('screenshot/lowres.webp')
->end()
->scalarNode('form_factor')
->info('The form factor of the screenshot. Will guess the form factor if not set.')
->example(['wide', 'narrow'])
->end()
->scalarNode('label')
->info('The label of the screenshot.')
->example('Homescreen of Awesome App')
->end()
->scalarNode('platform')
->info('The platform of the screenshot.')
->example(
[
'android',
'windows',
'chromeos',
'ipados',
'ios',
'kaios',
'macos',
'windows',
'xbox',
'any',
]
)
->end()
->scalarNode('format')
->info('The format of the screenshot. Will convert the file if set.')
->example(['jpg', 'png', 'webp'])
->end()
->end()
->end()
;

return $node;
}

private function setupServiceWorker(ArrayNodeDefinition $node): void
{
$node->children()
Expand Down Expand Up @@ -468,4 +524,70 @@ private function setupServiceWorker(ArrayNodeDefinition $node): void
->end()
->end();
}

private function setupWidgets(ArrayNodeDefinition $node): void
{
$node->children()
->arrayNode('widgets')
->info(
'EXPERIMENTAL. Specifies PWA-driven widgets. See https://learn.microsoft.com/en-us/microsoft-edge/progressive-web-apps-chromium/how-to/widgets for more information'
)
->arrayPrototype()
->children()
->scalarNode('name')
->isRequired()
->info('The title of the widget, presented to users.')
->end()
->scalarNode('short_name')
->info('An alternative short version of the name.')
->end()
->scalarNode('description')
->isRequired()
->info('The description of the widget.')
->example('My awesome widget')
->end()
->append($this->getIconsNode())
->append($this->getScreenshotsNode()->cannotBeEmpty())
->scalarNode('tag')
->isRequired()
->info('A string used to reference the widget in the PWA service worker.')
->end()
->scalarNode('template')
->info(
'The template to use to display the widget in the operating system widgets dashboard. Note: this property is currently only informational and not used. See ms_ac_template below.'
)
->end()
->scalarNode('ms_ac_template')
->isRequired()
->info(
'The URL of the custom Adaptive Cards template to use to display the widget in the operating system widgets dashboard. See Define a widget template below.'
)
->end()
->scalarNode('data')
->info(
'The URL where the data to fill the template with can be found. If present, this URL is required to return valid JSON.'
)
->end()
->scalarNode('type')
->info('The MIME type for the widget data.')
->end()
->booleanNode('auth')
->info('A boolean indicating if the widget requires authentication.')
->end()
->integerNode('update')
->info(
'The frequency, in seconds, at which the widget will be updated. Code in your service worker must perform the updating; the widget is not updated automatically. See Access widget instances at runtime.'
)
->end()
->booleanNode('multiple')
->defaultTrue()
->info(
'A boolean indicating whether to allow multiple instances of the widget. Defaults to true.'
)
->end()
->end()
->end()
->end()
->end();
}
}
16 changes: 16 additions & 0 deletions tests/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,22 @@
],
],
],
'edge_side_panel' => [
'preferred_width' => 480,
],
'iarc_rating_id' => '123456',
'scope_extensions' => [
[
'origin' => '*.foo.com',
],
[
'origin' => 'https://*.bar.com',
],
[
'origin' => 'https://*.baz.com',
],
],
'handle_links' => 'auto',
'serviceworker' => [
'generate' => true,
'src' => '/my-sw.js',
Expand Down

0 comments on commit fe2ef09

Please sign in to comment.