chrome-web-ai-types 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +21 -10
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -12,6 +12,16 @@ yarn add chrome-web-ai-types
12
12
  pnpm add chrome-web-ai-types
13
13
  ```
14
14
 
15
+ ### Reference the types in your project
16
+
17
+ For the global types (`Summarizer`, `Writer`, `Translator`, etc.) to be recognized, add this at the **top of a TypeScript file** that uses the APIs (or in a global `.d.ts` in your project):
18
+
19
+ ```ts
20
+ /// <reference types="chrome-web-ai-types" />
21
+ ```
22
+
23
+ Example: in a React component, Angular service, or Vue component that calls the APIs, put that line before any other code. Alternatively, add it once in a file like `src/global.d.ts` or `types/global.d.ts` so all files in the project get the types.
24
+
15
25
  ## Requirements
16
26
 
17
27
  - **TypeScript** 4.5+ (5.x recommended)
@@ -20,16 +30,16 @@ pnpm add chrome-web-ai-types
20
30
 
21
31
  ## APIs covered
22
32
 
23
- | API | Description |
24
- |-----|-------------|
25
- | **Summarizer** | Summarize text (key-points, tldr, teaser, headline) |
26
- | **Writer** | Generate text (tone, format, length) |
27
- | **Rewriter** | Rewrite text (tone, format, length) |
28
- | **Proofreader** | Grammar and spelling review |
29
- | **Translator** | Translate between languages |
30
- | **LanguageDetector** | Detect text language |
31
- | **LanguageModel** (Prompt API) | Prompts and sessions with Gemini Nano |
32
- | **window.ai** | `createLanguageModel()` (legacy) |
33
+ | API | Description |
34
+ | ------------------------------ | --------------------------------------------------- |
35
+ | **Summarizer** | Summarize text (key-points, tldr, teaser, headline) |
36
+ | **Writer** | Generate text (tone, format, length) |
37
+ | **Rewriter** | Rewrite text (tone, format, length) |
38
+ | **Proofreader** | Grammar and spelling review |
39
+ | **Translator** | Translate between languages |
40
+ | **LanguageDetector** | Detect text language |
41
+ | **LanguageModel** (Prompt API) | Prompts and sessions with Gemini Nano |
42
+ | **window.ai** | `createLanguageModel()` (legacy) |
33
43
 
34
44
  All expose `availability()`, `create(options?)`, streaming where applicable, and language options when documented.
35
45
 
@@ -81,6 +91,7 @@ Install the package and use the APIs in components or hooks. Global types are av
81
91
 
82
92
  ```tsx
83
93
  // src/hooks/useSummarizer.ts
94
+ /// <reference types="chrome-web-ai-types" />
84
95
  import { useState, useCallback } from "react";
85
96
 
86
97
  export function useSummarizer() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrome-web-ai-types",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "TypeScript definitions for Chrome Web AI APIs",
5
5
  "types": "index.d.ts",
6
6
  "keywords": [