your personal website on atproto - mirror blento.app
25
fork

Configure Feed

Select the types of activity you want to include in your feed.

add request login

+42 -4
+24 -2
docs/embed-sdk/v0.md
··· 175 175 Blento.notifyNavigate(`/${session.did}/event/r/${rkey}`); 176 176 ``` 177 177 178 + ### `Blento.promptLogin(): void` 179 + 180 + Ask the parent to show its login modal. Fire-and-forget — there is no 181 + returned Promise. To detect when the user has signed in, subscribe to 182 + `session` events: 183 + 184 + ```js 185 + if (!Blento.getSession()) { 186 + const off = Blento.on('session', (s) => { 187 + if (s) { 188 + off(); 189 + doTheThing(); 190 + } 191 + }); 192 + Blento.promptLogin(); 193 + } 194 + ``` 195 + 196 + Calling `promptLogin()` while the user is already signed in is a no-op from 197 + the iframe's perspective; the parent may still display the modal. 198 + 178 199 ## Errors 179 200 180 201 All write rejections are `BlentoError` instances with a stable `.code`: ··· 213 234 { v: 0, id, type: 'deleteRecord', payload: { collection, rkey } } 214 235 { v: 0, id, type: 'applyWrites', payload: { writes, validate? } } 215 236 { v: 0, id, type: 'uploadBlob', payload: { bytes: number[], mimeType } } 216 - { v: 0, type: 'blento:resize', heightPx } // unsolicited 217 - { v: 0, type: 'blento:navigate', url } // unsolicited 237 + { v: 0, type: 'blento:resize', heightPx } // unsolicited 238 + { v: 0, type: 'blento:navigate', url } // unsolicited 239 + { v: 0, type: 'blento:promptLogin' } // unsolicited 218 240 ``` 219 241 220 242 `id` is any unique string you generate — the parent echoes it on the response.
+6
src/lib/embed/AtmoEmbed.svelte
··· 3 3 import { browser } from '$app/environment'; 4 4 import { page } from '$app/state'; 5 5 import { user } from '$lib/atproto'; 6 + import { atProtoLoginModalState } from '$lib/atproto/LoginModal.svelte'; 6 7 import { 7 8 embedApplyWrites, 8 9 embedCreateRecord, ··· 198 199 } catch { 199 200 /* ignore malformed URLs */ 200 201 } 202 + return; 203 + } 204 + 205 + if (data.type === 'blento:promptLogin') { 206 + atProtoLoginModalState.show(); 201 207 return; 202 208 } 203 209
+6 -2
static/embed/v0/sdk.js
··· 14 14 * { v: 0, id, type: 'deleteRecord', payload: { collection, rkey } } 15 15 * { v: 0, id, type: 'applyWrites', payload: { writes, validate? } } 16 16 * { v: 0, id, type: 'uploadBlob', payload: { bytes: number[], mimeType } } 17 - * { v: 0, type: 'blento:resize', heightPx } 18 - * { v: 0, type: 'blento:navigate', url } 17 + * { v: 0, type: 'blento:resize', heightPx } 18 + * { v: 0, type: 'blento:navigate', url } 19 + * { v: 0, type: 'blento:promptLogin' } 19 20 * 20 21 * ─── Wire protocol (parent → iframe) ───────────────────────────────────────── 21 22 * { v: 0, type: 'ready', session } // sent once after handshake ··· 202 203 }, 203 204 notifyNavigate: function (url) { 204 205 sendToParent({ v: PROTOCOL_VERSION, type: 'blento:navigate', url: url }); 206 + }, 207 + promptLogin: function () { 208 + sendToParent({ v: PROTOCOL_VERSION, type: 'blento:promptLogin' }); 205 209 } 206 210 }; 207 211
+6
static/embed/v0/test.html
··· 130 130 <div class="row"> 131 131 <button id="btn-resize">notifyResize(800)</button> 132 132 <button id="btn-navigate">notifyNavigate('/')</button> 133 + <button id="btn-prompt-login">promptLogin()</button> 133 134 </div> 134 135 135 136 <div class="field"> ··· 247 248 $('btn-navigate').onclick = () => { 248 249 window.Blento.notifyNavigate('/'); 249 250 show('notifyNavigate(/) sent', null); 251 + }; 252 + 253 + $('btn-prompt-login').onclick = () => { 254 + window.Blento.promptLogin(); 255 + show('promptLogin() sent', null); 250 256 }; 251 257 252 258 if (window.Blento.getTheme().dark) {