@fave1/create-app 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +52 -2
- package/dist/create-app.js +247 -0
- package/dist/reserved-ids.js +2 -0
- package/package.json +29 -4
- package/templates/break/README.md +88 -0
- package/templates/break/_gitignore +5 -0
- package/templates/break/icon.png +0 -0
- package/templates/break/manifest.json +11 -0
- package/templates/break/package.json +18 -0
- package/templates/break/src/index.ts +64 -0
- package/templates/break/tsconfig.json +15 -0
- package/templates/break/types/fave1.d.ts +499 -0
- package/templates/minimal/README.md +88 -0
- package/templates/minimal/_gitignore +5 -0
- package/templates/minimal/icon.png +0 -0
- package/templates/minimal/manifest.json +11 -0
- package/templates/minimal/package.json +18 -0
- package/templates/minimal/src/index.ts +10 -0
- package/templates/minimal/tsconfig.json +15 -0
- package/templates/minimal/types/fave1.d.ts +499 -0
- package/templates/panel/README.md +88 -0
- package/templates/panel/_gitignore +5 -0
- package/templates/panel/icon.png +0 -0
- package/templates/panel/manifest.json +11 -0
- package/templates/panel/package.json +18 -0
- package/templates/panel/src/index.ts +25 -0
- package/templates/panel/tsconfig.json +15 -0
- package/templates/panel/types/fave1.d.ts +499 -0
- package/templates/storage/README.md +93 -0
- package/templates/storage/_gitignore +5 -0
- package/templates/storage/icon.png +0 -0
- package/templates/storage/manifest.json +11 -0
- package/templates/storage/package.json +18 -0
- package/templates/storage/src/index.ts +66 -0
- package/templates/storage/tsconfig.json +15 -0
- package/templates/storage/types/fave1.d.ts +499 -0
- package/templates/templates.json +6 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Blocks in, Fave1 design out. No permissions needed.
|
|
2
|
+
// You hand the shell an array of blocks; it draws them, so no app can fake Fave1’s header.
|
|
3
|
+
Fave1.defineApp({
|
|
4
|
+
onLaunch(ctx) {
|
|
5
|
+
const ui = ctx.ui;
|
|
6
|
+
let count = 0;
|
|
7
|
+
|
|
8
|
+
function draw() {
|
|
9
|
+
ui.render([
|
|
10
|
+
ui.heading('{{name}}'),
|
|
11
|
+
ui.muted('Blocks in, Fave1 design out.'),
|
|
12
|
+
ui.divider(),
|
|
13
|
+
ui.card([
|
|
14
|
+
ui.text(`Tapped ${count} time${count === 1 ? '' : 's'}`),
|
|
15
|
+
ui.button('Tap', {
|
|
16
|
+
variant: 'purple',
|
|
17
|
+
onClick: () => { count += 1; draw(); },
|
|
18
|
+
}),
|
|
19
|
+
]),
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
draw();
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1,499 @@
|
|
|
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
|
+
| '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
|
+
| 'declined' // room.direct(): their app doesn't take direct lines (no room.on('direct') and no direct() back within 3 s)
|
|
100
|
+
| 'unreachable' | 'timeout' | 'server';
|
|
101
|
+
|
|
102
|
+
/** What `ctx` rejects with — an `Error` carrying a `code`. `catch (err) { const e = err as Fave1Error; … }` */
|
|
103
|
+
interface Fave1Error extends Error {
|
|
104
|
+
code: Fave1ErrorCode;
|
|
105
|
+
/** Which limit was hit.
|
|
106
|
+
* On `quota`: `'app'` — this app's data (ctx.storage — 1 MB on Free, 10 MB on paid plans): let them delete something in your
|
|
107
|
+
* app first. `'account'` — the person's Fave1 storage, or their app data across every app (25 MB on Free): offer
|
|
108
|
+
* `ctx.files.manage()`. `ctx.files` is always `'account'`.
|
|
109
|
+
* 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
|
|
110
|
+
* (more on paid plans): it won't clear today, so tell them. From `files.get()`: `'read'` — 600 reads in a minute, all apps
|
|
111
|
+
* together: back off, it clears within the minute.
|
|
112
|
+
* An older runtime may leave it out; read `quota` as `'account'`, `rate` from `put()` as `'hour'` and from `get()` as `'read'`. */
|
|
113
|
+
scope?: 'app' | 'account' | 'hour' | 'month' | 'read' | 'shared';
|
|
114
|
+
/** On `conflict` from `shared.set()`: the row as it is now (its `v` is the base to use next). */
|
|
115
|
+
current?: Shared;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** One person's public value, as `pub.list()` returns it. */
|
|
119
|
+
interface PubRow<T = any> {
|
|
120
|
+
/** Opaque and per app — the same person has a different id in another app. */
|
|
121
|
+
id: string;
|
|
122
|
+
/** One letter for an avatar, yours included. Public rows never carry a name — show "You" on your own row. */
|
|
123
|
+
initial: string;
|
|
124
|
+
/** Their avatar gradient, ready for CSS `background`. */
|
|
125
|
+
color: string;
|
|
126
|
+
value: T;
|
|
127
|
+
/** ISO time of their last write. */
|
|
128
|
+
updatedAt: string;
|
|
129
|
+
/** This row belongs to the person using the app. */
|
|
130
|
+
me: boolean;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
interface PubQuery {
|
|
134
|
+
/** Rows whose value contains this JSON: `{ week: '2026-W40' }`, or `{ hides: [{ site: 'amazon.com' }] }`
|
|
135
|
+
* for an array that holds a matching item. Up to 2 KB. */
|
|
136
|
+
where?: unknown;
|
|
137
|
+
/** The field to sort by: `'best'`, `'-best'` (largest first), `'stats.best'`, or a key path like
|
|
138
|
+
* `['runs', 'amazon.com', 'ms']` when a key has a dot in it. Ties go to whoever wrote first. */
|
|
139
|
+
order?: string | string[];
|
|
140
|
+
/** Largest first. `'-best'` already means this. */
|
|
141
|
+
desc?: boolean;
|
|
142
|
+
/** 1–100. Default 50. */
|
|
143
|
+
limit?: number;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Why someone reports a row — `pub.report(id, reason)`. */
|
|
147
|
+
type PubReportReason = 'inappropriate' | 'scam' | 'exposes_personal_data' | 'other';
|
|
148
|
+
|
|
149
|
+
/** `pub` — one JSON value per person, up to 4 KB, that everyone using this app can read. Only its owner writes it.
|
|
150
|
+
* Writing needs a Fave1 account: when nobody's signed in, `ctx.can('pub')` is false and only `list()` works — other people's
|
|
151
|
+
* rows, without names (`name` is null). Show the board anyway and ask people to sign in to get on it.
|
|
152
|
+
* The first write from a new site asks the person once ("Post to …?"), so `set()` can take a moment — and can
|
|
153
|
+
* reject with `cancelled`. On the app's own page (`<id>.fave1.app`) it never asks. DEV builds use a sandbox in this browser
|
|
154
|
+
* unless Data is set to "My account" in the DEV panel.
|
|
155
|
+
* Values are `any` — read what you wrote. Want them checked? `const pub = ctx.pub as Pub<{ week: string; best: number }>`. */
|
|
156
|
+
interface Pub<T = any> {
|
|
157
|
+
/** Your value, or `undefined`. */
|
|
158
|
+
get(): Promise<T | undefined>;
|
|
159
|
+
/** Replaces your whole value. Calls in a row are merged — the last one is what's saved. */
|
|
160
|
+
set(value: T): Promise<void>;
|
|
161
|
+
delete(): Promise<void>;
|
|
162
|
+
list(query?: PubQuery): Promise<PubRow<T>[]>;
|
|
163
|
+
/** Your place in the same query — `null` when your value doesn't match or has no `order` field. */
|
|
164
|
+
rank(query: PubQuery & { order: string | string[] }): Promise<{ rank: number; total: number } | null>;
|
|
165
|
+
/** Report someone else's row — `id` from `list()`. Fave1 looks at it; whoever posted it is never told who reported.
|
|
166
|
+
* 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. */
|
|
167
|
+
report(id: string, reason?: PubReportReason, details?: string): Promise<void>;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Someone in a live room — `room.peers()`, and `peer` on `peer` events. */
|
|
171
|
+
interface LivePeer {
|
|
172
|
+
/** One socket — a person with two tabs open is two peers. */
|
|
173
|
+
sid: string;
|
|
174
|
+
/** Opaque and per app — the same value as `ctx.user.id` for them, and as rows in `ctx.pub`. */
|
|
175
|
+
id: string;
|
|
176
|
+
/** One letter for an avatar. No names in rooms. */
|
|
177
|
+
initial: string;
|
|
178
|
+
/** Their avatar gradient, ready for CSS `background`. */
|
|
179
|
+
color: string;
|
|
180
|
+
/** The last thing they sent with `room.cursor(…)` — `null` until they do. */
|
|
181
|
+
data: unknown;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** A change to the room's table — your own writes come through here too (`me: true`), before the server confirms them. */
|
|
185
|
+
interface LiveChange {
|
|
186
|
+
key: string;
|
|
187
|
+
/** `undefined` when the key was deleted. */
|
|
188
|
+
value: unknown;
|
|
189
|
+
/** Who did it — `null` for the table the room handed you on join (or after a reconnect). */
|
|
190
|
+
by: { sid: string; id: string } | null;
|
|
191
|
+
me: boolean;
|
|
192
|
+
/** The room's change counter after this change. */
|
|
193
|
+
seq: number;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** A direct line to one other person in a room — `room.direct(sid)`, or `room.on('direct', …)` when they opened one to you.
|
|
197
|
+
* A WebRTC data channel between the two browsers, so a message arrives in a few milliseconds instead of a trip through Fave1 —
|
|
198
|
+
* for what has to be fast and may be thrown away: inputs at 60 Hz, a shared pointer, "typing". Nothing is kept, nobody else in the
|
|
199
|
+
* room sees it, and whoever joins later sees nothing. Fave1 opens the connection inside its own frame (the page never sees addresses
|
|
200
|
+
* or credentials) and, when it can't be opened in 8 s (a firewall, a browser with WebRTC off), the same line opens **through the room**
|
|
201
|
+
* instead — `via` says which. If the direct connection drops later, the line stays open and moves to the room (`via` becomes `'room'`).
|
|
202
|
+
* A line opens only between two apps that both take it — one side calls `direct()`, the other listens with `room.on('direct')` (or calls
|
|
203
|
+
* `direct()` back). Each side can see the other's network (IP) address, as on any video call. Messages are JSON up to 1 KB, like `cursor()`. */
|
|
204
|
+
interface DirectLine {
|
|
205
|
+
/** The other person's socket — one tab. Key what you draw by this. */
|
|
206
|
+
sid: string;
|
|
207
|
+
/** Their app-scoped id (`ctx.user.id` for them) — `''` until the room knows them. */
|
|
208
|
+
id: string;
|
|
209
|
+
/** Lossy lines drop a late message instead of waiting for it — right for per-frame inputs, wrong for a chat. Set with `direct(sid, { lossy: true })`;
|
|
210
|
+
* the side that opened the line decides. */
|
|
211
|
+
readonly lossy: boolean;
|
|
212
|
+
readonly open: boolean;
|
|
213
|
+
/** `'direct'` — browser to browser; `'relay'` — through a TURN relay (still not through Fave1's room); `'room'` — the fallback, through the
|
|
214
|
+
* room's server. `null` until open. Read it live: a direct line that drops moves to `'room'` without closing. */
|
|
215
|
+
readonly via: 'direct' | 'relay' | 'room' | null;
|
|
216
|
+
/** Round trip in milliseconds, measured every 2 s once open — `null` until the first answer, and on a `'room'` line. */
|
|
217
|
+
readonly rtt: number | null;
|
|
218
|
+
/** Send one JSON value (up to 1 KB). Returns `false` — and sends nothing — when the line isn't open or the value is too big
|
|
219
|
+
* (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. */
|
|
220
|
+
send(data: unknown): boolean;
|
|
221
|
+
on(type: 'message', handler: (data: unknown) => void): () => void;
|
|
222
|
+
on(type: 'open', handler: (ev: { via: 'direct' | 'relay' | 'room' }) => void): () => void;
|
|
223
|
+
/** `closed` — either side called `close()`; `left` — they left the room; `lost` — your own room connection dropped (Fave1 reconnects the room
|
|
224
|
+
* 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
|
|
225
|
+
* moves to the room (`via`). */
|
|
226
|
+
on(type: 'close', handler: (ev: { reason: 'closed' | 'left' | 'lost' | 'gone' }) => void): () => void;
|
|
227
|
+
on(type: 'error', handler: (ev: { code: 'too-large' | 'rate' | 'invalid' }) => void): () => void;
|
|
228
|
+
close(): void;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** A room you joined — one shared table of `key → value`, kept on Fave1 and pushed to everyone in it the moment it changes. */
|
|
232
|
+
interface LiveRoom {
|
|
233
|
+
/** The room's wire name (a hash of what you passed to `join`). */
|
|
234
|
+
id: string;
|
|
235
|
+
/** What you passed to `join`. */
|
|
236
|
+
name: string;
|
|
237
|
+
/** You in this room — `id` is your app-scoped id, `sid` this tab's socket (both filled in once the room is open), and the
|
|
238
|
+
* initial and color the others see you as. */
|
|
239
|
+
me: { id: string | null; sid: string | null; initial: string; color: string };
|
|
240
|
+
/** Connected right now. Writes while closed are kept locally and dropped — wait for `open`. */
|
|
241
|
+
readonly open: boolean;
|
|
242
|
+
readonly seq: number;
|
|
243
|
+
get(key: string): unknown;
|
|
244
|
+
/** A copy of the whole table. */
|
|
245
|
+
all(): Record<string, unknown>;
|
|
246
|
+
/** 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
|
|
247
|
+
* holds up to 2,000 keys / 256 KB. When two people set the same key at the same moment, the one the server gets last wins. */
|
|
248
|
+
set(key: string, value: unknown): Promise<void>;
|
|
249
|
+
del(key: string): Promise<void>;
|
|
250
|
+
/** 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,
|
|
251
|
+
* last value wins. Up to 1 KB as JSON. */
|
|
252
|
+
cursor(data: unknown): void;
|
|
253
|
+
peers(): LivePeer[];
|
|
254
|
+
/** A direct line to one person in the room (`DirectLine`). Resolves once it's open — browser to browser, or through the room after 8 s when it
|
|
255
|
+
* can't be (`line.via`). Their app has to take it: it listens with `room.on('direct')`, or calls `direct()` to you — otherwise this rejects
|
|
256
|
+
* with `declined` after 3 s (also when they already hold 8 lines). The same `sid` always gives the same line; up to 8 at once, counting lines
|
|
257
|
+
* opened to you (`quota`). Also rejects with `not-found` when nobody
|
|
258
|
+
* has that `sid`, `invalid` for your own, `unreachable` when the room is closed, `timeout` after 20 s. `{ lossy: true }` for per-frame inputs. */
|
|
259
|
+
direct(sid: string, opts?: { lossy?: boolean }): Promise<DirectLine>;
|
|
260
|
+
on(type: 'change', handler: (change: LiveChange) => void): () => void;
|
|
261
|
+
on(type: 'peer', handler: (ev: { type: 'join' | 'leave' | 'cursor'; peer: LivePeer }) => void): () => void;
|
|
262
|
+
/** Someone in the room opened a direct line to you — it is already open. **Registering this is how your app takes direct lines**: without it,
|
|
263
|
+
* lines from others are declined (unless you call `direct()` to that person yourself). Register it right after `join()`. */
|
|
264
|
+
on(type: 'direct', handler: (line: DirectLine) => void): () => void;
|
|
265
|
+
/** Fires after a reconnect (`join()` itself resolves once the room is open) — the table may have moved on; `change` events for the
|
|
266
|
+
* differences come first. */
|
|
267
|
+
on(type: 'open', handler: (ev: { reconnected: true }) => void): () => void;
|
|
268
|
+
/** `lost` — dropped, Fave1 is reconnecting; `left` — you called `leave()`; `server` — the room closed it (idle for 45 days, or the
|
|
269
|
+
* socket's ticket ran out); `gone` — the app closed. */
|
|
270
|
+
on(type: 'close', handler: (ev: { code: number; reason: 'lost' | 'left' | 'server' | 'gone' }) => void): () => void;
|
|
271
|
+
/** The room refused something — `too-large`, `quota` (room full of keys/bytes), `rate` (over 40 writes a second), `invalid`. */
|
|
272
|
+
on(type: 'error', handler: (ev: { code: string; key?: string }) => void): () => void;
|
|
273
|
+
leave(): Promise<void>;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** `live` — rooms where people edit the same thing at the same time, Figma-style. Uses the `pub` permission (no new one): needs a
|
|
277
|
+
* signed-in person who hasn't switched `pub` off, and on someone else's site the first join asks once ("Join the room on …?") —
|
|
278
|
+
* the same yes that covers posting. Anyone who joins a room with the same name sees the same table, so put something only your
|
|
279
|
+
* 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. */
|
|
280
|
+
interface Live {
|
|
281
|
+
/** `what` names what people are joining in the permission line — `Join the {what} on <your app>?` — one word, default `room`
|
|
282
|
+
* (a Collab calls it a project). Older launchers ignore it. */
|
|
283
|
+
join(room: string, opts?: { what?: string }): Promise<LiveRoom>;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** One of this person's files for your app, as `files.put()` and `files.list()` return it. */
|
|
287
|
+
interface FileInfo {
|
|
288
|
+
id: string;
|
|
289
|
+
/** `opts.name` from `put()` — or, when you passed a `File` without one, the file's own name. Up to 200 characters; `''` when neither. */
|
|
290
|
+
name: string;
|
|
291
|
+
/** The blob's MIME type, lowercased and without parameters — `image/png`. `application/octet-stream` when the blob had none. */
|
|
292
|
+
type: string;
|
|
293
|
+
/** Bytes. */
|
|
294
|
+
size: number;
|
|
295
|
+
/** ISO time it was saved. */
|
|
296
|
+
createdAt: string;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/** `files` — this person's files for your app, on their Fave1 account: screenshots they marked up, exports, images they kept.
|
|
300
|
+
* Same permission as `storage` (no new one), same rules: needs a signed-in person, asks once on a new site, never at home,
|
|
301
|
+
* 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
|
|
302
|
+
* (app data + files together); when it's full, `put()` rejects with `quota` (`scope: 'account'`) — reading and deleting still work.
|
|
303
|
+
* **They can delete any file in Fave1 Settings › Storage at any time.** `get()` resolves `null` then — treat it as normal. */
|
|
304
|
+
interface Files {
|
|
305
|
+
/** Save a blob. Its type is kept lowercased, parameters dropped, and `get()` returns the blob with it.
|
|
306
|
+
* A `File` keeps its own name unless `opts.name` gives one. Empty files and HTML reject with `invalid`, over 25 MB with `too-large`.
|
|
307
|
+
* 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
|
|
308
|
+
* doesn't give the upload back. Past either, `rate` with `err.scope` `'hour'` or `'month'` — stop, keep your place, carry on later. */
|
|
309
|
+
put(blob: Blob, opts?: { name?: string }): Promise<FileInfo>;
|
|
310
|
+
/** 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
|
|
311
|
+
* 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.
|
|
312
|
+
* Get files as they come into view: past 600 reads a minute (all apps together), `rate` with `err.scope` `'read'`. */
|
|
313
|
+
get(id: string): Promise<Blob | null>;
|
|
314
|
+
/** This app's files for this person, newest first (up to 5,000). */
|
|
315
|
+
list(): Promise<FileInfo[]>;
|
|
316
|
+
/** Resolves even if the file was already gone. */
|
|
317
|
+
delete(id: string): Promise<void>;
|
|
318
|
+
/** 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`. */
|
|
319
|
+
manage(): void;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** What `ctx.page` always has. */
|
|
323
|
+
interface PageInfo {
|
|
324
|
+
url: string;
|
|
325
|
+
title: string;
|
|
326
|
+
/** All visible text — only when `page.text` is declared. The `page` permission doesn't fill it; read `document.body.innerText`. */
|
|
327
|
+
text?: string;
|
|
328
|
+
/** What's highlighted — or, if nothing is now, what was highlighted when they opened Fave1 (`page.selection` or `page`). */
|
|
329
|
+
selection?: string;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/** What the `page` permission adds — the live DOM and helpers. All of it, or none of it. */
|
|
333
|
+
interface PageAccess {
|
|
334
|
+
/** The page's real `document` — no wrapper, no proxy. */
|
|
335
|
+
document: Document;
|
|
336
|
+
/** `querySelector` on that document. The element type defaults to `HTMLElement`; pass another: `query<HTMLImageElement>('img')`. */
|
|
337
|
+
query<E extends Element = HTMLElement>(selector: string): E | null;
|
|
338
|
+
/** `querySelectorAll` on that document, as an array. */
|
|
339
|
+
queryAll<E extends Element = HTMLElement>(selector: string): E[];
|
|
340
|
+
/** A listener on the page (capture phase) that the shell removes when your app closes. Returns a remover. */
|
|
341
|
+
on<K extends keyof DocumentEventMap>(type: K, handler: (ev: DocumentEventMap[K]) => void): () => void;
|
|
342
|
+
on(type: string, handler: (ev: Event) => void): () => void;
|
|
343
|
+
/** A full-screen layer over the page for what you draw yourself — a game canvas, a score bar, confetti. Fave1 keeps it
|
|
344
|
+
* above everything on the page and below its own card, and removes it when your app closes. It lets clicks through:
|
|
345
|
+
* give `pointer-events: auto` to what should catch them. Same element on every call. `{ over: 'card' }` lifts it above
|
|
346
|
+
* the card for a moment (a celebration) — up there it takes no clicks; call `layer()` again to put it back. */
|
|
347
|
+
layer(options?: { over?: 'page' | 'card' }): HTMLElement;
|
|
348
|
+
/** True when a node or event target is Fave1’s own chrome — the card, its frames, the top-layer box, or the app-layer
|
|
349
|
+
* element itself. What you put inside `layer()` is still yours (`layer.contains`). A node with slot `f1-under` is the
|
|
350
|
+
* page. Skip chrome when you walk the page, and let its clicks through when you catch input on the page. */
|
|
351
|
+
isFave1(node: EventTarget | null): boolean;
|
|
352
|
+
/** Pull fixed layers the page stacked above the card back under it. Fave1 puts them back when the app closes. */
|
|
353
|
+
sinkFloaters(): void;
|
|
354
|
+
/** Pull one element under the card. Fave1 puts it back when the app closes. */
|
|
355
|
+
lowerFloater(el: Element): void;
|
|
356
|
+
/** 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. */
|
|
357
|
+
raiseFloaters(): void;
|
|
358
|
+
/** 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
|
|
359
|
+
* server first (skip with `direct: false` if you already did), then fetches it through Fave1. Fave1 sends no cookies and no
|
|
360
|
+
* 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
|
|
361
|
+
* same as anyone would get. Images only, up to 12 MB; nothing is kept. Resolves to `null` when it can't — never throws, except
|
|
362
|
+
* `invalid` for something that isn't an address. `data:` and `blob:` addresses are read as they are. */
|
|
363
|
+
fetchImage(url: string, options?: { direct?: boolean; signal?: AbortSignal }): Promise<Blob | null>;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/** `page` undeclared or switched off in Fave1 settings — none of it is there. */
|
|
367
|
+
type NoPageAccess = { [K in keyof PageAccess]?: undefined };
|
|
368
|
+
|
|
369
|
+
/** A value your app shares by link, as `shared.create()` · `get()` return it. */
|
|
370
|
+
interface Shared<T = unknown> {
|
|
371
|
+
/** The link's two halves. `ref` is `"<id>.<key>"` — the string you put in a URL and pass back to `get()` · `set()`. */
|
|
372
|
+
id: string; key: string; ref: string;
|
|
373
|
+
value: T;
|
|
374
|
+
/** Changes with every write. Pass it as `base` to `set()` so an edit made in between isn't lost. */
|
|
375
|
+
v: number;
|
|
376
|
+
/** Can people with the link write, not just read? The owner sets it with `create()` and `access()`. */
|
|
377
|
+
edit: boolean;
|
|
378
|
+
updatedAt: string;
|
|
379
|
+
/** This person made it. */
|
|
380
|
+
mine: boolean;
|
|
381
|
+
/** Who made it, and who wrote last (if someone other than the owner did) — first letter and avatar color, never a name. */
|
|
382
|
+
owner: { initial: string; color: string } | null;
|
|
383
|
+
editor: { initial: string; color: string } | null;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/** `shared` — one value shared by one link: a note, a list, a board. Declared with `storage` (no new permission).
|
|
387
|
+
* The owner creates it; anyone with the link reads it — signed out, or without your app added; and if the owner turned
|
|
388
|
+
* `edit` on, any signed-in person with the link can write. The owner can change that or take the link back at any time.
|
|
389
|
+
* Values up to 64 KB, 100 per person per app; they count toward the owner's Fave1 storage. The link is the secret —
|
|
390
|
+
* put `ref` in a URL your app opens with (`<id>.fave1.app/#s=<ref>`) and never post it anywhere public yourself.
|
|
391
|
+
* Owner calls (`create` · `access` · `list` · `delete`) follow the storage rules: a signed-in person, one OK on a new
|
|
392
|
+
* site, never at home. DEV builds keep it in this browser — a link made there opens nowhere else. */
|
|
393
|
+
interface SharedApi {
|
|
394
|
+
/** Share a value. `edit` lets people with the link write (default read-only). Rejects with `quota` — `err.scope` `'shared'`
|
|
395
|
+
* at 100 shared values, `'account'` when their Fave1 storage is full. */
|
|
396
|
+
create<T = unknown>(value: T, opts?: { edit?: boolean }): Promise<Shared<T>>;
|
|
397
|
+
/** Read by link. `null` when it's gone or the link is wrong — never throws for that. Works signed out. */
|
|
398
|
+
get<T = unknown>(ref: string): Promise<Shared<T> | null>;
|
|
399
|
+
/** Write by link — as the owner, or as a signed-in person when `edit` is on (`denied` otherwise, `signed-out` with no account).
|
|
400
|
+
* Pass `base` (the `v` you read) and, if someone wrote in between, it rejects with `conflict` carrying `err.current`
|
|
401
|
+
* (the row now): merge, then call `set()` again with its `v`. Without `base` it overwrites. */
|
|
402
|
+
set<T = unknown>(ref: string, value: T, opts?: { base?: number }): Promise<{ v: number }>;
|
|
403
|
+
/** Owner only: let people with the link write, or stop that. Takes the `id` or the `ref`. */
|
|
404
|
+
access(idOrRef: string, opts: { edit: boolean }): Promise<void>;
|
|
405
|
+
/** Everything this person shares from your app — with the keys, so you can show the links again. */
|
|
406
|
+
list(): Promise<Shared[]>;
|
|
407
|
+
/** Owner only: take the link back. Whoever has it gets `null` from then on. Resolves even if it was already gone. */
|
|
408
|
+
delete(idOrRef: string): Promise<void>;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
interface Ctx {
|
|
412
|
+
ui: Ui;
|
|
413
|
+
/** Where you're running: `'page'` — on someone's site, opened from the bookmarklet;
|
|
414
|
+
* `'app'` — at your own `<id>.fave1.app`, opened from My Fave1. Same bundle, split screens. */
|
|
415
|
+
surface: 'page' | 'app';
|
|
416
|
+
/** `storage` — private JSON on this person's Fave1 account, per key. Nobody else reads it — not other apps, not other people,
|
|
417
|
+
* not you. Values up to 64 KB (`too-large`); 1 MB per app on Free, 10 MB on paid plans (`usage()` tells you theirs) —
|
|
418
|
+
* 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
|
|
419
|
+
* storage — over any, `quota`, and `err.scope` says which (`'app'`, or `'account'` for the other two). A write that's the same
|
|
420
|
+
* size or smaller always goes through, even when full. Needs a signed-in person:
|
|
421
|
+
* `ctx.can('storage')` is false when nobody is — fold the feature.
|
|
422
|
+
* 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
|
|
423
|
+
* `cancelled`. At home (`<id>.fave1.app`) it never asks. DEV builds use a sandbox in this browser unless Data is set to
|
|
424
|
+
* "My account" in the DEV panel — the sandbox keeps the 1 MB limit, and
|
|
425
|
+
* `localStorage['fave1.dev.quota']` (a byte count, set on the site you test on) makes it act like a full account at that size.
|
|
426
|
+
* They can clear your app's data in Fave1 Settings › Storage at any time — a key that comes back `undefined` is normal.
|
|
427
|
+
* Big things go in `files`; keep the index and settings here. */
|
|
428
|
+
storage: {
|
|
429
|
+
get(key: string): Promise<unknown>;
|
|
430
|
+
set(key: string, value: unknown): Promise<void>;
|
|
431
|
+
delete(key: string): Promise<void>;
|
|
432
|
+
list(): Promise<string[]>;
|
|
433
|
+
/** How full your app's share is for this person. `bytes` — what your app keeps on their account, counted the way `set()`
|
|
434
|
+
* 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,
|
|
435
|
+
* don't hard-code). Files don't count here: they go to their Fave1 storage (`quota` with `scope: 'account'`, `files.manage()`).
|
|
436
|
+
* 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. */
|
|
437
|
+
usage(): Promise<{ bytes: number; limit: number }>;
|
|
438
|
+
/** One small settings object for this app — a pen color, a switch, the last tab. **No one-time OK, ever**: it opens on any
|
|
439
|
+
* site, even one that never said yes, so your app can open with the person's own settings everywhere. The price is that any
|
|
440
|
+
* page your app opens on can read and change it — **never put anything private here.** Up to 2 KB as JSON (`too-large`),
|
|
441
|
+
* one plain object (`invalid` otherwise); `set(null)` clears it. `get()` never asks and never waits for a tap: it's `null` when
|
|
442
|
+
* nobody is signed in, before the first `set()`, or if Fave1 couldn't be reached — keep a local copy and open with that.
|
|
443
|
+
* 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()`.
|
|
444
|
+
* Cleared with the rest when they clear your app in Fave1 Settings › Storage. A DEV build's sandbox keeps it in this browser. */
|
|
445
|
+
prefs: {
|
|
446
|
+
get(): Promise<Record<string, unknown> | null>;
|
|
447
|
+
set(value: Record<string, unknown> | null): Promise<void>;
|
|
448
|
+
};
|
|
449
|
+
};
|
|
450
|
+
/** Files on the account — declared with `storage`, like the JSON above. */
|
|
451
|
+
files: Files;
|
|
452
|
+
/** Values shared by link — declared with `storage` too. */
|
|
453
|
+
shared: SharedApi;
|
|
454
|
+
pub: Pub;
|
|
455
|
+
/** Live rooms — the same table, edited by several people at once (uses `pub`). */
|
|
456
|
+
live: Live;
|
|
457
|
+
/** Is this permission live right now? `pub` also needs a signed-in person who hasn't switched it off. */
|
|
458
|
+
can(permission: Permission): boolean;
|
|
459
|
+
/** Opens this app's permission screen in Fave1 settings. Only the person can turn things on. */
|
|
460
|
+
perms: { open(): void };
|
|
461
|
+
/** The page you opened on. `url` and `title` always; the rest only as far as `page.text` · `page.selection` · `page` allow.
|
|
462
|
+
* With `page` declared and switched on, check `document` once — after that TypeScript knows every `page` helper is there:
|
|
463
|
+
* `const page = ctx.page; if (!page.document) { …page access is off…; return; }`. */
|
|
464
|
+
page: PageInfo & (PageAccess | NoPageAccess);
|
|
465
|
+
/** `clipboard` — copy and paste, the iPhone way. `read()` asks the person **every time** ("Paste into <your app>?") and
|
|
466
|
+
* resolves what they copied, or `null` when they say no or there's no text to paste. `write()` called inside the person's
|
|
467
|
+
* tap (the browser counts a tap for a few seconds) copies at once — the tap was the yes; later it asks first.
|
|
468
|
+
* Resolves `true` once it's copied, `false` if they say no. */
|
|
469
|
+
clipboard: { read(): Promise<string | null>; write(text: string): Promise<boolean> };
|
|
470
|
+
/** Your app's settings, edited in the developer console (Config tab) and loaded before `onLaunch` — a plain JSON object.
|
|
471
|
+
* It ships without review, so it holds **values, not code** and nothing secret: every person who opens the app receives it.
|
|
472
|
+
* While you build, `fave1 dev` serves the `config.json` next to your manifest. Missing or unreachable → `{}`. */
|
|
473
|
+
readonly config: Readonly<Record<string, unknown>>;
|
|
474
|
+
/** 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,
|
|
475
|
+
* the same value as `me` rows in ctx.pub — and only for apps that declare `storage` or `pub`; undefined until the runtime
|
|
476
|
+
* has asked the server, when nobody is signed in, and in a DEV build's sandbox. `await ctx.user.load()` waits for that answer.
|
|
477
|
+
* On someone else's site it also stays undefined until that site has said yes to your app (`granted`) — it fills in after the
|
|
478
|
+
* first storage or pub call goes through. At home it's always there.
|
|
479
|
+
* `granted` says whether ctx.storage and ctx.pub work **on this page without asking**: true when this site already said yes
|
|
480
|
+
* 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
|
|
481
|
+
* first (or nobody is signed in); undefined until that answer, and for apps that declare neither `storage` nor `pub`.
|
|
482
|
+
* With Data set to "My account" in the DEV panel both work as they will live — the id belongs to your DEV slot. */
|
|
483
|
+
user: {
|
|
484
|
+
readonly signedIn: boolean;
|
|
485
|
+
readonly id?: string;
|
|
486
|
+
readonly granted?: boolean;
|
|
487
|
+
load(): Promise<{ readonly signedIn: boolean; readonly id?: string; readonly granted?: boolean }>;
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
interface App {
|
|
492
|
+
onLaunch(ctx: Ctx): void | Promise<void>;
|
|
493
|
+
/** The app closed — put the page back, stop your timers. Gets the same `ctx` as `onLaunch`. */
|
|
494
|
+
onDestroy?(ctx: Ctx): void | Promise<void>;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/** Lent to your bundle while its top-level code runs — the page you open on may use the name `Fave1` for
|
|
498
|
+
* something of its own, so Fave1 gives it back right after. Call `defineApp` once, at the top of your bundle. */
|
|
499
|
+
declare const Fave1: { defineApp(app: App): App };
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
Saves start in a sandbox in that browser. To test sign-in, the first-time prompt
|
|
29
|
+
and other sites, set **Data** to **My account** in the same panel — saves go to a
|
|
30
|
+
DEV slot on your Fave1 account, kept apart from the live app. Clear it in Fave1
|
|
31
|
+
settings › Storage.
|
|
32
|
+
|
|
33
|
+
## Ship it
|
|
34
|
+
|
|
35
|
+
Once, in the console: **Create app** at
|
|
36
|
+
[developers.fave1.com/apps](https://developers.fave1.com/apps) with the same ID as
|
|
37
|
+
`id` in `manifest.json` (`{{id}}`) — uploads go to the app with that ID. Then make a
|
|
38
|
+
publish key at [developers.fave1.com/keys](https://developers.fave1.com/keys) and put
|
|
39
|
+
it in a `.env` file in this folder (it's git-ignored):
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
FAVE1_KEY=f1_live_…
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`icon.png` is a placeholder so your DEV build has something to show in the launcher. Make
|
|
46
|
+
your own icon and upload it in the console's **Listing** tab (512×512 PNG or JPEG, square
|
|
47
|
+
corners) — the store doesn't read this file. Apps that use this placeholder are rejected
|
|
48
|
+
in review.
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm run submit # builds, then uploads dist/index.js
|
|
52
|
+
npm run submit -- --whats-new "Remembers your place" # with a line for the store
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
It prints a **Test** link — your app on its own home (`{{id}}.fave1.app`), in any
|
|
56
|
+
browser, for 12 hours. That's how you see the home screen (`ctx.surface === 'app'`)
|
|
57
|
+
on a phone or in Safari. On your laptop, the build you saved as the DEV source also
|
|
58
|
+
shows up in [My Fave1](https://www.fave1.com/myapps) — open it there to try its home
|
|
59
|
+
in a window.
|
|
60
|
+
|
|
61
|
+
That window opens phone-size. Built your home to use more room? Add
|
|
62
|
+
`"window": "medium"` (760 wide) or `"window": "wide"` (1120) to `manifest.json` — it
|
|
63
|
+
opens that wide when the screen allows, and people can still resize it. Phones always
|
|
64
|
+
get the full screen.
|
|
65
|
+
|
|
66
|
+
An exported `FAVE1_KEY` in your terminal or CI wins over `.env.local`, which wins
|
|
67
|
+
over `.env`.
|
|
68
|
+
|
|
69
|
+
**Uploading does not make it public.** The build lands in **Versions** as Ready;
|
|
70
|
+
you press **Submit for review** in the console. That split is deliberate — a
|
|
71
|
+
listing sent to review half-empty gets rejected by default.
|
|
72
|
+
|
|
73
|
+
Next to each build in Versions, **Test** gives you the same kind of link — Safari,
|
|
74
|
+
an iPad, a teammate's laptop. While a build is still Ready, `npm run submit` with
|
|
75
|
+
the same version replaces it; once it has gone to review, bump the version —
|
|
76
|
+
`npx fave1 version patch` updates `manifest.json`, `package.json` and
|
|
77
|
+
`package-lock.json` together. An update needs a version above the live one.
|
|
78
|
+
|
|
79
|
+
## Split your code however you like
|
|
80
|
+
|
|
81
|
+
`npm run build` type-checks with `tsc` and bundles `src/index.ts` — and everything
|
|
82
|
+
it imports, npm packages included — into one classic script (`dist/index.js`,
|
|
83
|
+
esbuild). That single file is what the shell loads and what `npm run submit`
|
|
84
|
+
uploads; keep it under 512 KB. CSS and SVG files you import come in as text, pictures
|
|
85
|
+
(PNG, JPEG, GIF, WebP) as `data:` URLs (`import css from './panel.css'`), so they ship
|
|
86
|
+
inside it too. `npm run dev` rebuilds with the same esbuild command on every save
|
|
87
|
+
(`npm run bundle`), so what you try is what you ship.
|
|
88
|
+
On sites with a strict security policy a `<style>` element is blocked — style with
|
|
89
|
+
`new CSSStyleSheet()` + `replaceSync(css)` + `adoptedStyleSheets`, or
|
|
90
|
+
`el.style.cssText`. `Fave1` is a global the runtime provides while your bundle runs — call
|
|
91
|
+
`Fave1.defineApp` once, at the top; there is nothing to import for it. The types are in `types/fave1.d.ts`.
|
|
92
|
+
|
|
93
|
+
Docs: [developers.fave1.com/docs](https://developers.fave1.com/docs)
|
|
Binary file
|