♻️ Refer develop version firefish (Cargo.lock, Cargo.toml, locales/ca-ES.yml, package.json, packages/backend-rs/src/cache/redis.rs, packages/backend-rs/src/database/redis.rs, packages/backend-rs/src/federation/activitypub/object/follow.rs, packages/backend-rs/src/federation/activitypub/object/like.rs, packages/backend-rs/src/federation/activitypub/object/relay.rs, packages/backend-rs/src/federation/internal_actor/instance.rs, packages/backend-rs/src/federation/internal_actor/relay.rs, packages/backend-rs/src/federation/nodeinfo/fetch.rs, packages/backend-rs/src/federation/nodeinfo/generate.rs, packages/backend-rs/src/misc/convert_host.rs, packages/backend-rs/src/misc/emoji.rs, packages/backend-rs/src/misc/emoji/reaction.rs, packages/backend-rs/src/misc/get_image_size.rs, packages/backend-rs/src/misc/latest_version.rs, packages/backend-rs/src/misc/password.rs, packages/backend-rs/src/misc/random_icon.rs, packages/backend-rs/src/misc/should_nyaify.rs, packages/backend-rs/src/misc/translate.rs, packages/backend-rs/src/service/antenna/check_hit.rs, packages/backend-rs/src/service/antenna/process_new_note.rs, packages/backend-rs/src/service/push_notification.rs, packages/backend-rs/src/service/stream.rs, packages/backend-rs/src/util/error_chain.rs, packages/backend-rs/src/util/http_client.rs, packages/backend/assets/resource-unknown.svg, packages/backend/package.json, packages/client/package.json, packages/client/src/components/MkInstanceCardMini.vue, packages/client/src/components/MkInstanceTicker.vue, packages/client/src/components/MkUrlPreview.vue, packages/client/src/ui/_common_/statusbar-federation.vue, packages/client/src/widgets/federation.vue, packages/client/src/widgets/instance-cloud.vue, packages/firefish-js/package.json, packages/macro-rs/macros-impl/Cargo.toml, packages/macro-rs/macros-impl/src/lib.rs, packages/macro-rs/macros-impl/src/napi.rs, packages/macro-rs/macros/src/lib.rs, packages/sw/package.json, pnpm-lock.yaml)

This commit is contained in:
ひでまる 2024-08-24 09:40:20 +09:00
parent cdd8109e81
commit 41186813ed
44 changed files with 778 additions and 665 deletions

135
Cargo.lock generated
View file

@ -115,9 +115,9 @@ dependencies = [
[[package]]
name = "arrayvec"
version = "0.7.4"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
[[package]]
name = "async-channel"
@ -397,9 +397,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
[[package]]
name = "bytemuck"
version = "1.16.3"
version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "102087e286b4677862ea56cf8fc58bb2cdfa8725c40ffb80fe3a008eb7f2fc83"
checksum = "6fd4c6dcc3b0aea2f5c0b4b82c2b15fe39ddbc76041a310848f4706edf76bb31"
[[package]]
name = "byteorder"
@ -427,12 +427,13 @@ checksum = "a2698f953def977c68f935bb0dfa959375ad4638570e969e2f1e9f433cbf1af6"
[[package]]
name = "cc"
version = "1.1.7"
version = "1.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc"
checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48"
dependencies = [
"jobserver",
"libc",
"shlex",
]
[[package]]
@ -549,15 +550,15 @@ dependencies = [
[[package]]
name = "core-foundation-sys"
version = "0.8.6"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "cpufeatures"
version = "0.2.12"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504"
checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad"
dependencies = [
"libc",
]
@ -666,17 +667,18 @@ dependencies = [
[[package]]
name = "cuid-util"
version = "0.1.0"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ea2bfe0336ff1b7ca74819b2df8dfae9afea358aff6b1688baa5c181d8c3713"
checksum = "1d59a706635108a7e8eaae7ec8e6154504fafa4a415ef38690d94fccea051757"
[[package]]
name = "cuid2"
version = "0.1.2"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47d99cacd52fd67db7490ad051c8c1973fb75520174d69aabbae08c534c9d0e8"
checksum = "50e281dc36864ea88fae2ec4e21eb280e8239487acb1ddc59b528b0afa7997bd"
dependencies = [
"cuid-util",
"getrandom",
"num",
"rand",
"sha3",
@ -948,9 +950,19 @@ dependencies = [
[[package]]
name = "error-doc"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6ecb74b1f4f3bbe7256b096a7ae9f7ce8f38558659b6624b7ad04e35919cf2e"
dependencies = [
"error-doc-impl",
"thiserror",
]
[[package]]
name = "error-doc-impl"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ffaad84523e0144697672bce3a0d8e300fd43404a630d420f238e2ef2e85b84"
checksum = "7a10557d7f42ee2e042f39b7bcfac19f1c4fad711e364a5ed9f9d7b6fa71b481"
dependencies = [
"proc-macro2",
"quote",
@ -1567,9 +1579,9 @@ checksum = "44feda355f4159a7c757171a77de25daf6411e217b4cabd03bd6650690468126"
[[package]]
name = "indexmap"
version = "2.3.0"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0"
checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c"
dependencies = [
"equivalent",
"hashbrown",
@ -1685,9 +1697,9 @@ checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0"
[[package]]
name = "js-sys"
version = "0.3.69"
version = "0.3.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d"
checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a"
dependencies = [
"wasm-bindgen",
]
@ -1758,9 +1770,9 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
[[package]]
name = "libc"
version = "0.2.155"
version = "0.2.157"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
checksum = "374af5f94e54fa97cf75e945cce8a6b201e88a1a07e688b47dfd2a59c66dbd86"
[[package]]
name = "libfuzzer-sys"
@ -1812,9 +1824,9 @@ dependencies = [
[[package]]
name = "libz-sys"
version = "1.1.18"
version = "1.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c15da26e5af7e25c90b37a2d75cdbf940cf4a55316de9d84c679c9b8bfabf82e"
checksum = "fdc53a7799a7496ebc9fd29f31f7df80e83c9bda5299768af5f9e59eeea74647"
dependencies = [
"cc",
"libc",
@ -1877,6 +1889,7 @@ name = "macros-impl"
version = "0.0.0"
dependencies = [
"convert_case",
"proc-macro-tester",
"proc-macro2",
"quote",
"syn 2.0.75",
@ -1932,9 +1945,9 @@ dependencies = [
[[package]]
name = "mio"
version = "1.0.1"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4"
checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec"
dependencies = [
"hermit-abi",
"libc",
@ -2176,9 +2189,9 @@ dependencies = [
[[package]]
name = "object"
version = "0.36.2"
version = "0.36.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e"
checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9"
dependencies = [
"memchr",
]
@ -2582,6 +2595,16 @@ dependencies = [
"version_check",
]
[[package]]
name = "proc-macro-tester"
version = "0.1.0-alpha.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe34f46c8f3754bfd1f73ec173dbf2e140fa43ece1f96ad81c02524f8c26b92a"
dependencies = [
"proc-macro2",
"quote",
]
[[package]]
name = "proc-macro2"
version = "1.0.86"
@ -2627,9 +2650,9 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
[[package]]
name = "quote"
version = "1.0.36"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
dependencies = [
"proc-macro2",
]
@ -2814,9 +2837,9 @@ dependencies = [
[[package]]
name = "rgb"
version = "0.8.47"
version = "0.8.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e12bc8d2f72df26a5d3178022df33720fbede0d31d82c7291662eff89836994d"
checksum = "0f86ae463694029097b846d8f99fd5536740602ae00022c0c50c5600720b2f71"
dependencies = [
"bytemuck",
]
@ -3127,9 +3150,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.125"
version = "1.0.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed"
checksum = "b3b863381a05ffefbc82571a2d893edf47b27fb0ebedbf582c39640e51abebef"
dependencies = [
"itoa",
"memchr",
@ -3200,6 +3223,12 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "signal-hook-registry"
version = "1.4.2"
@ -3630,9 +3659,9 @@ dependencies = [
[[package]]
name = "sysinfo"
version = "0.31.2"
version = "0.31.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4115055da5f572fff541dd0c4e61b0262977f453cc9fe04be83aba25a89bdab"
checksum = "2b92e0bdf838cbc1c4c9ba14f9c97a7ec6cdcd1ae66b10e1e42775a25553f45d"
dependencies = [
"core-foundation-sys",
"libc",
@ -3662,15 +3691,15 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
[[package]]
name = "tempfile"
version = "3.11.0"
version = "3.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53"
checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64"
dependencies = [
"cfg-if",
"fastrand 2.1.0",
"once_cell",
"rustix",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@ -4128,19 +4157,20 @@ dependencies = [
[[package]]
name = "wasm-bindgen"
version = "0.2.92"
version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8"
checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5"
dependencies = [
"cfg-if",
"once_cell",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.92"
version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da"
checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b"
dependencies = [
"bumpalo",
"log",
@ -4153,9 +4183,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.92"
version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726"
checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@ -4163,9 +4193,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.92"
version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836"
dependencies = [
"proc-macro2",
"quote",
@ -4176,9 +4206,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.92"
version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"
[[package]]
name = "web-push"
@ -4326,6 +4356,15 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-targets"
version = "0.48.5"

View file

@ -21,9 +21,9 @@ bb8 = { version = "0.8.5", default-features = false }
bcrypt = { version = "0.15.1", default-features = false }
chrono = { version = "0.4.38", default-features = false }
convert_case = { version = "0.6.0", default-features = false }
cuid2 = { version = "0.1.2", default-features = false }
cuid2 = { version = "0.1.3", default-features = false }
emojis = { version = "0.6.3", default-features = false }
error-doc = { version = "0.1.0" }
error-doc = { version = "0.2.0" }
futures-util = { version = "0.3.30", default-features = false }
identicon-rs = "5.0.1"
idna = { version = "1.0.2", default-features = false }
@ -32,18 +32,19 @@ isahc = { version = "1.7.2", default-features = false }
nom-exif = { version = "1.3.0", default-features = false }
once_cell = { version = "1.19.0", default-features = false }
pretty_assertions = { version = "1.4.0", default-features = false }
proc-macro-tester = { version = "0.1.0-alpha.1", default-features = false }
proc-macro2 = { version = "1.0.86", default-features = false }
quote = { version = "1.0.36", default-features = false }
quote = { version = "1.0.37", default-features = false }
rand = { version = "0.8.5", default-features = false }
redis = { version = "0.26.1", default-features = false }
regex = { version = "1.10.6", default-features = false }
rmp-serde = { version = "1.3.0", default-features = false }
sea-orm = { version = "1.0.0", default-features = false }
serde = { version = "1.0.208", default-features = false }
serde_json = { version = "1.0.125", default-features = false }
serde_json = { version = "1.0.126", default-features = false }
serde_yaml = { version = "0.9.34", default-features = false }
syn = { version = "2.0.75", default-features = false }
sysinfo = { version = "0.31.2", default-features = false }
sysinfo = { version = "0.31.3", default-features = false }
thiserror = { version = "1.0.63", default-features = false }
tokio = { version = "1.39.3", default-features = false }
tokio-test = { version = "0.4.4", default-features = false }

View file

@ -51,7 +51,7 @@ addToList: "Afegeix a la llista"
sendMessage: "Envia un missatge"
copyUsername: "Copia el nom d'usuari"
searchUser: "Cerca un usuari"
reply: "Resposta"
reply: "Respon"
loadMore: "Carrega'n més"
showMore: "Mostra'n més"
youGotNewFollower: "t'ha seguit"
@ -110,7 +110,7 @@ pinnedNote: "Publicació fixada"
pinned: "Fixa al perfil"
you: "Tu"
clickToShow: "Fes clic per mostrar"
sensitive: "NSFW"
sensitive: "Sensible"
add: "Afegeix"
reaction: "Reacció"
reactionSetting: "Reaccions per mostrar al selector de reaccions"
@ -118,8 +118,8 @@ reactionSettingDescription2: "Arrossega per reordenar, fes clic per suprimir, pr
\"+\" per afegir."
rememberNoteVisibility: "Recorda la configuració de visibilitat de les publicacions"
attachCancel: "Elimina el fitxer adjunt"
markAsSensitive: "Marca com a NSFW"
unmarkAsSensitive: "Desmarca com a NSFW"
markAsSensitive: "Marca com a sensible"
unmarkAsSensitive: "Desmarca com a sensible"
enterFileName: "Introdueix un nom de fitxer"
mute: "Silencia"
unmute: "Deixar de silenciar"
@ -129,7 +129,7 @@ suspend: "Suspèn"
unsuspend: "Treu la suspensió"
instances: "Servidors"
remove: "Elimina"
nsfw: "NSFW"
nsfw: "Sensible"
pinnedNotes: "Publicacions fixades"
userList: "Llistes"
smtpUser: "Nom d'usuari"
@ -846,7 +846,7 @@ federating: Federant
blocked: Bloquejat
subscribing: Subscrivint
publishing: Publicant
notResponding: Sense resposta
notResponding: Sense respon
instanceUsers: Usuaris d'aquest servidor
instanceFollowing: Seguint al servidor
instanceFollowers: Seguidors del servidor
@ -1300,7 +1300,7 @@ no: No
noCrawle: Rebutjar la indexació dels restrejadors
driveUsage: Espai fet servir al Disk
noCrawleDescription: Demanar als motors de cerca externs no indexar el teu contingut.
alwaysMarkSensitive: Marcar per defecte com a NSFW
alwaysMarkSensitive: Marcar per defecte com a sensible
lockedAccountInfo: Si has configurat la visibilitat del compte per "Només seguidors"
les teves publicacions no serien visibles per a ningú més, inclús si has d'aprovar
els teus seguidors manualment.
@ -1573,10 +1573,10 @@ sensitiveMediaDetection: Detecció de mitjans NSFW
remoteOnly: Només remotes
failedToUpload: S'ha produït un error en la càrrega
cannotUploadBecauseInappropriate: Aquest fitxer no s'ha pogut carregar perquè s'han
detectat parts d'aquest com a potencialment NSFW.
detectat parts d'aquest com a potencialment sensibles.
cannotUploadBecauseNoFreeSpace: La pujada ha fallat a causa de la manca d'espai al
Disc.
enableAutoSensitive: Marcatge automàtic NSFW
enableAutoSensitive: Marca automàticament com a sensible
moveTo: Mou aquest compte a un compte nou
customKaTeXMacro: Macros KaTeX personalitzats
_aboutFirefish:
@ -1766,8 +1766,8 @@ defaultReaction: Reacció d'emoji predeterminades per a publicacions sortints i
enableCustomKaTeXMacro: Activa les macros KaTeX personalitzades
noteId: ID de la publicació
_nsfw:
respect: Amaga els mitjans NSFW
ignore: No amagueu els mitjans NSFW
respect: Amaga els mitjans sensibles
ignore: No amagueu els mitjans sensibles
force: Amaga tots els mitjans
inUse: Utilitzat
ffVisibilityDescription: Et permet configurar qui pot veure a qui segueixes i qui
@ -2265,7 +2265,7 @@ publishTimelinesDescription: Si està activat, les línies de temps Global i Loc
noAltTextWarning: Alguns fitxers adjunts no tenen una descripció. T'has s oblidat
d'escriure-les?
showNoAltTextWarning: Mostra un avís si públiques un fitxer sense descripció
toReply: Resposta
toReply: Respondre
toQuote: Citar
toEdit: Edita
searchUsersDescription: "Per buscar publicacions concretes d'un usuari/servidor, escriu
@ -2291,8 +2291,8 @@ incorrectLanguageWarning: "Semblar ser que la teva publicació es troba en {dete
markLocalFilesNsfwByDefault: Marcar tots els fitxers locals nous com a sensibles per
defecte
markLocalFilesNsfwByDefaultDescription: Independentment d'aquest ajust, els usuaris
poden treure l'etiqueta NSFW els mateixos. Els fitxers que ja existeixen no es veuen
afectats.
poden treure els mateixos l'etiqueta de sensible. Els fitxers que ja existeixen
no es veuen afectats.
autocorrectNoteLanguage: Mostra un avís si l'idioma de la publicació no coincideix
amb el resultat de l'idioma detectat automàticament
noteEditHistory: Historial d'edicions

View file

@ -1,11 +1,11 @@
{
"name": "puyoskey",
"version": "v0.1.0-20240818",
"version": "v0.1.0-20240818.snapshot-16d0df49724a614ee912c022d2540c8b7040805f",
"repository": {
"type": "git",
"url": "https://git.v-sli.me/HidemaruOwO/puyoskey.git"
},
"packageManager": "pnpm@9.7.1",
"packageManager": "pnpm@9.8.0",
"private": true,
"scripts": {
"rebuild": "pnpm run clean && pnpm run build",
@ -47,8 +47,8 @@
"@biomejs/cli-darwin-x64": "1.8.3",
"@biomejs/cli-linux-arm64": "1.8.3",
"@biomejs/cli-linux-x64": "1.8.3",
"@types/node": "20.15.0",
"@types/node": "20.16.1",
"execa": "9.3.1",
"pnpm": "9.7.1"
"pnpm": "9.8.0"
}
}

View file

@ -16,7 +16,7 @@ pub enum Category {
Test,
}
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[error("failed to execute Redis command")]
Redis(#[from] RedisError),

View file

@ -82,7 +82,7 @@ async fn init_conn_pool() -> Result<(), RedisError> {
Ok(())
}
#[macros::errors]
#[error_doc::errors]
pub enum RedisConnError {
#[error("failed to initialize Redis connection pool")]
Redis(RedisError),

View file

@ -11,7 +11,7 @@ pub struct ApFollow {
impl ApObject for ApFollow {}
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[error("follower uri is missing")]
MissingFollowerUri,

View file

@ -7,7 +7,7 @@ use crate::{
};
use sea_orm::{ColumnTrait, DbErr, EntityTrait, QueryFilter, QuerySelect};
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[doc = "Nonexistent note"]
#[error("note {0} not found")]

View file

@ -1,28 +0,0 @@
use super::*;
use crate::{config::CONFIG, federation::internal_actor};
use serde::Serialize;
#[derive(Serialize)]
#[macros::export(object)]
pub struct FollowRelay {
pub id: String,
pub r#type: Activity,
pub actor: String,
pub object: String,
}
impl ActivityPubObject for FollowRelay {}
#[macros::export(js_name = "renderFollowRelay")]
pub async fn follow(relay_id: &str) -> Result<FollowRelay, internal_actor::relay::Error> {
Ok(FollowRelay {
id: format!("{}/activities/follow-relay/{}", CONFIG.url, relay_id),
r#type: Activity::Follow,
actor: format!(
"{}/users/{}",
CONFIG.url,
internal_actor::relay::get_id().await?
),
object: "https://www.w3.org/ns/activitystreams#Public".to_owned(),
})
}

View file

@ -7,7 +7,7 @@ use tokio::sync::OnceCell;
pub const USERNAME: &str = "instance.actor";
static INSTANCE_ACTOR: OnceCell<user::Model> = OnceCell::const_new();
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[error("@instance.actor not found")]
InstanceActorNotFound,

View file

@ -7,7 +7,7 @@ use tokio::sync::OnceCell;
pub const USERNAME: &str = "relay.actor";
static RELAY_ACTOR_ID: OnceCell<String> = OnceCell::const_new();
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[error("@relay.actor not found")]
RelayActorNotFound,

View file

@ -8,7 +8,7 @@ use isahc::AsyncReadResponseExt;
use serde::Deserialize;
/// Errors that can occur while fetching NodeInfo from a remote server
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[error("failed to acquire an HTTP client")]
HttpClient(#[from] http_client::Error),

View file

@ -143,7 +143,7 @@ pub async fn nodeinfo_2_0() -> Result<Nodeinfo20, DbErr> {
}
#[macros::for_ts]
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[doc = "Database error"]
#[error(transparent)]

View file

@ -2,7 +2,7 @@
// We may want to (re)implement these functions in the `federation` module
// in a Rusty way (e.g., traits of actor type) if needed.
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[doc = "UTS #46 process has failed"]
#[error(transparent)]

View file

@ -1,6 +0,0 @@
//! This module is used in the TypeScript backend only.
#[macros::ts_export]
pub fn is_unicode_emoji(s: &str) -> bool {
emojis::get(s).is_some()
}

View file

@ -53,7 +53,7 @@ pub fn count_reactions(reactions: &HashMap<String, u32>) -> HashMap<String, u32>
res
}
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[doc = "UTS #46 process has failed"]
#[error(transparent)]

View file

@ -7,7 +7,7 @@ use nom_exif::{parse_jpeg_exif, EntryValue, ExifTag};
use std::io::Cursor;
use tokio::sync::Mutex;
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[error("Redis cache operation has failed")]
Cache(#[from] cache::redis::Error),

View file

@ -6,7 +6,7 @@ use futures_util::AsyncReadExt;
use isahc::AsyncReadResponseExt;
use serde::Deserialize;
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[error("HTTP request failed")]
Isahc(#[from] isahc::Error),

View file

@ -15,7 +15,7 @@ pub fn hash_password(password: &str) -> Result<String, password_hash::errors::Er
.to_string())
}
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[error("failed to verify password against bcrypt hash")]
Bcrypt(#[from] bcrypt::BcryptError),

View file

@ -2,7 +2,7 @@ use crate::cache;
use chrono::Duration;
use identicon_rs::{error::IdenticonError, Identicon};
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[doc = "Failed to generate identicon"]
#[error(transparent)]

View file

@ -4,7 +4,7 @@ use crate::{cache, database::db_conn, model::entity::user};
use chrono::Duration;
use sea_orm::{DbErr, EntityTrait, QuerySelect};
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[doc = "Database error"]
#[error(transparent)]

View file

@ -3,7 +3,7 @@ use crate::{
util::http_client,
};
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[doc = "Database error"]
#[error(transparent)]

View file

@ -8,7 +8,7 @@ use crate::{
use chrono::Duration;
use sea_orm::{prelude::*, QuerySelect};
#[macros::errors]
#[error_doc::errors]
pub enum AntennaCheckError {
#[doc = "Database error"]
#[error(transparent)]

View file

@ -14,7 +14,7 @@ use crate::{
use redis::{streams::StreamMaxlen, AsyncCommands, RedisError};
use sea_orm::prelude::*;
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[doc = "Database error"]
#[error(transparent)]

View file

@ -13,7 +13,7 @@ use sea_orm::prelude::*;
use serde::Deserialize;
use web_push::*;
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[doc = "Database error"]
#[error(transparent)]

View file

@ -65,7 +65,7 @@ pub enum ChatEvent {
Typing,
}
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[error("failed to execute a Redis command")]
Redis(#[from] RedisError),

View file

@ -34,7 +34,7 @@ mod unit_test {
#[error("unexpected string '{0}'")]
struct InnerError2(String);
#[macros::errors]
#[error_doc::errors]
enum ErrorVariants {
#[error("error 1 occured")]
Error1(#[from] InnerError1),

View file

@ -5,7 +5,7 @@ use isahc::{config::*, HttpClient};
use once_cell::sync::OnceCell;
use std::time::Duration;
#[macros::errors]
#[error_doc::errors]
pub enum Error {
#[error("HTTP request failed")]
Isahc(#[from] isahc::Error),

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 27.5.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="resource-unknown" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
y="0px" viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="preserve">
<style type="text/css">
.st0{fill:none;stroke:#FE7E01;stroke-width:10;stroke-miterlimit:10;}
.st1{fill:#FE7E01;}
</style>
<path class="st0" d="M350,450H150c-27.61,0-50-22.39-50-50V100c0-27.61,22.39-50,50-50h200c27.61,0,50,22.39,50,50v300
C400,427.61,377.61,450,350,450z"/>
<g>
<path class="st1" d="M230.62,279.62c-1.17-8-0.59-14.96,1.75-20.88c2.33-5.91,5.5-11.12,9.5-15.62s8.12-8.71,12.38-12.62
c4.25-3.91,7.88-7.88,10.88-11.88s4.5-8.5,4.5-13.5c0-6.83-2-12.12-6-15.88s-9.67-5.62-17-5.62c-5.84,0-11.25,1.29-16.25,3.88
c-5,2.59-9.92,6.54-14.75,11.88l-20.5-19c7-8,15.16-14.41,24.5-19.25c9.33-4.83,19.75-7.25,31.25-7.25
c10.5,0,19.79,1.79,27.88,5.38c8.08,3.59,14.46,8.92,19.12,16c4.66,7.09,7,15.96,7,26.62c0,7.5-1.54,13.92-4.62,19.25
c-3.09,5.34-6.84,10.09-11.25,14.25c-4.42,4.17-8.75,8.29-13,12.38c-4.25,4.09-7.67,8.62-10.25,13.62
c-2.59,5-3.54,11.09-2.88,18.25H230.62z M246.88,346.12c-6.34,0-11.59-2.04-15.75-6.12c-4.17-4.08-6.25-9.38-6.25-15.88
c0-6.66,2.12-12.04,6.38-16.12c4.25-4.08,9.46-6.12,15.62-6.12c6.33,0,11.58,2.04,15.75,6.12c4.16,4.09,6.25,9.46,6.25,16.12
c0,6.5-2.09,11.79-6.25,15.88C258.46,344.08,253.21,346.12,246.88,346.12z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -26,15 +26,15 @@
"@koa/router": "13.0.0",
"@ladjs/koa-views": "9.0.0",
"@peertube/http-signature": "1.7.0",
"@redocly/openapi-core": "1.19.0",
"@redocly/openapi-core": "1.21.0",
"@sinonjs/fake-timers": "11.2.2",
"adm-zip": "0.5.15",
"ajv": "8.17.1",
"archiver": "7.0.1",
"async-lock": "1.4.1",
"async-mutex": "0.5.0",
"aws-sdk": "2.1677.0",
"axios": "1.7.4",
"aws-sdk": "2.1681.0",
"axios": "1.7.5",
"backend-rs": "workspace:*",
"blurhash": "2.0.5",
"bull": "4.16.0",
@ -80,7 +80,7 @@
"nested-property": "4.0.0",
"node-fetch": "3.3.2",
"nodemailer": "6.9.14",
"otpauth": "9.3.1",
"otpauth": "9.3.2",
"parse5": "7.1.2",
"pg": "8.12.0",
"private-ip": "3.0.2",
@ -133,7 +133,7 @@
"@types/koa__cors": "5.0.0",
"@types/koa__multer": "2.0.7",
"@types/koa__router": "12.0.4",
"@types/node": "20.15.0",
"@types/node": "20.16.1",
"@types/node-fetch": "2.6.11",
"@types/nodemailer": "6.4.15",
"@types/oauth": "0.9.5",
@ -147,7 +147,7 @@
"@types/random-seed": "0.3.5",
"@types/ratelimiter": "3.4.6",
"@types/rename": "1.0.7",
"@types/sanitize-html": "2.11.0",
"@types/sanitize-html": "2.13.0",
"@types/semver": "7.5.8",
"@types/sinonjs__fake-timers": "8.1.5",
"@types/syslog-pro": "1.0.3",
@ -165,7 +165,7 @@
"tsconfig-paths": "4.2.0",
"type-fest": "4.25.0",
"typescript": "5.5.4",
"webpack": "5.93.0",
"webpack": "5.94.0",
"ws": "8.18.0"
}
}

View file

@ -37,7 +37,7 @@
"autobind-decorator": "2.4.0",
"autosize": "6.0.1",
"broadcast-channel": "7.0.0",
"chart.js": "4.4.3",
"chart.js": "4.4.4",
"chartjs-adapter-date-fns": "3.0.0",
"chartjs-chart-matrix": "2.0.1",
"chartjs-plugin-gradient": "0.6.1",
@ -45,7 +45,7 @@
"check-password-strength": "2.0.10",
"city-timezones": "1.3.0",
"compare-versions": "6.1.1",
"cropperjs": "2.0.0-rc.1",
"cropperjs": "2.0.0-rc.2",
"date-fns": "3.6.0",
"emojilib": "3.0.12",
"eventemitter3": "5.0.1",
@ -69,12 +69,12 @@
"punycode": "2.3.1",
"qrcode": "1.5.4",
"qrcode-vue3": "1.6.8",
"rollup": "4.20.0",
"rollup": "4.21.0",
"s-age": "1.1.2",
"sass": "1.77.8",
"seedrandom": "3.0.5",
"stringz": "2.1.0",
"swiper": "11.1.9",
"swiper": "11.1.10",
"textarea-caret": "3.1.0",
"throttle-debounce": "5.0.2",
"tinycolor2": "1.6.0",
@ -82,7 +82,7 @@
"typescript": "5.5.4",
"unicode-emoji-json": "0.6.0",
"uuid": "10.0.0",
"vite": "5.4.1",
"vite": "5.4.2",
"vite-plugin-compression": "0.5.1",
"vue": "3.4.38",
"vue-draggable-plus": "0.5.3",

View file

@ -10,7 +10,7 @@
},
]"
>
<img class="icon" :src="getInstanceIcon(instance)" alt="" />
<img class="icon" :src="getInstanceIcon(instance)" @error="getInstanceIconErrorEvent($event)" alt="" />
<div class="body">
<span class="host">{{ instance.name ?? instance.host }}</span>
<span class="sub _monospace"
@ -37,6 +37,10 @@ function getInstanceIcon(instance: entities.Instance): string {
"/client-assets/dummy.png"
);
}
function getInstanceIconErrorEvent($event) {
$event.target.src = "/client-assets/dummy.png";
}
</script>
<style lang="scss" module>

View file

@ -9,7 +9,7 @@
class="hpaizdrt"
:style="bg"
>
<img class="icon" :src="getInstanceIcon(instance)" aria-hidden="true" />
<img class="icon" :src="getInstanceIcon(instance)" @error="getInstanceIconErrorEvent($event)" aria-hidden="true" />
<span class="name">{{ instance.name }}</span>
</div>
</template>
@ -84,6 +84,10 @@ function getInstanceIcon(instance): string {
"/client-assets/dummy.png"
);
}
function getInstanceIconErrorEvent($event) {
$event.target.src = "/client-assets/dummy.png";
}
</script>
<style lang="scss" scoped>

View file

@ -17,7 +17,11 @@
}"
>
<div v-if="thumbnail" class="thumbnail">
<img :src="thumbnail" loading="lazy" />
<img
:src="thumbnail"
loading="lazy"
@error="imageErrorEvent($event)"
/>
<button
v-if="tweetId"
v-tooltip="
@ -55,7 +59,12 @@
<p :title="description">
<span>
<span :title="sitename || undefined">
<img v-if="icon" class="icon" :src="icon" />
<img
v-if="icon"
class="icon"
:src="icon"
@error="imageErrorEvent($event)"
/>
{{ sitename }}
</span>
{{ description }}
@ -181,6 +190,10 @@ function adjustTweetHeight(message: any) {
if (height) tweetHeight.value = height;
}
function imageErrorEvent($event) {
$event.target.src = "/static-assets/resource-unknown.svg";
}
window.addEventListener("message", adjustTweetHeight);
onUnmounted(() => {

View file

@ -19,6 +19,7 @@
<img
class="icon"
:src="getInstanceIcon(instance)"
@error="getInstanceIconErrorEvent($event)"
alt=""
/>
<MkA
@ -82,6 +83,10 @@ function getInstanceIcon(instance): string {
"/client-assets/dummy.png"
);
}
function getInstanceIconErrorEvent($event) {
$event.target.src = "/client-assets/dummy.png";
}
</script>
<style lang="scss" scoped>

View file

@ -23,7 +23,7 @@
:key="instance.id"
class="instance"
>
<img :src="getInstanceIcon(instance)" alt="" />
<img :src="getInstanceIcon(instance)" @error="getInstanceIconErrorEvent($event)" alt="" />
<div class="body">
<a
class="a"
@ -111,6 +111,10 @@ function getInstanceIcon(instance): string {
);
}
function getInstanceIconErrorEvent($event) {
$event.target.src = "/client-assets/dummy.png";
}
defineExpose<WidgetComponentExpose>({
name,
configure,

View file

@ -11,6 +11,7 @@
<img
style="inline-size: 32px"
:src="getInstanceIcon(instance)"
@error="getInstanceIconErrorEvent($event)"
/>
</a>
</li>
@ -88,6 +89,10 @@ function getInstanceIcon(instance): string {
);
}
function getInstanceIconErrorEvent($event) {
$event.target.src = "/client-assets/dummy.png";
}
defineExpose<WidgetComponentExpose>({
name,
configure,

View file

@ -21,12 +21,12 @@
},
"devDependencies": {
"@types/jest": "29.5.12",
"@types/node": "20.15.0",
"@types/node": "20.16.1",
"jest": "29.7.0",
"jest-fetch-mock": "3.0.3",
"jest-websocket-mock": "2.5.0",
"mock-socket": "9.3.1",
"ts-jest": "29.2.4",
"ts-jest": "29.2.5",
"ts-node": "10.9.2",
"tsc-alias": "1.8.10",
"tsd": "0.31.1",

View file

@ -11,3 +11,6 @@ convert_case = { workspace = true }
proc-macro2 = { workspace = true }
quote = { workspace = true }
syn = { workspace = true, features = ["clone-impls", "extra-traits", "full", "parsing", "printing"] }
[dev-dependencies]
proc-macro-tester = { workspace = true }

View file

@ -1,4 +1,3 @@
#![allow(clippy::items_after_test_module)]
pub mod napi;
mod util;

View file

@ -27,7 +27,7 @@ use quote::{quote, ToTokens};
/// ## Applying the macro to a struct
/// ```
/// # use macros_impl::napi::napi;
/// # macros_impl::macro_doctest!({
/// # proc_macro_tester::assert_expands!({
/// #[macros::napi(object)]
/// struct Person {
/// id: i32,
@ -48,7 +48,7 @@ use quote::{quote, ToTokens};
/// ## Function with explicitly specified `js_name`
/// ```
/// # use macros_impl::napi::napi;
/// # macros_impl::macro_doctest!({
/// # proc_macro_tester::assert_expands!({
/// #[macros::napi(js_name = "add1")]
/// pub fn add_one(x: i32) -> i32 {
/// x + 1
@ -71,7 +71,7 @@ use quote::{quote, ToTokens};
/// ## Function with `i32` argument
/// ```
/// # use macros_impl::napi::napi;
/// # macros_impl::macro_doctest!({
/// # proc_macro_tester::assert_expands!({
/// #[macros::napi]
/// pub fn add_one(x: i32) -> i32 {
/// x + 1
@ -93,7 +93,7 @@ use quote::{quote, ToTokens};
/// ## Function with `&str` argument
/// ```
/// # use macros_impl::napi::napi;
/// # macros_impl::macro_doctest!({
/// # proc_macro_tester::assert_expands!({
/// #[macros::napi]
/// pub fn concatenate_string(str1: &str, str2: &str) -> String {
/// str1.to_owned() + str2
@ -116,7 +116,7 @@ use quote::{quote, ToTokens};
/// ## Function with `&[String]` argument
/// ```
/// # use macros_impl::napi::napi;
/// # macros_impl::macro_doctest!({
/// # proc_macro_tester::assert_expands!({
/// #[macros::napi]
/// pub fn string_array_length(array: &[String]) -> u32 {
/// array.len() as u32
@ -149,7 +149,7 @@ use quote::{quote, ToTokens};
/// # };
///
/// # use macros_impl::napi::napi;
/// # macros_impl::macro_doctest!({
/// # proc_macro_tester::assert_expands!({
/// #[macros::napi]
/// pub fn integer_divide(dividend: i64, divisor: i64) -> Result<i64, IntegerDivisionError> {
/// match divisor {
@ -345,113 +345,157 @@ pub fn napi(macro_attr: TokenStream, item: TokenStream) -> syn::Result<TokenStre
})
}
crate::macro_unit_tests! {
mut_ref_argument: {
#[macros::napi]
pub fn append_string_and_clone(
base_str: &mut String,
appended_str: &str,
) -> String {
base_str.push_str(appended_str);
base_str.to_owned()
}
} generates {
#[napi_derive::napi(js_name = "appendStringAndClone", )]
pub fn append_string_and_clone_napi(
mut base_str: String,
appended_str: String,
) -> String {
append_string_and_clone(&mut base_str, &appended_str)
}
}
// prevent cargo fmt from modifying code blocks in assert_*!
#[rustfmt::skip]
#[cfg(test)]
mod unit_test {
use super::napi;
use proc_macro_tester::*;
result_return_type: {
#[macros::napi]
pub fn integer_divide(
dividend: i64,
divisor: i64,
) -> Result<i64, IntegerDivisionError> {
match divisor {
0 => Err(IntegerDivisionError::DividedByZero),
_ => match dividend % divisor {
0 => Ok(dividend / divisor),
remainder => Err(IntegerDivisionError::NotDivisible(remainder)),
},
#[test]
fn mut_ref_argument() {
assert_yields!(
{
#[macros::napi]
pub fn append_string_and_clone(
base_str: &mut String,
appended_str: &str,
) -> String {
base_str.push_str(appended_str);
base_str.to_owned()
}
},
{
#[napi_derive::napi(js_name = "appendStringAndClone", )]
pub fn append_string_and_clone_napi(
mut base_str: String,
appended_str: String
) -> String {
append_string_and_clone(&mut base_str, &appended_str)
}
}
}
} generates {
#[napi_derive::napi(js_name = "integerDivide", )]
pub fn integer_divide_napi(
dividend: i64,
divisor: i64,
) -> napi::Result<i64> {
integer_divide(dividend, divisor)
.map_err(|err| napi::Error::from_reason(
format!("\n{}\n", crate::util::error_chain::format_error(&err))
))
}
);
}
async_function: {
#[macros::napi]
pub async fn async_add_one(x: i32) -> i32 {
x + 1
}
} generates {
#[napi_derive::napi(js_name = "asyncAddOne", )]
pub async fn async_add_one_napi(x: i32) -> i32 {
async_add_one(x)
.await
}
#[test]
fn result_return_type() {
assert_yields!(
{
#[macros::napi]
pub fn integer_divide(
dividend: i64,
divisor: i64,
) -> Result<i64, IntegerDivisionError> {
match divisor {
0 => Err(IntegerDivisionError::DividedByZero),
_ => match dividend % divisor {
0 => Ok(dividend / divisor),
remainder => Err(IntegerDivisionError::NotDivisible(remainder)),
},
}
}
},
{
#[napi_derive::napi(js_name = "integerDivide", )]
pub fn integer_divide_napi(dividend: i64, divisor: i64) -> napi::Result<i64> {
integer_divide(dividend, divisor).map_err(|err|
napi::Error::from_reason(format!(
"\n{}\n",
crate::util::error_chain::format_error(&err)
))
)
}
}
);
}
slice_type: {
#[macros::napi]
pub fn string_array_length(array: &[String]) -> u32 {
array.len() as u32
}
} generates {
#[napi_derive::napi(js_name = "stringArrayLength", )]
pub fn string_array_length_napi(array: Vec<String>) -> u32 {
string_array_length(&array)
}
#[test]
fn async_function() {
assert_yields!({
#[macros::napi]
pub async fn async_add_one(x: i32) -> i32 {
x + 1
}
}, {
#[napi_derive::napi(js_name = "asyncAddOne", )]
pub async fn async_add_one_napi(x: i32) -> i32 {
async_add_one(x)
.await
}
});
}
object_with_explicitly_set_use_nullable: {
#[macros::napi(object, use_nullable = false)]
struct Person {
id: i32,
name: Option<String>,
}
} becomes {
#[napi_derive::napi(object, use_nullable = false)]
struct Person {
id: i32,
name: Option<String>,
}
#[test]
fn slice_type() {
assert_yields!(
{
#[macros::napi]
pub fn string_array_length(array: &[String]) -> u32 {
array.len() as u32
}
},
{
#[napi_derive::napi(js_name = "stringArrayLength", )]
pub fn string_array_length_napi(array: Vec<String>) -> u32 {
string_array_length(&array)
}
}
);
}
macro_attr: {
#[macros::napi(ts_return_type = "number")]
pub fn add_one(x: i32) -> i32 {
x + 1
}
} generates {
#[napi_derive::napi(js_name = "addOne", ts_return_type = "number")]
pub fn add_one_napi(x: i32) -> i32 {
add_one(x)
}
#[test]
fn object_with_explicitly_set_use_nullable() {
assert_expands!(
{
#[macros::napi(object, use_nullable = false)]
struct Person {
id: i32,
name: Option<String>,
}
},
{
#[napi_derive::napi(object, use_nullable = false)]
struct Person {
id: i32,
name: Option<String>,
}
}
);
}
explicitly_specified_js_name_and_other_macro_attr: {
#[macros::napi(ts_return_type = "number", js_name = "add1")]
pub fn add_one(x: i32) -> i32 {
x + 1
}
} generates {
#[napi_derive::napi(ts_return_type = "number", js_name = "add1")]
pub fn add_one_napi(x: i32) -> i32 {
add_one(x)
}
#[test]
fn macro_attr() {
assert_yields!(
{
#[macros::napi(ts_return_type = "number")]
pub fn add_one(x: i32) -> i32 {
x + 1
}
},
{
#[napi_derive::napi(js_name = "addOne", ts_return_type = "number")]
pub fn add_one_napi(x: i32) -> i32 {
add_one(x)
}
}
);
}
#[test]
fn explicitly_specified_js_name_and_other_macro_attr() {
assert_yields!(
{
#[macros::napi(ts_return_type = "number", js_name = "add1")]
pub fn add_one(x: i32) -> i32 {
x + 1
}
},
{
#[napi_derive::napi(ts_return_type = "number", js_name = "add1")]
pub fn add_one_napi(x: i32) -> i32 {
add_one(x)
}
}
);
}
}

View file

@ -1,5 +1,4 @@
mod helper;
use helper::*;
use quote::quote;
/// Reads the version field in the project root package.json at compile time.
///
@ -24,50 +23,98 @@ pub fn read_version_from_package_json(_item: proc_macro::TokenStream) -> proc_ma
quote!(#version).into()
}
define_wrapper_proc_macro_attributes! {
/// Exports an enum to TypeScript, and derive [Clone].
///
/// You need this macro because [`napi_derive::napi`](https://docs.rs/napi-derive/latest/napi_derive/attr.napi.html)
/// automatically derives the [Clone] trait for enums and causes conflicts.
///
/// This is a wrapper of [`napi_derive::napi`](https://docs.rs/napi-derive/latest/napi_derive/attr.napi.html)
/// that expands to
/// ```no_run
/// #[cfg_attr(not(feature = "napi"), derive(Clone))]
/// #[cfg_attr(feature = "napi", napi_derive::napi(attr))]
/// # enum E {} // to work around doc test compilation error
/// ```
/// where `attr` is given attribute(s). See [`macros_impl::napi::napi`] for more details.
derive_clone_and_export(attr, item) {
/// See [`macros_impl::napi::napi`] for more details.
#[proc_macro_attribute]
pub fn napi(
attr: proc_macro::TokenStream,
item: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
let attr: proc_macro2::TokenStream = attr.into();
let orig_item: proc_macro2::TokenStream = item.into();
let napi_item: proc_macro2::TokenStream =
macros_impl::napi::napi(attr.clone(), orig_item.clone()).unwrap();
quote! {
#[cfg(not(feature = "napi"))]
#orig_item
#[cfg(feature = "napi")]
#napi_item
}
.into()
}
/// Exports an enum to TypeScript, and derive [Clone].
///
/// You need this macro because [`napi_derive::napi`](https://docs.rs/napi-derive/latest/napi_derive/attr.napi.html)
/// automatically derives the [Clone] trait for enums and causes conflicts.
///
/// This is a wrapper of [`napi_derive::napi`](https://docs.rs/napi-derive/latest/napi_derive/attr.napi.html)
/// that expands to
/// ```no_run
/// #[cfg_attr(not(feature = "napi"), derive(Clone))]
/// #[cfg_attr(feature = "napi", napi_derive::napi(attr))]
/// # enum E {} // to work around doc test compilation error
/// ```
/// where `attr` is given attribute(s). See [`macros_impl::napi::napi`] for more details.
#[proc_macro_attribute]
pub fn derive_clone_and_export(
attr: proc_macro::TokenStream,
item: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
let attr: proc_macro2::TokenStream = attr.into();
let item: proc_macro2::TokenStream = item.into();
quote! {
#[cfg_attr(not(feature = "napi"), derive(Clone))]
#[cfg_attr(feature = "napi", napi_derive::napi(#attr))]
#item
}
.into()
}
/// Exports a function, struct, enum, const, etc. to TypeScript.
///
/// This is a wrapper of [macro@napi] that expands to
/// ```no_run
/// #[cfg_attr(feature = "napi", macros::napi(attr))]
/// # fn f() {} // to work around doc test compilation error
/// ```
/// where `attr` is given attribute(s). See [`macros_impl::napi::napi`] for more details.
export(attr, item) {
/// Exports a function, struct, enum, const, etc. to TypeScript.
///
/// This is a wrapper of [macro@napi] that expands to
/// ```no_run
/// #[cfg_attr(feature = "napi", macros::napi(attr))]
/// # fn f() {} // to work around doc test compilation error
/// ```
/// where `attr` is given attribute(s). See [`macros_impl::napi::napi`] for more details.
#[proc_macro_attribute]
pub fn export(
attr: proc_macro::TokenStream,
item: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
let attr: proc_macro2::TokenStream = attr.into();
let item: proc_macro2::TokenStream = item.into();
quote! {
#[cfg_attr(feature = "napi", macros::napi(#attr))]
#item
}
.into()
}
/// Exports a function, struct, enum, const, etc. to TypeScript
/// and make it unable to use in Rust.
///
/// This is a wrapper of [macro@napi] that expands to
/// ```no_run
/// #[cfg(feature = "napi")]
/// #[macros::napi(attr)]
/// # fn f() {} // to work around doc test compilation error
/// ```
/// where `attr` is given attribute(s). See [`macros_impl::napi::napi`] for more details.
ts_export(attr, item) {
/// Exports a function, struct, enum, const, etc. to TypeScript
/// and make it unable to use in Rust.
///
/// This is a wrapper of [macro@napi] that expands to
/// ```no_run
/// #[cfg(feature = "napi")]
/// #[macros::napi(attr)]
/// # fn f() {} // to work around doc test compilation error
/// ```
/// where `attr` is given attribute(s). See [`macros_impl::napi::napi`] for more details.
#[proc_macro_attribute]
pub fn ts_export(
attr: proc_macro::TokenStream,
item: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
let attr: proc_macro2::TokenStream = attr.into();
let item: proc_macro2::TokenStream = item.into();
quote! {
#[cfg(feature = "napi")]
#[macros::napi(#attr)]
#item
@ -75,39 +122,19 @@ define_wrapper_proc_macro_attributes! {
#[cfg(any(test, doctest))]
#item
}
.into()
}
for_ts(_attr, item) {
#[proc_macro_attribute]
pub fn for_ts(
_: proc_macro::TokenStream,
item: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
let item: proc_macro2::TokenStream = item.into();
quote! {
#[cfg(any(test, doctest, feature = "napi"))]
#item
}
/// When applied to enums, this macro implements [`std::error::Error`] trait
/// and generates a document based on error messages unless there is already a doc comment
///
/// # Example
///
/// ```ignore
/// # use std::io;
/// #[macros::errors]
/// pub enum Error {
/// #[error("config file name is not set")]
/// NoConfigFileName,
/// #[error("failed to read the config file")]
/// ReadConfigFile(#[from] io::Error),
/// #[error("invalid file content ({0})")]
/// #[doc = "Invalid file content"]
/// InvalidContent(String),
/// }
/// ```
errors(_attr, item) {
#[derive(::thiserror::Error, ::std::fmt::Debug)]
#[error_doc::error_doc]
#item
}
}
reexport_proc_macro_attributes! {
/// Creates an extra wrapper function for [napi_derive](https://docs.rs/napi-derive/latest/napi_derive/).
/// See [macros_impl::napi::napi] for details.
macros_impl::napi::napi as napi
.into()
}

View file

@ -12,7 +12,7 @@
"devDependencies": {
"firefish-js": "workspace:*",
"idb-keyval": "6.2.1",
"vite": "5.4.1",
"vite": "5.4.2",
"vite-plugin-compression": "0.5.1"
}
}

672
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff