One app. Two modes.
You don’t build a bookmarklet app and an OS app. You build one bundle. The shell decides which mode it runs in — card mode or app mode.
A card on someone’s site
Etsy, eBay, articles — opened from the bookmarklet, a Fave1 Button or Try it. ctx.page is that live document. Break the Site lives here.
<id>.fave1.app
Opened from My Fave1. Same install, same session. ctx.page is your own page — never fave1.com.
The panel and the page
The panel — blocks or your own DOM
Blocks for lists and forms; host() for an editor, a gallery, a board. The header is always Fave1’s — no app can fake it.
The host page — full DOM
The real document. Query, mutate, animate. That’s the product.
Which mode am I in?
if (ctx.surface === 'card') { // Card mode — a card on someone's site. Play with the page. } else { // 'app' — app mode, your own screen at <id>.fave1.app. Boards, lists, settings. }
ctx.surface is how one bundle draws two screens — the game in card mode, the board in app mode. It never changes mid-run: opening the other mode is a fresh launch.
One wall
Reshape the host page all you like. You can’t touch the session, another app’s data, or the shell. Everything outside the page goes through ctx, and ctx only has what your manifest declared. The browser itself is yours too, with a few rules — Beyond ctx.
Everything on ctx
plus · tier). ctx.user—locales/*.json — English underneath. ctx.locale · ctx.t—on() fires while your app is open. ctx.notify—'card' in card mode, 'app' in app mode — above—storage · pub (so also ctx.files · ctx.shared · ctx.live), someone signed in. When one is off—voices()), and what’s left this month (usage()). No keys anywhere. See ctx.aiaiEvery call that can fail rejects with an Error carrying a code — denied, signed-out, quota and so on, typed as Fave1Error in types/fave1.d.ts. Each page lists the codes it can give.
Lifecycle
Fave1.defineApp({ onLaunch(ctx) { // The panel opened. Draw it, read the page, change the page. }, onDestroy() { // The panel closed. Put the page back, stop your timers. }, });
Two hooks, that’s all. onLaunch runs each time someone opens your app; onDestroy runs when they close it or open another one, and gets the same ctx. Your bundle itself runs once per page: close the app and open it again on the same page, and module variables still hold what they held. So set up your state in onLaunch and clear it in onDestroy. DEV builds load fresh on every open, so you won’t see leftovers while you build — people will. What should outlast the page goes in ctx.storage.