Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@svgmoji/core

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@svgmoji/core - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

13

CHANGELOG.md
# @svgmoji/core
## 2.0.0
> 2021-01-17
### Major Changes
- 9599f2dd: Remove all `*_REGEXP` exports. Use `emojibase-regex` as an alternative. This also shaves 300B from the total build size.
### Minor Changes
- 192504eb: Add support for passing a flat emoji object to the `url` method of `Moji`. This can lead to a performance boost in some cases.
- 192504eb: Add caching to the `Moji#find` method. Now the second time a search is made for the same code, it will be retrieved from the cache.
## 1.0.0

@@ -4,0 +17,0 @@

2

dist/declarations/src/base-moji.d.ts

@@ -20,2 +20,3 @@ import type { SpriteCollectionType } from './constants';

export declare abstract class Moji {
#private;
/**

@@ -55,2 +56,3 @@ * The name of the svgmoji.

*/
url(emoji: FlatEmoji): string;
url(code: string, options: {

@@ -57,0 +59,0 @@ fallback: false;

1

dist/declarations/src/index.d.ts

@@ -10,5 +10,4 @@ export * from './base-moji';

export * from './populate-minified-emoji';
export * from './regexp';
export * from './types';
export type { Emoticon } from 'emojibase';
export { fromUnicodeToHexcode, generateEmoticonPermutations, stripHexcode } from 'emojibase';

@@ -5,6 +5,5 @@ 'use strict';

var _classPrivateFieldGet = require('@babel/runtime/helpers/classPrivateFieldGet');
var emojibase = require('emojibase');
var matchSorter = require('match-sorter');
var EMOTICON_REGEX = require('emojibase-regex/emoticon');
var SHORTCODE_REGEX = require('emojibase-regex/shortcode');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');

@@ -15,4 +14,3 @@ var idbKeyval = require('idb-keyval');

var EMOTICON_REGEX__default = /*#__PURE__*/_interopDefault(EMOTICON_REGEX);
var SHORTCODE_REGEX__default = /*#__PURE__*/_interopDefault(SHORTCODE_REGEX);
var _classPrivateFieldGet__default = /*#__PURE__*/_interopDefault(_classPrivateFieldGet);
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefault(_objectWithoutProperties);

@@ -167,8 +165,2 @@

/**
* Simple regexp for testing if a string passed in is a hexcode.
*/
const HEXCODE_REGEX = /^[\dA-Fa-f][\dA-Fa-f-]+[\dA-Fa-f]$/;
const groups = ([{

@@ -288,2 +280,5 @@ "0": "smileys-emotion",

}][0]);
var _findCache = /*#__PURE__*/new WeakMap();
class Moji {

@@ -313,4 +308,8 @@ /**

*/
/**
* Cache the results for finding an emoji.
*/
get cdn() {
return "https://cdn.jsdelivr.net/npm/@svgmoji/".concat(this.name, "@").concat(this.version, "/");
return "https://cdn.jsdelivr.net/npm/@svgmoji/".concat(this.name, "@").concat(this.version);
}

@@ -333,2 +332,8 @@

} = _ref;
_findCache.set(this, {
writable: true,
value: new Map()
});
this.type = type;

@@ -355,3 +360,3 @@ this.data = isMinifiedEmojiList(data) ? populateMinifiedEmoji(data) : data;

} = options;
const emoji = this.find(code);
const emoji = isFlatEmoji(code) ? code : this.find(code);
const fallbackUrl = fallback ? this.fallbackUrl : undefined;

@@ -371,3 +376,3 @@

if (this.type === SpriteCollection.Group && emoji !== null && emoji !== void 0 && emoji.group) {
if (this.type === SpriteCollection.Group && emoji.group != null) {
var _groups$emoji$group;

@@ -379,3 +384,3 @@

if (this.type === SpriteCollection.Subgroup && emoji !== null && emoji !== void 0 && emoji.subgroup) {
if (this.type === SpriteCollection.Subgroup && emoji.subgroup != null) {
var _subgroups$emoji$subg;

@@ -395,20 +400,27 @@

find(code) {
if (EMOTICON_REGEX__default['default'].test(code)) {
return this.data.find(emoji => !!emoji.emoticon && emojibase.generateEmoticonPermutations(emoji.emoticon).includes(code));
if (_classPrivateFieldGet__default['default'](this, _findCache).has(code)) {
return _classPrivateFieldGet__default['default'](this, _findCache).get(code);
}
if (SHORTCODE_REGEX__default['default'].test(code)) {
return this.data.find(emoji => {
var _emoji$shortcodes;
for (const emoji of this.data) {
var _emoji$shortcodes, _emoji$shortcodes2;
return (_emoji$shortcodes = emoji.shortcodes) === null || _emoji$shortcodes === void 0 ? void 0 : _emoji$shortcodes.map(shortcode => ":".concat(shortcode, ":")).includes(code);
});
}
if ( // This is a native emoji match
emoji.emoji === code || // This uses the underlying text representation of the emoji
emoji.text === code || // This is a hexcode match.
emoji.hexcode === code || // There is a match for the shortcode
(_emoji$shortcodes = emoji.shortcodes) !== null && _emoji$shortcodes !== void 0 && _emoji$shortcodes.includes(code) || // There is a match for the shortcode, but with surrounding braces.
(_emoji$shortcodes2 = emoji.shortcodes) !== null && _emoji$shortcodes2 !== void 0 && _emoji$shortcodes2.map(shortcode => ":".concat(shortcode, ":")).includes(code) || // The provided code matches the emoticon.
emoji.emoticon && emojibase.generateEmoticonPermutations(emoji.emoticon).includes(code)) {
_classPrivateFieldGet__default['default'](this, _findCache).set(code, emoji);
if (HEXCODE_REGEX.test(code)) {
return this.data.find(emoji => emoji.hexcode === code);
} // Assume that the string passed is a native emoji string.
return emoji;
}
} // No matches were found in the data.
// eslint-disable-next-line unicorn/no-useless-undefined
return this.data.find(emoji => emoji.emoji === code || emoji.text === code);
_classPrivateFieldGet__default['default'](this, _findCache).set(code, undefined);
return;
}

@@ -428,2 +440,7 @@ /**

const data = excludeTone ? this.tonelessData : this.data;
if (!query) {
return data;
}
return matchSorter.matchSorter(data, query, {

@@ -468,3 +485,3 @@ threshold: matchSorter.rankings.WORD_STARTS_WITH,

const DEFAULT_OPTIONS = {
excludeTone: true
excludeTone: false
};

@@ -680,15 +697,2 @@

});
Object.defineProperty(exports, 'EMOTICON_REGEX', {
enumerable: true,
get: function () {
return EMOTICON_REGEX__default['default'];
}
});
Object.defineProperty(exports, 'SHORTCODE_REGEX', {
enumerable: true,
get: function () {
return SHORTCODE_REGEX__default['default'];
}
});
exports.HEXCODE_REGEX = HEXCODE_REGEX;
exports.Moji = Moji;

@@ -695,0 +699,0 @@ exports.SpriteCollection = SpriteCollection;

@@ -0,8 +1,5 @@

import _classPrivateFieldGet from '@babel/runtime/helpers/esm/classPrivateFieldGet';
import { generateEmoticonPermutations, NON_LATIN_LOCALES } from 'emojibase';
export { fromUnicodeToHexcode, generateEmoticonPermutations, stripHexcode } from 'emojibase';
import { matchSorter, rankings } from 'match-sorter';
import EMOTICON_REGEX from 'emojibase-regex/emoticon';
export { default as EMOTICON_REGEX } from 'emojibase-regex/emoticon';
import SHORTCODE_REGEX from 'emojibase-regex/shortcode';
export { default as SHORTCODE_REGEX } from 'emojibase-regex/shortcode';
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';

@@ -158,8 +155,2 @@ import { set, get } from 'idb-keyval';

/**
* Simple regexp for testing if a string passed in is a hexcode.
*/
const HEXCODE_REGEX = /^[\dA-Fa-f][\dA-Fa-f-]+[\dA-Fa-f]$/;
const groups = ([{

@@ -279,2 +270,5 @@ "0": "smileys-emotion",

}][0]);
var _findCache = /*#__PURE__*/new WeakMap();
class Moji {

@@ -304,4 +298,8 @@ /**

*/
/**
* Cache the results for finding an emoji.
*/
get cdn() {
return "https://cdn.jsdelivr.net/npm/@svgmoji/".concat(this.name, "@").concat(this.version, "/");
return "https://cdn.jsdelivr.net/npm/@svgmoji/".concat(this.name, "@").concat(this.version);
}

@@ -324,2 +322,8 @@

} = _ref;
_findCache.set(this, {
writable: true,
value: new Map()
});
this.type = type;

@@ -346,3 +350,3 @@ this.data = isMinifiedEmojiList(data) ? populateMinifiedEmoji(data) : data;

} = options;
const emoji = this.find(code);
const emoji = isFlatEmoji(code) ? code : this.find(code);
const fallbackUrl = fallback ? this.fallbackUrl : undefined;

@@ -362,3 +366,3 @@

if (this.type === SpriteCollection.Group && emoji !== null && emoji !== void 0 && emoji.group) {
if (this.type === SpriteCollection.Group && emoji.group != null) {
var _groups$emoji$group;

@@ -370,3 +374,3 @@

if (this.type === SpriteCollection.Subgroup && emoji !== null && emoji !== void 0 && emoji.subgroup) {
if (this.type === SpriteCollection.Subgroup && emoji.subgroup != null) {
var _subgroups$emoji$subg;

@@ -386,20 +390,27 @@

find(code) {
if (EMOTICON_REGEX.test(code)) {
return this.data.find(emoji => !!emoji.emoticon && generateEmoticonPermutations(emoji.emoticon).includes(code));
if (_classPrivateFieldGet(this, _findCache).has(code)) {
return _classPrivateFieldGet(this, _findCache).get(code);
}
if (SHORTCODE_REGEX.test(code)) {
return this.data.find(emoji => {
var _emoji$shortcodes;
for (const emoji of this.data) {
var _emoji$shortcodes, _emoji$shortcodes2;
return (_emoji$shortcodes = emoji.shortcodes) === null || _emoji$shortcodes === void 0 ? void 0 : _emoji$shortcodes.map(shortcode => ":".concat(shortcode, ":")).includes(code);
});
}
if ( // This is a native emoji match
emoji.emoji === code || // This uses the underlying text representation of the emoji
emoji.text === code || // This is a hexcode match.
emoji.hexcode === code || // There is a match for the shortcode
(_emoji$shortcodes = emoji.shortcodes) !== null && _emoji$shortcodes !== void 0 && _emoji$shortcodes.includes(code) || // There is a match for the shortcode, but with surrounding braces.
(_emoji$shortcodes2 = emoji.shortcodes) !== null && _emoji$shortcodes2 !== void 0 && _emoji$shortcodes2.map(shortcode => ":".concat(shortcode, ":")).includes(code) || // The provided code matches the emoticon.
emoji.emoticon && generateEmoticonPermutations(emoji.emoticon).includes(code)) {
_classPrivateFieldGet(this, _findCache).set(code, emoji);
if (HEXCODE_REGEX.test(code)) {
return this.data.find(emoji => emoji.hexcode === code);
} // Assume that the string passed is a native emoji string.
return emoji;
}
} // No matches were found in the data.
// eslint-disable-next-line unicorn/no-useless-undefined
return this.data.find(emoji => emoji.emoji === code || emoji.text === code);
_classPrivateFieldGet(this, _findCache).set(code, undefined);
return;
}

@@ -419,2 +430,7 @@ /**

const data = excludeTone ? this.tonelessData : this.data;
if (!query) {
return data;
}
return matchSorter(data, query, {

@@ -459,3 +475,3 @@ threshold: rankings.WORD_STARTS_WITH,

const DEFAULT_OPTIONS = {
excludeTone: true
excludeTone: false
};

@@ -653,2 +669,2 @@

export { HEXCODE_REGEX, Moji, SpriteCollection, fetchEmojis, fetchFromCDN, flattenEmojiData, isFlatEmoji, isFlatEmojiList, isMinifiedEmoji, isMinifiedEmojiList, joinShortcodesToEmoji, minifyEmoji, omitUndefined, populateMinifiedEmoji };
export { Moji, SpriteCollection, fetchEmojis, fetchFromCDN, flattenEmojiData, isFlatEmoji, isFlatEmojiList, isMinifiedEmoji, isMinifiedEmojiList, joinShortcodesToEmoji, minifyEmoji, omitUndefined, populateMinifiedEmoji };

@@ -5,6 +5,5 @@ 'use strict';

var _classPrivateFieldGet = require('@babel/runtime/helpers/classPrivateFieldGet');
var emojibase = require('emojibase');
var matchSorter = require('match-sorter');
var EMOTICON_REGEX = require('emojibase-regex/emoticon');
var SHORTCODE_REGEX = require('emojibase-regex/shortcode');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');

@@ -15,4 +14,3 @@ var idbKeyval = require('idb-keyval');

var EMOTICON_REGEX__default = /*#__PURE__*/_interopDefault(EMOTICON_REGEX);
var SHORTCODE_REGEX__default = /*#__PURE__*/_interopDefault(SHORTCODE_REGEX);
var _classPrivateFieldGet__default = /*#__PURE__*/_interopDefault(_classPrivateFieldGet);
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefault(_objectWithoutProperties);

@@ -167,8 +165,2 @@

/**
* Simple regexp for testing if a string passed in is a hexcode.
*/
const HEXCODE_REGEX = /^[\dA-Fa-f][\dA-Fa-f-]+[\dA-Fa-f]$/;
const groups = ([{

@@ -288,2 +280,5 @@ "0": "smileys-emotion",

}][0]);
var _findCache = /*#__PURE__*/new WeakMap();
class Moji {

@@ -313,4 +308,8 @@ /**

*/
/**
* Cache the results for finding an emoji.
*/
get cdn() {
return "https://cdn.jsdelivr.net/npm/@svgmoji/".concat(this.name, "@").concat(this.version, "/");
return "https://cdn.jsdelivr.net/npm/@svgmoji/".concat(this.name, "@").concat(this.version);
}

@@ -333,2 +332,8 @@

} = _ref;
_findCache.set(this, {
writable: true,
value: new Map()
});
this.type = type;

@@ -355,3 +360,3 @@ this.data = isMinifiedEmojiList(data) ? populateMinifiedEmoji(data) : data;

} = options;
const emoji = this.find(code);
const emoji = isFlatEmoji(code) ? code : this.find(code);
const fallbackUrl = fallback ? this.fallbackUrl : undefined;

@@ -371,3 +376,3 @@

if (this.type === SpriteCollection.Group && emoji !== null && emoji !== void 0 && emoji.group) {
if (this.type === SpriteCollection.Group && emoji.group != null) {
var _groups$emoji$group;

@@ -379,3 +384,3 @@

if (this.type === SpriteCollection.Subgroup && emoji !== null && emoji !== void 0 && emoji.subgroup) {
if (this.type === SpriteCollection.Subgroup && emoji.subgroup != null) {
var _subgroups$emoji$subg;

@@ -395,20 +400,27 @@

find(code) {
if (EMOTICON_REGEX__default['default'].test(code)) {
return this.data.find(emoji => !!emoji.emoticon && emojibase.generateEmoticonPermutations(emoji.emoticon).includes(code));
if (_classPrivateFieldGet__default['default'](this, _findCache).has(code)) {
return _classPrivateFieldGet__default['default'](this, _findCache).get(code);
}
if (SHORTCODE_REGEX__default['default'].test(code)) {
return this.data.find(emoji => {
var _emoji$shortcodes;
for (const emoji of this.data) {
var _emoji$shortcodes, _emoji$shortcodes2;
return (_emoji$shortcodes = emoji.shortcodes) === null || _emoji$shortcodes === void 0 ? void 0 : _emoji$shortcodes.map(shortcode => ":".concat(shortcode, ":")).includes(code);
});
}
if ( // This is a native emoji match
emoji.emoji === code || // This uses the underlying text representation of the emoji
emoji.text === code || // This is a hexcode match.
emoji.hexcode === code || // There is a match for the shortcode
(_emoji$shortcodes = emoji.shortcodes) !== null && _emoji$shortcodes !== void 0 && _emoji$shortcodes.includes(code) || // There is a match for the shortcode, but with surrounding braces.
(_emoji$shortcodes2 = emoji.shortcodes) !== null && _emoji$shortcodes2 !== void 0 && _emoji$shortcodes2.map(shortcode => ":".concat(shortcode, ":")).includes(code) || // The provided code matches the emoticon.
emoji.emoticon && emojibase.generateEmoticonPermutations(emoji.emoticon).includes(code)) {
_classPrivateFieldGet__default['default'](this, _findCache).set(code, emoji);
if (HEXCODE_REGEX.test(code)) {
return this.data.find(emoji => emoji.hexcode === code);
} // Assume that the string passed is a native emoji string.
return emoji;
}
} // No matches were found in the data.
// eslint-disable-next-line unicorn/no-useless-undefined
return this.data.find(emoji => emoji.emoji === code || emoji.text === code);
_classPrivateFieldGet__default['default'](this, _findCache).set(code, undefined);
return;
}

@@ -428,2 +440,7 @@ /**

const data = excludeTone ? this.tonelessData : this.data;
if (!query) {
return data;
}
return matchSorter.matchSorter(data, query, {

@@ -468,3 +485,3 @@ threshold: matchSorter.rankings.WORD_STARTS_WITH,

const DEFAULT_OPTIONS = {
excludeTone: true
excludeTone: false
};

@@ -683,15 +700,2 @@

});
Object.defineProperty(exports, 'EMOTICON_REGEX', {
enumerable: true,
get: function () {
return EMOTICON_REGEX__default['default'];
}
});
Object.defineProperty(exports, 'SHORTCODE_REGEX', {
enumerable: true,
get: function () {
return SHORTCODE_REGEX__default['default'];
}
});
exports.HEXCODE_REGEX = HEXCODE_REGEX;
exports.Moji = Moji;

@@ -698,0 +702,0 @@ exports.SpriteCollection = SpriteCollection;

@@ -5,6 +5,5 @@ 'use strict';

var _classPrivateFieldGet = require('@babel/runtime/helpers/classPrivateFieldGet');
var emojibase = require('emojibase');
var matchSorter = require('match-sorter');
var EMOTICON_REGEX = require('emojibase-regex/emoticon');
var SHORTCODE_REGEX = require('emojibase-regex/shortcode');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');

@@ -15,4 +14,3 @@ var idbKeyval = require('idb-keyval');

var EMOTICON_REGEX__default = /*#__PURE__*/_interopDefault(EMOTICON_REGEX);
var SHORTCODE_REGEX__default = /*#__PURE__*/_interopDefault(SHORTCODE_REGEX);
var _classPrivateFieldGet__default = /*#__PURE__*/_interopDefault(_classPrivateFieldGet);
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefault(_objectWithoutProperties);

@@ -167,8 +165,2 @@

/**
* Simple regexp for testing if a string passed in is a hexcode.
*/
const HEXCODE_REGEX = /^[\dA-Fa-f][\dA-Fa-f-]+[\dA-Fa-f]$/;
const groups = ([{

@@ -288,2 +280,5 @@ "0": "smileys-emotion",

}][0]);
var _findCache = /*#__PURE__*/new WeakMap();
class Moji {

@@ -313,4 +308,8 @@ /**

*/
/**
* Cache the results for finding an emoji.
*/
get cdn() {
return "https://cdn.jsdelivr.net/npm/@svgmoji/".concat(this.name, "@").concat(this.version, "/");
return "https://cdn.jsdelivr.net/npm/@svgmoji/".concat(this.name, "@").concat(this.version);
}

@@ -333,2 +332,8 @@

} = _ref;
_findCache.set(this, {
writable: true,
value: new Map()
});
this.type = type;

@@ -355,3 +360,3 @@ this.data = isMinifiedEmojiList(data) ? populateMinifiedEmoji(data) : data;

} = options;
const emoji = this.find(code);
const emoji = isFlatEmoji(code) ? code : this.find(code);
const fallbackUrl = fallback ? this.fallbackUrl : undefined;

@@ -371,3 +376,3 @@

if (this.type === SpriteCollection.Group && emoji !== null && emoji !== void 0 && emoji.group) {
if (this.type === SpriteCollection.Group && emoji.group != null) {
var _groups$emoji$group;

@@ -379,3 +384,3 @@

if (this.type === SpriteCollection.Subgroup && emoji !== null && emoji !== void 0 && emoji.subgroup) {
if (this.type === SpriteCollection.Subgroup && emoji.subgroup != null) {
var _subgroups$emoji$subg;

@@ -395,20 +400,27 @@

find(code) {
if (EMOTICON_REGEX__default['default'].test(code)) {
return this.data.find(emoji => !!emoji.emoticon && emojibase.generateEmoticonPermutations(emoji.emoticon).includes(code));
if (_classPrivateFieldGet__default['default'](this, _findCache).has(code)) {
return _classPrivateFieldGet__default['default'](this, _findCache).get(code);
}
if (SHORTCODE_REGEX__default['default'].test(code)) {
return this.data.find(emoji => {
var _emoji$shortcodes;
for (const emoji of this.data) {
var _emoji$shortcodes, _emoji$shortcodes2;
return (_emoji$shortcodes = emoji.shortcodes) === null || _emoji$shortcodes === void 0 ? void 0 : _emoji$shortcodes.map(shortcode => ":".concat(shortcode, ":")).includes(code);
});
}
if ( // This is a native emoji match
emoji.emoji === code || // This uses the underlying text representation of the emoji
emoji.text === code || // This is a hexcode match.
emoji.hexcode === code || // There is a match for the shortcode
(_emoji$shortcodes = emoji.shortcodes) !== null && _emoji$shortcodes !== void 0 && _emoji$shortcodes.includes(code) || // There is a match for the shortcode, but with surrounding braces.
(_emoji$shortcodes2 = emoji.shortcodes) !== null && _emoji$shortcodes2 !== void 0 && _emoji$shortcodes2.map(shortcode => ":".concat(shortcode, ":")).includes(code) || // The provided code matches the emoticon.
emoji.emoticon && emojibase.generateEmoticonPermutations(emoji.emoticon).includes(code)) {
_classPrivateFieldGet__default['default'](this, _findCache).set(code, emoji);
if (HEXCODE_REGEX.test(code)) {
return this.data.find(emoji => emoji.hexcode === code);
} // Assume that the string passed is a native emoji string.
return emoji;
}
} // No matches were found in the data.
// eslint-disable-next-line unicorn/no-useless-undefined
return this.data.find(emoji => emoji.emoji === code || emoji.text === code);
_classPrivateFieldGet__default['default'](this, _findCache).set(code, undefined);
return;
}

@@ -428,2 +440,7 @@ /**

const data = excludeTone ? this.tonelessData : this.data;
if (!query) {
return data;
}
return matchSorter.matchSorter(data, query, {

@@ -468,3 +485,3 @@ threshold: matchSorter.rankings.WORD_STARTS_WITH,

const DEFAULT_OPTIONS = {
excludeTone: true
excludeTone: false
};

@@ -673,15 +690,2 @@

});
Object.defineProperty(exports, 'EMOTICON_REGEX', {
enumerable: true,
get: function () {
return EMOTICON_REGEX__default['default'];
}
});
Object.defineProperty(exports, 'SHORTCODE_REGEX', {
enumerable: true,
get: function () {
return SHORTCODE_REGEX__default['default'];
}
});
exports.HEXCODE_REGEX = HEXCODE_REGEX;
exports.Moji = Moji;

@@ -688,0 +692,0 @@ exports.SpriteCollection = SpriteCollection;

@@ -0,8 +1,5 @@

import _classPrivateFieldGet from '@babel/runtime/helpers/esm/classPrivateFieldGet';
import { generateEmoticonPermutations, NON_LATIN_LOCALES } from 'emojibase';
export { fromUnicodeToHexcode, generateEmoticonPermutations, stripHexcode } from 'emojibase';
import { matchSorter, rankings } from 'match-sorter';
import EMOTICON_REGEX from 'emojibase-regex/emoticon';
export { default as EMOTICON_REGEX } from 'emojibase-regex/emoticon';
import SHORTCODE_REGEX from 'emojibase-regex/shortcode';
export { default as SHORTCODE_REGEX } from 'emojibase-regex/shortcode';
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';

@@ -158,8 +155,2 @@ import { set, get } from 'idb-keyval';

/**
* Simple regexp for testing if a string passed in is a hexcode.
*/
const HEXCODE_REGEX = /^[\dA-Fa-f][\dA-Fa-f-]+[\dA-Fa-f]$/;
const groups = ([{

@@ -279,2 +270,5 @@ "0": "smileys-emotion",

}][0]);
var _findCache = /*#__PURE__*/new WeakMap();
class Moji {

@@ -304,4 +298,8 @@ /**

*/
/**
* Cache the results for finding an emoji.
*/
get cdn() {
return "https://cdn.jsdelivr.net/npm/@svgmoji/".concat(this.name, "@").concat(this.version, "/");
return "https://cdn.jsdelivr.net/npm/@svgmoji/".concat(this.name, "@").concat(this.version);
}

@@ -324,2 +322,8 @@

} = _ref;
_findCache.set(this, {
writable: true,
value: new Map()
});
this.type = type;

@@ -346,3 +350,3 @@ this.data = isMinifiedEmojiList(data) ? populateMinifiedEmoji(data) : data;

} = options;
const emoji = this.find(code);
const emoji = isFlatEmoji(code) ? code : this.find(code);
const fallbackUrl = fallback ? this.fallbackUrl : undefined;

@@ -362,3 +366,3 @@

if (this.type === SpriteCollection.Group && emoji !== null && emoji !== void 0 && emoji.group) {
if (this.type === SpriteCollection.Group && emoji.group != null) {
var _groups$emoji$group;

@@ -370,3 +374,3 @@

if (this.type === SpriteCollection.Subgroup && emoji !== null && emoji !== void 0 && emoji.subgroup) {
if (this.type === SpriteCollection.Subgroup && emoji.subgroup != null) {
var _subgroups$emoji$subg;

@@ -386,20 +390,27 @@

find(code) {
if (EMOTICON_REGEX.test(code)) {
return this.data.find(emoji => !!emoji.emoticon && generateEmoticonPermutations(emoji.emoticon).includes(code));
if (_classPrivateFieldGet(this, _findCache).has(code)) {
return _classPrivateFieldGet(this, _findCache).get(code);
}
if (SHORTCODE_REGEX.test(code)) {
return this.data.find(emoji => {
var _emoji$shortcodes;
for (const emoji of this.data) {
var _emoji$shortcodes, _emoji$shortcodes2;
return (_emoji$shortcodes = emoji.shortcodes) === null || _emoji$shortcodes === void 0 ? void 0 : _emoji$shortcodes.map(shortcode => ":".concat(shortcode, ":")).includes(code);
});
}
if ( // This is a native emoji match
emoji.emoji === code || // This uses the underlying text representation of the emoji
emoji.text === code || // This is a hexcode match.
emoji.hexcode === code || // There is a match for the shortcode
(_emoji$shortcodes = emoji.shortcodes) !== null && _emoji$shortcodes !== void 0 && _emoji$shortcodes.includes(code) || // There is a match for the shortcode, but with surrounding braces.
(_emoji$shortcodes2 = emoji.shortcodes) !== null && _emoji$shortcodes2 !== void 0 && _emoji$shortcodes2.map(shortcode => ":".concat(shortcode, ":")).includes(code) || // The provided code matches the emoticon.
emoji.emoticon && generateEmoticonPermutations(emoji.emoticon).includes(code)) {
_classPrivateFieldGet(this, _findCache).set(code, emoji);
if (HEXCODE_REGEX.test(code)) {
return this.data.find(emoji => emoji.hexcode === code);
} // Assume that the string passed is a native emoji string.
return emoji;
}
} // No matches were found in the data.
// eslint-disable-next-line unicorn/no-useless-undefined
return this.data.find(emoji => emoji.emoji === code || emoji.text === code);
_classPrivateFieldGet(this, _findCache).set(code, undefined);
return;
}

@@ -419,2 +430,7 @@ /**

const data = excludeTone ? this.tonelessData : this.data;
if (!query) {
return data;
}
return matchSorter(data, query, {

@@ -459,3 +475,3 @@ threshold: rankings.WORD_STARTS_WITH,

const DEFAULT_OPTIONS = {
excludeTone: true
excludeTone: false
};

@@ -656,2 +672,2 @@

export { HEXCODE_REGEX, Moji, SpriteCollection, fetchEmojis, fetchFromCDN, flattenEmojiData, isFlatEmoji, isFlatEmojiList, isMinifiedEmoji, isMinifiedEmojiList, joinShortcodesToEmoji, minifyEmoji, omitUndefined, populateMinifiedEmoji };
export { Moji, SpriteCollection, fetchEmojis, fetchFromCDN, flattenEmojiData, isFlatEmoji, isFlatEmojiList, isMinifiedEmoji, isMinifiedEmojiList, joinShortcodesToEmoji, minifyEmoji, omitUndefined, populateMinifiedEmoji };
{
"name": "@svgmoji/core",
"version": "1.0.0",
"version": "2.0.0",
"description": "Utilities forked from emojibase for working with svgmoji",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc