@hcengineering/emoji 0.7.423

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/lib/index.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
+ default: () => index_default,
23
+ emojiId: () => import_plugin.emojiId
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ var import_plugin = require("./plugin");
27
+ __reExport(index_exports, require("./types"), module.exports);
28
+ __reExport(index_exports, require("./utils"), module.exports);
29
+ var index_default = import_plugin.emojiPlugin;
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["//\n// Copyright \u00A9 2025 Hardcore Engineering Inc.\n//\n// Licensed under the Eclipse Public License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License. You may\n// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n//\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//\nimport { emojiId, emojiPlugin } from './plugin'\n\nexport * from './types'\nexport * from './utils'\n\nexport { emojiId }\nexport default emojiPlugin\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA,oBAAqC;AAErC,0BAAc,oBAhBd;AAiBA,0BAAc,oBAjBd;AAoBA,IAAO,gBAAQ;",
6
+ "names": []
7
+ }
package/lib/plugin.js ADDED
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var plugin_exports = {};
20
+ __export(plugin_exports, {
21
+ default: () => plugin_default,
22
+ emojiId: () => emojiId,
23
+ emojiPlugin: () => emojiPlugin
24
+ });
25
+ module.exports = __toCommonJS(plugin_exports);
26
+ var import_platform = require("@hcengineering/platform");
27
+ const emojiId = "emoji";
28
+ const emojiPlugin = (0, import_platform.plugin)(emojiId, {
29
+ ids: {
30
+ CustomEmoji: ""
31
+ },
32
+ class: {
33
+ CustomEmoji: ""
34
+ },
35
+ component: {
36
+ EmojiPopup: "",
37
+ SettingsEmojiTable: ""
38
+ },
39
+ string: {
40
+ Remove: "",
41
+ SearchResults: "",
42
+ SearchDots: "",
43
+ DefaultSkinTone: "",
44
+ FrequentlyUsed: "",
45
+ GettingWorkDone: "",
46
+ SmileysAndPeople: "",
47
+ AnimalsAndNature: "",
48
+ FoodAndDrink: "",
49
+ TravelAndPlaces: "",
50
+ Activities: "",
51
+ Objects: "",
52
+ Symbols: "",
53
+ Flags: "",
54
+ NoTone: "",
55
+ Light: "",
56
+ MediumLight: "",
57
+ Medium: "",
58
+ MediumDark: "",
59
+ Dark: "",
60
+ CustomEmojis: "",
61
+ Shortcode: "",
62
+ ShortcodeDescription: "",
63
+ Image: "",
64
+ ImageDescription: "",
65
+ UploadImage: "",
66
+ Preview: "",
67
+ PreviewTextBegin: "",
68
+ PreviewTextEnd: "",
69
+ CreateTitle: "",
70
+ Create: "",
71
+ ImageAspectError: "",
72
+ ShortcodeMatchError: "",
73
+ ShortcodeExistsError: "",
74
+ NewCustomEmojiDialogClose: "",
75
+ NewCustomEmojiDialogCloseNote: ""
76
+ },
77
+ icon: {
78
+ Emoji: "",
79
+ EmojiAdd: "",
80
+ Activities: "",
81
+ AnimalsAndNature: "",
82
+ Flags: "",
83
+ FoodAndDrink: "",
84
+ FrequentlyUsed: "",
85
+ GettingWorkDone: "",
86
+ Objects: "",
87
+ Search: "",
88
+ SmileysAndPeople: "",
89
+ Symbols: "",
90
+ TravelAndPlaces: "",
91
+ Custom: ""
92
+ },
93
+ functions: {
94
+ GetEmojiByEmoticon: "",
95
+ GetEmojiByShortCode: "",
96
+ GetCustomEmoji: "",
97
+ ParseTextWithEmojis: ""
98
+ }
99
+ });
100
+ var plugin_default = emojiPlugin;
101
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/plugin.ts"],
4
+ "sourcesContent": ["//\n// Copyright \u00A9 2025 Hardcore Engineering Inc.\n//\n// Licensed under the Eclipse Public License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License. You may\n// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n//\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//\nimport { Asset, type IntlString, plugin, type Plugin, Resource } from '@hcengineering/platform'\nimport { AnyComponent } from '@hcengineering/ui'\nimport type { Class, Ref, Doc } from '@hcengineering/core'\nimport { CustomEmoji, ExtendedEmoji, ParsedTextWithEmojis } from './types'\n\n/** @public */\nexport const emojiId = 'emoji' as Plugin\n\nexport const emojiPlugin = plugin(emojiId, {\n ids: {\n CustomEmoji: '' as Ref<Doc>\n },\n class: {\n CustomEmoji: '' as Ref<Class<CustomEmoji>>\n },\n component: {\n EmojiPopup: '' as AnyComponent,\n SettingsEmojiTable: '' as AnyComponent\n },\n string: {\n Remove: '' as IntlString,\n SearchResults: '' as IntlString,\n SearchDots: '' as IntlString,\n DefaultSkinTone: '' as IntlString,\n FrequentlyUsed: '' as IntlString,\n GettingWorkDone: '' as IntlString,\n SmileysAndPeople: '' as IntlString,\n AnimalsAndNature: '' as IntlString,\n FoodAndDrink: '' as IntlString,\n TravelAndPlaces: '' as IntlString,\n Activities: '' as IntlString,\n Objects: '' as IntlString,\n Symbols: '' as IntlString,\n Flags: '' as IntlString,\n NoTone: '' as IntlString,\n Light: '' as IntlString,\n MediumLight: '' as IntlString,\n Medium: '' as IntlString,\n MediumDark: '' as IntlString,\n Dark: '' as IntlString,\n CustomEmojis: '' as IntlString,\n Shortcode: '' as IntlString,\n ShortcodeDescription: '' as IntlString,\n Image: '' as IntlString,\n ImageDescription: '' as IntlString,\n UploadImage: '' as IntlString,\n Preview: '' as IntlString,\n PreviewTextBegin: '' as IntlString,\n PreviewTextEnd: '' as IntlString,\n CreateTitle: '' as IntlString,\n Create: '' as IntlString,\n ImageAspectError: '' as IntlString,\n ShortcodeMatchError: '' as IntlString,\n ShortcodeExistsError: '' as IntlString,\n NewCustomEmojiDialogClose: '' as IntlString,\n NewCustomEmojiDialogCloseNote: '' as IntlString\n },\n icon: {\n Emoji: '' as Asset,\n EmojiAdd: '' as Asset,\n Activities: '' as Asset,\n AnimalsAndNature: '' as Asset,\n Flags: '' as Asset,\n FoodAndDrink: '' as Asset,\n FrequentlyUsed: '' as Asset,\n GettingWorkDone: '' as Asset,\n Objects: '' as Asset,\n Search: '' as Asset,\n SmileysAndPeople: '' as Asset,\n Symbols: '' as Asset,\n TravelAndPlaces: '' as Asset,\n Custom: '' as Asset\n },\n functions: {\n GetEmojiByEmoticon: '' as Resource<(emoticon: string | undefined) => string | undefined>,\n GetEmojiByShortCode: '' as Resource<\n (shortcode: string | undefined, skinTone?: number) => ExtendedEmoji | undefined\n >,\n GetCustomEmoji: '' as Resource<(shortcode: string | undefined, skinTone?: number) => CustomEmoji | undefined>,\n ParseTextWithEmojis: '' as Resource<(text: string) => ParsedTextWithEmojis>\n }\n})\n\nexport default emojiPlugin\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA,sBAAsE;AAM/D,MAAM,UAAU;AAEhB,MAAM,kBAAc,wBAAO,SAAS;AAAA,EACzC,KAAK;AAAA,IACH,aAAa;AAAA,EACf;AAAA,EACA,OAAO;AAAA,IACL,aAAa;AAAA,EACf;AAAA,EACA,WAAW;AAAA,IACT,YAAY;AAAA,IACZ,oBAAoB;AAAA,EACtB;AAAA,EACA,QAAQ;AAAA,IACN,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB,kBAAkB;AAAA,IAClB,cAAc;AAAA,IACd,iBAAiB;AAAA,IACjB,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,SAAS;AAAA,IACT,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,MAAM;AAAA,IACN,cAAc;AAAA,IACd,WAAW;AAAA,IACX,sBAAsB;AAAA,IACtB,OAAO;AAAA,IACP,kBAAkB;AAAA,IAClB,aAAa;AAAA,IACb,SAAS;AAAA,IACT,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,IAChB,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,kBAAkB;AAAA,IAClB,qBAAqB;AAAA,IACrB,sBAAsB;AAAA,IACtB,2BAA2B;AAAA,IAC3B,+BAA+B;AAAA,EACjC;AAAA,EACA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,OAAO;AAAA,IACP,cAAc;AAAA,IACd,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,kBAAkB;AAAA,IAClB,SAAS;AAAA,IACT,iBAAiB;AAAA,IACjB,QAAQ;AAAA,EACV;AAAA,EACA,WAAW;AAAA,IACT,oBAAoB;AAAA,IACpB,qBAAqB;AAAA,IAGrB,gBAAgB;AAAA,IAChB,qBAAqB;AAAA,EACvB;AACF,CAAC;AAED,IAAO,iBAAQ;",
6
+ "names": []
7
+ }
package/lib/types.js ADDED
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var types_exports = {};
31
+ __export(types_exports, {
32
+ Emoji: () => import_emojibase.default,
33
+ isCustomEmoji: () => isCustomEmoji
34
+ });
35
+ module.exports = __toCommonJS(types_exports);
36
+ var import_emojibase = __toESM(require("emojibase"));
37
+ function isCustomEmoji(emoji) {
38
+ return "image" in emoji;
39
+ }
40
+ __name(isCustomEmoji, "isCustomEmoji");
41
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/types.ts"],
4
+ "sourcesContent": ["//\n// Copyright \u00A9 2025 Hardcore Engineering Inc.\n//\n// Licensed under the Eclipse Public License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License. You may\n// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n//\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//\nimport type { Emoji } from 'emojibase'\nimport type { Blob, Doc, Ref } from '@hcengineering/core'\n\nexport { default as Emoji } from 'emojibase'\nexport type ExtendedEmoji = Emoji | CustomEmoji\nexport type EmojiWithGroup = ExtendedEmoji & { key: string }\nexport type TextOrEmoji = string | { emoji: string } | { emoji: string, image: Ref<Blob> }\n\n/** @public */\nexport interface ParsedTextWithEmojis {\n nodes: TextOrEmoji[]\n emojisOnly: boolean\n}\n\n/** @public */\nexport interface CustomEmoji extends Doc {\n shortcode: string\n image: Ref<Blob>\n}\n\nexport function isCustomEmoji (emoji: ExtendedEmoji): emoji is CustomEmoji {\n return 'image' in emoji\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,uBAAiC;AAiB1B,SAAS,cAAe,OAA4C;AACzE,SAAO,WAAW;AACpB;AAFgB;",
6
+ "names": []
7
+ }
package/lib/utils.js ADDED
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var utils_exports = {};
31
+ __export(utils_exports, {
32
+ emojiGlobalRegex: () => emojiGlobalRegex,
33
+ emojiRegex: () => emojiRegex,
34
+ emoticonGlobalRegex: () => emoticonGlobalRegex,
35
+ emoticonRegex: () => emoticonRegex,
36
+ fetchEmojis: () => fetchEmojis,
37
+ fetchMessages: () => fetchMessages,
38
+ getParseEmojisFunction: () => getParseEmojisFunction,
39
+ loadParseEmojisFunction: () => loadParseEmojisFunction,
40
+ shortcodeGlobalRegex: () => shortcodeGlobalRegex,
41
+ shortcodeRegex: () => shortcodeRegex
42
+ });
43
+ module.exports = __toCommonJS(utils_exports);
44
+ var import_emojibase_regex = __toESM(require("emojibase-regex"));
45
+ var import_emoticon = __toESM(require("emojibase-regex/emoticon"));
46
+ var import_shortcode = __toESM(require("emojibase-regex/shortcode"));
47
+ var import_emojibase = require("emojibase");
48
+ var import_plugin = __toESM(require("./plugin"));
49
+ var import_platform = require("@hcengineering/platform");
50
+ const emojiRegex = new RegExp(`(?:^|\\s)(${import_emojibase_regex.default.source})$`);
51
+ const emojiGlobalRegex = new RegExp(import_emojibase_regex.default.source, import_emojibase_regex.default.flags + "g");
52
+ const emoticonRegex = new RegExp(`(?:^|\\s)(${import_emoticon.default.source})$`);
53
+ const emoticonGlobalRegex = new RegExp(import_emoticon.default.source, import_emoticon.default.flags + "g");
54
+ const shortcodeRegex = new RegExp(`(?:^|\\s)(${import_shortcode.default.source})$`);
55
+ const shortcodeGlobalRegex = new RegExp(import_shortcode.default.source, import_shortcode.default.flags + "g");
56
+ async function fetchEmojis(locale, options = {}) {
57
+ const { compact = false, shortcodes: presets = [] } = options;
58
+ try {
59
+ const emojis = (await import(`emojibase-data/${locale}/${compact ? "compact" : "data"}.json`)).default;
60
+ const shortcodes = [];
61
+ for (const preset of presets) {
62
+ const shortcodeData = (await import(`emojibase-data/${locale}/shortcodes/${preset}.json`)).default;
63
+ shortcodes.push(shortcodeData);
64
+ }
65
+ return (0, import_emojibase.joinShortcodes)(emojis, shortcodes);
66
+ } catch (e) {
67
+ return compact ? await fetchEmojis("en", { ...options, compact: true }) : await fetchEmojis("en", { ...options, compact: false });
68
+ }
69
+ }
70
+ __name(fetchEmojis, "fetchEmojis");
71
+ async function fetchMessages(locale, options) {
72
+ try {
73
+ return (await import(`emojibase-data/${locale}/messages.json`)).default;
74
+ } catch (e) {
75
+ return await fetchMessages("en", options);
76
+ }
77
+ }
78
+ __name(fetchMessages, "fetchMessages");
79
+ async function loadParseEmojisFunction() {
80
+ try {
81
+ return await (0, import_platform.getResource)(import_plugin.default.functions.ParseTextWithEmojis);
82
+ } catch (e) {
83
+ console.log("Cannot locate emoji parsing function");
84
+ return void 0;
85
+ }
86
+ }
87
+ __name(loadParseEmojisFunction, "loadParseEmojisFunction");
88
+ function getParseEmojisFunction() {
89
+ try {
90
+ const c = (0, import_platform.getResourceP)(import_plugin.default.functions.ParseTextWithEmojis);
91
+ if (c instanceof Promise) {
92
+ return void 0;
93
+ }
94
+ return c;
95
+ } catch (e) {
96
+ console.log("Cannot locate emoji parsing function");
97
+ return void 0;
98
+ }
99
+ }
100
+ __name(getParseEmojisFunction, "getParseEmojisFunction");
101
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/utils.ts"],
4
+ "sourcesContent": ["//\n// Copyright \u00A9 2025 Hardcore Engineering Inc.\n//\n// Licensed under the Eclipse Public License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License. You may\n// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n//\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//\nimport EMOJI_REGEX from 'emojibase-regex'\nimport EMOTICON_REGEX from 'emojibase-regex/emoticon'\nimport SHORTCODE_REGEX from 'emojibase-regex/shortcode'\n\nimport {\n joinShortcodes,\n Emoji,\n type Locale,\n type CompactEmoji,\n type FetchEmojisExpandedOptions,\n type FetchEmojisOptions,\n type FetchFromCDNOptions,\n type MessagesDataset,\n type ShortcodesDataset\n} from 'emojibase'\nimport emojiPlugin from './plugin'\nimport { getResource, getResourceP } from '@hcengineering/platform'\nimport { ParsedTextWithEmojis } from './types'\n\nexport const emojiRegex = new RegExp(`(?:^|\\\\s)(${EMOJI_REGEX.source})$`)\nexport const emojiGlobalRegex = new RegExp(EMOJI_REGEX.source, EMOJI_REGEX.flags + 'g')\n\nexport const emoticonRegex = new RegExp(`(?:^|\\\\s)(${EMOTICON_REGEX.source})$`)\nexport const emoticonGlobalRegex = new RegExp(EMOTICON_REGEX.source, EMOTICON_REGEX.flags + 'g')\n\nexport const shortcodeRegex = new RegExp(`(?:^|\\\\s)(${SHORTCODE_REGEX.source})$`)\nexport const shortcodeGlobalRegex = new RegExp(SHORTCODE_REGEX.source, SHORTCODE_REGEX.flags + 'g')\n\nasync function fetchEmojis (locale: Locale, options: FetchEmojisOptions & { compact: true }): Promise<CompactEmoji[]>\n\nasync function fetchEmojis (locale: Locale, options?: FetchEmojisOptions & { compact?: false }): Promise<Emoji[]>\n\nasync function fetchEmojis (locale: Locale, options: FetchEmojisExpandedOptions = {}): Promise<unknown[]> {\n const { compact = false, shortcodes: presets = [] } = options\n try {\n const emojis = (await import(`emojibase-data/${locale}/${compact ? 'compact' : 'data'}.json`)).default as Emoji[]\n const shortcodes: ShortcodesDataset[] = []\n\n for (const preset of presets) {\n const shortcodeData = (await import(`emojibase-data/${locale}/shortcodes/${preset}.json`))\n .default as ShortcodesDataset\n shortcodes.push(shortcodeData)\n }\n\n return joinShortcodes(emojis, shortcodes)\n } catch (e) {\n return compact\n ? await fetchEmojis('en', { ...options, compact: true })\n : await fetchEmojis('en', { ...options, compact: false })\n }\n}\n\nasync function fetchMessages (locale: Locale, options?: FetchFromCDNOptions): Promise<MessagesDataset> {\n try {\n return (await import(`emojibase-data/${locale}/messages.json`)).default as MessagesDataset\n } catch (e) {\n return await fetchMessages('en', options)\n }\n}\n\nasync function loadParseEmojisFunction (): Promise<((text: string) => ParsedTextWithEmojis) | undefined> {\n try {\n return await getResource(emojiPlugin.functions.ParseTextWithEmojis)\n } catch (e) {\n console.log('Cannot locate emoji parsing function')\n return undefined\n }\n}\n\nfunction getParseEmojisFunction (): ((text: string) => ParsedTextWithEmojis) | undefined {\n try {\n const c = getResourceP(emojiPlugin.functions.ParseTextWithEmojis)\n if (c instanceof Promise) {\n return undefined\n }\n return c\n } catch (e) {\n console.log('Cannot locate emoji parsing function')\n return undefined\n }\n}\n\nexport { fetchEmojis, fetchMessages, loadParseEmojisFunction, type Locale, getParseEmojisFunction }\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA,6BAAwB;AACxB,sBAA2B;AAC3B,uBAA4B;AAE5B,uBAUO;AACP,oBAAwB;AACxB,sBAA0C;AAGnC,MAAM,aAAa,IAAI,OAAO,aAAa,uBAAAA,QAAY,MAAM,IAAI;AACjE,MAAM,mBAAmB,IAAI,OAAO,uBAAAA,QAAY,QAAQ,uBAAAA,QAAY,QAAQ,GAAG;AAE/E,MAAM,gBAAgB,IAAI,OAAO,aAAa,gBAAAC,QAAe,MAAM,IAAI;AACvE,MAAM,sBAAsB,IAAI,OAAO,gBAAAA,QAAe,QAAQ,gBAAAA,QAAe,QAAQ,GAAG;AAExF,MAAM,iBAAiB,IAAI,OAAO,aAAa,iBAAAC,QAAgB,MAAM,IAAI;AACzE,MAAM,uBAAuB,IAAI,OAAO,iBAAAA,QAAgB,QAAQ,iBAAAA,QAAgB,QAAQ,GAAG;AAMlG,eAAe,YAAa,QAAgB,UAAsC,CAAC,GAAuB;AACxG,QAAM,EAAE,UAAU,OAAO,YAAY,UAAU,CAAC,EAAE,IAAI;AACtD,MAAI;AACF,UAAM,UAAU,MAAM,OAAO,kBAAkB,MAAM,IAAI,UAAU,YAAY,MAAM,UAAU;AAC/F,UAAM,aAAkC,CAAC;AAEzC,eAAW,UAAU,SAAS;AAC5B,YAAM,iBAAiB,MAAM,OAAO,kBAAkB,MAAM,eAAe,MAAM,UAC9E;AACH,iBAAW,KAAK,aAAa;AAAA,IAC/B;AAEA,eAAO,iCAAe,QAAQ,UAAU;AAAA,EAC1C,SAAS,GAAG;AACV,WAAO,UACH,MAAM,YAAY,MAAM,EAAE,GAAG,SAAS,SAAS,KAAK,CAAC,IACrD,MAAM,YAAY,MAAM,EAAE,GAAG,SAAS,SAAS,MAAM,CAAC;AAAA,EAC5D;AACF;AAlBe;AAoBf,eAAe,cAAe,QAAgB,SAAyD;AACrG,MAAI;AACF,YAAQ,MAAM,OAAO,kBAAkB,MAAM,mBAAmB;AAAA,EAClE,SAAS,GAAG;AACV,WAAO,MAAM,cAAc,MAAM,OAAO;AAAA,EAC1C;AACF;AANe;AAQf,eAAe,0BAA0F;AACvG,MAAI;AACF,WAAO,UAAM,6BAAY,cAAAC,QAAY,UAAU,mBAAmB;AAAA,EACpE,SAAS,GAAG;AACV,YAAQ,IAAI,sCAAsC;AAClD,WAAO;AAAA,EACT;AACF;AAPe;AASf,SAAS,yBAAgF;AACvF,MAAI;AACF,UAAM,QAAI,8BAAa,cAAAA,QAAY,UAAU,mBAAmB;AAChE,QAAI,aAAa,SAAS;AACxB,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT,SAAS,GAAG;AACV,YAAQ,IAAI,sCAAsC;AAClD,WAAO;AAAA,EACT;AACF;AAXS;",
6
+ "names": ["EMOJI_REGEX", "EMOTICON_REGEX", "SHORTCODE_REGEX", "emojiPlugin"]
7
+ }
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@hcengineering/emoji",
3
+ "version": "0.7.423",
4
+ "main": "lib/index.js",
5
+ "svelte": "src/index.ts",
6
+ "types": "types/index.d.ts",
7
+ "files": [
8
+ "lib/**/*",
9
+ "types/**/*",
10
+ "tsconfig.json"
11
+ ],
12
+ "author": "Hardcore Engineering Inc.",
13
+ "license": "EPL-2.0",
14
+ "scripts": {
15
+ "build": "compile",
16
+ "build:watch": "compile",
17
+ "format": "format src",
18
+ "test": "jest --passWithNoTests --silent",
19
+ "_phase:build": "compile transpile src",
20
+ "_phase:test": "jest --passWithNoTests --silent",
21
+ "_phase:format": "format src",
22
+ "_phase:validate": "compile validate"
23
+ },
24
+ "devDependencies": {
25
+ "@hcengineering/platform-rig": "^0.7.423",
26
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
27
+ "@typescript-eslint/parser": "^6.21.0",
28
+ "eslint-config-standard-with-typescript": "^40.0.0",
29
+ "eslint-plugin-import": "^2.26.0",
30
+ "eslint-plugin-n": "^15.4.0",
31
+ "eslint-plugin-promise": "^6.1.1",
32
+ "eslint": "^8.54.0",
33
+ "prettier": "^3.6.2",
34
+ "typescript": "^5.9.3",
35
+ "jest": "^29.7.0",
36
+ "ts-jest": "^29.1.1",
37
+ "@types/jest": "^29.5.5"
38
+ },
39
+ "dependencies": {
40
+ "@hcengineering/core": "^0.7.423",
41
+ "@hcengineering/platform": "^0.7.423",
42
+ "@hcengineering/ui": "^0.7.423",
43
+ "emojibase": "^16.0.0",
44
+ "emojibase-data": "^16.0.0",
45
+ "emojibase-regex": "^16.0.0"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/hcengineering/platform.git"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ }
54
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "./node_modules/@hcengineering/platform-rig/profiles/default/tsconfig.json",
3
+
4
+ "compilerOptions": {
5
+ "rootDir": "./src",
6
+ "outDir": "./lib",
7
+ "declarationDir": "./types",
8
+ "tsBuildInfoFile": ".build/build.tsbuildinfo"
9
+ },
10
+ "include": ["src/**/*"],
11
+ "exclude": ["node_modules", "lib", "dist", "types", "bundle"]
12
+ }