From 4164e5b282f87584258cab289b5160e8c0f98c57 Mon Sep 17 00:00:00 2001 From: Carbon225 Date: Tue, 31 Dec 2024 21:58:05 +0100 Subject: [PATCH] define label inspector types --- packages/namerank-sdk/src/index.ts | 326 ++++++++++++++++++++++++++++- 1 file changed, 325 insertions(+), 1 deletion(-) diff --git a/packages/namerank-sdk/src/index.ts b/packages/namerank-sdk/src/index.ts index ff59979bf..1b9a9b876 100644 --- a/packages/namerank-sdk/src/index.ts +++ b/packages/namerank-sdk/src/index.ts @@ -9,24 +9,345 @@ export enum LabelStatus { Unknown = "unknown", } +// Character and grapheme types can potentially evolve independently. + +export enum CharacterType { + /** A lowercase letter [a-z] */ + SimpleLetter = "simple_letter", + + /** A digit [0-9] */ + SimpleNumber = "simple_number", + + /** A letter in any script that is not simple; `LC` class http://www.unicode.org/reports/tr44/#GC_Values_Table */ + OtherLetter = "other_letter", + + /** A digit in any script that is not simple; `N` class http://www.unicode.org/reports/tr44/#GC_Values_Table */ + OtherNumber = "other_number", + + /** A hyphen */ + Hyphen = "hyphen", + + /** A dollar sign */ + DollarSign = "dollarsign", + + /** An underscore */ + Underscore = "underscore", + + /** A character that is part of a valid emoji sequence */ + Emoji = "emoji", + + /** A zero width joiner or non-joiner not part of an emoji sequence */ + Invisible = "invisible", + + /** Any character that doesn't match other classifications */ + Special = "special" +} + +export enum GraphemeType { + /** Only lowercase letters [a-z] */ + SimpleLetter = "simple_letter", + + /** Only digits [0-9] */ + SimpleNumber = "simple_number", + + /** A letter (single-char grapheme) in any script that is not simple; `LC` class http://www.unicode.org/reports/tr44/#GC_Values_Table */ + OtherLetter = "other_letter", + + /** A digit (single-char grapheme) in any script that is not simple; `N` class http://www.unicode.org/reports/tr44/#GC_Values_Table */ + OtherNumber = "other_number", + + /** A hyphen */ + Hyphen = "hyphen", + + /** A dollar sign */ + DollarSign = "dollarsign", + + /** An underscore */ + Underscore = "underscore", + + /** An emoji or emoji ZWJ sequence */ + Emoji = "emoji", + + /** A zero width joiner or non-joiner */ + Invisible = "invisible", + + /** Either a grapheme that doesn't match other classifications, or a multi-character + * grapheme containing characters of different types */ + Special = "special" +} + +export interface InspectorCharResult { + /** Character being inspected */ + value: string; + + /** Script name (writing system) of the character. + * - is 'Unknown' if script is not assigned for a character + * - special scripts are 'Common' (e.g. punctuations, emojis) and 'Inherited' (e.g. combining marks) + */ + script: string; + + /** Name assigned to the character. + * - for unknown characters it is 'Unknown character in