@fave1/create-app 0.1.3 → 0.1.4
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.
- package/package.json +1 -1
- package/templates/break/README.md +1 -1
- package/templates/break/types/fave1.d.ts +34 -6
- package/templates/minimal/README.md +1 -1
- package/templates/minimal/types/fave1.d.ts +34 -6
- package/templates/panel/README.md +1 -1
- package/templates/panel/types/fave1.d.ts +34 -6
- package/templates/storage/README.md +1 -1
- package/templates/storage/types/fave1.d.ts +34 -6
package/package.json
CHANGED
|
@@ -85,7 +85,7 @@ the same version replaces it; once it has gone to review, bump the version —
|
|
|
85
85
|
`npm run build` type-checks with `tsc` and bundles `src/index.ts` — and everything
|
|
86
86
|
it imports, npm packages included — into one classic script (`dist/index.js`,
|
|
87
87
|
esbuild). That single file is what the shell loads and what `npm run submit`
|
|
88
|
-
uploads; keep it under
|
|
88
|
+
uploads; keep it under 1 MB. CSS and SVG files you import come in as text, pictures
|
|
89
89
|
(PNG, JPEG, GIF, WebP) as `data:` URLs (`import css from './panel.css'`), so they ship
|
|
90
90
|
inside it too. `npm run dev` rebuilds with the same esbuild command on every save
|
|
91
91
|
(`npm run bundle`), so what you try is what you ship.
|
|
@@ -84,7 +84,7 @@ interface Ui {
|
|
|
84
84
|
stack(children: Block[]): Block;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
type Permission = 'page.text' | 'page.selection' | 'page' | 'storage' | 'pub' | 'clipboard' | 'ai' | 'camera';
|
|
87
|
+
type Permission = 'page.text' | 'page.selection' | 'page' | 'storage' | 'pub' | 'clipboard' | 'ai' | 'camera' | 'mic';
|
|
88
88
|
|
|
89
89
|
/** `err.code` on anything `ctx` rejects with. */
|
|
90
90
|
type Fave1ErrorCode =
|
|
@@ -104,9 +104,9 @@ type Fave1ErrorCode =
|
|
|
104
104
|
| 'provider' // ctx.ai: the AI service failed (`err.reason` 'busy' | 'refused' | …, `err.retryable`)
|
|
105
105
|
| 'aborted' // ctx.ai: stopped — your signal, the tab went to the background, or the app closed
|
|
106
106
|
| 'no-voice' // ctx.ai.speak(): no way to pay for that voice — no key for its company and no Fave1 credits (Fave1 already told them)
|
|
107
|
-
| 'blocked' // ctx.camera: this site doesn't allow a camera
|
|
108
|
-
| 'unavailable' // ctx.camera:
|
|
109
|
-
| 'busy' // ctx.camera: another tab or app is using it
|
|
107
|
+
| 'blocked' // ctx.camera · ctx.mic: this site doesn't allow a camera / microphone
|
|
108
|
+
| 'unavailable' // ctx.camera · ctx.mic: none here, or the page isn't https
|
|
109
|
+
| 'busy' // ctx.camera · ctx.mic: another tab or app is using it
|
|
110
110
|
| 'credits' // ctx.purchases.buy(): not enough Fave1 credits (`err.balance`, `err.needed`) — Fave1 already showed Get credits
|
|
111
111
|
| 'not-yet' // ctx.purchases: in-app purchases aren't open to your app yet
|
|
112
112
|
| 'unreachable' | 'timeout' | 'server';
|
|
@@ -123,7 +123,7 @@ interface Fave1Error extends Error {
|
|
|
123
123
|
* together: back off, it clears within the minute.
|
|
124
124
|
* An older runtime may leave it out; read `quota` as `'account'`, `rate` from `put()` as `'hour'` and from `get()` as `'read'`. */
|
|
125
125
|
scope?: 'app' | 'account' | 'hour' | 'month' | 'read' | 'shared' | 'stickers' | 'all';
|
|
126
|
-
/** ctx.ai: more about why — `denied` 'undeclared' | 'off-in-settings' | 'paused' | 'not-now', `no-key` 'none' | 'credits-empty', `provider` 'busy' | '
|
|
126
|
+
/** ctx.ai: more about why — `denied` 'undeclared' | 'off-in-settings' | 'paused' | 'not-now', `no-key` 'none' | 'credits-empty' | 'fave1-only' (your app is a voice app — it runs on Fave1 AI only), `provider` 'busy' (overloaded — try again) | 'rate' (the person's key hit its per-minute limit — wait a minute) | 'billing' (their key's account has no credit) | 'quota' (their key hit its daily or free-plan limit) | 'refused' | 'model' | 'bad' | 'json' | 'length' — Fave1 tells the person about billing and quota, so don't offer a retry for those, `invalid` 'messages' | 'image' | 'json' | 'tools'. */
|
|
127
127
|
reason?: string;
|
|
128
128
|
/** ctx.ai `limit`: when it resets (ISO time — the 1st of next month, UTC). */
|
|
129
129
|
resetAt?: string;
|
|
@@ -131,6 +131,12 @@ interface Fave1Error extends Error {
|
|
|
131
131
|
retryAfter?: number;
|
|
132
132
|
/** ctx.ai: worth trying the same call again a bit later. */
|
|
133
133
|
retryable?: boolean;
|
|
134
|
+
/** ctx.ai: which AI said no — 'anthropic' | 'openai' | 'google' | 'xai' (on `key-broken` and `provider`). `err.message` already names it in plain words. */
|
|
135
|
+
by?: string;
|
|
136
|
+
/** ctx.ai: the person can fix this themselves (replace their key, switch to Fave1 AI, get credits, raise a limit) — show `err.message` and a button that calls `ctx.ai.setup()`. */
|
|
137
|
+
fixable?: boolean;
|
|
138
|
+
/** ctx.ai: Fave1 already showed the person a card about this with their options — keep your message short and don't stack another popup. */
|
|
139
|
+
shown?: boolean;
|
|
134
140
|
/** On `conflict` from `shared.set()`: the row as it is now (its `v` is the base to use next). */
|
|
135
141
|
current?: Shared;
|
|
136
142
|
/** ctx.purchases `credits`: their balance (when Fave1 may tell you — at home, or on a site your app is allowed on) and the item's price. */
|
|
@@ -331,7 +337,7 @@ interface Files {
|
|
|
331
337
|
* A `File` keeps its own name unless `opts.name` gives one. Empty files and HTML reject with `invalid`, over 25 MB with `too-large`.
|
|
332
338
|
* Uploads have two limits, all apps together: 600 an hour and 3,000 in 30 days on Free (more on paid plans); deleting a file
|
|
333
339
|
* doesn't give the upload back. Past either, `rate` with `err.scope` `'hour'` or `'month'` — stop, keep your place, carry on later. */
|
|
334
|
-
put(blob: Blob, opts?: { name?: string }): Promise<FileInfo>;
|
|
340
|
+
put(blob: Blob, opts?: { name?: string; onProgress?(sent: number): void }): Promise<FileInfo>;
|
|
335
341
|
/** The file, or `null` if it's gone. Never throws for a missing file. A file has no link of its own — to show it, make an object
|
|
336
342
|
* URL, set it as an `<img>` src, and `URL.revokeObjectURL()` it on load or error. Don't keep the URL; make a new one to draw again.
|
|
337
343
|
* Get files as they come into view: past 600 reads a minute (all apps together), `rate` with `err.scope` `'read'`. */
|
|
@@ -683,6 +689,26 @@ interface Camera {
|
|
|
683
689
|
close(): void;
|
|
684
690
|
readonly active: boolean;
|
|
685
691
|
}
|
|
692
|
+
/** `ctx.mic.open()` — a microphone that's on. */
|
|
693
|
+
interface MicFeed {
|
|
694
|
+
/** One audio track, no video — for `MediaRecorder` or `AudioContext.createMediaStreamSource`. Nothing plays through the speakers unless you do it. */
|
|
695
|
+
stream: MediaStream;
|
|
696
|
+
track: MediaStreamTrack | null;
|
|
697
|
+
/** What the browser actually applied. */
|
|
698
|
+
echo: boolean; noise: boolean; gain: boolean;
|
|
699
|
+
/** Input delay the device reports, in seconds — 0 when it doesn't say. */
|
|
700
|
+
latency: number;
|
|
701
|
+
stop(): void;
|
|
702
|
+
}
|
|
703
|
+
interface Mic {
|
|
704
|
+
/** Turns their microphone on — Fave1 asks first (once each time your app opens), then the browser asks for that site. Sound only.
|
|
705
|
+
* `echo` · `noise` · `gain` (all default true) are the browser's echo cancelling, noise suppression and automatic level — turn them off for
|
|
706
|
+
* someone on earphones. Rejects `denied` · `blocked` · `unavailable` · `busy`. Call it from a tap, not at launch. */
|
|
707
|
+
open(options?: { echo?: boolean; noise?: boolean; gain?: boolean }): Promise<MicFeed>;
|
|
708
|
+
/** Every microphone your app opened goes off. Closing your app does this too. */
|
|
709
|
+
close(): void;
|
|
710
|
+
readonly active: boolean;
|
|
711
|
+
}
|
|
686
712
|
/** One of the person's AIs. `id` is stable (`anthropic` · `openai` · `google` · `xai` · `fave1` · `mock`); `name` is what to show ("Claude", "Fave1 AI"). */
|
|
687
713
|
interface AiChoice { id: string; name: string }
|
|
688
714
|
interface AiChoices { current: AiChoice | null; others: AiChoice[]; locked: boolean }
|
|
@@ -792,6 +818,8 @@ interface Ctx {
|
|
|
792
818
|
clipboard: { read(): Promise<string | null>; write(text: string): Promise<boolean> };
|
|
793
819
|
/** Their camera, live, while your app is open — `camera` permission. The video stays on their page. */
|
|
794
820
|
camera: Camera;
|
|
821
|
+
/** Their microphone, live, while your app is open — `mic` permission, separate from the camera. The sound stays on their page. */
|
|
822
|
+
mic: Mic;
|
|
795
823
|
/** Your app's settings, edited in the developer console (Config tab) and loaded before `onLaunch` — a plain JSON object.
|
|
796
824
|
* It ships without review, so it holds **values, not code** and nothing secret: every person who opens the app receives it.
|
|
797
825
|
* While you build, `fave1 dev` serves the `config.json` next to your manifest. Missing or unreachable → `{}`. */
|
|
@@ -85,7 +85,7 @@ the same version replaces it; once it has gone to review, bump the version —
|
|
|
85
85
|
`npm run build` type-checks with `tsc` and bundles `src/index.ts` — and everything
|
|
86
86
|
it imports, npm packages included — into one classic script (`dist/index.js`,
|
|
87
87
|
esbuild). That single file is what the shell loads and what `npm run submit`
|
|
88
|
-
uploads; keep it under
|
|
88
|
+
uploads; keep it under 1 MB. CSS and SVG files you import come in as text, pictures
|
|
89
89
|
(PNG, JPEG, GIF, WebP) as `data:` URLs (`import css from './panel.css'`), so they ship
|
|
90
90
|
inside it too. `npm run dev` rebuilds with the same esbuild command on every save
|
|
91
91
|
(`npm run bundle`), so what you try is what you ship.
|
|
@@ -84,7 +84,7 @@ interface Ui {
|
|
|
84
84
|
stack(children: Block[]): Block;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
type Permission = 'page.text' | 'page.selection' | 'page' | 'storage' | 'pub' | 'clipboard' | 'ai' | 'camera';
|
|
87
|
+
type Permission = 'page.text' | 'page.selection' | 'page' | 'storage' | 'pub' | 'clipboard' | 'ai' | 'camera' | 'mic';
|
|
88
88
|
|
|
89
89
|
/** `err.code` on anything `ctx` rejects with. */
|
|
90
90
|
type Fave1ErrorCode =
|
|
@@ -104,9 +104,9 @@ type Fave1ErrorCode =
|
|
|
104
104
|
| 'provider' // ctx.ai: the AI service failed (`err.reason` 'busy' | 'refused' | …, `err.retryable`)
|
|
105
105
|
| 'aborted' // ctx.ai: stopped — your signal, the tab went to the background, or the app closed
|
|
106
106
|
| 'no-voice' // ctx.ai.speak(): no way to pay for that voice — no key for its company and no Fave1 credits (Fave1 already told them)
|
|
107
|
-
| 'blocked' // ctx.camera: this site doesn't allow a camera
|
|
108
|
-
| 'unavailable' // ctx.camera:
|
|
109
|
-
| 'busy' // ctx.camera: another tab or app is using it
|
|
107
|
+
| 'blocked' // ctx.camera · ctx.mic: this site doesn't allow a camera / microphone
|
|
108
|
+
| 'unavailable' // ctx.camera · ctx.mic: none here, or the page isn't https
|
|
109
|
+
| 'busy' // ctx.camera · ctx.mic: another tab or app is using it
|
|
110
110
|
| 'credits' // ctx.purchases.buy(): not enough Fave1 credits (`err.balance`, `err.needed`) — Fave1 already showed Get credits
|
|
111
111
|
| 'not-yet' // ctx.purchases: in-app purchases aren't open to your app yet
|
|
112
112
|
| 'unreachable' | 'timeout' | 'server';
|
|
@@ -123,7 +123,7 @@ interface Fave1Error extends Error {
|
|
|
123
123
|
* together: back off, it clears within the minute.
|
|
124
124
|
* An older runtime may leave it out; read `quota` as `'account'`, `rate` from `put()` as `'hour'` and from `get()` as `'read'`. */
|
|
125
125
|
scope?: 'app' | 'account' | 'hour' | 'month' | 'read' | 'shared' | 'stickers' | 'all';
|
|
126
|
-
/** ctx.ai: more about why — `denied` 'undeclared' | 'off-in-settings' | 'paused' | 'not-now', `no-key` 'none' | 'credits-empty', `provider` 'busy' | '
|
|
126
|
+
/** ctx.ai: more about why — `denied` 'undeclared' | 'off-in-settings' | 'paused' | 'not-now', `no-key` 'none' | 'credits-empty' | 'fave1-only' (your app is a voice app — it runs on Fave1 AI only), `provider` 'busy' (overloaded — try again) | 'rate' (the person's key hit its per-minute limit — wait a minute) | 'billing' (their key's account has no credit) | 'quota' (their key hit its daily or free-plan limit) | 'refused' | 'model' | 'bad' | 'json' | 'length' — Fave1 tells the person about billing and quota, so don't offer a retry for those, `invalid` 'messages' | 'image' | 'json' | 'tools'. */
|
|
127
127
|
reason?: string;
|
|
128
128
|
/** ctx.ai `limit`: when it resets (ISO time — the 1st of next month, UTC). */
|
|
129
129
|
resetAt?: string;
|
|
@@ -131,6 +131,12 @@ interface Fave1Error extends Error {
|
|
|
131
131
|
retryAfter?: number;
|
|
132
132
|
/** ctx.ai: worth trying the same call again a bit later. */
|
|
133
133
|
retryable?: boolean;
|
|
134
|
+
/** ctx.ai: which AI said no — 'anthropic' | 'openai' | 'google' | 'xai' (on `key-broken` and `provider`). `err.message` already names it in plain words. */
|
|
135
|
+
by?: string;
|
|
136
|
+
/** ctx.ai: the person can fix this themselves (replace their key, switch to Fave1 AI, get credits, raise a limit) — show `err.message` and a button that calls `ctx.ai.setup()`. */
|
|
137
|
+
fixable?: boolean;
|
|
138
|
+
/** ctx.ai: Fave1 already showed the person a card about this with their options — keep your message short and don't stack another popup. */
|
|
139
|
+
shown?: boolean;
|
|
134
140
|
/** On `conflict` from `shared.set()`: the row as it is now (its `v` is the base to use next). */
|
|
135
141
|
current?: Shared;
|
|
136
142
|
/** ctx.purchases `credits`: their balance (when Fave1 may tell you — at home, or on a site your app is allowed on) and the item's price. */
|
|
@@ -331,7 +337,7 @@ interface Files {
|
|
|
331
337
|
* A `File` keeps its own name unless `opts.name` gives one. Empty files and HTML reject with `invalid`, over 25 MB with `too-large`.
|
|
332
338
|
* Uploads have two limits, all apps together: 600 an hour and 3,000 in 30 days on Free (more on paid plans); deleting a file
|
|
333
339
|
* doesn't give the upload back. Past either, `rate` with `err.scope` `'hour'` or `'month'` — stop, keep your place, carry on later. */
|
|
334
|
-
put(blob: Blob, opts?: { name?: string }): Promise<FileInfo>;
|
|
340
|
+
put(blob: Blob, opts?: { name?: string; onProgress?(sent: number): void }): Promise<FileInfo>;
|
|
335
341
|
/** The file, or `null` if it's gone. Never throws for a missing file. A file has no link of its own — to show it, make an object
|
|
336
342
|
* URL, set it as an `<img>` src, and `URL.revokeObjectURL()` it on load or error. Don't keep the URL; make a new one to draw again.
|
|
337
343
|
* Get files as they come into view: past 600 reads a minute (all apps together), `rate` with `err.scope` `'read'`. */
|
|
@@ -683,6 +689,26 @@ interface Camera {
|
|
|
683
689
|
close(): void;
|
|
684
690
|
readonly active: boolean;
|
|
685
691
|
}
|
|
692
|
+
/** `ctx.mic.open()` — a microphone that's on. */
|
|
693
|
+
interface MicFeed {
|
|
694
|
+
/** One audio track, no video — for `MediaRecorder` or `AudioContext.createMediaStreamSource`. Nothing plays through the speakers unless you do it. */
|
|
695
|
+
stream: MediaStream;
|
|
696
|
+
track: MediaStreamTrack | null;
|
|
697
|
+
/** What the browser actually applied. */
|
|
698
|
+
echo: boolean; noise: boolean; gain: boolean;
|
|
699
|
+
/** Input delay the device reports, in seconds — 0 when it doesn't say. */
|
|
700
|
+
latency: number;
|
|
701
|
+
stop(): void;
|
|
702
|
+
}
|
|
703
|
+
interface Mic {
|
|
704
|
+
/** Turns their microphone on — Fave1 asks first (once each time your app opens), then the browser asks for that site. Sound only.
|
|
705
|
+
* `echo` · `noise` · `gain` (all default true) are the browser's echo cancelling, noise suppression and automatic level — turn them off for
|
|
706
|
+
* someone on earphones. Rejects `denied` · `blocked` · `unavailable` · `busy`. Call it from a tap, not at launch. */
|
|
707
|
+
open(options?: { echo?: boolean; noise?: boolean; gain?: boolean }): Promise<MicFeed>;
|
|
708
|
+
/** Every microphone your app opened goes off. Closing your app does this too. */
|
|
709
|
+
close(): void;
|
|
710
|
+
readonly active: boolean;
|
|
711
|
+
}
|
|
686
712
|
/** One of the person's AIs. `id` is stable (`anthropic` · `openai` · `google` · `xai` · `fave1` · `mock`); `name` is what to show ("Claude", "Fave1 AI"). */
|
|
687
713
|
interface AiChoice { id: string; name: string }
|
|
688
714
|
interface AiChoices { current: AiChoice | null; others: AiChoice[]; locked: boolean }
|
|
@@ -792,6 +818,8 @@ interface Ctx {
|
|
|
792
818
|
clipboard: { read(): Promise<string | null>; write(text: string): Promise<boolean> };
|
|
793
819
|
/** Their camera, live, while your app is open — `camera` permission. The video stays on their page. */
|
|
794
820
|
camera: Camera;
|
|
821
|
+
/** Their microphone, live, while your app is open — `mic` permission, separate from the camera. The sound stays on their page. */
|
|
822
|
+
mic: Mic;
|
|
795
823
|
/** Your app's settings, edited in the developer console (Config tab) and loaded before `onLaunch` — a plain JSON object.
|
|
796
824
|
* It ships without review, so it holds **values, not code** and nothing secret: every person who opens the app receives it.
|
|
797
825
|
* While you build, `fave1 dev` serves the `config.json` next to your manifest. Missing or unreachable → `{}`. */
|
|
@@ -85,7 +85,7 @@ the same version replaces it; once it has gone to review, bump the version —
|
|
|
85
85
|
`npm run build` type-checks with `tsc` and bundles `src/index.ts` — and everything
|
|
86
86
|
it imports, npm packages included — into one classic script (`dist/index.js`,
|
|
87
87
|
esbuild). That single file is what the shell loads and what `npm run submit`
|
|
88
|
-
uploads; keep it under
|
|
88
|
+
uploads; keep it under 1 MB. CSS and SVG files you import come in as text, pictures
|
|
89
89
|
(PNG, JPEG, GIF, WebP) as `data:` URLs (`import css from './panel.css'`), so they ship
|
|
90
90
|
inside it too. `npm run dev` rebuilds with the same esbuild command on every save
|
|
91
91
|
(`npm run bundle`), so what you try is what you ship.
|
|
@@ -84,7 +84,7 @@ interface Ui {
|
|
|
84
84
|
stack(children: Block[]): Block;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
type Permission = 'page.text' | 'page.selection' | 'page' | 'storage' | 'pub' | 'clipboard' | 'ai' | 'camera';
|
|
87
|
+
type Permission = 'page.text' | 'page.selection' | 'page' | 'storage' | 'pub' | 'clipboard' | 'ai' | 'camera' | 'mic';
|
|
88
88
|
|
|
89
89
|
/** `err.code` on anything `ctx` rejects with. */
|
|
90
90
|
type Fave1ErrorCode =
|
|
@@ -104,9 +104,9 @@ type Fave1ErrorCode =
|
|
|
104
104
|
| 'provider' // ctx.ai: the AI service failed (`err.reason` 'busy' | 'refused' | …, `err.retryable`)
|
|
105
105
|
| 'aborted' // ctx.ai: stopped — your signal, the tab went to the background, or the app closed
|
|
106
106
|
| 'no-voice' // ctx.ai.speak(): no way to pay for that voice — no key for its company and no Fave1 credits (Fave1 already told them)
|
|
107
|
-
| 'blocked' // ctx.camera: this site doesn't allow a camera
|
|
108
|
-
| 'unavailable' // ctx.camera:
|
|
109
|
-
| 'busy' // ctx.camera: another tab or app is using it
|
|
107
|
+
| 'blocked' // ctx.camera · ctx.mic: this site doesn't allow a camera / microphone
|
|
108
|
+
| 'unavailable' // ctx.camera · ctx.mic: none here, or the page isn't https
|
|
109
|
+
| 'busy' // ctx.camera · ctx.mic: another tab or app is using it
|
|
110
110
|
| 'credits' // ctx.purchases.buy(): not enough Fave1 credits (`err.balance`, `err.needed`) — Fave1 already showed Get credits
|
|
111
111
|
| 'not-yet' // ctx.purchases: in-app purchases aren't open to your app yet
|
|
112
112
|
| 'unreachable' | 'timeout' | 'server';
|
|
@@ -123,7 +123,7 @@ interface Fave1Error extends Error {
|
|
|
123
123
|
* together: back off, it clears within the minute.
|
|
124
124
|
* An older runtime may leave it out; read `quota` as `'account'`, `rate` from `put()` as `'hour'` and from `get()` as `'read'`. */
|
|
125
125
|
scope?: 'app' | 'account' | 'hour' | 'month' | 'read' | 'shared' | 'stickers' | 'all';
|
|
126
|
-
/** ctx.ai: more about why — `denied` 'undeclared' | 'off-in-settings' | 'paused' | 'not-now', `no-key` 'none' | 'credits-empty', `provider` 'busy' | '
|
|
126
|
+
/** ctx.ai: more about why — `denied` 'undeclared' | 'off-in-settings' | 'paused' | 'not-now', `no-key` 'none' | 'credits-empty' | 'fave1-only' (your app is a voice app — it runs on Fave1 AI only), `provider` 'busy' (overloaded — try again) | 'rate' (the person's key hit its per-minute limit — wait a minute) | 'billing' (their key's account has no credit) | 'quota' (their key hit its daily or free-plan limit) | 'refused' | 'model' | 'bad' | 'json' | 'length' — Fave1 tells the person about billing and quota, so don't offer a retry for those, `invalid` 'messages' | 'image' | 'json' | 'tools'. */
|
|
127
127
|
reason?: string;
|
|
128
128
|
/** ctx.ai `limit`: when it resets (ISO time — the 1st of next month, UTC). */
|
|
129
129
|
resetAt?: string;
|
|
@@ -131,6 +131,12 @@ interface Fave1Error extends Error {
|
|
|
131
131
|
retryAfter?: number;
|
|
132
132
|
/** ctx.ai: worth trying the same call again a bit later. */
|
|
133
133
|
retryable?: boolean;
|
|
134
|
+
/** ctx.ai: which AI said no — 'anthropic' | 'openai' | 'google' | 'xai' (on `key-broken` and `provider`). `err.message` already names it in plain words. */
|
|
135
|
+
by?: string;
|
|
136
|
+
/** ctx.ai: the person can fix this themselves (replace their key, switch to Fave1 AI, get credits, raise a limit) — show `err.message` and a button that calls `ctx.ai.setup()`. */
|
|
137
|
+
fixable?: boolean;
|
|
138
|
+
/** ctx.ai: Fave1 already showed the person a card about this with their options — keep your message short and don't stack another popup. */
|
|
139
|
+
shown?: boolean;
|
|
134
140
|
/** On `conflict` from `shared.set()`: the row as it is now (its `v` is the base to use next). */
|
|
135
141
|
current?: Shared;
|
|
136
142
|
/** ctx.purchases `credits`: their balance (when Fave1 may tell you — at home, or on a site your app is allowed on) and the item's price. */
|
|
@@ -331,7 +337,7 @@ interface Files {
|
|
|
331
337
|
* A `File` keeps its own name unless `opts.name` gives one. Empty files and HTML reject with `invalid`, over 25 MB with `too-large`.
|
|
332
338
|
* Uploads have two limits, all apps together: 600 an hour and 3,000 in 30 days on Free (more on paid plans); deleting a file
|
|
333
339
|
* doesn't give the upload back. Past either, `rate` with `err.scope` `'hour'` or `'month'` — stop, keep your place, carry on later. */
|
|
334
|
-
put(blob: Blob, opts?: { name?: string }): Promise<FileInfo>;
|
|
340
|
+
put(blob: Blob, opts?: { name?: string; onProgress?(sent: number): void }): Promise<FileInfo>;
|
|
335
341
|
/** The file, or `null` if it's gone. Never throws for a missing file. A file has no link of its own — to show it, make an object
|
|
336
342
|
* URL, set it as an `<img>` src, and `URL.revokeObjectURL()` it on load or error. Don't keep the URL; make a new one to draw again.
|
|
337
343
|
* Get files as they come into view: past 600 reads a minute (all apps together), `rate` with `err.scope` `'read'`. */
|
|
@@ -683,6 +689,26 @@ interface Camera {
|
|
|
683
689
|
close(): void;
|
|
684
690
|
readonly active: boolean;
|
|
685
691
|
}
|
|
692
|
+
/** `ctx.mic.open()` — a microphone that's on. */
|
|
693
|
+
interface MicFeed {
|
|
694
|
+
/** One audio track, no video — for `MediaRecorder` or `AudioContext.createMediaStreamSource`. Nothing plays through the speakers unless you do it. */
|
|
695
|
+
stream: MediaStream;
|
|
696
|
+
track: MediaStreamTrack | null;
|
|
697
|
+
/** What the browser actually applied. */
|
|
698
|
+
echo: boolean; noise: boolean; gain: boolean;
|
|
699
|
+
/** Input delay the device reports, in seconds — 0 when it doesn't say. */
|
|
700
|
+
latency: number;
|
|
701
|
+
stop(): void;
|
|
702
|
+
}
|
|
703
|
+
interface Mic {
|
|
704
|
+
/** Turns their microphone on — Fave1 asks first (once each time your app opens), then the browser asks for that site. Sound only.
|
|
705
|
+
* `echo` · `noise` · `gain` (all default true) are the browser's echo cancelling, noise suppression and automatic level — turn them off for
|
|
706
|
+
* someone on earphones. Rejects `denied` · `blocked` · `unavailable` · `busy`. Call it from a tap, not at launch. */
|
|
707
|
+
open(options?: { echo?: boolean; noise?: boolean; gain?: boolean }): Promise<MicFeed>;
|
|
708
|
+
/** Every microphone your app opened goes off. Closing your app does this too. */
|
|
709
|
+
close(): void;
|
|
710
|
+
readonly active: boolean;
|
|
711
|
+
}
|
|
686
712
|
/** One of the person's AIs. `id` is stable (`anthropic` · `openai` · `google` · `xai` · `fave1` · `mock`); `name` is what to show ("Claude", "Fave1 AI"). */
|
|
687
713
|
interface AiChoice { id: string; name: string }
|
|
688
714
|
interface AiChoices { current: AiChoice | null; others: AiChoice[]; locked: boolean }
|
|
@@ -792,6 +818,8 @@ interface Ctx {
|
|
|
792
818
|
clipboard: { read(): Promise<string | null>; write(text: string): Promise<boolean> };
|
|
793
819
|
/** Their camera, live, while your app is open — `camera` permission. The video stays on their page. */
|
|
794
820
|
camera: Camera;
|
|
821
|
+
/** Their microphone, live, while your app is open — `mic` permission, separate from the camera. The sound stays on their page. */
|
|
822
|
+
mic: Mic;
|
|
795
823
|
/** Your app's settings, edited in the developer console (Config tab) and loaded before `onLaunch` — a plain JSON object.
|
|
796
824
|
* It ships without review, so it holds **values, not code** and nothing secret: every person who opens the app receives it.
|
|
797
825
|
* While you build, `fave1 dev` serves the `config.json` next to your manifest. Missing or unreachable → `{}`. */
|
|
@@ -90,7 +90,7 @@ the same version replaces it; once it has gone to review, bump the version —
|
|
|
90
90
|
`npm run build` type-checks with `tsc` and bundles `src/index.ts` — and everything
|
|
91
91
|
it imports, npm packages included — into one classic script (`dist/index.js`,
|
|
92
92
|
esbuild). That single file is what the shell loads and what `npm run submit`
|
|
93
|
-
uploads; keep it under
|
|
93
|
+
uploads; keep it under 1 MB. CSS and SVG files you import come in as text, pictures
|
|
94
94
|
(PNG, JPEG, GIF, WebP) as `data:` URLs (`import css from './panel.css'`), so they ship
|
|
95
95
|
inside it too. `npm run dev` rebuilds with the same esbuild command on every save
|
|
96
96
|
(`npm run bundle`), so what you try is what you ship.
|
|
@@ -84,7 +84,7 @@ interface Ui {
|
|
|
84
84
|
stack(children: Block[]): Block;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
type Permission = 'page.text' | 'page.selection' | 'page' | 'storage' | 'pub' | 'clipboard' | 'ai' | 'camera';
|
|
87
|
+
type Permission = 'page.text' | 'page.selection' | 'page' | 'storage' | 'pub' | 'clipboard' | 'ai' | 'camera' | 'mic';
|
|
88
88
|
|
|
89
89
|
/** `err.code` on anything `ctx` rejects with. */
|
|
90
90
|
type Fave1ErrorCode =
|
|
@@ -104,9 +104,9 @@ type Fave1ErrorCode =
|
|
|
104
104
|
| 'provider' // ctx.ai: the AI service failed (`err.reason` 'busy' | 'refused' | …, `err.retryable`)
|
|
105
105
|
| 'aborted' // ctx.ai: stopped — your signal, the tab went to the background, or the app closed
|
|
106
106
|
| 'no-voice' // ctx.ai.speak(): no way to pay for that voice — no key for its company and no Fave1 credits (Fave1 already told them)
|
|
107
|
-
| 'blocked' // ctx.camera: this site doesn't allow a camera
|
|
108
|
-
| 'unavailable' // ctx.camera:
|
|
109
|
-
| 'busy' // ctx.camera: another tab or app is using it
|
|
107
|
+
| 'blocked' // ctx.camera · ctx.mic: this site doesn't allow a camera / microphone
|
|
108
|
+
| 'unavailable' // ctx.camera · ctx.mic: none here, or the page isn't https
|
|
109
|
+
| 'busy' // ctx.camera · ctx.mic: another tab or app is using it
|
|
110
110
|
| 'credits' // ctx.purchases.buy(): not enough Fave1 credits (`err.balance`, `err.needed`) — Fave1 already showed Get credits
|
|
111
111
|
| 'not-yet' // ctx.purchases: in-app purchases aren't open to your app yet
|
|
112
112
|
| 'unreachable' | 'timeout' | 'server';
|
|
@@ -123,7 +123,7 @@ interface Fave1Error extends Error {
|
|
|
123
123
|
* together: back off, it clears within the minute.
|
|
124
124
|
* An older runtime may leave it out; read `quota` as `'account'`, `rate` from `put()` as `'hour'` and from `get()` as `'read'`. */
|
|
125
125
|
scope?: 'app' | 'account' | 'hour' | 'month' | 'read' | 'shared' | 'stickers' | 'all';
|
|
126
|
-
/** ctx.ai: more about why — `denied` 'undeclared' | 'off-in-settings' | 'paused' | 'not-now', `no-key` 'none' | 'credits-empty', `provider` 'busy' | '
|
|
126
|
+
/** ctx.ai: more about why — `denied` 'undeclared' | 'off-in-settings' | 'paused' | 'not-now', `no-key` 'none' | 'credits-empty' | 'fave1-only' (your app is a voice app — it runs on Fave1 AI only), `provider` 'busy' (overloaded — try again) | 'rate' (the person's key hit its per-minute limit — wait a minute) | 'billing' (their key's account has no credit) | 'quota' (their key hit its daily or free-plan limit) | 'refused' | 'model' | 'bad' | 'json' | 'length' — Fave1 tells the person about billing and quota, so don't offer a retry for those, `invalid` 'messages' | 'image' | 'json' | 'tools'. */
|
|
127
127
|
reason?: string;
|
|
128
128
|
/** ctx.ai `limit`: when it resets (ISO time — the 1st of next month, UTC). */
|
|
129
129
|
resetAt?: string;
|
|
@@ -131,6 +131,12 @@ interface Fave1Error extends Error {
|
|
|
131
131
|
retryAfter?: number;
|
|
132
132
|
/** ctx.ai: worth trying the same call again a bit later. */
|
|
133
133
|
retryable?: boolean;
|
|
134
|
+
/** ctx.ai: which AI said no — 'anthropic' | 'openai' | 'google' | 'xai' (on `key-broken` and `provider`). `err.message` already names it in plain words. */
|
|
135
|
+
by?: string;
|
|
136
|
+
/** ctx.ai: the person can fix this themselves (replace their key, switch to Fave1 AI, get credits, raise a limit) — show `err.message` and a button that calls `ctx.ai.setup()`. */
|
|
137
|
+
fixable?: boolean;
|
|
138
|
+
/** ctx.ai: Fave1 already showed the person a card about this with their options — keep your message short and don't stack another popup. */
|
|
139
|
+
shown?: boolean;
|
|
134
140
|
/** On `conflict` from `shared.set()`: the row as it is now (its `v` is the base to use next). */
|
|
135
141
|
current?: Shared;
|
|
136
142
|
/** ctx.purchases `credits`: their balance (when Fave1 may tell you — at home, or on a site your app is allowed on) and the item's price. */
|
|
@@ -331,7 +337,7 @@ interface Files {
|
|
|
331
337
|
* A `File` keeps its own name unless `opts.name` gives one. Empty files and HTML reject with `invalid`, over 25 MB with `too-large`.
|
|
332
338
|
* Uploads have two limits, all apps together: 600 an hour and 3,000 in 30 days on Free (more on paid plans); deleting a file
|
|
333
339
|
* doesn't give the upload back. Past either, `rate` with `err.scope` `'hour'` or `'month'` — stop, keep your place, carry on later. */
|
|
334
|
-
put(blob: Blob, opts?: { name?: string }): Promise<FileInfo>;
|
|
340
|
+
put(blob: Blob, opts?: { name?: string; onProgress?(sent: number): void }): Promise<FileInfo>;
|
|
335
341
|
/** The file, or `null` if it's gone. Never throws for a missing file. A file has no link of its own — to show it, make an object
|
|
336
342
|
* URL, set it as an `<img>` src, and `URL.revokeObjectURL()` it on load or error. Don't keep the URL; make a new one to draw again.
|
|
337
343
|
* Get files as they come into view: past 600 reads a minute (all apps together), `rate` with `err.scope` `'read'`. */
|
|
@@ -683,6 +689,26 @@ interface Camera {
|
|
|
683
689
|
close(): void;
|
|
684
690
|
readonly active: boolean;
|
|
685
691
|
}
|
|
692
|
+
/** `ctx.mic.open()` — a microphone that's on. */
|
|
693
|
+
interface MicFeed {
|
|
694
|
+
/** One audio track, no video — for `MediaRecorder` or `AudioContext.createMediaStreamSource`. Nothing plays through the speakers unless you do it. */
|
|
695
|
+
stream: MediaStream;
|
|
696
|
+
track: MediaStreamTrack | null;
|
|
697
|
+
/** What the browser actually applied. */
|
|
698
|
+
echo: boolean; noise: boolean; gain: boolean;
|
|
699
|
+
/** Input delay the device reports, in seconds — 0 when it doesn't say. */
|
|
700
|
+
latency: number;
|
|
701
|
+
stop(): void;
|
|
702
|
+
}
|
|
703
|
+
interface Mic {
|
|
704
|
+
/** Turns their microphone on — Fave1 asks first (once each time your app opens), then the browser asks for that site. Sound only.
|
|
705
|
+
* `echo` · `noise` · `gain` (all default true) are the browser's echo cancelling, noise suppression and automatic level — turn them off for
|
|
706
|
+
* someone on earphones. Rejects `denied` · `blocked` · `unavailable` · `busy`. Call it from a tap, not at launch. */
|
|
707
|
+
open(options?: { echo?: boolean; noise?: boolean; gain?: boolean }): Promise<MicFeed>;
|
|
708
|
+
/** Every microphone your app opened goes off. Closing your app does this too. */
|
|
709
|
+
close(): void;
|
|
710
|
+
readonly active: boolean;
|
|
711
|
+
}
|
|
686
712
|
/** One of the person's AIs. `id` is stable (`anthropic` · `openai` · `google` · `xai` · `fave1` · `mock`); `name` is what to show ("Claude", "Fave1 AI"). */
|
|
687
713
|
interface AiChoice { id: string; name: string }
|
|
688
714
|
interface AiChoices { current: AiChoice | null; others: AiChoice[]; locked: boolean }
|
|
@@ -792,6 +818,8 @@ interface Ctx {
|
|
|
792
818
|
clipboard: { read(): Promise<string | null>; write(text: string): Promise<boolean> };
|
|
793
819
|
/** Their camera, live, while your app is open — `camera` permission. The video stays on their page. */
|
|
794
820
|
camera: Camera;
|
|
821
|
+
/** Their microphone, live, while your app is open — `mic` permission, separate from the camera. The sound stays on their page. */
|
|
822
|
+
mic: Mic;
|
|
795
823
|
/** Your app's settings, edited in the developer console (Config tab) and loaded before `onLaunch` — a plain JSON object.
|
|
796
824
|
* It ships without review, so it holds **values, not code** and nothing secret: every person who opens the app receives it.
|
|
797
825
|
* While you build, `fave1 dev` serves the `config.json` next to your manifest. Missing or unreachable → `{}`. */
|