@iconify/utils
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -11,2 +11,11 @@ /** | ||
/** | ||
* Convert emoji sequence or keyword | ||
* | ||
* If sequence is characters list, like '1f441-fe0f', it will be converted to [0x1f441, 0xfe0f] | ||
* If sequence contains anything other than [0-9A-F-\s], it will be converted character by character | ||
* | ||
* This is used to treat keywords, like ':cat:' differently when converting strings to sequences | ||
*/ | ||
declare function getSequenceFromEmojiStringOrKeyword(value: string): number[]; | ||
/** | ||
* Split emoji sequence by joiner | ||
@@ -19,3 +28,3 @@ * | ||
*/ | ||
declare function splitEmojiSequences(sequence: number[]): number[][]; | ||
declare function splitEmojiSequences(sequence: number[], separator?: number): number[][]; | ||
/** | ||
@@ -29,32 +38,8 @@ * Join emoji sequences | ||
*/ | ||
declare function joinEmojiSequences(sequences: number[][]): number[]; | ||
declare function joinEmojiSequences(sequences: number[][], separator?: number): number[]; | ||
/** | ||
* Remove variations | ||
*/ | ||
declare function removeEmojiVariations(sequence: number[]): number[]; | ||
/** | ||
* Remove variations | ||
* | ||
* This function should be used with UTF-32 sequence, not UTF-16 | ||
*/ | ||
declare function removeEmojiTones(sequence: number[]): number[]; | ||
/** | ||
* Get unqualified sequence | ||
*/ | ||
declare function getUnqualifiedEmojiSequence(sequence: number[]): number[]; | ||
/** | ||
* Types for mapEmojiSequence() | ||
*/ | ||
type MapCallback = (sequence: number[]) => number[]; | ||
interface MapOptions { | ||
removeEmpty?: boolean; | ||
removeDuplicates?: boolean; | ||
} | ||
/** | ||
* Run function on sequences | ||
* | ||
* Intended to be used with functions such as `removeEmojiVariations` or `removeEmojiTones` | ||
*/ | ||
declare function mapEmojiSequences(sequences: number[][], callback: MapCallback, options?: MapOptions): number[][]; | ||
export { getEmojiSequenceFromString, getUnqualifiedEmojiSequence, joinEmojiSequences, mapEmojiSequences, removeEmojiTones, removeEmojiVariations, splitEmojiSequences }; | ||
export { getEmojiSequenceFromString, getSequenceFromEmojiStringOrKeyword, getUnqualifiedEmojiSequence, joinEmojiSequences, splitEmojiSequences }; |
@@ -23,3 +23,9 @@ interface UnicodeFormattingOptions { | ||
declare function getEmojiSequenceString(sequence: number[], options?: Partial<UnicodeFormattingOptions>): string; | ||
/** | ||
* Convert unicode numbers sequence to string | ||
* | ||
* Simple version of `getEmojiSequenceString()` without options that otherwise add to bundle | ||
*/ | ||
declare function getEmojiSequenceKeyword(sequence: number[]): string; | ||
export { UnicodeFormattingOptions, getEmojiSequenceString, getEmojiUnicodeString }; | ||
export { UnicodeFormattingOptions, getEmojiSequenceKeyword, getEmojiSequenceString, getEmojiUnicodeString }; |
@@ -0,1 +1,3 @@ | ||
import { EmojiTestData } from '../test/parse.js'; | ||
/** | ||
@@ -19,4 +21,4 @@ * Create optimised regex | ||
*/ | ||
declare function createOptimisedRegex(emojis: (string | number[])[], testData?: number[][]): string; | ||
declare function createOptimisedRegex(emojis: (string | number[])[], testData?: EmojiTestData): string; | ||
export { createOptimisedRegex, createOptimisedRegexForEmojiSequences }; |
@@ -12,2 +12,3 @@ /** | ||
keyword: string; | ||
regexp: number; | ||
} | ||
@@ -29,3 +30,3 @@ /** | ||
*/ | ||
declare function getEmojiMatchesInText(regexp: string | RegExp, content: string): EmojiRegexMatch[]; | ||
declare function getEmojiMatchesInText(regexp: string | RegExp | (string | RegExp)[], content: string): EmojiRegexMatch[]; | ||
/** | ||
@@ -32,0 +33,0 @@ * Sort emojis, get prev and next text |
@@ -14,4 +14,4 @@ import { EmojiRegexMatch } from './find.js'; | ||
*/ | ||
declare function findAndReplaceEmojisInText(regexp: string | RegExp, content: string, callback: FindAndReplaceEmojisInTextCallback): string | null; | ||
declare function findAndReplaceEmojisInText(regexp: string | RegExp | (string | RegExp)[], content: string, callback: FindAndReplaceEmojisInTextCallback): string | null; | ||
export { FindAndReplaceEmojisInTextCallback, findAndReplaceEmojisInText }; |
import { EmojiComponentType } from '../data.js'; | ||
import { EmojiTestDataItem, EmojiSequenceToStringCallback } from './parse.js'; | ||
import { EmojiTestDataItem, EmojiTestData } from './parse.js'; | ||
@@ -14,4 +14,31 @@ interface EmojiTestDataComponentsMap { | ||
*/ | ||
declare function mapEmojiTestDataComponents(testSequences: Record<string, EmojiTestDataItem>, convert: EmojiSequenceToStringCallback): EmojiTestDataComponentsMap; | ||
declare function mapEmojiTestDataComponents(testSequences: EmojiTestData): EmojiTestDataComponentsMap; | ||
/** | ||
* Sequence with components | ||
*/ | ||
type EmojiSequenceWithComponents = (EmojiComponentType | number)[]; | ||
/** | ||
* Convert to string | ||
*/ | ||
declare function emojiSequenceWithComponentsToString(sequence: EmojiSequenceWithComponents): string; | ||
/** | ||
* Entry in sequence | ||
*/ | ||
interface EmojiSequenceComponentEntry { | ||
index: number; | ||
type: EmojiComponentType; | ||
} | ||
/** | ||
* Find variations in sequence | ||
*/ | ||
declare function findEmojiComponentsInSequence(sequence: number[]): EmojiSequenceComponentEntry[]; | ||
/** | ||
* Component values | ||
*/ | ||
type EmojiSequenceComponentValues = Partial<Record<EmojiComponentType, number[]>>; | ||
/** | ||
* Replace components in sequence | ||
*/ | ||
declare function replaceEmojiComponentsInCombinedSequence(sequence: EmojiSequenceWithComponents, values: EmojiSequenceComponentValues): number[]; | ||
export { EmojiTestDataComponentsMap, mapEmojiTestDataComponents }; | ||
export { EmojiSequenceComponentEntry, EmojiSequenceComponentValues, EmojiSequenceWithComponents, EmojiTestDataComponentsMap, emojiSequenceWithComponentsToString, findEmojiComponentsInSequence, mapEmojiTestDataComponents, replaceEmojiComponentsInCombinedSequence }; |
@@ -1,13 +0,14 @@ | ||
import { EmojiComponentType } from '../data.js'; | ||
import { EmojiTestDataComponentsMap } from './components.js'; | ||
import { EmojiTestDataItem } from './parse.js'; | ||
import { EmojiSequenceComponentEntry, EmojiTestDataComponentsMap } from './components.js'; | ||
import '../data.js'; | ||
import './parse.js'; | ||
interface EmojiNameVariation { | ||
index: number; | ||
type: EmojiComponentType; | ||
} | ||
/** | ||
* Split emoji name in base name and variations | ||
* | ||
* Variations are also split in strings and emoji components with indexes pointing to sequence | ||
*/ | ||
interface SplitEmojiName { | ||
base: string; | ||
key: string; | ||
variations?: (string | EmojiNameVariation)[]; | ||
variations?: (string | EmojiSequenceComponentEntry)[]; | ||
components?: number; | ||
@@ -21,19 +22,3 @@ } | ||
declare function splitEmojiNameVariations(name: string, sequence: number[], componentsData: EmojiTestDataComponentsMap): SplitEmojiName; | ||
/** | ||
* Map item | ||
*/ | ||
type EmojiComponentsMapItemSequence = (EmojiComponentType | number)[]; | ||
interface EmojiComponentsMapItem { | ||
name: string; | ||
sequence: EmojiComponentsMapItemSequence; | ||
children?: Record<EmojiComponentType, EmojiComponentsMapItem>; | ||
} | ||
/** | ||
* Get map of emoji components | ||
* | ||
* Result includes emoji sequences with largest number of characters (usually fully-qualified) | ||
* Only sequences with components are returned | ||
*/ | ||
declare function getEmojiComponentsMap(testData: EmojiTestDataItem[], componentsMap?: EmojiTestDataComponentsMap): EmojiComponentsMapItem[]; | ||
export { EmojiComponentsMapItem, SplitEmojiName, getEmojiComponentsMap, splitEmojiNameVariations }; | ||
export { SplitEmojiName, splitEmojiNameVariations }; |
type EmojiStatus = 'component' | 'fully-qualified' | 'minimally-qualified' | 'unqualified'; | ||
declare const componentStatus: EmojiStatus; | ||
/** | ||
* Callback for converting sequence to string | ||
* Base item | ||
*/ | ||
type EmojiSequenceToStringCallback = (value: number[]) => string; | ||
interface BaseEmojiTestDataItem { | ||
group: string; | ||
subgroup: string; | ||
version: string; | ||
} | ||
/** | ||
* Test data item | ||
*/ | ||
interface EmojiTestDataItem { | ||
group: string; | ||
subgroup: string; | ||
code: string; | ||
interface EmojiTestDataItem extends BaseEmojiTestDataItem { | ||
sequence: number[]; | ||
emoji: string; | ||
status: EmojiStatus; | ||
version: string; | ||
name: string; | ||
} | ||
type EmojiTestData = Record<string, EmojiTestDataItem>; | ||
/** | ||
* Get all emoji sequences from test file | ||
* | ||
* Returns all emojis as UTF-32 sequences | ||
*/ | ||
declare function parseEmojiTestFile(data: string): EmojiTestDataItem[]; | ||
/** | ||
* Get qualified variations from parsed test file | ||
* Returns all emojis as UTF-32 sequences, where: | ||
* key = unqualified sequence (without \uFE0F) | ||
* value = qualified sequence (with \uFE0F) | ||
* | ||
* Key is unqualified emoji, value is longest fully qualified emoji | ||
* Duplicate items that have different versions with and without \uFE0F are | ||
* listed only once, with unqualified sequence as key and longest possible | ||
* qualified sequence as value | ||
* | ||
* Example of 3 identical entries: | ||
* '1F441 FE0F 200D 1F5E8 FE0F' | ||
* '1F441 200D 1F5E8 FE0F' | ||
* '1F441 FE0F 200D 1F5E8' | ||
* '1F441 200D 1F5E8' | ||
* | ||
* Out of these entries, only one item will be returned with: | ||
* key = '1f441-200d-1f5e8' (converted to lower case, separated with dash) | ||
* value.sequence = [0x1F441, 0xFE0F, 0x200D, 0x1F5E8, 0xFE0F] | ||
* value.status = 'fully-qualified' | ||
* other properties in value are identical for all versions | ||
*/ | ||
declare function getQualifiedEmojiSequencesMap(sequences: number[][]): Map<number[], number[]>; | ||
declare function getQualifiedEmojiSequencesMap(sequences: number[][], toString: (value: number[]) => string): Record<string, string>; | ||
/** | ||
* Map data by sequence | ||
*/ | ||
declare function mapEmojiTestDataBySequence(testData: EmojiTestDataItem[], convert: EmojiSequenceToStringCallback): Record<string, EmojiTestDataItem>; | ||
declare function parseEmojiTestFile(data: string): EmojiTestData; | ||
export { EmojiSequenceToStringCallback, EmojiStatus, EmojiTestDataItem, componentStatus, getQualifiedEmojiSequencesMap, mapEmojiTestDataBySequence, parseEmojiTestFile }; | ||
export { BaseEmojiTestDataItem, EmojiStatus, EmojiTestData, EmojiTestDataItem, componentStatus, parseEmojiTestFile }; |
@@ -1,2 +0,2 @@ | ||
import { EmojiTestDataItem } from './parse.js'; | ||
import { EmojiTestData } from './parse.js'; | ||
@@ -14,2 +14,9 @@ /** | ||
/** | ||
* Base type to extend | ||
*/ | ||
interface BaseSequenceItem { | ||
sequence: number[]; | ||
sequenceKey?: string; | ||
} | ||
/** | ||
* Get qualified variations for emojis | ||
@@ -23,5 +30,8 @@ * | ||
*/ | ||
declare function getQualifiedEmojiVariations(sequences: number[][], testData?: (number[] | EmojiTestDataItem)[]): number[][]; | ||
declare function getQualifiedEmojiVariations(sequences: number[][], testData: (number[] | EmojiTestDataItem)[], toString: (value: number[]) => string): string[]; | ||
declare function getQualifiedEmojiVariation<T extends BaseSequenceItem>(item: T, testData?: EmojiTestData): T; | ||
/** | ||
* Get qualified emoji variations for set of emojis, ignoring duplicate entries | ||
*/ | ||
declare function getQualifiedEmojiVariations<T extends BaseSequenceItem>(items: T[], testData?: EmojiTestData): T[]; | ||
export { getQualifiedEmojiVariations, guessQualifiedEmojiSequence }; | ||
export { getQualifiedEmojiVariation, getQualifiedEmojiVariations, guessQualifiedEmojiSequence }; |
@@ -35,9 +35,10 @@ export { FullIconCustomisations, IconifyIconCustomisations, IconifyIconSize, IconifyIconSizeCustomisations, defaultIconCustomisations, defaultIconSizeCustomisations } from './customisations/defaults.js'; | ||
export { loadIcon } from './loader/loader.js'; | ||
export { getEmojiSequenceFromString, getUnqualifiedEmojiSequence, mapEmojiSequences, removeEmojiTones, removeEmojiVariations } from './emoji/cleanup.js'; | ||
export { getEmojiSequenceFromString, getUnqualifiedEmojiSequence } from './emoji/cleanup.js'; | ||
export { convertEmojiSequenceToUTF16, convertEmojiSequenceToUTF32, getEmojiCodePoint, getEmojiUnicode, isUTF32SplitNumber, mergeUTF32Numbers, splitUTF32Number } from './emoji/convert.js'; | ||
export { getEmojiSequenceString, getEmojiUnicodeString } from './emoji/format.js'; | ||
export { getQualifiedEmojiSequencesMap, parseEmojiTestFile } from './emoji/test/parse.js'; | ||
export { getEmojiSequenceKeyword, getEmojiSequenceString, getEmojiUnicodeString } from './emoji/format.js'; | ||
export { parseEmojiTestFile } from './emoji/test/parse.js'; | ||
export { getQualifiedEmojiVariations } from './emoji/test/variations.js'; | ||
export { getEmojisSequencesToCopy } from './emoji/test/copy.js'; | ||
export { findMissingEmojis } from './emoji/test/missing.js'; | ||
export { createOptimisedRegex, createOptimisedRegexForEmojiSequences } from './emoji/regex/create.js'; | ||
export { prepareEmojiForIconSet, prepareEmojiForIconsList } from './emoji/parse.js'; | ||
export { findAndReplaceEmojisInText } from './emoji/replace/replace.js'; | ||
@@ -50,2 +51,7 @@ export { camelToKebab, camelize, pascalize, snakelize } from './misc/strings.js'; | ||
import '@antfu/utils'; | ||
import './emoji/test/tree.js'; | ||
import './emoji/data.js'; | ||
import './emoji/test/similar.js'; | ||
import './emoji/test/components.js'; | ||
import './emoji/test/name.js'; | ||
import './emoji/replace/find.js'; |
@@ -6,3 +6,3 @@ { | ||
"author": "Vjacheslav Trushkin", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"license": "MIT", | ||
@@ -137,6 +137,6 @@ "bugs": "https://github.com/iconify/iconify/issues", | ||
}, | ||
"./lib/emoji/test/copy": { | ||
"require": "./lib/emoji/test/copy.cjs", | ||
"import": "./lib/emoji/test/copy.mjs", | ||
"types": "./lib/emoji/test/copy.d.ts" | ||
"./lib/emoji/test/missing": { | ||
"require": "./lib/emoji/test/missing.cjs", | ||
"import": "./lib/emoji/test/missing.mjs", | ||
"types": "./lib/emoji/test/missing.d.ts" | ||
}, | ||
@@ -153,2 +153,12 @@ "./lib/emoji/test/name": { | ||
}, | ||
"./lib/emoji/test/tree": { | ||
"require": "./lib/emoji/test/tree.cjs", | ||
"import": "./lib/emoji/test/tree.mjs", | ||
"types": "./lib/emoji/test/tree.d.ts" | ||
}, | ||
"./lib/emoji/test/similar": { | ||
"require": "./lib/emoji/test/similar.cjs", | ||
"import": "./lib/emoji/test/similar.mjs", | ||
"types": "./lib/emoji/test/similar.d.ts" | ||
}, | ||
"./lib/emoji/test/variations": { | ||
@@ -179,2 +189,7 @@ "require": "./lib/emoji/test/variations.cjs", | ||
}, | ||
"./lib/emoji/parse": { | ||
"require": "./lib/emoji/parse.cjs", | ||
"import": "./lib/emoji/parse.mjs", | ||
"types": "./lib/emoji/parse.d.ts" | ||
}, | ||
"./lib/icon-set/convert-info": { | ||
@@ -181,0 +196,0 @@ "require": "./lib/icon-set/convert-info.cjs", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
301972
198
9283