Skip to content

Commit

Permalink
Update the build script
Browse files Browse the repository at this point in the history
  • Loading branch information
Dlurak committed Aug 4, 2024
1 parent 74998ff commit 38d30a4
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 96 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export const emoticon = [
name: 'rage',
emoji: '๐Ÿ˜ก',
tags: ['angry'],
description: 'pouting face',
description: 'enraged face',
emoticons: [':@', ':-@', '=@', '=-@']
},
{
Expand Down
127 changes: 66 additions & 61 deletions schema.json
Original file line number Diff line number Diff line change
@@ -1,63 +1,68 @@
{
"angry": [">", "eyesNormal", "noseOptional", "mouthNegative"],
"anguished": [],
"astonished": [],
"blush": ["eyesNormal", "noseOptional", "blush", "mouthPositive"],
"broken_heart": [["<"], ["\\", "/"], ["3"]],
"cold_sweat": [],
"confounded": [],
"confused": ["eyesNormal", "noseOptional", "mouthConfused"],
"cry": ["eyesNormal", "drop", "noseOptional", "mouthNotPositive"],
"disappointed": [],
"disappointed_relieved": [],
"dizzy_face": [],
"expressionless": [],
"fearful": [],
"flushed": [],
"frowning": ["eyesNormal", "noseOptional", "mouthNegative"],
"grimacing": [],
"grin": [],
"grinning": [],
"heart": [["<"], ["3"]],
"heart_eyes": [],
"hushed": [],
"imp": ["horns", "eyesNormal", "noseOptional", "mouthNegative"],
"innocent": ["halo", "eyesNormal", "noseOptional", "mouthPositive"],
"joy": ["eyesNormal", "drop", "noseOptional", "mouthPositive"],
"kissing": ["eyesNormal", "noseOptional", "mouthKissing"],
"kissing_closed_eyes": [],
"kissing_heart": [],
"kissing_smiling_eyes": [],
"laughing": ["eyesClosed", "noseOptional", "mouthPositive"],
"man": ["eyes", "noseOptional", "moustache"],
"mask": [],
"neutral_face": ["eyesNormal", "noseOptional", "mouthNeutral"],
"no_mouth": ["eyesNormal", "nose"],
"open_mouth": ["eyesNormal", "noseOptional", "mouthOpen"],
"pensive": [],
"persevere": [],
"rage": ["eyesNormal", "noseOptional", "mouthAngry"],
"relaxed": [],
"relieved": [],
"scream": [],
"sleeping": [],
"sleepy": [],
"smile": ["eyesNormal", "noseOptional", "mouthPositiveVery"],
"smiley": ["eyesNormal", "noseOptional", "mouthPositiveNormal"],
"smiling_imp": ["horns", "eyesNormal", "noseOptional", "mouthPositive"],
"smirk": [],
"sob": ["eyesNormal", "drop", "drop", "noseOptional", "mouthNegative"],
"stuck_out_tongue": ["eyesNormal", "noseOptional", "mouthTongue"],
"stuck_out_tongue_closed_eyes": ["eyesClosed", "noseOptional", "mouthTongue"],
"stuck_out_tongue_winking_eye": ["eyesWink", "noseOptional", "mouthTongue"],
"sunglasses": ["eyesGlasses", "noseOptional", "mouthPositive"],
"sweat": ["drop", "eyesNormal", "noseOptional", "mouthNegative"],
"sweat_smile": ["drop", "eyesNormal", "noseOptional", "mouthPositive"],
"tired_face": [],
"triumph": [],
"unamused": ["eyesNormal", "noseOptional", "mouthSquiggly"],
"weary": [],
"wink": ["eyesWink", "noseOptional", "mouthPositive"],
"worried": [],
"yum": []
"angry": [[">", "eyesNormal", "noseOptional", "mouthNegative"]],
"anguished": [[]],
"astonished": [[]],
"blush": [["eyesNormal", "noseOptional", "blush", "mouthPositive"]],
"broken_heart": [[["<"], ["\\", "/"], ["3"]]],
"cold_sweat": [[]],
"confounded": [[]],
"confused": [["eyesNormal", "noseOptional", "mouthConfused"]],
"cry": [
["eyesNormal", "drop", "noseOptional", "mouthNotPositive"],
[["T"], ["-"], ["T"]]
],
"disappointed": [[]],
"disappointed_relieved": [[]],
"dizzy_face": [[]],
"expressionless": [[]],
"fearful": [[]],
"flushed": [[]],
"frowning": [["eyesNormal", "noseOptional", "mouthNegative"]],
"grimacing": [[]],
"grin": [[]],
"grinning": [[]],
"heart": [[["<"], ["3"]]],
"heart_eyes": [[]],
"hushed": [[]],
"imp": [["horns", "eyesNormal", "noseOptional", "mouthNegative"]],
"innocent": [["halo", "eyesNormal", "noseOptional", "mouthPositive"]],
"joy": [["eyesNormal", "drop", "noseOptional", "mouthPositive"]],
"kissing": [["eyesNormal", "noseOptional", "mouthKissing"]],
"kissing_closed_eyes": [[]],
"kissing_heart": [[]],
"kissing_smiling_eyes": [[]],
"laughing": [["eyesClosed", "noseOptional", "mouthPositive"]],
"man": [["eyes", "noseOptional", "moustache"]],
"mask": [[]],
"neutral_face": [["eyesNormal", "noseOptional", "mouthNeutral"]],
"no_mouth": [["eyesNormal", "nose"]],
"open_mouth": [["eyesNormal", "noseOptional", "mouthOpen"]],
"pensive": [[]],
"persevere": [[]],
"rage": [["eyesNormal", "noseOptional", "mouthAngry"]],
"relaxed": [[]],
"relieved": [[]],
"scream": [[]],
"sleeping": [[]],
"sleepy": [[]],
"smile": [["eyesNormal", "noseOptional", "mouthPositiveVery"]],
"smiley": [["eyesNormal", "noseOptional", "mouthPositiveNormal"]],
"smiling_imp": [["horns", "eyesNormal", "noseOptional", "mouthPositive"]],
"smirk": [[]],
"sob": [["eyesNormal", "drop", "drop", "noseOptional", "mouthNegative"]],
"stuck_out_tongue": [["eyesNormal", "noseOptional", "mouthTongue"]],
"stuck_out_tongue_closed_eyes": [
["eyesClosed", "noseOptional", "mouthTongue"]
],
"stuck_out_tongue_winking_eye": [["eyesWink", "noseOptional", "mouthTongue"]],
"sunglasses": [["eyesGlasses", "noseOptional", "mouthPositive"]],
"sweat": [["drop", "eyesNormal", "noseOptional", "mouthNegative"]],
"sweat_smile": [["drop", "eyesNormal", "noseOptional", "mouthPositive"]],
"tired_face": [[]],
"triumph": [[]],
"unamused": [["eyesNormal", "noseOptional", "mouthSquiggly"]],
"weary": [[]],
"wink": [["eyesWink", "noseOptional", "mouthPositive"]],
"worried": [[]],
"yum": [[]]
}
57 changes: 32 additions & 25 deletions script/build-data.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-check

/**
* @typedef Emoticon
* @property {string} name
Expand All @@ -11,7 +13,7 @@ import assert from 'node:assert/strict'
import fs from 'node:fs/promises'
import {gemoji} from 'gemoji'

/** @type {Record<string, Array<string>>} */
/** @type {Record<string, Array<Array<string>>>} */
const schema = JSON.parse(String(await fs.readFile('schema.json')))
/** @type {Record<string, string|Array<string>>} */
const alias = JSON.parse(String(await fs.readFile('alias.json')))
Expand All @@ -29,31 +31,36 @@ const data = Object.keys(schema)
.map((ctx) => {
assert(ctx.info, 'expected matching gemoji for `' + ctx.name + '`')
const structure = ctx.structure
const flatStructure = structure.map((key) => flatten([key]))
/** @type {Array<string>|undefined} */
let result

while (flatStructure[1]) {
result = unpack(flatStructure)
flatStructure.shift()
flatStructure[0] = result
}

// Remove some dangerous emoticons.
result = (result || []).filter((emoticon) => {
if (
(/^[a-zA-Z]+$/.test(emoticon) &&
(emoticon.toUpperCase() === emoticon ||
emoticon.toLowerCase() === emoticon)) ||
/([\s\S])\1+/g.test(emoticon) ||
emoticon === '=-'
) {
console.log('Removing dangerous/unused emoticon:', emoticon)
return false
}

return true
})
let result = structure
.flatMap((faceStructure) => {
const flatStructure = faceStructure.map((key) => flatten([key]))
/** @type {Array<string>|undefined} */
let result

while (flatStructure[1]) {
result = unpack(flatStructure)
flatStructure.shift()
flatStructure[0] = result
}

return result ?? []
})
.filter((emoticon) => {
// Remove some dangerous emoticons.
if (
(/^[a-zA-Z]+$/.test(emoticon) &&
(emoticon.toUpperCase() === emoticon ||
emoticon.toLowerCase() === emoticon)) ||
/([\s\S])\1+/g.test(emoticon) ||
emoticon === '=-'
) {
console.log('Removing dangerous/unused emoticon:', emoticon)
return false
}

return true
})

return {
name: ctx.name,
Expand Down
18 changes: 9 additions & 9 deletions support.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ the first column!
| :-: | :-: | :-: | :-: |
| ๐Ÿ˜  | angry | mad; annoyed | `>:(`; `>:[`; `>:-(`; `>:-[`; `>=(`; `>=[`; `>=-(`; `>=-[` |
| ๐Ÿ˜Š | blush | proud | `:")`; `:"]`; `:"D`; `:-")`; `:-"]`; `:-"D`; `=")`; `="]`; `="D`; `=-")`; `=-"]`; `=-"D` |
| ๐Ÿ’” | broken\_heart | | `<\3`; `</3` |
| ๐Ÿ’” | broken_heart | | `<\3`; `</3` |
| ๐Ÿ˜• | confused | | `:/`; `:\`; `:-/`; `:-\`; `=/`; `=\`; `=-/`; `=-\` |
| ๐Ÿ˜ข | cry | sad; tear | `:,(`; `:,[`; `:,\|`; `:,-(`; `:,-[`; `:,-\|`; `:'(`; `:'[`; `:'\|`; `:'-(`; `:'-[`; `:'-\|`; `=,(`; `=,[`; `=,\|`; `=,-(`; `=,-[`; `=,-\|`; `='(`; `='[`; `='\|`; `='-(`; `='-[`; `='-\|`; `T-T` |
| ๐Ÿ˜ฆ | frowning | | `:(`; `:[`; `:-(`; `:-[`; `=(`; `=[`; `=-(`; `=-[` |
Expand All @@ -18,19 +18,19 @@ the first column!
| ๐Ÿ˜— | kissing | | `:*`; `:-*`; `=*`; `=-*` |
| ๐Ÿ˜† | laughing | happy; haha | `x)`; `x]`; `xD`; `x-)`; `x-]`; `x-D`; `X)`; `X]`; `X-)`; `X-]`; `X-D` |
| ๐Ÿ‘จ | man | mustache; father; dad | `:3`; `:-3`; `=3`; `=-3`; `;3`; `;-3`; `x3`; `x-3`; `X3`; `X-3` |
| ๐Ÿ˜ | neutral\_face | meh | `:\|`; `:-\|`; `=\|`; `=-\|` |
| ๐Ÿ˜ถ | no\_mouth | mute; silence | `:-` |
| ๐Ÿ˜ฎ | open\_mouth | surprise; impressed; wow | `:o`; `:O`; `:0`; `:-o`; `:-O`; `:-0`; `=o`; `=O`; `=0`; `=-o`; `=-O`; `=-0` |
| ๐Ÿ˜ | neutral_face | meh | `:\|`; `:-\|`; `=\|`; `=-\|` |
| ๐Ÿ˜ถ | no_mouth | mute; silence | `:-` |
| ๐Ÿ˜ฎ | open_mouth | surprise; impressed; wow | `:o`; `:O`; `:0`; `:-o`; `:-O`; `:-0`; `=o`; `=O`; `=0`; `=-o`; `=-O`; `=-0` |
| ๐Ÿ˜ก | rage | angry | `:@`; `:-@`; `=@`; `=-@` |
| ๐Ÿ˜„ | smile | happy; joy; laugh; pleased | `:D`; `:-D`; `=D`; `=-D` |
| ๐Ÿ˜ƒ | smiley | happy; joy; haha | `:)`; `:]`; `:-)`; `:-]`; `=)`; `=]`; `=-)`; `=-]` |
| ๐Ÿ˜ˆ | smiling\_imp | devil; evil; horns | `]:)`; `]:]`; `]:D`; `]:-)`; `]:-]`; `]:-D`; `]=)`; `]=]`; `]=D`; `]=-)`; `]=-]`; `]=-D` |
| ๐Ÿ˜ˆ | smiling_imp | devil; evil; horns | `]:)`; `]:]`; `]:D`; `]:-)`; `]:-]`; `]:-D`; `]=)`; `]=]`; `]=D`; `]=-)`; `]=-]`; `]=-D` |
| ๐Ÿ˜ญ | sob | sad; cry; bawling | `:,'(`; `:,'[`; `:,'-(`; `:,'-[`; `:',(`; `:',[`; `:',-(`; `:',-[`; `=,'(`; `=,'[`; `=,'-(`; `=,'-[`; `=',(`; `=',[`; `=',-(`; `=',-[` |
| ๐Ÿ˜› | stuck\_out\_tongue | | `:p`; `:P`; `:d`; `:-p`; `:-P`; `:-d`; `=p`; `=P`; `=d`; `=-p`; `=-P`; `=-d` |
| ๐Ÿ˜ | stuck\_out\_tongue\_closed\_eyes | prank | `xP`; `x-p`; `x-P`; `x-d`; `Xp`; `Xd`; `X-p`; `X-P`; `X-d` |
| ๐Ÿ˜œ | stuck\_out\_tongue\_winking\_eye | prank; silly | `;p`; `;P`; `;d`; `;-p`; `;-P`; `;-d` |
| ๐Ÿ˜› | stuck_out_tongue | | `:p`; `:P`; `:d`; `:-p`; `:-P`; `:-d`; `=p`; `=P`; `=d`; `=-p`; `=-P`; `=-d` |
| ๐Ÿ˜ | stuck_out_tongue_closed_eyes | prank | `xP`; `x-p`; `x-P`; `x-d`; `Xp`; `Xd`; `X-p`; `X-P`; `X-d` |
| ๐Ÿ˜œ | stuck_out_tongue_winking_eye | prank; silly | `;p`; `;P`; `;d`; `;-p`; `;-P`; `;-d` |
| ๐Ÿ˜Ž | sunglasses | cool | `8)`; `8]`; `8D`; `8-)`; `8-]`; `8-D`; `B)`; `B]`; `B-)`; `B-]`; `B-D` |
| ๐Ÿ˜“ | sweat | | `,:(`; `,:[`; `,:-(`; `,:-[`; `,=(`; `,=[`; `,=-(`; `,=-[`; `':(`; `':[`; `':-(`; `':-[`; `'=(`; `'=[`; `'=-(`; `'=-[` |
| ๐Ÿ˜… | sweat\_smile | hot | `,:)`; `,:]`; `,:D`; `,:-)`; `,:-]`; `,:-D`; `,=)`; `,=]`; `,=D`; `,=-)`; `,=-]`; `,=-D`; `':)`; `':]`; `':D`; `':-)`; `':-]`; `':-D`; `'=)`; `'=]`; `'=D`; `'=-)`; `'=-]`; `'=-D` |
| ๐Ÿ˜… | sweat_smile | hot | `,:)`; `,:]`; `,:D`; `,:-)`; `,:-]`; `,:-D`; `,=)`; `,=]`; `,=D`; `,=-)`; `,=-]`; `,=-D`; `':)`; `':]`; `':D`; `':-)`; `':-]`; `':-D`; `'=)`; `'=]`; `'=D`; `'=-)`; `'=-]`; `'=-D` |
| ๐Ÿ˜’ | unamused | meh | `:$`; `:s`; `:z`; `:S`; `:Z`; `:-$`; `:-s`; `:-z`; `:-S`; `:-Z`; `=$`; `=s`; `=z`; `=S`; `=Z`; `=-$`; `=-s`; `=-z`; `=-S`; `=-Z` |
| ๐Ÿ˜‰ | wink | flirt | `;)`; `;]`; `;D`; `;-)`; `;-]`; `;-D` |

0 comments on commit 38d30a4

Please sign in to comment.