Slide 1

Slide 1 text

Christian Liebel @christianliebel [email protected] Building Cross-Platform Productivity Apps with PWA and Project Fugu

Slide 2

Slide 2 text

https://paint.js.org – Productivity app – Draw images – Lots of actions & tools – Installable – Read/save files – Copy/paste images from/to clipboard – Share files to other apps – Register for file extensions Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Demo App LIVE DEMO

Slide 3

Slide 3 text

Paint PWA Capabilities Progressive Enhancement Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Agenda

Slide 4

Slide 4 text

Canvas – Plain bitmap for the web – Cross-platform, hardware- accelerated graphics operations – Supports different contexts (2D, 3D: WebGL, WebGL 2.0) – Supported on all evergreen browsers and on IE 9+ Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Paint

Slide 5

Slide 5 text

Canvas 2D Context fillRect(x, y, width, height) strokeRect(x, y, width, height) beginPath() moveTo(x, y) lineTo(x, y) fill() stroke() Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Paint

Slide 6

Slide 6 text

Browser Support Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Paint Canvas element ✓ ✓ ✓ 2D rendering context ✓ ✓ ✓ à always build apps for the browser

Slide 7

Slide 7 text

Paint PWA Capabilities Progressive Enhancement Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Agenda

Slide 8

Slide 8 text

@christianliebel Building Cross-Platform Productivity Apps with PWA and Project Fugu Responsive Linkable Discoverable Installable App-like Connectivity Independent Fresh Safe Re-engageable Progressive

Slide 9

Slide 9 text

Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Web App Manifest Service Worker

Slide 10

Slide 10 text

Web App Manifest Distinguishes Web Apps from Websites JSON-based file containing metadata for apps only Apps can be identified by search engines, app store providers, etc. Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel PWA

Slide 11

Slide 11 text

manifest.webmanifest { "short_name": "Paint", "name": "Paint Workshop", "theme_color": "white", "icons": [{ "src": "icon.png", "sizes": "512x512" }], "start_url": "/index.html", "display": "standalone", "shortcuts": [/* … */] } Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel PWA Names Icons Display Mode Shortcuts Start URL Theme color (status bar/window bar)

Slide 12

Slide 12 text

Service Worker JavaScript executed in an own thread, registered by the website Acts as a controller, proxy, or interceptor Has a cache to store responses (for offline availability and performance) Can wake up even when the website is closed and perform background tasks (e.g., push notifications or sync) Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel PWA

Slide 13

Slide 13 text

Service Worker Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel PWA Service Worker Internet Website HTML/JS Cache fetch

Slide 14

Slide 14 text

Browser Support Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Progressive Web Apps Offline Availability ✓ ✓ ✓ Installability ✓ (iOS/iPadOS only) (Android only) Push notifications ✓ ✓ ✓

Slide 15

Slide 15 text

Paint PWA Capabilities Progressive Enhancement Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Agenda

Slide 16

Slide 16 text

Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel

Slide 17

Slide 17 text

Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Capabilities https://goo.gle/fugu-api-tracker

Slide 18

Slide 18 text

Browser Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Capabilities navigator.share({ url: 'http://example.com' }); ShareIntent DataTransferManager … NSSharingServicePicker

Slide 19

Slide 19 text

File System Access API Some applications heavily rely on working with files File System Access API allows you to open, save and overwrite files and directories Supported by Chrome, Edge Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Capabilities

Slide 20

Slide 20 text

API const [handle] = await self.showOpenFilePicker({ multiple: true, types: [{ description: 'PNG files', accept: {'image/png': ['.png']} }] }); Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel File System Access API

Slide 21

Slide 21 text

Async Clipboard API Allows reading from/writing to the clipboard in an asynchronous manner Reading from the clipboard requires user consent first (privacy!) Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Capabilities

Slide 22

Slide 22 text

API Copy Content await navigator.clipboard.writeText('foo'); await navigator.clipboard.write(/* data */); Paste Content const content = await navigator.clipboard.readText(); const content = await navigator.clipboard.read(); Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Async Clipboard API

Slide 23

Slide 23 text

File Handling API Register your PWA as a handler for file extensions Requires installing the application first Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Capabilities

Slide 24

Slide 24 text

Manifest Extension { "file_handlers": [{ "action": "/", "accept": { "text/plain": [".txt"] }, "icons": [] }] } Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel File System Handling API

Slide 25

Slide 25 text

API if ('launchQueue' in window) { launchQueue.setConsumer(async params => { const [handle] = params.files; // do something with the handle }); } Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel File System Handling API

Slide 26

Slide 26 text

Browser Support Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Capabilities Async Clipboard API ✓ ✓ (writeText() only) File System Access (Desktop only) — —

Slide 27

Slide 27 text

Paint PWA Capabilities Progressive Enhancement Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Agenda

Slide 28

Slide 28 text

Overview if ('showSaveFilePicker' in window) { const handle = await window.showSaveFilePicker(); // … } else { // a) fall back to an alternative API (if available) // b) disable/hide functionality } Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Progressive Enhancement

Slide 29

Slide 29 text

Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Target Platforms PROGRESSIVE WEB APPS + cars, smart fridges, …

Slide 30

Slide 30 text

Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel VS Code https://vscode.dev/

Slide 31

Slide 31 text

Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Photoshop https://creativecloud.adobe.com/cc/photoshop

Slide 32

Slide 32 text

Capabilities (2021 à 2022) Async Clipboard 8.91% à 10.10% (percent of desktop websites) File System Access 29 à 2,317 (+7889%) (desktop websites) https://almanac.httparchive.org/en/2022/capabilities Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel 2022 Web Almanac

Slide 33

Slide 33 text

New powerful APIs regularly ship with new releases of Chromium-based browsers Some only add minor finishing touches, others enable whole application categories as productivity apps to finally make the shift to the web The Fugu process makes sure that capabilities are implemented in an interoperable, secure and privacy-preserving manner Let’s make the web a more capable platform! Building Cross-Platform Productivity Apps with PWA and Project Fugu @christianliebel Summary

Slide 34

Slide 34 text

Thank you for your kind attention! Christian Liebel @christianliebel [email protected]