@@ -10,48 +10,62 @@ export default defineMojiAdapter({
10
10
range : ">=16.0.0 <17.0.0" ,
11
11
extend : "base" ,
12
12
sequences : async ( ctx ) => {
13
- const sequences = await fetchCache ( `https://unicode.org/Public/emoji/${ ctx . version } /emoji-sequences.txt` , {
14
- cacheKey : `v${ ctx . version } /sequences.json` ,
15
- parser ( data ) {
16
- const lines = data . split ( "\n" ) ;
13
+ const [ sequences , zwj ] = await Promise . all ( [
14
+ {
15
+ cacheKey : `v${ ctx . version } /sequences.json` ,
16
+ url : `https://unicode.org/Public/emoji/${ ctx . version } /emoji-sequences.txt` ,
17
+ } ,
18
+ {
19
+ cacheKey : `v${ ctx . version } /zwj-sequences.json` ,
20
+ url : `https://unicode.org/Public/emoji/${ ctx . version } /emoji-zwj-sequences.txt` ,
21
+ } ,
22
+ ] . map ( async ( { cacheKey, url } ) => {
23
+ return await fetchCache ( url , {
24
+ cacheKey,
25
+ parser ( data ) {
26
+ const lines = data . split ( "\n" ) ;
17
27
18
- const sequences : EmojiSequence [ ] = [ ] ;
28
+ const sequences : EmojiSequence [ ] = [ ] ;
19
29
20
- for ( let line of lines ) {
30
+ for ( let line of lines ) {
21
31
// skip empty line & comments
22
- if ( line . trim ( ) === "" || line . startsWith ( "#" ) ) {
23
- continue ;
24
- }
32
+ if ( line . trim ( ) === "" || line . startsWith ( "#" ) ) {
33
+ continue ;
34
+ }
25
35
26
- // remove line comment
27
- const commentIndex = line . indexOf ( "#" ) ;
28
- if ( commentIndex !== - 1 ) {
29
- line = line . slice ( 0 , commentIndex ) . trim ( ) ;
30
- }
36
+ // remove line comment
37
+ const commentIndex = line . indexOf ( "#" ) ;
38
+ if ( commentIndex !== - 1 ) {
39
+ line = line . slice ( 0 , commentIndex ) . trim ( ) ;
40
+ }
31
41
32
- const [ hex , property , description ] = line . split ( ";" ) . map ( ( col ) => col . trim ( ) ) . slice ( 0 , 4 ) ;
42
+ const [ hex , property , description ] = line . split ( ";" ) . map ( ( col ) => col . trim ( ) ) . slice ( 0 , 4 ) ;
33
43
34
- if ( hex == null || property == null || description == null ) {
35
- throw new Error ( `invalid line: ${ line } ` ) ;
36
- }
44
+ if ( hex == null || property == null || description == null ) {
45
+ throw new Error ( `invalid line: ${ line } ` ) ;
46
+ }
37
47
38
- const expandedHex = expandHexRange ( hex ) ;
48
+ const expandedHex = expandHexRange ( hex ) ;
39
49
40
- for ( const hex of expandedHex ) {
41
- sequences . push ( {
42
- hex : hex . replace ( / \s + / g, "-" ) ,
43
- property,
44
- description,
45
- gender : hex === FEMALE_SIGN ? "female" : hex === MALE_SIGN ? "male" : null ,
46
- } ) ;
50
+ for ( const hex of expandedHex ) {
51
+ sequences . push ( {
52
+ hex : hex . replace ( / \s + / g, "-" ) ,
53
+ property,
54
+ description,
55
+ gender : hex . includes ( FEMALE_SIGN ) ? "female" : hex . includes ( MALE_SIGN ) ? "male" : null ,
56
+ } ) ;
57
+ }
47
58
}
48
- }
49
59
50
- return sequences ;
51
- } ,
52
- bypassCache : ctx . force ,
53
- } ) ;
60
+ return sequences ;
61
+ } ,
62
+ bypassCache : ctx . force ,
63
+ } ) ;
64
+ } ) ) ;
54
65
55
- return sequences ;
66
+ return {
67
+ sequences : sequences || [ ] ,
68
+ zwj : zwj || [ ] ,
69
+ } ;
56
70
} ,
57
71
} ) ;
0 commit comments