| client implements), `packages/conformance/CLIENTS.md` (the conformance set), |
| 6 | `docs/tgw-format.md` (the message media). |
| 7 |
| 8 | ## a. Adopt the framework |
| 9 |
| 10 | - [ ] Pin the tag `v0.1.0`, never a branch ([integration.md, "Pinning a release"](integration.md#pinning-a-release)). |
| 11 | - [ ] Create one `WidgetHost` per widget on your platform; policy `strict` |
| 12 | (the default), `features` as the profile sets them, today `["webAnimations"]` |
| 13 | ([integration.md, "Policy and features"](integration.md#policy-and-features); the per-platform |
| 14 | API in [sdk-v1.md §4](sdk-v1.md#4-host-interface-per-platform)). |
| 15 | - [ ] `setVisible(false)` off screen, `setTheme` on theme change, `destroy()` on |
| 16 | recycle ([integration.md](integration.md)). |
| 17 |
| 18 | ## b. PoC on real messages (layer 233) from a test bot |
| 19 |
| 20 | - [ ] Render `messageMediaWidget`: inflate `payload` as **zlib (RFC 1950), not gzip**, no size limit |
| 21 | of your own ([tgw-format.md, "Inflating the payload"](tgw-format.md#inflating-the-payload), [integration.md, "The widget payload"](integration.md#the-widget-payload)). |
| 22 | - [ ] Enable rendering with your own platform/version flag; without it, and on |
| 23 | old layers, the message shows as unsupported media with its caption. |
| 24 | - [ ] Bubble sizing from the anchors: width 0 = the bubble's width, W = a fixed width in |
| 25 | [200, max]; height 0 = placeholder, then the content height in [50, 600] cached per |
| 26 | message, H = fixed clamp(H, 50, 600); hard clip at the bubble's height, no fullscreen |
| 27 | ([integration.md, "Bubble sizing"](integration.md#bubble-sizing), [sdk-v1.md §5.6](sdk-v1.md#56-bubble-size)). |
| 28 | - [ ] Taps only reach the widget; no keyboard input, no focus; text is not selectable |
| 29 | unless the widget sets `user-select: text`, and then it is selected the way your |
| 30 | client selects message text and copied with your copy command |
| 31 | ([integration.md, "Input"](integration.md#input), [sdk-v1.md §5.10](sdk-v1.md#510-text-selection-v011)). |
| 32 | - [ ] Off-screen pause: frames stop, timers at 1 Hz when the bubble leaves the screen. |
| 33 | - [ ] A killed widget keeps its last frame with the "Widget stopped" badge; the |
| 34 | bubble does not collapse ([sdk-v1.md §5.7](sdk-v1.md#57-failures-and-restarts-d22)). |
| 35 | - [ ] Caption as the preview text; the localized "Widget" stub without one. |
| 36 | - [ ] With no caption below the widget (none, or the caption shown above it, `invert_media`), the message |
| 37 | time over the widget's bottom corner on a backing (right, or left in a right-to-left interface), taps |
| 38 | on it yours; its band and corner as the host's `contentSafeArea` at creation, `setContentSafeArea` |
| 39 | only when the bubble's layout changes; with a caption below all 0 |
| 40 | ([integration.md, "The time over a widget with no caption below it"](integration.md#the-time-over-a-widget-with-no-caption-below-it), |
| 41 | [sdk-v1.md §5.12](sdk-v1.md#512-the-time-over-a-widget-with-no-caption-below-it-217)). `visual/17-time-corner`, |
| 42 | `corpus/safe-area`. |
| 43 | - [ ] A test bot sends widgets (≤ 4 KB compressed, every conformance widget included) to a |
| 44 | tester's private chat; forward them into the shared test channel (bots may send |
| 45 | widgets only to private chats). |
| 46 |
| 47 | ## c. SDK v1 |
| 48 |
| 49 | - [ ] Theme: the palette of the bubble the widget sits in (an outgoing bubble's when |
| 50 | the user sent or forwarded it), the button tokens and the text tokens into |
| 51 | `WidgetTheme`, updated on theme change; the widget view stays transparent over |
| 52 | the bubble, which is its canvas ([sdk-v1.md §5.1](sdk-v1.md#51-theme)). |
| 53 | - [ ] Text tokens (v0.1.1): `fontSize` follows the chat's text-size setting and |
| 54 | `setTheme` runs when the user changes it; `lineHeight` and `padding` match your |
| 55 | message text. `visual/14-unstyled-document` and `corpus/defaults` look like your |
| 56 | own messages ([sdk-v1.md §2.4](sdk-v1.md#24-the-renderers-defaults-the-root-the-text-button)). |
| 57 | - [ ] A native renderer (not a WebView) puts the profile's UA layer into its master CSS, |
| 58 | sets the theme variables on the root, propagates a body background to the whole |
| 59 | bubble and honours `user-select: text` (`docs/decisions.md`, "The renderer's |
| 60 | defaults", "Text selection"). |
| 61 | - [ ] Links: `openLink` / `openTelegramLink` only from a real tap; `openLink` with a |
| 62 | confirmation showing the full URL, then open; `openTelegramLink` straight into the |
| 63 | client's `t.me` handling, no confirmation of its own ([sdk-v1.md §5.2](sdk-v1.md#52-links)). |
| 64 | - [ ] Haptics with the rate limit ([sdk-v1.md §5.3](sdk-v1.md#53-haptics)). |
| 65 | - [ ] Storage per (account, chat, message id) on disk, preloaded at creation, |
| 66 | committed from `onStorageCommit`, deleted with the message, the chat, the |
| 67 | account and on "Clear cache" ([sdk-v1.md §5.4](sdk-v1.md#54-storage)). |
| 68 | - [ ] Gestures by the shared policy (v0.1.2): the bubble's recognizers driven by |
| 69 | `GestureArbiter` and the claim from `onGestureClaim` / `onGesture`; the menu, |
| 70 | swipe-to-reply and list scroll over elements that do not claim the press, the |
| 71 | widget's touch cancelled (`pointercancel`) when the bubble takes it; nothing taken |
| 72 | over `touch-action: none`; no double-tap reaction over the widget (double taps are |
| 73 | always the widget's); the leading 20 px never claimed |
| 74 | ([sdk-v1.md §5.5](sdk-v1.md#55-gestures-and-drag-d4); conformance `auto/23-gestures-a` / `-b`, |
| 75 | `visual/sdk/12-drag-gestures`). |
| 76 | - [ ] A widget stays stopped after 2 crashes in a row ([sdk-v1.md §5.7](sdk-v1.md#57-failures-and-restarts-d22)). |
| 77 | - [ ] A forwarded copy works like the original with its own, empty storage. The HTML |
| 78 | of a sent widget never changes: no edit replaces it (only the caption can be |
| 79 | edited), so there is no host to re-create for an edit. |
| 80 |
| 81 | ## d. The widget's state and requests |
| 82 |
| 83 | - [ ] Create the host with the message's chat state (`chat_data`) and shared state |
| 84 | (`public_data`) as `data` and the server's flags as `context`: `isCopy` = |
| 85 | `is_copy`, `canQuery` = `can_query`, |
| 86 | `backgroundQuery` = `background_query`, read from `messageMediaWidget`, never |
| 87 | derived; the chat type and the account's user id as `viewer` (the framework keeps it |
| 88 | from a widget without `can_query`) |
| 89 | ([integration.md, "The widget's state and requests"](integration.md#the-widgets-state-and-requests), |
| 90 | [sdk-v1.md §5.11](sdk-v1.md#511-the-widgets-state-requests-and-copies)). |
| 91 | - [ ] The network marker: a sign in the bubble, "a tap may send data to the bot's |
| 92 | server", exactly when the message has `can_query`; none without it, none on a |
| 93 | preview ([integration.md, "The network marker"](integration.md#the-widgets-state-and-requests)). |
| 94 | - [ ] `updateMessageWidgetData`: applied by its pts sequence (the account's in private |
| 95 | chats and basic groups; in a supergroup the channel's, through the usual edit of |
| 96 | channel posts), then `setData` with the full state on the live host; keep it with |
| 97 | the message. |
| 98 | - [ ] A shared widget (`widget_id` in the media) that watches (`onWatchPublicData` / |
| 99 | `watchesPublicData`): poll `messages.getWidgetPublicData` for one visible carrier per |
| 100 | id, one message per call with its last hash, again after the `period` each answer |
| 101 | carries (5–3600 s, 30 s by default, also before the first answer); a widget |
| 102 | that does not watch is never polled; apply a new |
| 103 | value with `setData` to every widget on screen with that id, forwards included. |
| 104 | Optionally cache the checked payload and the shared state per `widget_id`. |
| 105 | - [ ] `onRequest`: `messages.getBotWidgetQueryAnswer` with the widget's `data`; complete |
| 106 | once with `{ result }`, or `timeout` (`WIDGET_RESPONSE_TIMEOUT`), `rateLimited` |
| 107 | (`FLOOD_WAIT`), `failed` (anything else). Show nothing for an answer and do not |
| 108 | re-fetch the state after it. |
| 109 | - [ ] `onCopyText`: copy the text and show a toast with the text itself. |
| 110 | - [ ] Groups: widgets the bot sends to a group show and ask on a tap; via-bot results |
| 111 | are sent as widgets; forwarding a widget always keeps its author. |
| 112 | - [ ] Inline results: a widget result in the list (`botInlineMessageWidget`) is a preview |
| 113 | (`context.preview`, the result's state, `chat_data` / `public_data`, no flags, no marker): |
| 114 | no touches routed to it, a tap selects the result; the sent message gets a new |
| 115 | host ([sdk-v1.md §2.16](sdk-v1.md#216-previews)). |
| 116 |
| 117 | ## e. Test |
| 118 |
| 119 | - [ ] The conformance automatic set on your renderer, with the report |
| 120 | ([CLIENTS.md](../packages/conformance/CLIENTS.md)). |
| 121 | - [ ] The attack corpus (`corpus/attacks`): 0 leaks, 0 outside requests. |
| 122 | - [ ] The whole conformance set in the test channel as real layer-233 messages from |
| 123 | the test bot, in the order of `packages/conformance/channel.json`, each widget |
| 124 | with its reference picture posted next to it (`visual/` and `visual/sdk/`; |
| 125 | the automatic widgets report their own checks). Go through the visual ones with |
| 126 | the manual checklist: light and dark themes, rotation, system font size, an RTL |
| 127 | locale, reduce motion, bubble re-creation on scroll, forward, a caption edit. |
| 128 | - [ ] The widget's state and requests with a test bot: in the private chat (a tap, a |
| 129 | background request when the widget appears and every 5 s while it is on screen, |
| 130 | `editMessageWidgetData` without a restart, the network marker), a widget sent |
| 131 | without `allow_queries` (no requests, no marker), in a group (taps only, one |
| 132 | chat state for all members), a forward of a `fwd_allow_queries` widget (taps |
| 133 | only, no chat state, the marker), a forward without it (no requests, no marker), |
| 134 | a shared widget's shared state changing in the original and its forwards together. |
| 135 | - [ ] A feed bench on a low-end device: many widgets in a list, scroll, memory. |
| 136 |
| 137 | ## f. Send back |
| 138 |
| 139 | - [ ] The conformance report (`<platform>-<renderer>.json` and `summary.md`) and |
| 140 | every discrepancy you found, to the widget-sandbox maintainers or as a PR |
| 141 | into `packages/conformance/results/`. |
| 142 |