Project Fugu
Project Fugu
By Lucien Immink
8 min read
Cross-platform software development is hard. Each platform has its specific implementation of an API and you end up with separate apps for each platform. Multiple frameworks try to fix this issue by creating an abstract between the platform and the application. Browser vendors are doing the same and it's called Project Fugu.
- Authors
- Name
- Lucien Immink
- linkedinLucien Immink
- twitter@lucienimmink
- Github
- githublucienimmink
Cross-platform software development is hard. Features and capabilities of an application require you to think about how it needs to be implemented on different platforms like Android, iOS, Web, Windows, MacOS and Linux. If you, for example, need to access the address details of a contact that is stored on a device you need to implement a piece of software, that allows you to access and choose a contact, let's call it a contact picker, for all the different platforms you want to support or you need to come up with a completely custom implementation. Custom implementations are probably not what you want to do. It can become quite messy quite fast.
So what can you do?
What about an abstraction layer between the OS native API and a common top layer, which is preferably written in a well-known set of languages that can handle UIs with a breeze, like HTML, CSS and JavaScript? Here we are describing a framework like Apache Cordova, Ionic's Capacitor, Electron or Tauri. These hybrid applications combine web languages with a wrapper for the OS native APIs. Hybrid cause they use web technology packaged as apps for distribution and have access to native device APIs.
While these hybrid frameworks enable developers to build one UI for multiple platforms they still have to build the application for all the platforms they want to support. The support for a platform or platform specific feature can often be flaky.
But what about the web platform itself? Progressive Web Apps (PWAs) bring offline support and app-like experiences to the web. Extending the PWA principle with APIs to include more native APIs while keeping the principles of the web (trust, privacy and security) is the core of Project Fugu 🐡.
Project Fugu
Project Fugu 🐡 is an effort to close gaps in the web's capabilities enabling new classes of applications to run on the web. APIs that Project Fugu is delivering enable new experiences on the web while preserving the web's core benefits of security, low friction, and cross-platform delivery. All Project Fugu API proposals are made in the open and on the standards track.
Fugu is organized as a Chromium project, open to all Chromium contributors and organizations. Today, that includes Microsoft, Intel, Samsung, Electron and Google (among others). Fugu Leads triage incoming requests from partners, determine demand, prioritize them, find champions, track development, and help organize the release and documentation for the capability.
Let's take a look at some of the features that have already been released:
Async Clipboard access
The original clipboard API is synchronized, meaning that it blocks access to the JavaScript thread as long as it is active. This is ok for handling small amounts of data like a single line of plain text but it would be a bad user experience for larger chunks of data like an image or a video. Another downside is that it could only read and write to the DOM. Project Fugu introduced async clipboard access. The async clipboard API is based on a well-defined permission model that doesn't block the page.
Writing text to the clipboard
To copy text to the clipboard call writeText()
. Since this API is asynchronous, the writeText()
function returns a Promise that resolves or rejects depending on whether the passed text is copied successfully:
async function copyPageUrl() {
try {
await navigator.clipboard.writeText(location.href)
} catch (err) {
console.error('Failed to copy: ', err)
}
}
Support for writeText()
clipboard has been added since Chrome 66, Firefox 63, Edge 79 and Safari 13.1 and thus is widely available on all platforms and browsers.
Writing data to the clipboard
To copy raw data to the clipboard the data needs to be a blob
meaning that all forms of data that are available as a blob
can be copied to the clipboard, including canvas and images/video (using fetch).
try {
const imgURL = '/images/generic/file.png'
await navigator.clipboard.write([
new ClipboardItem({
// Set the mimetype beforehand and write a promise as the value.
'image/png': await fetch(imgUrl)?.blob(),
}),
])
console.log('Image copied.')
} catch (err) {
console.error(err.name, err.message)
}
Support for write()
clipboard has been added since Chrome 66, Firefox 63 (only desktop), Edge 79 and Safari 13.1 and thus is widely available on most platforms and browsers.
Reading from the clipboard
The navigator.clipboard.read()
method is also asynchronous and returns a promise. To read an image from the clipboard, obtain a list of ClipboardItem
objects, then iterate over them.
Each ClipboardItem
can hold its contents in different types, so you'll need to iterate over the list of types, again using a for...of
loop. For each type, call the getType()
method with the current type as an argument to obtain the corresponding blob. As before, this code is not tied to images and will work with other future file types.
async function getClipboardContents() {
try {
const clipboardItems = await navigator.clipboard.read()
for (const clipboardItem of clipboardItems) {
for (const type of clipboardItem.types) {
const blob = await clipboardItem.getType(type)
console.log(URL.createObjectURL(blob))
}
}
} catch (err) {
console.error(err.name, err.message)
}
}
Support for read()
clipboard has been added since Chrome 86, Firefox 90 (only desktop), Edge 79 and Safari 13.1 and thus is widely available on most platforms and browsers.
Badging API
The Badging API gives web developers a method of setting a badge on a document or application, to act as a notification that the state has changed without displaying a more distracting notification. A common use case for this would be an application with a messaging feature displaying a badge on the app icon to show that new messages have arrived.
Types of badges
There are two types of badges:
- Document badges are typically shown in the browser tab near or on the page icon.
- App badges, which are associated with the icon of an installed web app. These may display on the app icon in the dock, shelf, or home screen depending on the device in use.
Badge states
nothing
: Indicating that no badge is currently set. A badge can be in this state due to it being cleared by the application, or being reset by the user agent.flag
: Indicating that the badge is set, but has no specific data to display. A badge will be in this state if the application has set a badge, but has not passed any value to the method.<int>
: A value passed when setting the badge. This value will never be 0, passing a value of 0 when setting a badge will cause the user agent to clear the badge by setting it tonothing
.
navigator.setClientBadge() // set a badge
navigator.clearClientBadge() // clear the badge
navigator.setAppBadge(12) // set 12 as app badge
WebOTP API
These days, most people in the world own a mobile device and developers are commonly using phone numbers as an identifier for users of their services.
There are a variety of ways to verify phone numbers, but a randomly generated one-time password (OTP) sent by SMS is one of the most common. Sending this code back to the developer's server demonstrates control of the phone number.
The WebOTP API lets your app receive specially-formatted messages bound to your app's domain. From this, you can programmatically obtain an OTP from an SMS message and verify a phone number for the user more easily.
<form>
<input autocomplete="one-time-code" required />
<input type="submit" />
</form>
if ('OTPCredential' in window) {
window.addEventListener('DOMContentLoaded', e => {
...
const ac = new AbortController();
const input = document.querySelector('input[autocomplete="one-time-code"]');
navigator.credentials.get({
otp: { transport:['sms'] },
signal: ac.signal
}).then(otp => {
input.value = otp.code;
}).catch(err => { /* ... */ });
});
}
Learn more about how to implement webOTP: https://developer.chrome.com/articles/web-otp/.
Support for webOTP has been added since Chrome 93, Edge 93. Firefox and Safari have no support, meaning that webOTP is not readily available yet.
File System Access
Dave Bitter has written an excellent article about File system access
Features in the pipeline
Some of the features that are being developed or considered at the moment:
- Changing system settings API
- Geofencing
- Splash screen
- Remote desktop control
- Call dialer/answering/control
...but what about the other one?
Project Fugu can offer a great experience, but only if the browser supports these APIs. Safari (and thus iOS and iPad OS) are not actively part of Project Fugu and have been slow with implementing APIs that extend the functionality of the web. Eg. support for service workers and push notifications. If Safari and Apple will ever actively contribute to Project Fugu, remains an open question. On the one hand, the fact that Apple does not allow other browser engines from their mobile platforms is one of the main reasons why web apps are still considered less than native apps. On the other, EU regulators have noticed this as well and are actively in debate if this 'browser ban' is considered to be legal. For more information concerning this specific topic, check out open-web-advocacy.
Closing thoughts
Cross-platform software development is hard. Features and capabilities of an application require you to think about how it needs to be implemented on different platforms like Android, iOS, Web, Windows, MacOS and Linux. If you, for example, need to access the address details of a contact that is stored on a device you need to implement a piece of software, that allows you to access and choose a contact, let's call it a contact picker, for all the different platforms you want to support or you need to come up with a completely custom implementation. Custom implementations are probably not what you want to do. It can become quite messy quite fast.
So what can you do?
Progressive Web Apps (PWAs) bring offline support and app-like experiences to the web. Extending the PWA principle with APIs to include more native APIs while keeping the principles of the web (trust, privacy and security) is the core of Project Fugu 🐡.
Some of these APIs are readily available and should be considered when that feature is needed, like for example the async clipboard API. Other APIs though are only available in certain browsers, like the webOTP API so handle them with care and consult the online references.
If Safari and Apple will ever actively contribute to Project Fugu, remains an open question. On the one hand, the fact that Apple does not allow other browser engines from their mobile platforms is one of the main reasons why web apps are still considered less than native apps. On the other, EU regulators have noticed this as well and are actively in debate if this 'browser ban' is considered to be legal. For more information concerning this specific topic, check out open-web-advocacy.
Upcoming events
The Test Automation Meetup
PLEASE RSVP SO THAT WE KNOW HOW MUCH FOOD WE WILL NEED Test automation is a cornerstone of effective software development. It's about creating robust, predictable test suites that enhance quality and reliability. By diving into automation, you're architecting systems that ensure consistency and catch issues early. This expertise not only improves the development process but also broadens your skillset, making you a more versatile team member. Whether you're a developer looking to enhance your testing skills or a QA professional aiming to dive deeper into automation, RSVP for an evening of learning, delicious food, and the fusion of coding and quality assurance! 🚀🚀 18:00 – 🚪 Doors open to the public 18:15 – 🍕 Let’s eat 19:00 – 📢 First round of Talks 19:45 – 🍹 Small break 20:00 – 📢 Second round of Talks 20:45 – 🍻 Drinks 21:00 – 🙋♀️ See you next time? First Round of Talks: The Power of Cross-browser Component Testing - Clarke Verdel, SR. Front-end Developer at iO How can you use Component Testing to ensure consistency cross-browser? Second Round of Talks: Omg who wrote this **** code!? - Erwin Heitzman, SR. Test Automation Engineer at Rabobank How can tests help you and your team? Beyond the Unit Test - Christian Würthner, SR. Android Developer at iO How can you do advanced automated testing for, for instance, biometrics? RSVP now to secure your spot, and let's explore the fascinating world of test automation together!
| Coven of Wisdom - Amsterdam
Go to page for The Test Automation MeetupCoven of Wisdom - Herentals - Winter `24 edition
Worstelen jij en je team met automated testing en performance? Kom naar onze meetup waar ervaren sprekers hun inzichten en ervaringen delen over het bouwen van robuuste en efficiënte applicaties. Schrijf je in voor een avond vol kennis, heerlijk eten en een mix van creativiteit en technologie! 🚀 18:00 – 🚪 Deuren open 18:15 – 🍕 Food & drinks 19:00 – 📢 Talk 1 20:00 – 🍹 Kleine pauze 20:15 – 📢 Talk 2 21:00 – 🙋♀️ Drinks 22:00 – 🍻 Tot de volgende keer? Tijdens deze meetup gaan we dieper in op automated testing en performance. Onze sprekers delen heel wat praktische inzichten en ervaringen. Ze vertellen je hoe je effectieve geautomatiseerde tests kunt schrijven en onderhouden, en hoe je de prestaties van je applicatie kunt optimaliseren. Houd onze updates in de gaten voor meer informatie over de sprekers en hun specifieke onderwerpen. Over iO Wij zijn iO: een groeiend team van experts die end-to-end-diensten aanbieden voor communicatie en digitale transformatie. We denken groot en werken lokaal. Aan strategie, creatie, content, marketing en technologie. In nauwe samenwerking met onze klanten om hun merken te versterken, hun digitale systemen te verbeteren en hun toekomstbestendige groei veilig te stellen. We helpen klanten niet alleen hun zakelijke doelen te bereiken. Samen verkennen en benutten we de eindeloze mogelijkheden die markten in constante verandering bieden. De springplank voor die visie is talent. Onze campus is onze broedplaats voor innovatie, die een omgeving creëert die talent de ruimte en stimulans geeft die het nodig heeft om te ontkiemen, te ontwikkelen en te floreren. Want werken aan de infinite opportunities van morgen, dat doen we vandaag.
| Coven of Wisdom Herentals
Go to page for Coven of Wisdom - Herentals - Winter `24 editionMastering Event-Driven Design
PLEASE RSVP SO THAT WE KNOW HOW MUCH FOOD WE WILL NEED Are you and your team struggling with event-driven microservices? Join us for a meetup with Mehmet Akif Tütüncü, a senior software engineer, who has given multiple great talks so far and Allard Buijze founder of CTO and founder of AxonIQ, who built the fundaments of the Axon Framework. RSVP for an evening of learning, delicious food, and the fusion of creativity and tech! 🚀 18:00 – 🚪 Doors open to the public 18:15 – 🍕 Let’s eat 19:00 – 📢 Getting Your Axe On Event Sourcing with Axon Framework 20:00 – 🍹 Small break 20:15 – 📢 Event-Driven Microservices - Beyond the Fairy Tale 21:00 – 🙋♀️ drinks 22:00 – 🍻 See you next time? Details: Getting Your Axe On - Event Sourcing with Axon Framework In this presentation, we will explore the basics of event-driven architecture using Axon Framework. We'll start by explaining key concepts such as Event Sourcing and Command Query Responsibility Segregation (CQRS), and how they can improve the scalability and maintainability of modern applications. You will learn what Axon Framework is, how it simplifies implementing these patterns, and see hands-on examples of setting up a project with Axon Framework and Spring Boot. Whether you are new to these concepts or looking to understand them more, this session will provide practical insights and tools to help you build resilient and efficient applications. Event-Driven Microservices - Beyond the Fairy Tale Our applications need to be faster, better, bigger, smarter, and more enjoyable to meet our demanding end-users needs. In recent years, the way we build, run, and operate our software has changed significantly. We use scalable platforms to deploy and manage our applications. Instead of big monolithic deployment applications, we now deploy small, functionally consistent components as microservices. Problem. Solved. Right? Unfortunately, for most of us, microservices, and especially their event-driven variants, do not deliver on the beautiful, fairy-tale-like promises that surround them.In this session, Allard will share a different take on microservices. We will see that not much has changed in how we build software, which is why so many “microservices projects” fail nowadays. What lessons can we learn from concepts like DDD, CQRS, and Event Sourcing to help manage the complexity of our systems? He will also show how message-driven communication allows us to focus on finding the boundaries of functionally cohesive components, which we can evolve into microservices should the need arise.
| Coven of Wisdom - Utrecht
Go to page for Mastering Event-Driven Design