satteri-emoji 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Igor Koop
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # satteri-emoji
2
+
3
+ [![npm](https://img.shields.io/npm/v/satteri-emoji)](https://www.npmjs.com/package/satteri-emoji) [![License](https://img.shields.io/github/license/igor-koop/satteri-emoji)](https://github.com/igor-koop/satteri-emoji/blob/main/LICENSE) [![Coverage](https://codecov.io/gh/igor-koop/satteri-emoji/graph/badge.svg)](https://codecov.io/gh/igor-koop/satteri-emoji) [![Lint](https://img.shields.io/badge/lint-oxlint-ea580c)](https://oxc.rs/docs/guide/usage/linter) [![Types](https://img.shields.io/badge/types-TypeScript-3178c6)](https://www.typescriptlang.org/) [![CI](https://github.com/igor-koop/satteri-emoji/actions/workflows/ci.yml/badge.svg)](https://github.com/igor-koop/satteri-emoji/actions/workflows/ci.yml)
4
+
5
+ Satteri plugin to replace emoji shortcodes and, optionally, ASCII emoticons in Markdown text.
6
+
7
+ Inspired by [`remark-emoji`](https://github.com/rhysd/remark-emoji), but built for Satteri's JavaScript plugin API and powered by generated [`emojibase-data`](https://github.com/milesj/emojibase) lookup tables.
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ npm install satteri-emoji
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ import { markdownToHtml } from "satteri";
19
+ import { satteriEmoji } from "satteri-emoji";
20
+
21
+ const html = markdownToHtml("Hello :waving_hand:", {
22
+ mdastPlugins: [satteriEmoji()],
23
+ }).html;
24
+
25
+ // <p>Hello <span class="emoji" role="img" aria-label="waving hand">👋</span></p>
26
+ ```
27
+
28
+ GitHub-style names are available by opting into the GitHub shortcode dataset:
29
+
30
+ ```ts
31
+ satteriEmoji({ shortcodes: ["github"] });
32
+ ```
33
+
34
+ ## Options
35
+
36
+ | Option | Type | Default | Description |
37
+ | ------------ | -------------------------- | ---------- | ----------------------------------------------------------------- |
38
+ | `class` | `string` | `"emoji"` | CSS class on generated spans. Empty string omits the attribute. |
39
+ | `emoticons` | `boolean` | `false` | Replace ASCII emoticons like `:-)` and `:D`. |
40
+ | `hidden` | `boolean` | `false` | Add `aria-hidden="true"` to generated spans. |
41
+ | `label` | `boolean` | `true` | Add `role="img"` and `aria-label` to generated spans. |
42
+ | `locale` | `Locale` | `"en"` | Locale for accessible labels. |
43
+ | `override` | `Record<string, Override>` | — | Direct shortcode replacements; take precedence over all datasets. |
44
+ | `shortcodes` | `Catalog[]` | `["cldr"]` | Shortcode datasets to enable. |
45
+
46
+ Built-in datasets: `cldr`, `cldr-native`, `emojibase`, `emojibase-legacy`, `github`, `iamcal`, `joypixels`.
47
+
48
+ Built-in locales: `bn`, `da`, `de`, `en`, `en-gb`, `es`, `es-mx`, `et`, `fi`, `fr`, `hi`, `hu`, `it`, `ja`, `ko`, `lt`, `ms`, `nb`, `nl`, `pl`, `pt`, `ru`, `sv`, `th`, `uk`, `vi`, `zh`, `zh-hant`.
49
+
50
+ `Override` is `{ value: string; label?: string }`. When `label` is omitted the shortcode key is used as the accessible label.
51
+
52
+ ## Development
53
+
54
+ ```sh
55
+ git clone https://github.com/igor-koop/satteri-emoji
56
+ cd satteri-emoji
57
+ npm install
58
+ ```
59
+
60
+ | Script | Description |
61
+ | --------------- | ---------------------------------------------------- |
62
+ | `npm run data` | Regenerate the emoji registry from `emojibase-data`. |
63
+ | `npm run build` | Compile ESM and type declarations into `dist/`. |
64
+ | `npm test` | Run the Vitest test suite. |
65
+ | `npm run cov` | Run tests with V8 coverage. |
66
+ | `npm run check` | Format check, lint, and TypeScript typecheck. |
67
+ | `npm run fmt` | Auto-format with oxfmt. |
68
+
69
+ The package pre-generates `src/registry.ts` from `emojibase-data` so that runtime work is limited to a few lookups per plugin call rather than parsing the full Emojibase JSON on each page.
70
+
71
+ ## License
72
+
73
+ [MIT](LICENSE)
@@ -0,0 +1,92 @@
1
+ import type { MdastPluginInstance } from "satteri";
2
+ import { type Locale, type Catalog } from "./registry.js";
3
+ /** Replacement value and optional accessible label for a shortcode override. */
4
+ export interface Override {
5
+ /** Text rendered in place of the matched shortcode. */
6
+ readonly value: string;
7
+ /** Accessible label exposed to assistive technology via `aria-label`.
8
+ * Defaults to the shortcode key when omitted.
9
+ */
10
+ readonly label?: string;
11
+ }
12
+ /** Configuration options for {@link satteriEmoji}. */
13
+ export interface SatteriEmojiOptions {
14
+ /**
15
+ * CSS class of the `span` elements wrapping converted emoji and emoticon
16
+ * texts. Set to an empty string to omit the `class` attribute entirely.
17
+ *
18
+ * @default "emoji"
19
+ */
20
+ readonly class?: string;
21
+ /**
22
+ * Enable conversion of text emoticons such as `:-)` and `:D`.
23
+ *
24
+ * @default false
25
+ */
26
+ readonly emoticons?: boolean;
27
+ /**
28
+ * Hide converted emoji from assistive technology via `aria-hidden="true"`.
29
+ * Takes precedence over `label`.
30
+ *
31
+ * @default false
32
+ */
33
+ readonly hidden?: boolean;
34
+ /**
35
+ * Expose converted emoji to assistive technology via `role="img"` and
36
+ * `aria-label`. Ignored when `hidden` is enabled.
37
+ *
38
+ * @default true
39
+ */
40
+ readonly label?: boolean;
41
+ /**
42
+ * Locale for accessible `aria-label` text.
43
+ *
44
+ * @default "en"
45
+ */
46
+ readonly locale?: Locale;
47
+ /**
48
+ * Direct substitutions keyed by shortcode (without surrounding colons).
49
+ * Each entry supplies a replacement `value` and an optional accessible
50
+ * `label`. Overrides take precedence over every configured shortcode dataset.
51
+ */
52
+ readonly override?: Readonly<Record<string, Override>>;
53
+ /**
54
+ * Shortcode datasets used for matching.
55
+ *
56
+ * @default ["cldr"]
57
+ */
58
+ readonly shortcodes?: readonly Catalog[];
59
+ }
60
+ /** The plugin instance type returned by {@link satteriEmoji}. */
61
+ export interface SatteriEmojiPlugin {
62
+ name: "satteri-emoji";
63
+ text(...args: Parameters<NonNullable<MdastPluginInstance["text"]>>): void;
64
+ }
65
+ /**
66
+ * Create the satteri mdast plugin that converts emoji shortcodes — and,
67
+ * optionally, text emoticons — into accessible inline `span` elements.
68
+ *
69
+ * Each match (such as `:waving_hand:`, or `:-)` when
70
+ * {@link SatteriEmojiOptions.emoticons} is enabled) is replaced in place with a
71
+ * `span` wrapping the rendered Unicode emoji. Accessibility of the `span` is
72
+ * controlled by the plugin options. Markdown documents receive HTML nodes,
73
+ * while MDX documents receive equivalent JSX elements.
74
+ *
75
+ * @param options - Plugin configuration; every field is optional and falls back
76
+ * to the default documented on {@link SatteriEmojiOptions}.
77
+ * @returns A plugin instance to register in satteri's `mdastPlugins` option.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * import { markdownToHtml } from "satteri";
82
+ * import { satteriEmoji } from "satteri-emoji";
83
+ *
84
+ * const { html } = markdownToHtml("Hello :waving_hand:", {
85
+ * mdastPlugins: [satteriEmoji()],
86
+ * });
87
+ * // html === '<p>Hello <span class="emoji" role="img" aria-label="waving hand">👋</span></p>\n'
88
+ * ```
89
+ */
90
+ export declare function satteriEmoji(options?: SatteriEmojiOptions): SatteriEmojiPlugin;
91
+ export default satteriEmoji;
92
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,EAOL,KAAK,MAAM,EACX,KAAK,OAAO,EACb,MAAM,eAAe,CAAC;AAKvB,gFAAgF;AAChF,MAAM,WAAW,QAAQ;IACvB,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,sDAAsD;AACtD,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAE1B;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEvD;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CAC1C;AAED,iEAAiE;AACjE,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CAC3E;AAqBD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,kBAAkB,CAyDlF;AAyID,eAAe,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,184 @@
1
+ import { defineMdastPlugin } from "satteri";
2
+ import { HEXCODES, RE_EMOJI, RE_EMOTICON, EMOTICONS, LABELS, SHORTCODES, } from "./registry.js";
3
+ /** HTML special characters mapped to their entity equivalents. */
4
+ const HTML_ENTITIES = {
5
+ "&": "&amp;",
6
+ "<": "&lt;",
7
+ ">": "&gt;",
8
+ '"': "&quot;",
9
+ };
10
+ /**
11
+ * Create the satteri mdast plugin that converts emoji shortcodes — and,
12
+ * optionally, text emoticons — into accessible inline `span` elements.
13
+ *
14
+ * Each match (such as `:waving_hand:`, or `:-)` when
15
+ * {@link SatteriEmojiOptions.emoticons} is enabled) is replaced in place with a
16
+ * `span` wrapping the rendered Unicode emoji. Accessibility of the `span` is
17
+ * controlled by the plugin options. Markdown documents receive HTML nodes,
18
+ * while MDX documents receive equivalent JSX elements.
19
+ *
20
+ * @param options - Plugin configuration; every field is optional and falls back
21
+ * to the default documented on {@link SatteriEmojiOptions}.
22
+ * @returns A plugin instance to register in satteri's `mdastPlugins` option.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import { markdownToHtml } from "satteri";
27
+ * import { satteriEmoji } from "satteri-emoji";
28
+ *
29
+ * const { html } = markdownToHtml("Hello :waving_hand:", {
30
+ * mdastPlugins: [satteriEmoji()],
31
+ * });
32
+ * // html === '<p>Hello <span class="emoji" role="img" aria-label="waving hand">👋</span></p>\n'
33
+ * ```
34
+ */
35
+ export function satteriEmoji(options = {}) {
36
+ const config = {
37
+ class: options.class ?? "emoji",
38
+ emoticons: options.emoticons ?? false,
39
+ hidden: options.hidden ?? false,
40
+ label: options.label ?? true,
41
+ locale: options.locale ?? "en",
42
+ override: options.override,
43
+ shortcodes: options.shortcodes ?? ["cldr"],
44
+ };
45
+ const labels = LABELS[config.locale] ?? LABELS.en;
46
+ const shortcodes = {};
47
+ const replacements = new RegExp(config.emoticons ? `${RE_EMOJI}|(?<prefix>^|\\s)(?<emoticon>${RE_EMOTICON})` : RE_EMOJI, "g");
48
+ for (const dataset of config.shortcodes) {
49
+ Object.assign(shortcodes, SHORTCODES[dataset]);
50
+ }
51
+ return defineMdastPlugin({
52
+ name: "satteri-emoji",
53
+ text(node, ctx) {
54
+ const mdx = isMdx(ctx.fileURL);
55
+ let offset = 0;
56
+ for (const match of node.value.matchAll(replacements)) {
57
+ const resolved = resolveMatch(match, shortcodes, config.override, labels);
58
+ if (resolved === null)
59
+ continue;
60
+ const { value, label, index, source } = resolved;
61
+ if (index > offset) {
62
+ ctx.insertBefore(node, { type: "text", value: node.value.slice(offset, index) });
63
+ }
64
+ const attributes = createAttributes(config, label);
65
+ ctx.insertBefore(node, mdx ? createMdxSpan(value, attributes) : createHtmlSpan(value, attributes));
66
+ offset = index + source.length;
67
+ }
68
+ if (offset === 0) {
69
+ return;
70
+ }
71
+ if (offset < node.value.length) {
72
+ ctx.insertBefore(node, { type: "text", value: node.value.slice(offset) });
73
+ }
74
+ ctx.removeNode(node);
75
+ },
76
+ });
77
+ }
78
+ /**
79
+ * Resolve a regex match to its rendered value, accessible label, text index,
80
+ * and matched source string. Returns `null` when the match has no emoji mapping.
81
+ *
82
+ * @param match - A match from {@link String.prototype.matchAll}.
83
+ * @param shortcodes - Merged shortcode-to-hexcode lookup.
84
+ * @param overrides - Direct shortcode overrides from the plugin config.
85
+ * @param labels - Locale-specific hexcode-to-label lookup.
86
+ */
87
+ function resolveMatch(match, shortcodes, overrides, labels) {
88
+ const { shortcode, prefix = "", emoticon, } = match.groups;
89
+ const source = shortcode !== undefined ? match[0] : emoticon;
90
+ const index = match.index + prefix.length;
91
+ const hexcode = shortcode === undefined ? EMOTICONS[source] : shortcodes[shortcode];
92
+ const override = shortcode !== undefined && overrides !== undefined && Object.hasOwn(overrides, shortcode)
93
+ ? overrides[shortcode]
94
+ : undefined;
95
+ const value = override ? override.value : hexcode !== undefined ? HEXCODES[hexcode] : undefined;
96
+ if (value === undefined)
97
+ return null;
98
+ const label = override ? (override.label ?? shortcode) : labels[hexcode];
99
+ return { value, label, index, source };
100
+ }
101
+ /**
102
+ * Returns `true` when the document URL ends with `.mdx` (case-insensitive),
103
+ * `false` otherwise. A missing URL is treated as plain Markdown.
104
+ *
105
+ * @param fileURL - The document URL exposed as `ctx.fileURL`, or `undefined`.
106
+ */
107
+ function isMdx(fileURL) {
108
+ return fileURL?.pathname.toLowerCase().endsWith(".mdx") ?? false;
109
+ }
110
+ /**
111
+ * Build the `span` attribute map for a single converted emoji or emoticon.
112
+ *
113
+ * When `hidden` is set, only `aria-hidden="true"` is emitted. Otherwise,
114
+ * `label` adds `role="img"` and `aria-label`. An empty `class` omits the
115
+ * respective attribute.
116
+ *
117
+ * @param config - Resolved plugin options.
118
+ * @param label - Accessible name used as the `aria-label` value.
119
+ * @returns Attribute name/value pairs ready for HTML serialization or MDX JSX mapping.
120
+ */
121
+ function createAttributes(config, label) {
122
+ const attributes = {};
123
+ if (config.class) {
124
+ attributes["class"] = config.class;
125
+ }
126
+ if (config.hidden) {
127
+ attributes["aria-hidden"] = "true";
128
+ return attributes;
129
+ }
130
+ if (config.label) {
131
+ attributes["role"] = "img";
132
+ attributes["aria-label"] = label;
133
+ }
134
+ return attributes;
135
+ }
136
+ /**
137
+ * Build an `mdxJsxTextElement` span node wrapping the given text.
138
+ *
139
+ * @param value - The emoji text to render inside the span.
140
+ * @param attributes - Attribute name/value pairs to set on the element.
141
+ */
142
+ function createMdxSpan(value, attributes) {
143
+ return {
144
+ type: "mdxJsxTextElement",
145
+ name: "span",
146
+ attributes: Object.entries(attributes).map(([name, value]) => ({
147
+ type: "mdxJsxAttribute",
148
+ name,
149
+ value,
150
+ })),
151
+ data: { _mdxExplicitJsx: true },
152
+ children: [{ type: "text", value }],
153
+ };
154
+ }
155
+ /**
156
+ * Build an `html` span node wrapping the given text.
157
+ *
158
+ * @param value - The emoji text to render inside the span.
159
+ * @param attributes - Attribute name/value pairs to serialize as HTML attributes.
160
+ */
161
+ function createHtmlSpan(value, attributes) {
162
+ return {
163
+ type: "html",
164
+ value: `<span ${Object.entries(attributes)
165
+ .map(([name, value]) => `${name}="${escapeHtml(value)}"`)
166
+ .join(" ")}>${escapeHtml(value)}</span>`,
167
+ };
168
+ }
169
+ /**
170
+ * Escape `&`, `<`, `>`, and `"` to their HTML entity equivalents.
171
+ *
172
+ * @param value - The raw string to escape.
173
+ * @returns The escaped string, safe for HTML text and double-quoted attributes.
174
+ *
175
+ * @example
176
+ * ```ts
177
+ * escapeHtml('Tom & Jerry'); // 'Tom &amp; Jerry'
178
+ * ```
179
+ */
180
+ function escapeHtml(value) {
181
+ return value.replace(/[&<>"]/g, (c) => HTML_ENTITIES[c]);
182
+ }
183
+ export default satteriEmoji;
184
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,SAAS,EACT,MAAM,EACN,UAAU,GAGX,MAAM,eAAe,CAAC;AAwFvB,kEAAkE;AAClE,MAAM,aAAa,GAA2B;IAC5C,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,QAAQ;CACd,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,YAAY,CAAC,UAA+B,EAAE;IAC5D,MAAM,MAAM,GAAW;QACrB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,OAAO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,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAE,CAAC,CAAC;AAC5D,CAAC;AAED,eAAe,YAAY,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Regular expression source matching emoji shortcodes.
3
+ */
4
+ export declare const RE_EMOJI: ":(?<shortcode>[^:\\s]+):";
5
+ /**
6
+ * Regular expression matching text emoticons.
7
+ */
8
+ export declare const RE_EMOTICON: "\\\\[Mm]\\/|<\\/?3|>:[\\(\\)\\/]|>0\\)|[Oo]:\\)|:(?:\\{>|\\'[\\(\\)Do]|[#\\$&\\(-\\*\\/3<>-@B-ELOPSXZcjlopsxz\\|])|D[:x]|%\\(|8[#\\)D]|;[\\)Pp]|X[\\(DOP]|x[\\(DPop]";
9
+ /**
10
+ * Built-in locale identifiers.
11
+ */
12
+ export type Locale = "bn" | "da" | "de" | "en" | "en-gb" | "es" | "es-mx" | "et" | "fi" | "fr" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "ms" | "nb" | "nl" | "pl" | "pt" | "ru" | "sv" | "th" | "uk" | "vi" | "zh" | "zh-hant";
13
+ /**
14
+ * Built-in shortcode catalog identifiers.
15
+ */
16
+ export type Catalog = "cldr" | "cldr-native" | "emojibase" | "emojibase-legacy" | "github" | "iamcal" | "joypixels";
17
+ /**
18
+ * Emoji hexcode identifier.
19
+ */
20
+ export type Hexcode = string;
21
+ /**
22
+ * Maps emoji hexcodes to rendered Unicode emoji.
23
+ *
24
+ * Example: `HEXCODES["1F600"] -> "😀"`.
25
+ */
26
+ export declare const HEXCODES: Record<Hexcode, string>;
27
+ /**
28
+ * Maps catalog names to emoji shortcodes by hexcode.
29
+ *
30
+ * Example: `SHORTCODES.github["+1"] -> "1F44D"`.
31
+ */
32
+ export declare const SHORTCODES: Record<Catalog, Record<string, Hexcode>>;
33
+ /**
34
+ * Maps text emoticons to emoji hexcodes.
35
+ *
36
+ * Example: `EMOTICONS[":)"] -> "1F642"`.
37
+ */
38
+ export declare const EMOTICONS: Record<string, Hexcode>;
39
+ /**
40
+ * Maps locale identifiers to emoji labels by hexcode.
41
+ *
42
+ * Example: `LABELS.en["1F600"] -> "grinning face"`.
43
+ */
44
+ export declare const LABELS: Record<Locale, Record<Hexcode, string>>;
45
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAG,0BAAmC,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,WAAW,EACtB,sKAA+K,CAAC;AAElL;;GAEG;AACH,MAAM,MAAM,MAAM,GACd,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,OAAO,GACP,IAAI,GACJ,OAAO,GACP,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,MAAM,OAAO,GACf,MAAM,GACN,aAAa,GACb,WAAW,GACX,kBAAkB,GAClB,QAAQ,GACR,QAAQ,GACR,WAAW,CAAC;AAEhB;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CA85D5C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAk1tB/D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAiE7C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CA63qD1D,CAAC"}