@fave1/create-app 0.0.0-stage → 0.1.0

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 (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +52 -2
  3. package/dist/create-app.js +247 -0
  4. package/dist/reserved-ids.js +2 -0
  5. package/package.json +29 -4
  6. package/templates/break/README.md +81 -0
  7. package/templates/break/_gitignore +5 -0
  8. package/templates/break/icon.png +0 -0
  9. package/templates/break/manifest.json +11 -0
  10. package/templates/break/package.json +18 -0
  11. package/templates/break/src/index.ts +64 -0
  12. package/templates/break/tsconfig.json +15 -0
  13. package/templates/break/types/fave1.d.ts +334 -0
  14. package/templates/minimal/README.md +81 -0
  15. package/templates/minimal/_gitignore +5 -0
  16. package/templates/minimal/icon.png +0 -0
  17. package/templates/minimal/manifest.json +11 -0
  18. package/templates/minimal/package.json +18 -0
  19. package/templates/minimal/src/index.ts +10 -0
  20. package/templates/minimal/tsconfig.json +15 -0
  21. package/templates/minimal/types/fave1.d.ts +334 -0
  22. package/templates/panel/README.md +81 -0
  23. package/templates/panel/_gitignore +5 -0
  24. package/templates/panel/icon.png +0 -0
  25. package/templates/panel/manifest.json +11 -0
  26. package/templates/panel/package.json +18 -0
  27. package/templates/panel/src/index.ts +25 -0
  28. package/templates/panel/tsconfig.json +15 -0
  29. package/templates/panel/types/fave1.d.ts +334 -0
  30. package/templates/storage/README.md +86 -0
  31. package/templates/storage/_gitignore +5 -0
  32. package/templates/storage/icon.png +0 -0
  33. package/templates/storage/manifest.json +11 -0
  34. package/templates/storage/package.json +18 -0
  35. package/templates/storage/src/index.ts +66 -0
  36. package/templates/storage/tsconfig.json +15 -0
  37. package/templates/storage/types/fave1.d.ts +334 -0
  38. package/templates/templates.json +6 -0
@@ -0,0 +1,334 @@
1
+ /* Fave1 SDK types.
2
+ *
3
+ * The runtime comes from the shell — there is no SDK inside your bundle. `Fave1` is a global
4
+ * only while your bundle's top-level code runs — call `Fave1.defineApp` once, at the top. Your app
5
+ * only registers behavior, and everything after that comes in `ctx`. That's why this file is
6
+ * declarations only, with no `import`.
7
+ *
8
+ * manifest.json is the source of truth for permissions. A part of `ctx` whose permission isn't
9
+ * in the manifest is empty or refused at run time — a type here doesn't grant anything. */
10
+
11
+ type Block = { readonly __block: unique symbol };
12
+
13
+ /* Non-code files your code imports. The template's build bundles them into dist/index.js — CSS and SVG as text, pictures
14
+ * (PNG, JPEG, GIF, WebP) as data: URLs — because that one file is all that ships. `import css from './panel.css'` gives you
15
+ * the CSS as a string, `import logo from './logo.png'` a URL you can put in an <img>. */
16
+ declare module '*.css' { const text: string; export default text; }
17
+ declare module '*.svg' { const text: string; export default text; }
18
+ declare module '*.png' { const dataUrl: string; export default dataUrl; }
19
+ declare module '*.jpg' { const dataUrl: string; export default dataUrl; }
20
+ declare module '*.jpeg' { const dataUrl: string; export default dataUrl; }
21
+ declare module '*.gif' { const dataUrl: string; export default dataUrl; }
22
+ declare module '*.webp' { const dataUrl: string; export default dataUrl; }
23
+
24
+ interface Ui {
25
+ render(blocks: Block[]): void;
26
+ setLoading(message?: string): void;
27
+ /** `'error'` shows a coral toast; `'success'` and `'info'` look like the default. */
28
+ toast(message: string, type?: 'success' | 'error' | 'info'): void;
29
+ setTitle(title: string): void;
30
+ /** The standard failure view — the same look in every app. */
31
+ error(message?: string, options?: { retry?: () => void; retryLabel?: string }): void;
32
+
33
+ /** Your own element under the shell header, for what blocks can't draw — an editor, a gallery grid, a board with avatars.
34
+ * Same element every time until the app closes; `render(blocks)` puts blocks back, `host()` brings your DOM back untouched.
35
+ * It lives in its own shadow root outside the shell's — you can't reach the header from it, and the page's CSS stays out. */
36
+ host(): HTMLElement;
37
+ /** Shrink the panel to a small pill in the corner (icon · text · ×) and hand the page back — no dim. Tap the pill to restore.
38
+ * The pill sits bottom-right unless you pass `corner` — call again with another corner to move it. A no-op at home (`surface === 'app'`). */
39
+ minimize(options?: { text?: string; corner?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' }): void;
40
+ /** Bring the panel back after `minimize()`. */
41
+ restore(): void;
42
+ /**
43
+ * Fires when the panel folds to a pill (`true`) or opens back up (`false`) — the same moment the pill appears or the panel returns.
44
+ * Calling `minimize()` again while it is already a pill (new text or a different corner) does not fire.
45
+ * `restore()` you call yourself fires `false` too. Returns a function that stops listening.
46
+ * At home the panel never folds, so this never fires and the function you get back does nothing.
47
+ * An account prompt that opens the panel and puts the pill back does not fire — the person did not tap the pill.
48
+ */
49
+ onFold(cb: (folded: boolean) => void): () => void;
50
+ /**
51
+ * Is the panel a pill right now? Always `false` at home.
52
+ * `false` while an account prompt has the panel open; `true` again afterward if the pill is back.
53
+ */
54
+ folded(): boolean;
55
+ /** Park the open panel in a corner with the dim gone, so a game owns the middle. `'center'` puts it back. */
56
+ corner(where: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center'): void;
57
+ /** The job is done — close your app. On a site it's the same as tapping ×: Fave1 closes, `onDestroy` runs, and your layer and
58
+ * page listeners come off. At home (`surface === 'app'`) it closes your app and the person is back on My Fave1. */
59
+ close(): void;
60
+ /** Take Fave1 off the screen for a moment — the panel or the pill, and a permission line if one is up — for an app that captures
61
+ * or records the screen. Your layer (`ctx.page.layer()`) is yours and stays. `show()` brings everything back as it was; closing
62
+ * the app does too. A no-op at home (`surface === 'app'`). */
63
+ hide(): void;
64
+ /** Undo `hide()`. */
65
+ show(): void;
66
+
67
+ heading(text: string): Block;
68
+ text(text: string): Block;
69
+ muted(text: string): Block;
70
+ button(label: string, options?: {
71
+ onClick?: () => unknown;
72
+ variant?: 'primary' | 'purple' | 'ghost' | 'danger';
73
+ }): Block;
74
+ input(options?: { placeholder?: string; value?: string; onChange?: (value: string) => void }): Block;
75
+ card(children: Block[]): Block;
76
+ list(items: Block[]): Block;
77
+ item(text: string, options?: { sub?: string; icon?: string; onClick?: () => unknown }): Block;
78
+ badge(text: string): Block;
79
+ divider(): Block;
80
+ spinner(): Block;
81
+ image(src: string, options?: { alt?: string }): Block;
82
+ empty(icon: string, text: string): Block;
83
+ row(children: Block[]): Block;
84
+ stack(children: Block[]): Block;
85
+ }
86
+
87
+ type Permission = 'page.text' | 'page.selection' | 'page' | 'storage' | 'pub' | 'clipboard';
88
+
89
+ /** `err.code` on anything `ctx` rejects with. */
90
+ type Fave1ErrorCode =
91
+ | 'denied' // the permission isn't in manifest.json, or the person turned it off in Settings
92
+ | 'signed-out' // needs a Fave1 account and there isn't one here
93
+ | 'not-installed' // this person hasn't added the app (a sideloaded run)
94
+ | 'too-large' | 'quota' | 'invalid'
95
+ | 'rate' // too fast — pub writes in a row, file uploads (`err.scope` 'hour' | 'month') or file reads ('read'): wait, then carry on
96
+ | 'cancelled' // they said "Not now"
97
+ | 'unreachable' | 'timeout' | 'server';
98
+
99
+ /** What `ctx` rejects with — an `Error` carrying a `code`. `catch (err) { const e = err as Fave1Error; … }` */
100
+ interface Fave1Error extends Error {
101
+ code: Fave1ErrorCode;
102
+ /** Which limit was hit.
103
+ * On `quota`: `'app'` — this app's data (ctx.storage — 1 MB on Free, 10 MB on paid plans): let them delete something in your
104
+ * app first. `'account'` — the person's Fave1 storage, or their app data across every app (25 MB on Free): offer
105
+ * `ctx.files.manage()`. `ctx.files` is always `'account'`.
106
+ * On `rate` from `files.put()`: `'hour'` — 600 uploads in the past hour: try again in a bit. `'month'` — 3,000 in 30 days on Free
107
+ * (more on paid plans): it won't clear today, so tell them. From `files.get()`: `'read'` — 600 reads in a minute, all apps
108
+ * together: back off, it clears within the minute.
109
+ * An older runtime may leave it out; read `quota` as `'account'`, `rate` from `put()` as `'hour'` and from `get()` as `'read'`. */
110
+ scope?: 'app' | 'account' | 'hour' | 'month' | 'read';
111
+ }
112
+
113
+ /** One person's public value, as `pub.list()` returns it. */
114
+ interface PubRow<T = any> {
115
+ /** Opaque and per app — the same person has a different id in another app. */
116
+ id: string;
117
+ /** Their Fave1 name. `null` on your own row — show "You". */
118
+ name: string | null;
119
+ /** One letter for an avatar, yours included. */
120
+ initial: string;
121
+ /** Their avatar gradient, ready for CSS `background`. */
122
+ color: string;
123
+ value: T;
124
+ /** ISO time of their last write. */
125
+ updatedAt: string;
126
+ /** This row belongs to the person using the app. */
127
+ me: boolean;
128
+ }
129
+
130
+ interface PubQuery {
131
+ /** Rows whose value contains this JSON: `{ week: '2026-W40' }`, or `{ hides: [{ site: 'amazon.com' }] }`
132
+ * for an array that holds a matching item. Up to 2 KB. */
133
+ where?: unknown;
134
+ /** The field to sort by: `'best'`, `'-best'` (largest first), `'stats.best'`, or a key path like
135
+ * `['runs', 'amazon.com', 'ms']` when a key has a dot in it. Ties go to whoever wrote first. */
136
+ order?: string | string[];
137
+ /** Largest first. `'-best'` already means this. */
138
+ desc?: boolean;
139
+ /** 1–100. Default 50. */
140
+ limit?: number;
141
+ }
142
+
143
+ /** Why someone reports a row — `pub.report(id, reason)`. */
144
+ type PubReportReason = 'inappropriate' | 'scam' | 'exposes_personal_data' | 'other';
145
+
146
+ /** `pub` — one JSON value per person, up to 4 KB, that everyone using this app can read. Only its owner writes it.
147
+ * Writing needs a Fave1 account: when nobody's signed in, `ctx.can('pub')` is false and only `list()` works — other people's
148
+ * rows, without names (`name` is null). Show the board anyway and ask people to sign in to get on it.
149
+ * The first write from a new site asks the person once ("Post to …?"), so `set()` can take a moment — and can
150
+ * reject with `cancelled`. On the app's own page (`<id>.fave1.app`) it never asks. DEV builds use a sandbox in this browser
151
+ * unless Data is set to "My account" in the DEV panel.
152
+ * Values are `any` — read what you wrote. Want them checked? `const pub = ctx.pub as Pub<{ week: string; best: number }>`. */
153
+ interface Pub<T = any> {
154
+ /** Your value, or `undefined`. */
155
+ get(): Promise<T | undefined>;
156
+ /** Replaces your whole value. Calls in a row are merged — the last one is what's saved. */
157
+ set(value: T): Promise<void>;
158
+ delete(): Promise<void>;
159
+ list(query?: PubQuery): Promise<PubRow<T>[]>;
160
+ /** Your place in the same query — `null` when your value doesn't match or has no `order` field. */
161
+ rank(query: PubQuery & { order: string | string[] }): Promise<{ rank: number; total: number } | null>;
162
+ /** Report someone else's row — `id` from `list()`. Fave1 looks at it; whoever posted it is never told who reported.
163
+ * 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. */
164
+ report(id: string, reason?: PubReportReason, details?: string): Promise<void>;
165
+ }
166
+
167
+ /** One of this person's files for your app, as `files.put()` and `files.list()` return it. */
168
+ interface FileInfo {
169
+ id: string;
170
+ /** `opts.name` from `put()` — or, when you passed a `File` without one, the file's own name. Up to 200 characters; `''` when neither. */
171
+ name: string;
172
+ /** The blob's MIME type, lowercased and without parameters — `image/png`. `application/octet-stream` when the blob had none. */
173
+ type: string;
174
+ /** Bytes. */
175
+ size: number;
176
+ /** ISO time it was saved. */
177
+ createdAt: string;
178
+ }
179
+
180
+ /** `files` — this person's files for your app, on their Fave1 account: screenshots they marked up, exports, images they kept.
181
+ * Same permission as `storage` (no new one), same rules: needs a signed-in person, asks once on a new site, never at home,
182
+ * DEV builds use a sandbox in this browser unless Data is "My account". Up to 25 MB per file. Every file counts toward the person's Fave1 storage
183
+ * (app data + files together); when it's full, `put()` rejects with `quota` (`scope: 'account'`) — reading and deleting still work.
184
+ * **They can delete any file in Fave1 Settings › Storage at any time.** `get()` resolves `null` then — treat it as normal. */
185
+ interface Files {
186
+ /** Save a blob. Its type is kept lowercased, parameters dropped, and `get()` returns the blob with it.
187
+ * A `File` keeps its own name unless `opts.name` gives one. Empty files and HTML reject with `invalid`, over 25 MB with `too-large`.
188
+ * 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
189
+ * doesn't give the upload back. Past either, `rate` with `err.scope` `'hour'` or `'month'` — stop, keep your place, carry on later. */
190
+ put(blob: Blob, opts?: { name?: string }): Promise<FileInfo>;
191
+ /** 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
192
+ * 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.
193
+ * Get files as they come into view: past 600 reads a minute (all apps together), `rate` with `err.scope` `'read'`. */
194
+ get(id: string): Promise<Blob | null>;
195
+ /** This app's files for this person, newest first (up to 5,000). */
196
+ list(): Promise<FileInfo[]>;
197
+ /** Resolves even if the file was already gone. */
198
+ delete(id: string): Promise<void>;
199
+ /** Open this app's page in Fave1 Settings › Storage in a new tab — where people see and clear what your app keeps. Offer it on `quota`. */
200
+ manage(): void;
201
+ }
202
+
203
+ /** What `ctx.page` always has. */
204
+ interface PageInfo {
205
+ url: string;
206
+ title: string;
207
+ /** All visible text — only when `page.text` is declared. The `page` permission doesn't fill it; read `document.body.innerText`. */
208
+ text?: string;
209
+ /** What's highlighted — or, if nothing is now, what was highlighted when they opened Fave1 (`page.selection` or `page`). */
210
+ selection?: string;
211
+ }
212
+
213
+ /** What the `page` permission adds — the live DOM and helpers. All of it, or none of it. */
214
+ interface PageAccess {
215
+ /** The page's real `document` — no wrapper, no proxy. */
216
+ document: Document;
217
+ /** `querySelector` on that document. The element type defaults to `HTMLElement`; pass another: `query<HTMLImageElement>('img')`. */
218
+ query<E extends Element = HTMLElement>(selector: string): E | null;
219
+ /** `querySelectorAll` on that document, as an array. */
220
+ queryAll<E extends Element = HTMLElement>(selector: string): E[];
221
+ /** A listener on the page (capture phase) that the shell removes when your app closes. Returns a remover. */
222
+ on<K extends keyof DocumentEventMap>(type: K, handler: (ev: DocumentEventMap[K]) => void): () => void;
223
+ on(type: string, handler: (ev: Event) => void): () => void;
224
+ /** A full-screen layer over the page for what you draw yourself — a game canvas, a score bar, confetti. Fave1 keeps it
225
+ * above everything on the page and below its own card, and removes it when your app closes. It lets clicks through:
226
+ * give `pointer-events: auto` to what should catch them. Same element on every call. `{ over: 'card' }` lifts it above
227
+ * the card for a moment (a celebration) — up there it takes no clicks; call `layer()` again to put it back. */
228
+ layer(options?: { over?: 'page' | 'card' }): HTMLElement;
229
+ /** True when a node or event target is Fave1’s own chrome — the card, its frames, the top-layer box, or the app-layer
230
+ * element itself. What you put inside `layer()` is still yours (`layer.contains`). A node with slot `f1-under` is the
231
+ * page. Skip chrome when you walk the page, and let its clicks through when you catch input on the page. */
232
+ isFave1(node: EventTarget | null): boolean;
233
+ /** Pull fixed layers the page stacked above the card back under it. Fave1 puts them back when the app closes. */
234
+ sinkFloaters(): void;
235
+ /** Pull one element under the card. Fave1 puts it back when the app closes. */
236
+ lowerFloater(el: Element): void;
237
+ /** Put back everything `sinkFloaters` and `lowerFloater` pulled down. Call it when a round ends and the app stays open; closing the app does the same. */
238
+ raiseFloaters(): void;
239
+ /** The bytes of one image on the page — even when its server doesn't let other sites read it (no CORS). Tries the image's own
240
+ * server first (skip with `direct: false` if you already did), then fetches it through Fave1. Fave1 sends no cookies and no
241
+ * referrer, so an image you have to be signed in to see, or one its site refuses to hand to other pages, stays `null` — the
242
+ * same as anyone would get. Images only, up to 12 MB; nothing is kept. Resolves to `null` when it can't — never throws, except
243
+ * `invalid` for something that isn't an address. `data:` and `blob:` addresses are read as they are. */
244
+ fetchImage(url: string, options?: { direct?: boolean; signal?: AbortSignal }): Promise<Blob | null>;
245
+ }
246
+
247
+ /** `page` undeclared or switched off in Fave1 settings — none of it is there. */
248
+ type NoPageAccess = { [K in keyof PageAccess]?: undefined };
249
+
250
+ interface Ctx {
251
+ ui: Ui;
252
+ /** Where you're running: `'page'` — on someone's site, opened from the bookmarklet;
253
+ * `'app'` — at your own `<id>.fave1.app`, opened from My Fave1. Same bundle, split screens. */
254
+ surface: 'page' | 'app';
255
+ /** `storage` — private JSON on this person's Fave1 account, per key. Nobody else reads it — not other apps, not other people,
256
+ * not you. Values up to 64 KB (`too-large`); 1 MB per app on Free, 10 MB on paid plans (`usage()` tells you theirs) —
257
+ * design for 1 MB; every app's data together up to 25 MB on Free (250 MB on paid plans); and it all counts toward their Fave1
258
+ * storage — over any, `quota`, and `err.scope` says which (`'app'`, or `'account'` for the other two). A write that's the same
259
+ * size or smaller always goes through, even when full. Needs a signed-in person:
260
+ * `ctx.can('storage')` is false when nobody is — fold the feature.
261
+ * The first use on a new site asks once ("Use your Fave1 account here?"), so a call can take a moment and can reject with
262
+ * `cancelled`. At home (`<id>.fave1.app`) it never asks. DEV builds use a sandbox in this browser unless Data is set to
263
+ * "My account" in the DEV panel — the sandbox keeps the 1 MB limit, and
264
+ * `localStorage['fave1.dev.quota']` (a byte count, set on the site you test on) makes it act like a full account at that size.
265
+ * They can clear your app's data in Fave1 Settings › Storage at any time — a key that comes back `undefined` is normal.
266
+ * Big things go in `files`; keep the index and settings here. */
267
+ storage: {
268
+ get(key: string): Promise<unknown>;
269
+ set(key: string, value: unknown): Promise<void>;
270
+ delete(key: string): Promise<void>;
271
+ list(): Promise<string[]>;
272
+ /** How full your app's share is for this person. `bytes` — what your app keeps on their account, counted the way `set()`
273
+ * counts it (each value as JSON text); `limit` — your app's share on their plan (1 MB on Free, 10 MB on paid plans — ask,
274
+ * don't hard-code). Files don't count here: they go to their Fave1 storage (`quota` with `scope: 'account'`, `files.manage()`).
275
+ * Same rules as `list()`: needs a signed-in person, asks once on a new site, never at home. A DEV build's sandbox reports itself and 1 MB. */
276
+ usage(): Promise<{ bytes: number; limit: number }>;
277
+ /** One small settings object for this app — a pen color, a switch, the last tab. **No one-time OK, ever**: it opens on any
278
+ * site, even one that never said yes, so your app can open with the person's own settings everywhere. The price is that any
279
+ * page your app opens on can read and change it — **never put anything private here.** Up to 2 KB as JSON (`too-large`),
280
+ * one plain object (`invalid` otherwise); `set(null)` clears it. `get()` never asks and never waits for a tap: it's `null` when
281
+ * nobody is signed in, before the first `set()`, or if Fave1 couldn't be reached — keep a local copy and open with that.
282
+ * 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()`.
283
+ * Cleared with the rest when they clear your app in Fave1 Settings › Storage. A DEV build's sandbox keeps it in this browser. */
284
+ prefs: {
285
+ get(): Promise<Record<string, unknown> | null>;
286
+ set(value: Record<string, unknown> | null): Promise<void>;
287
+ };
288
+ };
289
+ /** Files on the account — declared with `storage`, like the JSON above. */
290
+ files: Files;
291
+ pub: Pub;
292
+ /** Is this permission live right now? `pub` also needs a signed-in person who hasn't switched it off. */
293
+ can(permission: Permission): boolean;
294
+ /** Opens this app's permission screen in Fave1 settings. Only the person can turn things on. */
295
+ perms: { open(): void };
296
+ /** The page you opened on. `url` and `title` always; the rest only as far as `page.text` · `page.selection` · `page` allow.
297
+ * With `page` declared and switched on, check `document` once — after that TypeScript knows every `page` helper is there:
298
+ * `const page = ctx.page; if (!page.document) { …page access is off…; return; }`. */
299
+ page: PageInfo & (PageAccess | NoPageAccess);
300
+ /** `clipboard` — copy and paste, the iPhone way. `read()` asks the person **every time** ("Paste into <your app>?") and
301
+ * resolves what they copied, or `null` when they say no or there's no text to paste. `write()` called inside the person's
302
+ * tap (the browser counts a tap for a few seconds) copies at once — the tap was the yes; later it asks first.
303
+ * Resolves `true` once it's copied, `false` if they say no. */
304
+ clipboard: { read(): Promise<string | null>; write(text: string): Promise<boolean> };
305
+ /** Your app's settings, edited in the developer console (Config tab) and loaded before `onLaunch` — a plain JSON object.
306
+ * It ships without review, so it holds **values, not code** and nothing secret: every person who opens the app receives it.
307
+ * While you build, `fave1 dev` serves the `config.json` next to your manifest. Missing or unreachable → `{}`. */
308
+ readonly config: Readonly<Record<string, unknown>>;
309
+ /** Who is here. `signedIn` is known at once — true when someone's signed in to Fave1. `id` is this person's id **as your app sees it** — opaque, different in every app,
310
+ * the same value as `me` rows in ctx.pub — and only for apps that declare `storage` or `pub`; undefined until the runtime
311
+ * has asked the server, when nobody is signed in, and in a DEV build's sandbox. `await ctx.user.load()` waits for that answer.
312
+ * On someone else's site it also stays undefined until that site has said yes to your app (`granted`) — it fills in after the
313
+ * first storage or pub call goes through. At home it's always there.
314
+ * `granted` says whether ctx.storage and ctx.pub work **on this page without asking**: true when this site already said yes
315
+ * to your app, in your app's own home and in a DEV build's sandbox; false when the first account call here will show the one-time OK
316
+ * first (or nobody is signed in); undefined until that answer, and for apps that declare neither `storage` nor `pub`.
317
+ * With Data set to "My account" in the DEV panel both work as they will live — the id belongs to your DEV slot. */
318
+ user: {
319
+ readonly signedIn: boolean;
320
+ readonly id?: string;
321
+ readonly granted?: boolean;
322
+ load(): Promise<{ readonly signedIn: boolean; readonly id?: string; readonly granted?: boolean }>;
323
+ };
324
+ }
325
+
326
+ interface App {
327
+ onLaunch(ctx: Ctx): void | Promise<void>;
328
+ /** The app closed — put the page back, stop your timers. Gets the same `ctx` as `onLaunch`. */
329
+ onDestroy?(ctx: Ctx): void | Promise<void>;
330
+ }
331
+
332
+ /** Lent to your bundle while its top-level code runs — the page you open on may use the name `Fave1` for
333
+ * something of its own, so Fave1 gives it back right after. Call `defineApp` once, at the top of your bundle. */
334
+ declare const Fave1: { defineApp(app: App): App };
@@ -0,0 +1,81 @@
1
+ # {{name}}
2
+
3
+ A Fave1 app. Behavior lives in `src/index.ts`; everything else — id, name, icon,
4
+ permissions — lives in `manifest.json`. The store reads the manifest **without
5
+ running your code**, and the shell builds a permission-scoped `ctx` from it.
6
+
7
+ You need Node.js 20 or newer, and Chrome or Edge on a computer while you build —
8
+ Safari blocks `http://localhost` on https sites, so your local build can't load there.
9
+ To check Safari, upload and press **Test** in Versions (below). You test on real
10
+ sites through Fave1 in your bookmarks bar — no Fave1 there yet? Add it first at
11
+ [www.fave1.com/get-started](https://www.fave1.com/get-started).
12
+
13
+ ```bash
14
+ npm install
15
+ npm run dev # serves your app at http://localhost:7300 — leave it running
16
+ ```
17
+
18
+ Open Fave1 from your bookmarks bar on any shop or article, hold the Fave1 logo,
19
+ paste `http://localhost:7300` and save. Your app shows up first with a DEV badge.
20
+ Chrome asks once per site to allow local network access — allow it, and press
21
+ Save again if the panel already said it found nothing. Save a file, reopen the
22
+ app, and it's the new build. Changed
23
+ `manifest.json`? Close Fave1 and click it in your bookmarks bar again — reopening
24
+ the app isn't enough. Port 7300 taken? `npm run dev -- --port 7400`.
25
+ Leave that terminal running and type everything else — `npm run submit` too — in a
26
+ second one; a command typed where the dev server runs does nothing.
27
+
28
+ ## Ship it
29
+
30
+ Once, in the console: **Create app** at
31
+ [developers.fave1.com/apps](https://developers.fave1.com/apps) with the same ID as
32
+ `id` in `manifest.json` (`{{id}}`) — uploads go to the app with that ID. Then make a
33
+ publish key at [developers.fave1.com/keys](https://developers.fave1.com/keys) and put
34
+ it in a `.env` file in this folder (it's git-ignored):
35
+
36
+ ```bash
37
+ FAVE1_KEY=f1_live_…
38
+ ```
39
+
40
+ `icon.png` is a placeholder so your DEV build has something to show in the launcher. Make
41
+ your own icon and upload it in the console's **Listing** tab (512×512 PNG or JPEG, square
42
+ corners) — the store doesn't read this file. Apps that use this placeholder are rejected
43
+ in review.
44
+
45
+ ```bash
46
+ npm run submit # builds, then uploads dist/index.js
47
+ npm run submit -- --whats-new "Remembers your place" # with a line for the store
48
+ ```
49
+
50
+ It prints a **Test** link — your app on its own home (`{{id}}.fave1.app`), in any
51
+ browser, for 12 hours. That's how you see the home screen (`ctx.surface === 'app'`):
52
+ `npm run dev` only runs on sites.
53
+
54
+ An exported `FAVE1_KEY` in your terminal or CI wins over `.env.local`, which wins
55
+ over `.env`.
56
+
57
+ **Uploading does not make it public.** The build lands in **Versions** as Ready;
58
+ you press **Submit for review** in the console. That split is deliberate — a
59
+ listing sent to review half-empty gets rejected by default.
60
+
61
+ Next to each build in Versions, **Test** gives you the same kind of link — Safari,
62
+ an iPad, a teammate's laptop. While a build is still Ready, `npm run submit` with
63
+ the same version replaces it; once it has gone to review, bump the version —
64
+ `npx fave1 version patch` updates `manifest.json`, `package.json` and
65
+ `package-lock.json` together. An update needs a version above the live one.
66
+
67
+ ## Split your code however you like
68
+
69
+ `npm run build` type-checks with `tsc` and bundles `src/index.ts` — and everything
70
+ it imports, npm packages included — into one classic script (`dist/index.js`,
71
+ esbuild). That single file is what the shell loads and what `npm run submit`
72
+ uploads; keep it under 512 KB. CSS and SVG files you import come in as text, pictures
73
+ (PNG, JPEG, GIF, WebP) as `data:` URLs (`import css from './panel.css'`), so they ship
74
+ inside it too. `npm run dev` rebuilds with the same esbuild command on every save
75
+ (`npm run bundle`), so what you try is what you ship.
76
+ On sites with a strict security policy a `<style>` element is blocked — style with
77
+ `new CSSStyleSheet()` + `replaceSync(css)` + `adoptedStyleSheets`, or
78
+ `el.style.cssText`. `Fave1` is a global the runtime provides while your bundle runs — call
79
+ `Fave1.defineApp` once, at the top; there is nothing to import for it. The types are in `types/fave1.d.ts`.
80
+
81
+ Docs: [developers.fave1.com/docs](https://developers.fave1.com/docs)
@@ -0,0 +1,5 @@
1
+ node_modules
2
+ dist
3
+ # Your publish key goes here (FAVE1_KEY=…) — fave1 submit reads it. Never commit it.
4
+ .env
5
+ .env.*
Binary file
@@ -0,0 +1,11 @@
1
+ {
2
+ "manifestVersion": 1,
3
+ "id": "{{id}}",
4
+ "name": "{{name}}",
5
+ "icon": "icon.png",
6
+ "version": "1.0.0",
7
+ "description": "",
8
+ "category": "Productivity",
9
+ "author": "",
10
+ "permissions": []
11
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "{{id}}",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "build": "tsc --noEmit && npm run bundle",
7
+ "watch": "npm run bundle -- --watch",
8
+ "bundle": "esbuild src/index.ts --bundle --format=iife --target=es2019 --loader:.css=text --loader:.svg=text --loader:.png=dataurl --loader:.jpg=dataurl --loader:.jpeg=dataurl --loader:.gif=dataurl --loader:.webp=dataurl --outfile=dist/index.js",
9
+ "check": "tsc --noEmit",
10
+ "dev": "fave1 dev",
11
+ "submit": "npm run build && fave1 submit"
12
+ },
13
+ "devDependencies": {
14
+ "@fave1/cli": "^0.1.0",
15
+ "esbuild": "^0.25.0",
16
+ "typescript": "^5.7.0"
17
+ }
18
+ }
@@ -0,0 +1,10 @@
1
+ // Identity and permissions live in manifest.json — this file only acts.
2
+ // The store reads the manifest without running this code, so nothing here can ask for more.
3
+ Fave1.defineApp({
4
+ onLaunch(ctx) {
5
+ ctx.ui.render([
6
+ ctx.ui.heading('{{name}}'),
7
+ ctx.ui.muted('Edit src/index.ts, save, then reopen the app.'),
8
+ ]);
9
+ },
10
+ });
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "skipLibCheck": true,
8
+ "types": [],
9
+ "noEmit": true
10
+ },
11
+ "include": [
12
+ "src",
13
+ "types"
14
+ ]
15
+ }