@atlaskit/emoji 72.5.19 → 73.0.1

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/cjs/api/EmojiResource.js +0 -28
  3. package/dist/cjs/api/EmojiUtils.js +1 -8
  4. package/dist/cjs/api/denormaliseEmojiServiceResponse.js +2 -2
  5. package/dist/cjs/api/denormaliseSkinEmoji.js +2 -2
  6. package/dist/cjs/api/media/SiteEmojiResource.js +3 -3
  7. package/dist/cjs/components/common/CachingMediaEmoji.js +1 -2
  8. package/dist/cjs/components/common/Emoji.js +4 -17
  9. package/dist/cjs/components/common/EmojiPreviewComponent.js +1 -4
  10. package/dist/cjs/components/common/EmojiRadioButton.js +1 -4
  11. package/dist/cjs/components/common/EmojiUploadPicker.js +5 -4
  12. package/dist/cjs/components/common/ResourcedEmojiComponent.js +4 -39
  13. package/dist/cjs/components/common/TonePreviewButton.js +2 -6
  14. package/dist/cjs/components/picker/CategorySelector.js +3 -3
  15. package/dist/cjs/components/picker/EmojiPickerEmojiRow.js +0 -3
  16. package/dist/cjs/util/analytics/createEvent.js +1 -1
  17. package/dist/cjs/util/type-helpers.js +0 -7
  18. package/dist/es2019/api/EmojiResource.js +0 -28
  19. package/dist/es2019/api/EmojiUtils.js +1 -5
  20. package/dist/es2019/api/denormaliseEmojiServiceResponse.js +2 -2
  21. package/dist/es2019/api/denormaliseSkinEmoji.js +2 -2
  22. package/dist/es2019/api/media/SiteEmojiResource.js +1 -1
  23. package/dist/es2019/components/common/CachingMediaEmoji.js +1 -2
  24. package/dist/es2019/components/common/Emoji.js +3 -16
  25. package/dist/es2019/components/common/EmojiPreviewComponent.js +1 -4
  26. package/dist/es2019/components/common/EmojiRadioButton.js +1 -4
  27. package/dist/es2019/components/common/EmojiUploadPicker.js +2 -2
  28. package/dist/es2019/components/common/ResourcedEmojiComponent.js +4 -38
  29. package/dist/es2019/components/common/TonePreviewButton.js +2 -6
  30. package/dist/es2019/components/picker/CategorySelector.js +1 -1
  31. package/dist/es2019/components/picker/EmojiPickerEmojiRow.js +0 -3
  32. package/dist/es2019/util/analytics/createEvent.js +1 -1
  33. package/dist/es2019/util/type-helpers.js +0 -4
  34. package/dist/esm/api/EmojiResource.js +0 -28
  35. package/dist/esm/api/EmojiUtils.js +1 -5
  36. package/dist/esm/api/denormaliseEmojiServiceResponse.js +2 -2
  37. package/dist/esm/api/denormaliseSkinEmoji.js +2 -2
  38. package/dist/esm/api/media/SiteEmojiResource.js +1 -1
  39. package/dist/esm/components/common/CachingMediaEmoji.js +1 -2
  40. package/dist/esm/components/common/Emoji.js +4 -17
  41. package/dist/esm/components/common/EmojiPreviewComponent.js +1 -4
  42. package/dist/esm/components/common/EmojiRadioButton.js +1 -4
  43. package/dist/esm/components/common/EmojiUploadPicker.js +2 -2
  44. package/dist/esm/components/common/ResourcedEmojiComponent.js +5 -40
  45. package/dist/esm/components/common/TonePreviewButton.js +2 -6
  46. package/dist/esm/components/picker/CategorySelector.js +1 -1
  47. package/dist/esm/components/picker/EmojiPickerEmojiRow.js +0 -3
  48. package/dist/esm/util/analytics/createEvent.js +1 -1
  49. package/dist/esm/util/type-helpers.js +0 -4
  50. package/dist/types/api/EmojiResource.d.ts +0 -6
  51. package/dist/types/api/EmojiUtils.d.ts +0 -4
  52. package/dist/types/api/calculateScale.d.ts +1 -1
  53. package/dist/types/api/media/SiteEmojiResource.d.ts +1 -1
  54. package/dist/types/components/common/Emoji.d.ts +1 -7
  55. package/dist/types/components/common/ResourcedEmojiComponent.d.ts +1 -6
  56. package/dist/types/types.d.ts +1 -15
  57. package/dist/types/util/type-helpers.d.ts +0 -4
  58. package/package.json +4 -4
  59. package/dist/cjs/api/denormaliseStandardRepresentation.js +0 -17
  60. package/dist/cjs/components/common/UnicodeEmoji.js +0 -137
  61. package/dist/cjs/util/emojiIdToEmoji.js +0 -119
  62. package/dist/cjs/util/is-unicode-representation.js +0 -9
  63. package/dist/cjs/util/renderUnicodeEmojiToImagePath.js +0 -56
  64. package/dist/es2019/api/denormaliseStandardRepresentation.js +0 -11
  65. package/dist/es2019/components/common/UnicodeEmoji.js +0 -125
  66. package/dist/es2019/util/emojiIdToEmoji.js +0 -93
  67. package/dist/es2019/util/is-unicode-representation.js +0 -1
  68. package/dist/es2019/util/renderUnicodeEmojiToImagePath.js +0 -24
  69. package/dist/esm/api/denormaliseStandardRepresentation.js +0 -11
  70. package/dist/esm/components/common/UnicodeEmoji.js +0 -128
  71. package/dist/esm/util/emojiIdToEmoji.js +0 -113
  72. package/dist/esm/util/is-unicode-representation.js +0 -3
  73. package/dist/esm/util/renderUnicodeEmojiToImagePath.js +0 -49
  74. package/dist/types/api/denormaliseStandardRepresentation.d.ts +0 -2
  75. package/dist/types/components/common/UnicodeEmoji.d.ts +0 -6
  76. package/dist/types/util/emojiIdToEmoji.d.ts +0 -16
  77. package/dist/types/util/is-unicode-representation.d.ts +0 -2
  78. package/dist/types/util/renderUnicodeEmojiToImagePath.d.ts +0 -1
  79. package/emoji-id-to-emoji/package.json +0 -10
  80. package/unicode-emoji-image/package.json +0 -10
@@ -1,56 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.renderUnicodeEmojiToImagePath = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
- var _isSsr = require("./is-ssr");
11
- var unicodeEmojiCanvasSize = 128;
12
- var unicodeEmojiCanvasFontSize = 124;
13
- var unicodeEmojiCanvasTopPadding = 8;
14
- var renderUnicodeEmojiToImagePath = exports.renderUnicodeEmojiToImagePath = /*#__PURE__*/function () {
15
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(unicodeEmoji) {
16
- var OffscreenCanvasCtor, canvas, context, blob;
17
- return _regenerator.default.wrap(function (_context) {
18
- while (1) switch (_context.prev = _context.next) {
19
- case 0:
20
- OffscreenCanvasCtor = globalThis['OffscreenCanvas'];
21
- if (!((0, _isSsr.isSSR)() || !OffscreenCanvasCtor || typeof URL === 'undefined')) {
22
- _context.next = 1;
23
- break;
24
- }
25
- return _context.abrupt("return", undefined);
26
- case 1:
27
- canvas = new OffscreenCanvasCtor(unicodeEmojiCanvasSize, unicodeEmojiCanvasSize);
28
- context = canvas.getContext('2d');
29
- if (context) {
30
- _context.next = 2;
31
- break;
32
- }
33
- return _context.abrupt("return", undefined);
34
- case 2:
35
- context.clearRect(0, 0, unicodeEmojiCanvasSize, unicodeEmojiCanvasSize);
36
- context.textAlign = 'center';
37
- context.textBaseline = 'middle';
38
- context.font = "".concat(unicodeEmojiCanvasFontSize, "px sans-serif");
39
- context.fillText(unicodeEmoji, unicodeEmojiCanvasSize / 2, unicodeEmojiCanvasSize / 2 + unicodeEmojiCanvasTopPadding);
40
- _context.next = 3;
41
- return canvas.convertToBlob({
42
- type: 'image/png'
43
- });
44
- case 3:
45
- blob = _context.sent;
46
- return _context.abrupt("return", URL.createObjectURL(blob));
47
- case 4:
48
- case "end":
49
- return _context.stop();
50
- }
51
- }, _callee);
52
- }));
53
- return function renderUnicodeEmojiToImagePath(_x) {
54
- return _ref.apply(this, arguments);
55
- };
56
- }();
@@ -1,11 +0,0 @@
1
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
2
- import { ProviderTypes } from '../types';
3
- import { emojiIdToEmoji } from '../util/emojiIdToEmoji';
4
- import { denormaliseServiceRepresentation } from './denormaliseServiceRepresentation';
5
- export const denormaliseStandardRepresentation = (emoji, meta) => {
6
- const unicodeEmoji = emojiIdToEmoji(emoji.id);
7
- const useUnicodeRepresentation = !!(emoji.id && emoji.type === ProviderTypes.STANDARD && unicodeEmoji && expValEqualsNoExposure('platform_use_unicode_emojis', 'isEnabled', true));
8
- return useUnicodeRepresentation ? {
9
- unicodeEmoji
10
- } : denormaliseServiceRepresentation(emoji.representation, meta);
11
- };
@@ -1,125 +0,0 @@
1
- /* UnicodeEmoji.tsx generated by @compiled/babel-plugin v3.0.2 */
2
- import _extends from "@babel/runtime/helpers/extends";
3
- import { ax, ix } from "@compiled/react/runtime";
4
- import React, { useEffect, useState } from 'react';
5
- import { defaultEmojiHeight } from '../../util/constants';
6
- import { isSSR } from '../../util/is-ssr';
7
- import { renderUnicodeEmojiToImagePath } from '../../util/renderUnicodeEmojiToImagePath';
8
- import { EmojiNodeWrapper, unicodeEmojiCanvasSize } from './Emoji';
9
- import EmojiPlaceholder from './EmojiPlaceholder';
10
- import { ImageEmoji } from './ImageEmoji';
11
- import { emojiNodeStyles, commonSelectedStyles, selectOnHoverStyles } from './styles';
12
- const useUnicodeEmojiImage = unicodeEmoji => {
13
- const [state, setState] = useState({
14
- status: 'loading'
15
- });
16
- useEffect(() => {
17
- let cancelled = false;
18
- let imagePathToRevoke;
19
- setState({
20
- status: 'loading',
21
- unicodeEmoji
22
- });
23
- void renderUnicodeEmojiToImagePath(unicodeEmoji).then(imagePath => {
24
- if (cancelled) {
25
- if (imagePath) {
26
- URL.revokeObjectURL(imagePath);
27
- }
28
- return;
29
- }
30
- imagePathToRevoke = imagePath;
31
- setState(imagePath ? {
32
- status: 'ready',
33
- unicodeEmoji,
34
- imagePath
35
- } : {
36
- status: 'failed',
37
- unicodeEmoji
38
- });
39
- }).catch(() => {
40
- if (!cancelled) {
41
- setState({
42
- status: 'failed',
43
- unicodeEmoji
44
- });
45
- }
46
- });
47
- return () => {
48
- cancelled = true;
49
- if (imagePathToRevoke) {
50
- URL.revokeObjectURL(imagePathToRevoke);
51
- }
52
- };
53
- }, [unicodeEmoji]);
54
- return state;
55
- };
56
- const UnicodeEmojiImage = props => {
57
- const {
58
- emoji,
59
- fitToHeight,
60
- showTooltip
61
- } = props;
62
- const emojiText = emoji.representation.unicodeEmoji;
63
- const unicodeEmojiImage = useUnicodeEmojiImage(emojiText);
64
- const hasCurrentEmojiImage = unicodeEmojiImage.unicodeEmoji === emojiText;
65
- if (isSSR() || !hasCurrentEmojiImage || unicodeEmojiImage.status === 'loading') {
66
- return /*#__PURE__*/React.createElement(EmojiPlaceholder, {
67
- shortName: emoji.shortName,
68
- showTooltip: showTooltip,
69
- size: fitToHeight,
70
- loading: true
71
- });
72
- }
73
- if (unicodeEmojiImage.status === 'ready') {
74
- return /*#__PURE__*/React.createElement(ImageEmoji, _extends({}, props, {
75
- emoji: {
76
- ...emoji,
77
- altRepresentation: undefined,
78
- representation: {
79
- imagePath: unicodeEmojiImage.imagePath,
80
- width: unicodeEmojiCanvasSize,
81
- height: unicodeEmojiCanvasSize
82
- }
83
- }
84
- }));
85
- }
86
- return /*#__PURE__*/React.createElement(EmojiPlaceholder, {
87
- shortName: emoji.shortName,
88
- showTooltip: showTooltip,
89
- size: fitToHeight
90
- });
91
- };
92
- export const UnicodeEmoji = props => {
93
- const {
94
- emoji,
95
- selected,
96
- selectOnHover,
97
- className,
98
- fitToHeight,
99
- renderUnicodeEmojiAsImage = true
100
- } = props;
101
- if (renderUnicodeEmojiAsImage) {
102
- return /*#__PURE__*/React.createElement(UnicodeEmojiImage, props);
103
- }
104
- const classes = `${emojiNodeStyles} ${selected ? commonSelectedStyles : ''} ${selectOnHover ? selectOnHoverStyles : ''} ${className ? className : ''}`;
105
- const emojiText = emoji.representation.unicodeEmoji;
106
- const defaultSize = `${fitToHeight !== null && fitToHeight !== void 0 ? fitToHeight : defaultEmojiHeight}px`;
107
- const emojiSize = `var(--emoji-common-unicode-size, ${defaultSize})`;
108
- const style = {
109
- display: 'inline-flex',
110
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
111
- fontSize: emojiSize,
112
- alignItems: 'center',
113
- aspectRatio: '1/1'
114
- };
115
- return (
116
- /*#__PURE__*/
117
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
118
- React.createElement(EmojiNodeWrapper, _extends({}, props, {
119
- type: "unicode",
120
- className: classes
121
- }), /*#__PURE__*/React.createElement("span", {
122
- style: style
123
- }, emojiText))
124
- );
125
- };
@@ -1,93 +0,0 @@
1
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
2
- const KEYCAP_COMBINING = 0x20e3;
3
- const VARIATION_SELECTOR_16 = 0xfe0f;
4
- const VARIATION_SELECTOR_15 = 0xfe0e;
5
- const EMOJI_MODIFIER_START = 0x1f3fb;
6
- const EMOJI_MODIFIER_END = 0x1f3ff;
7
- const REGIONAL_INDICATOR_START = 0x1f1e6;
8
- const REGIONAL_INDICATOR_END = 0x1f1ff;
9
- const FLAG_BASES = new Set([0x1f38c, 0x1f3c1, 0x1f3f3, 0x1f3f4, 0x1f6a9]);
10
-
11
- // Emoji variation bases from Unicode 14.0 emoji-variation-sequences.txt.
12
- // These are the code points with a defined U+FE0F emoji-style variant.
13
- const EMOJI_VARIATION_BASES = new Set([0x0023, 0x002a, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x00a9, 0x00ae, 0x203c, 0x2049, 0x2122, 0x2139, 0x2194, 0x2195, 0x2196, 0x2197, 0x2198, 0x2199, 0x21a9, 0x21aa, 0x2328, 0x23cf, 0x23ed, 0x23ee, 0x23ef, 0x23f1, 0x23f2, 0x23f8, 0x23f9, 0x23fa, 0x24c2, 0x25aa, 0x25ab, 0x25b6, 0x25c0, 0x25fb, 0x25fc, 0x2600, 0x2601, 0x2602, 0x2603, 0x2604, 0x260e, 0x2611, 0x2618, 0x261d, 0x2620, 0x2622, 0x2623, 0x2626, 0x262a, 0x262e, 0x262f, 0x2638, 0x2639, 0x263a, 0x2640, 0x2642, 0x265f, 0x2660, 0x2663, 0x2665, 0x2666, 0x2668, 0x267b, 0x267e, 0x2692, 0x2694, 0x2695, 0x2696, 0x2697, 0x2699, 0x269b, 0x269c, 0x26a0, 0x26a7, 0x26b0, 0x26b1, 0x26c8, 0x26cf, 0x26d1, 0x26d3, 0x26e9, 0x26f0, 0x26f1, 0x26f4, 0x26f7, 0x26f8, 0x26f9, 0x2702, 0x2708, 0x2709, 0x270c, 0x270d, 0x270f, 0x2712, 0x2714, 0x2716, 0x271d, 0x2721, 0x2733, 0x2734, 0x2744, 0x2747, 0x2763, 0x2764, 0x27a1, 0x2934, 0x2935, 0x2b05, 0x2b06, 0x2b07, 0x3030, 0x303d, 0x3297, 0x3299, 0x1f170, 0x1f171, 0x1f17e, 0x1f17f, 0x1f202, 0x1f237, 0x1f321, 0x1f324, 0x1f325, 0x1f326, 0x1f327, 0x1f328, 0x1f329, 0x1f32a, 0x1f32b, 0x1f32c, 0x1f336, 0x1f37d, 0x1f396, 0x1f397, 0x1f399, 0x1f39a, 0x1f39b, 0x1f39e, 0x1f39f, 0x1f3cb, 0x1f3cc, 0x1f3cd, 0x1f3ce, 0x1f3d4, 0x1f3d5, 0x1f3d6, 0x1f3d7, 0x1f3d8, 0x1f3d9, 0x1f3da, 0x1f3db, 0x1f3dc, 0x1f3dd, 0x1f3de, 0x1f3df, 0x1f3f3, 0x1f3f5, 0x1f3f7, 0x1f43f, 0x1f441, 0x1f4fd, 0x1f549, 0x1f54a, 0x1f56f, 0x1f570, 0x1f573, 0x1f574, 0x1f575, 0x1f576, 0x1f577, 0x1f578, 0x1f579, 0x1f587, 0x1f58a, 0x1f58b, 0x1f58c, 0x1f58d, 0x1f590, 0x1f5a5, 0x1f5a8, 0x1f5b1, 0x1f5b2, 0x1f5bc, 0x1f5c2, 0x1f5c3, 0x1f5c4, 0x1f5d1, 0x1f5d2, 0x1f5d3, 0x1f5dc, 0x1f5dd, 0x1f5de, 0x1f5e1, 0x1f5e3, 0x1f5e8, 0x1f5ef, 0x1f5f3, 0x1f5fa, 0x1f6cb, 0x1f6cd, 0x1f6ce, 0x1f6cf, 0x1f6e0, 0x1f6e1, 0x1f6e2, 0x1f6e3, 0x1f6e4, 0x1f6e5, 0x1f6e9, 0x1f6f0, 0x1f6f3, 0x231a, 0x231b, 0x23e9, 0x23ea, 0x23f3, 0x25fd, 0x25fe, 0x2614, 0x2615, 0x2648, 0x2649, 0x264a, 0x264b, 0x264c, 0x264d, 0x264e, 0x264f, 0x2650, 0x2651, 0x2652, 0x2653, 0x267f, 0x2693, 0x26a1, 0x26aa, 0x26ab, 0x26bd, 0x26be, 0x26c4, 0x26c5, 0x26d4, 0x26ea, 0x26f2, 0x26f3, 0x26f5, 0x26fa, 0x26fd, 0x2753, 0x2757, 0x2b1b, 0x2b1c, 0x2b50, 0x2b55, 0x1f004, 0x1f21a, 0x1f22f, 0x1f30d, 0x1f30e, 0x1f30f, 0x1f315, 0x1f31c, 0x1f378, 0x1f393, 0x1f3a7, 0x1f3ac, 0x1f3ad, 0x1f3ae, 0x1f3c2, 0x1f3c4, 0x1f3c6, 0x1f3ca, 0x1f3e0, 0x1f3ed, 0x1f408, 0x1f415, 0x1f41f, 0x1f426, 0x1f442, 0x1f446, 0x1f447, 0x1f448, 0x1f449, 0x1f44d, 0x1f44e, 0x1f453, 0x1f46a, 0x1f47d, 0x1f4a3, 0x1f4b0, 0x1f4b3, 0x1f4bb, 0x1f4bf, 0x1f4cb, 0x1f4da, 0x1f4df, 0x1f4e4, 0x1f4e5, 0x1f4e6, 0x1f4ea, 0x1f4eb, 0x1f4ec, 0x1f4ed, 0x1f4f7, 0x1f4f9, 0x1f4fa, 0x1f4fb, 0x1f508, 0x1f50d, 0x1f512, 0x1f513, 0x1f550, 0x1f551, 0x1f552, 0x1f553, 0x1f554, 0x1f555, 0x1f556, 0x1f557, 0x1f558, 0x1f559, 0x1f55a, 0x1f55b, 0x1f55c, 0x1f55d, 0x1f55e, 0x1f55f, 0x1f560, 0x1f561, 0x1f562, 0x1f563, 0x1f564, 0x1f565, 0x1f566, 0x1f567, 0x1f610, 0x1f687, 0x1f68d, 0x1f691, 0x1f694, 0x1f698, 0x1f6ad, 0x1f6b2, 0x1f6b9, 0x1f6ba, 0x1f6bc]);
14
- const isEmojiModifier = codePoint => typeof codePoint === 'number' && codePoint >= EMOJI_MODIFIER_START && codePoint <= EMOJI_MODIFIER_END;
15
- const shouldAddEmojiPresentationSelector = (codePoint, nextCodePoint) => EMOJI_VARIATION_BASES.has(codePoint) && nextCodePoint !== VARIATION_SELECTOR_16 && nextCodePoint !== VARIATION_SELECTOR_15 && nextCodePoint !== KEYCAP_COMBINING && !isEmojiModifier(nextCodePoint);
16
- const isRegionalIndicator = codePoint => codePoint >= REGIONAL_INDICATOR_START && codePoint <= REGIONAL_INDICATOR_END;
17
- const isStandaloneRegionalIndicator = codePoints => codePoints.length === 1 && isRegionalIndicator(codePoints[0]);
18
- const parseEmojiIdCodePoints = id => {
19
- const segments = id.split('-');
20
- const codePoints = [];
21
- for (const segment of segments) {
22
- if (!/^[0-9a-fA-F]+$/.test(segment)) {
23
- return undefined;
24
- }
25
- const cp = parseInt(segment, 16);
26
- // Valid Unicode scalar values: U+0000–U+10FFFF, excluding surrogates.
27
- if (isNaN(cp) || cp < 0 || cp > 0x10ffff || cp >= 0xd800 && cp <= 0xdfff) {
28
- return undefined;
29
- }
30
- codePoints.push(cp);
31
- }
32
- return codePoints.length ? codePoints : undefined;
33
- };
34
- const isFlagEmoji = codePoints => {
35
- if (codePoints.length === 2 && codePoints.every(isRegionalIndicator)) {
36
- return true;
37
- }
38
- return FLAG_BASES.has(codePoints[0]);
39
- };
40
-
41
- /**
42
- * Converts an emoji ID (a hyphen-separated string of hex Unicode code points,
43
- * e.g. `"1f44d"`, `"1f44d-1f3fb"`, `"1f468-200d-1f469-200d-1f467"`) into its
44
- * corresponding Unicode string.
45
- *
46
- * Special handling:
47
- * - Keycap sequences: U+20E3 (COMBINING ENCLOSING KEYCAP) must be preceded by
48
- * U+FE0F (VARIATION SELECTOR-16) to form a well-defined keycap emoji.
49
- * - Emoji variation bases are followed by U+FE0F to force emoji presentation.
50
- * - Flags and standalone regional indicators return `undefined` so callers use
51
- * Twemoji instead of native emoji.
52
- *
53
- * @returns The Unicode string for the emoji, or `undefined` if the input is
54
- * invalid (empty string, non-hex segments, or out-of-range code points).
55
- */
56
- export function emojiIdToEmoji(id) {
57
- if (!expValEqualsNoExposure('platform_use_unicode_emojis', 'isEnabled', true)) {
58
- return undefined;
59
- }
60
- if (!id) {
61
- return undefined;
62
- }
63
- const codePoints = parseEmojiIdCodePoints(id);
64
- if (!codePoints) {
65
- return undefined;
66
- }
67
- if (isStandaloneRegionalIndicator(codePoints) || isFlagEmoji(codePoints)) {
68
- return undefined;
69
- }
70
- const processedCodePoints = [];
71
- for (let i = 0; i < codePoints.length; i++) {
72
- const cp = codePoints[i];
73
- const next = codePoints[i + 1];
74
- processedCodePoints.push(cp);
75
-
76
- // Insert U+FE0F before U+20E3 if not already present.
77
- // Keycap sequences: digit/# /* followed by U+20E3 need U+FE0F between them.
78
- if (next === KEYCAP_COMBINING && cp !== VARIATION_SELECTOR_16) {
79
- processedCodePoints.push(VARIATION_SELECTOR_16);
80
- }
81
-
82
- // Emoji variation bases need U+FE0F immediately after the base code point,
83
- // including when the base appears inside a ZWJ sequence.
84
- if (shouldAddEmojiPresentationSelector(cp, next)) {
85
- processedCodePoints.push(VARIATION_SELECTOR_16);
86
- }
87
- }
88
- try {
89
- return String.fromCodePoint(...processedCodePoints);
90
- } catch {
91
- return undefined;
92
- }
93
- }
@@ -1 +0,0 @@
1
- export const isUnicodeRepresentation = rep => !!(rep && rep.unicodeEmoji);
@@ -1,24 +0,0 @@
1
- import { isSSR } from './is-ssr';
2
- const unicodeEmojiCanvasSize = 128;
3
- const unicodeEmojiCanvasFontSize = 124;
4
- const unicodeEmojiCanvasTopPadding = 8;
5
- export const renderUnicodeEmojiToImagePath = async unicodeEmoji => {
6
- const OffscreenCanvasCtor = globalThis['OffscreenCanvas'];
7
- if (isSSR() || !OffscreenCanvasCtor || typeof URL === 'undefined') {
8
- return undefined;
9
- }
10
- const canvas = new OffscreenCanvasCtor(unicodeEmojiCanvasSize, unicodeEmojiCanvasSize);
11
- const context = canvas.getContext('2d');
12
- if (!context) {
13
- return undefined;
14
- }
15
- context.clearRect(0, 0, unicodeEmojiCanvasSize, unicodeEmojiCanvasSize);
16
- context.textAlign = 'center';
17
- context.textBaseline = 'middle';
18
- context.font = `${unicodeEmojiCanvasFontSize}px sans-serif`;
19
- context.fillText(unicodeEmoji, unicodeEmojiCanvasSize / 2, unicodeEmojiCanvasSize / 2 + unicodeEmojiCanvasTopPadding);
20
- const blob = await canvas.convertToBlob({
21
- type: 'image/png'
22
- });
23
- return URL.createObjectURL(blob);
24
- };
@@ -1,11 +0,0 @@
1
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
2
- import { ProviderTypes } from '../types';
3
- import { emojiIdToEmoji } from '../util/emojiIdToEmoji';
4
- import { denormaliseServiceRepresentation } from './denormaliseServiceRepresentation';
5
- export var denormaliseStandardRepresentation = function denormaliseStandardRepresentation(emoji, meta) {
6
- var unicodeEmoji = emojiIdToEmoji(emoji.id);
7
- var useUnicodeRepresentation = !!(emoji.id && emoji.type === ProviderTypes.STANDARD && unicodeEmoji && expValEqualsNoExposure('platform_use_unicode_emojis', 'isEnabled', true));
8
- return useUnicodeRepresentation ? {
9
- unicodeEmoji: unicodeEmoji
10
- } : denormaliseServiceRepresentation(emoji.representation, meta);
11
- };
@@ -1,128 +0,0 @@
1
- /* UnicodeEmoji.tsx generated by @compiled/babel-plugin v3.0.2 */
2
- import _extends from "@babel/runtime/helpers/extends";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
- import { ax, ix } from "@compiled/react/runtime";
6
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
- import React, { useEffect, useState } from 'react';
9
- import { defaultEmojiHeight } from '../../util/constants';
10
- import { isSSR } from '../../util/is-ssr';
11
- import { renderUnicodeEmojiToImagePath } from '../../util/renderUnicodeEmojiToImagePath';
12
- import { EmojiNodeWrapper, unicodeEmojiCanvasSize } from './Emoji';
13
- import EmojiPlaceholder from './EmojiPlaceholder';
14
- import { ImageEmoji } from './ImageEmoji';
15
- import { emojiNodeStyles, commonSelectedStyles, selectOnHoverStyles } from './styles';
16
- var useUnicodeEmojiImage = function useUnicodeEmojiImage(unicodeEmoji) {
17
- var _useState = useState({
18
- status: 'loading'
19
- }),
20
- _useState2 = _slicedToArray(_useState, 2),
21
- state = _useState2[0],
22
- setState = _useState2[1];
23
- useEffect(function () {
24
- var cancelled = false;
25
- var imagePathToRevoke;
26
- setState({
27
- status: 'loading',
28
- unicodeEmoji: unicodeEmoji
29
- });
30
- void renderUnicodeEmojiToImagePath(unicodeEmoji).then(function (imagePath) {
31
- if (cancelled) {
32
- if (imagePath) {
33
- URL.revokeObjectURL(imagePath);
34
- }
35
- return;
36
- }
37
- imagePathToRevoke = imagePath;
38
- setState(imagePath ? {
39
- status: 'ready',
40
- unicodeEmoji: unicodeEmoji,
41
- imagePath: imagePath
42
- } : {
43
- status: 'failed',
44
- unicodeEmoji: unicodeEmoji
45
- });
46
- }).catch(function () {
47
- if (!cancelled) {
48
- setState({
49
- status: 'failed',
50
- unicodeEmoji: unicodeEmoji
51
- });
52
- }
53
- });
54
- return function () {
55
- cancelled = true;
56
- if (imagePathToRevoke) {
57
- URL.revokeObjectURL(imagePathToRevoke);
58
- }
59
- };
60
- }, [unicodeEmoji]);
61
- return state;
62
- };
63
- var UnicodeEmojiImage = function UnicodeEmojiImage(props) {
64
- var emoji = props.emoji,
65
- fitToHeight = props.fitToHeight,
66
- showTooltip = props.showTooltip;
67
- var emojiText = emoji.representation.unicodeEmoji;
68
- var unicodeEmojiImage = useUnicodeEmojiImage(emojiText);
69
- var hasCurrentEmojiImage = unicodeEmojiImage.unicodeEmoji === emojiText;
70
- if (isSSR() || !hasCurrentEmojiImage || unicodeEmojiImage.status === 'loading') {
71
- return /*#__PURE__*/React.createElement(EmojiPlaceholder, {
72
- shortName: emoji.shortName,
73
- showTooltip: showTooltip,
74
- size: fitToHeight,
75
- loading: true
76
- });
77
- }
78
- if (unicodeEmojiImage.status === 'ready') {
79
- return /*#__PURE__*/React.createElement(ImageEmoji, _extends({}, props, {
80
- emoji: _objectSpread(_objectSpread({}, emoji), {}, {
81
- altRepresentation: undefined,
82
- representation: {
83
- imagePath: unicodeEmojiImage.imagePath,
84
- width: unicodeEmojiCanvasSize,
85
- height: unicodeEmojiCanvasSize
86
- }
87
- })
88
- }));
89
- }
90
- return /*#__PURE__*/React.createElement(EmojiPlaceholder, {
91
- shortName: emoji.shortName,
92
- showTooltip: showTooltip,
93
- size: fitToHeight
94
- });
95
- };
96
- export var UnicodeEmoji = function UnicodeEmoji(props) {
97
- var emoji = props.emoji,
98
- selected = props.selected,
99
- selectOnHover = props.selectOnHover,
100
- className = props.className,
101
- fitToHeight = props.fitToHeight,
102
- _props$renderUnicodeE = props.renderUnicodeEmojiAsImage,
103
- renderUnicodeEmojiAsImage = _props$renderUnicodeE === void 0 ? true : _props$renderUnicodeE;
104
- if (renderUnicodeEmojiAsImage) {
105
- return /*#__PURE__*/React.createElement(UnicodeEmojiImage, props);
106
- }
107
- var classes = "".concat(emojiNodeStyles, " ").concat(selected ? commonSelectedStyles : '', " ").concat(selectOnHover ? selectOnHoverStyles : '', " ").concat(className ? className : '');
108
- var emojiText = emoji.representation.unicodeEmoji;
109
- var defaultSize = "".concat(fitToHeight !== null && fitToHeight !== void 0 ? fitToHeight : defaultEmojiHeight, "px");
110
- var emojiSize = "var(--emoji-common-unicode-size, ".concat(defaultSize, ")");
111
- var style = {
112
- display: 'inline-flex',
113
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
114
- fontSize: emojiSize,
115
- alignItems: 'center',
116
- aspectRatio: '1/1'
117
- };
118
- return (
119
- /*#__PURE__*/
120
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
121
- React.createElement(EmojiNodeWrapper, _extends({}, props, {
122
- type: "unicode",
123
- className: classes
124
- }), /*#__PURE__*/React.createElement("span", {
125
- style: style
126
- }, emojiText))
127
- );
128
- };
@@ -1,113 +0,0 @@
1
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
2
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
3
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
4
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
5
- var KEYCAP_COMBINING = 0x20e3;
6
- var VARIATION_SELECTOR_16 = 0xfe0f;
7
- var VARIATION_SELECTOR_15 = 0xfe0e;
8
- var EMOJI_MODIFIER_START = 0x1f3fb;
9
- var EMOJI_MODIFIER_END = 0x1f3ff;
10
- var REGIONAL_INDICATOR_START = 0x1f1e6;
11
- var REGIONAL_INDICATOR_END = 0x1f1ff;
12
- var FLAG_BASES = new Set([0x1f38c, 0x1f3c1, 0x1f3f3, 0x1f3f4, 0x1f6a9]);
13
-
14
- // Emoji variation bases from Unicode 14.0 emoji-variation-sequences.txt.
15
- // These are the code points with a defined U+FE0F emoji-style variant.
16
- var EMOJI_VARIATION_BASES = new Set([0x0023, 0x002a, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x00a9, 0x00ae, 0x203c, 0x2049, 0x2122, 0x2139, 0x2194, 0x2195, 0x2196, 0x2197, 0x2198, 0x2199, 0x21a9, 0x21aa, 0x2328, 0x23cf, 0x23ed, 0x23ee, 0x23ef, 0x23f1, 0x23f2, 0x23f8, 0x23f9, 0x23fa, 0x24c2, 0x25aa, 0x25ab, 0x25b6, 0x25c0, 0x25fb, 0x25fc, 0x2600, 0x2601, 0x2602, 0x2603, 0x2604, 0x260e, 0x2611, 0x2618, 0x261d, 0x2620, 0x2622, 0x2623, 0x2626, 0x262a, 0x262e, 0x262f, 0x2638, 0x2639, 0x263a, 0x2640, 0x2642, 0x265f, 0x2660, 0x2663, 0x2665, 0x2666, 0x2668, 0x267b, 0x267e, 0x2692, 0x2694, 0x2695, 0x2696, 0x2697, 0x2699, 0x269b, 0x269c, 0x26a0, 0x26a7, 0x26b0, 0x26b1, 0x26c8, 0x26cf, 0x26d1, 0x26d3, 0x26e9, 0x26f0, 0x26f1, 0x26f4, 0x26f7, 0x26f8, 0x26f9, 0x2702, 0x2708, 0x2709, 0x270c, 0x270d, 0x270f, 0x2712, 0x2714, 0x2716, 0x271d, 0x2721, 0x2733, 0x2734, 0x2744, 0x2747, 0x2763, 0x2764, 0x27a1, 0x2934, 0x2935, 0x2b05, 0x2b06, 0x2b07, 0x3030, 0x303d, 0x3297, 0x3299, 0x1f170, 0x1f171, 0x1f17e, 0x1f17f, 0x1f202, 0x1f237, 0x1f321, 0x1f324, 0x1f325, 0x1f326, 0x1f327, 0x1f328, 0x1f329, 0x1f32a, 0x1f32b, 0x1f32c, 0x1f336, 0x1f37d, 0x1f396, 0x1f397, 0x1f399, 0x1f39a, 0x1f39b, 0x1f39e, 0x1f39f, 0x1f3cb, 0x1f3cc, 0x1f3cd, 0x1f3ce, 0x1f3d4, 0x1f3d5, 0x1f3d6, 0x1f3d7, 0x1f3d8, 0x1f3d9, 0x1f3da, 0x1f3db, 0x1f3dc, 0x1f3dd, 0x1f3de, 0x1f3df, 0x1f3f3, 0x1f3f5, 0x1f3f7, 0x1f43f, 0x1f441, 0x1f4fd, 0x1f549, 0x1f54a, 0x1f56f, 0x1f570, 0x1f573, 0x1f574, 0x1f575, 0x1f576, 0x1f577, 0x1f578, 0x1f579, 0x1f587, 0x1f58a, 0x1f58b, 0x1f58c, 0x1f58d, 0x1f590, 0x1f5a5, 0x1f5a8, 0x1f5b1, 0x1f5b2, 0x1f5bc, 0x1f5c2, 0x1f5c3, 0x1f5c4, 0x1f5d1, 0x1f5d2, 0x1f5d3, 0x1f5dc, 0x1f5dd, 0x1f5de, 0x1f5e1, 0x1f5e3, 0x1f5e8, 0x1f5ef, 0x1f5f3, 0x1f5fa, 0x1f6cb, 0x1f6cd, 0x1f6ce, 0x1f6cf, 0x1f6e0, 0x1f6e1, 0x1f6e2, 0x1f6e3, 0x1f6e4, 0x1f6e5, 0x1f6e9, 0x1f6f0, 0x1f6f3, 0x231a, 0x231b, 0x23e9, 0x23ea, 0x23f3, 0x25fd, 0x25fe, 0x2614, 0x2615, 0x2648, 0x2649, 0x264a, 0x264b, 0x264c, 0x264d, 0x264e, 0x264f, 0x2650, 0x2651, 0x2652, 0x2653, 0x267f, 0x2693, 0x26a1, 0x26aa, 0x26ab, 0x26bd, 0x26be, 0x26c4, 0x26c5, 0x26d4, 0x26ea, 0x26f2, 0x26f3, 0x26f5, 0x26fa, 0x26fd, 0x2753, 0x2757, 0x2b1b, 0x2b1c, 0x2b50, 0x2b55, 0x1f004, 0x1f21a, 0x1f22f, 0x1f30d, 0x1f30e, 0x1f30f, 0x1f315, 0x1f31c, 0x1f378, 0x1f393, 0x1f3a7, 0x1f3ac, 0x1f3ad, 0x1f3ae, 0x1f3c2, 0x1f3c4, 0x1f3c6, 0x1f3ca, 0x1f3e0, 0x1f3ed, 0x1f408, 0x1f415, 0x1f41f, 0x1f426, 0x1f442, 0x1f446, 0x1f447, 0x1f448, 0x1f449, 0x1f44d, 0x1f44e, 0x1f453, 0x1f46a, 0x1f47d, 0x1f4a3, 0x1f4b0, 0x1f4b3, 0x1f4bb, 0x1f4bf, 0x1f4cb, 0x1f4da, 0x1f4df, 0x1f4e4, 0x1f4e5, 0x1f4e6, 0x1f4ea, 0x1f4eb, 0x1f4ec, 0x1f4ed, 0x1f4f7, 0x1f4f9, 0x1f4fa, 0x1f4fb, 0x1f508, 0x1f50d, 0x1f512, 0x1f513, 0x1f550, 0x1f551, 0x1f552, 0x1f553, 0x1f554, 0x1f555, 0x1f556, 0x1f557, 0x1f558, 0x1f559, 0x1f55a, 0x1f55b, 0x1f55c, 0x1f55d, 0x1f55e, 0x1f55f, 0x1f560, 0x1f561, 0x1f562, 0x1f563, 0x1f564, 0x1f565, 0x1f566, 0x1f567, 0x1f610, 0x1f687, 0x1f68d, 0x1f691, 0x1f694, 0x1f698, 0x1f6ad, 0x1f6b2, 0x1f6b9, 0x1f6ba, 0x1f6bc]);
17
- var isEmojiModifier = function isEmojiModifier(codePoint) {
18
- return typeof codePoint === 'number' && codePoint >= EMOJI_MODIFIER_START && codePoint <= EMOJI_MODIFIER_END;
19
- };
20
- var shouldAddEmojiPresentationSelector = function shouldAddEmojiPresentationSelector(codePoint, nextCodePoint) {
21
- return EMOJI_VARIATION_BASES.has(codePoint) && nextCodePoint !== VARIATION_SELECTOR_16 && nextCodePoint !== VARIATION_SELECTOR_15 && nextCodePoint !== KEYCAP_COMBINING && !isEmojiModifier(nextCodePoint);
22
- };
23
- var isRegionalIndicator = function isRegionalIndicator(codePoint) {
24
- return codePoint >= REGIONAL_INDICATOR_START && codePoint <= REGIONAL_INDICATOR_END;
25
- };
26
- var isStandaloneRegionalIndicator = function isStandaloneRegionalIndicator(codePoints) {
27
- return codePoints.length === 1 && isRegionalIndicator(codePoints[0]);
28
- };
29
- var parseEmojiIdCodePoints = function parseEmojiIdCodePoints(id) {
30
- var segments = id.split('-');
31
- var codePoints = [];
32
- var _iterator = _createForOfIteratorHelper(segments),
33
- _step;
34
- try {
35
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
36
- var segment = _step.value;
37
- if (!/^[0-9a-fA-F]+$/.test(segment)) {
38
- return undefined;
39
- }
40
- var cp = parseInt(segment, 16);
41
- // Valid Unicode scalar values: U+0000–U+10FFFF, excluding surrogates.
42
- if (isNaN(cp) || cp < 0 || cp > 0x10ffff || cp >= 0xd800 && cp <= 0xdfff) {
43
- return undefined;
44
- }
45
- codePoints.push(cp);
46
- }
47
- } catch (err) {
48
- _iterator.e(err);
49
- } finally {
50
- _iterator.f();
51
- }
52
- return codePoints.length ? codePoints : undefined;
53
- };
54
- var isFlagEmoji = function isFlagEmoji(codePoints) {
55
- if (codePoints.length === 2 && codePoints.every(isRegionalIndicator)) {
56
- return true;
57
- }
58
- return FLAG_BASES.has(codePoints[0]);
59
- };
60
-
61
- /**
62
- * Converts an emoji ID (a hyphen-separated string of hex Unicode code points,
63
- * e.g. `"1f44d"`, `"1f44d-1f3fb"`, `"1f468-200d-1f469-200d-1f467"`) into its
64
- * corresponding Unicode string.
65
- *
66
- * Special handling:
67
- * - Keycap sequences: U+20E3 (COMBINING ENCLOSING KEYCAP) must be preceded by
68
- * U+FE0F (VARIATION SELECTOR-16) to form a well-defined keycap emoji.
69
- * - Emoji variation bases are followed by U+FE0F to force emoji presentation.
70
- * - Flags and standalone regional indicators return `undefined` so callers use
71
- * Twemoji instead of native emoji.
72
- *
73
- * @returns The Unicode string for the emoji, or `undefined` if the input is
74
- * invalid (empty string, non-hex segments, or out-of-range code points).
75
- */
76
- export function emojiIdToEmoji(id) {
77
- if (!expValEqualsNoExposure('platform_use_unicode_emojis', 'isEnabled', true)) {
78
- return undefined;
79
- }
80
- if (!id) {
81
- return undefined;
82
- }
83
- var codePoints = parseEmojiIdCodePoints(id);
84
- if (!codePoints) {
85
- return undefined;
86
- }
87
- if (isStandaloneRegionalIndicator(codePoints) || isFlagEmoji(codePoints)) {
88
- return undefined;
89
- }
90
- var processedCodePoints = [];
91
- for (var i = 0; i < codePoints.length; i++) {
92
- var cp = codePoints[i];
93
- var next = codePoints[i + 1];
94
- processedCodePoints.push(cp);
95
-
96
- // Insert U+FE0F before U+20E3 if not already present.
97
- // Keycap sequences: digit/# /* followed by U+20E3 need U+FE0F between them.
98
- if (next === KEYCAP_COMBINING && cp !== VARIATION_SELECTOR_16) {
99
- processedCodePoints.push(VARIATION_SELECTOR_16);
100
- }
101
-
102
- // Emoji variation bases need U+FE0F immediately after the base code point,
103
- // including when the base appears inside a ZWJ sequence.
104
- if (shouldAddEmojiPresentationSelector(cp, next)) {
105
- processedCodePoints.push(VARIATION_SELECTOR_16);
106
- }
107
- }
108
- try {
109
- return String.fromCodePoint.apply(String, processedCodePoints);
110
- } catch (_unused) {
111
- return undefined;
112
- }
113
- }
@@ -1,3 +0,0 @@
1
- export var isUnicodeRepresentation = function isUnicodeRepresentation(rep) {
2
- return !!(rep && rep.unicodeEmoji);
3
- };
@@ -1,49 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
- import _regeneratorRuntime from "@babel/runtime/regenerator";
3
- import { isSSR } from './is-ssr';
4
- var unicodeEmojiCanvasSize = 128;
5
- var unicodeEmojiCanvasFontSize = 124;
6
- var unicodeEmojiCanvasTopPadding = 8;
7
- export var renderUnicodeEmojiToImagePath = /*#__PURE__*/function () {
8
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(unicodeEmoji) {
9
- var OffscreenCanvasCtor, canvas, context, blob;
10
- return _regeneratorRuntime.wrap(function (_context) {
11
- while (1) switch (_context.prev = _context.next) {
12
- case 0:
13
- OffscreenCanvasCtor = globalThis['OffscreenCanvas'];
14
- if (!(isSSR() || !OffscreenCanvasCtor || typeof URL === 'undefined')) {
15
- _context.next = 1;
16
- break;
17
- }
18
- return _context.abrupt("return", undefined);
19
- case 1:
20
- canvas = new OffscreenCanvasCtor(unicodeEmojiCanvasSize, unicodeEmojiCanvasSize);
21
- context = canvas.getContext('2d');
22
- if (context) {
23
- _context.next = 2;
24
- break;
25
- }
26
- return _context.abrupt("return", undefined);
27
- case 2:
28
- context.clearRect(0, 0, unicodeEmojiCanvasSize, unicodeEmojiCanvasSize);
29
- context.textAlign = 'center';
30
- context.textBaseline = 'middle';
31
- context.font = "".concat(unicodeEmojiCanvasFontSize, "px sans-serif");
32
- context.fillText(unicodeEmoji, unicodeEmojiCanvasSize / 2, unicodeEmojiCanvasSize / 2 + unicodeEmojiCanvasTopPadding);
33
- _context.next = 3;
34
- return canvas.convertToBlob({
35
- type: 'image/png'
36
- });
37
- case 3:
38
- blob = _context.sent;
39
- return _context.abrupt("return", URL.createObjectURL(blob));
40
- case 4:
41
- case "end":
42
- return _context.stop();
43
- }
44
- }, _callee);
45
- }));
46
- return function renderUnicodeEmojiToImagePath(_x) {
47
- return _ref.apply(this, arguments);
48
- };
49
- }();
@@ -1,2 +0,0 @@
1
- import { type EmojiMeta, type EmojiRepresentation, type EmojiServiceDescription } from '../types';
2
- export declare const denormaliseStandardRepresentation: (emoji: EmojiServiceDescription, meta?: EmojiMeta) => EmojiRepresentation;
@@ -1,6 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
- import type { Props } from './Emoji';
6
- export declare const UnicodeEmoji: (props: Props) => JSX.Element;
@@ -1,16 +0,0 @@
1
- /**
2
- * Converts an emoji ID (a hyphen-separated string of hex Unicode code points,
3
- * e.g. `"1f44d"`, `"1f44d-1f3fb"`, `"1f468-200d-1f469-200d-1f467"`) into its
4
- * corresponding Unicode string.
5
- *
6
- * Special handling:
7
- * - Keycap sequences: U+20E3 (COMBINING ENCLOSING KEYCAP) must be preceded by
8
- * U+FE0F (VARIATION SELECTOR-16) to form a well-defined keycap emoji.
9
- * - Emoji variation bases are followed by U+FE0F to force emoji presentation.
10
- * - Flags and standalone regional indicators return `undefined` so callers use
11
- * Twemoji instead of native emoji.
12
- *
13
- * @returns The Unicode string for the emoji, or `undefined` if the input is
14
- * invalid (empty string, non-hex segments, or out-of-range code points).
15
- */
16
- export declare function emojiIdToEmoji(id: string): string | undefined;