@fave1/create-app 0.1.3 → 0.1.5
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 +2 -2
- package/templates/break/README.md +4 -3
- package/templates/break/types/fave1.d.ts +161 -65
- package/templates/minimal/README.md +4 -3
- package/templates/minimal/types/fave1.d.ts +161 -65
- package/templates/panel/README.md +4 -3
- package/templates/panel/types/fave1.d.ts +161 -65
- package/templates/storage/README.md +4 -3
- package/templates/storage/types/fave1.d.ts +161 -65
|
@@ -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 =
|
|
@@ -92,23 +92,28 @@ type Fave1ErrorCode =
|
|
|
92
92
|
| 'signed-out' // needs a Fave1 account and there isn't one here
|
|
93
93
|
| 'not-installed' // this person hasn't added the app (a sideloaded run)
|
|
94
94
|
| 'too-large' | 'quota' | 'invalid'
|
|
95
|
-
| 'rate' // too fast — pub writes in a row, file uploads (`err.scope` 'hour' | 'month')
|
|
95
|
+
| 'rate' // too fast — pub writes in a row, file uploads (`err.scope` 'hour' | 'month'), file reads ('read'), shared.get() (per network),
|
|
96
|
+
// ctx.ai (20 a minute and 2 at once per app — `err.reason` 'busy', 60 a minute across all apps — 'minute'), or a second purchases.buy() while one is open: wait, then carry on
|
|
96
97
|
| 'cancelled' // they said "Not now"
|
|
97
98
|
| 'conflict' // shared.set() with a stale base — err.current is the row now; merge and set() again
|
|
98
|
-
| 'not-found' // shared.access() · delete() on a link that isn't yours or is gone · room.direct() to a sid that isn't in the room
|
|
99
|
+
| 'not-found' // shared.access() · delete() on a link that isn't yours or is gone · room.direct() to a sid that isn't in the room ·
|
|
100
|
+
// purchases.buy() an item you don't sell · finish() a receipt that isn't there
|
|
99
101
|
| 'declined' // room.direct(): their app doesn't take direct lines (no room.on('direct') and no direct() back within 3 s)
|
|
100
|
-
| 'no-key' // ctx.ai: no AI key and no Fave1 credits (`err.reason` 'none' | 'credits-empty') — Fave1 already told them where to add one
|
|
102
|
+
| 'no-key' // ctx.ai: no AI key and no Fave1 credits (`err.reason` 'none' | 'credits-empty' | 'fave1-only' | 'choice') — Fave1 already told them where to add one
|
|
101
103
|
| 'key-broken' // ctx.ai: their provider turned the key down — Fave1 already told them
|
|
102
104
|
| 'limit' // ctx.ai: this month's limit (`err.scope` 'app' | 'all', `err.resetAt`) — don't retry before then
|
|
103
|
-
| 'too-big' // ctx.ai: too much
|
|
105
|
+
| 'too-big' // ctx.ai: too much for one call (`err.reason` 'messages' | 'images' | 'text' | 'style', or none when the whole call is over —
|
|
106
|
+
// a system prompt over 20,000 characters, a schema over 16,000, about 120,000 tokens in all)
|
|
104
107
|
| 'provider' // ctx.ai: the AI service failed (`err.reason` 'busy' | 'refused' | …, `err.retryable`)
|
|
105
|
-
| 'aborted' // ctx.ai: stopped — your signal, the tab went to the background, or the app closed
|
|
106
|
-
| 'no-voice' // ctx.ai.speak():
|
|
107
|
-
|
|
108
|
-
| '
|
|
109
|
-
| '
|
|
108
|
+
| 'aborted' // ctx.ai: stopped — your signal, the tab went to the background (`err.reason` 'hidden'), or the app closed
|
|
109
|
+
| 'no-voice' // ctx.ai.speak(): voices run on Fave1 credits only (`err.reason` 'credits' — none left, Fave1 already told them · 'undeclared' — your
|
|
110
|
+
// manifest has no `"voice": true` · 'maker' — Fave1 can't speak that company's voices right now · 'choice' — `ai` isn't openai · google · xai)
|
|
111
|
+
| 'blocked' // ctx.camera · ctx.mic: this site doesn't allow a camera / microphone (`err.reason` 'site') · ctx.notify: Fave1 stopped this app
|
|
112
|
+
| 'unavailable' // ctx.camera · ctx.mic: none here ('none'), the page isn't https ('insecure'), or no camera gives that size ('size')
|
|
113
|
+
| 'busy' // ctx.camera · ctx.mic: another tab or app is using it
|
|
110
114
|
| 'credits' // ctx.purchases.buy(): not enough Fave1 credits (`err.balance`, `err.needed`) — Fave1 already showed Get credits
|
|
111
115
|
| 'not-yet' // ctx.purchases: in-app purchases aren't open to your app yet
|
|
116
|
+
| 'needs-tap' // ctx.notify.send(): they haven't said yes to your notifications yet and Fave1 couldn't ask here (the card is hidden) — show your card and call again
|
|
112
117
|
| 'unreachable' | 'timeout' | 'server';
|
|
113
118
|
|
|
114
119
|
/** What `ctx` rejects with — an `Error` carrying a `code`. `catch (err) { const e = err as Fave1Error; … }` */
|
|
@@ -122,8 +127,8 @@ interface Fave1Error extends Error {
|
|
|
122
127
|
* (more on paid plans): it won't clear today, so tell them. From `files.get()`: `'read'` — 600 reads in a minute, all apps
|
|
123
128
|
* together: back off, it clears within the minute.
|
|
124
129
|
* An older runtime may leave it out; read `quota` as `'account'`, `rate` from `put()` as `'hour'` and from `get()` as `'read'`. */
|
|
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' | '
|
|
130
|
+
scope?: 'app' | 'account' | 'hour' | 'month' | 'read' | 'shared' | 'stickers' | 'all' | 'day' | 'pending';
|
|
131
|
+
/** ctx.ai: more about why — `denied` 'undeclared' | 'off-in-settings' | 'paused' | 'not-now' | 'off' (Fave1 paused AI for your app), `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' (from `speak()` only 'busy' · 'billing' · 'model' · 'bad' · 'refused', with no `err.by`) — Fave1 tells the person about billing and quota, so don't offer a retry for those, `invalid` 'messages' | 'system' | 'model' | 'maxTokens' | 'image' | 'json' | 'tools' | 'cache' | 'ai' | 'maxSteps' | 'text' | 'voice' | 'style' | 'speed'. */
|
|
127
132
|
reason?: string;
|
|
128
133
|
/** ctx.ai `limit`: when it resets (ISO time — the 1st of next month, UTC). */
|
|
129
134
|
resetAt?: string;
|
|
@@ -131,9 +136,20 @@ interface Fave1Error extends Error {
|
|
|
131
136
|
retryAfter?: number;
|
|
132
137
|
/** ctx.ai: worth trying the same call again a bit later. */
|
|
133
138
|
retryable?: boolean;
|
|
134
|
-
/**
|
|
139
|
+
/** ctx.ai: what exactly was wrong — on `invalid`, and on `provider` with `reason` 'json' (which part of the answer didn't fit your schema). */
|
|
140
|
+
detail?: string;
|
|
141
|
+
/** ctx.ai `provider` · 'json': the answer as the model wrote it, before it failed your schema. */
|
|
142
|
+
text?: string;
|
|
143
|
+
/** ctx.ai: which AI said no — 'anthropic' | 'openai' | 'google' | 'xai' (on `key-broken` and `provider`). `err.message` already names it in plain words. */
|
|
144
|
+
by?: string;
|
|
145
|
+
/** 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()`. */
|
|
146
|
+
fixable?: boolean;
|
|
147
|
+
/** ctx.ai: Fave1 already showed the person a card about this with their options — keep your message short and don't stack another popup. */
|
|
148
|
+
shown?: boolean;
|
|
149
|
+
/** On `conflict` from `shared.set()`: the row as it is now — its `value` and `v` (the base to use next). */
|
|
135
150
|
current?: Shared;
|
|
136
|
-
/** 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.
|
|
151
|
+
/** 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.
|
|
152
|
+
* Fave1 shows Get credits the first time this happens while your app is open — after that it's yours to say. */
|
|
137
153
|
balance?: number;
|
|
138
154
|
needed?: number;
|
|
139
155
|
/** ctx.purchases `cancelled`: `true` when they chose Not now (rather than the panel closing). */
|
|
@@ -151,7 +167,7 @@ interface PubRow<T = any> {
|
|
|
151
167
|
value: T;
|
|
152
168
|
/** ISO time of their last write. */
|
|
153
169
|
updatedAt: string;
|
|
154
|
-
/** This row belongs to the person using the app. */
|
|
170
|
+
/** This row belongs to the person using the app. Always `false` on a site that hasn't said yes to your app yet. */
|
|
155
171
|
me: boolean;
|
|
156
172
|
}
|
|
157
173
|
|
|
@@ -160,7 +176,8 @@ interface PubQuery {
|
|
|
160
176
|
* for an array that holds a matching item. Up to 2 KB. */
|
|
161
177
|
where?: unknown;
|
|
162
178
|
/** The field to sort by: `'best'`, `'-best'` (largest first), `'stats.best'`, or a key path like
|
|
163
|
-
* `['runs', 'amazon.com', 'ms']` when a key has a dot in it
|
|
179
|
+
* `['runs', 'amazon.com', 'ms']` when a key has a dot in it — up to 6 levels, each 1–64 characters (`invalid` past that).
|
|
180
|
+
* Ties go to whoever wrote first. */
|
|
164
181
|
order?: string | string[];
|
|
165
182
|
/** Largest first. `'-best'` already means this. */
|
|
166
183
|
desc?: boolean;
|
|
@@ -173,7 +190,7 @@ type PubReportReason = 'inappropriate' | 'scam' | 'exposes_personal_data' | 'oth
|
|
|
173
190
|
|
|
174
191
|
/** `pub` — one JSON value per person, up to 4 KB, that everyone using this app can read. Only its owner writes it.
|
|
175
192
|
* Writing needs a Fave1 account: when nobody's signed in, `ctx.can('pub')` is false and only `list()` works — other people's
|
|
176
|
-
* rows,
|
|
193
|
+
* rows, with an initial and a color and never a name. Show the board anyway and ask people to sign in to get on it.
|
|
177
194
|
* The first write from a new site asks the person once ("Post to …?"), so `set()` can take a moment — and can
|
|
178
195
|
* reject with `cancelled`. On the app's own page (`<id>.fave1.app`) it never asks. DEV builds use a sandbox in this browser
|
|
179
196
|
* unless Data is set to "My account" in the DEV panel.
|
|
@@ -185,7 +202,7 @@ interface Pub<T = any> {
|
|
|
185
202
|
set(value: T): Promise<void>;
|
|
186
203
|
delete(): Promise<void>;
|
|
187
204
|
list(query?: PubQuery): Promise<PubRow<T>[]>;
|
|
188
|
-
/** Your place in the same query — `null` when your value doesn't match or has no `order` field. */
|
|
205
|
+
/** Your place in the same query — `null` when your value doesn't match or has no `order` field, and on a site that hasn't said yes to your app yet. */
|
|
189
206
|
rank(query: PubQuery & { order: string | string[] }): Promise<{ rank: number; total: number } | null>;
|
|
190
207
|
/** Report someone else's row — `id` from `list()`. Fave1 looks at it; whoever posted it is never told who reported.
|
|
191
208
|
* On a third-party site the first report asks once (Report). If your app shows other people's text, give people a way to do this. */
|
|
@@ -244,9 +261,8 @@ interface DirectLine {
|
|
|
244
261
|
* (an `error` event says which). Never waits, never throws. `true` means Fave1 has it; on a lossy line it can still be dropped on the way. */
|
|
245
262
|
send(data: unknown): boolean;
|
|
246
263
|
on(type: 'message', handler: (data: unknown) => void): () => void;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
* and they come back with a new sid — open a new line then); `gone` — the app closed. A dropped direct connection is not a close: the line
|
|
264
|
+
/** `closed` — either side called `close()`, or you left the room; `left` — they left the room; `lost` — your own room connection dropped (Fave1 reconnects the room
|
|
265
|
+
* and they come back with a new sid — open a new line then); `gone` — your app closed. A dropped direct connection is not a close: the line
|
|
250
266
|
* moves to the room (`via`). */
|
|
251
267
|
on(type: 'close', handler: (ev: { reason: 'closed' | 'left' | 'lost' | 'gone' }) => void): () => void;
|
|
252
268
|
on(type: 'error', handler: (ev: { code: 'too-large' | 'rate' | 'invalid' }) => void): () => void;
|
|
@@ -269,7 +285,9 @@ interface LiveRoom {
|
|
|
269
285
|
/** A copy of the whole table. */
|
|
270
286
|
all(): Record<string, unknown>;
|
|
271
287
|
/** Set one key for everyone. Applied here at once (a `change` with `me: true`), then sent. Values are JSON up to 8 KB; the room
|
|
272
|
-
* holds up to 2,000 keys / 256 KB.
|
|
288
|
+
* holds up to 2,000 keys / 256 KB. A key is 1–160 characters with no control characters (`invalid`). When two people set the same key
|
|
289
|
+
* at the same moment, the one the server gets last wins. If the room refuses the write (an `error` event with that `key`), Fave1 puts
|
|
290
|
+
* the room's value back here with a `change` (`me: false`, `by: null`). */
|
|
273
291
|
set(key: string, value: unknown): Promise<void>;
|
|
274
292
|
del(key: string): Promise<void>;
|
|
275
293
|
/** Share where you are or what you're doing — a cursor, a selection, "typing". Not saved; sent to the others at most every 40 ms,
|
|
@@ -290,11 +308,12 @@ interface LiveRoom {
|
|
|
290
308
|
/** Fires after a reconnect (`join()` itself resolves once the room is open) — the table may have moved on; `change` events for the
|
|
291
309
|
* differences come first. */
|
|
292
310
|
on(type: 'open', handler: (ev: { reconnected: true }) => void): () => void;
|
|
293
|
-
/** `lost` — dropped, Fave1 is reconnecting
|
|
294
|
-
*
|
|
311
|
+
/** `lost` — dropped, Fave1 is reconnecting (also when the same person opens a fifth tab in this room — each person keeps up to 4);
|
|
312
|
+
* `left` — you called `leave()`; `server` — the room closed it (nobody used it for 45 days); `gone` — your app closed. */
|
|
295
313
|
on(type: 'close', handler: (ev: { code: number; reason: 'lost' | 'left' | 'server' | 'gone' }) => void): () => void;
|
|
296
|
-
/** The room refused something — `too-large`, `quota` (room full of keys/bytes), `rate` (over 40 writes a second), `invalid`. */
|
|
314
|
+
/** The room refused something — `too-large`, `quota` (room full of keys/bytes), `rate` (over 40 writes a second from this tab), `invalid`. */
|
|
297
315
|
on(type: 'error', handler: (ev: { code: string; key?: string }) => void): () => void;
|
|
316
|
+
/** Leaves the room — `close` fires with `left`, and your direct lines close with `closed`. */
|
|
298
317
|
leave(): Promise<void>;
|
|
299
318
|
}
|
|
300
319
|
|
|
@@ -303,8 +322,9 @@ interface LiveRoom {
|
|
|
303
322
|
* the same yes that covers posting. Anyone who joins a room with the same name sees the same table, so put something only your
|
|
304
323
|
* people know into the name (an invite code, a link). DEV builds get a sandbox room in this browser — tabs on the same site share it. */
|
|
305
324
|
interface Live {
|
|
306
|
-
/** `what` names what people are joining in the permission line — `Join the {what} on <your app>?` —
|
|
307
|
-
* (a Collab calls it a project). Older launchers ignore it.
|
|
325
|
+
/** `what` names what people are joining in the permission line — `Join the {what} on <your app>?` — up to 20 letters, spaces and hyphens,
|
|
326
|
+
* default `room` (anything else falls back to it; a Collab calls it a project). Older launchers ignore it.
|
|
327
|
+
* `room` is 1–200 characters (else `invalid`). If it rejects (`timeout`, `server`, `unreachable` …) there is no room to wait on — call `join()` again. */
|
|
308
328
|
join(room: string, opts?: { what?: string }): Promise<LiveRoom>;
|
|
309
329
|
}
|
|
310
330
|
|
|
@@ -331,7 +351,7 @@ interface Files {
|
|
|
331
351
|
* 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
352
|
* 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
353
|
* 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>;
|
|
354
|
+
put(blob: Blob, opts?: { name?: string; /** 0 to 1 — how much of the upload has gone. */ onProgress?(fraction: number): void }): Promise<FileInfo>;
|
|
335
355
|
/** 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
356
|
* 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
357
|
* Get files as they come into view: past 600 reads a minute (all apps together), `rate` with `err.scope` `'read'`. */
|
|
@@ -370,11 +390,12 @@ interface PageAccess {
|
|
|
370
390
|
/** A full-screen layer over the page for what you draw yourself — a game canvas, a score bar, confetti. Fave1 keeps it
|
|
371
391
|
* above everything on the page and below its own card, and removes it when your app closes. It lets clicks through:
|
|
372
392
|
* give `pointer-events: auto` to what should catch them. Same element on every call. `{ over: 'card' }` lifts it above
|
|
373
|
-
* the card for a moment (a celebration) — up there it takes no clicks; call `layer()` again to put it back.
|
|
393
|
+
* the card for a moment (a celebration) — up there it takes no clicks; call `layer()` again to put it back.
|
|
394
|
+
* After your app closed it returns `null` — don't call it from a late timer. */
|
|
374
395
|
layer(options?: { over?: 'page' | 'card' }): HTMLElement;
|
|
375
396
|
/** True when a node or event target is Fave1’s own chrome — the card, its frames, the top-layer box, or the app-layer
|
|
376
|
-
* element itself. What you put inside `layer()` is still yours (`layer.contains`). A node with slot `f1-under`
|
|
377
|
-
* page. Skip chrome when you walk the page, and let its clicks through when you catch input on the page. */
|
|
397
|
+
* element itself. What you put inside `layer()` is still yours (`layer.contains`). A node with slot `f1-under` (something you
|
|
398
|
+
* slipped under the card yourself) counts as the page. Skip chrome when you walk the page, and let its clicks through when you catch input on the page. */
|
|
378
399
|
isFave1(node: EventTarget | null): boolean;
|
|
379
400
|
/** Pull fixed layers the page stacked above the card back under it. Fave1 puts them back when the app closes. */
|
|
380
401
|
sinkFloaters(): void;
|
|
@@ -410,6 +431,20 @@ interface Shared<T = unknown> {
|
|
|
410
431
|
editor: { initial: string; color: string } | null;
|
|
411
432
|
}
|
|
412
433
|
|
|
434
|
+
/** One of this person's shared links, as `shared.list()` returns it — no value: read it with `get(ref)`. */
|
|
435
|
+
interface SharedLink {
|
|
436
|
+
id: string; key: string; ref: string;
|
|
437
|
+
v: number;
|
|
438
|
+
edit: boolean;
|
|
439
|
+
/** Size of the value as JSON, in bytes — it counts toward their Fave1 storage. */
|
|
440
|
+
bytes: number;
|
|
441
|
+
updatedAt: string;
|
|
442
|
+
/** Someone other than the owner has written to it. */
|
|
443
|
+
edited: boolean;
|
|
444
|
+
/** Always `true` — `list()` only gives this person's own links. */
|
|
445
|
+
mine: boolean;
|
|
446
|
+
owner: { initial: string; color: string } | null;
|
|
447
|
+
}
|
|
413
448
|
/** `shared` — one value shared by one link: a note, a list, a board. Declared with `storage` (no new permission).
|
|
414
449
|
* The owner creates it; anyone with the link reads it — signed out, or without your app added; and if the owner turned
|
|
415
450
|
* `edit` on, any signed-in person with the link can write. The owner can change that or take the link back at any time.
|
|
@@ -421,16 +456,18 @@ interface SharedApi {
|
|
|
421
456
|
/** Share a value. `edit` lets people with the link write (default read-only). Rejects with `quota` — `err.scope` `'shared'`
|
|
422
457
|
* at 100 shared values, `'account'` when their Fave1 storage is full. */
|
|
423
458
|
create<T = unknown>(value: T, opts?: { edit?: boolean }): Promise<Shared<T>>;
|
|
424
|
-
/** Read by link. `null` when it's gone or the link is wrong — never throws for that. Works signed out.
|
|
459
|
+
/** Read by link. `null` when it's gone or the link is wrong — never throws for that. Works signed out.
|
|
460
|
+
* Reads are limited per network (`rate`) — read again when your page comes back into view, not in a tight loop. */
|
|
425
461
|
get<T = unknown>(ref: string): Promise<Shared<T> | null>;
|
|
426
462
|
/** Write by link — as the owner, or as a signed-in person when `edit` is on (`denied` otherwise, `signed-out` with no account).
|
|
427
463
|
* Pass `base` (the `v` you read) and, if someone wrote in between, it rejects with `conflict` carrying `err.current`
|
|
428
|
-
* (the row now
|
|
464
|
+
* (the row now — `value` and `v` are the server's; `owner` · `editor` are `null` and `updatedAt` is only roughly right there):
|
|
465
|
+
* merge, then call `set()` again with its `v`. Without `base` it overwrites. */
|
|
429
466
|
set<T = unknown>(ref: string, value: T, opts?: { base?: number }): Promise<{ v: number }>;
|
|
430
467
|
/** Owner only: let people with the link write, or stop that. Takes the `id` or the `ref`. */
|
|
431
468
|
access(idOrRef: string, opts: { edit: boolean }): Promise<void>;
|
|
432
|
-
/** Everything this person shares from your app — with the keys, so you can show the links again. */
|
|
433
|
-
list(): Promise<
|
|
469
|
+
/** Everything this person shares from your app — with the keys, so you can show the links again. No values: `get(ref)` one to read it. */
|
|
470
|
+
list(): Promise<SharedLink[]>;
|
|
434
471
|
/** Owner only: take the link back. Whoever has it gets `null` from then on. Resolves even if it was already gone. */
|
|
435
472
|
delete(idOrRef: string): Promise<void>;
|
|
436
473
|
}
|
|
@@ -443,7 +480,7 @@ interface StickerInfo {
|
|
|
443
480
|
name: string;
|
|
444
481
|
/** The picture's file id — it's one of your `files` too (`files.list()` shows it as `Sticker · <name>`). Deleting that file takes the sticker back. */
|
|
445
482
|
file: string;
|
|
446
|
-
/** ISO times it was first given and last changed. */
|
|
483
|
+
/** ISO times it was first given and last changed (`give()` on an id you already gave answers with now for both — `list()` keeps the first). */
|
|
447
484
|
createdAt: string;
|
|
448
485
|
updatedAt: string;
|
|
449
486
|
}
|
|
@@ -456,7 +493,8 @@ interface StickersApi {
|
|
|
456
493
|
/** Give a sticker. `image` is a Blob, a canvas or an ImageBitmap — Fave1 fits it in 512 × 512 and keeps it transparent (a PNG with
|
|
457
494
|
* see-through edges looks best). Giving the same `id` again swaps the picture and name and keeps it where they stuck it.
|
|
458
495
|
* `id` is up to 32 lowercase letters, digits and dashes; `name` 1 to 40 characters (`invalid` otherwise). Up to 24 stickers per person
|
|
459
|
-
* from your app — past that, `quota` with `err.scope` `'stickers'`.
|
|
496
|
+
* from your app — past that, `quota` with `err.scope` `'stickers'`. The fitted picture is up to 1 MB (`too-large`). A canvas with another
|
|
497
|
+
* site's picture drawn on it can't be read (`invalid`). */
|
|
460
498
|
give(sticker: { id: string; name: string; image: Blob | HTMLCanvasElement | ImageBitmap }): Promise<StickerInfo>;
|
|
461
499
|
/** What your app gave this person, newest first. */
|
|
462
500
|
list(): Promise<StickerInfo[]>;
|
|
@@ -473,7 +511,8 @@ interface StickersApi {
|
|
|
473
511
|
* Beyond text: pictures (`{ type: 'image', image }`), answers in a shape you choose (`json` → `data`) and tools the model can
|
|
474
512
|
* call (`tools` → `calls`, or let `ctx.ai.run()` call them for you until it's done). */
|
|
475
513
|
/** A slice of JSON Schema — `type` (one, or one plus `'null'`), `properties`, `required`, `items`, `enum`, `description`, and the
|
|
476
|
-
* checks `minimum` · `maximum` · `minLength` · `maxLength` · `minItems` · `maxItems`. Up to 6 levels
|
|
514
|
+
* checks `minimum` · `maximum` · `minLength` · `maxLength` · `minItems` · `maxItems`. Up to 6 levels of nesting below the top, 16,000 characters
|
|
515
|
+
* as JSON. Objects never get extra keys. */
|
|
477
516
|
interface AiSchema {
|
|
478
517
|
type: 'object' | 'array' | 'string' | 'number' | 'integer' | 'boolean' | ['object' | 'array' | 'string' | 'number' | 'integer' | 'boolean', 'null'];
|
|
479
518
|
description?: string;
|
|
@@ -496,24 +535,26 @@ type AiPart =
|
|
|
496
535
|
/** In an `assistant` turn — what the model needs back next time (its reasoning, sealed). Opaque — keep it exactly as `result.message` gave it. */
|
|
497
536
|
| { type: 'state'; state: string };
|
|
498
537
|
/** A plain string is shorthand for one text part. */
|
|
538
|
+
/** Up to 64 parts in one turn. */
|
|
499
539
|
interface AiMessage { role: 'user' | 'assistant'; content: string | (AiPart | string)[] }
|
|
500
540
|
interface AiTool {
|
|
501
541
|
/** Letters, digits, `_` and `-`, up to 64 — unique in the call. */
|
|
502
542
|
name: string;
|
|
503
|
-
/** When to call it — the model reads this to decide. */
|
|
543
|
+
/** When to call it — the model reads this to decide. Up to 2,000 characters. */
|
|
504
544
|
description: string;
|
|
505
545
|
/** What it takes — an object schema. */
|
|
506
546
|
input: AiSchema;
|
|
507
547
|
}
|
|
508
548
|
interface AiOptions {
|
|
509
|
-
/** One string is one user turn. Otherwise turns alternate, first and last are `'user'`. Up to 100 turns, 120,000 characters
|
|
549
|
+
/** One string is one user turn. Otherwise turns alternate, first and last are `'user'`. Up to 100 turns, and 120,000 characters for
|
|
550
|
+
* everything the call sends — messages, `system`, your `json` schema and your tool definitions together. */
|
|
510
551
|
messages: string | AiMessage[];
|
|
511
552
|
/** Instructions for the model — up to 20,000 characters. */
|
|
512
553
|
system?: string;
|
|
513
554
|
/** `'fast'` (default) — quick and cheap, right for most features. `'smart'` — slower, for harder thinking. Fave1 picks the
|
|
514
555
|
* model on whichever provider the person uses; you don't name one. */
|
|
515
556
|
model?: 'fast' | 'smart';
|
|
516
|
-
/** Cap on the answer's length in tokens — 1 to 4,096 (default 1,024). Lower is cheaper for them. */
|
|
557
|
+
/** Cap on the answer's length in tokens — 1 to 4,096 (default 1,024; more is lowered to 4,096). Lower is cheaper for them. */
|
|
517
558
|
maxTokens?: number;
|
|
518
559
|
/** Answer in this shape — `result.data` is the parsed value, already checked against the schema. */
|
|
519
560
|
json?: AiSchema;
|
|
@@ -543,7 +584,7 @@ interface AiResult {
|
|
|
543
584
|
message: AiMessage;
|
|
544
585
|
/** Tokens — `cached` is the part of `input` read from the provider's cache (cheaper). */
|
|
545
586
|
usage: { input: number; output: number; cached: number };
|
|
546
|
-
/** `'anthropic' | 'openai' | 'google' | 'xai'`, or `'mock'` in a DEV build
|
|
587
|
+
/** `'anthropic' | 'openai' | 'google' | 'xai'`, or `'mock'` · `'mock2'` (the two sandbox AIs) in a DEV build. */
|
|
547
588
|
provider: string;
|
|
548
589
|
model: string;
|
|
549
590
|
/** True for the stand-in answer a DEV build gets when you have no key or credits — the whole flow runs, nothing is charged.
|
|
@@ -563,7 +604,7 @@ interface AiRunOptions extends Omit<AiOptions, 'tools'> {
|
|
|
563
604
|
tools: AiRunTool[];
|
|
564
605
|
/** On by default here — every step resends the conversation so far. `false` turns it off. */
|
|
565
606
|
cache?: boolean;
|
|
566
|
-
/** Calls to the model at most — 1 to 10 (default 6). Each step is one call and counts against their limit. */
|
|
607
|
+
/** Calls to the model at most — 1 to 10 (default 6; more is lowered to 10). Each step is one call and counts against their limit. */
|
|
567
608
|
maxSteps?: number;
|
|
568
609
|
/** After each round of tool calls. */
|
|
569
610
|
onStep?(step: { step: number; calls: AiToolCall[]; results: AiPart[]; text: string }): void;
|
|
@@ -615,9 +656,10 @@ interface Ai {
|
|
|
615
656
|
* let your app use them yet: `choices({ ask: true })` shows Fave1's one-time OK and resolves with the list (unchanged if they say no).
|
|
616
657
|
* Where AI can't be used right now, `current` is `null`. In the sandbox you get two mock AIs to build with. */
|
|
617
658
|
choices(options?: { ask?: boolean }): Promise<AiChoices>;
|
|
618
|
-
/** Text to a voice. Pick a voice from `voices()` and that voice's company speaks it
|
|
619
|
-
*
|
|
620
|
-
*
|
|
659
|
+
/** Text to a voice. Pick a voice from `voices()` and that voice's company speaks it, on the person's Fave1 credits — whatever AI they
|
|
660
|
+
* use for text. **Your manifest needs `"voice": true`** (live, without it every call rejects `no-voice` · 'undeclared'; a DEV build lets it
|
|
661
|
+
* through, so set it before you submit). A voice app runs on Fave1 AI only, `chat()` included. Same Allow, limit and rules as `chat()`.
|
|
662
|
+
* Up to 1,200 characters; speak a song or a story line by line. A string is the text: `ctx.ai.speak('Hey you')`. */
|
|
621
663
|
speak(text: string | AiSpeakOptions, options?: Omit<AiSpeakOptions, 'text'>): Promise<AiSpeech>;
|
|
622
664
|
/** The eighteen voices — six tones each from OpenAI, Gemini and Grok — and whether each can speak for this person right now.
|
|
623
665
|
* Show them, let the person pick, pass the `id` to `speak()`. Where AI can't be used yet every voice is `ready: false`;
|
|
@@ -636,9 +678,9 @@ interface AiVoice {
|
|
|
636
678
|
tone: AiVoiceTone;
|
|
637
679
|
/** Would speak right now. */
|
|
638
680
|
ready: boolean;
|
|
639
|
-
/** Who pays: `
|
|
640
|
-
pays: '
|
|
641
|
-
/**
|
|
681
|
+
/** Who pays: `credits` — their Fave1 credits (voices always run on credits) · `null` — not ready. */
|
|
682
|
+
pays: 'credits' | null;
|
|
683
|
+
/** About how many Fave1 credits 1,000 characters cost. `null` when it isn't ready. */
|
|
642
684
|
credits: number | null;
|
|
643
685
|
}
|
|
644
686
|
interface AiSpeakOptions {
|
|
@@ -649,7 +691,7 @@ interface AiSpeakOptions {
|
|
|
649
691
|
style?: string;
|
|
650
692
|
/** 0.5 – 2, default 1. */
|
|
651
693
|
speed?: number;
|
|
652
|
-
/** With a tone: which company to use — `openai` · `google` · `xai
|
|
694
|
+
/** With a tone: which company to use — `openai` · `google` · `xai` (anything else rejects `no-voice` · 'choice'). A voice `id` already names its company. */
|
|
653
695
|
ai?: string;
|
|
654
696
|
signal?: AbortSignal;
|
|
655
697
|
}
|
|
@@ -662,8 +704,8 @@ interface AiSpeech {
|
|
|
662
704
|
voice: string;
|
|
663
705
|
/** Which company spoke it — `openai` · `google` · `xai`, `mock` in the sandbox. */
|
|
664
706
|
provider: string | null;
|
|
665
|
-
/** Who paid — their
|
|
666
|
-
paid: '
|
|
707
|
+
/** Who paid — their Fave1 `credits`. `null` in the sandbox. */
|
|
708
|
+
paid: 'credits' | null;
|
|
667
709
|
/** True in the sandbox — a short tone the length of your text. */
|
|
668
710
|
mock: boolean;
|
|
669
711
|
}
|
|
@@ -677,12 +719,32 @@ interface CameraFeed {
|
|
|
677
719
|
}
|
|
678
720
|
interface Camera {
|
|
679
721
|
/** Turns their camera on — Fave1 asks first (once each time your app opens), then the browser asks for that site. Video only.
|
|
680
|
-
* Rejects `denied` · `blocked` · `unavailable` · `busy`. Call it from a tap, not at launch. */
|
|
681
|
-
open(options?: { facing?: 'user' | 'environment'; width?: number; height?: number }): Promise<CameraFeed>;
|
|
722
|
+
* Rejects `denied` (`err.reason` 'not-now' · 'browser' · 'closed' if it lands after your app closed) · `blocked` · `unavailable` · `busy`. Call it from a tap, not at launch. */
|
|
723
|
+
open(options?: { facing?: 'user' | 'environment'; /** Ideal size, 64–1920 (default 720 on the long side); the browser picks the nearest. */ width?: number; height?: number }): Promise<CameraFeed>;
|
|
682
724
|
/** Every camera your app opened goes off. Closing your app does this too. */
|
|
683
725
|
close(): void;
|
|
684
726
|
readonly active: boolean;
|
|
685
727
|
}
|
|
728
|
+
/** `ctx.mic.open()` — a microphone that's on. */
|
|
729
|
+
interface MicFeed {
|
|
730
|
+
/** One audio track, no video — for `MediaRecorder` or `AudioContext.createMediaStreamSource`. Nothing plays through the speakers unless you do it. */
|
|
731
|
+
stream: MediaStream;
|
|
732
|
+
track: MediaStreamTrack | null;
|
|
733
|
+
/** What the browser actually applied. */
|
|
734
|
+
echo: boolean; noise: boolean; gain: boolean;
|
|
735
|
+
/** Input delay the device reports, in seconds — 0 when it doesn't say. */
|
|
736
|
+
latency: number;
|
|
737
|
+
stop(): void;
|
|
738
|
+
}
|
|
739
|
+
interface Mic {
|
|
740
|
+
/** Turns their microphone on — Fave1 asks first (once each time your app opens), then the browser asks for that site. Sound only.
|
|
741
|
+
* `echo` · `noise` · `gain` (all default true) are the browser's echo cancelling, noise suppression and automatic level — turn them off for
|
|
742
|
+
* someone on earphones. Rejects `denied` (`err.reason` 'not-now' · 'browser' · 'closed' if it lands after your app closed) · `blocked` · `unavailable` · `busy`. Call it from a tap, not at launch. */
|
|
743
|
+
open(options?: { echo?: boolean; noise?: boolean; gain?: boolean }): Promise<MicFeed>;
|
|
744
|
+
/** Every microphone your app opened goes off. Closing your app does this too. */
|
|
745
|
+
close(): void;
|
|
746
|
+
readonly active: boolean;
|
|
747
|
+
}
|
|
686
748
|
/** One of the person's AIs. `id` is stable (`anthropic` · `openai` · `google` · `xai` · `fave1` · `mock`); `name` is what to show ("Claude", "Fave1 AI"). */
|
|
687
749
|
interface AiChoice { id: string; name: string }
|
|
688
750
|
interface AiChoices { current: AiChoice | null; others: AiChoice[]; locked: boolean }
|
|
@@ -692,24 +754,50 @@ interface PurchaseItem { id: string; name: string; qty: number; credits: number
|
|
|
692
754
|
/** What `buy()` and `pending()` give back. `id` is the receipt — write it next to the thing you deliver. */
|
|
693
755
|
interface PurchaseReceipt { id: string; item: string; name: string; qty: number; credits: number }
|
|
694
756
|
interface Purchases {
|
|
695
|
-
/** Your items, in your order, and their credit balance — `null` when signed out,
|
|
757
|
+
/** Your items, in your order, and their credit balance — `null` when signed out, on a site your app isn't allowed on yet, and in a DEV build. */
|
|
696
758
|
items(): Promise<{ items: PurchaseItem[]; balance: number | null }>;
|
|
697
759
|
/** Shows Fave1's confirm line — the Buy button is Fave1's, with Fave1's price on it. Resolves with a receipt once the credits
|
|
698
760
|
* are taken. Put the thing in your storage **with the receipt id in the same write**, then `finish()`. */
|
|
699
761
|
buy(item: string): Promise<PurchaseReceipt>;
|
|
700
762
|
/** Commits a receipt after you delivered. `'returned'` — 7 days passed without `finish()`, Fave1 already gave the credits back. */
|
|
763
|
+
/** `invalid` if `receipt` isn't a receipt id from `buy()` or `pending()`. */
|
|
701
764
|
finish(receipt: string): Promise<'done' | 'returned'>;
|
|
702
|
-
/** Receipts paid for but not finished — call on open, deliver what your storage doesn't show yet, then `finish()`.
|
|
765
|
+
/** Receipts paid for but not finished — call on open, deliver what your storage doesn't show yet, then `finish()`.
|
|
766
|
+
* In a DEV build `pending()` and `finish()` stay in this browser (`[]` and `not-found` until a sandbox buy), while `items()` and `buy()`
|
|
767
|
+
* still ask Fave1 — so they say `not-yet` until in-app purchases open to your app. */
|
|
703
768
|
pending(): Promise<PurchaseReceipt[]>;
|
|
704
769
|
}
|
|
705
770
|
|
|
771
|
+
/** What `notify.send()` gives back — `id` is yours when you passed one, `at` (ISO time) is when it shows up. */
|
|
772
|
+
interface NotifyReceipt { id: string; at: string }
|
|
773
|
+
interface Notify {
|
|
774
|
+
/** Sends **this person** a notification from your app: a number on your icon and on their avatar, a row in their Fave1 notifications.
|
|
775
|
+
* It is for things they asked for themselves — a reminder they set, a timer they started. Never news, offers or "come back".
|
|
776
|
+
* `title` 1–80 characters, `body` up to 240, plain text. `at` (a `Date`, a timestamp or an ISO string, up to a year ahead) schedules it;
|
|
777
|
+
* leave it out to send now. `id` (letters, digits, `_ . : -`, up to 64) names it: sending the same `id` again replaces that one, and
|
|
778
|
+
* `cancel(id)` takes it back. `open` (up to 200 characters) comes back as `ctx.notify.opened` when they open your app from the row.
|
|
779
|
+
* The first call shows Fave1's "Let <app> send you reminders?" line — once per app, not per site. "Not now" rejects `cancelled`. At home, or
|
|
780
|
+
* on a site that already allowed your app, that turns your notifications off until they turn them on in Settings › Notifications
|
|
781
|
+
* (after that every call rejects `denied`); anywhere else it holds for this visit and the next visit asks again.
|
|
782
|
+
* Five a day per person (`rate`, `err.scope` 'day'), fifty waiting at once (`err.scope` 'pending'). No manifest permission. */
|
|
783
|
+
send(note: { title: string; body?: string; at?: Date | number | string; id?: string; open?: string }): Promise<NotifyReceipt>;
|
|
784
|
+
/** Takes one back by `id` — one still waiting, or one already delivered. `true` if there was one. */
|
|
785
|
+
cancel(id: string): Promise<boolean>;
|
|
786
|
+
/** `'on'` — they said yes. `'ask'` — the next `send()` asks. `'off'` — they said no or turned it off in Settings: don't call `send()`,
|
|
787
|
+
* point them at Settings › Notifications instead. Never asks anything itself. */
|
|
788
|
+
status(): Promise<'on' | 'ask' | 'off' | 'signed-out' | 'not-installed'>;
|
|
789
|
+
/** The `open` value of the notification that opened your app this time — read it in `onLaunch` and go there. `null` otherwise. */
|
|
790
|
+
readonly opened: string | null;
|
|
791
|
+
}
|
|
792
|
+
|
|
706
793
|
interface Ctx {
|
|
707
794
|
ui: Ui;
|
|
708
795
|
/** Where you're running: `'page'` — on someone's site, opened from the bookmarklet;
|
|
709
796
|
* `'app'` — at your own `<id>.fave1.app`, opened from My Fave1. Same bundle, split screens. */
|
|
710
797
|
surface: 'page' | 'app';
|
|
711
|
-
/** The language this person uses — `'en'`, `'ko'`, `'pt-BR'`… (what they picked in Fave1 Settings, else their browser's)
|
|
712
|
-
*
|
|
798
|
+
/** The language this person uses — `'en'`, `'ko'`, `'pt-BR'`… (what they picked in Fave1 Settings, else their browser's), as far as
|
|
799
|
+
* Fave1 itself speaks it: a language Fave1 doesn't offer yet comes back as `'en'` (today Fave1 offers English and Korean).
|
|
800
|
+
* Not the page's language — that's `page.lang` — except on Fave1's own pages at www.fave1.com, where it's that page's language. */
|
|
713
801
|
readonly locale: string;
|
|
714
802
|
/** Your app's text in their language, from `locales/<language>.json` (shipped by `npm run submit`). `{name}` fills from `vars`;
|
|
715
803
|
* pass `{ count }` to pick `key_one` · `key_other` …. Falls back to their base language, then `en.json`, then the key itself. */
|
|
@@ -728,6 +816,7 @@ interface Ctx {
|
|
|
728
816
|
* Big things go in `files`; keep the index and settings here. */
|
|
729
817
|
storage: {
|
|
730
818
|
get(key: string): Promise<unknown>;
|
|
819
|
+
/** Any JSON value except `null` (`invalid` — use `delete()` to clear a key). */
|
|
731
820
|
set(key: string, value: unknown): Promise<void>;
|
|
732
821
|
delete(key: string): Promise<void>;
|
|
733
822
|
list(): Promise<string[]>;
|
|
@@ -741,8 +830,9 @@ interface Ctx {
|
|
|
741
830
|
* your code can't change it), `null` at home. Read it with `get(key)`; trim or edit it with `set` · `delete` like any value.
|
|
742
831
|
* An item is JSON up to 4 KB (`too-large`); when the list passes 64 KB the oldest rows drop off. If `key` already holds
|
|
743
832
|
* something that isn't a list, `invalid`. Because it only adds and can't read, it asks once for your app — not once per
|
|
744
|
-
* site: "Keep your <what> in <app>?" (`opts.what`,
|
|
745
|
-
*
|
|
833
|
+
* site: "Keep your <what> in <app>?" (`opts.what`, up to 24 letters and spaces — anything else falls back to the default `history`).
|
|
834
|
+
* `cancelled` if they say not now. A site that already allowed your app never asks. `quota` when their storage or your app's share is full.
|
|
835
|
+
* Never asks at home; `site` is `'local'` for a file opened from their computer. */
|
|
746
836
|
append(key: string, item: unknown, opts?: { what?: string }): Promise<void>;
|
|
747
837
|
/** Forget the once-for-every-site OK that `append()` asked for — the next `append()` on a site asks again (call it when
|
|
748
838
|
* someone turns your history off). Keeps the data. */
|
|
@@ -754,8 +844,9 @@ interface Ctx {
|
|
|
754
844
|
/** One small settings object for this app — a pen color, a switch, the last tab. **No one-time OK, ever**: it opens on any
|
|
755
845
|
* site, even one that never said yes, so your app can open with the person's own settings everywhere. The price is that any
|
|
756
846
|
* page your app opens on can read and change it — **never put anything private here.** Up to 2 KB as JSON (`too-large`),
|
|
757
|
-
* one plain object (`invalid` otherwise); `set(null)` clears it. `get()` never asks and never waits for a tap: it's
|
|
758
|
-
*
|
|
847
|
+
* one plain object (`invalid` otherwise); `set(null)` clears it. `get()` never asks and never waits for a tap: it's the value as it was
|
|
848
|
+
* when your app opened (plus what this tab `set()` since) — a change made in another tab or on another site shows up the next time your
|
|
849
|
+
* app opens. It's `null` when nobody is signed in, before the first `set()`, or if Fave1 couldn't be reached — keep a local copy and open with that.
|
|
759
850
|
* It rejects with `denied` when `storage` isn't declared or was switched off — check `ctx.can('storage')` first. `set()` needs a signed-in person (`signed-out` · `denied` otherwise). Not counted in `usage()`.
|
|
760
851
|
* Cleared with the rest when they clear your app in Fave1 Settings › Storage. A DEV build's sandbox keeps it in this browser. */
|
|
761
852
|
prefs: {
|
|
@@ -777,7 +868,7 @@ interface Ctx {
|
|
|
777
868
|
/** In-app purchases paid with Fave1 credits — declared with `storage`. **Not open to your app yet**: every call rejects with
|
|
778
869
|
* `not-yet` until Fave1 opens it (see /docs/ctx-purchases). */
|
|
779
870
|
purchases: Purchases;
|
|
780
|
-
/** Is this permission live right now? `pub` also
|
|
871
|
+
/** Is this permission live right now? `storage` and `pub` also need a signed-in person (and `pub` one who hasn't switched it off). */
|
|
781
872
|
can(permission: Permission): boolean;
|
|
782
873
|
/** Opens this app's permission screen in Fave1 settings. Only the person can turn things on. */
|
|
783
874
|
perms: { open(): void };
|
|
@@ -792,11 +883,16 @@ interface Ctx {
|
|
|
792
883
|
clipboard: { read(): Promise<string | null>; write(text: string): Promise<boolean> };
|
|
793
884
|
/** Their camera, live, while your app is open — `camera` permission. The video stays on their page. */
|
|
794
885
|
camera: Camera;
|
|
886
|
+
/** Their microphone, live, while your app is open — `mic` permission, separate from the camera. The sound stays on their page. */
|
|
887
|
+
mic: Mic;
|
|
888
|
+
/** Notifications to this person from your app — reminders they set. Fave1 asks them once, the first time you send. */
|
|
889
|
+
notify: Notify;
|
|
795
890
|
/** Your app's settings, edited in the developer console (Config tab) and loaded before `onLaunch` — a plain JSON object.
|
|
796
891
|
* It ships without review, so it holds **values, not code** and nothing secret: every person who opens the app receives it.
|
|
797
892
|
* While you build, `fave1 dev` serves the `config.json` next to your manifest. Missing or unreachable → `{}`. */
|
|
798
893
|
readonly config: Readonly<Record<string, unknown>>;
|
|
799
|
-
/** Who is here. `signedIn` is known at once — true when someone's signed in to Fave1.
|
|
894
|
+
/** Who is here. `signedIn` is known at once — true when someone's signed in to Fave1. At home, an app that declares only `page.*` or
|
|
895
|
+
* `clipboard` never asks the account, so there `signedIn` is `false`, `plus` `'free'` and `tier` `null` even for someone signed in. `id` is this person's id **as your app sees it** — opaque, different in every app,
|
|
800
896
|
* the same value as `me` rows in ctx.pub — and only for apps that declare `storage` or `pub`; undefined until the runtime
|
|
801
897
|
* has asked the server, when nobody is signed in, and in a DEV build's sandbox. `await ctx.user.load()` waits for that answer.
|
|
802
898
|
* On someone else's site it also stays undefined until that site has said yes to your app (`granted`) — it fills in after the
|
|
@@ -813,7 +909,7 @@ interface Ctx {
|
|
|
813
909
|
readonly tier?: 'free' | 'basic' | 'plus' | 'ultra' | null;
|
|
814
910
|
readonly id?: string;
|
|
815
911
|
readonly granted?: boolean;
|
|
816
|
-
load(): Promise<{ readonly signedIn: boolean; readonly id?: string; readonly granted?: boolean }>;
|
|
912
|
+
load(): Promise<{ readonly signedIn: boolean; readonly id?: string; readonly granted?: boolean; readonly plus?: 'plus' | 'free'; readonly tier?: 'free' | 'basic' | 'plus' | 'ultra' | null }>;
|
|
817
913
|
};
|
|
818
914
|
}
|
|
819
915
|
|
|
@@ -76,8 +76,9 @@ An exported `FAVE1_KEY` in your terminal or CI wins over `.env.local`, which win
|
|
|
76
76
|
over `.env`.
|
|
77
77
|
|
|
78
78
|
**Uploading does not make it public.** The build lands in **Versions** as Ready;
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
run the pre-check on it there, then press **Submit for review** at the top of the
|
|
80
|
+
app in the console. That split is deliberate — Submit waits until your listing is
|
|
81
|
+
complete.
|
|
81
82
|
|
|
82
83
|
Next to each build in Versions, **Test** gives you the same kind of link — Safari,
|
|
83
84
|
an iPad, a teammate's laptop. While a build is still Ready, `npm run submit` with
|
|
@@ -90,7 +91,7 @@ the same version replaces it; once it has gone to review, bump the version —
|
|
|
90
91
|
`npm run build` type-checks with `tsc` and bundles `src/index.ts` — and everything
|
|
91
92
|
it imports, npm packages included — into one classic script (`dist/index.js`,
|
|
92
93
|
esbuild). That single file is what the shell loads and what `npm run submit`
|
|
93
|
-
uploads; keep it under
|
|
94
|
+
uploads; keep it under 1 MB. CSS and SVG files you import come in as text, pictures
|
|
94
95
|
(PNG, JPEG, GIF, WebP) as `data:` URLs (`import css from './panel.css'`), so they ship
|
|
95
96
|
inside it too. `npm run dev` rebuilds with the same esbuild command on every save
|
|
96
97
|
(`npm run bundle`), so what you try is what you ship.
|