engine/share_code library

Share codes and deep links (research theme-engine.md §11, Recommendation 13).

50 bits = family (5) + engineVersion (6) + seed (32) + CRC-7 (7), as 10 Crockford base32 symbols shown XXXXX-XXXXX. CRC polynomial x⁷ + x³ + 1 (0x09) is primitive, so every single-symbol substitution and every transposition of two different symbols is detected. Decoding is case-insensitive, maps O → 0 and I/L → 1, and ignores hyphens and spaces. Deep link: calsee://t/CODE (lowercase scheme and host, because Android matches them case-sensitively); web form https://calsee.tech/t/CODE (parsed only; App Links / Universal Links verification is pending, docs/release/README.md).

Classes

SharePayload
Decoded share-code payload.

Constants

crockfordAlphabet → const String
Crockford base32 alphabet (no I, L, O, U).
deepLinkScheme → const String
Deep-link scheme (lowercase).
deepLinkThemeHost → const String
Deep-link host for themes (lowercase).
deepLinkWebHosts → const Set<String>
Web hosts whose https://<host>/t/CODE links are theme links.
legacyDeepLinkScheme → const String
Pre-release placeholder scheme, still accepted when parsing so links made by development builds keep working.
shareFamilyHero → const int
Family field value for hero themes (seed = hero id).
shareFamilyReserved → const int
Reserved family field value.

Functions

crc7(List<int> bits) → int
CRC-7, polynomial x⁷ + x³ + 1 (0x09), MSB-first, init 0, over bits (each 0 or 1).
decodeShareCode(String input) → SharePayload?
Decodes a share code, or null when it is malformed or fails the CRC. Callers must still check the family id and that SharePayload. engineVersion is not newer than the app's ("update the app to open this theme").
encodePayload(SharePayload payload) → String
Encodes payload (see encodeShareCode).
encodeShareCode(int familyId, int engineVersion, int seed) → String
Encodes a payload as XXXXX-XXXXX. familyId 0–31, engineVersion 0–63; seed is taken modulo 2^32.
Formats the deep link for code: calsee://t/XXXXX-XXXXX.
Formats the web form of the link for code: https://calsee.tech/t/XXXXX-XXXXX.
normalizeShareCode(String input) → String?
Normalises user input to the 10 canonical symbols (upper case, O → 0, I/L → 1, hyphens and whitespace dropped), or null if it contains a character outside the alphabet or has the wrong length.
Parses a theme deep link (calsee://t/CODE, or the pre-release infinitecalc://t/CODE; scheme and host lowercase, the code may be any case) or a web link (https://calsee.tech/t/CODE). Returns null for anything else or a bad code.