{"version":"https://jsonfeed.org/version/1","title":"Aaron Gustafson: Content tagged Windows","description":"The latest 20 posts and links tagged Windows.","home_page_url":"https://www.aaron-gustafson.com","feed_url":"https://www.aaron-gustafson.com/feeds/windows.json","author":{"name":"Aaron Gustafson","url":"https://www.aaron-gustafson.com"},"icon":"https://www.aaron-gustafson.com/i/og-logo.png","favicon":"https://www.aaron-gustafson.com/favicon.png","expired":false,"items":[{"id":"https://www.aaron-gustafson.com/notebook/widgets/","title":"✍🏻 Widgets!","summary":"I finally had a chance to put the work I did on a widgets proposal for PWAs into practice on my own site. It’s pretty exciting!","content_html":"<p>It was a long time coming, but I finally had a chance to put the work I did on <a href=\"https://github.com/MicrosoftEdge/MSEdgeExplainers/tree/main/PWAWidgets\">a widgets proposal for PWAs</a> into practice on my own site. I’m pretty excited about it!</p>\n<h2 id=\"where-it-all-started\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#where-it-all-started\" aria-hidden=\"true\">#</a> Where it all started</h2>\n<p>I had <a href=\"https://web.archive.org/web/20200929174844/https://discourse.wicg.io/t/noodling-on-an-idea-projections-for-web-apps/3900\">the original idea for “projections”</a> way back in 2019. Inspired by <a href=\"https://en.wikipedia.org/wiki/Dashboard_(macOS)#Widget_functions_and_capabilities\">OS X’s Dashboard Widgets</a> and <a href=\"https://en.wikipedia.org/wiki/Adobe_AIR\">Adobe AIR</a>, I’d begun to wonder if it might be possible to <em>project</em> a component from a website into those kinds of surfaces. Rather than building a bespoke widget that connected to an API, I thought it made sense to leverage an installed PWA to manage those “projections.” I shared the idea at TPAC that year and got some interest from a broad range of folks, but didn’t have much time to work on the details until a few years later.</p>\n<p>In the intervening time, I kept working through the concept in my head. I mean in an ideal world, the widget would just be a responsive web page, right? But if that were the case, what happens when every widget loads the entirety of React to render their stock ticker? That seemed like a performance nightmare.</p>\n<p>In my gut, I felt like the right way to build things would be to have a standard library of widget templates and to enable devs to flow data into them via a Service Worker. Alex Russell suggested I model the APIs on how Notifications are handled (since they serve a similar function) and I was off to the races.</p>\n<p>I drafted <a href=\"https://github.com/aarongustafson/pwa-widgets\">a substantial proposal for my vision of how PWA widgets should work</a>. Key aspects included:</p>\n<ul>\n<li>A declarative way to define and configure a widget from within the Web App Manifest;</li>\n<li>A progressively enhanced pathway for devs to design a widget that adapts to its host environment, from using predefined templates to using custom templates to full-blown web-based widgets (with rendering akin to an <code>iframe</code>);</li>\n<li>A collection of recommended stock templates that implementors should offer to support most widget types;</li>\n<li>Extensibility to support custom templates using any of a variety of templating languages; and</li>\n<li>A complete suite of tools for managing widgets and any associated business logic within a Service Worker.</li>\n</ul>\n<h2 id=\"widgets-became-a-reality\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#widgets-became-a-reality\" aria-hidden=\"true\">#</a> Widgets became a reality</h2>\n<p>After continuing to gently push on this idea with colleagues across Microsoft (and beyond), I discovered that the Windows 11 team was looking to open up the new Widget Dashboard to third-party applications. I saw this as an opportunity to turn my idea into a reality. After working my way into the conversation, I made a solid case for why PWAs needed to be a part of that story and… it worked! (It no doubt helped that companies including Meta, Twitter, and Hulu were all invested in PWA as a means of delivering apps for Windows.)</p>\n<p>While the timeline for implementation didn’t allow us to tackle the entirety of my proposal, we did carve out the pieces that made for a compelling MVP. This allowed us to show what’s possible, see how folks use it, and plan for future investment in the space.</p>\n<p>Sadly, it meant tabling two features I really loved:</p>\n<ul>\n<li><strong>Stock/predefined templates</strong>. A library of lightly theme-able, consistent, cross-platform templates based on common data structures (e.g., RSS/Atom, iCal) would make it incredibly simple for devs to build a widget. If implemented well, devs might not even need to write a single line of business logic in their Service Worker as the browser could pick up all of the configuration details from the Manifest.</li>\n<li><strong>Configurable widget instances.</strong> Instead of singleton widgets, these would allow you to define a single widget type and replicate it for different use cases. For example, a widget to follow a social media user’s profile could be defined once and the individual instances could be configured with the specific account to be followed.</li>\n</ul>\n<p>I’m sincerely hopeful these two features eventually make their way to us as I think they truly unlock the power of the widget platform. Perhaps, with enough uptake on the current implementation, we can revisit these in the not-too-distant future.</p>\n<hr>\n<p>To test things out, I decided to build two widgets for this site:</p>\n<ol>\n<li>Latest posts</li>\n<li>Latest links</li>\n</ol>\n<p>Both are largely the same in terms of their setup: They display a list of linked titles from this site.</p>\n<h2 id=\"designing-my-widget-templates\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#designing-my-widget-templates\" aria-hidden=\"true\">#</a> Designing my widget templates</h2>\n<p>Given that they were going to be largely identical, I made <a href=\"https://github.com/aarongustafson/aaron-gustafson.com/blob/main/src/static/w/feed.ac.json\">a single “feed” template for use in both widgets</a>. The templating tech I used is called <a href=\"https://adaptivecards.io\">Adaptive Cards</a>, which is what Windows 11 uses for rendering.</p>\n<p>Adaptive Card templates are relatively straightforward JSON:</p>\n<pre class=\"language-json\" tabindex=\"0\"><code class=\"language-json\">&amp;#<span class=\"token number\">123</span>;\n  <span class=\"token property\">\"type\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"AdaptiveCard\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"$schema\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"http://adaptivecards.io/schemas/adaptive-card.json\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"version\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"1.6\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"body\"</span><span class=\"token operator\">:</span> &amp;#<span class=\"token number\">91</span>;\n    &amp;#<span class=\"token number\">123</span>;\n      <span class=\"token property\">\"$data\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"$&amp;#123;take(items,5)&amp;#125;\"</span><span class=\"token punctuation\">,</span>\n      <span class=\"token property\">\"type\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Container\"</span><span class=\"token punctuation\">,</span>\n      <span class=\"token property\">\"items\"</span><span class=\"token operator\">:</span> &amp;#<span class=\"token number\">91</span>;\n        &amp;#<span class=\"token number\">123</span>;\n          <span class=\"token property\">\"type\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"TextBlock\"</span><span class=\"token punctuation\">,</span>\n          <span class=\"token property\">\"text\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"&amp;#91;$&amp;#123;title&amp;#125;&amp;#93;($&amp;#123;url&amp;#125;)\"</span><span class=\"token punctuation\">,</span>\n          <span class=\"token property\">\"wrap\"</span><span class=\"token operator\">:</span> <span class=\"token boolean\">true</span><span class=\"token punctuation\">,</span>\n          <span class=\"token property\">\"weight\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Bolder\"</span><span class=\"token punctuation\">,</span>\n          <span class=\"token property\">\"spacing\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Padding\"</span><span class=\"token punctuation\">,</span>\n          <span class=\"token property\">\"height\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"stretch\"</span>\n        &amp;#<span class=\"token number\">125</span>;\n      &amp;#<span class=\"token number\">93</span>;<span class=\"token punctuation\">,</span>\n      <span class=\"token property\">\"height\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"stretch\"</span>\n    &amp;#<span class=\"token number\">125</span>;\n  &amp;#<span class=\"token number\">93</span>;<span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"backgroundImage\"</span><span class=\"token operator\">:</span> &amp;#<span class=\"token number\">123</span>;\n    <span class=\"token property\">\"url\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"https://www.aaron-gustafson.com/i/background-logo.png\"</span><span class=\"token punctuation\">,</span>\n    <span class=\"token property\">\"verticalAlignment\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Bottom\"</span><span class=\"token punctuation\">,</span>\n    <span class=\"token property\">\"horizontalAlignment\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Center\"</span>\n  &amp;#<span class=\"token number\">125</span>;\n&amp;#<span class=\"token number\">125</span>;</code></pre>\n<p>What this structure does is:</p>\n<ol>\n<li>Create a container into which I will place the content;</li>\n<li>Extract the first five <code>items</code> from the data being fed into the template (more on that in a moment);</li>\n<li>Loop through each <code>item</code> and\n<ul>\n<li>create a text block,</li>\n<li>populate its content with Markdown to generate a linked title (using the <code>title</code> and <code>url</code> keys from the <code>item</code> object)</li>\n<li>Set some basic styles to make the text bold, separate the titles a little and make them grow to fill the container; then, finally</li>\n</ul>\n</li>\n<li>Set a background on the widget.</li>\n</ol>\n<p>The way Adaptive Cards work is that they flow JSON data into a template and render that. The variable names in the template map directly to the incoming data structure, so are totally up to you to define. As these particular widgets are feed-driven and <a href=\"https://www.aaron-gustafson.com/feeds/\">this site already supports JSONFeed</a>, I set up the widgets to flow the appropriate feed into each and used the keys that were already there. For reference, here’s a sample JSONFeed <code>item</code>:</p>\n<pre class=\"language-json\" tabindex=\"0\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\n  <span class=\"token property\">\"id\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"…\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"title\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"…\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"summary\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"…\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"content_html\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"…\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"url\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"…\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"tags\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"date_published\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"…\"</span>\n<span class=\"token punctuation\">}</span></code></pre>\n<p>If you want to tinker with Adaptive Cards and make your own, you can do so with <a href=\"https://adaptivecards.io/designer/\">their Designer tool</a>.</p>\n<h3 id=\"defining-the-widgets-in-the-manifest\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#defining-the-widgets-in-the-manifest\" aria-hidden=\"true\">#</a> Defining the widgets in the Manifest</h3>\n<p>With a basic template created, the next step was to set up the two widgets in my Manifest. As they both function largely the same, I’ll just focus on the definition for one of them.</p>\n<p>First off, defining widgets in the Manifest is done via the <code>widgets</code> member, which is an array (much like <code>icons</code> and <code>shortcuts</code>). Each widget is represented as an object in that array. Here is the definition for the “latest posts” widget:</p>\n<pre class=\"language-json\" tabindex=\"0\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\n  <span class=\"token property\">\"name\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Latest Posts\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"short_name\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Posts\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"tag\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"feed-posts\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"description\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"The latest posts from Aaron Gustafson’s blog\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"template\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"feed\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"ms_ac_template\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"/w/feed.ac.json\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"data\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"/feeds/latest-posts.json\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"type\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"application/json\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"auth\"</span><span class=\"token operator\">:</span> <span class=\"token boolean\">false</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"update\"</span><span class=\"token operator\">:</span> <span class=\"token number\">21600</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"icons\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span>\n    <span class=\"token punctuation\">{</span>\n      <span class=\"token property\">\"src\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"/i/icons/webicon-rss.png\"</span><span class=\"token punctuation\">,</span>\n      <span class=\"token property\">\"type\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"image/png\"</span><span class=\"token punctuation\">,</span>\n      <span class=\"token property\">\"sizes\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"120x120\"</span>\n    <span class=\"token punctuation\">}</span>\n  <span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"screenshots\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span>\n    <span class=\"token punctuation\">{</span>\n      <span class=\"token property\">\"src\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"/i/screenshots/widget-posts.png\"</span><span class=\"token punctuation\">,</span>\n      <span class=\"token property\">\"sizes\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"387x387\"</span><span class=\"token punctuation\">,</span>\n      <span class=\"token property\">\"label\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"The latest posts widget\"</span>\n    <span class=\"token punctuation\">}</span>\n  <span class=\"token punctuation\">]</span>\n<span class=\"token punctuation\">}</span></code></pre>\n<p>Breaking this down:</p>\n<ol>\n<li><code>name</code> and <code>short_name</code> act much like these keys in the root of the Manifest as well as in <code>shortcuts</code>: The <code>name</code> value is used as the name for the widget unless there’s not enough room, in which case <code>short_name</code> is used.</li>\n<li>You can think of <code>tag</code> as analogous to <code>class</code> in HTML sense. It’s a way of labeling a widget so you can easily reference it later. Each widget instance will have a unique id created by the widget service, but that instance (or all instances, if the widget supports multiple instances) can be accessed via the <code>tag</code>. But more on that later.</li>\n<li>The <code>description</code> key is used for marketing the widget within a host OS or digital storefront. It should accurately (and briefly) describe what the widget does.</li>\n<li>The <code>template</code> key is not currently used in the Windows 11 implementation but refers to the expected standard library widget template provided by the system. As a template library is not currently available, the <code>ms_ac_template</code> value is used to provide a URL to get the custom Adaptive Card (hence “ac”) template. The “ms_” prefix is there because it’s expected that this would be a Microsoft-proprietary property. It follows <a href=\"https://www.w3.org/TR/appmanifest/#proprietary-extensions\">the guidance for extending the Manifest</a>.</li>\n<li>The <code>data</code> and <code>type</code> keys define the path to the data that should be fed into the template for rendering by the widget host and the MIME of the data format it’s in. The Windows 11 implementation currently only accepts JSON data, but the design of widgets is set up to allow for this to eventually extend to other standardized formats like RSS, iCal, vCard, and such.</li>\n<li><code>update</code> is an optional configuration member allowing you to set how often you’d like the widget to update, in seconds. Developers currently need to add the logic for implementing this into their Service Worker, but this setup allows the configuration to remain independent of the JavaScript code, making it easier to maintain.</li>\n<li>Finally, <code>icons</code> and <code>screenshots</code> allow us to define how the widget shows up in the widget host and how it is promoted for install.</li>\n</ol>\n<p>When someone installs my site as a PWA, the information about the available widgets gets ingested by the browser. The browser then determines, based on the provided values and its knowledge of the available widget service(s) on the device, which widgets should be offered. On Windows 11, this information is <a href=\"https://learn.microsoft.com/en-us/windows/apps/develop/widgets/implement-widget-provider-cs#update-the-package-manifest\">routed into the AppXManifest that governs how apps are represented in Windows</a>. The Windows 11 widget service can then read in the details about the available widgets and offer them for users to install.</p>\n<figure id=\"2023-10-09-01\">\n<p><img src=\"https://www.aaron-gustafson.com/i/posts/2023-10-09/widgets-promotion.gif\" alt=\"\"></p>\n<figcaption>An animated capture of Windows 11’s widget promotion surface, showing 2 widgets available from this site’s PWA.</figcaption>\n</figure>\n<h2 id=\"adding-widget-support-to-my-service-worker\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#adding-widget-support-to-my-service-worker\" aria-hidden=\"true\">#</a> Adding widget support to my Service Worker</h2>\n<p>As I mentioned earlier, all of the plumbing for widgets is done within a Service Worker and is modeled on the Notifications API. I’m not going to exhaustively detail how it all works, but I’ll give you enough detail to get you started.</p>\n<p>First off, widgets are exposed via the <code>self.widgets</code> interface. Most importantly, this interface lets you access and update any instances of a widget connected to your PWA.</p>\n<h3 id=\"installing-a-widget\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#installing-a-widget\" aria-hidden=\"true\">#</a> Installing a widget</h3>\n<p>When a user chooses to install a widget, that emits a “widgetinstall” event in your Service Worker. You use that to kickoff the widget lifecycle by gathering the template and data needed to instantiate the widget:</p>\n<pre class=\"language-js\" tabindex=\"0\"><code class=\"language-js\">self<span class=\"token punctuation\">.</span><span class=\"token function\">addEventListener</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"widgetinstall\"</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">event</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n  console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">Installing </span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>event<span class=\"token punctuation\">.</span>widget<span class=\"token punctuation\">.</span>tag<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  event<span class=\"token punctuation\">.</span><span class=\"token function\">waitUntil</span><span class=\"token punctuation\">(</span><span class=\"token function\">initializeWidget</span><span class=\"token punctuation\">(</span>event<span class=\"token punctuation\">.</span>widget<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre>\n<p>The event argument comes in with details of the specific widget being instantiated (as <code>event.widget</code>). In the code above, you can see I’ve logged the widget’s <code>tag</code> value to the console. I pass the widget information over to my <code>initializeWidget()</code> function and it updates the widget with the latest data and, if necessary, sets up a <a href=\"https://developer.mozilla.org/docs/Web/API/Web_Periodic_Background_Synchronization_API\">Periodic Background Sync</a>:</p>\n<pre class=\"language-js\" tabindex=\"0\"><code class=\"language-js\"><span class=\"token keyword\">async</span> <span class=\"token keyword\">function</span> <span class=\"token function\">initializeWidget</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">widget</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">await</span> <span class=\"token function\">updateWidget</span><span class=\"token punctuation\">(</span>widget<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">await</span> <span class=\"token function\">registerPeriodicSync</span><span class=\"token punctuation\">(</span>widget<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">return</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre>\n<p>The code for my <code>updateWidget()</code> function is as follows:</p>\n<pre class=\"language-js\" tabindex=\"0\"><code class=\"language-js\"><span class=\"token keyword\">async</span> <span class=\"token keyword\">function</span> <span class=\"token function\">updateWidget</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">widget</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">const</span> template <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> <span class=\"token punctuation\">(</span><span class=\"token keyword\">await</span> <span class=\"token function\">fetch</span><span class=\"token punctuation\">(</span>widget<span class=\"token punctuation\">.</span>definition<span class=\"token punctuation\">.</span>msAcTemplate<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">text</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">const</span> data <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> <span class=\"token punctuation\">(</span><span class=\"token keyword\">await</span> <span class=\"token function\">fetch</span><span class=\"token punctuation\">(</span>widget<span class=\"token punctuation\">.</span>definition<span class=\"token punctuation\">.</span>data<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">text</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n  <span class=\"token keyword\">try</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token keyword\">await</span> self<span class=\"token punctuation\">.</span>widgets<span class=\"token punctuation\">.</span><span class=\"token function\">updateByTag</span><span class=\"token punctuation\">(</span>widget<span class=\"token punctuation\">.</span>definition<span class=\"token punctuation\">.</span>tag<span class=\"token punctuation\">,</span> <span class=\"token punctuation\">{</span> template<span class=\"token punctuation\">,</span> data <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span> <span class=\"token keyword\">catch</span> <span class=\"token punctuation\">(</span>e<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">Couldn’t update the widget </span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>tag<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">,</span> e<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span>\n  <span class=\"token keyword\">return</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre>\n<p>This function does the following:</p>\n<ol>\n<li>Get the template for this widget</li>\n<li>Get the data to flow into the template</li>\n<li>Use the <code>self.widgets.updateByTag()</code> method to push the <var>template</var> and <var>data</var> to the widget service to update any widget instances connected to the widget’s <code>tag</code>.</li>\n</ol>\n<p>As I mentioned, I also have code in place to take advantage of Periodic Background Sync if/when it’s available and the browser allows my site to do it:</p>\n<pre class=\"language-js\" tabindex=\"0\"><code class=\"language-js\"><span class=\"token keyword\">async</span> <span class=\"token keyword\">function</span> <span class=\"token function\">registerPeriodicSync</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">widget</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">let</span> tag <span class=\"token operator\">=</span> widget<span class=\"token punctuation\">.</span>definition<span class=\"token punctuation\">.</span>tag<span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span><span class=\"token string\">\"update\"</span> <span class=\"token keyword\">in</span> widget<span class=\"token punctuation\">.</span>definition<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    registration<span class=\"token punctuation\">.</span>periodicSync<span class=\"token punctuation\">.</span><span class=\"token function\">getTags</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">tags</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n      <span class=\"token comment\">// only one registration per tag</span>\n      <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span><span class=\"token operator\">!</span>tags<span class=\"token punctuation\">.</span><span class=\"token function\">includes</span><span class=\"token punctuation\">(</span>tag<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n        periodicSync<span class=\"token punctuation\">.</span><span class=\"token function\">register</span><span class=\"token punctuation\">(</span>tag<span class=\"token punctuation\">,</span> <span class=\"token punctuation\">{</span>\n          <span class=\"token literal-property property\">minInterval</span><span class=\"token operator\">:</span> widget<span class=\"token punctuation\">.</span>definition<span class=\"token punctuation\">.</span>update<span class=\"token punctuation\">,</span>\n        <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n      <span class=\"token punctuation\">}</span>\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span>\n  <span class=\"token keyword\">return</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre>\n<p>This function also receives the widget details and:</p>\n<ol>\n<li>Looks to see if the widget <code>definition</code> (from the Manifest) includes an <code>update</code> member. If it has one, it…</li>\n<li>Checks to see if there’s already a Periodic Background Sync that is registered for this tag. If none exists, it…</li>\n<li>Registers a new Periodic Background Sync using the <code>tag</code> value and a minimum interval equal to the <code>update</code> requested.</li>\n</ol>\n<p>The <code>update</code> member, as you may recall, is the frequency (in seconds) you’d ideally like the widget to be updated. In reality, you’re at the mercy of the browser as to when (or even if) your sync will run, but that’s totally cool as there are other ways to update widgets as well.<sup class=\"footnote-ref\"><a href=\"#fn1\" id=\"fnref1\">1</a></sup></p>\n<h3 id=\"uninstalling-a-widget\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#uninstalling-a-widget\" aria-hidden=\"true\">#</a> Uninstalling a widget</h3>\n<p>When a user uninstalls a widget, your Service Worker will receive a “widgetuninstall” event. Much like the “widgetinstall” event, the argument contains details about that widget which you can use to clean up after yourself:</p>\n<pre class=\"language-js\" tabindex=\"0\"><code class=\"language-js\">self<span class=\"token punctuation\">.</span><span class=\"token function\">addEventListener</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"widgetuninstall\"</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">event</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n  console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">Uninstalling </span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>event<span class=\"token punctuation\">.</span>widget<span class=\"token punctuation\">.</span>tag<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  event<span class=\"token punctuation\">.</span><span class=\"token function\">waitUntil</span><span class=\"token punctuation\">(</span><span class=\"token function\">uninstallWidget</span><span class=\"token punctuation\">(</span>event<span class=\"token punctuation\">.</span>widget<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre>\n<p>Your application may have different cleanup needs, but this is a great time to clean up any unneeded Periodic Sync registrations. Just be sure to check the length of the widget’s <code>instances</code> array (<code>widget.instances</code>) to make sure you’re dealing with the last instance of a given widget <em>before</em> you unregister the sync:</p>\n<pre class=\"language-js\" tabindex=\"0\"><code class=\"language-js\"><span class=\"token keyword\">async</span> <span class=\"token keyword\">function</span> <span class=\"token function\">uninstallWidget</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">widget</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>widget<span class=\"token punctuation\">.</span>instances<span class=\"token punctuation\">.</span>length <span class=\"token operator\">===</span> <span class=\"token number\">1</span> <span class=\"token operator\">&amp;&amp;</span> <span class=\"token string\">\"update\"</span> <span class=\"token keyword\">in</span> widget<span class=\"token punctuation\">.</span>definition<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token keyword\">await</span> self<span class=\"token punctuation\">.</span>registration<span class=\"token punctuation\">.</span>periodicSync<span class=\"token punctuation\">.</span><span class=\"token function\">unregister</span><span class=\"token punctuation\">(</span>widget<span class=\"token punctuation\">.</span>definition<span class=\"token punctuation\">.</span>tag<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span>\n  <span class=\"token keyword\">return</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre>\n<h3 id=\"refreshing-your-widgets\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#refreshing-your-widgets\" aria-hidden=\"true\">#</a> Refreshing your widgets</h3>\n<p>Widget platforms may periodically freeze your widget(s) to save resources. For example, they may do this when widgets are not visible. To keep your widgets up to date, they will periodically issue a “widgetresume” event. If you’ve modeled your approach on the one I’ve outlined above, you can route this event right through to your <code>updateWidget()</code> function:</p>\n<pre class=\"language-js\" tabindex=\"0\"><code class=\"language-js\">self<span class=\"token punctuation\">.</span><span class=\"token function\">addEventListener</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"widgetresume\"</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">event</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n  console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">Resuming </span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>event<span class=\"token punctuation\">.</span>widget<span class=\"token punctuation\">.</span>tag<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  event<span class=\"token punctuation\">.</span><span class=\"token function\">waitUntil</span><span class=\"token punctuation\">(</span><span class=\"token function\">updateWidget</span><span class=\"token punctuation\">(</span>event<span class=\"token punctuation\">.</span>widget<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre>\n<h3 id=\"actions\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#actions\" aria-hidden=\"true\">#</a> Actions</h3>\n<p>While I don’t want to get too into the weeds here, I do want to mention that widgets can have predefined user actions as well. These actions result in “widget click” events being sent back to the Service Worker so you can respond to them:</p>\n<pre class=\"language-js\" tabindex=\"0\"><code class=\"language-js\">self<span class=\"token punctuation\">.</span><span class=\"token function\">addEventListener</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"widgetclick\"</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">event</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">const</span> widget <span class=\"token operator\">=</span> event<span class=\"token punctuation\">.</span>widget<span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">const</span> action <span class=\"token operator\">=</span> event<span class=\"token punctuation\">.</span>action<span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">switch</span> <span class=\"token punctuation\">(</span>action<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token comment\">// Custom Actions</span>\n    <span class=\"token keyword\">case</span> <span class=\"token string\">\"refresh\"</span><span class=\"token operator\">:</span>\n      event<span class=\"token punctuation\">.</span><span class=\"token function\">waitUntil</span><span class=\"token punctuation\">(</span><span class=\"token function\">updateWidget</span><span class=\"token punctuation\">(</span>widget<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n      <span class=\"token keyword\">break</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre>\n<p>For a great example of how a widget can integrate actions, you should check out <a href=\"https://microsoftedge.github.io/Demos/pwamp/\">the demo PWAmp project</a>. <a href=\"https://github.com/MicrosoftEdge/Demos/blob/main/pwamp/sw-widgets.js\">Their Service Worker widget code</a> is worth a read.</p>\n<h2 id=\"result!\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#result!\" aria-hidden=\"true\">#</a> Result!</h2>\n<p>With all of these pieces in place, I was excited to see my site showing up in the Widget Dashboard in Windows 11.</p>\n<figure id=\"2023-10-09-02\">\n<p><img src=\"https://www.aaron-gustafson.com/i/posts/2023-10-09/widgets-in-windows.jpg\" alt=\"\"></p>\n<figcaption>A screenshot of Windows 11 showing the Widget Dashboard overlaying the desktop with this site installed as a PWA to the right. The “latest posts” and “latest links” widgets are shown.</figcaption>\n</figure>\n<p>You can view the full source code on GitHub:</p>\n<ul>\n<li><a href=\"https://github.com/aarongustafson/aaron-gustafson.com/blob/main/src/static/w/feed.ac.json\">“Feed” Adaptive Card Template</a></li>\n<li><a href=\"https://github.com/aarongustafson/aaron-gustafson.com/blob/main/src/static/manifest.json#L158-L237\">Widget definitions in the Manifest</a></li>\n<li><a href=\"https://github.com/aarongustafson/aaron-gustafson.com/blob/main/src/_javascript/serviceworker/widgets.js\">Widgets code in my Service Worker</a></li>\n</ul>\n<hr>\n<p>I’m quite hopeful this will be the first of many places PWA-driven widgets will appear. If you’s like to see them supported elsewhere, be sure to tell your browser and OS vendor(s) of choice. The more they hear from their user base that this feature is needed, the more likely we are to see it get implemented in more places.</p>\n<h2 id=\"addendum%3A-gotchas\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#addendum%3A-gotchas\" aria-hidden=\"true\">#</a> Addendum: Gotchas</h2>\n<p>In wiring this all up, I ran into a few current bugs I wanted to flag so you can avoid them:</p>\n<ul>\n<li>The <code>icons</code> member won’t accept SVG images. This should eventually be fixed, but it was keeping my widgets from appearing as installable.</li>\n<li>The <code>screenshots</code> members can’t be incredibly large. I’m told you should provide square screenshots no larger than 500px ×500px.</li>\n</ul>\n<hr class=\"footnotes-sep\">\n<section class=\"footnotes\">\n<h4 class=\"hidden\">Footnotes</h4>\n<ol class=\"footnotes-list\">\n<li id=\"fn1\" class=\"footnote-item\"><p>Have you checked out <a href=\"https://developer.mozilla.org/docs/Web/API/Server-sent_events/Using_server-sent_events\">Server Events</a>? <a href=\"#fnref1\" class=\"footnote-backref\">↩︎</a></p>\n</li>\n</ol>\n</section>\n","social_text":"I finally had a chance to put the work I did on a widgets proposal for PWAs into practice on my own site. It’s pretty exciting!","url":"https://www.aaron-gustafson.com/notebook/widgets/","tags":["progressive web apps","experiments","JavaScript","Microsoft","this site","user experience","web development","web standards","Windows"],"image":"https://www.aaron-gustafson.com/i/posts/2023-10-09/hero1.jpg","date_published":"2023-10-09T22:38:54Z"},{"id":"https://www.aaron-gustafson.com/notebook/progressive-web-apps-and-the-windows-ecosystem/","title":"✍🏻 Progressive Web Apps and the Windows Ecosystem","summary":"I had the great pleasure of delivering this talk about Microsoft’s strategy towards Progressive Web Apps at the Build conference.","content_html":"<p><em>I had the great pleasure of delivering a talk about Microsoft’s strategy towards Progressive Web Apps at <a href=\"https://build.microsoft.com\">Build</a>. You can <a href=\"#slides\">view the slides</a> or <a href=\"#video\">watch the recording</a> of this talk, but what follows is a distillation of my talk, taken from my notes and slides.</em></p>\n<p>I’m here to talk to you about Progressive Web Apps, but before we really tuck into that, I wanna give a shout out to an app that’s really impressed me. This is Expense Manager by the folks at <a href=\"https://vaadin.com\">Vaadin</a>:</p>\n<figure class=\"video-embed video-embed--16x9\" id=\"figure-2017-05-24-01\">  \n<video class=\"video-embed__video\" src=\"/i/posts/2017-05-24/01.mp4\" controls loop muted></video>\n</figure>\n<p>I do a lot of traveling and it’s helpful when I can easily track my expenses. Their app is simple but refined in this regard. It’s snappy and provides a great overall UX; it’s also cross platform, which is nice since I often jump between different OSes across mobile and desktop.</p>\n<figure class=\"video-embed video-embed--16x9\" id=\"figure-2017-05-24-02\">  \n<video class=\"video-embed__video\" src=\"/i/posts/2017-05-24/02.mp4\" controls loop muted></video>\n</figure>\n<p>The experience on the desktop version of their app is obviously a little better because I’ve got more real estate for viewing my expenses, but the same attention to detail has clearly been paid to the experience in both form factors, which is nice to see.</p>\n<figure class=\"video-embed video-embed--16x9\" id=\"figure-2017-05-24-03\">  \n<video class=\"video-embed__video\" src=\"/i/posts/2017-05-24/03.mp4\" controls loop muted></video>\n</figure>\n<p>Oh, and a little secret here… it’s a web app. In fact it’s a Progressive Web App. You should really <a href=\"https://demo.vaadin.com/expense-manager\">play around with it yourself</a> and kick the tires a bit to see how it’s made.</p>\n<h2 id=\"what-is-a-progressive-web-app%3F\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#what-is-a-progressive-web-app%3F\" aria-hidden=\"true\">#</a> What is a Progressive Web App?</h2>\n<p>Now that we’ve seen one in action, I want to start by clarifying what a Progressive Web App is, just so I’m sure we’re all on the same page before we go down this rabbit hole. As a point of clarification, you’ll hear me use the terms Progressive Web App and PWA interchangeably.</p>\n<p>So what is a Progressive Web App? Let’s ignore the first part of this term for a moment—<em>progressive</em>—I promise I’ll circle back to it shortly. Now the term “web app” may sound like something you can put your finger on, right? It’s software, on the Web, you use to complete a task. Like an expense manager, but it can be any website or property, really.</p>\n<p>And so it is with Progressive Web Apps too.</p>\n<figure id=\"fig-2017-05-24-04\" class=\"media-container\">\n<p><img src=\"https://www.aaron-gustafson.com/i/posts/2017-05-24/04.png\" alt=\"\"></p>\n</figure>\n<p>“Web apps” in this context can be any website type—a newspapers, games, books, shopping sites—it really doesn’t matter what the content or purpose of the website is, the “web app” moniker is applicable to all of them. <span data-quotable>The term could just have easily been progressive web <em>site</em> and it may be helpful to think of it as such</span>. It doesn’t need to be a single page app. You don’t need to be running everything client side. There are no particular requirements for the type of PWA you are developing.</p>\n<p>Essentially, a PWA is a website that is capable of being promoted to being an installed app. It gets many of the benefits of being an app (some of which I will cover shortly), but also has all of the benefits of being a website too. If you’ve looked at or developed a <a href=\"https://web.archive.org/web/20170616215532/https://developer.microsoft.com/en-us/windows/bridges/hosted-web-apps\">Hosted Web App</a>(HWA), which Microsoft introduced with Windows 10, PWAs are very\nsimilar. In fact, if you’ve built an HWA, it shouldn’t be too difficult for you to convert it into a PWA and, in doing so, you’ll get a ton of extra goodies for free… but I’m getting ahead of myself.</p>\n<p><a href=\"#figure-2017-05-24-05\">Here’s a quick comparison</a> of the Twitter app and <a href=\"https://lite.twitter.com/\">Twitter Lite</a>, as seen on an Android device:</p>\n<figure class=\"video-embed video-embed--16x9\" id=\"figure-2017-05-24-05\">  \n<video class=\"video-embed__video\" src=\"/i/posts/2017-05-24/05.mp4\" controls loop muted></video>\n<figcaption>A video showing the Twitter Android app and Twitter Lite, side-by-side to demonstrate how similar they are.</figcaption>\n</figure>\n<p>You’ll notice that from a quality, polish, and user experience perspective, they are nearly indistinguishable. And this is just the first iteration of Twitter Lite. It launched last month. The only real difference is that one was built using Web technologies and lives at a URL.</p>\n<p>Though <a href=\"https://infrequently.org/2015/06/progressive-apps-escaping-tabs-without-losing-our-soul/\">the “progressive web apps” moniker was coined by Frances Berriman in 2015</a> and has quickly become a buzzword in our industry, it’s important to recognize that this idea of the Web as app is not new.</p>\n<p>Back in 2007, <a href=\"https://web.archive.org/web/20070322155954/http://www.adobe.com/aboutadobe/pressroom/pressreleases/200703/031907ApolloLabs.html\">Adobe introduced Apollo</a>, later renamed the Adobe Integrated Runtime (<abbr aria-title=\"also known as\">a.k.a.</abbr> <a href=\"http://www.adobe.com/products/air.html\">Adobe AIR</a>). This technology enabled designers and developers to build apps in Flash or using Web technologies—HTML, CSS and JavaScript. It was pretty revolutionary for the time, supporting drag &amp; drop, menu bar integration, file management, and more.</p>\n<p>In 2009, Palm debuted <a href=\"https://en.wikipedia.org/wiki/WebOS\">webOS</a> <a href=\"http://www.palminfocenter.com/news/9668/palm-announces-the-palm-pre-smartphone/\">with the Palm Pre</a>. All software for webOS was built using web technologies. Sadly, as an operating system in the handset space, it failed to catch on, but <a href=\"https://www.lgwebos.com/\">LG has licensed webOS</a> for use in smart TVs and is experimenting with it for <abbr aria-title=\"Internet of Things\">IoT</abbr> devices and smartwatches.</p>\n<p>Since that time, more OSes have begun embracing Web technologies as a means of building applications. Windows 8 allowed Windows Store apps to be written in HTML, CSS, and JavaScript. And <a href=\"https://en.wikipedia.org/wiki/Firefox_OS\">Firefox OS</a> and <a href=\"https://www.chromium.org/chromium-os\">Chromium/Chrome OS</a> are fundamentally tied to to the Web stack.</p>\n<p>Countless tools have followed Adobe’s lead as well, enabling designers and developers to use their Web skills to build applications for the vast majority of operating systems out there. <a href=\"https://facebook.github.io/react-native/\">React Native</a>, <a href=\"http://ionicframework.com/\">Ionic</a>, <a href=\"https://electron.atom.io/\">Electron</a>, <a href=\"http://phonegap.com/\">PhoneGap</a>, <a href=\"http://www.appcelerator.com/\">Appcelerator</a>… the list goes on and on. Obviously there’s something to the idea of building software using Web technologies. Progressive Web Apps are a brilliant way of accomplishing this in a standardized, consistent, way.</p>\n<h2 id=\"what-makes-a-pwa-a-pwa%3F\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#what-makes-a-pwa-a-pwa%3F\" aria-hidden=\"true\">#</a> What makes a PWA a PWA?</h2>\n<p>Google’s <a href=\"https://infrequently.org/\">Alex Russell</a> defined 10 characteristics he believes define this new breed of Web application:</p>\n<ol>\n<li><strong>Progressive:</strong> It works for every user, regardless of browser choice because it’s built with progressive enhancement as a core tenet.</li>\n<li><strong>Responsive:</strong> The UI adapts to fit any form factor.</li>\n<li><strong>Network independent:</strong> It works offline and on low-quality networks (which is something <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker\">Service Worker</a> helps with).</li>\n<li><strong>App-like:</strong> It feels like an app in terms of responsiveness and UX.</li>\n<li><strong>Fresh:</strong> The experience is always up to date (another area where Service Worker shines).</li>\n<li><strong>Safe:</strong> It is served via HTTPS to prevent snooping and to ensure content hasn’t been tampered with.</li>\n<li><strong>Discoverable:</strong> Search spiders can identify it as an app because it uses a <a href=\"https://developer.mozilla.org/en-US/docs/Web/Manifest\">Web Application Manifest</a> (and a Service Worker).</li>\n<li><strong>Re-engageable:</strong> It can re-engage users through features like <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Push_API\">push notifications</a>.</li>\n<li><strong>Installable:</strong> It can be installed by users if they find it useful. This could be done independently of—but is not necessarily exclusive of—app stores.</li>\n<li><strong>Linkable:</strong> It is easily accessed (and shared) via a URL.</li>\n</ol>\n<p>Let’s tuck into the installable piece first since this is the bit that really sets a PWA apart from a standard website. Now many might view this as a continuation of the competition between Web and traditional app development. I don’t think of the two as being competitive, so much as being choices. We should choose our development approach based on the needs of our project, team, budget, etc. It’s good to have options and both approaches have their strengths.</p>\n<blockquote>\n<p><del>Web vs. Platform-specific</del><br>\n<ins>Web *or* Platform-specific?<br>\nIt depends.</ins></p>\n</blockquote>\n<p>Often Web tech gets dismissed for not having the capabilities of apps. That’s changing rather rapidly. A visit to <a href=\"https://whatwebcando.today/\">whatwebcando.today</a> will give you a run-down of what your browser supports; you might be surprised with what you’ll learn about your browser’s capabilities. And if the end user experience is really good, does it matter what the underlying technology is?</p>\n<p>Well, it might…</p>\n<p>In the Web vs. apps discussion, time to market is an aspect that isn’t often discussed. With a traditional web and app approach, each platform is typically built atop a core API. The apps are designed and developed independently, using different toolsets and languages and requiring different skills from the development team. And even in instances where they are all created using a single tool, the timeline needs to be padded in order to account for submission to each app store. That can cause delays in getting your product in front of users. It can also delay your delivery of critical updates.</p>\n<figure id=\"fig-2017-05-24-06\" class=\"media-container\">\n<p><img src=\"https://www.aaron-gustafson.com/i/posts/2017-05-24/06.png\" alt=\"\"></p>\n</figure>\n<p>Contrast that with building your software as a web-based product with the characteristics of a PWA. Using this approach, you can build it once and deploy it everywhere… <em><a href=\"https://cloudfour.com/thinks/progressive-web-apps-simply-make-sense/\">even to platforms that don’t support PWAs</a>!</em> And if you opt to submit your app to the various app stores, you could likely get away with a a one-time submission because updates will be seamless from there on out—it is the Web after all.</p>\n<figure id=\"fig-2017-05-24-07\" class=\"media-container\">\n<p><img src=\"https://www.aaron-gustafson.com/i/posts/2017-05-24/07.png\" alt=\"\"></p>\n</figure>\n<p>Now that we’ve talked about install ability—the “app” bit, if you will—let’s circle back to that first principle of Progressive Web Apps: <em>progressive</em>. It must be important, after all it is literally the first word in this approach. “Progressive” in this context refers to <em>progressive enhancement</em>. In case you’re unfamiliar with the idea, I’ll provide a quick analogy; I’m a huge music and movie fan, so we’ll focus on sound for this analogy.</p>\n<p>Back in the early days of recording, we only had a single speaker (or horn, back in the Victrola days) to relay the sound to our ears. Round about the 1930s, modern two-channel stereophonic sound was invented to solve a cinematic problem: in early “talkies” a single channel of sound was delivered through multiple speakers, which sometimes led to a weird situation where a performer would be on one side of the screen, but their voice would be coming from the other side (the speaker near you). Stereo sound allowed the actor’s voice to follow them in a much more natural way. Even with this advancement, though, stereo recordings could still be listened to on a single speaker by combining the channels.</p>\n<p>Over time, stereophonic sound gave way to quadrophonic (or “surround”) sound and we kept adding more channels… and more channels, creating more and more immersive experiences. But even though a recording might sound best in 16.2 or 22.2<sup class=\"footnote-ref\"><a href=\"#fn1\" id=\"fnref1\">1</a></sup> channels of sound, movies, television, and music mastered for complete immersion can still be appreciated on a single, mono bluetooth speaker or on your mobile device (which is basically in mono when you’re viewing it in landscape mode). That is progressive enhancement.</p>\n<figure class=\"video-embed video-embed--16x9\" id=\"figure-2017-05-24-08\">  \n<video class=\"video-embed__video\" src=\"/i/posts/2017-05-24/08.mp4\" controls loop muted></video>\n<figcaption>An animated explanation of progressive enhancement using sound channels.</figcaption>\n</figure>\n<p>Progressive enhancement is concerned with honoring the core purpose of an experience—in software’s case the core purpose of a project and the core tasks a user will want to accomplish using it. The core experience should always be available, regardless of device or browser being used or the capabilities or limitations of that device… or of the user. It doesn’t mean you can’t create a better experience for folks who can benefit from that, but you never do that to the exclusion of your users.</p>\n<p>And yes, that means having an experience that works when JavaScript doesn’t. But that’s a whole other talk…</p>\n<p>With progressive enhancement, we build the baseline experience and then enhance it as we are able to. In practical terms, progressive enhancement ensures people can use your product, regardless of</p>\n<ul>\n<li>Unsupported browser and/or device features Network issues that block or delay important assets,</li>\n<li>Browser plug-ins that interfere with JavaScript execution,</li>\n<li>3rd party code that interferes with JavaScript execution.</li>\n<li>Proxy browsers that optimize/adjust your code,</li>\n<li>Your users requiring alternate input methods or assistive tech,</li>\n<li>etc.</li>\n</ul>\n<figure id=\"fig-2017-05-24-09\" class=\"media-container\">\n<p><img src=\"https://www.aaron-gustafson.com/i/posts/2017-05-24/09.png\" alt=\"\"></p>\n<figcaption>A chart plotting capabilities against experience, showing a steady improvement in experience as the number of capabilities increase.</figcaption>\n</figure>\n<p>Let me walk you through a very basic example of progressive enhancement in practice as I think it will illustrate this point.</p>\n<p>Here we have an email input field:</p>\n<pre class=\"language-html\" tabindex=\"0\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>input</span> <span class=\"token attr-name\">type</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>email<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>email<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">id</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>email<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">required</span> <span class=\"token attr-name\">aria-required</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>true<span class=\"token punctuation\">\"</span></span> <span class=\"token punctuation\">/></span></span></code></pre>\n<p>The “email” field type was introduced in HTML5, so older browsers may not support it. Those that don’t will provide the default <code>input</code> type—a text field—to users. That’s totally fine—it’s all we had for more than a dozen years before HTML5 came along! But even if a user’s device does support email fields, it’s implementation may vary. Based on how a browser answers the following questions, users will end up with different experiences:</p>\n<ul>\n<li>Do you support for email input type?</li>\n<li>Do you support the HTML5 form validation algorithm including the email format?</li>\n<li>Do you offer a virtual keyboard?</li>\n</ul>\n<p>Moving on to the <code>required</code> attribute—another HTML5 introduction—some browsers will use it for input validation, some won’t know what to do with it. Those that implement this feature may block form submission if the field is left empty, but some won’t do anything with that info <em>even if they know the field is empty</em>!</p>\n<p>Finally, there’s the <code>aria-required</code> attribute. This is a part of the ARIA (Accessible Rich Internet Applications) spec and is used to inform assistive technology if the field is required. But it’s possible the browser may not support the attribute or that the assistive tech being used may not do anything with that information even if the browser does expose it.</p>\n<p>In terms of experience of this field, it improves incrementally along a path like this:</p>\n<ol>\n<li>Input…</li>\n<li>with required notification to assistive tech…</li>\n<li>with required enforcement…</li>\n<li>with email type validation…</li>\n<li>with speedier entry via virtual keyboard.</li>\n</ol>\n<figure id=\"fig-2017-05-24-10\" class=\"media-container\">\n<p><img src=\"https://www.aaron-gustafson.com/i/posts/2017-05-24/10.png\" alt=\"\"></p>\n</figure>\n<p>Now think about that for a second—this incredible variety of experience is created by one HTML element when you add three specific attributes to it. And the experienced is enhanced—<em>progressively</em>—as the browser’s and operating system’s capabilities increase. Amazing!</p>\n<p>As I mentioned, <span data-quotable>progressive enhancement ensures people can use your product, no matter what</span>. You could just as easily swap in “PWA” for “progressive enhancement” in that statement. After all, PWAs give you network awareness and independence, they can be used to lower the overall cost of using your product for your for users through smart caching, they enable access to platform APIs on certain platforms, and they provide more ways for your product to get discovered (e.g., search, store, links). Those are some impressive progressive enhancement bona fides.</p>\n<p>Additionally, the two technical lynchpins of PWA—Web App Manifest and Service Worker—are ignored if they aren’t supported. Products you build using them <a href=\"https://cloudfour.com/thinks/why-does-the-washington-posts-progressive-web-app-increase-engagement-on-ios/\">will continue to work really well, even in their absence</a>. They are, by definition, progressive enhancements too.</p>\n<p>Now I’ve mentioned Service Worker a few times, so it probably makes sense to do a little sidebar here to explain what Service Workers are. A Service Worker is a proxy spawned by JavaScript that can handle a variety of tasks involving the network. They can</p>\n<ul>\n<li>Manage offline experiences,</li>\n<li>Intercept and respond to or modify network requests,</li>\n<li>Manage caching,</li>\n<li>Receive and handle push notifications, and</li>\n<li>Handle background sync requests.</li>\n</ul>\n<p><em>Note: At this point in the presentation, I passed the mic to my colleague <a href=\"https://twitter.com/boyofgreen\">Jeff Burtoft</a> to give a quick demo of Service Worker in practice.</em></p>\n<h2 id=\"what%E2%80%99s-the-timeline-for-progressive-web-apps-in-windows%3F\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#what%E2%80%99s-the-timeline-for-progressive-web-apps-in-windows%3F\" aria-hidden=\"true\">#</a> What’s the timeline for Progressive Web Apps in Windows?</h2>\n<p>Now that we’ve covered the groundwork of PWAs, I want to discuss where they fit in the Windows ecosystem. As I mentioned earlier, Windows has a history of supporting Web tech, but it even predates Windows 8. Back in Windows 7 we began supporting <a href=\"https://msdn.microsoft.com/en-us/library/gg491738(v=vs.85).aspx\">pinned sites</a>. They enabled developers to customize a sticky tab in the taskbar that provided quick access to key tasks, a customizable browser UI, and more. Then, in Windows 8, packaged apps could be completely written in HTML, CSS, and JavaScript. In Windows 10 we introduced Hosted Web Apps, which enabled your wholly web-based product to be distributed and installed via the Windows Store. And now we are in the process of taking our support of the Web to the next level with Progressive Web Apps.</p>\n<p>In terms of the work necessary to make this happen, the Edge team has already landed <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API\">Fetch API</a> support. Fetch is the powerful successor to <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest\">XMLHttpRequest</a> that is a critical underpinning of Service Worker. As I mentioned, Hosted Web Apps arrived with Windows 10 and they provide a secure, discrete container for Web apps within Windows that will also be used with PWAs. Additionally, <a href=\"https://learn.microsoft.com/en-us/microsoft-edge/webview2/how-to/winrt-from-js\">WinRT</a> provides programmatic access to OS internals like the calendar, contacts, Cortana, and more via JavaScript.</p>\n<p>Our engineering effort around Service Worker kicked off about a year ago and we’re making great progress in bringing PWAs to Edge and Windows. Support for PWAs will become available to Windows Insiders early this summer. Initially, Service Worker, the <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Cache\">Cache API</a>, and the <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Push_API\">Push API</a> will be behind a <a href=\"http://www.windowscentral.com/understanding-aboutflags-microsoft-edge\">feature flag</a>.</p>\n<p>Once PWAs are fully supported, they will use the same container technology currently in use for Hosted Web Apps. As I mentioned, it’s an established container with excellent performance and a ton of benefits:</p>\n<ul>\n<li>Standalone Window</li>\n<li>Independent from browser process\n<ul>\n<li>Less overhead</li>\n<li>Isolated cache</li>\n<li>Nearly unlimited storage (indexed DB, localStorage, etc.)</li>\n</ul>\n</li>\n<li>Offline &amp; background processes</li>\n<li>Access to Windows Runtime (WinRT) APIs via JavaScript\n<ul>\n<li>Calendar</li>\n<li>Cortana</li>\n<li>Address Book</li>\n</ul>\n</li>\n</ul>\n<p>On Windows, Progressive Web Apps are essentially Hosted Web Apps, evolved. In fact, you could build your PWA and ship it as an HWA today and when the remainder of the PWA stack lands, it will automatically transform into a full-fledged PWA (another benefit of the Web for distribution).</p>\n<h2 id=\"how-does-a-user-discover-a-progressive-web-app%3F\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#how-does-a-user-discover-a-progressive-web-app%3F\" aria-hidden=\"true\">#</a> How does a user discover a Progressive Web App?</h2>\n<p>Now that we’ve seen how PWAs operate within Windows, I want to take a few minutes to talk about how users will find your PWAs. As part of our initial move to support Progressive Web Apps, we will be enabling users to discover and install them from within the store and in Bing search results.</p>\n<figure id=\"fig-2017-05-24-11\" class=\"media-container\">\n<p><img src=\"https://www.aaron-gustafson.com/i/posts/2017-05-24/11.jpg\" alt=\"\"></p>\n<figcaption>Screenshots of Bing search results and the Windows Store, highlighting how an app might appear in both contexts.</figcaption>\n</figure>\n<p>Now you may be wondering, with all of the awesomeness the Web has to offer, why does it make sense for PWAs to reside in app stores? There are numerous reasons:</p>\n<ol>\n<li>It puts PWAs on equal footing with traditional apps.</li>\n<li>Stores provide an alternate means of discovery for PWAs.</li>\n<li>Users are generally more comfortable trusting software that has been reviewed for quality and safety.</li>\n<li>Developers can get more insight into their users through reviews and ratings as well as analytics concerning installs, uninstalls, shares, and performance.</li>\n<li>Having a store where users download software also reduces the cognitive overhead of tracking multiple sources for installing apps.</li>\n</ol>\n<p>PWAs can get into the Windows Store in one of two ways. The first is through active submission. Using a tool like the open source utility <a href=\"http://www.pwabuilder.com/\">PWA Builder</a>, you can generate the necessary app wrappers used by the various app stores and manually submit your PWA.</p>\n<p><em>Note: I invited Jeff back up on stage to walk through building a PWA and submitting it to the Windows Store using PWA Builder.</em></p>\n<p>Obviously we want Windows users to have access to as many quality PWAs as possible, but we recognize that not all development teams have the time to submit and maintain their apps in the Store. To address this, we’ve developed an approach to enable their apps to be easily discovered in the Store too. For lack of a better term, we’re currently calling this process “passive ingestion”.</p>\n<figure id=\"fig-2017-05-24-12\" class=\"media-container\">\n<p><img src=\"https://www.aaron-gustafson.com/i/posts/2017-05-24/12.png\" alt=\"\"></p>\n</figure>\n<p>We are already using the Bing Crawler to identify PWAs on the Web for our PWA research. The Web App Manifest is a proactive signal from developers that a given website should be considered an app; we’re listening to that signal and evaluating those sites as candidates for the Store. Once we identify quality PWAs, we’ll automatically generate the APPX wrapper format used by the Windows Store and assemble a Store entry based on metadata about the app provided in the Web App Manifest.</p>\n<p>We completely understand that some of you may not want your products automatically added to the Store and we respect that.\nBy adding these 2 lines to your site’s <a href=\"http://www.robotstxt.org/robotstxt.html\"><code>robots.txt</code> file</a>, the Bing Crawler will ignore your Web App Manifest, opting your site out of this process:</p>\n<pre class=\"language-txt\" tabindex=\"0\"><code class=\"language-txt\">User-agent: bingbot\nDisallow: /manifest.json</code></pre>\n<p>We are working on a set of criteria that will help us separate quality PWAs from sites that simply appear PWA-like. It’s still early days, but our consideration of what constitutes a “quality” PWA hinges on the following:</p>\n<ul>\n<li><strong>Does this site have a Web App Manifest?</strong> In our initial crawl of sites looking for PWAs, we discovered over 1.5 million manifests across 800k domains. Looking at a selection of these sites, we discovered that not all are good candidates for ingestion. Some aren’t PWAs at all, others have a boilerplate manifest generated by tools like favicon generators.</li>\n<li><strong>Does the Web App Manifest suggest quality?</strong> We will be looking for non-boilerplate manifests that include a name, description, and at least one icon that is larger than 192px square.</li>\n<li><strong>Is the site secure?</strong> At this point, we are only looking for HTTPS, we aren’t evaluating <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP\">CSP</a> or other protections.</li>\n<li><strong>Does the site have a valid Service Worker?</strong> <a href=\"https://serviceworke.rs/\">Mozilla has a bunch of recipes</a> if you are looking for somewhere to start.</li>\n<li><strong>Is the site popular?</strong> We will prioritize sites that rank highly on <a href=\"http://www.alexa.com/topsites\">Alexa</a>, <a href=\"https://www.quantcast.com/top-sites\">Quantcast</a>, and other “top sites” lists.</li>\n<li><strong>Does the site pass automated testing for quality?</strong> There are a number of tools out there for this, including our <a href=\"https://developer.microsoft.com/en-us/microsoft-edge/tools/staticscan/\">Site Scanner</a>, <a href=\"https://developers.google.com/web/tools/lighthouse/\">Lighthouse</a>, <a href=\"https://www.deque.com/products/axe/\">aXe</a>, and more.</li>\n<li><strong>Is the app content free?</strong> There are certainly ways to charge for apps and content in the Windows Store, but we won’t passively ingest any sites that require a licensing fee or subscription. You’ll be able to submit those manually though.</li>\n<li><strong>Does the app pass manual review?</strong> PWAs will need to meet the standards of the Windows Store, just like any other app. We will not ingest apps that violate laws or Store policies.</li>\n</ul>\n<p>Once in the Store, we’ll notify developers of their draft Store entry and they will be able to claim their apps to take complete control of their Store presence. Regardless, whether they got their by passive ingestion or my manual submission, the Web App Manifest will provide the basic set of information used for the app in the Store: name, description, icons, and screenshots. We’re also actively working with others in the W3C to introduce support for <a href=\"https://github.com/w3c/manifest/issues/569\">app categories</a> and <a href=\"https://github.com/w3c/manifest/issues/523\">IARC ratings</a>.</p>\n<p>PWAs will appear alongside other apps in the Store, with no differentiation. From a users’ perspective, a PWA will just be another app. They will install just like any other app. They will have settings just like any other app. They will uninstall just like any other app. They will also be shareable via URL or the Store. PWAs will be first-class apps on Windows.</p>\n<hr>\n<p>Phew… that was a lot to take in. At this point, you might have some questions. Here are a few I imagine you’re wrestling with.</p>\n<p><strong>Should I forget everything I know and start building a Progressive Web App?</strong></p>\n<p><em>No.</em> Progressive Web Apps are just one more way you can build a high-quality app experience.</p>\n<p><strong>Will Microsoft drop support for my favorite programming language in favor of Progressive Web Apps?</strong></p>\n<p><em>No.</em> We are committed to supporting a breadth of language options when it comes to developing apps.</p>\n<p><strong>Are Progressive Web Apps the right choice for my project?</strong></p>\n<p><em>Maybe.</em> When evaluating app development in relation to Progressive Web Apps, here are some of the questions I recommend asking…</p>\n<ul>\n<li>Are there features the Web can’t offer that are critical to the success of this product?</li>\n<li>What is the total cost (time and money) of building and maintaining each platform-specific app?</li>\n<li>What are the strengths of my dev team? <em>or</em> How easy will it be to assemble a new team with the necessary skills to build each app as opposed to a PWA?</li>\n<li>How critical will immediate app updates (e.g., adding new security features) be?</li>\n</ul>\n<p>In other words, the choice between PWA and a platform-specific app should be evaluated on a case-by-case basis. For example…</p>\n<ul>\n<li>If you are looking to craft an experience that takes full advantage of each platform you release it on and you want to agonize over every UX detail in order to differentiate your product… an app <em>might</em> be the best choice for you.</li>\n<li>If you are maintaining a product on multiple platforms in addition to the Web and they are all largely the same in terms of look &amp; feel and capabilities, it may make more sense to focus all of your efforts on the Web version and go PWA.</li>\n<li>If you are planning a brand new product and the Web provides all of the features you need (especially when you also consider the additional APIs provided via the host OS), building a PWA is probably going to be a faster, more cost-effective option.</li>\n</ul>\n<p><strong>Should I consider Progressive Web Apps as a solid option when developing software for Windows?</strong></p>\n<p><em>Definitely.</em></p>\n<p>You probably have more questions. I’ll do my best to answer them in the comments.</p>\n<h2 id=\"slides\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#slides\" aria-hidden=\"true\">#</a> Slides</h2>\n<p><a href=\"https://www.slideshare.net/AaronGustafson/progressive-web-apps-and-the-windows-ecosystem-build-2017\">Slides from this talk</a> are available on <a href=\"https://www.slideshare.net\">Slideshare</a>.</p>\n<figure class=\"video-embed video-embed--16x9\" id=\"figure-2017-05-24-13\">  \n<iframe class=\"video-embed__video\" src=\"https://www.slideshare.net/slideshow/embed_code/key/InI5w0bH4JxCwW\" frameborder=\"0\"></iframe>\n</figure>\n<h2 id=\"video\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#video\" aria-hidden=\"true\">#</a> Video</h2>\n<p><a href=\"https://channel9.msdn.com/Events/Build/2017/B8075\">A video recording of this presentation</a> (including Jeff’s demos) is available on <a href=\"https://channel9.msdn.com\">Channel 9</a>.</p>\n<figure class=\"video-embed video-embed--16x9\" id=\"figure-2017-05-24-14\">  \n<iframe src=\"https://channel9.msdn.com/Events/Build/2017/B8075/player\" width=\"900\" height=\"540\" allowFullScreen frameBorder=\"0\"></iframe>\n</figure>\n<p><em>Note: I no longer use “native” in the context of apps and platforms, but it remains in quoted material.</em></p>\n<hr class=\"footnotes-sep\">\n<section class=\"footnotes\">\n<h4 class=\"hidden\">Footnotes</h4>\n<ol class=\"footnotes-list\">\n<li id=\"fn1\" class=\"footnote-item\"><p>Crazy as it sounds, 22.2 is actually the standard used by Ultra-High Definition (UHD) television. <a href=\"#fnref1\" class=\"footnote-backref\">↩︎</a></p>\n</li>\n</ol>\n</section>\n","url":"https://www.aaron-gustafson.com/notebook/progressive-web-apps-and-the-windows-ecosystem/","tags":["progressive web apps","progressive enhancement","Windows","Microsoft","presentations"],"date_published":"2017-05-24T15:13:24Z"},{"id":"https://www.aaron-gustafson.com/speaking-engagements/progressive-web-apps-and-the-windows-ecosystem/","title":"📢 Progressive Web Apps and the Windows Ecosystem","summary":"In this session, I discuss what PWAs are, how they can be integrated into the development process of modern websites, the advantages and disadvantages of PWAs vs. native development, and what opportunities they present when installed alongside native apps in Windows.","content_html":"<p>Whether at home or at work, the web plays an increasingly critical role in our daily lives. As we have become more dependent on accessing the tools it powers, we’ve also struggled to overcome some of its limitations—network connectivity, for instance.</p>\n<p>At Microsoft, we’ve long been interested in the power of the web for software development and we are even more excited for the future possibilities offered by progressive web apps (PWAs). In this session, I discuss what PWAs are, how they can be integrated into the development process of modern websites, the advantages and disadvantages of PWAs vs. native development, and what opportunities they present when installed alongside native apps in Windows.</p>\n","social_text":"In this session, I discuss what PWAs are, how they can be integrated into the development process of modern websites, the advantages and disadvantages of PWAs vs. native development, and what opportunities they present when installed alongside native apps in Windows.","url":"https://www.aaron-gustafson.com/speaking-engagements/progressive-web-apps-and-the-windows-ecosystem/","tags":["progressive web apps","progressive enhancement","Windows","Microsoft"],"image":"https://www.aaron-gustafson.com/undefined","date_published":"2017-05-10T13:00:00Z"},{"id":"https://www.aaron-gustafson.com/notebook/mac-like-special-characters-in-windows/","title":"✍🏻 Mac-like Special Characters in Windows","summary":"I love the way OS X/macOS handles special characters and was looking to implement something similar on Windows. Here’s how I did it.","content_html":"<p>I am a bit of a geek for proper punctuation: Em dashes… en dashes… curly quotes… ellipses… I love them all! Prior to 2007, I was a long-time Windows user and was a master of the <kbd>Alt + <var>numeric code</var></kbd> system of entering special characters on that operating system.<sup class=\"footnote-ref\"><a href=\"#fn1\" id=\"fnref1\">1</a></sup> For nearly a decade, however, I’ve been writing and developing on a Mac and I absolutely love how much easier it is to use special characters. When I started setting up my new Surface Book, I began searching for a way to bring Mac-like special character entry to Windows 10.</p>\n<p><em>Disclaimer: I take absolutely no credit for the code you see below. I will give full credit to the sources as I discuss each. I just wanted to bring it all into one place so it’ll save you a few hours of research to get everything working.</em></p>\n<h2 id=\"step-1%3A-set-up-autohotkey\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#step-1%3A-set-up-autohotkey\" aria-hidden=\"true\">#</a> Step 1: Set up AutoHotKey</h2>\n<p><a href=\"https://thejournal.com/articles/2016/01/26/how-to-create-keyboard-shortcuts-for-special-characters-in-windows-10.aspx\">David Nagel’s solid article on mapping keystrokes in Windows</a>, I introduced me to <a href=\"https://autohotkey.com/\">AutoHotKey</a>. It’s an incredibly powerful program that’s like the lovechild of <a href=\"https://textexpander.com/\">TextExpander</a> and <a href=\"https://qsapp.com/\">Quicksilver</a>.</p>\n<p>In his article, David walks through the process of getting set up with AutoHotKey:</p>\n<ol>\n<li><a href=\"https://autohotkey.com/download/\">Download</a> &amp; install it.</li>\n<li>Create a new <code>.ahk</code> file (<samp>New &gt; AutoHotKey Script</samp> in Windows Explorer) and name it whatever you like.<sup class=\"footnote-ref\"><a href=\"#fn2\" id=\"fnref2\">2</a></sup></li>\n<li>Right-click the script, and choose <samp>Edit Script</samp> from the context menu.</li>\n<li>Enter some keyboard shortcuts (more on that in a moment).</li>\n<li>Save the script. I chose to save it to Dropbox to make it portable.</li>\n<li>Double click it to run the script.</li>\n<li>Open up your favorite writing tool and see your handiwork in action.</li>\n</ol>\n<h2 id=\"step-2%3A-create-some-shortcuts\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#step-2%3A-create-some-shortcuts\" aria-hidden=\"true\">#</a> Step 2: Create some shortcuts</h2>\n<p>AutoHotKey is completely scriptable and adding shortcuts is relatively straightforward. There are a few reserved characters, but once you understand what they are it’s pretty easy to get going very quickly. Here’s Dave’s intro example:</p>\n<pre class=\"language-txt\" tabindex=\"0\"><code class=\"language-txt\">!-::–\n!+-::—</code></pre>\n<p>In AutoHotKey scripting, “!” stands in for <kbd>Alt</kbd> and “+” stands in for <kbd>Shift</kbd>. So, to translate:</p>\n<ol>\n<li><kbd>Alt + -</kbd> will produce an en dash (–)</li>\n<li><kbd>Shift Alt + -</kbd> will produce an em dash (—)</li>\n</ol>\n<p>With these two examples, I was able to jump right in and map many of the most common shortcuts I use while writing. Before I got too far, however, I realized I really needed accents, umlauts, and the like. I searched some more and eventually discovered <a href=\"https://autohotkey.com/board/topic/27801-special-characters-osx-style\">a post in the AutoHotKey forum archive by “Veil” from way back in 2008</a>.</p>\n<p>Veil broke his solution into two parts, but I’ve combined them here to make it easier for your to copy into your AutoHotKey script file. This code has provided everything I’ve needed so far, so Veil—wherever you are—<strong>thank you</strong>!</p>\n<pre class=\"language-txt\" tabindex=\"0\"><code class=\"language-txt\">#UseHook\n!VKC0SC029::Return \t; grave -> the grave ` accent gave some probs, used the virtualkey + scancode instead\n!e::Return         \t; acute\n!i::Return          ; circumflex\n!t::Return         \t; tilde\n!u::Return          ; umlaut\n\n;                  1 2 3 4 5 6 7 8 9 1\n;                                    0\n;              r   g G a A c C t T u U\n*a::diacritic(\"a\",\"à,À,á,Á,â,Â,ã,Ã,ä,Ä\")\n*e::diacritic(\"e\",\"è,È,é,É,ê,Ê,e,E,ë,Ë\")\n*i::diacritic(\"i\",\"ì,Ì,í,Í,î,Î,i,I,ï,Ï\")\n*o::diacritic(\"o\",\"ò,Ò,ó,Ó,ô,Ô,õ,Õ,ö,Ö\")\n*u::diacritic(\"u\",\"ù,Ù,ú,Ú,û,Û,u,U,ü,Ü\")\n*n::diacritic(\"n\",\"n,N,n,N,n,N,ñ,Ñ,n,N\")\n*y::diacritic(\"y\",\"y,Y,y,Y,y,Y,y,Y,ÿ,Ÿ\")\n\ndiacritic(regular,accentedCharacters) {\n    StringSplit, char, accentedCharacters, `,\n    graveOption            := char1\n    graveShiftOption       := char2\n    acuteOption            := char3\n    acuteShiftOption       := char4\n    circumflexOption       := char5\n    circumflexShiftOption  := char6\n    tildeOption            := char7\n    tildeShiftOption       := char8\n    umlautOption           := char9\n    umlautShiftOption      := char10\n\n    if (A_PriorHotKey = \"!VKC0SC029\" &amp;&amp; A_TimeSincePriorHotkey &lt; 2000) {\n        if (GetKeyState(\"Shift\")) {\n            SendInput % graveShiftOption\n        } else {\n            SendInput % graveOption\n        }\n    } else if (A_PriorHotKey = \"!e\" &amp;&amp; A_TimeSincePriorHotkey &lt; 2000) {\n        if (GetKeyState(\"Shift\")) {\n            SendInput % acuteShiftOption\n        } else {\n            SendInput % acuteOption\n        }\n    } else if (A_PriorHotKey = \"!i\" &amp;&amp; A_TimeSincePriorHotkey &lt; 2000) {\n        if (GetKeyState(\"Shift\")) {\n            SendInput % circumflexShiftOption\n        } else {\n            SendInput % circumflexOption\n        }\n    } else if (A_PriorHotKey = \"!t\" &amp;&amp; A_TimeSincePriorHotkey &lt; 2000) {\n        if (GetKeyState(\"Shift\")) {\n            SendInput % tildeShiftOption\n        } else {\n            SendInput % tildeOption\n        }\n    } else if (A_PriorHotKey = \"!u\" &amp;&amp; A_TimeSincePriorHotkey &lt; 2000) {\n        if (GetKeyState(\"Shift\")) {\n            SendInput % umlautShiftOption\n        } else {\n            SendInput % umlautOption\n        }\n    } else {\n        if (GetKeyState(\"Shift\") or GetKeyState(\"Capslock\",\"T\")) {\n            SendInput % \"+\" regular\n        } else {\n            SendInput % regular\n        }\n    }\n}\n\n;\n; Alt + Shift + key\n;\n*!1::altShift(\"¡\",\"/\")\n*!2::altShift(\"€\",\"™\")\n*!3::altShift(\"£\",\"‹\")\n*!4::altShift(\"¢\",\"›\")\n*!5::altShift(\"8\",\"fi\")\n*!6::altShift(\"§\",\"fl\")\n*!7::altShift(\"¶\",\"‡\")\n*!8::altShift(\"•\",\"°\")\n*!9::altShift(\"ª\",\"·\")\n*!0::altShift(\"º\",\"‚\")\n\n*!a::altShift(\"å\",\"Å\")\n*!b::altShift(\"integral\",\"i\")\n*!c::altShift(\"ç\",\"Ç\")\n*!d::altShift(\"partial difference\",\"Î\")\n*!e::altShift(\"´\",\"‰\")\n*!f::altShift(\"ƒ\",\"Ï\")\n*!g::altShift(\"©\",\"Ì\")\n*!h::altShift(\"overdot\",\"Ó\")\n*!i::altShift(\"^\",\"È\")\n*!j::altShift(\"delta\",\"Ô\")\n*!k::altShift(\"°\",\"Apple\")\n*!l::altShift(\"¬\",\"Ò\")\n*!m::altShift(\"µ\",\"˜\")\n*!n::altShift(\"~\",\"ˆ\")\n*!o::altShift(\"ø\",\"Ø\")\n*!p::altShift(\"pi\",\"Pi\")\n*!q::altShift(\"œ\",\"Œ\")\n*!r::altShift(\"®\",\"Â\")\n*!s::altShift(\"ß\",\"Í\")\n;*!t::altShift(\"†\",\"Ê\")\n*!u::altShift(\"¨\",\"Ë\")\n*!v::altShift(\"v\",\"lozenge\")\n*!w::altShift(\"epsilon\",\"„\")\n*!x::altShift(\"approximately equal\",\"Ù\")\n*!y::altShift(\"¥\",\"Á\")\n*!z::altShift(\"Omega\",\"Û\")\n\n*!-::altShift(\"–\",\"—\")\n*!=::altShift(\"!=\",\"±\")\n*![::altShift(\"“\",\"”\")\n*!]::altShift(\"‘\",\"’\")\n*!`;::altShift(\"…\",\"Ú\")\n*!'::altShift(\"æ\",\"Æ\")\n*!\\::altShift(\"«\",\"»\")\n*!,::altShift(\"&lt;=\",\"¯\")\n*!.::altShift(\">=\",\"breve\")\n*!/::altShift(\"÷\",\"¿\")\n\naltShift(accented,accentedShift) {\n    if (!GetKeyState(\"Shift\")) {\n        SendInput % accented\n    } else {\n        SendInput % accentedShift\n    }\n}\n\n; Fix for some CTRL + stuff that may not work\n; TODO - Add more as we find them\n^a::Send ^{end}^+{home}\n^o::WinMenuSelectItem, A, , File, Open</code></pre>\n<h2 id=\"step-3%3A-run-your-script-when-windows-starts\" tabindex=\"-1\"><a class=\"header-anchor\" href=\"#step-3%3A-run-your-script-when-windows-starts\" aria-hidden=\"true\">#</a> Step 3: Run your script when Windows starts</h2>\n<p>The last thing you’ll want to do is add your <code>.ahk</code> file to Windows’ startup items. Dave covered that in his piece as well:</p>\n<ol>\n<li>Create a shortcut to your file (<samp>Right click &gt; Create Shortcut</samp>)</li>\n<li>Run <code>shell:startup</code> (<kbd>⊞ Win + R</kbd> opens the Run dialog or you can type ”Run“ in the Cortana Search Box)</li>\n<li>Move your shortcut to the folder that opens.</li>\n</ol>\n<p>Once you’ve followed those steps, you’re done. You can update your <code>.ahk</code> scripts needed and just double click it to replace the instance that’s currently running.</p>\n<hr>\n<p>If, like me (and <a href=\"https://twitter.com/search?q=%23davegoeswindows\">Dave</a> and <a href=\"https://snook.ca/archives/other/running-into-windows\">Jonathan</a> and <a href=\"http://danielmall.com/articles/opening-windows/\">Dan</a>), you’re using Windows after a long time in Mac land <em>and</em> you’re a typography nerd, hopefully you’ll find this helpful. And if you come up with any improvements to the character mapping, please share!</p>\n<hr class=\"footnotes-sep\">\n<section class=\"footnotes\">\n<h4 class=\"hidden\">Footnotes</h4>\n<ol class=\"footnotes-list\">\n<li id=\"fn1\" class=\"footnote-item\"><p>I actually memorized a ton of <a href=\"http://tools.oratory.com/altcodes.html\">the codes</a>, much to my amazement. I still remember a few, but I am thankful to have reclaimed a bit of that memory space over the last few years. <a href=\"#fnref1\" class=\"footnote-backref\">↩︎</a></p>\n</li>\n<li id=\"fn2\" class=\"footnote-item\"><p>If you shun the mouse, you can create a text file in your favorite editor and name it with the <code>.ahk</code> extension, but you might run into character encoding issues. I created mine in <a href=\"https://code.visualstudio.com/\">VS Code</a> as UTF-8, but had to open the file in Notepad and re-save it again to get it to actually work. I never figured out the exact issue, but I thought I’d give you a heads-up. <a href=\"#fnref2\" class=\"footnote-backref\">↩︎</a></p>\n</li>\n</ol>\n</section>\n","url":"https://www.aaron-gustafson.com/notebook/mac-like-special-characters-in-windows/","tags":["Windows","writing"],"date_published":"2016-11-02T15:59:42Z"},{"id":"https://www.aaron-gustafson.com/notebook/an-end-to-aging-ie-installs/","title":"✍🏻 An End to Aging IE Installs","summary":"Today is a momentous day.","content_html":"<p>Today is a momentous day.</p>\n<p>After spending years of griping about IE6’s staying power and lamenting Microsoft’s earlier decision to <a href=\"http://www.informationweek.com/news/191203474\">advocate against upgrading to IE7</a> (a decision they didn’t stick with, thankfully), Microsoft has turned a new leaf today, announcing that <a href=\"http://windowsteamblog.com/ie/b/ie/archive/2011/12/15/ie-to-start-automatic-upgrades-across-windows-xp-windows-vista-and-windows-7.aspx\">they will be pushing updates to IE to anyone who takes part in their Windows Update service</a>.</p>\n<p>What does this mean? Well, it means that grandma will be upgraded to IE8 if she’s still on Windows XP or IE9 if she’s on Vista or Windows 7.</p>\n<p>Corporations (and individuals) still have the ability to opt-out of these updates, but this move should put an end to upgrades that haven’t happened purely because users didn’t know how to upgrade to a new version of IE. As Microsoft’s own Peter Laudati so eloquently put it, <a href=\"http://blogs.msdn.com/b/peterlau/archive/2011/12/15/upgrade-your-parents-browser-weekend-holiday-to-become-obsolete.aspx\"><span class=\"initial quote\">“</span>Upgrade Your Parents Browser Weekend” is now officially obsolete</a>.</p>\n","url":"https://www.aaron-gustafson.com/notebook/an-end-to-aging-ie-installs/","tags":["browsers","Windows"],"date_published":"2011-12-15T19:34:06Z"}]}