Keep your coding agent up to date with the latest web best practices
Release v0.0.66
github-actions[bot]e2d758809d71
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.jsonindex 97dba4d..375a564 100644--- a/.claude-plugin/marketplace.json+++ b/.claude-plugin/marketplace.json@@ -8,7 +8,7 @@"name": "modern-web-guidance","source": "./","description": "Google Chrome's agent skills collection",- "version": "0.0.65"+ "version": "0.0.66"}]}diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.jsonindex 581aa9b..eb56d63 100644--- a/.claude-plugin/plugin.json+++ b/.claude-plugin/plugin.json@@ -1,7 +1,7 @@{"name": "modern-web-guidance","description": "Google Chrome's agent skills collection",- "version": "0.0.65",+ "version": "0.0.66","author": {"name": "Google Chrome"}diff --git a/README.md b/README.mdindex 693e804..1172126 100644--- a/README.md+++ b/README.md@@ -2,10 +2,10 @@This curated collection of skills, tools, and AI-ready documentation injects Chrome's web platform knowledge directly into your workflow, ensuring your coding agent builds apps that are modern, fast, and secure by default.-#### Skill Coverage in `v0.0.65`+#### Skill Coverage in `v0.0.66`<details>-<summary><strong>75 web features with implementation guidance from Chrome's experts</strong>: `::backdrop`, `:autofill`, `:has()`, `:not()`, `:user-valid and :user-invalid`, `@starting-style`, `<details>`, `<dialog closedby>`, `<dialog>`, `<link rel="expect">`, `<link rel="preload">`, `AbortController and AbortSignal`, `accent-color`, `Active view transition`, `Anchor positioning`, `blocking="render"`, `calc-size()`, `color-scheme`, `Container queries`, `content-visibility`, `Cross-document view transitions`, `Customizable <select>`, `Email, telephone, and URL <input> types`, `enterkeyhint`, `Fetch`, `Fetch priority`, `fetchLater`, `field-sizing`, `font-size-adjust`, `Form-associated WebMCP attributes`, `hidden="until-found"`, `image-set()`, `Individual transform properties`, `inert`, `inputmode`, `Interest invokers`, `interpolate-size`, `Intl.DurationFormat`, `Invoker commands`, `Language detector`, `light-dark()`, `linear() easing`, `Long animation frames`, `Masks`, `moveBefore()`, `Mutually exclusive <details> elements`, `Navigation API`, `navigator.modelContext`, `overlay`, `Page visibility state`, `Popover`, `popover="hint"`, `prefers-color-scheme media query`, `prefers-contrast media query`, `prefers-reduced-motion media query`, `Registered custom properties`, `Scheduler API`, `Scroll snap`, `Scroll-driven animations`, `scroll-initial-target`, `scrollbar-color`, `scrollbar-width`, `scrollIntoView()`, `sibling-count() and sibling-index()`, `sin(), cos(), tan(), asin(), acos(), atan(), and atan2() (CSS)`, `Speculation rules`, `Temporal`, `text-box`, `text-wrap`, `text-wrap: balance`, `text-wrap: pretty`, `Top-level await`, `transition-behavior`, `View transitions`, `view-transition-class`</summary>+<summary><strong>77 web features with implementation guidance from Chrome's experts</strong>: `::backdrop`, `:autofill`, `:has()`, `:not()`, `:user-valid and :user-invalid`, `@starting-style`, `<details>`, `<dialog closedby>`, `<dialog>`, `<link rel="expect">`, `<link rel="preload">`, `AbortController and AbortSignal`, `accent-color`, `Active view transition`, `Anchor positioning`, `blocking="render"`, `calc-size()`, `color-scheme`, `Container queries`, `content-visibility`, `Cross-document view transitions`, `Customizable <select>`, `Email, telephone, and URL <input> types`, `enterkeyhint`, `Fetch`, `Fetch priority`, `fetchLater`, `field-sizing`, `font-size-adjust`, `Form-associated WebMCP attributes`, `hidden="until-found"`, `image-set()`, `Individual transform properties`, `inert`, `inputmode`, `Interest invokers`, `interpolate-size`, `Intl.DurationFormat`, `Invoker commands`, `Language detector`, `light-dark()`, `linear() easing`, `Long animation frames`, `Masks`, `moveBefore()`, `Mutually exclusive <details> elements`, `Navigation API`, `navigator.modelContext`, `overlay`, `Page visibility state`, `Popover`, `popover="hint"`, `prefers-color-scheme media query`, `prefers-contrast media query`, `prefers-reduced-motion media query`, `Registered custom properties`, `Scheduler API`, `Scroll snap`, `Scroll-driven animations`, `scroll-initial-target`, `scrollbar-color`, `scrollbar-width`, `scrollIntoView()`, `sibling-count() and sibling-index()`, `sin(), cos(), tan(), asin(), acos(), atan(), and atan2() (CSS)`, `Speculation rules`, `Summarizer`, `Temporal`, `text-box`, `text-wrap`, `text-wrap: balance`, `text-wrap: pretty`, `Top-level await`, `transition-behavior`, `Translator`, `View transitions`, `view-transition-class`</summary>- **[::backdrop](https://webstatus.dev/features/backdrop), [<dialog>](https://webstatus.dev/features/dialog), [overlay](https://webstatus.dev/features/overlay), [Popover](https://webstatus.dev/features/popover), [@starting-style](https://webstatus.dev/features/starting-style), [transition-behavior](https://webstatus.dev/features/transition-behavior)**- **animate-to-from-top-layer**: Animate elements such as dialogs, popovers, and tooltips as they're entering/exiting the top layer.@@ -143,6 +143,8 @@ This curated collection of skills, tools, and AI-ready documentation injects Chr- **dynamic-sibling-styling**: Create dynamic visual spectrums or layout arrangements that automatically adapt to the number of elements in a group.- **[Speculation rules](https://webstatus.dev/features/speculation-rules)**- **improve-next-page-load-performance**: Improve page load performance by prefetching or prerendering pages that the user is likely to visit next.+- **[Summarizer](https://webstatus.dev/features/summarizer)**+ - **summarizer**: Summarize text content using the on-device Summarizer API.- **[Temporal](https://webstatus.dev/features/temporal)**- **sequence-distributed-events**: Log and sequence operations in distributed microservices or high-throughput tracing environments by recording timestamps with nanosecond resolution.- **calculate-event-differentials**: Calculate the duration and time remaining between dates and times.@@ -162,6 +164,8 @@ This curated collection of skills, tools, and AI-ready documentation injects Chr- **prevent-text-wrapping**: Ensure the browser does not insert line breaks into text and will allow text to overflow its container.- **[Top-level await](https://webstatus.dev/features/top-level-await)**- **conditional-async-dependencies**: Conditionally load or initialize async dependencies (such as importing polyfills for missing web features) without requiring complex orchestration across all of a page's script dependencies.+- **[Translator](https://webstatus.dev/features/translator)**+ - **translator**: Translate text between languages using the on-device Translator API.- **[View transitions](https://webstatus.dev/features/view-transitions)**- **same-document-transitions**: Visually connect persisting elements across different page states or navigations in a Single Page Application (SPA) (e.g. expanding a product thumbnail into a full-bleed hero image) by smoothly morphing their size, position, or other styling properties.- **[view-transition-class](https://webstatus.dev/features/view-transition-class), [View transitions](https://webstatus.dev/features/view-transitions)**diff --git a/gemini-extension.json b/gemini-extension.jsonindex b9c327b..661a038 100644--- a/gemini-extension.json+++ b/gemini-extension.json@@ -1,7 +1,7 @@{"name": "modern-web-guidance","description": "Google Chrome's web development agent skills.",- "version": "0.0.65",+ "version": "0.0.66","author": {"name": "Google Chrome"}diff --git a/package.json b/package.jsonindex b2ee766..4147784 100644--- a/package.json+++ b/package.json@@ -2,7 +2,7 @@"name": "modern-web-guidance","displayName": "Modern Web Guidance","description": "Curated collection of agent skills for modern web development.",- "version": "0.0.65",+ "version": "0.0.66","publisher": "GoogleChrome","engines": {"vscode": "^1.90.0",diff --git a/skills/modern-web/guides/built-in-ai/summarizer.md b/skills/modern-web/guides/built-in-ai/summarizer.mdnew file mode 100644index 0000000..f04313a--- /dev/null+++ b/skills/modern-web/guides/built-in-ai/summarizer.md@@ -0,0 +1,152 @@+The **Summarizer API** allows web developers to offer local, AI-powered text distillation directly within the browser using **Gemini Nano**. This API supports various formats, including key points, headlines, and TL;DRs, while operating entirely on-device to ensure user privacy.++---++## Getting Started++The Summarizer API is available starting in **Chrome 138**. It requires a one-time model download of Gemini Nano.+++### Hardware & Software Requirements++- **OS**: Windows 10/11, macOS 13+, Linux, or ChromeOS (Chromebook Plus).+- **Storage**: 22GB free space for the profile volume.+- **RAM/CPU**: 16GB+ RAM and 4+ CPU cores.+- **VRAM**: 4GB+ (if using GPU).++### Model Download and Availability++Check if the model is ready, needs downloading, or is unavailable.++**Mandatory Options Passing:** You must pass the identical configuration options object to both `Summarizer.availability(options)` and `Summarizer.create(options)`. Do NOT use the deprecated `window.ai.summarizer` API surface.++**Mandatory Progress Monitoring:** You MUST implement a monitor for model download progress by providing a `monitor(m)` callback to `Summarizer.create()` and adding a listener for the `downloadprogress` event.++**User Gesture Requirement:** When `availability` is `'downloadable'` or `'downloading'`, triggering the actual download via `Summarizer.create()` requires a user gesture (such as a user click). You must place the creation call inside an event listener rather than calling it unconditionally on page load to prevent `NotAllowedError`.++```javascript+const options = {+ type: 'key-points',+ format: 'plain-text',+ length: 'medium'+};++const availability = await Summarizer.availability(options);++if (availability === 'available') {+ const summarizer = await Summarizer.create(options);+ // Ready to use immediately+} else if (availability === 'downloadable') {+ // A user gesture is strictly required to start the download+ document.getElementById('start-download-btn').addEventListener('click', async () => {+ const summarizer = await Summarizer.create({+ ...options,+ monitor(m) {+ m.addEventListener('downloadprogress', (e) => {+ console.log(`Downloaded ${Math.round((e.loaded / e.total) * 100)}%`);+ });+ },+ });+ });+}+```++## API Functions & Configuration++When creating a summarizer via `Summarizer.create(options)`, you can customize+the output:++| Parameter | Options | Description |+| :----------- | :----------------------------------------- | :-------------------------------------- |+| `type` | `key-points`, `tldr`, `teaser`, `headline` | Defines the summary strategy. |+| `format` | `markdown`, `plain-text` | Output syntax style. |+| `length` | `short`, `medium`, `long` | Target length (e.g., 1 vs 5 sentences). |+| `preference` | `auto`, `speed`, `capability` | Balances latency vs. quality. |++### Example Configuration++```javascript+const options = {+ sharedContext: 'This is a scientific article',+ type: 'key-points',+ format: 'markdown',+ length: 'medium',+};++if (navigator.userActivation.isActive) {+ const summarizer = await Summarizer.create(options);+}+```++### Language Support++You can specify expected languages to ensure the browser can handle the specific+summary request.++```javascript+const summarizer = await Summarizer.create({+ type: 'key-points',+ expectedInputLanguages: ['en', 'ja'],+ outputLanguage: 'es',+});+```++## Summarization Methods++### 1. Batch Summarization++Processes the entire text at once and returns the result.++```javascript+const longText = document.querySelector('article').innerText;+const summary = await summarizer.summarize(longText, {+ context: 'This article is intended for a tech-savvy audience.',+});+console.log(summary);+```++### 2. Stream Summarization++Returns results in real-time as the model generates them, providing a more+responsive UI.++```javascript+const stream = summarizer.summarizeStreaming(longText);+for await (const chunk of stream) {+ console.log(chunk);+}+```++## Security and Permissions++- **Data Privacy**: No data is sent to Google; processing happens on the local+ device.+- **Cross-Origin**: Access can be granted to iframes using the Permission+ Policy.+ ```html+ <iframe src="https://example.com/" allow="summarizer"></iframe>+ ```+- **Web Workers**: Currently not supported.++## Fallback Strategy++Summarizer has limited availability.++Before initializing or querying availability, check if the browser supports the `Summarizer` API:++```javascript+if ('Summarizer' in self) {+ // The Summarizer API is supported.+} else {+ // Execute fallback strategy+}+```++If the `Summarizer` API is unsupported or availability checks return `'unavailable'`, you must gracefully fall back.++Recommended options:+1. **Remote API Fallback**: Direct the distillation request to a server endpoint or remote API (such as the Vertex AI Gemini API) so that users still get summaries.+2. **Graceful Degradation**: Visually disable the summarization controls in the UI, or hide the button while displaying a friendly message (e.g., `"Local summarization is currently unsupported in this browser"`). Do not allow interaction to trigger generic unhandled runtime exceptions.+3. **Polyfill Fallback**: You can use community-maintained polyfills like `built-in-ai-task-apis-polyfills` or `prompt-api-polyfill` to emulate the API surface using remote services with models in the cloud or on-device inference with local models.++> **Privacy and Cost Implications:** These polyfills possibly proxy requests to remote servers (such as Gemini API over the cloud). This completely nullifies the on-device privacy guarantees of the native Built-in AI APIs and will incur server-side API usage costs.diff --git a/skills/modern-web/guides/built-in-ai/translator.md b/skills/modern-web/guides/built-in-ai/translator.mdnew file mode 100644index 0000000..85db741--- /dev/null+++ b/skills/modern-web/guides/built-in-ai/translator.md@@ -0,0 +1,159 @@+The **Translator API** allows developers to perform client-side text translation using built-in AI models in Chrome. This approach eliminates the need for cloud-based translation services for ephemeral content, reducing costs and improving privacy by keeping data on the user's device.+++## Prerequisites & Requirements++### Browser Support++- **Chrome:** Version 138+ (Desktop only).+- **Not Supported:** Mobile (Android/iOS), Edge, Firefox, Safari.++### Hardware Requirements++To run Gemini Nano and associated models, the system needs:++- **Operating System:** Windows 10/11, macOS 13+, Linux, or ChromeOS (Chromebook+ Plus).+- **Storage:** At least **22 GB** free on the Chrome profile volume.+- **Memory/CPU:** 16 GB+ RAM and 4+ CPU cores.+- **GPU:** 4 GB+ VRAM (Mandatory for Prompt API with audio).+- **Network:** Required only for the initial download of language packs/models.++## Implementation & Code Samples++### 1. Checking Availability & Downloading Models++**Mandatory Options Passing:** You must pass the identical configuration options object to both `Translator.availability(options)` and `Translator.create(options)`.++**Mandatory Progress Monitoring:** You MUST implement a monitor for model download progress by providing a `monitor(m)` callback to `Translator.create()` and adding a listener for the `downloadprogress` event.++**User Gesture Requirement:** When `availability` is `'downloadable'`, triggering the model download via `Translator.create()` requires a user gesture (such as a button click listener context). Unconditional page-load calls will trigger a `NotAllowedError`.++```javascript+const options = {+ sourceLanguage: 'es',+ targetLanguage: 'fr',+};++const availability = await Translator.availability(options);++if (availability === 'available' || availability === 'downloadable') {+ // A user gesture is strictly required to trigger create when downloadable+ document.getElementById('start-translation-btn').addEventListener('click', async () => {+ const translator = await Translator.create({+ ...options,+ monitor(m) {+ m.addEventListener('downloadprogress', (e) => {+ console.log(`Downloaded ${Math.round(e.loaded * 100)}%`);+ });+ },+ });+ });+}+```++### 3. Executing Translations++The API supports both static and streaming responses.++**Standard Translation:**++```javascript+const translator = await Translator.create({+ sourceLanguage: 'en',+ targetLanguage: 'fr',+});++const result = await translator.translate(+ 'Where is the next bus stop, please?',+);+console.log(result);+// Output: "Où est le prochain arrêt de bus, s'il vous plaît ?"+```++**Streaming Translation (for long text):**++```javascript+const stream = translator.translateStreaming(longText);+for await (const chunk of stream) {+ console.log(chunk);+}+```++## Supported Languages++The API supports a wide range of BCP 47 language codes: Here are the languages supported by Chrome's implementation of the Translator API:++- **ar**: Arabic+- **bg**: Bulgarian+- **bn**: Bengali+- **cs**: Czech+- **da**: Danish+- **de**: German+- **el**: Greek+- **en**: English+- **es**: Spanish+- **fi**: Finnish+- **fr**: French+- **hi**: Hindi+- **hr**: Croatian+- **hu**: Hungarian+- **id**: Indonesian+- **it**: Italian+- **iw**: Hebrew+- **ja**: Japanese+- **kn**: Kannada+- **ko**: Korean+- **lt**: Lithuanian+- **mr**: Marathi+- **nl**: Dutch+- **no**: Norwegian+- **pl**: Polish+- **pt**: Portuguese+- **ro**: Romanian+- **ru**: Russian+- **sk**: Slovak+- **sl**: Slovenian+- **sv**: Swedish+- **ta**: Tamil+- **te**: Telugu+- **th**: Thai+- **tr**: Turkish+- **uk**: Ukrainian+- **vi**: Vietnamese+- **zh**: Chinese+- **zh-Hant**: Chinese (Traditional)++## Security & Performance++- **Permissions Policy:** Cross-origin iframes require explicit permission.+ ```html+ <iframe src="https://example.com/" allow="translator"></iframe>+ ```+- **Web Workers:** Currently **not supported** due to Permission Policy+ complexities.+- **Privacy:** No data is sent to Google servers during the translation process+ once the model is downloaded.++## Fallback Strategy++Translator has limited availability.++Before use, check if the `Translator` object is available in the global scope:++```javascript+if ('Translator' in self) {+ // The Translator API is supported.+} else {+ // Execute fallback strategy+}+```++If the `Translator` API is unsupported or availability checks return `'unavailable'`, you must gracefully fall back.++Recommended options:+1. **Remote API Fallback**: Redirect the translation request to a server endpoint or cloud remote API (such as the Vertex AI Gemini API) to deliver translation functionality.+2. **Graceful Degradation**: Visually disable translation control elements or buttons while showing an end-user friendly note (e.g., `"Client-side translation is currently unsupported in this browser"`). Do not allow unhandled exceptions.+3. **Polyfill Fallback**: You can use community-maintained polyfills like `built-in-ai-task-apis-polyfills` or `prompt-api-polyfill` to emulate the API surface using remote services.++> **Privacy and Cost Implications:** These polyfills proxy requests to remote servers (such as Gemini API over the cloud). This completely nullifies the on-device privacy guarantees of the native Built-in AI APIs and will incur server-side API usage costs.