| The profile is the contract between widgets and clients: a feature is **in** when every client draws it the same way, and every client's |
| 6 | validator removes what is **out** before it reaches the renderer, so a widget looks the same on iOS, Android, macOS, desktop and the web. |
| 7 | The validator (`packages/core/src/host/validator.ts`, `css-sanitizer.ts`), the Swift node model (`NativeValidator`), the sandbox shim and |
| 8 | the renderer read their tables from this profile (`src/shared/profile-tables.ts`); `packages/conformance` checks a client against it. |
| 9 |
| 10 | ## Detecting the profile |
| 11 |
| 12 | - `TelegramWidget.profile` is `1`; `TelegramWidget.isProfileAtLeast(n)` is `profile >= n`. A later profile only adds features. |
| 13 | - `CSS.supports(property, value)` and `CSS.supports(condition)` answer from the profile: `true` only when the validator keeps the declaration as written. |
| 14 | - `@supports` is evaluated by the validator against the same tables: the block is kept (unwrapped) or dropped before the CSS reaches the renderer. |
| 15 | - A widget that checks nothing still loads; what is out is removed, as described in the tables below. |
| 16 |
| 17 | ## Decisions |
| 18 |
| 19 | | key | decision | |
| 20 | |---|---| |
| 21 | | D3 | A feature is in when every client draws it; :hover and user-select: text are the exceptions (progressive enhancement: where a client lacks them, the widget still works) | |
| 22 | | D3a | v1: canvas 2D; Web Animations, filter, backdrop-filter if clients draw them; out: forms, inner scroll, 3D transforms, magic move; CSS animations and transitions in | |
| 23 | | D3b | Fonts: system generic families only, other names dropped | |
| 24 | | D4 | Input: taps in the PoC, drag in v1; no keyboard at all, not even Enter or Space (it conflicts with the chat input field; Artem, 2026-10-16) | |
| 25 | | D5 | strict policy everywhere; webAnimations and morphUpdates from the profile | |
| 26 | | D6 | 3D (__tw3d) cut from the release | |
| 27 | | D8 | SDK outward: openLink (confirmed with the full URL) and openTelegramLink (no confirmation of its own, 2026-10-29) on a tap, haptics; no sendMessage | |
| 28 | | D11 | One widget model: classic DOM in the sandbox | |
| 29 | | D12a | Above the cap: hard clip, no fullscreen | |
| 30 | | D14 | Theme: themeParams + --tg-theme-*, theme change event | |
| 31 | | D17 | State: localStorage per (account, chat, message id): the chat the message is in, as message ids are unique only within a chat (supergroups); 4 KB, QuotaExceededError; sessionStorage in memory | |
| 32 | | D18 | Text is not selectable by default; a widget enables selection with user-select: text (2026-10-20, replaces "Text selection forbidden") | |
| 33 | | D20 | Mini-HTML (2026-10-17): a widget is one HTML document of at most 4 KB compressed and 32 KB uncompressed, delivered in the message; the server compresses the HTML from the bot (zlib at level 9 since 2026-10-24) and enforces both limits | |
| 34 | | D21 | No accessibility in v1 | |
| 35 | | D23 | Runtime profile detection: TelegramWidget.profile / isProfileAtLeast, CSS.supports and @supports from the profile | |
| 36 | | inv1 | Invariant 1: widget JS only in QuickJS | |
| 37 | | inv2 | Invariant 2: the host validates everything against the allowlists | |
| 38 | | inv4 | Invariant 4: only data: images, host blob: and #fragment URLs reach the renderer | |
| 39 | | inv5 | Invariant 5: no network in QuickJS | |
| 40 | | inv6 | Invariant 6: navigation cancelled, shadow scope | |
| 41 | | P1 | Profile v1 freeze (2026-10-17): a candidate is in when the corpus uses it and the web renderers draw it; the rest are out until the native renderers are measured (profile 2) | |
| 42 | | P1-grid | Grid is in on condition that the Swift renderer and TwidgetCore implement it before their releases (2026-10-17) | |
| 43 | | P1-libs | No bundled libraries in v1 (2026-10-17) | |
| 44 | | P1-ua | Clarified in v0.1.1 (2026-10-20): the renderer's user-agent layer (tables.uaStylesheet) also fixes the root and the text elements: the bubble's text colour (the bubble's own fill is the canvas behind a transparent renderer), the client's text tokens (--tg-text-font-size, --tg-text-line-height, --tg-text-padding as the body's margin) and explicit sizes and margins for headings, paragraphs, lists, tables, quotes and code, so a UA default in this profile means that layer, not an engine's own stylesheet | |
| 45 | | SDK | SDK v1 (docs/sdk-v1.md), with Artem's answers of 2026-10-17: haptics without a gesture (bucket 5, 10 per second), any t.me path, URLs of at most 256 characters, 16 handlers per event type, stopped after 2 crashes in a row, double tap and long press stay with the bubble (replaced by G1 in v0.1.2) | |
| 46 | | G1 | Gestures, v0.1.2 (Artem, 2026-10-22): one shared policy with the same thresholds on every client and in the sandbox. A double tap over the widget is always the widget's (both clicks and dblclick, on every element; the reaction stays with the bubble outside the widget). For the rest touch-action is the claim, decided per element at pointerdown over the target and its ancestors (a container covers its children, as in CSS): auto: holds and swipes are the bubble's (the widget gets pointercancel); pan-y / pan-x: drags on the other axis are the widget's; none: everything is the widget's, holds (contextmenu) included. The leading 20 px of the widget and the bubble outside it never take a claim. Replaces "double tap and long press stay with the bubble" (SDK) | |
| 47 | | G2 | Vertical drags are the chat's, v0.1.3 (Artem, 2026-10-24): a widget claims only horizontal drags; a vertical drag over a widget always scrolls the chat, whatever touch-action says, and the widget gets pointercancel. auto: holds and drags are the bubble's; pan-y: horizontal drags are the widget's; pan-x claims nothing; none: horizontal drags and holds (contextmenu) are the widget's. The axis lock (the first move past the 10 px slop decides for the whole press), double taps and the leading 20 px are unchanged. The engine under the renderer always allows vertical panning. Replaces G1's pan-x and the vertical half of none | |
| 48 | | R1 | Resize anchor, v0.1.3 (Artem, 2026-10-24): TelegramWidget.setResizeAnchor('top' \| 'bottom') says which edge of the bubble stays put on screen when the widget's height changes (top by default: it grows downward; bottom: it grows upward and the content above moves). An SDK v1 addition inside profile 1: TelegramWidget.profile stays 1 and widgets detect the method with typeof. It goes through the bridge as a checked call (sdk-policy, four copies and the fixture), needs no gesture, and the host keeps the latest value and reports it with the height; the client's list compensates its scroll | |
| 49 | | I1 | The bot's data and requests (Artem, 2026-10-25; the server's spec): a widget is fixed code plus changeable state: the HTML never changes after sending; the state changes, and only the bot writes it. TelegramWidget.chatData, the chat state (one original message, seen only in its chat: in a group every member sees it; never forwarded), and publicData, the shared state (wherever the widget is shown: a forward gets a copy, or shares a shared widget's one state with the original): each a text of up to 1024 bytes (UTF-8), read-only in the widget; chatDataChanged / publicDataChanged when they change (no restart). isForward, chatType and viewer (Mini Apps' WebAppUser: id, first_name, last_name, username, is_premium; a field that breaks its rule is left out); a forward is told nothing about the chat it is in (no chatType: the bot must not learn where its widget was forwarded), and the widget knows its viewer only where it may ask the bot (can_query), originals included. request(data of 1-64 bytes): a callback button inside the widget; where it may ask is the server's per message (can_query: originals of a widget sent with allow_queries, forwards of one sent with fwd_allow_queries; background_query: the original in the private chat with the bot); the client marks a widget with can_query as one whose tap may send data to the bot's server; on a tap, one per tap (shared with openLink, openTelegramLink and copyText); in the background while visible: one when the widget appears on screen, then one per 5 s; one in flight; resolves { result } (text of at most 1024 bytes), rejects with error.code; the answer does not change the state. copyText(text of 1-256 characters) on a tap; the client's toast shows what it copied. Part of SDK v1 and layer 233 from the launch, inside profile 1. TelegramWidget.isPreview: an inline result in the list before it is sent gets its state but no input, no bridge call but ready and setResizeAnchor, no chat type or viewer, and Web Storage that is never committed. The checks are sdk-policy (four copies and the fixture) | |
| 50 | | L1 | Strict limits from the start (2026-10-29): about twice what real widgets use; past a counted cap the widget stops (docs/decisions.md) | |
| 51 | | L2 | Heavy boxes (Artem, 2026-11-02, after the client teams' stress-kit runs on five devices): at most 16 heavy boxes at once (a blurred box-shadow layer, a filter, a backdrop-filter, opacity below 1 but a disabled or pressed <button>'s, or a running animation of filter, backdrop-filter or opacity, or of box-shadow through a blurred layer), of them at most 2 with backdrop-filter; every renderer counts on the computed style (packages/core/src/shared/paint-policy.ts and its fixture) and past either the widget stops. A tightening of profile 1 (widgets were not launched yet), not profile 2 | |
| 52 | | P1-safe-area | Clarified on 2026-10-29 (Artem; widgets were not launched yet), not profile 2: a client draws the message time and its status over the bottom corner of a widget with no caption below it, as on a photo (with a caption below the time is in the caption's line and nothing is drawn over the widget; a caption shown above the widget, invert_media, is as none: Artem's decision of 2026-10-30). env(safe-area-inset-top\|right\|bottom\|left[, fallback]) is in: the validator rewrites it to var(--tg-content-safe-area-inset-…[, fallback]), root variables the renderer sets like the theme's (bottom = the height of the time's band, the others 0), with --tg-content-safe-area-corner-left\|right for the width of the client's corner in that band (a physical side: right in a left-to-right interface, left in a right-to-left one); 0 with a caption below. Another env() name resolves to its fallback or drops the declaration. The UA layer adds the band to the body's bottom padding, and TelegramWidget.contentSafeAreaInset with the contentSafeAreaChanged event gives the same numbers to script | |
| 53 |
| 54 | ## HTML elements and attributes |
| 55 |
| 56 | | id | feature | status | when out | decision | |
| 57 | |---|---|---|---|---| |
| 58 | | `html.el.structure` | div, span, p, br, hr, wbr | in | | D3a | |
| 59 | | `html.el.headings` | h1–h6 with UA default sizes and margins | in | | D3a | |
| 60 | | `html.el.sections` | header, footer, main, nav, section, article, aside, hgroup, search, address | in | | D3a | |
| 61 | | `html.el.inline-text` | Inline text semantics with UA styles: b, i, u, s, em, strong, small, mark, code, kbd, samp, var, abbr, cite, q, del, ins, dfn, time, data | in | | D3a | |
| 62 | | `html.el.sub-sup` | sub, sup (baseline shift, smaller size) | in | | D3a | |
| 63 | | `html.el.pre` | pre (monospace, preserved white space and line breaks) | in | | D3a | |
| 64 | | `html.el.blockquote` | blockquote, figure, figcaption (UA indents) | in | | D3a | |
| 65 | | `html.el.lists` | ul, ol, li, dl, dt, dd, menu with markers | in | | D3a | |
| 66 | | `html.el.table` | table, thead, tbody, tfoot, tr, td, th, caption, colgroup, col; colspan/rowspan | in | | D3a | |
| 67 | | `html.el.ruby` | ruby, rt, rp, bdi, bdo | **out** | rendered as <span> (the annotation shows inline) | P1 | |
| 68 | | `html.el.legacy` | Legacy presentational elements: center, font, big, tt, strike, nobr | **out** | <center> becomes a <div>, the others a <span>; the presentational attributes are dropped | P1 | |
| 69 | | `html.el.img` | <img> with a data: PNG, JPEG, GIF or WebP; width/height attributes | in | | D3a | |
| 70 | | `html.el.img-svg` | <img src="data:image/svg+xml"> | **out** | url-policy refuses the MIME: placeholder image | P1 | |
| 71 | | `html.el.img-other-formats` | <img> with data: AVIF, BMP, ICO | **out** | url-policy refuses the MIME: placeholder image | P1 | |
| 72 | | `html.el.img-remote` | <img src="https://…"> (any non-data: URL) | **out** | placeholder image; no request | inv4 | |
| 73 | | `html.el.canvas` | <canvas> element (2D context through the command stream) | in | | D3a | |
| 74 | | `html.el.button` | <button> as a tappable box with UA look | in | | D4 | |
| 75 | | `html.el.details` | details/summary: open state and toggle on tap | in | | P1 | |
| 76 | | `html.el.a-fragment` | <a href="#id">: no navigation, :target-free | in | | P1 | |
| 77 | | `html.el.a-external` | <a href="https://…">: href becomes "#" + data-tg-link, the tap goes to openLink (with a gesture) | in | | D8 | |
| 78 | | `html.el.forms` | Form controls: form, input (all types), select, option, optgroup, textarea, label, fieldset, legend, datalist, output | **out** | controls are dropped with their subtree (input, select, option, optgroup, textarea, datalist, fieldset, progress, meter); <form> becomes a <div>, <label>, <legend> and <output> a <span> | D3a | |
| 79 | | `html.el.progress-meter` | progress, meter (native gauges) | **out** | dropped with the subtree, like the other controls | P1 | |
| 80 | | `html.el.dialog-popover` | dialog (show/showModal), popover attribute | **out** | a dialog renders as a <div>; the popover attributes and the dialog and popover methods are dropped | P1 | |
| 81 | | `html.el.unknown` | Unknown / custom elements render as an inert <span data-tg-tag> | in | | P1 | |
| 82 | | `html.el.media` | audio, video, source, track | **out** | dropped with the subtree | P1 | |
| 83 | | `html.el.embedding` | script (as DOM), iframe, frame, object, embed, link, meta, base, portal, template, slot, math, fencedframe, … | **out** | dropped with the subtree | inv2 | |
| 84 | | `html.attr.global` | class, id, title, hidden, lang, style attribute | in | | D3a | |
| 85 | | `html.attr.dir` | dir="rtl" / dir="auto": bidi layout | in | | D3a | |
| 86 | | `html.attr.data-aria` | data-* and aria-* attributes (selectors, attr()); no a11y semantics in v1 | in | | D21 | |
| 87 | | `html.attr.legacy-presentational` | align, valign, bgcolor, border, cellpadding, cellspacing, color, face, nowrap | **out** | the attributes are dropped | P1 | |
| 88 | | `html.attr.event-handlers` | Inline on* handler attributes (run inside QuickJS, never reach the renderer) | in | | P1 | |
| 89 | | `html.attr.contenteditable` | contenteditable, spellcheck, inputmode, enterkeyhint, autocapitalize | **out** | drop the attribute | P1 | |
| 90 | | `html.attr.draggable` | draggable (HTML drag and drop) | **out** | drop the attribute; drag in v1 is pointer events | D4 | |
| 91 | | `html.attr.tabindex` | tabindex, autofocus, accesskey (keyboard focus and shortcuts) | **out** | drop the attributes (no keyboard: D4) | D4 | |
| 92 |
| 93 | ## Inline SVG |
| 94 |
| 95 | | id | feature | status | when out | decision | |
| 96 | |---|---|---|---|---| |
| 97 | | `svg.shapes` | Inline <svg>: rect, circle, ellipse, line, polyline, polygon, path with presentation attributes | in | | D3a | |
| 98 | | `svg.structure` | g, defs, symbol, use (fragment href), transform attribute, viewBox/preserveAspectRatio | in | | D3a | |
| 99 | | `svg.text` | SVG text, tspan | in | | D3a | |
| 100 | | `svg.gradients` | linearGradient, radialGradient, stop; fill="url(#id)" | in | | P1 | |
| 101 | | `svg.css` | CSS on inline SVG: fill/stroke from a stylesheet rule, :hover, CSS animation of SVG properties | in | | P1 | |
| 102 | | `svg.clip-mask` | clipPath, mask, pattern, marker | **out** | the elements are dropped with their subtree; clip-path, mask and marker attributes are dropped | P1 | |
| 103 | | `svg.filters` | SVG filter primitives (fe*) | **out** | filter and the fe* elements are dropped with their subtree; the filter attribute is dropped | P1 | |
| 104 | | `svg.smil` | SMIL animation: animate, animateTransform, animateMotion | **out** | animate, animateTransform, animateMotion and mpath are dropped | P1 | |
| 105 | | `svg.foreign-object` | foreignObject (HTML inside SVG) | **out** | drop the subtree | P1 | |
| 106 | | `svg.image` | <image href="data:…"> inside SVG | **out** | dropped | P1 | |
| 107 |
| 108 | ## CSS |
| 109 |
| 110 | | id | feature | status | when out | decision | |
| 111 | |---|---|---|---|---| |
| 112 | | `css.display.basic` | display: block, inline, inline-block, none | in | | D3a | |
| 113 | | `css.display.flex` | Flexbox: display flex/inline-flex, direction, wrap, justify-content, align-items/self/content, flex grow/shrink/basis, order | in | | D3a | |
| 114 | | `css.gap.flex` | gap / row-gap / column-gap in flex containers | in | | D3a | |
| 115 | | `css.display.grid` | CSS grid: display grid, grid-template-*, grid-area/column/row, auto-flow, place-* | in | | P1-grid | |
| 116 | | `css.display.table` | display: table / table-row / table-cell | in | | D3a | |
| 117 | | `css.display.other` | display: flow-root, contents, list-item | **out** | the declaration is dropped | P1 | |
| 118 | | `css.box.size` | width, height, min-/max-width/height (px, %, auto, fit-content, min/max-content) | in | | D3a | |
| 119 | | `css.box.spacing` | margin, padding (incl. auto margins and negative margins) | in | | D3a | |
| 120 | | `css.box.border` | border width/style/colour (solid, dashed, dotted, double) | in | | D3a | |
| 121 | | `css.box.radius` | border-radius, including clipping of the background | in | | D3a | |
| 122 | | `css.box.sizing` | box-sizing: border-box / content-box | in | | D3a | |
| 123 | | `css.box.aspect-ratio` | aspect-ratio | in | | D3a | |
| 124 | | `css.box.logical` | Logical properties: margin-inline, padding-block, inset-inline, inline-size, … | **out** | the declaration is dropped | P1 | |
| 125 | | `css.box.outline` | outline (width, style, colour, offset) | in | | D3a | |
| 126 | | `css.box.shadow` | box-shadow (outer, inset, spread, several layers) | in | | D3a | |
| 127 | | `css.box.float` | float, clear | in | | D3a | |
| 128 | | `css.box.columns` | Multi-column layout (columns, column-count, column-gap) | **out** | the declaration is dropped | P1 | |
| 129 | | `css.box.object-fit` | object-fit, object-position on <img> | in | | P1 | |
| 130 | | `css.position.relative-absolute` | position: relative / absolute with inset, top/right/bottom/left | in | | D3a | |
| 131 | | `css.position.fixed` | position: fixed (relative to the bubble, never the chat) | in | | P1 | |
| 132 | | `css.position.sticky` | position: sticky | **out** | becomes relative (no scrolling inside a widget) | P1 | |
| 133 | | `css.position.z-index` | z-index and stacking order | in | | D3a | |
| 134 | | `css.overflow.clip` | overflow: hidden / clip clips the content (with border-radius) | in | | D3a | |
| 135 | | `css.overflow.scroll` | overflow: auto / scroll (scrolling inside the widget) | **out** | becomes hidden: the box clips, no scrollbar, no scroll gesture | D3a | |
| 136 | | `css.visibility` | visibility: hidden / visible | in | | D3a | |
| 137 | | `css.opacity` | opacity | in | | D3a | |
| 138 | | `css.color.basic` | Colours: named, #hex (3/4/6/8), rgb()/rgba(), hsl()/hsla(), transparent, currentColor | in | | D3a | |
| 139 | | `css.color.modern` | Colour functions: hwb(), lab(), lch(), oklab(), oklch(), color() | **out** | the declaration is dropped (an earlier fallback declaration applies) | P1 | |
| 140 | | `css.color.mix` | color-mix() | **out** | the declaration is dropped | P1 | |
| 141 | | `css.color.light-dark` | light-dark() and color-scheme: light dark, resolved to the chat theme | in | | P1 | |
| 142 | | `css.background.basic` | background-color, background-image: url(data:…), background-size/position/repeat, several layers | in | | D3a | |
| 143 | | `css.background.clip-text` | background-clip: text (gradient text) | **out** | the declaration is dropped | P1 | |
| 144 | | `css.gradient.linear` | linear-gradient(), repeating-linear-gradient() | in | | D3a | |
| 145 | | `css.gradient.radial` | radial-gradient(), repeating-radial-gradient() | in | | D3a | |
| 146 | | `css.gradient.conic` | conic-gradient() | in | | P1 | |
| 147 | | `css.url.remote` | url() / image-set() with anything but a data: image or #fragment | **out** | the declaration is dropped | inv4 | |
| 148 | | `css.font.generic` | font-family with system generic families: system-ui, sans-serif, serif, monospace | in | | D3b | |
| 149 | | `css.font.ui-families` | font-family: ui-sans-serif, ui-serif, ui-monospace, ui-rounded | in | | P1 | |
| 150 | | `css.font.named` | font-family naming a font ("Helvetica", "Courier New", "Comic Sans MS", …) | **out** | the validator drops non-generic names from the list; -apple-system and BlinkMacSystemFont, the vendor names of the system UI font, become system-ui; an empty list falls back to the default (system-ui) | D3b | |
| 151 | | `css.font.face` | @font-face (web fonts) | **out** | the at-rule is dropped | D3b | |
| 152 | | `css.font.basic` | font-size, font-weight (100–900, bold), font-style italic, line-height, font shorthand | in | | D3a | |
| 153 | | `css.font.variant-numeric` | font-variant-numeric: tabular-nums (and font-feature-settings "tnum") | in | | P1 | |
| 154 | | `css.text.align` | text-align (left, right, center, justify, start, end), text-indent | in | | D3a | |
| 155 | | `css.text.decoration` | text-decoration (underline, line-through, overline; colour, style, thickness) | in | | D3a | |
| 156 | | `css.text.transform` | text-transform, letter-spacing, word-spacing | in | | D3a | |
| 157 | | `css.text.white-space` | white-space: normal, nowrap, pre, pre-wrap, pre-line | in | | D3a | |
| 158 | | `css.text.wrap` | overflow-wrap / word-break (breaking long words) | in | | D3a | |
| 159 | | `css.text.overflow` | text-overflow: ellipsis (single line) | in | | P1 | |
| 160 | | `css.text.line-clamp` | -webkit-line-clamp / line-clamp (multi-line ellipsis) | **out** | the declaration is dropped | P1 | |
| 161 | | `css.text.shadow` | text-shadow | **out** | the declaration is dropped | P1 | |
| 162 | | `css.text.vertical-align` | vertical-align (baseline, middle, top, sub, super, lengths) | in | | D3a | |
| 163 | | `css.text.list-style` | list-style-type / position (disc, decimal, none, …) | in | | D3a | |
| 164 | | `css.text.writing-mode` | writing-mode, text-orientation (vertical text) | **out** | the declaration is dropped | P1 | |
| 165 | | `css.text.rtl` | Right-to-left and bidi text (direction, unicode-bidi, Hebrew/Arabic shaping) | in | | D3a | |
| 166 | | `css.text.emoji` | Colour emoji glyphs (system emoji font) | in | | D3a | |
| 167 | | `css.text.selection` | Text selection: not selectable by default; user-select: text (or -webkit-user-select) enables it (none \| text \| auto) | in | | D18 | |
| 168 | | `css.transform.2d` | 2D transforms: translate, rotate, scale, skew, matrix; transform-origin; the translate/rotate/scale properties | in | | D3a | |
| 169 | | `css.transform.3d` | 3D transforms: rotateX/Y/3d, translateZ/3d, scaleZ/3d, matrix3d, perspective, transform-style, backface-visibility | **out** | a transform with a 3D function is dropped; perspective, transform-style and backface-visibility are dropped | D3a | |
| 170 | | `css.filter.blur-brightness-drop-shadow` | filter: blur(), brightness(), drop-shadow() | in (if every client draws it) | | D3a | |
| 171 | | `css.filter.other` | filter: grayscale(), sepia(), saturate(), contrast(), hue-rotate(), invert(), opacity() | **out** | the function is removed from the filter list; an empty list drops the declaration | P1 | |
| 172 | | `css.filter.url` | filter: url(#svg-filter) | **out** | the declaration is dropped | P1 | |
| 173 | | `css.backdrop-filter` | backdrop-filter: blur(), brightness() | in (if every client draws it) | | D3a | |
| 174 | | `css.blend` | mix-blend-mode, isolation, background-blend-mode | **out** | the declaration is dropped | P1 | |
| 175 | | `css.clip-path` | clip-path: inset(), circle(), ellipse(), polygon() | **out** | the declaration is dropped | P1 | |
| 176 | | `css.mask` | mask / -webkit-mask with gradients or data: images | **out** | the declaration is dropped | P1 | |
| 177 | | `css.pointer-events` | pointer-events: none / auto (hit testing passes through) | in | | P1 | |
| 178 | | `css.touch-action` | touch-action: none / pan-y (the widget claims horizontal drags from the chat; vertical drags are always the chat's) | in | | P1 | |
| 179 | | `css.cursor` | cursor (desktop only) | in | | D3 | |
| 180 | | `css.value.units` | Units px, em, rem, %, ch, ex; pt/cm/mm/in | in | | D3a | |
| 181 | | `css.value.vw` | vw / vmin / vmax / vi: the bubble width | in | | P1 | |
| 182 | | `css.value.vh` | vh / dvh / svh / vb: height-relative units | **out** | the declaration is dropped | P1 | |
| 183 | | `css.value.math` | calc(), min(), max(), clamp() | in | | D3a | |
| 184 | | `css.value.custom-properties` | Custom properties and var() with fallbacks; inheritance | in | | D3a | |
| 185 | | `css.value.keywords` | inherit, initial, unset, revert; !important | in | | D3a | |
| 186 | | `css.value.content` | content in ::before/::after: strings, attr(data-*), counters | in | | D3a | |
| 187 | | `css.value.env` | env() (safe-area-inset-*, …) | in | | P1-safe-area | |
| 188 |
| 189 | ## Selectors |
| 190 |
| 191 | | id | feature | status | when out | decision | |
| 192 | |---|---|---|---|---| |
| 193 | | `sel.basic` | Type, class, id, universal and attribute selectors; descendant, child, + and ~ combinators; selector lists | in | | D3a | |
| 194 | | `sel.structural` | :first-child, :last-child, :nth-child(), :nth-last-child(), :nth-of-type(), :only-child, :empty, :not() | in | | D3a | |
| 195 | | `sel.is-where` | :is(), :where() | in | | D3a | |
| 196 | | `sel.has` | :has() | **out** | the selector never matches (dropped from its list) | P1 | |
| 197 | | `sel.root` | :root (custom properties on the widget root) | in | | D3a | |
| 198 | | `sel.before-after` | ::before, ::after | in | | D3a | |
| 199 | | `sel.first-letter-line` | ::first-letter, ::first-line, ::marker | **out** | the selector never matches (dropped from its list) | P1 | |
| 200 | | `sel.hover` | :hover (progressive enhancement: desktop with a pointer; no-op on touch) | in | | D3 | |
| 201 | | `sel.active` | :active (pressed feedback while a tap is down) | in | | P1 | |
| 202 | | `sel.focus` | :focus, :focus-visible, :focus-within | **out** | the selector never matches (dropped from its list); the widget never owns keyboard focus | D4 | |
| 203 | | `sel.form-state` | :checked, :disabled, :enabled, :valid, :invalid, :placeholder-shown, ::placeholder | **out** | :disabled and :enabled become [disabled] and :not([disabled]) (the <button> state); the other form states never match | D3a | |
| 204 | | `sel.host-scoped` | :host, :host-context(), ::slotted(), ::part(), :scope | **out** | the selector never matches (dropped from its list) on every renderer | inv6 | |
| 205 | | `sel.target` | :target | **out** | the selector never matches (dropped from its list) | P1 | |
| 206 |
| 207 | ## At-rules |
| 208 |
| 209 | | id | feature | status | when out | decision | |
| 210 | |---|---|---|---|---| |
| 211 | | `at.media.width` | @media (min-width/max-width/orientation): the bubble width | in | | D3a | |
| 212 | | `at.media.color-scheme` | @media (prefers-color-scheme): the chat theme, live on theme change | in | | D14 | |
| 213 | | `at.media.reduced-motion` | @media (prefers-reduced-motion) | in | | P1 | |
| 214 | | `at.media.hover-pointer` | @media (hover: hover), (pointer: fine\|coarse) | **out** | the @media rule is dropped; matchMedia answers false | P1 | |
| 215 | | `at.media.other` | @media print, resolution, other media features | **out** | the @media rule is dropped; matchMedia answers false | P1 | |
| 216 | | `at.supports` | @supports evaluated from the profile tables (not the renderer engine) | in | | D23 | |
| 217 | | `at.keyframes` | @keyframes (and -webkit-keyframes) | in | | D3a | |
| 218 | | `at.import-namespace` | @import, @namespace | **out** | dropped | inv4 | |
| 219 | | `at.container` | @container queries (container-type in the widget) | **out** | the at-rule is dropped; container properties are dropped | P1 | |
| 220 | | `at.layer` | @layer cascade layers | **out** | the at-rule is dropped with its rules | P1 | |
| 221 | | `at.property` | @property (typed custom properties) | **out** | the at-rule is dropped | P1 | |
| 222 | | `at.exotic` | @counter-style, @starting-style, @scope, @page, @font-feature-values, @font-palette-values, @position-try | **out** | dropped like unknown at-rules | P1 | |
| 223 | | `at.nesting` | CSS nesting (.a { .b { } }, &) | **out** | nested rules are dropped with a css-dropped diagnostic | P1 | |
| 224 |
| 225 | ## Animation |
| 226 |
| 227 | | id | feature | status | when out | decision | |
| 228 | |---|---|---|---|---| |
| 229 | | `anim.transition` | CSS transitions (property, duration, delay incl. negative, timing functions) | in | | D3a | |
| 230 | | `anim.keyframes` | CSS animations: animation-name/duration/delay/iteration-count/direction/fill-mode/timing-function | in | | D3a | |
| 231 | | `anim.play-state` | animation-play-state: paused (and negative delays) freeze a frame | in | | D3a | |
| 232 | | `anim.easing` | Timing functions: ease*, linear, cubic-bezier(), steps(), linear() stops | in | | D3a | |
| 233 | | `anim.events` | animationstart/end/iteration and transitionend events reach the widget | in | | D3a | |
| 234 | | `anim.waapi` | Web Animations: Element.animate, getAnimations, Animation play/pause/currentTime/finished, document.timeline | in (if every client draws it) | | D3a | |
| 235 | | `anim.waapi-css-control` | Web Animations control of CSS animations/transitions (pause, seek, cancel via getAnimations) | in (if every client draws it) | | D3a | |
| 236 | | `anim.magic-move` | Magic move (shared-element morph between renders) | **out** | not offered (it belonged to the render() model) | D3a | |
| 237 |
| 238 | ## Canvas 2D |
| 239 |
| 240 | | id | feature | status | when out | decision | |
| 241 | |---|---|---|---|---| |
| 242 | | `canvas.rect` | fillRect, strokeRect, clearRect | in | | D3a | |
| 243 | | `canvas.path` | Paths: beginPath, moveTo, lineTo, arc, arcTo, bezierCurveTo, quadraticCurveTo, ellipse, rect, roundRect, closePath, fill (nonzero/evenodd), stroke | in | | D3a | |
| 244 | | `canvas.line-style` | lineWidth, lineCap, lineJoin, miterLimit, setLineDash, lineDashOffset | in | | D3a | |
| 245 | | `canvas.colors` | fillStyle / strokeStyle with CSS colours | in | | D3a | |
| 246 | | `canvas.gradients` | createLinearGradient, createRadialGradient, addColorStop | in | | D3a | |
| 247 | | `canvas.conic-gradient` | createConicGradient | **out** | createConicGradient returns a gradient that draws nothing | P1 | |
| 248 | | `canvas.pattern` | createPattern from a canvas or image | **out** | createPattern returns a pattern that draws nothing | P1 | |
| 249 | | `canvas.transform` | save, restore, translate, rotate, scale, transform, setTransform, resetTransform | in | | D3a | |
| 250 | | `canvas.clip` | clip() with a path | in | | D3a | |
| 251 | | `canvas.text` | fillText, strokeText, font, textAlign, textBaseline, measureText | in | | D3a | |
| 252 | | `canvas.alpha` | globalAlpha | in | | D3a | |
| 253 | | `canvas.composite` | globalCompositeOperation (source-over, destination-out, multiply, …) | **out** | the property is not applied (source-over) | P1 | |
| 254 | | `canvas.shadow` | shadowBlur, shadowColor, shadowOffsetX/Y | **out** | the properties are not applied | P1 | |
| 255 | | `canvas.filter` | ctx.filter (CSS filter on canvas drawing) | **out** | the property is not applied | P1 | |
| 256 | | `canvas.path2d` | Path2D objects (from SVG path data or built), fill/stroke/clip with them | in | | D3a | |
| 257 | | `canvas.draw-image` | drawImage from an <img> (data:) or another canvas | in | | D3a | |
| 258 | | `canvas.image-data` | getImageData / putImageData / createImageData (pixel read-back) | **out** | getImageData returns transparent pixels, putImageData draws nothing | P1 | |
| 259 | | `canvas.hit-test` | isPointInPath / isPointInStroke | in | | P1 | |
| 260 | | `canvas.hidpi` | Backing store sized by width/height attributes, CSS size independent (devicePixelRatio scaling) | in | | D3a | |
| 261 | | `canvas.readback` | toDataURL, toBlob, captureStream | **out** | toBlob/captureStream are stubs; toDataURL returns an empty image (data:,) | P1 | |
| 262 | | `canvas.webgl` | WebGL, OffscreenCanvas, bitmaprenderer contexts | **out** | getContext returns null; OffscreenCanvas throws | D6 | |
| 263 |
| 264 | ## JavaScript runtime |
| 265 |
| 266 | | id | feature | status | when out | decision | |
| 267 | |---|---|---|---|---| |
| 268 | | `js.dom.core` | DOM building: createElement(NS), append/insertBefore/remove, textContent, innerHTML (parsed in the sandbox), attributes, classList, dataset | in | | D11 | |
| 269 | | `js.dom.query` | querySelector(All), getElementById, getElementsBy*, closest, matches | in | | D11 | |
| 270 | | `js.dom.style` | element.style (CSSOM properties, setProperty, cssText), className | in | | D11 | |
| 271 | | `js.dom.events` | addEventListener (capture and bubble), dispatchEvent of CustomEvent, preventDefault, stopPropagation | in | | D11 | |
| 272 | | `js.layout.rect` | getBoundingClientRect, getClientRects (answered by the renderer) | in | | P1 | |
| 273 | | `js.layout.box` | offsetWidth/Height/Top/Left, clientWidth/Height, scrollWidth/Height | in | | P1 | |
| 274 | | `js.layout.computed-style` | getComputedStyle (incl. pseudo-elements and custom properties) | in | | P1 | |
| 275 | | `js.layout.match-media` | matchMedia (prefers-color-scheme answered from the chat theme) | in | | P1 | |
| 276 | | `js.layout.resize-observer` | ResizeObserver | in | | P1 | |
| 277 | | `js.layout.intersection-observer` | IntersectionObserver (emulated: always visible) | in | | P1 | |
| 278 | | `js.layout.element-from-point` | document.elementFromPoint | in | | P1 | |
| 279 | | `js.layout.measure-text` | Text measurement through canvas measureText (fonts of the client) | in | | P1 | |
| 280 | | `js.focus` | element.focus() / blur() / select(), document.activeElement: the widget takes keyboard focus | **out** | focus(), blur(), select() and setSelectionRange() do nothing; no call op reaches the renderer | D4 | |
| 281 | | `js.timers` | setTimeout / setInterval / clear*, ordering, clamped delays | in | | P1 | |
| 282 | | `js.raf` | requestAnimationFrame / cancelAnimationFrame (frames from the renderer) | in | | P1 | |
| 283 | | `js.microtasks` | Promise, async/await, queueMicrotask | in | | P1 | |
| 284 | | `js.storage.local` | localStorage: per (account, chat, message), preloaded, 4 KB, QuotaExceededError past it | in | | D17 | |
| 285 | | `js.storage.session` | sessionStorage: same key, in memory until app restart | in | | D17 | |
| 286 | | `js.intl` | Intl.NumberFormat, DateTimeFormat, PluralRules, RelativeTimeFormat, ListFormat, Collator (host ICU) | in | | P1 | |
| 287 | | `js.intl.format-to-parts` | Intl.NumberFormat/DateTimeFormat formatToParts | in | | P1 | |
| 288 | | `js.locale` | navigator.language reflects the client locale | in | | P1 | |
| 289 | | `js.crypto-random` | crypto.getRandomValues, crypto.randomUUID, Math.random | in | | P1 | |
| 290 | | `js.builtins` | TextEncoder/TextDecoder, URL, URLSearchParams, structuredClone, AbortController, atob/btoa | in | | P1 | |
| 291 | | `js.eval` | eval / new Function inside QuickJS (never in a browser context) | in | | inv1 | |
| 292 | | `js.css-supports` | CSS.supports() answered from the profile tables | in | | D23 | |
| 293 | | `js.visibility` | document.hidden / visibilityState / visibilitychange when the bubble leaves the screen | in | | P1 | |
| 294 | | `js.libraries` | Bundled libraries by CDN name: Chart.js 4, D3 7 (nothing is fetched) | **out** | nothing is bundled: a <script src> to a CDN is an external script like any other and is not run | P1-libs | |
| 295 | | `js.network` | fetch, XMLHttpRequest, WebSocket, EventSource, RTCPeerConnection, sendBeacon, importScripts, Worker, BroadcastChannel | **out** | NetworkDisabledError (fetch rejects with it) | inv5 | |
| 296 | | `js.navigation` | location assignment, history, window.open (→ openLink), form submission | **out** | navigation never happens; window.open goes through openLink | inv6 | |
| 297 | | `js.dialogs` | alert, confirm, prompt, print | **out** | non-blocking stubs: confirm → false, prompt → null | P1 | |
| 298 | | `js.device` | clipboard, share, vibrate, geolocation, mediaDevices, Notification | **out** | rejected promises / undefined; haptics come from the SDK | D8 | |
| 299 | | `js.shadow-dom` | attachShadow, customElements.define | **out** | attachShadow throws NotSupportedError, customElements.define is a no-op | P1 | |
| 300 | | `js.blob-file` | Blob, FileReader, URL.createObjectURL | **out** | inert stubs | inv4 | |
| 301 | | `js.fullscreen` | requestFullscreen | **out** | rejects | D12a | |
| 302 |
| 303 | ## TelegramWidget (SDK v1) |
| 304 |
| 305 | | id | feature | status | when out | decision | |
| 306 | |---|---|---|---|---| |
| 307 | | `tw.ready` | TelegramWidget.ready() | in | | D8 | |
| 308 | | `tw.theme` | TelegramWidget.theme and onTheme(cb): "light" \| "dark", called on change | in | | D14 | |
| 309 | | `tw.theme-params` | themeParams palette and --tg-theme-* CSS variables, theme change event | in | | D14 | |
| 310 | | `tw.open-link` | openLink(url): https only, in the task of a real tap, confirmed by the client with the full URL | in | | D8 | |
| 311 | | `tw.open-telegram-link` | openTelegramLink(url) for t.me links | in | | D8 | |
| 312 | | `tw.haptic` | Haptic feedback, rate-limited | in | | D8 | |
| 313 | | `tw.profile` | TelegramWidget.profile (integer) and isProfileAtLeast(n) | in | | D23 | |
| 314 | | `tw.send-message` | TelegramWidget.sendMessage | **out** | removed from the SDK | D8 | |
| 315 | | `tw.events` | onEvent / offEvent for themeChanged, activated, deactivated; at most 16 handlers per event type | in | | SDK | |
| 316 | | `tw.is-active` | TelegramWidget.isActive mirrors visibility (activated / deactivated) | in | | SDK | |
| 317 | | `tw.content-safe-area` | TelegramWidget.contentSafeAreaInset { top, right, bottom, left, cornerLeft, cornerRight } (logical px, frozen, a fresh object per change) and contentSafeAreaChanged, with the --tg-content-safe-area-inset-* / -corner-left\|right variables on the root, updated in one task | in | | P1-safe-area | |
| 318 | | `tw.resize-anchor` | TelegramWidget.setResizeAnchor('top' \| 'bottom'): the edge of the bubble that stays put when the widget's height changes | in | | R1 | |
| 319 | | `tw.bot-data` | TelegramWidget.chatData and publicData: the widget's chat state and shared state, which only the bot writes (read-only, null for none, each a text of up to 1024 bytes in UTF-8); chatDataChanged / publicDataChanged when they change | in | | I1 | |
| 320 | | `tw.context` | TelegramWidget.isForward, chatType and viewer (a WebAppUser): a forwarded copy, the kind of chat, who looks; no chatType in a forward, no viewer where the widget may not ask the bot | in | | I1 | |
| 321 | | `tw.request` | TelegramWidget.request(data): a callback button inside the widget; data of 1-64 bytes, resolves { result } (text of at most 1024 bytes), rejects with error.code; where it may ask is the server's flag per message | in | | I1 | |
| 322 | | `tw.copy-text` | TelegramWidget.copyText(text): copies 1-256 characters on a tap; the client's toast shows the copied text | in | | I1 | |
| 323 | | `tw.watch-public-data` | TelegramWidget.watchPublicData() / unwatchPublicData(): the widget asks to follow its shared state live; the client polls a shared widget's shared state (public_data) only while it watches and is on screen | in | | I1 | |
| 324 | | `tw.preview` | TelegramWidget.isPreview: an inline result shown in the list before it is sent | in | | I1 | |
| 325 |
| 326 | ## Input |
| 327 |
| 328 | | id | feature | status | when out | decision | |
| 329 | |---|---|---|---|---| |
| 330 | | `input.tap` | Tap: click on the element under the finger, with clientX/Y and target | in | | D4 | |
| 331 | | `input.pointer` | pointerdown / pointerup / pointercancel with coordinates, pointerId, pointerType, isPrimary | in | | D4 | |
| 332 | | `input.mouse-compat` | mousedown / mouseup compatibility events of a tap | in | | D4 | |
| 333 | | `input.touch-events` | touchstart / touchmove / touchend (touch clients only) | **out** | the renderer never forwards touch events; use pointer events | D4 | |
| 334 | | `input.drag` | Drag: pointermove with buttons while pressed, setPointerCapture, movementX/Y | in | | D4 | |
| 335 | | `input.hover-events` | pointerover/enter/leave/out, mouseover/enter/leave (desktop pointer only) | in | | D3 | |
| 336 | | `input.dblclick` | dblclick: a double tap over the widget is always the widget's, on every element | in | | G1 | |
| 337 | | `input.long-press` | contextmenu / long press (a right click with a mouse) claimed by touch-action: none on the element or an ancestor | in | | G1 | |
| 338 | | `input.keyboard` | Key events: keydown / keyup / keypress, beforeinput / input from keys, focus / blur / focusin / focusout from keys | **out** | the renderer never forwards key events; the widget never owns keyboard focus | D4 | |
| 339 | | `input.key-activation` | Enter / Space activate a focused button or link (a click from the keyboard) | **out** | keys do nothing in a widget: no synthetic click from Enter or Space | D4 | |
| 340 | | `input.key-gesture` | A key press counts as a user gesture for privileged bridge calls | **out** | only taps (pointer presses) grant a gesture | D4 | |
| 341 | | `input.wheel-scroll` | wheel and scroll events | **out** | the renderer never forwards wheel or scroll; no scrolling inside a widget | D3a | |
| 342 | | `input.user-activation` | Privileged calls (openLink) only in the task of a real tap; not from timers or synthetic clicks | in | | D8 | |
| 343 | | `input.prevent-default` | preventDefault on pointer events keeps the gesture in the widget (learned by the renderer) | in | | D4 | |
| 344 |
| 345 | ## Limits |
| 346 |
| 347 | | id | feature | status | when out | decision | |
| 348 | |---|---|---|---|---| |
| 349 | | `limit.text-node` | Text values (text node, canvas string, Path2D data) up to 32 K UTF-16 units; past it the widget stops (strict) | in | | D5 | |
| 350 | | `limit.text-budget` | Document text 48 K units, past it the widget stops; complex-script text 8192 units, past it the text is refused (strict) | in | | D5 | |
| 351 | | `limit.nodes` | At most 2000 nodes (elements, text, comments) in the document once a batch is applied; past it the widget stops (strict) | in | | P1 | |
| 352 | | `limit.timers` | At most 64 live timers (RangeError past it) | in | | P1 | |
| 353 | | `limit.cpu` | CPU quota 300 ms of JS per second (timers deferred, not killed; a task that runs past it makes the next ones wait longer); one task may run 500 ms; at most 128 layout queries in one task, and their time at most 1000 ms; past these the widget stops | in | | P1 | |
| 354 | | `limit.memory` | QuickJS heap 8 MB | in | | P1 | |
| 355 | | `limit.storage` | localStorage 4 KB per message (QuotaExceededError) | in | | D17 | |
| 356 | | `limit.attribute` | Attribute and inline-style values up to 8 K UTF-16 units; past it the widget stops (strict) | in | | L1 | |
| 357 | | `limit.batch` | At most 10 000 operations in one batch (the shim hands a task's DOM changes over in batches of about 1000, its element method calls in one); past it the widget stops (strict) | in | | L1 | |
| 358 | | `limit.css-rules` | At most 400 CSS rules and 32 @keyframes in the document's stylesheets; past them the widget stops (strict) | in | | L1 | |
| 359 | | `limit.canvas-commands` | At most 4000 canvas commands per canvas in one task (RangeError past it; strict) | in | | L1 | |
| 360 | | `limit.animations` | At most 64 running script animations (further ones are not rendered; strict) | in | | L1 | |
| 361 | | `limit.main-thread` | The host's main-thread work for a widget, its layout queries plus 25 µs per operation and 2 µs per canvas command, at most 100 ms per second (timers and frames deferred past it) | in | | L1 | |
| 362 | | `limit.canvas-pixels` | A widget's canvases hold at most 2048 × 2048 pixels together; past it the widget stops (strict; the renderer itself never applies a size past 4096 × 4096) | in | | L1 | |
| 363 | | `limit.paint-heavy` | At most 16 heavy boxes at once: a blurred box-shadow, a filter, a backdrop-filter, opacity below 1, or a running animation of one of them (shadows animated without blur do not count, nor the opacity of a disabled or pressed <button>: its own dimming); elements under display: none and a ::before / ::after without content are no boxes; past it the widget stops (strict; every renderer counts on the computed style) | in | | L2 | |
| 364 | | `limit.paint-backdrop` | Of the heavy boxes at most 2 with backdrop-filter; past it the widget stops (strict) | in | | L2 | |
| 365 | | `limit.image-pixels` | A data: image of at most 1024 × 1024 pixels, as its bytes say (larger: the placeholder); bytes of none of the profile's image formats are a broken image | in | | L1 | |
| 366 | | `limit.html-size` | HTML up to 32 KB uncompressed and 4 KB after zlib compression (server-side) | in | | D20 | |
| 367 | | `limit.url-length` | openLink / openTelegramLink URLs of at most 256 characters (TypeError past it) | in | | SDK | |
| 368 | | `limit.event-handlers` | At most 16 handlers per event type in onEvent (more are ignored) | in | | SDK | |
| 369 | | `limit.haptic-rate` | Haptics: a bucket of 5 calls refilled at 10 per second, and a touch: free while a finger is down on the widget and 5 s after it is lifted, otherwise one 1 s series (the next after a touch or 10 s later); the rest dropped (haptic-limit) | in | | SDK | |
| 370 |
| 371 | ## Client behaviour |
| 372 |
| 373 | | id | feature | status | when out | decision | |
| 374 | |---|---|---|---|---| |
| 375 | | `behaviour.theme-switch` | Live theme switch: prefers-color-scheme, light-dark() and onTheme follow the chat theme without a reload | in | | D14 | |
| 376 | | `behaviour.offscreen-pause` | Off-screen: frames stop, timers at most 1 Hz, visibilitychange fires | in | | P1 | |
| 377 | | `behaviour.auto-height` | The bubble takes the widget height; above the cap it is clipped hard | in | | D12a | |
| 378 | | `behaviour.no-selection` | Text is not selectable by default (a drag over text selects nothing); user-select: text enables it | in | | D18 | |
| 379 | | `behaviour.policy-strict` | strict policy on every client (gesture gate, text caps, budgets) | in | | D5 | |
| 380 | | `behaviour.restart` | After 2 consecutive crashes the widget stays stopped on its last frame with the "Widget stopped" badge; before that the client rebuilds it when shown again | in | | SDK | |
| 381 | | `behaviour.gesture-claim` | touch-action is the claim: taps and double taps over the widget are always its own, vertical drags always the chat's; auto leaves holds and horizontal swipes to the bubble (the widget gets pointercancel); pan-y gives the widget horizontal drags; none gives it horizontal drags and holds; pan-x claims nothing; the leading 20 px and the bubble outside the widget never take a claim | in | | G2 | |
| 382 | | `behaviour.storage-persist` | localStorage survives the widget being dropped and re-created, and an app restart; sessionStorage survives re-creation but not a restart; both are deleted with the message | in | | SDK | |
| 383 | | `behaviour.storage-forward` | A forwarded copy has its own storage, keyed by its own chat and message, so it starts empty | in | | SDK | |
| 384 | | `behaviour.message-edit` | The HTML of a sent widget never changes (an edit may change only the caption): a bot changes only the widget's state, chatData and publicData (behaviour.data-edit) | in | | I1 | |
| 385 | | `behaviour.size-hint` | Before load the bubble takes the bot's size anchors (width 0 = the bubble's width, W = a fixed width in [200, max]; height 0 = the placeholder, then the content height in [50, 600]; H = a fixed clamp(H, 50, 600)), cached per message | in | | D12a | |
| 386 | | `behaviour.time-corner` | A widget with no caption below it (none, or one shown above it) gets the message time and status over its bottom corner, on a backing as on a photo, and taps on it are the client's; the client passes the band (contentSafeArea bottom) and its corner (cornerRight, or cornerLeft in a right-to-left interface) before the first render and changes them only with the bubble's layout (a caption added, removed or moved above or below by an edit, "edited"); with a caption below the time is in the caption's line and the safe area is 0 | in | | P1-safe-area | |
| 387 | | `behaviour.resize-anchor` | When an auto height changes, the client keeps the widget's anchored edge in place on screen: top (default), the content below moves; bottom, the content above moves; also from a cached height and after a re-creation | in | | R1 | |
| 388 | | `behaviour.data-edit` | A change of the widget's state reaches the running widget as chatDataChanged / publicDataChanged (the client's setData with the full state: the server's update, or the polled shared state): no new host, no restart | in | | I1 | |
| 389 | | `behaviour.forward-copy` | A forwarded copy never has a chat state (chatData); its shared state (publicData) is a copy as of the forward or a shared widget's one shared state; it is told nothing about the chat it is in (no chatType); it asks the bot only on a tap and only if the widget was sent with fwd_allow_queries, and otherwise has no viewer either | in | | I1 | |
| 390 | | `behaviour.preview` | A widget in a list of inline results is a preview: the client creates it with context.preview and the result's state, routes no touches to it (a tap selects the result) and creates a new host for the sent message | in | | I1 | |
| 391 | | `behaviour.network-marker` | The network marker: the client marks a widget whose tap may send data to the bot's server exactly where the message has can_query (a UI contract of the server's spec) | in | | I1 | |
| 392 |
| 393 | ## Tables |
| 394 |
| 395 | What the validator lets through; anything else is removed as the features above say. |
| 396 |
| 397 | - **HTML elements kept:** `a`, `abbr`, `address`, `article`, `aside`, `b`, `blockquote`, `body`, `br`, `button`, `canvas`, `caption`, `cite`, `code`, `col`, `colgroup`, `data`, `dd`, `del`, `details`, `dfn`, `div`, `dl`, `dt`, `em`, `figcaption`, `figure`, `footer`, `h1`, `h2`, `h3`, `h4`, `h5`, `h6`, `head`, `header`, `hgroup`, `hr`, `html`, `i`, `img`, `ins`, `kbd`, `li`, `main`, `mark`, `menu`, `nav`, `ol`, `p`, `picture`, `pre`, `q`, `s`, `samp`, `search`, `section`, `small`, `span`, `strong`, `sub`, `summary`, `sup`, `table`, `tbody`, `td`, `tfoot`, `th`, `thead`, `time`, `tr`, `u`, `ul`, `var`, `wbr`. |
| 398 | - **Rendered as `<span>`:** `bdi`, `bdo`, `big`, `font`, `label`, `legend`, `nobr`, `output`, `rp`, `rt`, `ruby`, `strike`, `tt`; **as `<div>`:** `center`, `dialog`, `form`; unknown elements: `<span>`. |
| 399 | - **Dropped with their subtree:** `applet`, `area`, `audio`, `base`, `datalist`, `embed`, `fencedframe`, `fieldset`, `frame`, `frameset`, `iframe`, `input`, `link`, `listing`, `map`, `math`, `meta`, `metadata`, `meter`, `noembed`, `noframes`, `noscript`, `object`, `optgroup`, `option`, `param`, `plaintext`, `portal`, `progress`, `script`, `select`, `set`, `slot`, `source`, `template`, `textarea`, `title`, `track`, `video`, `xmp`. |
| 400 | - **HTML attributes:** `class`, `id`, `title`, `lang`, `dir`, `hidden`, `role`, `colspan`, `rowspan`, `span`, `width`, `height`, `alt`, `open`, `start`, `reversed`, `datetime`, `value`, `type`, `disabled`, `style`, the URL attributes `href` and `src` (checked), and the prefixes `data-*`, `aria-*`. |
| 401 | - **SVG elements:** `svg`, `g`, `path`, `rect`, `circle`, `ellipse`, `line`, `polyline`, `polygon`, `text`, `tspan`, `defs`, `symbol`, `use`, `linearGradient`, `radialGradient`, `stop`, `title`, `desc`, `a`. |
| 402 | - **SVG attributes:** `class`, `id`, `lang`, `role`, `viewBox`, `preserveAspectRatio`, `x`, `y`, `x1`, `y1`, `x2`, `y2`, `cx`, `cy`, `r`, `rx`, `ry`, `d`, `points`, `dx`, `dy`, `rotate`, `transform`, `width`, `height`, `fill`, `fill-opacity`, `fill-rule`, `stroke`, `stroke-width`, `stroke-opacity`, `stroke-linecap`, `stroke-linejoin`, `stroke-dasharray`, `stroke-dashoffset`, `stroke-miterlimit`, `opacity`, `color`, `display`, `visibility`, `overflow`, `text-anchor`, `dominant-baseline`, `alignment-baseline`, `baseline-shift`, `font-family`, `font-size`, `font-weight`, `font-style`, `letter-spacing`, `word-spacing`, `text-decoration`, `gradientUnits`, `gradientTransform`, `spreadMethod`, `fx`, `fy`, `fr`, `offset`, `stop-color`, `stop-opacity`, `pointer-events`, `shape-rendering`, `text-rendering`, `vector-effect`, `paint-order`, `cursor`, `pathLength`, `version`, `xml:space`, `xml:lang`, `href` (fragments only). |
| 403 | - **Image types (`data:` URLs):** `image/png`, `image/jpeg`, `image/jpg`, `image/gif`, `image/webp`. |
| 404 | - **Events delivered to the widget:** `click`, `pointerdown`, `pointerup`, `pointermove`, `pointerenter`, `pointerleave`, `pointerover`, `pointerout`, `pointercancel`, `dblclick`, `contextmenu`, `mousedown`, `mouseup`, `mousemove`, `mouseenter`, `mouseleave`, `mouseover`, `mouseout`, `load`, `error`, `toggle`, `animationstart`, `animationend`, `animationiteration`, `transitionend`. |
| 405 | - **Element methods that reach the renderer:** `setPointerCapture`, `releasePointerCapture`, `scrollTo`, `scrollBy`, `observeResize`, `unobserveResize`; properties: `scrollTop`, `scrollLeft`. |
| 406 | - **Canvas methods:** `save`, `restore`, `scale`, `rotate`, `translate`, `transform`, `setTransform`, `resetTransform`, `clearRect`, `fillRect`, `strokeRect`, `beginPath`, `closePath`, `moveTo`, `lineTo`, `bezierCurveTo`, `quadraticCurveTo`, `arc`, `arcTo`, `ellipse`, `rect`, `roundRect`, `fill`, `stroke`, `clip`, `fillText`, `strokeText`, `setLineDash`, `drawImage`, `reset`; properties: `fillStyle`, `strokeStyle`, `lineWidth`, `lineCap`, `lineJoin`, `miterLimit`, `lineDashOffset`, `font`, `textAlign`, `textBaseline`, `direction`, `globalAlpha`, `imageSmoothingEnabled`, `imageSmoothingQuality`; gradients: `linear`, `radial`; queries: `isPointInPath`, `isPointInStroke`, `getTransform`, `getLineDash`, `measureText`. |
| 407 | - **CSS properties:** `display`, `flex`, `flex-direction`, `flex-wrap`, `flex-flow`, `flex-grow`, `flex-shrink`, `flex-basis`, `justify-content`, `align-items`, `align-self`, `align-content`, `order`, `place-items`, `place-content`, `place-self`, `justify-items`, `justify-self`, `gap`, `row-gap`, `column-gap`, `grid-gap`, `grid-row-gap`, `grid-column-gap`, `grid`, `grid-template`, `grid-template-columns`, `grid-template-rows`, `grid-template-areas`, `grid-column`, `grid-column-start`, `grid-column-end`, `grid-row`, `grid-row-start`, `grid-row-end`, `grid-area`, `grid-auto-flow`, `grid-auto-columns`, `grid-auto-rows`, `width`, `height`, `min-width`, `min-height`, `max-width`, `max-height`, `margin`, `margin-top`, `margin-right`, `margin-bottom`, `margin-left`, `padding`, `padding-top`, `padding-right`, `padding-bottom`, `padding-left`, `border`, `border-width`, `border-style`, `border-color`, `border-top`, `border-right`, `border-bottom`, `border-left`, `border-top-width`, `border-right-width`, `border-bottom-width`, `border-left-width`, `border-top-style`, `border-right-style`, `border-bottom-style`, `border-left-style`, `border-top-color`, `border-right-color`, `border-bottom-color`, `border-left-color`, `border-radius`, `border-top-left-radius`, `border-top-right-radius`, `border-bottom-right-radius`, `border-bottom-left-radius`, `border-collapse`, `border-spacing`, `table-layout`, `caption-side`, `empty-cells`, `box-sizing`, `aspect-ratio`, `outline`, `outline-width`, `outline-style`, `outline-color`, `outline-offset`, `box-shadow`, `float`, `clear`, `object-fit`, `object-position`, `position`, `top`, `right`, `bottom`, `left`, `inset`, `z-index`, `overflow`, `overflow-x`, `overflow-y`, `visibility`, `opacity`, `color`, `background`, `background-color`, `background-image`, `background-size`, `background-position`, `background-position-x`, `background-position-y`, `background-repeat`, `background-origin`, `background-clip`, `color-scheme`, `font`, `font-family`, `font-size`, `font-weight`, `font-style`, `line-height`, `font-variant-numeric`, `font-feature-settings`, `text-align`, `text-indent`, `text-decoration`, `text-decoration-line`, `text-decoration-color`, `text-decoration-style`, `text-decoration-thickness`, `text-underline-offset`, `text-transform`, `letter-spacing`, `word-spacing`, `white-space`, `white-space-collapse`, `text-wrap-mode`, `overflow-wrap`, `word-wrap`, `word-break`, `text-overflow`, `vertical-align`, `list-style`, `list-style-type`, `list-style-position`, `direction`, `unicode-bidi`, `transform`, `transform-origin`, `transform-box`, `translate`, `rotate`, `scale`, `filter`, `backdrop-filter`, `-webkit-backdrop-filter`, `pointer-events`, `touch-action`, `cursor`, `content`, `counter-reset`, `counter-increment`, `quotes`, `transition`, `transition-property`, `transition-duration`, `transition-timing-function`, `transition-delay`, `animation`, `animation-name`, `animation-duration`, `animation-timing-function`, `animation-delay`, `animation-iteration-count`, `animation-direction`, `animation-fill-mode`, `animation-play-state`, `fill`, `fill-opacity`, `fill-rule`, `stroke`, `stroke-width`, `stroke-opacity`, `stroke-linecap`, `stroke-linejoin`, `stroke-dasharray`, `stroke-dashoffset`, `stroke-miterlimit`, `stop-color`, `stop-opacity`, `text-anchor`, `dominant-baseline`, `paint-order`, `vector-effect`, `shape-rendering`, `cx`, `cy`, `r`, `rx`, `ry`, `all`, `appearance`, `-webkit-appearance`, `will-change`, `text-rendering`, `-webkit-font-smoothing`, `-moz-osx-font-smoothing`, `-webkit-tap-highlight-color`, `user-select`, `-webkit-user-select`, and custom properties (`--*`). |
| 408 | - **CSS functions:** `var`, `calc`, `min`, `max`, `clamp`, `rgb`, `rgba`, `hsl`, `hsla`, `light-dark`, `linear-gradient`, `repeating-linear-gradient`, `radial-gradient`, `repeating-radial-gradient`, `conic-gradient`, `repeating-conic-gradient`, `translate`, `translatex`, `translatey`, `rotate`, `scale`, `scalex`, `scaley`, `skew`, `skewx`, `skewy`, `matrix`, `blur`, `brightness`, `drop-shadow`, `cubic-bezier`, `steps`, `linear`, `attr`, `counter`, `counters`, `minmax`, `repeat`, `fit-content`, `env`, `url` (`url()` takes `data:` images and `#fragment` only). |
| 409 | - **CSS units:** `px`, `em`, `rem`, `ch`, `ex`, `pt`, `pc`, `cm`, `mm`, `in`, `q`, `vw`, `svw`, `lvw`, `dvw`, `vi`, `svi`, `lvi`, `dvi`, `vmin`, `svmin`, `lvmin`, `dvmin`, `vmax`, `svmax`, `lvmax`, `dvmax`, `deg`, `rad`, `grad`, `turn`, `s`, `ms`, `fr`, `%` and unitless numbers. |
| 410 | - **`display` values:** `block`, `inline`, `inline-block`, `none`, `flex`, `inline-flex`, `grid`, `inline-grid`, `table`, `inline-table`, `table-row`, `table-cell`, `table-caption`, `table-row-group`, `table-header-group`, `table-footer-group`, `table-column`, `table-column-group`. |
| 411 | - **`position` values:** `static`, `relative`, `absolute`, `fixed`. |
| 412 | - **`user-select` values:** `none`, `text`, `auto`. |
| 413 | - **`-webkit-user-select` values:** `none`, `text`, `auto`. |
| 414 | - **`position` rewritten:** `sticky` → `relative`, `-webkit-sticky` → `relative`. |
| 415 | - **`overflow` rewritten:** `auto` → `hidden`, `scroll` → `hidden`, `overlay` → `hidden`. |
| 416 | - **Filter functions** (`filter`, `backdrop-filter`): `blur`, `brightness`, `drop-shadow`; any other function is removed from the list. |
| 417 | - **3D transform functions (the declaration is dropped):** `matrix3d`, `translate3d`, `translatez`, `scale3d`, `scalez`, `rotate3d`, `rotatex`, `rotatey`, `rotatez`, `perspective`. |
| 418 | - **Font families:** `system-ui`, `sans-serif`, `serif`, `monospace`, `ui-sans-serif`, `ui-serif`, `ui-monospace`, `ui-rounded`; `-apple-system` and `blinkmacsystemfont` (the vendor names of the system UI font) become `system-ui`, other names are removed from the list, `ui-sans-serif` gets `sans-serif` after it, `ui-serif` gets `serif` after it, `ui-monospace` gets `monospace` after it, `ui-rounded` gets `sans-serif` after it, an empty list becomes `system-ui`. |
| 419 | - **Pseudo-classes:** `:hover`, `:active`, `:root`, `:lang`, `:first-child`, `:last-child`, `:only-child`, `:nth-child`, `:nth-last-child`, `:nth-of-type`, `:nth-last-of-type`, `:first-of-type`, `:last-of-type`, `:only-of-type`, `:empty`, `:is`, `:where`, `:not`, `:before`, `:after`; `:disabled` becomes `[disabled]`, `:enabled` becomes `:not([disabled])`. **Pseudo-elements:** `::before`, `::after`. A selector with anything else is dropped from its list. |
| 420 | - **At-rules:** `@media`, `@supports`, `@keyframes`, `@-webkit-keyframes`; nested rules are dropped. |
| 421 | - **The renderer's own stylesheet** (since v0.1.1 the defaults of the root and the text elements, with the bubble's palette `--tg-theme-*` and the client's text tokens `--tg-text-*`, and text not selectable unless the widget sets `user-select: text`; an unstyled `<button>` in the client's style, with the `--tg-button-*` tokens; any widget CSS wins over the layer, docs/sdk-v1.md §2.4): `@layer tw-ua{:where(html){color:var(--tg-theme-text-color);font:var(--tg-text-font-size,15px)/var(--tg-text-line-height,1.35) system-ui,sans-serif;-webkit-text-size-adjust:none;text-size-adjust:none;overflow-wrap:break-word;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}:where(body){margin:var(--tg-text-padding,8px 12px);padding:0;padding-bottom:var(--tg-content-safe-area-inset-bottom,0px)}:where(h1,h2,h3,h4,h5,h6){margin:.75em 0 .35em;font-weight:600;line-height:1.25}:where(h1){font-size:1.6em}:where(h2){font-size:1.35em}:where(h3){font-size:1.2em}:where(h4){font-size:1.07em}:where(h5){font-size:1em}:where(h6){font-size:.87em}:where(p,ul,ol,menu,dl,pre,blockquote,figure,table){margin:.6em 0}:where(ul,ol,menu){padding:0 0 0 1.5em;padding-inline-start:1.5em;padding-inline-end:0}:where(ul,menu){list-style-type:disc}:where(ol){list-style-type:decimal}:where(li ul,li menu){list-style-type:circle}:where(li ul,li ol,li menu,li dl){margin:0}:where(dt){font-weight:600}:where(dd){margin:0 0 0 1.5em;margin-inline-start:1.5em;margin-inline-end:0}:where(table){border-collapse:collapse;border-spacing:0}:where(caption){padding:0 0 .3em;color:var(--tg-theme-hint-color);font-size:.87em;text-align:left;text-align:start}:where(th,td){padding:.3em .6em;border-bottom:1px solid var(--tg-theme-section-separator-color);text-align:left;text-align:start;vertical-align:top}:where(th){font-weight:600}:where(th:last-child,td:last-child){padding-right:0;padding-inline-end:0;padding-inline-start:.6em}:where(th:first-child,td:first-child){padding-left:0;padding-inline-start:0;padding-inline-end:.6em}:where(hr){height:0;margin:.6em 0;border:0;border-top:1px solid var(--tg-theme-section-separator-color)}:where(pre,code,kbd,samp){font-family:ui-monospace,monospace;font-size:.9em}:where(pre code,pre kbd,pre samp){font-size:1em}:where(pre){padding:.5em .7em;border-radius:6px;background:rgba(128,128,128,.12);white-space:pre-wrap}:where(blockquote){padding:0 0 0 .75em;padding-inline-start:.75em;padding-inline-end:0;border-left:3px solid var(--tg-theme-accent-text-color);border-inline-start:3px solid var(--tg-theme-accent-text-color);border-inline-end:0}:where(figcaption){margin:.3em 0 0;color:var(--tg-theme-hint-color);font-size:.87em}:where(img){max-width:100%}:where(a[href]){color:var(--tg-theme-link-color);text-decoration:none}:where(b,strong){font-weight:600}:where(i,em,cite,dfn,var){font-style:italic}:where(small){font-size:.85em}:where(sub,sup){position:relative;font-size:.75em;line-height:0;vertical-align:baseline}:where(sup){top:-.5em}:where(sub){bottom:-.25em}:where(mark){background:rgba(255,204,0,.4);color:inherit}:where(body>:first-child){margin-top:0}:where(body>:last-child){margin-bottom:0}:where(button){appearance:none;-webkit-appearance:none;margin:0;border:0;border-radius:var(--tg-button-radius,8px);padding:var(--tg-button-padding,8px 14px);min-height:var(--tg-button-height,auto);font:var(--tg-button-font,500 14px/1.2 system-ui,sans-serif);background:var(--tg-button-bg,rgba(51,144,236,.12));color:var(--tg-button-text,inherit);cursor:pointer;-webkit-tap-highlight-color:transparent}:where(button:not([disabled])):active{opacity:var(--tg-button-pressed-opacity,.7)}:where(button[disabled]){opacity:var(--tg-button-disabled-opacity,.5);cursor:default}}` |
| 422 | - **Media types:** `all`, `screen`; **media features:** `width`, `min-width`, `max-width`, `aspect-ratio`, `min-aspect-ratio`, `max-aspect-ratio`, `orientation`, `prefers-color-scheme`, `prefers-reduced-motion` (`prefers-color-scheme` and `prefers-reduced-motion` are answered by the client). A query with anything else drops its `@media` rule and makes `matchMedia` answer `false`. |
| 423 |